dc7cafbc0ca10f455b66a7f59d3412b2a7d1b9d5
[lhc/web/wiklou.git] / tests / parser / parserTests.txt
1 # MediaWiki Parser test cases
2 # Some taken from https://meta.wikimedia.org/wiki/Parser_testing
3 # All (C) their respective authors and released under the GPL
4 #
5 # The syntax should be fairly self-explanatory.
6 #
7 # Currently supported test options:
8 # One of the following three:
9 #
10 # (default) generate HTML output
11 # pst apply pre-save transform
12 # msg apply message transform
13 #
14 # Plus any combination of these:
15 #
16 # cat add category links
17 # (ignored by Parsoid, since it emits <link>s)
18 # ill add inter-language links
19 # (ignored by Parsoid, since it emits <link>s)
20 # subpage enable subpages (disabled by default)
21 # title=[[XXX]] run test using article title XXX
22 # language=XXX set content language to XXX for this test
23 # variant=XXX set the variant of language for this test (eg zh-tw)
24 # disabled do not run test
25 # parsoid parsoid-specific options (not run by PHP parser unless
26 # the test includes an html/php section)
27 # php php-only test (not run by the parsoid parser unless
28 # the test includes an html/parsoid section)
29 # showtitle make the first line the title
30 # showindicators make the first lines the page status indicators
31 # comment run through Linker::formatComment() instead of main parser
32 # local format section links in edit comment text as local links
33 # notoc disable table of contents
34 # thumbsize=NNN set the default thumb size to NNNpx for this test
35 # wrap include the normal wrapper <div class="mw-parser-output"> (since 1.30)
36 #
37 # You can also set the following parser properties via test options:
38 # wgEnableUploads, wgAllowExternalImages, wgMaxTocLevel,
39 # wgLinkHolderBatchSize, wgRawHtml, wgInterwikiMagic,
40 # wgEnableMagicLinks, wgMediaInTargetLanguage
41 #
42 # For testing purposes, temporary articles can created:
43 # !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
44 # where '/' denotes a newline.
45
46 # This is the standard article assumed to exist.
47 !! article
48 Main Page
49 !! text
50 blah blah
51 !! endarticle
52
53 !!article
54 Foo
55 !!text
56 FOO
57 !!endarticle
58
59 !!article
60 Foo''s bar''s
61 !!text
62 Article titles can contain single quotes!
63 !!endarticle
64
65 !!article
66 Template:Foo
67 !!text
68 FOO
69 !!endarticle
70
71 !! article
72 Template:redirect to foo
73 !! text
74 #REDIRECT [[Template:Foo]]
75 !! endarticle
76
77 !! article
78 Template:Blank
79 !! text
80 !! endarticle
81
82 !! article
83 Template:pipe
84 !! text
85 |
86 !! endarticle
87
88 !! article
89 Template:=
90 !! text
91 <nowiki>=</nowiki>
92 !! endarticle
93
94 !!article
95 MediaWiki:bad image list
96 !!text
97 * [[File:Bad.jpg]] except [[Nasty page]]
98 !!endarticle
99
100 !! article
101 Template:inner list
102 !! text
103 * item 1
104 !! endarticle
105
106 !! article
107 Template:tbl-start
108 !! text
109 {|
110 !! endarticle
111
112 !! article
113 Template:tbl-end
114 !! text
115 |}
116 !! endarticle
117
118 !! article
119 Template:echo
120 !! text
121 {{{1}}}
122 !! endarticle
123
124 !! article
125 Template:echo3
126 !! text
127 {{{1}}}
128 {{{1}}}
129 {{{1}}}
130 !! endarticle
131
132 // For Serbian; localize Template namespace
133 !! article
134 Шаблон:Echo
135 !! text
136 {{{1}}}
137 !! endarticle
138
139 !! article
140 Template:echo_with_span
141 !! text
142 <span>{{{1}}}</span>
143 !! endarticle
144
145 !! article
146 Template:echo_with_div
147 !! text
148 <div>{{{1}}}</div>
149 !! endarticle
150
151 !! article
152 Template:echo with depth
153 !! text
154 {{echo|{{{1}}}}}
155 !! endarticle
156
157 !! article
158 Template:blank_param
159 !! text
160 {{{1}}}
161 {{{}}}
162 !! endarticle
163
164 !! article
165 Template:table_attribs
166 !! text
167 <noinclude>
168 |</noinclude>style="color:red;"|Foo
169 !! endarticle
170
171 !! article
172 Template:table_attribs_2
173 !! text
174 <noinclude>
175 |</noinclude>style="color:red;"|Foo
176 |Bar||Baz
177 !! endarticle
178
179 !! article
180 Template:table_attribs_3
181 !! text
182 <noinclude>
183 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo
184 !! endarticle
185
186 !! article
187 Template:table_attribs_4
188 !! text
189 | style="background-color:#DC241f;" width="10px" |
190 !! endarticle
191
192 !! article
193 Template:table_attribs_5
194 !! text
195 <noinclude>
196 |</noinclude>style="color:red;"||Bar
197 !! endarticle
198
199 !! article
200 Template:table_attribs_6
201 !! text
202 style="background: <nowiki>
203
204
205 red;</nowiki>" |
206 !! endarticle
207
208 !! article
209 Template:table_attribs_7
210 !! text
211 <noinclude>
212 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo<ref>foo</ref>
213 !! endarticle
214
215 !! article
216 Template:table_header_cells
217 !! text
218 {{table_attribs}}!!style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
219 !! endarticle
220
221 !! article
222 Template:table_cells
223 !! text
224 {{table_attribs}}||style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
225 !! endarticle
226
227 !! article
228 Template:PartialTable
229 !! text
230 {|
231 |-
232 !! endarticle
233
234 !! article
235 Template:image_attribs
236 !! text
237 <noinclude>
238 [[File:foobar.jpg|</noinclude>right|Caption text<noinclude>]]</noinclude>
239 !! endarticle
240
241 ## See T48811 for details
242 !! article
243 Template:mixed_attr_content_template
244 !! text
245 style="color:red;" title="T48811"
246 |-
247 |foo
248 !! endarticle
249
250 !! article
251 Template:definition_list
252 !! text
253 one
254 ::two
255 !! endarticle
256
257 !! article
258 A?b
259 !! text
260 Weirdo titles!
261 !! endarticle
262
263 !!article
264 Template:Bullet
265 !!text
266 *Bar
267 !!endarticle
268
269 !!article
270 Template:OpenTable
271 !!text
272 {|
273 !!endarticle
274
275 !!article
276 Template:EmptyLITest
277 !!text
278 *a
279 *
280 *
281 *b
282 !!endarticle
283
284 !!article
285 Template:EmptyTRTest
286 !!text
287 {|
288 |-
289 |-
290 |foo
291 |-
292 |-
293 |bar
294 |}
295 !!endarticle
296
297 !!article
298 Template:EmptyTRWithHTMLAttrTest
299 !!text
300 <table>
301 <tr align="center"></tr>
302 <tr><td>foo</td></tr>
303 <tr align="center"></tr>
304 <tr><td>bar</td></tr>
305 </table>
306 !!endarticle
307
308 !! article
309 Template:With: Colon
310 !! text
311 Template with colon
312 !! endarticle
313
314 ###
315 ### Basic tests
316 ###
317
318 !! test
319 Blank input
320 !! wikitext
321 !! html
322 !! end
323
324 !! test
325 Simple paragraph
326 !! wikitext
327 This is a simple paragraph.
328 !! html
329 <p>This is a simple paragraph.
330 </p>
331 !! end
332
333 !! test
334 Paragraphs with extra newline spacing
335 !! wikitext
336 a
337
338 b (+2 nls)
339
340
341 c (+3 nls)
342
343
344
345 d (+4 nls)
346
347
348
349
350 e (+5 nls)
351 !! html
352 <p>a
353 </p><p>b (+2 nls)
354 </p><p><br />
355 c (+3 nls)
356 </p><p><br />
357 </p><p>d (+4 nls)
358 </p><p><br />
359 </p><p><br />
360 e (+5 nls)
361 </p>
362 !! end
363
364 !! test
365 Paragraphs with newline spacing with comment lines in between
366 !! wikitext
367 ----
368 a
369 <!--foo-->
370 b
371 ----
372 a
373 <!--foo--><!--More than 1 comment, still stripped-->
374 b
375 ----
376 a
377 <!--foo--> <!----> <!-- bar -->
378 b
379 ----
380 a
381 <!--foo-->
382
383 b
384 ----
385 a
386
387 <!--foo-->
388 b
389 ----
390 a
391 <!--foo-->
392
393
394 b
395 ----
396 a
397
398
399 <!--foo-->
400 b
401 ----
402 !! html
403 <hr />
404 <p>a
405 b
406 </p>
407 <hr />
408 <p>a
409 b
410 </p>
411 <hr />
412 <p>a
413 b
414 </p>
415 <hr />
416 <p>a
417 </p><p>b
418 </p>
419 <hr />
420 <p>a
421 </p><p>b
422 </p>
423 <hr />
424 <p>a
425 </p><p><br />
426 b
427 </p>
428 <hr />
429 <p>a
430 </p><p><br />
431 b
432 </p>
433 <hr />
434
435 !! end
436
437 !! test
438 Paragraphs with newline spacing with non-empty white-space lines in between
439 !! wikitext
440 ----
441 a
442
443 b
444 ----
445 a
446
447
448 b
449 ----
450 !! html
451 <hr />
452 <p>a
453 </p><p>b
454 </p>
455 <hr />
456 <p>a
457 </p><p><br />
458 b
459 </p>
460 <hr />
461
462 !! end
463
464 !! test
465 Paragraphs with newline spacing with non-empty mixed comment and white-space lines in between
466 !! wikitext
467 ----
468 a
469 <!--foo-->
470 b
471 ----
472 a
473 <!--foo--><!--More than 1 comment doesn't disable stripping of this line!-->
474 b
475 ----
476 a
477
478 <!--foo-->
479 <!--bar-->
480 b
481 ----
482 a
483
484 <!--foo-->
485 <!--bar-->
486
487 b
488 ----
489 !! html
490 <hr />
491 <p>a
492 b
493 </p>
494 <hr />
495 <p>a
496 b
497 </p>
498 <hr />
499 <p>a
500 </p><p>b
501 </p>
502 <hr />
503 <p>a
504 </p><p><br />
505 b
506 </p>
507 <hr />
508
509 !! end
510
511 !! test
512 Extra newlines: More paragraphs with indented comment
513 !! wikitext
514 a
515
516 <!--boo-->
517
518 b
519 !! html
520 <p>a
521 </p><p><br />
522 b
523 </p>
524 !!end
525
526 !! test
527 Extra newlines followed by heading
528 !! wikitext
529 a
530
531
532 =b=
533 [[a]]
534
535
536 =b=
537 !! html
538 <p>a
539 </p><p><br />
540 </p>
541 <h1><span class="mw-headline" id="b">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
542 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
543 </p><p><br />
544 </p>
545 <h1><span class="mw-headline" id="b_2">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
546
547 !! end
548
549 !! test
550 Extra newlines between heading and content are swallowed (Parsoid does not)
551 !! wikitext
552 =b=
553
554
555
556 [[a]]
557 !! html/php+tidy
558 <h1><span class="mw-headline" id="b">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
559 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
560 </p>
561 !! html/parsoid
562 <h1 id="b">b</h1>
563 <p>
564 <br></p>
565
566 <p><a rel="mw:WikiLink" href="./A" title="A">a</a></p>
567 !! end
568
569 !! test
570 Extra new lines before and after lists are preserved
571 !! wikitext
572 a
573
574
575 *b
576
577
578 c
579 !! html/php+tidy
580 <p>a
581 </p><p><br />
582 </p>
583 <ul><li>b</li></ul>
584 <p><br />
585 c
586 </p>
587 !! html/parsoid
588 <p>a</p>
589 <p>
590 <br></p>
591 <ul><li>b</li></ul>
592 <p>
593 <br>
594 c</p>
595 !! end
596
597 # Parsoid regression test
598 !!test
599 Multiple newlines after tables are converted to p-br-p tags
600 !!options
601 parsoid=wt2html,wt2wt
602 !!wikitext
603 {|
604 |x
605 |}
606
607
608
609
610 =b=
611 !!html/php+tidy
612 <table>
613 <tbody><tr>
614 <td>x
615 </td></tr></tbody></table>
616 <p><br />
617 </p><p><br />
618 </p>
619 <h1><span class="mw-headline" id="b">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
620 !!html/parsoid
621 <table>
622 <tbody>
623 <tr>
624 <td>x</td>
625 </tr>
626 </tbody>
627 </table>
628 <p><br/></p>
629 <p><br/></p>
630 <h1 id="b">b</h1>
631 !!end
632
633 !! test
634 Heading with line break in nowiki
635 !! options
636 parsoid=wt2html
637 !! config
638 wgFragmentMode=[ 'html5', 'legacy' ]
639 !! wikitext
640 ==A <nowiki>B
641 C</nowiki>==
642 !! html/php
643 <h2><span id="A_B.0AC"></span><span class="mw-headline" id="A_B
644 C">A B
645 C</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: A B&#10;C">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
646
647 !! html/parsoid
648 <h2 id="A_B
649 C"><span id="A_B.0AC" typeof="mw:FallbackId"></span>A <span typeof="mw:Nowiki">B
650 C</span></h2>
651 !! end
652
653 !! test
654 Parsing an URL
655 !! wikitext
656 http://fr.wikipedia.org/wiki/🍺
657 <!-- EasterEgg we love beer, better be able be able to link to it -->
658 !! html
659 <p><a rel="nofollow" class="external free" href="http://fr.wikipedia.org/wiki/🍺">http://fr.wikipedia.org/wiki/🍺</a>
660 </p>
661 !! end
662
663 !! test
664 Simple list
665 !! wikitext
666 *Item 1
667 *Item 2
668 !! html
669 <ul><li>Item 1</li>
670 <li>Item 2</li></ul>
671
672 !! end
673
674 !! test
675 Italics and bold
676 !! wikitext
677 *plain
678 *plain''italic''plain
679 *plain''italic''plain''italic''plain
680 *plain'''bold'''plain
681 *plain'''bold'''plain'''bold'''plain
682 *plain''italic''plain'''bold'''plain
683 *plain'''bold'''plain''italic''plain
684 *plain''italic'''bold-italic'''italic''plain
685 *plain'''bold''bold-italic''bold'''plain
686 *plain'''''bold-italic'''italic''plain
687 *plain'''''bold-italic''bold'''plain
688 *plain''italic'''bold-italic'''''plain
689 *plain'''bold''bold-italic'''''plain
690 *plain l'''italic''plain
691 *plain l''''bold''' plain
692 !! html
693 <ul><li>plain</li>
694 <li>plain<i>italic</i>plain</li>
695 <li>plain<i>italic</i>plain<i>italic</i>plain</li>
696 <li>plain<b>bold</b>plain</li>
697 <li>plain<b>bold</b>plain<b>bold</b>plain</li>
698 <li>plain<i>italic</i>plain<b>bold</b>plain</li>
699 <li>plain<b>bold</b>plain<i>italic</i>plain</li>
700 <li>plain<i>italic<b>bold-italic</b>italic</i>plain</li>
701 <li>plain<b>bold<i>bold-italic</i>bold</b>plain</li>
702 <li>plain<i><b>bold-italic</b>italic</i>plain</li>
703 <li>plain<b><i>bold-italic</i>bold</b>plain</li>
704 <li>plain<i>italic<b>bold-italic</b></i>plain</li>
705 <li>plain<b>bold<i>bold-italic</i></b>plain</li>
706 <li>plain l'<i>italic</i>plain</li>
707 <li>plain l'<b>bold</b> plain</li></ul>
708
709 !! end
710
711 # this example taken from the [[simple:Moon]] article (T49326)
712 !! test
713 Italics and possessives (1)
714 !! wikitext
715 obtained by ''[[Lunar Prospector]]'''s gamma-ray spectrometer
716 !! html
717 <p>obtained by <i><a href="/index.php?title=Lunar_Prospector&amp;action=edit&amp;redlink=1" class="new" title="Lunar Prospector (page does not exist)">Lunar Prospector</a>'</i>s gamma-ray spectrometer
718 </p>
719 !! end
720
721 # this example taken from [[en:Flaming Pie]] (T51926)
722 !! test
723 Italics and possessives (2)
724 !! wikitext
725 '''''Flaming Pie''''' is ... released in 1997. In ''Flaming Pie'''s liner notes
726 !! html
727 <p><i><b>Flaming Pie</b></i> is ... released in 1997. In <i>Flaming Pie'</i>s liner notes
728 </p>
729 !! end
730
731 # this example taken from [[en:Dictionary]] (T51926)
732 !! test
733 Italics and possessives (3)
734 !! wikitext
735 The first monolingual dictionary written in a Romance language was ''Sebastián Covarrubias''' ''Tesoro de la lengua castellana o española'', published in 1611 in Madrid. In 1612 the first edition of the ''Vocabolario dell'[[Accademia della Crusca]]'', for Italian, was published. In 1690 in Rotterdam was published, posthumously, the ''Dictionnaire Universel''.
736 !! html
737 <p>The first monolingual dictionary written in a Romance language was <i>Sebastián Covarrubias'</i> <i>Tesoro de la lengua castellana o española</i>, published in 1611 in Madrid. In 1612 the first edition of the <i>Vocabolario dell'<a href="/index.php?title=Accademia_della_Crusca&amp;action=edit&amp;redlink=1" class="new" title="Accademia della Crusca (page does not exist)">Accademia della Crusca</a></i>, for Italian, was published. In 1690 in Rotterdam was published, posthumously, the <i>Dictionnaire Universel</i>.
738 </p>
739 !! end
740
741
742 ###
743 ### 2-quote opening sequence tests
744 ###
745 !! test
746 Italics and bold: 2-quote opening sequence: (2,2)
747 !! wikitext
748 ''foo''
749 !! html
750 <p><i>foo</i>
751 </p>
752 !!end
753
754 !! test
755 Italics and bold: 2-quote opening sequence: (2,3)
756 !! wikitext
757 ''foo'''
758 !! html/*
759 <p><i>foo'</i>
760 </p>
761 !!end
762
763 !! test
764 Italics and bold: 2-quote opening sequence: (2,4)
765 !! options
766 parsoid=wt2html
767 !! wikitext
768 ''foo''''
769 !! html/*
770 <p><i>foo''</i>
771 </p>
772 !!end
773
774 # same html as previous, but wikitext adjusted to match parsoid html2wt
775 !! test
776 Italics and bold: 2-quote opening sequence: (2,4) w/ nowiki
777 !! wikitext
778 ''foo<nowiki>''</nowiki>''
779 !! html
780 <p><i>foo''</i>
781 </p>
782 !! end
783
784 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
785 !! test
786 Italics and bold: 2-quote opening sequence: (2,5)
787 !! options
788 parsoid=wt2html
789 !! wikitext
790 ''foo'''''
791 !! html/php
792 <p><i>foo</i>
793 </p>
794 !! html/parsoid
795 <p><i>foo</i><b></b>
796 </p>
797 !!end
798
799 # same html as previous, but wikitext adjusted to match parsoid html2wt
800 !! test
801 Italics and bold: 2-quote opening sequence: (2,5+3) w/ nowiki
802 !! wikitext
803 ''foo'''''<nowiki/>'''
804 !! html/php
805 <p><i>foo</i>
806 </p>
807 !! html/parsoid
808 <p><i>foo</i><b></b>
809 </p>
810 !! end
811
812
813 ###
814 ### 3-quote opening sequence tests
815 ###
816
817 !! test
818 Italics and bold: 3-quote opening sequence: (3,2)
819 !! wikitext
820 '''foo''
821 !! html/*
822 <p>'<i>foo</i>
823 </p>
824 !!end
825
826 !! test
827 Italics and bold: 3-quote opening sequence: (3,3)
828 !! wikitext
829 '''foo'''
830 !! html
831 <p><b>foo</b>
832 </p>
833 !!end
834
835 !! test
836 Italics and bold: 3-quote opening sequence: (3,4)
837 !! wikitext
838 '''foo''''
839 !! html/*
840 <p><b>foo'</b>
841 </p>
842 !!end
843
844 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
845 !! test
846 Italics and bold: 3-quote opening sequence: (3,5)
847 !! options
848 parsoid=wt2html
849 !! wikitext
850 '''foo'''''
851 !! html/php
852 <p><b>foo</b>
853 </p>
854 !! html/parsoid
855 <p><b>foo</b><i></i>
856 </p>
857 !!end
858
859 # same html as previous, but wikitext adjusted to match parsoid html2wt
860 !! test
861 Italics and bold: 3-quote opening sequence: (3,5+2) w/ nowiki
862 !! wikitext
863 '''foo'''''<nowiki/>''
864 !! html/php
865 <p><b>foo</b>
866 </p>
867 !! html/parsoid
868 <p><b>foo</b><i></i>
869 </p>
870 !! end
871
872
873 ###
874 ### 4-quote opening sequence tests
875 ###
876
877 !! test
878 Italics and bold: 4-quote opening sequence: (4,2)
879 !! options
880 parsoid=wt2html
881 !! wikitext
882 ''''foo''
883 !! html/*
884 <p>''<i>foo</i>
885 </p>
886 !!end
887
888 # same html as previous, but wikitext adjusted to match parsoid html2wt
889 !! test
890 Italics and bold: 4-quote opening sequence: (4,2) w/ nowiki
891 !! wikitext
892 <nowiki>''</nowiki>''foo''
893 !! html
894 <p>''<i>foo</i>
895 </p>
896 !! end
897
898 !! test
899 Italics and bold: 4-quote opening sequence: (4,3)
900 !! wikitext
901 ''''foo'''
902 !! html/*
903 <p>'<b>foo</b>
904 </p>
905 !!end
906
907 !! test
908 Italics and bold: 4-quote opening sequence: (4,4)
909 !! options
910 parsoid=wt2html
911 !! wikitext
912 ''''foo''''
913 !! html/*
914 <p>'<b>foo'</b>
915 </p>
916 !!end
917
918 # same html as previous, but wikitext adjusted to match parsoid html2wt
919 !! test
920 Italics and bold: 4-quote opening sequence: (4,4) w/ nowiki
921 !! wikitext
922 '<nowiki/>'''foo''''
923 !! html
924 <p>'<b>foo'</b>
925 </p>
926 !! end
927
928 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
929 !! test
930 Italics and bold: 4-quote opening sequence: (4,5)
931 !! options
932 parsoid=wt2html
933 !! wikitext
934 ''''foo'''''
935 !! html/php
936 <p>'<b>foo</b>
937 </p>
938 !! html/parsoid
939 <p>'<b>foo</b><i></i>
940 </p>
941 !!end
942
943 # same html as previous, but wikitext adjusted to match parsoid html2wt
944 !! test
945 Italics and bold: 4-quote opening sequence: (4,5+2) w/ nowiki
946 !! wikitext
947 '<nowiki/>'''foo'''''<nowiki/>''
948 !! html/php
949 <p>'<b>foo</b>
950 </p>
951 !! html/parsoid
952 <p>'<b>foo</b><i></i>
953 </p>
954 !! end
955
956
957 ###
958 ### 5-quote opening sequence tests
959 ###
960
961 !! test
962 Italics and bold: 5-quote opening sequence: (5,2)
963 !! options
964 parsoid=wt2html
965 !! wikitext
966 '''''foo''
967 !! html/*
968 <p><b><i>foo</i></b>
969 </p>
970 !!end
971
972 # same html as previous, but wikitext adjusted to match parsoid html2wt
973 !! test
974 Italics and bold: 5-quote opening sequence: (5,2+3)
975 !! wikitext
976 '''''foo'''''
977 !! html/*
978 <p><i><b>foo</b></i>
979 </p>
980 !! end
981
982 !! test
983 Italics and bold: 5-quote opening sequence: (5,3)
984 !! options
985 parsoid=wt2html
986 !! wikitext
987 '''''foo'''
988 !! html/*
989 <p><i><b>foo</b></i>
990 </p>
991 !!end
992
993 # same html as previous, but wikitext adjusted to match parsoid html2wt
994 !! test
995 Italics and bold: 5-quote opening sequence: (5,3+2)
996 !! wikitext
997 '''''foo'''''
998 !! html
999 <p><i><b>foo</b></i>
1000 </p>
1001 !! end
1002
1003 !! test
1004 Italics and bold: 5-quote opening sequence: (5,4)
1005 !! options
1006 parsoid=wt2html
1007 !! wikitext
1008 '''''foo''''
1009 !! html/*
1010 <p><i><b>foo'</b></i>
1011 </p>
1012 !!end
1013
1014 !! test
1015 Italics and bold: 5-quote opening sequence: (5,5)
1016 !! wikitext
1017 '''''foo'''''
1018 !! html
1019 <p><i><b>foo</b></i>
1020 </p>
1021 !!end
1022
1023 !! test
1024 Italics and bold: 5-quote opening sequence: (5,6)
1025 !! wikitext
1026 '''''foo''''''
1027 !! html/*
1028 <p><i><b>foo'</b></i>
1029 </p>
1030 !! end
1031
1032 ###
1033 ### multiple quote sequences in a line
1034 ###
1035
1036 !! test
1037 Italics and bold: multiple quote sequences: (2,4,2)
1038 !! options
1039 parsoid=wt2html
1040 !! wikitext
1041 ''foo''''bar''
1042 !! html/*
1043 <p><i>foo'<b>bar</b></i>
1044 </p>
1045 !! end
1046
1047 # same html as previous, but wikitext adjusted to match parsoid html2wt
1048 !! test
1049 Italics and bold: multiple quote sequences: (2,4,2+3) w/ nowiki
1050 !! wikitext
1051 ''foo'<nowiki/>'''bar'''''
1052 !! html
1053 <p><i>foo'<b>bar</b></i>
1054 </p>
1055 !! end
1056
1057 !! test
1058 Italics and bold: multiple quote sequences: (2,4,3)
1059 !! options
1060 parsoid=wt2html
1061 !! wikitext
1062 ''foo''''bar'''
1063 !! html/*
1064 <p><i>foo'<b>bar</b></i>
1065 </p>
1066 !! end
1067
1068 # same html as previous, but wikitext adjusted to match parsoid html2wt
1069 !! test
1070 Italics and bold: multiple quote sequences: (2,4,3+2) w/ nowiki
1071 !! wikitext
1072 ''foo'<nowiki/>'''bar'''''
1073 !! html
1074 <p><i>foo'<b>bar</b></i>
1075 </p>
1076 !! end
1077
1078 !! test
1079 Italics and bold: multiple quote sequences: (2,4,4)
1080 !! options
1081 parsoid=wt2html
1082 !! wikitext
1083 ''foo''''bar''''
1084 !! html/*
1085 <p><i>foo'<b>bar'</b></i>
1086 </p>
1087 !! end
1088
1089 # same html as previous, but wikitext adjusted to match parsoid html2wt
1090 !! test
1091 Italics and bold: multiple quote sequences: (2,4,4+2) w/ nowiki
1092 !! wikitext
1093 ''foo'<nowiki/>'''bar'<nowiki/>'''''
1094 !! html
1095 <p><i>foo'<b>bar'</b></i>
1096 </p>
1097 !! end
1098
1099 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1100 !! test
1101 Italics and bold: multiple quote sequences: (3,4,2)
1102 !! options
1103 parsoid=wt2html
1104 !! wikitext
1105 '''foo''''bar''
1106 !! html/php
1107 <p><b>foo'</b>bar
1108 </p>
1109 !! html/parsoid
1110 <p><b>foo'</b>bar<i></i>
1111 </p>
1112 !! end
1113
1114 # same html as previous, but wikitext adjusted to match parsoid html2wt
1115 !! test
1116 Italics and bold: multiple quote sequences: (3,4,2+2) w/ nowiki
1117 !! wikitext
1118 '''foo''''bar''<nowiki/>''
1119 !! html/php
1120 <p><b>foo'</b>bar
1121 </p>
1122 !! html/parsoid
1123 <p><b>foo'</b>bar<i></i>
1124 </p>
1125 !! end
1126
1127 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1128 !! test
1129 Italics and bold: multiple quote sequences: (3,4,3)
1130 !! options
1131 parsoid=wt2html
1132 !! wikitext
1133 '''foo''''bar'''
1134 !! html/php
1135 <p><b>foo'</b>bar
1136 </p>
1137 !! html/parsoid
1138 <p><b>foo'</b>bar<b></b>
1139 </p>
1140 !! end
1141
1142 # same html as previous, but wikitext adjusted to match parsoid html2wt
1143 !! test
1144 Italics and bold: multiple quote sequences: (3,4,3+3) w/ nowiki
1145 !! wikitext
1146 '''foo''''bar'''<nowiki/>'''
1147 !! html/php
1148 <p><b>foo'</b>bar
1149 </p>
1150 !! html/parsoid
1151 <p><b>foo'</b>bar<b></b>
1152 </p>
1153 !! end
1154
1155 ###
1156 ### other quote tests
1157 ###
1158 !! test
1159 Italics and bold: other quote tests: (2,3,5)
1160 !! wikitext
1161 ''this is about '''foo's family'''''
1162 !! html
1163 <p><i>this is about <b>foo's family</b></i>
1164 </p>
1165 !!end
1166
1167
1168 !! test
1169 Italics and bold: other quote tests: (2,(3,3),2)
1170 !! wikitext
1171 ''this is about '''foo's''' family''
1172 !! html
1173 <p><i>this is about <b>foo's</b> family</i>
1174 </p>
1175 !!end
1176
1177
1178 !! test
1179 Italics and bold: other quote tests: (3,2,3,2)
1180 !! options
1181 parsoid=wt2html
1182 !! wikitext
1183 '''this is about ''foo'''s family''
1184 !! html/*
1185 <p><b>this is about <i>foo</i></b><i>s family</i>
1186 </p>
1187 !!end
1188
1189
1190 # same html as previous, but wikitext adjusted to match parsoid html2wt
1191 !! test
1192 Italics and bold: other quote tests: (3,2,3+2+2,2)
1193 !! wikitext
1194 '''this is about ''foo'''''<nowiki/>''s family''
1195 !! html
1196 <p><b>this is about <i>foo</i></b><i>s family</i>
1197 </p>
1198 !! end
1199
1200
1201 !! test
1202 Italics and bold: other quote tests: (3,2,3,3)
1203 !! wikitext
1204 '''this is about ''foo'''s family'''
1205 !! html/*
1206 <p>'<i>this is about </i>foo<b>s family</b>
1207 </p>
1208 !!end
1209
1210
1211 !! test
1212 Italics and bold: other quote tests: (3,(2,2),3)
1213 !! wikitext
1214 '''this is about ''foo's'' family'''
1215 !! html
1216 <p><b>this is about <i>foo's</i> family</b>
1217 </p>
1218 !!end
1219
1220
1221 !! test
1222 Italicized possessive
1223 !! wikitext
1224 The ''[[Main Page]]'''s talk page.
1225 !! html/php
1226 <p>The <i><a href="/wiki/Main_Page" title="Main Page">Main Page</a>'</i>s talk page.
1227 </p>
1228 !! html/parsoid
1229 <p>The <i><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>'</i>s talk page.</p>
1230 !! end
1231
1232 !! test
1233 Quote balancing context should be restricted to td/th cells on the same wikitext line
1234 !! options
1235 parsoid=wt2html,wt2wt
1236 !! wikitext
1237 {|
1238 !''a!!''b
1239 |''a||''b
1240 |}
1241 !! html+tidy
1242 <table>
1243 <tbody><tr>
1244 <th><i>a</i></th>
1245 <th><i>b</i>
1246 </th>
1247 <td><i>a</i></td>
1248 <td><i>b</i>
1249 </td></tr></tbody></table>
1250 !! end
1251
1252 ###
1253 ### Non-html5 tags
1254 ###
1255
1256 !! test
1257 Non-html5 tags should be accepted
1258 !! wikitext
1259 <center>''foo''</center>
1260 <big>''foo''</big>
1261 <font>''foo''</font>
1262 <strike>''foo''</strike>
1263 <tt>''foo''</tt>
1264 !! html
1265 <center><i>foo</i></center>
1266 <p><big><i>foo</i></big>
1267 <font><i>foo</i></font>
1268 <strike><i>foo</i></strike>
1269 <tt><i>foo</i></tt>
1270 </p>
1271 !! end
1272
1273 !! test
1274 <wbr> is valid wikitext (T54468)
1275 !! wikitext
1276 <wbr>
1277 !! html
1278 <p><wbr />
1279 </p>
1280 !! end
1281
1282 # <strike> is HTML4, <s> is HTML4/5.
1283 !! test
1284 <s> or <strike> for strikethrough
1285 !! wikitext
1286 <strike>strike</strike>
1287
1288 <s>s</s>
1289 !! html
1290 <p><strike>strike</strike>
1291 </p><p><s>s</s>
1292 </p>
1293 !! end
1294
1295 ## a not permitted
1296 ## i,b,br omitted
1297 !! test
1298 Text-level semantic html elements in wikitext
1299 !! wikitext
1300 <em>text</em>
1301 <strong>text</strong>
1302 <small>text</small>
1303 <s>text</s>
1304 <cite>text</cite>
1305 <q>text</q>
1306 <dfn>text</dfn>
1307 <abbr>text</abbr>
1308 <data>text</data>
1309 <time>text</time>
1310 <code>text</code>
1311 <var>text</var>
1312 <samp>text</samp>
1313 <kbd>text</kbd>
1314 <sub>text</sub>
1315 <u>text</u>
1316 <mark>text</mark>
1317 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1318 <bdi>text</bdi>
1319 <bdo>text</bdo>
1320 <span>text</span>
1321 <wbr />
1322 !! html
1323 <p><em>text</em>
1324 <strong>text</strong>
1325 <small>text</small>
1326 <s>text</s>
1327 <cite>text</cite>
1328 <q>text</q>
1329 <dfn>text</dfn>
1330 <abbr>text</abbr>
1331 <data>text</data>
1332 <time>text</time>
1333 <code>text</code>
1334 <var>text</var>
1335 <samp>text</samp>
1336 <kbd>text</kbd>
1337 <sub>text</sub>
1338 <u>text</u>
1339 <mark>text</mark>
1340 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1341 <bdi>text</bdi>
1342 <bdo>text</bdo>
1343 <span>text</span>
1344 <wbr />
1345 </p>
1346 !! end
1347
1348 # test cases taken from
1349 # https://www.w3.org/TR/html5/text-level-semantics.html#the-ruby-element
1350 !! test
1351 Ruby markup (W3C-style)
1352 !! wikitext
1353 ;Mono-ruby for individual base characters
1354 :<ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby>
1355 ;Group ruby
1356 :<ruby>今日<rt>きょう</rt></ruby>
1357 ;Jukugo ruby
1358 :<ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby>
1359 ;Inline ruby
1360 :<ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby>
1361 ;Double-sided ruby
1362 :<ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby>
1363
1364 <ruby>
1365 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1366 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1367 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1368 </ruby>
1369 !! html
1370 <dl><dt>Mono-ruby for individual base characters</dt>
1371 <dd><ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby></dd>
1372 <dt>Group ruby</dt>
1373 <dd><ruby>今日<rt>きょう</rt></ruby></dd>
1374 <dt>Jukugo ruby</dt>
1375 <dd><ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby></dd>
1376 <dt>Inline ruby</dt>
1377 <dd><ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby></dd>
1378 <dt>Double-sided ruby</dt>
1379 <dd><ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby></dd></dl>
1380 <p><ruby>
1381 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1382 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1383 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1384 </ruby>
1385 </p>
1386 !! end
1387
1388 # The next two test different paths in the sanitizer.
1389 !! test
1390 Non-word characters don't terminate tag names (T19663, T42670, T54022)
1391 !! wikitext
1392 <blockquote|>a</blockquote>
1393
1394 <b→> doesn't terminate </b→>
1395
1396 <bä> doesn't terminate </bä>
1397
1398 <boo> doesn't terminate </boo>
1399
1400 <s.foo> doesn't terminate </s.foo>
1401
1402 <sub-ID#1>
1403 !! html/php
1404 <p>&lt;blockquote|&gt;a&lt;/blockquote&gt;
1405 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1406 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1407 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1408 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1409 </p><p>&lt;sub-ID#1&gt;
1410 </p>
1411 !! end
1412
1413 !! test
1414 Non-word characters don't terminate tag names
1415 !! wikitext
1416 <blockquote|>a</blockquote>
1417
1418 <b→> doesn't terminate </b→>
1419
1420 <bä> doesn't terminate </bä>
1421
1422 <boo> doesn't terminate </boo>
1423
1424 <s.foo> doesn't terminate </s.foo>
1425
1426 <sub-ID#1>
1427 !! html+tidy
1428 <p>&lt;blockquote|&gt;a
1429 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1430 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1431 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1432 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1433 </p><p>&lt;sub-ID#1&gt;
1434 </p>
1435 !! end
1436
1437 ###
1438 ### See tests/parser/parserTestsParserHook.php for the <tåg> extension)
1439 ### This checks that HTML5 tags (with non-word characters in the tag
1440 ### name) make it safely through the parser -- the Sanitizer will
1441 ### munge them later, as it should.
1442 ###
1443 !! test
1444 Non-word characters are valid in extension tags (T19663)
1445 !! wikitext
1446 <tåg>tåg</tåg>
1447 !! html/php
1448 <pre>
1449 'tåg'
1450 array (
1451 )
1452 </pre>
1453
1454 !! html/parsoid
1455 <pre typeof="mw:Extension/tåg" data-mw='{"name":"tåg","attrs":{},"body":{"extsrc":"tåg"}}' data-parsoid='{}' about="#mwt2"></pre>
1456 !! end
1457
1458 !! test
1459 Isolated close tags should be treated as literal text (T54760)
1460 !! options
1461 parsoid=wt2html
1462 !! wikitext
1463 </b>
1464
1465 <s.foo>s</s>
1466 !! html+tidy
1467 <p class="mw-empty-elt">
1468 </p><p>&lt;s.foo&gt;s
1469 </p>
1470 !! end
1471
1472 ###
1473 ### Special characters
1474 ###
1475
1476 !! test
1477 Bare pipe character (T54363)
1478 !! wikitext
1479 |
1480 !! html
1481 <p>|
1482 </p>
1483 !! end
1484
1485 !! test
1486 Bare pipe character from a template (T54363)
1487 !! wikitext
1488 {{pipe}}
1489 !! html
1490 <p>|
1491 </p>
1492 !! end
1493
1494 ###
1495 ### <nowiki> test cases
1496 ###
1497
1498 !! test
1499 <nowiki> unordered list
1500 !! wikitext
1501 <nowiki>* This is not an unordered list item.</nowiki>
1502 !! html/php
1503 <p>* This is not an unordered list item.
1504 </p>
1505 !! html/parsoid
1506 <p><span typeof="mw:Nowiki">* This is not an unordered list item.</span></p>
1507 !! end
1508
1509 !! test
1510 <nowiki> spacing
1511 !! wikitext
1512 <nowiki>Lorem ipsum dolor
1513
1514 sed abit.
1515 sed nullum.
1516
1517 :and a colon
1518 </nowiki>
1519 !! html/php
1520 <p>Lorem ipsum dolor
1521
1522 sed abit.
1523 sed nullum.
1524
1525 :and a colon
1526
1527 </p>
1528 !! html/parsoid
1529 <p><span typeof="mw:Nowiki">Lorem ipsum dolor
1530
1531 sed abit.
1532 sed nullum.
1533
1534 :and a colon
1535 </span></p>
1536 !! end
1537
1538 !! test
1539 Don't parse <nowiki><span class="error"></nowiki> (T149622)
1540 !! wikitext
1541 <nowiki><span class="error"></nowiki>
1542 !! html/php
1543 <p>&lt;span class="error"&gt;
1544 </p>
1545 !! html/parsoid
1546 <p><span typeof="mw:Nowiki">&lt;span class="error"></span></p>
1547 !! end
1548
1549 !! test
1550 nowiki 3
1551 !! wikitext
1552 :There is not nowiki.
1553 :There is <nowiki>nowiki</nowiki>.
1554
1555 #There is not nowiki.
1556 #There is <nowiki>nowiki</nowiki>.
1557
1558 *There is not nowiki.
1559 *There is <nowiki>nowiki</nowiki>.
1560 !! html/php
1561 <dl><dd>There is not nowiki.</dd>
1562 <dd>There is nowiki.</dd></dl>
1563 <ol><li>There is not nowiki.</li>
1564 <li>There is nowiki.</li></ol>
1565 <ul><li>There is not nowiki.</li>
1566 <li>There is nowiki.</li></ul>
1567
1568 !! html/parsoid
1569 <dl><dd data-parsoid='{}'>There is not nowiki.</dd>
1570 <dd data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</dd></dl>
1571
1572 <ol><li data-parsoid='{}'>There is not nowiki.</li>
1573 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ol>
1574
1575 <ul><li data-parsoid='{}'>There is not nowiki.</li>
1576 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ul>
1577 !! end
1578
1579 !! test
1580 Entities inside <nowiki>
1581 !! wikitext
1582 <nowiki>&lt;</nowiki>
1583 !! html/php
1584 <p>&lt;
1585 </p>
1586 !! html/parsoid
1587 <p><span typeof="mw:Nowiki"><span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span></span></p>
1588 !! end
1589
1590 !! test
1591 Entities inside template parameters
1592 !! wikitext
1593 {{echo|&ndash;}}
1594 !! html/php+tidy
1595 <p>&#8211;
1596 </p>
1597 !! html/parsoid
1598 <p><span typeof="mw:Transclusion mw:Entity" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&amp;ndash;"}},"i":0}}]}'>&ndash;</span></p>
1599 !! end
1600
1601 !! test
1602 Properly escape nowiki when combined with other wiki markup
1603 !! options
1604 parsoid=html2wt
1605 !! html/parsoid
1606 <p>* &lt;/nowiki&gt; tag</p>
1607 !! wikitext
1608 <nowiki>*</nowiki> <nowiki>&lt;/nowiki&gt;</nowiki> tag
1609 !! end
1610
1611 !! test
1612 T93824: Put escaped HTML tags inside nowiki
1613 !! options
1614 parsoid=html2wt
1615 !! html/parsoid
1616 <p>&lt;h2&gt;foo&lt;/h2&gt;</p>
1617 !! wikitext
1618 <nowiki><h2>foo</h2></nowiki>
1619 !! end
1620
1621 !! test
1622 T71950: 1. Put nowiki as close to cause as possible, even with non-quote escapable chars
1623 !! options
1624 parsoid=html2wt
1625 !! html/parsoid
1626 <p>This text: L'<a rel="mw:WikiLink" href="./Foo">Foo</a>
1627 This text: L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1628 This text: L'''<a rel="mw:WikiLink" href="./Foo">Foo</a>''</p>
1629 !! wikitext
1630 This text: L'[[Foo]]
1631 This text: L<nowiki>''</nowiki>[[Foo]]
1632 This text: L<nowiki>'''</nowiki>[[Foo]]<nowiki>''</nowiki>
1633 !! end
1634
1635 # This test fails because wikitext whitespace is not normalized before comparing.
1636 !! test
1637 T71950: 2. Put nowiki as close to cause as possible, after ' :'
1638 !! options
1639 parsoid=html2wt
1640 !! html/parsoid
1641 <p>This text : L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1642 </p>
1643 !! wikitext
1644 This text : L<nowiki>''</nowiki>[[Foo]]
1645 !! end
1646
1647 # This test and the next one are html2wt only as they test that incorrect wikitext
1648 # passed in template arguments gets escaped or wrapped in nowikis where required.
1649 !! test
1650 T71482: Use {{!}} instead of nowiki for single pipe in template argument
1651 !! options
1652 parsoid=html2wt
1653 !! html/parsoid
1654 <p><span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo|bar&quot;}},&quot;i&quot;:0}}]}" about="#mwt1"></span>
1655 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo|bar |[[&quot;}},&quot;i&quot;:0}}]}" about="#mwt2"></p>
1656 !! wikitext
1657 {{echo|foo{{!}}bar}}
1658 {{echo|<nowiki>foo|bar |[[</nowiki>}}
1659 !! end
1660
1661 !! test
1662 T53961: Output correct nowikis in template arguments
1663 !! options
1664 parsoid=html2wt
1665 !! html/parsoid
1666 <p><span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a [ b&quot;}},&quot;i&quot;:0}}]}" about="#mwt1"></span>
1667 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a }} b&quot;}},&quot;i&quot;:0}}]}" about="#mwt2"></span>
1668 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a [[ b&quot;}},&quot;i&quot;:0}}]}" about="#mwt3"></span>
1669 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a | {{ ]]&quot;}},&quot;i&quot;:0}}]}" about="#mwt4"></span>
1670 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a }&quot;}},&quot;i&quot;:0}}]}" about="#mwt5"></span></p>
1671 !! wikitext
1672 {{echo|a [ b}}
1673 {{echo|<nowiki>a }} b</nowiki>}}
1674 {{echo|<nowiki>a [[ b</nowiki>}}
1675 {{echo|<nowiki>a | {{ ]]</nowiki>}}
1676 {{echo|a <nowiki>}</nowiki>}}
1677 !! end
1678
1679 !! test
1680 Cases where "!!" needs nowiki protection
1681 !! options
1682 parsoid=html2wt
1683 !! html/parsoid
1684 <table>
1685 <tr><th>this needs protection !! here</th></tr>
1686 </table>
1687
1688 <table>
1689 <tr><th>this does not need
1690 protection !! here</th></tr>
1691 </table>
1692 !! wikitext
1693 {|
1694 !<nowiki>this needs protection !! here</nowiki>
1695 |}
1696
1697 {|
1698 !this does not need
1699 protection !! here
1700 |}
1701 !! end
1702
1703 ###
1704 ### Comments
1705 ###
1706 !! test
1707 Comments and Indent-Pre
1708 !! wikitext
1709 <!-- comment 1 --> asdf
1710
1711 <!-- comment 1 --> asdf
1712 <!-- comment 2 -->
1713
1714 <!-- comment 1 --> asdf
1715 <!-- comment 2 -->xyz
1716
1717 <!-- comment 1 --> asdf
1718 <!-- comment 2 --> xyz
1719 !! html
1720 <pre>asdf
1721 </pre>
1722 <pre>asdf
1723 </pre>
1724 <pre>asdf
1725 </pre>
1726 <p>xyz
1727 </p>
1728 <pre>asdf
1729 xyz
1730 </pre>
1731 !! end
1732
1733 !! test
1734 Comment test 2a
1735 !! wikitext
1736 asdf
1737 <!-- comment 1 -->
1738 jkl
1739 !! html
1740 <p>asdf
1741 jkl
1742 </p>
1743 !! end
1744
1745 !! test
1746 Comment test 2b
1747 !! wikitext
1748 asdf
1749 <!-- comment 1 -->
1750
1751 jkl
1752 !! html
1753 <p>asdf
1754 </p><p>jkl
1755 </p>
1756 !! end
1757
1758 !! test
1759 Comment test 3
1760 !! wikitext
1761 asdf
1762 <!-- comment 1 -->
1763 <!-- comment 2 -->
1764 jkl
1765 !! html
1766 <p>asdf
1767 jkl
1768 </p>
1769 !! end
1770
1771 !! test
1772 Comment test 4
1773 !! wikitext
1774 asdf<!-- comment 1 -->jkl
1775 !! html
1776 <p>asdfjkl
1777 </p>
1778 !! end
1779
1780 !! test
1781 Comment spacing
1782 !! wikitext
1783 a
1784 <!-- foo --> b <!-- bar -->
1785 c
1786 !! html
1787 <p>a
1788 </p>
1789 <pre> b
1790 </pre>
1791 <p>c
1792 </p>
1793 !! end
1794
1795 !! test
1796 Comment whitespace
1797 !! wikitext
1798 <!-- returns a single newline, not nothing, since the newline after > is not stripped -->
1799 !! html
1800
1801 !! end
1802
1803 !! test
1804 Comment semantics and delimiters
1805 !! wikitext
1806 <!-- --><!----><!-----><!------>
1807 !! html/php
1808
1809 !! html/parsoid
1810 <!-- --><!----><!--&#x2D;--><!--&#x2D;&#x2D;-->
1811 !! end
1812
1813 !! test
1814 Comment semantics and delimiters, redux
1815 !! wikitext
1816 <!-- In SGML every "foo" here would actually show up in the text -- foo -- bar
1817 -- foo -- funky huh? ... -->
1818 !! html/php
1819
1820 !! html/parsoid
1821 <!-- In SGML every "foo" here would actually show up in the text &#x2D;&#x2D; foo &#x2D;&#x2D; bar
1822 &#x2D;&#x2D; foo &#x2D;&#x2D; funky huh? ... -->
1823 !! end
1824
1825 !! test
1826 Comment semantics and delimiters: directors cut
1827 !! wikitext
1828 <!-- ... However we like to keep things simple and somewhat XML-ish so we eat
1829 everything starting with < followed by !-- until the first -- and > we see,
1830 that wouldn't be valid XML however, since in XML -- has to terminate a comment
1831 -->-->
1832 !! html/php
1833 <p>--&gt;
1834 </p>
1835 !! html/parsoid
1836 <!-- ... However we like to keep things simple and somewhat XML&#x2D;ish so we eat
1837 everything starting with < followed by !&#x2D;&#x2D; until the first &#x2D;&#x2D; and &#x3E; we see,
1838 that wouldn't be valid XML however, since in XML &#x2D;&#x2D; has to terminate a comment
1839 --><p>--></p>
1840 !! end
1841
1842 !! test
1843 Comment semantics: nesting
1844 !! wikitext
1845 <!--<!-- no, we're not going to do anything fancy here -->-->
1846 !! html/php
1847 <p>--&gt;
1848 </p>
1849 !! html/parsoid
1850 <!--<!&#x2D;&#x2D; no, we're not going to do anything fancy here --><p>--></p>
1851 !! end
1852
1853 # Parsoid closes the unclosed comment, even if it means a slight
1854 # round-trip diff.
1855 !! test
1856 Comment semantics: unclosed comment at end
1857 !! options
1858 parsoid=wt2html,html2html
1859 !! wikitext
1860 <!--This comment will run out to the end of the document
1861 !! html/php
1862
1863 !! html/parsoid
1864 <!--This comment will run out to the end of the document-->
1865 !! end
1866
1867 !! test
1868 Comment semantics: normalize comments to play nice with XML and browsers
1869 !! wikitext
1870 <!-- Browsers --!> think this is closed -->
1871 <!--> This would normally be text -->
1872 <!---> As would this -->
1873 <!-- XML doesn't like trailing dashes -------->
1874 <!-- Nor doubled hyphens -- anywhere in the data -->
1875 But this is not a comment.
1876 !! html/php
1877 <p>But this is not a comment.
1878 </p>
1879 !! html/parsoid
1880 <!-- Browsers &#x2D;&#x2D;!&#x3E; think this is closed -->
1881 <!--&#x3E; This would normally be text -->
1882 <!--&#x2D;&#x3E; As would this -->
1883 <!-- XML doesn't like trailing dashes &#x2D;&#x2D;&#x2D;&#x2D;&#x2D;&#x2D;-->
1884 <!-- Nor doubled hyphens &#x2D;&#x2D; anywhere in the data -->
1885 <p>But this is not a comment.</p>
1886 !! end
1887
1888 !! test
1889 Comment semantics: round-trip even text which contains encoded -->
1890 !! wikitext
1891 <!-- hello & goodbye - > --&gt; --&amp;gt; --&xx -->
1892 !! html/parsoid
1893 <!-- hello &#x26; goodbye &#x2D; &#x3E; &#x2D;&#x2D;&#x3E; &#x2D;&#x2D;&#x26;gt; &#x2D;&#x2D;&#x26;xx -->
1894 !! end
1895
1896 !! test
1897 Comment in template title
1898 !! wikitext
1899 {{f<!---->oo}}
1900 !! html
1901 <p>FOO
1902 </p>
1903 !! end
1904
1905 !! test
1906 Comment on its own line post-expand
1907 !! wikitext
1908 a
1909 {{blank}}<!---->
1910 b
1911 !! html
1912 <p>a
1913 </p><p>b
1914 </p>
1915 !! end
1916
1917 !! test
1918 Comment on its own line post-expand with non-significant whitespace
1919 !! wikitext
1920 a
1921 {{blank}} <!---->
1922 b
1923 !! html
1924 <p>a
1925 </p><p>b
1926 </p>
1927 !! end
1928
1929 !! test
1930 post-expand include size being exceeded
1931 !! options
1932 maxincludesize=20
1933 !! wikitext
1934 {{echo3|1234567890}}
1935 !! html
1936 <p><a href="/wiki/Template:Echo3" title="Template:Echo3">Template:Echo3</a><!-- WARNING: template omitted, post-expand include size too large -->
1937 </p>
1938 !! end
1939
1940 !! test
1941 max template depth being reached
1942 !! options
1943 maxtemplatedepth=1
1944 !! wikitext
1945 {{echo with depth|too deep!}}
1946 !! html
1947 <p><span class="error">Template recursion depth limit exceeded (1)</span>
1948 </p>
1949 !! end
1950
1951 !! test
1952 multiple templates that are redirects
1953 !! wikitext
1954 {{redirect to foo}}
1955 {{redirect to foo}}
1956 !! html
1957 <p>FOO
1958 FOO
1959 </p>
1960 !! end
1961
1962 !! test
1963 Multiple comments should still parse as SOL-transparent
1964 !! options
1965 parsoid=wt2html,wt2wt
1966 !! wikitext
1967 <!--c1-->*a
1968 <!--c2--><!--c3--><!--c4-->*b
1969 !! html/php
1970 <ul><li>a</li>
1971 <li>b</li></ul>
1972
1973 !! html/parsoid
1974 <!--c1--><ul>
1975 <li>a
1976 </li>
1977 <!--c2--><!--c3--><!--c4-->
1978 <li>b
1979 </li>
1980 </ul>
1981 !! end
1982
1983 ## Make sure ">" gets escaped in comments to avoid XSS
1984 !! test
1985 IE conditional comments
1986 !! wikitext
1987 <!--[if lt IE 9]>
1988 <script>alert('hi');</script>
1989 <![endif]-->
1990 !! html/parsoid
1991 <!--[if lt IE 9]&#x3E;
1992 <script&#x3E;alert('hi');</script&#x3E;
1993 <![endif]-->
1994 !! end
1995
1996 ###
1997 ### paragraph wrapping tests
1998 ###
1999
2000 !! test
2001 No block tags
2002 !! wikitext
2003 a
2004
2005 b
2006 !! html
2007 <p>a
2008 </p><p>b
2009 </p>
2010 !! end
2011
2012 !! test
2013 Block tag on one line (<div>)
2014 !! wikitext
2015 a <div>foo</div>
2016
2017 b
2018 !! html
2019 a <div>foo</div>
2020 <p>b
2021 </p>
2022 !! html+tidy
2023 <p>a </p><div>foo</div>
2024 <p>b
2025 </p>
2026 !! end
2027
2028 !! test
2029 No p-wrappable content
2030 !! options
2031 parsoid=wt2html,html2html
2032 !! wikitext
2033 <span><div>x</div></span>
2034 <span><s><div>x</div></s></span>
2035 <small><em></em></small><span><s><div>x</div></s></span>
2036 !! html+tidy
2037 <span><div>x</div></span>
2038 <span><s><div>x</div></s></span>
2039 <p><small><em></em></small></p><span><s><div>x</div></s></span>
2040 !! end
2041
2042 # T177612: Parsoid-only test
2043 !! test
2044 Transclusion meta tags shouldn't trip Parsoid's useless p-wrapper stripping code
2045 !! wikitext
2046 {{echo|<span><div>x</div></span>}}
2047 x
2048 !! html/parsoid
2049 <span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;span>&lt;div>x&lt;/div>&lt;/span>"}},"i":0}}]}'><div>x</div></span>
2050 <p>x</p>
2051 !! end
2052
2053 !! test
2054 Block tag on one line (<blockquote>)
2055 !! wikitext
2056 a <blockquote>foo</blockquote>
2057
2058 b
2059 !! html
2060 a <blockquote>foo</blockquote>
2061 <p>b
2062 </p>
2063 !! html+tidy
2064 <p>a </p><blockquote><p>foo</p></blockquote>
2065 <p>b
2066 </p>
2067 !! end
2068
2069 !! test
2070 Block tag on both lines (<div>)
2071 !! wikitext
2072 a <div>foo</div>
2073
2074 b <div>foo</div>
2075 !! html
2076 a <div>foo</div>
2077 b <div>foo</div>
2078
2079 !! html+tidy
2080 <p>a </p><div>foo</div><p>
2081 b </p><div>foo</div>
2082 !! end
2083
2084 !! test
2085 Block tag on both lines (<blockquote>)
2086 !! wikitext
2087 a <blockquote>foo</blockquote>
2088
2089 b <blockquote>foo</blockquote>
2090 !! html
2091 a <blockquote>foo</blockquote>
2092 b <blockquote>foo</blockquote>
2093
2094 !! html+tidy
2095 <p>a </p><blockquote><p>foo</p></blockquote><p>
2096 b </p><blockquote><p>foo</p></blockquote>
2097 !! end
2098
2099 !! test
2100 Multiple lines without block tags
2101 !! wikitext
2102 <div>foo</div> a
2103 b
2104 c
2105 d<!--foo--> e
2106 x <div>foo</div> z
2107 !! html
2108 <div>foo</div> a
2109 <p>b
2110 c
2111 d e
2112 </p>
2113 x <div>foo</div> z
2114
2115 !! html+tidy
2116 <div>foo</div><p> a
2117 </p><p>b
2118 c
2119 d e
2120 </p><p>
2121 x </p><div>foo</div><p> z
2122 </p>
2123 !! end
2124
2125 !! test
2126 Empty lines between lines with block tags
2127 !! wikitext
2128 <div></div>
2129
2130
2131 <div></div>a
2132
2133 b
2134 <div>a</div>b
2135
2136 <div>b</div>d
2137
2138
2139 <div>e</div>
2140 !! html
2141 <div></div>
2142 <p><br />
2143 </p>
2144 <div></div>a
2145 <p>b
2146 </p>
2147 <div>a</div>b
2148 <div>b</div>d
2149 <p><br />
2150 </p>
2151 <div>e</div>
2152
2153 !! html+tidy
2154 <div></div>
2155 <p><br />
2156 </p>
2157 <div></div><p>a
2158 </p><p>b
2159 </p>
2160 <div>a</div><p>b
2161 </p><div>b</div><p>d
2162 </p><p><br />
2163 </p>
2164 <div>e</div>
2165 !! html/parsoid
2166 <div data-parsoid='{"stx":"html"}'></div>
2167
2168 <p><br /></p>
2169 <div data-parsoid='{"stx":"html"}'></div><p>a</p>
2170
2171 <p>b</p>
2172 <div data-parsoid='{"stx":"html"}'>a</div><p>b</p>
2173
2174 <div data-parsoid='{"stx":"html"}'>b</div><p>d</p>
2175
2176 <p><br /></p>
2177 <div data-parsoid='{"stx":"html"}'>e</div>
2178 !! end
2179
2180 !! test
2181 Unclosed HTML p-tags should be handled properly
2182 !! wikitext
2183 <div><p>foo</div>
2184 a
2185
2186 b
2187 !! html/php+tidy
2188 <div><p>foo</p></div>
2189 <p>a
2190 </p><p>b
2191 </p>
2192 !! html/parsoid
2193 <div data-parsoid='{"stx":"html"}'><p data-parsoid='{"stx":"html", "autoInsertedEnd":true}'>foo</p></div>
2194 <p>a</p>
2195 <p>b</p>
2196 !! end
2197
2198 ## SSS FIXME: I can come up with other scenarios where this doesn't work because
2199 ## of eager output of buffered tokens in the p-wrapper. But, I'm going to ignore
2200 ## them for now.
2201 !! test
2202 1. P-wrapping should leave sol-transparent tags outside p-tags where possible
2203 !! options
2204 parsoid=wt2html
2205 !! wikitext
2206 a [[Category:A1]] [[Category:A2]]
2207 [[Category:A3]]
2208 [[Category:A4]]
2209 !! html/parsoid
2210 <p>a</p>
2211 <link rel="mw:PageProp/Category" href="./Category:A1"/> <link rel="mw:PageProp/Category" href="./Category:A2"/> <link rel="mw:PageProp/Category" href="./Category:A3"/> <link rel="mw:PageProp/Category" href="./Category:A4"/>
2212 !! end
2213
2214 !! test
2215 2. P-wrapping should leave sol-transparent tags outside p-tags where possible
2216 !! options
2217 parsoid=wt2html
2218 !! wikitext
2219 [[Category:A1]]a
2220 !! html/parsoid
2221 <link rel="mw:PageProp/Category" href="./Category:A1"/><p>a</p>
2222 !! end
2223
2224 !! test
2225 No paragraph necessary for SOL transparent template
2226 !! wikitext
2227 <span><div>foo</div></span>
2228 [[Category:Foo]]
2229
2230 <span><div>foo</div></span>
2231 {{echo|[[Category:Foo]]}}
2232 !! html/php
2233 <span><div>foo</div></span>
2234 <span><div>foo</div></span>
2235
2236 !! html/parsoid
2237 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2238 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
2239
2240 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2241 <link rel="mw:PageProp/Category" href="./Category:Foo" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Category:Foo]]"}},"i":0}}]}'/>
2242 !! end
2243
2244 !! test
2245 Avoid expanding multiline sol transparent template ranges unnecessarily
2246 !! wikitext
2247 hi
2248
2249
2250 {{echo|<br/>
2251 }}
2252
2253 [[Category:Ho]]
2254 !! html/php
2255 <p>hi
2256 </p><p><br />
2257 <br />
2258 </p>
2259 !! html/parsoid
2260 <p>hi</p>
2261
2262 <p><br />
2263 <br about="#mwt1" typeof="mw:Transclusion" data-parsoid='{}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;br/>\n"}},"i":0}}]}'/><span about="#mwt1">
2264 </span></p>
2265
2266 <link rel="mw:PageProp/Category" href="./Category:Ho" />
2267 !! end
2268
2269 !! test
2270 Paragraph wrapping following unclosed table
2271 !! options
2272 parsoid=wt2html,html2html
2273 !! wikitext
2274 {|
2275 |-
2276
2277 {|
2278 | x
2279 |}
2280
2281 a
2282
2283 b
2284
2285 c
2286 !! html/php+tidy
2287 <table>
2288
2289
2290 </table><table>
2291 <tbody><tr>
2292 <td>x
2293 </td></tr></tbody></table>
2294 <p>a
2295 </p><p>b
2296 </p><p>c
2297 </p>
2298 !! html/parsoid
2299 <table data-parsoid='{"autoInsertedEnd":true}'>
2300 <tbody><tr class="mw-empty-elt" data-parsoid='{"startTagSrc":"|-"}'></tr>
2301
2302 </tbody></table><table>
2303 <tbody><tr data-parsoid='{"autoInsertedStart":true}'><td>x</td></tr>
2304 </tbody></table>
2305
2306 <p>a</p>
2307
2308 <p>b</p>
2309
2310 <p>c</p>
2311 !! end
2312
2313 !! test
2314 Paragraph wrapping suppressed in html p
2315 !! options
2316 parsoid=wt2html,html2html
2317 !! wikitext
2318 <p>
2319
2320
2321 hi
2322
2323
2324
2325 </p>
2326 !! html/php+tidy
2327 <p>
2328
2329
2330 hi
2331
2332
2333
2334 </p>
2335 !! html/parsoid
2336 <p data-parsoid='{"stx":"html"}'>
2337
2338
2339 hi
2340
2341
2342
2343 </p>
2344 !! end
2345
2346 !! test
2347 Dangling table row doesn't prevent p-wrapping
2348 !! options
2349 parsoid=wt2html,html2html
2350 !! wikitext
2351 {|
2352 | hi
2353 |-
2354 |} ho
2355 !! html/parsoid
2356 <table>
2357 <tbody><tr><td>hi</td></tr>
2358 <tr class="mw-empty-elt"></tr>
2359 </tbody></table><p> ho</p>
2360 !! end
2361
2362 ###
2363 ### Preformatted text
2364 ###
2365
2366 !! test
2367 Preformatted text
2368 !! wikitext
2369 This is some
2370 Preformatted text
2371 With ''italic''
2372 And '''bold'''
2373 And a [[Main Page|link]]
2374 !! html
2375 <pre>This is some
2376 Preformatted text
2377 With <i>italic</i>
2378 And <b>bold</b>
2379 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
2380 </pre>
2381 !! end
2382
2383 !! test
2384 Tabs don't trigger preformatted text
2385 !! wikitext
2386 This is not
2387 preformatted text.
2388 This is preformatted text.
2389 So is this.
2390 !! html/php
2391 <p> This is not
2392 preformatted text.
2393 </p>
2394 <pre>This is preformatted text.
2395 So is this.
2396 </pre>
2397 !! html/parsoid
2398 <p> This is not
2399 preformatted text.</p>
2400 <pre>This is preformatted text.
2401 So is this.</pre>
2402 !! end
2403
2404 !! test
2405 Space before tab needs nowiki pre protection
2406 !! options
2407 parsoid=html2wt
2408 !! html/parsoid
2409 <p> a</p>
2410 !! wikitext
2411 <nowiki> </nowiki> a
2412 !! end
2413
2414 !! test
2415 Ident preformatting with inline content
2416 !! wikitext
2417 a
2418 ''b''
2419 !! html
2420 <pre>a
2421 <i>b</i>
2422 </pre>
2423 !! end
2424
2425 !! test
2426 <pre> with <nowiki> inside (compatibility with 1.6 and earlier)
2427 !! wikitext
2428 <pre><nowiki>
2429 <b>
2430 <cite>
2431 <em>
2432 </nowiki></pre>
2433 !! html
2434 <pre>
2435 &lt;b&gt;
2436 &lt;cite&gt;
2437 &lt;em&gt;
2438 </pre>
2439
2440 !! end
2441
2442 !! test
2443 Regression with preformatted in <center>
2444 !! wikitext
2445 <center>
2446 Blah
2447 </center>
2448 !! html
2449 <center>
2450 <pre>Blah
2451 </pre>
2452 </center>
2453
2454 !! end
2455
2456 !! test
2457 T54763: Preformatted in <blockquote>
2458 !! wikitext
2459 <blockquote>
2460 Blah
2461 {|
2462 |
2463 indented cell (no pre-wrapping!)
2464 |}
2465 </blockquote>
2466 !! html
2467 <blockquote>
2468 <p> Blah
2469 </p>
2470 <table>
2471 <tr>
2472 <td>
2473 <p> indented cell (no pre-wrapping!)
2474 </p>
2475 </td></tr></table>
2476 </blockquote>
2477
2478 !! end
2479
2480 !! test
2481 T53086: Double newlines in blockquotes should be turned into paragraphs
2482 !! wikitext
2483 <blockquote>
2484 Foo
2485
2486 Bar
2487 </blockquote>
2488 !! html
2489 <blockquote>
2490 <p>Foo
2491 </p><p>Bar
2492 </p>
2493 </blockquote>
2494
2495 !! end
2496
2497 !! test
2498 T17491: <ins>/<del> in blockquote
2499 !! wikitext
2500 <blockquote>
2501 Foo <del>bar</del> <ins>baz</ins> quux
2502 </blockquote>
2503 !! html
2504 <blockquote>
2505 <p>Foo <del>bar</del> <ins>baz</ins> quux
2506 </p>
2507 </blockquote>
2508
2509 !! html+tidy
2510 <blockquote>
2511 <p>Foo <del>bar</del> <ins>baz</ins> quux
2512 </p>
2513 </blockquote>
2514 !! end
2515
2516 !! test
2517 T17491: <ins>/<del> in blockquote (2)
2518 !! wikitext
2519 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2520 </blockquote>
2521 !! html
2522 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2523 </blockquote>
2524
2525 !! html+tidy
2526 <blockquote><p>Foo <del>bar</del> <ins>baz</ins> quux
2527 </p></blockquote>
2528 !! end
2529
2530 !! test
2531 <pre> with attributes (T5202)
2532 !! wikitext
2533 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2534 !! html
2535 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2536
2537 !! end
2538
2539 !! test
2540 <pre> with width attribute (T5202)
2541 !! wikitext
2542 <pre width="8">Narrow screen goodies</pre>
2543 !! html
2544 <pre width="8">Narrow screen goodies</pre>
2545
2546 !! end
2547
2548 !! test
2549 <pre> with forbidden attribute (T5202)
2550 !! wikitext
2551 <pre width="8" onmouseover="alert(document.cookie)">Narrow screen goodies</pre>
2552 !! html
2553 <pre width="8">Narrow screen goodies</pre>
2554
2555 !! end
2556
2557 !! test
2558 Entities inside <pre>
2559 !! wikitext
2560 <pre>&lt;</pre>
2561 !! html
2562 <pre>&lt;</pre>
2563
2564 !! end
2565
2566 !! test
2567 <pre> with forbidden attribute values (T5202)
2568 !! wikitext
2569 <pre width="8" style="border-width: expression(alert(document.cookie))">Narrow screen goodies</pre>
2570 !! html
2571 <pre width="8" style="/* insecure input */">Narrow screen goodies</pre>
2572
2573 !! end
2574
2575 !! test
2576 <nowiki> inside <pre> (T15238)
2577 !! wikitext
2578 <pre>
2579 <nowiki>
2580 </pre>
2581 <pre>
2582 <nowiki></nowiki>
2583 </pre>
2584 <pre><nowiki><nowiki></nowiki>Foo<nowiki></nowiki></nowiki></pre>
2585 !! html
2586 <pre>
2587 &lt;nowiki&gt;
2588 </pre>
2589 <pre>
2590
2591 </pre>
2592 <pre>&lt;nowiki&gt;Foo&lt;/nowiki&gt;</pre>
2593
2594 !! end
2595
2596 !! test
2597 <nowiki> inside of #tag:pre
2598 !! wikitext
2599 {{#tag:pre|Foo <nowiki>&rarr;bar</nowiki>}}
2600 !! html/php
2601 <pre>Foo &#8594;bar</pre>
2602
2603 !! html/parsoid
2604 <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>
2605 !! end
2606
2607 ## Don't expect this to rt, Parsoid drops the unmatched closing pre tags that
2608 ## aren't enclosed in nowikis.
2609 !! test
2610 <nowiki> and <pre> preference (first one wins)
2611 !! options
2612 parsoid=wt2html
2613 !! wikitext
2614 <pre>
2615 <nowiki>
2616 </pre>
2617 </nowiki>
2618 </pre>
2619
2620 <nowiki>
2621 <pre>
2622 <nowiki>
2623 </pre>
2624 </nowiki>
2625 </pre>
2626
2627 !! html/php
2628 <pre>
2629 &lt;nowiki&gt;
2630 </pre>
2631 <p>&lt;/nowiki&gt;
2632 &lt;/pre&gt;
2633 </p><p>
2634 &lt;pre&gt;
2635 &lt;nowiki&gt;
2636 &lt;/pre&gt;
2637
2638 &lt;/pre&gt;
2639 </p>
2640 !! html/parsoid
2641 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n&lt;nowiki>\n"}}'>&lt;nowiki>
2642 </pre>
2643 <p>&lt;/nowiki></p>
2644
2645
2646 <p><span typeof="mw:Nowiki">
2647 &lt;pre>
2648 &lt;nowiki>
2649 &lt;/pre>
2650 </span></p>
2651 !! end
2652
2653 !! test
2654 </pre> inside nowiki
2655 !! wikitext
2656 <nowiki></pre></nowiki>
2657 !! html
2658 <p>&lt;/pre&gt;
2659 </p>
2660 !! end
2661
2662 !! test
2663 Empty pre; pre inside other HTML tags (T56946)
2664 !! wikitext
2665 a
2666
2667 <div><pre>
2668 foo
2669 </pre></div>
2670 <pre></pre>
2671 !! html/php+tidy
2672 <p>a
2673 </p>
2674 <div><pre>foo
2675 </pre></div>
2676 <pre></pre>
2677 !! html/parsoid
2678 <p>a</p>
2679
2680 <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
2681 </pre></div>
2682 <pre typeof="mw:Extension/pre" about="#mwt4" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":""}}'></pre>
2683 !! end
2684
2685 !! test
2686 HTML pre followed by indent-pre
2687 !! wikitext
2688 <pre>foo</pre>
2689 bar
2690 !! html
2691 <pre>foo</pre>
2692 <pre>bar
2693 </pre>
2694 !! end
2695
2696 !! test
2697 Block tag pre
2698 !! wikitext
2699 <p><pre>foo</pre></p>
2700 !! html/php+tidy
2701 <p class="mw-empty-elt"></p><pre>foo</pre><p class="mw-empty-elt"></p>
2702 !! html/parsoid
2703 <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>
2704 !! end
2705
2706 !!test
2707 Templates: Indent-Pre: 1a. Templates that break a line should suppress <pre>
2708 !! wikitext
2709 {{echo|}}
2710 !! html
2711
2712 !!end
2713
2714 !!test
2715 Templates: Indent-Pre: 1b. Templates that break a line should suppress <pre>
2716 !! wikitext
2717 {{echo|
2718 foo}}
2719 !! html
2720 <p>foo
2721 </p>
2722 !!end
2723
2724 !! test
2725 Templates: Indent-Pre: 1c: Wrapping should be based on expanded content
2726 !! wikitext
2727 {{echo|a
2728 b}}
2729 !! html
2730 <pre>a
2731 </pre>
2732 <p>b
2733 </p>
2734 !!end
2735
2736 !! test
2737 Templates: Indent-Pre: 1d: Wrapping should be based on expanded content
2738 !! wikitext
2739 {{echo|a
2740 b
2741 c
2742 d
2743 e
2744 }}
2745 !! html
2746 <pre>a
2747 </pre>
2748 <p>b
2749 c
2750 </p>
2751 <pre>d
2752 </pre>
2753 <p>e
2754 </p>
2755 !!end
2756
2757 !!test
2758 Templates: Indent-Pre: 1e. Wrapping should be based on expanded content
2759 !! wikitext
2760 {{echo| foo}}
2761
2762 {{echo| foo}}{{echo| bar}}
2763
2764 {{echo| foo}}
2765 {{echo| bar}}
2766
2767 {{echo|<!--cmt--> foo}}
2768
2769 <!--cmt-->{{echo| foo}}
2770
2771 {{echo|{{echo| }}bar}}
2772 !! html
2773 <pre>foo
2774 </pre>
2775 <pre>foo bar
2776 </pre>
2777 <pre>foo
2778 bar
2779 </pre>
2780 <pre>foo
2781 </pre>
2782 <pre>foo
2783 </pre>
2784 <pre>bar
2785 </pre>
2786 !!end
2787
2788 !! test
2789 Templates: Indent-Pre: 1f: Wrapping should be based on expanded content
2790 !! wikitext
2791 {{echo| }}a
2792
2793 {{echo|
2794 }}a
2795
2796 {{echo|
2797 b}}
2798
2799 {{echo|a
2800 }}b
2801
2802 {{echo|a
2803 }} b
2804 !! html
2805 <pre>a
2806 </pre>
2807 <p><br />
2808 </p>
2809 <pre>a
2810 </pre>
2811 <p><br />
2812 </p>
2813 <pre>b
2814 </pre>
2815 <p>a
2816 </p>
2817 <pre>b
2818 </pre>
2819 <p>a
2820 </p>
2821 <pre>b
2822 </pre>
2823 !!end
2824
2825 ## Hmm, should Parsoid rt this?
2826 !! test
2827 Pres with newline attributes
2828 !! options
2829 parsoid=wt2html,html2html
2830 !! wikitext
2831 <pre class="one
2832 two">hi</pre>
2833 !! html/php
2834 <pre class="one two">hi</pre>
2835
2836 !! html/parsoid
2837 <pre typeof="mw:Extension/pre" about="#mwt2" class="one two" data-mw='{"name":"pre","attrs":{"class":"one two"},"body":{"extsrc":"hi"}}'>hi</pre>
2838 !! end
2839
2840 !! test
2841 Things that look like <pre> tags aren't treated as such
2842 !! wikitext
2843 Barack Obama <President> of the United States
2844 <President></President>
2845 !! html
2846 <p>Barack Obama &lt;President&gt; of the United States
2847 &lt;President&gt;&lt;/President&gt;
2848 </p>
2849 !! end
2850
2851 ## Remex doesn't account for fostered content.
2852 ## The difference between Parsoid and the PHP parser can be attributed to core
2853 ## commit 674e8388cba and 710618f89af in Parsoid's repo. Parsoid doesn't
2854 ## tokenize unmatched extension tags that shadow html tags as strings to ease
2855 ## an escaping mechanism. See the comment in `maybeExtensionTag`.
2856 !! test
2857 Handle broken pre-like tags (T66025)
2858 !! options
2859 parsoid=wt2html
2860 !! wikitext
2861 {{echo|<pre <pre>x</pre>}}
2862
2863 <table><pre </table>
2864 !! html/php
2865 <pre>x</pre>
2866 <table>&lt;pre </table>
2867
2868 !! html/php+tidy
2869 <pre>x</pre>
2870 &lt;pre <table></table>
2871 !! html/parsoid
2872 <pre typeof="mw:Transclusion mw:Extension/pre" 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>
2873
2874 <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>
2875 !! end
2876
2877 ## Similar to the above, but shows the difference between extension and html tags
2878 !! test
2879 Less than in attribute position
2880 !! wikitext
2881 <pre <pre>123</pre>
2882
2883 <div <div>123</div>
2884 !! html/php+tidy
2885 <pre>123</pre><p>
2886 &lt;div </p><div>123</div>
2887 !! html/parsoid
2888 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"&lt;pre":""},"body":{"extsrc":"123"}}'>123</pre><p>
2889
2890 &lt;div </p><div>123</div>
2891 !! end
2892
2893 !! test
2894 Parsoid: handle pre with space after attribute
2895 !! options
2896 parsoid=wt2html
2897 !! wikitext
2898 <pre style="width:50%;" >{{echo|foo}}</pre>
2899 !! html/php
2900 <pre style="width:50%;">{{echo|foo}}</pre>
2901
2902 !! html/parsoid
2903 <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>
2904 !! end
2905
2906 !! test
2907 Self-closed pre
2908 !! wikitext
2909 <pre />
2910 !! html/php
2911 <pre></pre>
2912
2913 !! html/parsoid
2914 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{}}'></pre>
2915 !! end
2916
2917 !! test
2918 Parsoid: Don't paragraph-wrap fosterable content even if table syntax is unbalanced
2919 !! options
2920 parsoid=wt2html
2921 !! wikitext
2922 {|
2923 <td>
2924 <td>
2925 </td>
2926
2927
2928
2929 |}
2930 !! html
2931 <table>
2932
2933 <tbody>
2934 <tr>
2935 <td></td>
2936
2937 <td>
2938 </td></tr>
2939
2940
2941
2942 </tbody></table>
2943 !! end
2944
2945
2946 #--------------------------------------------------------------------
2947 # Transclusion parameter whitespace stripping tests
2948 # Behavior is different for positional and named parameters
2949 #--------------------------------------------------------------------
2950 !! test
2951 Templates: Strip leading and trailing whitespace from named-param values
2952 !! wikitext
2953 {{echo|1= a }}
2954
2955 {{echo|1= {{echo|b}} }}
2956
2957 {{echo| 1 =
2958 c }}
2959
2960 {{echo| 1 =
2961 * d
2962 }}
2963 !! html
2964 <p>a
2965 </p><p>b
2966 </p><p>c
2967 </p>
2968 <ul><li>d</li></ul>
2969
2970 !! end
2971
2972 !! test
2973 Templates: Don't strip whitespace from positional-param values
2974 !! wikitext
2975 {{echo|a }}
2976
2977 {{echo|{{echo|b}} }}
2978
2979 {{echo| c
2980 }}
2981
2982 {{echo| {{echo|d}}
2983 }}
2984
2985 {{echo|
2986 e}}
2987
2988 {{echo|
2989 *f}}
2990
2991 {{echo|
2992 }}g
2993 !! html
2994 <p>a
2995 </p><p>b
2996 </p>
2997 <pre>c
2998 </pre>
2999 <p><br />
3000 </p>
3001 <pre>d
3002 </pre>
3003 <p><br />
3004 </p>
3005 <pre>e
3006 </pre>
3007 <p><br />
3008 </p>
3009 <ul><li>f</li></ul>
3010 <p><br />
3011 </p>
3012 <pre>g
3013 </pre>
3014 !! end
3015
3016 !! test
3017 Templates: Don't recognize targets split by newlines
3018 !! options
3019 parsoid=wt2html
3020 !! wikitext
3021 {{ech
3022 o|foo}}
3023 !! html/php
3024 <p>{{ech
3025 o|foo}}
3026 </p>
3027 !! html/parsoid
3028 <p>{{ech
3029 o|foo}}</p>
3030 !! end
3031
3032 !! test
3033 Templates: Recognize targets when newlines and comments don't split the target
3034 !! options
3035 parsoid=wt2html
3036 !! wikitext
3037 {{
3038 <!--X--> ech<!--X-->o<!--X-->
3039 <!--X--> <!--X-->
3040
3041 |foo}}
3042 !! html/php
3043 <p>foo
3044 </p>
3045 !! html/parsoid
3046 <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>
3047 !! end
3048
3049 !! test
3050 Templates: Handle empty comment-and-ws-only lines correctly
3051 !! wikitext
3052 {{echo|foo
3053 <!--should be ignored-->
3054 <!--should be ignored as well-->
3055 bar}}
3056 !! html/php
3057 <p>foo
3058 bar
3059 </p>
3060 !! html/parsoid
3061 <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>
3062 !! end
3063
3064 !! test
3065 Templates: Handle comments in the target
3066 !! wikitext
3067 {{echo
3068 <!-- should be ignored -->
3069 |foo}}
3070
3071 {{echo
3072 <!-- should be ignored and spaces on next line should not trip us up (T147742) -->
3073 |foo}}
3074
3075 {{echo<!-- should be ignored -->
3076 |foo}}
3077
3078 {{echo<!-- should be ignored -->|foo}}
3079
3080 {{<!-- should be ignored -->echo|foo}}
3081 !! html/php
3082 <p>foo
3083 </p><p>foo
3084 </p><p>foo
3085 </p><p>foo
3086 </p><p>foo
3087 </p>
3088 !! html/parsoid
3089 <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>
3090
3091 <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>
3092
3093 <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>
3094
3095 <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>
3096
3097 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
3098 !! end
3099
3100 !! test
3101 Templates: Handle comments in parameter names (T69657)
3102 !! wikitext
3103 {{echo|1
3104 <!-- should be ignored -->
3105 =foo}}
3106
3107 {{echo|
3108 <!-- should be ignored -->
3109 1 = foo}}
3110
3111 {{echo|1<!-- should be ignored -->=foo}}
3112
3113 {{echo|<!-- should be ignored -->1=foo}}
3114 !! html/php
3115 <p>foo
3116 </p><p>foo
3117 </p><p>foo
3118 </p><p>foo
3119 </p>
3120 !! html/parsoid
3121 <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>
3122
3123 <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>
3124
3125 <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>
3126
3127 <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>
3128 !! end
3129
3130 !! test
3131 Templates: Other wikitext in parameter names (T69657)
3132 !! wikitext
3133 {{echo|''1''=foo}}
3134 !! html/php
3135 <p>{{{1}}}
3136 </p>
3137 !! html/parsoid
3138 <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>
3139 !! end
3140
3141 !! test
3142 Templates: With colons
3143 !! wikitext
3144 {{With: Colon}}
3145 !! html/php
3146 <p>Template with colon
3147 </p>
3148 !! html/parsoid
3149 <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>
3150 !! end
3151
3152 #--------------------------------------------------------------------
3153 # Transclusion parameter escaping tests
3154 #--------------------------------------------------------------------
3155
3156 !! test
3157 Templates: Parsoid parameter escaping test 1
3158 !! wikitext
3159 {{echo|[foo]|{{echo|[bar]}}}}
3160 !! html/php+tidy
3161 <p>[foo]
3162 </p>
3163 !! html/parsoid
3164 <p about="#mwt1" typeof="mw:Transclusion"
3165 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[foo]"},"2":{"wt":"{{echo|[bar]}}"}},"i":0}}]}'>[foo]</p>
3166 !! end
3167
3168 !! test
3169 Parsoid: Pipes in external links in template parameter
3170 !! wikitext
3171 {{echo|[{{echo|http://example.com}} link]}}
3172 !! html/php+tidy
3173 <p><a rel="nofollow" class="external text" href="http://example.com">link</a>
3174 </p>
3175 !! html/parsoid
3176 <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>
3177 !! end
3178
3179 !! test
3180 Parsoid: pipe in transclusion parameter
3181 !! wikitext
3182 {{echo|http://foo.com/a&#124;b}}
3183 !! html/php+tidy
3184 <p><a rel="nofollow" class="external free" href="http://foo.com/a%7Cb">http://foo.com/a%7Cb</a>
3185 </p>
3186 !! html/parsoid
3187 <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>
3188 !! end
3189
3190 !! test
3191 Parsoid: Pipe in external link target and content in template parameter
3192 !! options
3193 parsoid=html2wt,wt2wt
3194 !! wikitext
3195 {{echo|[http://foo.com/a&#124;b a&#124;b]}}
3196 !! html/php+tidy
3197 <p><a rel="nofollow" class="external text" href="http://foo.com/a%7Cb">a&#124;b</a>
3198 </p>
3199 !! html/parsoid
3200 <p><a rel="mw:ExtLink" href="http://foo.com/a|b" about="#mwt1"
3201 typeof="mw:Transclusion"
3202 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},
3203 "params":{"1":{"wt":"[http://foo.com/a|b a|b]"}},"i":0}}]}'>a|b</a></p>
3204 !! end
3205
3206 !! test
3207 Parsoid: Pipe in template with nested template in external link target in template parameter (seriously)
3208 !! options
3209 parsoid
3210 !! wikitext
3211 {{echo|[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]}}
3212 !! html
3213 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]"}},"i":0}}]}'>[Main Page bar]</p>
3214 !! end
3215
3216 !! test
3217 Templates: Don't escape already nowiki-escaped text in template parameters
3218 !! options
3219 parsoid=html2wt,wt2wt
3220 !! wikitext
3221 {{echo|foo<nowiki>|</nowiki>bar}}
3222 {{echo|<nowiki>&lt;div&gt;</nowiki>}}
3223 {{echo|<nowiki></nowiki>}}
3224 !! html/php+tidy
3225 <p>foo|bar
3226 &lt;div&gt;
3227
3228 </p>
3229 !! html/parsoid
3230 <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>
3231 <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>
3232 <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>
3233 </p>
3234 !! end
3235
3236 ## T54824
3237 !! test
3238 Templates: '=' char in nested transclusions should not trigger nowiki escapes or conversion to named param
3239 !! options
3240 parsoid=html2wt,wt2wt
3241 !! wikitext
3242 {{echo|{{echo|1=bar}}}}
3243 !! html/php+tidy
3244 <p>bar
3245 </p>
3246 !! html/parsoid
3247 <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>
3248 !! end
3249
3250 ## T58733
3251 !! test
3252 Templates parameters with special tokenizing behavior dont get modified because of arg escaping
3253 !! wikitext
3254 {{echo|a : b}}
3255 !! html/php+tidy
3256 <p>a&#160;: b
3257 </p>
3258 !! html/parsoid
3259 <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>
3260 !! end
3261
3262 ## T73412
3263 !! test
3264 Templates: Preserve blank parameter names
3265 !! wikitext
3266 {{echo|=foo}}
3267 !! html/php+tidy
3268 <p>{{{1}}}
3269 </p>
3270 !! html/parsoid
3271 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"":{"wt":"foo"}},"i":0}}]}'>{{{1}}}</p>
3272 !! end
3273
3274 !! test
3275 Templates: Preserve blank parameter names in other positions
3276 !! wikitext
3277 {{blank_param|bar|=foo}}
3278 !! html/php+tidy
3279 <p>bar
3280 foo
3281 </p>
3282 !! html/parsoid
3283 <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
3284 foo</p>
3285 !! end
3286
3287 ###
3288 ### Parsoid-centric tests for testing RT edge cases for pre
3289 ###
3290
3291 !!test
3292 1a. Indent-Pre and Comments
3293 !! wikitext
3294 a
3295 <!--a-->
3296 c
3297 !! html
3298 <pre>a
3299 </pre>
3300 <p>c
3301 </p>
3302 !!end
3303
3304 !!test
3305 1b. Indent-Pre and Comments
3306 !! wikitext
3307 a
3308 <!--a-->
3309 c
3310 !! html
3311 <pre>a
3312 </pre>
3313 <p>c
3314 </p>
3315 !!end
3316
3317 !!test
3318 1c. Indent-Pre and Comments
3319 !! wikitext
3320 <!--a--> a
3321
3322 <!--a--> a
3323 !! html
3324 <pre> a
3325 </pre>
3326 <pre> a
3327 </pre>
3328 !!end
3329
3330 !!test
3331 1d. Indent-Pre and Comments
3332 (Pre-handler currently cannot distinguish between comment/ws order and normalizes them to [comment,ws] order)
3333 !! wikitext
3334 <!--a--> a
3335
3336 <!--b-->b
3337 !! html
3338 <pre>a
3339 </pre>
3340 <pre>b
3341 </pre>
3342 !!end
3343
3344 !!test
3345 2a. Indent-Pre and tables
3346 !! wikitext
3347 {|
3348 |-
3349 !h1!!h2
3350 |foo||bar
3351 |}
3352 !! html
3353 <table>
3354
3355 <tr>
3356 <th>h1</th>
3357 <th>h2
3358 </th>
3359 <td>foo</td>
3360 <td>bar
3361 </td></tr></table>
3362
3363 !!end
3364
3365 !!test
3366 2b. Indent-Pre and tables
3367 !! wikitext
3368 {|
3369 |-
3370 |foo
3371 |}
3372 !! html
3373 <table>
3374
3375 <tr>
3376 <td>foo
3377 </td></tr></table>
3378
3379 !!end
3380
3381 !!test
3382 2c. Indent-Pre and tables (T44252)
3383 !! wikitext
3384 {|
3385 |+foo
3386 ! |bar
3387 |}
3388 !! html
3389 <table>
3390 <caption>foo
3391 </caption>
3392 <tr>
3393 <th>bar
3394 </th></tr></table>
3395
3396 !!end
3397
3398 !!test
3399 2d. Indent-Pre and tables
3400 !! wikitext
3401 a
3402 {|
3403 |b
3404 |}
3405 !! html/php
3406 <pre>a
3407 </pre>
3408 <table>
3409 <tr>
3410 <td>b
3411 </td></tr></table>
3412
3413 !! html/parsoid
3414 <pre>a</pre>
3415 <table>
3416 <tbody><tr><td> b</td></tr>
3417 </tbody></table>
3418 !!end
3419
3420 !!test
3421 2e. Indent-Pre and table-line syntax
3422 !! wikitext
3423 a
3424 | b
3425 | c
3426 !! html/php
3427 <pre>a
3428 | b
3429 | c
3430 </pre>
3431 !!end
3432
3433 !!test
3434 2f. Indent-pre started by table-line syntax
3435 !! wikitext
3436 a
3437 | b
3438 | c
3439 !! html/php
3440 <p>a
3441 </p>
3442 <pre>| b
3443 | c
3444 </pre>
3445 !! html/parsoid
3446 <p>a</p>
3447 <pre>
3448 | b
3449 | c</pre>
3450 !!end
3451
3452 !! test
3453 2g. Indented table markup mixed with indented pre content (proposed in T8200)
3454 !! wikitext
3455 <table>
3456 <tr>
3457 <td>
3458 Text that should be rendered preformatted
3459 </td>
3460 </tr>
3461 </table>
3462 !! html
3463 <table>
3464 <tr>
3465 <td>
3466 <pre>Text that should be rendered preformatted
3467 </pre>
3468 </td>
3469 </tr>
3470 </table>
3471
3472 !! end
3473
3474 !! test
3475 2h. Indent pre in tables
3476 !! options
3477 parsoid=wt2html,html2html
3478 !! wikitext
3479 {|
3480 !
3481 foo
3482 !
3483 bar
3484 |-
3485 |
3486 baz
3487 {{!}}
3488 bam
3489 |}
3490 !! html/php
3491 <table>
3492 <tr>
3493 <th>
3494 <pre>foo
3495 </pre>
3496 </th>
3497 <th>
3498 <pre>bar
3499 </pre>
3500 </th></tr>
3501 <tr>
3502 <td>
3503 <pre>baz
3504 </pre>
3505 </td>
3506 <td>
3507 <pre>bam
3508 </pre>
3509 </td></tr></table>
3510
3511 !! html/parsoid
3512 <table>
3513 <tbody><tr><th>
3514 <pre>foo</pre>
3515 </th><th>
3516 <pre>bar</pre>
3517 </th></tr><tr>
3518 <td>
3519 <pre>baz</pre>
3520 </td><td data-parsoid='{"startTagSrc":"{{!}}"}'>
3521 <pre>bam</pre>
3522 </td></tr></tbody></table>
3523 !! end
3524
3525 !! test
3526 3a. Indent-Pre and block tags (single-line html)
3527 !! wikitext
3528 a <p> foo </p>
3529 b <div> foo </div>
3530 c <blockquote> foo </blockquote>
3531 <span> foo </span>
3532 !! html
3533 a <p> foo </p>
3534 b <div> foo </div>
3535 c <blockquote> foo </blockquote>
3536 <pre><span> foo </span>
3537 </pre>
3538 !! html/php+tidy
3539 <p> a </p><p> foo </p><p>
3540 b </p><div> foo </div><p>
3541 c </p><blockquote><p> foo </p></blockquote>
3542 <pre><span> foo </span>
3543 </pre>
3544 !! html/parsoid
3545 <p> a </p><p data-parsoid='{"stx":"html"}'> foo </p><p>
3546 b </p><div data-parsoid='{"stx":"html"}'> foo </div><p>
3547 c </p><blockquote data-parsoid='{"stx":"html"}'><p> foo </p></blockquote>
3548 <pre><span data-parsoid='{"stx":"html"}'> foo </span></pre>
3549 !! end
3550
3551 !! test
3552 3b. Indent-Pre and block tags (multi-line html)
3553 !! wikitext
3554 a <span>foo</span>
3555 <!-- comment --> b <div> foo </div>
3556 !! html/php
3557 <pre>a <span>foo</span>
3558 </pre>
3559 b <div> foo </div>
3560
3561 !! html/parsoid
3562 <pre>a <span data-parsoid='{"stx":"html"}'>foo</span></pre>
3563 <!-- comment --> <p>b </p><div data-parsoid='{"stx":"html"}'> foo </div>
3564 !! html/php+tidy
3565 <pre>a <span>foo</span>
3566 </pre><p>
3567 b </p><div> foo </div>
3568 !! end
3569
3570 !!test
3571 3c. Indent-Pre and block tags (pre-content on separate line)
3572 !! wikitext
3573 <p>
3574 foo
3575 </p>
3576
3577 <div>
3578 foo
3579 </div>
3580
3581 <center>
3582 foo
3583 </center>
3584
3585 <blockquote>
3586 foo
3587 </blockquote>
3588
3589 <blockquote>
3590 <pre>
3591 foo
3592 </pre>
3593 </blockquote>
3594
3595 <table><tr><td>
3596 foo
3597 </td></tr></table>
3598
3599 <ul><li>
3600 foo
3601 </li></ul>
3602
3603 !! html
3604 <p>
3605 foo
3606 </p>
3607 <div>
3608 <pre>foo
3609 </pre>
3610 </div>
3611 <center>
3612 <pre>foo
3613 </pre>
3614 </center>
3615 <blockquote>
3616 <p> foo
3617 </p>
3618 </blockquote>
3619 <blockquote>
3620 <pre>
3621 foo
3622 </pre>
3623 </blockquote>
3624 <table><tr><td>
3625 <pre>foo
3626 </pre>
3627 </td></tr></table>
3628 <ul><li>
3629 foo
3630 </li></ul>
3631
3632 !!end
3633
3634 !! test
3635 4. Indent-Pre and extension tags
3636 !! options
3637 parsoid=wt2html,html2html
3638 !! wikitext
3639 a <tag />
3640 !! html/php+tidy
3641 <p> a </p><pre>NULL
3642 array (
3643 )
3644 </pre>
3645 !! html/parsoid
3646 <p> a </p><pre typeof="mw:Extension/tag" about="#mwt2" data-mw='{"name":"tag","attrs":{}}'></pre>
3647 !! end
3648
3649 !! test
3650 5. Indent-Pre and html pre
3651 !! wikitext
3652 <pre class="123">hi</pre>
3653 !! html/php
3654 <pre class="123">hi</pre>
3655
3656 !! html/parsoid
3657 <pre typeof="mw:Extension/pre" about="#mwt2" class="123" data-mw='{"name":"pre","attrs":{"class":"123"},"body":{"extsrc":"hi"}}'>hi</pre>
3658 !! end
3659
3660 !!test
3661 Render paragraphs when indent-pre is suppressed in blocklevels
3662 !! wikitext
3663 <blockquote>
3664 foo
3665
3666 bar
3667 </blockquote>
3668 !! html
3669 <blockquote>
3670 <p> foo
3671 </p><p> bar
3672 </p>
3673 </blockquote>
3674
3675 !!end
3676
3677 !!test
3678 4. Multiple spaces at start-of-line
3679 !! wikitext
3680 <p> foo </p>
3681 foo
3682 {|
3683 |foo
3684 |}
3685 !! html
3686 <p> foo </p>
3687 <pre> foo
3688 </pre>
3689 <table>
3690 <tr>
3691 <td>foo
3692 </td></tr></table>
3693
3694 !!end
3695
3696 ## NOTE: the leading white-space chars on empty line are significant
3697 !! test
3698 5a. White-space in indent-pre
3699 !! wikitext
3700 a<br />
3701
3702 b
3703 !! html
3704 <pre>a<br />
3705
3706 b
3707 </pre>
3708 !! end
3709
3710 ## NOTE: the leading white-space chars on empty line are significant
3711 !! test
3712 5b. White-space in indent-pre
3713 !! wikitext
3714 a
3715
3716 b
3717
3718
3719 c
3720 !! html
3721 <pre>a
3722
3723 b
3724
3725
3726 c
3727 </pre>
3728 !! end
3729
3730 !! test
3731 5c. White-space in indent-pre
3732 !! wikitext
3733 ''a''
3734 ''b''
3735 ''c''
3736 !! html
3737 <pre><i>a</i>
3738 <i>b</i>
3739 <i>c</i>
3740 </pre>
3741 !! end
3742
3743 !! test
3744 6. Pre-blocks should extend across lines with leading WS even when there is no wrappable content
3745 !! wikitext
3746 a
3747
3748 <!-- continue -->
3749 b
3750
3751 c
3752
3753 d
3754 !! html
3755 <pre>a
3756
3757 b
3758 </pre>
3759 <pre>c
3760
3761 </pre>
3762 <p>d
3763 </p>
3764 !! end
3765
3766 !! test
3767 7a. Indent-pre and category links
3768 !! options
3769 parsoid=wt2html,wt2wt
3770 !! wikitext
3771 [[Category:foo]] <!-- No pre-wrapping -->
3772 {{echo| [[Category:foo]]}} <!-- No pre-wrapping -->
3773 !! html/php+tidy
3774 !! html/parsoid
3775 <link rel="mw:PageProp/Category" href="./Category:Foo"> <!-- No pre&#x2D;wrapping -->
3776 <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 -->
3777 !! end
3778
3779 ## We used to, but no longer wt2wt this test since the default serializer
3780 ## will normalize all categories to serialize on their own line.
3781 ## This wikitext usage is going to be fairly uncommon in production and
3782 ## selser will take care of preserving formatting in those scenarios.
3783 !! test
3784 7b. Indent-pre and category links
3785 !! options
3786 parsoid=wt2html
3787 !! wikitext
3788 [[Category:foo]] a
3789 [[Category:foo]] {{echo|b}}
3790 !! html/parsoid
3791 <pre><link rel="mw:PageProp/Category" href="./Category:Foo"> a
3792 <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>
3793 !! end
3794
3795 !! test
3796 Indent-Pre: Newlines in comments shouldn't affect sol state
3797 !! wikitext
3798 a <!--
3799 foo
3800 --> b
3801 !! html/php+tidy
3802 <p>a b
3803 </p>
3804 !! html/parsoid
3805 <p>a <!--
3806 foo
3807 --> b</p>
3808 !! end
3809
3810 ###
3811 ### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric)
3812 ###
3813
3814 !!test
3815 HTML-pre: 1. embedded newlines
3816 !! wikitext
3817 <pre>foo</pre>
3818
3819 <pre>
3820 foo
3821 </pre>
3822
3823 <pre>
3824
3825 foo
3826 </pre>
3827
3828 <pre>
3829
3830
3831 foo
3832 </pre>
3833 !! html/php+tidy
3834 <pre>foo</pre>
3835 <pre>foo
3836 </pre>
3837 <pre>
3838
3839 foo
3840 </pre>
3841 <pre>
3842
3843
3844 foo
3845 </pre>
3846 !! html/parsoid
3847 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre>
3848
3849 <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
3850 </pre>
3851
3852 <pre typeof="mw:Extension/pre" about="#mwt6" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\nfoo\n"}}'>
3853
3854 foo
3855 </pre>
3856
3857 <pre typeof="mw:Extension/pre" about="#mwt8" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\nfoo\n"}}'>
3858
3859
3860 foo
3861 </pre>
3862 !!end
3863
3864 !! test
3865 HTML-pre: big spaces
3866 !! wikitext
3867 <pre>
3868
3869
3870
3871
3872 haha
3873
3874
3875
3876
3877 haha
3878
3879
3880
3881
3882 </pre>
3883 !! html/php+tidy
3884 <pre>
3885
3886
3887
3888
3889 haha
3890
3891
3892
3893
3894 haha
3895
3896
3897
3898
3899 </pre>
3900 !! html/parsoid
3901 <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"}}'>
3902
3903
3904
3905
3906 haha
3907
3908
3909
3910
3911 haha
3912
3913
3914
3915
3916 </pre>
3917 !! end
3918
3919 !!test
3920 HTML-pre: 2: indented text
3921 !! wikitext
3922 <pre>
3923 foo
3924 </pre>
3925 !! html
3926 <pre>
3927 foo
3928 </pre>
3929
3930 !!end
3931
3932 !!test
3933 HTML-pre: 3: other wikitext
3934 !! wikitext
3935 <pre>
3936 * foo
3937 # bar
3938 = no-h =
3939 '' no-italic ''
3940 [[ NoLink ]]
3941 </pre>
3942 !! html/php
3943 <pre>
3944 * foo
3945 # bar
3946 = no-h =
3947 '' no-italic ''
3948 [[ NoLink ]]
3949 </pre>
3950
3951 !! html/parsoid
3952 <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
3953 # bar
3954 = no-h =
3955 '' no-italic ''
3956 [[ NoLink ]]
3957 </pre>
3958 !!end
3959
3960 ###
3961 ### Definition lists
3962 ###
3963 !! test
3964 Simple definition
3965 !! wikitext
3966 ;name :Definition
3967 !! html
3968 <dl><dt>name</dt>
3969 <dd>Definition</dd></dl>
3970
3971 !! end
3972
3973 !! test
3974 Definition list for indentation only
3975 !! wikitext
3976 :Indented text
3977 !! html
3978 <dl><dd>Indented text</dd></dl>
3979
3980 !! end
3981
3982 !! test
3983 Definition list with no space
3984 !! wikitext
3985 ;name:Definition
3986 !! html
3987 <dl><dt>name</dt>
3988 <dd>Definition</dd></dl>
3989
3990 !!end
3991
3992 !! test
3993 Definition list with URL link
3994 !! wikitext
3995 ;http://example.com/ :definition
3996 !! html
3997 <dl><dt><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a></dt>
3998 <dd>definition</dd></dl>
3999
4000 !! end
4001
4002 !! test
4003 Definition list with bracketed URL link
4004 !! wikitext
4005 ;[http://www.example.com/ Example]:Something about it
4006 !! html
4007 <dl><dt><a rel="nofollow" class="external text" href="http://www.example.com/">Example</a></dt>
4008 <dd>Something about it</dd></dl>
4009
4010 !! end
4011
4012 !! test
4013 Definition list with wikilink containing colon
4014 !! wikitext
4015 ;[[Help:FAQ]]:The least-read page on Wikipedia
4016 !! html
4017 <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>
4018 <dd>The least-read page on Wikipedia</dd></dl>
4019
4020 !! end
4021
4022 # At Brion's and JeLuF's insistence... :)
4023 !! test
4024 Definition list with news link containing colon
4025 !! wikitext
4026 ;news:alt.wikipedia.rox :This isn't even a real newsgroup!
4027 !! html/php
4028 <dl><dt><a rel="nofollow" class="external free" href="news:alt.wikipedia.rox">news:alt.wikipedia.rox</a></dt>
4029 <dd>This isn't even a real newsgroup!</dd></dl>
4030
4031 !! html/parsoid
4032 <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>
4033 !! end
4034
4035 !! test
4036 Malformed definition list with colon
4037 !! wikitext
4038 ;news:alt.wikipedia.rox -- don't crash or enter an infinite loop
4039 !! html
4040 <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>
4041
4042 !! end
4043
4044 !! test
4045 Definition lists: colon in external link text
4046 !! wikitext
4047 ;[http://www.wikipedia2.org/ Wikipedia :The Next Generation] :OK, I made that up
4048 !! html
4049 <dl><dt><a rel="nofollow" class="external text" href="http://www.wikipedia2.org/">Wikipedia :The Next Generation</a></dt>
4050 <dd>OK, I made that up</dd></dl>
4051
4052 !! end
4053
4054 !! test
4055 Definition lists: colon in HTML attribute
4056 !! wikitext
4057 ;<b style="display: inline">bold</b>
4058 !! html
4059 <dl><dt><b style="display: inline">bold</b></dt></dl>
4060
4061 !! end
4062
4063 !! test
4064 Definition lists: self-closed tag
4065 !! wikitext
4066 ;one<br/>two :two-line fun
4067 !! html
4068 <dl><dt>one<br />two</dt>
4069 <dd>two-line fun</dd></dl>
4070
4071 !! end
4072
4073 !! test
4074 Definition lists: ignore colons inside tags
4075 !! wikitext
4076 ;one <b>two : tag <i>fun:</i>:</b>:def
4077 !! html
4078 <dl><dt>one <b>two&#160;: tag <i>fun:</i>:</b></dt>
4079 <dd>def</dd></dl>
4080
4081 !! end
4082
4083 !! test
4084 Definition lists: excess closed tags
4085 !! wikitext
4086 ;one</b>two :bad tag fun
4087 !! html/php+tidy
4088 <dl><dt>onetwo</dt>
4089 <dd>bad tag fun</dd></dl>
4090 !! html/parsoid
4091 <dl>
4092 <dt>onetwo</dt>
4093 <dd>bad tag fun</dd>
4094 </dl>
4095 !! end
4096
4097 !! test
4098 T13748: Literal closing tags
4099 !! wikitext
4100 <dl>
4101 <dt>test 1</dt>
4102 <dd>test test test test test</dd>
4103 <dt>test 2</dt>
4104 <dd>test test test test test</dd>
4105 </dl>
4106 !! html
4107 <dl>
4108 <dt>test 1</dt>
4109 <dd>test test test test test</dd>
4110 <dt>test 2</dt>
4111 <dd>test test test test test</dd>
4112 </dl>
4113
4114 !! end
4115
4116 !! test
4117 Definition and unordered list using wiki syntax nested in unordered list using html tags.
4118 !! wikitext
4119 <ul><li>
4120 ;term :description
4121 *unordered
4122 </li></ul>
4123 !! html
4124 <ul><li>
4125 <dl><dt>term</dt>
4126 <dd>description</dd></dl>
4127 <ul><li>unordered</li></ul>
4128 </li></ul>
4129
4130 !! end
4131
4132 !! test
4133 Definition list with empty definition and following paragraph
4134 !! wikitext
4135 ;term:
4136
4137 Paragraph text
4138 !! html
4139 <dl><dt>term</dt>
4140 <dd></dd></dl>
4141 <p>Paragraph text
4142 </p>
4143 !! end
4144
4145 !! test
4146 Nested definition lists using html syntax
4147 !! wikitext
4148 <dl><dt>x</dt>
4149 <dd>a</dd>
4150 <dd>b</dd></dl>
4151 !! html
4152 <dl><dt>x</dt>
4153 <dd>a</dd>
4154 <dd>b</dd></dl>
4155
4156 !! end
4157
4158 !! test
4159 Definition Lists: No nesting: Multiple dd's
4160 !! wikitext
4161 ;x
4162 :a
4163 :b
4164 !! html
4165 <dl><dt>x</dt>
4166 <dd>a</dd>
4167 <dd>b</dd></dl>
4168
4169 !! end
4170
4171 !! test
4172 Definition Lists: Indentation: Regular
4173 !! wikitext
4174 :i1
4175 ::i2
4176 :::i3
4177 !! html
4178 <dl><dd>i1
4179 <dl><dd>i2
4180 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
4181
4182 !! end
4183
4184 !! test
4185 Definition Lists: Indentation: Missing 1st level
4186 !! wikitext
4187 ::i2
4188 :::i3
4189 !! html
4190 <dl><dd><dl><dd>i2
4191 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
4192
4193 !! end
4194
4195 !! test
4196 Definition Lists: Indentation: Multi-level indent
4197 !! wikitext
4198 :::i3
4199 !! html
4200 <dl><dd><dl><dd><dl><dd>i3</dd></dl></dd></dl></dd></dl>
4201
4202 !! end
4203
4204 !! test
4205 Definition Lists: Hacky use to indent tables
4206 !! wikitext
4207 ::{|
4208 |foo
4209 |bar
4210 |}
4211 this text
4212 should be left alone
4213 !! html
4214 <dl><dd><dl><dd><table>
4215 <tr>
4216 <td>foo
4217 </td>
4218 <td>bar
4219 </td></tr></table></dd></dl></dd></dl>
4220 <p>this text
4221 should be left alone
4222 </p>
4223 !! end
4224
4225 !! test
4226 Definition Lists: Hacky use to indent tables (with content following table)
4227 !! wikitext
4228 :{|
4229 |foo
4230 |bar
4231 |} <!--c1--> this text should be part of the dl
4232 !! html/php+tidy
4233 <dl><dd><table>
4234 <tbody><tr>
4235 <td>foo
4236 </td>
4237 <td>bar
4238 </td></tr></tbody></table> this text should be part of the dl</dd></dl>
4239 !! html/parsoid
4240 <dl><dd><table>
4241 <tbody><tr>
4242 <td>foo
4243 </td>
4244 <td>bar
4245 </td></tr></tbody></table> <!--c1--> this text should be part of the dl</dd></dl>
4246 !! end
4247
4248 !! test
4249 Definition Lists: Hacky use to indent tables, with comments (T65979)
4250 !! wikitext
4251 <!-- foo -->
4252 ::{|
4253 |foo
4254 |bar
4255 |}<!-- bar -->
4256 this text
4257 should be left alone
4258 !! html/parsoid
4259 <!-- foo -->
4260 <dl><dd><dl><dd><table><tr>
4261 <td>foo</td>
4262 <td>bar</td>
4263 </tr></table><!-- bar --></dd></dl></dd></dl>
4264 <p>this text
4265 should be left alone</p>
4266 !! end
4267
4268 !! test
4269 Definition Lists: Hacky use to indent tables, with comment before table
4270 !!options
4271 parsoid=wt2html
4272 !! wikitext
4273 ::<!-- foo -->{|
4274 |foo
4275 |}
4276 !! html/parsoid
4277 <dl><dd><dl><dd><!-- foo --><table><tr>
4278 <td>foo</td>
4279 </tr></table></dd></dl></dd></dl>
4280 !! end
4281
4282 # The trailing whitespace in this test is to catch a regression in
4283 # Parsoid after T54473.
4284 !! test
4285 Definition Lists: Hacky use to indent tables (WS-insensitive)
4286 !! wikitext
4287 :{|
4288 |a
4289 |}
4290 !! html/php
4291 <dl><dd><table>
4292 <tr>
4293 <td>a
4294 </td></tr></table></dd></dl>
4295
4296 !! html/parsoid
4297 <dl><dd><table>
4298 <tbody><tr><td>a</td></tr>
4299 </tbody></table></dd></dl>
4300 !! end
4301
4302 ## The PHP parser treats : items (dd) without a corresponding ; item (dt)
4303 ## as an empty dt item. It also ignores all but the last ";" when followed
4304 ## by ":" later on. So, ";" are not ignored in ";;;t3" but are ignored in
4305 ## ";;;t3 :d1". So, PHP parser behavior is a little inconsistent wrt multiple
4306 ## ";"s.
4307 ##
4308 ## Ex: ";;t2 ::d2" is transformed into:
4309 ##
4310 ## <dl>
4311 ## <dt>t2 </dt>
4312 ## <dd>
4313 ## <dl>
4314 ## <dt></dt>
4315 ## <dd>d2</dd>
4316 ## </dl>
4317 ## </dd>
4318 ## </dl>
4319 ##
4320 ## But, Parsoid treats "; :" as a tight atomic unit and excess ":" as plain text
4321 ## So, the same wikitext above (;;t2 ::d2) is transformed into:
4322 ##
4323 ## <dl>
4324 ## <dt>
4325 ## <dl>
4326 ## <dt>t2 </dt>
4327 ## <dd>:d2</dd>
4328 ## </dl>
4329 ## </dt>
4330 ## </dl>
4331 ##
4332 ## All Parsoid only definition list tests have this difference.
4333 ##
4334 ## See also: https://phabricator.wikimedia.org/T8569
4335 ## and https://lists.wikimedia.org/pipermail/wikitext-l/2011-November/000483.html
4336
4337 !! test
4338 Table / list interaction: indented table with lists in table contents
4339 !! wikitext
4340 :{|
4341 |-
4342 |a
4343
4344 *b
4345 |-
4346 |c
4347
4348 *d
4349 |}
4350 !! html
4351 <dl><dd><table>
4352
4353 <tr>
4354 <td>a
4355 <ul><li>b</li></ul>
4356 </td></tr>
4357 <tr>
4358 <td>c
4359 <ul><li>d</li></ul>
4360 </td></tr></table></dd></dl>
4361
4362 !! end
4363
4364 !!test
4365 Table / list interaction: lists nested in tables nested in indented lists
4366 !! wikitext
4367 :{|
4368 |
4369 :a
4370 :b
4371 |
4372 *c
4373 *d
4374 |}
4375
4376 *e
4377 *f
4378 !! html
4379 <dl><dd><table>
4380 <tr>
4381 <td>
4382 <dl><dd>a</dd>
4383 <dd>b</dd></dl>
4384 </td>
4385 <td>
4386 <ul><li>c</li>
4387 <li>d</li></ul>
4388 </td></tr></table></dd></dl>
4389 <ul><li>e</li>
4390 <li>f</li></ul>
4391
4392 !!end
4393
4394 !! test
4395 Definition Lists: Nesting: Multi-level (Parsoid only)
4396 !! wikitext
4397 ;t1 :d1
4398 ;;t2 ::d2
4399 ;;;t3 :::d3
4400 !! html/parsoid
4401 <dl>
4402 <dt>t1 </dt>
4403 <dd>d1</dd>
4404 <dt>
4405 <dl>
4406 <dt>t2 </dt>
4407 <dd>:d2</dd>
4408 <dt>
4409 <dl>
4410 <dt>t3 </dt>
4411 <dd>::d3</dd>
4412 </dl>
4413 </dt>
4414 </dl>
4415 </dt>
4416 </dl>
4417
4418
4419 !! end
4420
4421
4422 !! test
4423 Definition Lists: Nesting: Test 2
4424 !! wikitext
4425 ;t1
4426 ::d2
4427 !! html+tidy
4428 <dl><dt>t1</dt>
4429 <dd>
4430 <dl><dd>d2</dd></dl></dd></dl>
4431 !! end
4432
4433
4434 !! test
4435 Definition Lists: Nesting: Test 3
4436 !! wikitext
4437 :;t1
4438 ::::d2
4439 !! html+tidy
4440 <dl><dd><dl><dt>t1</dt>
4441 <dd>
4442 <dl><dd><dl><dd>d2</dd></dl></dd></dl></dd></dl></dd></dl>
4443 !! end
4444
4445
4446 !! test
4447 Definition Lists: Nesting: Test 4
4448 !! wikitext
4449 ::;t3
4450 :::d3
4451 !! html
4452 <dl><dd><dl><dd><dl><dt>t3</dt>
4453 <dd>d3</dd></dl></dd></dl></dd></dl>
4454
4455 !! end
4456
4457
4458 ## The Parsoid team believes the following three test exposes a
4459 ## bug in the PHP parser. (Parsoid team thinks the PHP parser is
4460 ## wrong to close the <dl> after the <dt> containing the <ul>.)
4461 ## It also exposes a "misfeature" in tidy, which doesn't like
4462 ## <dl> tags with a single <dt> child; it converts the <dt> into
4463 ## a <dd> in that case. (Parsoid leaves the <dt> alone!)
4464 !! test
4465 Definition Lists: Mixed Lists: Test 1
4466 !! wikitext
4467 :;*foo
4468 ::*bar
4469 :;baz
4470 !! html/php
4471 <dl><dd><dl><dt><ul><li>foo</li>
4472 <li>bar</li></ul></dt></dl>
4473 <dl><dt>baz</dt></dl></dd></dl>
4474
4475 !! html/php+tidy
4476 <dl><dd><dl><dt><ul><li>foo</li>
4477 <li>bar</li></ul></dt></dl>
4478 <dl><dt>baz</dt></dl></dd></dl>
4479 !! html/parsoid
4480 <dl>
4481 <dd><dl>
4482 <dt><ul>
4483 <li>foo
4484 </li>
4485 </ul></dt>
4486 <dd><ul>
4487 <li>bar
4488 </li>
4489 </ul></dd>
4490 <dt>baz</dt>
4491 </dl></dd>
4492 </dl>
4493 !! end
4494
4495 !! test
4496 Definition Lists: Mixed Lists: Test 2
4497 !! wikitext
4498 *:d1
4499 *:d2
4500 !! html
4501 <ul><li><dl><dd>d1</dd>
4502 <dd>d2</dd></dl></li></ul>
4503
4504 !! end
4505
4506
4507 !! test
4508 Definition Lists: Mixed Lists: Test 3
4509 !! wikitext
4510 *:::d1
4511 *:::d2
4512 !! html
4513 <ul><li><dl><dd><dl><dd><dl><dd>d1</dd>
4514 <dd>d2</dd></dl></dd></dl></dd></dl></li></ul>
4515
4516 !! end
4517
4518
4519 !! test
4520 Definition Lists: Mixed Lists: Test 4
4521 !! wikitext
4522 *;d1 :d2
4523 *;d3 :d4
4524 !! html
4525 <ul><li><dl><dt>d1</dt>
4526 <dd>d2</dd>
4527 <dt>d3</dt>
4528 <dd>d4</dd></dl></li></ul>
4529
4530 !! end
4531
4532
4533 !! test
4534 Definition Lists: Mixed Lists: Test 5
4535 !! wikitext
4536 *:d1
4537 *::d2
4538 !! html
4539 <ul><li><dl><dd>d1
4540 <dl><dd>d2</dd></dl></dd></dl></li></ul>
4541
4542 !! end
4543
4544
4545 !! test
4546 Definition Lists: Mixed Lists: Test 6
4547 !! wikitext
4548 #*:d1
4549 #*:::d3
4550 !! html
4551 <ol><li><ul><li><dl><dd>d1
4552 <dl><dd><dl><dd>d3</dd></dl></dd></dl></dd></dl></li></ul></li></ol>
4553
4554 !! end
4555
4556
4557 !! test
4558 Definition Lists: Mixed Lists: Test 7
4559 !! wikitext
4560 :*d1
4561 :*d2
4562 !! html
4563 <dl><dd><ul><li>d1</li>
4564 <li>d2</li></ul></dd></dl>
4565
4566 !! end
4567
4568
4569 !! test
4570 Definition Lists: Mixed Lists: Test 8
4571 !! wikitext
4572 :*d1
4573 ::*d2
4574 !! html
4575 <dl><dd><ul><li>d1</li></ul>
4576 <dl><dd><ul><li>d2</li></ul></dd></dl></dd></dl>
4577
4578 !! end
4579
4580
4581 !! test
4582 Definition Lists: Mixed Lists: Test 9
4583 !! wikitext
4584 *;foo :bar
4585 !! html
4586 <ul><li><dl><dt>foo</dt>
4587 <dd>bar</dd></dl></li></ul>
4588
4589 !! end
4590
4591
4592 !! test
4593 Definition Lists: Mixed Lists: Test 10
4594 !! wikitext
4595 *#;foo :bar
4596 !! html
4597 <ul><li><ol><li><dl><dt>foo</dt>
4598 <dd>bar</dd></dl></li></ol></li></ul>
4599
4600 !! end
4601
4602 # The Parsoid team disagrees with the PHP parser's seemingly-random
4603 # rules regarding dd/dt on the next few tests. Parsoid is more
4604 # consistent, and recognizes the shared nesting and keeps the
4605 # still-open tags around until the nesting is complete.
4606
4607 # This is a regression test for T175099
4608 !! test
4609 Definition Lists: Mixed Lists: Test 11
4610 !! wikitext
4611 ;a
4612 :*b
4613 !! html/php
4614 <dl><dt>a</dt>
4615 <dd>
4616 <ul><li>b</li></ul></dd></dl>
4617
4618 !! html/parsoid
4619 <dl><dt>a
4620 <dd><ul><li>b</li></ul></dd></dl>
4621 !! end
4622
4623 # FIXME: Maybe get rid of this test?
4624 !! test
4625 Definition Lists: Mixed Lists: Test 12
4626 !! wikitext
4627 *#*#;*;;foo :bar
4628 *#*#;boo :baz
4629 !! html/php
4630 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo</dt>
4631 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dd></dl></li></ul></dd></dl>
4632 <dl><dt>boo</dt>
4633 <dd>baz</dd></dl></li></ol></li></ul></li></ol></li></ul>
4634
4635 !! html/php+tidy
4636 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo</dt>
4637 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dt></dl></li></ul></dd></dl></li></ol></li></ul>
4638 <dl><dt>boo</dt>
4639 <dd>baz</dd></dl></li></ol></li></ul>
4640 !! html/parsoid
4641 <ul>
4642 <li>
4643 <ol>
4644 <li>
4645 <ul>
4646 <li>
4647 <ol>
4648 <li>
4649 <dl>
4650 <dt>
4651 <ul>
4652 <li>
4653 <dl>
4654 <dt>
4655 <dl>
4656 <dt>foo</dt>
4657 <dd data-parsoid='{"stx":"row"}'>bar</dd>
4658 </dl></dt>
4659 </dl></li>
4660 </ul></dt>
4661 <dt>boo</dt>
4662 <dd data-parsoid='{"stx":"row"}'>baz</dd>
4663 </dl></li>
4664 </ol></li>
4665 </ul></li>
4666 </ol></li>
4667 </ul>
4668 !! end
4669
4670 !! test
4671 Definition Lists: Mixed Lists: Test 13
4672 !! wikitext
4673 *#*#;*;;foo : bar
4674 *#*#;boo : baz
4675 !! html+tidy
4676 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</dt>
4677 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dt></dl></li></ul></dd></dl></li></ol></li></ul>
4678 <dl><dt>boo&#160;</dt>
4679 <dd>baz</dd></dl></li></ol></li></ul>
4680 !! end
4681
4682 # FIXME: Maybe get rid of this test?
4683 # From whitelist:
4684 # * The test is wrong, there are two colons where there should be :;
4685 # * The PHP parser is wrong to close the <dl> after the <dt> containing the <ul>.
4686 !! test
4687 Definition Lists: Weird Ones: Test 1
4688 !! wikitext
4689 *#;*::;;foo :bar (who uses this?)
4690 !! html/php+tidy
4691 <ul><li><ol><li><dl><dt>foo</dt>
4692 <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>
4693 !! html/parsoid
4694 <ul>
4695 <li>
4696 <ol>
4697 <li>
4698 <dl>
4699 <dt>
4700 <ul>
4701 <li>
4702 <dl>
4703 <dd>
4704 <dl>
4705 <dd>
4706 <dl>
4707 <dt>
4708 <dl>
4709 <dt>foo</dt>
4710 <dd data-parsoid='{"stx":"row"}'>bar (who uses this?)</dd>
4711 </dl></dt>
4712 </dl></dd>
4713 </dl></dd>
4714 </dl></li>
4715 </ul></dt>
4716 </dl></li>
4717 </ol></li>
4718 </ul>
4719 !! end
4720
4721 !! test
4722 Definition Lists: colons occurring in tags
4723 !! wikitext
4724 ;a:b
4725 ;'''a:b'''
4726 ;<i>a:b</i>
4727 ;<span>a:b</span>
4728 ;<div>a:b</div>
4729 ;<div>a
4730 :b</div>
4731 ;{{echo|a:b}}
4732 ;{{echo|''a:b''}}
4733 ;;;''a:b''
4734 !! html+tidy
4735 <dl><dt>a</dt>
4736 <dd>b</dd>
4737 <dt><b>a:b</b></dt>
4738 <dt><i>a:b</i></dt>
4739 <dt><span>a:b</span></dt>
4740 <dt><div>a:b</div></dt>
4741 <dt><div>a</div></dt>
4742 <dd>b</dd>
4743 <dt>a</dt>
4744 <dd>b</dd>
4745 <dt><i>a:b</i></dt></dl>
4746 <dl><dt><dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4747 !! html/parsoid
4748 <dl><dt>a</dt><dd data-parsoid='{"stx":"row"}'>b</dd>
4749 <dt><b>a:b</b></dt>
4750 <dt><i data-parsoid='{"stx":"html"}'>a:b</i></dt>
4751 <dt><span data-parsoid='{"stx":"html"}'>a:b</span></dt>
4752 <dt><div data-parsoid='{"stx":"html"}'>a:b</div></dt>
4753 <dt><div data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</div></dt>
4754 <dd>b</dd>
4755 <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>
4756 <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>
4757 <dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4758 !! end
4759
4760 # Parsoid's output differs here again because it shares
4761 # nesting between the two lists unlike the PHP parser.
4762 # Unsure which is more desirable.
4763 !! test
4764 Definition Lists: colons and tables 1
4765 !! wikitext
4766 :{|
4767 |x
4768 |}
4769 :{|
4770 |y
4771 |}
4772 !! html/php
4773 <dl><dd><table>
4774 <tr>
4775 <td>x
4776 </td></tr></table></dd></dl>
4777 <dl><dd><table>
4778 <tr>
4779 <td>y
4780 </td></tr></table></dd></dl>
4781
4782 !! html/parsoid
4783 <dl><dd><table>
4784 <tr>
4785 <td>x
4786 </td></tr></table></dd>
4787 <dd><table>
4788 <tr>
4789 <td>y
4790 </td></tr></table></dd></dl>
4791 !! end
4792
4793 # FIXME: Does this need a html/php section?
4794 !! test
4795 Definition Lists: template interaction
4796 !! wikitext
4797 ::{{definition_list}}
4798
4799 :one
4800 ::{{definition_list}}
4801 :::two
4802 :::three
4803 ::four
4804 !! html/parsoid
4805 <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">
4806 </span><dd about="#mwt1">two</dd></dl></dd></dl>
4807
4808 <dl><dd data-parsoid='{}'>one
4809 <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">
4810 </span><dd about="#mwt2">two
4811 <dl><dd>two</dd>
4812 <dd>three</dd></dl></dd>
4813 <dd data-parsoid='{}'>four</dd></dl></dd></dl>
4814 !! end
4815
4816
4817 ###
4818 ### External links
4819 ###
4820 !! test
4821 External links: non-bracketed
4822 !! wikitext
4823 Non-bracketed: http://example.com
4824 !! html
4825 <p>Non-bracketed: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4826 </p>
4827 !! end
4828
4829 # parsoid doesn't explicitly mark autonumbered links, see T55505
4830 !! test
4831 External links: numbered
4832 !! wikitext
4833 Numbered: [http://example.com]
4834 Numbered: [http://example.net]
4835 Numbered: [http://example.com]
4836 !! html/php
4837 <p>Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>
4838 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.net">[2]</a>
4839 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[3]</a>
4840 </p>
4841 !! html/parsoid
4842 <p>Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>
4843 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.net"></a>
4844 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a></p>
4845 !!end
4846
4847 !! test
4848 External links: specified text
4849 !! wikitext
4850 Specified text: [http://example.com link]
4851 !! html
4852 <p>Specified text: <a rel="nofollow" class="external text" href="http://example.com">link</a>
4853 </p>
4854 !!end
4855
4856 !! test
4857 External links: trail
4858 !! wikitext
4859 Linktrails should not work for external links: [http://example.com link]s
4860 !! html
4861 <p>Linktrails should not work for external links: <a rel="nofollow" class="external text" href="http://example.com">link</a>s
4862 </p>
4863 !! end
4864
4865 !! test
4866 External links: dollar sign in URL
4867 !! wikitext
4868 http://example.com/1$2345
4869 !! html
4870 <p><a rel="nofollow" class="external free" href="http://example.com/1$2345">http://example.com/1$2345</a>
4871 </p>
4872 !! end
4873
4874 # parsoid doesn't explicitly mark autonumbered links, see T55505
4875 !! test
4876 External links: dollar sign in URL (autonumber)
4877 !! wikitext
4878 [http://example.com/1$2345]
4879 !! html/php
4880 <p><a rel="nofollow" class="external autonumber" href="http://example.com/1$2345">[1]</a>
4881 </p>
4882 !! html/parsoid
4883 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/1$2345"></a></p>
4884 !!end
4885
4886 !! test
4887 External links: open square bracket forbidden in URL (T6377)
4888 !! options
4889 parsoid=wt2html,wt2wt,html2html
4890 !! wikitext
4891 http://example.com/1[2345
4892 !! html/php
4893 <p><a rel="nofollow" class="external free" href="http://example.com/1">http://example.com/1</a>[2345
4894 </p>
4895 !! html/parsoid
4896 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/1">http://example.com/1</a>[2345</p>
4897 !! end
4898
4899 !! test
4900 External links: open square bracket forbidden in URL (named) (T6377)
4901 !! options
4902 parsoid=wt2html,html2html
4903 !! wikitext
4904 [http://example.com/1[2345]
4905 !! html/php
4906 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4907 </p>
4908 !! html/parsoid
4909 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/1">[2345</a></p>
4910 !!end
4911
4912 # parsoid adds a space before the link name
4913 !! test
4914 External links: open square bracket forbidden in URL (named) (T6377)
4915 Parsoid variant.
4916 !! wikitext
4917 [http://example.com/1 [2345]
4918 !! html
4919 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4920 </p>
4921 !!end
4922
4923 !! test
4924 External links: nowiki in URL link text (T8230)
4925 !! wikitext
4926 [http://example.com/ <nowiki>''example site''</nowiki>]
4927 !! html
4928 <p><a rel="nofollow" class="external text" href="http://example.com/">''example site''</a>
4929 </p>
4930 !! end
4931
4932 !! test
4933 External links: newline forbidden in text (T8230 regression check)
4934 !! wikitext
4935 [http://example.com/ first
4936 second]
4937 !! html
4938 <p>[<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a> first
4939 second]
4940 </p>
4941 !!end
4942
4943 !! test
4944 External links: Pipe char between url and text
4945 !! wikitext
4946 [http://example.com | link]
4947 !! html
4948 <p><a rel="nofollow" class="external text" href="http://example.com">| link</a>
4949 </p>
4950 !!end
4951
4952 !! test
4953 External links: protocol-relative URL in brackets
4954 !! wikitext
4955 [//example.com/ Test]
4956 !! html
4957 <p><a rel="nofollow" class="external text" href="//example.com/">Test</a>
4958 </p>
4959 !! end
4960
4961 # parsoid doesn't explicitly mark autonumbered links, see T55505
4962 !! test
4963 External links: protocol-relative URL in brackets without text
4964 !! wikitext
4965 [//example.com]
4966 !! html/php
4967 <p><a rel="nofollow" class="external autonumber" href="//example.com">[1]</a>
4968 </p>
4969 !! html/parsoid
4970 <p><a rel="mw:ExtLink" class="external autonumber" href="//example.com"></a></p>
4971 !! end
4972
4973 !! test
4974 External links: protocol-relative URL in free text is left alone
4975 !! wikitext
4976 //example.com/Foo
4977 !! html
4978 <p>//example.com/Foo
4979 </p>
4980 !!end
4981
4982 !! test
4983 External links: protocol-relative URL in the middle of a word is left alone (T32269)
4984 !! wikitext
4985 foo//example.com/Foo
4986 !! html
4987 <p>foo//example.com/Foo
4988 </p>
4989 !! end
4990
4991 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
4992 !! test
4993 External links: with no contents
4994 !! options
4995 parsoid=wt2html,wt2wt
4996 !! wikitext
4997 [http://en.wikipedia.org/wiki/Foo]
4998
4999 [[wikipedia:Foo|Bar]]
5000
5001 [[wikipedia:Foo|<span>Bar</span>]]
5002 !! html/php
5003 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo">[1]</a>
5004 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
5005 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo"><span>Bar</span></a>
5006 </p>
5007 !! html/parsoid
5008 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo"></a></p>
5009 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo">Bar</a></p>
5010 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo"><span>Bar</span></a></p>
5011 !! end
5012
5013 !! test
5014 External links: Free with trailing punctuation
5015 !! wikitext
5016 http://example.com,
5017 http://example.com;
5018 http://example.com\
5019 http://example.com.
5020 http://example.com:
5021 http://example.com!
5022 http://example.com?
5023 http://example.com)
5024 http://example.com/url_with_(brackets)
5025 (http://example.com/url_without_brackets)
5026 http://example.com/url_with_entity&amp;
5027 http://example.com/url_with_entity&#x26;
5028 http://example.com/url_with_entity&#038;
5029 http://example.com/url_with_entity&nbsp;
5030 http://example.com/url_with_entity&#xA0;
5031 http://example.com/url_with_entity&#160;
5032 http://example.com/url_with_entity&lt;
5033 http://example.com/url_with_entity&#x3C;
5034 http://example.com/url_with_entity&#60;
5035 !! html/php
5036 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
5037 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>;
5038 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>\
5039 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.
5040 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
5041 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>!
5042 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>?
5043 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
5044 <a rel="nofollow" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
5045 (<a rel="nofollow" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
5046 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5047 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5048 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5049 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
5050 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#xa0;
5051 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
5052 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&lt;
5053 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#x3c;
5054 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#60;
5055 </p>
5056 !! html/parsoid
5057 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>,
5058 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>;
5059 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>\
5060 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>.
5061 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>:
5062 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>!
5063 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>?
5064 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>)
5065 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
5066 (<a rel="mw:ExtLink" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
5067 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5068 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5069 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5070 <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>
5071 <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>
5072 <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>
5073 <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>
5074 <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>
5075 <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>
5076 !! end
5077
5078 !! test
5079 External links: tricky Parsoid html2html case
5080 !! options
5081 parsoid=wt2html,wt2wt,html2html
5082 !! wikitext
5083 http://example.com/url_with_entity&amp;amp;
5084 !! html/php
5085 <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>;
5086 </p>
5087 !! html/parsoid
5088 <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>
5089 !! end
5090
5091 !! test
5092 External links: Free with trailing quotes (T113666)
5093 !! wikitext
5094 '''News:''' Stuff here
5095
5096 news:'a'b''c''d e
5097 !! html/php
5098 <p><b>News:</b> Stuff here
5099 </p><p><a rel="nofollow" class="external free" href="news:&#39;a&#39;b">news:'a'b</a><i>c</i>d e
5100 </p>
5101 !! html/parsoid
5102 <p><b>News:</b> Stuff here</p>
5103 <p><a rel="mw:ExtLink" class="external free" href="news:'a'b">news:'a'b</a><i>c</i>d e</p>
5104 !! end
5105
5106 !! test
5107 External links: with entity
5108 !! wikitext
5109 [http://&#x20;www.librarieswithoutborders.org Libraries without borders]
5110 !! html/php
5111 <p><a rel="nofollow" class="external text" href="http://+www.librarieswithoutborders.org">Libraries without borders</a>
5112 </p>
5113 !! html/parsoid
5114 <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>
5115 !! end
5116
5117 !! test
5118 External links: Lone protocols are never linked (T105697)
5119 !! wikitext
5120 http://
5121 http://;
5122 (http://)
5123 bitcoin:
5124 bitcoin:;
5125 (bitcoin:)
5126 !! html
5127 <p>http://
5128 http://;
5129 (http://)
5130 bitcoin:
5131 bitcoin:;
5132 (bitcoin:)
5133 </p>
5134 !! end
5135
5136 !! test
5137 External links: No preceding word characters allowed (T67278)
5138 !! wikitext
5139 NOPEhttp://example.com
5140 N0http://example.com
5141 ok:http://example.com
5142 ok-http://example.com
5143 !! html
5144 <p>NOPEhttp://example.com
5145 N0http://example.com
5146 ok:<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5147 ok-<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5148 </p>
5149 !! end
5150
5151 !! test
5152 External links: nofollow domain exception
5153 !! wikitext
5154 A [https://no-nofollow.org/foobar link], and another [https://example.org link].
5155 !! html
5156 <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>.
5157 </p>
5158 !!end
5159
5160 !! test
5161 External image
5162 !! wikitext
5163 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5164 !! html
5165 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
5166 </p>
5167 !! end
5168
5169 !! test
5170 External image from https
5171 !! wikitext
5172 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5173 !! html
5174 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
5175 </p>
5176 !! end
5177
5178 !! test
5179 External image (when not allowed)
5180 !! options
5181 wgAllowExternalImages=0
5182 !! wikitext
5183 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5184 !! html
5185 <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>
5186 </p>
5187 !! end
5188
5189 !! test
5190 Link to non-http image, no img tag
5191 !! wikitext
5192 Link to non-http image, no img tag: ftp://example.com/test.jpg
5193 !! html
5194 <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>
5195 </p>
5196 !! end
5197
5198 !! test
5199 External links: terminating separator
5200 !! wikitext
5201 Terminating separator: http://example.com/thing,
5202 !! html
5203 <p>Terminating separator: <a rel="nofollow" class="external free" href="http://example.com/thing">http://example.com/thing</a>,
5204 </p>
5205 !! end
5206
5207 !! test
5208 External links: intervening separator
5209 !! wikitext
5210 Intervening separator: http://example.com/1,2,3
5211 !! html
5212 <p>Intervening separator: <a rel="nofollow" class="external free" href="http://example.com/1,2,3">http://example.com/1,2,3</a>
5213 </p>
5214 !! end
5215
5216 !! test
5217 External links: old bug with URL in query
5218 !! wikitext
5219 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
5220 !! html
5221 <p>Old bug with URL in query: <a rel="nofollow" class="external text" href="http://example.com/thing?url=http://example.com">link</a>
5222 </p>
5223 !! end
5224
5225 !! test
5226 External links: old URL-in-URL bug, mixed protocols
5227 !! wikitext
5228 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
5229 !! html
5230 <p>And again with mixed protocols: <a rel="nofollow" class="external text" href="ftp://example.com?url=http://example.com">link</a>
5231 </p>
5232 !!end
5233
5234 # Since Parsoid is starting to emit canonical wikitext for links,
5235 # [http://example.com http://example.com] will not RT back to that
5236 # form anymore.
5237 !! test
5238 External links: URL in text
5239 !! options
5240 parsoid=wt2html
5241 !! wikitext
5242 URL in text: [http://example.com http://example.com]
5243 !! html/php
5244 <p>URL in text: <a rel="nofollow" class="external text" href="http://example.com">http://example.com</a>
5245 </p>
5246 !! html/parsoid
5247 <p>URL in text: <a rel="mw:ExtLink" class="external text" href="http://example.com">http://example.com</a></p>
5248 !! end
5249
5250 !! test
5251 External links: Clickable images
5252 !! wikitext
5253 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
5254 !! html/php
5255 <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>
5256 </p>
5257 !! html/parsoid
5258 <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>
5259 !! end
5260
5261 !! test
5262 External links: raw ampersand
5263 !! wikitext
5264 Old &amp; use: http://x&y
5265 !! html
5266 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5267 </p>
5268 !! end
5269
5270 !! test
5271 External links: encoded ampersand
5272 !! wikitext
5273 Old &amp; use: http://x&amp;y
5274 !! html/php
5275 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5276 </p>
5277 !! html/parsoid
5278 <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>
5279 !! end
5280
5281 !! test
5282 External links: encoded equals (T8102)
5283 !! wikitext
5284 http://example.com/?foo&#61;bar
5285 !! html/php
5286 <p><a rel="nofollow" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a>
5287 </p>
5288 !! html/parsoid
5289 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a></p>
5290 !! end
5291
5292 ##
5293 ## Note that parsoid doesn't explicit mark autonumbered links, nor
5294 ## does it number them. As discussed in T55505, we can identify
5295 ## autonumbered links via CSS.
5296 ##
5297
5298 !! test
5299 External links: [raw ampersand]
5300 !! wikitext
5301 Old &amp; use: [http://x&y]
5302 !! html/php
5303 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5304 </p>
5305 !! html/parsoid
5306 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&amp;y"></a></p>
5307 !! end
5308
5309 # note that parsoid html is identical to [raw ampersand] case; so html2wt
5310 # mode will return the [raw ampersand] wikitext
5311 !! test
5312 External links: [encoded ampersand]
5313 !! options
5314 parsoid=wt2html,wt2wt,html2html
5315 !! wikitext
5316 Old &amp; use: [http://x&amp;y]
5317 !! html/php
5318 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5319 </p>
5320 !! html/parsoid
5321 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&amp;y"></a></p>
5322 !! end
5323
5324 !! test
5325 External links: [raw equals]
5326 !! wikitext
5327 [http://example.com/?foo=bar]
5328 !! html/php
5329 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5330 </p>
5331 !! html/parsoid
5332 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/?foo=bar"></a></p>
5333 !! end
5334
5335 # note that parsoid html is identical to [raw equals] case; so html2wt
5336 # mode will return the [raw equals] wikitext
5337 !! test
5338 External links: [encoded equals] (T8102)
5339 !! options
5340 parsoid=wt2html,wt2wt,html2html
5341 !! wikitext
5342 [http://example.com/?foo&#61;bar]
5343 !! html/php
5344 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5345 </p>
5346 !! html/parsoid
5347 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/?foo=bar"></a></p>
5348 !! end
5349
5350 # xxx parsoid strips the IDN character, so the round-trip tests will
5351 # obviously fail and are disabled. --cscott
5352 !! test
5353 External links: [IDN ignored character reference in hostname; strip it right off]
5354 !! options
5355 parsoid=wt2html,wt2wt,html2html
5356 !! wikitext
5357 [http://e&zwnj;xample.com/]
5358 !! html/php
5359 <p><a rel="nofollow" class="external autonumber" href="http://example.com/">[1]</a>
5360 </p>
5361 !! html/parsoid
5362 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/"></a></p>
5363 !! end
5364
5365 # FIXME: This test (the IDN characters in the text of a link) is an inconsistency.
5366 # Where an external link could easily circumvent the sanitization of the text of
5367 # a link like this (where an IDN-ignore character is in the URL somewhere), this
5368 # test demands a higher standard. That's a bit strange.
5369 #
5370 # Example:
5371 #
5372 # http://e‌xample.com -> [http://example.com|http://example.com]
5373 # [http://example.com|http://e‌xample.com] -> [http://example.com|http://e‌xample.com]
5374 #
5375 # The first example is sanitized, but the second is not. Any security benefits
5376 # from this production are trivial to circumvent. Either remove this test and
5377 # let the parser(s) do their thing unaccosted, or fix the inconsistency and change
5378 # the test accordingly.
5379 #
5380 # All our love,
5381 # The Parsoid team.
5382 # xxx parsoid strips the IDN character, so the round-trip tests will
5383 # obviously fail and are disabled. --cscott
5384 !! test
5385 External links: IDN ignored character reference in hostname; strip it right off
5386 !! options
5387 parsoid=wt2html,html2html
5388 !! wikitext
5389 http://e&zwnj;xample.com/
5390 !! html/php
5391 <p><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>
5392 </p>
5393 !! html/parsoid
5394 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/">http://example.com/</a></p>
5395 !! end
5396
5397 !! test
5398 External links: www.jpeg.org (T2554)
5399 !! wikitext
5400 http://www.jpeg.org
5401 !! html
5402 <p><a rel="nofollow" class="external free" href="http://www.jpeg.org">http://www.jpeg.org</a>
5403 </p>
5404 !! end
5405
5406 # parsoid doesn't explicitly mark autonumbered links, see T55505
5407 !! test
5408 External links: URL within URL (T2002)
5409 !! wikitext
5410 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
5411 !! html/php
5412 <p><a rel="nofollow" class="external autonumber" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp">[1]</a>
5413 </p>
5414 !! html/parsoid
5415 <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>
5416 !! end
5417
5418 !! test
5419 T2361: URL inside bracketed URL
5420 !! wikitext
5421 [http://www.example.com/foo http://www.example.com/bar]
5422 !! html
5423 <p><a rel="nofollow" class="external text" href="http://www.example.com/foo">http://www.example.com/bar</a>
5424 </p>
5425 !! end
5426
5427 !! test
5428 T2361: URL within URL, not bracketed
5429 !! wikitext
5430 http://www.example.com/foo?=http://www.example.com/bar
5431 !! html
5432 <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>
5433 </p>
5434 !! end
5435
5436 !! test
5437 T2289: ">"-token in URL-tail
5438 !! wikitext
5439 http://www.example.com/<hello>
5440 !! html
5441 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>&lt;hello&gt;
5442 </p>
5443 !!end
5444
5445 !! test
5446 T2289: literal ">"-token in URL-tail
5447 !! wikitext
5448 http://www.example.com/<b>html</b>
5449 !! html/php
5450 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a><b>html</b>
5451 </p>
5452 !! html/parsoid
5453 <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>
5454 !! end
5455
5456 !! test
5457 T2289: ">"-token in bracketed URL
5458 !! wikitext
5459 [http://www.example.com/<hello> stuff]
5460 !! html
5461 <p><a rel="nofollow" class="external text" href="http://www.example.com/">&lt;hello&gt; stuff</a>
5462 </p>
5463 !!end
5464
5465 !! test
5466 T2289: literal ">"-token in bracketed URL
5467 !! wikitext
5468 [http://www.example.com/<b>html</b> stuff]
5469 !! html
5470 <p><a rel="nofollow" class="external text" href="http://www.example.com/"><b>html</b> stuff</a>
5471 </p>
5472 !!end
5473
5474 !! test
5475 T2289: literal double quote at end of URL
5476 !! wikitext
5477 http://www.example.com/"hello"
5478 !! html
5479 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>"hello"
5480 </p>
5481 !!end
5482
5483 !! test
5484 T2289: literal double quote in bracketed URL
5485 !! wikitext
5486 [http://www.example.com/"hello" stuff]
5487 !! html
5488 <p><a rel="nofollow" class="external text" href="http://www.example.com/">"hello" stuff</a>
5489 </p>
5490 !!end
5491
5492 !! test
5493 External links: multiple legal whitespace is fine, Magnus. Don't break it please. (T7081)
5494 !! wikitext
5495 [http://www.example.com test]
5496 !! html
5497 <p><a rel="nofollow" class="external text" href="http://www.example.com">test</a>
5498 </p>
5499 !! end
5500
5501 !! test
5502 External links: link text with spaces
5503 !! wikitext
5504 [http://www.example.com a b c]
5505 [http://www.example.com ''a'' ''b'']
5506 !! html
5507 <p><a rel="nofollow" class="external text" href="http://www.example.com">a b c</a>
5508 <a rel="nofollow" class="external text" href="http://www.example.com"><i>a</i> <i>b</i></a>
5509 </p>
5510 !! end
5511
5512 # Note edge case difference between PHP and Parsoid here.
5513 !! test
5514 External links: wiki links within external link (T5695)
5515 !! options
5516 parsoid=wt2html,html2html
5517 !! wikitext
5518 [http://example.com [[wikilink]] embedded in ext link]
5519
5520 [http://example.com test [[wikilink]] embedded in ext link]
5521 !! html/php
5522 <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>
5523 </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>
5524 </p>
5525 !! html/parsoid
5526 <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>
5527 <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>
5528 !! end
5529
5530 !! test
5531 T2787: Links with one slash after the url protocol are invalid
5532 !! wikitext
5533 http:/example.com
5534
5535 [http:/example.com title]
5536 !! html
5537 <p>http:/example.com
5538 </p><p>[http:/example.com title]
5539 </p>
5540 !! end
5541
5542 !! test
5543 Bracketed external links with template-generated invalid target
5544 !! wikitext
5545 [{{echo|http:/example.com}} title]
5546 !! html
5547 <p>[http:/example.com title]
5548 </p>
5549 !! end
5550
5551 # wt2html only because Parsoid would want to add <nowiki>s coming from html
5552 !! test
5553 Broken wikilinks (but not external links) prevent templates from closing
5554 !! options
5555 parsoid=wt2html
5556 !! wikitext
5557 [http://example.com x
5558
5559 {{echo|[http://example.com x}}
5560
5561 [[Foo
5562
5563 {{echo|[[Foo}}
5564 !! html/php
5565 <p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5566 </p><p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5567 </p><p>[[Foo
5568 </p><p>{{echo|[[Foo}}
5569 </p>
5570 !! html/parsoid
5571 <p>[<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a> x</p>
5572 <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>
5573 <p>[[Foo</p>
5574 <p>{{echo|[[Foo}}</p>
5575 !! end
5576
5577 !! test
5578 Wikilinks with embedded newlines are not broken
5579 !! wikitext
5580 {{echo|[[ Foo
5581 B
5582 C]]}}
5583 !! html/php
5584 <p>[[ Foo
5585 B
5586 C]]
5587 </p>
5588 !! html/parsoid
5589 <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>
5590 !! end
5591
5592 !! test
5593 Broken templates
5594 !! options
5595 parsoid=wt2html
5596 !! wikitext
5597 {{echo|[[Foo|}}]]
5598
5599 [[Foo|{{echo|]]}}
5600 !! html/php
5601 <p>{{echo|<a href="/wiki/Foo" title="Foo">}}</a>
5602 </p><p>[[Foo|]]
5603 </p>
5604 !! html/parsoid
5605 <p>{{echo|<a rel="mw:WikiLink" href="./Foo" title="Foo">}}</a></p>
5606 <p>[[Foo|<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"]]"}},"i":0}}]}'>]]</span></p>
5607 !! end
5608
5609 !! test
5610 T4702: Mismatched <i>, <b> and <a> tags are invalid
5611 !! wikitext
5612 ''[http://example.com text'']
5613 [http://example.com '''text]'''
5614 ''Something [http://example.com in italic'']
5615 ''Something [http://example.com mixed''''', even bold]'''
5616 '''''Now [http://example.com both''''']
5617 !! html
5618 <p><a rel="nofollow" class="external text" href="http://example.com"><i>text</i></a>
5619 <a rel="nofollow" class="external text" href="http://example.com"><b>text</b></a>
5620 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>in italic</i></a>
5621 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>mixed</i><b>, even bold</b></a>
5622 <i><b>Now </b></i><a rel="nofollow" class="external text" href="http://example.com"><i><b>both</b></i></a>
5623 </p>
5624 !! end
5625
5626
5627 !! test
5628 T6781: %26 in URL
5629 !! wikitext
5630 http://www.example.com/?title=AT%26T
5631 !! html/php
5632 <p><a rel="nofollow" class="external free" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a>
5633 </p>
5634 !! html/parsoid
5635 <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>
5636 !! end
5637
5638 # According to https://www.w3.org/TR/2011/WD-html5-20110525/Overview.html#parsing-urls a plain
5639 # % is actually legal in HTML5. Any change in output would need testing though.
5640 !! test
5641 T6781, T7267: %25 in URL
5642 !! wikitext
5643 http://www.example.com/?title=100%25_Bran
5644 !! html/php
5645 <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>
5646 </p>
5647 !! html/parsoid
5648 <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>
5649 !! end
5650
5651 !! test
5652 T6781, T7267: %28, %29 in URL
5653 !! wikitext
5654 http://www.example.com/?title=Ben-Hur_%281959_film%29
5655 !! html/php
5656 <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>
5657 </p>
5658 !! html/parsoid
5659 <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>
5660 !! end
5661
5662
5663 !! test
5664 T6781: %26 in autonumber URL
5665 !! wikitext
5666 [http://www.example.com/?title=AT%26T]
5667 !! html/php
5668 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=AT%26T">[1]</a>
5669 </p>
5670 !! html/parsoid
5671 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=AT%26T"></a></p>
5672 !! end
5673
5674 !! test
5675 T6781, T7267: %26 in autonumber URL
5676 !! wikitext
5677 [http://www.example.com/?title=100%25_Bran]
5678 !! html/php
5679 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=100%25_Bran">[1]</a>
5680 </p>
5681 !! html/parsoid
5682 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=100%25_Bran"></a></p>
5683 !! end
5684
5685 !! test
5686 T6781, T7267: %28, %29 in autonumber URL
5687 !! wikitext
5688 [http://www.example.com/?title=Ben-Hur_%281959_film%29]
5689 !! html/php
5690 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">[1]</a>
5691 </p>
5692 !! html/parsoid
5693 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29"></a></p>
5694 !! end
5695
5696
5697 !! test
5698 T6781: %26 in bracketed URL
5699 !! wikitext
5700 [http://www.example.com/?title=AT%26T link]
5701 !! html/php
5702 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=AT%26T">link</a>
5703 </p>
5704 !! html/parsoid
5705 <p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=AT%26T">link</a></p>
5706 !! end
5707
5708 !! test
5709 T6781, T7267: %25 in bracketed URL
5710 !! wikitext
5711 [http://www.example.com/?title=100%25_Bran link]
5712 !! html
5713 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=100%25_Bran">link</a>
5714 </p>
5715 !! end
5716
5717 !! test
5718 T6781, T7267: %28, %29 in bracketed URL
5719 !! wikitext
5720 [http://www.example.com/?title=Ben-Hur_%281959_film%29 link]
5721 !! html/php
5722 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a>
5723 </p>
5724 !! html/parsoid
5725 <p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a></p>
5726 !! end
5727
5728 !! test
5729 External link containing a period in the anchor. (T65947)
5730 !! wikitext
5731 [//foo.org/bar#baz. bang]
5732
5733 [//foo.org/bar. bang]
5734 !! html/php
5735 <p><a rel="nofollow" class="external text" href="//foo.org/bar#baz.">bang</a>
5736 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar.">bang</a>
5737 </p>
5738 !! html/parsoid
5739 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar#baz.">bang</a></p>
5740 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar.">bang</a></p>
5741 !! end
5742
5743 !! test
5744 External link containing a single quote. (T65947)
5745 !! wikitext
5746 [//foo.org/bar'baz]
5747
5748 [//foo.org/bar'baz bang]
5749 !! html/php
5750 <p><a rel="nofollow" class="external autonumber" href="//foo.org/bar&#39;baz">[1]</a>
5751 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar&#39;baz">bang</a>
5752 </p>
5753 !! html/parsoid
5754 <p><a rel="mw:ExtLink" class="external autonumber" href="//foo.org/bar'baz"></a></p>
5755 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar'baz">bang</a></p>
5756 !! end
5757
5758 !! test
5759 External link containing double-single-quotes in text '' (T6598 sanity check)
5760 !! wikitext
5761 Some [http://example.com/ pretty ''italics'' and stuff]!
5762 !! html
5763 <p>Some <a rel="nofollow" class="external text" href="http://example.com/">pretty <i>italics</i> and stuff</a>!
5764 </p>
5765 !! end
5766
5767 !! test
5768 External link containing double-single-quotes in text embedded in italics (T6598 sanity check)
5769 !! wikitext
5770 ''Some [http://example.com/ pretty ''italics'' and stuff]!''
5771 !! html
5772 <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>
5773 </p>
5774 !! end
5775
5776 # Don't add the html/php section since the output is broken and there isn't any reason to spec it
5777 !! test
5778 External link containing double-single-quotes with no space separating the url from text in italics
5779 !! wikitext
5780 [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]].]
5781 !! html/php+tidy
5782 <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>.
5783 </p>
5784 !! html/parsoid
5785 <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>
5786 !! end
5787
5788 !! test
5789 External link with comments in link text
5790 !! wikitext
5791 [http://www.google.com Google <!-- comment -->]
5792 !! html/php
5793 <p><a rel="nofollow" class="external text" href="http://www.google.com">Google </a>
5794 </p>
5795 !! html/parsoid
5796 <p><a rel="mw:ExtLink" class="external text" href="http://www.google.com">Google <!-- comment --></a></p>
5797 !! end
5798
5799 !! test
5800 External link to bare IPv4 address
5801 !! wikitext
5802 [http://192.168.0.1 Link]
5803 !! html/php
5804 <p><a rel="nofollow" class="external text" href="http://192.168.0.1">Link</a>
5805 </p>
5806 !! html/parsoid
5807 <p><a rel="mw:ExtLink" class="external text" href="http://192.168.0.1">Link</a></p>
5808 !! end
5809
5810 !! test
5811 URL-encoding in URL functions (single parameter)
5812 !! wikitext
5813 {{localurl:Some page|amp=&}}
5814 !! html
5815 <p>/index.php?title=Some_page&amp;amp=&amp;
5816 </p>
5817 !! end
5818
5819 !! test
5820 URL-encoding in URL functions (multiple parameters)
5821 !! wikitext
5822 {{localurl:Some page|q=?&amp=&}}
5823 !! html
5824 <p>/index.php?title=Some_page&amp;q=?&amp;amp=&amp;
5825 </p>
5826 !! end
5827
5828 !! test
5829 Brackets in urls
5830 !! wikitext
5831 http://example.com/index.php?foozoid%5B%5D=bar
5832
5833 http://example.com/index.php?foozoid&#x5B;&#x5D;=bar
5834 !! html/php
5835 <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>
5836 </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>
5837 </p>
5838 !! html/parsoid
5839 <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>
5840
5841 <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>
5842 !! end
5843
5844 !! test
5845 IPv6 urls, autolink format (T23261)
5846 !! wikitext
5847 http://[2404:130:0:1000::187:2]/index.php
5848
5849 Examples from RFC 2373, section 2.2:
5850
5851 *http://[1080::8:800:200C:417A]/unicast
5852 *http://[FF01::101]/multicast
5853 *http://[::1]/loopback
5854 *http://[::]/unspecified
5855 *http://[::13.1.68.3]/ipv4compat
5856 *http://[::FFFF:129.144.52.38]/ipv4compat
5857
5858 Examples from RFC 2732, section 2:
5859
5860 *http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
5861 *http://[1080:0:0:0:8:800:200C:417A]/index.html
5862 *http://[3ffe:2a00:100:7031::1]
5863 *http://[1080::8:800:200C:417A]/foo
5864 *http://[::192.9.5.5]/ipng
5865 *http://[::FFFF:129.144.52.38]:80/index.html
5866 *http://[2010:836B:4179::836B:4179]
5867 !! html/php
5868 <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>
5869 </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:
5870 </p>
5871 <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>
5872 <li><a rel="nofollow" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5873 <li><a rel="nofollow" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5874 <li><a rel="nofollow" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5875 <li><a rel="nofollow" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5876 <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>
5877 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5878 </p>
5879 <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>
5880 <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>
5881 <li><a rel="nofollow" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5882 <li><a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
5883 <li><a rel="nofollow" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5884 <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>
5885 <li><a rel="nofollow" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5886
5887 !! html/parsoid
5888 <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>
5889
5890 <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>
5891 <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>
5892 <li><a rel="mw:ExtLink" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5893 <li><a rel="mw:ExtLink" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5894 <li><a rel="mw:ExtLink" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5895 <li><a rel="mw:ExtLink" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5896 <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>
5897
5898 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external mw-magiclink">RFC 2732</a>, section 2:</p>
5899 <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>
5900 <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>
5901 <li><a rel="mw:ExtLink" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5902 <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>
5903 <li><a rel="mw:ExtLink" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5904 <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>
5905 <li><a rel="mw:ExtLink" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5906 !! end
5907
5908 !! test
5909 IPv6 urls, bracketed format (T23261)
5910 !! wikitext
5911 [http://[2404:130:0:1000::187:2]/index.php test]
5912
5913 Examples from RFC 2373, section 2.2:
5914
5915 *[http://[1080::8:800:200C:417A] unicast]
5916 *[http://[FF01::101] multicast]
5917 *[http://[::1]/ loopback]
5918 *[http://[::] unspecified]
5919 *[http://[::13.1.68.3] ipv4compat]
5920 *[http://[::FFFF:129.144.52.38] ipv4compat]
5921
5922 Examples from RFC 2732, section 2:
5923
5924 *[http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html 1]
5925 *[http://[1080:0:0:0:8:800:200C:417A]/index.html 2]
5926 *[http://[3ffe:2a00:100:7031::1] 3]
5927 *[http://[1080::8:800:200C:417A]/foo 4]
5928 *[http://[::192.9.5.5]/ipng 5]
5929 *[http://[::FFFF:129.144.52.38]:80/index.html 6]
5930 *[http://[2010:836B:4179::836B:4179] 7]
5931 !! html/php
5932 <p><a rel="nofollow" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a>
5933 </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:
5934 </p>
5935 <ul><li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5936 <li><a rel="nofollow" class="external text" href="http://[FF01::101]">multicast</a></li>
5937 <li><a rel="nofollow" class="external text" href="http://[::1]/">loopback</a></li>
5938 <li><a rel="nofollow" class="external text" href="http://[::]">unspecified</a></li>
5939 <li><a rel="nofollow" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5940 <li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5941 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5942 </p>
5943 <ul><li><a rel="nofollow" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
5944 <li><a rel="nofollow" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5945 <li><a rel="nofollow" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5946 <li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5947 <li><a rel="nofollow" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
5948 <li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5949 <li><a rel="nofollow" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5950
5951 !! html/parsoid
5952 <p><a rel="mw:ExtLink" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a></p>
5953
5954 <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>
5955 <ul><li><a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5956 <li><a rel="mw:ExtLink" class="external text" href="http://[FF01::101]">multicast</a></li>
5957 <li><a rel="mw:ExtLink" class="external text" href="http://[::1]/">loopback</a></li>
5958 <li><a rel="mw:ExtLink" class="external text" href="http://[::]">unspecified</a></li>
5959 <li><a rel="mw:ExtLink" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5960 <li><a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5961
5962 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external mw-magiclink">RFC 2732</a>, section 2:</p>
5963 <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>
5964 <li><a rel="mw:ExtLink" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5965 <li><a rel="mw:ExtLink" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5966 <li><a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5967 <li><a rel="mw:ExtLink" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
5968 <li><a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5969 <li><a rel="mw:ExtLink" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5970 !! end
5971
5972 !! test
5973 Non-extlinks in brackets
5974 !! wikitext
5975 [foo]
5976 [foo bar]
5977 [foo ''bar'']
5978 [fool's] errand
5979 [fool's errand]
5980 [{{echo|foo}}]
5981 [{{echo|foo}} bar]
5982 [{{echo|foo}} ''bar'']
5983 [{{echo|foo}}l's] errand
5984 [{{echo|foo}}l's errand]
5985 [url={{echo|foo}}]
5986 [url=http://example.com]
5987 [http:// bare protocols don't count]
5988 !! html/php
5989 <p>[foo]
5990 [foo bar]
5991 [foo <i>bar</i>]
5992 [fool's] errand
5993 [fool's errand]
5994 [foo]
5995 [foo bar]
5996 [foo <i>bar</i>]
5997 [fool's] errand
5998 [fool's errand]
5999 [url=foo]
6000 [url=<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>]
6001 [http:// bare protocols don't count]
6002 </p>
6003 !! html/parsoid
6004 <p>[foo]
6005 [foo bar]
6006 [foo <i>bar</i>]
6007 [fool's] errand
6008 [fool's errand]
6009 [<span about="#mwt19" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>]
6010 [<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]
6011 [<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>]
6012 [<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
6013 [<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]
6014 [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>]
6015 [url=<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>]
6016 [http:// bare protocols don't count]</p>
6017 !! end
6018
6019 !! test
6020 Percent encoding in external links
6021 !! wikitext
6022 [https://github.com/search?l=&q=ResourceLoader+%40wikimedia Search]
6023 !! html/php
6024 <p><a rel="nofollow" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a>
6025 </p>
6026 !! html/parsoid
6027 <p><a rel="mw:ExtLink" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a></p>
6028 !! end
6029
6030 !! test
6031 Use url link syntax for links where the content is equal the link target
6032 !! wikitext
6033 http://example.com
6034 !! html/php
6035 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
6036 </p>
6037 !! html/parsoid
6038 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a></p>
6039 !! end
6040
6041 !! test
6042 Parenthesis in external links, especially URL links
6043 !! wikitext
6044 http://example.com)
6045
6046 http://example.com/test)
6047
6048 http://example.com/(test)
6049
6050 http://example.com/((test)
6051
6052 (http://example.com/(test))
6053
6054 (http://example.com/(test)))))
6055
6056 http://example.com/a)b
6057
6058 [http://example.com) foo]
6059 !! html/php
6060 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
6061 </p><p><a rel="nofollow" class="external free" href="http://example.com/test">http://example.com/test</a>)
6062 </p><p><a rel="nofollow" class="external free" href="http://example.com/(test)">http://example.com/(test)</a>
6063 </p><p><a rel="nofollow" class="external free" href="http://example.com/((test)">http://example.com/((test)</a>
6064 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test))">http://example.com/(test))</a>
6065 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a>
6066 </p><p><a rel="nofollow" class="external free" href="http://example.com/a)b">http://example.com/a)b</a>
6067 </p><p><a rel="nofollow" class="external text" href="http://example.com)">foo</a>
6068 </p>
6069 !! html/parsoid
6070 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>)</p>
6071 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/test">http://example.com/test</a>)</p>
6072 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/(test)">http://example.com/(test)</a></p>
6073 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/((test)">http://example.com/((test)</a></p>
6074 <p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test))">http://example.com/(test))</a></p>
6075 <p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a></p>
6076 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/a)b">http://example.com/a)b</a></p>
6077 <p><a rel="mw:ExtLink" class="external text" href="http://example.com)">foo</a></p>
6078 !! end
6079
6080 !! test
6081 Parenthesis in external links, w/ transclusion or comment
6082 !! wikitext
6083 (http://example.com/{{echo|hi}})
6084
6085 (http://example.com<!-- hi -->)
6086 !! html/php
6087 <p>(<a rel="nofollow" class="external free" href="http://example.com/hi">http://example.com/hi</a>)
6088 </p><p>(<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
6089 </p>
6090 !! html/parsoid
6091 <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>
6092
6093 <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>
6094 !! end
6095
6096 !! test
6097 Serialize <a> tags with invalid link targets as plain text
6098 !! options
6099 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
6100 !! html/parsoid
6101 <a rel="mw:WikiLink" href="[[foo]]">text</a>
6102 <a rel="mw:WikiLink" href="[[foo]]">*text</a>
6103 <a rel="mw:WikiLink" href="[[foo]]">[[foo]]</a>
6104 <a rel="mw:WikiLink" href="[[foo]]">*a [[foo]]</a>
6105 !! wikitext
6106 text
6107 <nowiki>*</nowiki>text
6108 <nowiki>[[foo]]</nowiki>
6109 <nowiki>*</nowiki>a <nowiki>[[foo]]</nowiki>
6110 !! end
6111
6112 !! test
6113 mw:ExtLink -vs- mw:WikiLink (T94723)
6114 !! options
6115 parsoid=html2wt
6116 !! html/parsoid
6117 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"piped","a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>Bar</a>
6118 <a rel="mw:WikiLink" href="./Foo" title="Foo">Bar</a>
6119 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
6120 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
6121 <p>
6122 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
6123 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
6124 </p>
6125 !! wikitext
6126 [[Foo|Bar]]
6127 [[Foo|Bar]]
6128 [[:en:Foo|Bar]]
6129 [[:en:Foo|Bar]]
6130
6131 [[:en:European_Robin|European Robin]]
6132 [[:en:European_Robin|European Robin]]
6133 !! end
6134
6135 !! test
6136 mw:ExtLink linking to a interwiki URL can be round-tripped losslessly (T94723)
6137 !! options
6138 parsoid=wt2wt
6139 !! wikitext
6140 [http://en.wikipedia.org/wiki/European_Robin European Robin]
6141 !! html/parsoid
6142 THIS SECTION IS NOT USED (but Parsoid won't run the test without it)
6143 !! end
6144
6145
6146 ###
6147 ### Quotes
6148 ###
6149
6150 !! test
6151 Quotes
6152 !! wikitext
6153 Normal text. '''Bold text.''' Normal text. ''Italic text.''
6154
6155 Normal text. '''''Bold italic text.''''' Normal text.
6156 !! html
6157 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
6158 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
6159 </p>
6160 !! end
6161
6162 !! test
6163 Quotes wrapping HTML table
6164 !! wikitext
6165 '''<table><tr><td>hi</td></tr></table>'''
6166 !! html/php+tidy
6167 <b><table><tbody><tr><td>hi</td></tr></tbody></table></b>
6168 !! html/parsoid
6169 <b><table data-parsoid='{"stx":"html"}'><tbody><tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>hi</td></tr></tbody></table></b>
6170 !! end
6171
6172 # Parsoid inserts an empty bold tag pair at the end of the line, that the PHP
6173 # parser strips. The wikitext contains just the first half of the bold
6174 # quote pair.
6175 !! test
6176 Unclosed and unmatched quotes
6177 !! wikitext
6178 '''''Bold italic text '''with bold deactivated''' in between.'''''
6179
6180 '''''Bold italic text ''with italic deactivated'' in between.'''''
6181
6182 '''Bold text..
6183
6184 ..spanning two paragraphs (should not work).'''
6185
6186 '''Bold tag left open
6187
6188 ''Italic tag left open
6189
6190 Normal text.
6191
6192 <!-- Unmatching number of opening, closing tags: -->
6193 '''This year''''s election ''should'' beat '''last year''''s.
6194
6195 ''Tom'''s car is bigger than ''Susan'''s.
6196
6197 Plain ''italic'''s plain
6198 !! html/php
6199 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
6200 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
6201 </p><p><b>Bold text..</b>
6202 </p><p>..spanning two paragraphs (should not work).
6203 </p><p><b>Bold tag left open</b>
6204 </p><p><i>Italic tag left open</i>
6205 </p><p>Normal text.
6206 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
6207 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
6208 </p><p>Plain <i>italic'</i>s plain
6209 </p>
6210 !! html/parsoid
6211 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
6212 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
6213 </p><p><b>Bold text..</b>
6214 </p><p>..spanning two paragraphs (should not work).<b></b>
6215 </p><p><b>Bold tag left open</b>
6216 </p><p><i>Italic tag left open</i>
6217 </p><p>Normal text.
6218 </p>
6219 <!-- Unmatching number of opening, closing tags: -->
6220 <p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
6221 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
6222 </p><p>Plain <i>italic'</i>s plain
6223 </p>
6224 !! end
6225
6226 ###
6227 ### Tables
6228 ###
6229 ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
6230 ###
6231
6232 # This should not produce <table></table> as <table><tr><td></td></tr></table>
6233 # is the bare minimum required by the spec, see:
6234 # https://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
6235 # Parsoid team replies: empty table tags are legal in HTML5
6236 !! test
6237 A table with no data.
6238 !! options
6239 parsoid=wt2html
6240 !! wikitext
6241 {||}
6242 !! html/php
6243
6244 !! html/parsoid
6245 <table></table>
6246
6247 !! end
6248
6249 !! test
6250 A table with stray table end tags on start tag line (wt2html)
6251 !! options
6252 parsoid=wt2html
6253 !! wikitext
6254 {|style="color: red;"|}
6255
6256 {|style="color: red;" |}
6257 |foo
6258 |}
6259
6260 {|style="color: red;"|} id="foo"
6261 |foo
6262 |}
6263
6264 {|style="color: red;" |} id="foo"
6265 |foo
6266 |}
6267 !! html
6268 <table style="color: red;"></table>
6269
6270 <table style="color: red;">
6271 <tbody><tr>
6272 <td>foo</td>
6273 </tr></tbody>
6274 </table>
6275
6276 <table style="color: red;" id="foo">
6277 <tbody><tr>
6278 <td>foo</td>
6279 </tr></tbody>
6280 </table>
6281
6282 <table style="color: red;" id="foo">
6283 <tbody><tr>
6284 <td>foo</td>
6285 </tr></tbody>
6286 </table>
6287
6288 !! end
6289
6290 !! test
6291 A table with no data (take 2)
6292 !! wikitext
6293 {|
6294 |}
6295 !! html/parsoid
6296 <table></table>
6297 !! end
6298
6299 # A table with nothing but a caption is invalid XHTML, we might want to render
6300 # this as <p>caption</p>
6301 # Parsoid team replies: table with only a caption is legal in HTML5
6302 !! test
6303 A table with nothing but a caption
6304 !! wikitext
6305 {|
6306 |+caption
6307 |}
6308 !! html/php
6309 <table>
6310 <caption>caption
6311 </caption><tr><td></td></tr></table>
6312
6313 !! html/parsoid
6314 <table><caption>caption</caption></table>
6315 !! end
6316
6317 !! test
6318 A table with caption with default-spaced attributes and a table row
6319 !! wikitext
6320 {|
6321 |+ style="color: red;" |caption1
6322 |-
6323 |foo
6324 |}
6325 !! html
6326 <table>
6327 <caption style="color: red;">caption1
6328 </caption>
6329 <tr>
6330 <td>foo
6331 </td></tr></table>
6332
6333 !! end
6334
6335 !! test
6336 A table with captions with non-default spaced attributes and a table row
6337 !! wikitext
6338 {|
6339 |+style="color: red;"|caption2
6340 |+ style="color: red;"|caption3
6341 |-
6342 |foo
6343 |}
6344 !! html
6345 <table>
6346 <caption style="color: red;">caption2
6347 </caption>
6348 <caption style="color: red;">caption3
6349 </caption>
6350 <tr>
6351 <td>foo
6352 </td></tr></table>
6353
6354 !! end
6355
6356 !! test
6357 Table td-cell syntax variations
6358 !! wikitext
6359 {|
6360 |foo bar foo|baz
6361 |foo bar foo||baz
6362 |style='color:red;'|baz
6363 |style='color:red;'||baz
6364 |}
6365 !! html
6366 <table>
6367 <tr>
6368 <td>baz
6369 </td>
6370 <td>foo bar foo</td>
6371 <td>baz
6372 </td>
6373 <td style="color:red;">baz
6374 </td>
6375 <td>style='color:red;'</td>
6376 <td>baz
6377 </td></tr></table>
6378
6379 !! end
6380
6381 !! test
6382 Simple table
6383 !! wikitext
6384 {|
6385 |1||2
6386 |-
6387 |3||4
6388 |}
6389 !! html
6390 <table>
6391 <tr>
6392 <td>1</td>
6393 <td>2
6394 </td></tr>
6395 <tr>
6396 <td>3</td>
6397 <td>4
6398 </td></tr></table>
6399
6400 !! end
6401
6402 !! test
6403 Simple table but with multiple dashes for row wikitext
6404 !! wikitext
6405 {|
6406 |foo
6407 |-----
6408 |bar
6409 |}
6410 !! html
6411 <table>
6412 <tr>
6413 <td>foo
6414 </td></tr>
6415 <tr>
6416 <td>bar
6417 </td></tr></table>
6418
6419 !! end
6420
6421 !! test
6422 Multiplication table
6423 !! wikitext
6424 {| border="1" cellpadding="2"
6425 |+Multiplication table
6426 |-
6427 !&times;!!1!!2!!3
6428 |-
6429 !1
6430 |1||2||3
6431 |-
6432 !2
6433 |2||4||6
6434 |-
6435 !3
6436 |3||6||9
6437 |-
6438 !4
6439 |4||8||12
6440 |-
6441 !5
6442 |5||10||15
6443 |}
6444 !! html
6445 <table border="1" cellpadding="2">
6446 <caption>Multiplication table
6447 </caption>
6448 <tr>
6449 <th>&#215;</th>
6450 <th>1</th>
6451 <th>2</th>
6452 <th>3
6453 </th></tr>
6454 <tr>
6455 <th>1
6456 </th>
6457 <td>1</td>
6458 <td>2</td>
6459 <td>3
6460 </td></tr>
6461 <tr>
6462 <th>2
6463 </th>
6464 <td>2</td>
6465 <td>4</td>
6466 <td>6
6467 </td></tr>
6468 <tr>
6469 <th>3
6470 </th>
6471 <td>3</td>
6472 <td>6</td>
6473 <td>9
6474 </td></tr>
6475 <tr>
6476 <th>4
6477 </th>
6478 <td>4</td>
6479 <td>8</td>
6480 <td>12
6481 </td></tr>
6482 <tr>
6483 <th>5
6484 </th>
6485 <td>5</td>
6486 <td>10</td>
6487 <td>15
6488 </td></tr></table>
6489
6490 !! end
6491
6492 !! test
6493 Accept "||" in table headings
6494 !! wikitext
6495 {|
6496 !h1||h2
6497 |}
6498 !! html
6499 <table>
6500 <tr>
6501 <th>h1</th>
6502 <th>h2
6503 </th></tr></table>
6504
6505 !! end
6506
6507 !! test
6508 Accept "!!" in table data
6509 !! wikitext
6510 {|
6511 |Foo!!||
6512 |}
6513 !! html
6514 <table>
6515 <tr>
6516 <td>Foo!!</td>
6517 <td>
6518 </td></tr></table>
6519
6520 !! html/parsoid
6521 <table>
6522 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'> Foo!! </td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'></td></tr>
6523 </tbody></table>
6524 !! end
6525
6526 !! test
6527 Accept "||" in indented table headings
6528 !! wikitext
6529 :{|
6530 !h1||h2
6531 |}
6532 !! html
6533 <dl><dd><table>
6534 <tr>
6535 <th>h1</th>
6536 <th>h2
6537 </th></tr></table></dd></dl>
6538
6539 !! end
6540
6541 !! test
6542 Accept "!!" in templates
6543 !! wikitext
6544 {|
6545 !a {{echo|b!!c}}
6546 |}
6547 !! html/php
6548 <table>
6549 <tr>
6550 <th>a b</th>
6551 <th>c
6552 </th></tr></table>
6553
6554 !! html/parsoid
6555 <table>
6556 <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>
6557 !! end
6558
6559 !! test
6560 Accept "!!" in table headings after newline
6561 !! wikitext
6562 {|
6563 !a
6564 b!!c
6565 |}
6566 !! html/php
6567 <table>
6568 <tr>
6569 <th>a
6570 <p>b!!c
6571 </p>
6572 </th></tr></table>
6573
6574 !! html/parsoid
6575 <table>
6576 <tbody><tr><th>a
6577 <p>b!!c</p></th></tr>
6578 </tbody></table>
6579 !! end
6580
6581 !! test
6582 Accept "!!" in table data of mixed wikitext / html syntax
6583 !! wikitext
6584 {|
6585 !a
6586 <tr><td>b!!c</td></tr>
6587 |}
6588 !! html/php+tidy
6589 <table>
6590 <tbody><tr>
6591 <th>a
6592 </th></tr><tr><td>b!!c</td></tr>
6593 </tbody></table>
6594 !! html/parsoid
6595 <table>
6596 <tbody><tr><th>a</th></tr>
6597 <tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>b!!c</td></tr>
6598 </tbody></table>
6599 !! end
6600
6601 !! test
6602 Accept empty attributes in td/th cells (td/th cells starting with leading ||)
6603 !! wikitext
6604 {|
6605 !|h1
6606 ||a
6607 |}
6608 !! html
6609 <table>
6610 <tr>
6611 <th>h1
6612 </th>
6613 <td>a
6614 </td></tr></table>
6615
6616 !! end
6617
6618 !!test
6619 Accept "| !" at start of line in tables (ignore !-attribute)
6620 !! wikitext
6621 {|
6622 |-
6623 |!style="color:red"|bar
6624 |}
6625 !! html
6626 <table>
6627
6628 <tr>
6629 <td>bar
6630 </td></tr></table>
6631
6632 !!end
6633
6634 !!test
6635 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 +/-
6636 !! wikitext
6637 {|
6638 |-
6639 |style='color:red;'|+1
6640 |style='color:blue;'|-1
6641 |-
6642 |1||2||3
6643 |1||+2||-3
6644 |-
6645 | +1
6646 | -1
6647 |}
6648 !! html
6649 <table>
6650
6651 <tr>
6652 <td style="color:red;">+1
6653 </td>
6654 <td style="color:blue;">-1
6655 </td></tr>
6656 <tr>
6657 <td>1</td>
6658 <td>2</td>
6659 <td>3
6660 </td>
6661 <td>1</td>
6662 <td>+2</td>
6663 <td>-3
6664 </td></tr>
6665 <tr>
6666 <td>+1
6667 </td>
6668 <td>-1
6669 </td></tr></table>
6670
6671 !!end
6672
6673 !! test
6674 Table rowspan
6675 !! wikitext
6676 {| border=1
6677 |Cell 1, row 1
6678 |rowspan=2|Cell 2, row 1 (and 2)
6679 |Cell 3, row 1
6680 |-
6681 |Cell 1, row 2
6682 |Cell 3, row 2
6683 |}
6684 !! html
6685 <table border="1">
6686 <tr>
6687 <td>Cell 1, row 1
6688 </td>
6689 <td rowspan="2">Cell 2, row 1 (and 2)
6690 </td>
6691 <td>Cell 3, row 1
6692 </td></tr>
6693 <tr>
6694 <td>Cell 1, row 2
6695 </td>
6696 <td>Cell 3, row 2
6697 </td></tr></table>
6698
6699 !! end
6700
6701 !! test
6702 Nested table
6703 !! wikitext
6704 {| border=1
6705 | &alpha;
6706 |
6707 {| bgcolor=#ABCDEF border=2
6708 |nested
6709 |-
6710 |table
6711 |}
6712 |the original table again
6713 |}
6714 !! html
6715 <table border="1">
6716 <tr>
6717 <td>&#945;
6718 </td>
6719 <td>
6720 <table bgcolor="#ABCDEF" border="2">
6721 <tr>
6722 <td>nested
6723 </td></tr>
6724 <tr>
6725 <td>table
6726 </td></tr></table>
6727 </td>
6728 <td>the original table again
6729 </td></tr></table>
6730
6731 !! end
6732
6733 !! test
6734 Invalid attributes in table cell (T3830)
6735 !! wikitext
6736 {|
6737 |Cell:|broken
6738 |}
6739 !! html
6740 <table>
6741 <tr>
6742 <td>broken
6743 </td></tr></table>
6744
6745 !! end
6746
6747 !! test
6748 Table cell attributes: Pipes protected by nowikis should be treated as a plain character
6749 !! wikitext
6750 {|
6751 |title="foo" |bar
6752 |title="foo<nowiki>|</nowiki>" |bar
6753 |title="foo<nowiki>|</nowiki>" bar
6754 |}
6755 !! html/php
6756 <table>
6757 <tr>
6758 <td title="foo">bar
6759 </td>
6760 <td title="foo&#124;">bar
6761 </td>
6762 <td>title="foo|" bar
6763 </td></tr></table>
6764
6765 !! html/parsoid
6766 <table>
6767 <tbody><tr><td title="foo">bar</td>
6768 <td title="foo|" data-parsoid='{"a":{"title":"foo|"},"sa":{"title":"foo&lt;nowiki>|&lt;/nowiki>"},"autoInsertedEnd":true}'>bar</td>
6769 <td> title="foo<span typeof="mw:Nowiki">|</span>" bar</td></tr>
6770 </tbody></table>
6771 !! end
6772
6773 # See: http://lists.wikimedia.org/mailman/htdig/wikitech-l/2006-April/022293.html
6774 # N.B. The "|}" to close the table is missing from the input, so parsoid's
6775 # *2wt modes will fail.
6776 !! test
6777 Table security: embedded pipes
6778 !! options
6779 parsoid=wt2html,html2html
6780 !! wikitext
6781 {|
6782 | |[ftp://|x||]" onmouseover="alert(document.cookie)">test
6783 !! html/php
6784 <table>
6785 <tr>
6786 <td>[<a rel="nofollow" class="external free" href="ftp://%7Cx">ftp://%7Cx</a></td>
6787 <td>]" onmouseover="alert(document.cookie)"&gt;test
6788 </td>
6789 </tr>
6790 </table>
6791
6792 !! html/parsoid
6793 <table><tbody>
6794 <tr>
6795 <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>
6796 !! end
6797
6798 !! test
6799 Element attributes with double ! should not be broken up by <th>
6800 !! wikitext
6801 {|
6802 !hi <div class="!!">ha</div> ho
6803 |}
6804 !! html/php
6805 <table>
6806 <tr>
6807 <th>hi <div class="!!">ha</div> ho
6808 </th></tr></table>
6809
6810 !! html/parsoid
6811 <table>
6812 <tbody><tr><th>hi <div class="!!" data-parsoid='{"stx":"html"}'>ha</div> ho</th></tr>
6813 </tbody></table>
6814 !! end
6815
6816 !! test
6817 ! and || in element attributes should not be parsed as <th>/<td>
6818 !! wikitext
6819 {|
6820 |<div style="color: red !important;" data-contrived="put this here ||">hi</div>
6821 |}
6822 !! html/php
6823 <table>
6824 <tr>
6825 <td><div style="color: red !important;" data-contrived="put this here &#124;&#124;">hi</div>
6826 </td></tr></table>
6827
6828 !! html/parsoid
6829 <table>
6830 <tbody><tr><td><div style="color: red !important;" data-contrived="put this here ||" data-parsoid='{"stx":"html"}'>hi</div></td></tr>
6831 </tbody></table>
6832 !! end
6833
6834 # FIXME: The output seems broken. Filed as T110268.
6835 !! test
6836 ! and || in td attributes should not be parsed as <th>/<td>
6837 !! options
6838 parsoid=wt2html
6839 !! wikitext
6840 {|
6841 |style="color: red !important;" data-contrived="put this here ||"|foo
6842 |}
6843 !! html/php
6844 <table>
6845 <tr>
6846 <td>style="color: red !important;" data-contrived="put this here</td>
6847 <td>foo
6848 </td></tr></table>
6849
6850 !! html/parsoid
6851 <table>
6852 <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>
6853 </tbody></table>
6854 !! end
6855
6856 !! test
6857 Break on | in element attribute in template
6858 !! options
6859 parsoid=wt2html,html2html
6860 !! wikitext
6861 {{echo|1=<div class="hi|ho">ha</div>}}
6862 !! html/php
6863 <p>ho"&gt;ha&lt;/div&gt;
6864 </p>
6865 !! html/parsoid
6866 <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>
6867 !! end
6868
6869 !! test
6870 Break on | in element attribute name in template
6871 !! wikitext
6872 {{echo|<div cla|ss="hiho">ha</div>}}
6873 !! html/parsoid
6874 <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>
6875 !! end
6876
6877 !! test
6878 Don't break on | in extension attribute in template
6879 !! wikitext
6880 {{echo|<ref name="hi|ho">ha</ref>}}
6881
6882 <references />
6883 !! html/parsoid
6884 <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="./Main_Page#cite_note-hi|ho-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup></p>
6885
6886 <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="./Main_Page#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>
6887 !! end
6888
6889 ## We don't support roundtripping of these attributes in Parsoid.
6890 ## Selective serialization takes care of preventing dirty diffs.
6891 ## But, on edits, we dirty-diff the invalid attribute text.
6892 !! test
6893 Invalid text in table attributes should be discarded
6894 !! options
6895 parsoid=wt2html
6896 !! wikitext
6897 {| <span>boo</span> style='border:1px solid black'
6898 | <span>boo</span> style='color:blue' |1
6899 |<span>boo</span> style='color:blue'|2
6900 |}
6901 !! html/php
6902 <table style="border:1px solid black">
6903 <tr>
6904 <td style="color:blue">1
6905 </td>
6906 <td style="color:blue">2
6907 </td></tr></table>
6908
6909 !! html/parsoid
6910 <table style="border:1px solid black">
6911 <tr>
6912 <td style="color:blue">1</td>
6913 <td style="color:blue">2</td>
6914 </tr>
6915 </table>
6916 !! end
6917
6918 !! test
6919 Invalid text in table attributes should be preserved by selective serializer
6920 !! options
6921 parsoid={
6922 "modes": ["selser"],
6923 "changes": [
6924 ["td:first-child", "text", "abc"],
6925 ["td + td", "text", "xyz"]
6926 ]
6927 }
6928 !! wikitext
6929 {| <span>boo</span> style='border:1px solid black'
6930 | <span>boo</span> style='color:blue' | 1
6931 |<span>boo</span> style='color:blue'| 2
6932 |}
6933 !! wikitext/edited
6934 {| <span>boo</span> style='border:1px solid black'
6935 | <span>boo</span> style='color:blue' | abc
6936 |<span>boo</span> style='color:blue'| xyz
6937 |}
6938 !! end
6939
6940 !! test
6941 1. Template-generated table cell attributes and cell content
6942 !! wikitext
6943 {|
6944 |{{table_attribs}}
6945 | {{table_attribs}}
6946 || {{table_attribs_5}}
6947 | <!--foo--> <!--bar--> <!--baz--> {{table_attribs}}
6948 |align=center {{table_attribs}}
6949 | <!--foo--> align=center <!--bar--> {{table_attribs}}
6950 |}
6951 !! html
6952 <table>
6953 <tr>
6954 <td style="color:red;">Foo
6955 </td>
6956 <td style="color:red;">Foo
6957 </td>
6958 <td>style="color:red;"</td>
6959 <td>Bar
6960 </td>
6961 <td style="color:red;">Foo
6962 </td>
6963 <td align="center" style="color:red;">Foo
6964 </td>
6965 <td align="center" style="color:red;">Foo
6966 </td></tr></table>
6967
6968 !! end
6969
6970 !! test
6971 2. Template-generated table cell attributes and cell content
6972 !! wikitext
6973 {|
6974 |{{table_attribs_2}}
6975 |}
6976 !! html/php
6977 <table>
6978 <tr>
6979 <td style="color:red;">Foo
6980 </td>
6981 <td>Bar</td>
6982 <td>Baz
6983 </td></tr></table>
6984
6985 !! html/parsoid
6986 <table>
6987 <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>
6988 <td about="#mwt1">Bar</td><td about="#mwt1">Baz</td></tr>
6989 </tbody></table>
6990 !! end
6991
6992 !! test
6993 3. Template-generated table cell attributes and cell content
6994 !! wikitext
6995 {|
6996 !align=center {{table_header_cells}}
6997 |-
6998 |align=center {{table_cells}}
6999 |}
7000 !! html/php
7001 <table>
7002 <tr>
7003 <th align="center" style="color:red;">Foo</th>
7004 <th style="color:red;"><i>Bar</i></th>
7005 <th style="color:brown;"><i>Foo</i> and Baz
7006 </th></tr>
7007 <tr>
7008 <td align="center" style="color:red;">Foo</td>
7009 <td style="color:red;"><i>Bar</i></td>
7010 <td style="color:brown;"><i>Foo</i> and Baz
7011 </td></tr></table>
7012
7013 !! html/parsoid
7014 <table>
7015 <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>
7016 <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>
7017 </tbody></table>
7018 !! end
7019
7020 !! test
7021 4. Template-generated table cell attributes and cell content inside a templated table
7022 !! wikitext
7023 {{tbl-start}}
7024 !align=center {{table_header_cells}}
7025 |-
7026 |align=center {{table_cells}}
7027 {{tbl-end}}
7028 !! html/php
7029 <table>
7030 <tr>
7031 <th align="center" style="color:red;">Foo</th>
7032 <th style="color:red;"><i>Bar</i></th>
7033 <th style="color:brown;"><i>Foo</i> and Baz
7034 </th></tr>
7035 <tr>
7036 <td align="center" style="color:red;">Foo</td>
7037 <td style="color:red;"><i>Bar</i></td>
7038 <td style="color:brown;"><i>Foo</i> and Baz
7039 </td></tr></table>
7040
7041 !! html/parsoid
7042 <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}}]}'>
7043 <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>
7044 <tr>
7045 <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>
7046 </tbody></table>
7047 !! end
7048
7049 ## Edge case fix to prevent future regressions
7050 !! test
7051 T107652: <ref>s in templates that also generate table cell attributes should be rendered properly
7052 !! wikitext
7053 {|
7054 |{{table_attribs_7}}
7055 |}
7056 <references />
7057 !! html/parsoid
7058 <table>
7059 <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="./Main_Page#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></s></td></tr>
7060 </tbody></table>
7061 <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="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
7062 !! end
7063
7064 !! test
7065 Table with row followed by newlines and table heading
7066 !! options
7067 parsoid=wt2html,html2html
7068 !! wikitext
7069 {|
7070 |-
7071
7072 !foo
7073 |}
7074 !! html/*
7075 <table>
7076
7077
7078 <tr>
7079 <th>foo
7080 </th></tr></table>
7081
7082 !! end
7083
7084 !! test
7085 Table with empty line following the start tag
7086 !! options
7087 parsoid=wt2html,html2html
7088 !! wikitext
7089 {|
7090
7091 |-
7092 |foo
7093 |}
7094 !! html/*
7095 <table>
7096
7097
7098 <tr>
7099 <td>foo
7100 </td></tr></table>
7101
7102 !! end
7103
7104 !! test
7105 Table attributes with empty value
7106 !! options
7107 parsoid=wt2html,html2html
7108 !! wikitext
7109 {|
7110 | style=|hello
7111 |}
7112 !! html/php
7113 <table>
7114 <tr>
7115 <td style="">hello
7116 </td></tr></table>
7117
7118 !! html/parsoid
7119 <table>
7120 <tbody><tr><td style="">hello</td></tr>
7121 </tbody></table>
7122 !! end
7123
7124 !! test
7125 Wikitext table with a lot of comments
7126 !! wikitext
7127 {|
7128 <!-- c0 -->
7129 |foo
7130 <!-- c1 -->
7131 |-<!-- c2 -->
7132 <!-- c3 -->
7133 |<!-- c4 -->
7134 <!-- c5 -->
7135 |}
7136 !! html
7137 <table>
7138 <tr>
7139 <td>foo
7140 </td></tr>
7141 <tr>
7142 <td>
7143 </td></tr></table>
7144
7145 !! end
7146
7147 !! test
7148 Wikitext table comments represented in parsoid dom
7149 !! wikitext
7150 {|<!--c1--><!--c2-->
7151 |-<!--c3-->
7152 |x
7153 |}
7154 !! html/php+tidy
7155 <table>
7156
7157 <tbody><tr>
7158 <td>x
7159 </td></tr></tbody></table>
7160 !! html/parsoid
7161 <table><!--c1--><!--c2-->
7162 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'><!--c3-->
7163 <td data-parsoid='{"autoInsertedEnd":true}'>x</td></tr>
7164 </tbody></table>
7165 !! end
7166
7167 !! test
7168 Wikitext table with double-line table cell
7169 !! wikitext
7170 {|
7171 |a
7172 b
7173 |}
7174 !! html
7175 <table>
7176 <tr>
7177 <td>a
7178 <p>b
7179 </p>
7180 </td></tr></table>
7181
7182 !! end
7183
7184 !! test
7185 Table cell with a single comment
7186 !! wikitext
7187 {|
7188 |<!-- c1 -->
7189 |a
7190 |}
7191 !! html
7192 <table>
7193 <tr>
7194 <td>
7195 </td>
7196 <td>a
7197 </td></tr></table>
7198
7199 !! end
7200
7201 !! test
7202 Table-cell after a comment-only-empty-line
7203 !! wikitext
7204 {|
7205 |a
7206 <!--c1-->
7207 <!--c2-->|b
7208 |}
7209 !! html
7210 <table>
7211 <tr>
7212 <td>a
7213 </td>
7214 <td>b
7215 </td></tr></table>
7216
7217 !! html/parsoid
7218 <table>
7219 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>a</td>
7220 <!--c1-->
7221 <!--c2--><td data-parsoid='{"autoInsertedEnd":true}'>b</td></tr>
7222 </tbody></table>
7223
7224 !! end
7225
7226 !! test
7227 Build table with {{!}}
7228 !! wikitext
7229 {{{!}} class="wikitable"
7230 !header
7231 !second header
7232 {{!}}- style="color:red;"
7233 {{!}}data{{!}}{{!}} style="color:red;" {{!}}second data
7234 {{!}}}
7235 !! html
7236 <table class="wikitable">
7237 <tr>
7238 <th>header
7239 </th>
7240 <th>second header
7241 </th></tr>
7242 <tr style="color:red;">
7243 <td>data</td>
7244 <td style="color:red;">second data
7245 </td></tr></table>
7246
7247 !! end
7248
7249 !! test
7250 Build table with pipe as data
7251 !! wikitext
7252 {| class="wikitable"
7253 !header
7254 !second header
7255 |- style="color:red;"
7256 |data|| style="color:red;" |second data
7257 |-
7258 | style="color:red;" |data with | || style="color:red;" | second data with |
7259 |-
7260 ||data with | |||second data with |
7261 |}
7262 !! html
7263 <table class="wikitable">
7264 <tr>
7265 <th>header
7266 </th>
7267 <th>second header
7268 </th></tr>
7269 <tr style="color:red;">
7270 <td>data</td>
7271 <td style="color:red;">second data
7272 </td></tr>
7273 <tr>
7274 <td style="color:red;">data with |</td>
7275 <td style="color:red;">second data with |
7276 </td></tr>
7277 <tr>
7278 <td>data with |</td>
7279 <td>second data with |
7280 </td></tr></table>
7281
7282 !! end
7283
7284 !! test
7285 Build table with wikilink
7286 !! wikitext
7287 {| class="wikitable"
7288 !header||second header
7289 |- style="color:red;"
7290 |data [[Main Page|linktext]]||second data [[Main Page|linktext]]
7291 |-
7292 |data||second data [[Main Page|link|text with pipe]]
7293 |}
7294 !! html
7295 <table class="wikitable">
7296 <tr>
7297 <th>header</th>
7298 <th>second header
7299 </th></tr>
7300 <tr style="color:red;">
7301 <td>data <a href="/wiki/Main_Page" title="Main Page">linktext</a></td>
7302 <td>second data <a href="/wiki/Main_Page" title="Main Page">linktext</a>
7303 </td></tr>
7304 <tr>
7305 <td>data</td>
7306 <td>second data <a href="/wiki/Main_Page" title="Main Page">link|text with pipe</a>
7307 </td></tr></table>
7308
7309 !! end
7310
7311 # The expected HTML structure in this test is debatable. The PHP parser does
7312 # not parse this kind of table at all. The main focus for Parsoid is on
7313 # round-tripping, so this output is ok for now. TODO: revisit!
7314 !! test
7315 Wikitext table with html-syntax row
7316 !! wikitext
7317 {|
7318 |-
7319 <td>foo</td>
7320 |}
7321 !! html/parsoid
7322 <table>
7323 <tbody>
7324 <tr>
7325 <td>foo</td></tr></tbody></table>
7326 !! end
7327
7328 ## Remex doesn't account for fostered content.
7329 !! test
7330 Fostered content in tables: Plain text
7331 !! options
7332 parsoid=wt2html
7333 !! wikitext
7334 {|
7335 |-
7336 a
7337 |}
7338 !! html/php
7339 <table>
7340
7341 a
7342 </table>
7343
7344 !! html/php+tidy
7345
7346
7347 a
7348 <table></table>
7349 !! html/parsoid
7350 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>
7351 a</p>
7352 <table>
7353 <tbody><tr class="mw-empty-elt" data-parsoid='{"startTagSrc":"|-"}'></tr></tbody></table>
7354 !! end
7355
7356 !! test
7357 Fostered content in tables: Lists
7358 !! options
7359 parsoid=wt2html,html2html
7360 !! wikitext
7361 {|
7362 |-
7363 *a
7364 |}
7365 !! html/php
7366 <table>
7367
7368 <ul><li>a</li></ul>
7369 </table>
7370
7371 !! html/php+tidy
7372 <ul><li>a</li></ul><table>
7373
7374
7375 </table>
7376 !! html/parsoid
7377 <ul data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><li>a</li></ul><table>
7378 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7379
7380 </tr></tbody></table>
7381 !! end
7382
7383 !! test
7384 Template generated table cell with attributes
7385 !! wikitext
7386 {|
7387 |-
7388 {{table_attribs_4}} ||a||b
7389 |}
7390 !! html/php+tidy
7391 <table>
7392
7393 <tbody><tr>
7394 <td style="background-color:#DC241f;" width="10px"></td>
7395 <td>a</td>
7396 <td>b
7397 </td></tr></tbody></table>
7398 !! html/parsoid
7399 <table>
7400 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7401 <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>
7402 !! end
7403
7404 !! test
7405 Parsoid: Round-trip tables directly followed by content (T53219)
7406 !! options
7407 parsoid=wt2html,wt2wt
7408 !! wikitext
7409 {|
7410 |foo
7411 |} bar
7412
7413 {|
7414 |baz
7415 |}<b>quux</b>
7416 !! html+tidy
7417 <table>
7418 <tbody><tr>
7419 <td>foo
7420 </td></tr></tbody></table><p> bar
7421 </p><table>
7422 <tbody><tr>
7423 <td>baz
7424 </td></tr></tbody></table><p><b>quux</b>
7425 </p>
7426 !! end
7427
7428 !! test
7429 Parsoid: Default to a newline after tables in new content (T53219)
7430 !! options
7431 parsoid=html2wt
7432 !! html/parsoid
7433 <table><tbody>
7434 <tr><td>foo</td></tr></tbody></table> bar
7435 <table><tbody>
7436 <tr><td>baz</td></tr></tbody></table><b>quux</b>
7437 !! wikitext
7438 {|
7439 |foo
7440 |}
7441 <nowiki> </nowiki>bar
7442 {|
7443 |baz
7444 |}
7445 '''quux'''
7446 !! end
7447
7448 !! test
7449 Parsoid: Row-syntax table headings followed by comment & table cells
7450 !! options
7451 parsoid=wt2html,wt2wt
7452 !! wikitext
7453 {|
7454 !foo||bar
7455 <!-- foo --> ||baz||quux
7456 |}
7457 !! html/php
7458 <table>
7459 <tr>
7460 <th>foo</th>
7461 <th>bar
7462 </th>
7463 <td>baz</td>
7464 <td>quux
7465 </td></tr></table>
7466
7467 !! html/parsoid
7468 <table>
7469 <tbody><tr><th>foo</th><th>bar
7470 <!-- foo --></th><td> baz </td><td>quux</td></tr>
7471 </tbody></table>
7472 !! end
7473
7474 !!test
7475 Parsoid: Recover better from broken table attributes
7476 !!options
7477 parsoid=wt2html
7478 !!wikitext
7479 {| class="foo
7480 | class="bar" |
7481 foo
7482 |}
7483 !!html/php+tidy
7484 <table class="foo">
7485 <tbody><tr>
7486 <td class="bar">
7487 <p>foo
7488 </p>
7489 </td></tr></tbody></table>
7490 !!html/parsoid
7491 <table class="foo">
7492 <tr>
7493 <td class="bar">
7494 <p>foo</p></td></tr>
7495 </tbody></table>
7496 !!end
7497
7498 !! test
7499 Tables: Digest broken attributes on table and tr tag
7500 !! options
7501 parsoid=wt2html
7502 !! wikitext
7503 {| || |} ++
7504 |- || || ++ --
7505 |- > [
7506 |}
7507 !! html
7508 <table>
7509 <tbody>
7510 <tr class='mw-empty-elt'></tr>
7511 <tr class='mw-empty-elt'></tr>
7512 </tbody></table>
7513 !! end
7514
7515 !! test
7516 Table with missing opening <tr> tag
7517 !! options
7518 parsoid=wt2html,wt2wt
7519 !! wikitext
7520 <table>
7521 <td>foo</td>
7522 </tr>
7523 </table>
7524 !! html+tidy
7525 <table>
7526 <tbody><tr><td>foo</td>
7527 </tr>
7528 </tbody></table>
7529 !! end
7530
7531 # T137406: Whitespace in the HTML
7532 !! test
7533 1. Generate correct wikitext for tables with thead/tbody/tfoot
7534 !! options
7535 parsoid=html2wt
7536 !! html/parsoid
7537 <table>
7538 <caption>Test</caption>
7539 <thead>
7540 <tr>
7541 <th>Month</th>
7542 <th>Savings</th>
7543 </tr>
7544 </thead>
7545 <tbody>
7546 <tr>
7547 <td>January</td>
7548 <td>$100</td>
7549 </tr>
7550 <tr>
7551 <td>February</td>
7552 <td>$80</td>
7553 </tr>
7554 </tbody>
7555 <tfoot>
7556 <tr>
7557 <td>Sum</td>
7558 <td>$180</td>
7559 </tr>
7560 </tfoot>
7561 </table>
7562 !! wikitext
7563 {|
7564 |+Test
7565 !Month
7566 !Savings
7567 |-
7568 |January
7569 |$100
7570 |-
7571 |February
7572 |$80
7573 |-
7574 |Sum
7575 |$180
7576 |}
7577 !! html/php+tidy
7578 <table>
7579 <caption>Test
7580 </caption>
7581 <tbody><tr>
7582 <th>Month
7583 </th>
7584 <th>Savings
7585 </th></tr>
7586 <tr>
7587 <td>January
7588 </td>
7589 <td>$100
7590 </td></tr>
7591 <tr>
7592 <td>February
7593 </td>
7594 <td>$80
7595 </td></tr>
7596 <tr>
7597 <td>Sum
7598 </td>
7599 <td>$180
7600 </td></tr></tbody></table>
7601 !! end
7602
7603 # T137406: No whitespace in the HTML
7604 !! test
7605 2. Generate correct wikitext for tables with thead/tbody/tfoot
7606 !! options
7607 parsoid=html2wt
7608 !! html/parsoid
7609 <table><thead><tr><th>heading</th></tr></thead><tbody><tr><td>foo</td></tr></tbody></table>
7610 !! wikitext
7611 {|
7612 !heading
7613 |-
7614 |foo
7615 |}
7616 !! end
7617
7618 !! test
7619 Wikitext tables can be nested inside HTML tables
7620 !! options
7621 parsoid=html2wt
7622 !! html
7623 <table data-parsoid='{"stx":"html"}'>
7624 <tr><td>
7625 <table>
7626 <tr><td>foo</td></tr>
7627 </table>
7628 </td></tr>
7629 </table>
7630 !! wikitext
7631 <table>
7632 <tr><td>
7633 {|
7634 |foo
7635 |}
7636 </td></tr>
7637 </table>
7638 !! end
7639
7640 ###
7641 ### Internal links
7642 ###
7643 !! test
7644 Plain link, capitalized
7645 !! wikitext
7646 [[Main Page]]
7647 !! html
7648 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
7649 </p>
7650 !! end
7651
7652 !! test
7653 Plain link, uncapitalized
7654 !! wikitext
7655 [[main Page]]
7656 !! html
7657 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
7658 </p>
7659 !! end
7660
7661 !! test
7662 Piped link
7663 !! wikitext
7664 [[Main Page|The Main Page]]
7665 !! html
7666 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7667 </p>
7668 !! end
7669
7670 !! test
7671 Piped link with comment in link text
7672 !! wikitext
7673 [[Main Page|The Main<!--front--> Page]]
7674 !! html
7675 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7676 </p>
7677 !! end
7678
7679 !! test
7680 Piped link with multiple pipe characters in link text
7681 !! wikitext
7682 [[Main Page||The|Main|Page|]]
7683 !! html/php
7684 <p><a href="/wiki/Main_Page" title="Main Page">|The|Main|Page|</a>
7685 </p>
7686 !! html/parsoid
7687 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">|The|Main|Page|</a></p>
7688 !! end
7689
7690 !! test
7691 Piped link with no link text
7692 !! wikitext
7693 [[Thomas Bek (bishop of St David's)|]]
7694 !! html/php
7695 <p>[[Thomas Bek (bishop of St David's)|]]
7696 </p>
7697 !! html/parsoid
7698 <p>[[Thomas Bek (bishop of St David's)|]]</p>
7699 !! end
7700
7701 !! test
7702 Piped link with empty link text
7703 !! wikitext
7704 [[Main Page|<nowiki/>]] - empty nowiki
7705 [[Main Page| ]] - empty space
7706 [[Main Page|&nbsp;]] - empty non breaking space
7707 !! html/php
7708 <p><a href="/wiki/Main_Page" title="Main Page"></a> - empty nowiki
7709 <a href="/wiki/Main_Page" title="Main Page"> </a> - empty space
7710 <a href="/wiki/Main_Page" title="Main Page">&#160;</a> - empty non breaking space
7711 </p>
7712 !! html/parsoid
7713 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:Nowiki"></span></a> - empty nowiki
7714 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page"> </a> - empty space
7715 <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>
7716 !! end
7717
7718 !! test
7719 Broken link
7720 !! wikitext
7721 [[Zigzagzogzagzig]]
7722 !! html
7723 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig</a>
7724 </p>
7725 !! end
7726
7727 !! test
7728 Broken link with fragment
7729 !! wikitext
7730 [[Zigzagzogzagzig#zug]]
7731 !! html
7732 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig#zug</a>
7733 </p>
7734 !! end
7735
7736 !! test
7737 Special page link with fragment
7738 !! wikitext
7739 [[Special:Version#anchor]]
7740 !! html
7741 <p><a href="/wiki/Special:Version#anchor" title="Special:Version">Special:Version#anchor</a>
7742 </p>
7743 !! end
7744
7745 !! test
7746 Nonexistent special page link with fragment
7747 !! wikitext
7748 [[Special:ThisNameWillHopefullyNeverBeUsed#anchor]]
7749 !! html
7750 <p><a href="/wiki/Special:ThisNameWillHopefullyNeverBeUsed" class="new" title="Special:ThisNameWillHopefullyNeverBeUsed (page does not exist)">Special:ThisNameWillHopefullyNeverBeUsed#anchor</a>
7751 </p>
7752 !! end
7753
7754 !! test
7755 Link with prefix
7756 !! wikitext
7757 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
7758 !! html
7759 <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>
7760 </p>
7761 !! end
7762
7763 !! test
7764 Link with suffix
7765 !! wikitext
7766 [[Main Page]]xxx, [[Main Page]]XXX, [[Main Page]]!!!
7767 !! html
7768 <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>!!!
7769 </p>
7770 !! end
7771
7772 !! article
7773 prefixed article
7774 !! text
7775 Some text
7776 !! endarticle
7777
7778 !! test
7779 T45661: Piped links with identical prefixes
7780 !! wikitext
7781 [[prefixed article|prefixed articles with spaces]]
7782
7783 [[prefixed article|prefixed articlesaoeu]]
7784
7785 [[Main Page|Main Page test]]
7786 !! html
7787 <p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articles with spaces</a>
7788 </p><p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articlesaoeu</a>
7789 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page test</a>
7790 </p>
7791 !! end
7792
7793
7794 !! test
7795 Link with HTML entity in suffix / tail
7796 !! wikitext
7797 [[Main Page]]&quot;, [[Main Page]]&#97;
7798 !! html/php
7799 <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;
7800 </p>
7801 !! html/parsoid
7802 <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>
7803 !! end
7804
7805 !! test
7806 Link with 3 brackets
7807 !! wikitext
7808 [[[Main Page]]]
7809 Foo [[[Main Page]]]
7810 !! html
7811 <p>[[[Main Page]]]
7812 Foo [[[Main Page]]]
7813 </p>
7814 !! end
7815
7816 !! test
7817 Link with 4 brackets
7818 !! wikitext
7819 [[[[Main Page]]]]
7820 !! html
7821 <p>[[<a href="/wiki/Main_Page" title="Main Page">Main Page</a>]]
7822 </p>
7823 !! end
7824
7825 !! test
7826 Piped link with 3 brackets
7827 !! wikitext
7828 [[[main page|the main page]]]
7829 !! html
7830 <p>[[[main page|the main page]]]
7831 </p>
7832 !! end
7833
7834 !! test
7835 Piped link with extlink-like text
7836 !! wikitext
7837 [[Main Page|[bar]]]
7838 [[Main Page|This is a [bar]]]
7839 [[Main Page|[bar]]
7840 !! html/php
7841 <p><a href="/wiki/Main_Page" title="Main Page">[bar]</a>
7842 <a href="/wiki/Main_Page" title="Main Page">This is a [bar]</a>
7843 <a href="/wiki/Main_Page" title="Main Page">[bar</a>
7844 </p>
7845 !! html/parsoid
7846 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar]</a>
7847 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>This is a [bar]</a>
7848 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar</a></p>
7849 !! end
7850
7851 !! test
7852 Link with multiple pipes
7853 !! wikitext
7854 [[Main Page|The|Main|Page]]
7855 !! html
7856 <p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a>
7857 </p>
7858 !! end
7859
7860 !! test
7861 Anchor containing a #. (T65430)
7862 !! config
7863 wgFragmentMode=[ 'html5', 'legacy' ]
7864 !! wikitext
7865 [[Main Page#And#Link]]
7866 !! html/php
7867 <p><a href="/wiki/Main_Page#And#Link" title="Main Page">Main Page#And#Link</a>
7868 </p>
7869 !! html/parsoid
7870 <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>
7871 !! end
7872
7873 !! test
7874 Link to namespaces
7875 !! wikitext
7876 [[Talk:Parser testing]], [[Meta:Disclaimers]]
7877 !! html
7878 <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>
7879 </p>
7880 !! end
7881
7882 !! test
7883 Link with space in namespace
7884 !! wikitext
7885 [[User talk:Foo bar]]
7886 !! html
7887 <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>
7888 </p>
7889 !! end
7890
7891 !! article
7892 MemoryAlpha:AlphaTest
7893 !! text
7894 This is an article in the MemoryAlpha namespace
7895 (which shadows the memoryalpha interwiki link).
7896 !! endarticle
7897
7898 !! test
7899 Namespace takes precedence over interwiki link (T53680)
7900 !! wikitext
7901 [[MemoryAlpha:AlphaTest]]
7902 !! html
7903 <p><a href="/wiki/MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a>
7904 </p>
7905 !! end
7906
7907 # The previous test doesn't work correctly in html2*, due to not recognizing the
7908 # link as an internal one. This one checks for the correct behavior.
7909 !! test
7910 Link to namespace preferred over interwiki with correct rel attribute
7911 !! options
7912 parsoid=html2wt,html2html
7913 !! html/parsoid
7914 <p><a rel="mw:WikiLink" href="./MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a></p>
7915 !! wikitext
7916 [[MemoryAlpha:AlphaTest]]
7917 !! end
7918
7919 !! test
7920 Piped link to namespace
7921 !! wikitext
7922 [[Meta:Disclaimers|The disclaimers]]
7923 !! html
7924 <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>
7925 </p>
7926 !! end
7927
7928 !! test
7929 Link containing }
7930 !! wikitext
7931 [[Usually caused by a typo (oops}]]
7932 !! html
7933 <p>[[Usually caused by a typo (oops}]]
7934 </p>
7935 !! end
7936
7937 !! article
7938 7% Solution
7939 !! text
7940 Just a test of an article title containing a percent.
7941 !! endarticle
7942
7943 !! test
7944 Link containing % (not as a hex sequence)
7945 !! wikitext
7946 [[7% Solution]]
7947 [[7% Solution|7%25 Solution]]
7948 !! html/php
7949 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
7950 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
7951 </p>
7952 !! html/parsoid
7953 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
7954 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
7955 !! end
7956
7957 # note that the parsoid HTML is identical to the previous test output,
7958 # so the previous test ensures that the html2wt mode will generate the
7959 # "not as a hex sequence" wikitext.
7960 !! test
7961 Link containing % as a single hex sequence interpreted to char
7962 !! options
7963 parsoid=wt2wt,wt2html,html2html
7964 !! wikitext
7965 [[7%25 Solution]]
7966 [[7%25 Solution|7%25 Solution]]
7967 !! html/php
7968 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
7969 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
7970 </p>
7971 !! html/parsoid
7972 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
7973 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
7974 !!end
7975
7976 !! test
7977 Link containing % as a double hex sequence interpreted to hex sequence
7978 !! wikitext
7979 [[7%2525 Solution]]
7980 !! html
7981 <p>[[7%2525 Solution]]
7982 </p>
7983 !!end
7984
7985 ## Example for such a section: == < ==
7986 !! test
7987 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors
7988 !! config
7989 wgFragmentMode=[ 'html5', 'legacy' ]
7990 !! wikitext
7991 [[%23%3c]][[%23%3e]]
7992 !! html/php
7993 <p><a href="#&lt;">#&lt;</a><a href="#&gt;">#&gt;</a>
7994 </p>
7995 !! html/parsoid
7996 <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>
7997 !! end
7998
7999 ## Example for such a section: == < ==
8000 !! test
8001 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors (legacy)
8002 !! config
8003 wgFragmentMode=[ 'legacy' ]
8004 !! wikitext
8005 [[%23%3c]][[%23%3e]]
8006 !! html/php
8007 <p><a href="#.3C">#&lt;</a><a href="#.3E">#&gt;</a>
8008 </p>
8009 !! end
8010
8011 !! test
8012 Link containing "<#" and ">#" as a hex sequences
8013 !! wikitext
8014 [[%3c%23]][[%3e%23]]
8015 !! html
8016 <p>[[%3c%23]][[%3e%23]]
8017 </p>
8018 !! end
8019
8020 !! test
8021 Link containing an equals sign
8022 !! wikitext
8023 [[Special:BookSources/isbn=4-00-026157-6]]
8024 !! html/php
8025 <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>
8026 </p>
8027 !! html/parsoid
8028 <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>
8029 !! end
8030
8031 !! article
8032 Foo & bar
8033 !! text
8034 Just a test of an article title containing an ampersand
8035 !! endarticle
8036
8037 !! test
8038 Link containing an ampersand
8039 !! wikitext
8040 [[Foo & bar]]
8041
8042 [[Foo &amp; bar]]
8043
8044 [[Foo &amp;amp; bar]]
8045 !! html/php+tidy
8046 <p><a href="/wiki/Foo_%26_bar" title="Foo &amp; bar">Foo &amp; bar</a>
8047 </p><p><a href="/wiki/Foo_%26_bar" title="Foo &amp; bar">Foo &amp; bar</a>
8048 </p><p>[[Foo &amp;amp; bar]]
8049 </p>
8050 !! html/parsoid
8051 <p><a rel="mw:WikiLink" href="./Foo_&amp;_bar" title="Foo &amp; bar">Foo &amp; bar</a></p>
8052 <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>
8053 <p>[[Foo <span typeof="mw:Entity" data-parsoid='{"src":"&amp;amp;","srcContent":"&amp;"}'>&amp;</span>amp; bar]]</p>
8054 !! end
8055
8056 !! article
8057 Foo~bar
8058 !! text
8059 Just a test of an article title containing a tilde.
8060 !! endarticle
8061
8062 # note that links containing signatures, like [[Foo~~~~]], are
8063 # massaged by the pre-save transform (PST) and so the tildes are never
8064 # seen by the parser.
8065 !! test
8066 Link containing a tilde
8067 !! wikitext
8068 [[Foo~bar]]
8069 !! html/php
8070 <p><a href="/wiki/Foo~bar" title="Foo~bar">Foo~bar</a>
8071 </p>
8072 !! html/parsoid
8073 <p><a rel="mw:WikiLink" href="./Foo~bar" title="Foo~bar">Foo~bar</a></p>
8074 !! end
8075
8076 !! test
8077 Link containing double-single-quotes '' (T6598)
8078 !! wikitext
8079 [[Lista d''e paise d''o munno]]
8080 !! html/php
8081 <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>
8082 </p>
8083 !! html/parsoid
8084 <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>
8085 !! end
8086
8087 !! test
8088 Link containing double quotes and spaces
8089 !! wikitext
8090 [[Cool "Gator"]]
8091 !! html/php
8092 <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>
8093 </p>
8094 !! html/parsoid
8095 <p><a rel="mw:WikiLink" href='./Cool_"Gator"' title='Cool "Gator"'>Cool "Gator"</a></p>
8096 !! end
8097
8098 !! test
8099 File containing double quotes and spaces
8100 !! wikitext
8101 [[File:Cool "Gator".png]]
8102 !! html/parsoid
8103 <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>
8104 !! end
8105
8106 !! test
8107 Redirect containing double quotes and spaces
8108 !! wikitext
8109 #REDIRECT [[Cool "Gator"]]
8110 !! html/parsoid
8111 <link rel="mw:PageProp/redirect" href="./Cool_%22Gator%22" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Cool_%22Gator%22"},"sa":{"href":"Cool \"Gator\""}}'/>
8112 !! end
8113
8114 !! test
8115 Link containing double-single-quotes '' in text (T6598 sanity check)
8116 !! wikitext
8117 Some [[Link|pretty ''italics'' and stuff]]!
8118 !! html/php
8119 <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>!
8120 </p>
8121 !! html/parsoid
8122 <p>Some <a rel="mw:WikiLink" href="./Link" title="Link">pretty <i>italics</i> and stuff</a>!</p>
8123 !! end
8124
8125 !! test
8126 Link containing double-single-quotes '' in text embedded in italics (T6598 sanity check)
8127 !! wikitext
8128 ''Some [[Link|pretty ''italics'' and stuff]]!''
8129 !! html
8130 <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>
8131 </p>
8132 !! end
8133
8134 !! test
8135 Link with double quotes in title part (literal) and alternate part (interpreted)
8136 !! wikitext
8137 [[File:Denys_Savchenko_''Pentecoste''.jpg]]
8138
8139 [[''Pentecoste'']]
8140
8141 [[''Pentecoste''|Pentecoste]]
8142
8143 [[''Pentecoste''|''Pentecoste'']]
8144 !! html/php
8145 <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>
8146 </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>
8147 </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>
8148 </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>
8149 </p>
8150 !! html/parsoid
8151 <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>
8152 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">''Pentecoste''</a></p>
8153 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">Pentecoste</a></p>
8154 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''"><i>Pentecoste</i></a></p>
8155 !! end
8156
8157 !! test
8158 Broken image links with HTML captions (T41700)
8159 !! wikitext
8160 [[File:Nonexistent|<script></script>]]
8161 [[File:Nonexistent|100x100px|<script></script>]]
8162 [[File:Nonexistent|&lt;]]
8163 [[File:Nonexistent|a<i>b</i>c]]
8164 !! html/php
8165 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8166 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8167 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;</a>
8168 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">abc</a>
8169 </p>
8170 !! html/parsoid
8171 <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>
8172 <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>
8173 <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>
8174 <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>
8175 !! end
8176
8177 !! test
8178 Plain link to URL
8179 !! wikitext
8180 [[http://www.example.com]]
8181 !! html/php
8182 <p>[<a rel="nofollow" class="external autonumber" href="http://www.example.com">[1]</a>]
8183 </p>
8184 !! html/parsoid
8185 <p>[<a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com"></a>]</p>
8186 !! end
8187
8188 !! test
8189 Plain link to URL with link text
8190 !! wikitext
8191 [[http://www.example.com Link text]]
8192 !! html
8193 <p>[<a rel="nofollow" class="external text" href="http://www.example.com">Link text</a>]
8194 </p>
8195 !! end
8196
8197 !! test
8198 Plain link to protocol-relative URL
8199 !! wikitext
8200 [[//www.example.com]]
8201 !! html/php
8202 <p>[<a rel="nofollow" class="external autonumber" href="//www.example.com">[1]</a>]
8203 </p>
8204 !! html/parsoid
8205 <p>[<a rel="mw:ExtLink" class="external autonumber" href="//www.example.com"></a>]</p>
8206 !! end
8207
8208 !! test
8209 Plain link to protocol-relative URL with link text
8210 !! wikitext
8211 [[//www.example.com Link text]]
8212 !! html
8213 <p>[<a rel="nofollow" class="external text" href="//www.example.com">Link text</a>]
8214 </p>
8215 !! end
8216
8217 !! test
8218 Plain link to page with question mark in title
8219 !! wikitext
8220 [[A?b]]
8221
8222 [[A?b|Baz]]
8223 !! html
8224 <p><a href="/wiki/A%3Fb" title="A?b">A?b</a>
8225 </p><p><a href="/wiki/A%3Fb" title="A?b">Baz</a>
8226 </p>
8227 !! end
8228
8229 # I'm fairly sure the expected result here is wrong.
8230 # We want these to be URL links, not pseudo-pages with URLs for titles....
8231 # However the current output is also pretty screwy.
8232 #
8233 # ----
8234 # I'm changing it to match the current output--it arguably makes more
8235 # sense in the light of the test above. Old expected result was:
8236 #<p>Piped link to URL: <a href="/index.php?title=Http://www.example.com&amp;action=edit" class="new">an example URL</a>
8237 #</p>
8238 # But I think this test is bordering on "garbage in, garbage out" anyway.
8239 # -- wtm
8240 !! test
8241 Piped link to URL
8242 !! wikitext
8243 Piped link to URL: [[http://www.example.com|an example URL]]
8244 !! html/php
8245 <p>Piped link to URL: [<a rel="nofollow" class="external text" href="http://www.example.com%7Can">example URL</a>]
8246 </p>
8247 !! html/parsoid
8248 <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>
8249 !! end
8250
8251 !! test
8252 Plain link in template argument
8253 !! options
8254 parsoid=wt2html
8255 !! wikitext
8256 {{echo|[http://www.example.com |123]}}
8257
8258 {{echo|[[http://www.example.com |123]]}}
8259
8260 {{echo|[[http://www.example.com |123]}}
8261
8262 {{echo|[http://www.example.com |123]]}}
8263 !! html/php
8264 <p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8265 </p><p>[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>]
8266 </p><p>{{echo|[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>}}
8267 </p><p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8268 </p>
8269 !! html/parsoid
8270 <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>
8271
8272 <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>
8273
8274 <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>
8275
8276 <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>
8277 !! end
8278
8279 !! test
8280 T2002: [[page|http://url/]] should link to page, not http://url/
8281 !! wikitext
8282 [[Main Page|http://url/]]
8283 !! html/php
8284 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
8285 </p>
8286 !! html/parsoid
8287 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">http://url/</a></p>
8288 !! end
8289
8290 # Parsoid does not mark self-links, by design.
8291 !! test
8292 T2337: Escaped self-links should be bold
8293 !! options
8294 title=[[Bug462]]
8295 !! wikitext
8296 [[Bu&#103;462]] [[Bug462]]
8297 !! html/php+tidy
8298 <p><a class="mw-selflink selflink">Bu&#103;462</a> <a class="mw-selflink selflink">Bug462</a>
8299 </p>
8300 !! html/parsoid
8301 <p><a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a> <a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a></p>
8302 !! end
8303
8304 !! test
8305 Self-link to section should not be bold
8306 !! options
8307 title=[[Main Page]]
8308 !! wikitext
8309 [[Main Page#section]]
8310 !! html
8311 <p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
8312 </p>
8313 !! end
8314
8315 !! article
8316 00
8317 !! text
8318 This is 00.
8319 !! endarticle
8320
8321 !!test
8322 Self-link to numeric title
8323 !!options
8324 title=[[0]]
8325 !! wikitext
8326 [[0]]
8327 !! html
8328 <p><a class="mw-selflink selflink">0</a>
8329 </p>
8330 !!end
8331
8332 !!test
8333 Link to numeric-equivalent title
8334 !!options
8335 title=[[0]]
8336 !! wikitext
8337 [[00]]
8338 !! html
8339 <p><a href="/wiki/00" title="00">00</a>
8340 </p>
8341 !!end
8342
8343 !! test
8344 <nowiki> inside a link
8345 !! wikitext
8346 [[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
8347 !! html
8348 <p>[[Main Page]] <a href="/wiki/Main_Page" title="Main Page">the main page [it's not very good]</a>
8349 </p>
8350 !! end
8351
8352 !! test
8353 Non-breaking spaces in title
8354 !! wikitext
8355 [[&nbsp; Main &nbsp; Page &nbsp;]]
8356 !! html
8357 <p><a href="/wiki/Main_Page" title="Main Page">&#160; Main &#160; Page &#160;</a>
8358 </p>
8359 !!end
8360
8361 # Add new article for the test below so that it doesn't red-link
8362 !! article
8363 Foo bar baz
8364 !! text
8365 boo
8366 !! endarticle
8367
8368 !! test
8369 Multiple spaces in titles should normalize to a single underscore
8370 !! options
8371 parsoid=wt2html,wt2wt
8372 !! wikitext
8373 [[Foo bar baz|x]]
8374 [[Foo bar baz|x]]
8375 [[Foo bar baz|x]]
8376 !! html/php
8377 <p><a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8378 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8379 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8380 </p>
8381 !! html/parsoid
8382 <p><a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8383 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8384 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8385 </p>
8386 !! end
8387
8388 !! test
8389 Internal link with ca linktrail, surrounded by bold apostrophes (T29473 primary issue)
8390 !! options
8391 language=ca
8392 !! wikitext
8393 '''[[Main Page]]'''
8394 !! html
8395 <p><b><a href="/wiki/Main_Page" title="Main Page">Main Page</a></b>
8396 </p>
8397 !! end
8398
8399 !! test
8400 Internal link with ca linktrail, surrounded by italic apostrophes (T29473 primary issue)
8401 !! options
8402 language=ca
8403 !! wikitext
8404 ''[[Main Page]]''
8405 !! html
8406 <p><i><a href="/wiki/Main_Page" title="Main Page">Main Page</a></i>
8407 </p>
8408 !! end
8409
8410 !! test
8411 Internal link with en linktrail: no apostrophes (T29473)
8412 !! options
8413 language=en
8414 !! wikitext
8415 [[Something]]'nice
8416 !! html
8417 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (page does not exist)">Something</a>'nice
8418 </p>
8419 !! end
8420
8421 !! test
8422 Internal link with ca linktrail with apostrophes (T29473)
8423 !! options
8424 language=ca
8425 !! wikitext
8426 [[Something]]'nice
8427 !! html
8428 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (encara no existeix)">Something'nice</a>
8429 </p>
8430 !! end
8431
8432 !! test
8433 Internal link with kaa linktrail with apostrophes (T29473)
8434 !! options
8435 language=kaa
8436 !! wikitext
8437 [[Something]]'nice
8438 !! html
8439 <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>
8440 </p>
8441 !! end
8442
8443 !! test
8444 Link with multiple ":" in a subpage-supporting namespace (T65636)
8445 !! wikitext
8446 [[User:Foo/Test/63636:Bar|Test]]
8447 !! html/php
8448 <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>
8449 </p>
8450 !! html/parsoid
8451 <p><a rel="mw:WikiLink" href="./User:Foo/Test/63636:Bar" title="User:Foo/Test/63636:Bar">Test</a></p>
8452 !! end
8453
8454 ## Mainly a sanity check for Parsoid
8455 !! test
8456 Handle title parsing for subpages
8457 !! options
8458 title=[[/123123]]
8459 subpage
8460 !! wikitext
8461 123
8462 !! html/php
8463 <p>123
8464 </p>
8465 !! html/parsoid
8466 <p>123</p>
8467 !! end
8468
8469 !! article
8470 User:Test/123
8471 !! text
8472 test 123
8473 !! endarticle
8474
8475 !! test
8476 Link to a subpage from a namespace other than main
8477 !! options
8478 title=[[User:Test]]
8479 subpage
8480 !! wikitext
8481 [[/123]]
8482 !! html/php
8483 <p><a href="/wiki/User:Test/123" title="User:Test/123">/123</a>
8484 </p>
8485 !! html/parsoid
8486 <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>
8487 !! end
8488
8489 !! test
8490 Ensure that transclusion titles are not url-decoded
8491 !! options
8492 subpage title=[[Test]]
8493 parsoid=wt2html
8494 !! wikitext
8495 {{Bar%C3%A9}} {{/Bar%C3%A9}}
8496 !! html/php
8497 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}
8498 </p>
8499 !! html/parsoid
8500 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}</p>
8501 !! end
8502
8503 !! test
8504 Purely hash wikilink
8505 !! options
8506 title=[[User:Test/123]]
8507 subpage
8508 !! wikitext
8509 [[#a|b]]
8510 !! html/php
8511 <p><a href="#a">b</a>
8512 </p>
8513 !! html/parsoid
8514 <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>
8515 !! end
8516
8517 !! test
8518 Serialization of purely hash wikilink
8519 !! options
8520 title=[[User:Test/123]]
8521 subpage
8522 parsoid=html2wt
8523 !! html/parsoid
8524 <p><a href="#a">[[</a></p>
8525 !! wikitext
8526 [[#a|<nowiki>[[</nowiki>]]
8527 !! html/php
8528 <p><a href="#a">[[</a>
8529 </p>
8530 !! end
8531
8532 !! test
8533 1. Interaction of linktrail and template encapsulation
8534 !! wikitext
8535 {{echo|[[Foo]]}}l
8536 !! html/parsoid
8537 <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>
8538 !! end
8539
8540 !! test
8541 2. Interaction of linktrail and template encapsulation
8542 !! options
8543 parsoid
8544 !! wikitext
8545 {{echo|Some [[Fool]]}}s
8546 !! html
8547 <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>
8548 !! end
8549
8550 !! test
8551 3. Interaction of linktrail and template encapsulation
8552 !! options
8553 parsoid
8554 !! wikitext
8555 {{echo|Some [[Fool]]s are '''bold and foolish'''}}
8556 !! html
8557 <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>
8558 !! end
8559
8560 !! article
8561 Söfnuður
8562 !! text
8563 Test.
8564 !! endarticle
8565
8566 !! test
8567 Internal link with is link prefix
8568 !! options
8569 language=is
8570 !! wikitext
8571 Aðrir mótmælenda[[söfnuður|söfnuðir]] og
8572 !! html
8573 <p>Aðrir <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a> og
8574 </p>
8575 !! end
8576
8577 !! article
8578 Mótmælendatrú
8579 !! text
8580 Test.
8581 !! endarticle
8582
8583 !! test
8584 Internal link with is link trail and link prefix
8585 !! options
8586 language=is
8587 !! wikitext
8588 [[mótmælendatrú|xxx]]ar
8589 [[mótmælendatrú]]ar
8590 mótmælenda[[söfnuður]]
8591 mótmælenda[[söfnuður|söfnuðir]]
8592 mótmælenda[[söfnuður|söfnuðir]]xxx
8593 !! html
8594 <p><a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">xxxar</a>
8595 <a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">mótmælendatrúar</a>
8596 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuður</a>
8597 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a>
8598 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðirxxx</a>
8599 </p>
8600 !! end
8601
8602 !! test
8603 Parsoid link trail escaping
8604 !! options
8605 parsoid=html2wt,html2html
8606 !! html/parsoid
8607 <p><a rel="mw:WikiLink" href="./Apple" title="Apple">apple</a>s</p>
8608 !! wikitext
8609 [[apple]]<nowiki/>s
8610 !! end
8611
8612 !! test
8613 Parsoid link prefix escaping
8614 !! options
8615 language=is
8616 parsoid=html2wt,html2html
8617 !! html/parsoid
8618 <p>Aðrir mótmælenda<a rel="mw:WikiLink" href="./Söfnuður" title="Söfnuður">söfnuður</a></p>
8619 !! wikitext
8620 Aðrir mótmælenda<nowiki/>[[söfnuður]]
8621 !! end
8622
8623 !! test
8624 Parsoid link bracket escaping
8625 !! options
8626 parsoid=html2wt,html2html
8627 !! html/parsoid
8628 <p><a rel="mw:WikiLink" href="./Test" title="Test">Test</a></p>
8629 <p>[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]</p>
8630 <p>[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]</p>
8631 <p>[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]</p>
8632 <p>[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]</p>
8633 <p>[[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]]</p>
8634 !! wikitext
8635 [[Test]]
8636
8637 [<nowiki/>[[Test]]]
8638
8639 [[[[Test]]]]
8640
8641 [[[<nowiki/>[[Test]]]]]
8642
8643 [[[[[[Test]]]]]]
8644
8645 [[[[[<nowiki/>[[Test]]]]]]]
8646 !! end
8647
8648 !! test
8649 Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved
8650 !! wikitext
8651 [[Foo| bar]]
8652
8653 [[Foo| ''bar'']]
8654
8655 [http://wp.org foo]
8656
8657 [http://wp.org ''foo'']
8658 !! html
8659 <p><a href="/wiki/Foo" title="Foo"> bar</a>
8660 </p><p><a href="/wiki/Foo" title="Foo"> <i>bar</i></a>
8661 </p><p><a rel="nofollow" class="external text" href="http://wp.org">foo</a>
8662 </p><p><a rel="nofollow" class="external text" href="http://wp.org"><i>foo</i></a>
8663 </p>
8664 !! end
8665
8666 !! test
8667 Parsoid: Scoped parsing should handle mixed transclusions and plain text
8668 !! wikitext
8669 [[Foo|{{echo|a}} b {{echo|c}}]]
8670 !! html/parsoid
8671 <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>
8672 !! end
8673
8674 !! test
8675 Link with angle bracket after anchor
8676 !! config
8677 wgFragmentMode=[ 'html5', 'legacy' ]
8678 !! wikitext
8679 [[Foo#<bar>]]
8680 !! html/php
8681 <p><a href="/wiki/Foo#&lt;bar&gt;" title="Foo">Foo#&lt;bar&gt;</a>
8682 </p>
8683 !! html/parsoid
8684 <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>
8685 !! end
8686
8687 !! test
8688 Link with angle bracket after anchor (legacy)
8689 !! config
8690 wgFragmentMode=[ 'legacy' ]
8691 !! wikitext
8692 [[Foo#<bar>]]
8693 !! html/php
8694 <p><a href="/wiki/Foo#.3Cbar.3E" title="Foo">Foo#&lt;bar&gt;</a>
8695 </p>
8696 !! end
8697
8698 ###
8699 ### Interwiki links (see maintenance/interwiki.sql)
8700 ###
8701
8702 !! test
8703 Inline interwiki link
8704 !! options
8705 parsoid=wt2html,wt2wt,html2html
8706 !! wikitext
8707 [[MeatBall:SoftSecurity]]
8708 !! html/php
8709 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
8710 </p>
8711 !! html/parsoid
8712 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a></p>
8713 !! end
8714
8715 !! test
8716 Inline interwiki link with empty title (T4372)
8717 !! options
8718 parsoid=wt2html,wt2wt,html2html
8719 !! wikitext
8720 [[MeatBall:]]
8721 !! html/php
8722 <p><a href="http://www.usemod.com/cgi-bin/mb.pl" class="extiw" title="meatball:">MeatBall:</a>
8723 </p>
8724 !! html/parsoid
8725 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?" title="meatball:">MeatBall:</a></p>
8726 !! end
8727
8728 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
8729 !! test
8730 Interwiki link encoding conversion (T3636)
8731 !! options
8732 parsoid=wt2html,wt2wt
8733 !! wikitext
8734 *[[Wikipedia:ro:Olteni&#0355;a]]
8735 *[[Wikipedia:ro:Olteni&#355;a]]
8736 !! html
8737 <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>
8738 <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>
8739
8740 !! html/php+tidy
8741 <ul>
8742 <li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
8743 <li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
8744 </ul>
8745 !! html/parsoid
8746 <ul>
8747 <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>
8748 <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>
8749 </ul>
8750 !! end
8751
8752 !! test
8753 Interwiki link with fragment (T4130)
8754 !! wikitext
8755 [[MeatBall:SoftSecurity#foo]]
8756 !! html
8757 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity#foo</a>
8758 </p>
8759 !! end
8760
8761 !! test
8762 Link scenarios with escaped fragments
8763 !! config
8764 wgFragmentMode=[ 'html5', 'legacy' ]
8765 !! wikitext
8766 [[#Is this great?]]
8767 [[Foo#Is this great?]]
8768 [[meatball:Foo#Is this great?]]
8769 !! html/php
8770 <p><a href="#Is_this_great?">#Is this great?</a>
8771 <a href="/wiki/Foo#Is_this_great?" title="Foo">Foo#Is this great?</a>
8772 <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>
8773 </p>
8774 !! html/parsoid
8775 <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>
8776 <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>
8777 <a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?Foo#Is_this_great?" title="meatball:Foo" data-parsoid='{"stx":"simple","a":{"href":"http://www.usemod.com/cgi-bin/mb.pl?Foo#Is_this_great?"},"sa":{"href":"meatball:Foo#Is this great?"},"isIW":true}'>meatball:Foo#Is this great?</a></p>
8778 !! end
8779
8780 !! test
8781 Link scenarios with escaped fragments (legacy)
8782 !! config
8783 wgFragmentMode=[ 'legacy' ]
8784 !! wikitext
8785 [[#Is this great?]]
8786 [[Foo#Is this great?]]
8787 [[meatball:Foo#Is this great?]]
8788 !! html/php
8789 <p><a href="#Is_this_great.3F">#Is this great?</a>
8790 <a href="/wiki/Foo#Is_this_great.3F" title="Foo">Foo#Is this great?</a>
8791 <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>
8792 </p>
8793 !! end
8794
8795 # Ideally the wikipedia: prefix here should be proto-relative too
8796 # [CSA]: this is kind of a bogus test, as the PHP parser test doesn't
8797 # define the 'en' prefix, and originally the test used 'wikipedia',
8798 # which isn't a localinterwiki prefix hence the links to the 'en:Foo'
8799 # article.
8800 !! test
8801 Different interwiki prefixes mapping to the same URL
8802 !! wikitext
8803 [[:en:Foo]]
8804
8805 [[:en:Foo|Foo]]
8806
8807 [[wikipedia:Foo]]
8808
8809 [[:wikipedia:Foo|Foo]]
8810
8811 [[wikipedia:en:Foo]]
8812
8813 [[:wikipedia:en:Foo]]
8814
8815 [[ wikiPEdia :Foo]]
8816 !! html/parsoid
8817 <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>
8818
8819 <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>
8820
8821 <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>
8822
8823 <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>
8824
8825 <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>
8826
8827 <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>
8828
8829 <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>
8830 !! end
8831
8832 !! test
8833 Interwiki links that cannot be represented in wiki syntax
8834 !! wikitext
8835 [[meatball:ok]]
8836 [[meatball:ok#foo|ok with fragment]]
8837 [[meatball:ok_as_well?|ok ending with ? mark]]
8838 [http://de.wikipedia.org/wiki/Foo?action=history has query]
8839 [http://de.wikipedia.org/wiki/#foo is just fragment]
8840
8841 !! html/php
8842 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?ok" class="extiw" title="meatball:ok">meatball:ok</a>
8843 <a href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" class="extiw" title="meatball:ok">ok with fragment</a>
8844 <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>
8845 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8846 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a>
8847 </p>
8848 !! html/parsoid
8849 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok" title="meatball:ok">meatball:ok</a>
8850 <a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" title="meatball:ok">ok with fragment</a>
8851 <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>
8852 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8853 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a></p>
8854 !! end
8855
8856 !! test
8857 Interwiki links: trail
8858 !! wikitext
8859 [[wikipedia:Foo|Ba]]r
8860 !! html/php
8861 <p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
8862 </p>
8863 !! html/parsoid
8864 <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>
8865 !! end
8866
8867 !! test
8868 Local interwiki link
8869 !! options
8870 parsoid=wt2html,wt2wt,html2html
8871 !! wikitext
8872 [[local:Template:Foo]]
8873 !! html/php
8874 <p><a href="/wiki/Template:Foo" title="Template:Foo">local:Template:Foo</a>
8875 </p>
8876 !! html/parsoid
8877 <p><a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">local:Template:Foo</a></p>
8878 !! end
8879
8880 # Parsoid does not mark self-links, by design.
8881 !! test
8882 Local interwiki link: self-link to current page
8883 !! options
8884 title=[[Main Page]]
8885 parsoid=wt2html,wt2wt,html2html
8886 !! wikitext
8887 [[local:Main Page]]
8888 !! html/php
8889 <p><a class="mw-selflink selflink">local:Main Page</a>
8890 </p>
8891 !! html/parsoid
8892 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:Main Page</a></p>
8893 !! end
8894
8895 !! test
8896 Local interwiki link: prefix only (T66167)
8897 !! options
8898 parsoid=wt2html,wt2wt,html2html
8899 !! wikitext
8900 [[local:]]
8901 !! html/php
8902 <p><a href="/wiki/Main_Page" title="Main Page">local:</a>
8903 </p>
8904 !! html/parsoid
8905 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:</a></p>
8906 !! end
8907
8908 !! test
8909 Local interwiki link: with additional interwiki prefix (T63357)
8910 !! options
8911 parsoid=wt2html,wt2wt,html2html
8912 !! wikitext
8913 [[local:meatball:Hello]]
8914 !! html/php
8915 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Hello" class="extiw" title="meatball:Hello">local:meatball:Hello</a>
8916 </p>
8917 !! html/parsoid
8918 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?Hello" title="meatball:Hello">local:meatball:Hello</a></p>
8919 !! end
8920
8921 !! test
8922 Multiple local interwiki link prefixes
8923 !! wikitext
8924 [[local:local:local:local:mi:local:Foo]]
8925 !! options
8926 parsoid=wt2html,wt2wt,html2html
8927 !! html/php
8928 <p><a href="/wiki/Foo" title="Foo">local:local:local:local:mi:local:Foo</a>
8929 </p>
8930 !! html/parsoid
8931 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">local:local:local:local:mi:local:Foo</a></p>
8932 !! end
8933
8934 !! test
8935 Interwiki link with percent encoded target
8936 !! wikitext
8937 [[:es:Nueva Guip%C3%BAzcoa|Nueva Guipúzcoa]]
8938 !! html/php
8939 <p><a href="http://es.wikipedia.org/wiki/Nueva_Guip%C3%BAzcoa" class="extiw" title="es:Nueva Guipúzcoa">Nueva Guipúzcoa</a>
8940 </p>
8941 !! html/parsoid
8942 <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>
8943 !! end
8944
8945 ###
8946 ### Interlanguage links
8947 ### Language links (so that searching for '### language' matches..)
8948 ###
8949
8950 !! test
8951 Interlanguage link
8952 !! wikitext
8953 Blah blah blah
8954 [[zh:Chinese]]
8955 !! html/php
8956 <p>Blah blah blah
8957 </p>
8958 !! html/parsoid
8959 <p>Blah blah blah</p>
8960 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8961 !! end
8962
8963 ## parsoid html2wt will lose the space variations
8964 !! test
8965 Interlanguage link with spacing
8966 !! options
8967 parsoid=wt2html,wt2wt,html2html
8968 !! wikitext
8969 Blah blah blah
8970 [[ zh : Chinese ]]
8971 !! html/php
8972 <p>Blah blah blah
8973 </p>
8974 !! html/parsoid
8975 <p>Blah blah blah</p>
8976 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8977 !! end
8978
8979 !! test
8980 Double interlanguage link
8981 !! wikitext
8982 Blah blah blah
8983 [[es:Spanish]]
8984 [[zh:Chinese]]
8985 !! html/php
8986 <p>Blah blah blah
8987 </p>
8988 !! html/parsoid
8989 <p>Blah blah blah</p>
8990 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
8991 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8992 !! end
8993
8994 ## parsoid html2wt will lose the space variations
8995 !! test
8996 Interlanguage link variations
8997 !! options
8998 parsoid=wt2html,wt2wt,html2html
8999 !! wikitext
9000 Blah blah blah
9001 [[ es :Spanish]]
9002 [[ ZH :Chinese]]
9003 [[es:Foo_bar]]
9004 !! html/php
9005 <p>Blah blah blah
9006 </p>
9007 !! html/parsoid
9008 <p>Blah blah blah</p>
9009 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish" />
9010 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese" />
9011 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar" />
9012 !! end
9013
9014 !! test
9015 Escaping of interlanguage links (T129218, T156308)
9016 !! wikitext
9017 Blah blah blah
9018 [[:es:Spanish]]
9019 [[ : zh : Chinese ]]
9020 !! html/php
9021 <p>Blah blah blah
9022 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
9023 <a href="http://zh.wikipedia.org/wiki/Chinese" class="extiw" title="zh:Chinese"> zh : Chinese </a>
9024 </p>
9025 !! html/parsoid
9026 <p>Blah blah blah
9027 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
9028 <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh : Chinese </a></p>
9029 !! end
9030
9031 !! test
9032 Multiple colons escaping interlanguage links
9033 !! options
9034 parsoid=wt2html
9035 !! wikitext
9036 [[:es:Spanish]]
9037 [[::es:Spanish]]
9038 [[:::es:Spanish]]
9039 !! html/php
9040 <p><a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
9041 [[::es:Spanish]]
9042 [[:::es:Spanish]]
9043 </p>
9044 !! html/parsoid
9045 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
9046 [[::es:Spanish]]
9047 [[:::es:Spanish]]</p>
9048 !! end
9049
9050 ## parsoid html2wt will normalize the space to _
9051 !! test
9052 Space and question mark encoding in interlanguage links (T95473)
9053 !! options
9054 parsoid=wt2html,wt2wt,html2html
9055 !! wikitext
9056 Blah blah blah
9057 [[es:Foo bar?]]
9058 !! html/php
9059 <p>Blah blah blah
9060 </p>
9061 !! html/parsoid
9062 <p>Blah blah blah</p>
9063 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar%3F" />
9064 !! end
9065
9066 !! test
9067 Interlanguage link, with prefix links
9068 !! options
9069 language=ln
9070 !! wikitext
9071 Blah blah blah
9072 [[zh:Chinese]]
9073 !! html/php
9074 <p>Blah blah blah
9075 </p>
9076 !! html/parsoid
9077 <p>Blah blah blah</p>
9078 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9079 !! end
9080
9081 !! test
9082 Double interlanguage link, with prefix links (T10897)
9083 !! options
9084 language=ln
9085 !! wikitext
9086 Blah blah blah
9087 [[es:Spanish]]
9088 [[zh:Chinese]]
9089 !! html/php
9090 <p>Blah blah blah
9091 </p>
9092 !! html/parsoid
9093 <p>Blah blah blah</p>
9094 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
9095 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9096 !! end
9097
9098 !! test
9099 "Extra" interlanguage links (T34189 / gerrit 111390)
9100 !! wikitext
9101 Blah blah blah
9102 [[mul:Article]]
9103 !! html/php
9104 <p>Blah blah blah
9105 </p>
9106 !! html/parsoid
9107 <p>Blah blah blah</p>
9108 <link rel="mw:PageProp/Language" title="Multilingual" href="http://wikisource.org/wiki/Article"/>
9109 !! end
9110
9111 ## PHP parser tests script needs an update
9112 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
9113 !! test
9114 Language links render as inline links if $wgInterwikiMagic=false
9115 !! options
9116 wgInterwikiMagic=false
9117 parsoid=wt2html,wt2wt,html2html
9118 !! wikitext
9119 Blah blah blah
9120 [[zh:Chinese]]
9121 !! html/parsoid
9122 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
9123 !! end
9124
9125 ## PHP parser tests script needs an update
9126 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
9127 !! test
9128 Language links render as inline links in the Talk namespace
9129 !! options
9130 title=Talk:Foo
9131 parsoid=wt2html,wt2wt,html2html
9132 !! wikitext
9133 Blah blah blah
9134 [[zh:Chinese]]
9135 !! html/parsoid
9136 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
9137 !! end
9138
9139 !! test
9140 Parsoid-specific test: Wikilinks with &nbsp; should RT properly
9141 !! options
9142 language=ln
9143 !! wikitext
9144 [[WW&nbsp;II]]
9145 !! html
9146 <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>
9147 </p>
9148 !! end
9149
9150 !! test
9151 Parsoid T55221: Wikilinks should be properly entity-escaped
9152 !! options
9153 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
9154 !! html/parsoid
9155 <p>He&amp;nbsp;llo <a href="./Foo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9156 <p>He&amp;nbsp;llo <a href="./He&amp;nbsp;llo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9157 !! wikitext
9158 He&amp;nbsp;llo [[Foo|He&amp;nbsp;llo]]
9159
9160 He&amp;nbsp;llo He&amp;nbsp;llo
9161 !! html/php
9162 <p>He&amp;nbsp;llo <a href="/wiki/Foo" title="Foo">He&amp;nbsp;llo</a>
9163 </p><p>He&amp;nbsp;llo He&amp;nbsp;llo
9164 </p>
9165 !! end
9166
9167 # html2wt will fail because of title normalization without data-parsoid
9168 !! test
9169 Parsoid: handle constructor well
9170 !! options
9171 parsoid=wt2html,wt2wt
9172 !! wikitext
9173 [[constructor]]
9174
9175 [[constructor:foo]]
9176 !! html/php
9177 <p><a href="/index.php?title=Constructor&amp;action=edit&amp;redlink=1" class="new" title="Constructor (page does not exist)">constructor</a>
9178 </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>
9179 </p>
9180 !! html/parsoid
9181 <p><a rel="mw:WikiLink" href="./Constructor" title="Constructor" data-parsoid='{"stx":"simple","a":{"href":"./Constructor"},"sa":{"href":"constructor"}}'>constructor</a></p>
9182
9183 <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>
9184 !! end
9185
9186 !! test
9187 Template parameter named "constructor"
9188 !! wikitext
9189 {{echo| constructor = |hi}}
9190 !! html/parsoid
9191 <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>
9192 !! end
9193
9194 !! article
9195 ko:
9196 !! text
9197 Test.
9198 !! endarticle
9199
9200 # Note that `ko` isn't a known interlanguage prefix
9201 !! test
9202 Parsoid: recognize interlanguage links without a target page
9203 !! options
9204 ill
9205 !! wikitext
9206 [[es:]]
9207
9208 [[ko:]]
9209 !! html/php
9210 es:
9211 !! html/parsoid
9212 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/"/>
9213
9214 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9215 !! end
9216
9217 # Note that `ko` isn't a known interwiki prefix
9218 !! test
9219 Parsoid: recognize interwiki links without a target page
9220 !! options
9221 parsoid=wt2html,wt2wt,html2html
9222 !! wikitext
9223 [[:es:]]
9224
9225 [[:ko:]]
9226 !! html/php
9227 <p><a href="http://es.wikipedia.org/wiki/" class="extiw" title="es:">es:</a>
9228 </p><p><a href="/wiki/Ko:" title="Ko:">ko:</a>
9229 </p>
9230 !! html/parsoid
9231 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/" title="es:">es:</a></p>
9232 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9233 !! end
9234
9235 !! test
9236 Handle interwiki links pointing to the current wiki as plain wiki links (T47209)
9237 !! wikitext
9238 [[mi:Foo]]
9239 !! html/php
9240 <p><a href="/wiki/Foo" title="Foo">mi:Foo</a>
9241 </p>
9242 !! html/parsoid
9243 <p><a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo"},"sa":{"href":"mi:Foo"}}'>mi:Foo</a></p>
9244 !! end
9245
9246 !! test
9247 Interlanguage link with preceding local interwiki link (T70085)
9248 !! options
9249 parsoid=wt2html,wt2wt,html2html
9250 !! wikitext
9251 Blah blah blah
9252 [[local:es:Spanish]]
9253 !! html/php
9254 <p>Blah blah blah
9255 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">local:es:Spanish</a>
9256 </p>
9257 !! html/parsoid
9258 <p>Blah blah blah
9259 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">local:es:Spanish</a></p>
9260 !! end
9261
9262 !! test
9263 Looks like an interlanguage link, but is actually a local interwiki
9264 !! options
9265 parsoid=wt2html,wt2wt,html2html
9266 !! wikitext
9267 Blah blah blah
9268 [[mi:Template:Foo]]
9269 !! html/php
9270 <p>Blah blah blah
9271 <a href="/wiki/Template:Foo" title="Template:Foo">mi:Template:Foo</a>
9272 </p>
9273 !! html/parsoid
9274 <p>Blah blah blah
9275 <a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">mi:Template:Foo</a></p>
9276 !! end
9277
9278 ###
9279 ### Redirects, Parsoid-only
9280 ###
9281
9282 !! test
9283 1. Simple redirect to page
9284 !! wikitext
9285 #REDIRECT [[Main Page]]
9286 !! html/parsoid
9287 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9288 !! end
9289
9290 !! test
9291 2. Other redirect variants
9292 !! wikitext
9293 #REDIRECT [[Main_Page]]
9294 !! html/parsoid
9295 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Main_Page"},"sa":{"href":"Main_Page"}}'/>
9296 !! end
9297
9298 # Not a valid redirect in PHP (although perhaps it was, once upon a time)
9299 # This tests the Parsoid bail-out code.
9300 !! test
9301 3. Other redirect variants
9302 !! options
9303 parsoid=wt2html
9304 !! wikitext
9305 #REDIRECT [[<nowiki>[[Bar]]</nowiki>]]
9306 !! html/parsoid
9307 <ol><li>REDIRECT [[<span typeof="mw:Nowiki">[[Bar]]</span>]]</li></ol>
9308 !! end
9309
9310 !! test
9311 4. Redirect to a templated destination
9312 !! wikitext
9313 #REDIRECT [[{{echo|Foo}}bar]]
9314 !! html/parsoid
9315 <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"}]]}'/>
9316 !! end
9317
9318 !! test
9319 Empty redirect
9320 !! options
9321 parsoid=wt2html,wt2wt
9322 !! wikitext
9323 #REDIRECT [[]]
9324 !! html/parsoid
9325 <ol>
9326 <li>REDIRECT [[]]</li></ol>
9327 !! end
9328
9329 !! test
9330 Optional colon in #REDIRECT
9331 !! options
9332 # the colon is archaic syntax. we support it for wt2html, but we
9333 # don't care that it roundtrips back to the modern syntax.
9334 parsoid=wt2html,html2html
9335 !! wikitext
9336 #REDIRECT:[[Main Page]]
9337 !! html/parsoid
9338 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9339 !! end
9340
9341 !! test
9342 Whitespace in #REDIRECT with optional colon
9343 !! options
9344 # the colon and gratuitous whitespace is archaic syntax. we support
9345 # it for wt2html, but we don't care that it roundtrips back to the
9346 # modern syntax (without extra whitespace)
9347 parsoid=wt2html,html2html
9348 !! wikitext
9349
9350 #REDIRECT
9351 :
9352 [[Main Page]]
9353 !! html/parsoid
9354 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9355 !! end
9356
9357 !! test
9358 Piped link in #REDIRECT
9359 !! options
9360 # content after piped link is ignored. we support this syntax,
9361 # but don't care that the piped link is lost when we roundtrip this.
9362 parsoid=wt2html
9363 !! wikitext
9364 #REDIRECT [[Main Page|bar]]
9365 !! html/parsoid
9366 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9367 !! end
9368
9369 !! test
9370 Redirect to category (T104502)
9371 !! options
9372 parsoid=wt2html,wt2wt
9373 !! wikitext
9374 #REDIRECT [[Category:Foo]]
9375 !! html/parsoid
9376 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9377 !! end
9378
9379 !! test
9380 Redirect to category with URL encoding (T104502)
9381 !! options
9382 parsoid=wt2html
9383 !! wikitext
9384 #REDIRECT [[Category%3AFoo]]
9385 !! html/parsoid
9386 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9387 !! end
9388
9389 !! test
9390 Redirect to category page
9391 !! wikitext
9392 #REDIRECT [[:Category:Foo]]
9393 !! html/parsoid
9394 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9395 !! end
9396
9397 !! test
9398 Redirect to image page (1)
9399 !! wikitext
9400 #REDIRECT [[File:Wiki.png]]
9401 !! html/parsoid
9402 <link rel="mw:PageProp/redirect" href="./File:Wiki.png"/>
9403 !! end
9404
9405 !! test
9406 Redirect to image page (2)
9407 !! wikitext
9408 #REDIRECT [[Image:Wiki.png]]
9409 !! html/parsoid
9410 <link rel="mw:PageProp/redirect" href="./File:Wiki.png" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./File:Wiki.png"},"sa":{"href":"Image:Wiki.png"}}'/>
9411 !! end
9412
9413 # html2wt disabled because wts serializes as "#REDIRECT [[:en:File:Wiki.png]]"
9414 # Next test confirms this.
9415 !! test
9416 Redirect to language (1) (T104918)
9417 !! options
9418 parsoid=wt2html,wt2wt,html2html
9419 !! wikitext
9420 #REDIRECT [[en:File:Wiki.png]]
9421 !! html/parsoid
9422 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9423 !! end
9424
9425 !! test
9426 Redirect to language (2) (T104918)
9427 !! wikitext
9428 #REDIRECT [[:en:File:Wiki.png]]
9429 !! html/parsoid
9430 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9431 !! end
9432
9433 !! test
9434 Redirect to interwiki (T104918)
9435 !! wikitext
9436 #REDIRECT [[meatball:File:Wiki.png]]
9437 !! html/parsoid
9438 <link rel="mw:PageProp/redirect" href="http://www.usemod.com/cgi-bin/mb.pl?File:Wiki.png"/>
9439 !! end
9440
9441 !! test
9442 Non-English #REDIRECT
9443 !! options
9444 language=is
9445 !! wikitext
9446 #TILVÍSUN [[Main Page]]
9447 !! html/parsoid
9448 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#TILVÍSUN ","a":{"href":"./Main_Page"},"sa":{"href":"Main Page"}}'/>
9449 !! end
9450
9451 !! test
9452 Redirect syntax under text isn't considered a redirect
9453 !! wikitext
9454 some text
9455
9456 #redirect [[Main Page]]
9457 !! html/parsoid
9458 <p>some text</p>
9459 <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>
9460 !! end
9461
9462 !! test
9463 New redirect
9464 !! options
9465 parsoid=html2wt
9466 !! html/parsoid
9467 <p>Foo<link rel="mw:PageProp/redirect" href="./Foo"/></p>
9468 !! wikitext
9469 #REDIRECT [[Foo]]
9470 Foo
9471 !! end
9472
9473 !! test
9474 Redirect followed by block on the same line
9475 !! options
9476 parsoid=wt2html
9477 !! wikitext
9478 #REDIRECT [[Main Page]]<!-- haha -->==hi==
9479 !! html/parsoid
9480 <link rel="mw:PageProp/redirect" href="./Main_Page"/><!-- haha --><h2 id="hi">hi</h2>
9481 !! end
9482
9483 !! test
9484 Redirect followed by a newline
9485 !! wikitext
9486 #REDIRECT [[Main Page]]
9487 A newline
9488 !! html/parsoid
9489 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9490 <p>A newline</p>
9491 !! end
9492
9493 !! test
9494 Redirect followed by multiple newlines
9495 !! wikitext
9496 #REDIRECT [[Main Page]]
9497
9498
9499 A newline
9500 !! html/parsoid
9501 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9502
9503 <p><br/>
9504 A newline</p>
9505 !! end
9506
9507 !! test
9508 Drop duplicate redirects
9509 !! options
9510 parsoid=html2wt
9511 !! html/parsoid
9512 <link rel="mw:PageProp/redirect" href="./Foo"/>
9513 <link rel="mw:PageProp/redirect" href="./Bar"/>
9514 <link rel="mw:PageProp/redirect" href="./Baz"/>
9515 !! wikitext
9516 #REDIRECT [[Foo]]
9517 !! end
9518
9519 ##
9520 ## XHTML tidiness
9521 ###
9522
9523 !! test
9524 <br> to <br />
9525 !! wikitext
9526 1<br>2<br />3
9527 !! html
9528 <p>1<br />2<br />3
9529 </p>
9530 !! end
9531
9532 !! test
9533 Broken br tag sanitization
9534 !! wikitext
9535 </br>
9536 !! html/php
9537 <p>&lt;/br&gt;
9538 </p>
9539 !! end
9540
9541 # TODO: Fix html2html mode (T53055)!
9542 !! test
9543 Parsoid: Broken br tag recognition
9544 !! options
9545 parsoid=wt2html
9546 !! wikitext
9547 </br>
9548
9549 <br/ >
9550 !! html+tidy
9551 <p><br />
9552 </p><p><br />
9553 </p>
9554 !! end
9555
9556 !! test
9557 Incorrecly removing closing slashes from correctly formed XHTML
9558 !! wikitext
9559 <br style="clear:both;" />
9560 !! html
9561 <p><br style="clear:both;" />
9562 </p>
9563 !! end
9564
9565 !! test
9566 Failing to transform badly formed HTML into correct XHTML
9567 !! wikitext
9568 <br style="clear: left;">
9569 <br style="clear: right;">
9570 <br style="clear: both;">
9571 !! html
9572 <p><br style="clear: left;" />
9573 <br style="clear: right;" />
9574 <br style="clear: both;" />
9575 </p>
9576 !!end
9577
9578 ## FIXME: Is Parsoid's acceptance of self-closing html-tags
9579 ## a feature or a bug? See https://phabricator.wikimedia.org/T76962
9580 !! test
9581 Handling html with a div self-closing tag
9582 !! wikitext
9583 <div title />
9584 <div title/>
9585 <div title/ >
9586 <div title=bar />
9587 <div title=bar/>
9588 <div title=bar/ >
9589 !! html/php
9590 <p>&lt;div title /&gt;
9591 &lt;div title/&gt;
9592 </p>
9593 <div>
9594 <p>&lt;div title=bar /&gt;
9595 &lt;div title=bar/&gt;
9596 </p>
9597 <div title="bar/"></div>
9598 </div>
9599
9600 !! html/parsoid
9601 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9602 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9603 <div title="" data-parsoid='{"stx":"html","autoInsertedEnd":true}'>
9604 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9605 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9606 <div title="bar/" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></div></div>
9607 !! end
9608
9609 !! test
9610 Elements with solidus in various attribute positions
9611 !! options
9612 parsoid=wt2html,html2html
9613 !! wikitext
9614 <div cla/ss="123">ha</div>
9615
9616 <div / class="123">ha</div>
9617
9618 <div class= / "123">ha</div>
9619 !! html/php+tidy
9620 <div>ha</div>
9621 <div class="123">ha</div>
9622 <div class="/">ha</div>
9623 !! html/parsoid
9624 <div data-parsoid='{"stx":"html","a":{"cla":null,"ss":null},"sa":{"cla":"","ss":"123"}}'>ha</div>
9625
9626 <div class="123" data-parsoid='{"stx":"html"}'>ha</div>
9627
9628 <div class="/" data-parsoid='{"stx":"html","a":{"\"123\"":null},"sa":{"\"123\"":""}}'>ha</div>
9629 !! end
9630
9631 !! test
9632 Handling html with a br self-closing tag
9633 !! wikitext
9634 <br title />
9635 <br title/>
9636 <br title/ >
9637 <br title=bar />
9638 <br title=bar/>
9639 <br title=bar/ >
9640 !! html/php
9641 <p><br title="" />
9642 <br title="" />
9643 <br />
9644 <br title="bar" />
9645 <br title="bar" />
9646 <br title="bar/" />
9647 </p>
9648 !! html/parsoid
9649 <p><br title="" />
9650 <br title="" />
9651 <br title="" />
9652 <br title="bar" />
9653 <br title="bar" />
9654 <br title="bar/" />
9655 </p>
9656 !! end
9657
9658 !! test
9659 Horizontal ruler (should it add that extra space?)
9660 !! wikitext
9661 <hr>
9662 <hr >
9663 foo <hr
9664 > bar
9665 !! html+tidy
9666 <hr />
9667 <hr /><p>
9668 foo </p><hr /><p> bar
9669 </p>
9670 !! end
9671
9672 !! test
9673 Horizontal ruler -- 4+ dashes render hr
9674 !! wikitext
9675 ----
9676 !! html
9677 <hr />
9678
9679 !! end
9680
9681 !! test
9682 Horizontal ruler -- eats additional dashes on the same line
9683 !! wikitext
9684 ---------
9685 !! html
9686 <hr />
9687
9688 !! end
9689
9690 !! test
9691 Horizontal ruler -- does not collapse dashes on consecutive lines
9692 !! wikitext
9693 ----
9694 ----
9695 !! html
9696 <hr />
9697 <hr />
9698
9699 !! end
9700
9701 !! test
9702 Horizontal ruler -- <4 dashes render as plain text
9703 !! wikitext
9704 ---
9705 !! html
9706 <p>---
9707 </p>
9708 !! end
9709
9710 !! test
9711 Horizontal ruler -- Supports content following dashes on same line
9712 !! wikitext
9713 ---- Foo
9714 !! html
9715 <hr /> Foo
9716
9717 !! html+tidy
9718 <hr /><p> Foo
9719 </p>
9720 !! end
9721
9722 ###
9723 ### Block-level elements
9724 ###
9725 !! test
9726 Common list
9727 !! wikitext
9728 *Common list
9729 *item 2
9730 *item 3
9731 !! html
9732 <ul><li>Common list</li>
9733 <li>item 2</li>
9734 <li>item 3</li></ul>
9735
9736 !! end
9737
9738 !! test
9739 Numbered list
9740 !! wikitext
9741 #Numbered list
9742 #item 2
9743 #item 3
9744 !! html
9745 <ol><li>Numbered list</li>
9746 <li>item 2</li>
9747 <li>item 3</li></ol>
9748
9749 !! end
9750
9751 # the switch from level 3 to ordered should not introduce a newline between
9752 !! test
9753 Mixed list
9754 !! wikitext
9755 *Mixed list
9756 *#with numbers
9757 **and bullets
9758 *#and numbers
9759 *bullets again
9760 **bullet level 2
9761 ***bullet level 3
9762 ***#Number on level 4
9763 **bullet level 2
9764 **#Number on level 3
9765 **#Number on level 3
9766 *#number level 2
9767 *Level 1
9768 ***Level 3
9769 #**Level 3, but ordered
9770 !! html
9771 <ul><li>Mixed list
9772 <ol><li>with numbers</li></ol>
9773 <ul><li>and bullets</li></ul>
9774 <ol><li>and numbers</li></ol></li>
9775 <li>bullets again
9776 <ul><li>bullet level 2
9777 <ul><li>bullet level 3
9778 <ol><li>Number on level 4</li></ol></li></ul></li>
9779 <li>bullet level 2
9780 <ol><li>Number on level 3</li>
9781 <li>Number on level 3</li></ol></li></ul>
9782 <ol><li>number level 2</li></ol></li>
9783 <li>Level 1
9784 <ul><li><ul><li>Level 3</li></ul></li></ul></li></ul>
9785 <ol><li><ul><li><ul><li>Level 3, but ordered</li></ul></li></ul></li></ol>
9786
9787 !! end
9788
9789 !! test
9790 1. Nested mixed wikitext and html list
9791 !! wikitext
9792 *hi
9793 *<ul><li>ho</li></ul>
9794 *hi
9795 **ho
9796 !! html/php
9797 <ul><li>hi</li>
9798 <li><ul><li>ho</li></ul></li>
9799 <li>hi
9800 <ul><li>ho</li></ul></li></ul>
9801
9802 !! html/parsoid
9803 <ul><li>hi</li>
9804 <li><ul data-parsoid='{"stx":"html"}'><li data-parsoid='{"stx":"html"}'>ho</li></ul></li>
9805 <li>hi
9806 <ul><li>ho</li></ul></li></ul>
9807 !! end
9808
9809 !! test
9810 2. Nested mixed wikitext and html list (incompatible)
9811 !! wikitext
9812 ;hi
9813 :{{echo|<li>ho</li>}}
9814 !! html/php
9815 <dl><dt>hi</dt>
9816 <dd><li>ho</li></dd></dl>
9817
9818 !! html/parsoid
9819 <dl><dt>hi</dt>
9820 <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>
9821 !! end
9822
9823 !! test
9824 Nested lists 1
9825 !! wikitext
9826 *foo
9827 **bar
9828 !! html
9829 <ul><li>foo
9830 <ul><li>bar</li></ul></li></ul>
9831
9832 !! end
9833
9834 !! test
9835 Nested lists 2
9836 !! wikitext
9837 **foo
9838 *bar
9839 !! html
9840 <ul><li><ul><li>foo</li></ul></li>
9841 <li>bar</li></ul>
9842
9843 !! end
9844
9845 !! test
9846 Nested lists 3 (first element empty)
9847 !! wikitext
9848 *
9849 **bar
9850 !! html
9851 <ul><li>
9852 <ul><li>bar</li></ul></li></ul>
9853
9854 !! end
9855
9856 !! test
9857 Nested lists 4 (first element empty)
9858 !! wikitext
9859 **
9860 *bar
9861 !! html
9862 <ul><li><ul><li></li></ul></li>
9863 <li>bar</li></ul>
9864
9865 !! end
9866
9867 !! test
9868 Nested lists 5 (both elements empty)
9869 !! wikitext
9870 **
9871 *
9872 !! html
9873 <ul><li><ul><li></li></ul></li>
9874 <li></li></ul>
9875
9876 !! end
9877
9878 !! test
9879 Nested lists 6 (both elements empty)
9880 !! wikitext
9881 *
9882 **
9883 !! html
9884 <ul><li>
9885 <ul><li></li></ul></li></ul>
9886
9887 !! end
9888
9889 !! test
9890 Nested lists 7 (skip initial nesting levels)
9891 !! wikitext
9892 ***foo
9893 !! html
9894 <ul><li><ul><li><ul><li>foo</li></ul></li></ul></li></ul>
9895
9896 !! end
9897
9898 !! test
9899 Nested lists 8 (multiple nesting transitions)
9900 !! wikitext
9901 *foo
9902 ***bar
9903 **baz
9904 *boo
9905 !! html
9906 <ul><li>foo
9907 <ul><li><ul><li>bar</li></ul></li>
9908 <li>baz</li></ul></li>
9909 <li>boo</li></ul>
9910
9911 !! end
9912
9913 !! test
9914 Nested lists 9 (extension interaction)
9915 !! options
9916 parsoid
9917 !! wikitext
9918 *<references />
9919 !! html/parsoid
9920 <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>
9921 !! end
9922
9923 !! test
9924 1. Lists with start-of-line-transparent tokens before bullets: Comments
9925 !! wikitext
9926 *foo
9927 *<!--cmt-->bar
9928 <!--cmt-->*baz
9929 !! html
9930 <ul><li>foo</li>
9931 <li>bar</li>
9932 <li>baz</li></ul>
9933
9934 !! end
9935
9936 !! test
9937 Nested lists 10 (list and span siblings: wt2wt regression)
9938 !! wikitext
9939 *a <span>x</span>
9940 **b <span>y</span>
9941 !! html/parsoid
9942 <ul><li>a <span>x</span>
9943 <ul><li>b <span>y</span></li></ul></li></ul>
9944 !! end
9945
9946 !! test
9947 2. Lists with start-of-line-transparent tokens before bullets: Template close
9948 !! wikitext
9949 *foo {{echo|bar
9950 }}*baz
9951 !! html
9952 <ul><li>foo bar</li>
9953 <li>baz</li></ul>
9954
9955 !! end
9956
9957 !! test
9958 List items are not parsed correctly following a <pre> block (T2785)
9959 !! wikitext
9960 *<pre>foo</pre>
9961 *<pre>bar</pre>
9962 *zar
9963 !! html/php
9964 <ul><li><pre>foo</pre></li>
9965 <li><pre>bar</pre></li>
9966 <li>zar</li></ul>
9967
9968 !! html/parsoid
9969 <ul><li><pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre></li>
9970 <li><pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"bar"}}'>bar</pre></li>
9971 <li>zar</li></ul>
9972 !! end
9973
9974 # FIXME: Might benefit from a html/parsoid since this has a template
9975 !! test
9976 List items from template
9977 !! wikitext
9978
9979 {{inner list}}
9980 *item 2
9981
9982 *item 0
9983 {{inner list}}
9984 *item 2
9985
9986 *item 0
9987 *notSOL{{inner list}}
9988 *item 2
9989 !! html
9990 <ul><li>item 1</li>
9991 <li>item 2</li></ul>
9992 <ul><li>item 0</li>
9993 <li>item 1</li>
9994 <li>item 2</li></ul>
9995 <ul><li>item 0</li>
9996 <li>notSOL</li>
9997 <li>item 1</li>
9998 <li>item 2</li></ul>
9999
10000 !! end
10001
10002 !! test
10003 List interrupted by empty line or heading
10004 !! wikitext
10005 *foo
10006
10007 **bar
10008 ==A heading==
10009 *Another list item
10010 !! html
10011 <ul><li>foo</li></ul>
10012 <ul><li><ul><li>bar</li></ul></li></ul>
10013 <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>
10014 <ul><li>Another list item</li></ul>
10015
10016 !!end
10017
10018 !! test
10019 Multiple list tags generated by templates
10020 !! wikitext
10021 {{echo|<li>}}a
10022 {{echo|<li>}}b
10023 {{echo|<li>}}c
10024 !! html
10025 <li>a
10026 <li>b
10027 <li>c</li>
10028 </li>
10029 </li>
10030
10031
10032 !! html+tidy
10033 <li>a
10034 </li><li>b
10035 </li><li>c
10036 </li>
10037 !! html/parsoid
10038 <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>
10039 <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>
10040 <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>
10041 !! end
10042
10043 !! test
10044 Multiple newlines in between HTML list items don't induce paragraph wrapping
10045 !! wikitext
10046 <ul>
10047 <li>hi</li>
10048
10049
10050
10051
10052 <li>ho</li>
10053 </ul>
10054
10055 <dl>
10056 <dt>hi</dt>
10057 <dd>ho<div>123</div>
10058 </dd>
10059
10060
10061 </dl>
10062 !! html/php+tidy
10063 <ul>
10064 <li>hi</li>
10065
10066
10067
10068
10069 <li>ho</li>
10070 </ul>
10071 <dl>
10072 <dt>hi</dt>
10073 <dd>ho<div>123</div>
10074 </dd>
10075
10076
10077 </dl>
10078 !! end
10079
10080 !!test
10081 Single-comment whitespace lines dont break lists, and neither do multi-comment whitespace lines
10082 !! wikitext
10083 *a
10084 <!--This line will NOT split the list-->
10085 *b
10086 <!--This line will NOT split the list either-->
10087 *c
10088 <!--foo--> <!----> <!--This line NOT split the list either-->
10089 *d
10090 !! html
10091 <ul><li>a</li>
10092 <li>b</li>
10093 <li>c</li>
10094 <li>d</li></ul>
10095
10096 !!end
10097
10098 !!test
10099 Replacing whitespace with tabs still doesn't break the list (gerrit 78327)
10100 !! wikitext
10101 *a
10102 <!--This line will NOT split the list-->
10103 *b
10104 <!--This line will NOT split the list either-->
10105 *c
10106 <!--foo--> <!----> <!--This line NOT split the list
10107 either-->
10108 *d
10109 !! html
10110 <ul><li>a</li>
10111 <li>b</li>
10112 <li>c</li>
10113 <li>d</li></ul>
10114
10115 !!end
10116
10117 # FIXME: Parsoid has a dedicated DOM pass to mimic this Tidy-specific li-hack
10118 # That pass could possibly be removed.
10119 !!test
10120 Test the li-hack (a hack from Tidy days, but doesn't work as advertised with Remex)
10121 !!options
10122 parsoid=wt2html,wt2wt
10123 !! wikitext
10124 *foo
10125 *<li>li-hack
10126 *{{echo|<li>templated li-hack}}
10127 *<!--foo--><li> unsupported li-hack with preceding comments
10128
10129 <ul>
10130 <li><li>not a li-hack
10131 </li>
10132 </ul>
10133 !! html+tidy
10134 <ul><li>foo</li>
10135 <li class="mw-empty-elt"></li><li>li-hack</li>
10136 <li class="mw-empty-elt"></li><li>templated li-hack</li>
10137 <li class="mw-empty-elt"></li><li> unsupported li-hack with preceding comments</li></ul>
10138 <ul>
10139 <li class="mw-empty-elt"></li><li>not a li-hack
10140 </li>
10141 </ul>
10142 !! html/parsoid
10143 <ul><li> foo</li>
10144 <li data-parsoid='{"stx":"html","autoInsertedEnd":true,"liHackSrc":"*"}'>li-hack</li>
10145 <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>
10146 <li data-parsoid='{"autoInsertedEnd":true}'><!--foo--></li><li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>unsupported li-hack with preceding comments</li></ul>
10147
10148 <ul data-parsoid='{"stx":"html"}'>
10149 <li class="mw-empty-elt" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></li><li data-parsoid='{"stx":"html"}'>not a li-hack
10150 </li>
10151 </ul>
10152
10153 !!end
10154
10155 !! test
10156 Parsoid: Make sure nested lists are serialized on their own line even if HTML contains no newlines
10157 !! options
10158 parsoid
10159 !! wikitext
10160 #foo
10161 ##bar
10162
10163 *foo
10164 **bar
10165
10166 :foo
10167 ::bar
10168 !! html
10169 <ol>
10170 <li>foo<ol>
10171 <li>bar</li>
10172 </ol></li>
10173 </ol><ul>
10174 <li>foo<ul>
10175 <li>bar</li>
10176 </ul></li>
10177 </ul><dl>
10178 <dd>foo<dl>
10179 <dd>bar</dd>
10180 </dl></dd>
10181 </dl>
10182 !! end
10183
10184 !! test
10185 Parsoid: Test of whitespace serialization with Templated bullets
10186 !! options
10187 parsoid=wt2html
10188 !! wikitext
10189 * {{bullet}}
10190 !! html/parsoid
10191 <ul>
10192 <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>
10193 </ul>
10194 !! end
10195
10196 # ------------------------------------------------------------------------
10197 # The next set of tests are about Parsoid's ability to handle badly nested
10198 # tags (parse, minimize scope of fixup, and roundtrip back)
10199 # ------------------------------------------------------------------------
10200
10201 # Remex and Parsoid output stems from list handling diffs because Parsoid & PHP parser.
10202 # Parsoid's list handling is more aware of block structure.
10203 !! test
10204 Unbalanced closing block tags break a list
10205 !! wikitext
10206 <div>
10207 *a</div><div>
10208 *b</div>
10209 !! html+tidy
10210 <div>
10211 <ul><li>a</li></ul></div><div>
10212 <li>b</li></div>
10213 !! html/parsoid
10214 <div><ul>
10215 <li>a</li>
10216 </ul></div>
10217 <div><ul>
10218 <li>b</li>
10219 </ul></div>
10220 !! end
10221
10222 !! test
10223 Unbalanced closing non-block tags don't break a list
10224 !! options
10225 parsoid=wt2html,html2html
10226 !! wikitext
10227 <span>
10228 *a</span><span>
10229 *b</span>
10230 !! html/php+tidy
10231 <p><span>
10232 </span></p>
10233 <ul><li>a<span></span></li>
10234 <li>b</li></ul>
10235 !! html/parsoid
10236 <p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'></span></p>
10237 <ul><li>a<span data-parsoid='{"stx":"html","autoInsertedEnd":true}'></span></li>
10238 <li>b</li></ul>
10239 !! end
10240
10241 # Parsoid does some post-dom-building cleanup
10242 # which is why its output differs from Remex.
10243 !! test
10244 Unclosed formatting tags that straddle lists are closed and reopened
10245 !! options
10246 parsoid=wt2html,wt2wt,html2html
10247 !! wikitext
10248 #<s> a
10249 #b </s>
10250 !! html/php+tidy
10251 <ol><li><s> a</s></li><s>
10252 </s><li><s>b </s></li></ol>
10253 !! html/parsoid
10254 <ol><li><s> a</s></li>
10255 <li><s>b </s></li></ol>
10256 !! end
10257
10258 # Output is ugly because of all the misnested tag fixups.
10259 !! test
10260 1. List embedded in a formatting tag
10261 !! wikitext
10262 <small>
10263 *foo
10264 </small>
10265 !! html/php+tidy
10266 <p><small>
10267 </small></p><small><ul><li>foo</li></ul></small><small></small><p><small></small>
10268 </p>
10269 !! html/parsoid
10270 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p><small data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
10271 <ul><li data-parsoid='{}'>foo</li></ul></small>
10272 <p><small data-parsoid='{"stx":"html","autoInsertedStart":true}'></small></p>
10273 !! end
10274
10275 # Output is ugly because of all the misnested tag fixups.
10276 !! test
10277 2. List embedded in a formatting tag in a misnested way
10278 !! wikitext
10279 <small>
10280 *a
10281 *b</small>
10282 !! html/php+tidy
10283 <p><small>
10284 </small></p><small></small><ul><small><li>a</li>
10285 </small><li><small>b</small></li></ul>
10286 !! html/parsoid
10287 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p>
10288 <ul><small data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'><li>a</li></small>
10289 <li><small data-parsoid='{"stx":"html","autoInsertedStart":true}'>b</small></li></ul>
10290 !! end
10291
10292 # Output is ugly because of all the misnested tag fixups.
10293 !! test
10294 3. List embedded in a formatting tag in a misnested way
10295 !! wikitext
10296 <small>
10297
10298 ** 123</small>
10299 !! html/php+tidy
10300 <p><small>
10301 </small></p><small></small><ul><small></small><li><small></small><ul><small></small><li><small>123</small></li></ul></li></ul>
10302 !! html/parsoid
10303 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p>
10304
10305 <ul><li><ul><li data-parsoid='{}'><small data-parsoid='{"stx":"html","autoInsertedStart":true}'> 123</small></li></ul></li></ul>
10306 !! end
10307
10308 ###
10309 ### Magic Words
10310 ###
10311
10312 # Note that the current date is hard-coded as
10313 # 1970-01-01T00:02:03Z (a Thursday)
10314 # when running parser tests. The timezone is also fixed to GMT, so
10315 # local date will be identical to current date.
10316
10317 !! test
10318 Magic Word: {{CURRENTDAY}}
10319 !! wikitext
10320 {{CURRENTDAY}}
10321 !! html
10322 <p>1
10323 </p>
10324 !! end
10325
10326 !! test
10327 Magic Word: {{CURRENTDAY2}}
10328 !! wikitext
10329 {{CURRENTDAY2}}
10330 !! html
10331 <p>01
10332 </p>
10333 !! end
10334
10335 !! test
10336 Magic Word: {{CURRENTDAYNAME}}
10337 !! wikitext
10338 {{CURRENTDAYNAME}}
10339 !! html
10340 <p>Thursday
10341 </p>
10342 !! end
10343
10344 !! test
10345 Magic Word: {{CURRENTDOW}}
10346 !! wikitext
10347 {{CURRENTDOW}}
10348 !! html
10349 <p>4
10350 </p>
10351 !! end
10352
10353 !! test
10354 Magic Word: {{CURRENTMONTH}}
10355 !! wikitext
10356 {{CURRENTMONTH}}
10357 !! html
10358 <p>01
10359 </p>
10360 !! end
10361
10362 !! test
10363 Magic Word: {{CURRENTMONTH1}}
10364 !! wikitext
10365 {{CURRENTMONTH1}}
10366 !! html
10367 <p>1
10368 </p>
10369 !! end
10370
10371 !! test
10372 Magic Word: {{CURRENTMONTHABBREV}}
10373 !! wikitext
10374 {{CURRENTMONTHABBREV}}
10375 !! html
10376 <p>Jan
10377 </p>
10378 !! end
10379
10380 !! test
10381 Magic Word: {{CURRENTMONTHNAME}}
10382 !! wikitext
10383 {{CURRENTMONTHNAME}}
10384 !! html
10385 <p>January
10386 </p>
10387 !! end
10388
10389 !! test
10390 Magic Word: {{CURRENTMONTHNAMEGEN}}
10391 !! wikitext
10392 {{CURRENTMONTHNAMEGEN}}
10393 !! html
10394 <p>January
10395 </p>
10396 !! end
10397
10398 !! test
10399 Magic Word: {{CURRENTTIME}}
10400 !! wikitext
10401 {{CURRENTTIME}}
10402 !! html
10403 <p>00:02
10404 </p>
10405 !! end
10406
10407 !! test
10408 Magic Word: {{CURRENTHOUR}}
10409 !! wikitext
10410 {{CURRENTHOUR}}
10411 !! html
10412 <p>00
10413 </p>
10414 !! end
10415
10416 !! test
10417 Magic Word: {{CURRENTWEEK}} (T6594)
10418 !! wikitext
10419 {{CURRENTWEEK}}
10420 !! html
10421 <p>1
10422 </p>
10423 !! end
10424
10425 !! test
10426 Magic Word: {{CURRENTYEAR}}
10427 !! wikitext
10428 {{CURRENTYEAR}}
10429 !! html
10430 <p>1970
10431 </p>
10432 !! end
10433
10434 !! test
10435 Magic Word: {{CURRENTTIMESTAMP}}
10436 !! wikitext
10437 {{CURRENTTIMESTAMP}}
10438 !! html
10439 <p>19700101000203
10440 </p>
10441 !! end
10442
10443 !! test
10444 Magic Words LOCAL (UTC)
10445 !! wikitext
10446 *{{LOCALMONTH}}
10447 *{{LOCALMONTH1}}
10448 *{{LOCALMONTHNAME}}
10449 *{{LOCALMONTHNAMEGEN}}
10450 *{{LOCALMONTHABBREV}}
10451 *{{LOCALDAY}}
10452 *{{LOCALDAY2}}
10453 *{{LOCALDAYNAME}}
10454 *{{LOCALYEAR}}
10455 *{{LOCALTIME}}
10456 *{{LOCALHOUR}}
10457 *{{LOCALWEEK}}
10458 *{{LOCALDOW}}
10459 *{{LOCALTIMESTAMP}}
10460 !! html
10461 <ul><li>01</li>
10462 <li>1</li>
10463 <li>January</li>
10464 <li>January</li>
10465 <li>Jan</li>
10466 <li>1</li>
10467 <li>01</li>
10468 <li>Thursday</li>
10469 <li>1970</li>
10470 <li>00:02</li>
10471 <li>00</li>
10472 <li>1</li>
10473 <li>4</li>
10474 <li>19700101000203</li></ul>
10475
10476 !! end
10477
10478 !! test
10479 Magic Word: {{FULLPAGENAME}}
10480 !! options
10481 title=[[User:Ævar Arnfjörð Bjarmason]]
10482 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10483 !! wikitext
10484 {{FULLPAGENAME}}
10485 !! html/*
10486 <p>User:Ævar Arnfjörð Bjarmason
10487 </p>
10488 !! end
10489
10490 !! test
10491 Magic Word: {{FULLPAGENAMEE}}
10492 !! options
10493 title=[[User:Ævar Arnfjörð Bjarmason]]
10494 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10495 !! wikitext
10496 {{FULLPAGENAMEE}}
10497 !! html/*
10498 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10499 </p>
10500 !! end
10501
10502 !! test
10503 Magic Word: {{TALKSPACE}}
10504 !! options
10505 title=[[User:Ævar Arnfjörð Bjarmason]]
10506 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10507 !! wikitext
10508 {{TALKSPACE}}
10509 !! html/*
10510 <p>User talk
10511 </p>
10512 !! end
10513
10514 !! test
10515 Magic Word: {{TALKSPACE}}, same namespace
10516 !! options
10517 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10518 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10519 !! wikitext
10520 {{TALKSPACE}}
10521 !! html/*
10522 <p>User talk
10523 </p>
10524 !! end
10525
10526 !! test
10527 Magic Word: {{TALKSPACE}}, main namespace
10528 !! options
10529 title=[[Parser Test]]
10530 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10531 !! wikitext
10532 {{TALKSPACE}}
10533 !! html/*
10534 <p>Talk
10535 </p>
10536 !! end
10537
10538 !! test
10539 Magic Word: {{TALKSPACEE}}
10540 !! options
10541 title=[[User:Ævar Arnfjörð Bjarmason]]
10542 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10543 !! wikitext
10544 {{TALKSPACEE}}
10545 !! html/*
10546 <p>User_talk
10547 </p>
10548 !! end
10549
10550 !! test
10551 Magic Word: {{SUBJECTSPACE}}
10552 !! options
10553 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10554 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10555 !! wikitext
10556 {{SUBJECTSPACE}}
10557 !! html/*
10558 <p>User
10559 </p>
10560 !! end
10561
10562 !! test
10563 Magic Word: {{SUBJECTSPACE}}, same namespace
10564 !! options
10565 title=[[User:Ævar Arnfjörð Bjarmason]]
10566 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10567 !! wikitext
10568 {{SUBJECTSPACE}}
10569 !! html/*
10570 <p>User
10571 </p>
10572 !! end
10573
10574 !! test
10575 Magic Word: {{SUBJECTSPACE}}, main namespace
10576 !! options
10577 title=[[Parser Test]]
10578 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10579 !! wikitext
10580 {{SUBJECTSPACE}}
10581 !! html/*
10582
10583 !! end
10584
10585 !! test
10586 Magic Word: {{SUBJECTSPACEE}}
10587 !! options
10588 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10589 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10590 !! wikitext
10591 {{SUBJECTSPACEE}}
10592 !! html/*
10593 <p>User
10594 </p>
10595 !! end
10596
10597 !! test
10598 Magic Word: {{NAMESPACE}}
10599 !! options
10600 title=[[User:Ævar Arnfjörð Bjarmason]]
10601 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10602 !! wikitext
10603 {{NAMESPACE}}
10604 !! html/*
10605 <p>User
10606 </p>
10607 !! end
10608
10609 !! test
10610 Magic Word: {{NAMESPACEE}}
10611 !! options
10612 title=[[User:Ævar Arnfjörð Bjarmason]]
10613 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10614 !! wikitext
10615 {{NAMESPACEE}}
10616 !! html/*
10617 <p>User
10618 </p>
10619 !! end
10620
10621 !! test
10622 Magic Word: {{NAMESPACENUMBER}}
10623 !! options
10624 title=[[User:Ævar Arnfjörð Bjarmason]]
10625 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10626 !! wikitext
10627 {{NAMESPACENUMBER}}
10628 !! html/*
10629 <p>2
10630 </p>
10631 !! end
10632
10633 !! test
10634 Magic Word: {{SUBPAGENAME}}
10635 !! options
10636 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10637 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10638 !! wikitext
10639 {{SUBPAGENAME}}
10640 !! html/*
10641 <p>sub ö
10642 </p>
10643 !! end
10644
10645 !! test
10646 Magic Word: {{SUBPAGENAMEE}}
10647 !! options
10648 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10649 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10650 !! wikitext
10651 {{SUBPAGENAMEE}}
10652 !! html/*
10653 <p>sub_%C3%B6
10654 </p>
10655 !! end
10656
10657 !! test
10658 Magic Word: {{ROOTPAGENAME}}
10659 !! options
10660 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10661 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10662 !! wikitext
10663 {{ROOTPAGENAME}}
10664 !! html/*
10665 <p>Ævar Arnfjörð Bjarmason
10666 </p>
10667 !! end
10668
10669 !! test
10670 Magic Word: {{ROOTPAGENAMEE}}
10671 !! options
10672 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10673 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10674 !! wikitext
10675 {{ROOTPAGENAMEE}}
10676 !! html/*
10677 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10678 </p>
10679 !! end
10680
10681 !! test
10682 Magic Word: {{BASEPAGENAME}}
10683 !! options
10684 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10685 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10686 !! wikitext
10687 {{BASEPAGENAME}}
10688 !! html/*
10689 <p>Ævar Arnfjörð Bjarmason
10690 </p>
10691 !! end
10692
10693 !! test
10694 Magic Word: {{BASEPAGENAMEE}}
10695 !! options
10696 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10697 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10698 !! wikitext
10699 {{BASEPAGENAMEE}}
10700 !! html/*
10701 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10702 </p>
10703 !! end
10704
10705 !! test
10706 Magic Word: {{TALKPAGENAME}}
10707 !! options
10708 title=[[User:Ævar Arnfjörð Bjarmason]]
10709 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10710 !! wikitext
10711 {{TALKPAGENAME}}
10712 !! html/*
10713 <p>User talk:Ævar Arnfjörð Bjarmason
10714 </p>
10715 !! end
10716
10717 !! test
10718 Magic Word: {{TALKPAGENAMEE}}
10719 !! options
10720 title=[[User:Ævar Arnfjörð Bjarmason]]
10721 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10722 !! wikitext
10723 {{TALKPAGENAMEE}}
10724 !! html/*
10725 <p>User_talk:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10726 </p>
10727 !! end
10728
10729 !! test
10730 Magic Word: {{SUBJECTPAGENAME}}
10731 !! options
10732 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10733 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10734 !! wikitext
10735 {{SUBJECTPAGENAME}}
10736 !! html/*
10737 <p>User:Ævar Arnfjörð Bjarmason
10738 </p>
10739 !! end
10740
10741 !! test
10742 Magic Word: {{SUBJECTPAGENAMEE}}
10743 !! options
10744 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10745 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10746 !! wikitext
10747 {{SUBJECTPAGENAMEE}}
10748 !! html/*
10749 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10750 </p>
10751 !! end
10752
10753 !! test
10754 Magic Word: {{NUMBEROFFILES}}
10755 !! options
10756 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10757 !! wikitext
10758 {{NUMBEROFFILES}}
10759 !! html/*
10760 <p>7
10761 </p>
10762 !! end
10763
10764 !! test
10765 Magic Word: {{PAGENAME}}
10766 !! options
10767 title=[[User:Ævar Arnfjörð Bjarmason]]
10768 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10769 !! wikitext
10770 {{PAGENAME}}
10771 !! html/*
10772 <p>Ævar Arnfjörð Bjarmason
10773 </p>
10774 !! end
10775
10776 !! test
10777 Magic Word: {{PAGENAME}} with metacharacters
10778 !! options
10779 title=[['foo & bar = baz']]
10780 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10781 !! wikitext
10782 ''{{PAGENAME}}''
10783 !! html+tidy
10784 <p><i>&#39;foo &#38; bar &#61; baz&#39;</i>
10785 </p>
10786 !! end
10787
10788 !! test
10789 Magic Word: {{PAGENAME}} with metacharacters (T28781)
10790 !! options
10791 title=[[*RFC 1234 http://example.com/]]
10792 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10793 !! wikitext
10794 {{PAGENAME}}
10795 !! html+tidy
10796 <p>&#42;RFC&#32;1234 http&#58;//example.com/
10797 </p>
10798 !! end
10799
10800 !! test
10801 Magic Word: {{PAGENAMEE}}
10802 !! options
10803 title=[[User:Ævar Arnfjörð Bjarmason]]
10804 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10805 !! wikitext
10806 {{PAGENAMEE}}
10807 !! html/*
10808 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10809 </p>
10810 !! end
10811
10812 !! test
10813 Magic Word: {{PAGENAMEE}} with metacharacters (T28781)
10814 !! options
10815 title=[[*RFC 1234 http://example.com/]]
10816 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10817 !! wikitext
10818 {{PAGENAMEE}}
10819 !! html+tidy
10820 <p>&#42;RFC_1234_http&#58;//example.com/
10821 </p>
10822 !! end
10823
10824 !! test
10825 Magic Word: {{REVISIONID}}
10826 !! options
10827 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10828 showflags
10829 !! wikitext
10830 {{REVISIONID}}
10831 !! html/*
10832 <p>1337
10833 </p>
10834 flags=vary-revision-id
10835 !! end
10836
10837 !! test
10838 Magic Word: {{SCRIPTPATH}}
10839 !! options
10840 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10841 !! wikitext
10842 {{SCRIPTPATH}}
10843 !! html/*
10844
10845 !! end
10846
10847 !! test
10848 Magic Word: {{STYLEPATH}}
10849 !! options
10850 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10851 !! wikitext
10852 {{STYLEPATH}}
10853 !! html/*
10854 <p>/skins
10855 </p>
10856 !! end
10857
10858 !! test
10859 Magic Word: {{SERVER}}
10860 !! options
10861 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10862 !! wikitext
10863 {{SERVER}}
10864 !! html/*
10865 <p><a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10866 </p>
10867 !! end
10868
10869 !! test
10870 Magic Word: {{SERVERNAME}}
10871 !! options
10872 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10873 !! wikitext
10874 {{SERVERNAME}}
10875 !! html/*
10876 <p>example.org
10877 </p>
10878 !! end
10879
10880 !! test
10881 Magic Word: {{SITENAME}}
10882 !! options
10883 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10884 !! wikitext
10885 {{SITENAME}}
10886 !! html/*
10887 <p>MediaWiki
10888 </p>
10889 !! end
10890
10891 !! test
10892 Magic Word: {{PAGELANGUAGE}}
10893 !! options
10894 language=fr
10895 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10896 !! wikitext
10897 {{PAGELANGUAGE}}
10898 !! html/*
10899 <p>fr
10900 </p>
10901 !! end
10902
10903 !! test
10904 Magic Word: {{PAGELANGUAGE}} on a page with no explicitly set language
10905 !! options
10906 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10907 !! wikitext
10908 {{PAGELANGUAGE}}
10909 !! html/*
10910 <p>en
10911 </p>
10912 !! end
10913
10914 !! test
10915 Case-sensitive magic words, when cased differently, should just be template transclusions
10916 !! wikitext
10917 {{CurrentMonth}}
10918 {{currentday}}
10919 {{cURreNTweEK}}
10920 {{currentHour}}
10921 !! html
10922 <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>
10923 <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>
10924 <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>
10925 <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>
10926 </p>
10927 !! end
10928
10929 !! test
10930 Case-insensitive magic words should still work with weird casing.
10931 !! wikitext
10932 {{sErVeRNaMe}}
10933 {{LCFirst:AOEU}}
10934 {{ucFIRST:aoeu}}
10935 {{SERver}}
10936 !! html
10937 <p>example.org
10938 aOEU
10939 Aoeu
10940 <a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10941 </p>
10942 !! end
10943
10944 # From plwiki:PLOS_ONE
10945 !! test
10946 Parsoid: Page property magic word with magic word contents
10947 !! wikitext
10948 {{DISPLAYTITLE:''{{PAGENAME}}''}}
10949 !! html/parsoid
10950 <meta property="mw:PageProp/displaytitle" content="Main Page" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"src":"{{DISPLAYTITLE:&#39;&#39;{{PAGENAME}}&#39;&#39;}}"}' data-mw='{"attribs":[[{"txt":"content"},{"html":"DISPLAYTITLE:&lt;i data-parsoid=&#39;{\"dsr\":[15,31,2,2]}&#39;>&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[]],\"dsr\":[17,29,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"PAGENAME\",\"function\":\"pagename\"},\"params\":{},\"i\":0}}]}&#39;>Main Page&lt;/span>&lt;/i>"}]]}'/>
10951 !! end
10952
10953 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
10954 # But, this is a limitation of our representation and is documented in
10955 # TemplateHandler.js in processSpecialMagicWord
10956 !! test
10957 Parsoid: Template-generated DISPLAYTITLE
10958 !! wikitext
10959 {{{{echo|DISPLAYTITLE}}:Foo}}
10960 !! options
10961 showtitle
10962 !! config
10963 wgAllowDisplayTitle=true
10964 wgRestrictDisplayTitle=false
10965 !! html/php
10966 Foo
10967
10968 !! html/parsoid
10969 <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"}]]}'/>
10970 !! end
10971
10972 !! test
10973 Namespace 1 {{ns:1}}
10974 !! wikitext
10975 {{ns:1}}
10976 !! html
10977 <p>Talk
10978 </p>
10979 !! end
10980
10981 !! test
10982 Namespace 1 {{ns:01}}
10983 !! wikitext
10984 {{ns:01}}
10985 !! html
10986 <p>Talk
10987 </p>
10988 !! end
10989
10990 !! test
10991 Namespace 0 {{ns:0}} (T6783)
10992 !! wikitext
10993 {{ns:0}}
10994 !! html
10995
10996 !! end
10997
10998 !! test
10999 Namespace 0 {{ns:00}} (T6783)
11000 !! wikitext
11001 {{ns:00}}
11002 !! html
11003
11004 !! end
11005
11006 !! test
11007 Namespace -1 {{ns:-1}}
11008 !! wikitext
11009 {{ns:-1}}
11010 !! html
11011 <p>Special
11012 </p>
11013 !! end
11014
11015 !! test
11016 Namespace User {{ns:User}}
11017 !! wikitext
11018 {{ns:User}}
11019 !! html
11020 <p>User
11021 </p>
11022 !! end
11023
11024 !! test
11025 Namespace User talk {{ns:User_talk}}
11026 !! wikitext
11027 {{ns:User_talk}}
11028 !! html
11029 <p>User talk
11030 </p>
11031 !! end
11032
11033 !! test
11034 Namespace User talk {{ns:uSeR tAlK}}
11035 !! wikitext
11036 {{ns:uSeR tAlK}}
11037 !! html
11038 <p>User talk
11039 </p>
11040 !! end
11041
11042 !! test
11043 Namespace File {{ns:File}}
11044 !! wikitext
11045 {{ns:File}}
11046 !! html
11047 <p>File
11048 </p>
11049 !! end
11050
11051 !! test
11052 Namespace File {{ns:Image}}
11053 !! wikitext
11054 {{ns:Image}}
11055 !! html
11056 <p>File
11057 </p>
11058 !! end
11059
11060 !! test
11061 Namespace (lang=de) Benutzer {{ns:User}}
11062 !! options
11063 language=de
11064 !! wikitext
11065 {{ns:User}}
11066 !! html
11067 <p>Benutzer
11068 </p>
11069 !! end
11070
11071 !! test
11072 Namespace (lang=de) Benutzer Diskussion {{ns:3}}
11073 !! options
11074 language=de
11075 !! wikitext
11076 {{ns:3}}
11077 !! html
11078 <p>Benutzer Diskussion
11079 </p>
11080 !! end
11081
11082 !! test
11083 Urlencode
11084 !! wikitext
11085 {{urlencode:hi world?!}}
11086 {{urlencode:hi world?!|WIKI}}
11087 {{urlencode:hi world?!|PATH}}
11088 {{urlencode:hi world?!|QUERY}}
11089 !! html/php
11090 <p>hi+world%3F%21
11091 hi_world%3F!
11092 hi%20world%3F%21
11093 hi+world%3F%21
11094 </p>
11095 !! end
11096
11097 !! test
11098 Magic Word: prioritize type info over data-parsoid
11099 !! options
11100 parsoid=html2wt
11101 !! html/parsoid
11102 <meta property="mw:PageProp/forcetoc" data-parsoid='{"magicSrc":"__NOTOC__"}'/>
11103 !! wikitext
11104 __FORCETOC__
11105 !! end
11106
11107 !! test
11108 Magic Word: serialize on separate line (parsoid)
11109 !! options
11110 parsoid=wt2wt,html2wt
11111 !! wikitext
11112 foo
11113 __NOTOC__
11114 bar
11115 !! html/parsoid
11116 foo<meta property="mw:PageProp/notoc"/>bar
11117 !! end
11118
11119 !! test
11120 Magic Word: rt non-english wikis
11121 !! options
11122 parsoid=wt2wt
11123 language=de
11124 !! wikitext
11125 __NOEDITSECTION__
11126 !! html/parsoid
11127 <meta property="mw:PageProp/noeditsection" data-parsoid='{"magicSrc":"__NOEDITSECTION__"}'/>
11128 !! end
11129
11130 !!test
11131 __proto__ is treated as normal wikitext (T105997)
11132 !!wikitext
11133 __proto__
11134 !!html
11135 <p>__proto__
11136 </p>
11137 !!end
11138
11139 ###
11140 ### Magic links
11141 ###
11142 !! test
11143 Magic links: internal link to RFC (T2479)
11144 !! wikitext
11145 [[RFC 123]]
11146 !! html/php
11147 <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>
11148 </p>
11149 !! html/parsoid
11150 <p><a rel="mw:WikiLink" href="./RFC_123" title="RFC 123">RFC 123</a></p>
11151 !! end
11152
11153 !! test
11154 Magic links: RFC (T2479)
11155 !! wikitext
11156 RFC 822
11157 !! html/php
11158 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
11159 </p>
11160 !! html/parsoid
11161 <p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external mw-magiclink">RFC 822</a></p>
11162 !! end
11163
11164 !! test
11165 Magic links: RFC (T67278)
11166 !! wikitext
11167 This is RFC 822 but thisRFC 822 is not RFC 822linked.
11168 !! html/php
11169 <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.
11170 </p>
11171 !! html/parsoid
11172 <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>
11173 !! end
11174
11175 !! test
11176 Magic links: RFC (w/ non-newline whitespace, T30950/T31025)
11177 !! wikitext
11178 RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 822
11179 RFC
11180 822
11181 !! html/php
11182 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
11183 RFC
11184 822
11185 </p>
11186 !! html/parsoid
11187 <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>
11188 RFC
11189 822</p>
11190 !! end
11191
11192 !! test
11193 Magic links: ISBN (T3937)
11194 !! wikitext
11195 ISBN 0-306-40615-2
11196 !! html/php
11197 <p><a href="/wiki/Special:BookSources/0306406152" class="internal mw-magiclink-isbn">ISBN 0-306-40615-2</a>
11198 </p>
11199 !! html/parsoid
11200 <p><a href="./Special:BookSources/0306406152" rel="mw:WikiLink">ISBN 0-306-40615-2</a></p>
11201 !! end
11202
11203 !! test
11204 Magic links: ISBN (T67278)
11205 !! wikitext
11206 This is ISBN 978-0-316-09811-3 but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.
11207 !! html/php
11208 <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.
11209 </p>
11210 !! html/parsoid
11211 <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>
11212 !! end
11213
11214 !! test
11215 Magic links: ISBN (w/ non-newline whitespace, T30950/T31025)
11216 !! wikitext
11217 ISBN &nbsp;&#160;&#0160;&#xA0;&#Xa0; 978&nbsp;0&#160;316&#0160;09811&#xA0;3
11218 ISBN
11219 9780316098113
11220 ISBN 978
11221 0316098113
11222 !! html/php
11223 <p><a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978 0 316 09811 3</a>
11224 ISBN
11225 9780316098113
11226 ISBN 978
11227 0316098113
11228 </p>
11229 !! html/parsoid
11230 <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>
11231 ISBN
11232 9780316098113
11233 ISBN 978
11234 0316098113</p>
11235 !! end
11236
11237 !! test
11238 Magic links: PMID incorrectly converts space to underscore
11239 !! wikitext
11240 PMID 1234
11241 !! html/php
11242 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11243 </p>
11244 !! html/parsoid
11245 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external mw-magiclink">PMID 1234</a></p>
11246 !! end
11247
11248 !! test
11249 Magic links: PMID (T67278)
11250 !! wikitext
11251 This is PMID 1234 but thisPMID 1234 is not PMID 1234linked.
11252 !! html/php
11253 <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.
11254 </p>
11255 !! html/parsoid
11256 <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>
11257 !! end
11258
11259 !! test
11260 Magic links: PMID (w/ non-newline whitespace, T30950/T31025)
11261 !! wikitext
11262 PMID &nbsp;&#160;&#0160;&#xA0;&#Xa0; 1234
11263 PMID
11264 1234
11265 !! html/php
11266 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11267 PMID
11268 1234
11269 </p>
11270 !! html/parsoid
11271 <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>
11272 PMID
11273 1234</p>
11274 !! end
11275
11276 # <nowiki> nodes shouldn't be inserted during html2wt by Parsoid,
11277 # since these are ExtLinkText, not MagicLinkText
11278 !! test
11279 Magic links: use appropriate serialization for "almost" magic links.
11280 !! wikitext
11281 X[[Special:BookSources/0978739256|foo]]
11282
11283 X[https://tools.ietf.org/html/rfc1234 foo]
11284 !! html/php
11285 <p>X<a href="/wiki/Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a>
11286 </p><p>X<a rel="nofollow" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a>
11287 </p>
11288 !! html/parsoid
11289 <p>X<a rel="mw:WikiLink" href="./Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a></p>
11290 <p>X<a rel="mw:ExtLink" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a></p>
11291 !! end
11292
11293 !! test
11294 Magic links: All disabled (T47942)
11295 !! options
11296 wgEnableMagicLinks={"ISBN":false, "PMID":false, "RFC":false}
11297 !! wikitext
11298 ISBN 0-306-40615-2
11299 PMID 1234
11300 RFC 4321
11301 !! html/php
11302 <p>ISBN 0-306-40615-2
11303 PMID 1234
11304 RFC 4321
11305 </p>
11306 !! end
11307
11308 ###
11309 ### Templates
11310 ####
11311
11312 !! test
11313 Nonexistent template
11314 !! wikitext
11315 {{thistemplatedoesnotexist}}
11316 !! html
11317 <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>
11318 </p>
11319 !! end
11320
11321 !! test
11322 Template with invalid target containing tags
11323 !! wikitext
11324 {{a<b>b</b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11325 !! html
11326 <p>{{a<b>b</b>|foo|a=b|a = b}}
11327 </p>
11328 !! end
11329
11330 !! test
11331 Template with invalid target containing unclosed tag
11332 !! wikitext
11333 {{a<b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11334 !! html
11335 <p>{{a<b>|foo|a=b|a = b}}</b>
11336 </p>
11337 !! end
11338
11339 !! test
11340 Template with invalid target containing wikilink
11341 !! wikitext
11342 {{[[Main Page]]}}
11343 !! html/php
11344 <p>{{<a href="/wiki/Main_Page" title="Main Page">Main Page</a>}}
11345 </p>
11346 !! html/parsoid
11347 <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>
11348 !! end
11349
11350 !! test
11351 Template with just whitespace in it, T70421
11352 !! wikitext
11353 {{echo|{{ }}}}
11354 !! html/parsoid
11355 <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>
11356 !! end
11357
11358 !! article
11359 Template:test
11360 !! text
11361 This is a test template
11362 !! endarticle
11363
11364 !! test
11365 Simple template
11366 !! wikitext
11367 {{test}}
11368 !! html
11369 <p>This is a test template
11370 </p>
11371 !! end
11372
11373 !! test
11374 Template with explicit namespace
11375 !! wikitext
11376 {{Template:test}}
11377 !! html
11378 <p>This is a test template
11379 </p>
11380 !! end
11381
11382
11383 !! article
11384 Template:paramtest
11385 !! text
11386 This is a test template with parameter {{{param}}}
11387 !! endarticle
11388
11389 !! test
11390 Template parameter
11391 !! wikitext
11392 {{paramtest|param=foo}}
11393 !! html
11394 <p>This is a test template with parameter foo
11395 </p>
11396 !! end
11397
11398 !! article
11399 Template:paramtestnum
11400 !! text
11401 [[{{{1}}}|{{{2}}}]]
11402 !! endarticle
11403
11404 !! test
11405 Template unnamed parameter
11406 !! wikitext
11407 {{paramtestnum|Main Page|the main page}}
11408 !! html
11409 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
11410 </p>
11411 !! end
11412
11413 !! article
11414 Template:templatesimple
11415 !! text
11416 (test)
11417 !! endarticle
11418
11419 !! article
11420 Template:templateredirect
11421 !! text
11422 #redirect [[Template:templatesimple]]
11423 !! endarticle
11424
11425 !! article
11426 Template:templateasargtestnum
11427 !! text
11428 {{{{{1}}}}}
11429 !! endarticle
11430
11431 !! article
11432 Template:templateasargtest
11433 !! text
11434 {{template{{{templ}}}}}
11435 !! endarticle
11436
11437 !! article
11438 Template:templateasargtest2
11439 !! text
11440 {{{{{templ}}}}}
11441 !! endarticle
11442
11443 !! test
11444 Template with template name as unnamed argument
11445 !! wikitext
11446 {{templateasargtestnum|templatesimple}}
11447 !! html
11448 <p>(test)
11449 </p>
11450 !! end
11451
11452 !! test
11453 Template with template name as argument
11454 !! wikitext
11455 {{templateasargtest|templ=simple}}
11456 !! html
11457 <p>(test)
11458 </p>
11459 !! end
11460
11461 !! test
11462 Template with template name as argument (2)
11463 !! wikitext
11464 {{templateasargtest2|templ=templatesimple}}
11465 !! html
11466 <p>(test)
11467 </p>
11468 !! end
11469
11470 !! article
11471 Template:templateasargtestdefault
11472 !! text
11473 {{{{{templ|templatesimple}}}}}
11474 !! endarticle
11475
11476 !! article
11477 Template:templa
11478 !! text
11479 '''templ'''
11480 !! endarticle
11481
11482 !! test
11483 Template with default value
11484 !! wikitext
11485 {{templateasargtestdefault}}
11486 !! html
11487 <p>(test)
11488 </p>
11489 !! end
11490
11491 !! test
11492 Template with default value (value set)
11493 !! wikitext
11494 {{templateasargtestdefault|templ=templa}}
11495 !! html
11496 <p><b>templ</b>
11497 </p>
11498 !! end
11499
11500 !! test
11501 Template redirect
11502 !! wikitext
11503 {{templateredirect}}
11504 !! html/php
11505 <p>(test)
11506 </p>
11507 !! html/parsoid
11508 <link rel="mw:PageProp/redirect" href="./Template:Templatesimple" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"templateredirect","href":"./Template:Templateredirect"},"params":{},"i":0}}]}'/>
11509 !! end
11510
11511 !! test
11512 Template with argument in separate line
11513 !! wikitext
11514 {{ templateasargtest |
11515 templ = simple }}
11516 !! html
11517 <p>(test)
11518 </p>
11519 !! end
11520
11521 !! test
11522 Template with complex template as argument
11523 !! wikitext
11524 {{paramtest|
11525 param ={{ templateasargtest |
11526 templ = simple }}}}
11527 !! html
11528 <p>This is a test template with parameter (test)
11529 </p>
11530 !! end
11531
11532 !! test
11533 Templates with templated name
11534 !! wikitext
11535 {{{{echo|echo}}|foo}}
11536 {{{{echo|inner list}} }}
11537 !! html
11538 <p>foo
11539 </p>
11540 <ul><li>item 1</li></ul>
11541
11542 !! html/parsoid
11543 <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>
11544 <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>
11545 !! end
11546
11547 ## Regression test; the output here isn't really that interesting.
11548 !! test
11549 Templates with templated name and top level template args
11550 !! wikitext
11551 {{1{{2{{{3}}}|4=5}}}}
11552 !! html/parsoid
11553 <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>
11554 !! end
11555
11556 # Parsoid markup is deliberate "broken". This is an edge case.
11557 # See long comment in TemplateHandler.js:convertAttribsToString.
11558 !! test
11559 Templates with invalid templated targets
11560 !! wikitext
11561 {{echo
11562 {{echo|foo}}
11563 }}
11564 !! html/php
11565 <p>{{echo
11566 foo
11567 }}
11568 </p>
11569 !! html/parsoid
11570 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n{{echo|foo}}\n"},"params":{},"i":0}}]}'>{{echo
11571 foo }}</p>
11572 !! end
11573
11574 !! test
11575 Template with thumb image (with link in description)
11576 !! wikitext
11577 {{paramtest|param=[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
11578 !! html/php
11579 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>
11580
11581 !! html+tidy
11582 <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>
11583 !! html/parsoid
11584 <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>
11585 !! end
11586
11587 !! article
11588 Template:complextemplate
11589 !! text
11590 {{{1}}} {{paramtest|
11591 param ={{{param}}}}}
11592 !! endarticle
11593
11594 !! test
11595 Template with complex arguments
11596 !! wikitext
11597 {{complextemplate|
11598 param ={{ templateasargtest |
11599 templ = simple }}|[[Template:complextemplate|link]]}}
11600 !! html
11601 <p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test)
11602 </p>
11603 !! end
11604
11605 !! test
11606 T2553: link with two variables in a piped link
11607 !! wikitext
11608 {|
11609 |[[{{{1}}}|{{{2}}}]]
11610 |}
11611 !! html/php
11612 <table>
11613 <tr>
11614 <td>[[{{{1}}}|{{{2}}}]]
11615 </td></tr></table>
11616
11617 !! html/parsoid
11618 <table>
11619 <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>
11620 </tbody></table>
11621 !! end
11622
11623 # See: T2553
11624 !! test
11625 Abort table cell attribute parsing on wikilink
11626 !! wikitext
11627 {|
11628 |testing [[one|two]] |three||four
11629 |testing one two |three||four
11630 |testing="[[one|two]]" |three||four
11631 |}
11632 !! html/php
11633 <table>
11634 <tr>
11635 <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>
11636 <td>four
11637 </td>
11638 <td>three</td>
11639 <td>four
11640 </td>
11641 <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>
11642 <td>four
11643 </td></tr></table>
11644
11645 !! html/parsoid
11646 <table>
11647 <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>
11648 <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>
11649 <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>
11650 </tbody></table>
11651 !! end
11652
11653 !! test
11654 Don't abort table cell attribute parsing if wikilink is found in template arg
11655 !! wikitext
11656 {|
11657 |Test {{#tag:ref|One two "[[three]]" four}}
11658 |}
11659 !! html/parsoid
11660 <table>
11661 <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>
11662 </tbody></table>
11663 !! end
11664
11665 !! test
11666 Magic variable as template parameter
11667 !! wikitext
11668 {{paramtest|param={{SITENAME}}}}
11669 !! html
11670 <p>This is a test template with parameter MediaWiki
11671 </p>
11672 !! end
11673
11674 !! article
11675 Template:linktest
11676 !! text
11677 [[{{{param}}}|link]]
11678 !! endarticle
11679
11680 !! test
11681 Template parameter as link source
11682 !! wikitext
11683 {{linktest|param=Main Page}}
11684 !! html
11685 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
11686 </p>
11687 !! end
11688
11689 !!article
11690 Template:paramtest2
11691 !! text
11692 including another template, {{paramtest|param={{{arg}}}}}
11693 !! endarticle
11694
11695 !! test
11696 Template passing argument to another template
11697 !! wikitext
11698 {{paramtest2|arg='hmm'}}
11699 !! html
11700 <p>including another template, This is a test template with parameter 'hmm'
11701 </p>
11702 !! end
11703
11704 !! article
11705 Template:Linktest2
11706 !! text
11707 Main Page
11708 !! endarticle
11709
11710 !! test
11711 Template as link source
11712 !! wikitext
11713 [[{{linktest2}}]]
11714
11715 [[{{linktest2}}|Main Page]]
11716
11717 [[{{linktest2}}]]Page
11718 !! html
11719 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11720 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11721 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>Page
11722 </p>
11723 !! end
11724
11725
11726 !! article
11727 Template:loop1
11728 !! text
11729 {{loop2}}
11730 !! endarticle
11731
11732 !! article
11733 Template:loop2
11734 !! text
11735 {{loop1}}
11736 !! endarticle
11737
11738 !! test
11739 Template infinite loop
11740 !! wikitext
11741 {{loop1}}
11742 !! html
11743 <p><span class="error">Template loop detected: <a href="/wiki/Template:Loop1" title="Template:Loop1">Template:Loop1</a></span>
11744 </p>
11745 !! end
11746
11747 !! test
11748 Template from main namespace
11749 !! wikitext
11750 {{:Main Page}}
11751 !! html
11752 <p>blah blah
11753 </p>
11754 !! end
11755
11756 !! test
11757 Template from non-includable namespace
11758 !! options
11759 wgNonincludableNamespaces=10
11760 !! wikitext
11761 {{echo|uh oh!}}
11762 !! html
11763 <p><a href="/wiki/Template:Echo" title="Template:Echo">Template:Echo</a>
11764 </p>
11765 !! end
11766
11767 !! article
11768 Template:table
11769 !! text
11770 {|
11771 | 1 || 2
11772 |-
11773 | 3 || 4
11774 |}
11775 !! endarticle
11776
11777 !! test
11778 T2529: Template with table, not included at beginning of line
11779 !! wikitext
11780 foo {{table}}
11781 !! html
11782 <p>foo
11783 </p>
11784 <table>
11785 <tr>
11786 <td>1</td>
11787 <td>2
11788 </td></tr>
11789 <tr>
11790 <td>3</td>
11791 <td>4
11792 </td></tr></table>
11793
11794 !! end
11795
11796 !! test
11797 T2523: Template shouldn't eat newline (or add an extra one before table)
11798 !! wikitext
11799 foo
11800 {{table}}
11801 !! html
11802 <p>foo
11803 </p>
11804 <table>
11805 <tr>
11806 <td>1</td>
11807 <td>2
11808 </td></tr>
11809 <tr>
11810 <td>3</td>
11811 <td>4
11812 </td></tr></table>
11813
11814 !! end
11815
11816 !! test
11817 T2041: Template parameters shown as broken links
11818 !! wikitext
11819 {{{parameter}}}
11820 !! html
11821 <p>{{{parameter}}}
11822 </p>
11823 !! end
11824
11825 !! test
11826 Template with targets containing wikilinks
11827 !! options
11828 parsoid=wt2html
11829 !! wikitext
11830 {{[[foo]]}}
11831
11832 {{[[{{echo|foo}}]]}}
11833
11834 {{{{echo|[[foo}}]]}}
11835 !! html/php
11836 <p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11837 </p><p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11838 </p><p>{{[[foo}}]]
11839 </p>
11840 !! html/parsoid
11841 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">foo</a>}}</p>
11842 <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>
11843 <p>{{<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[foo}}]]"}},"i":0}}]}'>[[foo}}]]</span></p>
11844 !! end
11845
11846 !! article
11847 Template:''
11848 !! text
11849 bar
11850 !! endarticle
11851
11852 !! test
11853 Templates: Double quotes as template target
11854 !! wikitext
11855 foo {{''}} baz
11856 !! html/php
11857 <p>foo bar baz
11858 </p>
11859 !! html/parsoid
11860 <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
11861 </p>
11862 !! end
11863
11864 ## This test is about making sure Parsoid's data-mw is well formed in the
11865 ## face of multiple templates with intersecting and overlapping ranges. The
11866 ## wikitext itself is wretched.
11867 !! test
11868 Templates with intersecting and overlapping ranges
11869 !! wikitext
11870 {|{{echo|
11871 <p>ha</p>}}
11872 {|{{echo|
11873 <p>ho</p>}}
11874 {{echo|{{!}}hi}}
11875 |}
11876 !! html/php+tidy
11877 <p>ha</p><table>
11878
11879 </table><p>ho</p><table>
11880
11881 <tbody><tr>
11882 <td>hi
11883 </td></tr></tbody></table>
11884 !! html/parsoid
11885 <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":""}]]}'>
11886
11887 </table><p about="#mwt1">ho</p><table about="#mwt1" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"","html":""},{"html":""}]]}'>
11888
11889 <tbody><tr><td>hi</td></tr>
11890 </tbody></table>
11891 !! end
11892
11893 !! article
11894 Template:MSGNW test
11895 !! text
11896 ''None'' of '''this''' should be
11897 * interpreted
11898 but rather passed unmodified
11899 {{test}}
11900 <gallery>
11901 File:Foobar.jpg
11902 </gallery>
11903 <!-- comment -->
11904 !! endarticle
11905
11906 # hmm, fix this or just deprecate msgnw and document its behavior?
11907 !! test
11908 msgnw keyword
11909 !! wikitext
11910 {{msgnw:MSGNW test}}
11911 !! html/php
11912 <p>&#39;&#39;None&#39;&#39; of &#39;&#39;&#39;this&#39;&#39;&#39; should be
11913 &#42; interpreted
11914 &#32;but rather passed unmodified
11915 &#123;&#123;test&#125;&#125;
11916 &#60;gallery&#62;
11917 File:Foobar.jpg
11918 &#60;/gallery&#62;
11919 &#60;!-- comment --&#62;
11920 </p>
11921 !! end
11922
11923 !! test
11924 int keyword
11925 !! wikitext
11926 {{int:youhavenewmessages|lots of money|not!}}
11927 !! html
11928 <p>You have lots of money (not!).
11929 </p>
11930 !! end
11931
11932 !! test
11933 int keyword - non-existing message
11934 !! wikitext
11935 {{int:var}}
11936 !! html
11937 <p>⧼var⧽
11938 </p>
11939 !! end
11940
11941 !! article
11942 Template:Includes
11943 !! text
11944 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11945 !! endarticle
11946
11947 !! test
11948 <includeonly> and <noinclude> being included
11949 !! wikitext
11950 {{Includes}}
11951 !! html
11952 <p>Foobar
11953 </p>
11954 !! end
11955
11956 !! article
11957 Template:Includes2
11958 !! text
11959 <onlyinclude>Foo</onlyinclude>bar
11960 !! endarticle
11961
11962 !! test
11963 <onlyinclude> being included
11964 !! wikitext
11965 {{Includes2}}
11966 !! html
11967 <p>Foo
11968 </p>
11969 !! end
11970
11971
11972 !! article
11973 Template:Includes3
11974 !! text
11975 <onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly>
11976 !! endarticle
11977
11978 !! test
11979 <onlyinclude> and <includeonly> being included
11980 !! wikitext
11981 {{Includes3}}
11982 !! html
11983 <p>Foo
11984 </p>
11985 !! end
11986
11987 !! test
11988 <includeonly> and <noinclude> on a page
11989 !! wikitext
11990 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11991 !! html
11992 <p>Foozar
11993 </p>
11994 !! end
11995
11996 !! test
11997 Un-closed <noinclude>
11998 !! wikitext
11999 <noinclude>
12000 !! html
12001 !! end
12002
12003 !! test
12004 <onlyinclude> on a page
12005 !! wikitext
12006 <onlyinclude>Foo</onlyinclude>bar
12007 !! html
12008 <p>Foobar
12009 </p>
12010 !! end
12011
12012 !! test
12013 Un-closed <onlyinclude>
12014 !! wikitext
12015 <onlyinclude>
12016 !! html
12017 !! end
12018
12019 !!test
12020 Self-closed noinclude, includeonly, onlyinclude tags
12021 !! wikitext
12022 <noinclude />
12023 <includeonly />
12024 <onlyinclude />
12025 !! html
12026 <p><br />
12027 </p>
12028 !!end
12029
12030 !!test
12031 Unbalanced includeonly and noinclude tags
12032 !! wikitext
12033 {|
12034 |a</noinclude>
12035 |b</noinclude></noinclude>
12036 |c</noinclude></includeonly>
12037 |d</includeonly></includeonly>
12038 |}
12039 !! html
12040 <table>
12041 <tr>
12042 <td>a
12043 </td>
12044 <td>b
12045 </td>
12046 <td>c&lt;/includeonly&gt;
12047 </td>
12048 <td>d&lt;/includeonly&gt;&lt;/includeonly&gt;
12049 </td></tr></table>
12050
12051 !!end
12052
12053 !! article
12054 Template:Includeonly section
12055 !! text
12056 <includeonly>
12057 ==Includeonly section==
12058 </includeonly>
12059 ==Section T-1==
12060 !!endarticle
12061
12062 !! test
12063 T8563: Edit link generation for section shown by <includeonly>
12064 !! wikitext
12065 {{includeonly section}}
12066 !! html
12067 <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>
12068 <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>
12069
12070 !! end
12071
12072 # Uses same input as the contents of [[Template:Includeonly section]]
12073 !! test
12074 T8563: Section extraction for section shown by <includeonly>
12075 !! options
12076 section=T-2
12077 !! wikitext
12078 <includeonly>
12079 ==Includeonly section==
12080 </includeonly>
12081 ==Section T-2==
12082 !! html
12083 ==Section T-2==
12084 !! end
12085
12086 !! test
12087 T8563: Edit link generation for section suppressed by <includeonly>
12088 !! wikitext
12089 <includeonly>
12090 ==Includeonly section==
12091 </includeonly>
12092 ==Section 1==
12093 !! html
12094 <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>
12095
12096 !! end
12097
12098 !! test
12099 T8563: Section extraction for section suppressed by <includeonly>
12100 !! options
12101 section=1
12102 !! wikitext
12103 <includeonly>
12104 ==Includeonly section==
12105 </includeonly>
12106 ==Section 1==
12107 !! html
12108 ==Section 1==
12109 !! end
12110
12111 !! test
12112 Un-closed <includeonly>
12113 !! wikitext
12114 <includeonly>
12115 !! html/php
12116 !! html/parsoid
12117 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>"}' data-mw='{"src":"&lt;includeonly>"}'/>
12118 !! end
12119
12120 ## We used to, but no longer wt2wt this test since the default serializer
12121 ## will normalize the include directives to serialize on their own line.
12122 ## Selser will take care of preserving formatting in scenarios where they
12123 ## intermingled with other wikitext.
12124 !! test
12125 Includes and comments at SOL
12126 !! options
12127 parsoid=wt2html,html2html
12128 !! wikitext
12129 <!-- comment --><noinclude><!-- comment --></noinclude><!-- comment -->==hu==
12130
12131 <noinclude>
12132 some
12133 </noinclude>*stuff
12134 *here
12135
12136 <noinclude>
12137 some</noinclude>* stuff
12138 * here
12139
12140 <includeonly>can have stuff</includeonly>===here===
12141
12142 !! html/php
12143 <h2><span class="mw-headline" id="hu">hu</span></h2>
12144 <p>some
12145 </p>
12146 <ul><li>stuff</li>
12147 <li>here</li></ul>
12148 <p><br />
12149 some* stuff
12150 </p>
12151 <ul><li>here</li></ul>
12152 <h3><span class="mw-headline" id="here">here</span></h3>
12153
12154 !! html/parsoid
12155 <!-- 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>
12156
12157 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
12158 <p>some</p>
12159 <meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/><ul><li>stuff</li>
12160 <li>here</li></ul>
12161
12162 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
12163 <p>some<meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/>* stuff</p>
12164 <ul><li>here</li></ul>
12165
12166 <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>
12167
12168 !! end
12169
12170 # TODO: test with DOM fragment reuse!
12171 !! test
12172 Parsoid: DOM fragment reuse
12173 !! options
12174 parsoid=wt2wt,wt2html
12175 !! wikitext
12176 a{{echo|b<table></table>c}}d
12177
12178 a{{echo|b
12179 <table></table>
12180 c}}d
12181
12182 {{echo|a
12183
12184 <table></table>
12185
12186 b}}
12187 !! html
12188 <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>
12189
12190 <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">
12191 </span><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><span about="#mwt2">
12192 </span><p about="#mwt2">cd</p>
12193
12194 <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">
12195
12196 </span><table about="#mwt3" data-parsoid='{"stx":"html"}'></table><span about="#mwt3">
12197
12198 </span><p about="#mwt3">b</p>
12199 !! end
12200
12201 !! test
12202 Parsoid: Merge double tds (T52603)
12203 !! options
12204 parsoid
12205 !! wikitext
12206 {|
12207 |{{echo|{{!}} foo}}
12208 |}
12209 !! html
12210 <table><tbody>
12211 <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>
12212 </tbody></table>
12213 !! end
12214
12215 !! test
12216 Parsoid: Merge double tds in nested transclusion content (T52603)
12217 !! options
12218 parsoid
12219 !! wikitext
12220 {{echo|<div>}}
12221 {|
12222 |{{echo|{{!}} foo}}
12223 |}
12224 {{echo|</div>}}
12225 !! html
12226 <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}}]}'>
12227 <table><tbody>
12228 <tr><td data-mw='{"parts":["|"]}'> foo</td></tr>
12229 </tbody></table>
12230 </div>
12231 !! end
12232
12233 ###
12234 ### <includeonly> and <noinclude> in attributes
12235 ###
12236 !!test
12237 0. includeonly around the entire attribute
12238 !! wikitext
12239 <span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
12240 !! html
12241 <p><span id="v2">bar</span>
12242 </p>
12243 !!end
12244
12245 !!test
12246 1. includeonly in html attr key
12247 !! wikitext
12248 <span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
12249 !! html
12250 <p><span id="foo">bar</span>
12251 </p>
12252 !!end
12253
12254 !!test
12255 2. includeonly in html attr value
12256 !! wikitext
12257 <span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
12258 <span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
12259 !! html
12260 <p><span id="v1">bar</span>
12261 <span id="v1">bar</span>
12262 </p>
12263 !!end
12264
12265 !!test
12266 3. includeonly in part of an attr value
12267 !! wikitext
12268 <span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
12269 !! html
12270 <p><span style="color:red;">bar</span>
12271 </p>
12272 !!end
12273
12274 !!test
12275 4. includeonly in table attributes
12276 !! wikitext
12277 {|
12278 |- <noinclude>
12279 |-
12280 |a
12281 </noinclude>
12282 |- <includeonly>
12283 |-
12284 |b
12285 </includeonly>
12286 |}
12287 !! html
12288 <table>
12289
12290
12291 <tr>
12292 <td>a
12293 </td></tr>
12294 </table>
12295
12296 !!end
12297
12298 ###
12299 ### Preprocessor precedence tests
12300 ### See: https://www.mediawiki.org/wiki/Preprocessor_ABNF
12301 ###
12302 ##{{[[-{{{{{{[[Foo|bar}}]]}-}}}}}]]
12303 !! test
12304 Preprocessor precedence 1: link is rightmost opening
12305 !! options
12306 parsoid=wt2html
12307 !! wikitext
12308 {{[[Foo|bar}}]]
12309
12310 But close-brace is not a valid character in a link title:
12311 {{[[Foo}}|bar]]
12312
12313 However, we can still tell this was handled as a link in the preprocessor:
12314 {{echo|[[Foo}}|bar]]|bat}}
12315 !! html/php
12316 <p>{{<a href="/wiki/Foo" title="Foo">bar}}</a>
12317 </p><p>But close-brace is not a valid character in a link title:
12318 {{[[Foo}}|bar]]
12319 </p><p>However, we can still tell this was handled as a link in the preprocessor:
12320 [[Foo}}|bar]]
12321 </p>
12322 !! html/parsoid
12323 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">bar}}</a></p>
12324 <p>But close-brace is not a valid character in a link title: {{[[Foo}}|bar]]</p>
12325 <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>
12326 !! end
12327
12328 !! test
12329 Preprocessor precedence 2: template is rightmost opening
12330 !! options
12331 language=zh
12332 !! wikitext
12333 -{{echo|foo}-}}-
12334 !! html/php
12335 <p>-foo}--
12336 </p>
12337 !! html/parsoid
12338 <p>-<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}-"}},"i":0}}]}'>foo}-</span>-</p>
12339 !! end
12340
12341 !! test
12342 Preprocessor precedence 3: language converter is rightmost opening
12343 !! options
12344 language=zh
12345 parsoid=wt2html
12346 !! wikitext
12347 {{echo|hi}}
12348
12349 {{-{R|echo|hi}}}-
12350
12351 [[-{R|raw]]}-
12352 !! html/php
12353 <p>hi
12354 </p><p>{{echo|hi}}
12355 </p><p>[[raw]]
12356 </p>
12357 !! html/parsoid
12358 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"}},"i":0}}]}'>hi</p>
12359 <p>{{<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"echo|hi}}"}}'></span></p>
12360 <p>[[<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw]]"}}'></span></p>
12361 !! end
12362
12363 !! test
12364 Preprocessor precedence 4: left-most angle bracket
12365 !! options
12366 language=zh
12367 !! wikitext
12368 <!--{raw}-->
12369 !! html/php
12370 !! html/parsoid
12371 <!--{raw}-->
12372 !! end
12373
12374 !! article
12375 Template:Precedence5
12376 !! text
12377 {{{{{1}}}}}
12378 !! endarticle
12379
12380 !! test
12381 Preprocessor precedence 5: tplarg takes precedence over template
12382 !! wikitext
12383 {{Precedence5|Bullet}}
12384 !! html/php
12385 <ul><li>Bar</li></ul>
12386
12387 !! html/parsoid
12388 <ul typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Precedence5","href":"./Template:Precedence5"},"params":{"1":{"wt":"Bullet"}},"i":0}}]}'><li>Bar</li></ul>
12389 !! end
12390
12391 !! test
12392 Preprocessor precedence 6: broken link is rightmost opening
12393 !! options
12394 parsoid=wt2html
12395 !! wikitext
12396 {{echo|[[Foo}}
12397
12398 {{echo|[[Foo|bar|bat=baz}}
12399 !! html/php
12400 <p>{{echo|[[Foo}}
12401 </p><p>{{echo|[[Foo|bar|bat=baz}}
12402 </p>
12403 !! html/parsoid
12404 <p>{{echo|[[Foo}}</p>
12405 <p>{{echo|[[Foo|bar|bat=baz}}</p>
12406 !! end
12407
12408 # This next test exposes a difference between PHP and Parsoid:
12409 # Given [[Foo|{{echo|Bar]]x}}y]]z:
12410 # 1) Both PHP and Parsoid ignore the `]]` inside the `echo` in the
12411 # "preprocessor" stage. The `{{echo` extends until the `x}}`, and the
12412 # outer `[[Foo` extends until the `y]]`
12413 # 2a) But then the PHP preprocessor emits `[[Foo|Bar]]xy]]z` as an
12414 # intermediate result (after template expansion), and link processing
12415 # happens on this intermediate result, which moves the wikilink
12416 # boundary leftward to `[[Foo|Bar]]`
12417 # 2b) Parsoid works in a single step, so it's going to keep the
12418 # wikilink as extending to the `y]]`
12419 # 3a) Then PHP does linktrail processing which slurps up the trailing
12420 # `xy` inside the link.
12421 # 3b) Parsoid will do linktrail processing to slurp up the trailing
12422 # `z` inside the link.
12423 # This is "correct" behavior. Parsoid's basic worldview is that the
12424 # `]]` inside the template shouldn't be allowed to leak out to affect
12425 # the surrounding wikilink. PHP may match Parsoid (in the future)
12426 # if you use {{#balance}} (T114445).
12427
12428 !! test
12429 Preprocessor precedence 7: broken template is rightmost opening
12430 !! options
12431 parsoid=wt2html
12432 !! wikitext
12433 [[Foo|{{echo|Bar]]
12434
12435 [[Foo|{{echo|Bar]]-x}}-y]]-z
12436
12437 Careful: linktrails can move the end of the wikilink:
12438 [[Foo|{{echo|y']]a}}l]]l
12439 !! html/php
12440 <p><a href="/wiki/Foo" title="Foo">{{echo|Bar</a>
12441 </p><p><a href="/wiki/Foo" title="Foo">Bar</a>-x-y]]-z
12442 </p><p>Careful: linktrails can move the end of the wikilink:
12443 <a href="/wiki/Foo" title="Foo">y'al</a>]]l
12444 </p>
12445 !! html/parsoid
12446 <p>[[Foo|{{echo|Bar]]</p>
12447 <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>
12448 <p>Careful: linktrails can move the end of the wikilink:
12449 <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>
12450 !! end
12451
12452 !! test
12453 Preprocessor precedence 8: broken language converter is rightmost opening
12454 !! options
12455 language=zh
12456 !! wikitext
12457 [[Foo-{R|raw]]
12458 !! html
12459 <p>[[Foo-{R|raw]]
12460 </p>
12461 !! end
12462
12463 !! article
12464 Template:Preprocessor_precedence_9
12465 !! text
12466 ;4: {{{{1}}}}
12467 ;5: {{{{{2}}}}}
12468 ;6: {{{{{{3}}}}}}
12469 ;7: {{{{{{{4}}}}}}}
12470 !! endarticle
12471
12472 !! test
12473 Preprocessor precedence 9: groups of braces
12474 !! wikitext
12475 {{Preprocessor precedence 9|Four|Bullet|1|2}}
12476 !! html/php
12477 <dl><dt>4</dt>
12478 <dd>{Four}</dd>
12479 <dt>5</dt>
12480 <dd></dd></dl>
12481 <ul><li>Bar</li></ul>
12482 <dl><dt>6</dt>
12483 <dd>Four</dd>
12484 <dt>7</dt>
12485 <dd>{Bullet}</dd></dl>
12486
12487 !! html/parsoid
12488 <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}}]}'>
12489 <dt>4</dt>
12490 <dd>{Four}</dd>
12491 <dt>5</dt>
12492 <dd></dd>
12493 </dl><ul about="#mwt1">
12494 <li>Bar</li>
12495 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12496 <dt>6</dt>
12497 <dd>Four</dd>
12498 <dt>7</dt>
12499 <dd>{Bullet}</dd>
12500 </dl>
12501 !! end
12502
12503 !! article
12504 Template:Preprocessor_precedence_10
12505 !! text
12506 ;1: -{R|raw}-
12507 ;2: -{{Bullet}}-
12508 ;3: -{{{1}}}-
12509 ;4: -{{{{2}}}}-
12510 ;5: -{{{{{3}}}}}-
12511 ;6: -{{{{{{4}}}}}}-
12512 ;7: -{{{{{{{5}}}}}}}-
12513 !! endarticle
12514
12515 !! test
12516 Preprocessor precedence 10: groups of braces with leading dash
12517 !! options
12518 language=zh
12519 !! wikitext
12520 {{Preprocessor precedence 10|Three|raw2|Bullet|1|2}}
12521 !! html/php
12522 <dl><dt>1</dt>
12523 <dd>raw</dd>
12524 <dt>2</dt>
12525 <dd>-</dd></dl>
12526 <ul><li>Bar-</li></ul>
12527 <dl><dt>3</dt>
12528 <dd>-Three-</dd>
12529 <dt>4</dt>
12530 <dd>raw2</dd>
12531 <dt>5</dt>
12532 <dd>-</dd></dl>
12533 <ul><li>Bar-</li></ul>
12534 <dl><dt>6</dt>
12535 <dd>-Three-</dd>
12536 <dt>7</dt>
12537 <dd>raw2</dd></dl>
12538
12539 !! html/parsoid
12540 <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}}]}'>
12541 <dt>1</dt>
12542 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw"}}'></span></dd>
12543 <dt>2</dt>
12544 <dd>-</dd>
12545 </dl><ul about="#mwt1">
12546 <li>Bar-</li>
12547 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12548 <dt>3</dt>
12549 <dd>-Three-</dd>
12550 <dt>4</dt>
12551 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12552 <dt>5</dt>
12553 <dd>-</dd>
12554 </dl><ul about="#mwt1">
12555 <li>Bar-</li>
12556 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12557 <dt>6</dt>
12558 <dd>-Three-</dd>
12559 <dt>7</dt>
12560 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12561 </dl>
12562 !! end
12563
12564 !! test
12565 Preprocessor precedence 11: found during visual diff testing
12566 !! wikitext
12567 {{#tag:span|-{{#tag:span|-{{echo|x}}}}}}
12568
12569 {{echo|-{{echo|-{{echo|x}}}}}}
12570
12571 {{echo|-{{echo|x}}}}
12572 !! html/php
12573 <p><span>-<span>-x</span></span>
12574 </p><p>--x
12575 </p><p>-x
12576 </p>
12577 !! html/parsoid
12578 <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>
12579
12580 <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>
12581
12582 <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>
12583 !! end
12584
12585 !! test
12586 Preprocessor precedence 12: broken language converter closed by brace.
12587 !! options
12588 parsoid=wt2html
12589 !! wikitext
12590 This form breaks the template, which is unfortunate:
12591 *{{echo|foo-{bar}bat}}
12592
12593 But if the broken language converter markup is inside an extension
12594 tag, nothing bad happens:
12595 *<nowiki>foo-{bar}bat</nowiki>
12596 *{{echo|<nowiki>foo-{bar}bat</nowiki>}}
12597 *<pre>foo-{bar}bat</pre>
12598 *{{echo|<pre>foo-{bar}bat</pre>}}
12599
12600 <tag>foo-{bar}bat</tag>
12601 {{echo|<tag>foo-{bar}bat</tag>}}
12602
12603 !! html/php+tidy
12604 <p>This form breaks the template, which is unfortunate:
12605 </p>
12606 <ul><li>{{echo|foo-{bar}bat}}</li></ul>
12607 <p>But if the broken language converter markup is inside an extension
12608 tag, nothing bad happens:
12609 </p>
12610 <ul><li>foo-&#123;bar}bat</li>
12611 <li>foo-&#123;bar}bat</li>
12612 <li><pre>foo-{bar}bat</pre></li>
12613 <li><pre>foo-{bar}bat</pre></li></ul>
12614 <pre>'foo-{bar}bat'
12615 array (
12616 )
12617 </pre>
12618 <pre>'foo-{bar}bat'
12619 array (
12620 )
12621 </pre>
12622 !! html/parsoid
12623 <p>This form breaks the template, which is unfortunate:</p>
12624 <ul>
12625 <li>{{echo|foo-{bar}bat}}</li>
12626 </ul>
12627 <p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p>
12628 <ul>
12629 <li><span typeof="mw:Nowiki">foo-{bar}bat</span></li>
12630 <li><span typeof="mw:Transclusion mw:Nowiki" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;nowiki>foo-{bar}bat&lt;/nowiki>"}},"i":0}}]}'>foo-{bar}bat</span></li>
12631 <li><pre typeof="mw:Extension/pre" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo-{bar}bat"}}'>foo-{bar}bat</pre></li>
12632 <li><pre typeof="mw:Transclusion mw:Extension/pre" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;pre>foo-{bar}bat&lt;/pre>"}},"i":0}}]}'>foo-{bar}bat</pre></li>
12633 </ul>
12634 <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>
12635 !! end
12636
12637 !! test
12638 Preprocessor precedence 13: broken language converter in external link
12639 !! options
12640 parsoid=wt2html
12641 !! wikitext
12642 *[http://example.com/-{foo Example in URL]
12643 *[http://example.com Example in -{link} description]
12644 *{{echo|[http://example.com/-{foo Breaks template, however]}}
12645 !! html/php+tidy
12646 <ul><li><a rel="nofollow" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12647 <li><a rel="nofollow" class="external text" href="http://example.com">Example in -{link} description</a></li>
12648 <li>{{echo|<a rel="nofollow" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li></ul>
12649 !! html/parsoid
12650 <ul>
12651 <li><a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12652 <li><a rel="mw:ExtLink" class="external text" href="http://example.com">Example in -{link} description</a></li>
12653 <li>{{echo|<a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
12654 </ul>
12655 !! end
12656
12657 !! test
12658 Preprocessor precedence 14: broken language converter in comment
12659 !! wikitext
12660 *<!--{{foo}}-->...should be ok
12661 *<!---{{foo}}-->...extra dashes
12662 *{{echo|foo<!-- -{bar} -->bat}}...should be ok
12663 !! html/php+tidy
12664 <ul><li>...should be ok</li>
12665 <li>...extra dashes</li>
12666 <li>foobat...should be ok</li></ul>
12667 !! html/parsoid
12668 <ul>
12669 <li><!--{{foo}}-->...should be ok</li>
12670 <li><!--&#x2D;{{foo}}-->...extra dashes</li>
12671 <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>
12672 </ul>
12673 !! end
12674
12675 !! test
12676 Preprocessor precedence 15: broken brace markup in headings
12677 !! config
12678 wgFragmentMode=[ 'html5', 'legacy' ]
12679 !! options
12680 parsoid=wt2html
12681 !! wikitext
12682 __NOTOC__ __NOEDITSECTION__
12683 ===1 foo[bar 1===
12684 1
12685 ===2 foo[[bar 2===
12686 2
12687 ===3 foo{bar 3===
12688 3
12689 ===4 foo{{bar 4===
12690 4
12691 ===5 foo{{{bar 5===
12692 5
12693 ===6 foo-{bar 6===
12694 6
12695 !! html/php+tidy
12696 <h3><span id="1_foo.5Bbar_1"></span><span class="mw-headline" id="1_foo[bar_1">1 foo[bar 1</span></h3>
12697 <p>1
12698 </p>
12699 <h3><span id="2_foo.5B.5Bbar_2"></span><span class="mw-headline" id="2_foo[[bar_2">2 foo[[bar 2</span></h3>
12700 <p>2
12701 </p>
12702 <h3><span id="3_foo.7Bbar_3"></span><span class="mw-headline" id="3_foo{bar_3">3 foo{bar 3</span></h3>
12703 <p>3
12704 </p>
12705 <h3><span id="4_foo.7B.7Bbar_4"></span><span class="mw-headline" id="4_foo{{bar_4">4 foo{{bar 4</span></h3>
12706 <p>4
12707 </p>
12708 <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>
12709 <p>5
12710 </p>
12711 <h3><span id="6_foo-.7Bbar_6"></span><span class="mw-headline" id="6_foo-{bar_6">6 foo-{bar 6</span></h3>
12712 <p>6
12713 </p>
12714 !! html/parsoid
12715 <meta property="mw:PageProp/notoc"/> <meta property="mw:PageProp/noeditsection"/>
12716 <h3 id="1_foo[bar_1"><span id="1_foo.5Bbar_1" typeof="mw:FallbackId"></span>1 foo[bar 1</h3>
12717 <p>1</p>
12718 <h3 id="2_foo[[bar_2"><span id="2_foo.5B.5Bbar_2" typeof="mw:FallbackId"></span>2 foo[[bar 2</h3>
12719 <p>2</p>
12720 <h3 id="3_foo{bar_3"><span id="3_foo.7Bbar_3" typeof="mw:FallbackId"></span>3 foo{bar 3</h3>
12721 <p>3</p>
12722 <h3 id="4_foo{{bar_4"><span id="4_foo.7B.7Bbar_4" typeof="mw:FallbackId"></span>4 foo{{bar 4</h3>
12723 <p>4</p>
12724 <h3 id="5_foo{{{bar_5"><span id="5_foo.7B.7B.7Bbar_5" typeof="mw:FallbackId"></span>5 foo{{{bar 5</h3>
12725 <p>5</p>
12726 <h3 id="6_foo-{bar_6"><span id="6_foo-.7Bbar_6" typeof="mw:FallbackId"></span>6 foo-{bar 6</h3>
12727 <p>6</p>
12728 !! end
12729
12730 !! test
12731 Preprocessor precedence 16: matching closing braces to opening braces
12732 !! options
12733 language=zh
12734 parsoid=wt2html
12735 !! wikitext
12736 -{{{echo|foo}}bar}-
12737 !! html/php
12738 <p>foobar
12739 </p>
12740 !! html/parsoid
12741 <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>
12742 !! end
12743
12744 !! test
12745 Preprocessor precedence 17: template w/o target shouldn't prevent closing
12746 !! options
12747 parsoid=wt2html
12748 !! wikitext
12749 {{echo|hi {{}}}}
12750 !! html/php
12751 <p>hi {{}}
12752 </p>
12753 !! html/parsoid
12754 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi {{}}"}},"i":0}}]}'>hi {{}}</p>
12755 !! end
12756
12757 # Ensure we're using a language without variants for this test; even
12758 # if $wgUsePigLatinVariant is true. We've picked `de` arbitrarily.
12759 !! test
12760 Preprocessor precedence 18: another rightmost wins scenario
12761 !! options
12762 parsoid=wt2html
12763 language=de
12764 !! wikitext
12765 {{ -{{{{1|tplarg}}} }} }-
12766 !! html/php
12767 <p>{{ -{tplarg }} }-
12768 </p>
12769 !! html/parsoid
12770 <p>{{ -{<span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"1"},"params":{"1":{"wt":"tplarg"}},"i":0}}]}'>tplarg</span> }} }-</p>
12771 !! end
12772
12773 !! test
12774 Preprocessor precedence 19: break syntax
12775 !! options
12776 parsoid=wt2html
12777 !! wikitext
12778 -{{
12779 !! html/php
12780 <p>-{{
12781 </p>
12782 !! html/parsoid
12783 <p>-{{</p>
12784 !! end
12785
12786 ###
12787 ### Token Stream Patcher tests
12788 ###
12789 ### These tests won't always pass wt2wt and other modes because
12790 ### on serialization, the table will be output on a new line.
12791 ### For now, we are blacklisting them, and using this to test selser.
12792 ###
12793
12794 !!test
12795 1. Table tag in SOL posn. should get reparsed correctly with valid TSR
12796 !!options
12797 parsoid=wt2html,wt2wt
12798 !!wikitext
12799 {{echo|}}{| width = '100%'
12800 |foo
12801 |}
12802 !!html/parsoid
12803 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":""}},"i":0}}]}'></span><table width="100%">
12804 <tbody><tr><td>foo</td></tr>
12805 </tbody></table>
12806 !!end
12807
12808 ## We used to, but no longer wt2wt this test since the default serializer
12809 ## will normalize the include directives to serialize on their own line.
12810 ## Selser will take care of preserving formatting in scenarios where they
12811 ## intermingled with other wikitext.
12812 !!test
12813 2. Table tag in SOL posn. should get reparsed correctly with valid TSR
12814 !!options
12815 parsoid=wt2html
12816 !!wikitext
12817 <includeonly>a</includeonly>{| {{{b}}}
12818 |c
12819 |}
12820 !!html/parsoid
12821 <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":""}]]}'>
12822 <tbody><tr><td>c</td></tr>
12823 </tbody></table>
12824 !!end
12825
12826 !! test
12827 Table wikitext syntax outside wiki-tables
12828 !! wikitext
12829 a
12830 |+ not a caption
12831 ! not a table heading
12832 |- not a table row
12833 | not a table cell
12834 | class="foo bar" | baz
12835 b
12836 |}
12837 |-
12838 c
12839 !! html
12840 <p>a
12841 |+ not a caption
12842 ! not a table heading
12843 |- not a table row
12844 | not a table cell
12845 | class="foo bar" | baz
12846 b
12847 |}
12848 |-
12849 c
12850 </p>
12851 !! end
12852
12853 ###
12854 ### Testing parsing of templates where a template arg
12855 ### has the same name as the template itself.
12856 ###
12857
12858 !! article
12859 Template:quote
12860 !! text
12861 {{{quote|{{{1}}}}}}
12862 !! endarticle
12863
12864 !!test
12865 Templates: Template Name/Arg clash: 1. Use of positional param
12866 !! wikitext
12867 {{quote|foo}}
12868 !! html
12869 <p>foo
12870 </p>
12871 !!end
12872
12873 !!test
12874 Templates: Template Name/Arg clash: 2. Use of named param
12875 !! wikitext
12876 {{quote|quote=foo}}
12877 !! html
12878 <p>foo
12879 </p>
12880 !!end
12881
12882 !!test
12883 Templates: Template Name/Arg clash: 3. Use of named param with empty input
12884 !! wikitext
12885 {{quote|quote}}
12886 !! html
12887 <p>quote
12888 </p>
12889 !!end
12890
12891 ###
12892 ### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
12893 ###
12894
12895 !!test
12896 Templates: 1. Simple use
12897 !! wikitext
12898 {{echo|Foo}}
12899 !! html
12900 <p>Foo
12901 </p>
12902 !!end
12903
12904 !!test
12905 Templates: 2. Inside a block tag
12906 !! wikitext
12907 <div>{{echo|Foo}}</div>
12908 <blockquote>{{echo|Foo}}</blockquote>
12909 !! html
12910 <div>Foo</div>
12911 <blockquote>Foo</blockquote>
12912
12913 !! html+tidy
12914 <div>Foo</div>
12915 <blockquote><p>Foo</p></blockquote>
12916 !!end
12917
12918 !!test
12919 Templates: P-wrapping: 1a. Templates on consecutive lines
12920 !! wikitext
12921 {{echo|Foo}}
12922 {{echo|bar}}
12923 !! html
12924 <p>Foo
12925 bar
12926 </p>
12927 !!end
12928
12929 !!test
12930 Templates: P-wrapping: 1b. Templates on consecutive lines
12931 !! wikitext
12932 Foo
12933
12934 {{echo|bar}}
12935 {{echo|baz}}
12936 !! html
12937 <p>Foo
12938 </p><p>bar
12939 baz
12940 </p>
12941 !!end
12942
12943 !!test
12944 Templates: P-wrapping: 1c. Templates on consecutive lines
12945 !! wikitext
12946 {{echo|Foo}}
12947 {{echo|bar}} <div>baz</div>
12948 !! html
12949 <p>Foo
12950 </p>
12951 bar <div>baz</div>
12952
12953 !! html+tidy
12954 <p>Foo
12955 </p><p>
12956 bar </p><div>baz</div>
12957 !! end
12958
12959 !!test
12960 Templates: P-wrapping: 1d. Template preceded by comment-only line
12961 !!options
12962 parsoid
12963 !! wikitext
12964 <!-- foo -->
12965 {{echo|Bar}}
12966 !! html
12967 <!-- foo -->
12968
12969 <p about="#mwt223" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar"}},"i":0}}]}'>Bar</p>
12970 !!end
12971
12972 !! test
12973 Templates: Scopes should not be expanded unnecessarily
12974 !! options
12975 parsoid=wt2html,wt2wt
12976 !! wikitext
12977 {{echo|<div>a</div>}}b{{echo|
12978 <div>c</div>}}
12979 !! html
12980 <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}}]}'>
12981 </span><div about="#mwt2">c</div>
12982 !! end
12983
12984 !!test
12985 Templates: Inline Text: 1. Multiple template uses
12986 !! wikitext
12987 {{echo|Foo}}bar{{echo|baz}}
12988 !! html
12989 <p>Foobarbaz
12990 </p>
12991 !!end
12992
12993 !!test
12994 Templates: Inline Text: 2. Back-to-back template uses
12995 !! wikitext
12996 {{echo|Foo}}{{echo|bar}}
12997 !! html
12998 <p>Foobar
12999 </p>
13000 !!end
13001
13002 !!test
13003 Templates: Block Tags: 1. Multiple template uses
13004 !! wikitext
13005 {{echo|<div>Foo</div>}}<div>bar</div>{{echo|<div>baz</div>}}
13006 !! html
13007 <div>Foo</div><div>bar</div><div>baz</div>
13008
13009 !!end
13010
13011 !!test
13012 Templates: Block Tags: 2. Back-to-back template uses
13013 !! wikitext
13014 {{echo|<div>Foo</div>}}{{echo|<div>bar</div>}}
13015 !! html
13016 <div>Foo</div><div>bar</div>
13017
13018 !!end
13019
13020 ## Parsoid drops empty elements in templates.
13021 !! test
13022 Templates: Correctly encapsulate templates producing </p> tag without a corresponding <p> tag
13023 !! wikitext
13024 {{echo|a
13025 b</p>}}
13026 !! html/php+tidy
13027 <p>a
13028 </p><p>
13029 b</p><p class="mw-empty-elt"></p>
13030 !! html/parsoid
13031 <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">
13032 </span><p about="#mwt1">b</p>
13033 !! end
13034
13035 !!test
13036 Templates: Links: 1. Simple example
13037 !! wikitext
13038 {{echo|[[Foo|bar]]}}
13039 !! html
13040 <p><a href="/wiki/Foo" title="Foo">bar</a>
13041 </p>
13042 !!end
13043
13044 !!test
13045 Templates: Links: 2. Generation of link href
13046 !! wikitext
13047 [[{{echo|Foo}}|bar]]
13048 !! html
13049 <p><a href="/wiki/Foo" title="Foo">bar</a>
13050 </p>
13051 !!end
13052
13053 !!test
13054 Templates: Links: 3. Generation of part of a link href
13055 !! wikitext
13056 [[Fo{{echo|o}}|bar]]
13057
13058 [[Foo{{echo|bar}}]]
13059
13060 [[Foo{{echo|bar}}baz]]
13061
13062 [[Foo{{echo|bar}}|bar]]
13063
13064 [[:Foo{{echo|bar}}]]
13065
13066 [[:Foo{{echo|bar}}|bar]]
13067 !! html
13068 <p><a href="/wiki/Foo" title="Foo">bar</a>
13069 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
13070 </p><p><a href="/index.php?title=Foobarbaz&amp;action=edit&amp;redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a>
13071 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
13072 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
13073 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
13074 </p>
13075 !!end
13076
13077 !!test
13078 Templates: Links: 4. Multiple templates generating link href
13079 !! wikitext
13080 [[{{echo|F}}{{echo|o}}ob{{echo|ar}}]]
13081 !! html
13082 <p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
13083 </p>
13084 !!end
13085
13086 !!test
13087 Templates: Links: 5. Generation of link text
13088 !! wikitext
13089 [[Foo|{{echo|bar}}]]
13090 !! html
13091 <p><a href="/wiki/Foo" title="Foo">bar</a>
13092 </p>
13093 !!end
13094
13095 !!test
13096 Templates: Links: 5. Nested templates (only outermost template should be marked)
13097 !! wikitext
13098 {{echo|[[{{echo|Foo}}|bar]]}}
13099 !! html
13100 <p><a href="/wiki/Foo" title="Foo">bar</a>
13101 </p>
13102 !!end
13103
13104 !!test
13105 Templates: HTML Tag: 1. Generation of HTML attr. key
13106 !! wikitext
13107 <div {{echo|style}}="color:red;">foo</div>
13108 !! html
13109 <div style="color:red;">foo</div>
13110
13111 !!end
13112
13113 !!test
13114 Templates: HTML Tag: 2. Generation of HTML attr. value
13115 !! wikitext
13116 <div style={{echo|'color:red;'}}>foo</div>
13117 !! html
13118 <div style="color:red;">foo</div>
13119
13120 !!end
13121
13122 !!test
13123 Templates: HTML Tag: 3. Generation of HTML attr key and value
13124 !! wikitext
13125 <div {{echo|style}}={{echo|'color:red;'}}>foo</div>
13126 !! html
13127 <div style="color:red;">foo</div>
13128
13129 !!end
13130
13131 !!test
13132 Templates: HTML Tag: 4. Generation of starting piece of HTML attr value
13133 !! wikitext
13134 <div title="{{echo|This is a long title}} with just one piece templated">foo</div>
13135 !! html
13136 <div title="This is a long title with just one piece templated">foo</div>
13137
13138 !!end
13139
13140 !!test
13141 Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
13142 !! wikitext
13143 <div title="This is a long title with just {{echo|one piece}} templated">foo</div>
13144 !! html
13145 <div title="This is a long title with just one piece templated">foo</div>
13146
13147 !!end
13148
13149 !!test
13150 Templates: HTML Tag: 6. Generation of end piece of HTML attr value
13151 !! wikitext
13152 <div title="This is a long title with just one piece {{echo|templated}}">foo</div>
13153 !! html
13154 <div title="This is a long title with just one piece templated">foo</div>
13155
13156 !!end
13157
13158 # SSS FIXME: While it is great we added support for all this,
13159 # do we want to make this part of the spec? Maybe we want to
13160 # deprecate this kind of usage in the future?
13161 !!test
13162 Templates: HTML Tag: 7. Generation of partial attribute key string
13163 !! wikitext
13164 <div st{{echo|yle}}="color:red;">foo</div>
13165 !! html
13166 <div style="color:red;">foo</div>
13167
13168 !!end
13169
13170 !! test
13171 Templates: HTML Tag: 8. Template-generated attribute (k=v)
13172 !! wikitext
13173 <div {{echo|1=id="v1"}}>bar</div>
13174 !! html
13175 <div id="v1">bar</div>
13176
13177 !!end
13178
13179 !! test
13180 Templates: HTML Tag: 9. Multiple template-generated attributes
13181 !! wikitext
13182 <div {{echo|1=id="v1" title="foo"}}>bar</div>
13183 !! html
13184 <div id="v1" title="foo">bar</div>
13185
13186 !!end
13187
13188 !! test
13189 Templates: Support for templates generating attributes and content
13190 !! wikitext
13191 {| {{mixed_attr_content_template}}
13192 |-
13193 |bar
13194 |}
13195 !! html/php
13196 <table style="color:red;" title="T48811">
13197
13198 <tr>
13199 <td>foo
13200 </td></tr>
13201 <tr>
13202 <td>bar
13203 </td></tr></table>
13204
13205 !! html/parsoid
13206 <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|}"]}'>
13207 <tbody><tr>
13208 <td>foo</td></tr>
13209 <tr>
13210 <td>bar</td></tr>
13211 </tbody></table>
13212 !!end
13213
13214 !! article
13215 Template:attribute_from_template
13216 !! text
13217 class="123"
13218 !! endarticle
13219
13220 !! test
13221 Table cell with attribute before expanded attribute
13222 !! wikitext
13223 {|
13224 | align="center" {{attribute_from_template}} |456
13225 |}
13226 !! html/parsoid
13227 <table>
13228 <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>
13229 </tbody></table>
13230 !! end
13231
13232 !! test
13233 1. Entities and nowikis inside templated attributes should be handled correctly
13234 !! wikitext
13235 <div {{echo|style{{=}}"background:&#35;f9f9f9;"}}>foo</div>
13236 !! html/php
13237 <div style="background:#f9f9f9;">foo</div>
13238
13239 !! html/parsoid
13240 <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>
13241 !! end
13242
13243 !! test
13244 2. Entities and nowikis inside templated attributes should be handled correctly
13245 !! wikitext
13246 {|
13247 |{{table_attribs_3}}
13248 |}
13249 !! html/php
13250 <table>
13251 <tr>
13252 <td style="background:#f9f9f9;">Foo
13253 </td></tr></table>
13254
13255 !! html/parsoid
13256 <table>
13257 <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>
13258 </tbody></table>
13259 !! end
13260
13261 !! test
13262 3. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13263 !! wikitext
13264 {{tbl-start}}
13265 |{{table_attribs_3}}
13266 {{tbl-end}}
13267 !! html/php
13268 <table>
13269 <tr>
13270 <td style="background:#f9f9f9;">Foo
13271 </td></tr></table>
13272
13273 !! html/parsoid
13274 <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}}]}'>
13275 <tbody><tr><td style="background:#f9f9f9;">Foo</td></tr>
13276 </tbody></table>
13277 !! end
13278
13279 # T107622
13280 !! test
13281 4. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13282 !! wikitext
13283 {|
13284 |{{table_attribs_6}} hi
13285 |}
13286 !! html/php
13287 <table>
13288 <tr>
13289 <td style="background: red;">hi
13290 </td></tr></table>
13291
13292 !! html/parsoid
13293 <table>
13294 <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>
13295 </tbody></table>
13296 !! end
13297
13298 !!test
13299 Templates: HTML Tables: 1. Generating start of a HTML table
13300 !! wikitext
13301 {{echo|<table><tr><td>foo</td>}}</tr></table>
13302 !! html
13303 <table><tr><td>foo</td></tr></table>
13304
13305 !!end
13306
13307 !!test
13308 Templates: HTML Tables: 2a. Generating middle of a HTML table
13309 !! wikitext
13310 <table><tr>{{echo|<td>foo</td>}}</tr></table>
13311 !! html
13312 <table><tr><td>foo</td></tr></table>
13313
13314 !!end
13315
13316 !!test
13317 Templates: HTML Tables: 2b. Generating middle of a HTML table
13318 !! wikitext
13319 <table>{{echo|<tr><td>foo</td></tr>}}</table>
13320 !! html
13321 <table><tr><td>foo</td></tr></table>
13322
13323 !!end
13324
13325 !!test
13326 Templates: HTML Tables: 3. Generating end of a HTML table
13327 !! wikitext
13328 <table><tr>{{echo|<td>foo</td></tr></table>}}
13329 !! html
13330 <table><tr><td>foo</td></tr></table>
13331
13332 !!end
13333
13334 !!test
13335 Templates: HTML Tables: 4a. Generating a single tag of a HTML table
13336 !! wikitext
13337 {{echo|<table>}}<tr><td>foo</td></tr></table>
13338 !! html
13339 <table><tr><td>foo</td></tr></table>
13340
13341 !!end
13342
13343 !!test
13344 Templates: HTML Tables: 4b. Generating a single tag of a HTML table
13345 !! wikitext
13346 <table>{{echo|<tr>}}<td>foo</td></tr></table>
13347 !! html
13348 <table><tr><td>foo</td></tr></table>
13349
13350 !!end
13351
13352 !!test
13353 Templates: HTML Tables: 4c. Generating a single tag of a HTML table
13354 !! wikitext
13355 <table><tr>{{echo|<td>}}foo</td></tr></table>
13356 !! html
13357 <table><tr><td>foo</td></tr></table>
13358
13359 !!end
13360
13361 !!test
13362 Templates: HTML Tables: 4d. Generating a single tag of a HTML table
13363 !! wikitext
13364 <table><tr><td>foo{{echo|</td>}}</tr></table>
13365 !! html
13366 <table><tr><td>foo</td></tr></table>
13367
13368 !!end
13369
13370 !!test
13371 Templates: HTML Tables: 4e. Generating a single tag of a HTML table
13372 !! wikitext
13373 <table><tr><td>foo</td>{{echo|</tr>}}</table>
13374 !! html
13375 <table><tr><td>foo</td></tr></table>
13376
13377 !!end
13378
13379 !!test
13380 Templates: HTML Tables: 4f. Generating a single tag of a HTML table
13381 !! wikitext
13382 <table><tr><td>foo</td></tr>{{echo|</table>}}
13383 !! html
13384 <table><tr><td>foo</td></tr></table>
13385
13386 !!end
13387
13388 !!test
13389 Templates: HTML Tables: 5. Proper fostering of categories from inside
13390 !!options
13391 parsoid=wt2html,wt2wt
13392 !! wikitext
13393 <table>[[Category:foo1]]<tr><td>foo</td></tr></table>
13394 <!--Two categories (T52330)-->
13395 <table>[[Category:bar1]][[Category:bar2]]<tr><td>foo</td></tr></table>
13396 !! html
13397 <link rel="mw:PageProp/Category" href="./Category:Foo1"><table><tbody><tr><td>foo</td></tr></tbody></table>
13398 <!--Two categories (T52330)-->
13399 <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>
13400 !!end
13401
13402 ## Remex doesn't account for fostered content.
13403 !! test
13404 Templates: Wiki Tables: 1a. Fostering of entire template content
13405 !! wikitext
13406 {|
13407 {{echo|a}}
13408 |}
13409 !! html/php
13410 <table>
13411 a
13412 <tr><td></td></tr></table>
13413
13414 !! html/php+tidy
13415
13416 a
13417 <table><tbody><tr><td></td></tr></tbody></table>
13418 !! html/parsoid
13419 <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">
13420
13421 </table>
13422 !! end
13423
13424 !!test
13425 Templates: Wiki Tables: 1b. Fostering of entire template content
13426 !! wikitext
13427 {|
13428 {{echo|<div>}}
13429 foo
13430 {{echo|</div>}}
13431 |}
13432 !! html
13433 <table>
13434 <div>
13435 <p>foo
13436 </p>
13437 </div>
13438 <tr><td></td></tr></table>
13439
13440 !! html/php+tidy
13441 <div>
13442 <p>foo
13443 </p>
13444 </div><table>
13445
13446 <tbody><tr><td></td></tr></tbody></table>
13447 !! html/parsoid
13448 <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|}"]}'>
13449 <p>foo</p>
13450 </div><table about="#mwt3">
13451
13452 </table>
13453 !! end
13454
13455 ## Remex doesn't account for fostered content.
13456 !! test
13457 Templates: Wiki Tables: 2. Fostering of partial template content
13458 !! wikitext
13459 {|
13460 {{echo|a
13461 <div>b</div>}}
13462 |}
13463 !! html/php
13464 <table>
13465 a
13466 <div>b</div>
13467 <tr><td></td></tr></table>
13468
13469 !! html/php+tidy
13470
13471 a
13472 <div>b</div><table>
13473 <tbody><tr><td></td></tr></tbody></table>
13474 !! html/parsoid
13475 <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">
13476
13477
13478 </table>
13479 !! end
13480
13481 !!test
13482 Templates: Wiki Tables: 3. td-content via multiple templates
13483 !! wikitext
13484 {|
13485 {{echo|{{pipe}}a}}{{echo|b}}
13486 |}
13487 !! html
13488 <table>
13489 <tr>
13490 <td>ab
13491 </td></tr></table>
13492
13493 !!end
13494
13495 !!test
13496 Templates: Wiki Tables: 4. Templated tags, no content
13497 !! wikitext
13498 {{tbl-start}}
13499 {{tbl-end}}
13500 !! html
13501 <table>
13502 <tr><td></td></tr></table>
13503
13504 !!end
13505
13506 !!test
13507 Templates: Wiki Tables: 5. Templated tags, regular td-tags
13508 !! wikitext
13509 {{tbl-start}}
13510 |foo
13511 {{tbl-end}}
13512 !! html
13513 <table>
13514 <tr>
13515 <td>foo
13516 </td></tr></table>
13517
13518 !!end
13519
13520 !!test
13521 Templates: Wiki Tables: 6. Templated tags, templated td-tags
13522 !! wikitext
13523 {{tbl-start}}
13524 {{!}}foo
13525 {{tbl-end}}
13526 !! html
13527 <table>
13528 <tr>
13529 <td>foo
13530 </td></tr></table>
13531
13532 !!end
13533
13534 ## This test case is very specific to Parsoid's internals
13535 ## and is hence only tested for Parsoid's code. Parsoid uses
13536 ## a <meta> marker tag for <ref> tags and they are expanded
13537 ## much later. We are verifying that this <meta> tag usage
13538 ## doesn't prevent foster parenting.
13539 !! test
13540 Templates: Wiki Tables: 7. Fosterable <ref>s should get fostered
13541 !! wikitext
13542 {{PartialTable}}<ref>foo</ref>
13543 |}
13544
13545 <references />
13546 !! html/parsoid
13547 <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="./Main_Page#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup></p><table about="#mwt2">
13548 <tbody>
13549 </tbody></table>
13550
13551 <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="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">foo</span></li></ol>
13552 !! end
13553
13554 !! test
13555 Templates: Wiki Tables: 8. Fosterable meta-tags should get fostered
13556 !! wikitext
13557 {{echo|
13558 {{{!}}
13559 {{!}}-}}
13560 <onlyinclude>
13561 |foo
13562 </onlyinclude>
13563 {{!}}}
13564 !! html/parsoid
13565 <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{{!}}}"]}'>
13566 </span><meta typeof="mw:Includes/OnlyInclude" about="#mwt1"/><table about="#mwt1">
13567 <tbody><tr>
13568
13569 <td>foo
13570 <meta typeof="mw:Includes/OnlyInclude/End"/></td></tr>
13571 </tbody></table>
13572 !! end
13573
13574 !!test
13575 Templates: Lists: Multi-line list-items via templates
13576 !! wikitext
13577 *{{echo|a {{nonexistent|
13578 unused}}}}
13579 *{{echo|b {{nonexistent|
13580 unused}}}}
13581 !! html
13582 <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>
13583 <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>
13584
13585 !!end
13586
13587 !!test
13588 Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo)
13589 !! wikitext
13590 {{echo|''a}}{{echo|b''c''d}}{{echo|''e}}
13591 !! html
13592 <p><i>ab</i>c<i>d</i>e
13593 </p>
13594 !!end
13595
13596 !!test
13597 Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span)
13598 (PHP parser generates misnested html)
13599 !! wikitext
13600 {{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}}
13601 !! html/parsoid
13602 <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>
13603 !!end
13604
13605 !!test
13606 Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div)
13607 (PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s)
13608 !! options
13609 parsoid=wt2html,wt2wt
13610 !! wikitext
13611 {{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}}
13612 !! html
13613 <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>
13614 <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>
13615 <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>
13616 !!end
13617
13618 !!test
13619 Templates: Ugly nesting: 4. Divs opened/closed across templates
13620 !! wikitext
13621 a<div>b{{echo|c</div>d}}e
13622 !! html
13623 a<div>bc</div>de
13624
13625 !! html+tidy
13626 <p>a</p><div>bc</div><p>de
13627 </p>
13628 !! end
13629
13630 !! test
13631 Templates: Ugly templates: 3. newline-only template parameter
13632 !! wikitext
13633 foo {{echo|
13634 }}
13635 !! html
13636 <p>foo
13637 </p>
13638 !! end
13639
13640 # This looks like a bug: a single newline triggers p/br for some reason.
13641 !! test
13642 Templates: Ugly templates: 4. newline-only template parameter inconsistency
13643 !! wikitext
13644 {{echo|
13645 }}
13646 !! html
13647 <p><br />
13648 </p>
13649 !! end
13650
13651 # T66017 -- ugly wikitext with fostered content generates two template ranges that
13652 # have a true overlap (T1-start - T2-start - T1-end - T2-end).
13653 !! test
13654 Templates: Ugly templates: 5. Template encapsulation test: Non-trivial overlap of template ranges is properly handled
13655 !! wikitext
13656 {{echo|<table>}}
13657 {{echo|<div>foo}}
13658 {{echo|</table>}}
13659 !! html/parsoid
13660 <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">
13661 </span><table about="#mwt1">
13662 </table>
13663 !! end
13664
13665 # T66017 -- ugly wikitext with fostered content generates two template ranges
13666 # that are "identical" and generate nesting cycles in the algorithm
13667 !! test
13668 Templates: Ugly templates: 6. Template encapsulation test: Cyclical nesting of template ranges is properly handled
13669 !! wikitext
13670 {{echo|<table><tr><td><table>}}
13671 {{echo|<div>}}
13672 {{echo|</div>}}
13673 !! html/parsoid
13674 <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"}'>
13675 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13676 </table></td></tr></tbody></table>
13677 !! end
13678
13679 !! test
13680 Templates: Parameters substituted at the top-level
13681 !! wikitext
13682 {{{foo|''who'' {{echo|me}}? '''never!'''}}}
13683
13684 {{{foo|bar|baz}}}
13685 !! html/php
13686 <p><i>who</i> me? <b>never!</b>
13687 </p><p>bar
13688 </p>
13689 !! html/parsoid
13690 <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>
13691
13692 <p about="#mwt3" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"foo"},"params":{"1":{"wt":"bar"},"2":{"wt":"baz"}},"i":0}}]}'>bar</p>
13693 !! end
13694
13695 !! test
13696 Templates: Param with empty arg in the final position
13697 !! wikitext
13698 {{{hi|}}}
13699 !! html/parsoid
13700 <span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"hi"},"params":{"1":{"wt":""}},"i":0}}]}'></span>
13701 !! end
13702
13703 !!test
13704 Parser Functions: 1. Simple example
13705 !! wikitext
13706 {{uc:foo}}
13707 !! html
13708 <p>FOO
13709 </p>
13710 !!end
13711
13712 !!test
13713 Parser Functions: 2. Nested use (only outermost should be marked up)
13714 !! wikitext
13715 {{uc:{{lc:FOO}}}}
13716 !! html
13717 <p>FOO
13718 </p>
13719 !!end
13720
13721 ## Note that the templates inside the references are not wrapped
13722 !! test
13723 Template nested in extension tag in template
13724 !! options
13725 language=zh
13726 !! wikitext
13727 {{echo|hi<ref>[[ho|{{echo|hi}}]]</ref>}}
13728 {{echo|hi<ref>[http://test.com?q={{echo|ho}}]</ref>}}
13729 {{echo|hi<ref>-{ho|{{echo|hi}}}-</ref>}}
13730 <references />
13731 !! html/parsoid
13732 <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="./Wikipedia:首页#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup>
13733 <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="./Wikipedia:首页#cite_note-2" style="counter-reset: mw-Ref 2;"><span class="mw-reflink-text">[2]</span></a></sup>
13734 <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="./Wikipedia:首页#cite_note-3" style="counter-reset: mw-Ref 3;"><span class="mw-reflink-text">[3]</span></a></sup></p>
13735 <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="./Wikipedia:首页#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="./Wikipedia:首页#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="./Wikipedia:首页#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>
13736 !! end
13737
13738 ###
13739 ### Pre-save transform tests
13740 ###
13741
13742 !! test
13743 pre-save transform: subst:
13744 !! options
13745 pst
13746 !! wikitext
13747 {{subst:test}}
13748 !! html/php
13749 This is a test template
13750 !! end
13751
13752 !! test
13753 pre-save transform: normal template
13754 !! options
13755 pst
13756 !! wikitext
13757 {{test}}
13758 !! html/php
13759 {{test}}
13760 !! end
13761
13762 !! test
13763 pre-save transform: nonexistent template
13764 !! options
13765 pst
13766 !! wikitext
13767 {{thistemplatedoesnotexist}}
13768 !! html/php
13769 {{thistemplatedoesnotexist}}
13770 !! end
13771
13772 !! test
13773 pre-save transform: subst magic variables
13774 !! options
13775 pst
13776 !! wikitext
13777 {{subst:SITENAME}}
13778 !! html/php
13779 MediaWiki
13780 !! end
13781
13782 # This is T2089, which I fixed. -- wtm
13783 !! test
13784 pre-save transform: subst: templates with parameters
13785 !! options
13786 pst
13787 !! wikitext
13788 {{subst:paramtest|param="something else"}}
13789 !! html/php
13790 This is a test template with parameter "something else"
13791 !! end
13792
13793 !! article
13794 Template:nowikitest
13795 !! text
13796 <nowiki>'''not wiki'''</nowiki>
13797 !! endarticle
13798
13799 !! test
13800 pre-save transform: nowiki in subst (T3188)
13801 !! options
13802 pst
13803 !! wikitext
13804 {{subst:nowikitest}}
13805 !! html/php
13806 <nowiki>'''not wiki'''</nowiki>
13807 !! end
13808
13809 !! article
13810 Template:commenttest
13811 !! text
13812 This template has <!-- a comment --> in it.
13813 !! endarticle
13814
13815 !! test
13816 pre-save transform: comment in subst (T3936)
13817 !! options
13818 pst
13819 !! wikitext
13820 {{subst:commenttest}}
13821 !! html/php
13822 This template has <!-- a comment --> in it.
13823 !! end
13824
13825 !! test
13826 pre-save transform: unclosed tag
13827 !! options
13828 pst
13829 !! wikitext
13830 <nowiki>'''not wiki'''
13831 !! html/php
13832 <nowiki>'''not wiki'''
13833 !! end
13834
13835 !! test
13836 pre-save transform: mixed tag case
13837 !! options
13838 pst
13839 !! wikitext
13840 <NOwiki>'''not wiki'''</noWIKI>
13841 !! html/php
13842 <NOwiki>'''not wiki'''</noWIKI>
13843 !! end
13844
13845 !! test
13846 pre-save transform: unclosed comment in <nowiki>
13847 !! options
13848 pst
13849 !! wikitext
13850 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13851 !! html/php
13852 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13853 !!end
13854
13855 # Leading @ in this template definition works around a limitation
13856 # in parsoid's parserTests which otherwise strips the <span> from the
13857 # result (confusing it for a template wrapper)
13858 !! article
13859 Template:dangerous
13860 !!text
13861 @<span onmouseover="alert('crap')">Oh no</span>
13862 !!endarticle
13863
13864 !!test
13865 (confirming safety of fix for subst T3936)
13866 !! wikitext
13867 {{Template:dangerous}}
13868 !! html
13869 <p>@<span>Oh no</span>
13870 </p>
13871 !! end
13872
13873 !! test
13874 pre-save transform: comment containing gallery (T7024)
13875 !! options
13876 pst
13877 !! wikitext
13878 <!-- <gallery>data</gallery> -->
13879 !! html/php
13880 <!-- <gallery>data</gallery> -->
13881 !!end
13882
13883 !! test
13884 pre-save transform: comment containing extension
13885 !! options
13886 pst
13887 !! wikitext
13888 <!-- <tag>data</tag> -->
13889 !! html/php
13890 <!-- <tag>data</tag> -->
13891 !!end
13892
13893 !! test
13894 pre-save transform: comment containing nowiki
13895 !! options
13896 pst
13897 !! wikitext
13898 <!-- <nowiki>data</nowiki> -->
13899 !! html/php
13900 <!-- <nowiki>data</nowiki> -->
13901 !!end
13902
13903 !! test
13904 pre-save transform: <noinclude> in subst (T5298)
13905 !! options
13906 pst
13907 !! wikitext
13908 {{subst:Includes}}
13909 !! html/php
13910 Foobar
13911 !! end
13912
13913 !! test
13914 pre-save transform: <onlyinclude> in subst (T5298)
13915 !! options
13916 pst
13917 !! wikitext
13918 {{subst:Includes2}}
13919 !! html/php
13920 Foo
13921 !! end
13922
13923 !! article
13924 Template:SubstTest
13925 !!text
13926 {{<includeonly>subst:</includeonly>Includes}}
13927 !! endarticle
13928
13929 !! article
13930 Template:SafeSubstTest
13931 !! text
13932 {{<includeonly>safesubst:</includeonly>Includes}}
13933 !! endarticle
13934
13935 !! test
13936 T24297: safesubst: works during PST
13937 !! options
13938 pst
13939 !! wikitext
13940 {{subst:SafeSubstTest}}{{safesubst:SubstTest}}
13941 !! html/php
13942 FoobarFoobar
13943 !! end
13944
13945 !! test
13946 T24297: safesubst: works during normal parse
13947 !! wikitext
13948 {{SafeSubstTest}}
13949 !! html
13950 <p>Foobar
13951 </p>
13952 !! end
13953
13954 !! test
13955 subst: does not work during normal parse
13956 !! wikitext
13957 {{SubstTest}}
13958 !! html
13959 <p>{{subst:Includes}}
13960 </p>
13961 !! end
13962
13963 !! test
13964 pre-save transform: context links ("pipe trick")
13965 !! options
13966 pst
13967 !! wikitext
13968 [[Article (context)|]]
13969 [[Bar:Article|]]
13970 [[:Bar:Article|]]
13971 [[Bar:Article (context)|]]
13972 [[:Bar:Article (context)|]]
13973 [[|Article]]
13974 [[|Article (context)]]
13975 [[Bar:X (Y) Z|]]
13976 [[:Bar:X (Y) Z|]]
13977 !! html/php
13978 [[Article (context)|Article]]
13979 [[Bar:Article|Article]]
13980 [[:Bar:Article|Article]]
13981 [[Bar:Article (context)|Article]]
13982 [[:Bar:Article (context)|Article]]
13983 [[Article]]
13984 [[Article (context)]]
13985 [[Bar:X (Y) Z|X (Y) Z]]
13986 [[:Bar:X (Y) Z|X (Y) Z]]
13987 !! end
13988
13989 !! test
13990 pre-save transform: context links ("pipe trick") with interwiki prefix
13991 !! options
13992 pst
13993 !! wikitext
13994 [[interwiki:Article|]]
13995 [[:interwiki:Article|]]
13996 [[interwiki:Bar:Article|]]
13997 [[:interwiki:Bar:Article|]]
13998 !! html/php
13999 [[interwiki:Article|Article]]
14000 [[:interwiki:Article|Article]]
14001 [[interwiki:Bar:Article|Bar:Article]]
14002 [[:interwiki:Bar:Article|Bar:Article]]
14003 !! end
14004
14005 !! test
14006 pre-save transform: context links ("pipe trick") with parens in title
14007 !! options
14008 pst title=[[Somearticle (context)]]
14009 !! wikitext
14010 [[|Article]]
14011 !! html/php
14012 [[Article (context)|Article]]
14013 !! end
14014
14015 !! test
14016 pre-save transform: context links ("pipe trick") with comma in title
14017 !! options
14018 pst title=[[Someplace, Somewhere]]
14019 !! wikitext
14020 [[|Otherplace]]
14021 [[Otherplace, Elsewhere|]]
14022 [[Otherplace, Elsewhere, Anywhere|]]
14023 !! html/php
14024 [[Otherplace, Somewhere|Otherplace]]
14025 [[Otherplace, Elsewhere|Otherplace]]
14026 [[Otherplace, Elsewhere, Anywhere|Otherplace]]
14027 !! end
14028
14029 !! test
14030 pre-save transform: context links ("pipe trick") with parens and comma
14031 !! options
14032 pst title=[[Someplace (IGNORED), Somewhere]]
14033 !! wikitext
14034 [[|Otherplace]]
14035 [[Otherplace (place), Elsewhere|]]
14036 !! html/php
14037 [[Otherplace, Somewhere|Otherplace]]
14038 [[Otherplace (place), Elsewhere|Otherplace]]
14039 !! end
14040
14041 !! test
14042 pre-save transform: context links ("pipe trick") with comma and parens
14043 !! options
14044 pst title=[[Who, me? (context)]]
14045 !! wikitext
14046 [[|Yes, you.]]
14047 [[Me, Myself, and I (1937 song)|]]
14048 !! html/php
14049 [[Yes, you. (context)|Yes, you.]]
14050 [[Me, Myself, and I (1937 song)|Me, Myself, and I]]
14051 !! end
14052
14053 !! test
14054 pre-save transform: context links ("pipe trick") with namespace
14055 !! options
14056 pst title=[[Ns:Somearticle]]
14057 !! wikitext
14058 [[|Article]]
14059 !! html/php
14060 [[Ns:Article|Article]]
14061 !! end
14062
14063 !! test
14064 pre-save transform: context links ("pipe trick") with namespace and parens
14065 !! options
14066 pst title=[[Ns:Somearticle (context)]]
14067 !! wikitext
14068 [[|Article]]
14069 !! html/php
14070 [[Ns:Article (context)|Article]]
14071 !! end
14072
14073 !! test
14074 pre-save transform: context links ("pipe trick") with namespace and comma
14075 !! options
14076 pst title=[[Ns:Somearticle, Context, Whatever]]
14077 !! wikitext
14078 [[|Article]]
14079 !! html/php
14080 [[Ns:Article, Context, Whatever|Article]]
14081 !! end
14082
14083 !! test
14084 pre-save transform: context links ("pipe trick") with namespace, comma and parens
14085 !! options
14086 pst title=[[Ns:Somearticle, Context (context)]]
14087 !! wikitext
14088 [[|Article]]
14089 !! html/php
14090 [[Ns:Article (context)|Article]]
14091 !! end
14092
14093 !! test
14094 pre-save transform: context links ("pipe trick") with namespace, parens and comma
14095 !! options
14096 pst title=[[Ns:Somearticle (IGNORED), Context]]
14097 !! wikitext
14098 [[|Article]]
14099 !! html/php
14100 [[Ns:Article, Context|Article]]
14101 !! end
14102
14103 !! test
14104 pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, T32149)
14105 !! options
14106 pst
14107 !! wikitext
14108 [[Article(context)|]]
14109 [[Bar:Article(context)|]]
14110 [[:Bar:Article(context)|]]
14111 [[|Article(context)]]
14112 [[Bar:X(Y)Z|]]
14113 [[:Bar:X(Y)Z|]]
14114 !! html/php
14115 [[Article(context)|Article]]
14116 [[Bar:Article(context)|Article]]
14117 [[:Bar:Article(context)|Article]]
14118 [[Article(context)]]
14119 [[Bar:X(Y)Z|X(Y)Z]]
14120 [[:Bar:X(Y)Z|X(Y)Z]]
14121 !! end
14122
14123 !! test
14124 pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, T32149)
14125 !! options
14126 pst
14127 !! wikitext
14128 [[Article (context)|]]
14129 [[Bar:Article (context)|]]
14130 [[:Bar:Article (context)|]]
14131 [[|Article (context)]]
14132 [[Bar:X (Y) Z|]]
14133 [[:Bar:X (Y) Z|]]
14134 !! html/php
14135 [[Article (context)|Article]]
14136 [[Bar:Article (context)|Article]]
14137 [[:Bar:Article (context)|Article]]
14138 [[Article (context)]]
14139 [[Bar:X (Y) Z|X (Y) Z]]
14140 [[:Bar:X (Y) Z|X (Y) Z]]
14141 !! end
14142
14143 !! test
14144 pre-save transform: context links ("pipe trick") with parens and no space (Korean style, T32149)
14145 !! options
14146 pst
14147 !! wikitext
14148 [[Article(context)|]]
14149 [[Bar:Article(context)|]]
14150 [[:Bar:Article(context)|]]
14151 [[|Article(context)]]
14152 [[Bar:X(Y)Z|]]
14153 [[:Bar:X(Y)Z|]]
14154 !! html/php
14155 [[Article(context)|Article]]
14156 [[Bar:Article(context)|Article]]
14157 [[:Bar:Article(context)|Article]]
14158 [[Article(context)]]
14159 [[Bar:X(Y)Z|X(Y)Z]]
14160 [[:Bar:X(Y)Z|X(Y)Z]]
14161 !! end
14162
14163 !! test
14164 pre-save transform: context links ("pipe trick") with commas (T23660)
14165 !! options
14166 pst
14167 !! wikitext
14168 [[Article (context), context|]]
14169 [[Article (context),context|]]
14170 [[Bar:Article (context), context|]]
14171 [[Bar:Article (context),context|]]
14172 [[:Bar:Article (context), context|]]
14173 [[:Bar:Article (context),context|]]
14174 !! html/php
14175 [[Article (context), context|Article]]
14176 [[Article (context),context|Article]]
14177 [[Bar:Article (context), context|Article]]
14178 [[Bar:Article (context),context|Article]]
14179 [[:Bar:Article (context), context|Article]]
14180 [[:Bar:Article (context),context|Article]]
14181 !! end
14182
14183 !! test
14184 Parsoid: backwards pipe trick
14185 !! wikitext
14186 [[|'''bar''']]
14187 !! html/php
14188 <p>[[|<b>bar</b>]]
14189 </p>
14190 !! html/parsoid
14191 <p>[[|<b>bar</b>]]</p>
14192 !! end
14193
14194 !! test
14195 pre-save transform: trim trailing empty lines
14196 !! options
14197 pst
14198 !! wikitext
14199 Empty lines are trimmed
14200
14201
14202
14203
14204 !! html/php
14205 Empty lines are trimmed
14206 !! end
14207
14208 !! test
14209 pre-save transform: Signature expansion
14210 !! options
14211 pst
14212 !! wikitext
14213 * ~~~
14214 * ~~~~
14215 * ~~~~~
14216 * <noinclude>~~~</noinclude>
14217 * <includeonly>~~~</includeonly>
14218 * <onlyinclude>~~~</onlyinclude>
14219 !! html/php
14220 * [[Special:Contributions/127.0.0.1|127.0.0.1]]
14221 * [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
14222 * 00:02, 1 January 1970 (UTC)
14223 * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
14224 * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
14225 * <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>
14226 !! end
14227
14228
14229 !! test
14230 ParserOutput flags from signature expansion (T84843)
14231 !! options
14232 pst
14233 showflags
14234 !! wikitext
14235 ~~~~
14236 !! html/php
14237 [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
14238 flags=user-signature
14239 !! end
14240
14241
14242 !! test
14243 pre-save transform: Signature expansion in nowiki tags (T2093)
14244 !! options
14245 pst disabled
14246 !! wikitext
14247 Shall not expand:
14248
14249 <nowiki>~~~~</nowiki>
14250
14251 <includeonly><nowiki>~~~~</nowiki></includeonly>
14252
14253 <noinclude><nowiki>~~~~</nowiki></noinclude>
14254
14255 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14256
14257 {{subst:Foo}} shall be converted to FOO
14258
14259 As well as inside noinclude/onlyinclude
14260 <noinclude>{{subst:Foo}}</noinclude>
14261 <onlyinclude>{{subst:Foo}}</onlyinclude>
14262
14263 But not inside includeonly
14264 <includeonly>{{subst:Foo}}</includeonly>
14265 !! html/php
14266 Shall not expand:
14267
14268 <nowiki>~~~~</nowiki>
14269
14270 <includeonly><nowiki>~~~~</nowiki></includeonly>
14271
14272 <noinclude><nowiki>~~~~</nowiki></noinclude>
14273
14274 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14275
14276 FOO shall be converted to FOO
14277
14278 As well as inside noinclude/onlyinclude
14279 <noinclude>FOO</noinclude>
14280 <onlyinclude>FOO</onlyinclude>
14281
14282 But not inside includeonly
14283 <includeonly>{{subst:Foo}}</includeonly>
14284 !! end
14285
14286 !! test
14287 Parsoid: Recognize nowiki with trailing space in tags
14288 !! options
14289 parsoid=wt2html
14290 !! wikitext
14291 <nowiki ><div>[[foo]]</nowiki >
14292
14293 a<nowiki / >b
14294
14295 c<nowiki />d
14296
14297 e<nowiki/ >f
14298 !! html/php+tidy
14299 <p>&lt;div&gt;[[foo]]
14300 </p><p>a&lt;nowiki / &gt;b
14301 </p><p>cd
14302 </p><p>e&lt;nowiki/ &gt;f
14303 </p>
14304 !! html/parsoid
14305 <p><span typeof="mw:Nowiki">&lt;div>[[foo]]</span></p>
14306
14307 <p>a&lt;nowiki / >b</p>
14308
14309 <p>c<span typeof="mw:Nowiki"></span>d</p>
14310
14311 <p>e&lt;nowiki/ >f</p>
14312 !! end
14313
14314 !! test
14315 Parsoid: Recognize nowiki with odd capitalization
14316 !! options
14317 parsoid=wt2html
14318 !! wikitext
14319 <noWikI ><div>[[foo]]</Nowiki >
14320 !! html
14321 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
14322 !! end
14323
14324
14325 !! test
14326 Parsoid: Escape nowiki with trailing space in tags
14327 !! options
14328 parsoid=html2wt
14329 !! html/parsoid
14330 <p>&lt;nowiki &gt; foo &lt/nowiki ></p>
14331 <p>a&lt;nowiki /&gt;b</p>
14332 <p>c&lt;nowiki/ &gt;d</p>
14333 !! wikitext
14334 &lt;nowiki &gt; foo &lt;/nowiki &gt;
14335
14336 a&lt;nowiki /&gt;b
14337
14338 c&lt;nowiki/ &gt;d
14339 !! end
14340
14341 !! test
14342 Parsoid: Escape weird noWikI capitalizations
14343 !! options
14344 parsoid=html2wt
14345 !! html/parsoid
14346 <p>&lt;noWikI &gt; foo &lt/NoWikI ></p>
14347 !! wikitext
14348 &lt;noWikI &gt; foo &lt;/NoWikI &gt;
14349 !! end
14350
14351 ###
14352 ### Message transform tests
14353 ###
14354 !! test
14355 message transform: magic variables
14356 !! options
14357 msg
14358 !! wikitext
14359 {{SITENAME}}
14360 !! html
14361 MediaWiki
14362 !! end
14363
14364 !! test
14365 message transform: should not transform wiki markup
14366 !! options
14367 msg
14368 !! wikitext
14369 ''test''
14370 !! html
14371 ''test''
14372 !! end
14373
14374 !! test
14375 message transform: <noinclude> in transcluded template (T6926)
14376 !! options
14377 msg
14378 !! wikitext
14379 {{Includes}}
14380 !! html
14381 Foobar
14382 !! end
14383
14384 !! test
14385 message transform: <onlyinclude> in transcluded template (T6926)
14386 !! options
14387 msg
14388 !! wikitext
14389 {{Includes2}}
14390 !! html
14391 Foo
14392 !! end
14393
14394 !! test
14395 {{#special:}} page name, known
14396 !! options
14397 msg
14398 !! wikitext
14399 {{#special:Recentchanges}}
14400 !! html
14401 Special:RecentChanges
14402 !! end
14403
14404 !! test
14405 {{#special:}} page name with subpage, known
14406 !! options
14407 msg
14408 !! wikitext
14409 {{#special:Recentchanges/param}}
14410 !! html
14411 Special:RecentChanges/param
14412 !! end
14413
14414 !! test
14415 {{#special:}} page name, unknown
14416 !! options
14417 msg
14418 !! wikitext
14419 {{#special:foobar nonexistent}}
14420 !! html
14421 Special:Foobar nonexistent
14422 !! end
14423
14424 !! test
14425 {{#speciale:}} page name, known
14426 !! options
14427 msg
14428 !! wikitext
14429 {{#speciale:Recentchanges}}
14430 !! html
14431 Special:RecentChanges
14432 !! end
14433
14434 !! test
14435 {{#speciale:}} page name with subpage, known
14436 !! options
14437 msg
14438 !! wikitext
14439 {{#speciale:Recentchanges/param}}
14440 !! html
14441 Special:RecentChanges/param
14442 !! end
14443
14444 !! test
14445 {{#speciale:}} page name, unknown
14446 !! options
14447 msg
14448 !! wikitext
14449 {{#speciale:foobar nonexistent}}
14450 !! html
14451 Special:Foobar_nonexistent
14452 !! end
14453
14454 ###
14455 ### Images
14456 ###
14457 ### For Parsoid-specific tests, see
14458 #### https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
14459
14460 !! test
14461 Simple image
14462 !! options
14463 parsoid=wt2html,wt2wt,html2html
14464 !! wikitext
14465 [[Image:foobar.jpg]]
14466 !! html/php
14467 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14468 </p>
14469 !! html/parsoid
14470 <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>
14471 !! end
14472
14473 !! test
14474 Serialize simple image with span wrapper
14475 !! options
14476 parsoid=html2wt
14477 !! html/parsoid
14478 <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>
14479 !! wikitext
14480 [[File:Foobar.jpg]]
14481 !! end
14482
14483 !! test
14484 Simple image (using File: namespace, now canonical)
14485 !! wikitext
14486 [[File:Foobar.jpg]]
14487 !! html/php
14488 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14489 </p>
14490 !! html/parsoid
14491 <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>
14492 !! end
14493
14494 !! test
14495 Right-aligned image
14496 !! wikitext
14497 [[File:Foobar.jpg|right]]
14498 !! html/php
14499 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
14500
14501 !! html/parsoid
14502 <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>
14503 !! end
14504
14505 !! test
14506 Image with caption
14507 !! wikitext
14508 [[File:Foobar.jpg|right|Caption text]]
14509 !! html/php
14510 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption text"><img alt="Caption text" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
14511
14512 !! html/parsoid
14513 <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>
14514 !! end
14515
14516 !! test
14517 Image with caption, T55312 #1
14518 !! wikitext
14519 [[File:Foobar.jpg|right|Caption page stuff]]
14520 !! html/php
14521 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption page stuff"><img alt="Caption page stuff" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
14522
14523 !! html/parsoid
14524 <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>
14525 !! end
14526
14527 !! test
14528 Image with caption, T55312 #2
14529 !! wikitext
14530 [[File:Foobar.jpg|right|Caption page=]]
14531 !! html/php
14532 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption page="><img alt="Caption page=" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
14533
14534 !! html/parsoid
14535 <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>
14536 !! end
14537
14538 !! test
14539 Image with caption, T55312 #3
14540 !! wikitext
14541 [[File:Foobar.jpg|right|Caption page=stuff]]
14542 !! html/php
14543 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption page=stuff"><img alt="Caption page=stuff" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
14544
14545 !! html/parsoid
14546 <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>
14547 !! end
14548
14549 !! test
14550 Image caption with pipe entity
14551 !! wikitext
14552 [[File:Foobar.jpg|thumb|one &#x7C; two]]
14553 [[File:Foobar.jpg|thumb|one ''two'' &#x7C; three]]
14554 !! html/php
14555 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>one &#x7c; two</div></div></div>
14556 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>one <i>two</i> &#x7c; three</div></div></div>
14557
14558 !! html/parsoid
14559 <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>
14560 <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>
14561 !! end
14562
14563 !! test
14564 Allow empty links in image captions (T62753)
14565 !! options
14566 thumbsize=220
14567 !! wikitext
14568 [[File:Foobar.jpg|thumb|Caption [[Link1]]
14569 [[]]
14570 [[Link2]]
14571 ]]
14572 !! html/php
14573 <div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Caption <a href="/index.php?title=Link1&amp;action=edit&amp;redlink=1" class="new" title="Link1 (page does not exist)">Link1</a> [[]] <a href="/index.php?title=Link2&amp;action=edit&amp;redlink=1" class="new" title="Link2 (page does not exist)">Link2</a></div></div></div>
14574
14575 !! html/parsoid
14576 <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>
14577 [[]]
14578 <a rel="mw:WikiLink" href="./Link2" title="Link2" data-parsoid='{"stx":"simple","a":{"href":"./Link2"},"sa":{"href":"Link2"}}'>Link2</a>
14579 </figcaption></figure>
14580 !! end
14581
14582 !! test
14583 Titles in unlinked images (T23454)
14584 !! wikitext
14585 [[File:Foobar.jpg|link=|stuff]]
14586 !! html/php
14587 <p><img alt="stuff" src="http://example.com/images/3/3a/Foobar.jpg" title="stuff" width="1941" height="220" />
14588 </p>
14589 !! html/parsoid
14590 <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>
14591 !! end
14592
14593 !! test
14594 Link with empty target
14595 !! wikitext
14596 [[]]
14597 !! html
14598 <p>[[]]
14599 </p>
14600 !! end
14601
14602 !! test
14603 Image with link trail
14604 !! wikitext
14605 Linktrails should not work for images: [[File:Foobar.jpg]]s
14606 !! html/php
14607 <p>Linktrails should not work for images: <a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>s
14608 </p>
14609 !! html/parsoid
14610 <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>
14611 !! end
14612
14613 !! test
14614 Image with empty attribute
14615 !! options
14616 parsoid=wt2html,wt2wt,html2html
14617 !! wikitext
14618 [[File:Foobar.jpg|right||Caption text]]
14619 !! html/php
14620 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption text"><img alt="Caption text" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
14621
14622 !! html/parsoid
14623 <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>
14624 !! end
14625
14626 !! test
14627 1. Block image with individual attributes from templates
14628 !! wikitext
14629 [[File:Foobar.jpg|thumb|{{echo|137px}}|This is a caption]]
14630 !! html/php
14631 <div class="thumb tright"><div class="thumbinner" style="width:139px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/137px-Foobar.jpg" width="137" height="16" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/206px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/274px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This is a caption</div></div></div>
14632
14633 !! html/parsoid
14634 <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>
14635 !! end
14636
14637 !! test
14638 2. Block Image with individual attributes from templates
14639 !! wikitext
14640 [[File:Foobar.jpg|{{echo|thumb}}|{{echo|137px}}|This is a caption]]
14641 !! html/php
14642 <div class="thumb tright"><div class="thumbinner" style="width:139px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/137px-Foobar.jpg" width="137" height="16" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/206px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/274px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This is a caption</div></div></div>
14643
14644 !! html/parsoid
14645 <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>
14646 !! end
14647
14648 !! test
14649 3. Inline image with individual attributes from templates
14650 !! wikitext
14651 [[File:Foobar.jpg|{{echo|50px}}]]
14652 !! html/php
14653 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" width="50" height="6" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/75px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/100px-Foobar.jpg 2x" /></a>
14654 </p>
14655 !! html/parsoid
14656 <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>
14657 !! end
14658
14659 ## Parsoid does not provide editing support for images where templates produce multiple image attributes.
14660 ## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
14661 !! test
14662 Image with multiple attributes from the same template
14663 !! wikitext
14664 [[File:Foobar.jpg|{{image_attribs}}]]
14665 !! html/php
14666 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption text"><img alt="Caption text" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
14667
14668 !! html/parsoid
14669 <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>
14670 !! end
14671
14672 !! test
14673 Image with link tails
14674 !! options
14675 thumbsize=220
14676 !! wikitext
14677 123[[File:Foobar.jpg]]456
14678 123[[File:Foobar.jpg|right]]456
14679 123[[File:Foobar.jpg|thumb]]456
14680 !! html/php
14681 <p>123<a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>456
14682 </p>
14683 123<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>456
14684 123<div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div></div></div></div>456
14685
14686 !! html/php+tidy
14687 <p>123<a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>456
14688 </p><p>
14689 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" width="1941" height="220" /></a></div><p>456
14690 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" 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
14691 </p>
14692 !! html/parsoid
14693 <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>
14694 <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
14695 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>
14696 !! end
14697
14698 !! test
14699 Image with multiple captions -- only last one is accepted
14700 !! wikitext
14701 [[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]]
14702 !! html/php
14703 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption3 - accepted"><img alt="Caption3 - accepted" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
14704
14705 !! html/parsoid
14706 <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>
14707 !! end
14708
14709 !! test
14710 Image with multiple widths -- use last
14711 !! wikitext
14712 [[File:Foobar.jpg|200px|300px|caption]]
14713 !! html/php
14714 <p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" width="300" height="34" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/450px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/600px-Foobar.jpg 2x" /></a>
14715 </p>
14716 !! html/parsoid
14717 <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>
14718 !! end
14719
14720 !! test
14721 Image with multiple alignments -- use first (T50664)
14722 !! options
14723 thumbsize=220
14724 !! wikitext
14725 [[File:Foobar.jpg|thumb|left|right|center|caption]]
14726
14727 [[File:Foobar.jpg|middle|text-top|caption]]
14728 !! html/php
14729 <div class="thumb tleft"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
14730 <p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" style="vertical-align: middle" /></a>
14731 </p>
14732 !! html/parsoid
14733 <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>
14734 <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>
14735 !! end
14736
14737 !! test
14738 Image with width attribute at different positions
14739 !! wikitext
14740 [[File:Foobar.jpg|200px|right|Caption]]
14741 [[File:Foobar.jpg|right|200px|Caption]]
14742 [[File:Foobar.jpg|right|Caption|200px]]
14743 !! html/php
14744 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption"><img alt="Caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a></div>
14745 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption"><img alt="Caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a></div>
14746 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption"><img alt="Caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a></div>
14747
14748 !! html/parsoid
14749 <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>
14750 <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>
14751 <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>
14752 !! end
14753
14754 # a sad bit of backward-compatibility
14755 !! test
14756 Image with size specified with pxpx (T15500, T53628)
14757 !! options
14758 parsoid=wt2html,wt2wt,html2html
14759 !! wikitext
14760 [[File:Foobar.jpg|20pxpx]]
14761 [[File:Foobar.jpg|200x20pxpx]]
14762 !! html/php
14763 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg" width="20" height="2" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/30px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/40px-Foobar.jpg 2x" /></a>
14764 <a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/177px-Foobar.jpg" width="177" height="20" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/265px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/353px-Foobar.jpg 2x" /></a>
14765 </p>
14766 !! html/parsoid
14767 <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>
14768 !! end
14769
14770 !! test
14771 Image with link parameter, wiki target
14772 !! wikitext
14773 [[File:Foobar.jpg|link=Main Page]]
14774 !! html/php
14775 <p><a href="/wiki/Main_Page" title="Main Page"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14776 </p>
14777 !! html/parsoid
14778 <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>
14779 !! end
14780
14781 # parsoid T51293 (part 1)
14782 !! test
14783 Image with link parameter, URL target
14784 !! wikitext
14785 [[File:Foobar.jpg|link=http://example.com/]]
14786 !! html/php
14787 <p><a href="http://example.com/" rel="nofollow"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14788 </p>
14789 !! html/parsoid
14790 <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>
14791 !! end
14792
14793 # parsoid T51293 (part 2)
14794 !! test
14795 Image with link parameter, protocol-less URL target
14796 !! wikitext
14797 [[File:Foobar.jpg|link=//example.com/]]
14798 !! html/php
14799 <p><a href="//example.com/" rel="nofollow"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14800 </p>
14801 !! html/parsoid
14802 <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>
14803 !! end
14804
14805 !! test
14806 Escaping non-block captions (T107435)
14807 !! options
14808 parsoid={
14809 "modes": ["wt2wt"],
14810 "changes": [
14811 ["[typeof~='mw:Image']", "attr", "data-mw", "{\"caption\": \"|\"}"]
14812 ]
14813 }
14814 !! wikitext
14815 [[Image:Foobar.jpg|caption]]
14816 !! wikitext/edited
14817 [[Image:Foobar.jpg|<nowiki>|</nowiki>]]
14818 !! end
14819
14820 # wgExternalLinkTarget not supported by Parsoid
14821 !! test
14822 Image with link parameter, wgExternalLinkTarget
14823 !! wikitext
14824 [[Image:foobar.jpg|link=http://example.com/]]
14825 !! config
14826 wgExternalLinkTarget='foobar'
14827 !! html/php
14828 <p><a href="http://example.com/" target="foobar" rel="nofollow noreferrer noopener"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14829 </p>
14830 !! end
14831
14832 !! test
14833 Image with link parameter, wgNoFollowLinks set to false
14834 !! wikitext
14835 [[Image:foobar.jpg|link=http://example.com/]]
14836 !! config
14837 wgNoFollowLinks=false
14838 !! html/php
14839 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14840 </p>
14841 !! end
14842
14843 !! test
14844 Image with link parameter, wgNoFollowDomainExceptions
14845 !! wikitext
14846 [[Image:foobar.jpg|link=http://example.com/]]
14847 !! config
14848 wgNoFollowDomainExceptions='example.com'
14849 !! html/php
14850 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14851 </p>
14852 !! end
14853
14854 # wgExternalLinkTarget not supported by Parsoid
14855 !! test
14856 Image with link parameter, wgExternalLinkTarget, unnamed parameter
14857 !! wikitext
14858 [[Image:foobar.jpg|link=http://example.com/|Title]]
14859 !! config
14860 wgExternalLinkTarget='foobar'
14861 !! html/php
14862 <p><a href="http://example.com/" title="Title" target="foobar" rel="nofollow noreferrer noopener"><img alt="Title" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14863 </p>
14864 !! end
14865
14866 !! test
14867 Image with empty link parameter
14868 !! wikitext
14869 [[File:Foobar.jpg|link=]]
14870 !! html/php
14871 <p><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" />
14872 </p>
14873 !! html/parsoid
14874 <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>
14875 !! end
14876
14877 !! test
14878 Image with link parameter (wiki target) and unnamed parameter
14879 !! wikitext
14880 [[File:Foobar.jpg|link=Main_Page|Title]]
14881 !! html/php
14882 <p><a href="/wiki/Main_Page" title="Title"><img alt="Title" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14883 </p>
14884 !! html/parsoid
14885 <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>
14886 !! end
14887
14888 !! test
14889 Image with link parameter (URL target) and unnamed parameter
14890 !! wikitext
14891 [[File:Foobar.jpg|link=http://example.com/|Title]]
14892 !! html/php
14893 <p><a href="http://example.com/" title="Title" rel="nofollow"><img alt="Title" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14894 </p>
14895 !! html/parsoid
14896 <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>
14897 !! end
14898
14899 !! test
14900 Thumbnail image with link parameter
14901 !! options
14902 thumbsize=220
14903 parsoid=wt2html,wt2wt,html2html
14904 !! wikitext
14905 [[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
14906 !! html/php
14907 <div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="http://example.com/"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Title</div></div></div>
14908
14909 !! html/parsoid
14910 <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>
14911 !! end
14912
14913 !! test
14914 Manually-specified thumbnail image
14915 !! options
14916 thumbsize=220
14917 !! wikitext
14918 [[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
14919 !! html/php
14920 <div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="/wiki/File:Foobar.jpg"><img alt="" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Title</div></div></div>
14921
14922 !! html/parsoid
14923 <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>
14924 !! end
14925
14926 !! test
14927 Manually-specified thumbnail image with explicit link to wiki page
14928 !! options
14929 thumbsize=220
14930 parsoid=wt2html,wt2wt,html2html
14931 !! wikitext
14932 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
14933 !! html/php
14934 <div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="/wiki/Main_Page" title="Main Page"><img alt="" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Title</div></div></div>
14935
14936 !! html/parsoid
14937 <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>
14938 !! end
14939
14940 !! test
14941 Manually-specified thumbnail image with explicit link to url
14942 !! options
14943 thumbsize=220
14944 parsoid=wt2html,wt2wt,html2html
14945 !! wikitext
14946 [[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
14947 !! html/php
14948 <div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="http://example.com"><img alt="" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Title</div></div></div>
14949
14950 !! html/parsoid
14951 <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>
14952 !! end
14953
14954 !! test
14955 Manually-specified thumbnail image with explicit no link
14956 !! options
14957 thumbsize=220
14958 parsoid=wt2html,wt2wt,html2html
14959 !! wikitext
14960 [[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
14961 !! html/php
14962 <div class="thumb tright"><div class="thumbinner" style="width:137px;"><img alt="" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Title</div></div></div>
14963
14964 !! html/parsoid
14965 <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>
14966 !! end
14967
14968 !! test
14969 Manually-specified thumbnail image with explicit link and alt text
14970 !! options
14971 thumbsize=220
14972 parsoid=wt2html,wt2wt,html2html
14973 !! wikitext
14974 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
14975 !! html/php
14976 <div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="/wiki/Main_Page" title="Main Page"><img alt="alttext" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Title</div></div></div>
14977
14978 !! html/parsoid
14979 <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>
14980 !! end
14981
14982 !! test
14983 Image with frame and link
14984 !! options
14985 parsoid=wt2html,wt2wt,html2html
14986 !! wikitext
14987 [[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
14988 !! html/php
14989 <div class="thumb tleft"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption">This is a test image <a href="/wiki/Main_Page" title="Main Page">Main Page</a></div></div></div>
14990
14991 !! html/parsoid
14992 <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>
14993 !! end
14994
14995 !! test
14996 Image with frame and link and explicit alt
14997 !! options
14998 parsoid=wt2html,wt2wt,html2html
14999 !! wikitext
15000 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]]
15001 !! html/php
15002 <div class="thumb tleft"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Altitude" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption">This is a test image <a href="/wiki/Main_Page" title="Main Page">Main Page</a></div></div></div>
15003
15004 !! html/parsoid
15005 <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>
15006 !! end
15007
15008 !! test
15009 Image with wiki markup in implicit alt
15010 !! wikitext
15011 [[Image:Foobar.jpg|testing '''bold''' in alt]]
15012
15013 [[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
15014 !! html/php
15015 <p><a href="/wiki/File:Foobar.jpg" class="image" title="testing bold in alt"><img alt="testing bold in alt" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15016 </p><p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="testing bold in alt" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15017 </p>
15018 !! html/parsoid
15019 <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>
15020
15021 <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>
15022 !! end
15023
15024 !! test
15025 Alt image option should handle most kinds of wikitext without barfing
15026 !! wikitext
15027 [[Image:Foobar.jpg|thumb|This is the image caption|alt=This is a [[link]] and a {{echo|''bold template''}}.]]
15028 !! html/php
15029 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="This is a link and a bold template." src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This is the image caption</div></div></div>
15030
15031 !! html/parsoid
15032 <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>
15033 !! end
15034
15035 !! test
15036 Ampersand in alt attribute (T206940)
15037 !! wikitext
15038 [[File:Foobar.jpg|alt=&amp;amp;]]
15039
15040 <!-- consistency with gallery extension -->
15041 <gallery>
15042 File:Foobar.jpg|alt=&amp;amp;
15043 </gallery>
15044 !! html/php+tidy
15045 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="&amp;amp;" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15046 </p>
15047 <ul class="gallery mw-gallery-traditional">
15048 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15049 <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" 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>
15050 <div class="gallerytext">
15051 </div>
15052 </div></li>
15053 </ul>
15054 !! html/parsoid
15055 <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>
15056
15057 <!-- consistency with gallery extension -->
15058 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15059 <li class="gallerybox">
15060 <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>
15061 <div class="gallerytext"></div>
15062 </li>
15063 </ul>
15064 !! end
15065
15066 !! test
15067 Italics markup in alt attribute (T206940)
15068 !! wikitext
15069 [[File:Foobar.jpg|alt=''x''|caption]]
15070
15071 <!-- consistency with gallery extension -->
15072 <gallery>
15073 File:Foobar.jpg|alt=''x''|caption
15074 </gallery>
15075 !! html/php+tidy
15076 <p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="x" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15077 </p>
15078 <ul class="gallery mw-gallery-traditional">
15079 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15080 <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" 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>
15081 <div class="gallerytext">
15082 <p>caption
15083 </p>
15084 </div>
15085 </div></li>
15086 </ul>
15087 !! html/parsoid
15088 <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>
15089
15090 <!-- consistency with gallery extension -->
15091 <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"}}'>
15092 <li class="gallerybox">
15093 <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>
15094 <div class="gallerytext">caption</div>
15095 </li>
15096 </ul>
15097 !! end
15098
15099 !! test
15100 Nowiki markup in alt attribute (T206940)
15101 !! wikitext
15102 [[File:Foobar.jpg|alt=<nowiki>''</nowiki>x<nowiki>''</nowiki>|caption]]
15103
15104 <!-- consistency with gallery extension -->
15105 <gallery>
15106 File:Foobar.jpg|alt=<nowiki>''</nowiki>x<nowiki>''</nowiki>|caption
15107 </gallery>
15108 !! html/php+tidy
15109 <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" width="1941" height="220" /></a>
15110 </p>
15111 <ul class="gallery mw-gallery-traditional">
15112 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15113 <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" 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>
15114 <div class="gallerytext">
15115 <p>caption
15116 </p>
15117 </div>
15118 </div></li>
15119 </ul>
15120 !! html/parsoid
15121 <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>
15122
15123 <!-- consistency with gallery extension -->
15124 <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"}}'>
15125 <li class="gallerybox">
15126 <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>
15127 <div class="gallerytext">caption</div>
15128 </li>
15129 </ul>
15130 !! end
15131
15132 !! test
15133 Nowiki markup in alt attribute (edited html, no data-parsoid) (T206940)
15134 !! wikitext
15135 [[File:Foobar.jpg|alt=<nowiki>''x''</nowiki>|caption]]
15136
15137 <!-- consistency with gallery extension -->
15138 <gallery>
15139 File:Foobar.jpg|alt=<nowiki>''x''</nowiki>|caption
15140 </gallery>
15141 !! html/php+tidy
15142 <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" width="1941" height="220" /></a>
15143 </p>
15144 <ul class="gallery mw-gallery-traditional">
15145 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15146 <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" 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>
15147 <div class="gallerytext">
15148 <p>caption
15149 </p>
15150 </div>
15151 </div></li>
15152 </ul>
15153 !! html/parsoid
15154 <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>
15155
15156 <!-- consistency with gallery extension -->
15157 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15158 <li class="gallerybox">
15159 <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>
15160 <div class="gallerytext">caption</div>
15161 </li>
15162 </ul>
15163 !! end
15164
15165 !! test
15166 Ampersand in link attribute (T206940)
15167 !! wikitext
15168 [[File:Foobar.jpg|link=Foo &amp; bar]]
15169
15170 <!-- consistency with gallery extension -->
15171 <gallery>
15172 File:Foobar.jpg|link=Foo &amp; bar
15173 </gallery>
15174 !! html/php+tidy
15175 <p><a href="/wiki/Foo_%26_bar" title="Foo &amp; bar"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15176 </p>
15177 <ul class="gallery mw-gallery-traditional">
15178 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15179 <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" 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>
15180 <div class="gallerytext">
15181 </div>
15182 </div></li>
15183 </ul>
15184 !! html/parsoid
15185 <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>
15186
15187 <!-- consistency with gallery extension -->
15188 <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"}}'>
15189 <li class="gallerybox">
15190 <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>
15191 <div class="gallerytext"></div>
15192 </li>
15193 </ul>
15194 !! end
15195
15196 !! test
15197 Ampersand in link attribute (edited html, no data-parsoid) (T206940)
15198 !! wikitext
15199 [[File:Foobar.jpg|link=Foo_&_bar]]
15200
15201 <!-- consistency with gallery extension -->
15202 <gallery>
15203 File:Foobar.jpg|link=Foo_&_bar
15204 </gallery>
15205 !! html/php+tidy
15206 <p><a href="/wiki/Foo_%26_bar" title="Foo &amp; bar"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15207 </p>
15208 <ul class="gallery mw-gallery-traditional">
15209 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15210 <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" 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>
15211 <div class="gallerytext">
15212 </div>
15213 </div></li>
15214 </ul>
15215 !! html/parsoid
15216 <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>
15217
15218 <!-- consistency with gallery extension -->
15219 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15220 <li class="gallerybox">
15221 <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>
15222 <div class="gallerytext"></div>
15223 </li>
15224 </ul>
15225 !! end
15226
15227 !! test
15228 Italics markup in link attribute (T206940)
15229 !! wikitext
15230 [[Foo''s bar''s]]
15231
15232 <!-- Note that "italics" are stripped, even though this is a valid page title -->
15233 [[File:Foobar.jpg|link=Foo''s bar''s|caption1]]
15234
15235 [[File:Foobar.jpg|link=''Main Page''|caption2]]
15236
15237 <!-- consistency with gallery extension -->
15238 <gallery>
15239 File:Foobar.jpg|link=Foo''s bar''s|caption1
15240 File:Foobar.jpg|link=''Main Page''|caption2
15241 </gallery>
15242 !! html/php+tidy
15243 <p><a href="/wiki/Foo%27%27s_bar%27%27s" title="Foo&#39;&#39;s bar&#39;&#39;s">Foo''s bar''s</a>
15244 </p><p><a href="/wiki/Foos_bars" title="caption1"><img alt="caption1" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15245 </p><p><a href="/wiki/Main_Page" title="caption2"><img alt="caption2" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15246 </p>
15247 <ul class="gallery mw-gallery-traditional">
15248 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15249 <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" 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>
15250 <div class="gallerytext">
15251 <p>caption1
15252 </p>
15253 </div>
15254 </div></li>
15255 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15256 <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" 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>
15257 <div class="gallerytext">
15258 <p>caption2
15259 </p>
15260 </div>
15261 </div></li>
15262 </ul>
15263 !! html/parsoid
15264 <p><a rel="mw:WikiLink" href="./Foo''s_bar''s" title="Foo''s bar''s">Foo''s bar''s</a></p>
15265
15266 <!-- Note that "italics" are stripped, even though this is a valid page title -->
15267 <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>
15268
15269 <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>
15270
15271 <!-- consistency with gallery extension -->
15272 <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"}}'>
15273 <li class="gallerybox">
15274 <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>
15275 <div class="gallerytext">caption1</div>
15276 </li>
15277 <li class="gallerybox">
15278 <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>
15279 <div class="gallerytext">caption2</div>
15280 </li>
15281 </ul>
15282 !! end
15283
15284 !! test
15285 Nowiki markup in link attribute (T206940)
15286 !! wikitext
15287 [[File:Foobar.jpg|link=Foo<nowiki>''</nowiki>s_bar<nowiki>''</nowiki>s|caption]]
15288
15289 <!-- consistency with gallery extension -->
15290 <gallery>
15291 File:Foobar.jpg|link=Foo<nowiki>''</nowiki>s_bar<nowiki>''</nowiki>s|caption
15292 </gallery>
15293 !! html/php+tidy
15294 <p><a href="/wiki/Foo%27%27s_bar%27%27s" title="caption"><img alt="caption" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15295 </p>
15296 <ul class="gallery mw-gallery-traditional">
15297 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15298 <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" 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>
15299 <div class="gallerytext">
15300 <p>caption
15301 </p>
15302 </div>
15303 </div></li>
15304 </ul>
15305 !! html/parsoid
15306 <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>
15307
15308 <!-- consistency with gallery extension -->
15309 <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"}}'>
15310 <li class="gallerybox">
15311 <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>
15312 <div class="gallerytext">caption</div>
15313 </li>
15314 </ul>
15315 !! end
15316
15317 !! test
15318 Nowiki markup in link attribute (edited html, no data-parsoid) (T206940)
15319 !! wikitext
15320 [[File:Foobar.jpg|link=Foo<nowiki>''s_bar''</nowiki>s|caption]]
15321
15322 <!-- consistency with gallery extension -->
15323 <gallery>
15324 File:Foobar.jpg|link=Foo<nowiki>''s_bar''</nowiki>s|caption
15325 </gallery>
15326 !! html/php+tidy
15327 <p><a href="/wiki/Foo%27%27s_bar%27%27s" title="caption"><img alt="caption" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15328 </p>
15329 <ul class="gallery mw-gallery-traditional">
15330 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15331 <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" 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>
15332 <div class="gallerytext">
15333 <p>caption
15334 </p>
15335 </div>
15336 </div></li>
15337 </ul>
15338 !! html/parsoid
15339 <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>
15340
15341 <!-- consistency with gallery extension -->
15342 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15343 <li class="gallerybox">
15344 <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>
15345 <div class="gallerytext">caption</div>
15346 </li>
15347 </ul>
15348 !! end
15349
15350 !! test
15351 Image with table with attributes in caption
15352 !! options
15353 parsoid=wt2html,html2html
15354 !! wikitext
15355 [[File:Foobar.jpg|thumb|
15356 {| class="123" |
15357 |- class="456" |
15358 | ha
15359 |}
15360 ]]
15361 !! html/parsoid
15362 <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>
15363 <table class="123">
15364 <tbody><tr class="456" data-parsoid='{"startTagSrc":"|-"}'>
15365 <td> ha</td></tr>
15366 </tbody></table>
15367 </figcaption></figure>
15368 !! end
15369
15370 !! test
15371 Image with table with rows from templates in caption
15372 !! wikitext
15373 [[File:Foobar.jpg|thumb|
15374 {|
15375 {{echo|{{!}} hi}}
15376 |}
15377 ]]
15378 !! html/parsoid
15379 <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>
15380 <table>
15381 <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>
15382 </tbody></table>
15383 </figcaption></figure>
15384 !! end
15385
15386 !! test
15387 Image with nested tables in caption
15388 !! wikitext
15389 [[File:Foobar.jpg|thumb|Foo<br />
15390 {|
15391 |
15392 {|
15393 |z
15394 |}
15395 |}
15396 ]]
15397 !! html/parsoid
15398 <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}'/>
15399 <table>
15400 <tbody><tr><td>
15401 <table>
15402 <tbody><tr><td>z</td></tr>
15403 </tbody></table></td></tr>
15404 </tbody></table>
15405 </figcaption></figure>
15406 !! end
15407
15408 !! test
15409 Image with heading and horizontal rule in caption
15410 !! wikitext
15411 [[File:Foobar.jpg|thumb|
15412 ===Testing===
15413 123
15414 --------------
15415 ]]
15416 !! html/php
15417 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div><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>
15418
15419 !! html/parsoid
15420 <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>
15421 <h3 id="Testing">Testing</h3>
15422 123
15423 <hr data-parsoid='{"extra_dashes":10}'/>
15424 </figcaption></figure>
15425 !! end
15426
15427 ###################
15428 # Conflicting image format options.
15429 # First option specified should 'win'.
15430 # All three cases in each test should be identical.
15431
15432 !! test
15433 Image with 'frameless' first.
15434 !! options
15435 parsoid=wt2html,wt2wt,html2html
15436 !! wikitext
15437 [[File:Foobar.jpg|frameless|caption]]
15438
15439 [[File:Foobar.jpg|frameless|frame|caption]]
15440
15441 [[File:Foobar.jpg|frameless|thumb|caption]]
15442 !! html/php
15443 <p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>
15444 </p><p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>
15445 </p><p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>
15446 </p>
15447 !! html/parsoid
15448 <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>
15449 <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>
15450 <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>
15451 !! end
15452
15453 !! test
15454 Image with 'frame' first.
15455 !! options
15456 parsoid=wt2html,wt2wt,html2html
15457 !! wikitext
15458 [[File:Foobar.jpg|frame|caption]]
15459 [[File:Foobar.jpg|frame|frameless|caption]]
15460 [[File:Foobar.jpg|frame|thumb|caption]]
15461 !! html/php
15462 <div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption">caption</div></div></div>
15463 <div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption">caption</div></div></div>
15464 <div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption">caption</div></div></div>
15465
15466 !! html/parsoid
15467 <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>
15468 <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>
15469 <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>
15470 !! end
15471
15472 !! test
15473 Image with 'thumb' first.
15474 !! options
15475 parsoid=wt2html,wt2wt,html2html
15476 !! wikitext
15477 [[File:Foobar.jpg|thumb|caption]]
15478 [[File:Foobar.jpg|thumb|frameless|caption]]
15479 [[File:Foobar.jpg|thumb|frame|caption]]
15480 !! html/php
15481 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
15482 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
15483 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
15484
15485 !! html/parsoid
15486 <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>
15487 <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>
15488 <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>
15489 !! end
15490
15491 ###################
15492 # Image sizing.
15493 # See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
15494 # and https://phabricator.wikimedia.org/T64258
15495 # Foobar has actual size of 1941x220
15496 # 1. Thumbs & frameless always reduce, can't be enlarged unless it's
15497 # a scalable format.
15498 # 2. Framed images always ignore size options; always render at default size.
15499 # 3. "Unspecified format" and border are the only types which can be
15500 # enlarged.
15501
15502 !! test
15503 Image: unspecified format and border enlarge
15504 !! options
15505 parsoid=wt2html,wt2wt,html2html
15506 !! wikitext
15507 [[File:Foobar.jpg|2000px]]
15508
15509 [[File:Foobar.jpg|border|2000px]]
15510 !! html/php
15511 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="2000" height="227" /></a>
15512 </p><p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="2000" height="227" class="thumbborder" /></a>
15513 </p>
15514 !! html/parsoid
15515 <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>
15516 <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>
15517 !! end
15518
15519 !! test
15520 Image: "unspecified format" and border reduce
15521 !! options
15522 parsoid=wt2html,wt2wt,html2html
15523 !! wikitext
15524 [[File:Foobar.jpg|1000px]]
15525
15526 [[File:Foobar.jpg|border|1000px]]
15527 !! html/php
15528 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/1000px-Foobar.jpg" width="1000" height="113" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/1500px-Foobar.jpg 1.5x, http://example.com/images/3/3a/Foobar.jpg 2x" /></a>
15529 </p><p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/1000px-Foobar.jpg" width="1000" height="113" class="thumbborder" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/1500px-Foobar.jpg 1.5x, http://example.com/images/3/3a/Foobar.jpg 2x" /></a>
15530 </p>
15531 !! html/parsoid
15532 <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>
15533 <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>
15534 !! end
15535
15536 !! test
15537 Image: thumbs reduce
15538 !! options
15539 parsoid=wt2html,wt2wt,html2html
15540 !! wikitext
15541 [[File:Foobar.jpg|thumb|50px]]
15542 !! html/php
15543 <div class="thumb tright"><div class="thumbinner" style="width:52px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" width="50" height="6" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/75px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/100px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div></div></div></div>
15544
15545 !! html/parsoid
15546 <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>
15547 !! end
15548
15549 !! test
15550 Image: bitmap thumbs can't be enlarged past original size, but vector can.
15551 !! options
15552 parsoid=wt2html,wt2wt,html2html
15553 !! wikitext
15554 [[File:Foobar.jpg|thumb|2000px]]
15555
15556 [[File:Foobar.svg|thumb|2000px]]
15557 !! html/php
15558 <div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div></div></div></div>
15559 <div class="thumb tright"><div class="thumbinner" style="width:2002px;"><a href="/wiki/File:Foobar.svg" class="image"><img alt="Foobar.svg" src="http://example.com/images/thumb/f/ff/Foobar.svg/2000px-Foobar.svg.png" width="2000" height="1500" class="thumbimage" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/3000px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/4000px-Foobar.svg.png 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.svg" class="internal" title="Enlarge"></a></div></div></div></div>
15560
15561 !! html/parsoid
15562 <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>
15563 <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>
15564 !! end
15565
15566 !! test
15567 Image: frameless can reduce in size
15568 !! options
15569 parsoid=wt2html,wt2wt,html2html
15570 !! wikitext
15571 [[File:Foobar.jpg|frameless|50px]]
15572 !! html/php
15573 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" width="50" height="6" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/75px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/100px-Foobar.jpg 2x" /></a>
15574 </p>
15575 !! html/parsoid
15576 <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>
15577 !! end
15578
15579 !! test
15580 Image: bitmap frameless can't be enlarged past original size, but vector can
15581 !! options
15582 parsoid=wt2html,wt2wt,html2html
15583 !! wikitext
15584 [[File:Foobar.jpg|frameless|2000px]]
15585
15586 [[File:Foobar.svg|frameless|2000px]]
15587 !! html/php
15588 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15589 </p><p><a href="/wiki/File:Foobar.svg" class="image"><img alt="Foobar.svg" src="http://example.com/images/thumb/f/ff/Foobar.svg/2000px-Foobar.svg.png" width="2000" height="1500" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/3000px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/4000px-Foobar.svg.png 2x" /></a>
15590 </p>
15591 !! html/parsoid
15592 <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>
15593 <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>
15594 !! end
15595
15596 !! test
15597 Image: framed images are always unscaled.
15598 !! options
15599 parsoid=wt2html,wt2wt,html2html
15600 !! wikitext
15601 [[File:Foobar.jpg|frame]]
15602
15603 [[File:Foobar.jpg|frame|50px]]
15604
15605 [[File:Foobar.jpg|frame|50x50px]]
15606
15607 [[File:Foobar.jpg|frame|2000px]]
15608 !! html/php
15609 <div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption"></div></div></div>
15610 <div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption"></div></div></div>
15611 <div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption"></div></div></div>
15612 <div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption"></div></div></div>
15613
15614 !! html/parsoid
15615 <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>
15616 <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>
15617 <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>
15618 <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>
15619 !! end
15620
15621 ###################
15622
15623 !! test
15624 Link to image page- image page normally doesn't exists, hence edit link
15625 Add test with existing image page
15626 #<p><a href="/wiki/File:Test" title="Image:Test">Image:test</a>
15627 !! wikitext
15628 [[:Image:test]]
15629 !! html
15630 <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>
15631 </p>
15632 !! end
15633
15634 !! test
15635 T20784 Link to non-existent image page with caption should use caption as link text
15636 !! wikitext
15637 [[:Image:test|caption]]
15638 !! html
15639 <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>
15640 </p>
15641 !! end
15642
15643 !! test
15644 Frameless image caption with a free URL
15645 !! wikitext
15646 [[File:Foobar.jpg|http://example.com]]
15647 !! html/php
15648 <p><a href="/wiki/File:Foobar.jpg" class="image" title="http://example.com"><img alt="http://example.com" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15649 </p>
15650 !! html/parsoid
15651 <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>
15652 !! end
15653
15654 !! test
15655 Thumbnail image caption with a free URL
15656 !! options
15657 thumbsize=220
15658 !! wikitext
15659 [[File:Foobar.jpg|thumb|http://example.com]]
15660 !! html/php
15661 <div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div></div></div>
15662
15663 !! html/parsoid
15664 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a></figcaption></figure>
15665 !! end
15666
15667 !! test
15668 Thumbnail image caption with a free URL and explicit alt
15669 !! options
15670 thumbsize=220
15671 parsoid=wt2html,wt2wt,html2html
15672 !! wikitext
15673 [[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]]
15674 !! html/php
15675 <div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Alteration" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div></div></div>
15676
15677 !! html/parsoid
15678 <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>
15679 !! end
15680
15681 !! test
15682 SVG thumbnails with no language set
15683 !! options
15684 !! wikitext
15685 [[File:Foobar.svg|thumb|caption]]
15686 !! html/php
15687 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.svg" class="image"><img alt="" src="http://example.com/images/thumb/f/ff/Foobar.svg/180px-Foobar.svg.png" width="180" height="135" class="thumbimage" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/270px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/360px-Foobar.svg.png 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.svg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
15688
15689 !! html/parsoid
15690 <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>
15691 !! end
15692
15693 !! test
15694 SVG thumbnails with language de
15695 !! options
15696 parsoid=wt2html,wt2wt,html2html
15697 !! wikitext
15698 [[File:Foobar.svg|thumb|caption|lang=de]]
15699 !! html/php
15700 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/index.php?title=File:Foobar.svg&amp;lang=de" class="image"><img alt="" src="http://example.com/images/thumb/f/ff/Foobar.svg/langde-180px-Foobar.svg.png" width="180" height="135" class="thumbimage" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/langde-270px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/langde-360px-Foobar.svg.png 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.svg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
15701
15702 !! html/parsoid
15703 <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>
15704 !! end
15705
15706 !! test
15707 SVG thumbnails with invalid language code
15708 !! options
15709 parsoid=wt2html,wt2wt,html2html
15710 !! wikitext
15711 [[File:Foobar.svg|thumb|caption|lang=invalid:language:code]]
15712 !! html/php
15713 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.svg" class="image"><img alt="" src="http://example.com/images/thumb/f/ff/Foobar.svg/180px-Foobar.svg.png" width="180" height="135" class="thumbimage" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/270px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/360px-Foobar.svg.png 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.svg" class="internal" title="Enlarge"></a></div>lang=invalid:language:code</div></div></div>
15714
15715 !! html/parsoid
15716 <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>
15717 !! end
15718
15719 !! test
15720 SVG thumbnails in page language
15721 !! options
15722 language=ru
15723 wgMediaInTargetLanguage = true
15724 !! wikitext
15725 [[File:Foobar.svg]] [[File:Foobar.svg|lang=en]]
15726 !! html/php
15727 <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" 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" 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>
15728 </p>
15729 !! end
15730
15731 !! test
15732 SVG thumbnails in page language not present in the file
15733 !! options
15734 language=de
15735 wgMediaInTargetLanguage = true
15736 !! wikitext
15737 [[File:Foobar.svg]] [[File:Foobar.svg|lang=ru]]
15738 !! html/php
15739 <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" 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" 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>
15740 </p>
15741 !! end
15742
15743 !! test
15744 T3887: A ISBN with a thumbnail
15745 !! wikitext
15746 [[File:Foobar.jpg|thumb|ISBN 1235467890]]
15747 !! html/php
15748 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div><a href="/wiki/Special:BookSources/1235467890" class="internal mw-magiclink-isbn">ISBN 1235467890</a></div></div></div>
15749
15750 !! html/parsoid
15751 <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>
15752 !! end
15753
15754 !! test
15755 T3887: A RFC with a thumbnail
15756 !! wikitext
15757 [[File:Foobar.jpg|thumb|This is RFC 12354]]
15758 !! html/php
15759 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This is <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc12354">RFC 12354</a></div></div></div>
15760
15761 !! html/parsoid
15762 <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>
15763 !! end
15764
15765 !! test
15766 T3887: A mailto link with a thumbnail
15767 !! wikitext
15768 [[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
15769 !! html/php
15770 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Please <a rel="nofollow" class="external free" href="mailto:nobody@example.com">mailto:nobody@example.com</a></div></div></div>
15771
15772 !! html/parsoid
15773 <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>
15774 !! end
15775
15776 # Pending resolution to T2368
15777 !! test
15778 T2648: Frameless image caption with a link
15779 !! wikitext
15780 [[File:Foobar.jpg|text with a [[link]] in it]]
15781 !! html/php
15782 <p><a href="/wiki/File:Foobar.jpg" class="image" title="text with a link in it"><img alt="text with a link in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15783 </p>
15784 !! html/parsoid
15785 <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>
15786 !! end
15787
15788 !! test
15789 T2648: Frameless image caption with a link (suffix)
15790 !! wikitext
15791 [[File:Foobar.jpg|text with a [[link]]foo in it]]
15792 !! html/php
15793 <p><a href="/wiki/File:Foobar.jpg" class="image" title="text with a linkfoo in it"><img alt="text with a linkfoo in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15794 </p>
15795 !! html/parsoid
15796 <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>
15797 !! end
15798
15799 !! test
15800 T2648: Frameless image caption with an interwiki link
15801 !! wikitext
15802 [[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
15803 !! html/php
15804 <p><a href="/wiki/File:Foobar.jpg" class="image" title="text with a MeatBall:Link in it"><img alt="text with a MeatBall:Link in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15805 </p>
15806 !! html/parsoid
15807 <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>
15808 !! end
15809
15810 !! test
15811 T2648: Frameless image caption with a piped interwiki link
15812 !! wikitext
15813 [[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
15814 !! html/php
15815 <p><a href="/wiki/File:Foobar.jpg" class="image" title="text with a link in it"><img alt="text with a link in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15816 </p>
15817 !! html/parsoid
15818 <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>
15819 !! end
15820
15821 !! test
15822 T107474: Frameless image caption with <nowiki>
15823 !! wikitext
15824 [[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]]
15825 !! html/parsoid
15826 <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>
15827 !! end
15828
15829 !! test
15830 Escape HTML special chars in image alt text
15831 !! wikitext
15832 [[File:Foobar.jpg|& < > "]]
15833 !! html/php
15834 <p><a href="/wiki/File:Foobar.jpg" class="image" title="&amp; &lt; &gt; &quot;"><img alt="&amp; &lt; &gt; &quot;" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15835 </p>
15836 !! html/parsoid
15837 <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>
15838 !! end
15839
15840 !! test
15841 Escape HTML special chars in image alt text with LanguageConverter
15842 !! options
15843 language=zh
15844 !! wikitext
15845 [[File:Foobar.jpg|& < > "]]
15846 !! html/php
15847 <p><a href="/wiki/File:Foobar.jpg" class="image" title="&amp; &lt; &gt; &quot;"><img alt="&amp; &lt; &gt; &quot;" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15848 </p>
15849 !! html/parsoid
15850 <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>
15851 !! end
15852
15853 !! test
15854 Entities in file name and attributes
15855 !! wikitext
15856 [[File:7%25 solution.gif|manualthumb=7%25 solution.gif|link=7%25 solution|[[7%25 solution]]]]
15857 !! html/php
15858 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=7%25_solution.gif" class="new" title="File:7% solution.gif">7% solution</a>
15859 </p>
15860 !! html/parsoid
15861 <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>
15862 !! end
15863
15864 !! test
15865 T2499: Alt text should have &#1234;, not &amp;1234;
15866 !! wikitext
15867 [[File:Foobar.jpg|&#9792;]]
15868 !! html/php
15869 <p><a href="/wiki/File:Foobar.jpg" class="image" title="♀"><img alt="♀" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15870 </p>
15871 !! html/parsoid
15872 <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>
15873 !! end
15874
15875 !! test
15876 Broken image caption with link
15877 !! options
15878 parsoid=wt2html,wt2wt,html2html
15879 !! wikitext
15880 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
15881 !! html/php
15882 <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.
15883 </p>
15884 !! html/parsoid
15885 <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>
15886 !! end
15887
15888 !! test
15889 Image caption containing another image
15890 !! wikitext
15891 [[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
15892 !! html/php
15893 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This is a caption with another <a href="/wiki/File:Thumb.png" class="image" title="image"><img alt="image" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" /></a> inside it!</div></div></div>
15894
15895 !! html/parsoid
15896 <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>
15897 !! end
15898
15899 !! test
15900 Image: caption containing a newline
15901 !! wikitext
15902 [[File:Foobar.jpg|This
15903 *is some text]]
15904 !! html/php
15905 <p><a href="/wiki/File:Foobar.jpg" class="image" title="This *is some text"><img alt="This *is some text" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15906 </p>
15907 !! html/parsoid
15908 <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>
15909 !!end
15910
15911 !!test
15912 Image: caption containing leading space
15913 (The leading space should not trigger nowiki escaping in wt2wt mode)
15914 !! wikitext
15915 [[File:Foobar.jpg|thumb| bar]]
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" 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>
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> bar</figcaption></figure>
15921 !!end
15922
15923 # html/php output not have newlines after table, td, th, etc. because
15924 # Linker::makeThumbLink2() replaces the newlines with spaces since
15925 # the table is inside a caption.
15926 # FIXME: Verify if that circa 2004 fix is still required.
15927 !! test
15928 Image: caption containing a table
15929 !! options
15930 parsoid=wt2html,wt2wt,html2html
15931 !! wikitext
15932 [[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
15933 {|
15934 !Foo!!Bar
15935 |-
15936 |Foo1||Bar1
15937 |}
15938 and some more text.]]
15939 !! html/php
15940 <div class="thumb tright"><div class="thumbinner" style="width:202px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This is an example image thumbnail caption with a table <table> <tr> <th>Foo</th> <th>Bar </th></tr> <tr> <td>Foo1</td> <td>Bar1 </td></tr></table> and some more text.</div></div></div>
15941
15942 !! html/parsoid
15943 <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
15944 <table>
15945 <tbody>
15946 <tr><th>Foo</th><th>Bar</th></tr>
15947 <tr>
15948 <td>Foo1</td>
15949 <td>Bar1</td></tr></tbody></table>and some more text.</figcaption></figure>
15950 !! end
15951
15952 !! test
15953 T5090: External links other than http: in image captions
15954 !! wikitext
15955 [[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
15956 !! html/php
15957 <div class="thumb tright"><div class="thumbinner" style="width:202px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This caption has <a rel="nofollow" class="external text" href="irc://example.net">irc</a> and <a rel="nofollow" class="external text" href="https://example.com">Secure</a> ext links in it.</div></div></div>
15958
15959 !! html/parsoid
15960 <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>
15961 !! end
15962
15963 !! test
15964 Custom class
15965 !! options
15966 parsoid=wt2html,wt2wt,html2html
15967 !! wikitext
15968 [[Image:foobar.jpg|a|class=b]]
15969 !! html/php
15970 <p><a href="/wiki/File:Foobar.jpg" class="image" title="a"><img alt="a" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="b" /></a>
15971 </p>
15972 !! html/parsoid
15973 <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>
15974 !! end
15975
15976 !! test
15977 Localized image handling (1).
15978 !! options
15979 parsoid=wt2html,wt2wt,html2html
15980 language=es
15981 !! wikitext
15982 [[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]]
15983 !! html/php
15984 <div class="floatleft"><a href="/wiki/Foo" title="caption"><img alt="caption" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
15985
15986 !! html/parsoid
15987 <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>
15988 !! end
15989
15990 !! test
15991 Localized image handling (2).
15992 !! options
15993 thumbsize=220
15994 parsoid=wt2html,wt2wt,html2html
15995 language=es
15996 !! wikitext
15997 [[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
15998 !! html/php
15999 <div class="thumb tleft"><div class="thumbinner" style="width:222px;"><a href="/wiki/Foo" title="Foo"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/Archivo:Foobar.jpg" class="internal" title="Aumentar"></a></div>caption</div></div></div>
16000
16001 !! html/parsoid
16002 <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>
16003 !! end
16004
16005 !! test
16006 Localized image handling (3).
16007 !! options
16008 language=fa
16009 parsoid=html2wt
16010 !! html/parsoid
16011 <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>
16012 !! wikitext
16013 [[File:Foobar.jpg|بندانگشتی]]
16014 !! end
16015
16016 !! test
16017 "border", "frameless" and "class" attributes on an image.
16018 !! options
16019 thumbsize=220
16020 parsoid=wt2html,wt2wt,html2html
16021 !! wikitext
16022 [[File:Foobar.jpg|frameless|border|class=extra|caption]]
16023 !! html/php
16024 <p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="extra thumbborder" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a>
16025 </p>
16026 !! html/parsoid
16027 <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>
16028 !! end
16029
16030 # Note that 'right' is the default alignment, despite the misspelled 'righ' below
16031 !! test
16032 Invalid image attributes (T64500)
16033 !! options
16034 thumbsize=220
16035 parsoid=wt2html,wt2wt,html2html
16036 !! wikitext
16037 [[File:Foobar.jpg|thumb|float|left|caption]]
16038
16039 [[File:Foobar.jpg|thumb|righ|caption]]
16040
16041 [[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]]
16042 !! html/php
16043 <div class="thumb tleft"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
16044 <div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
16045 <div class="thumb tleft"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
16046
16047 !! html/parsoid
16048 <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>
16049 <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>
16050 <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>
16051 !! end
16052
16053 !! article
16054 File:Barfoo.jpg
16055 !! text
16056 #REDIRECT [[File:Barfoo.jpg]]
16057 !! endarticle
16058
16059 # FIXME: Parsoid should run this test -- but we'd need to teach the
16060 # mockAPI about the redirected Barfoo.jpg image.
16061 !! test
16062 Redirected image
16063 !! wikitext
16064 [[Image:Barfoo.jpg]]
16065 !! html/php
16066 <p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
16067 </p>
16068 !! end
16069
16070 !! test
16071 Missing image with uploads disabled
16072 !! options
16073 wgEnableUploads=0
16074 !! wikitext
16075 [[File:Foobaz.jpg]]
16076 !! html/php
16077 <p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a>
16078 </p>
16079 !! html/parsoid
16080 <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>
16081 !! end
16082
16083 # Parsoid-specific testing for images
16084 # https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
16085 # Currently imperfect due to a flaw in the Parsoid testrunner
16086 # Work in progress
16087 # THESE TESTS SHOULD BE MOVED UP and merged with the php-specific
16088 # image tests.
16089
16090 !! test
16091 Parsoid-specific image handling - simple image with size and middle alignment
16092 !! wikitext
16093 [[File:Foobar.jpg|middle|50px]]
16094 !! html/parsoid
16095 <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>
16096 !! end
16097
16098 !! test
16099 Parsoid-specific image handling - simple image with size, middle alignment, non-standard namespace alias
16100 !! options
16101 parsoid=wt2wt,wt2html,html2html
16102 !! wikitext
16103 [[Image:Foobar.jpg|middle|50px]]
16104 !! html/parsoid
16105 <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>
16106 !! end
16107
16108 !! test
16109 Parsoid-specific image handling - simple image with size and middle alignment (existing content)
16110 !! wikitext
16111 [[File:Foobar.jpg|50px|middle]]
16112 !! html/parsoid
16113 <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>
16114 !! end
16115
16116 !! test
16117 Parsoid-specific image handling - simple image with size and middle alignment and non-standard namespace name
16118 !! options
16119 parsoid=wt2html,wt2wt,html2html
16120 !! wikitext
16121 [[Image:Foobar.jpg|50px|middle]]
16122 !! html/parsoid
16123 <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>
16124 !! end
16125
16126 !! test
16127 Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
16128 !! wikitext
16129 [[File:Foobar.jpg|500x10px|baseline|caption]]
16130 !! html/parsoid
16131 <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>
16132 !! end
16133
16134 !! test
16135 Parsoid-specific image handling - simple image with border and size spec
16136 !! wikitext
16137 [[File:Foobar.jpg|50px|border|caption]]
16138 !! html/parsoid
16139 <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>
16140 !! end
16141
16142 !! test
16143 Parsoid-specific image handling - thumbnail with halign, valign, and caption
16144 !! options
16145 parsoid=wt2html,html2html
16146 !! wikitext
16147 [[File:Foobar.jpg|left|baseline|thumb|caption content]]
16148 !! html/parsoid
16149 <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>
16150 !! end
16151
16152 !! test
16153 Parsoid-specific image handling - thumbnail with halign, valign, and caption (existing content)
16154 !! options
16155 parsoid=wt2html,html2html
16156 !! wikitext
16157 [[File:Foobar.jpg|thumb|left|baseline|caption content]]
16158 !! html/parsoid
16159 <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>
16160 !! end
16161
16162 !! test
16163 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption
16164 !! options
16165 parsoid=wt2html,html2html
16166 !! wikitext
16167 [[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
16168 !! html/parsoid
16169 <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>
16170 !! end
16171
16172 !! test
16173 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption (existing content)
16174 !! options
16175 parsoid=wt2html,html2html
16176 !! wikitext
16177 [[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
16178 !! html/parsoid
16179 <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>
16180 !! end
16181
16182 !! test
16183 Parsoid-specific image handling - framed image with specific size and caption (size is ignored)
16184 !! options
16185 parsoid=wt2html,wt2wt,html2html
16186 !! wikitext
16187 [[File:Foobar.jpg|frame|500x50px|caption]]
16188 !! html/parsoid
16189 <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>
16190 !! end
16191
16192 !! test
16193 Parsoid-specific image handling - framed image with specific size, halign, valign, and caption (size is ignored)
16194 !! options
16195 parsoid=wt2html,html2html
16196 !! wikitext
16197 [[File:Foobar.jpg|left|baseline|frame|500x50px|caption]]
16198 !! html/parsoid
16199 <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>
16200 !! end
16201
16202 !! test
16203 Parsoid-specific image handling - frameless image with specific size, border, and caption
16204 !! wikitext
16205 [[File:Foobar.jpg|frameless|442x50px|border|caption]]
16206 !! html/parsoid
16207 <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>
16208 !! end
16209
16210 !! test
16211 Parsoid-specific image handling - simple image with a formatted caption
16212 !! wikitext
16213 [[File:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]]
16214 !! html/parsoid
16215 <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>
16216 !! end
16217
16218 !! test
16219 Parsoid-specific image handling - caption with a template in it
16220 !! wikitext
16221 [[File:Foobar.jpg|thumb|200x23px|This caption has a {{echo|transclusion}} in it.]]
16222 !! html/parsoid
16223 <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>
16224 !! end
16225
16226 !! test
16227 Parsoid-specific image handling - caption with unbalanced tags in it
16228 !! options
16229 parsoid=wt2html,wt2wt,html2html
16230 !! wikitext
16231 foo
16232 [[File:Foobar.jpg|thumb|200x200px|This caption has a <center>unbalanced tag in it.]]
16233 bar
16234 !! html/parsoid
16235 <p>foo</p>
16236 <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>
16237 <p>bar</p>
16238 !! end
16239
16240 !! test
16241 Parsoid-specific image handling - empty caption (1)
16242 !! options
16243 parsoid=wt2html,wt2wt
16244 !! wikitext
16245 [[File:Foobar.jpg|thumb|]]
16246 !! html/parsoid
16247 <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>
16248 !! end
16249
16250 # empty captions don't get serialized unless we're in the "round trip" case
16251 !! test
16252 Parsoid-specific image handling - empty caption (2)
16253 !! options
16254 parsoid=html2wt
16255 !! html/parsoid
16256 <figure class="mw-default-size" typeof="mw:Image/Thumb">
16257 <a href="./File:Foobar.jpg">
16258 <img resource="./File:Foobar.jpg"
16259 src="//example.com/images/3/3a/Foobar.jpg"
16260 data-file-width="1941" data-file-height="220" data-file-type="bitmap"
16261 height="25" width="220"/>
16262 </a>
16263 <figcaption></figcaption>
16264 </figure>
16265 !! wikitext
16266 [[File:Foobar.jpg|thumb]]
16267 !! end
16268
16269 !! test
16270 Parsoid-specific image handling - whitespace caption
16271 !! wikitext
16272 [[File:Foobar.jpg|thumb| ]]
16273 !! html/parsoid
16274 <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>
16275 !! end
16276
16277 !! test
16278 Parsoid-specific image handling - lang option
16279 !! wikitext
16280 foo
16281 [[File:Foobar.svg|lang=de|caption]]
16282 bar
16283 !! html/parsoid
16284 <p>foo
16285 <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>
16286 bar</p>
16287 !! end
16288
16289 ## Edge case bugs in Parsoid from T93580
16290 !! test
16291 T93580: 1. Templated <ref> inside block images
16292 !! wikitext
16293 [[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]]
16294
16295 <references />
16296 !! html/parsoid
16297 <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="./Main_Page#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup></figcaption></figure>
16298
16299 <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="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
16300 !! end
16301
16302 !! test
16303 T93580: 2. <ref> inside inline images
16304 !! wikitext
16305 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: <ref>foo</ref>]]
16306
16307 <references />
16308 !! html/parsoid
16309 <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=\"./Main_Page#cite_note-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]&lt;/span>&lt;/a>&lt;/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>
16310
16311 <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="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">foo</span></li></ol>
16312 !! end
16313
16314 !! test
16315 T93580: 3. Templated <ref> inside inline images
16316 !! wikitext
16317 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}]]
16318
16319 <references />
16320 !! html/parsoid
16321 <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=\"./Main_Page#cite_note-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]&lt;/span>&lt;/a>&lt;/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>
16322
16323 <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="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">foo</span></li></ol>
16324 !! end
16325
16326 ###
16327 ### Subpages
16328 ###
16329 !! article
16330 Subpage test/subpage
16331 !! text
16332 foo
16333 !! endarticle
16334
16335 !! test
16336 Subpage link
16337 !! options
16338 subpage title=[[Subpage test]]
16339 !! wikitext
16340 [[/subpage]]
16341 !! html
16342 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
16343 </p>
16344 !! end
16345
16346 !! test
16347 Subpage noslash link
16348 !! options
16349 subpage title=[[Subpage test]]
16350 !! wikitext
16351 [[/subpage/]]
16352 !! html
16353 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
16354 </p>
16355 !! end
16356
16357 !! article
16358 Subpage test/1/2/subpage
16359 !! text
16360 blah
16361 !! endarticle
16362
16363 !! test
16364 Relative subpage noslash link
16365 !! options
16366 parsoid=wt2wt,wt2html,html2html
16367 subpage title=[[Subpage test/1/2/3/4]]
16368 !! wikitext
16369 [[../../subpage/]]
16370
16371 [[../../subpage]]
16372 !! html/php
16373 <p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a>
16374 </p><p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage test/1/2/subpage</a>
16375 </p>
16376 !! html/parsoid
16377 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a></p>
16378 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage_test/1/2/subpage</a></p>
16379 !! end
16380
16381 !! test
16382 Parsoid: dot-slash prefixed wikilinks
16383 !! wikitext
16384 [[./foo]]
16385
16386 [[././bar]]
16387
16388 [[././baz/]]
16389 !! html/php
16390 <p>[[./foo]]
16391 </p><p>[[././bar]]
16392 </p><p>[[././baz/]]
16393 </p>
16394 !! html/parsoid
16395 <p>[[./foo]]
16396 </p><p>[[././bar]]
16397 </p><p>[[././baz/]]
16398 </p>
16399 !! end
16400
16401 !! test
16402 Render invalid page names as plain text (T53090)
16403 !! wikitext
16404 [[./../foo|bar]]
16405 [[foo�|bar]]
16406 [[foo/.|bar]]
16407 [[foo/..|bar]]
16408 [[foo~~~bar]]
16409 [[foo>bar]]
16410 [[foo[bar]]
16411 [[.]]
16412 [[..]]
16413 [[foo././bar]]
16414 [[foo[http://example.com]xyz]]
16415
16416 [[{{echo|./../foo}}|bar]]
16417 [[{{echo|foo/.}}|bar]]
16418 [[{{echo|foo/..}}|bar]]
16419 [[{{echo|foo~~~~bar}}]]
16420 [[{{echo|foo>bar}}]]
16421 [[{{echo|foo././bar}}]]
16422 [[{{echo|foo{bar}}]]
16423 [[{{echo|foo}bar}}]]
16424 [[{{echo|foo[bar}}]]
16425 [[{{echo|foo]bar}}]]
16426 [[{{echo|foo<bar}}]]
16427 !!html/php
16428 <p>[[./../foo|bar]]
16429 [[foo�|bar]]
16430 [[foo/.|bar]]
16431 [[foo/..|bar]]
16432 [[foo~~~bar]]
16433 [[foo&gt;bar]]
16434 [[foo[bar]]
16435 [[.]]
16436 [[..]]
16437 [[foo././bar]]
16438 [[foo<a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>xyz]]
16439 </p><p>[[./../foo|bar]]
16440 [[foo/.|bar]]
16441 [[foo/..|bar]]
16442 [[foo~~~~bar]]
16443 [[foo&gt;bar]]
16444 [[foo././bar]]
16445 [[foo{bar]]
16446 [[foo}bar]]
16447 [[foo[bar]]
16448 [[foo]bar]]
16449 [[foo&lt;bar]]
16450 </p>
16451 !!html/parsoid
16452 <p>[[./../foo|bar]]
16453 [[foo�|bar]]
16454 [[foo/.|bar]]
16455 [[foo/..|bar]]
16456 [[foo~~~bar]]
16457 [[foo>bar]]
16458 [[foo[bar]]
16459 [[.]]
16460 [[..]]
16461 [[foo././bar]]
16462 [[foo<a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>xyz]]</p>
16463
16464 <p>[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"./../foo"}},"i":0}}]}'>./../foo</span>|bar]]
16465 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/."}},"i":0}}]}'>foo/.</span>|bar]]
16466 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/.."}},"i":0}}]}'>foo/..</span>|bar]]
16467 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo~~~~bar"}},"i":0}}]}'>foo~~~~bar</span>]]
16468 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo>bar"}},"i":0}}]}'>foo>bar</span>]]
16469 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo././bar"}},"i":0}}]}'>foo././bar</span>]]
16470 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo{bar"}},"i":0}}]}'>foo{bar</span>]]
16471 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}bar"}},"i":0}}]}'>foo}bar</span>]]
16472 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo[bar"}},"i":0}}]}'>foo[bar</span>]]
16473 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo]bar"}},"i":0}}]}'>foo]bar</span>]]
16474 [[<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>
16475 !!end
16476
16477 !! test
16478 Disabled subpages
16479 !! wikitext
16480 [[/subpage]]
16481 !! html
16482 <p><a href="/index.php?title=/subpage&amp;action=edit&amp;redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a>
16483 </p>
16484 !! end
16485
16486 !! test
16487 T2561: {{/Subpage}}
16488 !! options
16489 subpage title=[[Page]]
16490 !! wikitext
16491 {{/Subpage}}
16492 !! html
16493 <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>
16494 </p>
16495 !! end
16496
16497 ###
16498 ### Categories
16499 ###
16500 !! article
16501 Category:MediaWiki User's Guide
16502 !! text
16503 blah
16504 !! endarticle
16505
16506 !! test
16507 Link to category
16508 !! wikitext
16509 [[:Category:MediaWiki User's Guide]]
16510 !! html
16511 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User&#39;s Guide">Category:MediaWiki User's Guide</a>
16512 </p>
16513 !! end
16514
16515 !! test
16516 Simple category
16517 !! options
16518 cat
16519 !! wikitext
16520 [[Category:MediaWiki User's Guide]]
16521 !! html/php
16522 cat=MediaWiki_User's_Guide sort=
16523 !! html/parsoid
16524 <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"}}'/>
16525 !! end
16526
16527 !! test
16528 PAGESINCATEGORY invalid title fatal (r33546 fix)
16529 !! wikitext
16530 {{PAGESINCATEGORY:<bogus>}}
16531 !! html
16532 <p>0
16533 </p>
16534 !! end
16535
16536 !! test
16537 Category with different sort key
16538 !! options
16539 cat
16540 !! wikitext
16541 [[Category:MediaWiki User's Guide|Foo]]
16542 !! html/php
16543 cat=MediaWiki_User's_Guide sort=Foo
16544 !! html/parsoid
16545 <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"}}'/>
16546 !! end
16547
16548 !! test
16549 Category with identical sort key
16550 !! options
16551 cat
16552 !! wikitext
16553 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
16554 !! html/php
16555 cat=MediaWiki_User's_Guide sort=MediaWiki User's Guide
16556 !! html/parsoid
16557 <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"}}'/>
16558 !! end
16559
16560 !! test
16561 Category with empty sort key
16562 !! options
16563 cat
16564 pst
16565 !! wikitext
16566 [[Category:MediaWiki User's Guide|]]
16567 !! html/php
16568 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
16569 !! end
16570
16571 !! test
16572 Category with empty sort key and parentheses
16573 !! options
16574 cat
16575 pst
16576 !! wikitext
16577 [[Category:Foo (bar)|]]
16578 !! html/php
16579 [[Category:Foo (bar)|Foo]]
16580 !! end
16581
16582 !! test
16583 Category with link tail
16584 !! options
16585 cat
16586 pst
16587 !! wikitext
16588 123[[Category:Foo]]456
16589 !! html/php
16590 123[[Category:Foo]]456
16591 !! end
16592
16593 !! test
16594 Category with template
16595 !! options
16596 cat
16597 pst
16598 !! wikitext
16599 [[Category:{{echo|Foo}}]]
16600 !! html/php
16601 [[Category:{{echo|Foo}}]]
16602 !! end
16603
16604 !! test
16605 Category with template in sort key
16606 !! options
16607 cat
16608 pst
16609 !! wikitext
16610 [[Category:Foo|{{echo|Bar}}]]
16611 !! html/php
16612 [[Category:Foo|{{echo|Bar}}]]
16613 !! end
16614
16615 !! test
16616 Category with template in sort key and title
16617 !! options
16618 cat
16619 pst
16620 !! wikitext
16621 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16622 !! html/php
16623 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16624 !! end
16625
16626 ## We used to, but no longer wt2wt this test since the default serializer
16627 ## will normalize all categories to serialize on their own line.
16628 ## This wikitext usage is going to be fairly uncommon in production and
16629 ## selser will take care of preserving formatting in those scenarios.
16630 !! test
16631 Category / paragraph interactions
16632 !! options
16633 parsoid=wt2html
16634 !! wikitext
16635 Foo [[Category:Baz]] Bar
16636
16637 Foo [[Category:Baz]]
16638 Bar
16639
16640 Foo
16641 [[Category:Baz]]
16642 Bar
16643
16644 Foo
16645 [[Category:Baz]] Bar
16646
16647 Foo
16648 [[Category:Baz]]
16649 [[Category:Baz]]
16650 [[Category:Baz]]
16651 Bar
16652
16653 [[Category:Baz]]
16654 [[Category:Baz]]
16655 [[Category:Baz]]
16656
16657 [[Category:Baz]]
16658 {{echo|[[Category:Baz]]}}
16659 [[Category:Baz]]
16660 !! html/php
16661 <p>Foo Bar
16662 </p><p>Foo
16663 Bar
16664 </p><p>Foo
16665 Bar
16666 </p><p>Foo Bar
16667 </p><p>Foo
16668 Bar
16669 </p>
16670 !! html/parsoid
16671 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16672 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16673 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16674 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16675 <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>
16676 <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}}]}'/>
16677 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
16678 !! end
16679
16680 ## We used to, but no longer wt2wt this test since the default serializer
16681 ## will normalize all categories to serialize on their own line.
16682 ## This wikitext usage is going to be fairly uncommon in production and
16683 ## selser will take care of preserving formatting in those scenarios.
16684 ##
16685 ## The whitespace on the empty line is part of the test. Please do not delete
16686 !! test
16687 1. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16688 !! options
16689 parsoid=wt2html
16690 !! wikitext
16691 This
16692
16693 [[Category:Foo]] and this should be part of same paragraph (not an indent-pre)
16694
16695 {{echo|[[Category:Foo]] and so should this!}}
16696 !! html/php
16697 <p>This and this should be part of same paragraph (not an indent-pre) and so should this!
16698 </p>
16699 !! html/parsoid
16700 <p>This
16701
16702 <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of same paragraph (not an indent-pre)
16703
16704 <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>
16705 !! end
16706
16707 ## Parsoid will not try to wt2wt this while preserving newlines because
16708 ## it suppresses excess newlines within list items -- and we don't want to
16709 ## introduce a special case just for categories, which is, in reality somewhat
16710 ## odd behavior -- categories are unlikely to be used in list items like this
16711 ## in top-level pages and are only likely to show up in template-generated
16712 ## list items where this RT-ing is a non-issue.
16713 ##
16714 ## The whitespace on the empty line is part of the test. Please do not delete
16715 !! test
16716 2. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16717 !! options
16718 parsoid=wt2html
16719 !! wikitext
16720 * This
16721
16722 [[Category:Foo]] and this should be part of the same list item
16723 * So should this
16724
16725 {{echo|[[Category:Foo]] and this should be part of the same list item}}
16726 !! html
16727 <ul><li>This and this should be part of the same list item</li>
16728 <li>So should this and this should be part of the same list item</li></ul>
16729 !! html/parsoid
16730 <ul>
16731 <li>This <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of the same list item</li>
16732 <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>
16733 </ul>
16734 !! end
16735
16736 ## Newlines and categories that follow the last item of a list
16737 ## are treated differently because this (list followed by categories)
16738 ## is an extremely common pattern on wikis.
16739 !! test
16740 3. Categories and newlines: newline suppression for last list item should RT properly
16741 !! wikitext
16742 *a
16743 *b
16744
16745 [[Category:Foo]]
16746
16747 [[Category:Bar]]
16748 [[Category:Baz]]
16749
16750 :c
16751
16752 [[Category:C]]
16753
16754 ;d
16755
16756 [[Category:D]]
16757 !! html/parsoid
16758 <ul><li>a</li>
16759 <li>b</li></ul>
16760
16761 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
16762
16763 <link rel="mw:PageProp/Category" href="./Category:Bar"/>
16764 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
16765
16766 <dl><dd>c</dd></dl>
16767
16768 <link rel="mw:PageProp/Category" href="./Category:C"/>
16769
16770 <dl><dt>d</dt></dl>
16771
16772 <link rel="mw:PageProp/Category" href="./Category:D"/>
16773 !! end
16774
16775 !! test
16776 4. Categories and newlines: newline suppression for last list item should RT properly
16777 !! wikitext
16778 *a
16779 ****b
16780
16781 [[Category:Foo]]
16782 !! html/parsoid
16783 <ul><li>a
16784 <ul><li><ul><li><ul><li>b</li></ul></li></ul></li></ul></li></ul>
16785
16786 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16787 !! end
16788
16789 ## only wt2html for this to make sure the algo only applies to the rightmost path
16790 !! test
16791 5. Categories and newlines: migrateTrailingCategories dom pass should only run on the rightmost path of nested lists
16792 !! options
16793 parsoid=wt2html
16794 !! wikitext
16795 *a
16796 **b
16797 [[Category:Foo]]
16798 *c
16799 **d
16800 [[Category:Foo]]
16801 !! html/parsoid
16802 <ul><li>a
16803 <ul><li>b
16804 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul></li>
16805 <li>c
16806 <ul><li>d</li></ul></li></ul>
16807 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16808 !! end
16809
16810 ## We used to, but no longer wt2wt this test since the default serializer
16811 ## will normalize all categories to serialize on their own line.
16812 ## This wikitext usage is going to be fairly uncommon in production and
16813 ## selser will take care of preserving formatting in those scenarios.
16814 !! test
16815 6. Categories and newlines: migrateTrailingCategories dom pass should not migrate categories not preceded by newlines
16816 !! options
16817 parsoid=wt2html
16818 !! wikitext
16819 *a [[Category:Foo]]
16820 !! html/parsoid
16821 <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>
16822 !! end
16823
16824 # This test also demonstrates because of newline+category tunneling
16825 # through the list hander, template wrapping doesn't expand to the
16826 # containing list when the list item swallows the category.
16827 !! test
16828 7. Categories and newlines: migrateTrailingCategories dom pass should leave template content alone
16829 !! wikitext
16830 *{{echo|a
16831 [[Category:Foo]]}}
16832 !! html/parsoid
16833 <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
16834 </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>
16835 !! end
16836
16837 !! test
16838 8. Categories and newlines: migrateTrailingCategories dom pass should not get tripped by intervening templates
16839 !! wikitext
16840 *a
16841
16842 {{echo|[[Category:Foo]]
16843 [[Category:Bar]]}}
16844 [[Category:Baz]]
16845 !! html/parsoid
16846 <ul><li>a</li></ul>
16847
16848 <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">
16849 </span><link rel="mw:PageProp/Category" href="./Category:Bar" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
16850 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
16851 !! end
16852
16853 !! test
16854 Categories and newlines: migrateTrailingCategories dom pass should not get tripped by comments and whitespace
16855 !! wikitext
16856 *a
16857
16858 [[Category:Bar]]<!--boo1--> <!--boo2-->
16859 [[Category:Baz]]<!--boo3--> <!--boo4-->
16860 !! html/parsoid
16861 <ul><li>a</li></ul>
16862
16863 <link rel="mw:PageProp/Category" href="./Category:Bar"/><!--boo1--> <!--boo2-->
16864 <link rel="mw:PageProp/Category" href="./Category:Baz"/><!--boo3--> <!--boo4-->
16865 !! end
16866
16867 !! test
16868 Categories and newlines: should behave properly with linkprefix (T87753)
16869 !! options
16870 language=ar
16871 !! wikitext
16872 foo bar
16873 foo bar
16874 [[تصنيف:Foo]]
16875 [[تصنيف:Bar]]
16876 !! html/php
16877 <p>foo bar
16878 foo bar
16879 </p>
16880 !! html/parsoid
16881 <p>foo bar
16882 foo bar</p>
16883 <link rel="mw:PageProp/Category" href="./تصنيف:Foo"/>
16884 <link rel="mw:PageProp/Category" href="./تصنيف:Bar"/>
16885 !! end
16886
16887 !! test
16888 No regressions on internal links following category (T174639)
16889 !! options
16890 parsoid=wt2html,html2html
16891 !! wikitext
16892 [[Category:Foo]]<div>a
16893
16894 [[Foo]]</div>
16895 !! html/php
16896 <div>a
16897 <a href="/wiki/Foo" title="Foo">Foo</a></div>
16898
16899 !! html/parsoid
16900 <link rel="mw:PageProp/Category" href="./Category:Foo"/><div>a
16901
16902 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></div>
16903 !! end
16904
16905 # Note that Parsoid differs slightly from PHP due to T175421
16906 !! test
16907 11. Special case where only newlines separate links (T175416)
16908 !! options
16909 parsoid=wt2html,html2html
16910 !! wikitext
16911 [[Category:Foo]]
16912
16913 [[Foo]][[es:Alimento]]
16914
16915 [[Foo]]
16916 !! html/php
16917 <p><br />
16918 <a href="/wiki/Foo" title="Foo">Foo</a>
16919 </p><p><a href="/wiki/Foo" title="Foo">Foo</a>
16920 </p>
16921 !! html/parsoid
16922 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
16923
16924 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p><link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
16925
16926 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p>
16927 !! end
16928
16929 !! test
16930 Category links with multiple namespaces
16931 !! wikitext
16932 [[Category:Project:Foo]]
16933 !! html/parsoid
16934 <link rel="mw:PageProp/Category" href="./Category:Project:Foo" />
16935 !! end
16936
16937 !! test
16938 Parsoid: Serialize link to category page with colon escape
16939 !! options
16940 parsoid
16941 !! wikitext
16942
16943 [[:Category:Foo]]
16944 [[:Category:Foo|Bar]]
16945 !! html
16946 <p>
16947 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Category:Foo</a>
16948 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Bar</a>
16949 </p>
16950 !! end
16951
16952 # We used to, but no longer wt2wt this test since the default serializer
16953 # will normalize all categories to serialize on their own line.
16954 # This wikitext usage is going to be fairly uncommon in production and
16955 # selser will take care of preventing whitespace insertion if this
16956 # occurs in an article.
16957 #
16958 # html2html disabled for the same reason (whitespace insertion between
16959 # x and y).
16960 #
16961 # html2wt disabled because it localizes the "Category" namespace.
16962 !! test
16963 Link prefix/suffixes aren't applied to category links
16964 !! options
16965 parsoid=wt2html
16966 language=is
16967 !! wikitext
16968 x[[Category:Foo]]y
16969 !! html/php
16970 <p>xy
16971 </p>
16972 !! html/parsoid
16973 <p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p>
16974 !! end
16975
16976 !! test
16977 Link prefix/suffixes aren't applied to language links
16978 !! options
16979 parsoid=wt2html
16980 language=is
16981 !! wikitext
16982 x[[es:Foo]]y
16983 !! html/php
16984 <p>xy
16985 </p>
16986 !! html/parsoid
16987 <p>x<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo" data-parsoid=""/>y</p>
16988 !! end
16989
16990 !! test
16991 Parsoid: Serialize link to file page with colon escape
16992 !! options
16993 parsoid
16994 !! wikitext
16995
16996 [[:File:Foo.png]]
16997 [[:File:Foo.png|Bar]]
16998 !! html
16999 <p>
17000 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">File:Foo.png</a>
17001 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">Bar</a>
17002 </p>
17003 !! end
17004
17005 !! test
17006 Parsoid: Serialize a genuine category link without colon escape
17007 !! options
17008 parsoid
17009 !! wikitext
17010 [[Category:Foo]]
17011 [[Category:Foo|Bar]]
17012 !! html
17013 <link rel="mw:PageProp/Category" href="./Category:Foo">
17014 <link rel="mw:PageProp/Category" href="./Category:Foo#Bar">
17015 !! end
17016
17017 !! test
17018 Normalize hrefs properly before testing for invalid link targets (T72894)
17019 !! options
17020 parsoid=html2wt
17021 !! html/parsoid
17022 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/>
17023 !! wikitext
17024 [[Category:Toxine bactérienne]]
17025 !! end
17026
17027 !! test
17028 Parsoid: Defaultsort
17029 !! wikitext
17030 {{DEFAULTSORT:Foo}}
17031 !! html/parsoid
17032 <meta property="mw:PageProp/categorydefaultsort" content="Foo"/>
17033 !! end
17034
17035 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
17036 # But, this is a limitation of our representation and is documented in
17037 # TemplateHandler.js in processSpecialMagicWord
17038 !! test
17039 Parsoid: Defaultsort (template-generated)
17040 !! wikitext
17041 {{{{echo|DEFAULTSORT}}:Foo}}
17042 !! html/parsoid
17043 <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"}]]}'/>
17044 !! end
17045
17046 ###
17047 ### Inter-language links
17048 ###
17049 !! test
17050 Interlanguage links
17051 !! options
17052 ill
17053 !! wikitext
17054 [[es:Alimento]]
17055 [[fr:Nourriture]]
17056 [[zh:食品]]
17057 !! html/php
17058 es:Alimento fr:Nourriture zh:食品
17059 !! html/parsoid
17060 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
17061 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Nourriture"/>
17062 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/食品"/>
17063 !! end
17064
17065 !! test
17066 Duplicate interlanguage links (T26502)
17067 !! options
17068 ill
17069 !! wikitext
17070 [[es:1]]
17071 [[es:2]]
17072 [[fr:1]]
17073 [[fr:2]]
17074 !! html/php
17075 es:1 fr:1
17076 !! html/parsoid
17077 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/1"/>
17078 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/2"/>
17079 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/1"/>
17080 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/2"/>
17081 !! end
17082
17083 ###
17084 ### Sections
17085 ###
17086 !! test
17087 Basic section headings
17088 !! wikitext
17089 ==Headline 1==
17090 Some text
17091
17092 ==Headline 2==
17093 More
17094 ===Smaller headline===
17095 Blah blah
17096 !! html
17097 <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>
17098 <p>Some text
17099 </p>
17100 <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>
17101 <p>More
17102 </p>
17103 <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>
17104 <p>Blah blah
17105 </p>
17106 !! end
17107
17108 !! test
17109 Section headings with TOC
17110 !! wikitext
17111 ==Headline 1==
17112 ===Subheadline 1===
17113 =====Skipping a level=====
17114 ======Skipping a level======
17115
17116 ==Headline 2==
17117 Some text
17118 ===Another headline===
17119 !! html
17120 <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>
17121 <ul>
17122 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
17123 <ul>
17124 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
17125 <ul>
17126 <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>
17127 <ul>
17128 <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>
17129 </ul>
17130 </li>
17131 </ul>
17132 </li>
17133 </ul>
17134 </li>
17135 <li class="toclevel-1 tocsection-5"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
17136 <ul>
17137 <li class="toclevel-2 tocsection-6"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
17138 </ul>
17139 </li>
17140 </ul>
17141 </div>
17142
17143 <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>
17144 <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>
17145 <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>
17146 <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>
17147 <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>
17148 <p>Some text
17149 </p>
17150 <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>
17151
17152 !! end
17153
17154 !! test
17155 TOC anchors don't collide
17156 !! wikitext
17157 __FORCETOC__
17158 ==Headline 2==
17159 ==Headline==
17160 ==Headline 2==
17161 ==Headline==
17162 !! html/php
17163 <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>
17164 <ul>
17165 <li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
17166 <li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
17167 <li class="toclevel-1 tocsection-3"><a href="#Headline_2_2"><span class="tocnumber">3</span> <span class="toctext">Headline 2</span></a></li>
17168 <li class="toclevel-1 tocsection-4"><a href="#Headline_3"><span class="tocnumber">4</span> <span class="toctext">Headline</span></a></li>
17169 </ul>
17170 </div>
17171
17172 <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>
17173 <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>
17174 <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>
17175 <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>
17176
17177 !! end
17178
17179 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
17180 # Parsoid html2wt direction adds <nowiki> for level 7 and up.
17181 !! test
17182 Handling of sections up to level 6 and beyond
17183 !! options
17184 parsoid=wt2html
17185 !! wikitext
17186 =Level 1 Heading=
17187 ==Level 2 Heading==
17188 ===Level 3 Heading===
17189 ====Level 4 Heading====
17190 =====Level 5 Heading=====
17191 ======Level 6 Heading======
17192 =======Level 7 Heading=======
17193 ========Level 8 Heading========
17194 =========Level 9 Heading=========
17195 ==========Level 10 Heading==========
17196 !! html/php
17197 <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>
17198 <ul>
17199 <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
17200 <ul>
17201 <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>
17202 <ul>
17203 <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>
17204 <ul>
17205 <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>
17206 <ul>
17207 <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>
17208 <ul>
17209 <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>
17210 <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>
17211 <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>
17212 <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>
17213 <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>
17214 </ul>
17215 </li>
17216 </ul>
17217 </li>
17218 </ul>
17219 </li>
17220 </ul>
17221 </li>
17222 </ul>
17223 </li>
17224 </ul>
17225 </div>
17226
17227 <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>
17228 <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>
17229 <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>
17230 <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>
17231 <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>
17232 <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>
17233 <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>
17234 <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>
17235 <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>
17236 <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>
17237
17238 !! html/parsoid
17239 <h1 id="Level_1_Heading" data-parsoid='{}'>Level 1 Heading</h1>
17240 <h2 id="Level_2_Heading" data-parsoid='{}'>Level 2 Heading</h2>
17241 <h3 id="Level_3_Heading" data-parsoid='{}'>Level 3 Heading</h3>
17242 <h4 id="Level_4_Heading" data-parsoid='{}'>Level 4 Heading</h4>
17243 <h5 id="Level_5_Heading" data-parsoid='{}'>Level 5 Heading</h5>
17244 <h6 id="Level_6_Heading" data-parsoid='{}'>Level 6 Heading</h6>
17245 <h6 id="=Level_7_Heading=" data-parsoid='{}'><span id=".3DLevel_7_Heading.3D" typeof="mw:FallbackId"></span>=Level 7 Heading=</h6>
17246 <h6 id="==Level_8_Heading==" data-parsoid='{}'><span id=".3D.3DLevel_8_Heading.3D.3D" typeof="mw:FallbackId"></span>==Level 8 Heading==</h6>
17247 <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>
17248 <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>
17249 !! end
17250
17251 !! test
17252 TOC regression (T11764)
17253 !! wikitext
17254 ==title 1==
17255 ===title 1.1===
17256 ====title 1.1.1====
17257 ===title 1.2===
17258 ==title 2==
17259 ===title 2.1===
17260 !! html
17261 <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>
17262 <ul>
17263 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
17264 <ul>
17265 <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>
17266 <ul>
17267 <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>
17268 </ul>
17269 </li>
17270 <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>
17271 </ul>
17272 </li>
17273 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
17274 <ul>
17275 <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>
17276 </ul>
17277 </li>
17278 </ul>
17279 </div>
17280
17281 <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>
17282 <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>
17283 <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>
17284 <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>
17285 <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>
17286 <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>
17287
17288 !! end
17289
17290 !! test
17291 TOC for heading containing <span id="..."></span> (T96153)
17292 !! wikitext
17293 __FORCETOC__
17294 ==<span id="old-anchor"></span>New title==
17295 !! html/php
17296 <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>
17297 <ul>
17298 <li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
17299 </ul>
17300 </div>
17301
17302 <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>
17303
17304 !! end
17305
17306 !! test
17307 TOC with wgMaxTocLevel=3 (T8204)
17308 !! options
17309 wgMaxTocLevel=3
17310 !! wikitext
17311 ==title 1==
17312 ===title 1.1===
17313 ====title 1.1.1====
17314 ===title 1.2===
17315 ==title 2==
17316 ===title 2.1===
17317 !! html
17318 <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>
17319 <ul>
17320 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
17321 <ul>
17322 <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>
17323 <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>
17324 </ul>
17325 </li>
17326 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
17327 <ul>
17328 <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>
17329 </ul>
17330 </li>
17331 </ul>
17332 </div>
17333
17334 <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>
17335 <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>
17336 <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>
17337 <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>
17338 <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>
17339 <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>
17340
17341 !! end
17342
17343 !! test
17344 TOC with wgMaxTocLevel=3 and two level four headings (T8204)
17345 !! options
17346 wgMaxTocLevel=3
17347 !! wikitext
17348 ==Section 1==
17349 ===Section 1.1===
17350 ====Section 1.1.1====
17351 ====Section 1.1.1.1====
17352 ==Section 2==
17353 !! html
17354 <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>
17355 <ul>
17356 <li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
17357 <ul>
17358 <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>
17359 </ul>
17360 </li>
17361 <li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li>
17362 </ul>
17363 </div>
17364
17365 <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>
17366 <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>
17367 <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>
17368 <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>
17369 <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>
17370
17371 !! end
17372
17373
17374 !! test
17375 Resolving duplicate section names
17376 !! wikitext
17377 ==Foo bar==
17378 ==Foo bar==
17379 !! html
17380 <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>
17381 <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>
17382
17383 !! end
17384
17385 !! test
17386 Resolving duplicate section names with differing case (T12721)
17387 !! wikitext
17388 ==Foo bar==
17389 ==Foo Bar==
17390 !! html
17391 <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>
17392 <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>
17393
17394 !! end
17395
17396 !! article
17397 Template:sections
17398 !! text
17399 ===Section 1===
17400 ==Section 2==
17401 !! endarticle
17402
17403 !! test
17404 Template with sections, __NOTOC__
17405 !! wikitext
17406 __NOTOC__
17407 ==Section 0==
17408 {{sections}}
17409 ==Section 4==
17410 !! html
17411 <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>
17412 <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>
17413 <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>
17414 <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>
17415
17416 !! end
17417
17418 !! test
17419 __NOEDITSECTION__ keyword
17420 !! wikitext
17421 __NOEDITSECTION__
17422 ==Section 1==
17423 ==Section 2==
17424 !! html
17425 <h2><span class="mw-headline" id="Section_1">Section 1</span></h2>
17426 <h2><span class="mw-headline" id="Section_2">Section 2</span></h2>
17427
17428 !! end
17429
17430 !! test
17431 Link inside a section heading
17432 !! wikitext
17433 ==Section with a [[Main Page|link]] in it==
17434 !! html
17435 <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>
17436
17437 !! end
17438
17439 !! test
17440 TOC regression (T14077)
17441 !! wikitext
17442 __TOC__
17443 ==title 1==
17444 ===title 1.1===
17445 ==title 2==
17446 !! html
17447 <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>
17448 <ul>
17449 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
17450 <ul>
17451 <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>
17452 </ul>
17453 </li>
17454 <li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li>
17455 </ul>
17456 </div>
17457
17458 <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>
17459 <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>
17460 <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>
17461
17462 !! end
17463
17464 !! test
17465 T3219 URL next to image (good)
17466 !! wikitext
17467 http://example.com [[File:Foobar.jpg]]
17468 !! html/php
17469 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> <a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
17470 </p>
17471 !! html/parsoid
17472 <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>
17473 !!end
17474
17475 # Parsoid doesn't wt2wt this cleanly because it adds <nowiki>s.
17476 !! test
17477 Short headings with trailing space should match behavior of Parser::doHeadings (T21910)
17478 !! options
17479 parsoid=wt2html,html2html
17480 !! wikitext
17481 ===
17482 The line above must have a trailing space!
17483 === <!--
17484 --> <!-- -->
17485 But just in case it doesn't...
17486 !! html/php
17487 <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>
17488 <p>The line above must have a trailing space!
17489 </p>
17490 <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>
17491 <p>But just in case it doesn't...
17492 </p>
17493 !! html/parsoid
17494 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
17495 <p>The line above must have a trailing space!</p>
17496 <h1 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h1> <!--
17497 --> <!-- -->
17498 <p>But just in case it doesn't...</p>
17499 !! end
17500
17501 !! test
17502 Header with special characters (T27462)
17503 !! wikitext
17504 The tooltips shall not show entities to the user (ie. be double escaped)
17505
17506 ==text > text==
17507 section 1
17508
17509 ==text < text==
17510 section 2
17511
17512 ==text & text==
17513 section 3
17514
17515 ==text ' text==
17516 section 4
17517
17518 ==text " text==
17519 section 5
17520 !! html/php
17521 <p>The tooltips shall not show entities to the user (ie. be double escaped)
17522 </p>
17523 <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>
17524 <ul>
17525 <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>
17526 <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>
17527 <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>
17528 <li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li>
17529 <li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li>
17530 </ul>
17531 </div>
17532
17533 <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>
17534 <p>section 1
17535 </p>
17536 <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>
17537 <p>section 2
17538 </p>
17539 <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>
17540 <p>section 3
17541 </p>
17542 <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>
17543 <p>section 4
17544 </p>
17545 <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>
17546 <p>section 5
17547 </p>
17548 !! html/parsoid
17549 <p>The tooltips shall not show entities to the user (ie. be double escaped)</p>
17550
17551 <h2 id="text_>_text"><span id="text_.3E_text" typeof="mw:FallbackId"></span>text > text</h2>
17552 <p>section 1</p>
17553
17554 <h2 id="text_&lt;_text"><span id="text_.3C_text" typeof="mw:FallbackId"></span>text &lt; text</h2>
17555 <p>section 2</p>
17556
17557 <h2 id="text_&amp;_text"><span id="text_.26_text" typeof="mw:FallbackId"></span>text &amp; text</h2>
17558 <p>section 3</p>
17559
17560 <h2 id="text_'_text"><span id="text_.27_text" typeof="mw:FallbackId"></span>text ' text</h2>
17561 <p>section 4</p>
17562
17563 <h2 id='text_"_text'><span id="text_.22_text" typeof="mw:FallbackId"></span>text " text</h2>
17564 <p>section 5</p>
17565 !! end
17566
17567 !! test
17568 Header with space, plus and underscore as entity
17569 !! wikitext
17570 Id should not contain + for spaces
17571
17572 ==Space between Text==
17573 section 1
17574
17575 ==Space-Entity&#32;between&#32;Text==
17576 section 2
17577
17578 ==Plus+between+Text==
17579 section 3
17580
17581 ==Plus-Entity&#43;between&#43;Text==
17582 section 4
17583
17584 ==Underscore_between_Text==
17585 section 5
17586
17587 ==Underscore-Entity&#95;between&#95;Text==
17588 section 6
17589
17590 [[#Space between Text]]
17591 [[#Space-Entity&#32;between&#32;Text]]
17592 [[#Plus+between+Text]]
17593 [[#Plus-Entity&#43;between&#43;Text]]
17594 [[#Underscore_between_Text]]
17595 [[#Underscore-Entity&#95;between&#95;Text]]
17596 !! html/php
17597 <p>Id should not contain + for spaces
17598 </p>
17599 <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>
17600 <ul>
17601 <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>
17602 <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>
17603 <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>
17604 <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>
17605 <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>
17606 <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>
17607 </ul>
17608 </div>
17609
17610 <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>
17611 <p>section 1
17612 </p>
17613 <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>
17614 <p>section 2
17615 </p>
17616 <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>
17617 <p>section 3
17618 </p>
17619 <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>
17620 <p>section 4
17621 </p>
17622 <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>
17623 <p>section 5
17624 </p>
17625 <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>
17626 <p>section 6
17627 </p><p><a href="#Space_between_Text">#Space between Text</a>
17628 <a href="#Space-Entity_between_Text">#Space-Entity&#32;between&#32;Text</a>
17629 <a href="#Plus.2Bbetween.2BText">#Plus+between+Text</a>
17630 <a href="#Plus-Entity.2Bbetween.2BText">#Plus-Entity&#43;between&#43;Text</a>
17631 <a href="#Underscore_between_Text">#Underscore_between_Text</a>
17632 <a href="#Underscore-Entity_between_Text">#Underscore-Entity&#95;between&#95;Text</a>
17633 </p>
17634 !! html/parsoid
17635 <p>Id should not contain + for spaces</p>
17636
17637 <h2 id="Space_between_Text">Space between Text</h2>
17638 <p>section 1</p>
17639
17640 <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>
17641 <p>section 2</p>
17642
17643 <h2 id="Plus+between+Text"><span id="Plus.2Bbetween.2BText" typeof="mw:FallbackId"></span>Plus+between+Text</h2>
17644 <p>section 3</p>
17645
17646 <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>
17647 <p>section 4</p>
17648
17649 <h2 id="Underscore_between_Text">Underscore_between_Text</h2>
17650 <p>section 5</p>
17651
17652 <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>
17653 <p>section 6</p>
17654
17655 <p><a rel="mw:WikiLink" href="./Main_Page#Space_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Space_between_Text"},"sa":{"href":"#Space between Text"}}'>#Space between Text</a>
17656 <a rel="mw:WikiLink" href="./Main_Page#Space-Entity_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Space-Entity_between_Text"},"sa":{"href":"#Space-Entity&amp;#32;between&amp;#32;Text"}}'>#Space-Entity between Text</a>
17657 <a rel="mw:WikiLink" href="./Main_Page#Plus+between+Text" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Plus+between+Text"},"sa":{"href":"#Plus+between+Text"}}'>#Plus+between+Text</a>
17658 <a rel="mw:WikiLink" href="./Main_Page#Plus-Entity+between+Text" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Plus-Entity+between+Text"},"sa":{"href":"#Plus-Entity&amp;#43;between&amp;#43;Text"}}'>#Plus-Entity+between+Text</a>
17659 <a rel="mw:WikiLink" href="./Main_Page#Underscore_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Underscore_between_Text"},"sa":{"href":"#Underscore_between_Text"}}'>#Underscore_between_Text</a>
17660 <a rel="mw:WikiLink" href="./Main_Page#Underscore-Entity_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Underscore-Entity_between_Text"},"sa":{"href":"#Underscore-Entity&amp;#95;between&amp;#95;Text"}}'>#Underscore-Entity_between_Text</a></p>
17661 !! end
17662
17663 # Parsoid html2wt disabled because it adds padding spaces around =
17664 !! test
17665 Headers with excess '=' characters
17666 (Are similar tests necessary beyond the 1st level?)
17667 !! options
17668 parsoid=wt2html,wt2wt,html2html
17669 !! wikitext
17670 =foo==
17671 ==foo=
17672 =''italic'' heading==
17673 ==''italic'' heading=
17674 !! html/php
17675 <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>
17676 <ul>
17677 <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
17678 <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
17679 <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>
17680 <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>
17681 </ul>
17682 </div>
17683
17684 <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>
17685 <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>
17686 <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>
17687 <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>
17688
17689 !! html/parsoid
17690 <h1 id="foo="><span id="foo.3D" typeof="mw:FallbackId"></span>foo=</h1>
17691 <h1 id="=foo"><span id=".3Dfoo" typeof="mw:FallbackId"></span>=foo</h1>
17692 <h1 id="italic_heading="><span id="italic_heading.3D" typeof="mw:FallbackId"></span><i>italic</i> heading=</h1>
17693 <h1 id="=italic_heading"><span id=".3Ditalic_heading" typeof="mw:FallbackId"></span>=<i>italic</i> heading</h1>
17694 !! end
17695
17696 !! test
17697 HTML headers vs TOC (T25393)
17698 (__NOEDITSECTION__ for clearer output, doesn't matter here)
17699 !! wikitext
17700 <h1>Header 1</h1>
17701 ==Header 1.1==
17702 ==Header 1.2==
17703
17704 <h1>Header 2
17705 </h1>
17706 ==Header 2.1==
17707 ==Header 2.2==
17708 __NOEDITSECTION__
17709 !! html/php
17710 <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>
17711 <ul>
17712 <li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
17713 <ul>
17714 <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>
17715 <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>
17716 </ul>
17717 </li>
17718 <li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a>
17719 <ul>
17720 <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>
17721 <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>
17722 </ul>
17723 </li>
17724 </ul>
17725 </div>
17726
17727 <h1><span class="mw-headline" id="Header_1">Header 1</span></h1>
17728 <h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2>
17729 <h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2>
17730 <h1><span class="mw-headline" id="Header_2">Header 2
17731 </span></h1>
17732 <h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2>
17733 <h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2>
17734
17735 !! html/parsoid
17736 <h1 id="Header_1" data-parsoid='{"stx":"html"}'>Header 1</h1>
17737 <h2 id="Header_1.1" data-parsoid='{}'>Header 1.1</h2>
17738 <h2 id="Header_1.2" data-parsoid='{}'>Header 1.2</h2>
17739
17740 <h1 id="Header_2" data-parsoid='{"stx":"html"}'>Header 2
17741 </h1>
17742 <h2 id="Header_2.1" data-parsoid='{}'>Header 2.1</h2>
17743 <h2 id="Header_2.2" data-parsoid='{}'>Header 2.2</h2>
17744 <meta property="mw:PageProp/noeditsection"/>
17745 !! end
17746
17747 !! test
17748 Single-line or multiline-comments can follow headings
17749 !! options
17750 parsoid=wt2html,wt2wt
17751 !! wikitext
17752 ==foo==<!---->
17753 ==bar==<!--c1-->
17754 ==baz==<!--
17755 c2
17756 c3-->
17757 !! html/php
17758 <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>
17759 <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>
17760 <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>
17761
17762 !! html/parsoid
17763 <h2 id="foo">foo</h2><!---->
17764 <h2 id="bar">bar</h2><!--c1-->
17765 <h2 id="baz">baz</h2><!--
17766 c2
17767 c3-->
17768 !! end
17769
17770 !! test
17771 T3219 URL next to image (broken)
17772 !! wikitext
17773 http://example.com[[File:Foobar.jpg]]
17774 !! html/php
17775 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
17776 </p>
17777 !! html/parsoid
17778 <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>
17779 !!end
17780
17781 !! test
17782 T3186 news: in the middle of text
17783 !! wikitext
17784 http://en.wikinews.org/wiki/Wikinews:Workplace
17785 !! html
17786 <p><a rel="nofollow" class="external free" href="http://en.wikinews.org/wiki/Wikinews:Workplace">http://en.wikinews.org/wiki/Wikinews:Workplace</a>
17787 </p>
17788 !!end
17789
17790
17791 !! test
17792 Namespaced link must have a title
17793 !! wikitext
17794 [[Project:]]
17795 !! html
17796 <p>[[Project:]]
17797 </p>
17798 !!end
17799
17800 !! test
17801 Namespaced link must have a title (bad fragment version)
17802 !! wikitext
17803 [[Project:#fragment]]
17804 !! html
17805 <p>[[Project:#fragment]]
17806 </p>
17807 !!end
17808
17809
17810 ###
17811 ### HTML tags and HTML attributes
17812 ###
17813
17814 !! test
17815 div with no attributes
17816 !! wikitext
17817 <div>HTML rocks</div>
17818 !! html
17819 <div>HTML rocks</div>
17820
17821 !! end
17822
17823 !! test
17824 div with double-quoted attribute
17825 !! wikitext
17826 <div id="rock">HTML rocks</div>
17827 !! html
17828 <div id="rock">HTML rocks</div>
17829
17830 !! end
17831
17832 !! test
17833 div with single-quoted attribute
17834 !! wikitext
17835 <div id='rock'>HTML rocks</div>
17836 !! html
17837 <div id="rock">HTML rocks</div>
17838
17839 !! end
17840
17841 !! test
17842 div with unquoted attribute
17843 !! wikitext
17844 <div id=rock>HTML rocks</div>
17845 !! html
17846 <div id="rock">HTML rocks</div>
17847
17848 !! end
17849
17850 !! test
17851 div with illegal double attributes
17852 !! wikitext
17853 <div id="a" id="b">HTML rocks</div>
17854 !! html
17855 <div id="b">HTML rocks</div>
17856
17857 !!end
17858
17859 !! test
17860 div with empty attribute value, space before equals
17861 !! options
17862 parsoid=wt2html,html2html
17863 !! wikitext
17864 <div class =>HTML rocks</div>
17865 !! html/php
17866 <div class="">HTML rocks</div>
17867
17868 !! html/parsoid
17869 <div class="" data-parsoid='{"stx":"html"}'>HTML rocks</div>
17870 !! end
17871
17872 !! test
17873 div with multiple empty attribute values
17874 !! config
17875 wgFragmentMode=[ 'html5', 'legacy' ]
17876 !! options
17877 parsoid=wt2html,html2html
17878 !! wikitext
17879 <div id= title=>HTML rocks</div>
17880 !! html/php
17881 <div id="title=">HTML rocks</div>
17882
17883 !! html/parsoid
17884 <div id="title=" data-parsoid='{"stx":"html"}'>HTML rocks</div>
17885 !! end
17886
17887 # FIXME Parsoid doesn't actually match PHP here.
17888 # Probably we should use the synthetic <foo /> or <indicator>
17889 # extensions for this test, which are enabled when running parser tests.
17890 !! test
17891 Extension tag in attribute value
17892 !! wikitext
17893 <span title="<translate>123</translate>">ok</span>
17894 !! html/php+disabled
17895 <p>&lt;span title="&lt;translate&gt;123&lt;/translate&gt;"&gt;ok&lt;/span&gt;
17896 </p>
17897 !! html/parsoid
17898 <p><span title="123" about="#mwt4" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html","a":{"title":"123"},"sa":{"title":"&lt;translate>123&lt;/translate>"}}' data-mw='{"attribs":[[{"txt":"title"},{"html":"&lt;translate typeof=\"mw:Extension/translate\" about=\"#mwt3\" data-parsoid=&apos;{\"dsr\":[13,39,2,2]}&apos; data-mw=&apos;{\"name\":\"translate\",\"attrs\":{},\"body\":{\"extsrc\":\"123\"}}&apos;>123&lt;/translate>"}]]}'>ok</span></p>
17899 !! end
17900
17901 !! test
17902 table with multiple empty attribute values
17903 !! options
17904 parsoid=wt2html,html2html
17905 !! wikitext
17906 {| title= id=
17907 |hi
17908 |}
17909 !! html/php
17910 <table title="id=">
17911 <tr>
17912 <td>hi
17913 </td></tr></table>
17914
17915 !! html/parsoid
17916 <table title="id=">
17917 <tbody><tr><td>hi</td></tr>
17918 </tbody></table>
17919 !! end
17920
17921 !! test
17922 div with braces in attribute value
17923 !! wikitext
17924 <div title="{}">Foo</div>
17925 !! html/php
17926 <div title="&#123;&#125;">Foo</div>
17927
17928 !! html/parsoid
17929 <div title="{}">Foo</div>
17930 !! end
17931
17932 !! test
17933 div with empty attribute value, no space before equals
17934 !! options
17935 parsoid=wt2html,html2html
17936 !! wikitext
17937 <div class=>HTML rocks</div>
17938 !! html/php
17939 <div class="">HTML rocks</div>
17940
17941 !! html/parsoid
17942 <div class="">HTML rocks</div>
17943 !! end
17944
17945 !! test
17946 HTML multiple attributes correction
17947 !! wikitext
17948 <p class="error" class="awesome">Awesome!</p>
17949 !! html
17950 <p class="awesome">Awesome!</p>
17951
17952 !!end
17953
17954 !! test
17955 Table multiple attributes correction
17956 !! wikitext
17957 {|
17958 !+ class="error" class="awesome"|status
17959 |}
17960 !! html
17961 <table>
17962 <tr>
17963 <th class="awesome">status
17964 </th></tr></table>
17965
17966 !!end
17967
17968 !! test
17969 DIV IN UPPERCASE
17970 !! wikitext
17971 <DIV ID="x">HTML ROCKS</DIV>
17972 !! html
17973 <div id="x">HTML ROCKS</div>
17974
17975 !!end
17976
17977 !! test
17978 Non-ASCII pseudo-tags are rendered as text
17979 !! wikitext
17980 <khyô>
17981 !! html
17982 <p>&lt;khyô&gt;
17983 </p>
17984 !! end
17985
17986 !! test
17987 Pseudo-tag with URL 'name' renders as url link
17988 !! wikitext
17989 <http://example.com/>
17990 !! html
17991 <p>&lt;<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&gt;
17992 </p>
17993 !! end
17994
17995 !! test
17996 text with amp in the middle of nowhere
17997 !! wikitext
17998 Remember AT&T?
17999 !! html
18000 <p>Remember AT&amp;T?
18001 </p>
18002 !! end
18003
18004 !! test
18005 text with character entity: eacute
18006 !! wikitext
18007 I always thought &eacute; was a cute letter.
18008 !! html+tidy
18009 <p>I always thought &#233; was a cute letter.
18010 </p>
18011 !! end
18012
18013 !! test
18014 text with entity-escaped character entity-like string: eacute
18015 !! wikitext
18016 I always thought &amp;eacute; was a cute letter.
18017 !! html
18018 <p>I always thought &amp;eacute; was a cute letter.
18019 </p>
18020 !! end
18021
18022 !! test
18023 text with undefined character entity: xacute
18024 !! wikitext
18025 I always thought &xacute; was a cute letter.
18026 !! html
18027 <p>I always thought &amp;xacute; was a cute letter.
18028 </p>
18029 !! end
18030
18031 !! test
18032 HTML5 tags
18033 !! wikitext
18034 <data value="5">five</data>
18035 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
18036 <mark>This highlighted text</mark>
18037 !! html
18038 <p><data value="5">five</data>
18039 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
18040 <mark>This highlighted text</mark>
18041 </p>
18042 !! end
18043
18044 !! test
18045 HTML tag with leading space is parsed as text
18046 !! wikitext
18047 < div>foo< /div>
18048 !! html
18049 <p>&lt; div&gt;foo&lt; /div&gt;
18050 </p>
18051 !! end
18052
18053 ## Don't expect Parsoid and PHP to match, since PHP isn't exactly following
18054 ## the HTML5 parsing spec.
18055 !! test
18056 Element with broken attribute syntax
18057 !! options
18058 parsoid=wt2html
18059 !! wikitext
18060 <div style=" style="123">hi</div>
18061 <div =>ho</div>
18062 !! html/php
18063 <div style="123">hi</div>
18064 <div>ho</div>
18065
18066 !! html/parsoid
18067 <div style=" style=" data-parsoid='{"stx":"html","a":{"123\"":null},"sa":{"123\"":""}}'>hi</div>
18068 <div data-parsoid='{"stx":"html","a":{"=":null},"sa":{"=":""}}'>ho</div>
18069 !! end
18070
18071 ###
18072 ### Nesting tests (see T43545, T52604, T53081)
18073 ###
18074
18075 # This test case is fixed in Parsoid by domino 1.0.12. (T52604)
18076 # Note that html2wt is considerably more difficult if we use <b> in
18077 # the test case, instead of <small>
18078 !! test
18079 Ensure that HTML adoption agency algorithm is properly implemented.
18080 !! wikitext
18081 <small>X<small>Y</small>Z</small>
18082 !! html
18083 <p><small>X<small>Y</small>Z</small>
18084 </p>
18085 !! end
18086
18087 # This was T43545 in the PHP parser.
18088 !! test
18089 Nesting of <kbd>
18090 !! wikitext
18091 <kbd>X<kbd>Y</kbd>Z</kbd>
18092 !! html+tidy
18093 <p><kbd>X<kbd>Y</kbd>Z</kbd>
18094 </p>
18095 !! end
18096
18097 # The following cases were T53081 in the PHP parser.
18098 # Note that there are some other nestable tags (b, i, etc) which are
18099 # not covered; see T53081 for discussion.
18100
18101 !! test
18102 Nesting of <em>
18103 !! wikitext
18104 <em>X<em>Y</em>Z</em>
18105 !! html+tidy
18106 <p><em>X<em>Y</em>Z</em>
18107 </p>
18108 !! end
18109
18110 !! test
18111 Nesting of <strong>
18112 !! wikitext
18113 <strong>X<strong>Y</strong>Z</strong>
18114 !! html+tidy
18115 <p><strong>X<strong>Y</strong>Z</strong>
18116 </p>
18117 !! end
18118
18119 !! test
18120 Nesting of <q>
18121 !! wikitext
18122 <q>X<q>Y</q>Z</q>
18123 !! html+tidy
18124 <p><q>X<q>Y</q>Z</q>
18125 </p>
18126 !! end
18127
18128 !! test
18129 Nesting of <ruby>
18130 !! wikitext
18131 <ruby>X<ruby>Y</ruby>Z</ruby>
18132 !! html
18133 <p><ruby>X<ruby>Y</ruby>Z</ruby>
18134 </p>
18135 !! end
18136
18137 !! test
18138 Nesting of <bdo>
18139 !! wikitext
18140 <bdo>X<bdo>Y</bdo>Z</bdo>
18141 !! html
18142 <p><bdo>X<bdo>Y</bdo>Z</bdo>
18143 </p>
18144 !! end
18145
18146
18147 ###
18148 ### Media links
18149 ###
18150
18151 !! test
18152 Media link
18153 !! wikitext
18154 [[Media:Foobar.jpg]]
18155 [[Media:Video.ogv]]
18156 [[:Media:Video.ogv]]
18157 !! html/php
18158 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a>
18159 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
18160 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
18161 </p>
18162 !! html/parsoid
18163 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Media:Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a>
18164 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" resource="./Media:Video.ogv" title="Video.ogv">Media:Video.ogv</a>
18165 <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>
18166 !! end
18167
18168 !! test
18169 Media link with text
18170 !! wikitext
18171 [[Media:Foobar.jpg|A neat file to look at]]
18172 !! html/php
18173 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">A neat file to look at</a>
18174 </p>
18175 !! html/parsoid
18176 <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>
18177 !! end
18178
18179 !! test
18180 Localized media link
18181 !! options
18182 language=is
18183 !! wikitext
18184 [[Miðill:Foobar.jpg]]
18185
18186 [[Miðill:Foobar.jpg|Icelandic]]
18187 !! html/php
18188 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Miðill:Foobar.jpg</a>
18189 </p><p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Icelandic</a>
18190 </p>
18191 !! html/parsoid
18192 <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>
18193 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Miðill:Foobar.jpg" title="Foobar.jpg">Icelandic</a></p>
18194 !! end
18195
18196 # FIXME: this is still bad HTML tag nesting
18197 # FIXME: doBlockLevels won't wrap this in a paragraph because it contains a div
18198 # Parsoid & Remex fix the p-wrapping since they operate on the DOM.
18199 !! test
18200 Media link with nasty text
18201 !! options
18202 parsoid=wt2html,html2html
18203 !! wikitext
18204 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
18205 !! html/php
18206 <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>
18207
18208 !! html/php+tidy
18209 <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>
18210 !! html/parsoid
18211 <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>
18212 !! end
18213
18214 !! test
18215 Media link from missing resource (parsoid-only)
18216 !! options
18217 parsoid=html2wt
18218 !! html/parsoid
18219 <a rel="mw:MediaLink" href="http://example.com/images/3/3a/Foobar.jpg">Bat!</a>
18220 !! wikitext
18221 [[Media:Foobar.jpg|Bat!]]
18222 !! end
18223
18224 !! test
18225 Media link from missing resource, localized (parsoid-only)
18226 !! options
18227 parsoid=html2wt
18228 language=is
18229 !! html/parsoid
18230 <a rel="mw:MediaLink" href="http://example.com/images/3/3a/Foobar.jpg">Bat!</a>
18231 !! wikitext
18232 [[Miðill:Foobar.jpg|Bat!]]
18233 !! end
18234
18235 # This is a sanity test to ensure we don't crash or choke when given
18236 # old cached 1.7.0 HTML for media links; we don't require that the
18237 # result be "valid" because wt2wt was completely broken in 1.7.0
18238 !! test
18239 Media link from old 1.7.0 DOM spec (crash test, parsoid-only) T198511
18240 !! options
18241 parsoid=html2wt
18242 !! html/parsoid
18243 <p>This is what Parsoid would emit (and we still handle this HTML fine):</p>
18244 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
18245 <p>But VisualEditor would mangle the rel attribute, and give us back this:</p>
18246 <p><a rel="mw:ExtLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
18247 <p>But at least we don't crash when trying to handle the mangled HTML!</p>
18248 !! wikitext
18249 This is what Parsoid would emit (and we still handle this HTML fine):
18250
18251 [[Media:Foobar.jpg|A neat file to look at]]
18252
18253 But VisualEditor would mangle the rel attribute, and give us back this:
18254
18255 [//example.com/images/3/3a/Foobar.jpg A neat file to look at]
18256
18257 But at least we don't crash when trying to handle the mangled HTML!
18258 !! end
18259
18260 !! test
18261 Media link to nonexistent file (T3702)
18262 !! wikitext
18263 [[Media:No such.jpg]]
18264 [[Media:No_such file.jpg]]
18265 !! html/php
18266 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a>
18267 <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>
18268 </p>
18269 !! html/parsoid
18270 <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>
18271 <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>
18272 !! end
18273
18274 !! test
18275 Image link to nonexistent file (T3850 - good)
18276 !! wikitext
18277 [[File:No_such.jpg]]
18278 !! html/php
18279 <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>
18280 </p>
18281 !! html/parsoid
18282 <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>
18283 !! end
18284
18285 !! test
18286 :Image link to nonexistent file (T3850 - bad)
18287 !! wikitext
18288 [[:Image:No such.jpg]]
18289 !! html/php
18290 <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>
18291 </p>
18292 !! html/parsoid
18293 <p><a rel="mw:WikiLink" href="./File:No_such.jpg" title="File:No such.jpg">Image:No such.jpg</a></p>
18294 !! end
18295
18296 !! test
18297 Character reference normalization in link text (T3938)
18298 !! wikitext
18299 [[Main Page|this&that]]
18300 !! html
18301 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
18302 </p>
18303 !!end
18304
18305 !! article
18306 אַ
18307 !! text
18308 Test for unicode normalization
18309
18310 The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
18311 !! endarticle
18312
18313 !! test
18314 (T21451) Links should refer to the normalized form.
18315 !! wikitext
18316 [[&#xFB2E;]]
18317 [[&#x5d0;&#x5b7;]]
18318 [[&#x5d0;ַ]]
18319 [[א&#x5b7;]]
18320 [[אַ]]
18321 !! html
18322 <p><a href="/wiki/%D7%90%D6%B7" title="אַ">&#xfb2e;</a>
18323 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;&#x5b7;</a>
18324 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;ַ</a>
18325 <a href="/wiki/%D7%90%D6%B7" title="אַ">א&#x5b7;</a>
18326 <a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a>
18327 </p>
18328 !! end
18329
18330 !! test
18331 Empty attribute crash test (T4067)
18332 !! wikitext
18333 <font color="">foo</font>
18334 !! html
18335 <p><font color="">foo</font>
18336 </p>
18337 !! end
18338
18339 !! test
18340 Empty attribute crash test single-quotes (T4067)
18341 !! wikitext
18342 <font color=''>foo</font>
18343 !! html
18344 <p><font color="">foo</font>
18345 </p>
18346 !! end
18347
18348 !! test
18349 Attribute test: equals, then nothing
18350 !! options
18351 parsoid=wt2html,html2html
18352 !! wikitext
18353 <font color=>foo</font>
18354 !! html/php
18355 <p><font color="">foo</font>
18356 </p>
18357 !! html/parsoid
18358 <p><font color="" data-parsoid='{"stx":"html"}'>foo</font></p>
18359 !! end
18360
18361 !! test
18362 Attribute test: unquoted value
18363 !! options
18364 parsoid=wt2html,html2html
18365 !! wikitext
18366 <font color=x>foo</font>
18367 !! html/php
18368 <p><font color="x">foo</font>
18369 </p>
18370 !! html/parsoid
18371 <p><font color="x" data-parsoid='{"stx":"html"}'>foo</font></p>
18372 !! end
18373
18374 !! test
18375 Attribute test: unquoted but illegal value (hash)
18376 !! wikitext
18377 <font color=#x>foo</font>
18378 !! html
18379 <p><font color="#x">foo</font>
18380 </p>
18381 !! end
18382
18383 # Parsoid does not serialize to empty attribute syntax,
18384 # so wt2wt and html2wt cases are skipped
18385 !! test
18386 Attribute test: no value (T54330)
18387 !! options
18388 parsoid=wt2html,html2html
18389 !! wikitext
18390 <font color>foo</font>
18391 !! html/php
18392 <p><font color="">foo</font>
18393 </p>
18394 !! html/parsoid
18395 <p><font color="">foo</font></p>
18396 !! end
18397
18398 !! test
18399 T4095: link with three closing brackets
18400 !! wikitext
18401 [[Main Page]]]
18402 !! html/php
18403 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
18404 </p>
18405 !! html/parsoid
18406 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>]</p>
18407 !! end
18408
18409 !! test
18410 T4095: link with pipe and three closing brackets
18411 !! wikitext
18412 [[Main Page|link]]]
18413 !! html/php
18414 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
18415 </p>
18416 !! html/parsoid
18417 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">link</a>]</p>
18418 !! end
18419
18420 !! test
18421 T4095: link with pipe and three closing brackets, version 2
18422 !! wikitext
18423 [[Main Page|[http://example.com/]]]
18424 !! html/php
18425 <p><a href="/wiki/Main_Page" title="Main Page">[http://example.com/]</a>
18426 </p>
18427 !! html/parsoid
18428 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">[http://example.com/]</a></p>
18429 !! end
18430
18431
18432 ###
18433 ### Safety
18434 ###
18435
18436 !! article
18437 Template:Dangerous attribute
18438 !! text
18439 " onmouseover="alert(document.cookie)
18440 !! endarticle
18441
18442 !! article
18443 Template:Dangerous style attribute
18444 !! text
18445 border-size: expression(alert(document.cookie))
18446 !! endarticle
18447
18448 !! article
18449 Template:Div style
18450 !! text
18451 <div style="float: right; {{{1}}}">Magic div</div>
18452 !! endarticle
18453
18454 !! test
18455 T4304: HTML attribute safety (safe template; regression T4309)
18456 !! wikitext
18457 <div title="{{test}}"></div>
18458 !! html/php
18459 <div title="This is a test template"></div>
18460
18461 !! html/parsoid
18462 <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>
18463 !! end
18464
18465 # Parsoid has enough context to handle this case
18466 !! test
18467 T4304: HTML attribute safety (dangerous template; 2309)
18468 !! wikitext
18469 <div title="{{dangerous attribute}}"></div>
18470 !! html/php
18471 <div title=""></div>
18472
18473 !! html/parsoid
18474 <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>
18475 !! end
18476
18477 !! test
18478 T4304: HTML attribute safety (dangerous style template; 2309)
18479 !! wikitext
18480 <div style="{{dangerous style attribute}}"></div>
18481 !! html/php
18482 <div style="/* insecure input */"></div>
18483
18484 !! html/parsoid
18485 <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>
18486 !! end
18487
18488 !! test
18489 T4304: HTML attribute safety (safe parameter; 2309)
18490 !! wikitext
18491 {{div style|width: 200px}}
18492 !! html/php
18493 <div style="float: right; width: 200px">Magic div</div>
18494
18495 !! html/parsoid
18496 <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>
18497 !! end
18498
18499 !! test
18500 T4304: HTML attribute safety (unsafe parameter; 2309)
18501 !! wikitext
18502 {{div style|width: expression(alert(document.cookie))}}
18503 !! html/php
18504 <div style="/* insecure input */">Magic div</div>
18505
18506 !! html/parsoid
18507 <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>
18508 !! end
18509
18510 ## Parsoid output here differs; needs investigation.
18511 !! test
18512 T4304: HTML attribute safety (unsafe breakout parameter; 2309)
18513 !! wikitext
18514 {{div style|"><script>alert(document.cookie)</script>}}
18515 !! html
18516 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
18517
18518 !! end
18519
18520 ## Parsoid output here differs; needs investigation.
18521 !! test
18522 T4304: HTML attribute safety (unsafe breakout parameter 2; 2309)
18523 !! wikitext
18524 {{div style|" ><script>alert(document.cookie)</script>}}
18525 !! html
18526 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
18527
18528 !! end
18529
18530 !! test
18531 T4304: HTML attribute safety (link)
18532 !! wikitext
18533 <div title="[[Main Page]]"></div>
18534 !! html/php
18535 <div title="&#91;&#91;Main Page&#93;&#93;"></div>
18536
18537 !! html/parsoid
18538 <div title="[[Main Page]]"></div>
18539 !! end
18540
18541 !! test
18542 T4304: HTML attribute safety (italics)
18543 !! wikitext
18544 <div title="''foobar''"></div>
18545 !! html
18546 <div title="&#39;&#39;foobar&#39;&#39;"></div>
18547
18548 !! end
18549
18550 !! test
18551 T4304: HTML attribute safety (bold)
18552 !! wikitext
18553 <div title="'''foobar'''"></div>
18554 !! html
18555 <div title="&#39;&#39;&#39;foobar&#39;&#39;&#39;"></div>
18556
18557 !! end
18558
18559 !! test
18560 T4304: HTML attribute safety (ISBN)
18561 !! wikitext
18562 <div title="ISBN 1234567890"></div>
18563 !! html
18564 <div title="&#73;SBN 1234567890"></div>
18565
18566 !! end
18567
18568 !! test
18569 T4304: HTML attribute safety (RFC)
18570 !! wikitext
18571 <div title="RFC 1234"></div>
18572 !! html
18573 <div title="&#82;FC 1234"></div>
18574
18575 !! end
18576
18577 !! test
18578 T4304: HTML attribute safety (PMID)
18579 !! wikitext
18580 <div title="PMID 1234567890"></div>
18581 !! html
18582 <div title="&#80;MID 1234567890"></div>
18583
18584 !! end
18585
18586 !! test
18587 T4304: HTML attribute safety (web link)
18588 !! wikitext
18589 <div title="http://example.com/"></div>
18590 !! html
18591 <div title="http&#58;//example.com/"></div>
18592
18593 !! end
18594
18595 !! test
18596 T4304: HTML attribute safety (named web link)
18597 !! wikitext
18598 <div title="[http://example.com/ link]"></div>
18599 !! html/php
18600 <div title="&#91;http&#58;//example.com/ link&#93;"></div>
18601
18602 !! html/parsoid
18603 <div title="[http://example.com/ link]"></div>
18604 !! end
18605
18606 !! test
18607 T5244: HTML attribute safety (extension; safe)
18608 !! wikitext
18609 <div style="<nowiki>background:blue</nowiki>"></div>
18610 !! html/php
18611 <div style="background:blue"></div>
18612
18613 !! html/parsoid
18614 <div style="background:blue" data-parsoid='{"stx":"html","a":{"style":"background:blue"},"sa":{"style":"&lt;nowiki>background:blue&lt;/nowiki>"}}'></div>
18615 !! end
18616
18617 !! test
18618 T5244: HTML attribute safety (extension; unsafe)
18619 !! wikitext
18620 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
18621 !! html/php
18622 <div style="/* insecure input */"></div>
18623
18624 !! html/parsoid
18625 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"&lt;nowiki>border-left:expression(alert(document.cookie))&lt;/nowiki>"}}'></div>
18626 !! end
18627
18628 # More MSIE fun discovered by Tom Gilder
18629
18630 !! test
18631 MSIE CSS safety test: spurious slash
18632 !! wikitext
18633 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
18634 !! html/php
18635 <div style="/* insecure input */">evil</div>
18636
18637 !! html/parsoid
18638 <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>
18639 !! end
18640
18641 !! test
18642 MSIE CSS safety test: hex code
18643 !! wikitext
18644 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
18645 !! html/php
18646 <div style="/* insecure input */">evil</div>
18647
18648 !! html/parsoid
18649 <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>
18650 !! end
18651
18652 !! test
18653 MSIE CSS safety test: comment in url
18654 !! wikitext
18655 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
18656 !! html/php
18657 <div style="background-image:u rl(javascript:alert(&#39;boo&#39;))">evil</div>
18658
18659 !! html/parsoid
18660 <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>
18661 !! end
18662
18663 !! test
18664 MSIE CSS safety test: comment in expression
18665 !! wikitext
18666 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
18667 !! html/php
18668 <div style="background-image:expres sion(alert(&#39;boo4&#39;))">evil4</div>
18669
18670 !! html/parsoid
18671 <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>
18672 !! end
18673
18674 !! test
18675 CSS safety test (all browsers): vertical tab (T57332 / CVE-2013-4567)
18676 !! wikitext
18677 <p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p>
18678 !! html/php
18679 <p style="/* invalid control char */">A</p>
18680
18681 !! html/parsoid
18682 <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>
18683 !! end
18684
18685 !! test
18686 MSIE 6 CSS safety test: Fullwidth (T57332)
18687 !! wikitext
18688 <p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p>
18689 <div style="top:EXPRESSION(alert())">B</div>
18690 !! html/php
18691 <p style="/* insecure input */">A</p>
18692 <div style="/* insecure input */">B</div>
18693
18694 !! html/parsoid
18695 <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>
18696 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"top:EXPRESSION(alert())"}}'>B</div>
18697 !! end
18698
18699 !! test
18700 MSIE 6 CSS safety test: IPA extensions (T57332)
18701 !! wikitext
18702 <div style="background-image:uʀʟ(javascript:alert())">A</div>
18703 <p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p>
18704 !! html/php
18705 <div style="/* insecure input */">A</div>
18706 <p style="/* insecure input */">B</p>
18707
18708 !! html/parsoid
18709 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:uʀʟ(javascript:alert())"}}'>A</div>
18710 <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>
18711 !! end
18712
18713 !! test
18714 MSIE 6 CSS safety test: sup/sub script (T57332)
18715 !! wikitext
18716 <div style="background-image:url⁽javascript:alert())">A</div>
18717 <div style="background-image:url₍javascript:alert())">B</div>
18718 <p style="font-size: 100px; color: expressioⁿ((title='XSSed'),'red')">C</p>
18719 !! html/php
18720 <div style="/* insecure input */">A</div>
18721 <div style="/* insecure input */">B</div>
18722 <p style="/* insecure input */">C</p>
18723
18724 !! html/parsoid
18725 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url⁽javascript:alert())"}}'>A</div>
18726 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url₍javascript:alert())"}}'>B</div>
18727 <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>
18728 !! end
18729
18730 !! test
18731 Opera -o-link CSS
18732 !! options
18733 parsoid=wt2html,html2html
18734 !! wikitext
18735 <div
18736 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;"
18737 style="-o-link:attr(title);-o-link-source:current">X</div>
18738 !! html/php
18739 <div title="data:text/html,&lt;img src=1 onerror=alert(1)&gt;" style="/* insecure input */">X</div>
18740
18741 !! html/parsoid
18742 <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>
18743 !! end
18744
18745 !! test
18746 MSIE 6 CSS safety test: Repetition markers (T57332)
18747 !! wikitext
18748 <p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p>
18749 <p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p>
18750 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">C</p>
18751 <p style="font-size: 100px; color: expresヽion((title='XSSed'),'red')">D</p>
18752 <p style="font-size: 100px; color: expresﹽion((title='XSSed'),'red')">E</p>
18753 <p style="font-size: 100px; color: expresﹼion((title='XSSed'),'red')">F</p>
18754 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">G</p>
18755 !! html/php
18756 <p style="/* insecure input */">A</p>
18757 <p style="/* insecure input */">B</p>
18758 <p style="/* insecure input */">C</p>
18759 <p style="/* insecure input */">D</p>
18760 <p style="/* insecure input */">E</p>
18761 <p style="/* insecure input */">F</p>
18762 <p style="/* insecure input */">G</p>
18763
18764 !! html/parsoid
18765 <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>
18766 <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>
18767 <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>
18768 <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>
18769 <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>
18770 <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>
18771 <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>
18772 !! end
18773
18774 !! test
18775 Table attribute legitimate extension
18776 !! wikitext
18777 {|
18778 !+ style="<nowiki>color:blue</nowiki>"|status
18779 |}
18780 !! html
18781 <table>
18782 <tr>
18783 <th style="color:blue">status
18784 </th></tr></table>
18785
18786 !!end
18787
18788 !! test
18789 Table attribute safety
18790 !! wikitext
18791 {|
18792 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"|status
18793 |}
18794 !! html
18795 <table>
18796 <tr>
18797 <th style="/* insecure input */">status
18798 </th></tr></table>
18799
18800 !! end
18801
18802 !! test
18803 CSS line continuation 1
18804 !! wikitext
18805 <div style="background-image: u\&#10;rl(test.jpg);"></div>
18806 !! html
18807 <div style="/* insecure input */"></div>
18808
18809 !! end
18810
18811 !! test
18812 CSS line continuation 2
18813 !! wikitext
18814 <div style="background-image: u\&#13;rl(test.jpg); "></div>
18815 !! html
18816 <div style="/* invalid control char */"></div>
18817
18818 !! end
18819
18820 !! article
18821 Template:Identity
18822 !! text
18823 {{{1}}}
18824 !! endarticle
18825
18826 !! test
18827 Expansion of multi-line templates in attribute values (T8255)
18828 !! wikitext
18829 <div style="background: {{identity|#00FF00}}">-</div>
18830 !! html
18831 <div style="background: #00FF00">-</div>
18832
18833 !! end
18834
18835 !! test
18836 Expansion of multi-line templates in attribute values (T8255 sanity check)
18837 !! wikitext
18838 <div style="background:
18839 #00FF00">-</div>
18840 !! html/php
18841 <div style="background: #00FF00">-</div>
18842
18843 !! html/parsoid
18844 <div style="background:
18845 #00FF00">-</div>
18846 !! end
18847
18848 !! test
18849 Expansion of multi-line templates in attribute values (T8255 sanity check 2)
18850 !! wikitext
18851 <div style="background: &#10;#00FF00">-</div>
18852 !! html
18853 <div style="background: &#10;#00FF00">-</div>
18854
18855 !! end
18856
18857 !! test
18858 Tags which are hidden from tidiers cannot pass through the Sanitizer
18859 !! wikitext
18860 <mw:toc><script>alert();</script></mw:toc>
18861 !! html+tidy
18862 <p>&lt;mw:toc&gt;&lt;script&gt;alert();&lt;/script&gt;&lt;/mw:toc&gt;
18863 </p>
18864 !! end
18865
18866 ###
18867 ### Parser hooks (see tests/parser/parserTestsParserHook.php for the <tag> extension)
18868 ###
18869
18870 !! test
18871 Parser hook: empty input
18872 !! wikitext
18873 <tag></tag>
18874 !! html/php
18875 <pre>
18876 ''
18877 array (
18878 )
18879 </pre>
18880
18881 !! html/parsoid
18882 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18883 !! end
18884
18885 ## Don't expect parsoid to rt this form.
18886 !! test
18887 Parser hook: empty input using terminated empty elements
18888 !! options
18889 parsoid=wt2html,html2html
18890 !! wikitext
18891 <tag/>
18892 !! html/php
18893 <pre>
18894 NULL
18895 array (
18896 )
18897 </pre>
18898
18899 !! html/parsoid
18900 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{}}' data-parsoid='{}' about="#mwt2"></pre>
18901 !! end
18902
18903 !! test
18904 Parser hook: empty input using terminated empty elements (space before)
18905 !! wikitext
18906 <tag />
18907 !! html/php
18908 <pre>
18909 NULL
18910 array (
18911 )
18912 </pre>
18913
18914 !! html/parsoid
18915 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{}}' data-parsoid='{}' about="#mwt2"></pre>
18916 !! end
18917
18918 !! test
18919 Parser hook: basic input
18920 !! wikitext
18921 <tag>input</tag>
18922 !! html/php
18923 <pre>
18924 'input'
18925 array (
18926 )
18927 </pre>
18928
18929 !! html/parsoid
18930 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18931 !! end
18932
18933 ## Don't expect parsoid to rt this form.
18934 !! test
18935 Parser hook: case insensitive
18936 !! options
18937 parsoid=wt2html,html2html
18938 !! wikitext
18939 <TAG>input</TAG>
18940 !! html/php
18941 <pre>
18942 'input'
18943 array (
18944 )
18945 </pre>
18946
18947 !! html/parsoid
18948 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18949 !! end
18950
18951 ## Don't expect parsoid to rt this form.
18952 !! test
18953 Parser hook: case insensitive, redux
18954 !! options
18955 parsoid=wt2html,html2html
18956 !! wikitext
18957 <TaG>input</TAg>
18958 !! html/php
18959 <pre>
18960 'input'
18961 array (
18962 )
18963 </pre>
18964
18965 !! html/parsoid
18966 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18967 !! end
18968
18969 !! test
18970 Parser hook: nested tags
18971 !! options
18972 parsoid=wt2html
18973 !! wikitext
18974 <tag><tag></tag></tag>
18975 !! html/php
18976 <pre>
18977 '<tag>'
18978 array (
18979 )
18980 </pre>&lt;/tag&gt;
18981
18982 !! html/php+tidy
18983 <pre>'<tag>'
18984 array (
18985 )
18986 </tag></pre><p>&lt;/tag&gt;
18987 </p>
18988 !! html/parsoid
18989 <pre typeof="mw:Extension/tag" about="#mwt2" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"&lt;tag>"}}'></pre><p>&lt;/tag></p>
18990 !! end
18991
18992 !! test
18993 Parser hook: basic arguments
18994 !! wikitext
18995 <tag width="200" height="100" depth="50" square=""></tag>
18996 !! html/php
18997 <pre>
18998 ''
18999 array (
19000 'width' => '200',
19001 'height' => '100',
19002 'depth' => '50',
19003 'square' => '',
19004 )
19005 </pre>
19006
19007 !! html/parsoid
19008 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19009 !! end
19010
19011 ## Don't expect parsoid to rt this form.
19012 !! test
19013 Parser hook: basic arguments, variations
19014 !! options
19015 parsoid=wt2html,html2html
19016 !! wikitext
19017 <tag width=200 height = "100" depth = '50' square></tag>
19018 !! html/php
19019 <pre>
19020 ''
19021 array (
19022 'width' => '200',
19023 'height' => '100',
19024 'depth' => '50',
19025 'square' => '',
19026 )
19027 </pre>
19028
19029 !! html/parsoid
19030 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19031 !! end
19032
19033 !! test
19034 Parser hook: argument containing a forward slash (T7344)
19035 !! wikitext
19036 <tag filename="/tmp/bla"></tag>
19037 !! html/php
19038 <pre>
19039 ''
19040 array (
19041 'filename' => '/tmp/bla',
19042 )
19043 </pre>
19044
19045 !! html/parsoid
19046 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"filename":"/tmp/bla"},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19047 !! end
19048
19049 ## Don't expect parsoid to rt this form.
19050 !! test
19051 Parser hook: empty input using terminated empty elements (T4374)
19052 !! options
19053 parsoid=wt2html,html2html
19054 !! wikitext
19055 <tag foo=bar/>text
19056 !! html/php
19057 <pre>
19058 NULL
19059 array (
19060 'foo' => 'bar',
19061 )
19062 </pre>text
19063
19064 !! html/parsoid
19065 <pre typeof="mw:Extension/tag" about="#mwt2" data-mw='{"name":"tag","attrs":{"foo":"bar"}}'></pre><p>text</p>
19066 !! end
19067
19068 ## </tag> should be output literally since there is no matching tag that begins it
19069 ## Don't expect parsoid to rt this form.
19070 !! test
19071 Parser hook: basic arguments using terminated empty elements (T4374)
19072 !! options
19073 parsoid=wt2html
19074 !! wikitext
19075 <tag width=200 height = "100" depth = '50' square/>
19076 other stuff
19077 </tag>
19078 !! html/php
19079 <pre>
19080 NULL
19081 array (
19082 'width' => '200',
19083 'height' => '100',
19084 'depth' => '50',
19085 'square' => '',
19086 )
19087 </pre>
19088 <p>other stuff
19089 &lt;/tag&gt;
19090 </p>
19091 !! html/parsoid
19092 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""}}' about="#mwt2"></pre><p>other stuff
19093 &lt;/tag></p>
19094 !! end
19095
19096 ## Don't expect parsoid to rt this form.
19097 !! test
19098 Parser hook: Don't allow unclosed extension tags
19099 !! options
19100 parsoid=wt2html
19101 !! wikitext
19102 test <tag>123
19103
19104 this is a '''test'''
19105 !! html/php
19106 <p>test &lt;tag&gt;123
19107 </p><p>this is a <b>test</b>
19108 </p>
19109 !! html/parsoid
19110 <p>test &lt;tag>123</p>
19111
19112 <p>this is a <b>test</b></p>
19113 !! end
19114
19115 !! test
19116 Parser hook: horizontal rule inside extension tag that outputs <pre>
19117 !! wikitext
19118 <tag>
19119 Hello
19120 <hr/>
19121 Goodbye
19122 </tag>
19123 !! html/php
19124 <pre>
19125 '
19126 Hello
19127 <hr/>
19128 Goodbye
19129 '
19130 array (
19131 )
19132 </pre>
19133
19134 !! end
19135
19136 ###
19137 ### (see tests/parser/parserTestsParserHook.php for the <statictag> extension)
19138 ###
19139
19140 !! test
19141 Parser hook: static parser hook not inside a comment
19142 !! wikitext
19143 <statictag>hello, world</statictag>
19144
19145 <statictag action="flush" />
19146 !! html/php
19147 <p><br />
19148 hello, world
19149 </p>
19150 !! html/parsoid
19151 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{},"body":{"extsrc":"hello, world"}}' data-parsoid='{}' about="#mwt2"></span></p>
19152 <p typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"}}' data-parsoid='{}' about="#mwt4">hello, world</p>
19153 !! end
19154
19155 !! test
19156 Parser hook: static parser hook inside a comment
19157 !! wikitext
19158 <!-- <statictag>hello, world</statictag> -->
19159 <statictag action="flush" />
19160 !! html/php
19161 <p><br />
19162 </p>
19163 !! html/parsoid
19164 <!-- <statictag&#x3E;hello, world</statictag&#x3E; -->
19165 <p typeof='mw:Extension/statictag' data-mw='{"name":"statictag","attrs":{"action":"flush"}}' data-parsoid='{}' about='#mwt2'></p>
19166 !! end
19167
19168 # Nested template calls; this case was broken by Parser.php rev 1.506,
19169 # since reverted.
19170
19171 !! article
19172 Template:One-parameter
19173 !! text
19174 (My parameter is: {{{1}}})
19175 !! endarticle
19176
19177 !! article
19178 Template:Map-one-parameter
19179 !! text
19180 {{{{{1}}}|{{{2}}}}}
19181 !! endarticle
19182
19183 !! test
19184 Nested template calls
19185 !! wikitext
19186 {{Map-one-parameter|One-parameter|param}}
19187 !! html
19188 <p>(My parameter is: param)
19189 </p>
19190 !! end
19191
19192
19193 ###
19194 ### Sanitizer
19195 ###
19196
19197 !! test
19198 Sanitizer: Closing of open tags
19199 !! wikitext
19200 <s></s><table></table>
19201 !! html/php+tidy
19202 <p><s></s></p><table></table>
19203 !! html/parsoid
19204 <p><s data-parsoid='{"stx":"html"}'></s></p><table data-parsoid='{"stx":"html"}'></table>
19205 !! end
19206
19207 !! test
19208 Sanitizer: Closing of open but not closed tags
19209 !! wikitext
19210 <s>foo
19211 !! html
19212 <p><s>foo</s>
19213 </p>
19214 !! end
19215
19216 !! test
19217 Sanitizer: Closing of closed but not open tags
19218 !! options
19219 parsoid=wt2html
19220 !! wikitext
19221 </s>
19222 !! html+tidy
19223 <p class="mw-empty-elt">
19224 </p>
19225 !! end
19226
19227 !! test
19228 Sanitizer: Closing of closed but not open table tags
19229 !! options
19230 parsoid=wt2html
19231 !! wikitext
19232 Table not started</td></tr></table>
19233 !! html+tidy
19234 <p>Table not started
19235 </p>
19236 !! end
19237
19238 !! test
19239 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
19240 !! config
19241 wgFragmentMode=[ 'html5', 'legacy' ]
19242 !! wikitext
19243 <span id="æ: v">byte</span>[[#æ: v|backlink]]
19244 !! html/php
19245 <p><span id="æ:_v">byte</span><a href="#æ:_v">backlink</a>
19246 </p>
19247 !! html/parsoid
19248 <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>
19249 !! end
19250
19251 !! test
19252 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id="" (legacy)
19253 !! config
19254 wgFragmentMode=[ 'legacy' ]
19255 !! wikitext
19256 <span id="æ: v">byte</span>[[#æ: v|backlink]]
19257 !! html/php
19258 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v">backlink</a>
19259 </p>
19260 !! end
19261
19262 # In HTML5, the restrictions are that id must contain at least one character,
19263 # and must not contain any space characters.
19264 !! test
19265 Sanitizer: Validating the contents of the id attribute (T6515)
19266 !! options
19267 disabled
19268 !! wikitext
19269 <br id="" /><br id="a space" />
19270 !! html
19271 Something ...
19272 !! end
19273
19274 # In HTML5, id must be unique amongst all the ids in the element's home subtree.
19275 !! test
19276 Sanitizer: Validating id attribute uniqueness (T6515, T8301)
19277 !! options
19278 disabled
19279 !! wikitext
19280 <br id="foo" /><br id="foo" />
19281 !! html
19282 Something need to be done. foo-2 ?
19283 !! end
19284
19285 !! test
19286 Sanitizer: Validating that <meta> and <link> work, but only for Microdata
19287 !! wikitext
19288 <div itemscope>
19289 <meta itemprop="hello" content="world">
19290 <meta http-equiv="refresh" content="5">
19291 <meta itemprop="hello" http-equiv="refresh" content="5">
19292 <link itemprop="hello" href="{{SERVER}}">
19293 <link rel="stylesheet" href="{{SERVER}}">
19294 <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
19295 </div>
19296 !! html
19297 <div itemscope="">
19298 <p> <meta itemprop="hello" content="world" />
19299 &lt;meta http-equiv="refresh" content="5"&gt;
19300 <meta itemprop="hello" content="5" />
19301 <link itemprop="hello" href="http&#58;//example.org" />
19302 &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"&gt;
19303 <link itemprop="hello" href="http&#58;//example.org" />
19304 </p>
19305 </div>
19306
19307 !! end
19308
19309 !! test
19310 Sanitizer: Strip comments from CSS attributes
19311 !! options
19312 parsoid=wt2html,wt2wt
19313 !! wikitext
19314 <span style="margin:/*negate mbox-text padding */-0.125em -0.45em; /*rainbow*/rgba(255, 0, 0, 0.3)">2013</span>
19315 !! html/php
19316 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span>
19317 </p>
19318 !! html/parsoid
19319 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span></p>
19320 !! end
19321
19322 !! test
19323 Sanitizer: Avoid unnecessary percent encoded characters in interwiki links
19324 !! wikitext
19325 [[meatball:Soft"Security]]
19326 !! html/php
19327 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Soft%22Security" class="extiw" title="meatball:Soft&quot;Security">meatball:Soft"Security</a>
19328 </p>
19329 !! html/parsoid
19330 <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>
19331 !! end
19332
19333 !! test
19334 Sanitizer: angle brackets are invalid, even in interwiki links (T182338)
19335 !! wikitext
19336 [[meatball:Foo<Bar]]
19337 [[meatball:Foo>Bar]]
19338 [[meatball:Foo&lt;bar]]
19339 [[meatball:Foo&gt;bar]]
19340 !! html/php
19341 <p>[[meatball:Foo&lt;Bar]]
19342 [[meatball:Foo&gt;Bar]]
19343 [[meatball:Foo&lt;bar]]
19344 [[meatball:Foo&gt;bar]]
19345 </p>
19346 !! html/parsoid
19347 <p>[[meatball:Foo&lt;Bar]]
19348 [[meatball:Foo>Bar]]
19349 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span>bar]]
19350 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;gt;","srcContent":">"}'>></span>bar]]</p>
19351 !! end
19352
19353 !! test
19354 Language converter: output gets cut off unexpectedly (T7757)
19355 !! options
19356 language=zh
19357 !! wikitext
19358 this bit is safe: }-
19359
19360 but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}-
19361
19362 then we get cut off here: }-
19363
19364 all additional text is vanished
19365 !! html/php
19366 <p>this bit is safe: }-
19367 </p><p>but if we add a conversion instance: xxx
19368 </p><p>then we get cut off here: }-
19369 </p><p>all additional text is vanished
19370 </p>
19371 !! html/parsoid
19372 <p>this bit is safe: }-</p>
19373 <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>
19374 <p>then we get cut off here: }-</p>
19375 <p>all additional text is vanished</p>
19376 !! end
19377
19378 !! test
19379 Language converter glossary rules inside attributes (T119158)
19380 !! options
19381 language=sr variant=sr-el
19382 !! wikitext
19383 -{H|foAjrjvi=>sr-el:" onload="alert(1)" data-foo="}-
19384
19385 [[File:Foobar.jpg|alt=-{}-foAjrjvi-{}-]]
19386 !! html/php
19387 <p>
19388 </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" width="1941" height="220" /></a>
19389 </p>
19390 !! html/parsoid
19391 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"foAjrjvi","l":"sr-el","t":"\" onload=\"alert(1)\" data-foo=\""}]}'/></p>
19392
19393 <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>
19394 !! end
19395
19396 !! test
19397 Self closed html pairs (T7487)
19398 !! wikitext
19399 <center><font id="bug" />Centered text</center>
19400 <div><font id="bug2" />In div text</div>
19401 !! html+tidy
19402 <center><font id="bug"></font>Centered text</center>
19403 <div><font id="bug2"></font>In div text</div>
19404 !! end
19405
19406 !! test
19407 Punctuation: nbsp before exclamation
19408 !! wikitext
19409 C'est grave !
19410 !! html
19411 <p>C'est grave&#160;!
19412 </p>
19413 !! end
19414
19415 !! test
19416 Punctuation: CSS !important (T13874)
19417 !! wikitext
19418 <div style="width:50% !important">important</div>
19419 !! html
19420 <div style="width:50% !important">important</div>
19421
19422 !!end
19423
19424 !! test
19425 Punctuation: CSS ! important (T13874; with space after)
19426 !! wikitext
19427 <div style="width:50% ! important">important</div>
19428 !! html
19429 <div style="width:50%&#32;! important">important</div>
19430
19431 !!end
19432
19433 !! test
19434 HTML bullet list, closed tags (T7497)
19435 !! wikitext
19436 <ul>
19437 <li>One</li>
19438 <li>Two</li>
19439 </ul>
19440 !! html/php
19441 <ul>
19442 <li>One</li>
19443 <li>Two</li>
19444 </ul>
19445
19446 !! html/parsoid
19447 <ul data-parsoid='{"stx":"html"}'>
19448 <li data-parsoid='{"stx":"html"}'>One</li>
19449 <li data-parsoid='{"stx":"html"}'>Two</li>
19450 </ul>
19451
19452 !! end
19453
19454 !! test
19455 HTML bullet list, unclosed tags (T7497)
19456 !! wikitext
19457 <ul>
19458 <li>One
19459 <li>Two
19460 </ul>
19461 !! html/php+tidy
19462 <ul>
19463 <li>One
19464 </li><li>Two
19465 </li></ul>
19466 !! html/parsoid
19467 <ul data-parsoid='{"stx":"html"}'>
19468 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
19469 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
19470 </ul>
19471
19472 !! end
19473
19474 !! test
19475 HTML ordered list, closed tags (T7497)
19476 !! wikitext
19477 <ol>
19478 <li>One</li>
19479 <li>Two</li>
19480 </ol>
19481 !! html/php
19482 <ol>
19483 <li>One</li>
19484 <li>Two</li>
19485 </ol>
19486
19487 !! html/parsoid
19488 <ol data-parsoid='{"stx":"html"}'>
19489 <li data-parsoid='{"stx":"html"}'>One</li>
19490 <li data-parsoid='{"stx":"html"}'>Two</li>
19491 </ol>
19492
19493 !! end
19494
19495 !! test
19496 HTML ordered list, unclosed tags (T7497)
19497 !! options
19498 !! wikitext
19499 <ol>
19500 <li>One
19501 <li>Two
19502 </ol>
19503 !! html/php+tidy
19504 <ol>
19505 <li>One
19506 </li><li>Two
19507 </li></ol>
19508 !! html/parsoid
19509 <ol data-parsoid='{"stx":"html"}'>
19510 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
19511 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
19512 </ol>
19513
19514 !! end
19515
19516 !! test
19517 HTML nested bullet list, closed tags (T7497)
19518 !! wikitext
19519 <ul>
19520 <li>One</li>
19521 <li>Two:
19522 <ul>
19523 <li>Sub-one</li>
19524 <li>Sub-two</li>
19525 </ul>
19526 </li>
19527 </ul>
19528 !! html/php
19529 <ul>
19530 <li>One</li>
19531 <li>Two:
19532 <ul>
19533 <li>Sub-one</li>
19534 <li>Sub-two</li>
19535 </ul>
19536 </li>
19537 </ul>
19538
19539 !! html/parsoid
19540 <ul data-parsoid='{"stx":"html"}'>
19541 <li data-parsoid='{"stx":"html"}'>One</li>
19542 <li data-parsoid='{"stx":"html"}'>Two:
19543 <ul data-parsoid='{"stx":"html"}'>
19544 <li data-parsoid='{"stx":"html"}'>Sub-one</li>
19545 <li data-parsoid='{"stx":"html"}'>Sub-two</li>
19546 </ul>
19547 </li>
19548 </ul>
19549 !! end
19550
19551 !! test
19552 HTML nested bullet list, open tags (T7497)
19553 !! wikitext
19554 <ul>
19555 <li>One
19556 <li>Two:
19557 <ul>
19558 <li>Sub-one
19559 <li>Sub-two
19560 </ul>
19561 </ul>
19562 !! html+tidy
19563 <ul>
19564 <li>One
19565 </li><li>Two:
19566 <ul>
19567 <li>Sub-one
19568 </li><li>Sub-two
19569 </li></ul>
19570 </li></ul>
19571 !! end
19572
19573 !! test
19574 HTML nested ordered list, closed tags (T7497)
19575 !! wikitext
19576 <ol>
19577 <li>One</li>
19578 <li>Two:
19579 <ol>
19580 <li>Sub-one</li>
19581 <li>Sub-two</li>
19582 </ol>
19583 </li>
19584 </ol>
19585 !! html
19586 <ol>
19587 <li>One</li>
19588 <li>Two:
19589 <ol>
19590 <li>Sub-one</li>
19591 <li>Sub-two</li>
19592 </ol>
19593 </li>
19594 </ol>
19595
19596 !! end
19597
19598 !! test
19599 HTML nested ordered list, open tags (T7497)
19600 !! wikitext
19601 <ol>
19602 <li>One
19603 <li>Two:
19604 <ol>
19605 <li>Sub-one
19606 <li>Sub-two
19607 </ol>
19608 </ol>
19609 !! html/php
19610 <ol>
19611 <li>One
19612 <li>Two:
19613 <ol>
19614 <li>Sub-one
19615 <li>Sub-two
19616 </ol>
19617 </ol>
19618
19619 !! html/parsoid
19620 <ol>
19621 <li>One
19622 </li>
19623 <li>Two:
19624 <ol>
19625 <li>Sub-one
19626 </li>
19627 <li>Sub-two
19628 </li>
19629 </ol>
19630 </li>
19631 </ol>
19632
19633 !! end
19634
19635 !! test
19636 HTML ordered list item with parameters oddity
19637 !! wikitext
19638 <ol><li id="fragment">One</li>
19639 </ol>
19640 !! html
19641 <ol><li id="fragment">One</li>
19642 </ol>
19643
19644 !! end
19645
19646 # parsoid doesn't explicitly mark autonumbered links, see T55505
19647 !!test
19648 T7918: autonumbering
19649 !! wikitext
19650 [http://first/] [http://second] [ftp://ftp]
19651
19652 ftp://inlineftp
19653
19654 [mailto:enclosed@mail.tld With target]
19655
19656 [mailto:enclosed@mail.tld]
19657
19658 mailto:inline@mail.tld
19659 !! html/php
19660 <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>
19661 </p><p><a rel="nofollow" class="external free" href="ftp://inlineftp">ftp://inlineftp</a>
19662 </p><p><a rel="nofollow" class="external text" href="mailto:enclosed@mail.tld">With target</a>
19663 </p><p><a rel="nofollow" class="external autonumber" href="mailto:enclosed@mail.tld">[4]</a>
19664 </p><p><a rel="nofollow" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a>
19665 </p>
19666 !! html/parsoid
19667 <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>
19668 <p><a rel="mw:ExtLink" class="external free" href="ftp://inlineftp">ftp://inlineftp</a></p>
19669 <p><a rel="mw:ExtLink" class="external text" href="mailto:enclosed@mail.tld">With target</a></p>
19670 <p><a rel="mw:ExtLink" class="external autonumber" href="mailto:enclosed@mail.tld"></a></p>
19671 <p><a rel="mw:ExtLink" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a></p>
19672 !! end
19673
19674
19675 #
19676 # Security and HTML correctness
19677 # From Nick Jenkins' fuzz testing
19678 #
19679
19680 !! test
19681 Fuzz testing: Parser13
19682 !! wikitext
19683 {|
19684 | http://a|
19685 !! html
19686 <table>
19687 <tr>
19688 <td>
19689 </td>
19690 </tr>
19691 </table>
19692
19693 !! end
19694
19695 # Note that Parsoid output differs from the PHP parser here: the PHP
19696 # parser breaks the URL for the magic word, while in Parsoid the URL
19697 # production takes precedence.
19698 !! test
19699 Fuzz testing: Parser14
19700 !! wikitext
19701 ==onmouseover===
19702 http://__TOC__
19703 !! html/php
19704 <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>
19705 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>
19706 <ul>
19707 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
19708 </ul>
19709 </div>
19710
19711
19712 !! html/php+tidy
19713 <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>
19714 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>
19715 <ul>
19716 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
19717 </ul>
19718 </div>
19719 !! html/parsoid
19720 <h2 id="onmouseover="><span id="onmouseover.3D" typeof="mw:FallbackId"></span>onmouseover=</h2>
19721 <p><a rel="mw:ExtLink" class="external free" href="http://__TOC__" data-parsoid='{"stx":"url"}'>http://__TOC__</a></p>
19722 !! end
19723
19724 !! test
19725 Fuzz testing: Parser14-table
19726 !! options
19727 parsoid=wt2html,html2html
19728 !! wikitext
19729 ==a==
19730 {| STYLE=__TOC__
19731 !! html
19732 <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>
19733 <table style="&#95;_TOC&#95;_">
19734 <tr><td></td></tr>
19735 </table>
19736
19737 !! html+tidy
19738 <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>
19739 <table style="__TOC__">
19740 <tr>
19741 <td></td>
19742 </tr>
19743 </table>
19744 !! html/parsoid
19745 <h2 id="a">a</h2>
19746 <table style="__TOC__"></table>
19747 !! end
19748
19749 # Known to produce bogus xml (extra </td>)
19750 # Don't add the html/php section since it generates broken HTML
19751 !! test
19752 Fuzz testing: Parser16
19753 !! wikitext
19754 {|
19755 !https://||||||
19756 !! html+tidy
19757 <table>
19758 <tbody><tr>
19759 <th>https://</th>
19760 <th></th>
19761 <th></th>
19762 <th>
19763
19764 </th></tr>
19765 </tbody></table>
19766 !! end
19767
19768 !! test
19769 Fuzz testing: Parser21
19770 !! wikitext
19771 {|
19772 !irc://{{ftp://a" onmouseover="alert('hello world');"
19773 |
19774 !! html
19775 <table>
19776 <tr>
19777 <th><a rel="nofollow" class="external free" href="irc://{{ftp://a">irc://{{ftp://a</a>" onmouseover="alert('hello world');"
19778 </th>
19779 <td>
19780 </td>
19781 </tr>
19782 </table>
19783
19784 !! end
19785
19786 !! test
19787 Fuzz testing: Parser22
19788 !! wikitext
19789 http://===r:::https://b
19790
19791 {|
19792 !! html
19793 <p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a>
19794 </p>
19795 <table>
19796 <tr><td></td></tr>
19797 </table>
19798
19799 !! end
19800
19801 ## Remex doesn't account for fostered content.
19802 ## Known to produce bad XML for now
19803 !! test
19804 Fuzz testing: Parser24
19805 !! options
19806 parsoid=wt2html
19807 !! wikitext
19808 {|
19809 {{{|
19810 <u CLASS=
19811 | {{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}} >
19812 <br style="onmouseover='alert(document.cookie);' " />
19813
19814 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19815 |
19816 !! html/php
19817 <table>
19818 {{{|
19819 <u class="&#124;">}}}} &gt;
19820 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
19821
19822 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19823 <tr>
19824 <td></u>
19825 </td>
19826 </tr>
19827 </table>
19828
19829 !! html/php+tidy
19830
19831 {{{|
19832 <u class="&#124;">}}}} &gt;
19833 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
19834
19835 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19836 </u><table><tbody><tr>
19837 <td>
19838 </td>
19839 </tr>
19840 </tbody></table><p><u class="&#124;">
19841 </u></p>
19842 !! html/parsoid
19843 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>
19844 {{{|
19845 <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>"}'/>}}}} >
19846 <br style="onmouseover='alert(document.cookie);' " data-parsoid='{"stx":"html","selfClose":true}'/>
19847
19848 MOVE YOUR MOUSE CURSOR OVER THIS TEXT</u></p>
19849 <table data-parsoid='{"autoInsertedEnd":true}'><tbody><tr data-parsoid='{"autoInsertedStart":true}'><td></td></tr></tbody></table>
19850 !! end
19851
19852 # Note: the current result listed for this is not what the original one was,
19853 # but the original bug was JavaScript injection, which is fixed in any case.
19854 # It's not clear that the original result listed was any more correct than the
19855 # current one. Original result:
19856 # <p>{{{|
19857 # </p>
19858 # <li class="&#124;&#124;">
19859 # }}}blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
19860 !!test
19861 Fuzz testing: Parser25 (T8055)
19862 !! wikitext
19863 {{{
19864 |
19865 <LI CLASS=||
19866 >
19867 }}}blah" onmouseover="alert('hello world');" align="left"'''MOVE MOUSE CURSOR OVER HERE
19868 !! html/php
19869 <p>&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
19870 </p>
19871 !! html/parsoid
19872 <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"]}'>
19873 </span><p about="#mwt1">&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b></p>
19874 !! end
19875
19876 !!test
19877 Fuzz testing: URL adjacent extension (with space, clean)
19878 !! wikitext
19879 http://example.com <nowiki>junk</nowiki>
19880 !! html/php
19881 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> junk
19882 </p>
19883 !! html/parsoid
19884 <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>
19885 !! end
19886
19887 !!test
19888 Fuzz testing: URL adjacent extension (no space, dirty; nowiki)
19889 !! wikitext
19890 http://example.com<nowiki>junk</nowiki>
19891 !! html/php
19892 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>junk
19893 </p>
19894 !! html/parsoid
19895 <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>
19896 !! end
19897
19898 !! test
19899 Fuzz testing: URL adjacent extension (no space, dirty; pre)
19900 !! wikitext
19901 http://example.com<pre>junk</pre>
19902 !! html/php
19903 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre>
19904
19905 !! html/php+tidy
19906 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p><pre>junk</pre>
19907 !! html/parsoid
19908 <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>
19909 !! end
19910
19911 !! test
19912 Fuzz testing: image with bogus manual thumbnail
19913 !! wikitext
19914 [[Image:foobar.jpg|thumbnail= ]]
19915 !! html/php
19916 <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div>
19917
19918 !! html/parsoid
19919 <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>
19920 !! end
19921
19922 # Parsoid will emit the newline literally in wt2wt; see next test case.
19923 !! test
19924 Fuzz testing: encoded newline in generated HTML replacements (T8577)
19925 !! options
19926 parsoid=wt2html
19927 !! wikitext
19928 <pre dir="&#10;"></pre>
19929 !! html/php
19930 <pre dir="&#10;"></pre>
19931
19932 !! html/parsoid
19933 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
19934 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
19935 !! end
19936
19937 !! test
19938 Fuzz testing: encoded newline in generated HTML replacements, html2wt (T8577)
19939 !! options
19940 parsoid=html2wt
19941 !! html/parsoid
19942 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
19943 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
19944 !! wikitext
19945 <pre dir="
19946 "></pre>
19947 !! html/php
19948 <pre dir=""></pre>
19949
19950 !! end
19951
19952 !! test
19953 Templates in extension attributes are not expanded
19954 !! wikitext
19955 <pre dir="{{echo|ltr}}"></pre>
19956 !! html/php
19957 <pre dir="{{echo|ltr}}"></pre>
19958
19959 !! html/parsoid
19960 <pre typeof="mw:Extension/pre" about="#mwt2" dir="{{echo|ltr}}" data-mw='{"name":"pre","attrs":{"dir":"{{echo|ltr}}"},"body":{"extsrc":""}}'></pre>
19961 !! end
19962
19963 !! test
19964 Parsing optional HTML elements (T8171)
19965 !! options
19966 !! wikitext
19967 <table>
19968 <tr>
19969 <td> Some tabular data</td>
19970 <td> More tabular data ...
19971 <td> And yet som tabular data</td>
19972 </tr>
19973 </table>
19974 !! html
19975 <table>
19976 <tr>
19977 <td> Some tabular data</td>
19978 <td> More tabular data ...
19979 </td><td> And yet som tabular data</td>
19980 </tr>
19981 </table>
19982
19983 !! end
19984
19985 !! test
19986 Correct handling of <td>, <tr> (T8171)
19987 !! options
19988 !! wikitext
19989 <table>
19990 <tr>
19991 <td> Some tabular data</td>
19992 <td> More tabular data ...</td>
19993 <td> And yet som tabular data</td>
19994 </tr>
19995 </table>
19996 !! html
19997 <table>
19998 <tr>
19999 <td> Some tabular data</td>
20000 <td> More tabular data ...</td>
20001 <td> And yet som tabular data</td>
20002 </tr>
20003 </table>
20004
20005 !! end
20006
20007
20008 !! test
20009 Parsing crashing regression (fr:JavaScript)
20010 !! wikitext
20011 </body></x>
20012 !! html
20013 <p>&lt;/body&gt;&lt;/x&gt;
20014 </p>
20015 !! end
20016
20017 !! test
20018 Inline wiki vs wiki block nesting
20019 !! wikitext
20020 '''Bold paragraph
20021
20022 New wiki paragraph
20023 !! html
20024 <p><b>Bold paragraph</b>
20025 </p><p>New wiki paragraph
20026 </p>
20027 !! end
20028
20029 # FIXME: The current php output is documented
20030 # and desired output is the parsoid target.
20031 !! test
20032 Inline HTML vs wiki block nesting
20033 !! wikitext
20034 <b>Bold paragraph
20035
20036 New wiki paragraph
20037 !! html/php
20038 <p><b>Bold paragraph
20039 </p><p>New wiki paragraph</b>
20040 </p>
20041 !! html/php+tidy
20042 <p><b>Bold paragraph
20043 </b></p><p><b>New wiki paragraph
20044 </b></p>
20045 !! html/parsoid
20046 <p><b>Bold paragraph</b>
20047 </p><p>New wiki paragraph
20048 </p>
20049 !! end
20050
20051 # Original result was this:
20052 # <p><b>bold</b><b>bold<i>bolditalics</i></b>
20053 # </p>
20054 # While that might be marginally more intuitive, maybe, the six-apostrophe
20055 # construct is clearly pathological and the result stated here (which is what
20056 # the parser actually does) is about as reasonable as anything.
20057 !!test
20058 Mixing markup for italics and bold
20059 !! options
20060 !! wikitext
20061 '''bold''''''bold''bolditalics'''''
20062 !! html
20063 <p>'<i>bold'</i><b>bold<i>bolditalics</i></b>
20064 </p>
20065 !! end
20066
20067
20068 !! article
20069 Xyzzyx
20070 !! text
20071 Article for special page transclusion test
20072 !! endarticle
20073
20074 !! test
20075 Special page transclusion
20076 !! options
20077 !! wikitext
20078 {{Special:Prefixindex/Xyzzyx}}
20079 !! html
20080 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
20081 </ul>
20082
20083 !! end
20084
20085 !! test
20086 Special page transclusion twice (T7021)
20087 !! options
20088 !! wikitext
20089 {{Special:Prefixindex/Xyzzyx}}
20090 {{Special:Prefixindex/Xyzzyx}}
20091 !! html
20092 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
20093 </ul>
20094 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
20095 </ul>
20096
20097 !! end
20098
20099 !! test
20100 Transclusion of default MediaWiki message
20101 !! wikitext
20102 {{MediaWiki:Mainpage}}
20103 !! html
20104 <p>Main Page
20105 </p>
20106 !! end
20107
20108 !! test
20109 Transclusion of nonexistent MediaWiki message
20110 !! wikitext
20111 {{MediaWiki:Mainpagexxx}}
20112 !! html
20113 <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>
20114 </p>
20115 !! end
20116
20117 !! test
20118 Transclusion of MediaWiki message with underscore
20119 !! wikitext
20120 {{MediaWiki:history_short}}
20121 !! html
20122 <p>History
20123 </p>
20124 !! end
20125
20126 !! test
20127 Transclusion of MediaWiki message with space
20128 !! wikitext
20129 {{MediaWiki:history short}}
20130 !! html
20131 <p>History
20132 </p>
20133 !! end
20134
20135 !! test
20136 Invalid header with following text
20137 !! wikitext
20138 = x = y
20139 !! html
20140 <p>= x = y
20141 </p>
20142 !! end
20143
20144
20145 !! test
20146 Section extraction test (section 0)
20147 !! options
20148 section=0
20149 !! wikitext
20150 start
20151 ==a==
20152 ===aa===
20153 ====aaa====
20154 ==b==
20155 ===ba===
20156 ===bb===
20157 ====bba====
20158 ===bc===
20159 ==c==
20160 ===ca===
20161 !! html/php
20162 start
20163 !! end
20164
20165 !! test
20166 Section extraction test (section 1)
20167 !! options
20168 section=1
20169 !! wikitext
20170 start
20171 ==a==
20172 ===aa===
20173 ====aaa====
20174 ==b==
20175 ===ba===
20176 ===bb===
20177 ====bba====
20178 ===bc===
20179 ==c==
20180 ===ca===
20181 !! html/php
20182 ==a==
20183 ===aa===
20184 ====aaa====
20185 !! end
20186
20187 !! test
20188 Section extraction test (section 2)
20189 !! options
20190 section=2
20191 !! wikitext
20192 start
20193 ==a==
20194 ===aa===
20195 ====aaa====
20196 ==b==
20197 ===ba===
20198 ===bb===
20199 ====bba====
20200 ===bc===
20201 ==c==
20202 ===ca===
20203 !! html/php
20204 ===aa===
20205 ====aaa====
20206 !! end
20207
20208 !! test
20209 Section extraction test (section 3)
20210 !! options
20211 section=3
20212 !! wikitext
20213 start
20214 ==a==
20215 ===aa===
20216 ====aaa====
20217 ==b==
20218 ===ba===
20219 ===bb===
20220 ====bba====
20221 ===bc===
20222 ==c==
20223 ===ca===
20224 !! html/php
20225 ====aaa====
20226 !! end
20227
20228 !! test
20229 Section extraction test (section 4)
20230 !! options
20231 section=4
20232 !! wikitext
20233 start
20234 ==a==
20235 ===aa===
20236 ====aaa====
20237 ==b==
20238 ===ba===
20239 ===bb===
20240 ====bba====
20241 ===bc===
20242 ==c==
20243 ===ca===
20244 !! html/php
20245 ==b==
20246 ===ba===
20247 ===bb===
20248 ====bba====
20249 ===bc===
20250 !! end
20251
20252 !! test
20253 Section extraction test (section 5)
20254 !! options
20255 section=5
20256 !! wikitext
20257 start
20258 ==a==
20259 ===aa===
20260 ====aaa====
20261 ==b==
20262 ===ba===
20263 ===bb===
20264 ====bba====
20265 ===bc===
20266 ==c==
20267 ===ca===
20268 !! html/php
20269 ===ba===
20270 !! end
20271
20272 !! test
20273 Section extraction test (section 6)
20274 !! options
20275 section=6
20276 !! wikitext
20277 start
20278 ==a==
20279 ===aa===
20280 ====aaa====
20281 ==b==
20282 ===ba===
20283 ===bb===
20284 ====bba====
20285 ===bc===
20286 ==c==
20287 ===ca===
20288 !! html/php
20289 ===bb===
20290 ====bba====
20291 !! end
20292
20293 !! test
20294 Section extraction test (section 7)
20295 !! options
20296 section=7
20297 !! wikitext
20298 start
20299 ==a==
20300 ===aa===
20301 ====aaa====
20302 ==b==
20303 ===ba===
20304 ===bb===
20305 ====bba====
20306 ===bc===
20307 ==c==
20308 ===ca===
20309 !! html/php
20310 ====bba====
20311 !! end
20312
20313 !! test
20314 Section extraction test (section 8)
20315 !! options
20316 section=8
20317 !! wikitext
20318 start
20319 ==a==
20320 ===aa===
20321 ====aaa====
20322 ==b==
20323 ===ba===
20324 ===bb===
20325 ====bba====
20326 ===bc===
20327 ==c==
20328 ===ca===
20329 !! html/php
20330 ===bc===
20331 !! end
20332
20333 !! test
20334 Section extraction test (section 9)
20335 !! options
20336 section=9
20337 !! wikitext
20338 start
20339 ==a==
20340 ===aa===
20341 ====aaa====
20342 ==b==
20343 ===ba===
20344 ===bb===
20345 ====bba====
20346 ===bc===
20347 ==c==
20348 ===ca===
20349 !! html/php
20350 ==c==
20351 ===ca===
20352 !! end
20353
20354 !! test
20355 Section extraction test (section 10)
20356 !! options
20357 section=10
20358 !! wikitext
20359 start
20360 ==a==
20361 ===aa===
20362 ====aaa====
20363 ==b==
20364 ===ba===
20365 ===bb===
20366 ====bba====
20367 ===bc===
20368 ==c==
20369 ===ca===
20370 !! html/php
20371 ===ca===
20372 !! end
20373
20374 !! test
20375 Section extraction test (nonexistent section 11)
20376 !! options
20377 section=11
20378 !! wikitext
20379 start
20380 ==a==
20381 ===aa===
20382 ====aaa====
20383 ==b==
20384 ===ba===
20385 ===bb===
20386 ====bba====
20387 ===bc===
20388 ==c==
20389 ===ca===
20390 !! html/php
20391 !! end
20392
20393 !! test
20394 Section extraction test with bogus heading (section 1)
20395 !! options
20396 section=1
20397 !! wikitext
20398 ==a==
20399 ==bogus== not a legal section
20400 ==b==
20401 !! html/php
20402 ==a==
20403 ==bogus== not a legal section
20404 !! end
20405
20406 !! test
20407 Section extraction test with bogus heading (section 2)
20408 !! options
20409 section=2
20410 !! wikitext
20411 ==a==
20412 ==bogus== not a legal section
20413 ==b==
20414 !! html/php
20415 ==b==
20416 !! end
20417
20418 !! test
20419 Section extraction test with comment after heading (section 1)
20420 !! options
20421 section=1
20422 !! wikitext
20423 ==a==
20424 ==b== <!-- -->
20425 ==c==
20426 !! html/php
20427 ==a==
20428 !! end
20429
20430 !! test
20431 Section extraction test with comment after heading (section 2)
20432 !! options
20433 section=2
20434 !! wikitext
20435 ==a==
20436 ==b== <!-- -->
20437 ==c==
20438 !! html/php
20439 ==b== <!-- -->
20440 !! end
20441
20442 !! test
20443 Section extraction test with bogus <nowiki> heading (section 1)
20444 !! options
20445 section=1
20446 !! wikitext
20447 ==a==
20448 ==bogus== <nowiki>not a legal section</nowiki>
20449 ==b==
20450 !! html/php
20451 ==a==
20452 ==bogus== <nowiki>not a legal section</nowiki>
20453 !! end
20454
20455 !! test
20456 Section extraction test with bogus <nowiki> heading (section 2)
20457 !! options
20458 section=2
20459 !! wikitext
20460 ==a==
20461 ==bogus== <nowiki>not a legal section</nowiki>
20462 ==b==
20463 !! html/php
20464 ==b==
20465 !! end
20466
20467 # Formerly testing for T4587, now resolved by the use of unmarked sections
20468 # instead of respecting commented sections
20469 !! test
20470 Section extraction prefixed by comment (section 1)
20471 !! options
20472 section=1
20473 !! wikitext
20474 <!-- -->==sec1==
20475 ==sec2==
20476 !! html/php
20477 ==sec2==
20478 !!end
20479
20480 !! test
20481 Section extraction prefixed by comment (section 2)
20482 !! options
20483 section=2
20484 !! wikitext
20485 <!-- -->==sec1==
20486 ==sec2==
20487 !! html/php
20488
20489 !!end
20490
20491 # Formerly testing for T4607, now resolved by the use of unmarked sections
20492 # instead of respecting HTML-style headings
20493 !! test
20494 Section extraction, mixed wiki and html (section 1)
20495 !! options
20496 section=1
20497 !! wikitext
20498 <h2>unmarked</h2>
20499 unmarked
20500 ==1==
20501 one
20502 ==2==
20503 two
20504 !! html/php
20505 ==1==
20506 one
20507 !! end
20508
20509 !! test
20510 Section extraction, mixed wiki and html (section 2)
20511 !! options
20512 section=2
20513 !! wikitext
20514 <h2>unmarked</h2>
20515 unmarked
20516 ==1==
20517 one
20518 ==2==
20519 two
20520 !! html/php
20521 ==2==
20522 two
20523 !! end
20524
20525
20526 # Formerly testing for T5342
20527 !! test
20528 Section extraction, heading surrounded by <noinclude>
20529 !! options
20530 section=1
20531 !! wikitext
20532 <noinclude>==unmarked==</noinclude>
20533 ==marked==
20534 !! html/php
20535 ==marked==
20536 !!end
20537
20538 # Test behavior of T21910
20539 !! test
20540 Sectiion with all-equals
20541 !! options
20542 section=2
20543 !! wikitext
20544 ===
20545 The line above must have a trailing space
20546 === <!--
20547 --> <!-- -->
20548 But just in case it doesn't...
20549 !! html/php
20550 === <!--
20551 --> <!-- -->
20552 But just in case it doesn't...
20553 !! end
20554
20555 !! test
20556 Section replacement test (section 0)
20557 !! options
20558 replace=0,"xxx"
20559 !! wikitext
20560 start
20561 ==a==
20562 ===aa===
20563 ====aaa====
20564 ==b==
20565 ===ba===
20566 ===bb===
20567 ====bba====
20568 ===bc===
20569 ==c==
20570 ===ca===
20571 !! html/php
20572 xxx
20573
20574 ==a==
20575 ===aa===
20576 ====aaa====
20577 ==b==
20578 ===ba===
20579 ===bb===
20580 ====bba====
20581 ===bc===
20582 ==c==
20583 ===ca===
20584 !! end
20585
20586 !! test
20587 Section replacement test (section 1)
20588 !! options
20589 replace=1,"xxx"
20590 !! wikitext
20591 start
20592 ==a==
20593 ===aa===
20594 ====aaa====
20595 ==b==
20596 ===ba===
20597 ===bb===
20598 ====bba====
20599 ===bc===
20600 ==c==
20601 ===ca===
20602 !! html/php
20603 start
20604 xxx
20605
20606 ==b==
20607 ===ba===
20608 ===bb===
20609 ====bba====
20610 ===bc===
20611 ==c==
20612 ===ca===
20613 !! end
20614
20615 !! test
20616 Section replacement test (section 2)
20617 !! options
20618 replace=2,"xxx"
20619 !! wikitext
20620 start
20621 ==a==
20622 ===aa===
20623 ====aaa====
20624 ==b==
20625 ===ba===
20626 ===bb===
20627 ====bba====
20628 ===bc===
20629 ==c==
20630 ===ca===
20631 !! html/php
20632 start
20633 ==a==
20634 xxx
20635
20636 ==b==
20637 ===ba===
20638 ===bb===
20639 ====bba====
20640 ===bc===
20641 ==c==
20642 ===ca===
20643 !! end
20644
20645 !! test
20646 Section replacement test (section 3)
20647 !! options
20648 replace=3,"xxx"
20649 !! wikitext
20650 start
20651 ==a==
20652 ===aa===
20653 ====aaa====
20654 ==b==
20655 ===ba===
20656 ===bb===
20657 ====bba====
20658 ===bc===
20659 ==c==
20660 ===ca===
20661 !! html/php
20662 start
20663 ==a==
20664 ===aa===
20665 xxx
20666
20667 ==b==
20668 ===ba===
20669 ===bb===
20670 ====bba====
20671 ===bc===
20672 ==c==
20673 ===ca===
20674 !! end
20675
20676 !! test
20677 Section replacement test (section 4)
20678 !! options
20679 replace=4,"xxx"
20680 !! wikitext
20681 start
20682 ==a==
20683 ===aa===
20684 ====aaa====
20685 ==b==
20686 ===ba===
20687 ===bb===
20688 ====bba====
20689 ===bc===
20690 ==c==
20691 ===ca===
20692 !! html/php
20693 start
20694 ==a==
20695 ===aa===
20696 ====aaa====
20697 xxx
20698
20699 ==c==
20700 ===ca===
20701 !! end
20702
20703 !! test
20704 Section replacement test (section 5)
20705 !! options
20706 replace=5,"xxx"
20707 !! wikitext
20708 start
20709 ==a==
20710 ===aa===
20711 ====aaa====
20712 ==b==
20713 ===ba===
20714 ===bb===
20715 ====bba====
20716 ===bc===
20717 ==c==
20718 ===ca===
20719 !! html/php
20720 start
20721 ==a==
20722 ===aa===
20723 ====aaa====
20724 ==b==
20725 xxx
20726
20727 ===bb===
20728 ====bba====
20729 ===bc===
20730 ==c==
20731 ===ca===
20732 !! end
20733
20734 !! test
20735 Section replacement test (section 6)
20736 !! options
20737 replace=6,"xxx"
20738 !! wikitext
20739 start
20740 ==a==
20741 ===aa===
20742 ====aaa====
20743 ==b==
20744 ===ba===
20745 ===bb===
20746 ====bba====
20747 ===bc===
20748 ==c==
20749 ===ca===
20750 !! html/php
20751 start
20752 ==a==
20753 ===aa===
20754 ====aaa====
20755 ==b==
20756 ===ba===
20757 xxx
20758
20759 ===bc===
20760 ==c==
20761 ===ca===
20762 !! end
20763
20764 !! test
20765 Section replacement test (section 7)
20766 !! options
20767 replace=7,"xxx"
20768 !! wikitext
20769 start
20770 ==a==
20771 ===aa===
20772 ====aaa====
20773 ==b==
20774 ===ba===
20775 ===bb===
20776 ====bba====
20777 ===bc===
20778 ==c==
20779 ===ca===
20780 !! html/php
20781 start
20782 ==a==
20783 ===aa===
20784 ====aaa====
20785 ==b==
20786 ===ba===
20787 ===bb===
20788 xxx
20789
20790 ===bc===
20791 ==c==
20792 ===ca===
20793 !! end
20794
20795 !! test
20796 Section replacement test (section 8)
20797 !! options
20798 replace=8,"xxx"
20799 !! wikitext
20800 start
20801 ==a==
20802 ===aa===
20803 ====aaa====
20804 ==b==
20805 ===ba===
20806 ===bb===
20807 ====bba====
20808 ===bc===
20809 ==c==
20810 ===ca===
20811 !! html/php
20812 start
20813 ==a==
20814 ===aa===
20815 ====aaa====
20816 ==b==
20817 ===ba===
20818 ===bb===
20819 ====bba====
20820 xxx
20821
20822 ==c==
20823 ===ca===
20824 !!end
20825
20826 !! test
20827 Section replacement test (section 9)
20828 !! options
20829 replace=9,"xxx"
20830 !! wikitext
20831 start
20832 ==a==
20833 ===aa===
20834 ====aaa====
20835 ==b==
20836 ===ba===
20837 ===bb===
20838 ====bba====
20839 ===bc===
20840 ==c==
20841 ===ca===
20842 !! html/php
20843 start
20844 ==a==
20845 ===aa===
20846 ====aaa====
20847 ==b==
20848 ===ba===
20849 ===bb===
20850 ====bba====
20851 ===bc===
20852 xxx
20853 !! end
20854
20855 !! test
20856 Section replacement test (section 10)
20857 !! options
20858 replace=10,"xxx"
20859 !! wikitext
20860 start
20861 ==a==
20862 ===aa===
20863 ====aaa====
20864 ==b==
20865 ===ba===
20866 ===bb===
20867 ====bba====
20868 ===bc===
20869 ==c==
20870 ===ca===
20871 !! html/php
20872 start
20873 ==a==
20874 ===aa===
20875 ====aaa====
20876 ==b==
20877 ===ba===
20878 ===bb===
20879 ====bba====
20880 ===bc===
20881 ==c==
20882 xxx
20883 !! end
20884
20885 !! test
20886 Section replacement test with initial whitespace (T15728)
20887 !! options
20888 replace=2,"xxx"
20889 !! wikitext
20890 Preformatted initial line
20891 ==a==
20892 ===a===
20893 !! html/php
20894 Preformatted initial line
20895 ==a==
20896 xxx
20897 !! end
20898
20899
20900 !! test
20901 Section extraction, heading followed by pre with 20 spaces (T8398)
20902 !! options
20903 section=1
20904 !! wikitext
20905 ==a==
20906 a
20907 !! html/php
20908 ==a==
20909 a
20910 !! end
20911
20912 !! test
20913 Section extraction, heading followed by pre with 19 spaces (T8398 sanity check)
20914 !! options
20915 section=1
20916 !! wikitext
20917 ==a==
20918 a
20919 !! html/php
20920 ==a==
20921 a
20922 !! end
20923
20924
20925 !! test
20926 Section extraction, <pre> around bogus header (T12309)
20927 !! options
20928 section=2
20929 !! wikitext
20930 == Section One ==
20931 <pre>
20932 =======
20933 </pre>
20934
20935 == Section Two ==
20936 stuff
20937 !! html/php
20938 == Section Two ==
20939 stuff
20940 !! end
20941
20942 !! test
20943 Section replacement, <pre> around bogus header (T12309)
20944 !! options
20945 replace=2,"xxx"
20946 !! wikitext
20947 == Section One ==
20948 <pre>
20949 =======
20950 </pre>
20951
20952 == Section Two ==
20953 stuff
20954 !! html/php
20955 == Section One ==
20956 <pre>
20957 =======
20958 </pre>
20959
20960 xxx
20961 !! end
20962
20963 !! test
20964 Handling of &#x0A; in URLs
20965 !! wikitext
20966 *irc://&#x0A;a
20967 !! html/php
20968 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
20969
20970 !! html/parsoid
20971 <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>
20972 !! end
20973
20974 !! test
20975 Handling of %0A in URLs
20976 !! wikitext
20977 *irc://%0Aa
20978 !! html/php
20979 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
20980
20981 !! html/parsoid
20982 <ul><li><a rel="mw:ExtLink" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
20983 !! end
20984
20985 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
20986 !! test
20987 5 quotes, code coverage +1 line
20988 !! options
20989 parsoid=wt2html
20990 !! wikitext
20991 '''''
20992 !! html/php
20993 !! html/parsoid
20994 <p><b><i></i></b></p>
20995 !! end
20996
20997 # same html as previous, but wikitext adjusted to match parsoid html2wt
20998 # note that wt2html and html2html will put the <i> before the <b>
20999 !! test
21000 5 quotes, code coverage +1 line w/ nowiki (1)
21001 !! options
21002 parsoid=wt2wt,html2wt
21003 !! wikitext
21004 '''''<nowiki/>'''''
21005 !! html/php
21006 <p><i></i>
21007 </p>
21008 !! html/parsoid
21009 <p><b><i></i></b></p>
21010 !! end
21011
21012 # same as previous, just swapping the <i> and <b>
21013 !! test
21014 5 quotes, code coverage +1 line w/ nowiki (2)
21015 !! wikitext
21016 '''''<nowiki/>'''''
21017 !! html/php
21018 <p><i></i>
21019 </p>
21020 !! html/parsoid
21021 <p><i><b></b></i></p>
21022 !! end
21023
21024 !! test
21025 Special:Search page linking.
21026 !! wikitext
21027 {{Special:search}}
21028 !! html
21029 <p><a href="/wiki/Special:Search" title="Special:Search">Special:Search</a>
21030 </p>
21031 !! end
21032
21033 !! test
21034 {{!}} is a magic word
21035 !! wikitext
21036 {{!}} is a magic word there and {{!}} is still a magic word here
21037 | is not a magic word here but {{!}} is still a magic word here
21038 !! html/php
21039 <p>| is a magic word there and | is still a magic word here
21040 | is not a magic word here but | is still a magic word here
21041 </p>
21042 !! html/parsoid
21043 <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
21044 | 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>
21045 !! end
21046
21047 !! test
21048 Say the magic word
21049 !! options
21050 title=[[Parser test]]
21051 !! wikitext
21052 *{{PAGENAME}}
21053 *{{PAGENAMEE}}
21054 *{{FULLPAGENAME}}
21055 *{{FULLPAGENAMEE}}
21056 *{{BASEPAGENAME}}
21057 *{{BASEPAGENAMEE}}
21058 *{{SUBPAGENAME}}
21059 *{{SUBPAGENAMEE}}
21060 *{{ROOTPAGENAME}}
21061 *{{ROOTPAGENAMEE}}
21062 *{{TALKPAGENAME}}
21063 *{{TALKPAGENAMEE}}
21064 *{{SUBJECTPAGENAME}}
21065 *{{SUBJECTPAGENAMEE}}
21066 *{{NAMESPACEE}}
21067 *{{NAMESPACE}}
21068 *{{NAMESPACENUMBER}}
21069 *{{TALKSPACE}}
21070 *{{TALKSPACEE}}
21071 *{{SUBJECTSPACE}}
21072 *{{SUBJECTSPACEE}}
21073 *{{Dynamic|{{NUMBEROFUSERS}}|{{NUMBEROFPAGES}}|{{CURRENTVERSION}}|{{CONTENTLANGUAGE}}|{{DIRECTIONMARK}}|{{CURRENTTIMESTAMP}}|{{NUMBEROFARTICLES}}}}
21074 !! html
21075 <ul><li>Parser test</li>
21076 <li>Parser_test</li>
21077 <li>Parser test</li>
21078 <li>Parser_test</li>
21079 <li>Parser test</li>
21080 <li>Parser_test</li>
21081 <li>Parser test</li>
21082 <li>Parser_test</li>
21083 <li>Parser test</li>
21084 <li>Parser_test</li>
21085 <li>Talk:Parser test</li>
21086 <li>Talk:Parser_test</li>
21087 <li>Parser test</li>
21088 <li>Parser_test</li>
21089 <li></li>
21090 <li></li>
21091 <li>0</li>
21092 <li>Talk</li>
21093 <li>Talk</li>
21094 <li></li>
21095 <li></li>
21096 <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>
21097
21098 !! end
21099 ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included.
21100
21101 !! test
21102 Gallery with valid attributes
21103 !! wikitext
21104 <gallery type="123" summary="345">
21105 File:File:Foobar.jpg
21106 </gallery>
21107 !! html/php
21108 <ul class="gallery mw-gallery-traditional" type="123">
21109 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21110 <div class="thumb" style="height: 150px;">File:Foobar.jpg</div>
21111 <div class="gallerytext">
21112 </div>
21113 </div></li>
21114 </ul>
21115
21116 !! html/parsoid
21117 <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"}}'>
21118 <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>
21119 </ul>
21120 !! end
21121
21122 ## Parsoid thinks the "centre" here is a property, not a caption.
21123 !! test
21124 Gallery
21125 !! options
21126 parsoid={
21127 "modes": ["wt2html"],
21128 "nativeGallery": true
21129 }
21130 !! wikitext
21131 <gallery>
21132 image1.png |
21133 image2.gif|||||
21134
21135 image3|
21136 image4 |300px| centre
21137 image5.svg| http://///////
21138 [[x|xx]]]]
21139 * image6
21140 </gallery>
21141 !! html/php
21142 <ul class="gallery mw-gallery-traditional">
21143 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21144 <div class="thumb" style="height: 150px;">Image1.png</div>
21145 <div class="gallerytext">
21146 </div>
21147 </div></li>
21148 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21149 <div class="thumb" style="height: 150px;">Image2.gif</div>
21150 <div class="gallerytext">
21151 </div>
21152 </div></li>
21153 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21154 <div class="thumb" style="height: 150px;">Image3</div>
21155 <div class="gallerytext">
21156 </div>
21157 </div></li>
21158 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21159 <div class="thumb" style="height: 150px;">Image4</div>
21160 <div class="gallerytext">
21161 <pre>centre
21162 </pre>
21163 </div>
21164 </div></li>
21165 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21166 <div class="thumb" style="height: 150px;">Image5.svg</div>
21167 <div class="gallerytext">
21168 <p><a rel="nofollow" class="external free" href="http://///////">http://///////</a>
21169 </p>
21170 </div>
21171 </div></li>
21172 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21173 <div class="thumb" style="height: 150px;">* image6</div>
21174 <div class="gallerytext">
21175 </div>
21176 </div></li>
21177 </ul>
21178
21179 !! html/parsoid
21180 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21181 <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>
21182 <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>
21183 <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>
21184 <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>
21185 <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>
21186 <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>
21187 </ul>
21188 !! end
21189
21190 !! test
21191 Gallery (with options, html)
21192 !! options
21193 parsoid={
21194 "modes": ["wt2html", "html2html"],
21195 "nativeGallery": true
21196 }
21197 !! wikitext
21198 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
21199 File:Nonexistent.jpg|caption
21200 File:Nonexistent.jpg
21201 image:foobar.jpg|some '''caption''' [[Main Page]]
21202 image:foobar.jpg
21203 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
21204 </gallery>
21205 !! html/php
21206 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
21207 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
21208 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21209 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21210 <div class="gallerytext">
21211 <p>caption
21212 </p>
21213 </div>
21214 </div></li>
21215 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21216 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21217 <div class="gallerytext">
21218 </div>
21219 </div></li>
21220 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21221 <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/105px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/140px-Foobar.jpg 2x" /></a></div></div>
21222 <div class="gallerytext">
21223 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21224 </p>
21225 </div>
21226 </div></li>
21227 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21228 <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/105px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/140px-Foobar.jpg 2x" /></a></div></div>
21229 <div class="gallerytext">
21230 </div>
21231 </div></li>
21232 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21233 <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="This is a foo-bar." src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/105px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/140px-Foobar.jpg 2x" /></a></div></div>
21234 <div class="gallerytext">
21235 <p>blabla.
21236 </p>
21237 </div>
21238 </div></li>
21239 </ul>
21240
21241 !! html/parsoid
21242 <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":{}}'>
21243 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
21244 <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>
21245 <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>
21246 <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>
21247 <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>
21248 <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>
21249 </ul>
21250 !! end
21251
21252 !! test
21253 Gallery (with options, extsrc)
21254 !! options
21255 parsoid={
21256 "nativeGallery": false
21257 }
21258 !! wikitext
21259 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
21260 File:Nonexistent.jpg|caption
21261 File:Nonexistent.jpg
21262 image:foobar.jpg|some '''caption''' [[Main Page]]
21263 image:foobar.jpg
21264 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
21265 </gallery>
21266 !! html/php
21267 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
21268 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
21269 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21270 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21271 <div class="gallerytext">
21272 <p>caption
21273 </p>
21274 </div>
21275 </div></li>
21276 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21277 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21278 <div class="gallerytext">
21279 </div>
21280 </div></li>
21281 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21282 <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/105px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/140px-Foobar.jpg 2x" /></a></div></div>
21283 <div class="gallerytext">
21284 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21285 </p>
21286 </div>
21287 </div></li>
21288 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21289 <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/105px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/140px-Foobar.jpg 2x" /></a></div></div>
21290 <div class="gallerytext">
21291 </div>
21292 </div></li>
21293 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21294 <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="This is a foo-bar." src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/105px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/140px-Foobar.jpg 2x" /></a></div></div>
21295 <div class="gallerytext">
21296 <p>blabla.
21297 </p>
21298 </div>
21299 </div></li>
21300 </ul>
21301
21302 !! html/parsoid
21303 <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"}}'>
21304 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
21305 <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>
21306 <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>
21307 <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>
21308 <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>
21309 <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>
21310 </ul>
21311 !! end
21312
21313 !! test
21314 Gallery (without px units)
21315 !! wikitext
21316 <gallery widths="70" heights="40">
21317 File:Foobar.jpg
21318 </gallery>
21319 !! html/php
21320 <ul class="gallery mw-gallery-traditional">
21321 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21322 <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/105px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/140px-Foobar.jpg 2x" /></a></div></div>
21323 <div class="gallerytext">
21324 </div>
21325 </div></li>
21326 </ul>
21327
21328 !! html/parsoid
21329 <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"}}'>
21330 <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>
21331 </ul>
21332 !! end
21333
21334 !! test
21335 Gallery (with invalid units)
21336 !! wikitext
21337 <gallery widths="70em" heights="40em">
21338 File:Foobar.jpg
21339 </gallery>
21340 !! html/php
21341 <ul class="gallery mw-gallery-traditional">
21342 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21343 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
21344 <div class="gallerytext">
21345 </div>
21346 </div></li>
21347 </ul>
21348
21349 !! html/parsoid
21350 <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"}}'>
21351 <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>
21352 </ul>
21353 !! end
21354
21355 !! test
21356 Gallery with link that has fragment
21357 !! options
21358 parsoid={
21359 "modes": ["wt2html", "html2html"],
21360 "nativeGallery": true
21361 }
21362 !! wikitext
21363 <gallery>
21364 image:foobar.jpg|link=Main_Page
21365 image:foobar.jpg|link=Main_Page#section
21366 image:foobar.jpg|link=Main Page#section|caption
21367 </gallery>
21368 !! html/php
21369 <ul class="gallery mw-gallery-traditional">
21370 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21371 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Main_Page"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
21372 <div class="gallerytext">
21373 </div>
21374 </div></li>
21375 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21376 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Main_Page#section"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
21377 <div class="gallerytext">
21378 </div>
21379 </div></li>
21380 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21381 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Main_Page#section"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
21382 <div class="gallerytext">
21383 <p>caption
21384 </p>
21385 </div>
21386 </div></li>
21387 </ul>
21388
21389 !! html/parsoid
21390 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21391 <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>
21392 <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>
21393 <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>
21394 </ul>
21395 !! end
21396
21397 ## Whoops, Parsoid shouldn't be parsing templates in the attribute caption!
21398 !! test
21399 Gallery with template inside caption
21400 !! options
21401 parsoid={
21402 "nativeGallery": true
21403 }
21404 !! wikitext
21405 <gallery caption="{{echo|hi}}">
21406 File:Foobar.jpg|{{echo|ho}}
21407 </gallery>
21408 !! html/php
21409 <ul class="gallery mw-gallery-traditional">
21410 <li class='gallerycaption'>{{echo|hi}}</li>
21411 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21412 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
21413 <div class="gallerytext">
21414 <p>ho
21415 </p>
21416 </div>
21417 </div></li>
21418 </ul>
21419
21420 !! html/parsoid
21421 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21422 <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>
21423 <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>
21424 </ul>
21425 !! end
21426
21427 !! test
21428 Gallery with wikitext inside caption
21429 !! options
21430 parsoid={
21431 "nativeGallery": true
21432 }
21433 !! wikitext
21434 <gallery>
21435 File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]]
21436 File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}}
21437 </gallery>
21438 !! html/php
21439 <ul class="gallery mw-gallery-traditional">
21440 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21441 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
21442 <div class="gallerytext">
21443 <p><a href="/wiki/File:Foobar.jpg" class="image" title="desc"><img alt="inneralt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg" width="20" height="2" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/30px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/40px-Foobar.jpg 2x" /></a>
21444 </p>
21445 </div>
21446 </div></li>
21447 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21448 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
21449 <div class="gallerytext">
21450 <p>This is a test template
21451 </p>
21452 </div>
21453 </div></li>
21454 </ul>
21455
21456 !! html/parsoid
21457 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21458 <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>
21459 <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>
21460 </ul>
21461 !! end
21462
21463 !! test
21464 Gallery (with showfilename option)
21465 !! options
21466 parsoid={
21467 "nativeGallery": true
21468 }
21469 !! wikitext
21470 <gallery showfilename="">
21471 File:Nonexistent.jpg|caption
21472 File:Nonexistent.jpg
21473 File:Foobar.jpg|some '''caption''' [[Main Page]]
21474 File:Foobar.jpg
21475 </gallery>
21476 !! html/php
21477 <ul class="gallery mw-gallery-traditional">
21478 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21479 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21480 <div class="gallerytext">
21481 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
21482 caption
21483 </p>
21484 </div>
21485 </div></li>
21486 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21487 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21488 <div class="gallerytext">
21489 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
21490 </p>
21491 </div>
21492 </div></li>
21493 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21494 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
21495 <div class="gallerytext">
21496 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
21497 some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21498 </p>
21499 </div>
21500 </div></li>
21501 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21502 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
21503 <div class="gallerytext">
21504 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
21505 </p>
21506 </div>
21507 </div></li>
21508 </ul>
21509
21510 !! html/parsoid
21511 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
21512 <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>
21513 <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>
21514 <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>
21515 <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>
21516 </ul>
21517 !! end
21518
21519 ## Should Parsoid be preserving these variations? See T151367
21520 !! test
21521 Gallery (with namespace-less filenames)
21522 !! options
21523 parsoid={
21524 "modes": ["wt2html", "html2html"],
21525 "nativeGallery": true
21526 }
21527 !! wikitext
21528 <gallery>
21529 File:Nonexistent.jpg
21530 Nonexistent.jpg
21531 image:foobar.jpg
21532 foobar.jpg
21533 </gallery>
21534 !! html/php
21535 <ul class="gallery mw-gallery-traditional">
21536 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21537 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21538 <div class="gallerytext">
21539 </div>
21540 </div></li>
21541 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21542 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21543 <div class="gallerytext">
21544 </div>
21545 </div></li>
21546 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21547 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
21548 <div class="gallerytext">
21549 </div>
21550 </div></li>
21551 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21552 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
21553 <div class="gallerytext">
21554 </div>
21555 </div></li>
21556 </ul>
21557
21558 !! html/parsoid
21559 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21560 <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>
21561 <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>
21562 <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>
21563 <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>
21564 </ul>
21565 !! end
21566
21567 !! test
21568 Gallery override link with wikilink (T36852)
21569 !! options
21570 parsoid={
21571 "nativeGallery": true
21572 }
21573 !! wikitext
21574 <gallery>
21575 File:Foobar.jpg|alt=galleryalt|link=Wikilink
21576 </gallery>
21577 !! html/php
21578 <ul class="gallery mw-gallery-traditional">
21579 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21580 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Wikilink"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
21581 <div class="gallerytext">
21582 </div>
21583 </div></li>
21584 </ul>
21585
21586 !! html/parsoid
21587 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21588 <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>
21589 </ul>
21590 !! end
21591
21592 !! test
21593 Gallery override link with absolute external link (T36852)
21594 !! options
21595 parsoid={
21596 "nativeGallery": true
21597 }
21598 !! wikitext
21599 <gallery>
21600 File:Foobar.jpg|alt=galleryalt|link=http://www.example.org
21601 </gallery>
21602 !! html/php
21603 <ul class="gallery mw-gallery-traditional">
21604 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21605 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="http://www.example.org"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
21606 <div class="gallerytext">
21607 </div>
21608 </div></li>
21609 </ul>
21610
21611 !! html/parsoid
21612 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21613 <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>
21614 </ul>
21615 !! end
21616
21617 !! test
21618 Gallery override link with absolute external link with LanguageConverter
21619 !! options
21620 language=zh
21621 !! wikitext
21622 <gallery>
21623 File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org
21624 </gallery>
21625 !! html/php
21626 <ul class="gallery mw-gallery-traditional">
21627 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21628 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="http://www.example.org"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
21629 <div class="gallerytext">
21630 <p>caption
21631 </p>
21632 </div>
21633 </div></li>
21634 </ul>
21635
21636 !! html/parsoid
21637 <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"}}'>
21638 <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>
21639 </ul>
21640 !! end
21641
21642 !! test
21643 Gallery override link with malicious javascript (T36852)
21644 !! options
21645 parsoid={
21646 "modes": ["wt2html", "html2html"],
21647 "nativeGallery": true
21648 }
21649 !! wikitext
21650 <gallery>
21651 File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!');
21652 </gallery>
21653 !! html/php
21654 <ul class="gallery mw-gallery-traditional">
21655 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21656 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/%22_onclick%3D%22alert(%27malicious_javascript_code!%27);"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
21657 <div class="gallerytext">
21658 </div>
21659 </div></li>
21660 </ul>
21661
21662 !! html/parsoid
21663 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21664 <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>
21665 </ul>
21666 !! end
21667
21668 # Note that parsoid uses the invalid link as a caption, PHP does not.
21669 !! test
21670 Gallery with invalid title as link (T45964)
21671 !! options
21672 parsoid={
21673 "modes": ["wt2html", "html2html"],
21674 "nativeGallery": true
21675 }
21676 !! wikitext
21677 <gallery>
21678 File:Foobar.jpg|link=<
21679 </gallery>
21680 !! html/php
21681 <ul class="gallery mw-gallery-traditional">
21682 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21683 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
21684 <div class="gallerytext">
21685 </div>
21686 </div></li>
21687 </ul>
21688
21689 !! html/parsoid
21690 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21691 <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>
21692 </ul>
21693 !! end
21694
21695 !! test
21696 Serialize gallery without attrs in data-mw
21697 !! options
21698 parsoid={
21699 "modes": ["html2wt"],
21700 "nativeGallery": true
21701 }
21702 !! html/parsoid
21703 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'>
21704 <li class="gallerycaption">123</li>
21705 <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>
21706 </ul>
21707 !! wikitext
21708 <gallery caption="123">
21709 File:Test.png
21710 </gallery>
21711 !! end
21712
21713 !! test
21714 Gallery with class and style attributes
21715 !! options
21716 parsoid={
21717 "nativeGallery": true
21718 }
21719 !! wikitext
21720 <gallery class="center" style="text-align: center;">
21721 File:Foobar.jpg
21722 </gallery>
21723 !! html/php
21724 <ul class="gallery mw-gallery-traditional center" style="text-align: center;">
21725 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21726 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
21727 <div class="gallerytext">
21728 </div>
21729 </div></li>
21730 </ul>
21731
21732 !! html/parsoid
21733 <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":{}}'>
21734 <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>
21735 </ul>
21736 !! end
21737
21738 !! test
21739 Gallery in slideshow mode
21740 !! options
21741 parsoid={
21742 "nativeGallery": true
21743 }
21744 !! wikitext
21745 <gallery mode="slideshow" showthumbnails="">
21746 File:Foobar.jpg
21747 </gallery>
21748 !! html/php
21749 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1">
21750 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21751 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
21752 <div class="gallerytext">
21753 </div>
21754 </div></li>
21755 </ul>
21756
21757 !! html/parsoid
21758 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'>
21759 <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>
21760 </ul>
21761 !! end
21762
21763 !! test
21764 Serialize gallery image captions on a line
21765 !! options
21766 parsoid={
21767 "modes": ["html2wt"],
21768 "nativeGallery": true
21769 }
21770 !! html/parsoid
21771 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21772 <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>
21773 <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>
21774 </ul>
21775 !! wikitext
21776 <gallery>
21777 File:Foobar.jpg| hi ho
21778 File:Foobar.jpg|hi<br />ho
21779 </gallery>
21780 !! end
21781
21782 !! test
21783 HTML Hex character encoding (spells the word "JavaScript")
21784 !! options
21785 parsoid=wt2html,wt2wt,html2html
21786 !! wikitext
21787 &#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
21788 !! html/php
21789 <p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
21790 </p>
21791 !! html/parsoid
21792 <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>
21793 !! end
21794
21795 !! test
21796 HTML Hex character encoding bogus encoding (T28437 regression check)
21797 !! wikitext
21798 &#xsee;&#XSEE;
21799 !! html
21800 <p>&amp;#xsee;&amp;#XSEE;
21801 </p>
21802 !! end
21803
21804 !! test
21805 HTML Hex character encoding mixed case
21806 !! options
21807 parsoid=wt2html,wt2wt,html2html
21808 !! wikitext
21809 &#xEE;&#Xee;
21810 !! html/php
21811 <p>&#xee;&#xee;
21812 </p>
21813 !! html/parsoid
21814 <p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
21815 !! end
21816
21817 # See: https://www.w3.org/TR/html5/syntax.html#character-references
21818 # Note that U+000C (form feed) is not a valid XML character, so
21819 # it is banned even though allowed in HTML5.
21820 !! test
21821 Illegal character references (T106578)
21822 !! wikitext
21823 ; Null: &#00;
21824 ; FF: &#xC;
21825 ; CR: &#xD;
21826 ; Control (low): &#8;
21827 ; Control (high): &#x7F; &#x9F;
21828 ; Surrogate: &#xD83D;&#xDCA9;
21829 ; This is an okay astral character: &#x1F4A9;
21830 !! html+tidy
21831 <dl><dt>Null</dt>
21832 <dd>&amp;#00;</dd>
21833 <dt>FF</dt>
21834 <dd>&amp;#xC;</dd>
21835 <dt>CR</dt>
21836 <dd>&amp;#xD;</dd>
21837 <dt>Control (low)</dt>
21838 <dd>&amp;#8;</dd>
21839 <dt>Control (high)</dt>
21840 <dd>&amp;#x7F; &amp;#x9F;</dd>
21841 <dt>Surrogate</dt>
21842 <dd>&amp;#xD83D;&amp;#xDCA9;</dd>
21843 <dt>This is an okay astral character</dt>
21844 <dd>&#x1f4a9;</dd></dl>
21845 !! end
21846
21847 !! test
21848 __FORCETOC__ override
21849 !! wikitext
21850 __NEWSECTIONLINK__
21851 __FORCETOC__
21852 !! html/php
21853 <p><br />
21854 </p>
21855 !! end
21856
21857 !! test
21858 ISBN code coverage
21859 !! wikitext
21860 ISBN 978-0-1234-56&#x20;789
21861 !! html/php
21862 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a>&#x20;789
21863 </p>
21864 !! html/parsoid
21865 <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>
21866 !! end
21867
21868 !! test
21869 ISBN followed by 5 spaces
21870 !! wikitext
21871 ISBN
21872 !! html
21873 <p>ISBN
21874 </p>
21875 !! end
21876
21877 !! test
21878 Double ISBN
21879 !! wikitext
21880 ISBN ISBN 1234567890
21881 !! html/php
21882 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21883 </p>
21884 !! html/parsoid
21885 <p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
21886 !! end
21887
21888 # Uppercase X and lowercase x as well
21889 !! test
21890 ISBN with an X
21891 !! wikitext
21892 ISBN 3-462-04561-X
21893 ISBN 3-462-04561-x
21894 ISBN 080442957X
21895 ISBN 080442957x
21896 ISBN 978080442957X
21897 ISBN 978080442957x
21898 !! html/php
21899 <p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a>
21900 <a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a>
21901 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a>
21902 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a>
21903 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a>
21904 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
21905 </p>
21906 !! html/parsoid
21907 <p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
21908 <a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
21909 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
21910 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
21911 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
21912 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
21913 !! end
21914
21915 !! test
21916 ISBN with empty prefix (parsoid test)
21917 !! wikitext
21918 ISBN 1234567890
21919 !! html/php
21920 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21921 </p>
21922 !! html/parsoid
21923 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p>
21924 !! end
21925
21926 !! test
21927 T24905: <abbr> followed by ISBN followed by </a>
21928 !! wikitext
21929 <abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
21930 !! html/php
21931 <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>
21932 </p>
21933 !! html/parsoid
21934 <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>
21935 !! end
21936
21937 !! test
21938 Double RFC
21939 !! wikitext
21940 RFC RFC 1234
21941 !! html/php
21942 <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a>
21943 </p>
21944 !! html/parsoid
21945 <p>RFC <a href="https://tools.ietf.org/html/rfc1234" rel="mw:ExtLink" class="external mw-magiclink">RFC 1234</a></p>
21946 !! end
21947
21948 !! test
21949 Double RFC with a wiki link
21950 !! wikitext
21951 RFC [[RFC 1234]]
21952 !! html/php
21953 <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>
21954 </p>
21955 !! html/parsoid
21956 <p>RFC <a rel="mw:WikiLink" href="./RFC_1234" title="RFC 1234">RFC 1234</a></p>
21957 !! end
21958
21959 !! test
21960 RFC code coverage
21961 !! wikitext
21962 RFC 983&#x20;987
21963 !! html/php
21964 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
21965 </p>
21966 !! html/parsoid
21967 <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>
21968 !! end
21969
21970 !! test
21971 Centre-aligned image
21972 !! wikitext
21973 [[Image:foobar.jpg|centre]]
21974 !! html/php
21975 <div class="center"><div class="floatnone"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div></div>
21976
21977 !! html/parsoid
21978 <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>
21979 !! end
21980
21981 !! test
21982 None-aligned image
21983 !! wikitext
21984 [[Image:foobar.jpg|none]]
21985 !! html/php
21986 <div class="floatnone"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
21987
21988 !! html/parsoid
21989 <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>
21990 !! end
21991
21992 !! test
21993 Width + Height sized image (using px) (height is ignored)
21994 !! wikitext
21995 [[Image:foobar.jpg|640x480px]]
21996 !! html/php
21997 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" width="640" height="73" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/960px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/1280px-Foobar.jpg 2x" /></a>
21998 </p>
21999 !! html/parsoid
22000 <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>
22001 !! end
22002
22003 !! test
22004 Width-sized image (using px, no following whitespace)
22005 !! wikitext
22006 [[Image:foobar.jpg|640px]]
22007 !! html/php
22008 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" width="640" height="73" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/960px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/1280px-Foobar.jpg 2x" /></a>
22009 </p>
22010 !! html/parsoid
22011 <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>
22012 !! end
22013
22014 !! test
22015 Width-sized image (using px, with following whitespace - test regression from r39467)
22016 !! wikitext
22017 [[Image:foobar.jpg|640px ]]
22018 !! html/php
22019 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" width="640" height="73" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/960px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/1280px-Foobar.jpg 2x" /></a>
22020 </p>
22021 !! html/parsoid
22022 <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>
22023 !!end
22024
22025 !! test
22026 Width-sized image (using px, with preceding whitespace - test regression from r39467)
22027 !! wikitext
22028 [[Image:foobar.jpg| 640px]]
22029 !! html/php
22030 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" width="640" height="73" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/960px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/1280px-Foobar.jpg 2x" /></a>
22031 </p>
22032 !! html/parsoid
22033 <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>
22034 !! end
22035
22036 !! test
22037 Image with page parameter
22038 !! options
22039 djvu
22040 !! wikitext
22041 [[File:LoremIpsum.djvu|page=2]]
22042 !! html/php
22043 <p><a href="/index.php?title=File:LoremIpsum.djvu&amp;page=2" class="image"><img alt="LoremIpsum.djvu" src="http://example.com/images/thumb/5/5f/LoremIpsum.djvu/page2-2480px-LoremIpsum.djvu.jpg" width="2480" height="3508" srcset="http://example.com/images/thumb/5/5f/LoremIpsum.djvu/page2-3720px-LoremIpsum.djvu.jpg 1.5x, http://example.com/images/thumb/5/5f/LoremIpsum.djvu/page2-4960px-LoremIpsum.djvu.jpg 2x" /></a>
22044 </p>
22045 !! html/parsoid
22046 <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>
22047 !! end
22048
22049 !! test
22050 Another italics / bold test
22051 !! wikitext
22052 ''' ''x'
22053 !! html
22054 <pre>'<i> </i>x'
22055 </pre>
22056 !!end
22057
22058 # FIXME: The php output seems broken. It's interleaving some open/close tags.
22059 !! test
22060 dt/dd/dl test
22061 !! wikitext
22062 :;;;::
22063 !! html/php
22064 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dt></dl></dd></dl></dd></dl></dd></dl></dd></dl></dd></dl>
22065
22066 !! html/parsoid
22067 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dd></dl></dd></dl></dt></dl></dt></dl></dt></dl></dd></dl>
22068
22069 !!end
22070
22071 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
22072 !! test
22073 Images with the "|" character in the comment
22074 !! wikitext
22075 [[File:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
22076 !! html/php
22077 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>An <a rel="nofollow" class="external text" href="http://test/?param1=%7Cleft%7C&amp;param2=%7Cx">external</a> URL</div></div></div>
22078
22079 !! html/parsoid
22080 <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>
22081 !! end
22082
22083 !! test
22084 [Before] HTML without raw HTML enabled ($wgRawHtml==false)
22085 !! wikitext
22086 <html><script>alert(1);</script></html>
22087 !! html
22088 <p>&lt;html&gt;&lt;script&gt;alert(1);&lt;/script&gt;&lt;/html&gt;
22089 </p>
22090 !! end
22091
22092 !! test
22093 HTML with raw HTML ($wgRawHtml==true)
22094 !! options
22095 wgRawHtml=1
22096 !! wikitext
22097 <html><script>alert(1);</script></html>
22098 !! html/php
22099 <p><script>alert(1);</script>
22100 </p>
22101 !! html/parsoid
22102 <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>
22103 !! end
22104
22105 !! test
22106 Parents of subpages, one level up
22107 !! options
22108 subpage title=[[Subpage test/L1/L2/L3]]
22109 !! wikitext
22110 [[../|L2]]
22111 !! html
22112 <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>
22113 </p>
22114 !! end
22115
22116
22117 !! test
22118 Parents of subpages, one level up, not named
22119 !! options
22120 subpage title=[[Subpage test/L1/L2/L3]]
22121 !! wikitext
22122 [[../]]
22123 !! html
22124 <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>
22125 </p>
22126 !! end
22127
22128
22129
22130 !! test
22131 Parents of subpages, two levels up
22132 !! options
22133 subpage title=[[Subpage test/L1/L2/L3]]
22134 !! wikitext
22135 [[../../|L1]]2
22136
22137 [[../../|L1]]l
22138 !! html
22139 <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
22140 </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>
22141 </p>
22142 !! end
22143
22144 !! test
22145 Parents of subpages, two levels up, without trailing slash or name.
22146 !! options
22147 subpage title=[[Subpage test/L1/L2/L3]]
22148 !! wikitext
22149 [[../..]]
22150 !! html
22151 <p>[[../..]]
22152 </p>
22153 !! end
22154
22155 !! test
22156 Parents of subpages, two levels up, with lots of extra trailing slashes.
22157 !! options
22158 subpage title=[[Subpage test/L1/L2/L3]]
22159 !! wikitext
22160 [[../../////]]
22161 !! html
22162 <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>
22163 </p>
22164 !! end
22165
22166 !! article
22167 Subpage test/L1/L2/L3Sibling
22168 !! text
22169 Sibling article
22170 !! endarticle
22171
22172 !! test
22173 Transclusion of a sibling page (one level up)
22174 !! options
22175 subpage title=[[Subpage test/L1/L2/L3]]
22176 !! wikitext
22177 {{../L3Sibling}}
22178 !! html
22179 <p>Sibling article
22180 </p>
22181 !! end
22182
22183 !! test
22184 Transclusion of a child page
22185 !! options
22186 subpage title=[[Subpage test/L1/L2]]
22187 !! wikitext
22188 {{/L3Sibling}}
22189 !! html
22190 <p>Sibling article
22191 </p>
22192 !! end
22193
22194 # This is wt2html only in Parsoid because we add <nowiki>
22195 # because of {{..}} and we don't expect to fix that to
22196 # eliminate the nowikis selective for {{..}} markup.
22197 !! test
22198 Non-transclusion because of too many up levels
22199 !! options
22200 subpage title=[[Subpage test/L1/L2/L3]]
22201 parsoid=wt2html
22202 !! wikitext
22203 {{../../../../More than parent}}
22204 !! html/php
22205 <p>{{../../../../More than parent}}
22206 </p>
22207 !! html/parsoid
22208 <p>{{../../../../More than parent}}</p>
22209 !! end
22210
22211 !! test
22212 Definition list code coverage
22213 !! wikitext
22214 ;title :def
22215 ;title :def
22216 ;title:def
22217 !! html/php
22218 <dl><dt>title</dt>
22219 <dd>def</dd>
22220 <dt>title</dt>
22221 <dd>def</dd>
22222 <dt>title</dt>
22223 <dd>def</dd></dl>
22224
22225 !! html/parsoid
22226 <dl><dt>title </dt><dd>def</dd>
22227 <dt>title </dt><dd>def</dd>
22228 <dt>title</dt><dd>def</dd></dl>
22229 !! end
22230
22231 !! test
22232 Don't fall for the self-closing div
22233 !! wikitext
22234 <div>hello world</div/>
22235 !! html
22236 <div>hello world</div>
22237
22238 !! end
22239
22240 !! test
22241 MSGNW magic word
22242 !! wikitext
22243 {{MSGNW:msg}}
22244 !! html/php
22245 <p>&#91;&#91;:Template:Msg&#93;&#93;
22246 </p>
22247 !! end
22248
22249 !! test
22250 RAW magic word
22251 !! wikitext
22252 {{RAW:QUERTY}}
22253 !! html
22254 <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>
22255 </p>
22256 !! end
22257
22258 # This isn't needed for XHTML conformance, but would be handy as a fallback security measure
22259 !! test
22260 Always escape literal '>' in output, not just after '<'
22261 !! wikitext
22262 ><>
22263 !! html
22264 <p>&gt;&lt;&gt;
22265 </p>
22266 !! end
22267
22268 !! test
22269 Template caching
22270 !! wikitext
22271 {{Test}}
22272 {{Test}}
22273 !! html
22274 <p>This is a test template
22275 This is a test template
22276 </p>
22277 !! end
22278
22279
22280 !! article
22281 MediaWiki:Fake
22282 !! text
22283 ==header==
22284 !! endarticle
22285
22286 !! test
22287 Inclusion of !userCanEdit() content
22288 !! wikitext
22289 {{MediaWiki:Fake}}
22290 !! html
22291 <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>
22292
22293 !! end
22294
22295
22296 !! test
22297 Out-of-order TOC heading levels
22298 !! wikitext
22299 ==2==
22300 ======6======
22301 ===3===
22302 =1=
22303 =====5=====
22304 ==2==
22305 !! html
22306 <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>
22307 <ul>
22308 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
22309 <ul>
22310 <li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
22311 <li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
22312 </ul>
22313 </li>
22314 <li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
22315 <ul>
22316 <li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
22317 <li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
22318 </ul>
22319 </li>
22320 </ul>
22321 </div>
22322
22323 <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>
22324 <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>
22325 <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>
22326 <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>
22327 <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>
22328 <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>
22329
22330 !! end
22331
22332
22333 !! test
22334 ISBN with a dummy number
22335 !! wikitext
22336 ISBN ---
22337 !! html
22338 <p>ISBN ---
22339 </p>
22340 !! end
22341
22342
22343 !! test
22344 ISBN with space-delimited number
22345 !! wikitext
22346 ISBN 92 9017 032 8
22347 !! html/php
22348 <p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a>
22349 </p>
22350 !! html/parsoid
22351 <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>
22352 !! end
22353
22354
22355 !! test
22356 ISBN with multiple spaces, no number
22357 !! wikitext
22358 ISBN foo
22359 !! html
22360 <p>ISBN foo
22361 </p>
22362 !! end
22363
22364
22365 !! test
22366 ISBN length
22367 !! wikitext
22368 ISBN 123456789
22369
22370 ISBN 1234567890
22371
22372 ISBN 12345678901
22373 !! html/php
22374 <p>ISBN 123456789
22375 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
22376 </p><p>ISBN 12345678901
22377 </p>
22378 !! html/parsoid
22379 <p>ISBN 123456789</p>
22380
22381 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
22382
22383 <p>ISBN 12345678901</p>
22384 !! end
22385
22386
22387 !! test
22388 ISBN with trailing year (T9110)
22389 !! wikitext
22390 ISBN 1-234-56789-0 - 2006
22391
22392 ISBN 1 234 56789 0 - 2006
22393 !! html/php
22394 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006
22395 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006
22396 </p>
22397 !! html/parsoid
22398 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p>
22399
22400 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p>
22401 !! end
22402
22403
22404 !! test
22405 anchorencode
22406 !! config
22407 wgFragmentMode=[ 'html5', 'legacy' ]
22408 !! wikitext
22409 {{anchorencode:foo bar©#%n}}
22410 !! html/php
22411 <p>foo_bar©#%n
22412 </p>
22413 !! html/parsoid
22414 <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>
22415 !! end
22416
22417 !! test
22418 anchorencode (legacy)
22419 !! config
22420 wgFragmentMode=[ 'legacy' ]
22421 !! wikitext
22422 {{anchorencode:foo bar©#%n}}
22423 !! html/php
22424 <p>foo_bar.C2.A9.23.25n
22425 </p>
22426 !! end
22427
22428 !! test
22429 anchorencode trims spaces
22430 !! config
22431 wgFragmentMode=[ 'html5', 'legacy' ]
22432 !! wikitext
22433 {{anchorencode: __pretty__please__}}
22434 !! html/php
22435 <p>pretty_please
22436 </p>
22437 !! html/parsoid
22438 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: __pretty__please__","function":"anchorencode"},"params":{},"i":0}}]}'>pretty_please</p>
22439 !! end
22440
22441 !! test
22442 anchorencode deals with links
22443 !! config
22444 wgFragmentMode=[ 'html5', 'legacy' ]
22445 !! wikitext
22446 {{anchorencode: [[hello|world]] [[hi]]}}
22447 !! html/php
22448 <p>world_hi
22449 </p>
22450 !! html/parsoid
22451 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: [[hello|world]] [[hi]]","function":"anchorencode"},"params":{},"i":0}}]}'>world_hi</p>
22452 !! end
22453
22454 !! test
22455 anchorencode deals with templates
22456 !! config
22457 wgFragmentMode=[ 'html5', 'legacy' ]
22458 !! wikitext
22459 {{anchorencode: {{Foo}} x}}
22460 !! html/php
22461 <p>FOO_x
22462 </p>
22463 !! html/parsoid
22464 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: {{Foo}} x","function":"anchorencode"},"params":{},"i":0}}]}'>FOO_x</p>
22465 !! end
22466
22467 !! test
22468 anchorencode encodes like the TOC generator: (T20431)
22469 !! config
22470 wgFragmentMode=[ 'html5', 'legacy' ]
22471 !! wikitext
22472 ===_ +:.3A%3A _ &&amp;]] x===
22473 {{anchorencode: _ +:.3A%3A _ &&amp;]] x}}
22474 __NOEDITSECTION__
22475 !! html/php
22476 <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>
22477 <p>+:.3A%3A_&amp;&amp;&#93;&#93;_x
22478 </p>
22479 !! html/parsoid
22480 <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>
22481 <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>
22482 <meta property="mw:PageProp/noeditsection"/>
22483 !! end
22484
22485 !! test
22486 anchorencode encodes like the TOC generator: (T20431) (legacy)
22487 !! config
22488 wgFragmentMode=[ 'legacy' ]
22489 !! wikitext
22490 ===_ +:.3A%3A&&amp;]]===
22491 {{anchorencode: _ +:.3A%3A&&amp;]] }}
22492 __NOEDITSECTION__
22493 !! html/php
22494 <h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&amp;&amp;]]</span></h3>
22495 <p>.2B:.3A.253A.26.26.5D.5D
22496 </p>
22497 !! end
22498
22499 !! test
22500 T8200: blockquotes and paragraph formatting
22501 !! wikitext
22502 <blockquote>
22503 foo
22504 </blockquote>
22505
22506 bar
22507
22508 baz
22509 !! html
22510 <blockquote>
22511 <p>foo
22512 </p>
22513 </blockquote>
22514 <p>bar
22515 </p>
22516 <pre>baz
22517 </pre>
22518 !! end
22519
22520 !! test
22521 T10293: Use of center tag ruins paragraph formatting
22522 !! wikitext
22523 <center>
22524 foo
22525 </center>
22526
22527 bar
22528
22529 baz
22530 !! html
22531 <center>
22532 <p>foo
22533 </p>
22534 </center>
22535 <p>bar
22536 </p>
22537 <pre>baz
22538 </pre>
22539 !! end
22540
22541 !!test
22542 Parsing of overlapping (improperly nested) inline html tags
22543 !! wikitext
22544 <span><s>x</span></s>
22545 !! html/php
22546 <p><span><s>x&lt;/span&gt;</s></span>
22547 </p>
22548 !! html/parsoid
22549 <p><span><s>x</s></span>
22550 </p>
22551 !!end
22552
22553 ###
22554 ### Language variants related tests
22555 ###
22556
22557 # Parsoid does not mark self-links.
22558 # Parsoid does not convert links; PHP will do any necessary redirects.
22559
22560 !! test
22561 Self-link in language variants
22562 !! options
22563 title=[[Dunav]] language=sr
22564 !! wikitext
22565 Both [[Dunav]] and [[Дунав]] are names for this river.
22566 !! html/php
22567 <p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
22568 </p>
22569 !! html/parsoid
22570 <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>
22571 !! end
22572
22573 !! article
22574 Дуна
22575 !! text
22576 content
22577 !! endarticle
22578
22579 !! test
22580 Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
22581 !! options
22582 title=[[Duna]] language=sr
22583 !! wikitext
22584 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
22585 !! html/php
22586 <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.
22587 </p>
22588 !! html/parsoid
22589 <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>
22590 !! end
22591
22592 !! test
22593 Link to a section of a variant of this title shouldn't be parsed as self-link
22594 !! options
22595 title=[[Duna]] language=sr
22596 !! wikitext
22597 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
22598 !! html/php
22599 <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.
22600 </p>
22601 !! html/parsoid
22602 <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>
22603 !! end
22604
22605 !! test
22606 Link to pages in language variants
22607 !! options
22608 language=sr
22609 !! wikitext
22610 Main Page can be written as [[Маин Паге]]
22611 !! html/php
22612 <p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>
22613 </p>
22614 !! html/parsoid
22615 <p>Main Page can be written as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a></p>
22616 !! end
22617
22618
22619 !! test
22620 Multiple links to pages in language variants
22621 !! options
22622 language=sr
22623 !! wikitext
22624 [[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
22625 !! html/php
22626 <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>.
22627 </p>
22628 !! html/parsoid
22629 <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>
22630 !! end
22631
22632
22633 !! test
22634 Simple template in language variants
22635 !! options
22636 language=sr
22637 !! wikitext
22638 {{тест}}
22639 !! html/php
22640 <p>This is a test template
22641 </p>
22642 !! end
22643
22644
22645 !! test
22646 Template with explicit namespace in language variants
22647 !! options
22648 language=sr
22649 !! wikitext
22650 {{Template:тест}}
22651 !! html/php
22652 <p>This is a test template
22653 </p>
22654 !! end
22655
22656
22657 !! test
22658 Basic test for template parameter in language variants
22659 !! options
22660 language=sr
22661 !! wikitext
22662 {{парамтест|param=foo}}
22663 !! html/php
22664 <p>This is a test template with parameter foo
22665 </p>
22666 !! end
22667
22668 !! test
22669 Simple category in language variants
22670 !! options
22671 language=sr cat
22672 !! wikitext
22673 [[Category:МедиаWики Усер'с Гуиде]]
22674 !! html/php
22675 cat=МедиаWики_Усер'с_Гуиде sort=
22676 !! html/parsoid
22677 <link rel="mw:PageProp/Category" href="./Категорија:МедиаWики_Усер'с_Гуиде" data-parsoid='{"stx":"simple","a":{"href":"./Категорија:МедиаWики_Усер&#39;с_Гуиде"},"sa":{"href":"Category:МедиаWики Усер&#39;с Гуиде"}}'/>
22678 !! end
22679
22680 !! article
22681 Category:分类
22682 !! text
22683 blah
22684 !! endarticle
22685
22686 !! article
22687 Category:分類
22688 !! text
22689 blah
22690 !! endarticle
22691
22692 ## We used to, but no longer wt2wt this test since the default serializer
22693 ## will normalize all categories to serialize on their own line.
22694 ## This wikitext usage is going to be fairly uncommon in production and
22695 ## selser will take care of preserving formatting in those scenarios.
22696 !! test
22697 Don't convert blue categorylinks to another variant (T35210)
22698 !! options
22699 cat
22700 language=zh
22701 parsoid=wt2html
22702 !! wikitext
22703 [[A]][[Category:分类]]
22704 !! html/php
22705 cat=分类 sort=
22706 !! html/parsoid
22707 <p><a rel="mw:WikiLink" href="./A" title="A">A</a></p>
22708 <link rel="mw:PageProp/Category" href="./Category:分类"/>
22709 !! end
22710
22711 !! test
22712 Stripping -{}- tags (language variants)
22713 !! options
22714 language=sr
22715 !! wikitext
22716 Latin proverb: -{Ne nuntium necare}-
22717 !! html/php
22718 <p>Latin proverb: Ne nuntium necare
22719 </p>
22720 !! html/parsoid
22721 <p>Latin proverb: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22722 !! end
22723
22724
22725 !! test
22726 Prevent conversion with -{}- tags (language variants)
22727 !! options
22728 language=sr variant=sr-ec
22729 !! wikitext
22730 Latinski: -{Ne nuntium necare}-
22731 !! html/php
22732 <p>Латински: Ne nuntium necare
22733 </p>
22734 !! html/parsoid
22735 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22736 !! end
22737
22738
22739 !! test
22740 Prevent conversion of text with -{}- tags (language variants)
22741 !! options
22742 language=sr variant=sr-ec
22743 !! wikitext
22744 Latinski: -{Ne nuntium necare}-
22745 !! html/php
22746 <p>Латински: Ne nuntium necare
22747 </p>
22748 !! html/parsoid
22749 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22750 !! end
22751
22752
22753 !! test
22754 Prevent conversion of links with -{}- tags (language variants)
22755 !! options
22756 language=sr variant=sr-ec
22757 !! wikitext
22758 -{[[Main Page]]}-
22759 !! html/php
22760 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
22761 </p>
22762 !! html/parsoid
22763 <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>
22764 !! end
22765
22766
22767 !! test
22768 -{}- tags within headlines (within html for parserConvert())
22769 !! config
22770 wgFragmentMode=[ 'html5', 'legacy' ]
22771 !! options
22772 language=sr variant=sr-ec
22773 !! wikitext
22774 ==-{Naslov}-==
22775
22776 Note that even an unprotected headline ID is not affected by language
22777 conversion:
22778
22779 ==Latinski==
22780 !! html/php
22781 <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>
22782 <p>Ноте тхат евен ан унпротецтед хеадлине ИД ис нот аффецтед бy лангуаге
22783 цонверсион:
22784 </p>
22785 <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>
22786
22787 !! html/parsoid
22788 <h2 id="-{Naslov}-"><span id="-.7BNaslov.7D-" typeof="mw:FallbackId"></span><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Naslov"}}'></span></h2>
22789
22790 <p>Note that even an unprotected headline ID is not affected by language
22791 conversion:</p>
22792
22793 <h2 id="Latinski">Latinski</h2>
22794 !! end
22795
22796 !! test
22797 Explicit definition of language variant alternatives
22798 !! options
22799 language=zh variant=zh-tw
22800 !! wikitext
22801 -{zh:China;zh-tw:Taiwan}-, not China
22802 !! html/php
22803 <p>Taiwan, not China
22804 </p>
22805 !! html/parsoid
22806 <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>
22807 !! end
22808
22809 !! test
22810 Filter syntax for language variants
22811 !! options
22812 language=zh variant=zh-tw
22813 !! wikitext
22814 foo-{zh;zh-hans;zh-hant|blog, WEBJOURNAL, WEBLOG}-quux
22815 !! html/php
22816 <p>fooblog, WEBJOURNAL, WEBLOGquux
22817 </p>
22818 !! html/parsoid
22819 <p>foo<span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"blog, WEBJOURNAL, WEBLOG"}}'></span>quux</p>
22820 !! end
22821
22822 # Note that Parsoid post-processing for language variants needs to
22823 # update the `title` attribute here, based on the mw:ExpandedAttrs property
22824 !! test
22825 Conversion around HTML tags
22826 !! options
22827 language=sr variant=sr-ec
22828 !! wikitext
22829 -{H|span=>sr-ec:script;title=>sr-ec:src}-
22830 <span title="La-{sr-el:L;sr-ec:C}-tin">ski</span>
22831 !! html/php
22832 <p>
22833 <span title="ЛаCтин">ски</span>
22834 </p>
22835 !! html/parsoid
22836 <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"}]}'/>
22837 <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>
22838 !! end
22839
22840 !! test
22841 Explicit session-wise two-way language variant mapping (A flag and - flag)
22842 !! options
22843 language=zh variant=zh-tw
22844 !! wikitext
22845 This is -{zh:China; zh-tw:Taiwan}-, but we'll forget that now.
22846
22847 Taiwan is not China.
22848
22849 But -{A|zh:China; zh-tw:Taiwan}- is China,
22850
22851 (This-{-|zh:China; zh-tw:Taiwan}- should be stripped!)
22852
22853 and -{China}- is China.
22854 !! html/php
22855 <p>This is Taiwan, but we'll forget that now.
22856 </p><p>Taiwan is not China.
22857 </p><p>But Taiwan is Taiwan,
22858 </p><p>(This should be stripped!)
22859 </p><p>and China is China.
22860 </p>
22861 !! html/parsoid
22862 <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>
22863 <p>Taiwan is not China.</p>
22864 <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>
22865 <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>
22866 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"China"}}'></span> is China.</p>
22867 !! end
22868
22869 !! test
22870 Explicit session-wise one-way language variant mapping (A flag and - flag)
22871 !! options
22872 language=zh variant=zh-tw
22873 !! wikitext
22874 This is -{COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}-, but we'll forget that now.
22875
22876 COUNTRY is China or Taiwan.
22877
22878 But -{A|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- is COUNTRY,
22879
22880 (This-{-|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
22881
22882 and -{COUNTRY}- is COUNTRY.
22883 !! html/php
22884 <p>This is Taiwan, but we'll forget that now.
22885 </p><p>COUNTRY is China or Taiwan.
22886 </p><p>But Taiwan is Taiwan,
22887 </p><p>(This should be stripped!)
22888 </p><p>and COUNTRY is COUNTRY.
22889 </p>
22890 !! html/parsoid
22891 <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>
22892 <p>COUNTRY is China or Taiwan.</p>
22893 <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>
22894 <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>
22895 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"COUNTRY"}}'></span> is COUNTRY.</p>
22896 !! end
22897
22898 !! test
22899 Explicit session-wise two-way language variant mapping (H flag for hide)
22900 !! options
22901 language=zh variant=zh-tw
22902 !! wikitext
22903 (This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
22904
22905 Taiwan is China.
22906 !! html/php
22907 <p>(This should be stripped!)
22908 </p><p>Taiwan is Taiwan.
22909 </p>
22910 !! html/parsoid
22911 <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>
22912 <p>Taiwan is China.</p>
22913 !! end
22914
22915 !! test
22916 Explicit session-wise one-way language variant mapping (H flag for hide)
22917 !! options
22918 language=zh variant=zh-tw
22919 !! wikitext
22920 (This-{H|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
22921
22922 COUNTRY is Taiwan or China.
22923 !! html/php
22924 <p>(This should be stripped!)
22925 </p><p>Taiwan is Taiwan or China.
22926 </p>
22927 !! html/parsoid
22928 <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>
22929 <p>COUNTRY is Taiwan or China.</p>
22930 !! end
22931
22932 ## Note that parsoid test runner does not support 'showtitle' option.
22933 !! test
22934 Adding explicit conversion rule for title (T flag)
22935 !! options
22936 language=zh variant=zh-tw showtitle
22937 !! wikitext
22938 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
22939
22940 Taiwan is China.
22941 !! html/php
22942 Taiwan
22943 <p>Should be stripped!
22944 </p><p>Taiwan is China.
22945 </p>
22946 !! html/parsoid
22947 <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>
22948 <p>Taiwan is China.</p>
22949 !! end
22950
22951 !! test
22952 Code coverage: T combined with H flag
22953 !! options
22954 language=zh variant=zh-tw showtitle
22955 !! wikitext
22956 Should be stripped-{T;H|zh:China; zh-tw:Taiwan}-!
22957
22958 Taiwan is China.
22959 !! html/php
22960 Taiwan
22961 <p>Should be stripped!
22962 </p><p>Taiwan is Taiwan.
22963 </p>
22964 !! html/parsoid
22965 <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>
22966 <p>Taiwan is China.</p>
22967 !! end
22968
22969 !! test
22970 Code coverage: T with no variants
22971 !! options
22972 language=zh variant=zh-tw showtitle
22973 !! wikitext
22974 -{H|zh:China; zh-tw:Taiwan}-
22975 Taiwan is China.-{T|Taiwan is China}-
22976 !! html/php
22977 Taiwan is China
22978 <p>
22979 Taiwan is Taiwan.
22980 </p>
22981 !! html/parsoid
22982 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
22983 Taiwan is China.<meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Taiwan is China"},"title":true}'/></p>
22984 !! end
22985
22986 !! test
22987 Code coverage: rules with no variants
22988 !! options
22989 language=zh variant=zh-tw
22990 !! wikitext
22991 -{H|zh:China; zh-tw:Taiwan}-
22992 Taiwan is China.
22993 -{H|China}-
22994 Taiwan is China.
22995 !! html/php
22996 <p>
22997 Taiwan is Taiwan.
22998
22999 Taiwan is China.
23000 </p>
23001 !! html/parsoid
23002 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
23003 Taiwan is China.
23004 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":"China"}]}'/>
23005 Taiwan is China.</p>
23006 !! end
23007
23008
23009 !! test
23010 Code coverage: D flag for conversion rule
23011 !! options
23012 language=zh variant=zh-tw
23013 !! wikitext
23014 -{D|zh-cn:XA; zh-tw:YA}-
23015 -{A;D|zh-cn:XB; zh-tw:YB}-
23016 -{D;H|zh-cn:XC; zh-tw:YC}-
23017
23018 -{D;H|FOO=>zh-tw:BAR;FOO=>zh-cn:BAT}-
23019
23020 -{D|0=>zh-tw:1}-
23021 -{A;D|2=>zh-tw:3}-
23022 -{D;H|4=>zh-tw:5}-
23023
23024 XA XB XC YA YB YC FOO BAR BAT 012345
23025 !! html/php
23026 <p>大陆:XA;台灣:YA;
23027
23028 大陆:XC;台灣:YC;
23029 </p><p>FOO⇒台灣:BAR;FOO⇒大陆:BAT;
23030 </p><p>0⇒台灣:1;
23031
23032 4⇒台灣:5;
23033 </p><p>XA YB YC YA YB YC BAR BAR BAT 013355
23034 </p>
23035 !! html/parsoid
23036 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"twoway":[{"l":"zh-cn","t":"XA"},{"l":"zh-tw","t":"YA"}]}'></span>
23037 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XB"},{"l":"zh-tw","t":"YB"}]}'/>
23038 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XC"},{"l":"zh-tw","t":"YC"}]}'></span></p>
23039 <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>
23040 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"oneway":[{"f":"0","l":"zh-tw","t":"1"}]}'></span>
23041 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"2","l":"zh-tw","t":"3"}]}'/>
23042 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"4","l":"zh-tw","t":"5"}]}'></span></p>
23043 <p>XA XB XC YA YB YC FOO BAR BAT 012345</p>
23044 !! end
23045
23046 !! test
23047 Code coverage: N flag for conversion rule
23048 !! options
23049 language=zh variant=zh-cn
23050 !! wikitext
23051 -{N|zh-cn}-
23052
23053 -{N|zh-tw}-
23054
23055 -{N|sr-ec}-
23056 !! html/php
23057 <p>大陆
23058 </p><p>台灣
23059 </p><p>српски (ћирилица)‎
23060 </p>
23061 !! html/parsoid
23062 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-cn"}}'></span></p>
23063 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-tw"}}'></span></p>
23064 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"sr-ec"}}'></span></p>
23065 !! end
23066
23067 # html2wt suppresses the bogus 'D' flag, so this is wt2html only
23068 !! test
23069 Code coverage: N flag for conversion rule (wt2html only)
23070 !! options
23071 language=zh variant=zh-cn
23072 parsoid=wt2html,html2html
23073 !! wikitext
23074 -{D;N|en}-
23075 !! html/php
23076 <p>English
23077 </p>
23078 !! html/parsoid
23079 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"en"}}' data-parsoid='{"fl":["D","N"]}'></span></p>
23080 !! end
23081
23082 !! test
23083 Testing that changing the language variant here in the tests actually works
23084 !! options
23085 language=zh variant=zh showtitle
23086 !! wikitext
23087 Should be stripped-{T|zh:China; zh-tw:Taiwan}-!
23088 !! html/php
23089 China
23090 <p>Should be stripped!
23091 </p>
23092 !! html/parsoid
23093 <p>Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
23094 !! end
23095
23096 !! test
23097 Recursive conversion of alt and title attrs shouldn't clear converter state
23098 !! options
23099 language=zh variant=zh-cn
23100 showtitle
23101 !! wikitext
23102 -{H|zh-cn:Exclamation; zh-tw:exclamation}-
23103 Should be stripped-{T|zh-cn:China; zh-tw:Taiwan}-<span title="exclamation">!</span>
23104 !! html/php
23105 China
23106 <p>
23107 Should be stripped<span title="Exclamation">!</span>
23108 </p>
23109 !! html/parsoid
23110 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh-cn","t":"Exclamation"},{"l":"zh-tw","t":"exclamation"}]}'/>
23111 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>
23112 !! end
23113
23114 !! test
23115 T26072: more test on conversion rule for title
23116 !! options
23117 language=zh variant=zh-tw showtitle
23118 !! wikitext
23119 This should be stripped-{T|zh:China; zh-tw:Taiwan}-!
23120
23121 This won't take interferes with the title rule-{H|zh:Beijing; zh-tw:Taipei}-.
23122 !! html/php
23123 Taiwan
23124 <p>This should be stripped!
23125 </p><p>This won't take interferes with the title rule.
23126 </p>
23127 !! html/parsoid
23128 <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>
23129 <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>
23130 !! end
23131
23132 !! test
23133 Partly disable title conversion if variant == main language code
23134 !! options
23135 language=zh variant=zh title=[[ZH]] showtitle
23136 !! wikitext
23137 -{T|zh-cn:CN;zh-tw:TW}-
23138 !! html/php
23139 ZH
23140 <p>
23141 </p>
23142 !! html/parsoid
23143 <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>
23144 !! end
23145
23146 !! test
23147 Partly disable title conversion if variant == main language code, more
23148 !! options
23149 language=zh variant=zh title=[[ZH]] showtitle
23150 !! wikitext
23151 -{T|TW}-
23152 !! html/php
23153 ZH
23154 <p>
23155 </p>
23156 !! html/parsoid
23157 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"TW"},"title":true}'/></p>
23158 !! end
23159
23160 !! test
23161 Raw output of variant escape tags (R flag)
23162 !! options
23163 language=zh variant=zh-tw
23164 !! wikitext
23165 Raw: -{R|zh:China;zh-tw:Taiwan}-
23166 !! html/php
23167 <p>Raw: zh:China;zh-tw:Taiwan
23168 </p>
23169 !! html/parsoid
23170 <p>Raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"zh:China;zh-tw:Taiwan"}}'></span></p>
23171 !! end
23172
23173 # html2wt suppresses the bogus 'D' flags, so this is wt2html only
23174 !! test
23175 Raw output of variant escape tags (R flag) (wt2html only)
23176 !! options
23177 language=zh variant=zh-tw
23178 parsoid=wt2html,html2html
23179 !! wikitext
23180 -{Variant}- -{D|syntax}- -{D;R|options}-
23181 !! html/php
23182 <p>Variant syntax options
23183 </p>
23184 !! html/parsoid
23185 <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>
23186 !! end
23187
23188 !! test
23189 Nested markup inside raw output of variant escape tags (R flag)
23190 !! options
23191 language=zh variant=zh-tw
23192 !! wikitext
23193 Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
23194 !! html/php
23195 <p>Nested raw: nested Taiwan nested
23196 </p>
23197 !! html/parsoid
23198 <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>
23199 !! end
23200
23201 !! test
23202 Nested markup and spaces inside raw output of variant escape tags (R flag)
23203 !! options
23204 language=zh variant=zh-tw
23205 !! wikitext
23206 X-{ outer -{ inner }- outer }-X
23207 !! html/php
23208 <p>X outer inner outer X
23209 </p>
23210 !! html/parsoid
23211 <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>
23212 !! end
23213
23214 !! test
23215 Templates inside raw output of variant escape tags (R flag)
23216 !! options
23217 language=zh variant=zh-tw
23218 !! wikitext
23219 Nested raw: -{R|nested {{echo|hi}} templates}-
23220 !! html/php
23221 <p>Nested raw: nested hi templates
23222 </p>
23223 !! html/parsoid
23224 <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>
23225 !! end
23226
23227 !! test
23228 Strings evaluating false shouldn't be ignored by Language converter (T51072)
23229 !! options
23230 language=zh variant=zh-cn
23231 !! wikitext
23232 -{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
23233 !! html/php
23234 <p>0
23235 </p>
23236 !! html/parsoid
23237 <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>
23238 !! end
23239
23240 !! test
23241 Conversion rules from [numeric-only string] to [something else] (T48634)
23242 !! options
23243 language=zh variant=zh-cn
23244 !! wikitext
23245 -{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
23246 !! html/php
23247 <p>D12345EE12345
23248 </p>
23249 !! html/parsoid
23250 <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>
23251 !! end
23252
23253 !! test
23254 Two-way converter rule entries with an empty value should be ignored (T53551)
23255 !! options
23256 language=zh variant=zh-cn
23257 !! wikitext
23258 -{H|zh-cn:foo;zh-tw:;}-foobar
23259 !! html/php
23260 <p>foobar
23261 </p>
23262 !! html/parsoid
23263 <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>
23264 !! end
23265
23266 !! test
23267 One-way converter rule entries with an empty "from" string should be ignored (T53551)
23268 !! options
23269 language=zh variant=zh-cn
23270 !! wikitext
23271 -{H|=>zh-cn:foo;}-foobar
23272 !! html/php
23273 <p>foobar
23274 </p>
23275 !! html/parsoid
23276 <p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[5]}' data-mw-variant='{"add":true,"oneway":[{"f":"","l":"zh-cn","t":"foo"}]}'/>foobar</p>
23277 !! end
23278
23279 !! test
23280 Empty converter rule entries shouldn't be inserted into the conversion table (T53551)
23281 !! options
23282 language=zh variant=zh-cn
23283 !! wikitext
23284 -{H|}-foobar
23285 !! html/php
23286 <p>foobar
23287 </p>
23288 !! html/parsoid
23289 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":""}]}'/>foobar</p>
23290 !! end
23291
23292 !! test
23293 Nested using of manual convert syntax
23294 !! options
23295 language=zh variant=zh-hk
23296 !! wikitext
23297 Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
23298 !! html/php
23299 <p>Nested: Hello Hong Kong!
23300 </p>
23301 !! html/parsoid
23302 <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>
23303 !! end
23304
23305 !! test
23306 HTML markups with conversion syntax in attribs, nested in other conversion blocks
23307 !! options
23308 language=zh variant=zh-cn
23309 !! wikitext
23310 -{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}-
23311 !! html/php
23312 <p><span title="X">A</span>
23313 </p>
23314 !! html/parsoid
23315 <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>
23316 !! end
23317
23318 !! test
23319 HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet in PHP parser)
23320 !! options
23321 language=zh variant=zh-cn
23322 !! wikitext
23323 -{<span title="-{X}-">A</span>}-
23324 !! html/php+disabled
23325 <p><span title="X">A</span>
23326 </p>
23327 !! html/parsoid
23328 <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>
23329 !! end
23330
23331 # Parsoid and PHP disagree on how to parse this example: Parsoid
23332 # insists that the content of a language converter element be a valid
23333 # DOM fragment or attribute string
23334 !! test
23335 Language converter markup with block content
23336 !! options
23337 language=zh variant=zh-cn
23338 !! wikitext
23339 <span>a-{b<div>c}-d
23340
23341 <span>a-{zh;zh-hans;zh-hant|b<div>c}-d
23342
23343 <span>a-{H|0=>zh-cn:x<span>y;0=>zh-tw:b<div>c}-d
23344 !! html/php+tidy
23345 <span>ab<div>cd
23346 <span>ab<div>cd
23347 <span>ad
23348 </span></div></span></div></span>
23349 !! html/parsoid
23350 <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
23351
23352 <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
23353
23354 <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>
23355 !! end
23356
23357 !! test
23358 LanguageConverter selser (1)
23359 !! options
23360 language=zh variant=zh-cn
23361 parsoid={
23362 "modes": ["wt2wt", "selser"],
23363 "changes": [
23364 ["span[typeof]", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
23365 ]
23366 }
23367 !! wikitext
23368 -{raw}-
23369 !! wikitext/edited
23370 -{edited}-
23371 !! end
23372
23373 !! test
23374 LanguageConverter selser (2)
23375 !! options
23376 language=zh variant=zh-cn
23377 parsoid={
23378 "modes": ["wt2wt", "selser"],
23379 "changes": [
23380 ["span[class='x']", "contents", "text", "-{foo}-"],
23381 ["a", "contents", "text", "-{"],
23382 ["span[typeof]", "attr", "data-mw", "{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"-{\"}},\"i\":0}}]}"]
23383 ]
23384 }
23385 !! wikitext
23386 <span class="x">TEXT1</span>
23387 [http://example.com TEXT2]
23388 [[Foo|TEXT3]]
23389 {{echo|TEXT4}}
23390 !! wikitext/edited
23391 <span class="x"><nowiki>-{foo}-</nowiki></span>
23392 [http://example.com -{]
23393 [[Foo|<nowiki>-{</nowiki>]]
23394 {{1x|<nowiki>-{</nowiki>}}
23395 !! end
23396
23397 # Tests LanguageVariantText in ConstrainedText
23398 !! test
23399 LanguageConverter selser (3)
23400 !! options
23401 language=zh variant=zh-cn
23402 parsoid={
23403 "modes": ["wt2wt", "selser"],
23404 "changes": [
23405 ["td > span", "attr", "typeof", "mw:LanguageVariant"],
23406 ["td > span", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
23407 ]
23408 }
23409 !! wikitext
23410 {|
23411 |-
23412 |<span>Foo</span>
23413 |}
23414 !! wikitext/edited
23415 {|
23416 |-
23417 |<nowiki/>-{edited}-
23418 |}
23419 !! end
23420
23421 # Tests LanguageVariantText._fromSelSer
23422 !! test
23423 LanguageConverter selser (4)
23424 !! options
23425 language=zh variant=zh-cn
23426 parsoid={
23427 "modes": ["wt2wt", "selser"],
23428 "changes": [
23429 ["td > span.x", "remove"]
23430 ]
23431 }
23432 !! wikitext
23433 {|
23434 |-
23435 |<span class="x">Foo</span>-{Bar}-
23436 ||<span class="x">Foo</span>-{Bar}-
23437 |}
23438 !! wikitext/edited
23439 {|
23440 |-
23441 |<nowiki/>-{Bar}-
23442 ||-{Bar}-
23443 |}
23444 !! end
23445
23446 # Since Parsoid is starting to emit canonical wikitext for links,
23447 # [http://example.com http://example.com] will not RT back to that
23448 # form anymore.
23449 # Parsoid does not language-convert links (it is done in a
23450 # post-processing step)
23451 !! test
23452 Proper conversion of text in external links
23453 !! options
23454 language=sr variant=sr-ec
23455 parsoid=wt2html
23456 !! wikitext
23457 http://www.google.com
23458 gopher://www.google.com
23459 [http://www.google.com http://www.google.com]
23460 [gopher://www.google.com gopher://www.google.com]
23461 [https://www.google.com irc://www.google.com]
23462 [ftp://www.google.com www.google.com/ftp://dir]
23463 [//www.google.com www.google.com]
23464 !! html/php
23465 <p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
23466 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
23467 <a rel="nofollow" class="external text" href="http://www.google.com">http://www.google.com</a>
23468 <a rel="nofollow" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
23469 <a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
23470 <a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
23471 <a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
23472 </p>
23473 !! html/parsoid
23474 <p><a rel="mw:ExtLink" class="external free" href="http://www.google.com">http://www.google.com</a>
23475 <a rel="mw:ExtLink" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
23476 <a rel="mw:ExtLink" class="external text" href="http://www.google.com">http://www.google.com</a>
23477 <a rel="mw:ExtLink" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
23478 <a rel="mw:ExtLink" class="external text" href="https://www.google.com">irc://www.google.com</a>
23479 <a rel="mw:ExtLink" class="external text" href="ftp://www.google.com">www.google.com/ftp://dir</a>
23480 <a rel="mw:ExtLink" class="external text" href="//www.google.com">www.google.com</a></p>
23481 !! end
23482
23483 !! test
23484 Do not convert roman numbers to language variants
23485 !! options
23486 language=sr variant=sr-ec
23487 !! wikitext
23488 Fridrih IV je car.
23489 !! html/php
23490 <p>Фридрих IV је цар.
23491 </p>
23492 !! html/parsoid
23493 <p>Fridrih IV je car.</p>
23494 !! end
23495
23496 !! test
23497 Unclosed language converter markup "-{"
23498 !! options
23499 language=sr
23500 !! wikitext
23501 -{T|hello
23502 !! html
23503 <p>-{T|hello
23504 </p>
23505 !! end
23506
23507 !! test
23508 Don't convert raw rule "-{R|=&gt;}-" to "=>"
23509 !! options
23510 language=sr
23511 !! wikitext
23512 -{R|=&gt;}-
23513 !! html/php
23514 <p>=&gt;
23515 </p>
23516 !! html/parsoid
23517 <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>
23518 !!end
23519
23520 !! test
23521 Don't break link parsing if language converter markup is in the caption.
23522 !! options
23523 language=sr variant=sr-ec
23524 !! wikitext
23525 [[Main Page|-{R|main page}-]]
23526 !! html/php
23527 <p><a href="/wiki/Main_Page" title="Маин Паге">main page</a>
23528 </p>
23529 !! html/parsoid
23530 <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>
23531 !! end
23532
23533 !! test
23534 T146304: Don't break template parsing if language converter markup is in the parameter.
23535 !! options
23536 language=sr variant=sr-ec
23537 !! wikitext
23538 {{echo|-{R|foo}-}}
23539 !! html/php
23540 <p>foo
23541 </p>
23542 !! html/parsoid
23543 <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>
23544 !! end
23545
23546 !! test
23547 T146305: Don't break image parsing if language converter markup is in the caption.
23548 !! options
23549 language=sr
23550 !! wikitext
23551 [[Датотека:Foobar.jpg|thumb|-{R|caption:}-]]
23552 !! html/php
23553 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/%D0%94%D0%B0%D1%82%D0%BE%D1%82%D0%B5%D0%BA%D0%B0:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/%D0%94%D0%B0%D1%82%D0%BE%D1%82%D0%B5%D0%BA%D0%B0:Foobar.jpg" class="internal" title="Повећајте"></a></div>caption:</div></div></div>
23554
23555 !! html/parsoid
23556 <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>
23557 !! end
23558
23559 !! test
23560 T146305: Don't break image parsing if nested language converter markup is in the caption.
23561 !! options
23562 language=zh variant=zh-cn
23563 !! wikitext
23564 [[File:Foobar.jpg|thumb|-{|zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
23565 !! html/php
23566 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="放大"></a></div>blog (hk: WEBJOURNAL, tw: WEBLOG)</div></div></div>
23567
23568 !! html/parsoid
23569 <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>
23570 !! end
23571
23572 # XXX html2wt disabled because rich markup in alt is not preserved.
23573 !! test
23574 Don't break gallery if language converter markup is inside.
23575 !! options
23576 language=zh
23577 !! wikitext
23578 <gallery>
23579 File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-
23580 File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt
23581 </gallery>
23582 !! html/php
23583 <ul class="gallery mw-gallery-traditional">
23584 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
23585 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="bat" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
23586 <div class="gallerytext">
23587 <p><a href="/wiki/File:Foobar.jpg" class="image" title="bar"><img alt="foo" src="http://example.com/images/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg" width="20" height="2" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/30px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/40px-Foobar.jpg 2x" /></a>
23588 </p>
23589 </div>
23590 </div></li>
23591 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
23592 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
23593 <div class="gallerytext">
23594 <p>This is a test template
23595 </p>
23596 </div>
23597 </div></li>
23598 </ul>
23599
23600 !! html/parsoid
23601 <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"}}'>
23602 <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>
23603 <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>
23604 </ul>
23605 !! end
23606
23607 !! test
23608 T153135: Don't break list handling if language converter markup is in the item.
23609 !! options
23610 language=zh variant=zh-cn
23611 !! wikitext
23612 ;-{zh-cn:AAA;zh-tw:BBB}-
23613 ;-{R|foo:bar}-
23614 !! html/php
23615 <dl><dt>AAA</dt>
23616 <dt>foo:bar</dt></dl>
23617
23618 !! html/parsoid
23619 <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>
23620 <dt data-parsoid='{"dsr":[25,39,1,0]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"foo:bar"}}'></span></dt>
23621 </dl>
23622 !! end
23623
23624 // Note that parsoid does not protect colons unless language converter
23625 // markup is properly nested, because it is a backtracking parser.
23626 !! test
23627 T153135: Unclosed markup in definition list (code coverage)
23628 !! options
23629 language=zh variant=zh-cn
23630 !! wikitext
23631 ;<b>foo:bar
23632 ;-{zh-cn:AAA
23633 !! html/php+tidy
23634 <dl><dt><b>foo:bar</b></dt><b>
23635 <dt>-{zh-cn:AAA</dt></b></dl><p><b>
23636 </b></p>
23637 !! html/parsoid
23638 <dl><dt data-parsoid='{}'><b data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo:bar</b></dt><b data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
23639 <dt data-parsoid='{}'>-{zh-cn</dt><dd data-parsoid='{"stx":"row"}'>AAA</dd></b></dl>
23640 !! end
23641
23642 !! test
23643 T153135: Nested language converter markup in definition list (code coverage)
23644 !! options
23645 language=zh variant=zh-cn
23646 !! wikitext
23647 ;-{|zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
23648 !! html/php
23649 <dl><dt>AAA foo:bar bat:baz</dt>
23650 <dd>def</dd></dl>
23651
23652 !! html/parsoid
23653 <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>
23654 <dd data-parsoid='{"stx":"row","dsr":[49,53,1,0]}'>def</dd>
23655 </dl>
23656 !! end
23657
23658 # html2wt mode disabled due to <nowiki> insertion.
23659 !! test
23660 T153140: Don't break table handling if language converter markup is in the cell.
23661 !! options
23662 language=sr variant=sr-ec
23663 parsoid=wt2html,wt2wt,html2html
23664 !! wikitext
23665 {|
23666 |-
23667 | -{R|B}-
23668 |}
23669 !! html/php
23670 <table>
23671
23672 <tr>
23673 <td>B
23674 </td></tr></table>
23675
23676 !! html/parsoid
23677 <table>
23678 <tbody>
23679 <tr>
23680 <td><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"B"}}'></span></td>
23681 </tr>
23682 </tbody>
23683 </table>
23684 !! end
23685
23686 !! test
23687 Language converter tricky html2wt cases (1)
23688 !! options
23689 language=sr
23690 parsoid=html2wt,wt2wt
23691 !! html/parsoid
23692 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"}-"}}'></span></p>
23693 !! wikitext
23694 -{<nowiki>}-</nowiki>}-
23695 !! html/php
23696 <p>&#125;-
23697 </p>
23698 !! end
23699
23700 !! test
23701 Language converter tricky html2wt cases (2)
23702 !! options
23703 language=sr
23704 parsoid=html2wt,wt2wt
23705 !! html/parsoid
23706 <p>-{foo}-</p>
23707 !! wikitext
23708 <nowiki>-{foo}-</nowiki>
23709 !! html/php
23710 <p>-&#123;foo&#125;-
23711 </p>
23712 !! end
23713
23714 !! test
23715 Language converter tricky html2wt cases (3)
23716 !! options
23717 language=sr
23718 parsoid=html2wt,wt2wt
23719 !! html/parsoid
23720 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"|"}}'></span></p>
23721 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"R|raw"}}'></span></p>
23722 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"-{foo}-"}}'></span></p>
23723 !! wikitext
23724 -{R||}-
23725
23726 -{R|R|raw}-
23727
23728 -{<nowiki>-{foo}-</nowiki>}-
23729 !! html/php
23730 <p>|
23731 </p><p>R|raw
23732 </p><p>-&#123;foo&#125;-
23733 </p>
23734 !! end
23735
23736 !! test
23737 Language converter tricky html2wt cases (4)
23738 !! options
23739 language=sr
23740 parsoid=html2wt,wt2wt
23741 !! html/parsoid
23742 <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>
23743 !! wikitext
23744 -{R|{{echo|hey}}}-
23745 !! html/php
23746 <p>hey
23747 </p>
23748 !! end
23749
23750 # Note that the <nowiki> escaping added by parsoid for source text,
23751 # destination text, and language names only works on the PHP side
23752 # for *destination text*. (HTML entity escaping wouldn't work
23753 # any better.) This is probably a bug, at least for source texts.
23754 # (For language names PHP uses a precise regexp based on the languages
23755 # it currently knows have variants, which is fragile since this set
23756 # can grow/shrink over time.)
23757 !! test
23758 Language converter tricky html2wt cases (5)
23759 !! options
23760 language=zh variant=zh-cn
23761 !! html/parsoid
23762 <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>
23763 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"A","l":"bo:g;us","t":"B"}]}'/></p>
23764 <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>
23765 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"bo:g;us","t":"xyz"},{"l":"zh-cn","t":"abc"}]}'></span></p>
23766 <p>a:b=>c xyz</p>
23767 !! wikitext
23768 -{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
23769
23770 -{H|A=><nowiki>bo:g;us</nowiki>:B}-
23771
23772 -{A|zh-tw:xyz; zh-cn:<nowiki>0;zh-tw:bar</nowiki>}-
23773
23774 -{<nowiki>bo:g;us</nowiki>:xyz; zh-cn:abc}-
23775
23776 a:b=>c xyz
23777 !! html/php+disabled
23778 <p>foobat;xyz=&gt;zh-cn:abc
23779 </p><p>A
23780 </p><p>0;zh-tw:bar
23781 </p><p>abc
23782 </p><p>a:b=&gt;c 0;zh-tw:bar
23783 </p>
23784 !! end
23785
23786 !! test
23787 T179579: Nowiki and lc interaction
23788 !! options
23789 parsoid=wt2html
23790 language=sr
23791 !! wikitext
23792 -{</nowiki>123}-
23793
23794 -{123<nowiki>|</nowiki>456}-
23795 !! html/parsoid
23796 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&amp;lt;/nowiki>123"}}' data-parsoid='{"fl":[],"src":"-{&lt;/nowiki>123}-"}'></span></p>
23797
23798 <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>
23799 !! end
23800
23801 !! test
23802 T2529: Uncovered bullet
23803 !! wikitext
23804 *Foo {{bullet}}
23805 !! html
23806 <ul><li>Foo</li>
23807 <li>Bar</li></ul>
23808
23809 !! end
23810
23811 !! test
23812 T2529: Uncovered bullet in a deeply nested list
23813 !! wikitext
23814 *******Foo {{bullet}}
23815 !! html
23816 <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>
23817 <li>Bar</li></ul>
23818
23819 !! end
23820
23821 !! test
23822 T2529: Uncovered table already at line-start
23823 !! wikitext
23824 x
23825
23826 {{table}}
23827 y
23828 !! html
23829 <p>x
23830 </p>
23831 <table>
23832 <tr>
23833 <td>1</td>
23834 <td>2
23835 </td></tr>
23836 <tr>
23837 <td>3</td>
23838 <td>4
23839 </td></tr></table>
23840 <p>y
23841 </p>
23842 !! end
23843
23844 !! test
23845 T2529: Uncovered bullet in parser function result
23846 !! wikitext
23847 *Foo {{lc:{{bullet}} }}
23848 !! html
23849 <ul><li>Foo</li>
23850 <li>bar</li></ul>
23851
23852 !! end
23853
23854 !! test
23855 T7678: Double-parsed template argument
23856 !! wikitext
23857 {{lc:{{{1}}}|hello}}
23858 !! html
23859 <p>{{{1}}}
23860 </p>
23861 !! end
23862
23863 !! test
23864 T7678: Double-parsed template invocation
23865 !! wikitext
23866 {{lc:{{paramtest {{!}} param = hello }} }}
23867 !! html
23868 <p>{{paramtest | param = hello }}
23869 </p>
23870 !! end
23871
23872 !! test
23873 Case insensitivity of parser functions for non-ASCII characters (T10143)
23874 !! options
23875 language=cs
23876 title=[[Main Page]]
23877 !! wikitext
23878 {{PRVNÍVELKÉ:ěščř}}
23879 {{prvnívelké:ěščř}}
23880 {{PRVNÍMALÉ:ěščř}}
23881 {{prvnímalé:ěščř}}
23882 {{MALÁ:ěščř}}
23883 {{malá:ěščř}}
23884 {{VELKÁ:ěščř}}
23885 {{velká:ěščř}}
23886 !! html
23887 <p>Ěščř
23888 Ěščř
23889 ěščř
23890 ěščř
23891 ěščř
23892 ěščř
23893 ĚŠČŘ
23894 ĚŠČŘ
23895 </p>
23896 !! end
23897
23898 !! test
23899 Morwen/13: Unclosed link followed by heading
23900 !! wikitext
23901 [[link
23902 ==heading==
23903 !! html
23904 <p>[[link
23905 </p>
23906 <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>
23907
23908 !! end
23909
23910 !! test
23911 HHP2.1: Heuristics for headings in preprocessor parenthetical structures
23912 !! wikitext
23913 {{foo|
23914 =heading=
23915 !! html
23916 <p>{{foo|
23917 </p>
23918 <h1><span class="mw-headline" id="heading">heading</span></h1>
23919
23920 !! end
23921
23922 !! test
23923 HHP2.2: Heuristics for headings in preprocessor parenthetical structures
23924 !! wikitext
23925 {{foo|
23926 ==heading==
23927 !! html
23928 <p>{{foo|
23929 </p>
23930 <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>
23931
23932 !! end
23933
23934 !! test
23935 Tildes in comments
23936 !! options
23937 pst
23938 !! wikitext
23939 <!-- ~~~~ -->
23940 !! html/php
23941 <!-- ~~~~ -->
23942 !! end
23943
23944 !! test
23945 Paragraphs inside divs (no extra line breaks)
23946 !! wikitext
23947 <div>Line one
23948
23949 Line two</div>
23950 !! html
23951 <div>Line one
23952 Line two</div>
23953
23954 !! end
23955
23956 !! test
23957 Paragraphs inside divs (extra line break on open)
23958 !! wikitext
23959 <div>
23960 Line one
23961
23962 Line two</div>
23963 !! html
23964 <div>
23965 <p>Line one
23966 </p>
23967 Line two</div>
23968
23969 !! end
23970
23971 !! test
23972 Paragraphs inside divs (extra line break on close)
23973 !! wikitext
23974 <div>Line one
23975
23976 Line two
23977 </div>
23978 !! html
23979 <div>Line one
23980 <p>Line two
23981 </p>
23982 </div>
23983
23984 !! end
23985
23986 !! test
23987 Paragraphs inside divs (extra line break on open and close)
23988 !! wikitext
23989 <div>
23990 Line one
23991
23992 Line two
23993 </div>
23994 !! html
23995 <div>
23996 <p>Line one
23997 </p><p>Line two
23998 </p>
23999 </div>
24000
24001 !! end
24002
24003 # doBlockLevels screws up this output and Remex cleans up as much as it can.
24004 !! test
24005 Nesting tags, paragraphs on lines which begin with <div>
24006 !! wikitext
24007 <div></div><strong>A
24008 B</strong>
24009 !! html/php+tidy
24010 <div></div><p><strong>A
24011 </strong></p><strong></strong><p><strong>B</strong>
24012 </p>
24013 !! html/parsoid
24014 <div data-parsoid='{"stx":"html"}'></div><p><strong data-parsoid='{"stx":"html","autoInsertedEnd":true}'>A</strong></p>
24015 <p><strong data-parsoid='{"stx":"html","autoInsertedStart":true}'>B</strong></p>
24016 !! end
24017
24018 # T8200: <blockquote> should behave like <div> with respect to line breaks
24019 !! test
24020 T8200: paragraphs inside blockquotes (no extra line breaks)
24021 !! wikitext
24022 <blockquote>Line one
24023
24024 Line two</blockquote>
24025 !! html
24026 <blockquote>Line one
24027 Line two</blockquote>
24028
24029 !! html+tidy
24030 <blockquote><p>Line one
24031 Line two</p></blockquote>
24032 !! end
24033
24034 !! test
24035 T8200: paragraphs inside blockquotes (extra line break on open)
24036 !! wikitext
24037 <blockquote>
24038 Line one
24039
24040 Line two</blockquote>
24041 !! html
24042 <blockquote>
24043 <p>Line one
24044 </p>
24045 Line two</blockquote>
24046
24047 !! html+tidy
24048 <blockquote>
24049 <p>Line one
24050 </p><p>
24051 Line two</p></blockquote>
24052 !! end
24053
24054 !! test
24055 T8200: paragraphs inside blockquotes (extra line break on close)
24056 !! wikitext
24057 <blockquote>Line one
24058
24059 Line two
24060 </blockquote>
24061 !! html
24062 <blockquote>Line one
24063 <p>Line two
24064 </p>
24065 </blockquote>
24066
24067 !! html+tidy
24068 <blockquote><p>Line one
24069 </p><p>Line two
24070 </p>
24071 </blockquote>
24072 !! end
24073
24074 !! test
24075 T8200: paragraphs inside blockquotes (extra line break on open and close)
24076 !! wikitext
24077 <blockquote>
24078 Line one
24079
24080 Line two
24081 </blockquote>
24082 !! html
24083 <blockquote>
24084 <p>Line one
24085 </p><p>Line two
24086 </p>
24087 </blockquote>
24088
24089 !! end
24090
24091 ## This is a corner case interaction between the paragraph wrapping in the
24092 ## php parser's BlockLevelPass and Remex. `doBlockLevels` has a notion of
24093 ## some tags which close paragraphs (and thus prevent wrapping on their line),
24094 ## of which "div" is one, but do p-wrapping inside them. These are referred
24095 ## to as "never suppressing". Remex, for its part, doesn't traverse into
24096 ## "div"s to p-wrap. Hence, we only get this partial wrapping.
24097 !! test
24098 Paragraphs inside blockquotes/divs (no extra line breaks)
24099 !! wikitext
24100 <blockquote><div>Line one
24101
24102 Line two</div></blockquote>
24103 !! html
24104 <blockquote><div>Line one
24105 Line two</div></blockquote>
24106
24107 !! end
24108
24109 !! test
24110 Paragraphs inside blockquotes/divs (extra line break on open)
24111 !! wikitext
24112 <blockquote><div>
24113 Line one
24114
24115 Line two</div></blockquote>
24116 !! html
24117 <blockquote><div>
24118 <p>Line one
24119 </p>
24120 Line two</div></blockquote>
24121
24122 !! end
24123
24124 !! test
24125 Paragraphs inside blockquotes/divs (extra line break on close)
24126 !! wikitext
24127 <blockquote><div>Line one
24128
24129 Line two
24130 </div></blockquote>
24131 !! html
24132 <blockquote><div>Line one
24133 <p>Line two
24134 </p>
24135 </div></blockquote>
24136
24137 !! end
24138
24139 !! test
24140 Paragraphs inside blockquotes/divs (extra line break on open and close)
24141 !! wikitext
24142 <blockquote><div>
24143 Line one
24144
24145 Line two
24146 </div></blockquote>
24147 !! html
24148 <blockquote><div>
24149 <p>Line one
24150 </p><p>Line two
24151 </p>
24152 </div></blockquote>
24153
24154 !! end
24155
24156 !! test
24157 Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion
24158 !! options
24159 wgLinkHolderBatchSize=0
24160 !! wikitext
24161 [[meatball:1]]
24162 [[meatball:2]]
24163 [[meatball:3]]
24164 !! html
24165 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?1" class="extiw" title="meatball:1">meatball:1</a>
24166 <a href="http://www.usemod.com/cgi-bin/mb.pl?2" class="extiw" title="meatball:2">meatball:2</a>
24167 <a href="http://www.usemod.com/cgi-bin/mb.pl?3" class="extiw" title="meatball:3">meatball:3</a>
24168 </p>
24169 !! end
24170
24171 !! test
24172 Free external link invading image caption
24173 !! wikitext
24174 [[Image:Foobar.jpg|thumb|http://x|hello]]
24175 !! html/php
24176 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>hello</div></div></div>
24177
24178 !! html/parsoid
24179 <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>
24180 !! end
24181
24182 !! test
24183 T17196: localised external link numbers
24184 !! options
24185 language=fa
24186 !! wikitext
24187 [http://en.wikipedia.org/]
24188 !! html/php
24189 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/">[۱]</a>
24190 </p>
24191 !! html/parsoid
24192 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/"></a></p>
24193 !! end
24194
24195 !! test
24196 Multibyte character in padleft
24197 !! wikitext
24198 {{padleft:-Hello|7|Æ}}
24199 !! html/php
24200 <p>Æ-Hello
24201 </p>
24202 !! html/parsoid
24203 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:-Hello","function":"padleft"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Æ-Hello</p>
24204 !! end
24205
24206 !! test
24207 Multibyte character in padright
24208 !! wikitext
24209 {{padright:Hello-|7|Æ}}
24210 !! html/php
24211 <p>Hello-Æ
24212 </p>
24213 !! html/parsoid
24214 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:Hello-","function":"padright"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Hello-Æ</p>
24215 !! end
24216
24217 !!test
24218 formatdate parser function
24219 !! wikitext
24220 {{#formatdate:2009-03-24}}
24221 !! html
24222 <p><span class="mw-formatted-date" title="2009-03-24">2009-03-24</span>
24223 </p>
24224 !! end
24225
24226 !!test
24227 formatdate parser function, with default format
24228 !! wikitext
24229 {{#formatdate:2009-03-24|mdy}}
24230 !! html
24231 <p><span class="mw-formatted-date" title="2009-03-24">March 24, 2009</span>
24232 </p>
24233 !! end
24234
24235 !! test
24236 Spacing of numbers in formatted dates
24237 !! wikitext
24238 {{#formatdate:January 15}}
24239 !! html
24240 <p><span class="mw-formatted-date" title="01-15">January 15</span>
24241 </p>
24242 !! end
24243
24244 !! test
24245 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
24246 !! options
24247 language=nl title=[[MediaWiki:Common.css]]
24248 !! wikitext
24249 {{#formatdate:2009-03-24|dmy}}
24250 !! html
24251 <p><span class="mw-formatted-date" title="2009-03-24">24 March 2009</span>
24252 </p>
24253 !! end
24254
24255 #
24256 #
24257 #
24258
24259 #
24260 # Edit comments
24261 #
24262
24263 !! test
24264 Edit comment with link
24265 !! options
24266 comment
24267 !! wikitext
24268 I like the [[Main Page]] a lot
24269 !! html/php
24270 I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot
24271 !!end
24272
24273 !! test
24274 Edit comment with link and link text
24275 !! options
24276 comment
24277 !! wikitext
24278 I like the [[Main Page|best pages]] a lot
24279 !! html/php
24280 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
24281 !!end
24282
24283 !! test
24284 Edit comment with link and link text with suffix
24285 !! options
24286 comment
24287 !! wikitext
24288 I like the [[Main Page|best page]]s a lot
24289 !! html/php
24290 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
24291 !!end
24292
24293 !! test
24294 Edit comment with section link (non-local, eg in history list)
24295 !! options
24296 comment title=[[Main Page]]
24297 !! wikitext
24298 /* External links */ removed bogus entries
24299 !! html/php
24300 <a href="/wiki/Main_Page#External_links" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
24301 !!end
24302
24303 !! test
24304 Edit comment with section link and text before it (non-local, eg in history list)
24305 !! options
24306 comment title=[[Main Page]]
24307 !! wikitext
24308 pre-comment text /* External links */ removed bogus entries
24309 !! html/php
24310 pre-comment text <a href="/wiki/Main_Page#External_links" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
24311 !!end
24312
24313 !! test
24314 Edit comment with section link (local, eg in diff view)
24315 !! options
24316 comment local title=[[Main Page]]
24317 !! wikitext
24318 /* External links */ removed bogus entries
24319 !! html/php
24320 <a href="#External_links">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
24321 !!end
24322
24323 !! test
24324 Edit comment with subpage link (T16080)
24325 !! options
24326 comment
24327 subpage
24328 title=[[Subpage test]]
24329 !! wikitext
24330 Poked at a [[/subpage]] here...
24331 !! html/php
24332 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> here...
24333 !!end
24334
24335 !! test
24336 Edit comment with subpage link and link text (T16080)
24337 !! options
24338 comment
24339 subpage
24340 title=[[Subpage test]]
24341 !! wikitext
24342 Poked at a [[/subpage|neat little page]] here...
24343 !! html/php
24344 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">neat little page</a> here...
24345 !!end
24346
24347 !! test
24348 Edit comment with bogus subpage link in non-subpage NS (T16080)
24349 !! options
24350 comment
24351 title=[[Subpage test]]
24352 !! wikitext
24353 Poked at a [[/subpage]] here...
24354 !! html/php
24355 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...
24356 !!end
24357
24358 !! test
24359 Edit comment with bare anchor link (local, as on diff)
24360 !! options
24361 comment
24362 local
24363 title=[[Main Page]]
24364 !! wikitext
24365 [[#section]]
24366 !! html/php
24367 <a href="#section">#section</a>
24368 !! end
24369
24370 !! test
24371 Edit comment with bare anchor link (non-local, as on history)
24372 !! options
24373 comment
24374 title=[[Main Page]]
24375 !! wikitext
24376 [[#section]]
24377 !! html/php
24378 <a href="/wiki/Main_Page#section" title="Main Page">#section</a>
24379 !! end
24380
24381 !! test
24382 Anchor starting with underscore
24383 !! options
24384 title=[[Foo]]
24385 !! wikitext
24386 [[#_ref|One]]
24387 !! html/php
24388 <p><a href="#_ref">One</a>
24389 </p>
24390 !! html/parsoid
24391 <p><a rel="mw:WikiLink" href="./Foo#_ref" data-parsoid='{"stx":"piped","a":{"href":"./Foo#_ref"},"sa":{"href":"#_ref"}}'>One</a></p>
24392 !! end
24393
24394 !! test
24395 Id starting with underscore
24396 !! wikitext
24397 <div id="_ref"></div>
24398 !! html/*
24399 <div id="_ref"></div>
24400
24401 !! end
24402
24403 !! test
24404 Edit comment with link with more than one pipe (T99346)
24405 !! options
24406 comment
24407 !! wikitext
24408 [[Main Page|Many|pipes]]
24409 !! html/php
24410 <a href="/wiki/Main_Page" title="Main Page">Many|pipes</a>
24411 !! end
24412
24413 !! test
24414 Complex edit comment with link with more than one pipe (T99346)
24415 !! options
24416 comment
24417 !! wikitext
24418 Created page with "<noinclude>[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]]</noinclude> === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..."
24419 !! html/php
24420 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;
24421 !! end
24422
24423 !! test
24424 Space normalisation on autocomment (T24784)
24425 !! options
24426 comment
24427 title=[[Main Page]]
24428 !! wikitext
24429 /* __hello__world__ */
24430 !! html/php
24431 <a href="/wiki/Main_Page#hello_world" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">__hello__world__</span></span>
24432 !! end
24433
24434 !! test
24435 percent-encoding and + signs in comments (T28410)
24436 !! options
24437 comment
24438 !! wikitext
24439 [[ABC%33D% ++]] [[ABC%33D% ++|+%20]]
24440 !! html/php
24441 <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>
24442 !! end
24443
24444 # Parsoid doesn't support this yet: see T75581
24445 # but it *should* omit the 'src' attribute if the image is bad.
24446 # PHP side of tests was disabled in
24447 # mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
24448 # because of issues in the PHP parserTests infrastructure
24449 # (but the output below is indeed what the PHP side emits)
24450 !! test
24451 Bad images - basic functionality
24452 !! wikitext
24453 [[File:Bad.jpg]]
24454 !! html/php+disabled
24455 !! html/parsoid
24456 <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>
24457 !! end
24458
24459 !! test
24460 Bad images - T18039: text after bad image disappears
24461 !! wikitext
24462 Foo bar
24463 [[File:Bad.jpg]]
24464 Bar foo
24465 !! html/php+disabled
24466 <p>Foo bar
24467 </p><p>Bar foo
24468 </p>
24469 !! html/parsoid
24470 <p>Foo bar
24471 <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>
24472 Bar foo</p>
24473 !! end
24474
24475 !! test
24476 Verify that displaytitle works (T24501) no displaytitle
24477 !! options
24478 showtitle
24479 !! config
24480 wgAllowDisplayTitle=true
24481 wgRestrictDisplayTitle=false
24482 !! wikitext
24483 this is not the the title
24484 !! html/php
24485 Parser test
24486 <p>this is not the the title
24487 </p>
24488 !! end
24489
24490 !! test
24491 Verify that displaytitle works (T24501) RestrictDisplayTitle=false
24492 !! options
24493 showtitle
24494 title=[[Screen]]
24495 !! config
24496 wgAllowDisplayTitle=true
24497 wgRestrictDisplayTitle=false
24498 !! wikitext
24499 this is not the the title
24500 {{DISPLAYTITLE:whatever}}
24501 !! html/php
24502 whatever
24503 <p>this is not the the title
24504 </p>
24505 !! end
24506
24507 !! test
24508 Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch
24509 !! options
24510 showtitle
24511 title=[[Screen]]
24512 !! config
24513 wgAllowDisplayTitle=true
24514 wgRestrictDisplayTitle=true
24515 !! wikitext
24516 this is not the the title
24517 {{DISPLAYTITLE:whatever}}
24518 !! html/php
24519 Screen
24520 <p>this is not the the title
24521 </p>
24522 !! end
24523
24524 !! test
24525 Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching
24526 !! options
24527 showtitle
24528 title=[[Screen]]
24529 !! config
24530 wgAllowDisplayTitle=true
24531 wgRestrictDisplayTitle=true
24532 !! wikitext
24533 this is not the the title
24534 {{DISPLAYTITLE:screen}}
24535 !! html/php
24536 screen
24537 <p>this is not the the title
24538 </p>
24539 !! end
24540
24541 !! test
24542 Verify that displaytitle works (T24501) AllowDisplayTitle=false
24543 !! options
24544 showtitle
24545 title=[[Screen]]
24546 !! config
24547 wgAllowDisplayTitle=false
24548 !! wikitext
24549 this is not the the title
24550 {{DISPLAYTITLE:screen}}
24551 !! html/php
24552 Screen
24553 <p>this is not the the title
24554 <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>
24555 </p>
24556 !! end
24557
24558 !! test
24559 Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE
24560 !! options
24561 showtitle
24562 title=[[Screen]]
24563 !! config
24564 wgAllowDisplayTitle=false
24565 !! wikitext
24566 this is not the the title
24567 !! html/php
24568 Screen
24569 <p>this is not the the title
24570 </p>
24571 !! end
24572
24573 !! test
24574 Verify that displaytitle handles inline CSS styles (T28547) - rejected value
24575 !! options
24576 showtitle
24577 title=[[Screen]]
24578 !! config
24579 wgAllowDisplayTitle=true
24580 wgRestrictDisplayTitle=true
24581 !! wikitext
24582 this is not the the title
24583 {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
24584 !! html/php
24585 <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
24586 <p>this is not the the title
24587 </p>
24588 !! end
24589
24590 !! test
24591 Verify that displaytitle handles inline CSS styles (T28547) - accepted value
24592 !! options
24593 showtitle
24594 title=[[Screen]]
24595 !! config
24596 wgAllowDisplayTitle=true
24597 wgRestrictDisplayTitle=true
24598 !! wikitext
24599 this is not the the title
24600 {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
24601 !! html/php
24602 <span style="color: red;">s</span>creen
24603 <p>this is not the the title
24604 </p>
24605 !! end
24606
24607 !! test
24608 Page status indicators: Empty name is invalid
24609 !! options
24610 showindicators
24611 !! wikitext
24612 <indicator name=" "></indicator>
24613 <indicator></indicator>
24614 !! html/php
24615 <p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
24616 <span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
24617 </p>
24618 !! end
24619
24620 !! test
24621 Page status indicators: Weird syntaxes that are okay
24622 !! options
24623 showindicators
24624 !! wikitext
24625 <indicator name="empty" />
24626 <indicator name="name"></indicator>
24627 !! html/php
24628 empty=
24629 name=
24630 <p><br />
24631 </p>
24632 !! end
24633
24634 !! test
24635 Page status indicators: Torture test
24636 !! options
24637 showindicators
24638 !! wikitext
24639 <indicator name="01">hello world</indicator>
24640 <indicator name="02">[[Main Page]]</indicator>
24641 <indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator>
24642 <indicator name="04">[[File:Foobar.jpg|25px]]</indicator>
24643 <indicator name="05">*foo
24644 *bar</indicator>
24645 <indicator name="06"><nowiki>foo</nowiki></indicator>
24646 <indicator name="07"> Preformatted</indicator>
24647 <indicator name="08"><div>Broken tag</indicator>
24648 <indicator name="09">{| class=wikitable
24649 |cell
24650 |}</indicator>
24651 <indicator name="10">Two
24652
24653 paragraphs</indicator>
24654 !! html/php
24655 01=hello world
24656 02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
24657 03=<img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/25px-Foobar.jpg" width="25" height="3" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/38px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg 2x" />
24658 04=<a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/25px-Foobar.jpg" width="25" height="3" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/38px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg 2x" /></a>
24659 05=<ul><li>foo</li>
24660 <li>bar</li></ul>
24661
24662 06=foo
24663 07=<pre>Preformatted
24664 </pre>
24665 08=<div>Broken tag</div>
24666
24667 09=<table class="wikitable">
24668 <tr>
24669 <td>cell
24670 </td></tr></table>
24671
24672 10=<p>Two
24673 </p><p>paragraphs
24674 </p>
24675 <p><br />
24676 </p><p><br />
24677 </p><p><br />
24678 </p><p><br />
24679 </p><p><br />
24680 </p>
24681 !! end
24682
24683 !! test
24684 preload: check <noinclude> and <includeonly>
24685 !! options
24686 preload
24687 !! wikitext
24688 Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
24689 !! html/php
24690 Hello kind world.
24691 !! end
24692
24693 !! test
24694 preload: check <onlyinclude>
24695 !! options
24696 preload
24697 !! wikitext
24698 Goodbye <onlyinclude>Hello world</onlyinclude>
24699 !! html/php
24700 Hello world
24701 !! end
24702
24703 !! test
24704 preload: can pass tags through if we want to
24705 !! options
24706 preload
24707 !! wikitext
24708 <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
24709 !! html/php
24710 <includeonly>Hello world</includeonly>
24711 !! end
24712
24713 !! test
24714 preload: check that it doesn't try to do tricks
24715 !! options
24716 preload
24717 !! wikitext
24718 * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
24719 !! html/php
24720 * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
24721 !! end
24722
24723 !! test
24724 Play a bit with r67090 and T5158
24725 !! wikitext
24726 <div style="width:50% !important">&nbsp;</div>
24727 <div style="width:50%&nbsp;!important">&nbsp;</div>
24728 <div style="width:50%&#160;!important">&nbsp;</div>
24729 <div style="border : solid;">&nbsp;</div>
24730 !! html/php
24731 <div style="width:50% !important">&#160;</div>
24732 <div style="width:50% !important">&#160;</div>
24733 <div style="width:50% !important">&#160;</div>
24734 <div style="border&#32;: solid;">&#160;</div>
24735
24736 !! html/parsoid
24737 <div style="width:50% !important" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
24738 <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>
24739 <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>
24740 <div style="border : solid;" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
24741
24742 !! end
24743
24744 !! test
24745 French spaces in wikitext
24746 !! wikitext
24747 foo ! bar ? bat 50 % is less than 75 %.
24748
24749 Hello : this ; is « something ‹ else › again »
24750 !! html
24751 <p>foo&#160;! bar&#160;? bat 50&#160;% is less than 75&#160;%.
24752 </p><p>Hello&#160;: this&#160;; is «&#160;something ‹&#160;else&#160;› again&#160;»
24753 </p>
24754 !! end
24755
24756 # It would be reasonable for Parsoid and PHP to differ here.
24757 # The PHP behavior is arguably a bug.
24758 !! test
24759 Corner case: french spaces in definition list
24760 !! wikitext
24761 ;foo : bar
24762 !! html+tidy
24763 <dl><dt>foo&#160;</dt>
24764 <dd>bar</dd></dl>
24765 !! end
24766
24767 !! test
24768 T5158: Test for French spaces in attributes
24769 !! wikitext
24770 <br style=" clear : both ; " />
24771 !! html/php
24772 <p><br style="clear&#32;: both&#32;;" />
24773 </p>
24774 !! end
24775
24776 !! test
24777 HTML5 data attributes
24778 !! wikitext
24779 <span data-foo="bar">Baz</span>
24780 <p data-abc-def_hij="">Quuz</p>
24781 !! html/php
24782 <p><span data-foo="bar">Baz</span>
24783 </p>
24784 <p data-abc-def_hij="">Quuz</p>
24785
24786 !! html/parsoid
24787 <p><span data-foo="bar" data-parsoid='{"stx":"html"}'>Baz</span></p>
24788 <p data-abc-def_hij="" data-parsoid='{"stx":"html"}'>Quuz</p>
24789 !! end
24790
24791 !! test
24792 Strip reserved data attributes
24793 !! wikitext
24794 <div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
24795 !! html/php
24796 <div data-ok="fred">d</div>
24797
24798 !! html/parsoid
24799 <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>
24800 !! end
24801
24802 !! test
24803 percent-encoding and + signs in internal links (T28410)
24804 !! wikitext
24805 [[User:+%]] [[Page+title%]]
24806 [[%+]] [[%+|%20]] [[%+ ]] [[%+r]]
24807 [[%]] [[+]] [[File:%+abc%39|foo|[[bar]]]]
24808 [[%33%45]] [[%33%45+]]
24809 !! html/php
24810 <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>
24811 <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>
24812 <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>
24813 <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>
24814 </p>
24815 !! html/parsoid
24816 <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>
24817 <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>
24818 <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>
24819 <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>
24820 !! end
24821
24822 !! test
24823 Special characters in embedded file links (T29679)
24824 !! wikitext
24825 [[File:Contains & ampersand.jpg]]
24826 [[File:Does not exist.jpg|Title with & ampersand]]
24827 !! html/php
24828 <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>
24829 <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>
24830 </p>
24831 !! html/parsoid
24832 <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>
24833 <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>
24834 !! end
24835
24836 !! test
24837 Confirm that 'apos' named character reference doesn't make it to output (not legal in HTML 4)
24838 !! wikitext
24839 Text&apos;s been normalized?
24840 !! html
24841 <p>Text&#39;s been normalized?
24842 </p>
24843 !! end
24844
24845 !! test
24846 T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
24847 !! wikitext
24848 http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
24849 !! html
24850 <p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> &lt;-- U+3000 (vim: ^Vu3000)
24851 </p>
24852 !! end
24853
24854 !! test
24855 T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
24856 !! wikitext
24857 [http://www.example.org/ ideograms]
24858 !! html
24859 <p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a>
24860 </p>
24861 !! end
24862
24863 !! test
24864 T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
24865 !! wikitext
24866 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
24867 !! html
24868 <p><img src="http://www.example.org/pic.png" alt="pic.png"/> &lt;-- U+3000 (vim: ^Vu3000)
24869 </p>
24870 !! end
24871
24872 !! article
24873 Mediawiki:loop1
24874 !! text
24875 {{Identical|A}}
24876 !! endarticle
24877
24878 !! article
24879 Mediawiki:loop2
24880 !! text
24881 {{Identical|B}}
24882 !! endarticle
24883
24884 !! article
24885 Template:Identical
24886 !! text
24887 {{int:loop1}}
24888 {{int:loop2}}
24889 !! endarticle
24890
24891 !! test
24892 T33098 Template which includes system messages which includes the template
24893 !! wikitext
24894 {{Identical}}
24895 !! html
24896 <p><span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
24897 <span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
24898 </p>
24899 !! end
24900
24901 !! test
24902 T33490 Turkish: ucfirst 'blah'
24903 !! options
24904 language=tr
24905 !! wikitext
24906 {{ucfirst:blah}}
24907 !! html
24908 <p>Blah
24909 </p>
24910 !! end
24911
24912 !! test
24913 T33490 Turkish: ucfirst 'ix'
24914 !! options
24915 language=tr
24916 !! wikitext
24917 {{ucfirst:ix}}
24918 !! html
24919 <p>İx
24920 </p>
24921 !! end
24922
24923 !! test
24924 T33490 Turkish: lcfirst 'BLAH'
24925 !! options
24926 language=tr
24927 !! wikitext
24928 {{lcfirst:BLAH}}
24929 !! html
24930 <p>bLAH
24931 </p>
24932 !! end
24933
24934 !! test
24935 T33490 Turkish: ucfırst (with a dotless i)
24936 !! options
24937 language=tr
24938 !! wikitext
24939 {{ucfırst:blah}}
24940 !! html
24941 <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>
24942 </p>
24943 !! end
24944
24945 !! test
24946 T33490 ucfırst (with a dotless i) with English language
24947 !! options
24948 language=en
24949 !! wikitext
24950 {{ucfırst:blah}}
24951 !! html
24952 <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>
24953 </p>
24954 !! end
24955
24956 # Note that Parsoid doesn't emit an explicit TOC.
24957 # Note also that the html2wt direction tends to emit an extra newline
24958 # between the __TOC__ magicword and the first heading unless *both*
24959 # the <meta> and the <h2> have a data-parsoid attribute set (even if
24960 # it's "{}").
24961
24962 !! test
24963 T28375: TOC with italics
24964 !! options
24965 title=[[Main Page]]
24966 !! wikitext
24967 __TOC__
24968 ==''Lost'' episodes==
24969 !! html/php
24970 <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>
24971 <ul>
24972 <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>
24973 </ul>
24974 </div>
24975
24976 <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>
24977
24978 !! html/parsoid
24979 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24980 <h2 id="Lost_episodes" data-parsoid='{}'><i>Lost</i> episodes</h2>
24981 !! end
24982
24983 !! test
24984 T28375: TOC with bold
24985 !! options
24986 title=[[Main Page]]
24987 !! wikitext
24988 __TOC__
24989 =='''should be bold''' then normal text==
24990 !! html/php
24991 <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>
24992 <ul>
24993 <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>
24994 </ul>
24995 </div>
24996
24997 <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>
24998
24999 !! html/parsoid
25000 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25001 <h2 id="should_be_bold_then_normal_text" data-parsoid='{}'><b>should be bold</b> then normal text</h2>
25002 !! end
25003
25004 !! test
25005 T35845: Headings become cursive in TOC when they contain an image
25006 !! options
25007 title=[[Main Page]]
25008 !! wikitext
25009 __TOC__
25010 ==Image [[Image:foobar.jpg]]==
25011 !! html/php
25012 <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>
25013 <ul>
25014 <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
25015 </ul>
25016 </div>
25017
25018 <h2><span class="mw-headline" id="Image">Image <a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&amp;action=edit&amp;section=1" title="Edit section: Image">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
25019
25020 !! html/parsoid
25021 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25022 <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>
25023 !! end
25024
25025 !! test
25026 T35845 (2): Headings become bold in TOC when they contain a blockquote
25027 !! options
25028 title=[[Main Page]]
25029 !! wikitext
25030 __TOC__
25031 ==<blockquote>Quote</blockquote>==
25032 !! html/php
25033 <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>
25034 <ul>
25035 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
25036 </ul>
25037 </div>
25038
25039 <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>
25040
25041 !! html/php+tidy
25042 <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>
25043 <ul>
25044 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
25045 </ul>
25046 </div>
25047
25048 <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>
25049 !! html/parsoid
25050 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25051 <h2 id="Quote" data-parsoid='{}'><blockquote><p>Quote</p></blockquote></h2>
25052 !! end
25053
25054 !! test
25055 Unclosed tags in TOC
25056 !! config
25057 wgFragmentMode=[ 'html5', 'legacy' ]
25058 !! options
25059 title=[[Main Page]]
25060 !! wikitext
25061 __TOC__
25062 ==Proof: 2 < 3==
25063 <small>Hanc marginis exiguitas non caperet.</small>
25064 QED
25065 !! html/php
25066 <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>
25067 <ul>
25068 <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>
25069 </ul>
25070 </div>
25071
25072 <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>
25073 <p><small>Hanc marginis exiguitas non caperet.</small>
25074 QED
25075 </p>
25076 !! html/parsoid
25077 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25078 <h2 id="Proof:_2_&lt;_3" data-parsoid='{}'><span id="Proof:_2_.3C_3" typeof="mw:FallbackId"></span>Proof: 2 &lt; 3</h2>
25079 <p><small>Hanc marginis exiguitas non caperet.</small>
25080 QED</p>
25081 !! end
25082
25083 !! test
25084 Multiple tags in TOC
25085 !! wikitext
25086 __TOC__
25087 ==<i>Foo</i> <b>Bar</b>==
25088
25089 ==<i>Foo</i> <blockquote>Bar</blockquote>==
25090 !! html/php
25091 <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>
25092 <ul>
25093 <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>
25094 <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>
25095 </ul>
25096 </div>
25097
25098 <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>
25099 <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>
25100
25101 !! html/php+tidy
25102 <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>
25103 <ul>
25104 <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>
25105 <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>
25106 </ul>
25107 </div>
25108
25109 <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>
25110 <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>
25111 !! html/parsoid
25112 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25113 <h2 id="Foo_Bar" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b></h2>
25114
25115 <h2 id="Foo_Bar_2" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote><p>Bar</p></blockquote></h2>
25116 !! end
25117
25118 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
25119 # html5 tag parsing.
25120 !! test
25121 Tags with parameters in TOC
25122 !! options
25123 parsoid=wt2html
25124 !! wikitext
25125 __TOC__
25126 ==<sup class="in-h2">Hello</sup>==
25127
25128 ==<sup class="a > b">Evilbye</sup>==
25129 !! html/php
25130 <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>
25131 <ul>
25132 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
25133 <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>
25134 </ul>
25135 </div>
25136
25137 <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>
25138 <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>
25139
25140 !! html/parsoid
25141 <meta property="mw:PageProp/toc" />
25142 <h2 id="Hello"><sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup></h2>
25143
25144 <h2 id='b">Evilbye'><span id="b.22.3EEvilbye" typeof="mw:FallbackId"></span><sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup></h2>
25145 !! end
25146
25147 !! test
25148 span tags with directionality in TOC
25149 !! wikitext
25150 __TOC__
25151 ==<span dir="ltr">C++</span>==
25152
25153 ==<span dir="rtl">זבנג!</span>==
25154
25155 ==<span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span>==
25156
25157 ==<span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span>==
25158
25159 ==<span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span>==
25160 !! html/php
25161 <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>
25162 <ul>
25163 <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>
25164 <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>
25165 <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>
25166 <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>
25167 <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>
25168 </ul>
25169 </div>
25170
25171 <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>
25172 <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>
25173 <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>
25174 <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>
25175 <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>
25176
25177 !! html/parsoid
25178 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25179 <h2 id="C++" data-parsoid='{}'><span id="C.2B.2B" typeof="mw:FallbackId"></span><span dir="ltr">C++</span></h2>
25180 <h2 id="זבנג!"><span id=".D7.96.D7.91.D7.A0.D7.92.21" typeof="mw:FallbackId"></span><span dir="rtl">זבנג!</span></h2>
25181 <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>
25182 <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>
25183 <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>
25184 !! end
25185
25186 !! test
25187 T74884: bdi element in ToC
25188 !! wikitext
25189 __TOC__
25190 ==<bdi>test</bdi>==
25191 !! html/php
25192 <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>
25193 <ul>
25194 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
25195 </ul>
25196 </div>
25197
25198 <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>
25199
25200 !! html/parsoid
25201 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25202 <h2 id="test" data-parsoid='{}'><bdi>test</bdi></h2>
25203 !! end
25204
25205 !! test
25206 T35715: s/strike element in ToC
25207 !! wikitext
25208 __TOC__
25209 ==<s>test</s> test <strike>test</strike>==
25210 !! html/php
25211 <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>
25212 <ul>
25213 <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>
25214 </ul>
25215 </div>
25216
25217 <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>
25218
25219 !! html/parsoid
25220 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25221 <h2 id="test_test_test" data-parsoid='{}'><s>test</s> test <strike>test</strike></h2>
25222 !! end
25223
25224 !! test
25225 T198618: style element in ToC
25226 !! options
25227 styletag=1
25228 !! wikitext
25229 __TOC__
25230 ==<style>.foo {}</style>Style<style>.bar {}</style>==
25231 !! html/php
25232 <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>
25233 <ul>
25234 <li class="toclevel-1 tocsection-1"><a href="#Style"><span class="tocnumber">1</span> <span class="toctext">Style</span></a></li>
25235 </ul>
25236 </div>
25237
25238 <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>
25239
25240 !! html/parsoid
25241 <meta property="mw:PageProp/toc" data-parsoid="{}"/>
25242 <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>
25243 !! end
25244
25245 !! test
25246 T198618: script element in ToC
25247 !! options
25248 wgRawHtml=1
25249 !! wikitext
25250 __TOC__
25251 ==<html><script>alert(1);</script></html>Script<html><script>alert(1);</script></html>==
25252 !! html/php
25253 <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>
25254 <ul>
25255 <li class="toclevel-1 tocsection-1"><a href="#Script"><span class="tocnumber">1</span> <span class="toctext">Script</span></a></li>
25256 </ul>
25257 </div>
25258
25259 <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>
25260
25261 !! html/parsoid
25262 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25263 <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>
25264 !! end
25265
25266 !! test
25267 Empty <p> tag in TOC, removed by Sanitizer (T92892)
25268 !! wikitext
25269 __TOC__
25270 ==x==
25271 !! html/php
25272 <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>
25273 <ul>
25274 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
25275 </ul>
25276 </div>
25277
25278 <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>
25279
25280 !! html/parsoid
25281 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25282 <h2 id="x" data-parsoid='{}'>x</h2>
25283 !! end
25284
25285 !! article
25286 MediaWiki:T34057
25287 !! text
25288 == {{int:headline_sample}} ==
25289 !! endarticle
25290
25291 !! test
25292 T34057: Title needed when expanding <h> nodes.
25293 !! options
25294 title=[[Main Page]]
25295 !! wikitext
25296 {{int:T34057}}
25297 !! html
25298 <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>
25299
25300 !! end
25301
25302 !! test
25303 Strip marker in urlencode
25304 !! wikitext
25305 {{urlencode:x<nowiki/>y}}
25306 {{urlencode:x<nowiki/>y|wiki}}
25307 {{urlencode:x<nowiki/>y|path}}
25308 {{urlencode:x<pre id="one">two</pre>y}}
25309 !! html/php
25310 <p>xy
25311 xy
25312 xy
25313 xy
25314 </p>
25315 !! end
25316
25317 !! test
25318 Strip marker in lc
25319 !! wikitext
25320 {{lc:x<nowiki/>y}}
25321 !! html
25322 <p>xy
25323 </p>
25324 !! end
25325
25326 !! test
25327 Strip marker in uc
25328 !! wikitext
25329 {{uc:x<nowiki/>y}}
25330 !! html
25331 <p>XY
25332 </p>
25333 !! end
25334
25335 !! test
25336 Strip marker in formatNum
25337 !! wikitext
25338 {{formatnum:1<nowiki/>2}}
25339 {{formatnum:1<nowiki/>2|R}}
25340 !! html
25341 <p>12
25342 12
25343 </p>
25344 !! end
25345
25346 !! test
25347 Check noCommafy in formatNum
25348 !! options
25349 language=be-tarask
25350 !! wikitext
25351 {{formatnum:123456.78}}
25352 {{formatnum:123456.78|NOSEP}}
25353 !! html
25354 <p>123 456,78
25355 123456.78
25356 </p>
25357 !! end
25358
25359 !! test
25360 Wrong option for formatNum (T58199)
25361 !! wikitext
25362 {{formatnum:1,234.56|Random}}
25363 {{formatnum:1,234.56|EVERYTHING}}
25364 {{formatnum:1234.56|any argument that has the string 'NOSEP'}}
25365 !! html
25366 <p>1,234.56
25367 1,234.56
25368 1,234.56
25369 </p>
25370 !! end
25371
25372 !! test
25373 Strip marker in grammar
25374 !! options
25375 language=fi
25376 !! wikitext
25377 {{grammar:elative|foo<nowiki/>bar}}
25378 !! html
25379 <p>foobarista
25380 </p>
25381 !! end
25382
25383 !! test
25384 Strip marker in padleft
25385 !! wikitext
25386 {{padleft:|2|x<nowiki/>y}}
25387 !! html
25388 <p>xy
25389 </p>
25390 !! end
25391
25392 !! test
25393 Strip marker in padright
25394 !! wikitext
25395 {{padright:|2|x<nowiki/>y}}
25396 !! html
25397 <p>xy
25398 </p>
25399 !! end
25400
25401 !! test
25402 Strip marker in anchorencode
25403 !! wikitext
25404 {{anchorencode:x<nowiki/>y}}
25405 !! html/php
25406 <p>xy
25407 </p>
25408 !! html/parsoid
25409 <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>
25410 !! end
25411
25412 !! test
25413 nowiki inside link inside heading (T20295)
25414 !! wikitext
25415 ==[[foo|x<nowiki>y</nowiki>z]]==
25416 !! html
25417 <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>
25418
25419 !! end
25420
25421 !! test
25422 new support for bdi element (T33817)
25423 !! wikitext
25424 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
25425 !! html
25426 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
25427
25428 !!end
25429
25430 !! test
25431 Ignore pipe between table row attributes
25432 !! wikitext
25433 {|
25434 |quux
25435 |- id=foo | style='color: red'
25436 |bar
25437 |}
25438 !! html
25439 <table>
25440 <tr>
25441 <td>quux
25442 </td></tr>
25443 <tr id="foo" style="color: red">
25444 <td>bar
25445 </td></tr></table>
25446
25447 !! end
25448
25449 !!test
25450 Language parser function
25451 !! wikitext
25452 {{#language:ar}}
25453 !! html
25454 <p>العربية
25455 </p>
25456 !! end
25457
25458 !!test
25459 Padleft and padright (default 0-padding)
25460 !! wikitext
25461 {{padleft:xyz|5}}
25462 {{padright:xyz|5}}
25463 !! html/php
25464 <p>00xyz
25465 xyz00
25466 </p>
25467 !! html/parsoid
25468 <p><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:xyz","function":"padleft"},"params":{"1":{"wt":"5"}},"i":0}}]}'>00xyz</span>
25469 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:xyz","function":"padright"},"params":{"1":{"wt":"5"}},"i":0}}]}'>xyz00</span></p>
25470 !! end
25471
25472 !!test
25473 Padleft and padright (partial fill)
25474 !! wikitext
25475 {{padleft:xyz|6|ab}}
25476 {{padright:xyz|6|ab}}
25477 !! html/php
25478 <p>abaxyz
25479 xyzaba
25480 </p>
25481 !! html/parsoid
25482 <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>
25483 <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>
25484 !! end
25485
25486 !!test
25487 Padleft and padright as substr
25488 !! wikitext
25489 {{padleft:|3|abcde}}
25490 {{padright:|3|abcde}}
25491 !! html/php
25492 <p>abc
25493 abc
25494 </p>
25495 !! html/parsoid
25496 <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>
25497 <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>
25498 !! end
25499
25500 !! test
25501 Padleft and padright with non-numerical length (T180403)
25502 !! wikitext
25503 {{padleft:abcdef|junk}}
25504 {{padright:abcdef|junk}}
25505 !! html/php
25506 <p>abcdef
25507 abcdef
25508 </p>
25509 !! end
25510
25511 !!test
25512 Special parser function
25513 !! wikitext
25514 {{#special:RandomPage}}
25515 {{#special:BaDtItLe}}
25516 {{#special:Foobar}}
25517 !! html
25518 <p>Special:Random
25519 Special:Badtitle
25520 Special:Foobar
25521 </p>
25522 !! end
25523
25524 !!test
25525 T36939 - Case insensitive link parsing ([HttP://])
25526 !! wikitext
25527 [HttP://MediaWiki.Org/]
25528 !! html/php
25529 <p><a rel="nofollow" class="external autonumber" href="HttP://MediaWiki.Org/">[1]</a>
25530 </p>
25531 !! html/parsoid
25532 <p><a rel="mw:ExtLink" class="external autonumber" href="HttP://MediaWiki.Org/"></a></p>
25533 !! end
25534
25535 !!test
25536 T36939 - Case insensitive link parsing ([HttP:// title])
25537 !! wikitext
25538 [HttP://MediaWiki.Org/ MediaWiki]
25539 !! html
25540 <p><a rel="nofollow" class="external text" href="HttP://MediaWiki.Org/">MediaWiki</a>
25541 </p>
25542 !! end
25543
25544 !!test
25545 T36939 - Case insensitive link parsing (HttP://)
25546 !! wikitext
25547 HttP://MediaWiki.Org/
25548 !! html/php
25549 <p><a rel="nofollow" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a>
25550 </p>
25551 !! html/parsoid
25552 <p><a rel="mw:ExtLink" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a></p>
25553 !! end
25554
25555 !!test
25556 Disable TOC
25557 !! options
25558 notoc
25559 !! wikitext
25560 Lead
25561 ==Section 1==
25562 ==Section 2==
25563 ==Section 3==
25564 ==Section 4==
25565 ==Section 5==
25566 !! html
25567 <p>Lead
25568 </p>
25569
25570 <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>
25571 <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>
25572 <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>
25573 <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>
25574 <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>
25575
25576 !! end
25577
25578
25579 ###
25580 ### Parsoid-specific tests
25581 ### Parsoid-PHP parser incompatibilities
25582 ###
25583 !!test
25584 1. SOL-sensitive wikitext tokens as template-args
25585 !!options
25586 parsoid=wt2html,wt2wt
25587 !! wikitext
25588 {{echo|*a}}
25589 {{echo|#a}}
25590 {{echo|:a}}
25591 !! html
25592 <span about="#mwt1" typeof="mw:Transclusion">
25593 </span><ul about="#mwt1"><li>a</li>
25594 </ul>
25595 <span about="#mwt2" typeof="mw:Transclusion">
25596 </span><ol about="#mwt2"><li>a</li>
25597 </ol>
25598 <span about="#mwt3" typeof="mw:Transclusion">
25599 </span><dl about="#mwt3"><dd>a</dd>
25600 </dl>
25601 !!end
25602
25603 #### -----------------------------------------------------------------
25604 #### Parsoid-specific functionality tests
25605 #### -----------------------------------------------------------------
25606
25607 # T65642/T68749: Formatting elt fixup around images.
25608 # We know wt2wt will fail, but we expect selser to pass.
25609 # Due to the nature of our testing, wt2wt and selser tests will enter the
25610 # blacklist and we'll catch selser regressions based on changes to the
25611 # blacklist entries for selser tests.
25612 !! test
25613 1. Treebuilder fixup of formatting elt
25614 !! options
25615 parsoid=wt2html,wt2wt
25616 !! wikitext
25617 {|
25618 |
25619 <small>
25620 [[Image:Foobar.jpg|right|Test]]
25621 </small>
25622 |}
25623 !! html/php+tidy
25624 <table>
25625 <tbody><tr>
25626 <td>
25627 <p><small>
25628 </small></p><small>
25629 <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" width="1941" height="220" /></a></div>
25630 </small><p><small></small>
25631 </p>
25632 </td></tr></tbody></table>
25633 !! html/parsoid
25634 <table>
25635 <tbody><tr><td>
25636 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p><small data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
25637 <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>
25638 <p><small data-parsoid='{"stx":"html","autoInsertedStart":true}'></small></p></td></tr>
25639 </tbody></table>
25640 !! end
25641
25642 !! test
25643 2. Treebuilder fixup of formatting elt
25644 !! options
25645 parsoid=wt2html,wt2wt
25646 !! wikitext
25647 '''foo[[File:Foobar.jpg|thumb|caption]]bar'''
25648
25649 <small>[[Image:Foobar.jpg|right|300px]]</small>
25650 !! html/php+tidy
25651 <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" 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>
25652 </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" 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>
25653 !! html/parsoid
25654 <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>
25655
25656 <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>
25657 !! end
25658
25659 !! test
25660 3. Treebuilder fixup of formatting elt
25661 !! options
25662 parsoid=wt2html,wt2wt
25663 !! wikitext
25664 <small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
25665 !! html/php+tidy
25666 <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" 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>
25667 </p>
25668 !! html/parsoid
25669 <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>
25670 !! end
25671
25672 !! test
25673 4. Treebuilder fixup of formatting elt: formatting tags around captionless images
25674 !! options
25675 parsoid=wt2html,wt2wt
25676 !! wikitext
25677 '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
25678 !! html/php+tidy
25679 <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" 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>
25680 !! html/parsoid
25681 <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>
25682 !! end
25683
25684 #### ----------------------------------------------------------------
25685 #### Parsoid-only testing of Parsoid's impl of LST
25686 #### Not implemented yet, see
25687 #### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
25688 #### ----------------------------------------------------------------
25689
25690 ## We still need to support serializing the older format while content is stored.
25691 !! test
25692 LST Sections: Backwards compatibility
25693 !! options
25694 parsoid={
25695 "suppressErrors": true,
25696 "modes": ["html2wt"]
25697 }
25698 !! wikitext
25699 <section begin="2011-05-16" />
25700 <section end="2014-04-10 (MW 1.23wmf22)" />
25701 !! html/parsoid
25702 <p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/>
25703 <meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p>
25704 !! end
25705
25706 !! test
25707 LST Sections: Newfangled approach
25708 !! wikitext
25709 <section begin="2011-05-16" />
25710 <section end="2014-04-10 (MW 1.23wmf22)" />
25711 !! html/parsoid
25712 <p><span typeof="mw:Extension/section" about="#mwt4" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"}}'>
25713 </span>
25714 <span typeof="mw:Extension/section" about="#mwt6" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"}}'>
25715 </span></p>
25716 !! end
25717
25718 #--------- Test stripping of empty nodes in template content ----------
25719
25720 !! test
25721 Empty LI and TR nodes should be stripped from template content
25722 !! wikitext
25723 {{EmptyLITest}}
25724 {{EmptyTRTest}}
25725 !! html/parsoid
25726 <ul about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyLITest","href":"./Template:EmptyLITest"},"params":{},"i":0}}]}'>
25727 <li>a</li>
25728 <li>b</li>
25729 </ul>
25730 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRTest","href":"./Template:EmptyTRTest"},"params":{},"i":0}}]}'>
25731 <tbody>
25732 <tr>
25733 <td>foo</td>
25734 </tr>
25735 <tr>
25736 <td>bar</td>
25737 </tr>
25738 </tbody>
25739 </table>
25740 !! end
25741
25742 !! test
25743 Empty LI and TR nodes should not be stripped from top-level content
25744 !! wikitext
25745 *a
25746 *
25747 *b
25748
25749 {|
25750 |-
25751 |-
25752 |foo
25753 |}
25754 !! html/parsoid
25755 <ul>
25756 <li>a</li>
25757 <li class='mw-empty-elt'></li>
25758 <li>b</li>
25759 </ul>
25760 <table>
25761 <tbody>
25762 <tr class='mw-empty-elt'></tr>
25763 <tr>
25764 <td>foo</td>
25765 </tr>
25766 </tbody>
25767 </table>
25768 !! end
25769
25770 !! test
25771 Empty TR nodes should not be stripped if they have any attributes set
25772 !! wikitext
25773 {{EmptyTRWithHTMLAttrTest}}
25774 !! html/parsoid
25775 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'>
25776 <tr align='center'></tr>
25777 <tr><td>foo</td></tr>
25778 <tr align='center'></tr>
25779 <tr><td>bar</td></tr>
25780 </table>
25781 !! end
25782
25783 #### ----------------------------------------------------------------
25784 #### The following section of tests are primarily to test
25785 #### wikitext escaping capabilities of Parsoid. Given that
25786 #### escaping can be done any number of ways, the wikitext (input)
25787 #### is always adjusted to reflect how Parsoid adds nowiki
25788 #### escape tags.
25789 ####
25790 #### We are marking several tests as parsoid-only since the
25791 #### HTML in the result section is different from what the
25792 #### PHP parser generates for it.
25793 #### ----------------------------------------------------------------
25794
25795
25796 #### --------------- Headings ---------------
25797 #### 0. Unnested
25798 #### 1. Nested inside html <h1>=foo=</h1>
25799 #### 2. Outside heading nest on a single line <h1>foo</h1>*bar
25800 #### 3. Nested inside html with wikitext split by html tags
25801 #### 4. No escape needed
25802 #### 5. Empty headings <h1></h1>
25803 #### 6. Heading chars in SOL context
25804 #### ----------------------------------------
25805 !! test
25806 Headings: 0. Unnested
25807 !! options
25808 parsoid=html2wt
25809 !! html/parsoid
25810 <p>=foo=</p>
25811
25812 <p> =foo=
25813 <!--cmt-->
25814 =foo=</p>
25815
25816 <p>=foo<i>a</i>=</p>
25817 !! wikitext
25818 <nowiki>=foo=</nowiki>
25819
25820 <nowiki> </nowiki>=foo=
25821 <!--cmt-->
25822 <nowiki>=foo=</nowiki>
25823
25824 =foo''a''<nowiki>=</nowiki>
25825 !!end
25826
25827 # New headings and existing headings are handled differently
25828 !! test
25829 Headings: 1. Nested inside html
25830 !! options
25831 parsoid=html2wt
25832 !! html/parsoid
25833 <h1>=foo=</h1>
25834 <h2>=foo=</h2>
25835 <h3>=foo=</h3>
25836
25837 <h1 data-parsoid=''>=foo=</h1>
25838 <h2 data-parsoid=''>=foo=</h2>
25839 <h3 data-parsoid=''>=foo=</h3>
25840 <h4 data-parsoid=''>=foo=</h4>
25841 <h5 data-parsoid=''>=foo=</h5>
25842 <h6 data-parsoid=''>=foo=</h6>
25843 !! wikitext
25844 = =foo= =
25845
25846 == =foo= ==
25847
25848 === =foo= ===
25849
25850 =<nowiki>=foo=</nowiki>=
25851 ==<nowiki>=foo=</nowiki>==
25852 ===<nowiki>=foo=</nowiki>===
25853 ====<nowiki>=foo=</nowiki>====
25854 =====<nowiki>=foo=</nowiki>=====
25855 ======<nowiki>=foo=</nowiki>======
25856
25857 !!end
25858
25859 !! test
25860 Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
25861 !! options
25862 parsoid=html2wt
25863 !! html/parsoid
25864 <h1>foo</h1>*bar
25865 <h1>foo</h1>=bar
25866 <h1>foo</h1>=bar=
25867 !! wikitext
25868 = foo =
25869 <nowiki>*</nowiki>bar
25870
25871 = foo =
25872 =bar
25873
25874 = foo =
25875 <nowiki>=bar=</nowiki>
25876 !!end
25877
25878 !! test
25879 Headings: 3. Nested inside html with wikitext split by html tags
25880 !! options
25881 parsoid=html2wt
25882 !! html/parsoid
25883 <h1>=<b>bold</b>foo=</h1>
25884 !! wikitext
25885 = ='''bold'''foo= =
25886 !!end
25887
25888 !! test
25889 Headings: 4a. No escaping needed (testing just h1 and h2)
25890 !! options
25891 parsoid=html2wt
25892 !! html/parsoid
25893 <h1>=foo</h1>
25894 <h1>foo=</h1>
25895 <h1> =foo= </h1>
25896 <h1>=foo= bar</h1>
25897 <h2>=foo</h2>
25898 <h2>foo=</h2>
25899 <h1>=</h1>
25900 <h1><i>=</i>foo=</h1>
25901 !! wikitext
25902 = =foo =
25903
25904 = foo= =
25905
25906 = =foo= =
25907
25908 = =foo= bar =
25909
25910 == =foo ==
25911
25912 == foo= ==
25913
25914 = = =
25915
25916 = ''=''foo= =
25917 !!end
25918
25919 !! test
25920 Headings: 4b. No escaping needed (inside p-tags)
25921 !! options
25922 parsoid=html2wt
25923 !! html/parsoid
25924 <p>=foo= x
25925 =foo= <s></s>
25926 </p>
25927 !! wikitext
25928 =foo= x
25929 =foo= <s></s>
25930 !! html/php
25931 <p>=foo= x
25932 =foo= <s></s>
25933 </p>
25934 !!end
25935
25936 !! test
25937 Headings: 4c. Short headings (1)
25938 !! options
25939 parsoid=html2wt
25940 !! html/parsoid
25941 <p>===
25942 </p>
25943 !! wikitext
25944 <nowiki>===</nowiki>
25945 !! html/php
25946 <p>===
25947 </p>
25948 !! end
25949
25950 # in the html2wt direction we emit '= = =' or '=<nowiki>=</nowiki>='
25951 !! test
25952 Headings: 4d. Short headings (2)
25953 !! options
25954 parsoid=wt2html,html2html
25955 !! wikitext
25956 =
25957 ==
25958 ===
25959 ====
25960 =====
25961 !! html/php
25962 <p>=
25963 ==
25964 </p>
25965 <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>
25966 <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>
25967 <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>
25968
25969 !! html/parsoid
25970 <p>=
25971 ==</p>
25972 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
25973 <h1 id="=="><span id=".3D.3D" typeof="mw:FallbackId"></span>==</h1>
25974 <h2 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h2>
25975 !! end
25976
25977 !! test
25978 Headings: 5. Empty headings
25979 !! options
25980 parsoid=html2wt
25981 !! html/parsoid
25982 <h1 data-parsoid='{}'></h1>
25983
25984 <h2 data-parsoid='{}'></h2>
25985
25986 <h3 data-parsoid='{}'></h3>
25987
25988 <h4 data-parsoid='{}'></h4>
25989
25990 <h5 data-parsoid='{}'></h5>
25991
25992 <h6 data-parsoid='{}'></h6>
25993 !! wikitext
25994 =<nowiki/>=
25995
25996 ==<nowiki/>==
25997
25998 ===<nowiki/>===
25999
26000 ====<nowiki/>====
26001
26002 =====<nowiki/>=====
26003
26004 ======<nowiki/>======
26005 !!end
26006
26007 !! test
26008 Headings: 6a. Heading chars in SOL context (with trailing spaces)
26009 !! options
26010 parsoid=html2wt
26011 !! html/parsoid
26012 <p>=a=</p>
26013
26014 <p>=a=</p>
26015
26016 <p>=a=</p>
26017 !! wikitext
26018 <nowiki>=a=</nowiki>
26019
26020 <nowiki>=a=</nowiki>
26021
26022 <nowiki>=a=</nowiki>
26023 !!end
26024
26025 !! test
26026 Headings: 6b. Heading chars in SOL context (with trailing newlines)
26027 !! options
26028 parsoid=html2wt
26029 !! html/parsoid
26030 <p>=a=
26031 b</p>
26032
26033 <p>=a=
26034 b</p>
26035
26036 <p>=a=
26037 b</p>
26038 !! wikitext
26039 <nowiki>=a=</nowiki>
26040 b
26041
26042 <nowiki>=a=</nowiki>
26043 b
26044
26045 <nowiki>=a=</nowiki>
26046 b
26047 !!end
26048
26049 !! test
26050 Headings: 6c. Heading chars in SOL context (leading newline break)
26051 !! options
26052 parsoid=html2wt
26053 !! html/parsoid
26054 <p>a
26055 =b=</p>
26056 !! wikitext
26057 a
26058 <nowiki>=b=</nowiki>
26059 !!end
26060
26061 !! test
26062 Headings: 6d. Heading chars in SOL context (with interspersed comments)
26063 !! options
26064 parsoid=html2wt
26065 !! html/parsoid
26066 <!--c0--><p>=a=</p>
26067
26068 <!--c1--><p>=a=</p> <!--c2--> <!--c3-->
26069 !! wikitext
26070 <!--c0--><nowiki>=a=</nowiki>
26071
26072 <!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3-->
26073 !!end
26074
26075 !! test
26076 Headings: 6d. Heading chars in SOL context (No escaping needed)
26077 !! options
26078 parsoid=html2wt
26079 !! html/parsoid
26080 =a=<div>b</div>
26081 !! wikitext
26082 =a=<div>b</div>
26083 !!end
26084
26085 !! test
26086 Headings: 7. Insert a newline between new content and headings
26087 !! options
26088 parsoid=html2wt
26089 !! html/parsoid
26090 <h2>NEW</h2>
26091 <p>new</p>
26092 <h2 data-parsoid='{}'>A</h2>
26093 <p data-parsoid='{}'>a</p>
26094 !! wikitext
26095 == NEW ==
26096 new
26097
26098 ==A==
26099 a
26100
26101 !! end
26102
26103 !! test
26104 Headings: Used as horizontal rule
26105 !! config
26106 wgFragmentMode=[ 'html5', 'legacy' ]
26107 !! options
26108 parsoid=wt2html
26109 !! wikitext
26110 ===============
26111 !! html/php
26112 <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>
26113
26114 !! html/parsoid
26115 <h6 id="==="><span id=".3D.3D.3D" typeof="mw:FallbackId"></span>===</h6>
26116 !! end
26117
26118 #### --------------- Lists ---------------
26119 #### 0. Outside nests (*foo, etc.)
26120 #### 1. Nested inside html <ul><li>*foo</li></ul>
26121 #### 2. Inside definition lists
26122 #### 3. Only bullets at start should be escaped
26123 #### 4. No escapes needed
26124 #### 5. No unnecessary escapes
26125 #### 6. Escape bullets in SOL position
26126 #### 7. Escape bullets in a multi-line context
26127 #### ----------------------------------------
26128
26129 !! test
26130 Lists: 0. Outside nests
26131 !! options
26132 parsoid=html2wt
26133 !! html/parsoid
26134 <p>*foo</p>
26135
26136 <p>#foo</p>
26137
26138 <p>;Foo:bar</p>
26139 !! wikitext
26140 <nowiki>*</nowiki>foo
26141
26142 <nowiki>#</nowiki>foo
26143
26144 <nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar
26145 !!end
26146
26147 ## Making these next 3 tests Parsoid-only since they are html2wt tests
26148 ## to test wikitext escaping, and insignificant whitespace diffs
26149 ## cause PHP parser tests to barf
26150 !! test
26151 Lists: 1. Nested inside html (No unnecessary escapes)
26152 !! options
26153 parsoid=html2wt
26154 !! html/parsoid
26155 <ul>
26156 <li>*foo</li>
26157 <li>#foo</li>
26158 <li>:foo</li>
26159 <li>;foo</li>
26160 <li data-parsoid='{}'>*foo</li>
26161 <li data-parsoid='{}'>#foo</li>
26162 <li data-parsoid='{}'>:foo</li>
26163 <li data-parsoid='{}'>;foo</li>
26164 </ul>
26165
26166 <ol>
26167 <li>*foo</li>
26168 <li>#foo</li>
26169 <li>:foo</li>
26170 <li>;foo</li>
26171 <li data-parsoid='{}'>*foo</li>
26172 <li data-parsoid='{}'>#foo</li>
26173 <li data-parsoid='{}'>:foo</li>
26174 <li data-parsoid='{}'>;foo</li>
26175 </ol>
26176 !! wikitext
26177 * *foo
26178 * #foo
26179 * :foo
26180 * ;foo
26181 *<nowiki>*foo</nowiki>
26182 *<nowiki>#foo</nowiki>
26183 *<nowiki>:foo</nowiki>
26184 *<nowiki>;foo</nowiki>
26185
26186 # *foo
26187 # #foo
26188 # :foo
26189 # ;foo
26190 #<nowiki>*foo</nowiki>
26191 #<nowiki>#foo</nowiki>
26192 #<nowiki>:foo</nowiki>
26193 #<nowiki>;foo</nowiki>
26194 !!end
26195
26196 !! test
26197 Lists: 2. Inside definition lists
26198 !! options
26199 parsoid=html2wt
26200 !! html/parsoid
26201 <dl><dt>;foo</dt></dl>
26202 <dl><dt>:foo</dt></dl>
26203 <dl><dt>:foo</dt>
26204 <dd>bar</dd></dl>
26205 <dl><dd>:foo</dd></dl>
26206 !! wikitext
26207 ; ;foo
26208
26209 ; <nowiki>:foo</nowiki>
26210
26211 ; <nowiki>:foo</nowiki>
26212 : bar
26213
26214 : :foo
26215 !!end
26216
26217 !! test
26218 Lists: 3. Only bullets at start of text in wikitext-generated HTML should be escaped
26219 !! options
26220 parsoid=html2wt
26221 !! html/parsoid
26222 <ul>
26223 <li>*foo*bar</li>
26224 <li data-parsoid='{}'>*foo<i>it</i>*bar</li>
26225 </ul>
26226 !! wikitext
26227 * *foo*bar
26228 *<nowiki>*foo</nowiki>''it''*bar
26229 !!end
26230
26231 !! test
26232 Lists: 4. No escapes needed
26233 !! options
26234 parsoid=html2wt
26235 !! html/parsoid
26236 <ul>
26237 <li>foo*bar
26238 </li>
26239 </ul>
26240 <ul>
26241 <li><i>foo</i>*bar
26242 </li>
26243 </ul>
26244 <ul>
26245 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>: bar
26246 </li>
26247 </ul>
26248 <ul>
26249 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar
26250 </li>
26251 </ul>
26252 !! wikitext
26253 *foo*bar
26254
26255 *''foo''*bar
26256
26257 *[[Foo]]: bar
26258
26259 *[[Foo]]*bar
26260 !!end
26261
26262 !! test
26263 Lists: 5. No unnecessary escapes
26264 !! options
26265 parsoid=html2wt
26266 !! html/parsoid
26267 <ul><li> bar <span>[[foo]]</span></li></ul>
26268 <ul><li> =bar <span>[[foo]]</span></li></ul>
26269 <ul><li> [[bar <span>[[foo]]</span></li></ul>
26270 <ul><li> ]]bar <span>[[foo]]</span></li></ul>
26271 <ul><li> =bar <span>foo]]</span>=</li></ul>
26272 <ul><li> <s></s>: a</li></ul>
26273 <ul><li> <i>* foo</i></li></ul>
26274
26275 !! wikitext
26276 * bar <span><nowiki>[[foo]]</nowiki></span>
26277
26278 * =bar <span><nowiki>[[foo]]</nowiki></span>
26279
26280 * [[bar <span><nowiki>[[foo]]</nowiki></span>
26281
26282 * ]]bar <span><nowiki>[[foo]]</nowiki></span>
26283
26284 * =bar <span>foo]]</span>=
26285
26286 * <s></s>: a
26287
26288 * ''* foo''
26289 !!end
26290
26291 !! test
26292 Lists: 6. Escape bullets in SOL position
26293 !! options
26294 parsoid=html2wt
26295 !! html/parsoid
26296 <p><!--cmt-->*foo</p>
26297 !! wikitext
26298 <!--cmt--><nowiki>*</nowiki>foo
26299 !!end
26300
26301 !! test
26302 Lists: 7. Escape bullets in a multi-line context
26303 !! options
26304 parsoid=html2wt
26305 !! html/parsoid
26306 <p>a
26307 *b
26308 </p>
26309 !! wikitext
26310 a
26311 <nowiki>*</nowiki>b
26312 !!end
26313
26314 !! test
26315 Lists: 8. Escape colons only if not present in tags
26316 !! options
26317 parsoid=html2wt
26318 !! html/parsoid
26319 <dl><dt>a:b<i>c:d</i></dt></dl>
26320 !! wikitext
26321 ; <nowiki>a:b</nowiki>''c:d''
26322 !! end
26323
26324 #### --------------- HRs ---------------
26325 #### 1. Single line
26326 #### -----------------------------------
26327
26328 !! test
26329 HRs: 1. Single line
26330 !! options
26331 parsoid=html2wt
26332 !! html/parsoid
26333 <hr />----
26334 <hr />=foo=
26335 <hr />*foo
26336 !! wikitext
26337 ----<nowiki>----</nowiki>
26338 ----=foo=
26339 ----*foo
26340 !! end
26341
26342 #### --------------- Tables ---------------
26343 #### 1a. Simple example
26344 #### 1b. No escaping needed (!foo)
26345 #### 1c. No escaping needed (|foo)
26346 #### 1d. No escaping needed (|}foo)
26347 ####
26348 #### 2a. Nested in td (<td>foo|bar</td>)
26349 #### 2b. Nested in td (<td>foo||bar</td>)
26350 #### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
26351 ####
26352 #### 3a. Nested in th (<th>foo!bar</th>)
26353 #### 3b. Nested in th (<th>foo!!bar</th>)
26354 #### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
26355 ####
26356 #### 4a. Escape -
26357 #### 4b. Escape +
26358 #### 4c. No escaping needed
26359 #### --------------------------------------
26360
26361 !! test
26362 Tables: 1a. Simple example
26363 !! options
26364 parsoid=html2wt
26365 !! html/parsoid
26366 <p>{|
26367 |}
26368 </p>
26369 !! wikitext
26370 <nowiki>{|</nowiki>
26371 |}
26372 !! end
26373
26374 !! test
26375 Tables: 1b. No escaping needed
26376 !! options
26377 parsoid=html2wt
26378 !! html/parsoid
26379 <p>!foo
26380 </p>
26381 !! wikitext
26382 !foo
26383 !! end
26384
26385 !! test
26386 Tables: 1c. No escaping needed
26387 !! options
26388 parsoid=html2wt
26389 !! html/parsoid
26390 <p>|foo
26391 </p>
26392 !! wikitext
26393 |foo
26394 !! end
26395
26396 !! test
26397 Tables: 1d. No escaping needed
26398 !! options
26399 parsoid=html2wt
26400 !! html/parsoid
26401 <p>|}foo
26402 </p>
26403 !! wikitext
26404 |}foo
26405 !! end
26406
26407 !! test
26408 Tables: 2a. Nested in td
26409 !! options
26410 parsoid=html2wt
26411 !! html/parsoid
26412 <table><tbody><tr>
26413 <td>foo|bar</td></tr>
26414 <tr><td>x<div>a|b</div></td>
26415 </tbody></table>
26416 !! wikitext
26417 {|
26418 |<nowiki>foo|bar</nowiki>
26419 |-
26420 |x<div><nowiki>a|b</nowiki></div>
26421 |}
26422 !! html/php+tidy
26423 <table>
26424 <tbody><tr>
26425 <td>foo|bar
26426 </td></tr>
26427 <tr>
26428 <td>x<div>a|b</div>
26429 </td></tr></tbody></table>
26430 !! end
26431
26432 !! test
26433 Tables: 2b. Nested in td
26434 !! options
26435 parsoid=html2wt
26436 !! html/parsoid
26437 <table><tbody><tr>
26438 <td>foo||bar</td>
26439 <td>a<i>b||c</i></td>
26440 <td>a<i><div>b||c</div></i></td>
26441 </tr></tbody></table>
26442 !! wikitext
26443 {|
26444 |<nowiki>foo||bar</nowiki>
26445 |a''<nowiki>b||c</nowiki>''
26446 |a''<div><nowiki>b||c</nowiki></div>''
26447 |}
26448 !! html/php
26449 <table>
26450 <tr>
26451 <td>foo||bar
26452 </td>
26453 <td>a<i>b||c</i>
26454 </td>
26455 <td>a<i><div>b||c</div></i>
26456 </td></tr></table>
26457
26458 !! end
26459
26460 !! test
26461 Tables: 2c. Nested in td -- no escaping needed
26462 !! options
26463 parsoid=html2wt
26464 !! html/*
26465 <table>
26466 <tr>
26467 <td>foo!!bar
26468 </td></tr></table>
26469
26470 !! wikitext
26471 {|
26472 |foo!!bar
26473 |}
26474 !! end
26475
26476 !! test
26477 Tables: 3a. Nested in th
26478 !! options
26479 parsoid=html2wt
26480 !! html/*
26481 <table>
26482 <tr>
26483 <th>foo!bar
26484 </th></tr></table>
26485
26486 !! wikitext
26487 {|
26488 !foo!bar
26489 |}
26490 !! end
26491
26492 !! test
26493 Tables: 3b. Nested in th
26494 !! options
26495 parsoid=html2wt
26496 !! html/parsoid
26497 <table><tbody>
26498 <tr><th>foo!!bar</th>
26499 <th><i>foo|bar</i></th>
26500 <th><i>foo!!bar</i></th>
26501 <th><i><span>foo!!bar</span></i></th>
26502 </tr></tbody></table>
26503 !! wikitext
26504 {|
26505 !<nowiki>foo!!bar</nowiki>
26506 !''<nowiki>foo|bar</nowiki>''
26507 !''<nowiki>foo!!bar</nowiki>''
26508 !''<span><nowiki>foo!!bar</nowiki></span>''
26509 |}
26510 !! html/php
26511 <table>
26512 <tr>
26513 <th>foo!!bar
26514 </th>
26515 <th><i>foo|bar</i>
26516 </th>
26517 <th><i>foo!!bar</i>
26518 </th>
26519 <th><i><span>foo!!bar</span></i>
26520 </th></tr></table>
26521
26522 !! end
26523
26524 !! test
26525 Tables: 3c. Nested in th
26526 !! options
26527 parsoid=html2wt
26528 !! html/parsoid
26529 <table><tbody>
26530 <tr><th>foo||bar</th>
26531 <th><span typeof="mw:Nowiki">foo||bar</span></th>
26532 </tr></tbody></table>
26533 !! wikitext
26534 {|
26535 !<nowiki>foo||bar</nowiki>
26536 !<nowiki>foo||bar</nowiki>
26537 |}
26538 !! html/php
26539 <table>
26540 <tr>
26541 <th>foo||bar
26542 </th>
26543 <th>foo||bar
26544 </th></tr></table>
26545
26546 !! end
26547
26548 !! test
26549 Tables: 4a. Escape -
26550 !! options
26551 parsoid=html2wt
26552 !! html/*
26553 <table>
26554 <tr>
26555 <th>-bar
26556 </th></tr>
26557 <tr>
26558 <td>-bar
26559 </td></tr></table>
26560
26561 !! wikitext
26562 {|
26563 !-bar
26564 |-
26565 |<nowiki>-bar</nowiki>
26566 |}
26567 !! end
26568
26569 !! test
26570 Tables: 4b. Escape +
26571 !! options
26572 parsoid=html2wt
26573 !! html/*
26574 <table>
26575 <tr>
26576 <th>+bar
26577 </th></tr>
26578 <tr>
26579 <td>+bar
26580 </td></tr></table>
26581
26582 !! wikitext
26583 {|
26584 !+bar
26585 |-
26586 |<nowiki>+bar</nowiki>
26587 |}
26588 !! end
26589
26590 !! test
26591 Tables: 4c. No escaping needed
26592 !! options
26593 parsoid=html2wt
26594 !! html/parsoid
26595 <table><tbody>
26596 <tr><td>foo-bar</td><td>foo+bar</td></tr>
26597 <tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
26598 <tr><td>foo
26599 <p>bar|baz
26600 +bar
26601 -bar</p></td></tr>
26602 <tr><td>x
26603 <div>a|b</div></td>
26604 </tbody></table>
26605 !! wikitext
26606 {|
26607 |foo-bar
26608 |foo+bar
26609 |-
26610 |''foo''-bar
26611 |''foo''+bar
26612 |-
26613 |foo
26614 bar|baz
26615 +bar
26616 -bar
26617 |-
26618 |x
26619 <div>a|b</div>
26620 |}
26621 !! html/php
26622 <table>
26623 <tr>
26624 <td>foo-bar
26625 </td>
26626 <td>foo+bar
26627 </td></tr>
26628 <tr>
26629 <td><i>foo</i>-bar
26630 </td>
26631 <td><i>foo</i>+bar
26632 </td></tr>
26633 <tr>
26634 <td>foo
26635 <p>bar|baz
26636 +bar
26637 -bar
26638 </p>
26639 </td></tr>
26640 <tr>
26641 <td>x
26642 <div>a|b</div>
26643 </td></tr></table>
26644
26645 !! end
26646
26647 !! test
26648 Tables: 4d. No escaping needed
26649 !! options
26650 parsoid=html2wt
26651 !! html/parsoid
26652 <table>
26653 <tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
26654 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
26655 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
26656 </tbody></table>
26657 !! wikitext
26658 {|
26659 |[[Foo]]-bar
26660 ||+1
26661 ||-2
26662 |}
26663 !! html/php
26664 <table>
26665 <tr>
26666 <td><a href="/wiki/Foo" title="Foo">Foo</a>-bar
26667 </td>
26668 <td>+1
26669 </td>
26670 <td>-2
26671 </td></tr></table>
26672
26673 !! end
26674
26675 !! test
26676 Tables: 5. Empty table cells should get whitespace to avoid need for nowikis
26677 !! options
26678 parsoid=html2wt
26679 !! html/parsoid
26680 <table><tr><td></td><td align="center" data-parsoid='{"stx":"row"}'></td><td data-parsoid='{"stx":"row"}'></td></tr></table>
26681
26682 <table><tr><td></td><td align="center"></td><td></td></tr></table>
26683
26684 <table><tr><td></td><td align="center" data-parsoid='{"stx":"row", "startTagSrc":"{{!}}{{!}}"}'></td><td data-parsoid='{"stx":"row"}'></td></tr></table>
26685
26686 <table><tr><th></th><th align="center" data-parsoid='{"stx":"row"}'></th><th data-parsoid='{"stx":"row"}'></th></tr></table>
26687 !! wikitext
26688 {|
26689 | || align="center" | ||
26690 |}
26691
26692 {|
26693 |
26694 | align="center" |
26695 |
26696 |}
26697
26698 {|
26699 | {{!}}{{!}} align="center" | ||
26700 |}
26701
26702 {|
26703 ! !! align="center" | !!
26704 |}
26705 !! html/php+tidy
26706 <table>
26707 <tbody><tr>
26708 <td></td>
26709 <td align="center"></td>
26710 <td>
26711 </td></tr></tbody></table>
26712 <table>
26713 <tbody><tr>
26714 <td>
26715 </td>
26716 <td align="center">
26717 </td>
26718 <td>
26719 </td></tr></tbody></table>
26720 <table>
26721 <tbody><tr>
26722 <td></td>
26723 <td align="center"></td>
26724 <td>
26725 </td></tr></tbody></table>
26726 <table>
26727 <tbody><tr>
26728 <th></th>
26729 <th align="center"></th>
26730 <th>
26731 </th></tr></tbody></table>
26732 !! end
26733
26734 !! test
26735 T97430: Don't emit empty nowiki pairs around marker meta tags
26736 !! options
26737 parsoid=html2wt
26738 !! html/parsoid
26739 <p>*This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
26740 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
26741 !! wikitext
26742 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
26743 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
26744 !! end
26745
26746 !! test
26747 Unclosed xmlish element in table line shouldn't eat end delimiters
26748 !! options
26749 parsoid=html2wt
26750 !! html/parsoid
26751 <table>
26752 <tbody><tr><td> &lt;foo</td>
26753 <td> bar></td></tr>
26754 </tbody></table>
26755 !! wikitext
26756 {|
26757 | <foo
26758 | bar>
26759 |}
26760 !! html/php
26761 <table>
26762 <tr>
26763 <td>&lt;foo
26764 </td>
26765 <td>bar&gt;
26766 </td></tr></table>
26767
26768 !! end
26769
26770 #### --------------- Links ----------------
26771 #### 1. Quote marks in link text
26772 #### 2. Wikilinks: Escapes needed
26773 #### 3. Wikilinks: No escapes needed
26774 #### 4. Extlinks: Escapes needed
26775 #### 5. Extlinks: No escapes needed
26776 #### --------------------------------------
26777 !! test
26778 Links 1. WikiLinks: No escapes needed
26779 !! options
26780 parsoid=html2wt
26781 !! html/parsoid
26782 <p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
26783 <a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
26784 <a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
26785 !! wikitext
26786 [[Foo|Foo''boo'']]
26787 [[Foo|[Foobar]]]
26788 [[Foo|x [Foobar] x]]
26789 !! html/php
26790 <p><a href="/wiki/Foo" title="Foo">Foo<i>boo</i></a>
26791 <a href="/wiki/Foo" title="Foo">[Foobar]</a>
26792 <a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
26793 </p>
26794 !! end
26795
26796 !! test
26797 Links 2. WikiLinks: Escapes needed
26798 !! options
26799 parsoid=html2wt
26800 !! html/parsoid
26801 <a href="Foo" rel="mw:WikiLink">Foobar]</a>
26802 <a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
26803 <a href="Foo" rel="mw:WikiLink">[[Bar]]</a>
26804 <a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a>
26805 <a href="Foo" rel="mw:WikiLink">|Bar</a>
26806 <a href="Foo" rel="mw:WikiLink">]]bar</a>
26807 <a href="Foo" rel="mw:WikiLink">[[bar</a>
26808 <a href="Foo" rel="mw:WikiLink">x [[ y</a>
26809 <a href="Foo" rel="mw:WikiLink">x ]] y</a>
26810 <a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a>
26811 !! wikitext
26812 [[Foo|<nowiki>Foobar]</nowiki>]]
26813 [[Foo|x <nowiki>[http://google.com g]</nowiki> x]]
26814 [[Foo|<nowiki>[[Bar]]</nowiki>]]
26815 [[Foo|<nowiki>x [[Bar]] x</nowiki>]]
26816 [[Foo|<nowiki>|Bar</nowiki>]]
26817 [[Foo|<nowiki>]]bar</nowiki>]]
26818 [[Foo|<nowiki>[[bar</nowiki>]]
26819 [[Foo|<nowiki>x [[ y</nowiki>]]
26820 [[Foo|<nowiki>x ]] y</nowiki>]]
26821 [[Foo|<nowiki>x ]] y [[ z</nowiki>]]
26822 !! html/php
26823 <p><a href="/wiki/Foo" title="Foo">Foobar]</a>
26824 <a href="/wiki/Foo" title="Foo">x [http://google.com g] x</a>
26825 <a href="/wiki/Foo" title="Foo">[[Bar]]</a>
26826 <a href="/wiki/Foo" title="Foo">x [[Bar]] x</a>
26827 <a href="/wiki/Foo" title="Foo">|Bar</a>
26828 <a href="/wiki/Foo" title="Foo">]]bar</a>
26829 <a href="/wiki/Foo" title="Foo">[[bar</a>
26830 <a href="/wiki/Foo" title="Foo">x [[ y</a>
26831 <a href="/wiki/Foo" title="Foo">x ]] y</a>
26832 <a href="/wiki/Foo" title="Foo">x ]] y [[ z</a>
26833 </p>
26834 !! end
26835
26836 !! test
26837 Links 3. WikiLinks: No escapes needed
26838 !! options
26839 parsoid=html2wt
26840 !! html/parsoid
26841 <p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
26842 <a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
26843 !! wikitext
26844 [[Foo|[Foobar]]
26845 [[Foo|foo|bar]]
26846 !! html/php
26847 <p><a href="/wiki/Foo" title="Foo">[Foobar</a>
26848 <a href="/wiki/Foo" title="Foo">foo|bar</a>
26849 </p>
26850 !! end
26851
26852 !! test
26853 Links 4. ExtLinks: Escapes needed
26854 !! options
26855 parsoid=html2wt
26856 !! html/parsoid
26857 <p><a rel="mw:ExtLink" href="http://google.com">[google]</a>
26858 <a rel="mw:ExtLink" href="http://google.com">google]</a>
26859 <a rel="mw:ExtLink" href="http://google.com">goog] le</a></p>
26860 <p>[http://google.com]</p>
26861 <p>[http://google.com google]</p>
26862 <p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p>
26863 <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>
26864 !! wikitext
26865 [http://google.com <nowiki>[google]</nowiki>]
26866 [http://google.com <nowiki>google]</nowiki>]
26867 [http://google.com <nowiki>goog] le</nowiki>]
26868
26869 <nowiki>[http://google.com]</nowiki>
26870
26871 <nowiki>[http://google.com google]</nowiki>
26872
26873 [http://google.com<nowiki>]</nowiki>
26874
26875 [{{echo|http://google.com}}<nowiki>]</nowiki>
26876 !! html/php
26877 <p><a rel="nofollow" class="external text" href="http://google.com">[google]</a>
26878 <a rel="nofollow" class="external text" href="http://google.com">google]</a>
26879 <a rel="nofollow" class="external text" href="http://google.com">goog] le</a>
26880 </p><p>[http://google.com]
26881 </p><p>[http://google.com google]
26882 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
26883 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
26884 </p>
26885 !! end
26886
26887 !! test
26888 Links 5. ExtLinks: No escapes needed
26889 !! options
26890 parsoid=html2wt
26891 !! html/parsoid
26892 <p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
26893 <p>[<a ref="mw:ExtLink" href="http://google.com"></a>]</p>
26894 !! wikitext
26895 [http://google.com [google]
26896
26897 [[http://google.com]]
26898 !! html/php
26899 <p><a rel="nofollow" class="external text" href="http://google.com">[google</a>
26900 </p><p>[<a rel="nofollow" class="external autonumber" href="http://google.com">[1]</a>]
26901 </p>
26902 !! end
26903
26904 !! test
26905 Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300)
26906 !! options
26907 parsoid=html2wt
26908 !! html/parsoid
26909 <p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y
26910 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>?x
26911 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>&amp;x
26912 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>'x
26913 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,x
26914 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.x
26915 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
26916 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>:x
26917 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
26918 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>!x
26919 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>=x
26920 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>(x)
26921 <a rel="mw:ExtLink" href="http://example.com(x" data-parsoid='{"stx":"url"}'>http://example.com(x</a>)
26922 </p>
26923 !! wikitext
26924 x<nowiki/>http://example.com<nowiki/>y
26925 http://example.com<nowiki/>?x
26926 http://example.com<nowiki/>&x
26927 http://example.com<nowiki/>'x
26928 http://example.com<nowiki/>,x
26929 http://example.com<nowiki/>.x
26930 http://example.com<nowiki/>;x
26931 http://example.com<nowiki/>:x
26932 http://example.com<nowiki/>;x
26933 http://example.com<nowiki/>!x
26934 http://example.com<nowiki/>=x
26935 http://example.com<nowiki/>(x)
26936 http://example.com(x<nowiki/>)
26937 !! end
26938
26939 !! test
26940 Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
26941 !! options
26942 parsoid=html2wt
26943 !! html/parsoid
26944 <p>x
26945 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>
26946 y
26947 "<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>"
26948 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>)
26949 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>) foo
26950 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,
26951 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, foo
26952 </p>
26953 !! wikitext
26954 x
26955 http://example.com
26956 y
26957 "http://example.com"
26958 (http://example.com)
26959 (http://example.com) foo
26960 http://example.com,
26961 http://example.com, foo
26962 !! html/php
26963 <p>x
26964 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
26965 y
26966 "<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>"
26967 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
26968 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) foo
26969 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
26970 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, foo
26971 </p>
26972 !! end
26973
26974 !! test
26975 Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
26976 !! options
26977 parsoid=html2wt
26978 !! html/parsoid
26979 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\
26980 -<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p>
26981 !! wikitext
26982 http://example.com.,;:!?\
26983 -http://example.com:
26984 !! html/php
26985 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.,;:!?\
26986 -<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
26987 </p>
26988 !! end
26989
26990 !! test
26991 Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
26992 !! options
26993 parsoid=html2wt
26994 !! html/parsoid
26995 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
26996 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
26997 X<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
26998 !! wikitext
26999 RFC 123<nowiki/>4
27000 RFC 123<nowiki/>y
27001 X<nowiki/>RFC 123<nowiki/>y
27002 !! end
27003
27004 !! test
27005 Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
27006 !! options
27007 parsoid=html2wt
27008 !! html/parsoid
27009 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
27010 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
27011 -<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
27012 </p>
27013 !! wikitext
27014 RFC 123?foo
27015 RFC 123&foo
27016 -RFC 123-
27017 !! html/php
27018 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>?foo
27019 <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
27020 -<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>-
27021 </p>
27022 !! end
27023
27024 !! test
27025 Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300)
27026 !! options
27027 parsoid=html2wt
27028 !! html/parsoid
27029 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4
27030 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
27031 X<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
27032 !! wikitext
27033 PMID 123<nowiki/>4
27034 PMID 123<nowiki/>y
27035 X<nowiki/>PMID 123<nowiki/>y
27036 !! end
27037
27038 !! test
27039 Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300)
27040 !! options
27041 parsoid=html2wt
27042 !! html/parsoid
27043 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo
27044 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo
27045 -<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>-
27046 </p>
27047 !! wikitext
27048 PMID 123?foo
27049 PMID 123&foo
27050 -PMID 123-
27051 !! html/php
27052 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>?foo
27053 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>&amp;foo
27054 -<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>-
27055 </p>
27056 !! end
27057
27058 !! test
27059 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300)
27060 !! options
27061 parsoid=html2wt
27062 !! html/parsoid
27063 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
27064 <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
27065 a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
27066 </p>
27067 !! wikitext
27068 ISBN 1234567890<nowiki/>1
27069 ISBN 1234567890<nowiki/>x
27070 a<nowiki/>ISBN 1234567890<nowiki/>b
27071 !! end
27072
27073 !! test
27074 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (T66300)
27075 !! options
27076 parsoid=html2wt
27077 !! html/parsoid
27078 <p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
27079 !! wikitext
27080 -ISBN 1234567890's
27081 !! html/php
27082 <p>-<a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>'s
27083 </p>
27084 !! end
27085
27086 !! test
27087 Links 14. Protect link-like plain text. (Parsoid bug T78425)
27088 !! options
27089 parsoid=html2wt
27090 !! html/*
27091 <p>this is not a link: http://example.com
27092 </p>
27093 !! wikitext
27094 this is not a link: <nowiki>http://example.com</nowiki>
27095 !! end
27096
27097 !! test
27098 Links 15. Link trails can't become link prefixes.
27099 !! options
27100 language=is
27101 parsoid=html2wt
27102 !! html/parsoid
27103 <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>
27104 !! wikitext
27105 [[Söfnuður]]-[[00]]
27106 !! html/php
27107 <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>
27108 </p>
27109 !! end
27110
27111 #### --------------- Quotes ---------------
27112 #### 1. Quotes inside <b> and <i>
27113 #### 2. Link fragments separated by <i> and <b> tags
27114 #### 3. Link fragments inside <i> and <b>
27115 #### 4. No escaping needed
27116 #### --------------------------------------
27117 !! test
27118 1a. Quotes inside <b> and <i>
27119 !! options
27120 parsoid=html2wt
27121 !! html/*
27122 <p><i>'foo'</i>
27123 <i>''foo''</i>
27124 <i>'''foo'''</i>
27125 <i>foo</i>'s
27126 <b>'foo'</b>
27127 <b>''foo''</b>
27128 <b>'''foo'''</b>
27129 <b>foo'<i>bar'</i>baz</b>
27130 <b>foo</b>'s
27131 '<i>foo</i>
27132 <i>foo</i>'
27133 <i>foo'</i>'
27134 '<i>foo</i>'
27135 '<b>foo</b>
27136 <b>foo</b>'
27137 '<b>foo</b>'
27138 <i>fools'<span> errand</span></i>
27139 <i><span>fool</span>'s errand</i>
27140 '<i>foo</i> bar '<i>baz</i>
27141 a|!*#-:;+-~[]{}b'<i>x</i>
27142 </p>
27143 !! wikitext
27144 ''<nowiki/>'foo'''
27145 ''<nowiki>''foo''</nowiki>''
27146 ''<nowiki>'''foo'''</nowiki>''
27147 ''foo''<nowiki/>'s
27148 '''<nowiki/>'foo''''
27149 '''<nowiki>''foo''</nowiki>'''
27150 '''<nowiki>'''foo'''</nowiki>'''
27151 '''foo'<nowiki/>''bar'<nowiki/>''baz'''
27152 '''foo'''<nowiki/>'s
27153 '''foo''
27154 ''foo''<nowiki/>'
27155 ''foo'''<nowiki/>'
27156 '''foo''<nowiki/>'
27157 ''''foo'''
27158 '''foo'''<nowiki/>'
27159 ''''foo'''<nowiki/>'
27160 ''fools'<span> errand</span>''
27161 ''<span>fool</span>'s errand''
27162 '<nowiki/>''foo'' bar '''baz''
27163 a|!*#-:;+-~[]{}b'''x''
27164 !! end
27165
27166 !! test
27167 1b. Quotes inside <b> and <i> with other tags on same line
27168 !! options
27169 parsoid=html2wt
27170 !! html/parsoid
27171 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
27172 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
27173 <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>
27174 <a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" rel="mw:WikiLink" title="Bar">bar</a></i>
27175 '<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>
27176 '<i>foo</i> <div title="name">test</div>
27177 '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
27178 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
27179 <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>
27180 </ol>
27181 !! wikitext
27182 '''a'' foo ''[[bar]]''
27183 ''a''' foo ''[[bar]]''
27184 ''a''' foo '''{{echo|[[bar]]}}'''
27185 [[foo]] x'''[[bar]]''
27186 '''foo'' <ref>test</ref>
27187 '''foo'' <div title="name">test</div>
27188 '''foo'' and <br> bar
27189 <references />
27190 !! end
27191
27192 !! test
27193 2. Link fragments separated by <i> and <b> tags
27194 !! options
27195 parsoid=html2wt
27196 !! html/parsoid
27197 <p>[[<i>foo</i>hello]]</p>
27198 <p>[[<b>foo</b>hello]]</p>
27199 !! wikitext
27200 [[''foo''<nowiki>hello]]</nowiki>
27201
27202 [['''foo'''<nowiki>hello]]</nowiki>
27203 !! end
27204
27205 # FIXME: Escaping one or both of [[ and ]] is also acceptable --
27206 # this is one of the shortcomings of this format
27207 !! test
27208 3. Link fragments inside <i> and <b>
27209 !! options
27210 parsoid=html2wt
27211 !! html/parsoid
27212 <p><i>[[foo</i>]]</p>
27213 <p><b>[[foo</b>]]</p>
27214 !! wikitext
27215 ''[[foo''<nowiki>]]</nowiki>
27216
27217 '''[[foo'''<nowiki>]]</nowiki>
27218 !! end
27219
27220 !! test
27221 4. No escaping needed
27222 !! options
27223 parsoid=html2wt
27224 !! html/parsoid
27225 <p>'<span><i>bar</i></span>'
27226 '<span><b>bar</b></span>'
27227 'a:b'foo
27228 </p>
27229 !! wikitext
27230 '<span>''bar''</span>'
27231 '<span>'''bar'''</span>'
27232 'a:b'foo
27233 !! end
27234
27235 #### ----------- Paragraphs ---------------
27236 #### 1. No unnecessary escapes
27237 #### --------------------------------------
27238
27239 !! test
27240 1. No unnecessary escapes
27241 !! options
27242 parsoid=html2wt
27243 !! html/parsoid
27244 <p>bar <span>[[foo]]</span>
27245 </p><p>=bar <span>[[foo]]</span>
27246 </p><p>[[bar <span>[[foo]]</span>
27247 </p><p>]]bar <span>[[foo]]</span>
27248 </p><p>=bar <span>foo]]</span>=
27249 </p>
27250 !! wikitext
27251 bar <span><nowiki>[[foo]]</nowiki></span>
27252
27253 =bar <span><nowiki>[[foo]]</nowiki></span>
27254
27255 [[bar <span><nowiki>[[foo]]</nowiki></span>
27256
27257 ]]bar <span><nowiki>[[foo]]</nowiki></span>
27258
27259 =bar <span>foo]]</span><nowiki>=</nowiki>
27260 !!end
27261
27262 #### ----------------------- PRE --------------------------
27263 !! test
27264 1. Leading whitespace in SOL context should be escaped
27265 !! options
27266 parsoid=html2wt
27267 !! html/parsoid
27268 <p> a</p>
27269
27270 <p> a</p>
27271
27272 <p> a(tab)</p>
27273
27274 <p> a
27275 <!--cmt-->
27276 a</p>
27277
27278 <p>a
27279 b</p>
27280
27281 <p>a
27282 b</p>
27283
27284 <p>a
27285 b</p>
27286 !! wikitext
27287 <nowiki> </nowiki>a
27288
27289 <nowiki> </nowiki> a
27290
27291 a(tab)
27292
27293 <nowiki> </nowiki> a
27294 <!--cmt-->
27295 <nowiki> </nowiki>a
27296
27297 a
27298 <nowiki> </nowiki>b
27299
27300 a
27301 b
27302
27303 a
27304 b
27305 !! html/php
27306 <p> a
27307 </p><p> a
27308 </p><p> a(tab)
27309 </p><p> a
27310 a
27311 </p><p>a
27312 b
27313 </p><p>a
27314 b
27315 </p><p>a
27316 b
27317 </p>
27318 !! end
27319
27320 !! test
27321 2. Leading whitespace in non-indent-pre contexts should not be escaped
27322 !! options
27323 parsoid=html2wt
27324 !! html/parsoid
27325 <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>
27326 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
27327 <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>
27328 b</span></li>
27329 </ol>
27330 !! wikitext
27331 foo <ref>''a''
27332 b</ref>
27333 <references />
27334 !! end
27335
27336 !! test
27337 3. Leading whitespace in indent-pre suppressing contexts should not be escaped
27338 !! options
27339 parsoid=html2wt
27340 !! html/parsoid
27341 <blockquote>
27342 <p>
27343 a
27344 <span>b</span>
27345 c</p>
27346 </blockquote>
27347 !! wikitext
27348 <blockquote>
27349 a
27350 <span>b</span>
27351 c
27352 </blockquote>
27353 !! end
27354
27355 !! test
27356 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
27357 !! options
27358 parsoid=html2wt
27359 !! html/parsoid
27360 <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>
27361 !! wikitext
27362 [[File:Foobar.jpg|thumb|caption]]
27363 !! end
27364
27365 !! test
27366 5. Nowiki escaping should account for indent-pres
27367 !! options
27368 parsoid=html2wt
27369 !! html/parsoid
27370 <pre>==foo==</pre>
27371 !! wikitext
27372 ==foo==
27373 !! end
27374
27375 !! test
27376 T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
27377 !! options
27378 parsoid=html2wt
27379 !! html/parsoid
27380 <pre>
27381 * foo
27382 * bar
27383 </pre>
27384 !! wikitext
27385 * foo
27386 * bar
27387 !! end
27388
27389 !! test
27390 Whitespace scrubbing in SOL position should account for SOL-sensitive wikitext markup
27391 !! options
27392 parsoid = {
27393 "modes": ["html2wt"],
27394 "scrubWikitext": true
27395 }
27396 !! html/parsoid
27397 <p> foo</p>
27398 <p> %foo</p>
27399 <p> *foo</p>
27400 <p> #foo</p>
27401 <p> =foo=</p>
27402 <p><link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid="{}"> *foo</p>
27403 <p> <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid="{}">*foo</p>
27404 <p> <!--boo-->*foo</p>
27405 <p><!--boo--> *foo</p>
27406 <p><!--a--> <!--b--> <!--c--> <!--d--> <!--e--> foo</p>
27407 <p><!--a--> <!--b--> <!--c--> <!--d--> <!--e--> *foo</p>
27408 !! wikitext
27409 foo
27410
27411 %foo
27412
27413 <nowiki/>*foo
27414
27415 <nowiki/>#foo
27416
27417 <nowiki/>=foo=
27418
27419 [[Category:Foo]]
27420 <nowiki/>*foo
27421
27422 [[Category:Foo]]
27423 <nowiki>*</nowiki>foo
27424
27425 <nowiki/><!--boo-->*foo
27426
27427 <!--boo--><nowiki/>*foo
27428
27429 <!--a--><!--b--><!--c--><!--d--><!--e-->foo
27430
27431 <!--a--><nowiki/><!--b--><!--c--><!--d--><!--e-->*foo
27432 !! end
27433
27434 #### --------------- Behavior Switches --------------------
27435
27436 !! test
27437 1. Valid behavior switches should be escaped
27438 !! options
27439 parsoid=html2wt
27440 !! html/parsoid
27441 __TOC__
27442 <i>__TOC__</i>
27443 !! wikitext
27444 <nowiki>__TOC__</nowiki>
27445 ''<nowiki>__TOC__</nowiki>''
27446 !! end
27447
27448 !! test
27449 2. Invalid behavior switches should not be escaped
27450 !! options
27451 parsoid=html2wt
27452 !! html/parsoid
27453 __TOO__
27454 __|__
27455 !! wikitext
27456 __TOO__
27457 __|__
27458 !! end
27459
27460 # We use indent-pre as an indirect way to test for sol-transparent behavior.
27461 !! test
27462 Behavior switches should be SOL-transparent
27463 !! options
27464 parsoid=html2wt
27465 !! html/parsoid
27466 <meta property="mw:PageProp/toc" />
27467
27468 <!-- this one's bogus -->
27469 <pre>__TOO__</pre>
27470
27471 <pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre>
27472
27473 <meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre>
27474 !! wikitext
27475 __TOC__
27476
27477 <!-- this one's bogus -->
27478 __TOO__
27479
27480 __TOC__ foo
27481
27482 __TOC__
27483 bar
27484 !! end
27485
27486 #### --------------- HTML tags ---------------
27487 #### 1. a tags
27488 #### 2. other tags
27489 #### 3. multi-line html tag
27490 #### 4. extension tags
27491 #### -----------------------------------------
27492 !! test
27493 1. a tags
27494 !! options
27495 parsoid=html2wt
27496 !! html/parsoid
27497 &lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
27498 !! wikitext
27499 <a href="http://google.com">google</a>
27500 !! end
27501
27502 !! test
27503 2. other tags
27504 !! options
27505 parsoid=html2wt
27506 !! html/parsoid
27507 <ul><li> &lt;div&gt;foo&lt;/div&gt;</li>
27508 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
27509 <li> &lt;td&gt;</li></ul>
27510
27511 !! wikitext
27512 * <nowiki><div>foo</div></nowiki>
27513 * <nowiki><div style="color:red">foo</div></nowiki>
27514 * <nowiki><td></nowiki>
27515 !! end
27516
27517 !! test
27518 3. multi-line html tag
27519 !! options
27520 parsoid=html2wt
27521 !! html/parsoid
27522 <p>&lt;div
27523 &gt;foo&lt;/div
27524 &gt;
27525 </p>
27526 !! wikitext
27527 <nowiki><div
27528 >foo</div
27529 ></nowiki>
27530 !! end
27531
27532 !! test
27533 4. extension tags
27534 !! options
27535 parsoid=html2wt
27536 !! html/parsoid
27537 <p>&lt;ref&gt;foo&lt;/ref&gt;
27538 </p><p>&lt;ref&gt;bar
27539 </p><p>baz&lt;/ref&gt;
27540 </p>
27541 !! wikitext
27542 <nowiki><ref>foo</ref></nowiki>
27543
27544 <nowiki><ref>bar</nowiki>
27545
27546 baz<nowiki></ref></nowiki>
27547 !! end
27548
27549 !! test
27550 Parsoid: newline inducing block nodes don't suppress <nowiki>
27551 !! options
27552 parsoid=html2wt
27553 !! html/parsoid
27554 a<h1>foo</h1>
27555 !! wikitext
27556 <nowiki> </nowiki>a
27557
27558 = foo =
27559 !! end
27560
27561 #### --------------- Others ---------------
27562 !! test
27563 Escaping nowikis
27564 !! options
27565 parsoid=html2wt
27566 !! html/parsoid
27567 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
27568 </p>
27569 !! wikitext
27570 &lt;nowiki&gt;foo&lt;/nowiki&gt;
27571 !! end
27572
27573 ## The quote-char in the input is necessary for triggering the bug
27574 !! test
27575 (T54035) Nowiki-escaping should not get tripped by " :" in text
27576 !! options
27577 parsoid=html2wt
27578 !! html/parsoid
27579 <p>foo's bar :</p>
27580 !! wikitext
27581 foo's bar :
27582 !! end
27583
27584 #----------- End of wikitext escaping tests --------------
27585
27586 !! test
27587
27588 Tag-like HTML structures are passed through as text
27589 !! wikitext
27590 <x y>
27591
27592 <x.y>
27593
27594 <x-y>
27595
27596 1>2
27597
27598 x<y
27599
27600 a>b
27601
27602 1<d e>f
27603 !! html
27604 <p>&lt;x y&gt;
27605 </p><p>&lt;x.y&gt;
27606 </p><p>&lt;x-y&gt;
27607 </p><p>1&gt;2
27608 </p><p>x&lt;y
27609 </p><p>a&gt;b
27610 </p><p>1&lt;d e&gt;f
27611 </p>
27612 !! end
27613
27614 !! test
27615 HTML tag with necessary entities in attributes
27616 !! wikitext
27617 <span title="&amp;amp;">foo</span>
27618 !! html
27619 <p><span title="&amp;amp;">foo</span>
27620 </p>
27621 !! end
27622
27623 !! test
27624 HTML tag with 'unnecessary' entity encoding in attributes
27625 !! wikitext
27626 <span title="&amp;">foo</span>
27627 !! html
27628 <p><span title="&amp;">foo</span>
27629 </p>
27630 !! end
27631
27632 !! test
27633 HTML tag with broken attribute value quoting
27634 !! options
27635 parsoid=wt2html,html2html
27636 !! wikitext
27637 <span title="Hello world>Foo</span>
27638 !! html/php
27639 <p><span title="Hello world">Foo</span>
27640 </p>
27641 !! html/parsoid
27642 <p><span title="Hello world">Foo</span></p>
27643 !! end
27644
27645 !! test
27646 Self-closed tag with broken attribute value quoting
27647 !! options
27648 parsoid=wt2html,html2html
27649 !! wikitext
27650 <div title="Hello world />Foo
27651 !! html/php+tidy
27652 <div title="Hello world"></div><p>Foo
27653 </p>
27654 !! html/parsoid
27655 <div title="Hello world " data-parsoid='{"stx":"html","selfClose":true}'></div><p>Foo</p>
27656 !! end
27657
27658 !! test
27659 Table with broken attribute value quoting
27660 !! options
27661 parsoid=wt2html,html2html
27662 !! wikitext
27663 {|
27664 | title="Hello world|Foo
27665 |}
27666 !! html/php
27667 <table>
27668 <tr>
27669 <td title="Hello world">Foo
27670 </td></tr></table>
27671
27672 !! html/parsoid
27673 <table>
27674 <tr>
27675 <td title="Hello world">Foo
27676 </td></tr></table>
27677
27678 !! end
27679
27680 !! test
27681 Table with broken attribute value quoting on consecutive lines
27682 !! options
27683 parsoid=wt2html,html2html
27684 !! wikitext
27685 {|
27686 | title="Hello world|Foo
27687 | style="color:red|Bar
27688 |}
27689 !! html/php
27690 <table>
27691 <tr>
27692 <td title="Hello world">Foo
27693 </td>
27694 <td style="color:red">Bar
27695 </td></tr></table>
27696
27697 !! html/parsoid
27698 <table><tbody>
27699 <tr>
27700 <td title="Hello world">Foo
27701 </td><td style="color: red">Bar
27702 </td></tr></tbody></table>
27703
27704 !! end
27705
27706 !!test
27707 Accept empty td cell attribute
27708 !! wikitext
27709 {|
27710 | align="center" |foo|| |
27711 |}
27712 !! html
27713 <table>
27714 <tr>
27715 <td align="center">foo</td>
27716 <td>
27717 </td></tr></table>
27718
27719 !!end
27720
27721 !!test
27722 Non-empty attributes in th-cells
27723 !! wikitext
27724 {|
27725 !Foo!! style="color: red" |Bar
27726 |}
27727 !! html
27728 <table>
27729 <tr>
27730 <th>Foo</th>
27731 <th style="color: red">Bar
27732 </th></tr></table>
27733
27734 !!end
27735
27736 !!test
27737 Accept empty attributes in th-cells
27738 !! wikitext
27739 {|
27740 !|foo!!|bar
27741 |}
27742 !! html
27743 <table>
27744 <tr>
27745 <th>foo</th>
27746 <th>bar
27747 </th></tr></table>
27748
27749 !!end
27750
27751 !!test
27752 Empty table rows go away
27753 !! wikitext
27754 {|
27755 |Hello
27756 |there
27757 |- class="foo"
27758 |-
27759 |}
27760 !! html
27761 <table>
27762 <tr>
27763 <td>Hello
27764 </td>
27765 <td>there
27766 </td></tr>
27767
27768 </table>
27769
27770 !! end
27771
27772 ###
27773 ### Parsoid-centric tests for testing RTing of inter-element separators
27774 ### Edge cases not tested by existing parser tests and specific to
27775 ### Parsoid-specific serialization strategies.
27776 ###
27777
27778 !!test
27779 RT-ed inter-element separators should be valid separators
27780 !! wikitext
27781 {|
27782 |- [[foo]]
27783 |}
27784 !! html/php
27785 <table>
27786
27787 </table>
27788
27789 !! html/parsoid
27790 <table>
27791 <tbody><tr class='mw-empty-elt' data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
27792 </tbody></table>
27793 !!end
27794
27795 # Parsoid-only test of a DOM pass
27796 !!test
27797 Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out
27798 !! wikitext
27799 {|
27800 |<small>foo
27801 bar
27802 |}
27803
27804 {|
27805 |<small>foo<small>
27806 |}
27807 !! html/parsoid
27808 <table>
27809 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo
27810 <p>bar</p></small></td></tr>
27811 </tbody></table>
27812
27813 <table>
27814 <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>
27815 </tbody></table>
27816 !!end
27817
27818 # Note that the "style" attribute is really a template parameter here.
27819 # The = would have to be {{=}} if you wanted the literal.
27820 !!test
27821 Empty TD followed by TD with tpl-generated attribute
27822 !! wikitext
27823 {|
27824 |-
27825 |
27826 |{{echo|style='color:red'}}|foo
27827 |}
27828 !! html
27829 <table>
27830
27831 <tr>
27832 <td>
27833 </td>
27834 <td>foo
27835 </td></tr></table>
27836
27837 !!end
27838
27839 !!test
27840 Indented table with an empty td
27841 !! wikitext
27842 {|
27843 |-
27844 |
27845 |foo
27846 |}
27847 !! html
27848 <table>
27849
27850 <tr>
27851 <td>
27852 </td>
27853 <td>foo
27854 </td></tr></table>
27855
27856 !!end
27857
27858 !! test
27859 Indented table with blank lines in between (T85627)
27860 !! wikitext
27861 {|
27862 |foo
27863
27864
27865 |}
27866 !! html/php
27867 <table>
27868 <tr>
27869 <td>foo
27870 <p><br />
27871 </p>
27872 </td></tr></table>
27873
27874 !! html/parsoid
27875 <table>
27876 <tbody><tr><td>foo
27877 <p>
27878 <br /></p></td></tr>
27879 </tbody></table>
27880 !! end
27881
27882 !!test
27883 Indented block & table
27884 !! wikitext
27885 <div>foo</div>
27886 {|
27887 |foo
27888 |}
27889 !! html/php
27890 <div>foo</div>
27891 <table>
27892 <tr>
27893 <td>foo
27894 </td></tr></table>
27895
27896 !! html/parsoid
27897 <div data-parsoid='{"stx":"html"}'>foo</div>
27898 <table><tbody>
27899 <tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>foo</td></tr>
27900 </tbody></table>
27901 !!end
27902
27903 !! test
27904 Indent and comment before table row
27905 !! wikitext
27906 {|
27907 <!--hi-->|-
27908 |there
27909 |}
27910 !! html/php
27911 <table>
27912
27913 <tr>
27914 <td>there
27915 </td></tr></table>
27916
27917 !! html/parsoid
27918 <table>
27919 <!--hi--><tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
27920 <td data-parsoid='{"autoInsertedEnd":true}'> there</td></tr>
27921 </tbody></table>
27922 !! end
27923
27924 # Parsoid-specific since PHP parser doesn't handle this mixed tbl-wikitext
27925 !!test
27926 Empty TR followed by a template-generated TR
27927 !!options
27928 parsoid
27929 !! wikitext
27930 {|
27931 |-
27932 {{echo|<tr><td>foo</td></tr>}}
27933 |}
27934 !! html
27935 <table>
27936 <tbody>
27937 <tr class='mw-empty-elt'></tr>
27938 <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}}]}'>
27939 <td>foo</td></tr>
27940 </tbody></table>
27941 !!end
27942
27943 ## PHP and parsoid output differ for this, and since this is primarily
27944 ## for testing Parsoid's serializer, marking this Parsoid only
27945 !!test
27946 Empty TR followed by mixed-ws-comment line should RT correctly
27947 !!options
27948 parsoid
27949 !! wikitext
27950 {|
27951 |-
27952 <!--c-->
27953 |-
27954 <!--c--> <!--d-->
27955 |}
27956 !! html
27957 <table>
27958 <tbody>
27959 <tr class='mw-empty-elt'></tr>
27960 <!--c-->
27961 <tr>
27962 <!--c--> </tr><!--d-->
27963 </tbody></table>
27964
27965 !!end
27966
27967 !!test
27968 Multi-line image caption generated by templates with/without trailing newlines
27969 !! wikitext
27970 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]]
27971 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]]
27972 !! html/parsoid
27973 <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>
27974 <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>
27975 !!end
27976
27977 !! test
27978 New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly
27979 !! options
27980 parsoid=html2wt
27981 !! html/parsoid
27982 <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>
27983
27984 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{}'/><h1>new heading</h1>
27985 !! wikitext
27986 <includeonly>foo</includeonly>
27987 new para
27988
27989 [[Category:Foo]]
27990
27991 = new heading =
27992 !! end
27993
27994 ## PHP emits broken html for this, and since this is primarily
27995 ## a Parsoid serializer test, marking this Parsoid only
27996 !!test
27997 Improperly nested inline or quotes tags with whitespace in between
27998 !! wikitext
27999 <span> <s>x</span> </s>
28000 ''' ''x''' ''
28001 !! html/parsoid
28002 <p><span> <s>x</s></span><s> </s>
28003 <b> <i>x</i></b><i> </i>
28004 </p>
28005 !!end
28006
28007 !!test
28008 Encapsulate protected attributes from wt
28009 !! wikitext
28010 <div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
28011
28012 {| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true"
28013 |ok
28014 |}
28015 !! html/parsoid
28016 <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>
28017
28018 <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">
28019 <tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'>ok</td></tr>
28020 </tbody></table>
28021 !!end
28022
28023 ## Currently the p-wrapper is fragile in how it adds / removes transformations.
28024 ## Having nested or stray pre tags results in the attempt to add duplicates,
28025 ## causing an assertion fail. This test tries to prevent that situation.
28026 !! test
28027 Ensure ParagraphWrapper can deal with stray closing pre tags
28028 !! options
28029 parsoid=wt2html
28030 !! wikitext
28031 plain text</pre>
28032 !! html/parsoid
28033 <p>plain text</p>
28034 !! end
28035
28036 ## Remex doesn't account for fostered content.
28037 !! test
28038 1. Ensure fostered text content is wrapped in element nodes
28039 !! options
28040 parsoid=wt2html
28041 !! wikitext
28042 <table>hi</table><table>ho</table>
28043 !! html/php+tidy
28044 hi<table></table>ho<table></table>
28045 !! html/parsoid
28046 <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>
28047 !! end
28048
28049 ## Remex doesn't account for fostered content.
28050 !! test
28051 2. Ensure fostered text content is wrapped in element nodes (traps regressions around fostered marker on the element getting lost)
28052 !! options
28053 parsoid=wt2html,wt2wt
28054 !! wikitext
28055 <table>
28056 <tr> || ||
28057 <td> a
28058 </table>
28059 !! html/php+tidy
28060 || ||
28061 <table>
28062 <tbody><tr><td> a
28063 </td></tr></tbody></table>
28064 !! html/parsoid
28065 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'> || ||</p>
28066 <table data-parsoid='{"stx":"html"}'>
28067 <tbody><tr data-parsoid='{"stx":"html","autoInsertedEnd":true}'><td data-parsoid='{"stx":"html","autoInsertedEnd":true}'> a
28068 </td></tr></tbody></table>
28069 !! end
28070
28071 ## Remex doesn't account for fostered content.
28072 !! test
28073 Encapsulation properly handles null DSR information from foster box
28074 !! options
28075 parsoid=wt2html,wt2wt
28076 !! wikitext
28077 {{echo|<table>foo<tr><td>bar</td></tr></table>}}
28078 !! html/parsoid
28079 <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>
28080 !! end
28081
28082 ## Remex doesn't account for fostered content.
28083 !! test
28084 1. Encapsulate foster-parented transclusion content
28085 !! options
28086 parsoid=wt2wt,wt2html
28087 !! wikitext
28088 <table>{{echo|foo<tr><td>bar</td></tr>}}</table>
28089 !! html/php+tidy
28090 foo<table><tbody><tr><td>bar</td></tr></tbody></table>
28091 !! html/parsoid
28092 <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>
28093 !! end
28094
28095 !! test
28096 2. Encapsulate foster-parented transclusion content
28097 !! options
28098 parsoid=wt2wt,wt2html
28099 !! wikitext
28100 <table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table>
28101 !! html/parsoid
28102 <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>
28103 <table>
28104 <tbody>
28105 <tr>
28106 <td>bar</td>
28107 </tr>
28108 </tbody>
28109 </table>
28110 !! end
28111
28112 !! test
28113 3. Encapsulate foster-parented transclusion content
28114 !! options
28115 parsoid=wt2wt,wt2html
28116 !! wikitext
28117 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
28118 !! html/parsoid
28119 <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;]}">
28120 <p>foo</p>
28121 </div>
28122 <table>
28123 <tbody>
28124 <tr>
28125 <td>bar</td>
28126 </tr>
28127 </tbody>
28128 </table>
28129 !! end
28130
28131 !! test
28132 4. Encapsulate foster-parented transclusion content
28133 !! options
28134 parsoid=wt2wt,wt2html
28135 !! wikitext
28136 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
28137 !! html/parsoid
28138 <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;]}">
28139 <p>foo</p>
28140 </div>
28141 <table>
28142 <tbody>
28143 <tr>
28144 <td>bar</td>
28145 </tr>
28146 </tbody>
28147 </table>
28148 !! end
28149
28150 ## Remex doesn't account for fostered content.
28151 !! test
28152 5. Encapsulate foster-parented transclusion content
28153 !!options
28154 parsoid=wt2wt,wt2html
28155 !! wikitext
28156 <table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table>
28157 !! html/php+tidy
28158 foo<table><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table>
28159 !! html/parsoid
28160 <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>
28161 !! end
28162
28163 ## Remex doesn't account for fostered content.
28164 !! test
28165 6. Encapsulate foster-parented transclusion content
28166 !! options
28167 parsoid=wt2wt,wt2html
28168 !! wikitext
28169 <table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p>
28170 !! html/php+tidy
28171 foo<table><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table><p>ok</p>
28172 !! html/parsoid
28173 <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>
28174 !! end
28175
28176 !! test
28177 7. Encapsulate foster-parented transclusion content
28178 !!options
28179 parsoid=wt2wt,wt2html
28180 !! wikitext
28181 <table>{{echo|<p>foo</p>}}<td>bar</td></table>
28182 !! html/parsoid
28183 <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>
28184 <table>
28185 <tbody>
28186 <tr>
28187 <td>bar</td>
28188 </tr>
28189 </tbody>
28190 </table>
28191 !! end
28192
28193 ## Remex doesn't account for fostered content.
28194 # Note that the wt is broken on purpose: the = should be {{=}} if you
28195 # don't want it to be a template parameter key.
28196 !! test
28197 8. Encapsulate foster-parented transclusion content
28198 !! options
28199 parsoid=wt2wt,wt2html
28200 !! wikitext
28201 {{echo|a
28202 }}{|{{echo|style='color:red'}}
28203 |-
28204 |b
28205 |}
28206 !! html/php+tidy
28207 <p>a
28208 </p>
28209 <table>
28210
28211 <tbody><tr>
28212 <td>b
28213 </td></tr></tbody></table>
28214 !! html/parsoid
28215 <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">
28216 </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">
28217 <tbody><tr>
28218 <td>b
28219 </td></tr></tbody></table>
28220 !! end
28221
28222 ## Remex doesn't account for fostered content.
28223 !! test
28224 9. Encapsulate foster-parented transclusion content
28225 !!options
28226 parsoid=wt2wt,wt2html
28227 !! wikitext
28228 <table>{{echo|hi</table>hello}}
28229 !! html/php+tidy
28230 hi<table></table><p>hello
28231 </p>
28232 !! html/parsoid
28233 <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>
28234 !! end
28235
28236 !! test
28237 Table in fosterable position
28238 !!options
28239 parsoid=wt2html
28240 !! wikitext
28241 {{OpenTable}}
28242 <div>
28243 {|
28244 |}
28245 </div>
28246 |}
28247 !! html/parsoid
28248 <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">
28249 </span>
28250 <table about="#mwt1" data-parsoid='{"autoInsertedEnd":true}'></table>
28251
28252 <table>
28253 </table>
28254 !! end
28255
28256 # Parsoid only for T66747
28257 !! test
28258 Properly encapsulate empty-content transclusions in fosterable positions
28259 !! wikitext
28260 <table>
28261 {{#if:|
28262 <td>foo</td>
28263 }}
28264 </table>
28265 !! html/parsoid
28266 <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"}]]}'>
28267
28268 </table>
28269 !! end
28270
28271 ## No longer captures its original intention
28272 !! test
28273 Always encapsulate foster box when template range is expanded to table
28274 !! options
28275 disabled
28276 parsoid=wt2wt
28277 !! wikitext
28278 {|
28279 hello
28280 {{OpenTable}}
28281 |}
28282 !! html/parsoid
28283
28284 !! end
28285
28286 !! test
28287 T115289: Unclosed table
28288 !! wikitext
28289 {{echo|<table>}}<!--c-->[[Category:Two]]
28290 !! html/parsoid
28291 <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>
28292 !! end
28293
28294 !! test
28295 T115289: Don't migrate newlines out of tables with fostered content
28296 !! wikitext
28297 <table><td></td>{{echo|<tr>[[Category:One]]}}<!--c-->[[Category:Two]]
28298 !! html/parsoid
28299 <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>
28300 !! end
28301
28302 !! test
28303 T73074: More fostering fun
28304 !! wikitext
28305 <table><td></td>{{echo|<tr>}}<!--c-->[[Category:Two]]
28306 !! html/parsoid
28307 <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>
28308 !! end
28309
28310 !!test
28311 Support <object> element with .data attribute
28312 !!options
28313 parsoid=html2wt
28314 !! html/parsoid
28315 <object data="test.swf"></object>
28316 !! wikitext
28317 <object data="test.swf"></object>
28318 !!end
28319
28320 !! test
28321 Don't block XML namespace declaration
28322 !! wikitext
28323 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span>
28324 !! html/php
28325 <p><span xmlns:dct="http&#58;//purl.org/dc/terms/" property="dct:title">MediaWiki</span>
28326 </p>
28327 !! html/parsoid
28328 <p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p>
28329 !! end
28330
28331 # -----------------------------------------------------------------
28332 # The following section of tests are primarily to spec requirements
28333 # around Parsoid's serialization (old, new, edited content)
28334 #
28335 # All these tests are marked Parsoid html2wt and html2html only
28336 # ----------------------------------------------------------------
28337
28338 !! test
28339 Ignore rel attribute in a-tags during serialization to url-links
28340 !! options
28341 parsoid=html2wt
28342 !! html/parsoid
28343 <a href='http://en.wikipedia.org/wiki/Foobar'>http://en.wikipedia.org/wiki/Foobar</a>
28344 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:ExtLink'>http://en.wikipedia.org/wiki/Foobar</a>
28345 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:WikiLink'>http://en.wikipedia.org/wiki/Foobar</a>
28346 !! wikitext
28347 http://en.wikipedia.org/wiki/Foobar
28348 http://en.wikipedia.org/wiki/Foobar
28349 http://en.wikipedia.org/wiki/Foobar
28350 !! end
28351
28352 # 'mi' is a localinterwiki prefix as well as a language
28353 !! test
28354 Serialize interwiki links pointing to the current wiki as plain wiki links (T67869)
28355 !! options
28356 parsoid=html2wt
28357 !! html/parsoid
28358 <p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p>
28359 !! wikitext
28360 [[Foo]]
28361 !! end
28362
28363 !! test
28364 Parsoid should accept interwiki shortcuts
28365 !! options
28366 parsoid=html2wt
28367 !! html/parsoid
28368 <p><a rel='mw:WikiLink' href='./fr:Foo'>Foo</a>
28369 <a rel='mw:ExtLink' href='./fr:Foo'>Foo</a>
28370 <a href='./fr:Foo'>Foo</a></p>
28371 <p><a rel='mw:WikiLink' href='fr%3AFoo'>Foo</a>
28372 <a rel='mw:ExtLink' href='fr%3AFoo'>Foo</a>
28373 <a href='fr%3AFoo'>Foo</a></p>
28374 <p><a href='FR%3AFoo'>Foo</a>
28375 <a href='./FR:Foo'>Foo</a></p>
28376 !! wikitext
28377 [[:fr:Foo|Foo]]
28378 [[:fr:Foo|Foo]]
28379 [[:fr:Foo|Foo]]
28380
28381 [[:fr:Foo|Foo]]
28382 [[:fr:Foo|Foo]]
28383 [[:fr:Foo|Foo]]
28384
28385 [[:fr:Foo|Foo]]
28386 [[:fr:Foo|Foo]]
28387 !! end
28388
28389 !! test
28390 Parsoid should not accept invalid interwiki shortcuts
28391 !! options
28392 parsoid=html2wt
28393 !! html/parsoid
28394 <p><a rel='mw:WikiLink' href='news:Foo'>Foo</a>
28395 <a rel='mw:ExtLink' href='news:Foo'>Foo</a>
28396 <a href='news:Foo'>Foo</a></p>
28397 !! wikitext
28398 [news:Foo Foo]
28399 [news:Foo Foo]
28400 [news:Foo Foo]
28401 !! end
28402
28403 # See T93839
28404 !! test
28405 New wikilinks should be serialized properly
28406 !! options
28407 parsoid=html2wt
28408 !! html/parsoid
28409 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
28410 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
28411 <a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a>
28412 <a href="http://en.wikipedia.org/wiki/Foo">http://en.wikipedia.org/wiki/Foo</a>
28413 <a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a>
28414 !! wikitext
28415 [[Foo]]
28416 [[Foo]]
28417 [[:en:Foo|//en.wikipedia.org/wiki/Foo]]
28418 http://en.wikipedia.org/wiki/Foo
28419 [[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]]
28420 !! end
28421
28422 !! test
28423 New wiki links (href variations)
28424 !! options
28425 parsoid=html2wt
28426 !! html/parsoid
28427 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
28428 <a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a>
28429 <a rel="mw:WikiLink" href="Foo bar">Foo_bar</a>
28430 <a rel="mw:WikiLink" href="./Toxine_bact%C3%A9rienne">Toxine bactérienne</a>
28431 !! wikitext
28432 [[Foo_bar]]
28433 [[Foo_bar]]
28434 [[Foo_bar]]
28435 [[Toxine bactérienne]]
28436 !! end
28437
28438 !! test
28439 New wiki links (content string variations)
28440 !! options
28441 parsoid=html2wt
28442 !! html/parsoid
28443 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
28444 <a rel="mw:WikiLink" href="./Foo_bar">Foo bar</a>
28445 <a rel="mw:WikiLink" href="./Foo_bar">./Foo_bar</a>
28446 !! wikitext
28447 [[Foo_bar]]
28448 [[Foo bar]]
28449 [[Foo_bar|./Foo_bar]]
28450 !! end
28451
28452 !! test
28453 New category links (href variations)
28454 !! options
28455 parsoid=html2wt
28456 !! html/parsoid
28457 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" />
28458 <link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" />
28459 <link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" />
28460 !! wikitext
28461 [[Category:Toxine bactérienne]]
28462 [[Category:Toxine bactérienne]]
28463 [[Category:Toxine bactérienne]]
28464 !! end
28465
28466 !! test
28467 New sol transparent links don't need indent-pre nowiki protection
28468 !! options
28469 parsoid=html2wt
28470 language=de
28471 !! html/parsoid
28472 <link rel="mw:PageProp/redirect" href="./Main_Page">
28473 <!-- this is good --> <link rel="mw:PageProp/Category" href="./Category:Good" />
28474 <!-- this is great --> <link rel="mw:PageProp/Category" href="./Kategorie:Great" />
28475 !! wikitext
28476 #WEITERLEITUNG [[Main Page]]
28477 <!-- this is good --> [[Category:Good]]
28478 <!-- this is great --> [[Kategorie:Great]]
28479 !! end
28480
28481 !! test
28482 New interlanguage links (href variations)
28483 !! options
28484 parsoid=html2wt
28485 !! html/parsoid
28486 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" />
28487 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" />
28488 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" />
28489 !! wikitext
28490 [[es:Toxine bactérienne]]
28491 [[es:Toxine_bactérienne]]
28492 [[es:Toxine_bactérienne]]
28493 !! end
28494
28495 !! test
28496 Image: Modifying size of an image (1)
28497 !! options
28498 parsoid={
28499 "modes": ["wt2wt"],
28500 "changes": [
28501 ["img[height]", "attr", "height", "22"],
28502 ["img[width]", "attr", "width", "200"]
28503 ]
28504 }
28505 !! wikitext
28506 [[Image:Foobar.jpg|230x230px]]
28507 !! wikitext/edited
28508 [[Image:Foobar.jpg|200x200px]]
28509 !!end
28510
28511 !! test
28512 Image: Modifying size of an image (2)
28513 !! options
28514 parsoid={
28515 "modes": ["wt2wt"],
28516 "changes": [
28517 ["img[height]", "attr", "height", "100"],
28518 ["img[width]", "attr", "width", "500"]
28519 ]
28520 }
28521 !! wikitext
28522 [[Image:Foobar.jpg|230x230px]]
28523 !! wikitext/edited
28524 [[Image:Foobar.jpg|500x500px]]
28525 !!end
28526
28527 # Change in size is ignored so long as class='mw-default-size'
28528 !! test
28529 Image: Modifying size of an image (3)
28530 !! options
28531 parsoid={
28532 "modes": ["wt2wt"],
28533 "changes": [
28534 ["figure[class]", "removeClass", "mw-default-size"],
28535 ["figure img", "attr", "height", "19"],
28536 ["figure img", "attr", "width", "170"]
28537 ]
28538 }
28539 !! wikitext
28540 [[Image:Foobar.jpg|thumb]]
28541 !! wikitext/edited
28542 [[Image:Foobar.jpg|thumb|170x170px]]
28543 !!end
28544
28545 !! test
28546 Image: Modifying alignment of an image (T50665)
28547 !! options
28548 parsoid={
28549 "modes": ["wt2wt"],
28550 "changes": [
28551 ["figure[class]", "removeClass", "mw-halign-right"],
28552 ["figure[class]", "addClass", "mw-halign-left"]
28553 ]
28554 }
28555 !! wikitext
28556 [[Image:Foobar.jpg|thumb|caption|right]]
28557 !! wikitext/edited
28558 [[Image:Foobar.jpg|thumb|caption|left]]
28559 !! end
28560
28561 !! test
28562 Image: Modifying mw-default-size of an frameless image (T64805)
28563 !! options
28564 parsoid={
28565 "modes": ["wt2wt"],
28566 "changes": [
28567 ["figure.mw-default-size", "removeClass", "mw-default-size"]
28568 ]
28569 }
28570 !! wikitext
28571 [[Image:Foobar.jpg|frameless|right]]
28572 !! wikitext/edited
28573 [[Image:Foobar.jpg|frameless|right|220x220px]]
28574 !! end
28575
28576 !! test
28577 Image: Modifying valign of an image (T51221)
28578 !! options
28579 parsoid={
28580 "modes": ["wt2wt"],
28581 "changes": [
28582 ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
28583 ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
28584 ]
28585 }
28586 !! wikitext
28587 [[File:Foobar.jpg|20px|middle]]
28588 !! wikitext/edited
28589 [[File:Foobar.jpg|20px|text-top]]
28590 !! end
28591
28592 !! test
28593 Image: Modifying alt attribute of an image (T58400)
28594 !! options
28595 parsoid={
28596 "modes": ["wt2wt"],
28597 "changes": [
28598 ["img[alt]", "attr", "alt", "some alternate edited text"]
28599 ]
28600 }
28601 !! wikitext
28602 [[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
28603 !! wikitext/edited
28604 [[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
28605 !!end
28606
28607 !! test
28608 Image: Modifying caption of an image
28609 !! options
28610 parsoid={
28611 "modes": ["wt2wt"],
28612 "changes": [
28613 ["figcaption", "text", "new caption"]
28614 ]
28615 }
28616 !! wikitext
28617 [[Image:Foobar.jpg|thumb|original caption]]
28618 !! wikitext/edited
28619 [[Image:Foobar.jpg|thumb|new caption]]
28620 !!end
28621
28622 !! test
28623 Image: empty alt attribute (T50924)
28624 !! options
28625 parsoid
28626 !! wikitext
28627 [[File:Foobar.jpg|thumb|alt=|bar]]
28628 !! html
28629 <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>
28630 !! end
28631
28632 !! test
28633 Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
28634 !! options
28635 parsoid=html2wt
28636 language=ar
28637 disabled
28638 !! html/parsoid
28639 <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>
28640 !! wikitext
28641 [[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
28642 !! end
28643
28644 !! test
28645 Image: Block level image should have \n before and after
28646 !! wikitext
28647 123
28648 [[File:Foobar.jpg|right|thumb|150x150px]]
28649 456
28650 !! html/parsoid
28651 <p>123</p>
28652 <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>
28653 <p>456</p>
28654 !! end
28655
28656 !! test
28657 Image: New block level image should have \n before and after (existing content)
28658 !! wikitext
28659 123
28660 [[File:Foobar.jpg|right|thumb|150x150px]]
28661 456
28662 !! html/parsoid
28663 <p>123</p>
28664 <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>
28665 <p>456</p>
28666 !! end
28667
28668 !! test
28669 Image: upright option (parsoid)
28670 !! wikitext
28671 [[File:Foobar.jpg|thumb|upright|caption]]
28672 [[File:Foobar.jpg|thumb|upright=0.5|caption]]
28673 [[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]]
28674 !! html/parsoid
28675 <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>
28676 <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>
28677 <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>
28678 !! end
28679
28680 !! test
28681 Image: upright option is ignored on inline and frame images (parsoid)
28682 !! wikitext
28683 [[File:Foobar.jpg|500x500px|upright=0.5|caption]]
28684 !! html/parsoid
28685 <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>
28686 !! end
28687
28688 !! test
28689 Image: in template parameter with empty parameter
28690 !! wikitext
28691 {{echo|[[File:Foobar.jpg|link=]]}}
28692 !! html/parsoid
28693 <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>
28694 !! end
28695
28696 !! test
28697 Image: from basic HTML (1)
28698 !! options
28699 parsoid=html2wt
28700 !! html/parsoid
28701 <span typeof="mw:Image">
28702 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
28703 </span>
28704 !! wikitext
28705 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
28706 !! end
28707
28708 !! test
28709 Image: from basic HTML (2)
28710 !! options
28711 parsoid=html2wt
28712 !! html/parsoid
28713 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
28714 !! wikitext
28715 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
28716 !! end
28717
28718 !! test
28719 Image: from basic HTML (3)
28720 !! options
28721 parsoid=html2wt
28722 !! html/parsoid
28723 <a href="Main"><img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"></a>
28724 !! wikitext
28725 [[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
28726 !! end
28727
28728 !! test
28729 Image: from basic HTML (4)
28730 !! options
28731 parsoid=html2wt
28732 !! html/parsoid
28733 <img src="./File:Foobar.jpg">
28734 !! wikitext
28735 [[File:Foobar.jpg|link=]]
28736 !! end
28737
28738 !! test
28739 Image: Invalid title as link
28740 !! wikitext
28741 [[File:Foobar.jpg|link=<]]
28742 !! html/php
28743 <p><a href="/wiki/File:Foobar.jpg" class="image" title="link=&lt;"><img alt="link=&lt;" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
28744 </p>
28745 !! html/parsoid
28746 <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>
28747 !! end
28748
28749 !! test
28750 Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
28751 !! options
28752 parsoid=html2wt
28753 !! html/parsoid
28754 <ul>
28755 <li><p>foo</p></li>
28756 </ul>
28757 !! wikitext
28758 * foo
28759 !! end
28760
28761 !! test
28762 Lists: Serialize correctly even when list tags has unneeded whitespace between tags
28763 !! options
28764 parsoid=html2wt
28765 !! html/parsoid
28766 <ul> <li>foo</li></ul>
28767 !! wikitext
28768 * foo
28769 !! end
28770
28771 !! test
28772 Don't strip leading whitespace when handling indent-pre suppressing tags
28773 !! options
28774 parsoid=html2wt
28775 !! html/parsoid
28776 <table>
28777 <tr><td> indented row</td></tr>
28778 </table>
28779 <blockquote><p>
28780 <b>This is very bold of you!</b>
28781 </p>
28782 <table><tr><td>
28783 indented cell (no pre-wrapping!)
28784 </td></tr></table>
28785 </blockquote>
28786 <p>foo</p>
28787 <div>bar</div>
28788 !! wikitext
28789 {|
28790 | indented row
28791 |}
28792 <blockquote>
28793 '''This is very bold of you!'''
28794
28795 {|
28796 |
28797 indented cell (no pre-wrapping!)
28798 |}
28799 </blockquote>
28800 foo
28801 <div>bar</div>
28802 !! end
28803
28804 !! test
28805 Nowiki-wrap leading whitespace when handling indent-pre inducing tags
28806 !! options
28807 parsoid=html2wt
28808 !! html/parsoid
28809 <p>foo</p>
28810 <span>bar</span>
28811
28812 <span>foo2
28813 </span>bar2
28814
28815 <div>foo</div>
28816 <span>bar</span>
28817
28818 <div>
28819 <span>foo</span>
28820 </div>
28821 !! wikitext
28822 foo
28823
28824 <span>bar</span>
28825
28826 <span>foo2
28827 <nowiki> </nowiki></span>bar2
28828
28829 <div>foo</div>
28830 <nowiki> </nowiki><span>bar</span>
28831
28832 <div>
28833 <nowiki> </nowiki><span>foo</span>
28834 </div>
28835 !! end
28836
28837 !! test
28838 Lists: Dont insert newlines in a serialized list item.
28839 !! options
28840 parsoid=html2wt
28841 !! html/parsoid
28842 <ul><li>a<br>b</li><li>c</li></ul>
28843 !! wikitext
28844 * a<br />b
28845 * c
28846 !! end
28847
28848 !! test
28849 1. Headings: Force sol-transparent links and behavior switches to serialize before/after
28850 !! options
28851 parsoid={
28852 "modes": ["html2wt"],
28853 "scrubWikitext": false
28854 }
28855 !! html/parsoid
28856 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
28857 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
28858
28859 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
28860 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
28861
28862 <h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2>
28863
28864 <h2><meta property="mw:PageProp/toc" /> ok</h2>
28865 !! wikitext
28866 == hello there [[Category:A1]] ==
28867
28868 == [[Category:A2]] hi pal ==
28869
28870 == <!--foo--> [[Category:A3]] how goes it ==
28871
28872 == it goes well [[Category:A4]] <!--bar--> ==
28873
28874 ==howdy [[Category:A5]]==
28875
28876 == __TOC__ ok ==
28877 !! end
28878
28879 !! test
28880 2. Headings: Force sol-transparent links and behavior switches to serialize before/after
28881 !! options
28882 parsoid={
28883 "modes": ["html2wt"],
28884 "scrubWikitext": true
28885 }
28886 !! html/parsoid
28887 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
28888 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
28889
28890 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
28891 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
28892
28893 <h2><meta property="mw:PageProp/toc" /> ok</h2>
28894 !! wikitext
28895 == hello there ==
28896 [[Category:A1]]
28897 [[Category:A2]]
28898
28899 == hi pal ==
28900
28901 <!--foo-->[[Category:A3]]
28902
28903 == how goes it ==
28904
28905 == it goes well ==
28906 [[Category:A4]] <!--bar-->
28907
28908 __TOC__
28909
28910 == ok ==
28911 !! end
28912
28913 !! test
28914 Headings: Don't hoist metas that come from templates
28915 !! options
28916 parsoid={
28917 "modes": ["html2wt"],
28918 "scrubWikitext": true
28919 }
28920 !! html/parsoid
28921 <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>
28922 !! wikitext
28923 == {{echo|foo [[Category:Foo]]}} ==
28924 !! end
28925
28926 !! test
28927 Headings: Category in ref isn't hoisted
28928 !! options
28929 parsoid={
28930 "modes": ["html2wt"],
28931 "scrubWikitext": true
28932 }
28933 !! html/parsoid
28934 <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>
28935
28936 <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>
28937 !! wikitext
28938 == foo <ref>bar
28939 [[Category:Baz]] </ref> ==
28940
28941 <references />
28942 !! end
28943
28944 !! test
28945 Parsoid: Serialize positional parameters with = in them as named parameter
28946 !! options
28947 parsoid=html2wt
28948 !! html/parsoid
28949 <p about="#mwt1" typeof="mw:Transclusion"
28950 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p>
28951
28952 <p about="#mwt1" typeof="mw:Transclusion"
28953 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p>
28954
28955 <!--Orig params with data-parsoid has heuristics for handling = chars-->
28956 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
28957 <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>
28958 !! wikitext
28959 {{echo|1=f=oo}}
28960
28961 {{echo|1=f=oo|2=bar}}
28962
28963 <!--Orig params with data-parsoid has heuristics for handling = chars-->
28964 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
28965 {{echo|<nowiki>f=oo</nowiki>|bar}}
28966 !! end
28967
28968 !! test
28969 Parsoid: Serialize positional parameters with = in extlink as named parameter
28970 !! options
28971 parsoid=html2wt
28972 !! html/parsoid
28973 <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>
28974 !! wikitext
28975 {{echo|1=http://stuff?is=ok}}
28976 !! end
28977
28978 !! test
28979 Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes
28980 !! options
28981 parsoid=html2wt
28982 !! html/parsoid
28983 <div>a<p>b</p></div>
28984 <div>a
28985 <p>b</p></div>
28986 <div>
28987 a
28988 <p>b</p></div>
28989 !! wikitext
28990 <div>a
28991 b
28992 </div>
28993 <div>a
28994 b
28995 </div>
28996 <div>
28997 a
28998
28999 b
29000 </div>
29001 !! end
29002
29003 !! test
29004 Substrings resembling wikitext in hrefs should not get nowiki escapes
29005 !! options
29006 parsoid=html2wt
29007 !! html/parsoid
29008 <a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a>
29009 !! wikitext
29010 [[Foo''bar''baz]]
29011 !! end
29012
29013 !! test
29014 Enforce single-line context in the serializer
29015 !! options
29016 parsoid=html2wt
29017 !! html/parsoid
29018 <h2>testing
29019 123</h2>
29020
29021 <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">
29022 </span><span about="#mwt1">you</span> </h2>
29023
29024 <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>
29025
29026 <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
29027 there</span></li></ol>
29028
29029 <ul><li>asd
29030 sdf</li></ul>
29031
29032 <ul><li>foo
29033 bar
29034 baz</li>
29035 <li>foo <b>bar</b>
29036 baz</li></ul>
29037
29038 <dl><dt>hi
29039 ho </dt><dd data-parsoid='{"stx":"row"}'> hi
29040 ho</dd></dl>
29041
29042 <dl><dd> <table>
29043 <tbody><tr><td> ha
29044 ha
29045 ha</td></tr>
29046 </tbody></table></dd></dl>
29047 !! wikitext
29048 == testing 123 ==
29049
29050 == hi {{bogus|there
29051 you}} ==
29052
29053 == foo <ref>hello
29054 there</ref> ==
29055
29056 <references />
29057
29058 * asd sdf
29059
29060 * foo bar baz
29061 * foo '''bar''' baz
29062
29063 ; hi ho : hi ho
29064
29065 : {|
29066 | ha
29067 ha
29068 ha
29069 |}
29070 !! end
29071
29072 !! test
29073 Serialize new placeholder space without spans
29074 !! options
29075 parsoid=html2wt
29076 !! html/parsoid
29077 <p>foo<span typeof="mw:Placeholder"> </span>: bar</p>
29078
29079 <p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p>
29080
29081 <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>
29082 !! wikitext
29083 foo : bar
29084
29085 foo : bar
29086
29087 <ref>foo : bar</ref>ok
29088 !! end
29089
29090
29091 #-----------------------
29092 # Tag minimization tests
29093 #-----------------------
29094
29095 !! test
29096 1. I/B quote minimization: wikitext-only tags should be combined
29097 !! options
29098 parsoid=html2wt
29099 !! html/parsoid
29100 <p><i>A</i><i>B</i></p>
29101 <p><b>A</b><b>B</b></p>
29102 <p><i>A</i><b><i>B</i></b></p>
29103 <p><b>A</b><i><b>B</b></i></p>
29104 <p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p>
29105 <p><i><b>A</b></i><i><b>B</b></i></p>
29106 <p><i><b>A</b></i><b><i>B</i></b></p>
29107 <p><b><i>A</i></b><i><b>B</b></i></p>
29108 !! wikitext
29109 ''AB''
29110
29111 '''AB'''
29112
29113 ''A'''B'''''
29114
29115 '''A''B'''''
29116
29117 '''A''BC''D'''
29118
29119 '''''AB'''''
29120
29121 '''''AB'''''
29122
29123 '''''AB'''''
29124 !! end
29125
29126 !! test
29127 2. I/B quote minimization: wikitext and html tags should not be combined
29128 !! options
29129 parsoid=html2wt
29130 !! html/parsoid
29131 <p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
29132 <p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
29133 !! wikitext
29134 ''A''<i>B</i>
29135
29136 ''A''<nowiki/>'''<i>B</i>'''
29137 !! end
29138
29139 !! test
29140 3. I/B quote minimization: templated content stops minimization
29141 !! options
29142 parsoid=html2wt
29143 !! html/parsoid
29144 <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>
29145 <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>
29146 !! wikitext
29147 ''A''{{echo|''B''}}
29148
29149 ''A''{{echo|'''''B'''''}}
29150 !! end
29151
29152 !! test
29153 4. I/B quote minimization: new content should be mimimized with adjacent old content
29154 !! options
29155 parsoid=html2wt
29156 !! html/parsoid
29157 <p><i>A</i><i>B</i></p>
29158 <p><b>A</b><b>B</b></p>
29159 <p><i>A</i><b><i>B</i></b></p>
29160 !! wikitext
29161 ''AB''
29162
29163 '''AB'''
29164
29165 ''A'''B'''''
29166 !! end
29167
29168 !! test
29169 5a. Merge adjacent quote nodes if they've been edited
29170 !! options
29171 parsoid={
29172 "modes": ["wt2wt", "selser"],
29173 "changes": [
29174 ["p", "contents", "remove", ":contains('b')"]
29175 ]
29176 }
29177 !! wikitext
29178 ''a''b''c''
29179 !! wikitext/edited
29180 ''ac''
29181 !! end
29182
29183 !! test
29184 5b. Merge adjacent quote nodes if they've been edited
29185 !! options
29186 parsoid={
29187 "modes": ["wt2wt", "selser"],
29188 "changes": [
29189 ["#x", "remove"]
29190 ]
29191 }
29192 !! wikitext
29193 ''a''<span id="x">b</span>''c''
29194 !! wikitext/edited
29195 ''ac''
29196 !! end
29197
29198 !! test
29199 1. Merge adjacent link nodes as long as at least one element is new
29200 !! options
29201 parsoid={
29202 "modes": ["html2wt"],
29203 "scrubWikitext": true
29204 }
29205 !! html/parsoid
29206 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29207 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29208 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a>
29209 !! wikitext
29210 [[Football]]
29211 [[Football]]
29212 [[Football|Foot]][[Football|ball]]
29213 !! end
29214
29215 !! test
29216 2. Merge adjacent link nodes and enable additional normalizations
29217 !! options
29218 parsoid={
29219 "modes": ["html2wt"],
29220 "scrubWikitext": true
29221 }
29222 !! html/parsoid
29223 <a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a>
29224 !! wikitext
29225 ''[[Football]]''
29226 !! end
29227
29228 !! test
29229 3. Don't merge adjacent link nodes if scrubWikitext is false
29230 !! options
29231 parsoid={
29232 "modes": ["html2wt"],
29233 "scrubWikitext": false
29234 }
29235 !! html/parsoid
29236 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29237 !! wikitext
29238 [[Football|Foot]][[Football|ball]]
29239 !! end
29240
29241 !! test
29242 1. Move format tags outside of WikiLink
29243 !! options
29244 parsoid={
29245 "modes": ["html2wt"],
29246 "scrubWikitext": true
29247 }
29248 !! html/parsoid
29249 <a rel="mw:WikiLink" href="./Football"><i>Football</i></a>
29250 <a rel="mw:WikiLink" href="./Football"><i><b>Football</b></i></a>
29251 <a rel="mw:WikiLink" href="./Football"><u><i><b>Football</b></i></u></a>
29252 !! wikitext
29253 ''[[Football]]''
29254 '''''[[Football]]'''''
29255 <u>'''''[[Football]]'''''</u>
29256 !! end
29257
29258 !! test
29259 2. Move format tags outside of WikiLink with mergable A tags
29260 !! options
29261 parsoid={
29262 "modes": ["html2wt"],
29263 "scrubWikitext": true
29264 }
29265 !! html/parsoid
29266 <a rel="mw:WikiLink" href="./Football"><i><b>Foot</b></i></a><a rel="mw:WikiLink" href="./Football"><i><b>ball</b></i></a>
29267 !! wikitext
29268 '''''[[Football]]'''''
29269 !! end
29270
29271 !! test
29272 3. Move format tags outside of WikiLink while preserving formats already outside WikiLink
29273 !! options
29274 parsoid={
29275 "modes": ["html2wt"],
29276 "scrubWikitext": true
29277 }
29278 !! html/parsoid
29279 <font color="red"><a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><u><b>Foo</b></u></a></font>
29280 !! wikitext
29281 <font color="red"><u>'''[[Foo]]'''</u></font>
29282 !! end
29283
29284 !! test
29285 4. Do not move format tags outside of WikiLink which includes attributes color, style and class
29286 !! options
29287 parsoid={
29288 "modes": ["html2wt"],
29289 "scrubWikitext": true
29290 }
29291 !! html/parsoid
29292 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><font color="red">Foo</font></a>
29293 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><span style="color: blue; font-size: 46px;">Foo></span></a>
29294 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><span class="Bar">Foo</span></a>
29295 !! wikitext
29296 [[Foo|<font color="red">Foo</font>]]
29297 [[Foo|<span style="color: blue; font-size: 46px;">Foo></span>]]
29298 [[Foo|<span class="Bar">Foo</span>]]
29299 !! end
29300
29301 !! test
29302 5. T194083 Regression test: Manual edit test that also enables scrubWikitext to move format tags outside wikilinks
29303 !! options
29304 parsoid={
29305 "modes": ["selser"],
29306 "scrubWikitext": true,
29307 "changes": [
29308 ["a", "html", "<i>Foo</i>"]
29309 ]
29310 }
29311 !! wikitext
29312 [[Foo]]
29313 !! wikitext/edited
29314 ''[[Foo]]''
29315 !! end
29316
29317 !! test
29318 6. Regression test: Manual edit test to ensure diff markers are not lost
29319 !! options
29320 parsoid={
29321 "modes": ["selser"],
29322 "scrubWikitext": true,
29323 "changes": [
29324 ["i", "wrap", "<a href='./Foo' rel='mw:WikiLink'></a>"]
29325 ]
29326 }
29327 !! wikitext
29328 ''Foo''
29329 !! wikitext/edited
29330 ''[[Foo]]''
29331 !! end
29332
29333 !! test
29334 7. T194083 Regression test: Manual edit test to ensure nested diff markers aren't inserted
29335 !! options
29336 parsoid={
29337 "modes": ["selser"],
29338 "scrubWikitext": true,
29339 "changes": [
29340 ["div", "after", "\n<p><a href='./Foo' rel='mw:WikiLink'>Foo </a>, placeholder</p>"]
29341 ]
29342 }
29343 !! wikitext
29344 <div>placeholder</div>
29345 !! wikitext/edited
29346 <div>placeholder</div>
29347 [[Foo]] , placeholder
29348 !! end
29349
29350 #------------------------------
29351 # End of tag minimization tests
29352 #------------------------------
29353
29354 !!test
29355 T56262: New entities
29356 !! options
29357 parsoid=html2wt
29358 !! html/parsoid
29359 <span typeof="mw:Entity">&nbsp;</span>
29360 !! wikitext
29361 &nbsp;
29362 !! end
29363
29364 ## Note that there is no wikitext output for 'unknownproperty' ##
29365 ## Unknown magic words are silently dropped ##
29366
29367 !! test
29368 Magic words
29369 !! options
29370 parsoid=html2wt
29371 !! html/parsoid
29372 <meta property='mw:PageProp/toc' />
29373 <meta property='mw:PageProp/notoc' />
29374 <meta property='mw:PageProp/forcetoc' />
29375 <meta property='mw:PageProp/index' />
29376 <meta property='mw:PageProp/noindex' />
29377 <meta property='mw:PageProp/nogallery' />
29378 <meta property='mw:PageProp/noeditsection' />
29379 <meta property='mw:PageProp/notitleconvert' />
29380 <meta property='mw:PageProp/nocontentconvert' />
29381 <meta property='mw:PageProp/unknownproperty' />
29382 !! wikitext
29383 __TOC__
29384 __NOTOC__
29385 __FORCETOC__
29386 __INDEX__
29387 __NOINDEX__
29388 __NOGALLERY__
29389 __NOEDITSECTION__
29390 __NOTITLECONVERT__
29391 __NOCONTENTCONVERT__
29392 !! end
29393
29394 !! test
29395 Consecutive <pre>s should not get merged
29396 !! options
29397 parsoid=html2wt,html2html
29398 !! html/parsoid
29399 <pre>a</pre><pre>b</pre>
29400
29401 <pre>c
29402 </pre><pre>
29403 d</pre>
29404
29405 <pre>e
29406
29407 </pre><pre>
29408
29409 f</pre>
29410 !! wikitext
29411 a
29412
29413 b
29414
29415 c
29416
29417 d
29418
29419 e
29420
29421
29422
29423 f
29424 !! end
29425
29426 !! test
29427 Edited ISBN links not serializable as ISBN links should serialize as wikilinks
29428 !! options
29429 parsoid=html2wt
29430 !! html/parsoid
29431 <a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a>
29432 !! wikitext
29433 [[Special:BookSources/1234567890|ISBN 1234567895]]
29434 !! end
29435
29436 !! test
29437 Edited RFC links not serializable as RFC links should serialize as extlinks
29438 !! options
29439 parsoid=html2wt
29440 !! html/parsoid
29441 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
29442 !! wikitext
29443 [https://tools.ietf.org/html/rfc123 New RFC]
29444 !! end
29445
29446 !! test
29447 Edited PMID links not serializable as PMID links should serialize as extlinks
29448 !! options
29449 parsoid=html2wt
29450 !! html/parsoid
29451 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a>
29452 !! wikitext
29453 [//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID]
29454 !! end
29455
29456 !! test
29457 WTS of autolinks with trailing/surrounding context
29458 !! options
29459 parsoid=html2wt
29460 !! html/parsoid
29461 <p><a href="http://cscott.net">http://cscott.net</a><b>foo</b></p>
29462 <p><a href="http://cscott.net">http://cscott.net</a><b data-parsoid='{"stx":"html"}'>foo</b></p>
29463 <p><b><a href="http://cscott.net">http://cscott.net</a></b></p>
29464 <p><b><a href="http://cscott.net">http://cscott.net</a> </b></p>
29465 <p><b><a href="http://cscott.net">http://cscott.net</a>x</b></p>
29466 <p><a href="http://cscott.net">http://cscott.net</a>x</p>
29467 !! wikitext
29468 http://cscott.net'''foo'''
29469
29470 http://cscott.net<b>foo</b>
29471
29472 '''http://cscott.net'''
29473
29474 '''http://cscott.net '''
29475
29476 '''http://cscott.net<nowiki/>x'''
29477
29478 http://cscott.net<nowiki/>x
29479 !! end
29480
29481 !! test
29482 WTS of autolinks with nowikis (round-trip)
29483 !! wikitext
29484 x<nowiki/>http://cscott.net<nowiki/>x
29485 !! html/parsoid
29486 <p>x<a rel="mw:ExtLink" class="external free" href="http://cscott.net">http://cscott.net</a>x</p>
29487 !! end
29488
29489 # this is the "easy" test because it leaves in place all the
29490 # data-parsoid information indicating this is an autolink
29491 !! test
29492 WTS of autolinks with escapes (editing)
29493 !! options
29494 parsoid={
29495 "modes": ["wt2wt"],
29496 "changes": [
29497 [ "span", "remove" ]
29498 ]
29499 }
29500 !! wikitext
29501 x<nowiki/>http://cscott.net<nowiki/>x
29502 !! wikitext/edited
29503 x<nowiki/>http://cscott.net<nowiki/>x
29504 !! end
29505
29506 !! test
29507 WTS of edited autolink-like text (T103364)
29508 !! options
29509 parsoid={
29510 "modes": ["wt2wt"],
29511 "changes": [
29512 [ "span[typeof]", "removeAttr", "typeof" ]
29513 ]
29514 }
29515 !! wikitext
29516 Not a link: <nowiki>http://example.com</nowiki>.
29517 !! wikitext/edited
29518 Not a link: <span><nowiki>http://example.com</nowiki></span>.
29519 !! end
29520
29521 !! test
29522 WTS of newly-authored autolink-like text (T103364)
29523 !! options
29524 parsoid=html2wt
29525 !! html/parsoid
29526 <p>http://example.com is not a link.</p>
29527 !! wikitext
29528 <nowiki>http://example.com</nowiki> is not a link.
29529 !! end
29530
29531 !! test
29532 WTS of autolink-like text after an autolink (T108563)
29533 !! options
29534 parsoid=html2wt
29535 !! html/parsoid
29536 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p>
29537 !! wikitext
29538 http://example.com <nowiki>http://example.com</nowiki> is not a link.
29539 !! end
29540
29541 !! test
29542 Magic links inside links (not autolinked)
29543 !! wikitext
29544 [[Foo|http://example.com]]
29545 [[Foo|RFC 1234]]
29546 [[Foo|PMID 1234]]
29547 [[Foo|ISBN 123456789x]]
29548
29549 [http://foo.com http://example.com]
29550 [http://foo.com RFC 1234]
29551 [http://foo.com PMID 1234]
29552 [http://foo.com ISBN 123456789x]
29553 !! html+tidy
29554 <p><a href="/wiki/Foo" title="Foo">http://example.com</a>
29555 <a href="/wiki/Foo" title="Foo">RFC 1234</a>
29556 <a href="/wiki/Foo" title="Foo">PMID 1234</a>
29557 <a href="/wiki/Foo" title="Foo">ISBN 123456789x</a>
29558 </p><p><a rel="nofollow" class="external text" href="http://foo.com">http://example.com</a>
29559 <a rel="nofollow" class="external text" href="http://foo.com">RFC 1234</a>
29560 <a rel="nofollow" class="external text" href="http://foo.com">PMID 1234</a>
29561 <a rel="nofollow" class="external text" href="http://foo.com">ISBN 123456789x</a>
29562 </p>
29563 !! html/parsoid
29564 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a>
29565 <a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a>
29566 <a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a>
29567 <a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p>
29568
29569 <p><a rel="mw:ExtLink" class="external text" href="http://foo.com">http://example.com</a>
29570 <a rel="mw:ExtLink" class="external text" href="http://foo.com">RFC 1234</a>
29571 <a rel="mw:ExtLink" class="external text" href="http://foo.com">PMID 1234</a>
29572 <a rel="mw:ExtLink" class="external text" href="http://foo.com">ISBN 123456789x</a></p>
29573 !! end
29574
29575 !! test
29576 Magic links inside image captions (autolinked)
29577 !! wikitext
29578 [[File:Foobar.jpg|thumb|http://example.com]]
29579 [[File:Foobar.jpg|thumb|RFC 1234]]
29580 [[File:Foobar.jpg|thumb|PMID 1234]]
29581 [[File:Foobar.jpg|thumb|ISBN 123456789x]]
29582 !! html+tidy
29583 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div></div></div>
29584 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a></div></div></div>
29585 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a></div></div></div>
29586 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div><a href="/wiki/Special:BookSources/123456789X" class="internal mw-magiclink-isbn">ISBN 123456789x</a></div></div></div>
29587 !! html/parsoid
29588 <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>
29589 <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>
29590 <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>
29591 <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>
29592 !! end
29593
29594 !! test
29595 WTS of magic word text (T109371)
29596 !! options
29597 parsoid=html2wt
29598 !! html/parsoid
29599 <p>RFC 1234</p>
29600 <p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p>
29601 <p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p>
29602 !! wikitext
29603 <nowiki>RFC 1234</nowiki>
29604
29605 [http://foo.com RFC 1234]
29606
29607 [[Foo|RFC 1234]]
29608 !! end
29609
29610 !! test
29611 Edited Redirect link should emit a non-piped wikitext link
29612 !! options
29613 parsoid=html2wt
29614 !! html/parsoid
29615 <link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>
29616 !! wikitext
29617 #REDIRECT [[Bar]]
29618 !! end
29619
29620 !! test
29621 T75121: Infer extension name from typeOf if data-mw is not present
29622 !! options
29623 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
29624 !! html/parsoid
29625 <div typeOf="mw:Extension/foo"></div>
29626 !! wikitext
29627 <foo />
29628 !! end
29629
29630 # Note that the <p> wrapping isn't present in PHP parser output
29631 # The important thing for this test is that P-wrapping doesn't
29632 # interfere with the <nowiki> protection for leading - in <td>
29633 # (which isn't necessary for <th>).
29634 !! test
29635 T88318: p-wrapped dash in table.
29636 !! options
29637 parsoid=html2wt,wt2wt
29638 !! html/parsoid
29639 <table><tbody>
29640 <tr><th><p>-</p></th><th><p>- </p></th></tr>
29641 <tr><td><p>-</p></td><td><p>- </p></td></tr>
29642 <tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr>
29643 </tbody></table>
29644 !! wikitext
29645 {|
29646 !-
29647 !-
29648 |-
29649 |<nowiki>-</nowiki>
29650 |<nowiki>- </nowiki>
29651 |-
29652 |<small>-</small>
29653 |<br />
29654 -
29655 |<br />-
29656 |}
29657 !! html/php+tidy
29658 <table>
29659 <tbody><tr>
29660 <th>-
29661 </th>
29662 <th>-
29663 </th></tr>
29664 <tr>
29665 <td>-
29666 </td>
29667 <td>-
29668 </td></tr>
29669 <tr>
29670 <td><small>-</small>
29671 </td>
29672 <td><br />
29673 <p>-
29674 </p>
29675 </td>
29676 <td><br />-
29677 </td></tr></tbody></table>
29678 !! end
29679
29680 !! test
29681 T149209: WTS: Handle newlines in table cells properly
29682 !! options
29683 parsoid=html2wt
29684 !! html/parsoid
29685 <table>
29686 <tbody>
29687 <tr><td>a
29688 b
29689 </td><td data-parsoid='{"stx":"row"}'>c</td></tr>
29690 <tr><td><p>x</p>
29691 </td><td data-parsoid='{"stx":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr>
29692 </tbody></table>
29693 <table>
29694 <tbody>
29695 <tr><th>a
29696 b
29697 </th><th data-parsoid='{"stx":"row"}'>c</th></tr>
29698 <tr><th><p>x</h>
29699 </th><th data-parsoid='{"stx":"row"}'>y</th></tr>
29700 </tbody></table>
29701 !! wikitext
29702 {|
29703 |a
29704 b
29705 |c
29706 |-
29707 |x
29708 {{!}}y
29709 |}
29710 {|
29711 !a
29712 b
29713 !c
29714 |-
29715 !x
29716 !y
29717 |}
29718 !! end
29719
29720 !! test
29721 T149209: Selser: Handle newlines in table cells properly
29722 !! options
29723 parsoid={
29724 "modes": ["selser"],
29725 "changes": [
29726 [ "#h1", "html", "a\nb\n" ],
29727 [ "#h2", "html", "a\nb\n" ],
29728 [ "#c1", "html", "a\nb\n" ],
29729 [ "#c2", "html", "<p>a</p>" ],
29730 [ "#c3", "html", "<p>a</p>" ],
29731 [ "#c4", "html", "edit-me<p>a</p>" ]
29732 ]
29733 }
29734 !! wikitext
29735 {|
29736 ! id="h1" |edit-me!!1
29737 |-
29738 ! id="h2" |edit-me||2
29739 |-
29740 | id="c1" |edit-me||3
29741 |-
29742 | id="c2" |edit-me||4
29743 |-
29744 | id="c3" |edit-me||p||q||r
29745 |-
29746 | id="c4" |edit-me||p||q||r
29747 |}
29748 !! wikitext/edited
29749 {|
29750 ! id="h1" |a
29751 b
29752 !1
29753 |-
29754 ! id="h2" |a
29755 b
29756 !2
29757 |-
29758 | id="c1" |a
29759 b
29760 |3
29761 |-
29762 | id="c2" |a
29763 |4
29764 |-
29765 | id="c3" |a
29766 |p||q||r
29767 |-
29768 | id="c4" |edit-me
29769 a
29770 |p||q||r
29771 |}
29772 !! end
29773
29774 !! test
29775 HTML id attribute with Parsoid-like element ids should not be serialized to wikitext
29776 !! options
29777 parsoid=html2wt
29778 !! html/parsoid
29779 <table id='mwAb'>
29780 <td id='mwAc'>foo</td>
29781 <td id='serialize-this'>bar</td>
29782 </table>
29783 !! wikitext
29784 {|
29785 |foo
29786 | id="serialize-this" |bar
29787 |}
29788 !! end
29789
29790 !! test
29791 Parsoid-like element ids should not be serialized to wikitext unless shadowed
29792 !! options
29793 parsoid=html2wt
29794 !! html/parsoid
29795 <div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div>
29796 !! wikitext
29797 <div id="hello">ok</div>
29798 !! end
29799
29800 !! test
29801 Testing serialization after deletion in references
29802 !! options
29803 parsoid={
29804 "modes": ["wt2wt"],
29805 "changes": [
29806 ["#x", "remove"]
29807 ]
29808 }
29809 !! wikitext
29810 hi <ref><div id="x">ho</div></ref>
29811
29812 <references />
29813 !! wikitext/edited
29814 hi <ref></ref>
29815
29816 <references />
29817 !! end
29818
29819 !!test
29820 Testing serialization after deletion of table cells
29821 !!options
29822 parsoid={
29823 "modes": ["wt2wt", "selser"],
29824 "changes": [
29825 ["#x", "remove"]
29826 ]
29827 }
29828 !!wikitext
29829 {|
29830 !h1 !!h2 !!h3
29831 | id="x" |c1 {{!}}{{!}}{{!}}c2 |||c3
29832 |}
29833 !! wikitext/edited
29834 {|
29835 !h1!!h2!!h3
29836 |c2|||c3
29837 |}
29838 !!end
29839
29840 !! test
29841 Testing selser after addition of new row before first row (T125419)
29842 !! options
29843 parsoid={
29844 "modes": ["wt2wt", "selser"],
29845 "changes": [
29846 [ "tr", "before", "<tr><td>X</td></tr>" ]
29847 ]
29848 }
29849 !! wikitext
29850 {|
29851 |a
29852 |}
29853 !! wikitext/edited
29854 {|
29855 |X
29856 |-
29857 |a
29858 |}
29859 !! end
29860
29861 !! test
29862 Serialize new table rows in a HTML table using HTML tags
29863 !! options
29864 parsoid={
29865 "modes": ["wt2wt", "selser"],
29866 "changes": [
29867 [ "tr", "before", "<tr><td>X</td></tr>" ]
29868 ]
29869 }
29870 !! wikitext
29871 <table><tr><td>a</td></tr></table>
29872 !! wikitext/edited
29873 <table><tr><td>X</td></tr><tr><td>a</td></tr></table>
29874 !! end
29875
29876 !! test
29877 Serialize new table cells in a HTML row using HTML tags
29878 !! options
29879 parsoid={
29880 "modes": ["wt2wt", "selser"],
29881 "changes": [
29882 [ "td", "before", "<td>X</td>" ]
29883 ]
29884 }
29885 !! wikitext
29886 <table><tr><td>a</td></tr></table>
29887 !! wikitext/edited
29888 <table><tr><td>X</td><td>a</td></tr></table>
29889 !! end
29890
29891 !! test
29892 Serialize wikitext list items as HTML list items when embedded in a HTML list
29893 !! options
29894 parsoid=html2wt
29895 !! html
29896 <ul data-parsoid='{"stx": "html"}'>
29897 <li data-parsoid='{}'>a</li>
29898 <li>b</li>
29899 </ul>
29900 !! wikitext
29901 <ul>
29902 <li>a</li>
29903 <li>b</li>
29904 </ul>
29905 !! end
29906
29907 # SSS FIXME: Is this actually a good thing given the
29908 # odd nested list output that is generated by MW?
29909 # <ul><li>foo<ul>..</ul></li></ul> instead of
29910 # <ul><li>foo</li><ul>..</ul></ul>
29911 !! test
29912 Wikitext lists can be nested inside HTML lists
29913 !! options
29914 parsoid=html2wt
29915 !! html
29916 <ul data-parsoid='{"stx": "html"}'>
29917 <li data-parsoid='{"stx": "html"}'>a
29918 <ul><li>b</li></ul>
29919 </li>
29920 </ul>
29921
29922 <ul data-parsoid='{"stx": "html"}'>
29923 <li>x
29924 <ul><li>y</li></ul>
29925 </li>
29926 </ul>
29927 !! wikitext
29928 <ul>
29929 <li>a
29930 * b
29931 </li>
29932 </ul>
29933
29934 <ul>
29935 <li>x
29936 * y
29937 </li>
29938 </ul>
29939 !! end
29940
29941 !! test
29942 WTS change modes
29943 !! options
29944 parsoid={
29945 "modes": ["wt2wt"],
29946 "changes": [
29947 [ "#xyz", "before", "<b>before</b> stuff " ],
29948 [ "#xyz", "after", " stuff <i>after</i>" ],
29949 [ "#xyz", "html", "x <b>y</b> z" ]
29950 ]
29951 }
29952 !! wikitext
29953 <span id="xyz">hello</span>
29954 !! wikitext/edited
29955 '''before''' stuff <span id="xyz">x '''y''' z</span> stuff ''after''
29956 !! end
29957
29958 !! test
29959 Never serialize a-tag as html, regardless of what data-parsoid has to say
29960 !! options
29961 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
29962 !! html/parsoid
29963 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a>
29964 !! wikitext
29965 [[Foo]]
29966 !! end
29967
29968 ## SSS FIXME: This is broken output nevertheless.
29969 ## What might be a reasonable non-broken output for this?
29970 ## This is an edge case unlikely to be seen in production
29971 ## that I am not wasting more time on this right now.
29972 !! test
29973 Never serialize a-tag as html, no matter what attributes it has
29974 !! options
29975 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
29976 !! html/parsoid
29977 <a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a>
29978 !! wikitext
29979 [http://boo.org http://boohoo.org]
29980 !! end
29981
29982 # Misnested is an indication that selser can reuse the source but these have
29983 # shown to sneak through on occasion. See T101768.
29984 # The original wikitext here is: [http://test.com [[one]] two three]
29985 !! test
29986 Strip span tags added to mark misnested links
29987 !! options
29988 parsoid=html2wt
29989 !! html/parsoid
29990 <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>
29991 !! wikitext
29992 [http://test.com][[one]] two three
29993 !! end
29994
29995 !! test
29996 Catch regression when unpacking misnested links
29997 !! options
29998 parsoid=wt2html
29999 !! wikitext
30000 {{echo|hi}}[http://example.com [[ho]]]
30001 !! html/parsoid
30002 <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>
30003 !! end
30004
30005 !! test
30006 Catch regression when unpacking with trailing content
30007 !! wikitext
30008 {{echo|Foo <references/> bar}}
30009 !! html/parsoid
30010 <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>
30011 !! end
30012
30013 !! test
30014 Use data-parsoid.firstWikitextNode to compute newline constraints for template content
30015 !! options
30016 parsoid=html2wt
30017 !! html/parsoid
30018 <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|}"]}'>
30019 <tbody><tr><td>d
30020 </td></tr>
30021 </tbody></table>
30022 !! wikitext
30023 {{echo|a}}
30024 {|{{echo|c
30025 {{!}}d
30026 }}
30027 |}
30028 !! end
30029
30030 ## This test verifies the presence and computation of this attribute indirectly
30031 ## by making an edit and ensuring that the serialization is correct (which it would be
30032 ## only if firstWikitextNode is properly set).
30033 !! test
30034 data-parsoid.firstWikitextNode should be computed properly in the presence of fostered content
30035 !! options
30036 parsoid= {
30037 "modes": ["wt2wt"],
30038 "changes": [
30039 [ "div#x", "remove" ],
30040 [ "div", "before", "<div>new</div>" ]
30041 ]
30042 }
30043 !! wikitext
30044 <div id="x">foo</div>
30045 {|
30046 {{echo|<div>boo</div>
30047 {{!}}b}}
30048 |c
30049 |}
30050 !! wikitext/edited
30051
30052 <div>new</div>
30053 {|
30054 {{echo|<div>boo</div>
30055 {{!}}b}}
30056 |c
30057 |}
30058 !! end
30059
30060 # --------------------------------------------
30061 # Tests spec'ing wikitext serialization norms |
30062 # --------------------------------------------
30063
30064 !! test
30065 Serialize multi-line indent-pre starting with wikitext syntax
30066 !! options
30067 parsoid=html2wt
30068 !! html/parsoid
30069 <pre>* 1
30070 ** 2
30071 * 3</pre>
30072 !! wikitext
30073 * 1
30074 ** 2
30075 * 3
30076 !! end
30077
30078 !! test
30079 1. Categories should always be serialized on their own line
30080 !! options
30081 parsoid=html2wt
30082 !! html/parsoid
30083 foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar
30084 !! wikitext
30085 foo
30086 [[Category:Foo]]
30087 bar
30088 !! end
30089
30090 !! test
30091 2. Categories that are part of templates should not introduce a line break
30092 !! wikitext
30093 foo {{echo|<span>bar</span> [[Category:baz]]}} bar
30094 !! html/parsoid
30095 <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>
30096 !! end
30097
30098 # Careful while editing these next 2 tests. There are \u200f characters
30099 # before and after the <link> tags in the HTML and following some
30100 # of the categories in wikitext
30101 # Do not remove these characters in edits.
30102 #
30103 # As part of the serialization, these bidi characters will get stripped.
30104 !! test
30105 RTL (\u200f) and LTR (\u200e) markers around category tags should be stripped
30106 !! options
30107 parsoid={
30108 "modes": ["html2wt"],
30109 "scrubWikitext": true
30110 }
30111 !! html/parsoid
30112 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏
30113 ‏<link rel="mw:PageProp/Category" href="./קטגוריה:_שיטות_משפט" />‏</p>
30114 !! wikitext
30115 [[קטגוריה:טקסים]]
30116 [[קטגוריה: שיטות משפט]]
30117 !! end
30118
30119 !! test
30120 RTL (\u200f) and LTR (\u200e) markers should not be stripped if followed by a text node
30121 !! options
30122 parsoid={
30123 "modes": ["html2wt"],
30124 "scrubWikitext": true
30125 }
30126 !! html/parsoid
30127 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏y</p>
30128 !! wikitext
30129 [[קטגוריה:טקסים]]
30130 ‏y
30131 !! end
30132
30133 !! test
30134 Lists: Add space after bullets
30135 !! options
30136 parsoid=html2wt
30137 !! html/parsoid
30138 <ul>
30139 <li>foo</li>
30140 <li> bar</li>
30141 <li><span> baz</span></li>
30142 </ul>
30143 !! wikitext
30144 * foo
30145 * bar
30146 * <span> baz</span>
30147 !! end
30148
30149 !! test
30150 1. Headings: Add space before/after == (T53744)
30151 !! options
30152 parsoid=html2wt
30153 !! html/parsoid
30154 <h2>foo</h2>
30155 <h2> bar</h2>
30156 <h2>baz </h2>
30157 <h2><span> baz</span></h2>
30158 !! wikitext
30159 == foo ==
30160
30161 == bar ==
30162
30163 == baz ==
30164
30165 == <span> baz</span> ==
30166 !! end
30167
30168 !! test
30169 2. Headings: Add space before/after == even after hoisted content
30170 !! options
30171 parsoid={
30172 "modes": ["html2wt"],
30173 "scrubWikitext": true
30174 }
30175 !! html/parsoid
30176 <h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2>
30177 !! wikitext
30178 [[Category:A2]]
30179
30180 == ok ==
30181 !! end
30182
30183 !! test
30184 1. Headings: suppress newly created empty headings
30185 !! options
30186 parsoid={
30187 "modes": ["html2wt"],
30188 "scrubWikitext": true
30189 }
30190 !! html/parsoid
30191 <h2></h2>
30192 !! wikitext
30193 !! end
30194
30195 !! test
30196 2. Headings: don't suppress empty headings if scrubWikitext is false
30197 !! options
30198 parsoid=html2wt
30199 !! html/parsoid
30200 <h2></h2>
30201 !! wikitext
30202 ==<nowiki/>==
30203 !! end
30204
30205 !! test
30206 3. Headings: suppress empty headings on edits
30207 !! options
30208 parsoid={
30209 "modes": ["selser"],
30210 "scrubWikitext": true,
30211 "changes": [
30212 [ "#x", "remove"]
30213 ]
30214 }
30215 !! wikitext
30216 ==<span id="x">foo</span>==
30217 !! wikitext/edited
30218 !! end
30219
30220 !! test
30221 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = true)
30222 !! options
30223 parsoid={
30224 "modes": ["html2wt"],
30225 "scrubWikitext": true
30226 }
30227 !! html/parsoid
30228 <h2>foo<br/>bar</h2>
30229 <h2>foo <span><br/>bar</span> baz</h2>
30230 !! wikitext
30231 == foo bar ==
30232
30233 == foo <span> bar</span> baz ==
30234 !! end
30235
30236 !! test
30237 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = false)
30238 !! options
30239 parsoid={
30240 "modes": ["html2wt"],
30241 "scrubWikitext": false
30242 }
30243 !! html/parsoid
30244 <h2>foo<br/>bar</h2>
30245 !! wikitext
30246 == foo<br />bar ==
30247 !! end
30248
30249 !! test
30250 1. WT Quote Tags: suppress newly created empty style tags
30251 !! options
30252 parsoid={
30253 "modes": ["html2wt"],
30254 "scrubWikitext": true
30255 }
30256 !! html/parsoid
30257 <i></i><b></b>
30258 !! wikitext
30259 !! end
30260
30261 !! test
30262 2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false
30263 !! options
30264 parsoid=html2wt
30265 !! html/parsoid
30266 <i></i><b></b>
30267 !! wikitext
30268 ''<nowiki/>'''''<nowiki/>'''
30269 !! end
30270
30271 !! test
30272 3. WT Quote Tags: suppress empty style tags on edits
30273 !! options
30274 parsoid={
30275 "modes": ["selser"],
30276 "scrubWikitext": true,
30277 "changes": [
30278 [ "#x", "remove"]
30279 ]
30280 }
30281 !! wikitext
30282 '''<span id="x">foo</span>'''
30283 !! wikitext/edited
30284 !! end
30285
30286 !! test
30287 1. Anchors: suppress newly created empty anchors
30288 !! options
30289 parsoid={
30290 "modes": ["html2wt"],
30291 "scrubWikitext": true
30292 }
30293 !! html/parsoid
30294 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
30295 !! wikitext
30296 !! end
30297
30298 !! test
30299 2. Anchors: don't suppress empty anchors if scrubWikitext is false
30300 !! options
30301 parsoid={
30302 "modes": ["html2wt"],
30303 "scrubWikitext": false
30304 }
30305 !! html/parsoid
30306 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
30307 !! wikitext
30308 [[Test|<nowiki/>]]
30309 !! end
30310
30311 !! test
30312 3. Anchors: suppress empty anchors on edits
30313 !! options
30314 parsoid={
30315 "modes": ["selser"],
30316 "scrubWikitext": true,
30317 "changes": [
30318 [ "#x", "remove"]
30319 ]
30320 }
30321 !! wikitext
30322 [[Test|<span id="x">foo</span>]]
30323 !! wikitext/edited
30324 !! end
30325
30326 !! test
30327 3a. Anchors: do not suppress numbered extlinks
30328 !! options
30329 parsoid={
30330 "modes": ["wt2wt"],
30331 "scrubWikitext": true
30332 }
30333 !! wikitext
30334 [http://foo.com]
30335 !! html/parsoid
30336 <a rel="mw:ExtLink" href="http://foo.com"></a>
30337 !! end
30338
30339 !! test
30340 3b. Anchors: do not suppress numbered extlinks
30341 !! options
30342 parsoid={
30343 "modes": ["wt2wt"],
30344 "scrubWikitext": true,
30345 "changes": [
30346 [ "#x", "remove"]
30347 ]
30348 }
30349 !! wikitext
30350 [http://foo.com <span id="x">foo</span>]
30351 !! wikitext/edited
30352 [http://foo.com]
30353 !! end
30354
30355 !!test
30356 Normalizations should be restricted to edited content
30357 !!options
30358 parsoid={
30359 "modes": ["selser"],
30360 "scrubWikitext": true,
30361 "changes": [
30362 [ "h1", "before", "<i></i>"]
30363 ]
30364 }
30365 !!wikitext
30366 a
30367 = =
30368 b
30369 !!wikitext/edited
30370 a
30371 = =
30372 b
30373 !!end
30374
30375 !! test
30376 1. Multiple normalizations (html2wt)
30377 !! options
30378 parsoid={
30379 "modes": ["html2wt"],
30380 "scrubWikitext": true
30381 }
30382 !! html
30383 <h2><i></i></h2>
30384 <p><a href='Foo' rel='mw:WikiLink'>foo<i></i>
30385 </a><b><i></i></b>x</p>
30386 !! wikitext
30387
30388 [[foo]]
30389 x
30390
30391 !! end
30392
30393 !! test
30394 2. Multiple normalizations (selser)
30395 !! options
30396 parsoid={
30397 "modes": ["selser"],
30398 "scrubWikitext": true,
30399 "changes": [
30400 [ "#x", "after", "<h1><i></i></h1>\n<p> bar<b></b></p>"]
30401 ]
30402 }
30403 !! wikitext
30404 <div id="x">foo</div>
30405 !! wikitext/edited
30406 <div id="x">foo</div>
30407 bar
30408 !! end
30409
30410 !! test
30411 1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
30412 !! options
30413 parsoid={
30414 "modes": ["html2wt"],
30415 "scrubWikitext": true
30416 }
30417 !! html/parsoid
30418 <p> hi</p>
30419 <p> hello</p>
30420 !! wikitext
30421 hi
30422
30423 hello
30424 !! end
30425
30426 !! test
30427 2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false
30428 !! options
30429 parsoid=html2wt
30430 !! html/parsoid
30431 <p> hi</p>
30432 <p> hello</p>
30433 !! wikitext
30434 <nowiki> </nowiki>hi
30435
30436 <nowiki> </nowiki> hello
30437 !! end
30438
30439 !! test
30440 3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
30441 !! options
30442 parsoid={
30443 "modes": ["html2wt"],
30444 "scrubWikitext": true
30445 }
30446 !! html/parsoid
30447 <p>Foo
30448 bar
30449 baz</p>
30450
30451 <table><tr><td>Foo
30452 bar
30453 baz bang</td></tr></table>
30454
30455 <p><!--boo--> foo
30456 bar</p>
30457
30458 <p> foo
30459 bar<span>boo</span></p>
30460 !! wikitext
30461 Foo
30462 bar
30463 baz
30464
30465 {|
30466 |Foo
30467 bar
30468 baz bang
30469 |}
30470
30471 <!--boo-->foo
30472 bar
30473
30474 foo
30475 bar<span>boo</span>
30476 !! end
30477
30478 !! test
30479 4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs
30480 !! options
30481 parsoid={
30482 "modes": ["selser"],
30483 "scrubWikitext": true,
30484 "changes": [
30485 [ "p", "html", " a\n b" ]
30486 ]
30487 }
30488 !! wikitext
30489 xyz
30490 !! wikitext/edited
30491 a
30492 b
30493 !! end
30494
30495 !! test
30496 1. New links that end in spaces
30497 !! options
30498 parsoid={
30499 "modes": ["html2wt"],
30500 "scrubWikitext": false
30501 }
30502 !! html/parsoid
30503 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
30504 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
30505 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
30506 !! wikitext
30507 [[Berlin ]]<nowiki/>is the capital of Germany.
30508
30509 [[Foo ]]'''bar'''
30510
30511 [[Boston ]] is a city.
30512 !! end
30513
30514 !! test
30515 2. New links that end in spaces
30516 !! options
30517 parsoid={
30518 "modes": ["html2wt"],
30519 "scrubWikitext": true
30520 }
30521 !! html/parsoid
30522 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
30523 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
30524 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
30525 !! wikitext
30526 [[Berlin]] is the capital of Germany.
30527
30528 [[Foo]] '''bar'''
30529
30530 [[Boston]] is a city.
30531 !! end
30532
30533 !! test
30534 1. Table cells with escapable prefixes
30535 !! options
30536 parsoid={
30537 "modes": ["html2wt"],
30538 "scrubWikitext": false
30539 }
30540 !! html
30541 <table>
30542 <tr><td>a</td></tr>
30543 <tr><td>-</td></tr>
30544 <tr><td>+</td></tr>
30545 </table>
30546 !! wikitext
30547 {|
30548 |a
30549 |-
30550 |<nowiki>-</nowiki>
30551 |-
30552 |<nowiki>+</nowiki>
30553 |}
30554 !! end
30555
30556 !! test
30557 2. Table cells with escapable prefixes
30558 !! options
30559 parsoid={
30560 "modes": ["html2wt"],
30561 "scrubWikitext": true
30562 }
30563 !! html
30564 <table>
30565 <tr><td>a</td></tr>
30566 <tr><td>-</td></tr>
30567 <tr><td>+</td></tr>
30568 </table>
30569 !! wikitext
30570 {|
30571 |a
30572 |-
30573 | -
30574 |-
30575 | +
30576 |}
30577 !! end
30578
30579 !! test
30580 3a. Table cells with escapable prefixes after edits
30581 !! options
30582 parsoid={
30583 "modes": ["selser"],
30584 "scrubWikitext": true,
30585 "changes": [
30586 [ "table tbody tr:first-child td:first-child", "remove"]
30587 ]
30588 }
30589 !! wikitext
30590 {|
30591 |a||-
30592 |}
30593 !! wikitext/edited
30594 {|
30595 | -
30596 |}
30597 !! end
30598
30599 !! test
30600 3b. Table cells with escapable prefixes after edits
30601 !! options
30602 parsoid={
30603 "modes": ["selser"],
30604 "scrubWikitext": true,
30605 "changes": [
30606 [ "table tbody tr:first-child td:first-child", "html", "-" ],
30607 [ "#x", "remove" ]
30608 ]
30609 }
30610 !! wikitext
30611 {|
30612 |pqr
30613 |<span id="x">foo</span>+
30614 |}
30615 !! wikitext/edited
30616 {|
30617 | -
30618 | +
30619 |}
30620 !! end
30621
30622 # FIXME: This test will fail because
30623 # normalization doesn't realize that the id attribute
30624 # will eliminate the escapable scenario
30625 !! test
30626 4a. Table cells without escapable prefixes after edits
30627 !! options
30628 parsoid={
30629 "modes": ["selser"],
30630 "scrubWikitext": true,
30631 "changes": [
30632 [ "#x", "html", "-" ]
30633 ]
30634 }
30635 !! wikitext
30636 {|
30637 | id="x" |abcd
30638 |}
30639 !! wikitext/edited
30640 {|
30641 | id="x" |-
30642 |}
30643 !! end
30644
30645 ## This tests normalizer's ability to discriminate between
30646 ## cells having identical content.
30647 !! test
30648 4b. Table cells without escapable prefixes after edits
30649 !! options
30650 parsoid={
30651 "modes": ["selser"],
30652 "scrubWikitext": true,
30653 "changes": [
30654 [ "td", "html", "-" ]
30655 ]
30656 }
30657 !! wikitext
30658 {|
30659 |a||b
30660 |}
30661 !! wikitext/edited
30662 {|
30663 | -||-
30664 |}
30665 !! end
30666
30667 ## This tests normalizer's ability to not be tripped by
30668 ## comments (and whitespace)
30669 !! test
30670 4c. Table cells without escapable prefixes after edits
30671 !! options
30672 parsoid={
30673 "modes": ["selser"],
30674 "scrubWikitext": true,
30675 "changes": [
30676 [ "table tbody tr td:first-child", "remove" ]
30677 ]
30678 }
30679 !! wikitext
30680 {|
30681 |-
30682 <!--foo--> |a||-
30683 |}
30684 !! wikitext/edited
30685 {|
30686 |-
30687 <!--foo--> | -
30688 |}
30689 !! end
30690
30691 ## This tests normalizer's ability to handle HTML cells
30692 !! test
30693 4d. Table cells without escapable prefixes after edits
30694 !! options
30695 parsoid={
30696 "modes": ["selser"],
30697 "scrubWikitext": true,
30698 "changes": [
30699 [ "td", "html", "-" ]
30700 ]
30701 }
30702 !! wikitext
30703 <table>
30704 <tr><td>a</td></tr>
30705 </table>
30706 !! wikitext/edited
30707 <table>
30708 <tr><td>-</td></tr>
30709 </table>
30710 !! end
30711
30712 ## T111151 Remove font elements without attributes
30713 !! test
30714 5a. font tags without attributes should be dropped in scrubWikitext mode
30715 !! options
30716 parsoid={
30717 "modes": ["html2wt"],
30718 "scrubWikitext": true
30719 }
30720 !! html
30721 <font>foo</font>
30722 <font><font>bar</font></font>
30723 <font class="x">boo</font>
30724 !! wikitext
30725 foo
30726 bar
30727 <font class="x">boo</font>
30728 !! end
30729
30730 !! test
30731 5b. font tags should not be dropped without scrubWikitext being enabled
30732 !! options
30733 parsoid={
30734 "modes": ["html2wt"],
30735 "scrubWikitext": false
30736 }
30737 !! html
30738 <font>foo</font>
30739 !! wikitext
30740 <font>foo</font>
30741 !! end
30742
30743 !! test
30744 Escape nowiki DOM elements
30745 !! options
30746 parsoid=html2wt
30747 !! html/parsoid
30748 <nowiki><i>foo</i></nowiki>
30749 !! wikitext
30750 &lt;nowiki&gt;''foo''&lt;/nowiki&gt;
30751 !! end
30752
30753 # This is meant to be an interim fix while we go about figuring out
30754 # how to not introduce these trailing <nowiki/>s in the first place.
30755 !! test
30756 T115717: Strip trailing <nowiki/>s (without affecting valid uses)
30757 !! options
30758 parsoid=html2wt
30759 !! html/parsoid
30760 <p>x<meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/>
30761 y</p>
30762 <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>
30763 <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>
30764 !! wikitext
30765 x
30766 y
30767
30768 {{echo|
30769 1 = <nowiki/>}}
30770
30771 {{echo|
30772 1 = <nowiki/>
30773 }}
30774 !! end
30775
30776 !! test
30777 New list is serialized on newlines
30778 !! options
30779 parsoid=html2wt
30780 !! html/parsoid
30781 <p>The quick brown fox jumps over the lazy dog.</p><ul>
30782 <li>Yesterday</li>
30783 <li>Today</li>
30784 <li>Tomorrow</li>
30785 </ul><p>The quick onyx goblin jumps over the lazy dwarf.</p>
30786 !! wikitext
30787 The quick brown fox jumps over the lazy dog.
30788
30789 * Yesterday
30790 * Today
30791 * Tomorrow
30792
30793 The quick onyx goblin jumps over the lazy dwarf.
30794 !! end
30795
30796 !! test
30797 New lists in formatting elements serialized w/o newlines
30798 !! options
30799 parsoid=html2wt
30800 !! html/parsoid
30801 <small>
30802
30803 <ul>
30804 <li>123</li>
30805 </ul>
30806
30807 </small>
30808
30809 <small><ul><li>hi</li></ul></small>
30810 !! wikitext
30811 <small>
30812 * 123
30813 </small>
30814
30815 <small>
30816 * hi
30817 </small>
30818 !! end
30819
30820 !! test
30821 New list in table doesn't need newlines
30822 !! options
30823 parsoid=html2wt
30824 !! html/parsoid
30825 <table><tr><td><ul><li>test</li><li>123</li></td></tr></table>
30826 !! wikitext
30827 {|
30828 |
30829 * test
30830 * 123
30831 |}
30832 !! end
30833
30834 # ---------------------------------------------------
30835 # End of tests spec'ing wikitext serialization norms |
30836 # ---------------------------------------------------
30837
30838 # T104032
30839 !! test
30840 Bare inline nodes not wrapped inside p-tags should be treated as p-wrapped
30841 !! options
30842 parsoid=html2wt
30843 !! html/parsoid
30844 a<p>b</p>
30845 <b>c</b><p>d</p>
30846 <table><tr>
30847 <td>a<p>b</p></td>
30848 <td><b>c</b><p>d</p></td>
30849 </tr></table>
30850 !! wikitext
30851 a
30852
30853 b
30854
30855 '''c'''
30856
30857 d
30858 {|
30859 |a
30860 b
30861 |'''c'''
30862 d
30863 |}
30864 !! end
30865
30866 !! test
30867 Anchor without href scenarios
30868 !! options
30869 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
30870 !! html/parsoid
30871 <a class="bc"></a>
30872 <a class="no">dice</a>
30873 <a name="foo"></a>
30874 !! wikitext
30875
30876 dice
30877 <span name="foo"></span>
30878 !! end
30879
30880 !! test
30881 New transclusion added after a list should be serialized after the list
30882 !! options
30883 parsoid=html2wt
30884 !! html/parsoid
30885 <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>
30886 !! wikitext
30887 * a
30888 {{echo|foo}}
30889 !! end
30890
30891 # -----------------------------------------------------------------
30892 # End of section for Parsoid-only html2wt tests for serialization
30893 # of new content
30894 # -----------------------------------------------------------------
30895
30896 # -----------------------------------------------------------------
30897 # The following section of tests are primarily to spec behavior of
30898 # the selective serializer. All these tests have manual selser
30899 # changes. The automated selser changes for all tests handle the
30900 # wide variation of changes, but these tests here capture specs
30901 # deterministically.
30902 # ----------------------------------------------------------------
30903
30904 ## T90517
30905 !! test
30906 Selser: New comments should not be lost
30907 !! options
30908 parsoid={
30909 "modes": ["selser"],
30910 "changes": [
30911 [ "#a", "after", "<!--c1-->" ],
30912 [ "#b", "before", "<!--c2-->" ]
30913 ]
30914 }
30915 !! wikitext
30916 <span id="a">a</span>
30917
30918 <span id="b">b</span>
30919 !! wikitext/edited
30920 <span id="a">a</span><!--c1-->
30921
30922 <!--c2--><span id="b">b</span>
30923 !! end
30924
30925 ## T89383
30926 !! test
30927 Selser: Check for validity of DSR before using it
30928 !! options
30929 parsoid={
30930 "modes": ["selser"],
30931 "changes": [
30932 [ "#a", "before", "<meta property='mw:PageProp/displaytitle' content='foo'>" ]
30933 ]
30934 }
30935 !! wikitext
30936 <span id="a">a</span>
30937 !! wikitext/edited
30938 {{DISPLAYTITLE:foo}}
30939 <span id="a">a</span>
30940 !! end
30941
30942 !! test
30943 1. DOMDiff: Changes to <ref> content should be looked up using id
30944 !! options
30945 parsoid={
30946 "modes": ["selser"],
30947 "changes": [
30948 ["#X", "after", "bar"],
30949 ["#Y", "after", "baz"]
30950 ]
30951 }
30952 !! wikitext
30953 X <ref><span id="X">foo</span></ref>
30954 Y <ref name="a" />
30955 <references>
30956 <ref name="a"><span id="Y">foo</span></ref>
30957 </references>
30958 !! wikitext/edited
30959 X <ref><span id="X">foo</span>bar</ref>
30960 Y <ref name="a" />
30961 <references>
30962 <ref name="a"><span id="Y">foo</span>baz</ref>
30963 </references>
30964 !! end
30965
30966 !! test
30967 2. DOMDiff: Changes to <ref> content should be looked up using id
30968 !! options
30969 parsoid={
30970 "modes": ["selser"],
30971 "changes": [
30972 ["#Z", "after", "bar"]
30973 ]
30974 }
30975 !! wikitext
30976 A <ref>foo bar for a</ref>
30977 B <ref group="X" name="b" />
30978
30979 <references />
30980
30981 <references group="X">
30982 <ref name="b"><span id="Z">foo</span></ref>
30983 </references>
30984 !! wikitext/edited
30985 A <ref>foo bar for a</ref>
30986 B <ref group="X" name="b" />
30987
30988 <references />
30989
30990 <references group="X">
30991 <ref name="b"><span id="Z">foo</span>bar</ref>
30992 </references>
30993 !! end
30994
30995 !! test
30996 DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388)
30997 !! options
30998 parsoid={
30999 "modes": ["selser"],
31000 "changes": [
31001 [ "div:first-child", "text", "bar" ]
31002 ]
31003 }
31004 !! wikitext
31005 <div style="{{1x|color:red;}}%">foo</div>
31006 !! wikitext/edited
31007 <div style="{{1x|color:red;}}%">bar</div>
31008 !! end
31009
31010 !! test
31011 Empty LI (T49673)
31012 !! wikitext
31013 *a
31014 *
31015 *
31016 *b
31017 !! html+tidy
31018 <ul><li>a</li>
31019 <li class="mw-empty-elt"></li>
31020 <li class="mw-empty-elt"></li>
31021 <li>b</li></ul>
31022 !! end
31023
31024 !! test
31025 Thumbnail output
31026 !! wikitext
31027 [[File:Thumb.png|thumb]]
31028 !! html/php+tidy
31029 <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" 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>
31030 !! html/parsoid
31031 <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>
31032 !! end
31033
31034 !! test
31035 unclosed internal link XSS (T137264)
31036 !! wikitext
31037 [[#%3Cscript%3Ealert(1)%3C/script%3E|
31038 !! html/php
31039 <p>[[#&lt;script&gt;alert(1)&lt;/script&gt;|
31040 </p>
31041 !! html/parsoid
31042 <p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p>
31043 !! end
31044
31045 !! test
31046 Validating that <style> isn't eaten by tidy (T167349)
31047 !! options
31048 styletag=1
31049 !! wikitext
31050 <div class="foo">
31051 <style>.foo::before { content: "<foo>"; }</style>
31052 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
31053 </div>
31054 !! html/php+tidy
31055 <div class="foo">
31056 <style>.foo::before { content: "<foo>"; }</style>
31057 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
31058 </div>
31059 !! html/parsoid
31060 <div class="foo">
31061 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31062 <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>
31063 </div>
31064 !! end
31065
31066 ## Right now, Parsoid doesn't de-duplicate style tags.
31067 ## So, we shouldn't see link tags that need to bypass the sanitizer.
31068 ## In a followup patch, when we de-duplicate style tags and
31069 ## introduce link tags, we'll add a hook for link tags in
31070 ## the parser test runner script.
31071 !! test
31072 Validating that <style> isn't wrapped in a paragraph (T186965)
31073 !! options
31074 styletag=1
31075 !! wikitext
31076 A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31077
31078 <style>.foo::before { content: "<foo>"; }</style>
31079
31080 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
31081
31082 But if it's on a line with other content, let it be wrapped.
31083
31084 <style>.foo::before { content: "<foo>"; }</style> bar
31085
31086 foo <style>.foo::before { content: "<foo>"; }</style>
31087
31088 foo <style>.foo::before { content: "<foo>"; }</style> bar
31089
31090 And the same if we have non-paragraph-breaking whitespace
31091
31092 foo
31093 <style>.foo::before { content: "<foo>"; }</style>
31094 bar
31095 !! html/php
31096 <p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31097 </p>
31098 <style>.foo::before { content: "<foo>"; }</style>
31099 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
31100 <p>But if it's on a line with other content, let it be wrapped.
31101 </p><p><style>.foo::before { content: "<foo>"; }</style> bar
31102 </p><p>foo <style>.foo::before { content: "<foo>"; }</style>
31103 </p><p>foo <style>.foo::before { content: "<foo>"; }</style> bar
31104 </p><p>And the same if we have non-paragraph-breaking whitespace
31105 </p><p>foo
31106 <style>.foo::before { content: "<foo>"; }</style>
31107 bar
31108 </p>
31109 !! html/parsoid
31110 <p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph</p>
31111
31112 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31113
31114 <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>
31115
31116 <p>But if it's on a line with other content, let it be wrapped.</p>
31117
31118 <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>
31119
31120 <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>
31121
31122 <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>
31123
31124 <p>And the same if we have non-paragraph-breaking whitespace</p>
31125
31126 <p>foo
31127 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31128 bar</p>
31129 !! end
31130
31131 !! test
31132 Validating that <link> isn't wrapped in a paragraph (T186965)
31133 !! options
31134 styletag=1
31135 !! wikitext
31136 A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31137
31138 <link rel="foo" href="bar"/>
31139
31140 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
31141
31142 But if it's on a line with other content, let it be wrapped.
31143
31144 <link rel="foo" href="bar"/> bar
31145
31146 foo <link rel="foo" href="bar"/>
31147
31148 foo <link rel="foo" href="bar"/> bar
31149
31150 And the same if we have non-paragraph-breaking whitespace
31151
31152 foo
31153 <link rel="foo" href="bar"/>
31154 bar
31155 !! html/php
31156 <p>A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31157 </p>
31158 <link rel="foo" href="bar"/>
31159 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
31160 <p>But if it's on a line with other content, let it be wrapped.
31161 </p><p><link rel="foo" href="bar"/> bar
31162 </p><p>foo <link rel="foo" href="bar"/>
31163 </p><p>foo <link rel="foo" href="bar"/> bar
31164 </p><p>And the same if we have non-paragraph-breaking whitespace
31165 </p><p>foo
31166 <link rel="foo" href="bar"/>
31167 bar
31168 </p>
31169 !! end
31170
31171 !! test
31172 Extension returning multiple nodes starting with a style tag roundtrips
31173 !! options
31174 wgRawHtml=1
31175 !! wikitext
31176 <table>
31177 {{echo|<html><style>.hi { color: red; }</style>
31178 </html>}}
31179 <tr><td class="hi">ho</td></tr>
31180 </table>
31181 !! html/parsoid
31182 <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">
31183 </span></p><table about="#mwt5" data-parsoid='{"stx":"html"}'>
31184
31185 <tbody><tr><td class="hi">ho</td></tr>
31186 </tbody></table>
31187 !! end
31188
31189 !! test
31190 Decoding of HTML entities in headings and links for IDs and link fragments (T103714)
31191 !! config
31192 wgFragmentMode=[ 'html5', 'legacy' ]
31193 !! wikitext
31194 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
31195 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
31196 !! html/php
31197 <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>
31198 <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>
31199 </p>
31200 !! html/parsoid
31201 <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>
31202 <p><a rel="mw:WikiLink" href="./Main_Page#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#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>
31203 !! end
31204
31205 !! test
31206 Decoding of HTML entities in headings and links for IDs and link fragments (T103714) (legacy)
31207 !! config
31208 wgFragmentMode=[ 'legacy' ]
31209 !! wikitext
31210 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
31211 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
31212 !! html/php
31213 <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>
31214 <p><a href="#A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a>
31215 </p>
31216 !! end
31217
31218 !! test
31219 Decoding of HTML entities in embedded HTML tags
31220 !! wikitext
31221 <table class="1&2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
31222 !! html/php
31223 <table class="1&amp;2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
31224
31225 !! html/parsoid
31226 <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>
31227 !! end
31228
31229 !! test
31230 Decoding of HTML entities in indicator names for IDs (T104196)
31231 !! options
31232 parsoid=wt2html,html2html
31233 showindicators
31234 !! wikitext
31235 <indicator name="1&2&amp;3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
31236 !! html/php
31237 1&2&3&amp;4&amp;amp;5=Indicator
31238
31239 !! html/parsoid
31240 <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>
31241 !! end
31242
31243 # this version of the test strips out the ambiguity so Parsoid rts cleanly
31244 !! test
31245 Decoding of HTML entities in indicator names for IDs (unambiguous) (T104196)
31246 !! options
31247 showindicators
31248 !! wikitext
31249 <indicator name="1&2&3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
31250 !! html/php
31251 1&2&3&amp;4&amp;amp;5=Indicator
31252
31253 !! html/parsoid
31254 <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>
31255 !! end
31256
31257 # This fragment mode is what Parsoid supports.
31258 !! test
31259 HTML5 ids: fallback to legacy
31260 !! config
31261 wgFragmentMode=[ 'html5', 'legacy' ]
31262 !! wikitext
31263 ==Foo bar==
31264
31265 ==foo Bar==
31266
31267 ==Тест==
31268
31269 ==Тест==
31270
31271 ==тест==
31272
31273 ==Hey < # " > % : '==
31274 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31275
31276 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31277
31278 <!-- These two links should produce identical HTML -->
31279 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31280
31281 !! html/php
31282 <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>
31283 <ul>
31284 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31285 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31286 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
31287 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
31288 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
31289 <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>
31290 </ul>
31291 </div>
31292
31293 <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>
31294 <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>
31295 <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>
31296 <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>
31297 <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>
31298 <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>
31299 <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>
31300 </p><p>💩 <span id="💩"></span>
31301 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
31302 </p>
31303 !! html/parsoid
31304 <h2 id="Foo_bar">Foo bar</h2>
31305
31306 <h2 id="foo_Bar_2">foo Bar</h2>
31307
31308 <h2 id="Тест"><span id=".D0.A2.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>Тест</h2>
31309
31310 <h2 id="Тест_2"><span id=".D0.A2.D0.B5.D1.81.D1.82_2" typeof="mw:FallbackId"></span>Тест</h2>
31311
31312 <h2 id="тест"><span id=".D1.82.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>тест</h2>
31313
31314 <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>
31315 <p><a rel="mw:WikiLink" href="./Main_Page#Foo_bar">#Foo bar</a> <a rel="mw:WikiLink" href="./Main_Page#foo_Bar">#foo Bar</a> <a rel="mw:WikiLink" href="./Main_Page#Тест">#Тест</a> <a rel="mw:WikiLink" href="./Main_Page#тест">#тест</a> <a rel="mw:WikiLink" href="./Main_Page#Hey_&lt;_#_&quot;_>_%_:_'" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Hey_&lt;_#_\"_>_%_:_&#39;"},"sa":{"href":"#Hey &lt; # \" > % : &#39;"}}'>#Hey &lt; # " > % : '</a></p>
31316
31317 <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>
31318
31319 <!-- These two links should produce identical HTML -->
31320 <p><a rel="mw:WikiLink" href="./Main_Page#啤酒">#啤酒</a> <a rel="mw:WikiLink" href="./Main_Page#啤酒" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#啤酒"},"sa":{"href":"#%E5%95%A4%E9%85%92"}}'>#啤酒</a></p>
31321 !! end
31322
31323 # Parsoid doesn't support this mode
31324 !! test
31325 HTML5 ids: legacy with a fallback to modern
31326 !! config
31327 wgFragmentMode=[ 'legacy', 'html5' ]
31328 !! wikitext
31329 ==Foo bar==
31330
31331 ==foo Bar==
31332
31333 ==Тест==
31334
31335 ==Тест==
31336
31337 ==тест==
31338
31339 ==Hey < # " > % : '==
31340 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31341
31342 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31343
31344 <!-- These two links should produce identical HTML -->
31345 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31346
31347 !! html/php
31348 <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>
31349 <ul>
31350 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31351 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31352 <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>
31353 <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>
31354 <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>
31355 <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>
31356 </ul>
31357 </div>
31358
31359 <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>
31360 <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>
31361 <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>
31362 <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>
31363 <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>
31364 <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>
31365 <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>
31366 </p><p>.F0.9F.92.A9 <span id=".F0.9F.92.A9"></span>
31367 </p><p><a href="#.E5.95.A4.E9.85.92">#啤酒</a> <a href="#.E5.95.A4.E9.85.92">#啤酒</a>
31368 </p>
31369 !! end
31370
31371 # Parsoid doesn't support this mode.
31372 !! test
31373 HTML5 ids: no legacy
31374 !! config
31375 wgFragmentMode=[ 'html5' ]
31376 !! wikitext
31377 ==Foo bar==
31378
31379 ==foo Bar==
31380
31381 ==Тест==
31382
31383 ==Тест==
31384
31385 ==тест==
31386
31387 ==Hey < # " > % : '==
31388 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31389
31390 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31391
31392 <!-- These two links should produce identical HTML -->
31393 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31394
31395 !! html/php
31396 <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>
31397 <ul>
31398 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31399 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31400 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
31401 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
31402 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
31403 <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>
31404 </ul>
31405 </div>
31406
31407 <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>
31408 <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>
31409 <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>
31410 <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>
31411 <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>
31412 <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>
31413 <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>
31414 </p><p>💩 <span id="💩"></span>
31415 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
31416 </p>
31417 !! end
31418
31419 !! test
31420 T90902: Normalize weird characters in section IDs
31421 !! config
31422 wgFragmentMode=[ 'html5', 'legacy' ]
31423 !! wikitext
31424 ==Foo&nbsp;bar==
31425 [[#Foo&nbsp;bar]]
31426
31427 !! html/php
31428 <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>
31429 <p><a href="#Foo_bar">#Foo&#160;bar</a>
31430 </p>
31431 !! html/parsoid
31432 <h2 id="Foo_bar"> Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span>bar </h2>
31433 <p><a rel="mw:WikiLink" href="./Main_Page#Foo_bar" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Foo_bar"},"sa":{"href":"#Foo&amp;nbsp;bar"}}'>#Foo bar</a></p>
31434 !! end
31435
31436 !! test
31437 T51672: Test for brackets in attributes of elements in external link texts
31438 !! wikitext
31439 [http://example.com/ link <span title="title with [brackets]">span</span>]
31440 [http://example.com/ link <span title="title with &#91;brackets&#93;">span</span>]
31441
31442 !! html/php
31443 <p><a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
31444 <a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
31445 </p>
31446 !! html/parsoid
31447 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/">link <span title="title with [brackets]">span</span></a>
31448 <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>
31449 !! end
31450
31451 !! test
31452 T72875: Test for brackets in attributes of elements in internal link texts
31453 !! wikitext
31454 [[Foo|link <span title="title with [[double brackets]]">span</span>]]
31455 [[Foo|link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span>]]
31456
31457 !! html/php
31458 <p><a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
31459 <a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
31460 </p>
31461 !! html/parsoid
31462 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">link <span title="title with [[double brackets]]">span</span></a>
31463 <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>
31464 !! end
31465
31466 !! test
31467 T199926: html arrow wt: Parsoid sometimes trips up on verticalbar chars in hrefs
31468 !! options
31469 parsoid={
31470 "modes": ["html2wt"]
31471 }
31472 !! html/parsoid
31473 <a href="https://stats.wikimedia.org/v2/#/fr.wikipedia.org/reading/page-views-by-country/normal|map|2-Year~2016060100~2018071100|~total">9</a>
31474 <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>
31475 !! wikitext
31476 [https://stats.wikimedia.org/v2/#/fr.wikipedia.org/reading/page-views-by-country/normal|map|2-Year~2016060100~2018071100|~total 9]
31477 [[stats:v2/#/fr.wikipedia.org/reading/page-views-by-country/normal%7Cmap%7C2-Year~2016060100~2018071100%7C~total|10]]
31478 !! end
31479
31480 !! test
31481 T179544: {{anchorencode:}} output should be always usable in links
31482 !! config
31483 wgFragmentMode=[ 'html5' ]
31484 !! wikitext
31485 <span id="{{anchorencode:[foo]}}"></span>[[#{{anchorencode:[foo]}}]]
31486 !! html/php
31487 <p><span id="&#91;foo&#93;"></span><a href="#[foo]">#&#91;foo&#93;</a>
31488 </p>
31489 !! html/parsoid
31490 <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="./Main_Page#[foo]" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#[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>
31491 !! end
31492
31493 ## ------------------------------
31494 ## Parsoid section-wrapping tests
31495 ## ------------------------------
31496 !! test
31497 Section wrapping for well-nested sections (no leading content)
31498 !! options
31499 parsoid={
31500 "wrapSections": true
31501 }
31502 !! wikitext
31503 =1=
31504 a
31505
31506 =2=
31507 b
31508
31509 ==2.1==
31510 c
31511
31512 ==2.2==
31513 d
31514
31515 ===2.2.1===
31516 e
31517
31518 =3=
31519 f
31520 !! html/parsoid
31521 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
31522 <p>a</p>
31523
31524 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
31525 <p>b</p>
31526
31527 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
31528 <p>c</p>
31529
31530 </section><section data-mw-section-id="4"><h2 id="2.2">2.2</h2>
31531 <p>d</p>
31532
31533 <section data-mw-section-id="5"><h3 id="2.2.1">2.2.1</h3>
31534 <p>e</p>
31535
31536 </section></section></section><section data-mw-section-id="6"><h1 id="3">3</h1>
31537 <p>f</p>
31538
31539 </section>
31540 !! end
31541
31542 !! test
31543 Section wrapping for well-nested sections (with leading content)
31544 !! options
31545 parsoid={
31546 "wrapSections": true
31547 }
31548 !! wikitext
31549 Para 1.
31550
31551 Para 2 with a <div>nested in it</div>
31552
31553 Para 3.
31554
31555 =1=
31556 a
31557
31558 =2=
31559 b
31560
31561 ==2.1==
31562 c
31563 !! html/parsoid
31564 <section data-mw-section-id="0"><p>Para 1.</p>
31565
31566 <p>Para 2 with a </p><div>nested in it</div>
31567
31568 <p>Para 3.</p>
31569
31570 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
31571 <p>a</p>
31572
31573 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
31574 <p>b</p>
31575
31576 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
31577 <p>c</p>
31578
31579 </section></section>
31580 !! end
31581
31582 !! test
31583 Section wrapping with template-generated sections (good nesting 1)
31584 !! options
31585 parsoid={
31586 "wrapSections": true
31587 }
31588 !! wikitext
31589 =1=
31590 a
31591
31592 {{echo|1=
31593 ==1.1==
31594 b
31595 }}
31596
31597 ==1.2==
31598 c
31599
31600 =2=
31601 d
31602 !! html/parsoid
31603 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
31604 <p>a</p>
31605
31606 <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">
31607 </span><p about="#mwt1">b</p>
31608 </section><section data-mw-section-id="3"><h2 id="1.2">1.2</h2>
31609 <p>c</p>
31610
31611 </section></section><section data-mw-section-id="4"><h1 id="2">2</h1>
31612 <p>d</p></section>
31613 !! end
31614
31615 # In this example, the template scope is mildly expanded to incorporate the
31616 # trailing newline after the transclusion since that is part of section 1.1.1
31617 !! test
31618 Section wrapping with template-generated sections (good nesting 2)
31619 !! options
31620 parsoid={
31621 "wrapSections": true,
31622 "modes": ["wt2html", "wt2wt"]
31623 }
31624 !! wikitext
31625 =1=
31626 a
31627
31628 {{echo|1=
31629 ==1.1==
31630 b
31631 ===1.1.1===
31632 d
31633 }}
31634 =2=
31635 e
31636 !! html/parsoid
31637 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
31638 <p>a</p>
31639
31640 <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">
31641 </span><p about="#mwt1">b</p><span about="#mwt1">
31642 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.1.1">1.1.1</h3><span about="#mwt1">
31643 </span><p about="#mwt1">d</p><span about="#mwt1">
31644 </span></section></section></section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="2">2</h1>
31645 <p>e</p></section>
31646 !! end
31647
31648 # In this example, the template scope is mildly expanded to incorporate the
31649 # trailing newline after the transclusion since that is part of section 1.2.1
31650 !! test
31651 Section wrapping with template-generated sections (good nesting 3)
31652 !! options
31653 parsoid={
31654 "wrapSections": true,
31655 "modes": ["wt2html", "wt2wt"]
31656 }
31657 !! wikitext
31658 =1=
31659 a
31660
31661 {{echo|1=
31662 x
31663 ==1.1==
31664 b
31665 ==1.2==
31666 c
31667 ===1.2.1===
31668 d
31669 }}
31670 =2=
31671 e
31672 !! html/parsoid
31673 <section data-mw-section-id="0"></section><section data-mw-section-id="1" data-parsoid="{}"><h1 id="1"> 1 </h1>
31674 <p>a</p>
31675
31676 <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">
31677 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.1">1.1</h2><span about="#mwt1">
31678 </span><p about="#mwt1">b</p><span about="#mwt1">
31679 </span></section><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.2">1.2</h2><span about="#mwt1">
31680 </span><p about="#mwt1">c</p><span about="#mwt1">
31681 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.2.1">1.2.1</h3><span about="#mwt1">
31682 </span><p about="#mwt1">d</p><span about="#mwt1">
31683 </span></section></section></section><section data-mw-section-id="5"><h1 id="2">2</h1>
31684 <p>e</p></section>
31685 !! end
31686
31687 # Because of section-wrapping and template-wrapping interactions,
31688 # the scope of the template is expanded so that the template markup
31689 # is valid in the presence of <section> tags.
31690 # This exercises the s1 is null scenario in the wrapSections code
31691 !! test
31692 Section wrapping with template-generated sections (bad nesting 1)
31693 !! options
31694 parsoid={
31695 "wrapSections": true
31696 }
31697 !! wikitext
31698 <div>
31699 a
31700
31701 {{echo|
31702 =1=
31703 b
31704 }}
31705
31706 c
31707 </div>
31708 !! html/parsoid
31709 <section data-mw-section-id="-1"></section><section data-mw-section-id="-2"><div data-parsoid='{"stx":"html"}'>
31710 <p>a</p>
31711
31712 <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"]}'>
31713 </span><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="1">1</h1><span about="#mwt1">
31714 </span><p about="#mwt1">b
31715 </p><span about="#mwt1">
31716
31717 </span><p about="#mwt1">c</p><span about="#mwt1">
31718 </span></section></div></section>
31719 !! end
31720
31721 # Because of section-wrapping and template-wrapping interactions,
31722 # the scope of the template is expanded so that the template markup
31723 # is valid in the presence of <section> tags.
31724 # This exercises the s1 is ancestor of s2 scenario in the wrapSections code
31725 !! test
31726 Section wrapping with template-generated sections (bad nesting 2)
31727 !! options
31728 parsoid={
31729 "wrapSections": true
31730 }
31731 !! wikitext
31732 =1=
31733 a
31734
31735 {{echo|1=
31736 =2=
31737 b
31738 ==2.1==
31739 c
31740 }}
31741
31742 d
31743
31744 =3=
31745 e
31746 !! html/parsoid
31747 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
31748 <p>a</p>
31749
31750 </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">
31751 </span><p about="#mwt1">b</p><span about="#mwt1">
31752 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="2.1">2.1</h2><span about="#mwt1">
31753 </span><p about="#mwt1">c</p><span about="#mwt1">
31754
31755 </span><p about="#mwt1">d</p><span about="#mwt1">
31756
31757 </span></section></section><section data-mw-section-id="4"><h1 id="3">3</h1>
31758 <p>e</p></section>
31759 !! end
31760
31761 # Because of section-wrapping and template-wrapping interactions,
31762 # additional template wrappers are added to <section> tags
31763 # so that template wrapping semantics are valid whether section
31764 # tags are retained or stripped. But, the template scope can expand
31765 # greatly when accounting for section tags.
31766 # This exercises the s1 and s2 are in different subtrees scenario
31767 !! test
31768 Section wrapping with template-generated sections (bad nesting 3)
31769 !! options
31770 parsoid={
31771 "wrapSections": true,
31772 "modes": ["wt2html", "wt2wt"]
31773 }
31774 !! wikitext
31775 =1=
31776 a
31777
31778 {{echo|1=
31779 ==1.2==
31780 b
31781 =2=
31782 c
31783 }}
31784
31785 d
31786
31787 =3=
31788 e
31789 !! html/parsoid
31790 <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>
31791 <p>a</p>
31792
31793 <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">
31794 </span><p about="#mwt1">b</p><span about="#mwt1">
31795 </span></section></section><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="2">2</h1><span about="#mwt1">
31796 </span><p about="#mwt1">c</p>
31797
31798 <p>d</p>
31799 </section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="3">3</h1>
31800 <p>e</p></section>
31801 !! end
31802
31803 !! test
31804 Section wrapping with uneditable lead section + div wrapping multiple sections
31805 !! options
31806 parsoid={
31807 "wrapSections": true
31808 }
31809 !! wikitext
31810 foo
31811
31812 <div style="border:1px solid red;">
31813 =1=
31814 a
31815
31816 ==1.1==
31817 b
31818
31819 =2=
31820 c
31821 </div>
31822
31823 =3=
31824 d
31825
31826 ==3.1==
31827 e
31828 !! html/parsoid
31829 <section data-mw-section-id="-1"><p>foo</p>
31830
31831 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
31832 <section data-mw-section-id="1"><h1 id="1">1</h1>
31833 <p>a</p>
31834
31835 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
31836 <p>b</p>
31837
31838 </section></section><section data-mw-section-id="-1"><h1 id="2">2</h1>
31839 <p>c</p>
31840 </section></div>
31841
31842 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
31843 <p>d</p>
31844
31845 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
31846 <p>e</p>
31847 </section></section>
31848 !! end
31849
31850 !! test
31851 Section wrapping with editable lead section + div overlapping multiple sections
31852 !! options
31853 parsoid={
31854 "wrapSections": true
31855 }
31856 !! wikitext
31857 foo
31858
31859 =1=
31860 a
31861 <div style="border:1px solid red;">
31862 b
31863
31864 ==1.1==
31865 c
31866
31867 =2=
31868 d
31869 </div>
31870 e
31871
31872 =3=
31873 f
31874
31875 ==3.1==
31876 g
31877 !! html/parsoid
31878 <section data-mw-section-id="0"><p>foo</p>
31879
31880 </section><section data-mw-section-id="-1"><h1 id="1">1</h1>
31881 <p>a</p>
31882 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
31883 <p>b</p>
31884
31885 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
31886 <p>c</p>
31887
31888 </section><section data-mw-section-id="-1"><h1 id="2">2</h1>
31889 <p>d</p>
31890 </section></div>
31891 <p>e</p>
31892
31893 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
31894 <p>f</p>
31895
31896 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
31897 <p>g</p>
31898 </section></section>
31899 !! end
31900
31901 !! test
31902 HTML header tags should not be wrapped in section tags
31903 !! options
31904 parsoid={
31905 "wrapSections": true
31906 }
31907 !! wikitext
31908 foo
31909
31910 <h1>a</h1>
31911
31912 =b=
31913
31914 <h1>c</h1>
31915
31916 =d=
31917 !! html/parsoid
31918 <section data-mw-section-id="0"><p>foo</p>
31919
31920 <h1 id="a" data-parsoid='{"stx":"html"}'>a</h1>
31921
31922 </section><section data-mw-section-id="1"><h1 id="b">b</h1>
31923
31924 <h1 id="c" data-parsoid='{"stx":"html"}'>c</h1>
31925
31926 </section><section data-mw-section-id="2"><h1 id="d">d</h1></section>
31927 !! end
31928
31929 !! test
31930 Lead section containing only whitespace and comments.
31931 !! options
31932 parsoid={
31933 "wrapSections": true
31934 }
31935 !! wikitext
31936
31937 <!-- this is a comment, presumably significant to editors -->
31938 =1=
31939 a
31940
31941 =2=
31942 b
31943 !! html/parsoid
31944 <section data-mw-section-id="0" data-parsoid="{}">
31945 <!-- this is a comment, presumably significant to editors -->
31946 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
31947 <p>a</p>
31948
31949 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
31950 <p>b</p></section>
31951 !! end
31952
31953 !! test
31954 Pseudo-sections emitted by templates should have id -2
31955 !! options
31956 parsoid={
31957 "wrapSections": true
31958 }
31959 !! wikitext
31960 foo
31961 {{echo|<div>
31962 ==a==
31963 ==b==
31964 </div>
31965 }}
31966 !! html/parsoid
31967 <section data-mw-section-id="-1"><p>foo</p>
31968 </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}}]}'>
31969 <section data-mw-section-id="-1"><h2 id="a">a</h2>
31970 </section><section data-mw-section-id="-1"><h2 id="b">b</h2>
31971 </section></div><span about="#mwt1">
31972 </span></section>
31973 !! end
31974
31975 ##########################################################################
31976 Tests demonstrating white-space insensitivity in input wikitext
31977 for wikitext headings, wikitext list items, and wikitext table captions,
31978 headings, and cells. HTML versions of the same should preserve whitespace.
31979 ##########################################################################
31980 !! test
31981 Trim whitespace in wikitext headings, list items, table captions, headings, and cells
31982 !! options
31983 parsoid={
31984 "modes": ["wt2html"],
31985 "preserveIEW": true
31986 }
31987 !! wikitext
31988 __NOTOC__
31989 == <!--c1--> <!--c2--> Spaces <!--c3--> <!--c4--> ==
31990 == <!--c1--> <!--c2--> Tabs <!--c3--><!--c4--> ==
31991 == <!--Headings with fallback ids--> Личная жизнь ==
31992 * <!--c1--> <!--c2--> List item <!--c3--> <!--c4-->
31993 ; <!--term to define--> term : <!--term's definition--> definition
31994 {|
31995 |+ <!--c1--> <!--c2--> Table Caption <!--c3--> <!--c4-->
31996 |-
31997 ! <!--c1--> <!--c2--> Table Heading 1 <!--c3--> <!--c4--> !! Table Heading 2 <!--c5-->
31998 |-
31999 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
32000 |-
32001 | class="foo" || <!--c1--> <!--c2--> Table Cell 3 <!--c3--> <!--c4-->
32002 |-
32003 | <!--c1--> testing [[one|two]] <!--c2--> | <!--c3--> some content
32004 |}
32005 : {|
32006 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
32007 |} foo <!--c1-->
32008 !! html/php+tidy
32009 <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>
32010 <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>
32011 <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>
32012 <ul><li>List item</li></ul>
32013 <dl><dt>term&#160;</dt>
32014 <dd>definition</dd></dl>
32015 <table>
32016 <caption>Table Caption
32017 </caption>
32018 <tbody><tr>
32019 <th>Table Heading 1</th>
32020 <th>Table Heading 2
32021 </th></tr>
32022 <tr>
32023 <td>Table Cell 1</td>
32024 <td>Table Cell 2
32025 </td></tr>
32026 <tr>
32027 <td>class="foo"</td>
32028 <td>Table Cell 3
32029 </td></tr>
32030 <tr>
32031 <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
32032 </td></tr></tbody></table>
32033 <dl><dd><table>
32034 <tbody><tr>
32035 <td>Table Cell 1</td>
32036 <td>Table Cell 2
32037 </td></tr></tbody></table> foo</dd></dl>
32038 !! html/parsoid
32039 <meta property="mw:PageProp/notoc">
32040 <h2 id="Spaces"><!--c1--><!--c2-->Spaces<!--c3--><!--c4--></h2>
32041 <h2 id="Tabs"><!--c1--><!--c2-->Tabs<!--c3--><!--c4--></h2>
32042 <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>
32043 <ul><li><!--c1--><!--c2-->List item<!--c3--><!--c4--></li></ul>
32044 <dl><dt><!--term to define-->term&nbsp;</dt><dd><!--term's definition-->definition</dd></dl>
32045 <table>
32046 <caption><!--c1--><!--c2-->Table Caption<!--c3--><!--c4--></caption>
32047 <tbody><tr>
32048 <th><!--c1--><!--c2-->Table Heading 1<!--c3--><!--c4--></th><th>Table Heading 2<!--c5--></th></tr>
32049 <tr>
32050 <td><!--c1--><!--c2-->Table Cell 1<!--c3--><!--c4--></td><td>Table Cell 2<!--c5--></td></tr>
32051 <tr>
32052 <td>class="foo"</td><td><!--c1--><!--c2-->Table Cell 3<!--c3--><!--c4--></td></tr>
32053 <tr>
32054 <td><!--c1-->testing <a rel="mw:WikiLink" href="./One" title="One">two</a> <!--c2--> | <!--c3--> some content</td></tr>
32055 </tbody></table>
32056 <dl><dd><table>
32057 <tbody><tr><td><!--c1--><!--c2-->Table Cell 1<!--c3--><!--c4--></td><td>Table Cell 2<!--c5--></td></tr>
32058 </tbody></table> foo<!--c1--></dd></dl>
32059 !! end
32060
32061 # Looks like <caption> is not accepted in HTML
32062 !! test
32063 Do not trim whitespace in HTML headings, list items, table captions, headings, and cells
32064 !! options
32065 parsoid={
32066 "modes": ["wt2html"],
32067 "preserveIEW": true
32068 }
32069 !! wikitext
32070 __NOTOC__
32071 <h2> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
32072 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
32073 <table>
32074 <tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> <th></tr>
32075 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> <th></tr>
32076 </table>
32077 !! html/php+tidy
32078 <h2><span class="mw-headline" id="Heading"> Heading </span></h2>
32079 <ul><li> List item </li></ul>
32080 <table>
32081 <tbody><tr><th> Table Heading </th><th></th></tr>
32082 <tr><td> Table Cell </td><th></th></tr>
32083 </tbody></table>
32084 !! html/parsoid
32085 <meta property="mw:PageProp/notoc"/>
32086 <h2 id="Heading"> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
32087 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
32088 <table>
32089 <tbody><tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> </th><th></th></tr>
32090 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> </td><th></th></tr>
32091 </tbody></table>
32092 !! end
32093
32094 !! test
32095 Do not trim whitespace in links and quotes
32096 !! options
32097 parsoid={
32098 "modes": ["wt2html"],
32099 "preserveIEW": true
32100 }
32101 !! wikitext
32102 foo '' <!--c1--> italic <!--c2--> '' and ''' <!--c3--> bold <!--c4--> '''
32103 [[Foo| some text ]]
32104 !! html/php+tidy
32105 <p>foo <i> italic </i> and <b> bold </b>
32106 <a href="/wiki/Foo" title="Foo"> some text </a>
32107 </p>
32108 !! html/parsoid
32109 <p>foo <i> <!--c1--> italic <!--c2--> </i> and <b> <!--c3--> bold <!--c4--> </b>
32110 <a rel="mw:WikiLink" href="./Foo" title="Foo"> some text </a></p>
32111 !! end
32112
32113 !! test
32114 Remove p tags surrounding a single element in a figcaption
32115 !! options
32116 parsoid=html2wt
32117 !! wikitext
32118 [[File:Foobar.jpg|right|200x200px|Caption]]
32119 !! html/parsoid
32120 <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>
32121 !! end
32122
32123 !! test
32124 Selser preserves lack of newline before list and allows newline after the list
32125 !! options
32126 parsoid={
32127 "modes": ["selser"],
32128 "scrubWikitext": true,
32129 "changes": [
32130 [ "ul", "after", "<p>footer</p>" ]
32131 ]
32132 }
32133 !! wikitext
32134 header
32135 *foo
32136 *bar
32137 !! wikitext/edited
32138 header
32139 *foo
32140 *bar
32141
32142 footer
32143 !! end
32144
32145
32146 !! test
32147 Selser does not introduce newlines between unedited paragraph preceding the list
32148 !! options
32149 parsoid={
32150 "modes": ["selser"],
32151 "changes": [
32152 [ "table tbody tr td p:last-child", "empty" ]
32153 ]
32154 }
32155 !! wikitext
32156 {|
32157 |
32158 header
32159 *foo
32160 *bar
32161 footer
32162 |}
32163 !! wikitext/edited
32164 {|
32165 |
32166 header
32167 *foo
32168 *bar
32169
32170 |}
32171 !! end
32172
32173 !! test
32174 Selser does not introduce newlines between unedited paragraph following the list
32175 !! options
32176 parsoid={
32177 "modes": ["selser"],
32178 "changes": [
32179 [ "table tbody tr td p:first-child", "empty" ]
32180 ]
32181 }
32182 !! wikitext
32183 {|
32184 |
32185 header
32186 *foo
32187 *bar
32188 footer
32189 |}
32190 !! wikitext/edited
32191 {|
32192 |
32193
32194 *foo
32195 *bar
32196 footer
32197 |}
32198 !! end
32199
32200 !! test
32201 Remove a list item but do not insert newline above list
32202 !! options
32203 parsoid={
32204 "modes": ["selser"],
32205 "changes": [
32206 [ "ul li:last-child", "remove" ]
32207 ]
32208 }
32209 !! wikitext
32210 header
32211 *foo
32212 *bar
32213 footer
32214 !! wikitext/edited
32215 header
32216 *foo
32217 footer
32218 !! end