Put <dt>/<dd>/<li> in the always-suppressing category of doBlockLevels
[lhc/web/wiklou.git] / tests / parser / parserTests.txt
1 # MediaWiki Parser test cases
2 # Some taken from https://meta.wikimedia.org/wiki/Parser_testing
3 # All (C) their respective authors and released under the GPL
4 #
5 # The syntax should be fairly self-explanatory.
6 #
7 # Currently supported test options:
8 # One of the following three:
9 #
10 # (default) generate HTML output
11 # pst apply pre-save transform
12 # msg apply message transform
13 #
14 # Plus any combination of these:
15 #
16 # cat add category links
17 # (ignored by Parsoid, since it emits <link>s)
18 # ill add inter-language links
19 # (ignored by Parsoid, since it emits <link>s)
20 # subpage enable subpages (disabled by default)
21 # title=[[XXX]] run test using article title XXX
22 # language=XXX set content language to XXX for this test
23 # variant=XXX set the variant of language for this test (eg zh-tw)
24 # disabled do not run test
25 # parsoid parsoid-specific options (not run by PHP parser unless
26 # the test includes an html/php section)
27 # php php-only test (not run by the parsoid parser unless
28 # the test includes an html/parsoid section)
29 # showtitle make the first line the title
30 # showindicators make the first lines the page status indicators
31 # comment run through Linker::formatComment() instead of main parser
32 # local format section links in edit comment text as local links
33 # notoc disable table of contents
34 # thumbsize=NNN set the default thumb size to NNNpx for this test
35 # wrap include the normal wrapper <div class="mw-parser-output"> (since 1.30)
36 #
37 # You can also set the following parser properties via test options:
38 # wgEnableUploads, wgAllowExternalImages, wgMaxTocLevel,
39 # wgLinkHolderBatchSize, wgRawHtml, wgInterwikiMagic,
40 # wgEnableMagicLinks
41 #
42 # For testing purposes, temporary articles can created:
43 # !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
44 # where '/' denotes a newline.
45
46 # This is the standard article assumed to exist.
47 !! article
48 Main Page
49 !! text
50 blah blah
51 !! endarticle
52
53 !!article
54 Foo
55 !!text
56 FOO
57 !!endarticle
58
59 !!article
60 Template:Foo
61 !!text
62 FOO
63 !!endarticle
64
65 !! article
66 Template:redirect to foo
67 !! text
68 #REDIRECT [[Template:Foo]]
69 !! endarticle
70
71 !! article
72 Template:Blank
73 !! text
74 !! endarticle
75
76 !! article
77 Template:pipe
78 !! text
79 |
80 !! endarticle
81
82 !! article
83 Template:=
84 !! text
85 <nowiki>=</nowiki>
86 !! endarticle
87
88 !!article
89 MediaWiki:bad image list
90 !!text
91 * [[File:Bad.jpg]] except [[Nasty page]]
92 !!endarticle
93
94 !! article
95 Template:inner list
96 !! text
97 * item 1
98 !! endarticle
99
100 !! article
101 Template:tbl-start
102 !! text
103 {|
104 !! endarticle
105
106 !! article
107 Template:tbl-end
108 !! text
109 |}
110 !! endarticle
111
112 !! article
113 Template:echo
114 !! text
115 {{{1}}}
116 !! endarticle
117
118 !! article
119 Template:echo3
120 !! text
121 {{{1}}}
122 {{{1}}}
123 {{{1}}}
124 !! endarticle
125
126 // For Serbian; localize Template namespace
127 !! article
128 Шаблон:Echo
129 !! text
130 {{{1}}}
131 !! endarticle
132
133 !! article
134 Template:echo_with_span
135 !! text
136 <span>{{{1}}}</span>
137 !! endarticle
138
139 !! article
140 Template:echo_with_div
141 !! text
142 <div>{{{1}}}</div>
143 !! endarticle
144
145 !! article
146 Template:echo with depth
147 !! text
148 {{echo|{{{1}}}}}
149 !! endarticle
150
151 !! article
152 Template:blank_param
153 !! text
154 {{{1}}}
155 {{{}}}
156 !! endarticle
157
158 !! article
159 Template:table_attribs
160 !! text
161 <noinclude>
162 |</noinclude>style="color:red;"|Foo
163 !! endarticle
164
165 !! article
166 Template:table_attribs_2
167 !! text
168 <noinclude>
169 |</noinclude>style="color:red;"|Foo
170 |Bar||Baz
171 !! endarticle
172
173 !! article
174 Template:table_attribs_3
175 !! text
176 <noinclude>
177 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo
178 !! endarticle
179
180 !! article
181 Template:table_attribs_4
182 !! text
183 | style="background-color:#DC241f;" width="10px" |
184 !! endarticle
185
186 !! article
187 Template:table_attribs_5
188 !! text
189 <noinclude>
190 |</noinclude>style="color:red;"||Bar
191 !! endarticle
192
193 !! article
194 Template:table_attribs_6
195 !! text
196 style="background: <nowiki>
197
198
199 red;</nowiki>" |
200 !! endarticle
201
202 !! article
203 Template:table_attribs_7
204 !! text
205 <noinclude>
206 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo<ref>foo</ref>
207 !! endarticle
208
209 !! article
210 Template:table_header_cells
211 !! text
212 {{table_attribs}}!!style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
213 !! endarticle
214
215 !! article
216 Template:table_cells
217 !! text
218 {{table_attribs}}||style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
219 !! endarticle
220
221 !! article
222 Template:PartialTable
223 !! text
224 {|
225 |-
226 !! endarticle
227
228 !! article
229 Template:image_attribs
230 !! text
231 <noinclude>
232 [[File:foobar.jpg|</noinclude>right|Caption text<noinclude>]]</noinclude>
233 !! endarticle
234
235 ## See T48811 for details
236 !! article
237 Template:mixed_attr_content_template
238 !! text
239 style="color:red;" title="T48811"
240 |-
241 |foo
242 !! endarticle
243
244 !! article
245 Template:definition_list
246 !! text
247 one
248 ::two
249 !! endarticle
250
251 !! article
252 A?b
253 !! text
254 Weirdo titles!
255 !! endarticle
256
257 !!article
258 Template:Bullet
259 !!text
260 *Bar
261 !!endarticle
262
263 !!article
264 Template:OpenTable
265 !!text
266 {|
267 !!endarticle
268
269 !!article
270 Template:EmptyLITest
271 !!text
272 *a
273 *
274 *
275 *b
276 !!endarticle
277
278 !!article
279 Template:EmptyTRTest
280 !!text
281 {|
282 |-
283 |-
284 |foo
285 |-
286 |-
287 |bar
288 |}
289 !!endarticle
290
291 !!article
292 Template:EmptyTRWithHTMLAttrTest
293 !!text
294 <table>
295 <tr align="center"></tr>
296 <tr><td>foo</td></tr>
297 <tr align="center"></tr>
298 <tr><td>bar</td></tr>
299 </table>
300 !!endarticle
301
302 !! article
303 Template:With: Colon
304 !! text
305 Template with colon
306 !! endarticle
307
308 ###
309 ### Basic tests
310 ###
311
312 !! test
313 Blank input
314 !! wikitext
315 !! html
316 !! end
317
318 !! test
319 Simple paragraph
320 !! wikitext
321 This is a simple paragraph.
322 !! html
323 <p>This is a simple paragraph.
324 </p>
325 !! end
326
327 !! test
328 Paragraphs with extra newline spacing
329 !! wikitext
330 a
331
332 b (+2 nls)
333
334
335 c (+3 nls)
336
337
338
339 d (+4 nls)
340
341
342
343
344 e (+5 nls)
345 !! html
346 <p>a
347 </p><p>b (+2 nls)
348 </p><p><br />
349 c (+3 nls)
350 </p><p><br />
351 </p><p>d (+4 nls)
352 </p><p><br />
353 </p><p><br />
354 e (+5 nls)
355 </p>
356 !! end
357
358 !! test
359 Paragraphs with newline spacing with comment lines in between
360 !! wikitext
361 ----
362 a
363 <!--foo-->
364 b
365 ----
366 a
367 <!--foo--><!--More than 1 comment, still stripped-->
368 b
369 ----
370 a
371 <!--foo--> <!----> <!-- bar -->
372 b
373 ----
374 a
375 <!--foo-->
376
377 b
378 ----
379 a
380
381 <!--foo-->
382 b
383 ----
384 a
385 <!--foo-->
386
387
388 b
389 ----
390 a
391
392
393 <!--foo-->
394 b
395 ----
396 !! html
397 <hr />
398 <p>a
399 b
400 </p>
401 <hr />
402 <p>a
403 b
404 </p>
405 <hr />
406 <p>a
407 b
408 </p>
409 <hr />
410 <p>a
411 </p><p>b
412 </p>
413 <hr />
414 <p>a
415 </p><p>b
416 </p>
417 <hr />
418 <p>a
419 </p><p><br />
420 b
421 </p>
422 <hr />
423 <p>a
424 </p><p><br />
425 b
426 </p>
427 <hr />
428
429 !! end
430
431 !! test
432 Paragraphs with newline spacing with non-empty white-space lines in between
433 !! wikitext
434 ----
435 a
436
437 b
438 ----
439 a
440
441
442 b
443 ----
444 !! html
445 <hr />
446 <p>a
447 </p><p>b
448 </p>
449 <hr />
450 <p>a
451 </p><p><br />
452 b
453 </p>
454 <hr />
455
456 !! end
457
458 !! test
459 Paragraphs with newline spacing with non-empty mixed comment and white-space lines in between
460 !! wikitext
461 ----
462 a
463 <!--foo-->
464 b
465 ----
466 a
467 <!--foo--><!--More than 1 comment doesn't disable stripping of this line!-->
468 b
469 ----
470 a
471
472 <!--foo-->
473 <!--bar-->
474 b
475 ----
476 a
477
478 <!--foo-->
479 <!--bar-->
480
481 b
482 ----
483 !! html
484 <hr />
485 <p>a
486 b
487 </p>
488 <hr />
489 <p>a
490 b
491 </p>
492 <hr />
493 <p>a
494 </p><p>b
495 </p>
496 <hr />
497 <p>a
498 </p><p><br />
499 b
500 </p>
501 <hr />
502
503 !! end
504
505 !! test
506 Extra newlines: More paragraphs with indented comment
507 !! wikitext
508 a
509
510 <!--boo-->
511
512 b
513 !! html
514 <p>a
515 </p><p><br />
516 b
517 </p>
518 !!end
519
520 !! test
521 Extra newlines followed by heading
522 !! wikitext
523 a
524
525
526 =b=
527 [[a]]
528
529
530 =b=
531 !! html
532 <p>a
533 </p><p><br />
534 </p>
535 <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>
536 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
537 </p><p><br />
538 </p>
539 <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>
540
541 !! end
542
543 !! test
544 Extra newlines between heading and content are swallowed (Parsoid does not)
545 !! wikitext
546 =b=
547
548
549
550 [[a]]
551 !! html/php+tidy
552 <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>
553 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
554 </p>
555 !! html/parsoid
556 <h1 id="b">b</h1>
557 <p>
558 <br></p>
559
560 <p><a rel="mw:WikiLink" href="./A" title="A">a</a></p>
561 !! end
562
563 !! test
564 Extra new lines before and after lists are preserved
565 !! wikitext
566 a
567
568
569 *b
570
571
572 c
573 !! html/php+tidy
574 <p>a
575 </p><p><br />
576 </p>
577 <ul><li>b</li></ul>
578 <p><br />
579 c
580 </p>
581 !! html/parsoid
582 <p>a</p>
583 <p>
584 <br></p>
585 <ul><li>b</li></ul>
586 <p>
587 <br>
588 c</p>
589 !! end
590
591 # Parsoid regression test
592 !!test
593 Multiple newlines after tables are converted to p-br-p tags
594 !!options
595 parsoid=wt2html,wt2wt
596 !!wikitext
597 {|
598 |x
599 |}
600
601
602
603
604 =b=
605 !!html/php+tidy
606 <table>
607 <tbody><tr>
608 <td>x
609 </td></tr></tbody></table>
610 <p><br />
611 </p><p><br />
612 </p>
613 <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>
614 !!html/parsoid
615 <table>
616 <tbody>
617 <tr>
618 <td>x</td>
619 </tr>
620 </tbody>
621 </table>
622 <p><br/></p>
623 <p><br/></p>
624 <h1 id="b">b</h1>
625 !!end
626
627 !! test
628 Heading with line break in nowiki
629 !! options
630 parsoid=wt2html
631 !! config
632 wgFragmentMode=[ 'html5', 'legacy' ]
633 !! wikitext
634 ==A <nowiki>B
635 C</nowiki>==
636 !! html/php
637 <h2><span id="A_B.0AC"></span><span class="mw-headline" id="A_B
638 C">A B
639 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>
640
641 !! html/parsoid
642 <h2 id="A_B
643 C"><span id="A_B.0AC" typeof="mw:FallbackId"></span>A <span typeof="mw:Nowiki">B
644 C</span></h2>
645 !! end
646
647 !! test
648 Parsing an URL
649 !! wikitext
650 http://fr.wikipedia.org/wiki/🍺
651 <!-- EasterEgg we love beer, better be able be able to link to it -->
652 !! html
653 <p><a rel="nofollow" class="external free" href="http://fr.wikipedia.org/wiki/🍺">http://fr.wikipedia.org/wiki/🍺</a>
654 </p>
655 !! end
656
657 !! test
658 Simple list
659 !! wikitext
660 *Item 1
661 *Item 2
662 !! html
663 <ul><li>Item 1</li>
664 <li>Item 2</li></ul>
665
666 !! end
667
668 !! test
669 Italics and bold
670 !! wikitext
671 *plain
672 *plain''italic''plain
673 *plain''italic''plain''italic''plain
674 *plain'''bold'''plain
675 *plain'''bold'''plain'''bold'''plain
676 *plain''italic''plain'''bold'''plain
677 *plain'''bold'''plain''italic''plain
678 *plain''italic'''bold-italic'''italic''plain
679 *plain'''bold''bold-italic''bold'''plain
680 *plain'''''bold-italic'''italic''plain
681 *plain'''''bold-italic''bold'''plain
682 *plain''italic'''bold-italic'''''plain
683 *plain'''bold''bold-italic'''''plain
684 *plain l'''italic''plain
685 *plain l''''bold''' plain
686 !! html
687 <ul><li>plain</li>
688 <li>plain<i>italic</i>plain</li>
689 <li>plain<i>italic</i>plain<i>italic</i>plain</li>
690 <li>plain<b>bold</b>plain</li>
691 <li>plain<b>bold</b>plain<b>bold</b>plain</li>
692 <li>plain<i>italic</i>plain<b>bold</b>plain</li>
693 <li>plain<b>bold</b>plain<i>italic</i>plain</li>
694 <li>plain<i>italic<b>bold-italic</b>italic</i>plain</li>
695 <li>plain<b>bold<i>bold-italic</i>bold</b>plain</li>
696 <li>plain<i><b>bold-italic</b>italic</i>plain</li>
697 <li>plain<b><i>bold-italic</i>bold</b>plain</li>
698 <li>plain<i>italic<b>bold-italic</b></i>plain</li>
699 <li>plain<b>bold<i>bold-italic</i></b>plain</li>
700 <li>plain l'<i>italic</i>plain</li>
701 <li>plain l'<b>bold</b> plain</li></ul>
702
703 !! end
704
705 # this example taken from the [[simple:Moon]] article (T49326)
706 !! test
707 Italics and possessives (1)
708 !! wikitext
709 obtained by ''[[Lunar Prospector]]'''s gamma-ray spectrometer
710 !! html
711 <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
712 </p>
713 !! end
714
715 # this example taken from [[en:Flaming Pie]] (T51926)
716 !! test
717 Italics and possessives (2)
718 !! wikitext
719 '''''Flaming Pie''''' is ... released in 1997. In ''Flaming Pie'''s liner notes
720 !! html
721 <p><i><b>Flaming Pie</b></i> is ... released in 1997. In <i>Flaming Pie'</i>s liner notes
722 </p>
723 !! end
724
725 # this example taken from [[en:Dictionary]] (T51926)
726 !! test
727 Italics and possessives (3)
728 !! wikitext
729 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''.
730 !! html
731 <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>.
732 </p>
733 !! end
734
735
736 ###
737 ### 2-quote opening sequence tests
738 ###
739 !! test
740 Italics and bold: 2-quote opening sequence: (2,2)
741 !! wikitext
742 ''foo''
743 !! html
744 <p><i>foo</i>
745 </p>
746 !!end
747
748 !! test
749 Italics and bold: 2-quote opening sequence: (2,3)
750 !! wikitext
751 ''foo'''
752 !! html/*
753 <p><i>foo'</i>
754 </p>
755 !!end
756
757 !! test
758 Italics and bold: 2-quote opening sequence: (2,4)
759 !! options
760 parsoid=wt2html
761 !! wikitext
762 ''foo''''
763 !! html/*
764 <p><i>foo''</i>
765 </p>
766 !!end
767
768 # same html as previous, but wikitext adjusted to match parsoid html2wt
769 !! test
770 Italics and bold: 2-quote opening sequence: (2,4) w/ nowiki
771 !! wikitext
772 ''foo<nowiki>''</nowiki>''
773 !! html
774 <p><i>foo''</i>
775 </p>
776 !! end
777
778 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
779 !! test
780 Italics and bold: 2-quote opening sequence: (2,5)
781 !! options
782 parsoid=wt2html
783 !! wikitext
784 ''foo'''''
785 !! html/php
786 <p><i>foo</i>
787 </p>
788 !! html/parsoid
789 <p><i>foo</i><b></b>
790 </p>
791 !!end
792
793 # same html as previous, but wikitext adjusted to match parsoid html2wt
794 !! test
795 Italics and bold: 2-quote opening sequence: (2,5+3) w/ nowiki
796 !! wikitext
797 ''foo'''''<nowiki/>'''
798 !! html/php
799 <p><i>foo</i>
800 </p>
801 !! html/parsoid
802 <p><i>foo</i><b></b>
803 </p>
804 !! end
805
806
807 ###
808 ### 3-quote opening sequence tests
809 ###
810
811 !! test
812 Italics and bold: 3-quote opening sequence: (3,2)
813 !! wikitext
814 '''foo''
815 !! html/*
816 <p>'<i>foo</i>
817 </p>
818 !!end
819
820 !! test
821 Italics and bold: 3-quote opening sequence: (3,3)
822 !! wikitext
823 '''foo'''
824 !! html
825 <p><b>foo</b>
826 </p>
827 !!end
828
829 !! test
830 Italics and bold: 3-quote opening sequence: (3,4)
831 !! wikitext
832 '''foo''''
833 !! html/*
834 <p><b>foo'</b>
835 </p>
836 !!end
837
838 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
839 !! test
840 Italics and bold: 3-quote opening sequence: (3,5)
841 !! options
842 parsoid=wt2html
843 !! wikitext
844 '''foo'''''
845 !! html/php
846 <p><b>foo</b>
847 </p>
848 !! html/parsoid
849 <p><b>foo</b><i></i>
850 </p>
851 !!end
852
853 # same html as previous, but wikitext adjusted to match parsoid html2wt
854 !! test
855 Italics and bold: 3-quote opening sequence: (3,5+2) w/ nowiki
856 !! wikitext
857 '''foo'''''<nowiki/>''
858 !! html/php
859 <p><b>foo</b>
860 </p>
861 !! html/parsoid
862 <p><b>foo</b><i></i>
863 </p>
864 !! end
865
866
867 ###
868 ### 4-quote opening sequence tests
869 ###
870
871 !! test
872 Italics and bold: 4-quote opening sequence: (4,2)
873 !! options
874 parsoid=wt2html
875 !! wikitext
876 ''''foo''
877 !! html/*
878 <p>''<i>foo</i>
879 </p>
880 !!end
881
882 # same html as previous, but wikitext adjusted to match parsoid html2wt
883 !! test
884 Italics and bold: 4-quote opening sequence: (4,2) w/ nowiki
885 !! wikitext
886 <nowiki>''</nowiki>''foo''
887 !! html
888 <p>''<i>foo</i>
889 </p>
890 !! end
891
892 !! test
893 Italics and bold: 4-quote opening sequence: (4,3)
894 !! wikitext
895 ''''foo'''
896 !! html/*
897 <p>'<b>foo</b>
898 </p>
899 !!end
900
901 !! test
902 Italics and bold: 4-quote opening sequence: (4,4)
903 !! options
904 parsoid=wt2html
905 !! wikitext
906 ''''foo''''
907 !! html/*
908 <p>'<b>foo'</b>
909 </p>
910 !!end
911
912 # same html as previous, but wikitext adjusted to match parsoid html2wt
913 !! test
914 Italics and bold: 4-quote opening sequence: (4,4) w/ nowiki
915 !! wikitext
916 '<nowiki/>'''foo''''
917 !! html
918 <p>'<b>foo'</b>
919 </p>
920 !! end
921
922 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
923 !! test
924 Italics and bold: 4-quote opening sequence: (4,5)
925 !! options
926 parsoid=wt2html
927 !! wikitext
928 ''''foo'''''
929 !! html/php
930 <p>'<b>foo</b>
931 </p>
932 !! html/parsoid
933 <p>'<b>foo</b><i></i>
934 </p>
935 !!end
936
937 # same html as previous, but wikitext adjusted to match parsoid html2wt
938 !! test
939 Italics and bold: 4-quote opening sequence: (4,5+2) w/ nowiki
940 !! wikitext
941 '<nowiki/>'''foo'''''<nowiki/>''
942 !! html/php
943 <p>'<b>foo</b>
944 </p>
945 !! html/parsoid
946 <p>'<b>foo</b><i></i>
947 </p>
948 !! end
949
950
951 ###
952 ### 5-quote opening sequence tests
953 ###
954
955 !! test
956 Italics and bold: 5-quote opening sequence: (5,2)
957 !! options
958 parsoid=wt2html
959 !! wikitext
960 '''''foo''
961 !! html/*
962 <p><b><i>foo</i></b>
963 </p>
964 !!end
965
966 # same html as previous, but wikitext adjusted to match parsoid html2wt
967 !! test
968 Italics and bold: 5-quote opening sequence: (5,2+3)
969 !! wikitext
970 '''''foo'''''
971 !! html/*
972 <p><i><b>foo</b></i>
973 </p>
974 !! end
975
976 !! test
977 Italics and bold: 5-quote opening sequence: (5,3)
978 !! options
979 parsoid=wt2html
980 !! wikitext
981 '''''foo'''
982 !! html/*
983 <p><i><b>foo</b></i>
984 </p>
985 !!end
986
987 # same html as previous, but wikitext adjusted to match parsoid html2wt
988 !! test
989 Italics and bold: 5-quote opening sequence: (5,3+2)
990 !! wikitext
991 '''''foo'''''
992 !! html
993 <p><i><b>foo</b></i>
994 </p>
995 !! end
996
997 !! test
998 Italics and bold: 5-quote opening sequence: (5,4)
999 !! options
1000 parsoid=wt2html
1001 !! wikitext
1002 '''''foo''''
1003 !! html/*
1004 <p><i><b>foo'</b></i>
1005 </p>
1006 !!end
1007
1008 !! test
1009 Italics and bold: 5-quote opening sequence: (5,5)
1010 !! wikitext
1011 '''''foo'''''
1012 !! html
1013 <p><i><b>foo</b></i>
1014 </p>
1015 !!end
1016
1017 !! test
1018 Italics and bold: 5-quote opening sequence: (5,6)
1019 !! wikitext
1020 '''''foo''''''
1021 !! html/*
1022 <p><i><b>foo'</b></i>
1023 </p>
1024 !! end
1025
1026 ###
1027 ### multiple quote sequences in a line
1028 ###
1029
1030 !! test
1031 Italics and bold: multiple quote sequences: (2,4,2)
1032 !! options
1033 parsoid=wt2html
1034 !! wikitext
1035 ''foo''''bar''
1036 !! html/*
1037 <p><i>foo'<b>bar</b></i>
1038 </p>
1039 !! end
1040
1041 # same html as previous, but wikitext adjusted to match parsoid html2wt
1042 !! test
1043 Italics and bold: multiple quote sequences: (2,4,2+3) w/ nowiki
1044 !! wikitext
1045 ''foo'<nowiki/>'''bar'''''
1046 !! html
1047 <p><i>foo'<b>bar</b></i>
1048 </p>
1049 !! end
1050
1051 !! test
1052 Italics and bold: multiple quote sequences: (2,4,3)
1053 !! options
1054 parsoid=wt2html
1055 !! wikitext
1056 ''foo''''bar'''
1057 !! html/*
1058 <p><i>foo'<b>bar</b></i>
1059 </p>
1060 !! end
1061
1062 # same html as previous, but wikitext adjusted to match parsoid html2wt
1063 !! test
1064 Italics and bold: multiple quote sequences: (2,4,3+2) w/ nowiki
1065 !! wikitext
1066 ''foo'<nowiki/>'''bar'''''
1067 !! html
1068 <p><i>foo'<b>bar</b></i>
1069 </p>
1070 !! end
1071
1072 !! test
1073 Italics and bold: multiple quote sequences: (2,4,4)
1074 !! options
1075 parsoid=wt2html
1076 !! wikitext
1077 ''foo''''bar''''
1078 !! html/*
1079 <p><i>foo'<b>bar'</b></i>
1080 </p>
1081 !! end
1082
1083 # same html as previous, but wikitext adjusted to match parsoid html2wt
1084 !! test
1085 Italics and bold: multiple quote sequences: (2,4,4+2) w/ nowiki
1086 !! wikitext
1087 ''foo'<nowiki/>'''bar'<nowiki/>'''''
1088 !! html
1089 <p><i>foo'<b>bar'</b></i>
1090 </p>
1091 !! end
1092
1093 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1094 !! test
1095 Italics and bold: multiple quote sequences: (3,4,2)
1096 !! options
1097 parsoid=wt2html
1098 !! wikitext
1099 '''foo''''bar''
1100 !! html/php
1101 <p><b>foo'</b>bar
1102 </p>
1103 !! html/parsoid
1104 <p><b>foo'</b>bar<i></i>
1105 </p>
1106 !! end
1107
1108 # same html as previous, but wikitext adjusted to match parsoid html2wt
1109 !! test
1110 Italics and bold: multiple quote sequences: (3,4,2+2) w/ nowiki
1111 !! wikitext
1112 '''foo''''bar''<nowiki/>''
1113 !! html/php
1114 <p><b>foo'</b>bar
1115 </p>
1116 !! html/parsoid
1117 <p><b>foo'</b>bar<i></i>
1118 </p>
1119 !! end
1120
1121 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1122 !! test
1123 Italics and bold: multiple quote sequences: (3,4,3)
1124 !! options
1125 parsoid=wt2html
1126 !! wikitext
1127 '''foo''''bar'''
1128 !! html/php
1129 <p><b>foo'</b>bar
1130 </p>
1131 !! html/parsoid
1132 <p><b>foo'</b>bar<b></b>
1133 </p>
1134 !! end
1135
1136 # same html as previous, but wikitext adjusted to match parsoid html2wt
1137 !! test
1138 Italics and bold: multiple quote sequences: (3,4,3+3) w/ nowiki
1139 !! wikitext
1140 '''foo''''bar'''<nowiki/>'''
1141 !! html/php
1142 <p><b>foo'</b>bar
1143 </p>
1144 !! html/parsoid
1145 <p><b>foo'</b>bar<b></b>
1146 </p>
1147 !! end
1148
1149 ###
1150 ### other quote tests
1151 ###
1152 !! test
1153 Italics and bold: other quote tests: (2,3,5)
1154 !! wikitext
1155 ''this is about '''foo's family'''''
1156 !! html
1157 <p><i>this is about <b>foo's family</b></i>
1158 </p>
1159 !!end
1160
1161
1162 !! test
1163 Italics and bold: other quote tests: (2,(3,3),2)
1164 !! wikitext
1165 ''this is about '''foo's''' family''
1166 !! html
1167 <p><i>this is about <b>foo's</b> family</i>
1168 </p>
1169 !!end
1170
1171
1172 !! test
1173 Italics and bold: other quote tests: (3,2,3,2)
1174 !! options
1175 parsoid=wt2html
1176 !! wikitext
1177 '''this is about ''foo'''s family''
1178 !! html/*
1179 <p><b>this is about <i>foo</i></b><i>s family</i>
1180 </p>
1181 !!end
1182
1183
1184 # same html as previous, but wikitext adjusted to match parsoid html2wt
1185 !! test
1186 Italics and bold: other quote tests: (3,2,3+2+2,2)
1187 !! wikitext
1188 '''this is about ''foo'''''<nowiki/>''s family''
1189 !! html
1190 <p><b>this is about <i>foo</i></b><i>s family</i>
1191 </p>
1192 !! end
1193
1194
1195 !! test
1196 Italics and bold: other quote tests: (3,2,3,3)
1197 !! wikitext
1198 '''this is about ''foo'''s family'''
1199 !! html/*
1200 <p>'<i>this is about </i>foo<b>s family</b>
1201 </p>
1202 !!end
1203
1204
1205 !! test
1206 Italics and bold: other quote tests: (3,(2,2),3)
1207 !! wikitext
1208 '''this is about ''foo's'' family'''
1209 !! html
1210 <p><b>this is about <i>foo's</i> family</b>
1211 </p>
1212 !!end
1213
1214
1215 !! test
1216 Italicized possessive
1217 !! wikitext
1218 The ''[[Main Page]]'''s talk page.
1219 !! html/php
1220 <p>The <i><a href="/wiki/Main_Page" title="Main Page">Main Page</a>'</i>s talk page.
1221 </p>
1222 !! html/parsoid
1223 <p>The <i><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>'</i>s talk page.</p>
1224 !! end
1225
1226 !! test
1227 Quote balancing context should be restricted to td/th cells on the same wikitext line
1228 !! options
1229 parsoid=wt2html,wt2wt
1230 !! wikitext
1231 {|
1232 !''a!!''b
1233 |''a||''b
1234 |}
1235 !! html+tidy
1236 <table>
1237 <tbody><tr>
1238 <th><i>a</i></th>
1239 <th><i>b</i>
1240 </th>
1241 <td><i>a</i></td>
1242 <td><i>b</i>
1243 </td></tr></tbody></table>
1244 !! end
1245
1246 ###
1247 ### Non-html5 tags
1248 ###
1249
1250 !! test
1251 Non-html5 tags should be accepted
1252 !! wikitext
1253 <center>''foo''</center>
1254 <big>''foo''</big>
1255 <font>''foo''</font>
1256 <strike>''foo''</strike>
1257 <tt>''foo''</tt>
1258 !! html
1259 <center><i>foo</i></center>
1260 <p><big><i>foo</i></big>
1261 <font><i>foo</i></font>
1262 <strike><i>foo</i></strike>
1263 <tt><i>foo</i></tt>
1264 </p>
1265 !! end
1266
1267 !! test
1268 <wbr> is valid wikitext (T54468)
1269 !! wikitext
1270 <wbr>
1271 !! html
1272 <p><wbr />
1273 </p>
1274 !! end
1275
1276 # <strike> is HTML4, <s> is HTML4/5.
1277 !! test
1278 <s> or <strike> for strikethrough
1279 !! wikitext
1280 <strike>strike</strike>
1281
1282 <s>s</s>
1283 !! html
1284 <p><strike>strike</strike>
1285 </p><p><s>s</s>
1286 </p>
1287 !! end
1288
1289 ## a not permitted
1290 ## i,b,br omitted
1291 !! test
1292 Text-level semantic html elements in wikitext
1293 !! wikitext
1294 <em>text</em>
1295 <strong>text</strong>
1296 <small>text</small>
1297 <s>text</s>
1298 <cite>text</cite>
1299 <q>text</q>
1300 <dfn>text</dfn>
1301 <abbr>text</abbr>
1302 <data>text</data>
1303 <time>text</time>
1304 <code>text</code>
1305 <var>text</var>
1306 <samp>text</samp>
1307 <kbd>text</kbd>
1308 <sub>text</sub>
1309 <u>text</u>
1310 <mark>text</mark>
1311 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1312 <bdi>text</bdi>
1313 <bdo>text</bdo>
1314 <span>text</span>
1315 <wbr />
1316 !! html
1317 <p><em>text</em>
1318 <strong>text</strong>
1319 <small>text</small>
1320 <s>text</s>
1321 <cite>text</cite>
1322 <q>text</q>
1323 <dfn>text</dfn>
1324 <abbr>text</abbr>
1325 <data>text</data>
1326 <time>text</time>
1327 <code>text</code>
1328 <var>text</var>
1329 <samp>text</samp>
1330 <kbd>text</kbd>
1331 <sub>text</sub>
1332 <u>text</u>
1333 <mark>text</mark>
1334 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1335 <bdi>text</bdi>
1336 <bdo>text</bdo>
1337 <span>text</span>
1338 <wbr />
1339 </p>
1340 !! end
1341
1342 # test cases taken from
1343 # https://www.w3.org/TR/html5/text-level-semantics.html#the-ruby-element
1344 !! test
1345 Ruby markup (W3C-style)
1346 !! wikitext
1347 ;Mono-ruby for individual base characters
1348 :<ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby>
1349 ;Group ruby
1350 :<ruby>今日<rt>きょう</rt></ruby>
1351 ;Jukugo ruby
1352 :<ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby>
1353 ;Inline ruby
1354 :<ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby>
1355 ;Double-sided ruby
1356 :<ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby>
1357
1358 <ruby>
1359 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1360 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1361 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1362 </ruby>
1363 !! html
1364 <dl><dt>Mono-ruby for individual base characters</dt>
1365 <dd><ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby></dd>
1366 <dt>Group ruby</dt>
1367 <dd><ruby>今日<rt>きょう</rt></ruby></dd>
1368 <dt>Jukugo ruby</dt>
1369 <dd><ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby></dd>
1370 <dt>Inline ruby</dt>
1371 <dd><ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby></dd>
1372 <dt>Double-sided ruby</dt>
1373 <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>
1374 <p><ruby>
1375 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1376 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1377 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1378 </ruby>
1379 </p>
1380 !! end
1381
1382 # The next two test different paths in the sanitizer.
1383 !! test
1384 Non-word characters don't terminate tag names (T19663, T42670, T54022)
1385 !! wikitext
1386 <blockquote|>a</blockquote>
1387
1388 <b→> doesn't terminate </b→>
1389
1390 <bä> doesn't terminate </bä>
1391
1392 <boo> doesn't terminate </boo>
1393
1394 <s.foo> doesn't terminate </s.foo>
1395
1396 <sub-ID#1>
1397 !! html
1398 <p>&lt;blockquote|&gt;a&lt;/blockquote&gt;
1399 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1400 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1401 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1402 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1403 </p><p>&lt;sub-ID#1&gt;
1404 </p>
1405 !! end
1406
1407 !! test
1408 Non-word characters don't terminate tag names
1409 !! wikitext
1410 <blockquote|>a</blockquote>
1411
1412 <b→> doesn't terminate </b→>
1413
1414 <bä> doesn't terminate </bä>
1415
1416 <boo> doesn't terminate </boo>
1417
1418 <s.foo> doesn't terminate </s.foo>
1419
1420 <sub-ID#1>
1421 !! html+tidy
1422 <p>&lt;blockquote|&gt;a
1423 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1424 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1425 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1426 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1427 </p><p>&lt;sub-ID#1&gt;
1428 </p>
1429 !! end
1430
1431 ###
1432 ### See tests/parser/parserTestsParserHook.php for the <tåg> extension)
1433 ### This checks that HTML5 tags (with non-word characters in the tag
1434 ### name) make it safely through the parser -- the Sanitizer will
1435 ### munge them later, as it should.
1436 ###
1437 !! test
1438 Non-word characters are valid in extension tags (T19663)
1439 !! wikitext
1440 <tåg>tåg</tåg>
1441 !! html/php
1442 <pre>
1443 'tåg'
1444 array (
1445 )
1446 </pre>
1447
1448 !! html/parsoid
1449 <pre typeof="mw:Extension/tåg" data-mw='{"name":"tåg","attrs":{},"body":{"extsrc":"tåg"}}' data-parsoid='{}' about="#mwt2"></pre>
1450 !! end
1451
1452 !! test
1453 Isolated close tags should be treated as literal text (T54760)
1454 !! options
1455 parsoid=wt2html
1456 !! wikitext
1457 </b>
1458
1459 <s.foo>s</s>
1460 !! html/php+tidy
1461 <p class="mw-empty-elt">
1462 </p><p>&lt;s.foo&gt;s
1463 </p>
1464 !! html/parsoid
1465 <p>&lt;s.foo&gt;s</p>
1466 !! end
1467
1468 ###
1469 ### Special characters
1470 ###
1471
1472 !! test
1473 Bare pipe character (T54363)
1474 !! wikitext
1475 |
1476 !! html
1477 <p>|
1478 </p>
1479 !! end
1480
1481 !! test
1482 Bare pipe character from a template (T54363)
1483 !! wikitext
1484 {{pipe}}
1485 !! html
1486 <p>|
1487 </p>
1488 !! end
1489
1490 ###
1491 ### <nowiki> test cases
1492 ###
1493
1494 !! test
1495 <nowiki> unordered list
1496 !! wikitext
1497 <nowiki>* This is not an unordered list item.</nowiki>
1498 !! html/php
1499 <p>* This is not an unordered list item.
1500 </p>
1501 !! html/parsoid
1502 <p><span typeof="mw:Nowiki">* This is not an unordered list item.</span></p>
1503 !! end
1504
1505 !! test
1506 <nowiki> spacing
1507 !! wikitext
1508 <nowiki>Lorem ipsum dolor
1509
1510 sed abit.
1511 sed nullum.
1512
1513 :and a colon
1514 </nowiki>
1515 !! html/php
1516 <p>Lorem ipsum dolor
1517
1518 sed abit.
1519 sed nullum.
1520
1521 :and a colon
1522
1523 </p>
1524 !! html/parsoid
1525 <p><span typeof="mw:Nowiki">Lorem ipsum dolor
1526
1527 sed abit.
1528 sed nullum.
1529
1530 :and a colon
1531 </span></p>
1532 !! end
1533
1534 !! test
1535 Don't parse <nowiki><span class="error"></nowiki> (T149622)
1536 !! wikitext
1537 <nowiki><span class="error"></nowiki>
1538 !! html/php
1539 <p>&lt;span class="error"&gt;
1540 </p>
1541 !! html/parsoid
1542 <p><span typeof="mw:Nowiki">&lt;span class="error"></span></p>
1543 !! end
1544
1545 !! test
1546 nowiki 3
1547 !! wikitext
1548 :There is not nowiki.
1549 :There is <nowiki>nowiki</nowiki>.
1550
1551 #There is not nowiki.
1552 #There is <nowiki>nowiki</nowiki>.
1553
1554 *There is not nowiki.
1555 *There is <nowiki>nowiki</nowiki>.
1556 !! html/php
1557 <dl><dd>There is not nowiki.</dd>
1558 <dd>There is nowiki.</dd></dl>
1559 <ol><li>There is not nowiki.</li>
1560 <li>There is nowiki.</li></ol>
1561 <ul><li>There is not nowiki.</li>
1562 <li>There is nowiki.</li></ul>
1563
1564 !! html/parsoid
1565 <dl><dd data-parsoid='{}'>There is not nowiki.</dd>
1566 <dd data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</dd></dl>
1567
1568 <ol><li data-parsoid='{}'>There is not nowiki.</li>
1569 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ol>
1570
1571 <ul><li data-parsoid='{}'>There is not nowiki.</li>
1572 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ul>
1573 !! end
1574
1575 !! test
1576 Entities inside <nowiki>
1577 !! wikitext
1578 <nowiki>&lt;</nowiki>
1579 !! html/php
1580 <p>&lt;
1581 </p>
1582 !! html/parsoid
1583 <p><span typeof="mw:Nowiki"><span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span></span></p>
1584 !! end
1585
1586 !! test
1587 Entities inside template parameters
1588 !! wikitext
1589 {{echo|&ndash;}}
1590 !! html/php+tidy
1591 <p>&#8211;
1592 </p>
1593 !! html/parsoid
1594 <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>
1595 !! end
1596
1597 !! test
1598 Properly escape nowiki when combined with other wiki markup
1599 !! options
1600 parsoid=html2wt
1601 !! html/parsoid
1602 <p>* &lt;/nowiki&gt; tag</p>
1603 !! wikitext
1604 <nowiki>*</nowiki> <nowiki>&lt;/nowiki&gt;</nowiki> tag
1605 !! end
1606
1607 !! test
1608 T93824: Put escaped HTML tags inside nowiki
1609 !! options
1610 parsoid=html2wt
1611 !! html/parsoid
1612 <p>&lt;h2&gt;foo&lt;/h2&gt;</p>
1613 !! wikitext
1614 <nowiki><h2>foo</h2></nowiki>
1615 !! end
1616
1617 !! test
1618 T71950: 1. Put nowiki as close to cause as possible, even with non-quote escapable chars
1619 !! options
1620 parsoid=html2wt
1621 !! html/parsoid
1622 <p>This text: L'<a rel="mw:WikiLink" href="./Foo">Foo</a>
1623 This text: L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1624 This text: L'''<a rel="mw:WikiLink" href="./Foo">Foo</a>''</p>
1625 !! wikitext
1626 This text: L'[[Foo]]
1627 This text: L<nowiki>''</nowiki>[[Foo]]
1628 This text: L<nowiki>'''</nowiki>[[Foo]]<nowiki>''</nowiki>
1629 !! end
1630
1631 # This test fails because wikitext whitespace is not normalized before comparing.
1632 !! test
1633 T71950: 2. Put nowiki as close to cause as possible, after ' :'
1634 !! options
1635 parsoid=html2wt
1636 !! html/parsoid
1637 <p>This text : L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1638 </p>
1639 !! wikitext
1640 This text : L<nowiki>''</nowiki>[[Foo]]
1641 !! end
1642
1643 # This test and the next one are html2wt only as they test that incorrect wikitext
1644 # passed in template arguments gets escaped or wrapped in nowikis where required.
1645 !! test
1646 T71482: Use {{!}} instead of nowiki for single pipe in template argument
1647 !! options
1648 parsoid=html2wt
1649 !! html/parsoid
1650 <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>
1651 <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>
1652 !! wikitext
1653 {{echo|foo{{!}}bar}}
1654 {{echo|<nowiki>foo|bar |[[</nowiki>}}
1655 !! end
1656
1657 !! test
1658 T53961: Output correct nowikis in template arguments
1659 !! options
1660 parsoid=html2wt
1661 !! html/parsoid
1662 <p><span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a [ b&quot;}},&quot;i&quot;:0}}]}" about="#mwt1"></span>
1663 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a }} b&quot;}},&quot;i&quot;:0}}]}" about="#mwt2"></span>
1664 <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>
1665 <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>
1666 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a }&quot;}},&quot;i&quot;:0}}]}" about="#mwt5"></span></p>
1667 !! wikitext
1668 {{echo|a [ b}}
1669 {{echo|<nowiki>a }} b</nowiki>}}
1670 {{echo|<nowiki>a [[ b</nowiki>}}
1671 {{echo|<nowiki>a | {{ ]]</nowiki>}}
1672 {{echo|a <nowiki>}</nowiki>}}
1673 !! end
1674
1675 !! test
1676 Cases where "!!" needs nowiki protection
1677 !! options
1678 parsoid=html2wt
1679 !! html/parsoid
1680 <table>
1681 <tr><th>this needs protection !! here</th></tr>
1682 </table>
1683
1684 <table>
1685 <tr><th>this does not need
1686 protection !! here</th></tr>
1687 </table>
1688 !! wikitext
1689 {|
1690 !<nowiki>this needs protection !! here</nowiki>
1691 |}
1692
1693 {|
1694 !this does not need
1695 protection !! here
1696 |}
1697 !! end
1698
1699 ###
1700 ### Comments
1701 ###
1702 !! test
1703 Comments and Indent-Pre
1704 !! wikitext
1705 <!-- comment 1 --> asdf
1706
1707 <!-- comment 1 --> asdf
1708 <!-- comment 2 -->
1709
1710 <!-- comment 1 --> asdf
1711 <!-- comment 2 -->xyz
1712
1713 <!-- comment 1 --> asdf
1714 <!-- comment 2 --> xyz
1715 !! html
1716 <pre>asdf
1717 </pre>
1718 <pre>asdf
1719 </pre>
1720 <pre>asdf
1721 </pre>
1722 <p>xyz
1723 </p>
1724 <pre>asdf
1725 xyz
1726 </pre>
1727 !! end
1728
1729 !! test
1730 Comment test 2a
1731 !! wikitext
1732 asdf
1733 <!-- comment 1 -->
1734 jkl
1735 !! html
1736 <p>asdf
1737 jkl
1738 </p>
1739 !! end
1740
1741 !! test
1742 Comment test 2b
1743 !! wikitext
1744 asdf
1745 <!-- comment 1 -->
1746
1747 jkl
1748 !! html
1749 <p>asdf
1750 </p><p>jkl
1751 </p>
1752 !! end
1753
1754 !! test
1755 Comment test 3
1756 !! wikitext
1757 asdf
1758 <!-- comment 1 -->
1759 <!-- comment 2 -->
1760 jkl
1761 !! html
1762 <p>asdf
1763 jkl
1764 </p>
1765 !! end
1766
1767 !! test
1768 Comment test 4
1769 !! wikitext
1770 asdf<!-- comment 1 -->jkl
1771 !! html
1772 <p>asdfjkl
1773 </p>
1774 !! end
1775
1776 !! test
1777 Comment spacing
1778 !! wikitext
1779 a
1780 <!-- foo --> b <!-- bar -->
1781 c
1782 !! html
1783 <p>a
1784 </p>
1785 <pre> b
1786 </pre>
1787 <p>c
1788 </p>
1789 !! end
1790
1791 !! test
1792 Comment whitespace
1793 !! wikitext
1794 <!-- returns a single newline, not nothing, since the newline after > is not stripped -->
1795 !! html
1796
1797 !! end
1798
1799 !! test
1800 Comment semantics and delimiters
1801 !! wikitext
1802 <!-- --><!----><!-----><!------>
1803 !! html/php
1804
1805 !! html/parsoid
1806 <!-- --><!----><!--&#x2D;--><!--&#x2D;&#x2D;-->
1807 !! end
1808
1809 !! test
1810 Comment semantics and delimiters, redux
1811 !! wikitext
1812 <!-- In SGML every "foo" here would actually show up in the text -- foo -- bar
1813 -- foo -- funky huh? ... -->
1814 !! html/php
1815
1816 !! html/parsoid
1817 <!-- In SGML every "foo" here would actually show up in the text &#x2D;&#x2D; foo &#x2D;&#x2D; bar
1818 &#x2D;&#x2D; foo &#x2D;&#x2D; funky huh? ... -->
1819 !! end
1820
1821 !! test
1822 Comment semantics and delimiters: directors cut
1823 !! wikitext
1824 <!-- ... However we like to keep things simple and somewhat XML-ish so we eat
1825 everything starting with < followed by !-- until the first -- and > we see,
1826 that wouldn't be valid XML however, since in XML -- has to terminate a comment
1827 -->-->
1828 !! html/php
1829 <p>--&gt;
1830 </p>
1831 !! html/parsoid
1832 <!-- ... However we like to keep things simple and somewhat XML&#x2D;ish so we eat
1833 everything starting with < followed by !&#x2D;&#x2D; until the first &#x2D;&#x2D; and &#x3E; we see,
1834 that wouldn't be valid XML however, since in XML &#x2D;&#x2D; has to terminate a comment
1835 --><p>--></p>
1836 !! end
1837
1838 !! test
1839 Comment semantics: nesting
1840 !! wikitext
1841 <!--<!-- no, we're not going to do anything fancy here -->-->
1842 !! html/php
1843 <p>--&gt;
1844 </p>
1845 !! html/parsoid
1846 <!--<!&#x2D;&#x2D; no, we're not going to do anything fancy here --><p>--></p>
1847 !! end
1848
1849 # Parsoid closes the unclosed comment, even if it means a slight
1850 # round-trip diff.
1851 !! test
1852 Comment semantics: unclosed comment at end
1853 !! options
1854 parsoid=wt2html,html2html
1855 !! wikitext
1856 <!--This comment will run out to the end of the document
1857 !! html/php
1858
1859 !! html/parsoid
1860 <!--This comment will run out to the end of the document-->
1861 !! end
1862
1863 !! test
1864 Comment semantics: normalize comments to play nice with XML and browsers
1865 !! wikitext
1866 <!-- Browsers --!> think this is closed -->
1867 <!--> This would normally be text -->
1868 <!---> As would this -->
1869 <!-- XML doesn't like trailing dashes -------->
1870 <!-- Nor doubled hyphens -- anywhere in the data -->
1871 But this is not a comment.
1872 !! html/php
1873 <p>But this is not a comment.
1874 </p>
1875 !! html/parsoid
1876 <!-- Browsers &#x2D;&#x2D;!&#x3E; think this is closed -->
1877 <!--&#x3E; This would normally be text -->
1878 <!--&#x2D;&#x3E; As would this -->
1879 <!-- XML doesn't like trailing dashes &#x2D;&#x2D;&#x2D;&#x2D;&#x2D;&#x2D;-->
1880 <!-- Nor doubled hyphens &#x2D;&#x2D; anywhere in the data -->
1881 <p>But this is not a comment.</p>
1882 !! end
1883
1884 !! test
1885 Comment semantics: round-trip even text which contains encoded -->
1886 !! wikitext
1887 <!-- hello & goodbye - > --&gt; --&amp;gt; --&xx -->
1888 !! html/parsoid
1889 <!-- hello &#x26; goodbye &#x2D; &#x3E; &#x2D;&#x2D;&#x3E; &#x2D;&#x2D;&#x26;gt; &#x2D;&#x2D;&#x26;xx -->
1890 !! end
1891
1892 !! test
1893 Comment in template title
1894 !! wikitext
1895 {{f<!---->oo}}
1896 !! html
1897 <p>FOO
1898 </p>
1899 !! end
1900
1901 !! test
1902 Comment on its own line post-expand
1903 !! wikitext
1904 a
1905 {{blank}}<!---->
1906 b
1907 !! html
1908 <p>a
1909 </p><p>b
1910 </p>
1911 !! end
1912
1913 !! test
1914 Comment on its own line post-expand with non-significant whitespace
1915 !! wikitext
1916 a
1917 {{blank}} <!---->
1918 b
1919 !! html
1920 <p>a
1921 </p><p>b
1922 </p>
1923 !! end
1924
1925 !! test
1926 post-expand include size being exceeded
1927 !! options
1928 maxincludesize=20
1929 !! wikitext
1930 {{echo3|1234567890}}
1931 !! html
1932 <p><a href="/wiki/Template:Echo3" title="Template:Echo3">Template:Echo3</a><!-- WARNING: template omitted, post-expand include size too large -->
1933 </p>
1934 !! end
1935
1936 !! test
1937 max template depth being reached
1938 !! options
1939 maxtemplatedepth=1
1940 !! wikitext
1941 {{echo with depth|too deep!}}
1942 !! html
1943 <p><span class="error">Template recursion depth limit exceeded (1)</span>
1944 </p>
1945 !! end
1946
1947 !! test
1948 multiple templates that are redirects
1949 !! wikitext
1950 {{redirect to foo}}
1951 {{redirect to foo}}
1952 !! html
1953 <p>FOO
1954 FOO
1955 </p>
1956 !! end
1957
1958 !! test
1959 Multiple comments should still parse as SOL-transparent
1960 !! options
1961 parsoid=wt2html,wt2wt
1962 !! wikitext
1963 <!--c1-->*a
1964 <!--c2--><!--c3--><!--c4-->*b
1965 !! html/php
1966 <ul><li>a</li>
1967 <li>b</li></ul>
1968
1969 !! html/parsoid
1970 <!--c1--><ul>
1971 <li>a
1972 </li>
1973 <!--c2--><!--c3--><!--c4-->
1974 <li>b
1975 </li>
1976 </ul>
1977 !! end
1978
1979 ## Make sure ">" gets escaped in comments to avoid XSS
1980 !! test
1981 IE conditional comments
1982 !! wikitext
1983 <!--[if lt IE 9]>
1984 <script>alert('hi');</script>
1985 <![endif]-->
1986 !! html/parsoid
1987 <!--[if lt IE 9]&#x3E;
1988 <script&#x3E;alert('hi');</script&#x3E;
1989 <![endif]-->
1990 !! end
1991
1992 ###
1993 ### paragraph wrapping tests
1994 ###
1995
1996 !! test
1997 No block tags
1998 !! wikitext
1999 a
2000
2001 b
2002 !! html
2003 <p>a
2004 </p><p>b
2005 </p>
2006 !! end
2007
2008 !! test
2009 Block tag on one line (<div>)
2010 !! wikitext
2011 a <div>foo</div>
2012
2013 b
2014 !! html
2015 a <div>foo</div>
2016 <p>b
2017 </p>
2018 !! html+tidy
2019 <p>a </p><div>foo</div>
2020 <p>b
2021 </p>
2022 !! end
2023
2024 # Remex wraps empty tag runs with p-tags.
2025 # Parsoid strips them out during p-wrapping.
2026 !! test
2027 No p-wrappable content
2028 !! wikitext
2029 <span><div>x</div></span>
2030 <span><s><div>x</div></s></span>
2031 <small><em></em></small><span><s><div>x</div></s></span>
2032 !! html/php+tidy
2033 <span><div>x</div></span>
2034 <span><s><div>x</div></s></span>
2035 <p><small><em></em></small></p><span><s><div>x</div></s></span>
2036 !! html/parsoid
2037 <span><div>x</div></span>
2038 <span><s><div>x</div></s></span>
2039 <small><em></em></small><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 # The difference between Parsoid & Remex here
2126 # is because of Parsoid's Tidy-emulation code
2127 # for p-wrapping. We'll start work to remove this
2128 # emulation code in Parsoid sooner than later.
2129 # Remex wraps empty tag runs with p-tags.
2130 # Parsoid strips them out in a separate pass.
2131 !! test
2132 Empty lines between lines with block tags
2133 !! wikitext
2134 <div></div>
2135
2136
2137 <div></div>a
2138
2139 b
2140 <div>a</div>b
2141
2142 <div>b</div>d
2143
2144
2145 <div>e</div>
2146 !! html
2147 <div></div>
2148 <p><br />
2149 </p>
2150 <div></div>a
2151 <p>b
2152 </p>
2153 <div>a</div>b
2154 <div>b</div>d
2155 <p><br />
2156 </p>
2157 <div>e</div>
2158
2159 !! html+tidy
2160 <div></div>
2161 <p><br />
2162 </p>
2163 <div></div><p>a
2164 </p><p>b
2165 </p>
2166 <div>a</div><p>b
2167 </p><div>b</div><p>d
2168 </p><p><br />
2169 </p>
2170 <div>e</div>
2171 !! html/parsoid
2172 <div data-parsoid='{"stx":"html"}'></div>
2173
2174 <p><br /></p>
2175 <div data-parsoid='{"stx":"html"}'></div><p>a</p>
2176
2177 <p>b</p>
2178 <div data-parsoid='{"stx":"html"}'>a</div><p>b</p>
2179
2180 <div data-parsoid='{"stx":"html"}'>b</div><p>d</p>
2181
2182 <p><br /></p>
2183 <div data-parsoid='{"stx":"html"}'>e</div>
2184 !! end
2185
2186 !! test
2187 Unclosed HTML p-tags should be handled properly
2188 !! wikitext
2189 <div><p>foo</div>
2190 a
2191
2192 b
2193 !! html/php+tidy
2194 <div><p>foo</p></div>
2195 <p>a
2196 </p><p>b
2197 </p>
2198 !! html/parsoid
2199 <div data-parsoid='{"stx":"html"}'><p data-parsoid='{"stx":"html", "autoInsertedEnd":true}'>foo</p></div>
2200 <p>a</p>
2201 <p>b</p>
2202 !! end
2203
2204 ## SSS FIXME: I can come up with other scenarios where this doesn't work because
2205 ## of eager output of buffered tokens in the p-wrapper. But, I'm going to ignore
2206 ## them for now.
2207 !! test
2208 1. P-wrapping should leave sol-transparent tags outside p-tags where possible
2209 !! options
2210 parsoid=wt2html
2211 !! wikitext
2212 a [[Category:A1]] [[Category:A2]]
2213 [[Category:A3]]
2214 [[Category:A4]]
2215 !! html/parsoid
2216 <p>a</p>
2217 <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"/>
2218 !! end
2219
2220 !! test
2221 2. P-wrapping should leave sol-transparent tags outside p-tags where possible
2222 !! options
2223 parsoid=wt2html
2224 !! wikitext
2225 [[Category:A1]]a
2226 !! html/parsoid
2227 <link rel="mw:PageProp/Category" href="./Category:A1"/><p>a</p>
2228 !! end
2229
2230 !! test
2231 No paragraph necessary for SOL transparent template
2232 !! wikitext
2233 <span><div>foo</div></span>
2234 [[Category:Foo]]
2235
2236 <span><div>foo</div></span>
2237 {{echo|[[Category:Foo]]}}
2238 !! html/php
2239 <span><div>foo</div></span>
2240 <span><div>foo</div></span>
2241
2242 !! html/parsoid
2243 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2244 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
2245
2246 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2247 <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}}]}'/>
2248 !! end
2249
2250 !! test
2251 Avoid expanding multiline sol transparent template ranges unnecessarily
2252 !! wikitext
2253 hi
2254
2255
2256 {{echo|<br/>
2257 }}
2258
2259 [[Category:Ho]]
2260 !! html/php
2261 <p>hi
2262 </p><p><br />
2263 <br />
2264 </p>
2265 !! html/parsoid
2266 <p>hi</p>
2267
2268 <p><br />
2269 <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">
2270 </span></p>
2271
2272 <link rel="mw:PageProp/Category" href="./Category:Ho" />
2273 !! end
2274
2275 !! test
2276 Paragraph wrapping following unclosed table
2277 !! options
2278 parsoid=wt2html,html2html
2279 !! wikitext
2280 {|
2281 |-
2282
2283 {|
2284 | x
2285 |}
2286
2287 a
2288
2289 b
2290
2291 c
2292 !! html/php+tidy
2293 <table>
2294
2295
2296 </table><table>
2297 <tbody><tr>
2298 <td>x
2299 </td></tr></tbody></table>
2300 <p>a
2301 </p><p>b
2302 </p><p>c
2303 </p>
2304 !! html/parsoid
2305 <table data-parsoid='{"autoInsertedEnd":true}'>
2306 <tbody><tr class="mw-empty-elt" data-parsoid='{"startTagSrc":"|-"}'></tr>
2307
2308 </tbody></table><table>
2309 <tbody><tr data-parsoid='{"autoInsertedStart":true}'><td>x</td></tr>
2310 </tbody></table>
2311
2312 <p>a</p>
2313
2314 <p>b</p>
2315
2316 <p>c</p>
2317 !! end
2318
2319 !! test
2320 Paragraph wrapping suppressed in html p
2321 !! options
2322 parsoid=wt2html,html2html
2323 !! wikitext
2324 <p>
2325
2326
2327 hi
2328
2329
2330
2331 </p>
2332 !! html/php+tidy
2333 <p>
2334
2335
2336 hi
2337
2338
2339
2340 </p>
2341 !! html/parsoid
2342 <p data-parsoid='{"stx":"html"}'>
2343
2344
2345 hi
2346
2347
2348
2349 </p>
2350 !! end
2351
2352 ###
2353 ### Preformatted text
2354 ###
2355
2356 !! test
2357 Preformatted text
2358 !! wikitext
2359 This is some
2360 Preformatted text
2361 With ''italic''
2362 And '''bold'''
2363 And a [[Main Page|link]]
2364 !! html
2365 <pre>This is some
2366 Preformatted text
2367 With <i>italic</i>
2368 And <b>bold</b>
2369 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
2370 </pre>
2371 !! end
2372
2373 !! test
2374 Tabs don't trigger preformatted text
2375 !! wikitext
2376 This is not
2377 preformatted text.
2378 This is preformatted text.
2379 So is this.
2380 !! html/php
2381 <p> This is not
2382 preformatted text.
2383 </p>
2384 <pre>This is preformatted text.
2385 So is this.
2386 </pre>
2387 !! html/parsoid
2388 <p> This is not
2389 preformatted text.</p>
2390 <pre>This is preformatted text.
2391 So is this.</pre>
2392 !! end
2393
2394 !! test
2395 Space before tab needs nowiki pre protection
2396 !! options
2397 parsoid=html2wt
2398 !! html/parsoid
2399 <p> a</p>
2400 !! wikitext
2401 <nowiki> </nowiki> a
2402 !! end
2403
2404 !! test
2405 Ident preformatting with inline content
2406 !! wikitext
2407 a
2408 ''b''
2409 !! html
2410 <pre>a
2411 <i>b</i>
2412 </pre>
2413 !! end
2414
2415 !! test
2416 <pre> with <nowiki> inside (compatibility with 1.6 and earlier)
2417 !! wikitext
2418 <pre><nowiki>
2419 <b>
2420 <cite>
2421 <em>
2422 </nowiki></pre>
2423 !! html
2424 <pre>
2425 &lt;b&gt;
2426 &lt;cite&gt;
2427 &lt;em&gt;
2428 </pre>
2429
2430 !! end
2431
2432 !! test
2433 Regression with preformatted in <center>
2434 !! wikitext
2435 <center>
2436 Blah
2437 </center>
2438 !! html
2439 <center>
2440 <pre>Blah
2441 </pre>
2442 </center>
2443
2444 !! end
2445
2446 !! test
2447 T54763: Preformatted in <blockquote>
2448 !! wikitext
2449 <blockquote>
2450 Blah
2451 {|
2452 |
2453 indented cell (no pre-wrapping!)
2454 |}
2455 </blockquote>
2456 !! html
2457 <blockquote>
2458 <p> Blah
2459 </p>
2460 <table>
2461 <tr>
2462 <td>
2463 <p> indented cell (no pre-wrapping!)
2464 </p>
2465 </td></tr></table>
2466 </blockquote>
2467
2468 !! end
2469
2470 !! test
2471 T53086: Double newlines in blockquotes should be turned into paragraphs
2472 !! wikitext
2473 <blockquote>
2474 Foo
2475
2476 Bar
2477 </blockquote>
2478 !! html
2479 <blockquote>
2480 <p>Foo
2481 </p><p>Bar
2482 </p>
2483 </blockquote>
2484
2485 !! end
2486
2487 !! test
2488 T17491: <ins>/<del> in blockquote
2489 !! wikitext
2490 <blockquote>
2491 Foo <del>bar</del> <ins>baz</ins> quux
2492 </blockquote>
2493 !! html
2494 <blockquote>
2495 <p>Foo <del>bar</del> <ins>baz</ins> quux
2496 </p>
2497 </blockquote>
2498
2499 !! html+tidy
2500 <blockquote>
2501 <p>Foo <del>bar</del> <ins>baz</ins> quux
2502 </p>
2503 </blockquote>
2504 !! end
2505
2506 !! test
2507 T17491: <ins>/<del> in blockquote (2)
2508 !! wikitext
2509 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2510 </blockquote>
2511 !! html
2512 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2513 </blockquote>
2514
2515 !! html+tidy
2516 <blockquote><p>Foo <del>bar</del> <ins>baz</ins> quux
2517 </p></blockquote>
2518 !! end
2519
2520 !! test
2521 <pre> with attributes (T5202)
2522 !! wikitext
2523 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2524 !! html
2525 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2526
2527 !! end
2528
2529 !! test
2530 <pre> with width attribute (T5202)
2531 !! wikitext
2532 <pre width="8">Narrow screen goodies</pre>
2533 !! html
2534 <pre width="8">Narrow screen goodies</pre>
2535
2536 !! end
2537
2538 !! test
2539 <pre> with forbidden attribute (T5202)
2540 !! wikitext
2541 <pre width="8" onmouseover="alert(document.cookie)">Narrow screen goodies</pre>
2542 !! html
2543 <pre width="8">Narrow screen goodies</pre>
2544
2545 !! end
2546
2547 !! test
2548 Entities inside <pre>
2549 !! wikitext
2550 <pre>&lt;</pre>
2551 !! html
2552 <pre>&lt;</pre>
2553
2554 !! end
2555
2556 !! test
2557 <pre> with forbidden attribute values (T5202)
2558 !! wikitext
2559 <pre width="8" style="border-width: expression(alert(document.cookie))">Narrow screen goodies</pre>
2560 !! html
2561 <pre width="8" style="/* insecure input */">Narrow screen goodies</pre>
2562
2563 !! end
2564
2565 !! test
2566 <nowiki> inside <pre> (T15238)
2567 !! wikitext
2568 <pre>
2569 <nowiki>
2570 </pre>
2571 <pre>
2572 <nowiki></nowiki>
2573 </pre>
2574 <pre><nowiki><nowiki></nowiki>Foo<nowiki></nowiki></nowiki></pre>
2575 !! html
2576 <pre>
2577 &lt;nowiki&gt;
2578 </pre>
2579 <pre>
2580
2581 </pre>
2582 <pre>&lt;nowiki&gt;Foo&lt;/nowiki&gt;</pre>
2583
2584 !! end
2585
2586 !! test
2587 <nowiki> inside of #tag:pre
2588 !! wikitext
2589 {{#tag:pre|Foo <nowiki>&rarr;bar</nowiki>}}
2590 !! html/php
2591 <pre>Foo &#8594;bar</pre>
2592
2593 !! html/parsoid
2594 <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>
2595 !! end
2596
2597 ## Don't expect this to rt, Parsoid drops the unmatched closing pre tags that
2598 ## aren't enclosed in nowikis.
2599 !! test
2600 <nowiki> and <pre> preference (first one wins)
2601 !! options
2602 parsoid=wt2html
2603 !! wikitext
2604 <pre>
2605 <nowiki>
2606 </pre>
2607 </nowiki>
2608 </pre>
2609
2610 <nowiki>
2611 <pre>
2612 <nowiki>
2613 </pre>
2614 </nowiki>
2615 </pre>
2616
2617 !! html/php
2618 <pre>
2619 &lt;nowiki&gt;
2620 </pre>
2621 <p>&lt;/nowiki&gt;
2622 &lt;/pre&gt;
2623 </p><p>
2624 &lt;pre&gt;
2625 &lt;nowiki&gt;
2626 &lt;/pre&gt;
2627
2628 &lt;/pre&gt;
2629 </p>
2630 !! html/parsoid
2631 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n&lt;nowiki>\n"}}'>&lt;nowiki>
2632 </pre>
2633 <p>&lt;/nowiki></p>
2634
2635
2636 <p><span typeof="mw:Nowiki">
2637 &lt;pre>
2638 &lt;nowiki>
2639 &lt;/pre>
2640 </span></p>
2641 !! end
2642
2643 !! test
2644 </pre> inside nowiki
2645 !! wikitext
2646 <nowiki></pre></nowiki>
2647 !! html
2648 <p>&lt;/pre&gt;
2649 </p>
2650 !! end
2651
2652 !! test
2653 Empty pre; pre inside other HTML tags (T56946)
2654 !! wikitext
2655 a
2656
2657 <div><pre>
2658 foo
2659 </pre></div>
2660 <pre></pre>
2661 !! html/php+tidy
2662 <p>a
2663 </p>
2664 <div><pre>foo
2665 </pre></div>
2666 <pre></pre>
2667 !! html/parsoid
2668 <p>a</p>
2669
2670 <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
2671 </pre></div>
2672 <pre typeof="mw:Extension/pre" about="#mwt4" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":""}}'></pre>
2673 !! end
2674
2675 !! test
2676 HTML pre followed by indent-pre
2677 !! wikitext
2678 <pre>foo</pre>
2679 bar
2680 !! html
2681 <pre>foo</pre>
2682 <pre>bar
2683 </pre>
2684 !! end
2685
2686 !! test
2687 Block tag pre
2688 !! wikitext
2689 <p><pre>foo</pre></p>
2690 !! html/php+tidy
2691 <p class="mw-empty-elt"></p><pre>foo</pre><p class="mw-empty-elt"></p>
2692 !! html/parsoid
2693 <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>
2694 !! end
2695
2696 !!test
2697 Templates: Indent-Pre: 1a. Templates that break a line should suppress <pre>
2698 !! wikitext
2699 {{echo|}}
2700 !! html
2701
2702 !!end
2703
2704 !!test
2705 Templates: Indent-Pre: 1b. Templates that break a line should suppress <pre>
2706 !! wikitext
2707 {{echo|
2708 foo}}
2709 !! html
2710 <p>foo
2711 </p>
2712 !!end
2713
2714 !! test
2715 Templates: Indent-Pre: 1c: Wrapping should be based on expanded content
2716 !! wikitext
2717 {{echo|a
2718 b}}
2719 !! html
2720 <pre>a
2721 </pre>
2722 <p>b
2723 </p>
2724 !!end
2725
2726 !! test
2727 Templates: Indent-Pre: 1d: Wrapping should be based on expanded content
2728 !! wikitext
2729 {{echo|a
2730 b
2731 c
2732 d
2733 e
2734 }}
2735 !! html
2736 <pre>a
2737 </pre>
2738 <p>b
2739 c
2740 </p>
2741 <pre>d
2742 </pre>
2743 <p>e
2744 </p>
2745 !!end
2746
2747 !!test
2748 Templates: Indent-Pre: 1e. Wrapping should be based on expanded content
2749 !! wikitext
2750 {{echo| foo}}
2751
2752 {{echo| foo}}{{echo| bar}}
2753
2754 {{echo| foo}}
2755 {{echo| bar}}
2756
2757 {{echo|<!--cmt--> foo}}
2758
2759 <!--cmt-->{{echo| foo}}
2760
2761 {{echo|{{echo| }}bar}}
2762 !! html
2763 <pre>foo
2764 </pre>
2765 <pre>foo bar
2766 </pre>
2767 <pre>foo
2768 bar
2769 </pre>
2770 <pre>foo
2771 </pre>
2772 <pre>foo
2773 </pre>
2774 <pre>bar
2775 </pre>
2776 !!end
2777
2778 !! test
2779 Templates: Indent-Pre: 1f: Wrapping should be based on expanded content
2780 !! wikitext
2781 {{echo| }}a
2782
2783 {{echo|
2784 }}a
2785
2786 {{echo|
2787 b}}
2788
2789 {{echo|a
2790 }}b
2791
2792 {{echo|a
2793 }} b
2794 !! html
2795 <pre>a
2796 </pre>
2797 <p><br />
2798 </p>
2799 <pre>a
2800 </pre>
2801 <p><br />
2802 </p>
2803 <pre>b
2804 </pre>
2805 <p>a
2806 </p>
2807 <pre>b
2808 </pre>
2809 <p>a
2810 </p>
2811 <pre>b
2812 </pre>
2813 !!end
2814
2815 ## Hmm, should Parsoid rt this?
2816 !! test
2817 Pres with newline attributes
2818 !! options
2819 parsoid=wt2html,html2html
2820 !! wikitext
2821 <pre class="one
2822 two">hi</pre>
2823 !! html/php
2824 <pre class="one two">hi</pre>
2825
2826 !! html/parsoid
2827 <pre typeof="mw:Extension/pre" about="#mwt2" class="one two" data-mw='{"name":"pre","attrs":{"class":"one two"},"body":{"extsrc":"hi"}}'>hi</pre>
2828 !! end
2829
2830 !! test
2831 Things that look like <pre> tags aren't treated as such
2832 !! wikitext
2833 Barack Obama <President> of the United States
2834 <President></President>
2835 !! html
2836 <p>Barack Obama &lt;President&gt; of the United States
2837 &lt;President&gt;&lt;/President&gt;
2838 </p>
2839 !! end
2840
2841 !! test
2842 Handle broken pre-like tags (T66025)
2843 !! options
2844 parsoid=wt2html
2845 !! wikitext
2846 {{echo|<pre <pre>x</pre>}}
2847
2848 <table><pre </table>
2849 !! html/php
2850 <pre>x</pre>
2851 <table>&lt;pre </table>
2852
2853 !! html/php+tidy
2854 <pre>x</pre>
2855 &lt;pre <table></table>
2856 !! html/parsoid
2857 <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>
2858
2859 <span data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>&lt;pre </span><table data-parsoid='{"stx":"html"}'></table>
2860 !! end
2861
2862 !! test
2863 Parsoid: handle pre with space after attribute
2864 !! options
2865 parsoid=wt2html
2866 !! wikitext
2867 <pre style="width:50%;" >{{echo|foo}}</pre>
2868 !! html/php
2869 <pre style="width:50%;">{{echo|foo}}</pre>
2870
2871 !! html/parsoid
2872 <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>
2873 !! end
2874
2875 # TODO / maybe: fix wt2wt for this
2876 !! test
2877 Parsoid: Don't paragraph-wrap fosterable content
2878 !! options
2879 parsoid=wt2html
2880 !! wikitext
2881 {|
2882 <td></td>
2883 <td></td>
2884
2885
2886
2887 |}
2888 !! html
2889 <table>
2890
2891 <tbody>
2892 <tr>
2893 <td></td>
2894
2895 <td></td></tr>
2896
2897
2898
2899 </tbody></table>
2900 !! end
2901
2902 !! test
2903 Self-closed pre
2904 !! wikitext
2905 <pre />
2906 !! html/php
2907 <pre></pre>
2908
2909 !! html/parsoid
2910 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":null}'></pre>
2911 !! end
2912
2913 !! test
2914 Parsoid: Don't paragraph-wrap fosterable content even if table syntax is unbalanced
2915 !! options
2916 parsoid=wt2html
2917 !! wikitext
2918 {|
2919 <td>
2920 <td>
2921 </td>
2922
2923
2924
2925 |}
2926 !! html
2927 <table>
2928
2929 <tbody>
2930 <tr>
2931 <td></td>
2932
2933 <td>
2934 </td></tr>
2935
2936
2937
2938 </tbody></table>
2939 !! end
2940
2941
2942 #--------------------------------------------------------------------
2943 # Transclusion parameter whitespace stripping tests
2944 # Behavior is different for positional and named parameters
2945 #--------------------------------------------------------------------
2946 !! test
2947 Templates: Strip leading and trailing whitespace from named-param values
2948 !! wikitext
2949 {{echo|1= a }}
2950
2951 {{echo|1= {{echo|b}} }}
2952
2953 {{echo| 1 =
2954 c }}
2955
2956 {{echo| 1 =
2957 * d
2958 }}
2959 !! html
2960 <p>a
2961 </p><p>b
2962 </p><p>c
2963 </p>
2964 <ul><li>d</li></ul>
2965
2966 !! end
2967
2968 !! test
2969 Templates: Don't strip whitespace from positional-param values
2970 !! wikitext
2971 {{echo|a }}
2972
2973 {{echo|{{echo|b}} }}
2974
2975 {{echo| c
2976 }}
2977
2978 {{echo| {{echo|d}}
2979 }}
2980
2981 {{echo|
2982 e}}
2983
2984 {{echo|
2985 *f}}
2986
2987 {{echo|
2988 }}g
2989 !! html
2990 <p>a
2991 </p><p>b
2992 </p>
2993 <pre>c
2994 </pre>
2995 <p><br />
2996 </p>
2997 <pre>d
2998 </pre>
2999 <p><br />
3000 </p>
3001 <pre>e
3002 </pre>
3003 <p><br />
3004 </p>
3005 <ul><li>f</li></ul>
3006 <p><br />
3007 </p>
3008 <pre>g
3009 </pre>
3010 !! end
3011
3012 !! test
3013 Templates: Don't recognize targets split by newlines
3014 !! options
3015 parsoid=wt2html
3016 !! wikitext
3017 {{ech
3018 o|foo}}
3019 !! html/php
3020 <p>{{ech
3021 o|foo}}
3022 </p>
3023 !! html/parsoid
3024 <p>{{ech
3025 o|foo}}</p>
3026 !! end
3027
3028 !! test
3029 Templates: Recognize targets when newlines and comments don't split the target
3030 !! options
3031 parsoid=wt2html
3032 !! wikitext
3033 {{
3034 <!--X--> ech<!--X-->o<!--X-->
3035 <!--X--> <!--X-->
3036
3037 |foo}}
3038 !! html/php
3039 <p>foo
3040 </p>
3041 !! html/parsoid
3042 <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>
3043 !! end
3044
3045 !! test
3046 Templates: Handle empty comment-and-ws-only lines correctly
3047 !! wikitext
3048 {{echo|foo
3049 <!--should be ignored-->
3050 <!--should be ignored as well-->
3051 bar}}
3052 !! html/php
3053 <p>foo
3054 bar
3055 </p>
3056 !! html/parsoid
3057 <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>
3058 !! end
3059
3060 !! test
3061 Templates: Handle comments in the target
3062 !! wikitext
3063 {{echo
3064 <!-- should be ignored -->
3065 |foo}}
3066
3067 {{echo
3068 <!-- should be ignored and spaces on next line should not trip us up (T147742) -->
3069 |foo}}
3070
3071 {{echo<!-- should be ignored -->
3072 |foo}}
3073
3074 {{echo<!-- should be ignored -->|foo}}
3075
3076 {{<!-- should be ignored -->echo|foo}}
3077 !! html/php
3078 <p>foo
3079 </p><p>foo
3080 </p><p>foo
3081 </p><p>foo
3082 </p><p>foo
3083 </p>
3084 !! html/parsoid
3085 <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>
3086
3087 <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>
3088
3089 <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>
3090
3091 <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>
3092
3093 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
3094 !! end
3095
3096 !! test
3097 Templates: Handle comments in parameter names (T69657)
3098 !! wikitext
3099 {{echo|1
3100 <!-- should be ignored -->
3101 =foo}}
3102
3103 {{echo|
3104 <!-- should be ignored -->
3105 1 = foo}}
3106
3107 {{echo|1<!-- should be ignored -->=foo}}
3108
3109 {{echo|<!-- should be ignored -->1=foo}}
3110 !! html/php
3111 <p>foo
3112 </p><p>foo
3113 </p><p>foo
3114 </p><p>foo
3115 </p>
3116 !! html/parsoid
3117 <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>
3118
3119 <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>
3120
3121 <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>
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 -->1"}}},"i":0}}]}'>foo</p>
3124 !! end
3125
3126 !! test
3127 Templates: Other wikitext in parameter names (T69657)
3128 !! wikitext
3129 {{echo|''1''=foo}}
3130 !! html/php
3131 <p>{{{1}}}
3132 </p>
3133 !! html/parsoid
3134 <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>
3135 !! end
3136
3137 !! test
3138 Templates: With colons
3139 !! wikitext
3140 {{With: Colon}}
3141 !! html/php
3142 <p>Template with colon
3143 </p>
3144 !! html/parsoid
3145 <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>
3146 !! end
3147
3148 #--------------------------------------------------------------------
3149 # Transclusion parameter escaping tests
3150 #--------------------------------------------------------------------
3151
3152 !! test
3153 Templates: Parsoid parameter escaping test 1
3154 !! wikitext
3155 {{echo|[foo]|{{echo|[bar]}}}}
3156 !! html/php+tidy
3157 <p>[foo]
3158 </p>
3159 !! html/parsoid
3160 <p about="#mwt1" typeof="mw:Transclusion"
3161 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[foo]"},"2":{"wt":"{{echo|[bar]}}"}},"i":0}}]}'>[foo]</p>
3162 !! end
3163
3164 !! test
3165 Parsoid: Pipes in external links in template parameter
3166 !! wikitext
3167 {{echo|[{{echo|http://example.com}} link]}}
3168 !! html/php+tidy
3169 <p><a rel="nofollow" class="external text" href="http://example.com">link</a>
3170 </p>
3171 !! html/parsoid
3172 <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>
3173 !! end
3174
3175 !! test
3176 Parsoid: pipe in transclusion parameter
3177 !! wikitext
3178 {{echo|http://foo.com/a&#124;b}}
3179 !! html/php+tidy
3180 <p><a rel="nofollow" class="external free" href="http://foo.com/a%7Cb">http://foo.com/a%7Cb</a>
3181 </p>
3182 !! html/parsoid
3183 <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>
3184 !! end
3185
3186 !! test
3187 Parsoid: Pipe in external link target and content in template parameter
3188 !! options
3189 parsoid=html2wt,wt2wt
3190 !! wikitext
3191 {{echo|[http://foo.com/a&#124;b a&#124;b]}}
3192 !! html/php+tidy
3193 <p><a rel="nofollow" class="external text" href="http://foo.com/a%7Cb">a&#124;b</a>
3194 </p>
3195 !! html/parsoid
3196 <p><a rel="mw:ExtLink" href="http://foo.com/a|b" about="#mwt1"
3197 typeof="mw:Transclusion"
3198 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},
3199 "params":{"1":{"wt":"[http://foo.com/a|b a|b]"}},"i":0}}]}'>a|b</a></p>
3200 !! end
3201
3202 !! test
3203 Parsoid: Pipe in template with nested template in external link target in template parameter (seriously)
3204 !! options
3205 parsoid
3206 !! wikitext
3207 {{echo|[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]}}
3208 !! html
3209 <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>
3210 !! end
3211
3212 !! test
3213 Templates: Don't escape already nowiki-escaped text in template parameters
3214 !! options
3215 parsoid=html2wt,wt2wt
3216 !! wikitext
3217 {{echo|foo<nowiki>|</nowiki>bar}}
3218 {{echo|<nowiki>&lt;div&gt;</nowiki>}}
3219 {{echo|<nowiki></nowiki>}}
3220 !! html/php+tidy
3221 <p>foo|bar
3222 &lt;div&gt;
3223
3224 </p>
3225 !! html/parsoid
3226 <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>
3227 <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>
3228 <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>
3229 </p>
3230 !! end
3231
3232 ## T54824
3233 !! test
3234 Templates: '=' char in nested transclusions should not trigger nowiki escapes or conversion to named param
3235 !! options
3236 parsoid=html2wt,wt2wt
3237 !! wikitext
3238 {{echo|{{echo|1=bar}}}}
3239 !! html/php+tidy
3240 <p>bar
3241 </p>
3242 !! html/parsoid
3243 <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>
3244 !! end
3245
3246 ## T58733
3247 !! test
3248 Templates parameters with special tokenizing behavior dont get modified because of arg escaping
3249 !! wikitext
3250 {{echo|a : b}}
3251 !! html/php+tidy
3252 <p>a&#160;: b
3253 </p>
3254 !! html/parsoid
3255 <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>
3256 !! end
3257
3258 ## T73412
3259 !! test
3260 Templates: Preserve blank parameter names
3261 !! wikitext
3262 {{echo|=foo}}
3263 !! html/php+tidy
3264 <p>{{{1}}}
3265 </p>
3266 !! html/parsoid
3267 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"":{"wt":"foo"}},"i":0}}]}'>{{{1}}}</p>
3268 !! end
3269
3270 !! test
3271 Templates: Preserve blank parameter names in other positions
3272 !! wikitext
3273 {{blank_param|bar|=foo}}
3274 !! html/php+tidy
3275 <p>bar
3276 foo
3277 </p>
3278 !! html/parsoid
3279 <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
3280 foo</p>
3281 !! end
3282
3283 ###
3284 ### Parsoid-centric tests for testing RT edge cases for pre
3285 ###
3286
3287 !!test
3288 1a. Indent-Pre and Comments
3289 !! wikitext
3290 a
3291 <!--a-->
3292 c
3293 !! html
3294 <pre>a
3295 </pre>
3296 <p>c
3297 </p>
3298 !!end
3299
3300 !!test
3301 1b. Indent-Pre and Comments
3302 !! wikitext
3303 a
3304 <!--a-->
3305 c
3306 !! html
3307 <pre>a
3308 </pre>
3309 <p>c
3310 </p>
3311 !!end
3312
3313 !!test
3314 1c. Indent-Pre and Comments
3315 !! wikitext
3316 <!--a--> a
3317
3318 <!--a--> a
3319 !! html
3320 <pre> a
3321 </pre>
3322 <pre> a
3323 </pre>
3324 !!end
3325
3326 !!test
3327 1d. Indent-Pre and Comments
3328 (Pre-handler currently cannot distinguish between comment/ws order and normalizes them to [comment,ws] order)
3329 !! wikitext
3330 <!--a--> a
3331
3332 <!--b-->b
3333 !! html
3334 <pre>a
3335 </pre>
3336 <pre>b
3337 </pre>
3338 !!end
3339
3340 !!test
3341 2a. Indent-Pre and tables
3342 !! wikitext
3343 {|
3344 |-
3345 !h1!!h2
3346 |foo||bar
3347 |}
3348 !! html
3349 <table>
3350
3351 <tr>
3352 <th>h1</th>
3353 <th>h2
3354 </th>
3355 <td>foo</td>
3356 <td>bar
3357 </td></tr></table>
3358
3359 !!end
3360
3361 !!test
3362 2b. Indent-Pre and tables
3363 !! wikitext
3364 {|
3365 |-
3366 |foo
3367 |}
3368 !! html
3369 <table>
3370
3371 <tr>
3372 <td>foo
3373 </td></tr></table>
3374
3375 !!end
3376
3377 !!test
3378 2c. Indent-Pre and tables (T44252)
3379 !! wikitext
3380 {|
3381 |+foo
3382 ! |bar
3383 |}
3384 !! html
3385 <table>
3386 <caption>foo
3387 </caption>
3388 <tr>
3389 <th>bar
3390 </th></tr></table>
3391
3392 !!end
3393
3394 !!test
3395 2d. Indent-Pre and tables
3396 !! wikitext
3397 a
3398 {|
3399 |b
3400 |}
3401 !! html/php
3402 <pre>a
3403 </pre>
3404 <table>
3405 <tr>
3406 <td>b
3407 </td></tr></table>
3408
3409 !! html/parsoid
3410 <pre>a</pre>
3411 <table>
3412 <tbody><tr><td> b</td></tr>
3413 </tbody></table>
3414 !!end
3415
3416 !!test
3417 2e. Indent-Pre and table-line syntax
3418 !! wikitext
3419 a
3420 | b
3421 | c
3422 !! html/php
3423 <pre>a
3424 | b
3425 | c
3426 </pre>
3427 !!end
3428
3429 !!test
3430 2f. Indent-pre started by table-line syntax
3431 !! wikitext
3432 a
3433 | b
3434 | c
3435 !! html/php
3436 <p>a
3437 </p>
3438 <pre>| b
3439 | c
3440 </pre>
3441 !! html/parsoid
3442 <p>a</p>
3443 <pre>
3444 | b
3445 | c</pre>
3446 !!end
3447
3448 !! test
3449 2g. Indented table markup mixed with indented pre content (proposed in T8200)
3450 !! wikitext
3451 <table>
3452 <tr>
3453 <td>
3454 Text that should be rendered preformatted
3455 </td>
3456 </tr>
3457 </table>
3458 !! html
3459 <table>
3460 <tr>
3461 <td>
3462 <pre>Text that should be rendered preformatted
3463 </pre>
3464 </td>
3465 </tr>
3466 </table>
3467
3468 !! end
3469
3470 !! test
3471 2h. Indent pre in tables
3472 !! options
3473 parsoid=wt2html,html2html
3474 !! wikitext
3475 {|
3476 !
3477 foo
3478 !
3479 bar
3480 |-
3481 |
3482 baz
3483 {{!}}
3484 bam
3485 |}
3486 !! html/php
3487 <table>
3488 <tr>
3489 <th>
3490 <pre>foo
3491 </pre>
3492 </th>
3493 <th>
3494 <pre>bar
3495 </pre>
3496 </th></tr>
3497 <tr>
3498 <td>
3499 <pre>baz
3500 </pre>
3501 </td>
3502 <td>
3503 <pre>bam
3504 </pre>
3505 </td></tr></table>
3506
3507 !! html/parsoid
3508 <table>
3509 <tbody><tr><th>
3510 <pre>foo</pre>
3511 </th><th>
3512 <pre>bar</pre>
3513 </th></tr><tr>
3514 <td>
3515 <pre>baz</pre>
3516 </td><td data-parsoid='{"startTagSrc":"{{!}}"}'>
3517 <pre>bam</pre>
3518 </td></tr></tbody></table>
3519 !! end
3520
3521 !!test
3522 3a. Indent-Pre and block tags (single-line html)
3523 !! wikitext
3524 a <p> foo </p>
3525 b <div> foo </div>
3526 c <blockquote> foo </blockquote>
3527 <span> foo </span>
3528 !! html
3529 a <p> foo </p>
3530 b <div> foo </div>
3531 c <blockquote> foo </blockquote>
3532 <pre><span> foo </span>
3533 </pre>
3534 !! html/parsoid
3535 <p>a </p><p data-parsoid='{"stx":"html"}'> foo </p>
3536 <p>b </p><div data-parsoid='{"stx":"html"}'> foo </div>
3537 <p>c </p><blockquote data-parsoid='{"stx":"html"}'> foo </blockquote>
3538 <pre><span> foo </span>
3539 </pre>
3540 !! html/php+tidy
3541 <p> a </p><p> foo </p><p>
3542 b </p><div> foo </div><p>
3543 c </p><blockquote><p> foo </p></blockquote>
3544 <pre><span> foo </span>
3545 </pre>
3546 !! end
3547
3548 !! test
3549 3b. Indent-Pre and block tags (multi-line html)
3550 !! wikitext
3551 a <span>foo</span>
3552 <!-- comment --> b <div> foo </div>
3553 !! html/php
3554 <pre>a <span>foo</span>
3555 </pre>
3556 b <div> foo </div>
3557
3558 !! html/parsoid
3559 <pre>a <span data-parsoid='{"stx":"html"}'>foo</span></pre>
3560 <!-- comment --> <p>b </p><div data-parsoid='{"stx":"html"}'> foo </div>
3561 !! html/php+tidy
3562 <pre>a <span>foo</span>
3563 </pre><p>
3564 b </p><div> foo </div>
3565 !! end
3566
3567 !!test
3568 3c. Indent-Pre and block tags (pre-content on separate line)
3569 !! wikitext
3570 <p>
3571 foo
3572 </p>
3573
3574 <div>
3575 foo
3576 </div>
3577
3578 <center>
3579 foo
3580 </center>
3581
3582 <blockquote>
3583 foo
3584 </blockquote>
3585
3586 <blockquote>
3587 <pre>
3588 foo
3589 </pre>
3590 </blockquote>
3591
3592 <table><tr><td>
3593 foo
3594 </td></tr></table>
3595
3596 <ul><li>
3597 foo
3598 </li></ul>
3599
3600 !! html
3601 <p>
3602 foo
3603 </p>
3604 <div>
3605 <pre>foo
3606 </pre>
3607 </div>
3608 <center>
3609 <pre>foo
3610 </pre>
3611 </center>
3612 <blockquote>
3613 <p> foo
3614 </p>
3615 </blockquote>
3616 <blockquote>
3617 <pre>
3618 foo
3619 </pre>
3620 </blockquote>
3621 <table><tr><td>
3622 <pre>foo
3623 </pre>
3624 </td></tr></table>
3625 <ul><li>
3626 foo
3627 </li></ul>
3628
3629 !!end
3630
3631 !! test
3632 4. Indent-Pre and extension tags
3633 !! wikitext
3634 a <tag />
3635 !! html/php
3636 a <pre>
3637 NULL
3638 array (
3639 )
3640 </pre>
3641
3642 !! html/parsoid
3643 a <pre typeof="mw:Extension/tag" about="#mwt2" data-parsoid='{}' data-mw='{"name":"tag","attrs":{},"body":null}'></pre>
3644 !! end
3645
3646 !! test
3647 5. Indent-Pre and html pre
3648 !! wikitext
3649 <pre class="123">hi</pre>
3650 !! html/php
3651 <pre class="123">hi</pre>
3652
3653 !! html/parsoid
3654 <pre typeof="mw:Extension/pre" about="#mwt2" class="123" data-mw='{"name":"pre","attrs":{"class":"123"},"body":{"extsrc":"hi"}}'>hi</pre>
3655 !! end
3656
3657 !!test
3658 Render paragraphs when indent-pre is suppressed in blocklevels
3659 !! wikitext
3660 <blockquote>
3661 foo
3662
3663 bar
3664 </blockquote>
3665 !! html
3666 <blockquote>
3667 <p> foo
3668 </p><p> bar
3669 </p>
3670 </blockquote>
3671
3672 !!end
3673
3674 !!test
3675 4. Multiple spaces at start-of-line
3676 !! wikitext
3677 <p> foo </p>
3678 foo
3679 {|
3680 |foo
3681 |}
3682 !! html
3683 <p> foo </p>
3684 <pre> foo
3685 </pre>
3686 <table>
3687 <tr>
3688 <td>foo
3689 </td></tr></table>
3690
3691 !!end
3692
3693 ## NOTE: the leading white-space chars on empty line are significant
3694 !! test
3695 5a. White-space in indent-pre
3696 !! wikitext
3697 a<br />
3698
3699 b
3700 !! html
3701 <pre>a<br />
3702
3703 b
3704 </pre>
3705 !! end
3706
3707 ## NOTE: the leading white-space chars on empty line are significant
3708 !! test
3709 5b. White-space in indent-pre
3710 !! wikitext
3711 a
3712
3713 b
3714
3715
3716 c
3717 !! html
3718 <pre>a
3719
3720 b
3721
3722
3723 c
3724 </pre>
3725 !! end
3726
3727 !! test
3728 5c. White-space in indent-pre
3729 !! wikitext
3730 ''a''
3731 ''b''
3732 ''c''
3733 !! html
3734 <pre><i>a</i>
3735 <i>b</i>
3736 <i>c</i>
3737 </pre>
3738 !! end
3739
3740 !! test
3741 6. Pre-blocks should extend across lines with leading WS even when there is no wrappable content
3742 !! wikitext
3743 a
3744
3745 <!-- continue -->
3746 b
3747
3748 c
3749
3750 d
3751 !! html
3752 <pre>a
3753
3754 b
3755 </pre>
3756 <pre>c
3757
3758 </pre>
3759 <p>d
3760 </p>
3761 !! end
3762
3763 !! test
3764 7a. Indent-pre and category links
3765 !! options
3766 parsoid=wt2html,wt2wt
3767 !! wikitext
3768 [[Category:foo]] <!-- No pre-wrapping -->
3769 {{echo| [[Category:foo]]}} <!-- No pre-wrapping -->
3770 !! html/php+tidy
3771 !! html/parsoid
3772 <link rel="mw:PageProp/Category" href="./Category:Foo"> <!-- No pre&#x2D;wrapping -->
3773 <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 -->
3774 !! end
3775
3776 ## We used to, but no longer wt2wt this test since the default serializer
3777 ## will normalize all categories to serialize on their own line.
3778 ## This wikitext usage is going to be fairly uncommon in production and
3779 ## selser will take care of preserving formatting in those scenarios.
3780 !! test
3781 7b. Indent-pre and category links
3782 !! options
3783 parsoid=wt2html
3784 !! wikitext
3785 [[Category:foo]] a
3786 [[Category:foo]] {{echo|b}}
3787 !! html/parsoid
3788 <pre><link rel="mw:PageProp/Category" href="./Category:Foo"> a
3789 <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>
3790 !! end
3791
3792 !! test
3793 Indent-Pre: Newlines in comments shouldn't affect sol state
3794 !! wikitext
3795 a <!--
3796 foo
3797 --> b
3798 !! html/php+tidy
3799 <p>a b
3800 </p>
3801 !! html/parsoid
3802 <p>a <!--
3803 foo
3804 --> b</p>
3805 !! end
3806
3807 ###
3808 ### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric)
3809 ###
3810
3811 !!test
3812 HTML-pre: 1. embedded newlines
3813 !! wikitext
3814 <pre>foo</pre>
3815
3816 <pre>
3817 foo
3818 </pre>
3819
3820 <pre>
3821
3822 foo
3823 </pre>
3824
3825 <pre>
3826
3827
3828 foo
3829 </pre>
3830 !! html/php+tidy
3831 <pre>foo</pre>
3832 <pre>foo
3833 </pre>
3834 <pre>
3835
3836 foo
3837 </pre>
3838 <pre>
3839
3840
3841 foo
3842 </pre>
3843 !! html/parsoid
3844 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre>
3845
3846 <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
3847 </pre>
3848
3849 <pre typeof="mw:Extension/pre" about="#mwt6" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\nfoo\n"}}'>
3850
3851 foo
3852 </pre>
3853
3854 <pre typeof="mw:Extension/pre" about="#mwt8" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\nfoo\n"}}'>
3855
3856
3857 foo
3858 </pre>
3859 !!end
3860
3861 !! test
3862 HTML-pre: big spaces
3863 !! wikitext
3864 <pre>
3865
3866
3867
3868
3869 haha
3870
3871
3872
3873
3874 haha
3875
3876
3877
3878
3879 </pre>
3880 !! html/php+tidy
3881 <pre>
3882
3883
3884
3885
3886 haha
3887
3888
3889
3890
3891 haha
3892
3893
3894
3895
3896 </pre>
3897 !! html/parsoid
3898 <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"}}'>
3899
3900
3901
3902
3903 haha
3904
3905
3906
3907
3908 haha
3909
3910
3911
3912
3913 </pre>
3914 !! end
3915
3916 !!test
3917 HTML-pre: 2: indented text
3918 !! wikitext
3919 <pre>
3920 foo
3921 </pre>
3922 !! html
3923 <pre>
3924 foo
3925 </pre>
3926
3927 !!end
3928
3929 !!test
3930 HTML-pre: 3: other wikitext
3931 !! wikitext
3932 <pre>
3933 * foo
3934 # bar
3935 = no-h =
3936 '' no-italic ''
3937 [[ NoLink ]]
3938 </pre>
3939 !! html/php
3940 <pre>
3941 * foo
3942 # bar
3943 = no-h =
3944 '' no-italic ''
3945 [[ NoLink ]]
3946 </pre>
3947
3948 !! html/parsoid
3949 <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
3950 # bar
3951 = no-h =
3952 '' no-italic ''
3953 [[ NoLink ]]
3954 </pre>
3955 !!end
3956
3957 ###
3958 ### Definition lists
3959 ###
3960 !! test
3961 Simple definition
3962 !! wikitext
3963 ;name :Definition
3964 !! html
3965 <dl><dt>name&#160;</dt>
3966 <dd>Definition</dd></dl>
3967
3968 !! end
3969
3970 !! test
3971 Definition list for indentation only
3972 !! wikitext
3973 :Indented text
3974 !! html
3975 <dl><dd>Indented text</dd></dl>
3976
3977 !! end
3978
3979 !! test
3980 Definition list with no space
3981 !! wikitext
3982 ;name:Definition
3983 !! html
3984 <dl><dt>name</dt>
3985 <dd>Definition</dd></dl>
3986
3987 !!end
3988
3989 !! test
3990 Definition list with URL link
3991 !! wikitext
3992 ;http://example.com/ :definition
3993 !! html
3994 <dl><dt><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&#160;</dt>
3995 <dd>definition</dd></dl>
3996
3997 !! end
3998
3999 !! test
4000 Definition list with bracketed URL link
4001 !! wikitext
4002 ;[http://www.example.com/ Example]:Something about it
4003 !! html
4004 <dl><dt><a rel="nofollow" class="external text" href="http://www.example.com/">Example</a></dt>
4005 <dd>Something about it</dd></dl>
4006
4007 !! end
4008
4009 !! test
4010 Definition list with wikilink containing colon
4011 !! wikitext
4012 ;[[Help:FAQ]]:The least-read page on Wikipedia
4013 !! html
4014 <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>
4015 <dd>The least-read page on Wikipedia</dd></dl>
4016
4017 !! end
4018
4019 # At Brion's and JeLuF's insistence... :)
4020 !! test
4021 Definition list with news link containing colon
4022 !! wikitext
4023 ;news:alt.wikipedia.rox :This isn't even a real newsgroup!
4024 !! html/php
4025 <dl><dt><a rel="nofollow" class="external free" href="news:alt.wikipedia.rox">news:alt.wikipedia.rox</a>&#160;</dt>
4026 <dd>This isn't even a real newsgroup!</dd></dl>
4027
4028 !! html/parsoid
4029 <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>
4030 !! end
4031
4032 !! test
4033 Malformed definition list with colon
4034 !! wikitext
4035 ;news:alt.wikipedia.rox -- don't crash or enter an infinite loop
4036 !! html
4037 <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>
4038
4039 !! end
4040
4041 !! test
4042 Definition lists: colon in external link text
4043 !! wikitext
4044 ;[http://www.wikipedia2.org/ Wikipedia :The Next Generation] :OK, I made that up
4045 !! html
4046 <dl><dt><a rel="nofollow" class="external text" href="http://www.wikipedia2.org/">Wikipedia&#160;:The Next Generation</a>&#160;</dt>
4047 <dd>OK, I made that up</dd></dl>
4048
4049 !! end
4050
4051 !! test
4052 Definition lists: colon in HTML attribute
4053 !! wikitext
4054 ;<b style="display: inline">bold</b>
4055 !! html
4056 <dl><dt><b style="display: inline">bold</b></dt></dl>
4057
4058 !! end
4059
4060 !! test
4061 Definition lists: self-closed tag
4062 !! wikitext
4063 ;one<br/>two :two-line fun
4064 !! html
4065 <dl><dt>one<br />two&#160;</dt>
4066 <dd>two-line fun</dd></dl>
4067
4068 !! end
4069
4070 !! test
4071 Definition lists: ignore colons inside tags
4072 !! wikitext
4073 ;one <b>two : tag <i>fun:</i>:</b>:def
4074 !! html
4075 <dl><dt>one <b>two&#160;: tag <i>fun:</i>:</b></dt>
4076 <dd>def</dd></dl>
4077
4078 !! end
4079
4080 !! test
4081 Definition lists: excess closed tags
4082 !! wikitext
4083 ;one</b>two :bad tag fun
4084 !! html/php+tidy
4085 <dl><dt>onetwo&#160;</dt>
4086 <dd>bad tag fun</dd></dl>
4087 !! html/parsoid
4088 <dl>
4089 <dt>onetwo</dt>
4090 <dd>bad tag fun</dd>
4091 </dl>
4092 !! end
4093
4094 !! test
4095 T13748: Literal closing tags
4096 !! wikitext
4097 <dl>
4098 <dt>test 1</dt>
4099 <dd>test test test test test</dd>
4100 <dt>test 2</dt>
4101 <dd>test test test test test</dd>
4102 </dl>
4103 !! html
4104 <dl>
4105 <dt>test 1</dt>
4106 <dd>test test test test test</dd>
4107 <dt>test 2</dt>
4108 <dd>test test test test test</dd>
4109 </dl>
4110
4111 !! end
4112
4113 !! test
4114 Definition and unordered list using wiki syntax nested in unordered list using html tags.
4115 !! wikitext
4116 <ul><li>
4117 ;term :description
4118 *unordered
4119 </li></ul>
4120 !! html
4121 <ul><li>
4122 <dl><dt>term&#160;</dt>
4123 <dd>description</dd></dl>
4124 <ul><li>unordered</li></ul>
4125 </li></ul>
4126
4127 !! end
4128
4129 !! test
4130 Definition list with empty definition and following paragraph
4131 !! wikitext
4132 ;term:
4133
4134 Paragraph text
4135 !! html
4136 <dl><dt>term</dt>
4137 <dd></dd></dl>
4138 <p>Paragraph text
4139 </p>
4140 !! end
4141
4142 !! test
4143 Nested definition lists using html syntax
4144 !! wikitext
4145 <dl><dt>x</dt>
4146 <dd>a</dd>
4147 <dd>b</dd></dl>
4148 !! html
4149 <dl><dt>x</dt>
4150 <dd>a</dd>
4151 <dd>b</dd></dl>
4152
4153 !! end
4154
4155 !! test
4156 Definition Lists: No nesting: Multiple dd's
4157 !! wikitext
4158 ;x
4159 :a
4160 :b
4161 !! html
4162 <dl><dt>x</dt>
4163 <dd>a</dd>
4164 <dd>b</dd></dl>
4165
4166 !! end
4167
4168 !! test
4169 Definition Lists: Indentation: Regular
4170 !! wikitext
4171 :i1
4172 ::i2
4173 :::i3
4174 !! html
4175 <dl><dd>i1
4176 <dl><dd>i2
4177 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
4178
4179 !! end
4180
4181 !! test
4182 Definition Lists: Indentation: Missing 1st level
4183 !! wikitext
4184 ::i2
4185 :::i3
4186 !! html
4187 <dl><dd><dl><dd>i2
4188 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
4189
4190 !! end
4191
4192 !! test
4193 Definition Lists: Indentation: Multi-level indent
4194 !! wikitext
4195 :::i3
4196 !! html
4197 <dl><dd><dl><dd><dl><dd>i3</dd></dl></dd></dl></dd></dl>
4198
4199 !! end
4200
4201 !! test
4202 Definition Lists: Hacky use to indent tables
4203 !! wikitext
4204 ::{|
4205 |foo
4206 |bar
4207 |}
4208 this text
4209 should be left alone
4210 !! html
4211 <dl><dd><dl><dd><table>
4212 <tr>
4213 <td>foo
4214 </td>
4215 <td>bar
4216 </td></tr></table></dd></dl></dd></dl>
4217 <p>this text
4218 should be left alone
4219 </p>
4220 !! end
4221
4222 !! test
4223 Definition Lists: Hacky use to indent tables (with content following table)
4224 !! wikitext
4225 :{|
4226 |foo
4227 |bar
4228 |} <!--c1--> this text should be part of the dl
4229 !! html/php+tidy
4230 <dl><dd><table>
4231 <tbody><tr>
4232 <td>foo
4233 </td>
4234 <td>bar
4235 </td></tr></tbody></table> this text should be part of the dl</dd></dl>
4236 !! html/parsoid
4237 <dl><dd><table>
4238 <tbody><tr>
4239 <td>foo
4240 </td>
4241 <td>bar
4242 </td></tr></tbody></table> <!--c1--> this text should be part of the dl</dd></dl>
4243 !! end
4244
4245 !! test
4246 Definition Lists: Hacky use to indent tables, with comments (T65979)
4247 !! wikitext
4248 <!-- foo -->
4249 ::{|
4250 |foo
4251 |bar
4252 |}<!-- bar -->
4253 this text
4254 should be left alone
4255 !! html/parsoid
4256 <!-- foo -->
4257 <dl><dd><dl><dd><table><tr>
4258 <td>foo</td>
4259 <td>bar</td>
4260 </tr></table><!-- bar --></dd></dl></dd></dl>
4261 <p>this text
4262 should be left alone</p>
4263 !! end
4264
4265 !! test
4266 Definition Lists: Hacky use to indent tables, with comment before table
4267 !!options
4268 parsoid=wt2html
4269 !! wikitext
4270 ::<!-- foo -->{|
4271 |foo
4272 |}
4273 !! html/parsoid
4274 <dl><dd><dl><dd><!-- foo --><table><tr>
4275 <td>foo</td>
4276 </tr></table></dd></dl></dd></dl>
4277 !! end
4278
4279 # The trailing whitespace in this test is to catch a regression in
4280 # Parsoid after T54473.
4281 !! test
4282 Definition Lists: Hacky use to indent tables (WS-insensitive)
4283 !! wikitext
4284 :{|
4285 |a
4286 |}
4287 !! html/php
4288 <dl><dd><table>
4289 <tr>
4290 <td>a
4291 </td></tr></table></dd></dl>
4292
4293 !! html/parsoid
4294 <dl><dd><table>
4295 <tbody><tr><td>a</td></tr>
4296 </tbody></table></dd></dl>
4297 !! end
4298
4299 ## The PHP parser treats : items (dd) without a corresponding ; item (dt)
4300 ## as an empty dt item. It also ignores all but the last ";" when followed
4301 ## by ":" later on. So, ";" are not ignored in ";;;t3" but are ignored in
4302 ## ";;;t3 :d1". So, PHP parser behavior is a little inconsistent wrt multiple
4303 ## ";"s.
4304 ##
4305 ## Ex: ";;t2 ::d2" is transformed into:
4306 ##
4307 ## <dl>
4308 ## <dt>t2 </dt>
4309 ## <dd>
4310 ## <dl>
4311 ## <dt></dt>
4312 ## <dd>d2</dd>
4313 ## </dl>
4314 ## </dd>
4315 ## </dl>
4316 ##
4317 ## But, Parsoid treats "; :" as a tight atomic unit and excess ":" as plain text
4318 ## So, the same wikitext above (;;t2 ::d2) is transformed into:
4319 ##
4320 ## <dl>
4321 ## <dt>
4322 ## <dl>
4323 ## <dt>t2 </dt>
4324 ## <dd>:d2</dd>
4325 ## </dl>
4326 ## </dt>
4327 ## </dl>
4328 ##
4329 ## All Parsoid only definition list tests have this difference.
4330 ##
4331 ## See also: https://phabricator.wikimedia.org/T8569
4332 ## and https://lists.wikimedia.org/pipermail/wikitext-l/2011-November/000483.html
4333
4334 !! test
4335 Table / list interaction: indented table with lists in table contents
4336 !! wikitext
4337 :{|
4338 |-
4339 |a
4340
4341 *b
4342 |-
4343 |c
4344
4345 *d
4346 |}
4347 !! html
4348 <dl><dd><table>
4349
4350 <tr>
4351 <td>a
4352 <ul><li>b</li></ul>
4353 </td></tr>
4354 <tr>
4355 <td>c
4356 <ul><li>d</li></ul>
4357 </td></tr></table></dd></dl>
4358
4359 !! end
4360
4361 !!test
4362 Table / list interaction: lists nested in tables nested in indented lists
4363 !! wikitext
4364 :{|
4365 |
4366 :a
4367 :b
4368 |
4369 *c
4370 *d
4371 |}
4372
4373 *e
4374 *f
4375 !! html
4376 <dl><dd><table>
4377 <tr>
4378 <td>
4379 <dl><dd>a</dd>
4380 <dd>b</dd></dl>
4381 </td>
4382 <td>
4383 <ul><li>c</li>
4384 <li>d</li></ul>
4385 </td></tr></table></dd></dl>
4386 <ul><li>e</li>
4387 <li>f</li></ul>
4388
4389 !!end
4390
4391 !! test
4392 Definition Lists: Nesting: Multi-level (Parsoid only)
4393 !! wikitext
4394 ;t1 :d1
4395 ;;t2 ::d2
4396 ;;;t3 :::d3
4397 !! html/parsoid
4398 <dl>
4399 <dt>t1 </dt>
4400 <dd>d1</dd>
4401 <dt>
4402 <dl>
4403 <dt>t2 </dt>
4404 <dd>:d2</dd>
4405 <dt>
4406 <dl>
4407 <dt>t3 </dt>
4408 <dd>::d3</dd>
4409 </dl>
4410 </dt>
4411 </dl>
4412 </dt>
4413 </dl>
4414
4415
4416 !! end
4417
4418
4419 !! test
4420 Definition Lists: Nesting: Test 2
4421 !! wikitext
4422 ;t1
4423 ::d2
4424 !! html+tidy
4425 <dl><dt>t1</dt>
4426 <dd>
4427 <dl><dd>d2</dd></dl></dd></dl>
4428 !! end
4429
4430
4431 !! test
4432 Definition Lists: Nesting: Test 3
4433 !! wikitext
4434 :;t1
4435 ::::d2
4436 !! html+tidy
4437 <dl><dd><dl><dt>t1</dt>
4438 <dd>
4439 <dl><dd><dl><dd>d2</dd></dl></dd></dl></dd></dl></dd></dl>
4440 !! end
4441
4442
4443 !! test
4444 Definition Lists: Nesting: Test 4
4445 !! wikitext
4446 ::;t3
4447 :::d3
4448 !! html
4449 <dl><dd><dl><dd><dl><dt>t3</dt>
4450 <dd>d3</dd></dl></dd></dl></dd></dl>
4451
4452 !! end
4453
4454
4455 ## The Parsoid team believes the following three test exposes a
4456 ## bug in the PHP parser. (Parsoid team thinks the PHP parser is
4457 ## wrong to close the <dl> after the <dt> containing the <ul>.)
4458 ## It also exposes a "misfeature" in tidy, which doesn't like
4459 ## <dl> tags with a single <dt> child; it converts the <dt> into
4460 ## a <dd> in that case. (Parsoid leaves the <dt> alone!)
4461 !! test
4462 Definition Lists: Mixed Lists: Test 1
4463 !! wikitext
4464 :;*foo
4465 ::*bar
4466 :;baz
4467 !! html/php
4468 <dl><dd><dl><dt><ul><li>foo</li>
4469 <li>bar</li></ul></dt></dl>
4470 <dl><dt>baz</dt></dl></dd></dl>
4471
4472 !! html/php+tidy
4473 <dl><dd><dl><dt><ul><li>foo</li>
4474 <li>bar</li></ul></dt></dl>
4475 <dl><dt>baz</dt></dl></dd></dl>
4476 !! html/parsoid
4477 <dl>
4478 <dd><dl>
4479 <dt><ul>
4480 <li>foo
4481 </li>
4482 </ul></dt>
4483 <dd><ul>
4484 <li>bar
4485 </li>
4486 </ul></dd>
4487 <dt>baz</dt>
4488 </dl></dd>
4489 </dl>
4490 !! end
4491
4492 !! test
4493 Definition Lists: Mixed Lists: Test 2
4494 !! wikitext
4495 *:d1
4496 *:d2
4497 !! html
4498 <ul><li><dl><dd>d1</dd>
4499 <dd>d2</dd></dl></li></ul>
4500
4501 !! end
4502
4503
4504 !! test
4505 Definition Lists: Mixed Lists: Test 3
4506 !! wikitext
4507 *:::d1
4508 *:::d2
4509 !! html
4510 <ul><li><dl><dd><dl><dd><dl><dd>d1</dd>
4511 <dd>d2</dd></dl></dd></dl></dd></dl></li></ul>
4512
4513 !! end
4514
4515
4516 !! test
4517 Definition Lists: Mixed Lists: Test 4
4518 !! wikitext
4519 *;d1 :d2
4520 *;d3 :d4
4521 !! html
4522 <ul><li><dl><dt>d1&#160;</dt>
4523 <dd>d2</dd>
4524 <dt>d3&#160;</dt>
4525 <dd>d4</dd></dl></li></ul>
4526
4527 !! end
4528
4529
4530 !! test
4531 Definition Lists: Mixed Lists: Test 5
4532 !! wikitext
4533 *:d1
4534 *::d2
4535 !! html
4536 <ul><li><dl><dd>d1
4537 <dl><dd>d2</dd></dl></dd></dl></li></ul>
4538
4539 !! end
4540
4541
4542 !! test
4543 Definition Lists: Mixed Lists: Test 6
4544 !! wikitext
4545 #*:d1
4546 #*:::d3
4547 !! html
4548 <ol><li><ul><li><dl><dd>d1
4549 <dl><dd><dl><dd>d3</dd></dl></dd></dl></dd></dl></li></ul></li></ol>
4550
4551 !! end
4552
4553
4554 !! test
4555 Definition Lists: Mixed Lists: Test 7
4556 !! wikitext
4557 :*d1
4558 :*d2
4559 !! html
4560 <dl><dd><ul><li>d1</li>
4561 <li>d2</li></ul></dd></dl>
4562
4563 !! end
4564
4565
4566 !! test
4567 Definition Lists: Mixed Lists: Test 8
4568 !! wikitext
4569 :*d1
4570 ::*d2
4571 !! html
4572 <dl><dd><ul><li>d1</li></ul>
4573 <dl><dd><ul><li>d2</li></ul></dd></dl></dd></dl>
4574
4575 !! end
4576
4577
4578 !! test
4579 Definition Lists: Mixed Lists: Test 9
4580 !! wikitext
4581 *;foo :bar
4582 !! html
4583 <ul><li><dl><dt>foo&#160;</dt>
4584 <dd>bar</dd></dl></li></ul>
4585
4586 !! end
4587
4588
4589 !! test
4590 Definition Lists: Mixed Lists: Test 10
4591 !! wikitext
4592 *#;foo :bar
4593 !! html
4594 <ul><li><ol><li><dl><dt>foo&#160;</dt>
4595 <dd>bar</dd></dl></li></ol></li></ul>
4596
4597 !! end
4598
4599 # The Parsoid team disagrees with the PHP parser's seemingly-random
4600 # rules regarding dd/dt on the next few tests. Parsoid is more
4601 # consistent, and recognizes the shared nesting and keeps the
4602 # still-open tags around until the nesting is complete.
4603
4604 # This is a regression test for T175099
4605 !! test
4606 Definition Lists: Mixed Lists: Test 11
4607 !! wikitext
4608 ;a
4609 :*b
4610 !! html/php
4611 <dl><dt>a</dt>
4612 <dd>
4613 <ul><li>b</li></ul></dd></dl>
4614
4615 !! html/parsoid
4616 <dl><dt>a
4617 <dd><ul><li>b</li></ul></dd></dl>
4618 !! end
4619
4620 # FIXME: Maybe get rid of this test?
4621 !! test
4622 Definition Lists: Mixed Lists: Test 12
4623 !! wikitext
4624 *#*#;*;;foo :bar
4625 *#*#;boo :baz
4626 !! html/php
4627 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</dt>
4628 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dd></dl></li></ul></dd></dl>
4629 <dl><dt>boo&#160;</dt>
4630 <dd>baz</dd></dl></li></ol></li></ul></li></ol></li></ul>
4631
4632 !! html/php+tidy
4633 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</dt>
4634 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dt></dl></li></ul></dd></dl></li></ol></li></ul>
4635 <dl><dt>boo&#160;</dt>
4636 <dd>baz</dd></dl></li></ol></li></ul>
4637 !! html/parsoid
4638 <ul>
4639 <li>
4640 <ol>
4641 <li>
4642 <ul>
4643 <li>
4644 <ol>
4645 <li>
4646 <dl>
4647 <dt>
4648 <ul>
4649 <li>
4650 <dl>
4651 <dt>
4652 <dl>
4653 <dt>foo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
4654 <dd data-parsoid='{"stx":"row"}'>bar</dd>
4655 </dl></dt>
4656 </dl></li>
4657 </ul></dt>
4658 <dt>boo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
4659 <dd data-parsoid='{"stx":"row"}'>baz</dd>
4660 </dl></li>
4661 </ol></li>
4662 </ul></li>
4663 </ol></li>
4664 </ul>
4665 !! end
4666
4667 # FIXME: Maybe get rid of this test?
4668 # From whitelist:
4669 # * The test is wrong, there are two colons where there should be :;
4670 # * The PHP parser is wrong to close the <dl> after the <dt> containing the <ul>.
4671 !! test
4672 Definition Lists: Weird Ones: Test 1
4673 !! wikitext
4674 *#;*::;;foo :bar (who uses this?)
4675 !! html/php+tidy
4676 <ul><li><ol><li><dl><dt>foo&#160;</dt>
4677 <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>
4678 !! html/parsoid
4679 <ul>
4680 <li>
4681 <ol>
4682 <li>
4683 <dl>
4684 <dt>
4685 <ul>
4686 <li>
4687 <dl>
4688 <dd>
4689 <dl>
4690 <dd>
4691 <dl>
4692 <dt>
4693 <dl>
4694 <dt>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span></dt>
4695 <dd data-parsoid='{"stx":"row"}'>bar (who uses this?)</dd>
4696 </dl></dt>
4697 </dl></dd>
4698 </dl></dd>
4699 </dl></li>
4700 </ul></dt>
4701 </dl></li>
4702 </ol></li>
4703 </ul>
4704 !! end
4705
4706 !! test
4707 Definition Lists: colons occurring in tags
4708 !! wikitext
4709 ;a:b
4710 ;'''a:b'''
4711 ;<i>a:b</i>
4712 ;<span>a:b</span>
4713 ;<div>a:b</div>
4714 ;<div>a
4715 :b</div>
4716 ;{{echo|a:b}}
4717 ;{{echo|''a:b''}}
4718 ;;;''a:b''
4719 !! html+tidy
4720 <dl><dt>a</dt>
4721 <dd>b</dd>
4722 <dt><b>a:b</b></dt>
4723 <dt><i>a:b</i></dt>
4724 <dt><span>a:b</span></dt>
4725 <dt><div>a:b</div></dt>
4726 <dt><div>a</div></dt>
4727 <dd>b</dd>
4728 <dt>a</dt>
4729 <dd>b</dd>
4730 <dt><i>a:b</i></dt></dl>
4731 <dl><dt><dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4732 !! html/parsoid
4733 <dl><dt>a</dt><dd data-parsoid='{"stx":"row"}'>b</dd>
4734 <dt><b>a:b</b></dt>
4735 <dt><i data-parsoid='{"stx":"html"}'>a:b</i></dt>
4736 <dt><span data-parsoid='{"stx":"html"}'>a:b</span></dt>
4737 <dt><div data-parsoid='{"stx":"html"}'>a:b</div></dt>
4738 <dt><div data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</div></dt>
4739 <dd>b</dd>
4740 <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>
4741 <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>
4742 <dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4743 !! end
4744
4745 # Parsoid's output differs here again because it shares
4746 # nesting between the two lists unlike the PHP parser.
4747 # Unsure which is more desirable.
4748 !! test
4749 Definition Lists: colons and tables 1
4750 !! wikitext
4751 :{|
4752 |x
4753 |}
4754 :{|
4755 |y
4756 |}
4757 !! html/php
4758 <dl><dd><table>
4759 <tr>
4760 <td>x
4761 </td></tr></table></dd></dl>
4762 <dl><dd><table>
4763 <tr>
4764 <td>y
4765 </td></tr></table></dd></dl>
4766
4767 !! html/parsoid
4768 <dl><dd><table>
4769 <tr>
4770 <td>x
4771 </td></tr></table></dd>
4772 <dd><table>
4773 <tr>
4774 <td>y
4775 </td></tr></table></dd></dl>
4776 !! end
4777
4778 # FIXME: Does this need a html/php section?
4779 !! test
4780 Definition Lists: template interaction
4781 !! wikitext
4782 ::{{definition_list}}
4783
4784 :one
4785 ::{{definition_list}}
4786 :::two
4787 :::three
4788 ::four
4789 !! html/parsoid
4790 <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">
4791 </span><dd about="#mwt1">two</dd></dl></dd></dl>
4792
4793 <dl><dd data-parsoid='{}'>one
4794 <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">
4795 </span><dd about="#mwt2">two
4796 <dl><dd>two</dd>
4797 <dd>three</dd></dl></dd>
4798 <dd data-parsoid='{}'>four</dd></dl></dd></dl>
4799 !! end
4800
4801
4802 ###
4803 ### External links
4804 ###
4805 !! test
4806 External links: non-bracketed
4807 !! wikitext
4808 Non-bracketed: http://example.com
4809 !! html
4810 <p>Non-bracketed: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4811 </p>
4812 !! end
4813
4814 # parsoid doesn't explicitly mark autonumbered links, see T55505
4815 !! test
4816 External links: numbered
4817 !! wikitext
4818 Numbered: [http://example.com]
4819 Numbered: [http://example.net]
4820 Numbered: [http://example.com]
4821 !! html/php
4822 <p>Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>
4823 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.net">[2]</a>
4824 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[3]</a>
4825 </p>
4826 !! html/parsoid
4827 <p>Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>
4828 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.net"></a>
4829 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a></p>
4830 !!end
4831
4832 !! test
4833 External links: specified text
4834 !! wikitext
4835 Specified text: [http://example.com link]
4836 !! html
4837 <p>Specified text: <a rel="nofollow" class="external text" href="http://example.com">link</a>
4838 </p>
4839 !!end
4840
4841 !! test
4842 External links: trail
4843 !! wikitext
4844 Linktrails should not work for external links: [http://example.com link]s
4845 !! html
4846 <p>Linktrails should not work for external links: <a rel="nofollow" class="external text" href="http://example.com">link</a>s
4847 </p>
4848 !! end
4849
4850 !! test
4851 External links: dollar sign in URL
4852 !! wikitext
4853 http://example.com/1$2345
4854 !! html
4855 <p><a rel="nofollow" class="external free" href="http://example.com/1$2345">http://example.com/1$2345</a>
4856 </p>
4857 !! end
4858
4859 # parsoid doesn't explicitly mark autonumbered links, see T55505
4860 !! test
4861 External links: dollar sign in URL (autonumber)
4862 !! wikitext
4863 [http://example.com/1$2345]
4864 !! html/php
4865 <p><a rel="nofollow" class="external autonumber" href="http://example.com/1$2345">[1]</a>
4866 </p>
4867 !! html/parsoid
4868 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/1$2345"></a></p>
4869 !!end
4870
4871 !! test
4872 External links: open square bracket forbidden in URL (T6377)
4873 !! options
4874 parsoid=wt2html,wt2wt,html2html
4875 !! wikitext
4876 http://example.com/1[2345
4877 !! html/php
4878 <p><a rel="nofollow" class="external free" href="http://example.com/1">http://example.com/1</a>[2345
4879 </p>
4880 !! html/parsoid
4881 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/1">http://example.com/1</a>[2345</p>
4882 !! end
4883
4884 !! test
4885 External links: open square bracket forbidden in URL (named) (T6377)
4886 !! options
4887 parsoid=wt2html,html2html
4888 !! wikitext
4889 [http://example.com/1[2345]
4890 !! html/php
4891 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4892 </p>
4893 !! html/parsoid
4894 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/1">[2345</a></p>
4895 !!end
4896
4897 # parsoid adds a space before the link name
4898 !! test
4899 External links: open square bracket forbidden in URL (named) (T6377)
4900 Parsoid variant.
4901 !! wikitext
4902 [http://example.com/1 [2345]
4903 !! html
4904 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4905 </p>
4906 !!end
4907
4908 !! test
4909 External links: nowiki in URL link text (T8230)
4910 !! wikitext
4911 [http://example.com/ <nowiki>''example site''</nowiki>]
4912 !! html
4913 <p><a rel="nofollow" class="external text" href="http://example.com/">''example site''</a>
4914 </p>
4915 !! end
4916
4917 !! test
4918 External links: newline forbidden in text (T8230 regression check)
4919 !! wikitext
4920 [http://example.com/ first
4921 second]
4922 !! html
4923 <p>[<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a> first
4924 second]
4925 </p>
4926 !!end
4927
4928 !! test
4929 External links: Pipe char between url and text
4930 !! wikitext
4931 [http://example.com | link]
4932 !! html
4933 <p><a rel="nofollow" class="external text" href="http://example.com">| link</a>
4934 </p>
4935 !!end
4936
4937 !! test
4938 External links: protocol-relative URL in brackets
4939 !! wikitext
4940 [//example.com/ Test]
4941 !! html
4942 <p><a rel="nofollow" class="external text" href="//example.com/">Test</a>
4943 </p>
4944 !! end
4945
4946 # parsoid doesn't explicitly mark autonumbered links, see T55505
4947 !! test
4948 External links: protocol-relative URL in brackets without text
4949 !! wikitext
4950 [//example.com]
4951 !! html/php
4952 <p><a rel="nofollow" class="external autonumber" href="//example.com">[1]</a>
4953 </p>
4954 !! html/parsoid
4955 <p><a rel="mw:ExtLink" class="external autonumber" href="//example.com"></a></p>
4956 !! end
4957
4958 !! test
4959 External links: protocol-relative URL in free text is left alone
4960 !! wikitext
4961 //example.com/Foo
4962 !! html
4963 <p>//example.com/Foo
4964 </p>
4965 !!end
4966
4967 !! test
4968 External links: protocol-relative URL in the middle of a word is left alone (T32269)
4969 !! wikitext
4970 foo//example.com/Foo
4971 !! html
4972 <p>foo//example.com/Foo
4973 </p>
4974 !! end
4975
4976 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
4977 !! test
4978 External links: with no contents
4979 !! options
4980 parsoid=wt2html,wt2wt
4981 !! wikitext
4982 [http://en.wikipedia.org/wiki/Foo]
4983
4984 [[wikipedia:Foo|Bar]]
4985
4986 [[wikipedia:Foo|<span>Bar</span>]]
4987 !! html/php
4988 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo">[1]</a>
4989 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
4990 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo"><span>Bar</span></a>
4991 </p>
4992 !! html/parsoid
4993 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo"></a></p>
4994 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo">Bar</a></p>
4995 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo"><span>Bar</span></a></p>
4996 !! end
4997
4998 !! test
4999 External links: Free with trailing punctuation
5000 !! wikitext
5001 http://example.com,
5002 http://example.com;
5003 http://example.com\
5004 http://example.com.
5005 http://example.com:
5006 http://example.com!
5007 http://example.com?
5008 http://example.com)
5009 http://example.com/url_with_(brackets)
5010 (http://example.com/url_without_brackets)
5011 http://example.com/url_with_entity&amp;
5012 http://example.com/url_with_entity&#x26;
5013 http://example.com/url_with_entity&#038;
5014 http://example.com/url_with_entity&nbsp;
5015 http://example.com/url_with_entity&#xA0;
5016 http://example.com/url_with_entity&#160;
5017 http://example.com/url_with_entity&lt;
5018 http://example.com/url_with_entity&#x3C;
5019 http://example.com/url_with_entity&#60;
5020 !! html/php
5021 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
5022 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>;
5023 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>\
5024 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.
5025 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
5026 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>!
5027 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>?
5028 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
5029 <a rel="nofollow" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
5030 (<a rel="nofollow" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
5031 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5032 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5033 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5034 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
5035 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#xa0;
5036 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
5037 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&lt;
5038 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#x3c;
5039 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#60;
5040 </p>
5041 !! html/parsoid
5042 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>,
5043 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>;
5044 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>\
5045 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>.
5046 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>:
5047 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>!
5048 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>?
5049 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>)
5050 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
5051 (<a rel="mw:ExtLink" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
5052 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5053 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5054 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5055 <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>
5056 <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>
5057 <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>
5058 <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>
5059 <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>
5060 <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>
5061 !! end
5062
5063 !! test
5064 External links: tricky Parsoid html2html case
5065 !! options
5066 parsoid=wt2html,wt2wt,html2html
5067 !! wikitext
5068 http://example.com/url_with_entity&amp;amp;
5069 !! html/php
5070 <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>;
5071 </p>
5072 !! html/parsoid
5073 <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>
5074 !! end
5075
5076 !! test
5077 External links: Free with trailing quotes (T113666)
5078 !! wikitext
5079 '''News:''' Stuff here
5080
5081 news:'a'b''c''d e
5082 !! html/php
5083 <p><b>News:</b> Stuff here
5084 </p><p><a rel="nofollow" class="external free" href="news:&#39;a&#39;b">news:'a'b</a><i>c</i>d e
5085 </p>
5086 !! html/parsoid
5087 <p><b>News:</b> Stuff here</p>
5088 <p><a rel="mw:ExtLink" class="external free" href="news:'a'b">news:'a'b</a><i>c</i>d e</p>
5089 !! end
5090
5091 !! test
5092 External links: with entity
5093 !! wikitext
5094 [http://&#x20;www.librarieswithoutborders.org Libraries without borders]
5095 !! html/php
5096 <p><a rel="nofollow" class="external text" href="http://+www.librarieswithoutborders.org">Libraries without borders</a>
5097 </p>
5098 !! html/parsoid
5099 <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>
5100 !! end
5101
5102 !! test
5103 External links: Lone protocols are never linked (T105697)
5104 !! wikitext
5105 http://
5106 http://;
5107 (http://)
5108 bitcoin:
5109 bitcoin:;
5110 (bitcoin:)
5111 !! html
5112 <p>http://
5113 http://;
5114 (http://)
5115 bitcoin:
5116 bitcoin:;
5117 (bitcoin:)
5118 </p>
5119 !! end
5120
5121 !! test
5122 External links: No preceding word characters allowed (T67278)
5123 !! wikitext
5124 NOPEhttp://example.com
5125 N0http://example.com
5126 ok:http://example.com
5127 ok-http://example.com
5128 !! html
5129 <p>NOPEhttp://example.com
5130 N0http://example.com
5131 ok:<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5132 ok-<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5133 </p>
5134 !! end
5135
5136 !! test
5137 External links: nofollow domain exception
5138 !! wikitext
5139 A [https://no-nofollow.org/foobar link], and another [https://example.org link].
5140 !! html
5141 <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>.
5142 </p>
5143 !!end
5144
5145 !! test
5146 External image
5147 !! wikitext
5148 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5149 !! html
5150 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
5151 </p>
5152 !! end
5153
5154 !! test
5155 External image from https
5156 !! wikitext
5157 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5158 !! html
5159 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
5160 </p>
5161 !! end
5162
5163 !! test
5164 External image (when not allowed)
5165 !! options
5166 wgAllowExternalImages=0
5167 !! wikitext
5168 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5169 !! html
5170 <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>
5171 </p>
5172 !! end
5173
5174 !! test
5175 Link to non-http image, no img tag
5176 !! wikitext
5177 Link to non-http image, no img tag: ftp://example.com/test.jpg
5178 !! html
5179 <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>
5180 </p>
5181 !! end
5182
5183 !! test
5184 External links: terminating separator
5185 !! wikitext
5186 Terminating separator: http://example.com/thing,
5187 !! html
5188 <p>Terminating separator: <a rel="nofollow" class="external free" href="http://example.com/thing">http://example.com/thing</a>,
5189 </p>
5190 !! end
5191
5192 !! test
5193 External links: intervening separator
5194 !! wikitext
5195 Intervening separator: http://example.com/1,2,3
5196 !! html
5197 <p>Intervening separator: <a rel="nofollow" class="external free" href="http://example.com/1,2,3">http://example.com/1,2,3</a>
5198 </p>
5199 !! end
5200
5201 !! test
5202 External links: old bug with URL in query
5203 !! wikitext
5204 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
5205 !! html
5206 <p>Old bug with URL in query: <a rel="nofollow" class="external text" href="http://example.com/thing?url=http://example.com">link</a>
5207 </p>
5208 !! end
5209
5210 !! test
5211 External links: old URL-in-URL bug, mixed protocols
5212 !! wikitext
5213 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
5214 !! html
5215 <p>And again with mixed protocols: <a rel="nofollow" class="external text" href="ftp://example.com?url=http://example.com">link</a>
5216 </p>
5217 !!end
5218
5219 # Since Parsoid is starting to emit canonical wikitext for links,
5220 # [http://example.com http://example.com] will not RT back to that
5221 # form anymore.
5222 !! test
5223 External links: URL in text
5224 !! options
5225 parsoid=wt2html
5226 !! wikitext
5227 URL in text: [http://example.com http://example.com]
5228 !! html/php
5229 <p>URL in text: <a rel="nofollow" class="external text" href="http://example.com">http://example.com</a>
5230 </p>
5231 !! html/parsoid
5232 <p>URL in text: <a rel="mw:ExtLink" class="external text" href="http://example.com">http://example.com</a></p>
5233 !! end
5234
5235 !! test
5236 External links: Clickable images
5237 !! wikitext
5238 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
5239 !! html/php
5240 <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>
5241 </p>
5242 !! html/parsoid
5243 <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>
5244 !! end
5245
5246 !! test
5247 External links: raw ampersand
5248 !! wikitext
5249 Old &amp; use: http://x&y
5250 !! html
5251 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5252 </p>
5253 !! end
5254
5255 !! test
5256 External links: encoded ampersand
5257 !! wikitext
5258 Old &amp; use: http://x&amp;y
5259 !! html/php
5260 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5261 </p>
5262 !! html/parsoid
5263 <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>
5264 !! end
5265
5266 !! test
5267 External links: encoded equals (T8102)
5268 !! wikitext
5269 http://example.com/?foo&#61;bar
5270 !! html/php
5271 <p><a rel="nofollow" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a>
5272 </p>
5273 !! html/parsoid
5274 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a></p>
5275 !! end
5276
5277 ##
5278 ## Note that parsoid doesn't explicit mark autonumbered links, nor
5279 ## does it number them. As discussed in T55505, we can identify
5280 ## autonumbered links via CSS.
5281 ##
5282
5283 !! test
5284 External links: [raw ampersand]
5285 !! wikitext
5286 Old &amp; use: [http://x&y]
5287 !! html/php
5288 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5289 </p>
5290 !! html/parsoid
5291 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&amp;y"></a></p>
5292 !! end
5293
5294 # note that parsoid html is identical to [raw ampersand] case; so html2wt
5295 # mode will return the [raw ampersand] wikitext
5296 !! test
5297 External links: [encoded ampersand]
5298 !! options
5299 parsoid=wt2html,wt2wt,html2html
5300 !! wikitext
5301 Old &amp; use: [http://x&amp;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 !! test
5310 External links: [raw equals]
5311 !! wikitext
5312 [http://example.com/?foo=bar]
5313 !! html/php
5314 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5315 </p>
5316 !! html/parsoid
5317 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/?foo=bar"></a></p>
5318 !! end
5319
5320 # note that parsoid html is identical to [raw equals] case; so html2wt
5321 # mode will return the [raw equals] wikitext
5322 !! test
5323 External links: [encoded equals] (T8102)
5324 !! options
5325 parsoid=wt2html,wt2wt,html2html
5326 !! wikitext
5327 [http://example.com/?foo&#61;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 # xxx parsoid strips the IDN character, so the round-trip tests will
5336 # obviously fail and are disabled. --cscott
5337 !! test
5338 External links: [IDN ignored character reference in hostname; strip it right off]
5339 !! options
5340 parsoid=wt2html,wt2wt,html2html
5341 !! wikitext
5342 [http://e&zwnj;xample.com/]
5343 !! html/php
5344 <p><a rel="nofollow" class="external autonumber" href="http://example.com/">[1]</a>
5345 </p>
5346 !! html/parsoid
5347 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/"></a></p>
5348 !! end
5349
5350 # FIXME: This test (the IDN characters in the text of a link) is an inconsistency.
5351 # Where an external link could easily circumvent the sanitization of the text of
5352 # a link like this (where an IDN-ignore character is in the URL somewhere), this
5353 # test demands a higher standard. That's a bit strange.
5354 #
5355 # Example:
5356 #
5357 # http://e‌xample.com -> [http://example.com|http://example.com]
5358 # [http://example.com|http://e‌xample.com] -> [http://example.com|http://e‌xample.com]
5359 #
5360 # The first example is sanitized, but the second is not. Any security benefits
5361 # from this production are trivial to circumvent. Either remove this test and
5362 # let the parser(s) do their thing unaccosted, or fix the inconsistency and change
5363 # the test accordingly.
5364 #
5365 # All our love,
5366 # The Parsoid team.
5367 # xxx parsoid strips the IDN character, so the round-trip tests will
5368 # obviously fail and are disabled. --cscott
5369 !! test
5370 External links: IDN ignored character reference in hostname; strip it right off
5371 !! options
5372 parsoid=wt2html,html2html
5373 !! wikitext
5374 http://e&zwnj;xample.com/
5375 !! html/php
5376 <p><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>
5377 </p>
5378 !! html/parsoid
5379 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/">http://example.com/</a></p>
5380 !! end
5381
5382 !! test
5383 External links: www.jpeg.org (T2554)
5384 !! wikitext
5385 http://www.jpeg.org
5386 !! html
5387 <p><a rel="nofollow" class="external free" href="http://www.jpeg.org">http://www.jpeg.org</a>
5388 </p>
5389 !! end
5390
5391 # parsoid doesn't explicitly mark autonumbered links, see T55505
5392 !! test
5393 External links: URL within URL (T2002)
5394 !! wikitext
5395 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
5396 !! html/php
5397 <p><a rel="nofollow" class="external autonumber" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp">[1]</a>
5398 </p>
5399 !! html/parsoid
5400 <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>
5401 !! end
5402
5403 !! test
5404 T2361: URL inside bracketed URL
5405 !! wikitext
5406 [http://www.example.com/foo http://www.example.com/bar]
5407 !! html
5408 <p><a rel="nofollow" class="external text" href="http://www.example.com/foo">http://www.example.com/bar</a>
5409 </p>
5410 !! end
5411
5412 !! test
5413 T2361: URL within URL, not bracketed
5414 !! wikitext
5415 http://www.example.com/foo?=http://www.example.com/bar
5416 !! html
5417 <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>
5418 </p>
5419 !! end
5420
5421 !! test
5422 T2289: ">"-token in URL-tail
5423 !! wikitext
5424 http://www.example.com/<hello>
5425 !! html
5426 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>&lt;hello&gt;
5427 </p>
5428 !!end
5429
5430 !! test
5431 T2289: literal ">"-token in URL-tail
5432 !! wikitext
5433 http://www.example.com/<b>html</b>
5434 !! html/php
5435 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a><b>html</b>
5436 </p>
5437 !! html/parsoid
5438 <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>
5439 !! end
5440
5441 !! test
5442 T2289: ">"-token in bracketed URL
5443 !! wikitext
5444 [http://www.example.com/<hello> stuff]
5445 !! html
5446 <p><a rel="nofollow" class="external text" href="http://www.example.com/">&lt;hello&gt; stuff</a>
5447 </p>
5448 !!end
5449
5450 !! test
5451 T2289: literal ">"-token in bracketed URL
5452 !! wikitext
5453 [http://www.example.com/<b>html</b> stuff]
5454 !! html
5455 <p><a rel="nofollow" class="external text" href="http://www.example.com/"><b>html</b> stuff</a>
5456 </p>
5457 !!end
5458
5459 !! test
5460 T2289: literal double quote at end of URL
5461 !! wikitext
5462 http://www.example.com/"hello"
5463 !! html
5464 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>"hello"
5465 </p>
5466 !!end
5467
5468 !! test
5469 T2289: literal double quote in bracketed URL
5470 !! wikitext
5471 [http://www.example.com/"hello" stuff]
5472 !! html
5473 <p><a rel="nofollow" class="external text" href="http://www.example.com/">"hello" stuff</a>
5474 </p>
5475 !!end
5476
5477 !! test
5478 External links: multiple legal whitespace is fine, Magnus. Don't break it please. (T7081)
5479 !! wikitext
5480 [http://www.example.com test]
5481 !! html
5482 <p><a rel="nofollow" class="external text" href="http://www.example.com">test</a>
5483 </p>
5484 !! end
5485
5486 !! test
5487 External links: link text with spaces
5488 !! wikitext
5489 [http://www.example.com a b c]
5490 [http://www.example.com ''a'' ''b'']
5491 !! html
5492 <p><a rel="nofollow" class="external text" href="http://www.example.com">a b c</a>
5493 <a rel="nofollow" class="external text" href="http://www.example.com"><i>a</i> <i>b</i></a>
5494 </p>
5495 !! end
5496
5497 # Note edge case difference between PHP and Parsoid here.
5498 !! test
5499 External links: wiki links within external link (T5695)
5500 !! options
5501 parsoid=wt2html,html2html
5502 !! wikitext
5503 [http://example.com [[wikilink]] embedded in ext link]
5504
5505 [http://example.com test [[wikilink]] embedded in ext link]
5506 !! html/php
5507 <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>
5508 </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>
5509 </p>
5510 !! html/parsoid
5511 <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>
5512 <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>
5513 !! end
5514
5515 !! test
5516 T2787: Links with one slash after the url protocol are invalid
5517 !! wikitext
5518 http:/example.com
5519
5520 [http:/example.com title]
5521 !! html
5522 <p>http:/example.com
5523 </p><p>[http:/example.com title]
5524 </p>
5525 !! end
5526
5527 !! test
5528 Bracketed external links with template-generated invalid target
5529 !! wikitext
5530 [{{echo|http:/example.com}} title]
5531 !! html
5532 <p>[http:/example.com title]
5533 </p>
5534 !! end
5535
5536 # wt2html only because Parsoid would want to add <nowiki>s coming from html
5537 !! test
5538 Broken wikilinks (but not external links) prevent templates from closing
5539 !! options
5540 parsoid=wt2html
5541 !! wikitext
5542 [http://example.com x
5543
5544 {{echo|[http://example.com x}}
5545
5546 [[Foo
5547
5548 {{echo|[[Foo}}
5549 !! html/php
5550 <p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5551 </p><p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5552 </p><p>[[Foo
5553 </p><p>{{echo|[[Foo}}
5554 </p>
5555 !! html/parsoid
5556 <p>[<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a> x</p>
5557 <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>
5558 <p>[[Foo</p>
5559 <p>{{echo|[[Foo}}</p>
5560 !! end
5561
5562 !! test
5563 Wikilinks with embedded newlines are not broken
5564 !! wikitext
5565 {{echo|[[ Foo
5566 B
5567 C]]}}
5568 !! html/php
5569 <p>[[ Foo
5570 B
5571 C]]
5572 </p>
5573 !! html/parsoid
5574 <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>
5575 !! end
5576
5577 !! test
5578 Broken templates
5579 !! options
5580 parsoid=wt2html
5581 !! wikitext
5582 {{echo|[[Foo|}}]]
5583
5584 [[Foo|{{echo|]]}}
5585 !! html/php
5586 <p>{{echo|<a href="/wiki/Foo" title="Foo">}}</a>
5587 </p><p>[[Foo|]]
5588 </p>
5589 !! html/parsoid
5590 <p>{{echo|<a rel="mw:WikiLink" href="./Foo" title="Foo">}}</a></p>
5591 <p>[[Foo|<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"]]"}},"i":0}}]}'>]]</span></p>
5592 !! end
5593
5594 !! test
5595 T4702: Mismatched <i>, <b> and <a> tags are invalid
5596 !! wikitext
5597 ''[http://example.com text'']
5598 [http://example.com '''text]'''
5599 ''Something [http://example.com in italic'']
5600 ''Something [http://example.com mixed''''', even bold]'''
5601 '''''Now [http://example.com both''''']
5602 !! html
5603 <p><a rel="nofollow" class="external text" href="http://example.com"><i>text</i></a>
5604 <a rel="nofollow" class="external text" href="http://example.com"><b>text</b></a>
5605 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>in italic</i></a>
5606 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>mixed</i><b>, even bold</b></a>
5607 <i><b>Now </b></i><a rel="nofollow" class="external text" href="http://example.com"><i><b>both</b></i></a>
5608 </p>
5609 !! end
5610
5611
5612 !! test
5613 T6781: %26 in URL
5614 !! wikitext
5615 http://www.example.com/?title=AT%26T
5616 !! html/php
5617 <p><a rel="nofollow" class="external free" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a>
5618 </p>
5619 !! html/parsoid
5620 <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>
5621 !! end
5622
5623 # According to https://www.w3.org/TR/2011/WD-html5-20110525/Overview.html#parsing-urls a plain
5624 # % is actually legal in HTML5. Any change in output would need testing though.
5625 !! test
5626 T6781, T7267: %25 in URL
5627 !! wikitext
5628 http://www.example.com/?title=100%25_Bran
5629 !! html/php
5630 <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>
5631 </p>
5632 !! html/parsoid
5633 <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>
5634 !! end
5635
5636 !! test
5637 T6781, T7267: %28, %29 in URL
5638 !! wikitext
5639 http://www.example.com/?title=Ben-Hur_%281959_film%29
5640 !! html/php
5641 <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>
5642 </p>
5643 !! html/parsoid
5644 <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>
5645 !! end
5646
5647
5648 !! test
5649 T6781: %26 in autonumber URL
5650 !! wikitext
5651 [http://www.example.com/?title=AT%26T]
5652 !! html/php
5653 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=AT%26T">[1]</a>
5654 </p>
5655 !! html/parsoid
5656 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=AT%26T"></a></p>
5657 !! end
5658
5659 !! test
5660 T6781, T7267: %26 in autonumber URL
5661 !! wikitext
5662 [http://www.example.com/?title=100%25_Bran]
5663 !! html/php
5664 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=100%25_Bran">[1]</a>
5665 </p>
5666 !! html/parsoid
5667 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=100%25_Bran"></a></p>
5668 !! end
5669
5670 !! test
5671 T6781, T7267: %28, %29 in autonumber URL
5672 !! wikitext
5673 [http://www.example.com/?title=Ben-Hur_%281959_film%29]
5674 !! html/php
5675 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">[1]</a>
5676 </p>
5677 !! html/parsoid
5678 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29"></a></p>
5679 !! end
5680
5681
5682 !! test
5683 T6781: %26 in bracketed URL
5684 !! wikitext
5685 [http://www.example.com/?title=AT%26T link]
5686 !! html/php
5687 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=AT%26T">link</a>
5688 </p>
5689 !! html/parsoid
5690 <p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=AT%26T">link</a></p>
5691 !! end
5692
5693 !! test
5694 T6781, T7267: %25 in bracketed URL
5695 !! wikitext
5696 [http://www.example.com/?title=100%25_Bran link]
5697 !! html
5698 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=100%25_Bran">link</a>
5699 </p>
5700 !! end
5701
5702 !! test
5703 T6781, T7267: %28, %29 in bracketed URL
5704 !! wikitext
5705 [http://www.example.com/?title=Ben-Hur_%281959_film%29 link]
5706 !! html/php
5707 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a>
5708 </p>
5709 !! html/parsoid
5710 <p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a></p>
5711 !! end
5712
5713 !! test
5714 External link containing a period in the anchor. (T65947)
5715 !! wikitext
5716 [//foo.org/bar#baz. bang]
5717
5718 [//foo.org/bar. bang]
5719 !! html/php
5720 <p><a rel="nofollow" class="external text" href="//foo.org/bar#baz.">bang</a>
5721 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar.">bang</a>
5722 </p>
5723 !! html/parsoid
5724 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar#baz.">bang</a></p>
5725 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar.">bang</a></p>
5726 !! end
5727
5728 !! test
5729 External link containing a single quote. (T65947)
5730 !! wikitext
5731 [//foo.org/bar'baz]
5732
5733 [//foo.org/bar'baz bang]
5734 !! html/php
5735 <p><a rel="nofollow" class="external autonumber" href="//foo.org/bar&#39;baz">[1]</a>
5736 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar&#39;baz">bang</a>
5737 </p>
5738 !! html/parsoid
5739 <p><a rel="mw:ExtLink" class="external autonumber" href="//foo.org/bar'baz"></a></p>
5740 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar'baz">bang</a></p>
5741 !! end
5742
5743 !! test
5744 External link containing double-single-quotes in text '' (T6598 sanity check)
5745 !! wikitext
5746 Some [http://example.com/ pretty ''italics'' and stuff]!
5747 !! html
5748 <p>Some <a rel="nofollow" class="external text" href="http://example.com/">pretty <i>italics</i> and stuff</a>!
5749 </p>
5750 !! end
5751
5752 !! test
5753 External link containing double-single-quotes in text embedded in italics (T6598 sanity check)
5754 !! wikitext
5755 ''Some [http://example.com/ pretty ''italics'' and stuff]!''
5756 !! html
5757 <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>
5758 </p>
5759 !! end
5760
5761 # Don't add the html/php section since the output is broken and there isn't any reason to spec it
5762 !! test
5763 External link containing double-single-quotes with no space separating the url from text in italics
5764 !! wikitext
5765 [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]].]
5766 !! html/php+tidy
5767 <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>.
5768 </p>
5769 !! html/parsoid
5770 <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>
5771 !! end
5772
5773 !! test
5774 External link with comments in link text
5775 !! wikitext
5776 [http://www.google.com Google <!-- comment -->]
5777 !! html/php
5778 <p><a rel="nofollow" class="external text" href="http://www.google.com">Google </a>
5779 </p>
5780 !! html/parsoid
5781 <p><a rel="mw:ExtLink" class="external text" href="http://www.google.com">Google <!-- comment --></a></p>
5782 !! end
5783
5784 !! test
5785 External link to bare IPv4 address
5786 !! wikitext
5787 [http://192.168.0.1 Link]
5788 !! html/php
5789 <p><a rel="nofollow" class="external text" href="http://192.168.0.1">Link</a>
5790 </p>
5791 !! html/parsoid
5792 <p><a rel="mw:ExtLink" class="external text" href="http://192.168.0.1">Link</a></p>
5793 !! end
5794
5795 !! test
5796 URL-encoding in URL functions (single parameter)
5797 !! wikitext
5798 {{localurl:Some page|amp=&}}
5799 !! html
5800 <p>/index.php?title=Some_page&amp;amp=&amp;
5801 </p>
5802 !! end
5803
5804 !! test
5805 URL-encoding in URL functions (multiple parameters)
5806 !! wikitext
5807 {{localurl:Some page|q=?&amp=&}}
5808 !! html
5809 <p>/index.php?title=Some_page&amp;q=?&amp;amp=&amp;
5810 </p>
5811 !! end
5812
5813 !! test
5814 Brackets in urls
5815 !! wikitext
5816 http://example.com/index.php?foozoid%5B%5D=bar
5817
5818 http://example.com/index.php?foozoid&#x5B;&#x5D;=bar
5819 !! html/php
5820 <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>
5821 </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>
5822 </p>
5823 !! html/parsoid
5824 <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>
5825
5826 <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>
5827 !! end
5828
5829 !! test
5830 IPv6 urls, autolink format (T23261)
5831 !! wikitext
5832 http://[2404:130:0:1000::187:2]/index.php
5833
5834 Examples from RFC 2373, section 2.2:
5835
5836 *http://[1080::8:800:200C:417A]/unicast
5837 *http://[FF01::101]/multicast
5838 *http://[::1]/loopback
5839 *http://[::]/unspecified
5840 *http://[::13.1.68.3]/ipv4compat
5841 *http://[::FFFF:129.144.52.38]/ipv4compat
5842
5843 Examples from RFC 2732, section 2:
5844
5845 *http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
5846 *http://[1080:0:0:0:8:800:200C:417A]/index.html
5847 *http://[3ffe:2a00:100:7031::1]
5848 *http://[1080::8:800:200C:417A]/foo
5849 *http://[::192.9.5.5]/ipng
5850 *http://[::FFFF:129.144.52.38]:80/index.html
5851 *http://[2010:836B:4179::836B:4179]
5852 !! html/php
5853 <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>
5854 </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:
5855 </p>
5856 <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>
5857 <li><a rel="nofollow" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5858 <li><a rel="nofollow" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5859 <li><a rel="nofollow" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5860 <li><a rel="nofollow" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5861 <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>
5862 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5863 </p>
5864 <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>
5865 <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>
5866 <li><a rel="nofollow" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5867 <li><a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
5868 <li><a rel="nofollow" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5869 <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>
5870 <li><a rel="nofollow" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5871
5872 !! html/parsoid
5873 <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>
5874
5875 <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>
5876 <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>
5877 <li><a rel="mw:ExtLink" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5878 <li><a rel="mw:ExtLink" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5879 <li><a rel="mw:ExtLink" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5880 <li><a rel="mw:ExtLink" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5881 <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>
5882
5883 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external mw-magiclink">RFC 2732</a>, section 2:</p>
5884 <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>
5885 <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>
5886 <li><a rel="mw:ExtLink" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5887 <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>
5888 <li><a rel="mw:ExtLink" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5889 <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>
5890 <li><a rel="mw:ExtLink" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5891 !! end
5892
5893 !! test
5894 IPv6 urls, bracketed format (T23261)
5895 !! wikitext
5896 [http://[2404:130:0:1000::187:2]/index.php test]
5897
5898 Examples from RFC 2373, section 2.2:
5899
5900 *[http://[1080::8:800:200C:417A] unicast]
5901 *[http://[FF01::101] multicast]
5902 *[http://[::1]/ loopback]
5903 *[http://[::] unspecified]
5904 *[http://[::13.1.68.3] ipv4compat]
5905 *[http://[::FFFF:129.144.52.38] ipv4compat]
5906
5907 Examples from RFC 2732, section 2:
5908
5909 *[http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html 1]
5910 *[http://[1080:0:0:0:8:800:200C:417A]/index.html 2]
5911 *[http://[3ffe:2a00:100:7031::1] 3]
5912 *[http://[1080::8:800:200C:417A]/foo 4]
5913 *[http://[::192.9.5.5]/ipng 5]
5914 *[http://[::FFFF:129.144.52.38]:80/index.html 6]
5915 *[http://[2010:836B:4179::836B:4179] 7]
5916 !! html/php
5917 <p><a rel="nofollow" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a>
5918 </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:
5919 </p>
5920 <ul><li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5921 <li><a rel="nofollow" class="external text" href="http://[FF01::101]">multicast</a></li>
5922 <li><a rel="nofollow" class="external text" href="http://[::1]/">loopback</a></li>
5923 <li><a rel="nofollow" class="external text" href="http://[::]">unspecified</a></li>
5924 <li><a rel="nofollow" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5925 <li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5926 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5927 </p>
5928 <ul><li><a rel="nofollow" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
5929 <li><a rel="nofollow" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5930 <li><a rel="nofollow" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5931 <li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5932 <li><a rel="nofollow" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
5933 <li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5934 <li><a rel="nofollow" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5935
5936 !! html/parsoid
5937 <p><a rel="mw:ExtLink" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a></p>
5938
5939 <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>
5940 <ul><li><a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5941 <li><a rel="mw:ExtLink" class="external text" href="http://[FF01::101]">multicast</a></li>
5942 <li><a rel="mw:ExtLink" class="external text" href="http://[::1]/">loopback</a></li>
5943 <li><a rel="mw:ExtLink" class="external text" href="http://[::]">unspecified</a></li>
5944 <li><a rel="mw:ExtLink" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5945 <li><a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5946
5947 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external mw-magiclink">RFC 2732</a>, section 2:</p>
5948 <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>
5949 <li><a rel="mw:ExtLink" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5950 <li><a rel="mw:ExtLink" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5951 <li><a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5952 <li><a rel="mw:ExtLink" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
5953 <li><a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5954 <li><a rel="mw:ExtLink" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5955 !! end
5956
5957 !! test
5958 Non-extlinks in brackets
5959 !! wikitext
5960 [foo]
5961 [foo bar]
5962 [foo ''bar'']
5963 [fool's] errand
5964 [fool's errand]
5965 [{{echo|foo}}]
5966 [{{echo|foo}} bar]
5967 [{{echo|foo}} ''bar'']
5968 [{{echo|foo}}l's] errand
5969 [{{echo|foo}}l's errand]
5970 [url={{echo|foo}}]
5971 [url=http://example.com]
5972 [http:// bare protocols don't count]
5973 !! html/php
5974 <p>[foo]
5975 [foo bar]
5976 [foo <i>bar</i>]
5977 [fool's] errand
5978 [fool's errand]
5979 [foo]
5980 [foo bar]
5981 [foo <i>bar</i>]
5982 [fool's] errand
5983 [fool's errand]
5984 [url=foo]
5985 [url=<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>]
5986 [http:// bare protocols don't count]
5987 </p>
5988 !! html/parsoid
5989 <p>[foo]
5990 [foo bar]
5991 [foo <i>bar</i>]
5992 [fool's] errand
5993 [fool's errand]
5994 [<span about="#mwt19" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>]
5995 [<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]
5996 [<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>]
5997 [<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
5998 [<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]
5999 [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>]
6000 [url=<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>]
6001 [http:// bare protocols don't count]</p>
6002 !! end
6003
6004 !! test
6005 Percent encoding in external links
6006 !! wikitext
6007 [https://github.com/search?l=&q=ResourceLoader+%40wikimedia Search]
6008 !! html/php
6009 <p><a rel="nofollow" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a>
6010 </p>
6011 !! html/parsoid
6012 <p><a rel="mw:ExtLink" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a></p>
6013 !! end
6014
6015 !! test
6016 Use url link syntax for links where the content is equal the link target
6017 !! wikitext
6018 http://example.com
6019 !! html/php
6020 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
6021 </p>
6022 !! html/parsoid
6023 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a></p>
6024 !! end
6025
6026 !! test
6027 Parenthesis in external links, especially URL links
6028 !! wikitext
6029 http://example.com)
6030
6031 http://example.com/test)
6032
6033 http://example.com/(test)
6034
6035 http://example.com/((test)
6036
6037 (http://example.com/(test))
6038
6039 (http://example.com/(test)))))
6040
6041 http://example.com/a)b
6042
6043 [http://example.com) foo]
6044 !! html/php
6045 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
6046 </p><p><a rel="nofollow" class="external free" href="http://example.com/test">http://example.com/test</a>)
6047 </p><p><a rel="nofollow" class="external free" href="http://example.com/(test)">http://example.com/(test)</a>
6048 </p><p><a rel="nofollow" class="external free" href="http://example.com/((test)">http://example.com/((test)</a>
6049 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test))">http://example.com/(test))</a>
6050 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a>
6051 </p><p><a rel="nofollow" class="external free" href="http://example.com/a)b">http://example.com/a)b</a>
6052 </p><p><a rel="nofollow" class="external text" href="http://example.com)">foo</a>
6053 </p>
6054 !! html/parsoid
6055 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>)</p>
6056 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/test">http://example.com/test</a>)</p>
6057 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/(test)">http://example.com/(test)</a></p>
6058 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/((test)">http://example.com/((test)</a></p>
6059 <p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test))">http://example.com/(test))</a></p>
6060 <p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a></p>
6061 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/a)b">http://example.com/a)b</a></p>
6062 <p><a rel="mw:ExtLink" class="external text" href="http://example.com)">foo</a></p>
6063 !! end
6064
6065 !! test
6066 Parenthesis in external links, w/ transclusion or comment
6067 !! wikitext
6068 (http://example.com/{{echo|hi}})
6069
6070 (http://example.com<!-- hi -->)
6071 !! html/php
6072 <p>(<a rel="nofollow" class="external free" href="http://example.com/hi">http://example.com/hi</a>)
6073 </p><p>(<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
6074 </p>
6075 !! html/parsoid
6076 <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>
6077
6078 <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>
6079 !! end
6080
6081 !! test
6082 Serialize <a> tags with invalid link targets as plain text
6083 !! options
6084 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
6085 !! html/parsoid
6086 <a rel="mw:WikiLink" href="[[foo]]">text</a>
6087 <a rel="mw:WikiLink" href="[[foo]]">*text</a>
6088 <a rel="mw:WikiLink" href="[[foo]]">[[foo]]</a>
6089 <a rel="mw:WikiLink" href="[[foo]]">*a [[foo]]</a>
6090 !! wikitext
6091 text
6092 <nowiki>*</nowiki>text
6093 <nowiki>[[foo]]</nowiki>
6094 <nowiki>*</nowiki>a <nowiki>[[foo]]</nowiki>
6095 !! end
6096
6097 !! test
6098 mw:ExtLink -vs- mw:WikiLink (T94723)
6099 !! options
6100 parsoid=html2wt
6101 !! html/parsoid
6102 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"piped","a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>Bar</a>
6103 <a rel="mw:WikiLink" href="./Foo" title="Foo">Bar</a>
6104 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
6105 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
6106 <p>
6107 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
6108 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
6109 </p>
6110 !! wikitext
6111 [[Foo|Bar]]
6112 [[Foo|Bar]]
6113 [[:en:Foo|Bar]]
6114 [[:en:Foo|Bar]]
6115
6116 [[:en:European_Robin|European Robin]]
6117 [[:en:European_Robin|European Robin]]
6118 !! end
6119
6120 !! test
6121 mw:ExtLink linking to a interwiki URL can be round-tripped losslessly (T94723)
6122 !! options
6123 parsoid=wt2wt
6124 !! wikitext
6125 [http://en.wikipedia.org/wiki/European_Robin European Robin]
6126 !! html/parsoid
6127 THIS SECTION IS NOT USED (but Parsoid won't run the test without it)
6128 !! end
6129
6130
6131 ###
6132 ### Quotes
6133 ###
6134
6135 !! test
6136 Quotes
6137 !! wikitext
6138 Normal text. '''Bold text.''' Normal text. ''Italic text.''
6139
6140 Normal text. '''''Bold italic text.''''' Normal text.
6141 !! html
6142 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
6143 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
6144 </p>
6145 !! end
6146
6147
6148 # Parsoid inserts an empty bold tag pair at the end of the line, that the PHP
6149 # parser strips. The wikitext contains just the first half of the bold
6150 # quote pair.
6151 !! test
6152 Unclosed and unmatched quotes
6153 !! wikitext
6154 '''''Bold italic text '''with bold deactivated''' in between.'''''
6155
6156 '''''Bold italic text ''with italic deactivated'' in between.'''''
6157
6158 '''Bold text..
6159
6160 ..spanning two paragraphs (should not work).'''
6161
6162 '''Bold tag left open
6163
6164 ''Italic tag left open
6165
6166 Normal text.
6167
6168 <!-- Unmatching number of opening, closing tags: -->
6169 '''This year''''s election ''should'' beat '''last year''''s.
6170
6171 ''Tom'''s car is bigger than ''Susan'''s.
6172
6173 Plain ''italic'''s plain
6174 !! html/php
6175 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
6176 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
6177 </p><p><b>Bold text..</b>
6178 </p><p>..spanning two paragraphs (should not work).
6179 </p><p><b>Bold tag left open</b>
6180 </p><p><i>Italic tag left open</i>
6181 </p><p>Normal text.
6182 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
6183 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
6184 </p><p>Plain <i>italic'</i>s plain
6185 </p>
6186 !! html/parsoid
6187 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
6188 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
6189 </p><p><b>Bold text..</b>
6190 </p><p>..spanning two paragraphs (should not work).<b></b>
6191 </p><p><b>Bold tag left open</b>
6192 </p><p><i>Italic tag left open</i>
6193 </p><p>Normal text.
6194 </p>
6195 <!-- Unmatching number of opening, closing tags: -->
6196 <p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
6197 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
6198 </p><p>Plain <i>italic'</i>s plain
6199 </p>
6200 !! end
6201
6202 ###
6203 ### Tables
6204 ###
6205 ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
6206 ###
6207
6208 # This should not produce <table></table> as <table><tr><td></td></tr></table>
6209 # is the bare minimum required by the spec, see:
6210 # https://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
6211 # Parsoid team replies: empty table tags are legal in HTML5
6212 !! test
6213 A table with no data.
6214 !! options
6215 parsoid=wt2html
6216 !! wikitext
6217 {||}
6218 !! html/php
6219
6220 !! html/parsoid
6221 <table></table>
6222
6223 !! end
6224
6225 !! test
6226 A table with stray table end tags on start tag line (wt2html)
6227 !! options
6228 parsoid=wt2html
6229 !! wikitext
6230 {|style="color: red;"|}
6231
6232 {|style="color: red;" |}
6233 |foo
6234 |}
6235
6236 {|style="color: red;"|} id="foo"
6237 |foo
6238 |}
6239
6240 {|style="color: red;" |} id="foo"
6241 |foo
6242 |}
6243 !! html
6244 <table style="color: red;"></table>
6245
6246 <table style="color: red;">
6247 <tbody><tr>
6248 <td>foo</td>
6249 </tr></tbody>
6250 </table>
6251
6252 <table style="color: red;" id="foo">
6253 <tbody><tr>
6254 <td>foo</td>
6255 </tr></tbody>
6256 </table>
6257
6258 <table style="color: red;" id="foo">
6259 <tbody><tr>
6260 <td>foo</td>
6261 </tr></tbody>
6262 </table>
6263
6264 !! end
6265
6266 !! test
6267 A table with no data (take 2)
6268 !! wikitext
6269 {|
6270 |}
6271 !! html/parsoid
6272 <table></table>
6273 !! end
6274
6275 # A table with nothing but a caption is invalid XHTML, we might want to render
6276 # this as <p>caption</p>
6277 # Parsoid team replies: table with only a caption is legal in HTML5
6278 !! test
6279 A table with nothing but a caption
6280 !! wikitext
6281 {|
6282 |+caption
6283 |}
6284 !! html/php
6285 <table>
6286 <caption>caption
6287 </caption><tr><td></td></tr></table>
6288
6289 !! html/parsoid
6290 <table><caption>caption</caption></table>
6291 !! end
6292
6293 !! test
6294 A table with caption with default-spaced attributes and a table row
6295 !! wikitext
6296 {|
6297 |+ style="color: red;" |caption1
6298 |-
6299 |foo
6300 |}
6301 !! html
6302 <table>
6303 <caption style="color: red;">caption1
6304 </caption>
6305 <tr>
6306 <td>foo
6307 </td></tr></table>
6308
6309 !! end
6310
6311 !! test
6312 A table with captions with non-default spaced attributes and a table row
6313 !! wikitext
6314 {|
6315 |+style="color: red;"|caption2
6316 |+ style="color: red;"|caption3
6317 |-
6318 |foo
6319 |}
6320 !! html
6321 <table>
6322 <caption style="color: red;">caption2
6323 </caption>
6324 <caption style="color: red;">caption3
6325 </caption>
6326 <tr>
6327 <td>foo
6328 </td></tr></table>
6329
6330 !! end
6331
6332 !! test
6333 Table td-cell syntax variations
6334 !! wikitext
6335 {|
6336 |foo bar foo|baz
6337 |foo bar foo||baz
6338 |style='color:red;'|baz
6339 |style='color:red;'||baz
6340 |}
6341 !! html
6342 <table>
6343 <tr>
6344 <td>baz
6345 </td>
6346 <td>foo bar foo</td>
6347 <td>baz
6348 </td>
6349 <td style="color:red;">baz
6350 </td>
6351 <td>style='color:red;'</td>
6352 <td>baz
6353 </td></tr></table>
6354
6355 !! end
6356
6357 !! test
6358 Simple table
6359 !! wikitext
6360 {|
6361 |1||2
6362 |-
6363 |3||4
6364 |}
6365 !! html
6366 <table>
6367 <tr>
6368 <td>1</td>
6369 <td>2
6370 </td></tr>
6371 <tr>
6372 <td>3</td>
6373 <td>4
6374 </td></tr></table>
6375
6376 !! end
6377
6378 !! test
6379 Simple table but with multiple dashes for row wikitext
6380 !! wikitext
6381 {|
6382 |foo
6383 |-----
6384 |bar
6385 |}
6386 !! html
6387 <table>
6388 <tr>
6389 <td>foo
6390 </td></tr>
6391 <tr>
6392 <td>bar
6393 </td></tr></table>
6394
6395 !! end
6396
6397 !! test
6398 Multiplication table
6399 !! wikitext
6400 {| border="1" cellpadding="2"
6401 |+Multiplication table
6402 |-
6403 !&times;!!1!!2!!3
6404 |-
6405 !1
6406 |1||2||3
6407 |-
6408 !2
6409 |2||4||6
6410 |-
6411 !3
6412 |3||6||9
6413 |-
6414 !4
6415 |4||8||12
6416 |-
6417 !5
6418 |5||10||15
6419 |}
6420 !! html
6421 <table border="1" cellpadding="2">
6422 <caption>Multiplication table
6423 </caption>
6424 <tr>
6425 <th>&#215;</th>
6426 <th>1</th>
6427 <th>2</th>
6428 <th>3
6429 </th></tr>
6430 <tr>
6431 <th>1
6432 </th>
6433 <td>1</td>
6434 <td>2</td>
6435 <td>3
6436 </td></tr>
6437 <tr>
6438 <th>2
6439 </th>
6440 <td>2</td>
6441 <td>4</td>
6442 <td>6
6443 </td></tr>
6444 <tr>
6445 <th>3
6446 </th>
6447 <td>3</td>
6448 <td>6</td>
6449 <td>9
6450 </td></tr>
6451 <tr>
6452 <th>4
6453 </th>
6454 <td>4</td>
6455 <td>8</td>
6456 <td>12
6457 </td></tr>
6458 <tr>
6459 <th>5
6460 </th>
6461 <td>5</td>
6462 <td>10</td>
6463 <td>15
6464 </td></tr></table>
6465
6466 !! end
6467
6468 !! test
6469 Accept "||" in table headings
6470 !! wikitext
6471 {|
6472 !h1||h2
6473 |}
6474 !! html
6475 <table>
6476 <tr>
6477 <th>h1</th>
6478 <th>h2
6479 </th></tr></table>
6480
6481 !! end
6482
6483 !! test
6484 Accept "!!" in table data
6485 !! wikitext
6486 {|
6487 |Foo!!||
6488 |}
6489 !! html
6490 <table>
6491 <tr>
6492 <td>Foo!!</td>
6493 <td>
6494 </td></tr></table>
6495
6496 !! html/parsoid
6497 <table>
6498 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'> Foo!! </td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'></td></tr>
6499 </tbody></table>
6500 !! end
6501
6502 !! test
6503 Accept "||" in indented table headings
6504 !! wikitext
6505 :{|
6506 !h1||h2
6507 |}
6508 !! html
6509 <dl><dd><table>
6510 <tr>
6511 <th>h1</th>
6512 <th>h2
6513 </th></tr></table></dd></dl>
6514
6515 !! end
6516
6517 !! test
6518 Accept "!!" in templates
6519 !! wikitext
6520 {|
6521 !a {{echo|b!!c}}
6522 |}
6523 !! html/php
6524 <table>
6525 <tr>
6526 <th>a b</th>
6527 <th>c
6528 </th></tr></table>
6529
6530 !! html/parsoid
6531 <table>
6532 <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>
6533 !! end
6534
6535 !! test
6536 Accept "!!" in table headings after newline
6537 !! wikitext
6538 {|
6539 !a
6540 b!!c
6541 |}
6542 !! html/php
6543 <table>
6544 <tr>
6545 <th>a
6546 <p>b!!c
6547 </p>
6548 </th></tr></table>
6549
6550 !! html/parsoid
6551 <table>
6552 <tbody><tr><th>a
6553 <p>b!!c</p></th></tr>
6554 </tbody></table>
6555 !! end
6556
6557 !! test
6558 Accept "!!" in table data of mixed wikitext / html syntax
6559 !! wikitext
6560 {|
6561 !a
6562 <tr><td>b!!c</td></tr>
6563 |}
6564 !! html/php+tidy
6565 <table>
6566 <tbody><tr>
6567 <th>a
6568 </th></tr><tr><td>b!!c</td></tr>
6569 </tbody></table>
6570 !! html/parsoid
6571 <table>
6572 <tbody><tr><th>a</th></tr>
6573 <tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>b!!c</td></tr>
6574 </tbody></table>
6575 !! end
6576
6577 !! test
6578 Accept empty attributes in td/th cells (td/th cells starting with leading ||)
6579 !! wikitext
6580 {|
6581 !|h1
6582 ||a
6583 |}
6584 !! html
6585 <table>
6586 <tr>
6587 <th>h1
6588 </th>
6589 <td>a
6590 </td></tr></table>
6591
6592 !! end
6593
6594 !!test
6595 Accept "| !" at start of line in tables (ignore !-attribute)
6596 !! wikitext
6597 {|
6598 |-
6599 |!style="color:red"|bar
6600 |}
6601 !! html
6602 <table>
6603
6604 <tr>
6605 <td>bar
6606 </td></tr></table>
6607
6608 !!end
6609
6610 !!test
6611 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 +/-
6612 !! wikitext
6613 {|
6614 |-
6615 |style='color:red;'|+1
6616 |style='color:blue;'|-1
6617 |-
6618 |1||2||3
6619 |1||+2||-3
6620 |-
6621 | +1
6622 | -1
6623 |}
6624 !! html
6625 <table>
6626
6627 <tr>
6628 <td style="color:red;">+1
6629 </td>
6630 <td style="color:blue;">-1
6631 </td></tr>
6632 <tr>
6633 <td>1</td>
6634 <td>2</td>
6635 <td>3
6636 </td>
6637 <td>1</td>
6638 <td>+2</td>
6639 <td>-3
6640 </td></tr>
6641 <tr>
6642 <td>+1
6643 </td>
6644 <td>-1
6645 </td></tr></table>
6646
6647 !!end
6648
6649 !! test
6650 Table rowspan
6651 !! wikitext
6652 {| border=1
6653 |Cell 1, row 1
6654 |rowspan=2|Cell 2, row 1 (and 2)
6655 |Cell 3, row 1
6656 |-
6657 |Cell 1, row 2
6658 |Cell 3, row 2
6659 |}
6660 !! html
6661 <table border="1">
6662 <tr>
6663 <td>Cell 1, row 1
6664 </td>
6665 <td rowspan="2">Cell 2, row 1 (and 2)
6666 </td>
6667 <td>Cell 3, row 1
6668 </td></tr>
6669 <tr>
6670 <td>Cell 1, row 2
6671 </td>
6672 <td>Cell 3, row 2
6673 </td></tr></table>
6674
6675 !! end
6676
6677 !! test
6678 Nested table
6679 !! wikitext
6680 {| border=1
6681 | &alpha;
6682 |
6683 {| bgcolor=#ABCDEF border=2
6684 |nested
6685 |-
6686 |table
6687 |}
6688 |the original table again
6689 |}
6690 !! html
6691 <table border="1">
6692 <tr>
6693 <td>&#945;
6694 </td>
6695 <td>
6696 <table bgcolor="#ABCDEF" border="2">
6697 <tr>
6698 <td>nested
6699 </td></tr>
6700 <tr>
6701 <td>table
6702 </td></tr></table>
6703 </td>
6704 <td>the original table again
6705 </td></tr></table>
6706
6707 !! end
6708
6709 !! test
6710 Invalid attributes in table cell (T3830)
6711 !! wikitext
6712 {|
6713 |Cell:|broken
6714 |}
6715 !! html
6716 <table>
6717 <tr>
6718 <td>broken
6719 </td></tr></table>
6720
6721 !! end
6722
6723 !! test
6724 Table cell attributes: Pipes protected by nowikis should be treated as a plain character
6725 !! wikitext
6726 {|
6727 |title="foo" |bar
6728 |title="foo<nowiki>|</nowiki>" |bar
6729 |title="foo<nowiki>|</nowiki>" bar
6730 |}
6731 !! html/php
6732 <table>
6733 <tr>
6734 <td title="foo">bar
6735 </td>
6736 <td title="foo&#124;">bar
6737 </td>
6738 <td>title="foo|" bar
6739 </td></tr></table>
6740
6741 !! html/parsoid
6742 <table>
6743 <tbody><tr><td title="foo">bar</td>
6744 <td title="foo|" data-parsoid='{"a":{"title":"foo|"},"sa":{"title":"foo&lt;nowiki>|&lt;/nowiki>"},"autoInsertedEnd":true}'>bar</td>
6745 <td> title="foo<span typeof="mw:Nowiki">|</span>" bar</td></tr>
6746 </tbody></table>
6747 !! end
6748
6749 # See: http://lists.wikimedia.org/mailman/htdig/wikitech-l/2006-April/022293.html
6750 # N.B. The "|}" to close the table is missing from the input, so parsoid's
6751 # *2wt modes will fail.
6752 !! test
6753 Table security: embedded pipes
6754 !! options
6755 parsoid=wt2html,html2html
6756 !! wikitext
6757 {|
6758 | |[ftp://|x||]" onmouseover="alert(document.cookie)">test
6759 !! html/php
6760 <table>
6761 <tr>
6762 <td>[<a rel="nofollow" class="external free" href="ftp://%7Cx">ftp://%7Cx</a></td>
6763 <td>]" onmouseover="alert(document.cookie)"&gt;test
6764 </td>
6765 </tr>
6766 </table>
6767
6768 !! html/parsoid
6769 <table><tbody>
6770 <tr>
6771 <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>
6772 !! end
6773
6774 !! test
6775 Element attributes with double ! should not be broken up by <th>
6776 !! wikitext
6777 {|
6778 !hi <div class="!!">ha</div> ho
6779 |}
6780 !! html/php
6781 <table>
6782 <tr>
6783 <th>hi <div class="!!">ha</div> ho
6784 </th></tr></table>
6785
6786 !! html/parsoid
6787 <table>
6788 <tbody><tr><th>hi <div class="!!" data-parsoid='{"stx":"html"}'>ha</div> ho</th></tr>
6789 </tbody></table>
6790 !! end
6791
6792 !! test
6793 ! and || in element attributes should not be parsed as <th>/<td>
6794 !! wikitext
6795 {|
6796 |<div style="color: red !important;" data-contrived="put this here ||">hi</div>
6797 |}
6798 !! html/php
6799 <table>
6800 <tr>
6801 <td><div style="color: red&#32;!important;" data-contrived="put this here &#124;&#124;">hi</div>
6802 </td></tr></table>
6803
6804 !! html/parsoid
6805 <table>
6806 <tbody><tr><td><div style="color: red !important;" data-contrived="put this here ||" data-parsoid='{"stx":"html"}'>hi</div></td></tr>
6807 </tbody></table>
6808 !! end
6809
6810 # FIXME: The output seems broken. Filed as T110268.
6811 !! test
6812 ! and || in td attributes should not be parsed as <th>/<td>
6813 !! options
6814 parsoid=wt2html
6815 !! wikitext
6816 {|
6817 |style="color: red !important;" data-contrived="put this here ||"|foo
6818 |}
6819 !! html/php
6820 <table>
6821 <tr>
6822 <td>style="color: red&#160;!important;" data-contrived="put this here</td>
6823 <td>foo
6824 </td></tr></table>
6825
6826 !! html/parsoid
6827 <table>
6828 <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>
6829 </tbody></table>
6830 !! end
6831
6832 !! test
6833 Break on | in element attribute in template
6834 !! options
6835 parsoid=wt2html,html2html
6836 !! wikitext
6837 {{echo|1=<div class="hi|ho">ha</div>}}
6838 !! html/php
6839 <p>ho"&gt;ha&lt;/div&gt;
6840 </p>
6841 !! html/parsoid
6842 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"ho\">ha&lt;/div>"}},"i":0}}]}'>ho">ha</span>
6843 !! end
6844
6845 !! test
6846 Break on | in element attribute name in template
6847 !! wikitext
6848 {{echo|<div cla|ss="hiho">ha</div>}}
6849 !! html/parsoid
6850 <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>
6851 !! end
6852
6853 !! test
6854 Don't break on | in extension attribute in template
6855 !! wikitext
6856 {{echo|<ref name="hi|ho">ha</ref>}}
6857
6858 <references />
6859 !! html/parsoid
6860 <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>
6861
6862 <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>
6863 !! end
6864
6865 ## We don't support roundtripping of these attributes in Parsoid.
6866 ## Selective serialization takes care of preventing dirty diffs.
6867 ## But, on edits, we dirty-diff the invalid attribute text.
6868 !! test
6869 Invalid text in table attributes should be discarded
6870 !! options
6871 parsoid=wt2html
6872 !! wikitext
6873 {| <span>boo</span> style='border:1px solid black'
6874 | <span>boo</span> style='color:blue' |1
6875 |<span>boo</span> style='color:blue'|2
6876 |}
6877 !! html/php
6878 <table style="border:1px solid black">
6879 <tr>
6880 <td style="color:blue">1
6881 </td>
6882 <td style="color:blue">2
6883 </td></tr></table>
6884
6885 !! html/parsoid
6886 <table style="border:1px solid black">
6887 <tr>
6888 <td style="color:blue">1</td>
6889 <td style="color:blue">2</td>
6890 </tr>
6891 </table>
6892 !! end
6893
6894 !! test
6895 Invalid text in table attributes should be preserved by selective serializer
6896 !! options
6897 parsoid={
6898 "modes": ["selser"],
6899 "changes": [
6900 ["td:first-child", "text", "abc"],
6901 ["td + td", "text", "xyz"]
6902 ]
6903 }
6904 !! wikitext
6905 {| <span>boo</span> style='border:1px solid black'
6906 | <span>boo</span> style='color:blue' | 1
6907 |<span>boo</span> style='color:blue'| 2
6908 |}
6909 !! wikitext/edited
6910 {| <span>boo</span> style='border:1px solid black'
6911 | <span>boo</span> style='color:blue' | abc
6912 |<span>boo</span> style='color:blue'| xyz
6913 |}
6914 !! end
6915
6916 !! test
6917 1. Template-generated table cell attributes and cell content
6918 !! wikitext
6919 {|
6920 |{{table_attribs}}
6921 | {{table_attribs}}
6922 || {{table_attribs_5}}
6923 | <!--foo--> <!--bar--> <!--baz--> {{table_attribs}}
6924 |align=center {{table_attribs}}
6925 | <!--foo--> align=center <!--bar--> {{table_attribs}}
6926 |}
6927 !! html
6928 <table>
6929 <tr>
6930 <td style="color:red;">Foo
6931 </td>
6932 <td style="color:red;">Foo
6933 </td>
6934 <td>style="color:red;"</td>
6935 <td>Bar
6936 </td>
6937 <td style="color:red;">Foo
6938 </td>
6939 <td align="center" style="color:red;">Foo
6940 </td>
6941 <td align="center" style="color:red;">Foo
6942 </td></tr></table>
6943
6944 !! end
6945
6946 !! test
6947 2. Template-generated table cell attributes and cell content
6948 !! wikitext
6949 {|
6950 |{{table_attribs_2}}
6951 |}
6952 !! html/php
6953 <table>
6954 <tr>
6955 <td style="color:red;">Foo
6956 </td>
6957 <td>Bar</td>
6958 <td>Baz
6959 </td></tr></table>
6960
6961 !! html/parsoid
6962 <table>
6963 <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>
6964 <td about="#mwt1">Bar</td><td about="#mwt1">Baz</td></tr>
6965 </tbody></table>
6966 !! end
6967
6968 !! test
6969 3. Template-generated table cell attributes and cell content
6970 !! wikitext
6971 {|
6972 !align=center {{table_header_cells}}
6973 |-
6974 |align=center {{table_cells}}
6975 |}
6976 !! html/php
6977 <table>
6978 <tr>
6979 <th align="center" style="color:red;">Foo</th>
6980 <th style="color:red;"><i>Bar</i></th>
6981 <th style="color:brown;"><i>Foo</i> and Baz
6982 </th></tr>
6983 <tr>
6984 <td align="center" style="color:red;">Foo</td>
6985 <td style="color:red;"><i>Bar</i></td>
6986 <td style="color:brown;"><i>Foo</i> and Baz
6987 </td></tr></table>
6988
6989 !! html/parsoid
6990 <table>
6991 <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>
6992 <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>
6993 </tbody></table>
6994 !! end
6995
6996 !! test
6997 4. Template-generated table cell attributes and cell content inside a templated table
6998 !! wikitext
6999 {{tbl-start}}
7000 !align=center {{table_header_cells}}
7001 |-
7002 |align=center {{table_cells}}
7003 {{tbl-end}}
7004 !! html/php
7005 <table>
7006 <tr>
7007 <th align="center" style="color:red;">Foo</th>
7008 <th style="color:red;"><i>Bar</i></th>
7009 <th style="color:brown;"><i>Foo</i> and Baz
7010 </th></tr>
7011 <tr>
7012 <td align="center" style="color:red;">Foo</td>
7013 <td style="color:red;"><i>Bar</i></td>
7014 <td style="color:brown;"><i>Foo</i> and Baz
7015 </td></tr></table>
7016
7017 !! html/parsoid
7018 <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}}]}'>
7019 <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>
7020 <tr>
7021 <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>
7022 </tbody></table>
7023 !! end
7024
7025 ## Edge case fix to prevent future regressions
7026 !! test
7027 T107652: <ref>s in templates that also generate table cell attributes should be rendered properly
7028 !! wikitext
7029 {|
7030 |{{table_attribs_7}}
7031 |}
7032 <references />
7033 !! html/parsoid
7034 <table>
7035 <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","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{}}'><a href="./Main_Page#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></s></td></tr>
7036 </tbody></table>
7037 <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>
7038 !! end
7039
7040 !! test
7041 Table with row followed by newlines and table heading
7042 !! options
7043 parsoid=wt2html,html2html
7044 !! wikitext
7045 {|
7046 |-
7047
7048 !foo
7049 |}
7050 !! html/*
7051 <table>
7052
7053
7054 <tr>
7055 <th>foo
7056 </th></tr></table>
7057
7058 !! end
7059
7060 !! test
7061 Table with empty line following the start tag
7062 !! options
7063 parsoid=wt2html,html2html
7064 !! wikitext
7065 {|
7066
7067 |-
7068 |foo
7069 |}
7070 !! html/*
7071 <table>
7072
7073
7074 <tr>
7075 <td>foo
7076 </td></tr></table>
7077
7078 !! end
7079
7080 !! test
7081 Table attributes with empty value
7082 !! options
7083 parsoid=wt2html,html2html
7084 !! wikitext
7085 {|
7086 | style=|hello
7087 |}
7088 !! html/php
7089 <table>
7090 <tr>
7091 <td style="">hello
7092 </td></tr></table>
7093
7094 !! html/parsoid
7095 <table>
7096 <tbody><tr><td style="">hello</td></tr>
7097 </tbody></table>
7098 !! end
7099
7100 !! test
7101 Wikitext table with a lot of comments
7102 !! wikitext
7103 {|
7104 <!-- c0 -->
7105 |foo
7106 <!-- c1 -->
7107 |-<!-- c2 -->
7108 <!-- c3 -->
7109 |<!-- c4 -->
7110 <!-- c5 -->
7111 |}
7112 !! html
7113 <table>
7114 <tr>
7115 <td>foo
7116 </td></tr>
7117 <tr>
7118 <td>
7119 </td></tr></table>
7120
7121 !! end
7122
7123 !! test
7124 Wikitext table comments represented in parsoid dom
7125 !! wikitext
7126 {|<!--c1--><!--c2-->
7127 |-<!--c3-->
7128 |x
7129 |}
7130 !! html/php+tidy
7131 <table>
7132
7133 <tbody><tr>
7134 <td>x
7135 </td></tr></tbody></table>
7136 !! html/parsoid
7137 <table><!--c1--><!--c2-->
7138 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'><!--c3-->
7139 <td data-parsoid='{"autoInsertedEnd":true}'>x</td></tr>
7140 </tbody></table>
7141 !! end
7142
7143 !! test
7144 Wikitext table with double-line table cell
7145 !! wikitext
7146 {|
7147 |a
7148 b
7149 |}
7150 !! html
7151 <table>
7152 <tr>
7153 <td>a
7154 <p>b
7155 </p>
7156 </td></tr></table>
7157
7158 !! end
7159
7160 !! test
7161 Table cell with a single comment
7162 !! wikitext
7163 {|
7164 |<!-- c1 -->
7165 |a
7166 |}
7167 !! html
7168 <table>
7169 <tr>
7170 <td>
7171 </td>
7172 <td>a
7173 </td></tr></table>
7174
7175 !! end
7176
7177 !! test
7178 Table-cell after a comment-only-empty-line
7179 !! wikitext
7180 {|
7181 |a
7182 <!--c1-->
7183 <!--c2-->|b
7184 |}
7185 !! html
7186 <table>
7187 <tr>
7188 <td>a
7189 </td>
7190 <td>b
7191 </td></tr></table>
7192
7193 !! html/parsoid
7194 <table>
7195 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>a</td>
7196 <!--c1-->
7197 <!--c2--><td data-parsoid='{"autoInsertedEnd":true}'>b</td></tr>
7198 </tbody></table>
7199
7200 !! end
7201
7202 !! test
7203 Build table with {{!}}
7204 !! wikitext
7205 {{{!}} class="wikitable"
7206 !header
7207 !second header
7208 {{!}}- style="color:red;"
7209 {{!}}data{{!}}{{!}} style="color:red;" {{!}}second data
7210 {{!}}}
7211 !! html
7212 <table class="wikitable">
7213 <tr>
7214 <th>header
7215 </th>
7216 <th>second header
7217 </th></tr>
7218 <tr style="color:red;">
7219 <td>data</td>
7220 <td style="color:red;">second data
7221 </td></tr></table>
7222
7223 !! end
7224
7225 !! test
7226 Build table with pipe as data
7227 !! wikitext
7228 {| class="wikitable"
7229 !header
7230 !second header
7231 |- style="color:red;"
7232 |data|| style="color:red;" |second data
7233 |-
7234 | style="color:red;" |data with | || style="color:red;" | second data with |
7235 |-
7236 ||data with | |||second data with |
7237 |}
7238 !! html
7239 <table class="wikitable">
7240 <tr>
7241 <th>header
7242 </th>
7243 <th>second header
7244 </th></tr>
7245 <tr style="color:red;">
7246 <td>data</td>
7247 <td style="color:red;">second data
7248 </td></tr>
7249 <tr>
7250 <td style="color:red;">data with |</td>
7251 <td style="color:red;">second data with |
7252 </td></tr>
7253 <tr>
7254 <td>data with |</td>
7255 <td>second data with |
7256 </td></tr></table>
7257
7258 !! end
7259
7260 !! test
7261 Build table with wikilink
7262 !! wikitext
7263 {| class="wikitable"
7264 !header||second header
7265 |- style="color:red;"
7266 |data [[Main Page|linktext]]||second data [[Main Page|linktext]]
7267 |-
7268 |data||second data [[Main Page|link|text with pipe]]
7269 |}
7270 !! html
7271 <table class="wikitable">
7272 <tr>
7273 <th>header</th>
7274 <th>second header
7275 </th></tr>
7276 <tr style="color:red;">
7277 <td>data <a href="/wiki/Main_Page" title="Main Page">linktext</a></td>
7278 <td>second data <a href="/wiki/Main_Page" title="Main Page">linktext</a>
7279 </td></tr>
7280 <tr>
7281 <td>data</td>
7282 <td>second data <a href="/wiki/Main_Page" title="Main Page">link|text with pipe</a>
7283 </td></tr></table>
7284
7285 !! end
7286
7287 # The expected HTML structure in this test is debatable. The PHP parser does
7288 # not parse this kind of table at all. The main focus for Parsoid is on
7289 # round-tripping, so this output is ok for now. TODO: revisit!
7290 !! test
7291 Wikitext table with html-syntax row
7292 !! wikitext
7293 {|
7294 |-
7295 <td>foo</td>
7296 |}
7297 !! html/parsoid
7298 <table>
7299 <tbody>
7300 <tr>
7301 <td>foo</td></tr></tbody></table>
7302 !! end
7303
7304 !! test
7305 Fostered content in tables: Plain text
7306 !! options
7307 parsoid=wt2html,html2html
7308 !! wikitext
7309 {|
7310 |-
7311 a
7312 |}
7313 !! html/php
7314 <table>
7315
7316 a
7317 </table>
7318
7319 !! html/php+tidy
7320
7321
7322 a
7323 <table></table>
7324 !! html/parsoid
7325 <span data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>
7326 a
7327 </span><table>
7328 <tbody><tr class="mw-empty-elt" data-parsoid='{"startTagSrc":"|-"}'></tr></tbody></table>
7329 !! end
7330
7331 !! test
7332 Fostered content in tables: Lists
7333 !! options
7334 parsoid=wt2html,html2html
7335 !! wikitext
7336 {|
7337 |-
7338 *a
7339 |}
7340 !! html/php
7341 <table>
7342
7343 <ul><li>a</li></ul>
7344 </table>
7345
7346 !! html/php+tidy
7347 <ul><li>a</li></ul><table>
7348
7349
7350 </table>
7351 !! html/parsoid
7352 <ul data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><li>a</li></ul><table>
7353 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7354
7355 </tr></tbody></table>
7356 !! end
7357
7358 !! test
7359 Template generated table cell with attributes
7360 !! wikitext
7361 {|
7362 |-
7363 {{table_attribs_4}} ||a||b
7364 |}
7365 !! html/php+tidy
7366 <table>
7367
7368 <tbody><tr>
7369 <td style="background-color:#DC241f;" width="10px"></td>
7370 <td>a</td>
7371 <td>b
7372 </td></tr></tbody></table>
7373 !! html/parsoid
7374 <table>
7375 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7376 <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>
7377 !! end
7378
7379 !! test
7380 Parsoid: Round-trip tables directly followed by content (T53219)
7381 !! options
7382 parsoid=wt2html,wt2wt
7383 !! wikitext
7384 {|
7385 |foo
7386 |} bar
7387
7388 {|
7389 |baz
7390 |}<b>quux</b>
7391 !! html+tidy
7392 <table>
7393 <tbody><tr>
7394 <td>foo
7395 </td></tr></tbody></table><p> bar
7396 </p><table>
7397 <tbody><tr>
7398 <td>baz
7399 </td></tr></tbody></table><p><b>quux</b>
7400 </p>
7401 !! end
7402
7403 !! test
7404 Parsoid: Default to a newline after tables in new content (T53219)
7405 !! options
7406 parsoid=html2wt
7407 !! html/parsoid
7408 <table><tbody>
7409 <tr><td>foo</td></tr></tbody></table> bar
7410 <table><tbody>
7411 <tr><td>baz</td></tr></tbody></table><b>quux</b>
7412 !! wikitext
7413 {|
7414 |foo
7415 |}
7416 <nowiki> </nowiki>bar
7417 {|
7418 |baz
7419 |}
7420 '''quux'''
7421 !! end
7422
7423 !! test
7424 Parsoid: Row-syntax table headings followed by comment & table cells
7425 !! options
7426 parsoid=wt2html,wt2wt
7427 !! wikitext
7428 {|
7429 !foo||bar
7430 <!-- foo --> ||baz||quux
7431 |}
7432 !! html/php
7433 <table>
7434 <tr>
7435 <th>foo</th>
7436 <th>bar
7437 </th>
7438 <td>baz</td>
7439 <td>quux
7440 </td></tr></table>
7441
7442 !! html/parsoid
7443 <table>
7444 <tbody><tr><th>foo</th><th>bar
7445 <!-- foo --></th><td> baz </td><td>quux</td></tr>
7446 </tbody></table>
7447 !! end
7448
7449 !!test
7450 Parsoid: Recover better from broken table attributes
7451 !!options
7452 parsoid=wt2html
7453 !!wikitext
7454 {| class="foo
7455 | class="bar" |
7456 foo
7457 |}
7458 !!html/php+tidy
7459 <table class="foo">
7460 <tbody><tr>
7461 <td class="bar">
7462 <p>foo
7463 </p>
7464 </td></tr></tbody></table>
7465 !!html/parsoid
7466 <table class="foo">
7467 <tr>
7468 <td class="bar">
7469 <p>foo</p></td></tr>
7470 </tbody></table>
7471 !!end
7472
7473 !! test
7474 Tables: Digest broken attributes on table and tr tag
7475 !! options
7476 parsoid=wt2html
7477 !! wikitext
7478 {| || |} ++
7479 |- || || ++ --
7480 |- > [
7481 |}
7482 !! html
7483 <table>
7484 <tbody>
7485 <tr class='mw-empty-elt'></tr>
7486 <tr class='mw-empty-elt'></tr>
7487 </tbody></table>
7488 !! end
7489
7490 !! test
7491 Table with missing opening <tr> tag
7492 !! options
7493 parsoid=wt2html,wt2wt
7494 !! wikitext
7495 <table>
7496 <td>foo</td>
7497 </tr>
7498 </table>
7499 !! html+tidy
7500 <table>
7501 <tbody><tr><td>foo</td>
7502 </tr>
7503 </tbody></table>
7504 !! end
7505
7506 # T137406: Whitespace in the HTML
7507 !! test
7508 1. Generate correct wikitext for tables with thead/tbody/tfoot
7509 !! options
7510 parsoid=html2wt
7511 !! html/parsoid
7512 <table>
7513 <caption>Test</caption>
7514 <thead>
7515 <tr>
7516 <th>Month</th>
7517 <th>Savings</th>
7518 </tr>
7519 </thead>
7520 <tbody>
7521 <tr>
7522 <td>January</td>
7523 <td>$100</td>
7524 </tr>
7525 <tr>
7526 <td>February</td>
7527 <td>$80</td>
7528 </tr>
7529 </tbody>
7530 <tfoot>
7531 <tr>
7532 <td>Sum</td>
7533 <td>$180</td>
7534 </tr>
7535 </tfoot>
7536 </table>
7537 !! wikitext
7538 {|
7539 |+Test
7540 !Month
7541 !Savings
7542 |-
7543 |January
7544 |$100
7545 |-
7546 |February
7547 |$80
7548 |-
7549 |Sum
7550 |$180
7551 |}
7552 !! html/php+tidy
7553 <table>
7554 <caption>Test
7555 </caption>
7556 <tbody><tr>
7557 <th>Month
7558 </th>
7559 <th>Savings
7560 </th></tr>
7561 <tr>
7562 <td>January
7563 </td>
7564 <td>$100
7565 </td></tr>
7566 <tr>
7567 <td>February
7568 </td>
7569 <td>$80
7570 </td></tr>
7571 <tr>
7572 <td>Sum
7573 </td>
7574 <td>$180
7575 </td></tr></tbody></table>
7576 !! end
7577
7578 # T137406: No whitespace in the HTML
7579 !! test
7580 2. Generate correct wikitext for tables with thead/tbody/tfoot
7581 !! options
7582 parsoid=html2wt
7583 !! html/parsoid
7584 <table><thead><tr><th>heading</th></tr></thead><tbody><tr><td>foo</td></tr></tbody></table>
7585 !! wikitext
7586 {|
7587 !heading
7588 |-
7589 |foo
7590 |}
7591 !! end
7592
7593 !! test
7594 Wikitext tables can be nested inside HTML tables
7595 !! options
7596 parsoid=html2wt
7597 !! html
7598 <table data-parsoid='{"stx":"html"}'>
7599 <tr><td>
7600 <table>
7601 <tr><td>foo</td></tr>
7602 </table>
7603 </td></tr>
7604 </table>
7605 !! wikitext
7606 <table>
7607 <tr><td>
7608 {|
7609 |foo
7610 |}
7611 </td></tr>
7612 </table>
7613 !! end
7614
7615 ###
7616 ### Internal links
7617 ###
7618 !! test
7619 Plain link, capitalized
7620 !! wikitext
7621 [[Main Page]]
7622 !! html
7623 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
7624 </p>
7625 !! end
7626
7627 !! test
7628 Plain link, uncapitalized
7629 !! wikitext
7630 [[main Page]]
7631 !! html
7632 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
7633 </p>
7634 !! end
7635
7636 !! test
7637 Piped link
7638 !! wikitext
7639 [[Main Page|The Main Page]]
7640 !! html
7641 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7642 </p>
7643 !! end
7644
7645 !! test
7646 Piped link with comment in link text
7647 !! wikitext
7648 [[Main Page|The Main<!--front--> Page]]
7649 !! html
7650 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7651 </p>
7652 !! end
7653
7654 !! test
7655 Piped link with multiple pipe characters in link text
7656 !! wikitext
7657 [[Main Page||The|Main|Page|]]
7658 !! html/php
7659 <p><a href="/wiki/Main_Page" title="Main Page">|The|Main|Page|</a>
7660 </p>
7661 !! html/parsoid
7662 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">|The|Main|Page|</a></p>
7663 !! end
7664
7665 !! test
7666 Piped link with no link text
7667 !! wikitext
7668 [[Thomas Bek (bishop of St David's)|]]
7669 !! html/php
7670 <p>[[Thomas Bek (bishop of St David's)|]]
7671 </p>
7672 !! html/parsoid
7673 <p>[[Thomas Bek (bishop of St David's)|]]</p>
7674 !! end
7675
7676 !! test
7677 Piped link with empty link text
7678 !! wikitext
7679 [[Main Page|<nowiki/>]] - empty nowiki
7680 [[Main Page| ]] - empty space
7681 [[Main Page|&nbsp;]] - empty non breaking space
7682 !! html/php
7683 <p><a href="/wiki/Main_Page" title="Main Page"></a> - empty nowiki
7684 <a href="/wiki/Main_Page" title="Main Page"> </a> - empty space
7685 <a href="/wiki/Main_Page" title="Main Page">&#160;</a> - empty non breaking space
7686 </p>
7687 !! html/parsoid
7688 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:Nowiki"></span></a> - empty nowiki
7689 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page"> </a> - empty space
7690 <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>
7691 !! end
7692
7693 !! test
7694 Broken link
7695 !! wikitext
7696 [[Zigzagzogzagzig]]
7697 !! html
7698 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig</a>
7699 </p>
7700 !! end
7701
7702 !! test
7703 Broken link with fragment
7704 !! wikitext
7705 [[Zigzagzogzagzig#zug]]
7706 !! html
7707 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig#zug</a>
7708 </p>
7709 !! end
7710
7711 !! test
7712 Special page link with fragment
7713 !! wikitext
7714 [[Special:Version#anchor]]
7715 !! html
7716 <p><a href="/wiki/Special:Version#anchor" title="Special:Version">Special:Version#anchor</a>
7717 </p>
7718 !! end
7719
7720 !! test
7721 Nonexistent special page link with fragment
7722 !! wikitext
7723 [[Special:ThisNameWillHopefullyNeverBeUsed#anchor]]
7724 !! html
7725 <p><a href="/wiki/Special:ThisNameWillHopefullyNeverBeUsed" class="new" title="Special:ThisNameWillHopefullyNeverBeUsed (page does not exist)">Special:ThisNameWillHopefullyNeverBeUsed#anchor</a>
7726 </p>
7727 !! end
7728
7729 !! test
7730 Link with prefix
7731 !! wikitext
7732 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
7733 !! html
7734 <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>
7735 </p>
7736 !! end
7737
7738 !! test
7739 Link with suffix
7740 !! wikitext
7741 [[Main Page]]xxx, [[Main Page]]XXX, [[Main Page]]!!!
7742 !! html
7743 <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>!!!
7744 </p>
7745 !! end
7746
7747 !! article
7748 prefixed article
7749 !! text
7750 Some text
7751 !! endarticle
7752
7753 !! test
7754 T45661: Piped links with identical prefixes
7755 !! wikitext
7756 [[prefixed article|prefixed articles with spaces]]
7757
7758 [[prefixed article|prefixed articlesaoeu]]
7759
7760 [[Main Page|Main Page test]]
7761 !! html
7762 <p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articles with spaces</a>
7763 </p><p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articlesaoeu</a>
7764 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page test</a>
7765 </p>
7766 !! end
7767
7768
7769 !! test
7770 Link with HTML entity in suffix / tail
7771 !! wikitext
7772 [[Main Page]]&quot;, [[Main Page]]&#97;
7773 !! html/php
7774 <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;
7775 </p>
7776 !! html/parsoid
7777 <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>
7778 !! end
7779
7780 !! test
7781 Link with 3 brackets
7782 !! wikitext
7783 [[[Main Page]]]
7784 Foo [[[Main Page]]]
7785 !! html
7786 <p>[[[Main Page]]]
7787 Foo [[[Main Page]]]
7788 </p>
7789 !! end
7790
7791 !! test
7792 Link with 4 brackets
7793 !! wikitext
7794 [[[[Main Page]]]]
7795 !! html
7796 <p>[[<a href="/wiki/Main_Page" title="Main Page">Main Page</a>]]
7797 </p>
7798 !! end
7799
7800 !! test
7801 Piped link with 3 brackets
7802 !! wikitext
7803 [[[main page|the main page]]]
7804 !! html
7805 <p>[[[main page|the main page]]]
7806 </p>
7807 !! end
7808
7809 !! test
7810 Piped link with extlink-like text
7811 !! wikitext
7812 [[Main Page|[bar]]]
7813 [[Main Page|This is a [bar]]]
7814 [[Main Page|[bar]]
7815 !! html/php
7816 <p><a href="/wiki/Main_Page" title="Main Page">[bar]</a>
7817 <a href="/wiki/Main_Page" title="Main Page">This is a [bar]</a>
7818 <a href="/wiki/Main_Page" title="Main Page">[bar</a>
7819 </p>
7820 !! html/parsoid
7821 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar]</a>
7822 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>This is a [bar]</a>
7823 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar</a></p>
7824 !! end
7825
7826 !! test
7827 Link with multiple pipes
7828 !! wikitext
7829 [[Main Page|The|Main|Page]]
7830 !! html
7831 <p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a>
7832 </p>
7833 !! end
7834
7835 !! test
7836 Anchor containing a #. (T65430)
7837 !! config
7838 wgFragmentMode=[ 'html5', 'legacy' ]
7839 !! wikitext
7840 [[Main Page#And#Link]]
7841 !! html/php
7842 <p><a href="/wiki/Main_Page#And#Link" title="Main Page">Main Page#And#Link</a>
7843 </p>
7844 !! html/parsoid
7845 <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>
7846 !! end
7847
7848 !! test
7849 Link to namespaces
7850 !! wikitext
7851 [[Talk:Parser testing]], [[Meta:Disclaimers]]
7852 !! html
7853 <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>
7854 </p>
7855 !! end
7856
7857 !! test
7858 Link with space in namespace
7859 !! wikitext
7860 [[User talk:Foo bar]]
7861 !! html
7862 <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>
7863 </p>
7864 !! end
7865
7866 !! article
7867 MemoryAlpha:AlphaTest
7868 !! text
7869 This is an article in the MemoryAlpha namespace
7870 (which shadows the memoryalpha interwiki link).
7871 !! endarticle
7872
7873 !! test
7874 Namespace takes precedence over interwiki link (T53680)
7875 !! wikitext
7876 [[MemoryAlpha:AlphaTest]]
7877 !! html
7878 <p><a href="/wiki/MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a>
7879 </p>
7880 !! end
7881
7882 # The previous test doesn't work correctly in html2*, due to not recognizing the
7883 # link as an internal one. This one checks for the correct behavior.
7884 !! test
7885 Link to namespace preferred over interwiki with correct rel attribute
7886 !! options
7887 parsoid=html2wt,html2html
7888 !! html/parsoid
7889 <p><a rel="mw:WikiLink" href="./MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a></p>
7890 !! wikitext
7891 [[MemoryAlpha:AlphaTest]]
7892 !! end
7893
7894 !! test
7895 Piped link to namespace
7896 !! wikitext
7897 [[Meta:Disclaimers|The disclaimers]]
7898 !! html
7899 <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>
7900 </p>
7901 !! end
7902
7903 !! test
7904 Link containing }
7905 !! wikitext
7906 [[Usually caused by a typo (oops}]]
7907 !! html
7908 <p>[[Usually caused by a typo (oops}]]
7909 </p>
7910 !! end
7911
7912 !! article
7913 7% Solution
7914 !! text
7915 Just a test of an article title containing a percent.
7916 !! endarticle
7917
7918 !! test
7919 Link containing % (not as a hex sequence)
7920 !! wikitext
7921 [[7% Solution]]
7922 [[7% Solution|7%25 Solution]]
7923 !! html/php
7924 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
7925 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
7926 </p>
7927 !! html/parsoid
7928 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
7929 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
7930 !! end
7931
7932 # note that the parsoid HTML is identical to the previous test output,
7933 # so the previous test ensures that the html2wt mode will generate the
7934 # "not as a hex sequence" wikitext.
7935 !! test
7936 Link containing % as a single hex sequence interpreted to char
7937 !! options
7938 parsoid=wt2wt,wt2html,html2html
7939 !! wikitext
7940 [[7%25 Solution]]
7941 [[7%25 Solution|7%25 Solution]]
7942 !! html/php
7943 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
7944 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
7945 </p>
7946 !! html/parsoid
7947 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
7948 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
7949 !!end
7950
7951 !! test
7952 Link containing % as a double hex sequence interpreted to hex sequence
7953 !! wikitext
7954 [[7%2525 Solution]]
7955 !! html
7956 <p>[[7%2525 Solution]]
7957 </p>
7958 !!end
7959
7960 ## Example for such a section: == < ==
7961 !! test
7962 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors
7963 !! config
7964 wgFragmentMode=[ 'html5', 'legacy' ]
7965 !! wikitext
7966 [[%23%3c]][[%23%3e]]
7967 !! html/php
7968 <p><a href="#&lt;">#&lt;</a><a href="#&gt;">#&gt;</a>
7969 </p>
7970 !! html/parsoid
7971 <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>
7972 !! end
7973
7974 ## Example for such a section: == < ==
7975 !! test
7976 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors (legacy)
7977 !! config
7978 wgFragmentMode=[ 'legacy' ]
7979 !! wikitext
7980 [[%23%3c]][[%23%3e]]
7981 !! html/php
7982 <p><a href="#.3C">#&lt;</a><a href="#.3E">#&gt;</a>
7983 </p>
7984 !! end
7985
7986 !! test
7987 Link containing "<#" and ">#" as a hex sequences
7988 !! wikitext
7989 [[%3c%23]][[%3e%23]]
7990 !! html
7991 <p>[[%3c%23]][[%3e%23]]
7992 </p>
7993 !! end
7994
7995 !! test
7996 Link containing an equals sign
7997 !! wikitext
7998 [[Special:BookSources/isbn=4-00-026157-6]]
7999 !! html/php
8000 <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>
8001 </p>
8002 !! html/parsoid
8003 <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>
8004 !! end
8005
8006 !! article
8007 Foo~bar
8008 !! text
8009 Just a test of an article title containing a tilde.
8010 !! endarticle
8011
8012 # note that links containing signatures, like [[Foo~~~~]], are
8013 # massaged by the pre-save transform (PST) and so the tildes are never
8014 # seen by the parser.
8015 !! test
8016 Link containing a tilde
8017 !! wikitext
8018 [[Foo~bar]]
8019 !! html/php
8020 <p><a href="/wiki/Foo~bar" title="Foo~bar">Foo~bar</a>
8021 </p>
8022 !! html/parsoid
8023 <p><a rel="mw:WikiLink" href="./Foo~bar" title="Foo~bar">Foo~bar</a></p>
8024 !! end
8025
8026 !! test
8027 Link containing double-single-quotes '' (T6598)
8028 !! wikitext
8029 [[Lista d''e paise d''o munno]]
8030 !! html/php
8031 <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>
8032 </p>
8033 !! html/parsoid
8034 <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>
8035 !! end
8036
8037 !! test
8038 Link containing double quotes and spaces
8039 !! wikitext
8040 [[Cool "Gator"]]
8041 !! html/php
8042 <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>
8043 </p>
8044 !! html/parsoid
8045 <p><a rel="mw:WikiLink" href='./Cool_"Gator"' title='Cool "Gator"'>Cool "Gator"</a></p>
8046 !! end
8047
8048 !! test
8049 File containing double quotes and spaces
8050 !! wikitext
8051 [[File:Cool "Gator".png]]
8052 !! html/parsoid
8053 <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>
8054 !! end
8055
8056 !! test
8057 Redirect containing double quotes and spaces
8058 !! wikitext
8059 #REDIRECT [[Cool "Gator"]]
8060 !! html/parsoid
8061 <link rel="mw:PageProp/redirect" href="./Cool_%22Gator%22" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Cool_%22Gator%22"},"sa":{"href":"Cool \"Gator\""}}'/>
8062 !! end
8063
8064 !! test
8065 Link containing double-single-quotes '' in text (T6598 sanity check)
8066 !! wikitext
8067 Some [[Link|pretty ''italics'' and stuff]]!
8068 !! html/php
8069 <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>!
8070 </p>
8071 !! html/parsoid
8072 <p>Some <a rel="mw:WikiLink" href="./Link" title="Link">pretty <i>italics</i> and stuff</a>!</p>
8073 !! end
8074
8075 !! test
8076 Link containing double-single-quotes '' in text embedded in italics (T6598 sanity check)
8077 !! wikitext
8078 ''Some [[Link|pretty ''italics'' and stuff]]!''
8079 !! html
8080 <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>
8081 </p>
8082 !! end
8083
8084 !! test
8085 Link with double quotes in title part (literal) and alternate part (interpreted)
8086 !! wikitext
8087 [[File:Denys_Savchenko_''Pentecoste''.jpg]]
8088
8089 [[''Pentecoste'']]
8090
8091 [[''Pentecoste''|Pentecoste]]
8092
8093 [[''Pentecoste''|''Pentecoste'']]
8094 !! html/php
8095 <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>
8096 </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>
8097 </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>
8098 </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>
8099 </p>
8100 !! html/parsoid
8101 <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>
8102 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">''Pentecoste''</a></p>
8103 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">Pentecoste</a></p>
8104 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''"><i>Pentecoste</i></a></p>
8105 !! end
8106
8107 !! test
8108 Broken image links with HTML captions (T41700)
8109 !! wikitext
8110 [[File:Nonexistent|<script></script>]]
8111 [[File:Nonexistent|100x100px|<script></script>]]
8112 [[File:Nonexistent|&lt;]]
8113 [[File:Nonexistent|a<i>b</i>c]]
8114 !! html/php
8115 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8116 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8117 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;</a>
8118 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">abc</a>
8119 </p>
8120 !! html/parsoid
8121 <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>
8122 <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>
8123 <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>
8124 <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>
8125 !! end
8126
8127 !! test
8128 Plain link to URL
8129 !! wikitext
8130 [[http://www.example.com]]
8131 !! html/php
8132 <p>[<a rel="nofollow" class="external autonumber" href="http://www.example.com">[1]</a>]
8133 </p>
8134 !! html/parsoid
8135 <p>[<a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com"></a>]</p>
8136 !! end
8137
8138 !! test
8139 Plain link to URL with link text
8140 !! wikitext
8141 [[http://www.example.com Link text]]
8142 !! html
8143 <p>[<a rel="nofollow" class="external text" href="http://www.example.com">Link text</a>]
8144 </p>
8145 !! end
8146
8147 !! test
8148 Plain link to protocol-relative URL
8149 !! wikitext
8150 [[//www.example.com]]
8151 !! html/php
8152 <p>[<a rel="nofollow" class="external autonumber" href="//www.example.com">[1]</a>]
8153 </p>
8154 !! html/parsoid
8155 <p>[<a rel="mw:ExtLink" class="external autonumber" href="//www.example.com"></a>]</p>
8156 !! end
8157
8158 !! test
8159 Plain link to protocol-relative URL with link text
8160 !! wikitext
8161 [[//www.example.com Link text]]
8162 !! html
8163 <p>[<a rel="nofollow" class="external text" href="//www.example.com">Link text</a>]
8164 </p>
8165 !! end
8166
8167 !! test
8168 Plain link to page with question mark in title
8169 !! wikitext
8170 [[A?b]]
8171
8172 [[A?b|Baz]]
8173 !! html
8174 <p><a href="/wiki/A%3Fb" title="A?b">A?b</a>
8175 </p><p><a href="/wiki/A%3Fb" title="A?b">Baz</a>
8176 </p>
8177 !! end
8178
8179 # I'm fairly sure the expected result here is wrong.
8180 # We want these to be URL links, not pseudo-pages with URLs for titles....
8181 # However the current output is also pretty screwy.
8182 #
8183 # ----
8184 # I'm changing it to match the current output--it arguably makes more
8185 # sense in the light of the test above. Old expected result was:
8186 #<p>Piped link to URL: <a href="/index.php?title=Http://www.example.com&amp;action=edit" class="new">an example URL</a>
8187 #</p>
8188 # But I think this test is bordering on "garbage in, garbage out" anyway.
8189 # -- wtm
8190 !! test
8191 Piped link to URL
8192 !! wikitext
8193 Piped link to URL: [[http://www.example.com|an example URL]]
8194 !! html/php
8195 <p>Piped link to URL: [<a rel="nofollow" class="external text" href="http://www.example.com%7Can">example URL</a>]
8196 </p>
8197 !! html/parsoid
8198 <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>
8199 !! end
8200
8201 !! test
8202 Plain link in template argument
8203 !! options
8204 parsoid=wt2html
8205 !! wikitext
8206 {{echo|[http://www.example.com |123]}}
8207
8208 {{echo|[[http://www.example.com |123]]}}
8209
8210 {{echo|[[http://www.example.com |123]}}
8211
8212 {{echo|[http://www.example.com |123]]}}
8213 !! html/php
8214 <p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8215 </p><p>[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>]
8216 </p><p>{{echo|[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>}}
8217 </p><p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8218 </p>
8219 !! html/parsoid
8220 <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>
8221
8222 <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>
8223
8224 <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>
8225
8226 <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>
8227 !! end
8228
8229 !! test
8230 T2002: [[page|http://url/]] should link to page, not http://url/
8231 !! wikitext
8232 [[Main Page|http://url/]]
8233 !! html/php
8234 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
8235 </p>
8236 !! html/parsoid
8237 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">http://url/</a></p>
8238 !! end
8239
8240 # Parsoid does not mark self-links, by design.
8241 !! test
8242 T2337: Escaped self-links should be bold
8243 !! options
8244 title=[[Bug462]]
8245 !! wikitext
8246 [[Bu&#103;462]] [[Bug462]]
8247 !! html/php+tidy
8248 <p><a class="mw-selflink selflink">Bu&#103;462</a> <a class="mw-selflink selflink">Bug462</a>
8249 </p>
8250 !! html/parsoid
8251 <p><a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a> <a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a></p>
8252 !! end
8253
8254 !! test
8255 Self-link to section should not be bold
8256 !! options
8257 title=[[Main Page]]
8258 !! wikitext
8259 [[Main Page#section]]
8260 !! html
8261 <p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
8262 </p>
8263 !! end
8264
8265 !! article
8266 00
8267 !! text
8268 This is 00.
8269 !! endarticle
8270
8271 !!test
8272 Self-link to numeric title
8273 !!options
8274 title=[[0]]
8275 !! wikitext
8276 [[0]]
8277 !! html
8278 <p><a class="mw-selflink selflink">0</a>
8279 </p>
8280 !!end
8281
8282 !!test
8283 Link to numeric-equivalent title
8284 !!options
8285 title=[[0]]
8286 !! wikitext
8287 [[00]]
8288 !! html
8289 <p><a href="/wiki/00" title="00">00</a>
8290 </p>
8291 !!end
8292
8293 !! test
8294 <nowiki> inside a link
8295 !! wikitext
8296 [[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
8297 !! html
8298 <p>[[Main Page]] <a href="/wiki/Main_Page" title="Main Page">the main page [it's not very good]</a>
8299 </p>
8300 !! end
8301
8302 !! test
8303 Non-breaking spaces in title
8304 !! wikitext
8305 [[&nbsp; Main &nbsp; Page &nbsp;]]
8306 !! html
8307 <p><a href="/wiki/Main_Page" title="Main Page">&#160; Main &#160; Page &#160;</a>
8308 </p>
8309 !!end
8310
8311 # Add new article for the test below so that it doesn't red-link
8312 !! article
8313 Foo bar baz
8314 !! text
8315 boo
8316 !! endarticle
8317
8318 !! test
8319 Multiple spaces in titles should normalize to a single underscore
8320 !! options
8321 parsoid=wt2html,wt2wt
8322 !! wikitext
8323 [[Foo bar baz|x]]
8324 [[Foo bar baz|x]]
8325 [[Foo bar baz|x]]
8326 !! html/php
8327 <p><a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8328 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8329 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8330 </p>
8331 !! html/parsoid
8332 <p><a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8333 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8334 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8335 </p>
8336 !! end
8337
8338 !! test
8339 Internal link with ca linktrail, surrounded by bold apostrophes (T29473 primary issue)
8340 !! options
8341 language=ca
8342 !! wikitext
8343 '''[[Main Page]]'''
8344 !! html
8345 <p><b><a href="/wiki/Main_Page" title="Main Page">Main Page</a></b>
8346 </p>
8347 !! end
8348
8349 !! test
8350 Internal link with ca linktrail, surrounded by italic apostrophes (T29473 primary issue)
8351 !! options
8352 language=ca
8353 !! wikitext
8354 ''[[Main Page]]''
8355 !! html
8356 <p><i><a href="/wiki/Main_Page" title="Main Page">Main Page</a></i>
8357 </p>
8358 !! end
8359
8360 !! test
8361 Internal link with en linktrail: no apostrophes (T29473)
8362 !! options
8363 language=en
8364 !! wikitext
8365 [[Something]]'nice
8366 !! html
8367 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (page does not exist)">Something</a>'nice
8368 </p>
8369 !! end
8370
8371 !! test
8372 Internal link with ca linktrail with apostrophes (T29473)
8373 !! options
8374 language=ca
8375 !! wikitext
8376 [[Something]]'nice
8377 !! html
8378 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (encara no existeix)">Something'nice</a>
8379 </p>
8380 !! end
8381
8382 !! test
8383 Internal link with kaa linktrail with apostrophes (T29473)
8384 !! options
8385 language=kaa
8386 !! wikitext
8387 [[Something]]'nice
8388 !! html
8389 <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>
8390 </p>
8391 !! end
8392
8393 !! test
8394 Link with multiple ":" in a subpage-supporting namespace (T65636)
8395 !! wikitext
8396 [[User:Foo/Test/63636:Bar|Test]]
8397 !! html/php
8398 <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>
8399 </p>
8400 !! html/parsoid
8401 <p><a rel="mw:WikiLink" href="./User:Foo/Test/63636:Bar" title="User:Foo/Test/63636:Bar">Test</a></p>
8402 !! end
8403
8404 ## Mainly a sanity check for Parsoid
8405 !! test
8406 Handle title parsing for subpages
8407 !! options
8408 title=[[/123123]]
8409 subpage
8410 !! wikitext
8411 123
8412 !! html/php
8413 <p>123
8414 </p>
8415 !! html/parsoid
8416 <p>123</p>
8417 !! end
8418
8419 !! article
8420 User:Test/123
8421 !! text
8422 test 123
8423 !! endarticle
8424
8425 !! test
8426 Link to a subpage from a namespace other than main
8427 !! options
8428 title=[[User:Test]]
8429 subpage
8430 !! wikitext
8431 [[/123]]
8432 !! html/php
8433 <p><a href="/wiki/User:Test/123" title="User:Test/123">/123</a>
8434 </p>
8435 !! html/parsoid
8436 <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>
8437 !! end
8438
8439 !! test
8440 Ensure that transclusion titles are not url-decoded
8441 !! options
8442 subpage title=[[Test]]
8443 parsoid=wt2html
8444 !! wikitext
8445 {{Bar%C3%A9}} {{/Bar%C3%A9}}
8446 !! html/php
8447 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}
8448 </p>
8449 !! html/parsoid
8450 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}</p>
8451 !! end
8452
8453 !! test
8454 Purely hash wikilink
8455 !! options
8456 title=[[User:Test/123]]
8457 subpage
8458 !! wikitext
8459 [[#a|b]]
8460 !! html/php
8461 <p><a href="#a">b</a>
8462 </p>
8463 !! html/parsoid
8464 <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>
8465 !! end
8466
8467 !! test
8468 Serialization of purely hash wikilink
8469 !! options
8470 title=[[User:Test/123]]
8471 subpage
8472 parsoid=html2wt
8473 !! html/parsoid
8474 <p><a href="#a">[[</a></p>
8475 !! wikitext
8476 [[#a|<nowiki>[[</nowiki>]]
8477 !! html/php
8478 <p><a href="#a">[[</a>
8479 </p>
8480 !! end
8481
8482 !! test
8483 1. Interaction of linktrail and template encapsulation
8484 !! wikitext
8485 {{echo|[[Foo]]}}l
8486 !! html/parsoid
8487 <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>
8488 !! end
8489
8490 !! test
8491 2. Interaction of linktrail and template encapsulation
8492 !! options
8493 parsoid
8494 !! wikitext
8495 {{echo|Some [[Fool]]}}s
8496 !! html
8497 <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>
8498 !! end
8499
8500 !! test
8501 3. Interaction of linktrail and template encapsulation
8502 !! options
8503 parsoid
8504 !! wikitext
8505 {{echo|Some [[Fool]]s are '''bold and foolish'''}}
8506 !! html
8507 <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>
8508 !! end
8509
8510 !! article
8511 Söfnuður
8512 !! text
8513 Test.
8514 !! endarticle
8515
8516 !! test
8517 Internal link with is link prefix
8518 !! options
8519 language=is
8520 !! wikitext
8521 Aðrir mótmælenda[[söfnuður|söfnuðir]] og
8522 !! html
8523 <p>Aðrir <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a> og
8524 </p>
8525 !! end
8526
8527 !! article
8528 Mótmælendatrú
8529 !! text
8530 Test.
8531 !! endarticle
8532
8533 !! test
8534 Internal link with is link trail and link prefix
8535 !! options
8536 language=is
8537 !! wikitext
8538 [[mótmælendatrú|xxx]]ar
8539 [[mótmælendatrú]]ar
8540 mótmælenda[[söfnuður]]
8541 mótmælenda[[söfnuður|söfnuðir]]
8542 mótmælenda[[söfnuður|söfnuðir]]xxx
8543 !! html
8544 <p><a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">xxxar</a>
8545 <a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">mótmælendatrúar</a>
8546 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuður</a>
8547 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a>
8548 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðirxxx</a>
8549 </p>
8550 !! end
8551
8552 !! test
8553 Parsoid link trail escaping
8554 !! options
8555 parsoid=html2wt,html2html
8556 !! html/parsoid
8557 <p><a rel="mw:WikiLink" href="./Apple" title="Apple">apple</a>s</p>
8558 !! wikitext
8559 [[apple]]<nowiki/>s
8560 !! end
8561
8562 !! test
8563 Parsoid link prefix escaping
8564 !! options
8565 language=is
8566 parsoid=html2wt,html2html
8567 !! html/parsoid
8568 <p>Aðrir mótmælenda<a rel="mw:WikiLink" href="./Söfnuður" title="Söfnuður">söfnuður</a></p>
8569 !! wikitext
8570 Aðrir mótmælenda<nowiki/>[[söfnuður]]
8571 !! end
8572
8573 !! test
8574 Parsoid link bracket escaping
8575 !! options
8576 parsoid=html2wt,html2html
8577 !! html/parsoid
8578 <p><a rel="mw:WikiLink" href="./Test" title="Test">Test</a></p>
8579 <p>[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]</p>
8580 <p>[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]</p>
8581 <p>[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]</p>
8582 <p>[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]</p>
8583 <p>[[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]]</p>
8584 !! wikitext
8585 [[Test]]
8586
8587 [<nowiki/>[[Test]]]
8588
8589 [[[[Test]]]]
8590
8591 [[[<nowiki/>[[Test]]]]]
8592
8593 [[[[[[Test]]]]]]
8594
8595 [[[[[<nowiki/>[[Test]]]]]]]
8596 !! end
8597
8598 !! test
8599 Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved
8600 !! wikitext
8601 [[Foo| bar]]
8602
8603 [[Foo| ''bar'']]
8604
8605 [http://wp.org foo]
8606
8607 [http://wp.org ''foo'']
8608 !! html
8609 <p><a href="/wiki/Foo" title="Foo"> bar</a>
8610 </p><p><a href="/wiki/Foo" title="Foo"> <i>bar</i></a>
8611 </p><p><a rel="nofollow" class="external text" href="http://wp.org">foo</a>
8612 </p><p><a rel="nofollow" class="external text" href="http://wp.org"><i>foo</i></a>
8613 </p>
8614 !! end
8615
8616 !! test
8617 Parsoid: Scoped parsing should handle mixed transclusions and plain text
8618 !! wikitext
8619 [[Foo|{{echo|a}} b {{echo|c}}]]
8620 !! html/parsoid
8621 <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>
8622 !! end
8623
8624 !! test
8625 Link with angle bracket after anchor
8626 !! config
8627 wgFragmentMode=[ 'html5', 'legacy' ]
8628 !! wikitext
8629 [[Foo#<bar>]]
8630 !! html/php
8631 <p><a href="/wiki/Foo#&lt;bar&gt;" title="Foo">Foo#&lt;bar&gt;</a>
8632 </p>
8633 !! html/parsoid
8634 <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>
8635 !! end
8636
8637 !! test
8638 Link with angle bracket after anchor (legacy)
8639 !! config
8640 wgFragmentMode=[ 'legacy' ]
8641 !! wikitext
8642 [[Foo#<bar>]]
8643 !! html/php
8644 <p><a href="/wiki/Foo#.3Cbar.3E" title="Foo">Foo#&lt;bar&gt;</a>
8645 </p>
8646 !! end
8647
8648 ###
8649 ### Interwiki links (see maintenance/interwiki.sql)
8650 ###
8651
8652 !! test
8653 Inline interwiki link
8654 !! options
8655 parsoid=wt2html,wt2wt,html2html
8656 !! wikitext
8657 [[MeatBall:SoftSecurity]]
8658 !! html/php
8659 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
8660 </p>
8661 !! html/parsoid
8662 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a></p>
8663 !! end
8664
8665 !! test
8666 Inline interwiki link with empty title (T4372)
8667 !! options
8668 parsoid=wt2html,wt2wt,html2html
8669 !! wikitext
8670 [[MeatBall:]]
8671 !! html/php
8672 <p><a href="http://www.usemod.com/cgi-bin/mb.pl" class="extiw" title="meatball:">MeatBall:</a>
8673 </p>
8674 !! html/parsoid
8675 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?" title="meatball:">MeatBall:</a></p>
8676 !! end
8677
8678 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
8679 !! test
8680 Interwiki link encoding conversion (T3636)
8681 !! options
8682 parsoid=wt2html,wt2wt
8683 !! wikitext
8684 *[[Wikipedia:ro:Olteni&#0355;a]]
8685 *[[Wikipedia:ro:Olteni&#355;a]]
8686 !! html
8687 <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>
8688 <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>
8689
8690 !! html/php+tidy
8691 <ul>
8692 <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>
8693 <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>
8694 </ul>
8695 !! html/parsoid
8696 <ul>
8697 <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>
8698 <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>
8699 </ul>
8700 !! end
8701
8702 !! test
8703 Interwiki link with fragment (T4130)
8704 !! wikitext
8705 [[MeatBall:SoftSecurity#foo]]
8706 !! html
8707 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity#foo</a>
8708 </p>
8709 !! end
8710
8711 !! test
8712 Link scenarios with escaped fragments
8713 !! config
8714 wgFragmentMode=[ 'html5', 'legacy' ]
8715 !! wikitext
8716 [[#Is this great?]]
8717 [[Foo#Is this great?]]
8718 [[meatball:Foo#Is this great?]]
8719 !! html/php
8720 <p><a href="#Is_this_great?">#Is this great?</a>
8721 <a href="/wiki/Foo#Is_this_great?" title="Foo">Foo#Is this great?</a>
8722 <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>
8723 </p>
8724 !! html/parsoid
8725 <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>
8726 <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>
8727 <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>
8728 !! end
8729
8730 !! test
8731 Link scenarios with escaped fragments (legacy)
8732 !! config
8733 wgFragmentMode=[ 'legacy' ]
8734 !! wikitext
8735 [[#Is this great?]]
8736 [[Foo#Is this great?]]
8737 [[meatball:Foo#Is this great?]]
8738 !! html/php
8739 <p><a href="#Is_this_great.3F">#Is this great?</a>
8740 <a href="/wiki/Foo#Is_this_great.3F" title="Foo">Foo#Is this great?</a>
8741 <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>
8742 </p>
8743 !! end
8744
8745 # Ideally the wikipedia: prefix here should be proto-relative too
8746 # [CSA]: this is kind of a bogus test, as the PHP parser test doesn't
8747 # define the 'en' prefix, and originally the test used 'wikipedia',
8748 # which isn't a localinterwiki prefix hence the links to the 'en:Foo'
8749 # article.
8750 !! test
8751 Different interwiki prefixes mapping to the same URL
8752 !! wikitext
8753 [[:en:Foo]]
8754
8755 [[:en:Foo|Foo]]
8756
8757 [[wikipedia:Foo]]
8758
8759 [[:wikipedia:Foo|Foo]]
8760
8761 [[wikipedia:en:Foo]]
8762
8763 [[:wikipedia:en:Foo]]
8764
8765 [[ wikiPEdia :Foo]]
8766 !! html/parsoid
8767 <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>
8768
8769 <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>
8770
8771 <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>
8772
8773 <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>
8774
8775 <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>
8776
8777 <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>
8778
8779 <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>
8780 !! end
8781
8782 !! test
8783 Interwiki links that cannot be represented in wiki syntax
8784 !! wikitext
8785 [[meatball:ok]]
8786 [[meatball:ok#foo|ok with fragment]]
8787 [[meatball:ok_as_well?|ok ending with ? mark]]
8788 [http://de.wikipedia.org/wiki/Foo?action=history has query]
8789 [http://de.wikipedia.org/wiki/#foo is just fragment]
8790
8791 !! html/php
8792 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?ok" class="extiw" title="meatball:ok">meatball:ok</a>
8793 <a href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" class="extiw" title="meatball:ok">ok with fragment</a>
8794 <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>
8795 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8796 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a>
8797 </p>
8798 !! html/parsoid
8799 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok" title="meatball:ok">meatball:ok</a>
8800 <a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" title="meatball:ok">ok with fragment</a>
8801 <a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok_as_well?" title="meatball:ok as well?">ok ending with ? mark</a>
8802 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8803 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a></p>
8804 !! end
8805
8806 !! test
8807 Interwiki links: trail
8808 !! wikitext
8809 [[wikipedia:Foo|Ba]]r
8810 !! html/php
8811 <p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
8812 </p>
8813 !! html/parsoid
8814 <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>
8815 !! end
8816
8817 !! test
8818 Local interwiki link
8819 !! options
8820 parsoid=wt2html,wt2wt,html2html
8821 !! wikitext
8822 [[local:Template:Foo]]
8823 !! html/php
8824 <p><a href="/wiki/Template:Foo" title="Template:Foo">local:Template:Foo</a>
8825 </p>
8826 !! html/parsoid
8827 <p><a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">local:Template:Foo</a></p>
8828 !! end
8829
8830 # Parsoid does not mark self-links, by design.
8831 !! test
8832 Local interwiki link: self-link to current page
8833 !! options
8834 title=[[Main Page]]
8835 parsoid=wt2html,wt2wt,html2html
8836 !! wikitext
8837 [[local:Main Page]]
8838 !! html/php
8839 <p><a class="mw-selflink selflink">local:Main Page</a>
8840 </p>
8841 !! html/parsoid
8842 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:Main Page</a></p>
8843 !! end
8844
8845 !! test
8846 Local interwiki link: prefix only (T66167)
8847 !! options
8848 parsoid=wt2html,wt2wt,html2html
8849 !! wikitext
8850 [[local:]]
8851 !! html/php
8852 <p><a href="/wiki/Main_Page" title="Main Page">local:</a>
8853 </p>
8854 !! html/parsoid
8855 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:</a></p>
8856 !! end
8857
8858 !! test
8859 Local interwiki link: with additional interwiki prefix (T63357)
8860 !! options
8861 parsoid=wt2html,wt2wt,html2html
8862 !! wikitext
8863 [[local:meatball:Hello]]
8864 !! html/php
8865 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Hello" class="extiw" title="meatball:Hello">local:meatball:Hello</a>
8866 </p>
8867 !! html/parsoid
8868 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?Hello" title="meatball:Hello">local:meatball:Hello</a></p>
8869 !! end
8870
8871 !! test
8872 Multiple local interwiki link prefixes
8873 !! wikitext
8874 [[local:local:local:local:mi:local:Foo]]
8875 !! options
8876 parsoid=wt2html,wt2wt,html2html
8877 !! html/php
8878 <p><a href="/wiki/Foo" title="Foo">local:local:local:local:mi:local:Foo</a>
8879 </p>
8880 !! html/parsoid
8881 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">local:local:local:local:mi:local:Foo</a></p>
8882 !! end
8883
8884 ###
8885 ### Interlanguage links
8886 ### Language links (so that searching for '### language' matches..)
8887 ###
8888
8889 !! test
8890 Interlanguage link
8891 !! wikitext
8892 Blah blah blah
8893 [[zh:Chinese]]
8894 !! html/php
8895 <p>Blah blah blah
8896 </p>
8897 !! html/parsoid
8898 <p>Blah blah blah</p>
8899 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8900 !! end
8901
8902 ## parsoid html2wt will lose the space variations
8903 !! test
8904 Interlanguage link with spacing
8905 !! options
8906 parsoid=wt2html,wt2wt,html2html
8907 !! wikitext
8908 Blah blah blah
8909 [[ zh : Chinese ]]
8910 !! html/php
8911 <p>Blah blah blah
8912 </p>
8913 !! html/parsoid
8914 <p>Blah blah blah</p>
8915 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8916 !! end
8917
8918 !! test
8919 Double interlanguage link
8920 !! wikitext
8921 Blah blah blah
8922 [[es:Spanish]]
8923 [[zh:Chinese]]
8924 !! html/php
8925 <p>Blah blah blah
8926 </p>
8927 !! html/parsoid
8928 <p>Blah blah blah</p>
8929 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
8930 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8931 !! end
8932
8933 ## parsoid html2wt will lose the space variations
8934 !! test
8935 Interlanguage link variations
8936 !! options
8937 parsoid=wt2html,wt2wt,html2html
8938 !! wikitext
8939 Blah blah blah
8940 [[ es :Spanish]]
8941 [[ ZH :Chinese]]
8942 [[es:Foo_bar]]
8943 !! html/php
8944 <p>Blah blah blah
8945 </p>
8946 !! html/parsoid
8947 <p>Blah blah blah</p>
8948 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish" />
8949 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese" />
8950 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar" />
8951 !! end
8952
8953 !! test
8954 Escaping of interlanguage links (T129218, T156308)
8955 !! wikitext
8956 Blah blah blah
8957 [[:es:Spanish]]
8958 [[ : zh : Chinese ]]
8959 !! html/php
8960 <p>Blah blah blah
8961 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
8962 <a href="http://zh.wikipedia.org/wiki/Chinese" class="extiw" title="zh:Chinese"> zh : Chinese </a>
8963 </p>
8964 !! html/parsoid
8965 <p>Blah blah blah
8966 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
8967 <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh : Chinese </a></p>
8968 !! end
8969
8970 !! test
8971 Multiple colons escaping interlanguage links
8972 !! options
8973 parsoid=wt2html
8974 !! wikitext
8975 [[:es:Spanish]]
8976 [[::es:Spanish]]
8977 [[:::es:Spanish]]
8978 !! html/php
8979 <p><a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
8980 [[::es:Spanish]]
8981 [[:::es:Spanish]]
8982 </p>
8983 !! html/parsoid
8984 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
8985 [[::es:Spanish]]
8986 [[:::es:Spanish]]</p>
8987 !! end
8988
8989 ## parsoid html2wt will normalize the space to _
8990 !! test
8991 Space and question mark encoding in interlanguage links (T95473)
8992 !! options
8993 parsoid=wt2html,wt2wt,html2html
8994 !! wikitext
8995 Blah blah blah
8996 [[es:Foo bar?]]
8997 !! html/php
8998 <p>Blah blah blah
8999 </p>
9000 !! html/parsoid
9001 <p>Blah blah blah</p>
9002 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar%3F" />
9003 !! end
9004
9005 !! test
9006 Interlanguage link, with prefix links
9007 !! options
9008 language=ln
9009 !! wikitext
9010 Blah blah blah
9011 [[zh:Chinese]]
9012 !! html/php
9013 <p>Blah blah blah
9014 </p>
9015 !! html/parsoid
9016 <p>Blah blah blah</p>
9017 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9018 !! end
9019
9020 !! test
9021 Double interlanguage link, with prefix links (T10897)
9022 !! options
9023 language=ln
9024 !! wikitext
9025 Blah blah blah
9026 [[es:Spanish]]
9027 [[zh:Chinese]]
9028 !! html/php
9029 <p>Blah blah blah
9030 </p>
9031 !! html/parsoid
9032 <p>Blah blah blah</p>
9033 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
9034 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9035 !! end
9036
9037 !! test
9038 "Extra" interlanguage links (T34189 / gerrit 111390)
9039 !! wikitext
9040 Blah blah blah
9041 [[mul:Article]]
9042 !! html/php
9043 <p>Blah blah blah
9044 </p>
9045 !! html/parsoid
9046 <p>Blah blah blah</p>
9047 <link rel="mw:PageProp/Language" title="Multilingual" href="http://wikisource.org/wiki/Article"/>
9048 !! end
9049
9050 ## PHP parser tests script needs an update
9051 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
9052 !! test
9053 Language links render as inline links if $wgInterwikiMagic=false
9054 !! options
9055 wgInterwikiMagic=false
9056 parsoid=wt2html,wt2wt,html2html
9057 !! wikitext
9058 Blah blah blah
9059 [[zh:Chinese]]
9060 !! html/parsoid
9061 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
9062 !! end
9063
9064 ## PHP parser tests script needs an update
9065 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
9066 !! test
9067 Language links render as inline links in the Talk namespace
9068 !! options
9069 title=Talk:Foo
9070 parsoid=wt2html,wt2wt,html2html
9071 !! wikitext
9072 Blah blah blah
9073 [[zh:Chinese]]
9074 !! html/parsoid
9075 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
9076 !! end
9077
9078 !! test
9079 Parsoid-specific test: Wikilinks with &nbsp; should RT properly
9080 !! options
9081 language=ln
9082 !! wikitext
9083 [[WW&nbsp;II]]
9084 !! html
9085 <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>
9086 </p>
9087 !! end
9088
9089 !! test
9090 Parsoid T55221: Wikilinks should be properly entity-escaped
9091 !! options
9092 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
9093 !! html/parsoid
9094 <p>He&amp;nbsp;llo <a href="./Foo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9095 <p>He&amp;nbsp;llo <a href="./He&amp;nbsp;llo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9096 !! wikitext
9097 He&amp;nbsp;llo [[Foo|He&amp;nbsp;llo]]
9098
9099 He&amp;nbsp;llo He&amp;nbsp;llo
9100 !! html/php
9101 <p>He&amp;nbsp;llo <a href="/wiki/Foo" title="Foo">He&amp;nbsp;llo</a>
9102 </p><p>He&amp;nbsp;llo He&amp;nbsp;llo
9103 </p>
9104 !! end
9105
9106 # html2wt will fail because of title normalization without data-parsoid
9107 !! test
9108 Parsoid: handle constructor well
9109 !! options
9110 parsoid=wt2html,wt2wt
9111 !! wikitext
9112 [[constructor]]
9113
9114 [[constructor:foo]]
9115 !! html/php
9116 <p><a href="/index.php?title=Constructor&amp;action=edit&amp;redlink=1" class="new" title="Constructor (page does not exist)">constructor</a>
9117 </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>
9118 </p>
9119 !! html/parsoid
9120 <p><a rel="mw:WikiLink" href="./Constructor" title="Constructor" data-parsoid='{"stx":"simple","a":{"href":"./Constructor"},"sa":{"href":"constructor"}}'>constructor</a></p>
9121
9122 <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>
9123 !! end
9124
9125 !! test
9126 Template parameter named "constructor"
9127 !! wikitext
9128 {{echo| constructor = |hi}}
9129 !! html/parsoid
9130 <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>
9131 !! end
9132
9133 !! article
9134 ko:
9135 !! text
9136 Test.
9137 !! endarticle
9138
9139 # Note that `ko` isn't a known interlanguage prefix
9140 !! test
9141 Parsoid: recognize interlanguage links without a target page
9142 !! options
9143 ill
9144 !! wikitext
9145 [[es:]]
9146
9147 [[ko:]]
9148 !! html/php
9149 es:
9150 !! html/parsoid
9151 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/"/>
9152
9153 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9154 !! end
9155
9156 # Note that `ko` isn't a known interwiki prefix
9157 !! test
9158 Parsoid: recognize interwiki links without a target page
9159 !! options
9160 parsoid=wt2html,wt2wt,html2html
9161 !! wikitext
9162 [[:es:]]
9163
9164 [[:ko:]]
9165 !! html/php
9166 <p><a href="http://es.wikipedia.org/wiki/" class="extiw" title="es:">es:</a>
9167 </p><p><a href="/wiki/Ko:" title="Ko:">ko:</a>
9168 </p>
9169 !! html/parsoid
9170 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/" title="es:">es:</a></p>
9171 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9172 !! end
9173
9174 !! test
9175 Handle interwiki links pointing to the current wiki as plain wiki links (T47209)
9176 !! wikitext
9177 [[mi:Foo]]
9178 !! html/php
9179 <p><a href="/wiki/Foo" title="Foo">mi:Foo</a>
9180 </p>
9181 !! html/parsoid
9182 <p><a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo"},"sa":{"href":"mi:Foo"}}'>mi:Foo</a></p>
9183 !! end
9184
9185 !! test
9186 Interlanguage link with preceding local interwiki link (T70085)
9187 !! options
9188 parsoid=wt2html,wt2wt,html2html
9189 !! wikitext
9190 Blah blah blah
9191 [[local:es:Spanish]]
9192 !! html/php
9193 <p>Blah blah blah
9194 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">local:es:Spanish</a>
9195 </p>
9196 !! html/parsoid
9197 <p>Blah blah blah
9198 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">local:es:Spanish</a></p>
9199 !! end
9200
9201 !! test
9202 Looks like an interlanguage link, but is actually a local interwiki
9203 !! options
9204 parsoid=wt2html,wt2wt,html2html
9205 !! wikitext
9206 Blah blah blah
9207 [[mi:Template:Foo]]
9208 !! html/php
9209 <p>Blah blah blah
9210 <a href="/wiki/Template:Foo" title="Template:Foo">mi:Template:Foo</a>
9211 </p>
9212 !! html/parsoid
9213 <p>Blah blah blah
9214 <a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">mi:Template:Foo</a></p>
9215 !! end
9216
9217 ###
9218 ### Redirects, Parsoid-only
9219 ###
9220
9221 !! test
9222 1. Simple redirect to page
9223 !! wikitext
9224 #REDIRECT [[Main Page]]
9225 !! html/parsoid
9226 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9227 !! end
9228
9229 !! test
9230 2. Other redirect variants
9231 !! wikitext
9232 #REDIRECT [[Main_Page]]
9233 !! html/parsoid
9234 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Main_Page"},"sa":{"href":"Main_Page"}}'/>
9235 !! end
9236
9237 # Not a valid redirect in PHP (although perhaps it was, once upon a time)
9238 # This tests the Parsoid bail-out code.
9239 !! test
9240 3. Other redirect variants
9241 !! options
9242 parsoid=wt2html
9243 !! wikitext
9244 #REDIRECT [[<nowiki>[[Bar]]</nowiki>]]
9245 !! html/parsoid
9246 <ol><li>REDIRECT [[<span typeof="mw:Nowiki">[[Bar]]</span>]]</li></ol>
9247 !! end
9248
9249 !! test
9250 4. Redirect to a templated destination
9251 !! wikitext
9252 #REDIRECT [[{{echo|Foo}}bar]]
9253 !! html/parsoid
9254 <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"}]]}'/>
9255 !! end
9256
9257 !! test
9258 Empty redirect
9259 !! options
9260 parsoid=wt2html,wt2wt
9261 !! wikitext
9262 #REDIRECT [[]]
9263 !! html/parsoid
9264 <ol>
9265 <li>REDIRECT [[]]</li></ol>
9266 !! end
9267
9268 !! test
9269 Optional colon in #REDIRECT
9270 !! options
9271 # the colon is archaic syntax. we support it for wt2html, but we
9272 # don't care that it roundtrips back to the modern syntax.
9273 parsoid=wt2html,html2html
9274 !! wikitext
9275 #REDIRECT:[[Main Page]]
9276 !! html/parsoid
9277 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9278 !! end
9279
9280 !! test
9281 Whitespace in #REDIRECT with optional colon
9282 !! options
9283 # the colon and gratuitous whitespace is archaic syntax. we support
9284 # it for wt2html, but we don't care that it roundtrips back to the
9285 # modern syntax (without extra whitespace)
9286 parsoid=wt2html,html2html
9287 !! wikitext
9288
9289 #REDIRECT
9290 :
9291 [[Main Page]]
9292 !! html/parsoid
9293 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9294 !! end
9295
9296 !! test
9297 Piped link in #REDIRECT
9298 !! options
9299 # content after piped link is ignored. we support this syntax,
9300 # but don't care that the piped link is lost when we roundtrip this.
9301 parsoid=wt2html
9302 !! wikitext
9303 #REDIRECT [[Main Page|bar]]
9304 !! html/parsoid
9305 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9306 !! end
9307
9308 !! test
9309 Redirect to category (T104502)
9310 !! options
9311 parsoid=wt2html,wt2wt
9312 !! wikitext
9313 #REDIRECT [[Category:Foo]]
9314 !! html/parsoid
9315 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9316 !! end
9317
9318 !! test
9319 Redirect to category with URL encoding (T104502)
9320 !! options
9321 parsoid=wt2html
9322 !! wikitext
9323 #REDIRECT [[Category%3AFoo]]
9324 !! html/parsoid
9325 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9326 !! end
9327
9328 !! test
9329 Redirect to category page
9330 !! wikitext
9331 #REDIRECT [[:Category:Foo]]
9332 !! html/parsoid
9333 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9334 !! end
9335
9336 !! test
9337 Redirect to image page (1)
9338 !! wikitext
9339 #REDIRECT [[File:Wiki.png]]
9340 !! html/parsoid
9341 <link rel="mw:PageProp/redirect" href="./File:Wiki.png"/>
9342 !! end
9343
9344 !! test
9345 Redirect to image page (2)
9346 !! wikitext
9347 #REDIRECT [[Image:Wiki.png]]
9348 !! html/parsoid
9349 <link rel="mw:PageProp/redirect" href="./File:Wiki.png" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./File:Wiki.png"},"sa":{"href":"Image:Wiki.png"}}'/>
9350 !! end
9351
9352 # html2wt disabled because wts serializes as "#REDIRECT [[:en:File:Wiki.png]]"
9353 # Next test confirms this.
9354 !! test
9355 Redirect to language (1) (T104918)
9356 !! options
9357 parsoid=wt2html,wt2wt,html2html
9358 !! wikitext
9359 #REDIRECT [[en:File:Wiki.png]]
9360 !! html/parsoid
9361 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9362 !! end
9363
9364 !! test
9365 Redirect to language (2) (T104918)
9366 !! wikitext
9367 #REDIRECT [[:en:File:Wiki.png]]
9368 !! html/parsoid
9369 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9370 !! end
9371
9372 !! test
9373 Redirect to interwiki (T104918)
9374 !! wikitext
9375 #REDIRECT [[meatball:File:Wiki.png]]
9376 !! html/parsoid
9377 <link rel="mw:PageProp/redirect" href="http://www.usemod.com/cgi-bin/mb.pl?File:Wiki.png"/>
9378 !! end
9379
9380 !! test
9381 Non-English #REDIRECT
9382 !! options
9383 language=is
9384 !! wikitext
9385 #TILVÍSUN [[Main Page]]
9386 !! html/parsoid
9387 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#TILVÍSUN ","a":{"href":"./Main_Page"},"sa":{"href":"Main Page"}}'/>
9388 !! end
9389
9390 !! test
9391 Redirect syntax under text isn't considered a redirect
9392 !! wikitext
9393 some text
9394
9395 #redirect [[Main Page]]
9396 !! html/parsoid
9397 <p>some text</p>
9398 <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>
9399 !! end
9400
9401 !! test
9402 New redirect
9403 !! options
9404 parsoid=html2wt
9405 !! html/parsoid
9406 <p>Foo<link rel="mw:PageProp/redirect" href="./Foo"/></p>
9407 !! wikitext
9408 #REDIRECT [[Foo]]
9409 Foo
9410 !! end
9411
9412 !! test
9413 Redirect followed by block on the same line
9414 !! options
9415 parsoid=wt2html
9416 !! wikitext
9417 #REDIRECT [[Main Page]]<!-- haha -->==hi==
9418 !! html/parsoid
9419 <link rel="mw:PageProp/redirect" href="./Main_Page"/><!-- haha --><h2 id="hi">hi</h2>
9420 !! end
9421
9422 !! test
9423 Redirect followed by a newline
9424 !! wikitext
9425 #REDIRECT [[Main Page]]
9426 A newline
9427 !! html/parsoid
9428 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9429 <p>A newline</p>
9430 !! end
9431
9432 !! test
9433 Redirect followed by multiple newlines
9434 !! wikitext
9435 #REDIRECT [[Main Page]]
9436
9437
9438 A newline
9439 !! html/parsoid
9440 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9441
9442 <p><br/>
9443 A newline</p>
9444 !! end
9445
9446 !! test
9447 Drop duplicate redirects
9448 !! options
9449 parsoid=html2wt
9450 !! html/parsoid
9451 <link rel="mw:PageProp/redirect" href="./Foo"/>
9452 <link rel="mw:PageProp/redirect" href="./Bar"/>
9453 <link rel="mw:PageProp/redirect" href="./Baz"/>
9454 !! wikitext
9455 #REDIRECT [[Foo]]
9456 !! end
9457
9458 ##
9459 ## XHTML tidiness
9460 ###
9461
9462 !! test
9463 <br> to <br />
9464 !! wikitext
9465 1<br>2<br />3
9466 !! html
9467 <p>1<br />2<br />3
9468 </p>
9469 !! end
9470
9471 !! test
9472 Broken br tag sanitization
9473 !! wikitext
9474 </br>
9475 !! html/php
9476 <p>&lt;/br&gt;
9477 </p>
9478 !! end
9479
9480 # TODO: Fix html2html mode (T53055)!
9481 !! test
9482 Parsoid: Broken br tag recognition
9483 !! options
9484 parsoid=wt2html
9485 !! wikitext
9486 </br>
9487
9488 <br/ >
9489 !! html+tidy
9490 <p><br />
9491 </p><p><br />
9492 </p>
9493 !! end
9494
9495 !! test
9496 Incorrecly removing closing slashes from correctly formed XHTML
9497 !! wikitext
9498 <br style="clear:both;" />
9499 !! html
9500 <p><br style="clear:both;" />
9501 </p>
9502 !! end
9503
9504 !! test
9505 Failing to transform badly formed HTML into correct XHTML
9506 !! wikitext
9507 <br style="clear: left;">
9508 <br style="clear: right;">
9509 <br style="clear: both;">
9510 !! html
9511 <p><br style="clear: left;" />
9512 <br style="clear: right;" />
9513 <br style="clear: both;" />
9514 </p>
9515 !!end
9516
9517 ## FIXME: Is Parsoid's acceptance of self-closing html-tags
9518 ## a feature or a bug? See https://phabricator.wikimedia.org/T76962
9519 !! test
9520 Handling html with a div self-closing tag
9521 !! wikitext
9522 <div title />
9523 <div title/>
9524 <div title/ >
9525 <div title=bar />
9526 <div title=bar/>
9527 <div title=bar/ >
9528 !! html/php
9529 <p>&lt;div title /&gt;
9530 &lt;div title/&gt;
9531 </p>
9532 <div>
9533 <p>&lt;div title=bar /&gt;
9534 &lt;div title=bar/&gt;
9535 </p>
9536 <div title="bar/"></div>
9537 </div>
9538
9539 !! html/parsoid
9540 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9541 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9542 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9543 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9544 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9545 <div title="bar/" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></div>
9546 !! end
9547
9548 !! test
9549 Handling html with a br self-closing tag
9550 !! wikitext
9551 <br title />
9552 <br title/>
9553 <br title/ >
9554 <br title=bar />
9555 <br title=bar/>
9556 <br title=bar/ >
9557 !! html/php
9558 <p><br title="" />
9559 <br title="" />
9560 <br />
9561 <br title="bar" />
9562 <br title="bar" />
9563 <br title="bar/" />
9564 </p>
9565 !! html/parsoid
9566 <p><br title="" />
9567 <br title="" />
9568 <br title="" />
9569 <br title="bar" />
9570 <br title="bar" />
9571 <br title="bar/" />
9572 </p>
9573 !! end
9574
9575 !! test
9576 Horizontal ruler (should it add that extra space?)
9577 !! wikitext
9578 <hr>
9579 <hr >
9580 foo <hr
9581 > bar
9582 !! html+tidy
9583 <hr />
9584 <hr /><p>
9585 foo </p><hr /><p> bar
9586 </p>
9587 !! end
9588
9589 !! test
9590 Horizontal ruler -- 4+ dashes render hr
9591 !! wikitext
9592 ----
9593 !! html
9594 <hr />
9595
9596 !! end
9597
9598 !! test
9599 Horizontal ruler -- eats additional dashes on the same line
9600 !! wikitext
9601 ---------
9602 !! html
9603 <hr />
9604
9605 !! end
9606
9607 !! test
9608 Horizontal ruler -- does not collapse dashes on consecutive lines
9609 !! wikitext
9610 ----
9611 ----
9612 !! html
9613 <hr />
9614 <hr />
9615
9616 !! end
9617
9618 !! test
9619 Horizontal ruler -- <4 dashes render as plain text
9620 !! wikitext
9621 ---
9622 !! html
9623 <p>---
9624 </p>
9625 !! end
9626
9627 !! test
9628 Horizontal ruler -- Supports content following dashes on same line
9629 !! wikitext
9630 ---- Foo
9631 !! html
9632 <hr /> Foo
9633
9634 !! html+tidy
9635 <hr /><p> Foo
9636 </p>
9637 !! end
9638
9639 ###
9640 ### Block-level elements
9641 ###
9642 !! test
9643 Common list
9644 !! wikitext
9645 *Common list
9646 *item 2
9647 *item 3
9648 !! html
9649 <ul><li>Common list</li>
9650 <li>item 2</li>
9651 <li>item 3</li></ul>
9652
9653 !! end
9654
9655 !! test
9656 Numbered list
9657 !! wikitext
9658 #Numbered list
9659 #item 2
9660 #item 3
9661 !! html
9662 <ol><li>Numbered list</li>
9663 <li>item 2</li>
9664 <li>item 3</li></ol>
9665
9666 !! end
9667
9668 # the switch from level 3 to ordered should not introduce a newline between
9669 !! test
9670 Mixed list
9671 !! wikitext
9672 *Mixed list
9673 *#with numbers
9674 **and bullets
9675 *#and numbers
9676 *bullets again
9677 **bullet level 2
9678 ***bullet level 3
9679 ***#Number on level 4
9680 **bullet level 2
9681 **#Number on level 3
9682 **#Number on level 3
9683 *#number level 2
9684 *Level 1
9685 ***Level 3
9686 #**Level 3, but ordered
9687 !! html
9688 <ul><li>Mixed list
9689 <ol><li>with numbers</li></ol>
9690 <ul><li>and bullets</li></ul>
9691 <ol><li>and numbers</li></ol></li>
9692 <li>bullets again
9693 <ul><li>bullet level 2
9694 <ul><li>bullet level 3
9695 <ol><li>Number on level 4</li></ol></li></ul></li>
9696 <li>bullet level 2
9697 <ol><li>Number on level 3</li>
9698 <li>Number on level 3</li></ol></li></ul>
9699 <ol><li>number level 2</li></ol></li>
9700 <li>Level 1
9701 <ul><li><ul><li>Level 3</li></ul></li></ul></li></ul>
9702 <ol><li><ul><li><ul><li>Level 3, but ordered</li></ul></li></ul></li></ol>
9703
9704 !! end
9705
9706 !! test
9707 1. Nested mixed wikitext and html list
9708 !! wikitext
9709 *hi
9710 *<ul><li>ho</li></ul>
9711 *hi
9712 **ho
9713 !! html/php
9714 <ul><li>hi</li>
9715 <li><ul><li>ho</li></ul></li>
9716 <li>hi
9717 <ul><li>ho</li></ul></li></ul>
9718
9719 !! html/parsoid
9720 <ul><li>hi</li>
9721 <li><ul data-parsoid='{"stx":"html"}'><li data-parsoid='{"stx":"html"}'>ho</li></ul></li>
9722 <li>hi
9723 <ul><li>ho</li></ul></li></ul>
9724 !! end
9725
9726 !! test
9727 2. Nested mixed wikitext and html list (incompatible)
9728 !! wikitext
9729 ;hi
9730 :{{echo|<li>ho</li>}}
9731 !! html/php
9732 <dl><dt>hi</dt>
9733 <dd><li>ho</li></dd></dl>
9734
9735 !! html/parsoid
9736 <dl><dt>hi</dt>
9737 <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>
9738 !! end
9739
9740 !! test
9741 Nested lists 1
9742 !! wikitext
9743 *foo
9744 **bar
9745 !! html
9746 <ul><li>foo
9747 <ul><li>bar</li></ul></li></ul>
9748
9749 !! end
9750
9751 !! test
9752 Nested lists 2
9753 !! wikitext
9754 **foo
9755 *bar
9756 !! html
9757 <ul><li><ul><li>foo</li></ul></li>
9758 <li>bar</li></ul>
9759
9760 !! end
9761
9762 !! test
9763 Nested lists 3 (first element empty)
9764 !! wikitext
9765 *
9766 **bar
9767 !! html
9768 <ul><li>
9769 <ul><li>bar</li></ul></li></ul>
9770
9771 !! end
9772
9773 !! test
9774 Nested lists 4 (first element empty)
9775 !! wikitext
9776 **
9777 *bar
9778 !! html
9779 <ul><li><ul><li></li></ul></li>
9780 <li>bar</li></ul>
9781
9782 !! end
9783
9784 !! test
9785 Nested lists 5 (both elements empty)
9786 !! wikitext
9787 **
9788 *
9789 !! html
9790 <ul><li><ul><li></li></ul></li>
9791 <li></li></ul>
9792
9793 !! end
9794
9795 !! test
9796 Nested lists 6 (both elements empty)
9797 !! wikitext
9798 *
9799 **
9800 !! html
9801 <ul><li>
9802 <ul><li></li></ul></li></ul>
9803
9804 !! end
9805
9806 !! test
9807 Nested lists 7 (skip initial nesting levels)
9808 !! wikitext
9809 ***foo
9810 !! html
9811 <ul><li><ul><li><ul><li>foo</li></ul></li></ul></li></ul>
9812
9813 !! end
9814
9815 !! test
9816 Nested lists 8 (multiple nesting transitions)
9817 !! wikitext
9818 *foo
9819 ***bar
9820 **baz
9821 *boo
9822 !! html
9823 <ul><li>foo
9824 <ul><li><ul><li>bar</li></ul></li>
9825 <li>baz</li></ul></li>
9826 <li>boo</li></ul>
9827
9828 !! end
9829
9830 !! test
9831 Nested lists 9 (extension interaction)
9832 !! options
9833 parsoid
9834 !! wikitext
9835 *<references />
9836 !! html/parsoid
9837 <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>
9838 !! end
9839
9840 !! test
9841 1. Lists with start-of-line-transparent tokens before bullets: Comments
9842 !! wikitext
9843 *foo
9844 *<!--cmt-->bar
9845 <!--cmt-->*baz
9846 !! html
9847 <ul><li>foo</li>
9848 <li>bar</li>
9849 <li>baz</li></ul>
9850
9851 !! end
9852
9853 !! test
9854 Nested lists 10 (list and span siblings: wt2wt regression)
9855 !! wikitext
9856 *a <span>x</span>
9857 **b <span>y</span>
9858 !! html/parsoid
9859 <ul><li>a <span>x</span>
9860 <ul><li>b <span>y</span></li></ul></li></ul>
9861 !! end
9862
9863 !! test
9864 2. Lists with start-of-line-transparent tokens before bullets: Template close
9865 !! wikitext
9866 *foo {{echo|bar
9867 }}*baz
9868 !! html
9869 <ul><li>foo bar</li>
9870 <li>baz</li></ul>
9871
9872 !! end
9873
9874 !! test
9875 List items are not parsed correctly following a <pre> block (T2785)
9876 !! wikitext
9877 *<pre>foo</pre>
9878 *<pre>bar</pre>
9879 *zar
9880 !! html/php
9881 <ul><li><pre>foo</pre></li>
9882 <li><pre>bar</pre></li>
9883 <li>zar</li></ul>
9884
9885 !! html/parsoid
9886 <ul><li><pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre></li>
9887 <li><pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"bar"}}'>bar</pre></li>
9888 <li>zar</li></ul>
9889 !! end
9890
9891 # FIXME: Might benefit from a html/parsoid since this has a template
9892 !! test
9893 List items from template
9894 !! wikitext
9895
9896 {{inner list}}
9897 *item 2
9898
9899 *item 0
9900 {{inner list}}
9901 *item 2
9902
9903 *item 0
9904 *notSOL{{inner list}}
9905 *item 2
9906 !! html
9907 <ul><li>item 1</li>
9908 <li>item 2</li></ul>
9909 <ul><li>item 0</li>
9910 <li>item 1</li>
9911 <li>item 2</li></ul>
9912 <ul><li>item 0</li>
9913 <li>notSOL</li>
9914 <li>item 1</li>
9915 <li>item 2</li></ul>
9916
9917 !! end
9918
9919 !! test
9920 List interrupted by empty line or heading
9921 !! wikitext
9922 *foo
9923
9924 **bar
9925 ==A heading==
9926 *Another list item
9927 !! html
9928 <ul><li>foo</li></ul>
9929 <ul><li><ul><li>bar</li></ul></li></ul>
9930 <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>
9931 <ul><li>Another list item</li></ul>
9932
9933 !!end
9934
9935 !! test
9936 Multiple list tags generated by templates
9937 !! wikitext
9938 {{echo|<li>}}a
9939 {{echo|<li>}}b
9940 {{echo|<li>}}c
9941 !! html
9942 <li>a
9943 <li>b
9944 <li>c</li>
9945 </li>
9946 </li>
9947
9948
9949 !! html+tidy
9950 <li>a
9951 </li><li>b
9952 </li><li>c
9953 </li>
9954 !! html/parsoid
9955 <li about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","autoInsertedEnd":true,"dsr":[0,44,null,null],"pi":[[{"k":"1"}],[{"k":"1"}],[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;li>"}},"i":0}},"a\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;li>"}},"i":1}},"b\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;li>"}},"i":2}},"c"]}'>a
9956 </li><li about="#mwt1">b
9957 </li><li about="#mwt1" data-parsoid='{"stx":"html","autoInsertedEnd":true,"dsr":[null,44,null,0]}'>c</li>
9958 !! end
9959
9960 !! test
9961 Multiple newlines in between HTML list items don't induce paragraph wrapping
9962 !! wikitext
9963 <ul>
9964 <li>hi</li>
9965
9966
9967
9968
9969 <li>ho</li>
9970 </ul>
9971
9972 <dl>
9973 <dt>hi</dt>
9974 <dd>ho<div>123</div>
9975 </dd>
9976
9977
9978 </dl>
9979 !! html/php+tidy
9980 <ul>
9981 <li>hi</li>
9982
9983
9984
9985
9986 <li>ho</li>
9987 </ul>
9988 <dl>
9989 <dt>hi</dt>
9990 <dd>ho<div>123</div>
9991 </dd>
9992
9993
9994 </dl>
9995 !! end
9996
9997 !!test
9998 Single-comment whitespace lines dont break lists, and neither do multi-comment whitespace lines
9999 !! wikitext
10000 *a
10001 <!--This line will NOT split the list-->
10002 *b
10003 <!--This line will NOT split the list either-->
10004 *c
10005 <!--foo--> <!----> <!--This line NOT split the list either-->
10006 *d
10007 !! html
10008 <ul><li>a</li>
10009 <li>b</li>
10010 <li>c</li>
10011 <li>d</li></ul>
10012
10013 !!end
10014
10015 !!test
10016 Replacing whitespace with tabs still doesn't break the list (gerrit 78327)
10017 !! wikitext
10018 *a
10019 <!--This line will NOT split the list-->
10020 *b
10021 <!--This line will NOT split the list either-->
10022 *c
10023 <!--foo--> <!----> <!--This line NOT split the list
10024 either-->
10025 *d
10026 !! html
10027 <ul><li>a</li>
10028 <li>b</li>
10029 <li>c</li>
10030 <li>d</li></ul>
10031
10032 !!end
10033
10034 # FIXME: Parsoid has a dedicated DOM pass to mimic this Tidy-specific li-hack
10035 # That pass could possibly be removed.
10036 !!test
10037 Test the li-hack (a hack from Tidy days, but doesn't work as advertised with Remex)
10038 !!options
10039 parsoid=wt2html,wt2wt
10040 !! wikitext
10041 *foo
10042 *<li>li-hack
10043 *{{echo|<li>templated li-hack}}
10044 *<!--foo--><li> unsupported li-hack with preceding comments
10045
10046 <ul>
10047 <li><li>not a li-hack
10048 </li>
10049 </ul>
10050 !! html+tidy
10051 <ul><li>foo</li>
10052 <li class="mw-empty-elt"></li><li>li-hack</li>
10053 <li class="mw-empty-elt"></li><li>templated li-hack</li>
10054 <li class="mw-empty-elt"></li><li> unsupported li-hack with preceding comments</li></ul>
10055 <ul>
10056 <li class="mw-empty-elt"></li><li>not a li-hack
10057 </li>
10058 </ul>
10059 !! html/parsoid
10060 <ul><li> foo</li>
10061 <li data-parsoid='{"stx":"html","autoInsertedEnd":true,"liHackSrc":"*"}'>li-hack</li>
10062 <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>
10063 <li data-parsoid='{"autoInsertedEnd":true}'><!--foo--></li><li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>unsupported li-hack with preceding comments</li></ul>
10064
10065 <ul data-parsoid='{"stx":"html"}'>
10066 <li class="mw-empty-elt" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></li><li data-parsoid='{"stx":"html"}'>not a li-hack
10067 </li>
10068 </ul>
10069
10070 !!end
10071
10072 !! test
10073 Parsoid: Make sure nested lists are serialized on their own line even if HTML contains no newlines
10074 !! options
10075 parsoid
10076 !! wikitext
10077 #foo
10078 ##bar
10079
10080 *foo
10081 **bar
10082
10083 :foo
10084 ::bar
10085 !! html
10086 <ol>
10087 <li>foo<ol>
10088 <li>bar</li>
10089 </ol></li>
10090 </ol><ul>
10091 <li>foo<ul>
10092 <li>bar</li>
10093 </ul></li>
10094 </ul><dl>
10095 <dd>foo<dl>
10096 <dd>bar</dd>
10097 </dl></dd>
10098 </dl>
10099 !! end
10100
10101 !! test
10102 Parsoid: Test of whitespace serialization with Templated bullets
10103 !! options
10104 parsoid=wt2html
10105 !! wikitext
10106 * {{bullet}}
10107 !! html/parsoid
10108 <ul>
10109 <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>
10110 </ul>
10111 !! end
10112
10113 # ------------------------------------------------------------------------
10114 # The next set of tests are about Parsoid's ability to handle badly nested
10115 # tags (parse, minimize scope of fixup, and roundtrip back)
10116 # ------------------------------------------------------------------------
10117
10118 # Remex and Parsoid output stems from list handling diffs because Parsoid & PHP parser.
10119 # Parsoid's list handling is more aware of block structure.
10120 !! test
10121 Unbalanced closing block tags break a list
10122 !! wikitext
10123 <div>
10124 *a</div><div>
10125 *b</div>
10126 !! html+tidy
10127 <div>
10128 <ul><li>a</li></ul></div><div>
10129 <li>b</li></div>
10130 !! html/parsoid
10131 <div><ul>
10132 <li>a</li>
10133 </ul></div>
10134 <div><ul>
10135 <li>b</li>
10136 </ul></div>
10137 !! end
10138
10139 !! test
10140 Unbalanced closing non-block tags don't break a list
10141 !! wikitext
10142 <span>
10143 *a</span><span>
10144 *b</span>
10145 !! html/php+tidy
10146 <p><span>
10147 </span></p>
10148 <ul><li>a<span></span></li>
10149 <li>b</li></ul>
10150 !! html/parsoid
10151 <span>
10152 <ul>
10153 <li>a<span></span></li>
10154 <li>b</li>
10155 </ul>
10156 </span>
10157 !! end
10158
10159 # Parsoid does some post-dom-building cleanup
10160 # which is why its output differs from Remex.
10161 !! test
10162 Unclosed formatting tags that straddle lists are closed and reopened
10163 !! options
10164 parsoid=wt2html,wt2wt,html2html
10165 !! wikitext
10166 #<s> a
10167 #b </s>
10168 !! html/php+tidy
10169 <ol><li><s> a</s></li><s>
10170 </s><li><s>b </s></li></ol>
10171 !! html/parsoid
10172 <ol><li><s> a</s></li>
10173 <li><s>b </s></li></ol>
10174 !! end
10175
10176 # Output is ugly because of all the misnested tag fixups.
10177 # Remex is wrapping p-tags around empty elements.
10178 # Parsoid has special-case handling of this pattern of
10179 # wrapping lists in formatting tags.
10180 # FIXME: Should we remove this code from Parsoid? Or add
10181 # special support in Remex? If the latter, maybe just wait
10182 # for Parsoid to become the default parser.
10183 # See T70395.
10184 !!test
10185 1. List embedded in a formatting tag
10186 !! wikitext
10187 <small>
10188 *foo
10189 </small>
10190 !! html/php+tidy
10191 <p><small>
10192 </small></p><small><ul><li>foo</li></ul></small><small></small><p><small></small>
10193 </p>
10194 !! html/parsoid
10195 <small>
10196 <ul>
10197 <li>foo</li>
10198 </ul>
10199 </small>
10200 !!end
10201
10202 # Output is ugly because of all the misnested tag fixups
10203 # Remex is wrapping p-tags around empty elements.
10204 # Parsoid has code that strips useless p-tags.
10205 !!test
10206 2. List embedded in a formatting tag in a misnested way
10207 !! wikitext
10208 <small>
10209 *a
10210 *b</small>
10211 !! html/php+tidy
10212 <p><small>
10213 </small></p><small></small><ul><small><li>a</li>
10214 </small><li><small>b</small></li></ul>
10215 !! html/parsoid
10216 <small></small>
10217 <ul><small>
10218 <li>a</li>
10219 </small>
10220 <li><small>b</small></li>
10221 </ul>
10222 !!end
10223
10224 ###
10225 ### Magic Words
10226 ###
10227
10228 # Note that the current date is hard-coded as
10229 # 1970-01-01T00:02:03Z (a Thursday)
10230 # when running parser tests. The timezone is also fixed to GMT, so
10231 # local date will be identical to current date.
10232
10233 !! test
10234 Magic Word: {{CURRENTDAY}}
10235 !! wikitext
10236 {{CURRENTDAY}}
10237 !! html
10238 <p>1
10239 </p>
10240 !! end
10241
10242 !! test
10243 Magic Word: {{CURRENTDAY2}}
10244 !! wikitext
10245 {{CURRENTDAY2}}
10246 !! html
10247 <p>01
10248 </p>
10249 !! end
10250
10251 !! test
10252 Magic Word: {{CURRENTDAYNAME}}
10253 !! wikitext
10254 {{CURRENTDAYNAME}}
10255 !! html
10256 <p>Thursday
10257 </p>
10258 !! end
10259
10260 !! test
10261 Magic Word: {{CURRENTDOW}}
10262 !! wikitext
10263 {{CURRENTDOW}}
10264 !! html
10265 <p>4
10266 </p>
10267 !! end
10268
10269 !! test
10270 Magic Word: {{CURRENTMONTH}}
10271 !! wikitext
10272 {{CURRENTMONTH}}
10273 !! html
10274 <p>01
10275 </p>
10276 !! end
10277
10278 !! test
10279 Magic Word: {{CURRENTMONTH1}}
10280 !! wikitext
10281 {{CURRENTMONTH1}}
10282 !! html
10283 <p>1
10284 </p>
10285 !! end
10286
10287 !! test
10288 Magic Word: {{CURRENTMONTHABBREV}}
10289 !! wikitext
10290 {{CURRENTMONTHABBREV}}
10291 !! html
10292 <p>Jan
10293 </p>
10294 !! end
10295
10296 !! test
10297 Magic Word: {{CURRENTMONTHNAME}}
10298 !! wikitext
10299 {{CURRENTMONTHNAME}}
10300 !! html
10301 <p>January
10302 </p>
10303 !! end
10304
10305 !! test
10306 Magic Word: {{CURRENTMONTHNAMEGEN}}
10307 !! wikitext
10308 {{CURRENTMONTHNAMEGEN}}
10309 !! html
10310 <p>January
10311 </p>
10312 !! end
10313
10314 !! test
10315 Magic Word: {{CURRENTTIME}}
10316 !! wikitext
10317 {{CURRENTTIME}}
10318 !! html
10319 <p>00:02
10320 </p>
10321 !! end
10322
10323 !! test
10324 Magic Word: {{CURRENTHOUR}}
10325 !! wikitext
10326 {{CURRENTHOUR}}
10327 !! html
10328 <p>00
10329 </p>
10330 !! end
10331
10332 !! test
10333 Magic Word: {{CURRENTWEEK}} (T6594)
10334 !! wikitext
10335 {{CURRENTWEEK}}
10336 !! html
10337 <p>1
10338 </p>
10339 !! end
10340
10341 !! test
10342 Magic Word: {{CURRENTYEAR}}
10343 !! wikitext
10344 {{CURRENTYEAR}}
10345 !! html
10346 <p>1970
10347 </p>
10348 !! end
10349
10350 !! test
10351 Magic Word: {{CURRENTTIMESTAMP}}
10352 !! wikitext
10353 {{CURRENTTIMESTAMP}}
10354 !! html
10355 <p>19700101000203
10356 </p>
10357 !! end
10358
10359 !! test
10360 Magic Words LOCAL (UTC)
10361 !! wikitext
10362 *{{LOCALMONTH}}
10363 *{{LOCALMONTH1}}
10364 *{{LOCALMONTHNAME}}
10365 *{{LOCALMONTHNAMEGEN}}
10366 *{{LOCALMONTHABBREV}}
10367 *{{LOCALDAY}}
10368 *{{LOCALDAY2}}
10369 *{{LOCALDAYNAME}}
10370 *{{LOCALYEAR}}
10371 *{{LOCALTIME}}
10372 *{{LOCALHOUR}}
10373 *{{LOCALWEEK}}
10374 *{{LOCALDOW}}
10375 *{{LOCALTIMESTAMP}}
10376 !! html
10377 <ul><li>01</li>
10378 <li>1</li>
10379 <li>January</li>
10380 <li>January</li>
10381 <li>Jan</li>
10382 <li>1</li>
10383 <li>01</li>
10384 <li>Thursday</li>
10385 <li>1970</li>
10386 <li>00:02</li>
10387 <li>00</li>
10388 <li>1</li>
10389 <li>4</li>
10390 <li>19700101000203</li></ul>
10391
10392 !! end
10393
10394 !! test
10395 Magic Word: {{FULLPAGENAME}}
10396 !! options
10397 title=[[User:Ævar Arnfjörð Bjarmason]]
10398 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10399 !! wikitext
10400 {{FULLPAGENAME}}
10401 !! html/*
10402 <p>User:Ævar Arnfjörð Bjarmason
10403 </p>
10404 !! end
10405
10406 !! test
10407 Magic Word: {{FULLPAGENAMEE}}
10408 !! options
10409 title=[[User:Ævar Arnfjörð Bjarmason]]
10410 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10411 !! wikitext
10412 {{FULLPAGENAMEE}}
10413 !! html/*
10414 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10415 </p>
10416 !! end
10417
10418 !! test
10419 Magic Word: {{TALKSPACE}}
10420 !! options
10421 title=[[User:Ævar Arnfjörð Bjarmason]]
10422 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10423 !! wikitext
10424 {{TALKSPACE}}
10425 !! html/*
10426 <p>User talk
10427 </p>
10428 !! end
10429
10430 !! test
10431 Magic Word: {{TALKSPACE}}, same namespace
10432 !! options
10433 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10434 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10435 !! wikitext
10436 {{TALKSPACE}}
10437 !! html/*
10438 <p>User talk
10439 </p>
10440 !! end
10441
10442 !! test
10443 Magic Word: {{TALKSPACE}}, main namespace
10444 !! options
10445 title=[[Parser Test]]
10446 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10447 !! wikitext
10448 {{TALKSPACE}}
10449 !! html/*
10450 <p>Talk
10451 </p>
10452 !! end
10453
10454 !! test
10455 Magic Word: {{TALKSPACEE}}
10456 !! options
10457 title=[[User:Ævar Arnfjörð Bjarmason]]
10458 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10459 !! wikitext
10460 {{TALKSPACEE}}
10461 !! html/*
10462 <p>User_talk
10463 </p>
10464 !! end
10465
10466 !! test
10467 Magic Word: {{SUBJECTSPACE}}
10468 !! options
10469 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10470 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10471 !! wikitext
10472 {{SUBJECTSPACE}}
10473 !! html/*
10474 <p>User
10475 </p>
10476 !! end
10477
10478 !! test
10479 Magic Word: {{SUBJECTSPACE}}, same namespace
10480 !! options
10481 title=[[User:Ævar Arnfjörð Bjarmason]]
10482 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10483 !! wikitext
10484 {{SUBJECTSPACE}}
10485 !! html/*
10486 <p>User
10487 </p>
10488 !! end
10489
10490 !! test
10491 Magic Word: {{SUBJECTSPACE}}, main namespace
10492 !! options
10493 title=[[Parser Test]]
10494 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10495 !! wikitext
10496 {{SUBJECTSPACE}}
10497 !! html/*
10498
10499 !! end
10500
10501 !! test
10502 Magic Word: {{SUBJECTSPACEE}}
10503 !! options
10504 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10505 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10506 !! wikitext
10507 {{SUBJECTSPACEE}}
10508 !! html/*
10509 <p>User
10510 </p>
10511 !! end
10512
10513 !! test
10514 Magic Word: {{NAMESPACE}}
10515 !! options
10516 title=[[User:Ævar Arnfjörð Bjarmason]]
10517 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10518 !! wikitext
10519 {{NAMESPACE}}
10520 !! html/*
10521 <p>User
10522 </p>
10523 !! end
10524
10525 !! test
10526 Magic Word: {{NAMESPACEE}}
10527 !! options
10528 title=[[User:Ævar Arnfjörð Bjarmason]]
10529 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10530 !! wikitext
10531 {{NAMESPACEE}}
10532 !! html/*
10533 <p>User
10534 </p>
10535 !! end
10536
10537 !! test
10538 Magic Word: {{NAMESPACENUMBER}}
10539 !! options
10540 title=[[User:Ævar Arnfjörð Bjarmason]]
10541 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10542 !! wikitext
10543 {{NAMESPACENUMBER}}
10544 !! html/*
10545 <p>2
10546 </p>
10547 !! end
10548
10549 !! test
10550 Magic Word: {{SUBPAGENAME}}
10551 !! options
10552 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10553 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10554 !! wikitext
10555 {{SUBPAGENAME}}
10556 !! html/*
10557 <p>sub ö
10558 </p>
10559 !! end
10560
10561 !! test
10562 Magic Word: {{SUBPAGENAMEE}}
10563 !! options
10564 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10565 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10566 !! wikitext
10567 {{SUBPAGENAMEE}}
10568 !! html/*
10569 <p>sub_%C3%B6
10570 </p>
10571 !! end
10572
10573 !! test
10574 Magic Word: {{ROOTPAGENAME}}
10575 !! options
10576 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10577 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10578 !! wikitext
10579 {{ROOTPAGENAME}}
10580 !! html/*
10581 <p>Ævar Arnfjörð Bjarmason
10582 </p>
10583 !! end
10584
10585 !! test
10586 Magic Word: {{ROOTPAGENAMEE}}
10587 !! options
10588 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10589 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10590 !! wikitext
10591 {{ROOTPAGENAMEE}}
10592 !! html/*
10593 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10594 </p>
10595 !! end
10596
10597 !! test
10598 Magic Word: {{BASEPAGENAME}}
10599 !! options
10600 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10601 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10602 !! wikitext
10603 {{BASEPAGENAME}}
10604 !! html/*
10605 <p>Ævar Arnfjörð Bjarmason
10606 </p>
10607 !! end
10608
10609 !! test
10610 Magic Word: {{BASEPAGENAMEE}}
10611 !! options
10612 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10613 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10614 !! wikitext
10615 {{BASEPAGENAMEE}}
10616 !! html/*
10617 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10618 </p>
10619 !! end
10620
10621 !! test
10622 Magic Word: {{TALKPAGENAME}}
10623 !! options
10624 title=[[User:Ævar Arnfjörð Bjarmason]]
10625 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10626 !! wikitext
10627 {{TALKPAGENAME}}
10628 !! html/*
10629 <p>User talk:Ævar Arnfjörð Bjarmason
10630 </p>
10631 !! end
10632
10633 !! test
10634 Magic Word: {{TALKPAGENAMEE}}
10635 !! options
10636 title=[[User:Ævar Arnfjörð Bjarmason]]
10637 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10638 !! wikitext
10639 {{TALKPAGENAMEE}}
10640 !! html/*
10641 <p>User_talk:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10642 </p>
10643 !! end
10644
10645 !! test
10646 Magic Word: {{SUBJECTPAGENAME}}
10647 !! options
10648 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10649 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10650 !! wikitext
10651 {{SUBJECTPAGENAME}}
10652 !! html/*
10653 <p>User:Ævar Arnfjörð Bjarmason
10654 </p>
10655 !! end
10656
10657 !! test
10658 Magic Word: {{SUBJECTPAGENAMEE}}
10659 !! options
10660 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10661 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10662 !! wikitext
10663 {{SUBJECTPAGENAMEE}}
10664 !! html/*
10665 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10666 </p>
10667 !! end
10668
10669 !! test
10670 Magic Word: {{NUMBEROFFILES}}
10671 !! options
10672 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10673 !! wikitext
10674 {{NUMBEROFFILES}}
10675 !! html/*
10676 <p>7
10677 </p>
10678 !! end
10679
10680 !! test
10681 Magic Word: {{PAGENAME}}
10682 !! options
10683 title=[[User:Ævar Arnfjörð Bjarmason]]
10684 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10685 !! wikitext
10686 {{PAGENAME}}
10687 !! html/*
10688 <p>Ævar Arnfjörð Bjarmason
10689 </p>
10690 !! end
10691
10692 !! test
10693 Magic Word: {{PAGENAME}} with metacharacters
10694 !! options
10695 title=[['foo & bar = baz']]
10696 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10697 !! wikitext
10698 ''{{PAGENAME}}''
10699 !! html+tidy
10700 <p><i>&#39;foo &#38; bar &#61; baz&#39;</i>
10701 </p>
10702 !! end
10703
10704 !! test
10705 Magic Word: {{PAGENAME}} with metacharacters (T28781)
10706 !! options
10707 title=[[*RFC 1234 http://example.com/]]
10708 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10709 !! wikitext
10710 {{PAGENAME}}
10711 !! html+tidy
10712 <p>&#42;RFC&#32;1234 http&#58;//example.com/
10713 </p>
10714 !! end
10715
10716 !! test
10717 Magic Word: {{PAGENAMEE}}
10718 !! options
10719 title=[[User:Ævar Arnfjörð Bjarmason]]
10720 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10721 !! wikitext
10722 {{PAGENAMEE}}
10723 !! html/*
10724 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10725 </p>
10726 !! end
10727
10728 !! test
10729 Magic Word: {{PAGENAMEE}} with metacharacters (T28781)
10730 !! options
10731 title=[[*RFC 1234 http://example.com/]]
10732 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10733 !! wikitext
10734 {{PAGENAMEE}}
10735 !! html+tidy
10736 <p>&#42;RFC_1234_http&#58;//example.com/
10737 </p>
10738 !! end
10739
10740 !! test
10741 Magic Word: {{REVISIONID}}
10742 !! options
10743 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10744 showflags
10745 !! wikitext
10746 {{REVISIONID}}
10747 !! html/*
10748 <p>1337
10749 </p>
10750 flags=vary-revision-id
10751 !! end
10752
10753 !! test
10754 Magic Word: {{SCRIPTPATH}}
10755 !! options
10756 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10757 !! wikitext
10758 {{SCRIPTPATH}}
10759 !! html/*
10760
10761 !! end
10762
10763 !! test
10764 Magic Word: {{STYLEPATH}}
10765 !! options
10766 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10767 !! wikitext
10768 {{STYLEPATH}}
10769 !! html/*
10770 <p>/skins
10771 </p>
10772 !! end
10773
10774 !! test
10775 Magic Word: {{SERVER}}
10776 !! options
10777 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10778 !! wikitext
10779 {{SERVER}}
10780 !! html/*
10781 <p><a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10782 </p>
10783 !! end
10784
10785 !! test
10786 Magic Word: {{SERVERNAME}}
10787 !! options
10788 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10789 !! wikitext
10790 {{SERVERNAME}}
10791 !! html/*
10792 <p>example.org
10793 </p>
10794 !! end
10795
10796 !! test
10797 Magic Word: {{SITENAME}}
10798 !! options
10799 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10800 !! wikitext
10801 {{SITENAME}}
10802 !! html/*
10803 <p>MediaWiki
10804 </p>
10805 !! end
10806
10807 !! test
10808 Magic Word: {{PAGELANGUAGE}}
10809 !! options
10810 language=fr
10811 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10812 !! wikitext
10813 {{PAGELANGUAGE}}
10814 !! html/*
10815 <p>fr
10816 </p>
10817 !! end
10818
10819 !! test
10820 Magic Word: {{PAGELANGUAGE}} on a page with no explicitly set language
10821 !! options
10822 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10823 !! wikitext
10824 {{PAGELANGUAGE}}
10825 !! html/*
10826 <p>en
10827 </p>
10828 !! end
10829
10830 !! test
10831 Case-sensitive magic words, when cased differently, should just be template transclusions
10832 !! wikitext
10833 {{CurrentMonth}}
10834 {{currentday}}
10835 {{cURreNTweEK}}
10836 {{currentHour}}
10837 !! html
10838 <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>
10839 <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>
10840 <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>
10841 <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>
10842 </p>
10843 !! end
10844
10845 !! test
10846 Case-insensitive magic words should still work with weird casing.
10847 !! wikitext
10848 {{sErVeRNaMe}}
10849 {{LCFirst:AOEU}}
10850 {{ucFIRST:aoeu}}
10851 {{SERver}}
10852 !! html
10853 <p>example.org
10854 aOEU
10855 Aoeu
10856 <a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10857 </p>
10858 !! end
10859
10860 # From plwiki:PLOS_ONE
10861 !! test
10862 Parsoid: Page property magic word with magic word contents
10863 !! wikitext
10864 {{DISPLAYTITLE:''{{PAGENAME}}''}}
10865 !! html/parsoid
10866 <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>"}]]}'/>
10867 !! end
10868
10869 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
10870 # But, this is a limitation of our representation and is documented in
10871 # TemplateHandler.js in processSpecialMagicWord
10872 !! test
10873 Parsoid: Template-generated DISPLAYTITLE
10874 !! wikitext
10875 {{{{echo|DISPLAYTITLE}}:Foo}}
10876 !! options
10877 showtitle
10878 !! config
10879 wgAllowDisplayTitle=true
10880 wgRestrictDisplayTitle=false
10881 !! html/php
10882 Foo
10883
10884 !! html/parsoid
10885 <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"}]]}'/>
10886 !! end
10887
10888 !! test
10889 Namespace 1 {{ns:1}}
10890 !! wikitext
10891 {{ns:1}}
10892 !! html
10893 <p>Talk
10894 </p>
10895 !! end
10896
10897 !! test
10898 Namespace 1 {{ns:01}}
10899 !! wikitext
10900 {{ns:01}}
10901 !! html
10902 <p>Talk
10903 </p>
10904 !! end
10905
10906 !! test
10907 Namespace 0 {{ns:0}} (T6783)
10908 !! wikitext
10909 {{ns:0}}
10910 !! html
10911
10912 !! end
10913
10914 !! test
10915 Namespace 0 {{ns:00}} (T6783)
10916 !! wikitext
10917 {{ns:00}}
10918 !! html
10919
10920 !! end
10921
10922 !! test
10923 Namespace -1 {{ns:-1}}
10924 !! wikitext
10925 {{ns:-1}}
10926 !! html
10927 <p>Special
10928 </p>
10929 !! end
10930
10931 !! test
10932 Namespace User {{ns:User}}
10933 !! wikitext
10934 {{ns:User}}
10935 !! html
10936 <p>User
10937 </p>
10938 !! end
10939
10940 !! test
10941 Namespace User talk {{ns:User_talk}}
10942 !! wikitext
10943 {{ns:User_talk}}
10944 !! html
10945 <p>User talk
10946 </p>
10947 !! end
10948
10949 !! test
10950 Namespace User talk {{ns:uSeR tAlK}}
10951 !! wikitext
10952 {{ns:uSeR tAlK}}
10953 !! html
10954 <p>User talk
10955 </p>
10956 !! end
10957
10958 !! test
10959 Namespace File {{ns:File}}
10960 !! wikitext
10961 {{ns:File}}
10962 !! html
10963 <p>File
10964 </p>
10965 !! end
10966
10967 !! test
10968 Namespace File {{ns:Image}}
10969 !! wikitext
10970 {{ns:Image}}
10971 !! html
10972 <p>File
10973 </p>
10974 !! end
10975
10976 !! test
10977 Namespace (lang=de) Benutzer {{ns:User}}
10978 !! options
10979 language=de
10980 !! wikitext
10981 {{ns:User}}
10982 !! html
10983 <p>Benutzer
10984 </p>
10985 !! end
10986
10987 !! test
10988 Namespace (lang=de) Benutzer Diskussion {{ns:3}}
10989 !! options
10990 language=de
10991 !! wikitext
10992 {{ns:3}}
10993 !! html
10994 <p>Benutzer Diskussion
10995 </p>
10996 !! end
10997
10998 !! test
10999 Urlencode
11000 !! wikitext
11001 {{urlencode:hi world?!}}
11002 {{urlencode:hi world?!|WIKI}}
11003 {{urlencode:hi world?!|PATH}}
11004 {{urlencode:hi world?!|QUERY}}
11005 !! html/php
11006 <p>hi+world%3F%21
11007 hi_world%3F!
11008 hi%20world%3F%21
11009 hi+world%3F%21
11010 </p>
11011 !! end
11012
11013 !! test
11014 Magic Word: prioritize type info over data-parsoid
11015 !! options
11016 parsoid=html2wt
11017 !! html/parsoid
11018 <meta property="mw:PageProp/forcetoc" data-parsoid='{"magicSrc":"__NOTOC__"}'/>
11019 !! wikitext
11020 __FORCETOC__
11021 !! end
11022
11023 !! test
11024 Magic Word: serialize on separate line (parsoid)
11025 !! options
11026 parsoid=wt2wt,html2wt
11027 !! wikitext
11028 foo
11029 __NOTOC__
11030 bar
11031 !! html/parsoid
11032 foo<meta property="mw:PageProp/notoc"/>bar
11033 !! end
11034
11035 !! test
11036 Magic Word: rt non-english wikis
11037 !! options
11038 parsoid=wt2wt
11039 language=de
11040 !! wikitext
11041 __NOEDITSECTION__
11042 !! html/parsoid
11043 <meta property="mw:PageProp/noeditsection" data-parsoid='{"magicSrc":"__NOEDITSECTION__"}'/>
11044 !! end
11045
11046 !!test
11047 __proto__ is treated as normal wikitext (T105997)
11048 !!wikitext
11049 __proto__
11050 !!html
11051 <p>__proto__
11052 </p>
11053 !!end
11054
11055 ###
11056 ### Magic links
11057 ###
11058 !! test
11059 Magic links: internal link to RFC (T2479)
11060 !! wikitext
11061 [[RFC 123]]
11062 !! html/php
11063 <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>
11064 </p>
11065 !! html/parsoid
11066 <p><a rel="mw:WikiLink" href="./RFC_123" title="RFC 123">RFC 123</a></p>
11067 !! end
11068
11069 !! test
11070 Magic links: RFC (T2479)
11071 !! wikitext
11072 RFC 822
11073 !! html/php
11074 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
11075 </p>
11076 !! html/parsoid
11077 <p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external mw-magiclink">RFC 822</a></p>
11078 !! end
11079
11080 !! test
11081 Magic links: RFC (T67278)
11082 !! wikitext
11083 This is RFC 822 but thisRFC 822 is not RFC 822linked.
11084 !! html/php
11085 <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.
11086 </p>
11087 !! html/parsoid
11088 <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>
11089 !! end
11090
11091 !! test
11092 Magic links: RFC (w/ non-newline whitespace, T30950/T31025)
11093 !! wikitext
11094 RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 822
11095 RFC
11096 822
11097 !! html/php
11098 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
11099 RFC
11100 822
11101 </p>
11102 !! html/parsoid
11103 <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>
11104 RFC
11105 822</p>
11106 !! end
11107
11108 !! test
11109 Magic links: ISBN (T3937)
11110 !! wikitext
11111 ISBN 0-306-40615-2
11112 !! html/php
11113 <p><a href="/wiki/Special:BookSources/0306406152" class="internal mw-magiclink-isbn">ISBN 0-306-40615-2</a>
11114 </p>
11115 !! html/parsoid
11116 <p><a href="./Special:BookSources/0306406152" rel="mw:WikiLink">ISBN 0-306-40615-2</a></p>
11117 !! end
11118
11119 !! test
11120 Magic links: ISBN (T67278)
11121 !! wikitext
11122 This is ISBN 978-0-316-09811-3 but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.
11123 !! html/php
11124 <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.
11125 </p>
11126 !! html/parsoid
11127 <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>
11128 !! end
11129
11130 !! test
11131 Magic links: ISBN (w/ non-newline whitespace, T30950/T31025)
11132 !! wikitext
11133 ISBN &nbsp;&#160;&#0160;&#xA0;&#Xa0; 978&nbsp;0&#160;316&#0160;09811&#xA0;3
11134 ISBN
11135 9780316098113
11136 ISBN 978
11137 0316098113
11138 !! html/php
11139 <p><a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978 0 316 09811 3</a>
11140 ISBN
11141 9780316098113
11142 ISBN 978
11143 0316098113
11144 </p>
11145 !! html/parsoid
11146 <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>
11147 ISBN
11148 9780316098113
11149 ISBN 978
11150 0316098113</p>
11151 !! end
11152
11153 !! test
11154 Magic links: PMID incorrectly converts space to underscore
11155 !! wikitext
11156 PMID 1234
11157 !! html/php
11158 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11159 </p>
11160 !! html/parsoid
11161 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external mw-magiclink">PMID 1234</a></p>
11162 !! end
11163
11164 !! test
11165 Magic links: PMID (T67278)
11166 !! wikitext
11167 This is PMID 1234 but thisPMID 1234 is not PMID 1234linked.
11168 !! html/php
11169 <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.
11170 </p>
11171 !! html/parsoid
11172 <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>
11173 !! end
11174
11175 !! test
11176 Magic links: PMID (w/ non-newline whitespace, T30950/T31025)
11177 !! wikitext
11178 PMID &nbsp;&#160;&#0160;&#xA0;&#Xa0; 1234
11179 PMID
11180 1234
11181 !! html/php
11182 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11183 PMID
11184 1234
11185 </p>
11186 !! html/parsoid
11187 <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>
11188 PMID
11189 1234</p>
11190 !! end
11191
11192 # <nowiki> nodes shouldn't be inserted during html2wt by Parsoid,
11193 # since these are ExtLinkText, not MagicLinkText
11194 !! test
11195 Magic links: use appropriate serialization for "almost" magic links.
11196 !! wikitext
11197 X[[Special:BookSources/0978739256|foo]]
11198
11199 X[https://tools.ietf.org/html/rfc1234 foo]
11200 !! html/php
11201 <p>X<a href="/wiki/Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a>
11202 </p><p>X<a rel="nofollow" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a>
11203 </p>
11204 !! html/parsoid
11205 <p>X<a rel="mw:WikiLink" href="./Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a></p>
11206 <p>X<a rel="mw:ExtLink" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a></p>
11207 !! end
11208
11209 !! test
11210 Magic links: All disabled (T47942)
11211 !! options
11212 wgEnableMagicLinks={"ISBN":false, "PMID":false, "RFC":false}
11213 !! wikitext
11214 ISBN 0-306-40615-2
11215 PMID 1234
11216 RFC 4321
11217 !! html/php
11218 <p>ISBN 0-306-40615-2
11219 PMID 1234
11220 RFC 4321
11221 </p>
11222 !! end
11223
11224 ###
11225 ### Templates
11226 ####
11227
11228 !! test
11229 Nonexistent template
11230 !! wikitext
11231 {{thistemplatedoesnotexist}}
11232 !! html
11233 <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>
11234 </p>
11235 !! end
11236
11237 !! test
11238 Template with invalid target containing tags
11239 !! wikitext
11240 {{a<b>b</b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11241 !! html
11242 <p>{{a<b>b</b>|foo|a=b|a = b}}
11243 </p>
11244 !! end
11245
11246 !! test
11247 Template with invalid target containing unclosed tag
11248 !! wikitext
11249 {{a<b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11250 !! html
11251 <p>{{a<b>|foo|a=b|a = b}}</b>
11252 </p>
11253 !! end
11254
11255 !! test
11256 Template with invalid target containing wikilink
11257 !! wikitext
11258 {{[[Main Page]]}}
11259 !! html/php
11260 <p>{{<a href="/wiki/Main_Page" title="Main Page">Main Page</a>}}
11261 </p>
11262 !! html/parsoid
11263 <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>
11264 !! end
11265
11266 !! test
11267 Template with just whitespace in it, T70421
11268 !! wikitext
11269 {{echo|{{ }}}}
11270 !! html/parsoid
11271 <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>
11272 !! end
11273
11274 !! article
11275 Template:test
11276 !! text
11277 This is a test template
11278 !! endarticle
11279
11280 !! test
11281 Simple template
11282 !! wikitext
11283 {{test}}
11284 !! html
11285 <p>This is a test template
11286 </p>
11287 !! end
11288
11289 !! test
11290 Template with explicit namespace
11291 !! wikitext
11292 {{Template:test}}
11293 !! html
11294 <p>This is a test template
11295 </p>
11296 !! end
11297
11298
11299 !! article
11300 Template:paramtest
11301 !! text
11302 This is a test template with parameter {{{param}}}
11303 !! endarticle
11304
11305 !! test
11306 Template parameter
11307 !! wikitext
11308 {{paramtest|param=foo}}
11309 !! html
11310 <p>This is a test template with parameter foo
11311 </p>
11312 !! end
11313
11314 !! article
11315 Template:paramtestnum
11316 !! text
11317 [[{{{1}}}|{{{2}}}]]
11318 !! endarticle
11319
11320 !! test
11321 Template unnamed parameter
11322 !! wikitext
11323 {{paramtestnum|Main Page|the main page}}
11324 !! html
11325 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
11326 </p>
11327 !! end
11328
11329 !! article
11330 Template:templatesimple
11331 !! text
11332 (test)
11333 !! endarticle
11334
11335 !! article
11336 Template:templateredirect
11337 !! text
11338 #redirect [[Template:templatesimple]]
11339 !! endarticle
11340
11341 !! article
11342 Template:templateasargtestnum
11343 !! text
11344 {{{{{1}}}}}
11345 !! endarticle
11346
11347 !! article
11348 Template:templateasargtest
11349 !! text
11350 {{template{{{templ}}}}}
11351 !! endarticle
11352
11353 !! article
11354 Template:templateasargtest2
11355 !! text
11356 {{{{{templ}}}}}
11357 !! endarticle
11358
11359 !! test
11360 Template with template name as unnamed argument
11361 !! wikitext
11362 {{templateasargtestnum|templatesimple}}
11363 !! html
11364 <p>(test)
11365 </p>
11366 !! end
11367
11368 !! test
11369 Template with template name as argument
11370 !! wikitext
11371 {{templateasargtest|templ=simple}}
11372 !! html
11373 <p>(test)
11374 </p>
11375 !! end
11376
11377 !! test
11378 Template with template name as argument (2)
11379 !! wikitext
11380 {{templateasargtest2|templ=templatesimple}}
11381 !! html
11382 <p>(test)
11383 </p>
11384 !! end
11385
11386 !! article
11387 Template:templateasargtestdefault
11388 !! text
11389 {{{{{templ|templatesimple}}}}}
11390 !! endarticle
11391
11392 !! article
11393 Template:templa
11394 !! text
11395 '''templ'''
11396 !! endarticle
11397
11398 !! test
11399 Template with default value
11400 !! wikitext
11401 {{templateasargtestdefault}}
11402 !! html
11403 <p>(test)
11404 </p>
11405 !! end
11406
11407 !! test
11408 Template with default value (value set)
11409 !! wikitext
11410 {{templateasargtestdefault|templ=templa}}
11411 !! html
11412 <p><b>templ</b>
11413 </p>
11414 !! end
11415
11416 !! test
11417 Template redirect
11418 !! wikitext
11419 {{templateredirect}}
11420 !! html/php
11421 <p>(test)
11422 </p>
11423 !! html/parsoid
11424 <link rel="mw:PageProp/redirect" href="./Template:Templatesimple" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"templateredirect","href":"./Template:Templateredirect"},"params":{},"i":0}}]}'/>
11425 !! end
11426
11427 !! test
11428 Template with argument in separate line
11429 !! wikitext
11430 {{ templateasargtest |
11431 templ = simple }}
11432 !! html
11433 <p>(test)
11434 </p>
11435 !! end
11436
11437 !! test
11438 Template with complex template as argument
11439 !! wikitext
11440 {{paramtest|
11441 param ={{ templateasargtest |
11442 templ = simple }}}}
11443 !! html
11444 <p>This is a test template with parameter (test)
11445 </p>
11446 !! end
11447
11448 !! test
11449 Templates with templated name
11450 !! wikitext
11451 {{{{echo|echo}}|foo}}
11452 {{{{echo|inner list}} }}
11453 !! html
11454 <p>foo
11455 </p>
11456 <ul><li>item 1</li></ul>
11457
11458 !! html/parsoid
11459 <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>
11460 <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>
11461 !! end
11462
11463 ## Regression test; the output here isn't really that interesting.
11464 !! test
11465 Templates with templated name and top level template args
11466 !! wikitext
11467 {{1{{2{{{3}}}|4=5}}}}
11468 !! html/parsoid
11469 <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>
11470 !! end
11471
11472 # Parsoid markup is deliberate "broken". This is an edge case.
11473 # See long comment in TemplateHandler.js:convertAttribsToString.
11474 !! test
11475 Templates with invalid templated targets
11476 !! wikitext
11477 {{echo
11478 {{echo|foo}}
11479 }}
11480 !! html/php
11481 <p>{{echo
11482 foo
11483 }}
11484 </p>
11485 !! html/parsoid
11486 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n{{echo|foo}}\n"},"params":{},"i":0}}]}'>{{echo
11487 foo }}</p>
11488 !! end
11489
11490 !! test
11491 Template with thumb image (with link in description)
11492 !! wikitext
11493 {{paramtest|param=[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
11494 !! html/php
11495 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>
11496
11497 !! html+tidy
11498 <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>
11499 !! html/parsoid
11500 <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>
11501 !! end
11502
11503 !! article
11504 Template:complextemplate
11505 !! text
11506 {{{1}}} {{paramtest|
11507 param ={{{param}}}}}
11508 !! endarticle
11509
11510 !! test
11511 Template with complex arguments
11512 !! wikitext
11513 {{complextemplate|
11514 param ={{ templateasargtest |
11515 templ = simple }}|[[Template:complextemplate|link]]}}
11516 !! html
11517 <p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test)
11518 </p>
11519 !! end
11520
11521 !! test
11522 T2553: link with two variables in a piped link
11523 !! wikitext
11524 {|
11525 |[[{{{1}}}|{{{2}}}]]
11526 |}
11527 !! html/php
11528 <table>
11529 <tr>
11530 <td>[[{{{1}}}|{{{2}}}]]
11531 </td></tr></table>
11532
11533 !! html/parsoid
11534 <table>
11535 <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>
11536 </tbody></table>
11537 !! end
11538
11539 # See: T2553
11540 !! test
11541 Abort table cell attribute parsing on wikilink
11542 !! wikitext
11543 {|
11544 |testing [[one|two]] |three||four
11545 |testing one two |three||four
11546 |testing="[[one|two]]" |three||four
11547 |}
11548 !! html/php
11549 <table>
11550 <tr>
11551 <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>
11552 <td>four
11553 </td>
11554 <td>three</td>
11555 <td>four
11556 </td>
11557 <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>
11558 <td>four
11559 </td></tr></table>
11560
11561 !! html/parsoid
11562 <table>
11563 <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>
11564 <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>
11565 <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>
11566 </tbody></table>
11567 !! end
11568
11569 !! test
11570 Don't abort table cell attribute parsing if wikilink is found in template arg
11571 !! wikitext
11572 {|
11573 |Test {{#tag:ref|One two "[[three]]" four}}
11574 |}
11575 !! html/parsoid
11576 <table>
11577 <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>
11578 </tbody></table>
11579 !! end
11580
11581 !! test
11582 Magic variable as template parameter
11583 !! wikitext
11584 {{paramtest|param={{SITENAME}}}}
11585 !! html
11586 <p>This is a test template with parameter MediaWiki
11587 </p>
11588 !! end
11589
11590 !! article
11591 Template:linktest
11592 !! text
11593 [[{{{param}}}|link]]
11594 !! endarticle
11595
11596 !! test
11597 Template parameter as link source
11598 !! wikitext
11599 {{linktest|param=Main Page}}
11600 !! html
11601 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
11602 </p>
11603 !! end
11604
11605 !!article
11606 Template:paramtest2
11607 !! text
11608 including another template, {{paramtest|param={{{arg}}}}}
11609 !! endarticle
11610
11611 !! test
11612 Template passing argument to another template
11613 !! wikitext
11614 {{paramtest2|arg='hmm'}}
11615 !! html
11616 <p>including another template, This is a test template with parameter 'hmm'
11617 </p>
11618 !! end
11619
11620 !! article
11621 Template:Linktest2
11622 !! text
11623 Main Page
11624 !! endarticle
11625
11626 !! test
11627 Template as link source
11628 !! wikitext
11629 [[{{linktest2}}]]
11630
11631 [[{{linktest2}}|Main Page]]
11632
11633 [[{{linktest2}}]]Page
11634 !! html
11635 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11636 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11637 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>Page
11638 </p>
11639 !! end
11640
11641
11642 !! article
11643 Template:loop1
11644 !! text
11645 {{loop2}}
11646 !! endarticle
11647
11648 !! article
11649 Template:loop2
11650 !! text
11651 {{loop1}}
11652 !! endarticle
11653
11654 !! test
11655 Template infinite loop
11656 !! wikitext
11657 {{loop1}}
11658 !! html
11659 <p><span class="error">Template loop detected: <a href="/wiki/Template:Loop1" title="Template:Loop1">Template:Loop1</a></span>
11660 </p>
11661 !! end
11662
11663 !! test
11664 Template from main namespace
11665 !! wikitext
11666 {{:Main Page}}
11667 !! html
11668 <p>blah blah
11669 </p>
11670 !! end
11671
11672 !! test
11673 Template from non-includable namespace
11674 !! options
11675 wgNonincludableNamespaces=10
11676 !! wikitext
11677 {{echo|uh oh!}}
11678 !! html
11679 <p><a href="/wiki/Template:Echo" title="Template:Echo">Template:Echo</a>
11680 </p>
11681 !! end
11682
11683 !! article
11684 Template:table
11685 !! text
11686 {|
11687 | 1 || 2
11688 |-
11689 | 3 || 4
11690 |}
11691 !! endarticle
11692
11693 !! test
11694 T2529: Template with table, not included at beginning of line
11695 !! wikitext
11696 foo {{table}}
11697 !! html
11698 <p>foo
11699 </p>
11700 <table>
11701 <tr>
11702 <td>1</td>
11703 <td>2
11704 </td></tr>
11705 <tr>
11706 <td>3</td>
11707 <td>4
11708 </td></tr></table>
11709
11710 !! end
11711
11712 !! test
11713 T2523: Template shouldn't eat newline (or add an extra one before table)
11714 !! wikitext
11715 foo
11716 {{table}}
11717 !! html
11718 <p>foo
11719 </p>
11720 <table>
11721 <tr>
11722 <td>1</td>
11723 <td>2
11724 </td></tr>
11725 <tr>
11726 <td>3</td>
11727 <td>4
11728 </td></tr></table>
11729
11730 !! end
11731
11732 !! test
11733 T2041: Template parameters shown as broken links
11734 !! wikitext
11735 {{{parameter}}}
11736 !! html
11737 <p>{{{parameter}}}
11738 </p>
11739 !! end
11740
11741 !! test
11742 Template with targets containing wikilinks
11743 !! options
11744 parsoid=wt2html
11745 !! wikitext
11746 {{[[foo]]}}
11747
11748 {{[[{{echo|foo}}]]}}
11749
11750 {{{{echo|[[foo}}]]}}
11751 !! html/php
11752 <p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11753 </p><p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11754 </p><p>{{[[foo}}]]
11755 </p>
11756 !! html/parsoid
11757 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">foo</a>}}</p>
11758 <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>
11759 <p>{{<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[foo}}]]"}},"i":0}}]}'>[[foo}}]]</span></p>
11760 !! end
11761
11762 !! article
11763 Template:''
11764 !! text
11765 bar
11766 !! endarticle
11767
11768 !! test
11769 Templates: Double quotes as template target
11770 !! wikitext
11771 foo {{''}} baz
11772 !! html/php
11773 <p>foo bar baz
11774 </p>
11775 !! html/parsoid
11776 <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
11777 </p>
11778 !! end
11779
11780 ## This test is about making sure Parsoid's data-mw is well formed in the
11781 ## face of multiple templates with intersecting and overlapping ranges. The
11782 ## wikitext itself is wretched.
11783 !! test
11784 Templates with intersecting and overlapping ranges
11785 !! wikitext
11786 {|{{echo|
11787 <p>ha</p>}}
11788 {|{{echo|
11789 <p>ho</p>}}
11790 {{echo|{{!}}hi}}
11791 |}
11792 !! html/php+tidy
11793 <p>ha</p><table>
11794
11795 </table><p>ho</p><table>
11796
11797 <tbody><tr>
11798 <td>hi
11799 </td></tr></tbody></table>
11800 !! html/parsoid
11801 <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":""}]]}'>
11802
11803 </table><p about="#mwt1">ho</p><table about="#mwt1" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"","html":""},{"html":""}]]}'>
11804
11805 <tbody><tr><td>hi</td></tr>
11806 </tbody></table>
11807 !! end
11808
11809 !! article
11810 Template:MSGNW test
11811 !! text
11812 ''None'' of '''this''' should be
11813 * interpreted
11814 but rather passed unmodified
11815 {{test}}
11816 <gallery>
11817 File:Foobar.jpg
11818 </gallery>
11819 <!-- comment -->
11820 !! endarticle
11821
11822 # hmm, fix this or just deprecate msgnw and document its behavior?
11823 !! test
11824 msgnw keyword
11825 !! wikitext
11826 {{msgnw:MSGNW test}}
11827 !! html/php
11828 <p>&#39;&#39;None&#39;&#39; of &#39;&#39;&#39;this&#39;&#39;&#39; should be
11829 &#42; interpreted
11830 &#32;but rather passed unmodified
11831 &#123;&#123;test&#125;&#125;
11832 &#60;gallery&#62;
11833 File:Foobar.jpg
11834 &#60;/gallery&#62;
11835 &#60;!-- comment --&#62;
11836 </p>
11837 !! end
11838
11839 !! test
11840 int keyword
11841 !! wikitext
11842 {{int:youhavenewmessages|lots of money|not!}}
11843 !! html
11844 <p>You have lots of money (not!).
11845 </p>
11846 !! end
11847
11848 !! test
11849 int keyword - non-existing message
11850 !! wikitext
11851 {{int:var}}
11852 !! html
11853 <p>⧼var⧽
11854 </p>
11855 !! end
11856
11857 !! article
11858 Template:Includes
11859 !! text
11860 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11861 !! endarticle
11862
11863 !! test
11864 <includeonly> and <noinclude> being included
11865 !! wikitext
11866 {{Includes}}
11867 !! html
11868 <p>Foobar
11869 </p>
11870 !! end
11871
11872 !! article
11873 Template:Includes2
11874 !! text
11875 <onlyinclude>Foo</onlyinclude>bar
11876 !! endarticle
11877
11878 !! test
11879 <onlyinclude> being included
11880 !! wikitext
11881 {{Includes2}}
11882 !! html
11883 <p>Foo
11884 </p>
11885 !! end
11886
11887
11888 !! article
11889 Template:Includes3
11890 !! text
11891 <onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly>
11892 !! endarticle
11893
11894 !! test
11895 <onlyinclude> and <includeonly> being included
11896 !! wikitext
11897 {{Includes3}}
11898 !! html
11899 <p>Foo
11900 </p>
11901 !! end
11902
11903 !! test
11904 <includeonly> and <noinclude> on a page
11905 !! wikitext
11906 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11907 !! html
11908 <p>Foozar
11909 </p>
11910 !! end
11911
11912 !! test
11913 Un-closed <noinclude>
11914 !! wikitext
11915 <noinclude>
11916 !! html
11917 !! end
11918
11919 !! test
11920 <onlyinclude> on a page
11921 !! wikitext
11922 <onlyinclude>Foo</onlyinclude>bar
11923 !! html
11924 <p>Foobar
11925 </p>
11926 !! end
11927
11928 !! test
11929 Un-closed <onlyinclude>
11930 !! wikitext
11931 <onlyinclude>
11932 !! html
11933 !! end
11934
11935 !!test
11936 Self-closed noinclude, includeonly, onlyinclude tags
11937 !! wikitext
11938 <noinclude />
11939 <includeonly />
11940 <onlyinclude />
11941 !! html
11942 <p><br />
11943 </p>
11944 !!end
11945
11946 !!test
11947 Unbalanced includeonly and noinclude tags
11948 !! wikitext
11949 {|
11950 |a</noinclude>
11951 |b</noinclude></noinclude>
11952 |c</noinclude></includeonly>
11953 |d</includeonly></includeonly>
11954 |}
11955 !! html
11956 <table>
11957 <tr>
11958 <td>a
11959 </td>
11960 <td>b
11961 </td>
11962 <td>c&lt;/includeonly&gt;
11963 </td>
11964 <td>d&lt;/includeonly&gt;&lt;/includeonly&gt;
11965 </td></tr></table>
11966
11967 !!end
11968
11969 !! article
11970 Template:Includeonly section
11971 !! text
11972 <includeonly>
11973 ==Includeonly section==
11974 </includeonly>
11975 ==Section T-1==
11976 !!endarticle
11977
11978 !! test
11979 T8563: Edit link generation for section shown by <includeonly>
11980 !! wikitext
11981 {{includeonly section}}
11982 !! html
11983 <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>
11984 <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>
11985
11986 !! end
11987
11988 # Uses same input as the contents of [[Template:Includeonly section]]
11989 !! test
11990 T8563: Section extraction for section shown by <includeonly>
11991 !! options
11992 section=T-2
11993 !! wikitext
11994 <includeonly>
11995 ==Includeonly section==
11996 </includeonly>
11997 ==Section T-2==
11998 !! html
11999 ==Section T-2==
12000 !! end
12001
12002 !! test
12003 T8563: Edit link generation for section suppressed by <includeonly>
12004 !! wikitext
12005 <includeonly>
12006 ==Includeonly section==
12007 </includeonly>
12008 ==Section 1==
12009 !! html
12010 <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>
12011
12012 !! end
12013
12014 !! test
12015 T8563: Section extraction for section suppressed by <includeonly>
12016 !! options
12017 section=1
12018 !! wikitext
12019 <includeonly>
12020 ==Includeonly section==
12021 </includeonly>
12022 ==Section 1==
12023 !! html
12024 ==Section 1==
12025 !! end
12026
12027 !! test
12028 Un-closed <includeonly>
12029 !! wikitext
12030 <includeonly>
12031 !! html/php
12032 !! html/parsoid
12033 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>"}'/>
12034 !! end
12035
12036 ## We used to, but no longer wt2wt this test since the default serializer
12037 ## will normalize the include directives to serialize on their own line.
12038 ## Selser will take care of preserving formatting in scenarios where they
12039 ## intermingled with other wikitext.
12040 !! test
12041 Includes and comments at SOL
12042 !! options
12043 parsoid=wt2html,html2html
12044 !! wikitext
12045 <!-- comment --><noinclude><!-- comment --></noinclude><!-- comment -->==hu==
12046
12047 <noinclude>
12048 some
12049 </noinclude>*stuff
12050 *here
12051
12052 <includeonly>can have stuff</includeonly>===here===
12053
12054 !! html/php
12055 <h2><span class="mw-headline" id="hu">hu</span></h2>
12056 <p>some
12057 </p>
12058 <ul><li>stuff</li>
12059 <li>here</li></ul>
12060 <h3><span class="mw-headline" id="here">here</span></h3>
12061
12062 !! html/parsoid
12063 <!-- 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>
12064
12065 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
12066 <p>some</p>
12067 <meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/><ul><li>stuff</li>
12068 <li>here</li></ul>
12069
12070 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>can have stuff&lt;/includeonly>"}'/><meta typeof="mw:Includes/IncludeOnly/End" data-parsoid='{"src":""}'/><h3 id="here">here</h3>
12071
12072 !! end
12073
12074 # TODO: test with DOM fragment reuse!
12075 !! test
12076 Parsoid: DOM fragment reuse
12077 !! options
12078 parsoid=wt2wt,wt2html
12079 !! wikitext
12080 a{{echo|b<table></table>c}}d
12081
12082 a{{echo|b
12083 <table></table>
12084 c}}d
12085
12086 {{echo|a
12087
12088 <table></table>
12089
12090 b}}
12091 !! html
12092 <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>
12093
12094 <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">
12095 </span><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><span about="#mwt2">
12096 </span><p about="#mwt2">cd</p>
12097
12098 <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">
12099
12100 </span><table about="#mwt3" data-parsoid='{"stx":"html"}'></table><span about="#mwt3">
12101
12102 </span><p about="#mwt3">b</p>
12103 !! end
12104
12105 !! test
12106 Parsoid: Merge double tds (T52603)
12107 !! options
12108 parsoid
12109 !! wikitext
12110 {|
12111 |{{echo|{{!}} foo}}
12112 |}
12113 !! html
12114 <table><tbody>
12115 <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>
12116 </tbody></table>
12117 !! end
12118
12119 !! test
12120 Parsoid: Merge double tds in nested transclusion content (T52603)
12121 !! options
12122 parsoid
12123 !! wikitext
12124 {{echo|<div>}}
12125 {|
12126 |{{echo|{{!}} foo}}
12127 |}
12128 {{echo|</div>}}
12129 !! html
12130 <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}}]}'>
12131 <table><tbody>
12132 <tr><td data-mw='{"parts":["|"]}'> foo</td></tr>
12133 </tbody></table>
12134 </div>
12135 !! end
12136
12137 ###
12138 ### <includeonly> and <noinclude> in attributes
12139 ###
12140 !!test
12141 0. includeonly around the entire attribute
12142 !! wikitext
12143 <span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
12144 !! html
12145 <p><span id="v2">bar</span>
12146 </p>
12147 !!end
12148
12149 !!test
12150 1. includeonly in html attr key
12151 !! wikitext
12152 <span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
12153 !! html
12154 <p><span id="foo">bar</span>
12155 </p>
12156 !!end
12157
12158 !!test
12159 2. includeonly in html attr value
12160 !! wikitext
12161 <span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
12162 <span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
12163 !! html
12164 <p><span id="v1">bar</span>
12165 <span id="v1">bar</span>
12166 </p>
12167 !!end
12168
12169 !!test
12170 3. includeonly in part of an attr value
12171 !! wikitext
12172 <span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
12173 !! html
12174 <p><span style="color:red;">bar</span>
12175 </p>
12176 !!end
12177
12178 !!test
12179 4. includeonly in table attributes
12180 !! wikitext
12181 {|
12182 |- <noinclude>
12183 |-
12184 |a
12185 </noinclude>
12186 |- <includeonly>
12187 |-
12188 |b
12189 </includeonly>
12190 |}
12191 !! html
12192 <table>
12193
12194
12195 <tr>
12196 <td>a
12197 </td></tr>
12198 </table>
12199
12200 !!end
12201
12202 ###
12203 ### Preprocessor precedence tests
12204 ### See: https://www.mediawiki.org/wiki/Preprocessor_ABNF
12205 ###
12206 ##{{[[-{{{{{{[[Foo|bar}}]]}-}}}}}]]
12207 !! test
12208 Preprocessor precedence 1: link is rightmost opening
12209 !! options
12210 parsoid=wt2html
12211 !! wikitext
12212 {{[[Foo|bar}}]]
12213
12214 But close-brace is not a valid character in a link title:
12215 {{[[Foo}}|bar]]
12216
12217 However, we can still tell this was handled as a link in the preprocessor:
12218 {{echo|[[Foo}}|bar]]|bat}}
12219 !! html/php
12220 <p>{{<a href="/wiki/Foo" title="Foo">bar}}</a>
12221 </p><p>But close-brace is not a valid character in a link title:
12222 {{[[Foo}}|bar]]
12223 </p><p>However, we can still tell this was handled as a link in the preprocessor:
12224 [[Foo}}|bar]]
12225 </p>
12226 !! html/parsoid
12227 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">bar}}</a></p>
12228 <p>But close-brace is not a valid character in a link title: {{[[Foo}}|bar]]</p>
12229 <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>
12230 !! end
12231
12232 !! test
12233 Preprocessor precedence 2: template is rightmost opening
12234 !! options
12235 language=zh
12236 !! wikitext
12237 -{{echo|foo}-}}-
12238 !! html/php
12239 <p>-foo}--
12240 </p>
12241 !! html/parsoid
12242 <p>-<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}-"}},"i":0}}]}'>foo}-</span>-</p>
12243 !! end
12244
12245 !! test
12246 Preprocessor precedence 3: language converter is rightmost opening
12247 !! options
12248 language=zh
12249 parsoid=wt2html
12250 !! wikitext
12251 {{echo|hi}}
12252
12253 {{-{R|echo|hi}}}-
12254
12255 [[-{R|raw]]}-
12256 !! html/php
12257 <p>hi
12258 </p><p>{{echo|hi}}
12259 </p><p>[[raw]]
12260 </p>
12261 !! html/parsoid
12262 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"}},"i":0}}]}'>hi</p>
12263 <p>{{<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"echo|hi}}"}}'></span></p>
12264 <p>[[<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw]]"}}'></span></p>
12265 !! end
12266
12267 !! test
12268 Preprocessor precedence 4: left-most angle bracket
12269 !! options
12270 language=zh
12271 !! wikitext
12272 <!--{raw}-->
12273 !! html/php
12274 !! html/parsoid
12275 <!--{raw}-->
12276 !! end
12277
12278 !! article
12279 Template:Precedence5
12280 !! text
12281 {{{{{1}}}}}
12282 !! endarticle
12283
12284 !! test
12285 Preprocessor precedence 5: tplarg takes precedence over template
12286 !! wikitext
12287 {{Precedence5|Bullet}}
12288 !! html/php
12289 <ul><li>Bar</li></ul>
12290
12291 !! html/parsoid
12292 <ul typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Precedence5","href":"./Template:Precedence5"},"params":{"1":{"wt":"Bullet"}},"i":0}}]}'><li>Bar</li></ul>
12293 !! end
12294
12295 !! test
12296 Preprocessor precedence 6: broken link is rightmost opening
12297 !! options
12298 parsoid=wt2html
12299 !! wikitext
12300 {{echo|[[Foo}}
12301
12302 {{echo|[[Foo|bar|bat=baz}}
12303 !! html/php
12304 <p>{{echo|[[Foo}}
12305 </p><p>{{echo|[[Foo|bar|bat=baz}}
12306 </p>
12307 !! html/parsoid
12308 <p>{{echo|[[Foo}}</p>
12309 <p>{{echo|[[Foo|bar|bat=baz}}</p>
12310 !! end
12311
12312 # This next test exposes a difference between PHP and Parsoid:
12313 # Given [[Foo|{{echo|Bar]]x}}y]]z:
12314 # 1) Both PHP and Parsoid ignore the `]]` inside the `echo` in the
12315 # "preprocessor" stage. The `{{echo` extends until the `x}}`, and the
12316 # outer `[[Foo` extends until the `y]]`
12317 # 2a) But then the PHP preprocessor emits `[[Foo|Bar]]xy]]z` as an
12318 # intermediate result (after template expansion), and link processing
12319 # happens on this intermediate result, which moves the wikilink
12320 # boundary leftward to `[[Foo|Bar]]`
12321 # 2b) Parsoid works in a single step, so it's going to keep the
12322 # wikilink as extending to the `y]]`
12323 # 3a) Then PHP does linktrail processing which slurps up the trailing
12324 # `xy` inside the link.
12325 # 3b) Parsoid will do linktrail processing to slurp up the trailing
12326 # `z` inside the link.
12327 # This is "correct" behavior. Parsoid's basic worldview is that the
12328 # `]]` inside the template shouldn't be allowed to leak out to affect
12329 # the surrounding wikilink. PHP may match Parsoid (in the future)
12330 # if you use {{#balance}} (T114445).
12331
12332 !! test
12333 Preprocessor precedence 7: broken template is rightmost opening
12334 !! options
12335 parsoid=wt2html
12336 !! wikitext
12337 [[Foo|{{echo|Bar]]
12338
12339 [[Foo|{{echo|Bar]]-x}}-y]]-z
12340
12341 Careful: linktrails can move the end of the wikilink:
12342 [[Foo|{{echo|y']]a}}l]]l
12343 !! html/php
12344 <p><a href="/wiki/Foo" title="Foo">{{echo|Bar</a>
12345 </p><p><a href="/wiki/Foo" title="Foo">Bar</a>-x-y]]-z
12346 </p><p>Careful: linktrails can move the end of the wikilink:
12347 <a href="/wiki/Foo" title="Foo">y'al</a>]]l
12348 </p>
12349 !! html/parsoid
12350 <p>[[Foo|{{echo|Bar]]</p>
12351 <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>
12352 <p>Careful: linktrails can move the end of the wikilink:
12353 <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>
12354 !! end
12355
12356 !! test
12357 Preprocessor precedence 8: broken language converter is rightmost opening
12358 !! options
12359 language=zh
12360 !! wikitext
12361 [[Foo-{R|raw]]
12362 !! html
12363 <p>[[Foo-{R|raw]]
12364 </p>
12365 !! end
12366
12367 !! article
12368 Template:Preprocessor_precedence_9
12369 !! text
12370 ;4: {{{{1}}}}
12371 ;5: {{{{{2}}}}}
12372 ;6: {{{{{{3}}}}}}
12373 ;7: {{{{{{{4}}}}}}}
12374 !! endarticle
12375
12376 !! test
12377 Preprocessor precedence 9: groups of braces
12378 !! wikitext
12379 {{Preprocessor precedence 9|Four|Bullet|1|2}}
12380 !! html/php
12381 <dl><dt>4</dt>
12382 <dd>{Four}</dd>
12383 <dt>5</dt>
12384 <dd></dd></dl>
12385 <ul><li>Bar</li></ul>
12386 <dl><dt>6</dt>
12387 <dd>Four</dd>
12388 <dt>7</dt>
12389 <dd>{Bullet}</dd></dl>
12390
12391 !! html/parsoid
12392 <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}}]}'>
12393 <dt>4</dt>
12394 <dd>{Four}</dd>
12395 <dt>5</dt>
12396 <dd></dd>
12397 </dl><ul about="#mwt1">
12398 <li>Bar</li>
12399 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12400 <dt>6</dt>
12401 <dd>Four</dd>
12402 <dt>7</dt>
12403 <dd>{Bullet}</dd>
12404 </dl>
12405 !! end
12406
12407 !! article
12408 Template:Preprocessor_precedence_10
12409 !! text
12410 ;1: -{R|raw}-
12411 ;2: -{{Bullet}}-
12412 ;3: -{{{1}}}-
12413 ;4: -{{{{2}}}}-
12414 ;5: -{{{{{3}}}}}-
12415 ;6: -{{{{{{4}}}}}}-
12416 ;7: -{{{{{{{5}}}}}}}-
12417 !! endarticle
12418
12419 !! test
12420 Preprocessor precedence 10: groups of braces with leading dash
12421 !! options
12422 language=zh
12423 !! wikitext
12424 {{Preprocessor precedence 10|Three|raw2|Bullet|1|2}}
12425 !! html/php
12426 <dl><dt>1</dt>
12427 <dd>raw</dd>
12428 <dt>2</dt>
12429 <dd>-</dd></dl>
12430 <ul><li>Bar-</li></ul>
12431 <dl><dt>3</dt>
12432 <dd>-Three-</dd>
12433 <dt>4</dt>
12434 <dd>raw2</dd>
12435 <dt>5</dt>
12436 <dd>-</dd></dl>
12437 <ul><li>Bar-</li></ul>
12438 <dl><dt>6</dt>
12439 <dd>-Three-</dd>
12440 <dt>7</dt>
12441 <dd>raw2</dd></dl>
12442
12443 !! html/parsoid
12444 <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}}]}'>
12445 <dt>1</dt>
12446 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw"}}'></span></dd>
12447 <dt>2</dt>
12448 <dd>-</dd>
12449 </dl><ul about="#mwt1">
12450 <li>Bar-</li>
12451 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12452 <dt>3</dt>
12453 <dd>-Three-</dd>
12454 <dt>4</dt>
12455 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12456 <dt>5</dt>
12457 <dd>-</dd>
12458 </dl><ul about="#mwt1">
12459 <li>Bar-</li>
12460 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12461 <dt>6</dt>
12462 <dd>-Three-</dd>
12463 <dt>7</dt>
12464 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12465 </dl>
12466 !! end
12467
12468 !! test
12469 Preprocessor precedence 11: found during visual diff testing
12470 !! wikitext
12471 {{#tag:span|-{{#tag:span|-{{echo|x}}}}}}
12472
12473 {{echo|-{{echo|-{{echo|x}}}}}}
12474
12475 {{echo|-{{echo|x}}}}
12476 !! html/php
12477 <p><span>-<span>-x</span></span>
12478 </p><p>--x
12479 </p><p>-x
12480 </p>
12481 !! html/parsoid
12482 <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>
12483
12484 <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>
12485
12486 <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>
12487 !! end
12488
12489 !! test
12490 Preprocessor precedence 12: broken language converter closed by brace.
12491 !! options
12492 parsoid=wt2html
12493 !! wikitext
12494 This form breaks the template, which is unfortunate:
12495 *{{echo|foo-{bar}bat}}
12496
12497 But if the broken language converter markup is inside an extension
12498 tag, nothing bad happens:
12499 *<nowiki>foo-{bar}bat</nowiki>
12500 *{{echo|<nowiki>foo-{bar}bat</nowiki>}}
12501 *<pre>foo-{bar}bat</pre>
12502 *{{echo|<pre>foo-{bar}bat</pre>}}
12503
12504 <tag>foo-{bar}bat</tag>
12505 {{echo|<tag>foo-{bar}bat</tag>}}
12506
12507 !! html/php+tidy
12508 <p>This form breaks the template, which is unfortunate:
12509 </p>
12510 <ul><li>{{echo|foo-{bar}bat}}</li></ul>
12511 <p>But if the broken language converter markup is inside an extension
12512 tag, nothing bad happens:
12513 </p>
12514 <ul><li>foo-&#123;bar}bat</li>
12515 <li>foo-&#123;bar}bat</li>
12516 <li><pre>foo-{bar}bat</pre></li>
12517 <li><pre>foo-{bar}bat</pre></li></ul>
12518 <pre>'foo-{bar}bat'
12519 array (
12520 )
12521 </pre>
12522 <pre>'foo-{bar}bat'
12523 array (
12524 )
12525 </pre>
12526 !! html/parsoid
12527 <p>This form breaks the template, which is unfortunate:</p>
12528 <ul>
12529 <li>{{echo|foo-{bar}bat}}</li>
12530 </ul>
12531 <p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p>
12532 <ul>
12533 <li><span typeof="mw:Nowiki">foo-{bar}bat</span></li>
12534 <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>
12535 <li><pre typeof="mw:Extension/pre" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo-{bar}bat"}}'>foo-{bar}bat</pre></li>
12536 <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>
12537 </ul>
12538 <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>
12539 !! end
12540
12541 !! test
12542 Preprocessor precedence 13: broken language converter in external link
12543 !! options
12544 parsoid=wt2html
12545 !! wikitext
12546 *[http://example.com/-{foo Example in URL]
12547 *[http://example.com Example in -{link} description]
12548 *{{echo|[http://example.com/-{foo Breaks template, however]}}
12549 !! html/php+tidy
12550 <ul><li><a rel="nofollow" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12551 <li><a rel="nofollow" class="external text" href="http://example.com">Example in -{link} description</a></li>
12552 <li>{{echo|<a rel="nofollow" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li></ul>
12553 !! html/parsoid
12554 <ul>
12555 <li><a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12556 <li><a rel="mw:ExtLink" class="external text" href="http://example.com">Example in -{link} description</a></li>
12557 <li>{{echo|<a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
12558 </ul>
12559 !! end
12560
12561 !! test
12562 Preprocessor precedence 14: broken language converter in comment
12563 !! wikitext
12564 *<!--{{foo}}-->...should be ok
12565 *<!---{{foo}}-->...extra dashes
12566 *{{echo|foo<!-- -{bar} -->bat}}...should be ok
12567 !! html/php+tidy
12568 <ul><li>...should be ok</li>
12569 <li>...extra dashes</li>
12570 <li>foobat...should be ok</li></ul>
12571 !! html/parsoid
12572 <ul>
12573 <li><!--{{foo}}-->...should be ok</li>
12574 <li><!--&#x2D;{{foo}}-->...extra dashes</li>
12575 <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>
12576 </ul>
12577 !! end
12578
12579 !! test
12580 Preprocessor precedence 15: broken brace markup in headings
12581 !! config
12582 wgFragmentMode=[ 'html5', 'legacy' ]
12583 !! options
12584 parsoid=wt2html
12585 !! wikitext
12586 __NOTOC__ __NOEDITSECTION__
12587 ===1 foo[bar 1===
12588 1
12589 ===2 foo[[bar 2===
12590 2
12591 ===3 foo{bar 3===
12592 3
12593 ===4 foo{{bar 4===
12594 4
12595 ===5 foo{{{bar 5===
12596 5
12597 ===6 foo-{bar 6===
12598 6
12599 !! html/php+tidy
12600 <h3><span id="1_foo.5Bbar_1"></span><span class="mw-headline" id="1_foo[bar_1">1 foo[bar 1</span></h3>
12601 <p>1
12602 </p>
12603 <h3><span id="2_foo.5B.5Bbar_2"></span><span class="mw-headline" id="2_foo[[bar_2">2 foo[[bar 2</span></h3>
12604 <p>2
12605 </p>
12606 <h3><span id="3_foo.7Bbar_3"></span><span class="mw-headline" id="3_foo{bar_3">3 foo{bar 3</span></h3>
12607 <p>3
12608 </p>
12609 <h3><span id="4_foo.7B.7Bbar_4"></span><span class="mw-headline" id="4_foo{{bar_4">4 foo{{bar 4</span></h3>
12610 <p>4
12611 </p>
12612 <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>
12613 <p>5
12614 </p>
12615 <h3><span id="6_foo-.7Bbar_6"></span><span class="mw-headline" id="6_foo-{bar_6">6 foo-{bar 6</span></h3>
12616 <p>6
12617 </p>
12618 !! html/parsoid
12619 <meta property="mw:PageProp/notoc"/> <meta property="mw:PageProp/noeditsection"/>
12620 <h3 id="1_foo[bar_1"><span id="1_foo.5Bbar_1" typeof="mw:FallbackId"></span>1 foo[bar 1</h3>
12621 <p>1</p>
12622 <h3 id="2_foo[[bar_2"><span id="2_foo.5B.5Bbar_2" typeof="mw:FallbackId"></span>2 foo[[bar 2</h3>
12623 <p>2</p>
12624 <h3 id="3_foo{bar_3"><span id="3_foo.7Bbar_3" typeof="mw:FallbackId"></span>3 foo{bar 3</h3>
12625 <p>3</p>
12626 <h3 id="4_foo{{bar_4"><span id="4_foo.7B.7Bbar_4" typeof="mw:FallbackId"></span>4 foo{{bar 4</h3>
12627 <p>4</p>
12628 <h3 id="5_foo{{{bar_5"><span id="5_foo.7B.7B.7Bbar_5" typeof="mw:FallbackId"></span>5 foo{{{bar 5</h3>
12629 <p>5</p>
12630 <h3 id="6_foo-{bar_6"><span id="6_foo-.7Bbar_6" typeof="mw:FallbackId"></span>6 foo-{bar 6</h3>
12631 <p>6</p>
12632 !! end
12633
12634 !! test
12635 Preprocessor precedence 16: matching closing braces to opening braces
12636 !! options
12637 language=zh
12638 parsoid=wt2html
12639 !! wikitext
12640 -{{{echo|foo}}bar}-
12641 !! html/php
12642 <p>foobar
12643 </p>
12644 !! html/parsoid
12645 <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>
12646 !! end
12647
12648 !! test
12649 Preprocessor precedence 17: template w/o target shouldn't prevent closing
12650 !! options
12651 parsoid=wt2html
12652 !! wikitext
12653 {{echo|hi {{}}}}
12654 !! html/php
12655 <p>hi {{}}
12656 </p>
12657 !! html/parsoid
12658 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi {{}}"}},"i":0}}]}'>hi {{}}</p>
12659 !! end
12660
12661 !! test
12662 Preprocessor precedence 18: another rightmost wins scenario
12663 !! options
12664 parsoid=wt2html
12665 !! wikitext
12666 {{ -{{{{1|tplarg}}} }} }-
12667 !! html/php
12668 <p>{{ -{tplarg }} }-
12669 </p>
12670 !! html/parsoid
12671 <p>{{ -{<span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"1"},"params":{"1":{"wt":"tplarg"}},"i":0}}]}'>tplarg</span> }} }-</p>
12672 !! end
12673
12674 !! test
12675 Preprocessor precedence 19: break syntax
12676 !! options
12677 parsoid=wt2html
12678 !! wikitext
12679 -{{
12680 !! html/php
12681 <p>-{{
12682 </p>
12683 !! html/parsoid
12684 <p>-{{</p>
12685 !! end
12686
12687 ###
12688 ### Token Stream Patcher tests
12689 ###
12690 ### These tests won't always pass wt2wt and other modes because
12691 ### on serialization, the table will be output on a new line.
12692 ### For now, we are blacklisting them, and using this to test selser.
12693 ###
12694
12695 !!test
12696 1. Table tag in SOL posn. should get reparsed correctly with valid TSR
12697 !!options
12698 parsoid=wt2html,wt2wt
12699 !!wikitext
12700 {{echo|}}{| width = '100%'
12701 |foo
12702 |}
12703 !!html/parsoid
12704 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":""}},"i":0}}]}'></span><table width="100%">
12705 <tbody><tr><td>foo</td></tr>
12706 </tbody></table>
12707 !!end
12708
12709 ## We used to, but no longer wt2wt this test since the default serializer
12710 ## will normalize the include directives to serialize on their own line.
12711 ## Selser will take care of preserving formatting in scenarios where they
12712 ## intermingled with other wikitext.
12713 !!test
12714 2. Table tag in SOL posn. should get reparsed correctly with valid TSR
12715 !!options
12716 parsoid=wt2html
12717 !!wikitext
12718 <includeonly>a</includeonly>{| {{{b}}}
12719 |c
12720 |}
12721 !!html/parsoid
12722 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"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":""}]]}'>
12723 <tbody><tr><td>c</td></tr>
12724 </tbody></table>
12725 !!end
12726
12727 !! test
12728 Table wikitext syntax outside wiki-tables
12729 !! wikitext
12730 a
12731 |+ not a caption
12732 ! not a table heading
12733 |- not a table row
12734 | not a table cell
12735 | class="foo bar" | baz
12736 b
12737 |}
12738 |-
12739 c
12740 !! html
12741 <p>a
12742 |+ not a caption
12743 ! not a table heading
12744 |- not a table row
12745 | not a table cell
12746 | class="foo bar" | baz
12747 b
12748 |}
12749 |-
12750 c
12751 </p>
12752 !! end
12753
12754 ###
12755 ### Testing parsing of templates where a template arg
12756 ### has the same name as the template itself.
12757 ###
12758
12759 !! article
12760 Template:quote
12761 !! text
12762 {{{quote|{{{1}}}}}}
12763 !! endarticle
12764
12765 !!test
12766 Templates: Template Name/Arg clash: 1. Use of positional param
12767 !! wikitext
12768 {{quote|foo}}
12769 !! html
12770 <p>foo
12771 </p>
12772 !!end
12773
12774 !!test
12775 Templates: Template Name/Arg clash: 2. Use of named param
12776 !! wikitext
12777 {{quote|quote=foo}}
12778 !! html
12779 <p>foo
12780 </p>
12781 !!end
12782
12783 !!test
12784 Templates: Template Name/Arg clash: 3. Use of named param with empty input
12785 !! wikitext
12786 {{quote|quote}}
12787 !! html
12788 <p>quote
12789 </p>
12790 !!end
12791
12792 ###
12793 ### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
12794 ###
12795
12796 !!test
12797 Templates: 1. Simple use
12798 !! wikitext
12799 {{echo|Foo}}
12800 !! html
12801 <p>Foo
12802 </p>
12803 !!end
12804
12805 !!test
12806 Templates: 2. Inside a block tag
12807 !! wikitext
12808 <div>{{echo|Foo}}</div>
12809 <blockquote>{{echo|Foo}}</blockquote>
12810 !! html
12811 <div>Foo</div>
12812 <blockquote>Foo</blockquote>
12813
12814 !! html+tidy
12815 <div>Foo</div>
12816 <blockquote><p>Foo</p></blockquote>
12817 !!end
12818
12819 !!test
12820 Templates: P-wrapping: 1a. Templates on consecutive lines
12821 !! wikitext
12822 {{echo|Foo}}
12823 {{echo|bar}}
12824 !! html
12825 <p>Foo
12826 bar
12827 </p>
12828 !!end
12829
12830 !!test
12831 Templates: P-wrapping: 1b. Templates on consecutive lines
12832 !! wikitext
12833 Foo
12834
12835 {{echo|bar}}
12836 {{echo|baz}}
12837 !! html
12838 <p>Foo
12839 </p><p>bar
12840 baz
12841 </p>
12842 !!end
12843
12844 !!test
12845 Templates: P-wrapping: 1c. Templates on consecutive lines
12846 !! wikitext
12847 {{echo|Foo}}
12848 {{echo|bar}} <div>baz</div>
12849 !! html
12850 <p>Foo
12851 </p>
12852 bar <div>baz</div>
12853
12854 !! html+tidy
12855 <p>Foo
12856 </p><p>
12857 bar </p><div>baz</div>
12858 !! end
12859
12860 !!test
12861 Templates: P-wrapping: 1d. Template preceded by comment-only line
12862 !!options
12863 parsoid
12864 !! wikitext
12865 <!-- foo -->
12866 {{echo|Bar}}
12867 !! html
12868 <!-- foo -->
12869
12870 <p about="#mwt223" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar"}},"i":0}}]}'>Bar</p>
12871 !!end
12872
12873 !!test
12874 Templates: Inline Text: 1. Multiple template uses
12875 !! wikitext
12876 {{echo|Foo}}bar{{echo|baz}}
12877 !! html
12878 <p>Foobarbaz
12879 </p>
12880 !!end
12881
12882 !!test
12883 Templates: Inline Text: 2. Back-to-back template uses
12884 !! wikitext
12885 {{echo|Foo}}{{echo|bar}}
12886 !! html
12887 <p>Foobar
12888 </p>
12889 !!end
12890
12891 !!test
12892 Templates: Block Tags: 1. Multiple template uses
12893 !! wikitext
12894 {{echo|<div>Foo</div>}}<div>bar</div>{{echo|<div>baz</div>}}
12895 !! html
12896 <div>Foo</div><div>bar</div><div>baz</div>
12897
12898 !!end
12899
12900 !!test
12901 Templates: Block Tags: 2. Back-to-back template uses
12902 !! wikitext
12903 {{echo|<div>Foo</div>}}{{echo|<div>bar</div>}}
12904 !! html
12905 <div>Foo</div><div>bar</div>
12906
12907 !!end
12908
12909 ## This is an edge case relating to paragraph wrapping.
12910 ## Note that Parsoid fails to match Remex because it's using the closing tag
12911 ## as a heuristic to determine if it's in a block, rather than SAX based events.
12912 ## And Parsoid drops empty elements in templates.
12913 !! test
12914 Templates: Correctly encapsulate templates producing </p> tag without a corresponding <p> tag
12915 !! wikitext
12916 {{echo|a
12917 b</p>}}
12918 !! html/php+tidy
12919 <p>a
12920 </p><p>
12921 b</p><p class="mw-empty-elt"></p>
12922 !! html/parsoid
12923 <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">
12924 </span><span about="#mwt1">b</span>
12925 !! end
12926
12927 !!test
12928 Templates: Links: 1. Simple example
12929 !! wikitext
12930 {{echo|[[Foo|bar]]}}
12931 !! html
12932 <p><a href="/wiki/Foo" title="Foo">bar</a>
12933 </p>
12934 !!end
12935
12936 !!test
12937 Templates: Links: 2. Generation of link href
12938 !! wikitext
12939 [[{{echo|Foo}}|bar]]
12940 !! html
12941 <p><a href="/wiki/Foo" title="Foo">bar</a>
12942 </p>
12943 !!end
12944
12945 !!test
12946 Templates: Links: 3. Generation of part of a link href
12947 !! wikitext
12948 [[Fo{{echo|o}}|bar]]
12949
12950 [[Foo{{echo|bar}}]]
12951
12952 [[Foo{{echo|bar}}baz]]
12953
12954 [[Foo{{echo|bar}}|bar]]
12955
12956 [[:Foo{{echo|bar}}]]
12957
12958 [[:Foo{{echo|bar}}|bar]]
12959 !! html
12960 <p><a href="/wiki/Foo" title="Foo">bar</a>
12961 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12962 </p><p><a href="/index.php?title=Foobarbaz&amp;action=edit&amp;redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a>
12963 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12964 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12965 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12966 </p>
12967 !!end
12968
12969 !!test
12970 Templates: Links: 4. Multiple templates generating link href
12971 !! wikitext
12972 [[{{echo|F}}{{echo|o}}ob{{echo|ar}}]]
12973 !! html
12974 <p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12975 </p>
12976 !!end
12977
12978 !!test
12979 Templates: Links: 5. Generation of link text
12980 !! wikitext
12981 [[Foo|{{echo|bar}}]]
12982 !! html
12983 <p><a href="/wiki/Foo" title="Foo">bar</a>
12984 </p>
12985 !!end
12986
12987 !!test
12988 Templates: Links: 5. Nested templates (only outermost template should be marked)
12989 !! wikitext
12990 {{echo|[[{{echo|Foo}}|bar]]}}
12991 !! html
12992 <p><a href="/wiki/Foo" title="Foo">bar</a>
12993 </p>
12994 !!end
12995
12996 !!test
12997 Templates: HTML Tag: 1. Generation of HTML attr. key
12998 !! wikitext
12999 <div {{echo|style}}="color:red;">foo</div>
13000 !! html
13001 <div style="color:red;">foo</div>
13002
13003 !!end
13004
13005 !!test
13006 Templates: HTML Tag: 2. Generation of HTML attr. value
13007 !! wikitext
13008 <div style={{echo|'color:red;'}}>foo</div>
13009 !! html
13010 <div style="color:red;">foo</div>
13011
13012 !!end
13013
13014 !!test
13015 Templates: HTML Tag: 3. Generation of HTML attr key and value
13016 !! wikitext
13017 <div {{echo|style}}={{echo|'color:red;'}}>foo</div>
13018 !! html
13019 <div style="color:red;">foo</div>
13020
13021 !!end
13022
13023 !!test
13024 Templates: HTML Tag: 4. Generation of starting piece of HTML attr value
13025 !! wikitext
13026 <div title="{{echo|This is a long title}} with just one piece templated">foo</div>
13027 !! html
13028 <div title="This is a long title with just one piece templated">foo</div>
13029
13030 !!end
13031
13032 !!test
13033 Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
13034 !! wikitext
13035 <div title="This is a long title with just {{echo|one piece}} templated">foo</div>
13036 !! html
13037 <div title="This is a long title with just one piece templated">foo</div>
13038
13039 !!end
13040
13041 !!test
13042 Templates: HTML Tag: 6. Generation of end piece of HTML attr value
13043 !! wikitext
13044 <div title="This is a long title with just one piece {{echo|templated}}">foo</div>
13045 !! html
13046 <div title="This is a long title with just one piece templated">foo</div>
13047
13048 !!end
13049
13050 # SSS FIXME: While it is great we added support for all this,
13051 # do we want to make this part of the spec? Maybe we want to
13052 # deprecate this kind of usage in the future?
13053 !!test
13054 Templates: HTML Tag: 7. Generation of partial attribute key string
13055 !! wikitext
13056 <div st{{echo|yle}}="color:red;">foo</div>
13057 !! html
13058 <div style="color:red;">foo</div>
13059
13060 !!end
13061
13062 !! test
13063 Templates: HTML Tag: 8. Template-generated attribute (k=v)
13064 !! wikitext
13065 <div {{echo|1=id="v1"}}>bar</div>
13066 !! html
13067 <div id="v1">bar</div>
13068
13069 !!end
13070
13071 !! test
13072 Templates: HTML Tag: 9. Multiple template-generated attributes
13073 !! wikitext
13074 <div {{echo|1=id="v1" title="foo"}}>bar</div>
13075 !! html
13076 <div id="v1" title="foo">bar</div>
13077
13078 !!end
13079
13080 !! test
13081 Templates: Support for templates generating attributes and content
13082 !! wikitext
13083 {| {{mixed_attr_content_template}}
13084 |-
13085 |bar
13086 |}
13087 !! html/php
13088 <table style="color:red;" title="T48811">
13089
13090 <tr>
13091 <td>foo
13092 </td></tr>
13093 <tr>
13094 <td>bar
13095 </td></tr></table>
13096
13097 !! html/parsoid
13098 <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|}"]}'>
13099 <tbody><tr>
13100 <td>foo</td></tr>
13101 <tr>
13102 <td>bar</td></tr>
13103 </tbody></table>
13104 !!end
13105
13106 !! article
13107 Template:attribute_from_template
13108 !! text
13109 class="123"
13110 !! endarticle
13111
13112 !! test
13113 Table cell with attribute before expanded attribute
13114 !! wikitext
13115 {|
13116 | align="center" {{attribute_from_template}} |456
13117 |}
13118 !! html/parsoid
13119 <table>
13120 <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>
13121 </tbody></table>
13122 !! end
13123
13124 !! test
13125 1. Entities and nowikis inside templated attributes should be handled correctly
13126 !! wikitext
13127 <div {{echo|style{{=}}"background:&#35;f9f9f9;"}}>foo</div>
13128 !! html/php
13129 <div style="background:#f9f9f9;">foo</div>
13130
13131 !! html/parsoid
13132 <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>
13133 !! end
13134
13135 !! test
13136 2. Entities and nowikis inside templated attributes should be handled correctly
13137 !! wikitext
13138 {|
13139 |{{table_attribs_3}}
13140 |}
13141 !! html/php
13142 <table>
13143 <tr>
13144 <td style="background:#f9f9f9;">Foo
13145 </td></tr></table>
13146
13147 !! html/parsoid
13148 <table>
13149 <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>
13150 </tbody></table>
13151 !! end
13152
13153 !! test
13154 3. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13155 !! wikitext
13156 {{tbl-start}}
13157 |{{table_attribs_3}}
13158 {{tbl-end}}
13159 !! html/php
13160 <table>
13161 <tr>
13162 <td style="background:#f9f9f9;">Foo
13163 </td></tr></table>
13164
13165 !! html/parsoid
13166 <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}}]}'>
13167 <tbody><tr><td style="background:#f9f9f9;">Foo</td></tr>
13168 </tbody></table>
13169 !! end
13170
13171 # T107622
13172 !! test
13173 4. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13174 !! wikitext
13175 {|
13176 |{{table_attribs_6}} hi
13177 |}
13178 !! html/php
13179 <table>
13180 <tr>
13181 <td style="background: red;">hi
13182 </td></tr></table>
13183
13184 !! html/parsoid
13185 <table>
13186 <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>
13187 </tbody></table>
13188 !! end
13189
13190 !!test
13191 Templates: HTML Tables: 1. Generating start of a HTML table
13192 !! wikitext
13193 {{echo|<table><tr><td>foo</td>}}</tr></table>
13194 !! html
13195 <table><tr><td>foo</td></tr></table>
13196
13197 !!end
13198
13199 !!test
13200 Templates: HTML Tables: 2a. Generating middle of a HTML table
13201 !! wikitext
13202 <table><tr>{{echo|<td>foo</td>}}</tr></table>
13203 !! html
13204 <table><tr><td>foo</td></tr></table>
13205
13206 !!end
13207
13208 !!test
13209 Templates: HTML Tables: 2b. Generating middle of a HTML table
13210 !! wikitext
13211 <table>{{echo|<tr><td>foo</td></tr>}}</table>
13212 !! html
13213 <table><tr><td>foo</td></tr></table>
13214
13215 !!end
13216
13217 !!test
13218 Templates: HTML Tables: 3. Generating end of a HTML table
13219 !! wikitext
13220 <table><tr>{{echo|<td>foo</td></tr></table>}}
13221 !! html
13222 <table><tr><td>foo</td></tr></table>
13223
13224 !!end
13225
13226 !!test
13227 Templates: HTML Tables: 4a. Generating a single tag of a HTML table
13228 !! wikitext
13229 {{echo|<table>}}<tr><td>foo</td></tr></table>
13230 !! html
13231 <table><tr><td>foo</td></tr></table>
13232
13233 !!end
13234
13235 !!test
13236 Templates: HTML Tables: 4b. Generating a single tag of a HTML table
13237 !! wikitext
13238 <table>{{echo|<tr>}}<td>foo</td></tr></table>
13239 !! html
13240 <table><tr><td>foo</td></tr></table>
13241
13242 !!end
13243
13244 !!test
13245 Templates: HTML Tables: 4c. Generating a single tag of a HTML table
13246 !! wikitext
13247 <table><tr>{{echo|<td>}}foo</td></tr></table>
13248 !! html
13249 <table><tr><td>foo</td></tr></table>
13250
13251 !!end
13252
13253 !!test
13254 Templates: HTML Tables: 4d. Generating a single tag of a HTML table
13255 !! wikitext
13256 <table><tr><td>foo{{echo|</td>}}</tr></table>
13257 !! html
13258 <table><tr><td>foo</td></tr></table>
13259
13260 !!end
13261
13262 !!test
13263 Templates: HTML Tables: 4e. Generating a single tag of a HTML table
13264 !! wikitext
13265 <table><tr><td>foo</td>{{echo|</tr>}}</table>
13266 !! html
13267 <table><tr><td>foo</td></tr></table>
13268
13269 !!end
13270
13271 !!test
13272 Templates: HTML Tables: 4f. Generating a single tag of a HTML table
13273 !! wikitext
13274 <table><tr><td>foo</td></tr>{{echo|</table>}}
13275 !! html
13276 <table><tr><td>foo</td></tr></table>
13277
13278 !!end
13279
13280 !!test
13281 Templates: HTML Tables: 5. Proper fostering of categories from inside
13282 !!options
13283 parsoid=wt2html,wt2wt
13284 !! wikitext
13285 <table>[[Category:foo1]]<tr><td>foo</td></tr></table>
13286 <!--Two categories (T52330)-->
13287 <table>[[Category:bar1]][[Category:bar2]]<tr><td>foo</td></tr></table>
13288 !! html
13289 <link rel="mw:PageProp/Category" href="./Category:Foo1"><table><tbody><tr><td>foo</td></tr></tbody></table>
13290 <!--Two categories (T52330)-->
13291 <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>
13292 !!end
13293
13294 !! test
13295 Templates: Wiki Tables: 1a. Fostering of entire template content
13296 !! wikitext
13297 {|
13298 {{echo|a}}
13299 |}
13300 !! html/php
13301 <table>
13302 a
13303 <tr><td></td></tr></table>
13304
13305 !! html/php+tidy
13306
13307 a
13308 <table><tbody><tr><td></td></tr></tbody></table>
13309 !! html/parsoid
13310 <span 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</span><table about="#mwt2">
13311
13312 </table>
13313 !! end
13314
13315 !!test
13316 Templates: Wiki Tables: 1b. Fostering of entire template content
13317 !! wikitext
13318 {|
13319 {{echo|<div>}}
13320 foo
13321 {{echo|</div>}}
13322 |}
13323 !! html
13324 <table>
13325 <div>
13326 <p>foo
13327 </p>
13328 </div>
13329 <tr><td></td></tr></table>
13330
13331 !! html/php+tidy
13332 <div>
13333 <p>foo
13334 </p>
13335 </div><table>
13336
13337 <tbody><tr><td></td></tr></tbody></table>
13338 !! html/parsoid
13339 <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|}"]}'>
13340 <p>foo</p>
13341 </div><table about="#mwt3">
13342
13343 </table>
13344 !! end
13345
13346 !! test
13347 Templates: Wiki Tables: 2. Fostering of partial template content
13348 !! wikitext
13349 {|
13350 {{echo|a
13351 <div>b</div>}}
13352 |}
13353 !! html/php
13354 <table>
13355 a
13356 <div>b</div>
13357 <tr><td></td></tr></table>
13358
13359 !! html/php+tidy
13360
13361 a
13362 <div>b</div><table>
13363 <tbody><tr><td></td></tr></tbody></table>
13364 !! html/parsoid
13365 <span 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</span><div about="#mwt2">b</div><table about="#mwt2">
13366
13367
13368 </table>
13369 !! end
13370
13371 !!test
13372 Templates: Wiki Tables: 3. td-content via multiple templates
13373 !! wikitext
13374 {|
13375 {{echo|{{pipe}}a}}{{echo|b}}
13376 |}
13377 !! html
13378 <table>
13379 <tr>
13380 <td>ab
13381 </td></tr></table>
13382
13383 !!end
13384
13385 !!test
13386 Templates: Wiki Tables: 4. Templated tags, no content
13387 !! wikitext
13388 {{tbl-start}}
13389 {{tbl-end}}
13390 !! html
13391 <table>
13392 <tr><td></td></tr></table>
13393
13394 !!end
13395
13396 !!test
13397 Templates: Wiki Tables: 5. Templated tags, regular td-tags
13398 !! wikitext
13399 {{tbl-start}}
13400 |foo
13401 {{tbl-end}}
13402 !! html
13403 <table>
13404 <tr>
13405 <td>foo
13406 </td></tr></table>
13407
13408 !!end
13409
13410 !!test
13411 Templates: Wiki Tables: 6. Templated tags, templated td-tags
13412 !! wikitext
13413 {{tbl-start}}
13414 {{!}}foo
13415 {{tbl-end}}
13416 !! html
13417 <table>
13418 <tr>
13419 <td>foo
13420 </td></tr></table>
13421
13422 !!end
13423
13424 ## This test case is very specific to Parsoid's internals
13425 ## and is hence only tested for Parsoid's code. Parsoid uses
13426 ## a <meta> marker tag for <ref> tags and they are expanded
13427 ## much later. We are verifying that this <meta> tag usage
13428 ## doesn't prevent foster parenting.
13429 !!test
13430 Templates: Wiki Tables: 7. Fosterable <ref>s should get fostered
13431 !!wikitext
13432 {{PartialTable}}<ref>foo</ref>
13433 |}
13434
13435 <references />
13436 !!html/parsoid
13437 <sup about="#mwt2" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Transclusion mw:Extension/ref" data-mw='{"parts":[{"template":{"target":{"wt":"PartialTable","href":"./Template:PartialTable"},"params":{},"i":0}},"&lt;ref>foo&lt;/ref>\n|}"]}'><a href="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></sup><table about="#mwt2">
13438 <tbody>
13439 </tbody></table>
13440
13441 <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>
13442 !!end
13443
13444 !! test
13445 Templates: Wiki Tables: 8. Fosterable meta-tags should get fostered
13446 !! wikitext
13447 {{echo|
13448 {{{!}}
13449 {{!}}-}}
13450 <onlyinclude>
13451 |foo
13452 </onlyinclude>
13453 {{!}}}
13454 !! html/parsoid
13455 <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{{!}}}"]}'>
13456 </span><meta typeof="mw:Includes/OnlyInclude" about="#mwt1"/><table about="#mwt1">
13457 <tbody><tr>
13458
13459 <td>foo
13460 <meta typeof="mw:Includes/OnlyInclude/End"/></td></tr>
13461 </tbody></table>
13462 !! end
13463
13464 !!test
13465 Templates: Lists: Multi-line list-items via templates
13466 !! wikitext
13467 *{{echo|a {{nonexistent|
13468 unused}}}}
13469 *{{echo|b {{nonexistent|
13470 unused}}}}
13471 !! html
13472 <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>
13473 <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>
13474
13475 !!end
13476
13477 !!test
13478 Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo)
13479 !! wikitext
13480 {{echo|''a}}{{echo|b''c''d}}{{echo|''e}}
13481 !! html
13482 <p><i>ab</i>c<i>d</i>e
13483 </p>
13484 !!end
13485
13486 !!test
13487 Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span)
13488 (PHP parser generates misnested html)
13489 !! wikitext
13490 {{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}}
13491 !! html/parsoid
13492 <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>
13493 !!end
13494
13495 !!test
13496 Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div)
13497 (PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s)
13498 !! options
13499 parsoid=wt2html,wt2wt
13500 !! wikitext
13501 {{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}}
13502 !! html
13503 <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>
13504 <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>
13505 <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>
13506 !!end
13507
13508 !!test
13509 Templates: Ugly nesting: 4. Divs opened/closed across templates
13510 !! wikitext
13511 a<div>b{{echo|c</div>d}}e
13512 !! html
13513 a<div>bc</div>de
13514
13515 !! html+tidy
13516 <p>a</p><div>bc</div><p>de
13517 </p>
13518 !! end
13519
13520 !! test
13521 Templates: Ugly templates: 3. newline-only template parameter
13522 !! wikitext
13523 foo {{echo|
13524 }}
13525 !! html
13526 <p>foo
13527 </p>
13528 !! end
13529
13530 # This looks like a bug: a single newline triggers p/br for some reason.
13531 !! test
13532 Templates: Ugly templates: 4. newline-only template parameter inconsistency
13533 !! wikitext
13534 {{echo|
13535 }}
13536 !! html
13537 <p><br />
13538 </p>
13539 !! end
13540
13541 # T66017 -- ugly wikitext with fostered content generates two template ranges that
13542 # have a true overlap (T1-start - T2-start - T1-end - T2-end).
13543 !! test
13544 Templates: Ugly templates: 5. Template encapsulation test: Non-trivial overlap of template ranges is properly handled
13545 !! wikitext
13546 {{echo|<table>}}
13547 {{echo|<div>foo}}
13548 {{echo|</table>}}
13549 !! html/parsoid
13550 <div about="#mwt1" typeof="mw:Transclusion" 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}}]}' data-parsoid='{"stx":"html","autoInsertedEnd":true,"pi":[[{"k":"1"}],[{"k":"1"}],[{"k":"1"}]]}'>foo
13551 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13552 </table>
13553 !! end
13554
13555 # T66017 -- ugly wikitext with fostered content generates two template ranges
13556 # that are "identical" and generate nesting cycles in the algorithm
13557 !! test
13558 Templates: Ugly templates: 6. Template encapsulation test: Cyclical nesting of template ranges is properly handled
13559 !! wikitext
13560 {{echo|<table><tr><td><table>}}
13561 {{echo|<div>}}
13562 {{echo|</div>}}
13563 !! html/parsoid
13564 <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"}'>
13565 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13566 </table></td></tr></tbody></table>
13567 !! end
13568
13569 !! test
13570 Templates: Parameters substituted at the top-level
13571 !! wikitext
13572 {{{foo|''who'' {{echo|me}}? '''never!'''}}}
13573
13574 {{{foo|bar|baz}}}
13575 !! html/php
13576 <p><i>who</i> me? <b>never!</b>
13577 </p><p>bar
13578 </p>
13579 !! html/parsoid
13580 <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>
13581
13582 <p about="#mwt3" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"foo"},"params":{"1":{"wt":"bar"},"2":{"wt":"baz"}},"i":0}}]}'>bar</p>
13583 !! end
13584
13585 !! test
13586 Templates: Param with empty arg in the final position
13587 !! wikitext
13588 {{{hi|}}}
13589 !! html/parsoid
13590 <span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"hi"},"params":{"1":{"wt":""}},"i":0}}]}'></span>
13591 !! end
13592
13593 !!test
13594 Parser Functions: 1. Simple example
13595 !! wikitext
13596 {{uc:foo}}
13597 !! html
13598 <p>FOO
13599 </p>
13600 !!end
13601
13602 !!test
13603 Parser Functions: 2. Nested use (only outermost should be marked up)
13604 !! wikitext
13605 {{uc:{{lc:FOO}}}}
13606 !! html
13607 <p>FOO
13608 </p>
13609 !!end
13610
13611 ## Note that the templates inside the references are not wrapped
13612 !! test
13613 Template nested in extension tag in template
13614 !! wikitext
13615 {{echo|hi<ref>[[ho|{{echo|hi}}]]</ref>}}
13616 {{echo|hi<ref>[http://test.com?q={{echo|ho}}]</ref>}}
13617 <references />
13618 !! html/parsoid
13619 <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","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{}}'><a href="./Main_Page#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup>
13620 <span about="#mwt7" 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="#mwt7" class="mw-ref" id="cite_ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-2"},"attrs":{}}'><a href="./Main_Page#cite_note-2" style="counter-reset: mw-Ref 2;"><span class="mw-reflink-text">[2]</span></a></sup></p>
13621 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt10" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text"><a rel="mw:WikiLink" href="./Ho" title="Ho" data-parsoid='{"stx":"piped","a":{"href":"./Ho"},"sa":{"href":"ho"}}'>hi</a></span></li><li about="#cite_note-2" id="cite_note-2"><a href="./Main_Page#cite_ref-2" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-2" class="mw-reference-text"><a typeof="mw:ExpandedAttrs" about="#mwt11" rel="mw:ExtLink" class="external autonumber" href="http://test.com?q=ho" data-mw='{"attribs":[[{"txt":"href"},{"html":"http://test.com?q=ho"}]]}'></a></span></li></ol>
13622 !! end
13623
13624 ###
13625 ### Pre-save transform tests
13626 ###
13627 !! test
13628 pre-save transform: subst:
13629 !! options
13630 pst
13631 !! wikitext
13632 {{subst:test}}
13633 !! html/php
13634 This is a test template
13635 !! end
13636
13637 !! test
13638 pre-save transform: normal template
13639 !! options
13640 pst
13641 !! wikitext
13642 {{test}}
13643 !! html/php
13644 {{test}}
13645 !! end
13646
13647 !! test
13648 pre-save transform: nonexistent template
13649 !! options
13650 pst
13651 !! wikitext
13652 {{thistemplatedoesnotexist}}
13653 !! html/php
13654 {{thistemplatedoesnotexist}}
13655 !! end
13656
13657 !! test
13658 pre-save transform: subst magic variables
13659 !! options
13660 pst
13661 !! wikitext
13662 {{subst:SITENAME}}
13663 !! html/php
13664 MediaWiki
13665 !! end
13666
13667 # This is T2089, which I fixed. -- wtm
13668 !! test
13669 pre-save transform: subst: templates with parameters
13670 !! options
13671 pst
13672 !! wikitext
13673 {{subst:paramtest|param="something else"}}
13674 !! html/php
13675 This is a test template with parameter "something else"
13676 !! end
13677
13678 !! article
13679 Template:nowikitest
13680 !! text
13681 <nowiki>'''not wiki'''</nowiki>
13682 !! endarticle
13683
13684 !! test
13685 pre-save transform: nowiki in subst (T3188)
13686 !! options
13687 pst
13688 !! wikitext
13689 {{subst:nowikitest}}
13690 !! html/php
13691 <nowiki>'''not wiki'''</nowiki>
13692 !! end
13693
13694 !! article
13695 Template:commenttest
13696 !! text
13697 This template has <!-- a comment --> in it.
13698 !! endarticle
13699
13700 !! test
13701 pre-save transform: comment in subst (T3936)
13702 !! options
13703 pst
13704 !! wikitext
13705 {{subst:commenttest}}
13706 !! html/php
13707 This template has <!-- a comment --> in it.
13708 !! end
13709
13710 !! test
13711 pre-save transform: unclosed tag
13712 !! options
13713 pst
13714 !! wikitext
13715 <nowiki>'''not wiki'''
13716 !! html/php
13717 <nowiki>'''not wiki'''
13718 !! end
13719
13720 !! test
13721 pre-save transform: mixed tag case
13722 !! options
13723 pst
13724 !! wikitext
13725 <NOwiki>'''not wiki'''</noWIKI>
13726 !! html/php
13727 <NOwiki>'''not wiki'''</noWIKI>
13728 !! end
13729
13730 !! test
13731 pre-save transform: unclosed comment in <nowiki>
13732 !! options
13733 pst
13734 !! wikitext
13735 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13736 !! html/php
13737 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13738 !!end
13739
13740 # Leading @ in this template definition works around a limitation
13741 # in parsoid's parserTests which otherwise strips the <span> from the
13742 # result (confusing it for a template wrapper)
13743 !! article
13744 Template:dangerous
13745 !!text
13746 @<span onmouseover="alert('crap')">Oh no</span>
13747 !!endarticle
13748
13749 !!test
13750 (confirming safety of fix for subst T3936)
13751 !! wikitext
13752 {{Template:dangerous}}
13753 !! html
13754 <p>@<span>Oh no</span>
13755 </p>
13756 !! end
13757
13758 !! test
13759 pre-save transform: comment containing gallery (T7024)
13760 !! options
13761 pst
13762 !! wikitext
13763 <!-- <gallery>data</gallery> -->
13764 !! html/php
13765 <!-- <gallery>data</gallery> -->
13766 !!end
13767
13768 !! test
13769 pre-save transform: comment containing extension
13770 !! options
13771 pst
13772 !! wikitext
13773 <!-- <tag>data</tag> -->
13774 !! html/php
13775 <!-- <tag>data</tag> -->
13776 !!end
13777
13778 !! test
13779 pre-save transform: comment containing nowiki
13780 !! options
13781 pst
13782 !! wikitext
13783 <!-- <nowiki>data</nowiki> -->
13784 !! html/php
13785 <!-- <nowiki>data</nowiki> -->
13786 !!end
13787
13788 !! test
13789 pre-save transform: <noinclude> in subst (T5298)
13790 !! options
13791 pst
13792 !! wikitext
13793 {{subst:Includes}}
13794 !! html/php
13795 Foobar
13796 !! end
13797
13798 !! test
13799 pre-save transform: <onlyinclude> in subst (T5298)
13800 !! options
13801 pst
13802 !! wikitext
13803 {{subst:Includes2}}
13804 !! html/php
13805 Foo
13806 !! end
13807
13808 !! article
13809 Template:SubstTest
13810 !!text
13811 {{<includeonly>subst:</includeonly>Includes}}
13812 !! endarticle
13813
13814 !! article
13815 Template:SafeSubstTest
13816 !! text
13817 {{<includeonly>safesubst:</includeonly>Includes}}
13818 !! endarticle
13819
13820 !! test
13821 T24297: safesubst: works during PST
13822 !! options
13823 pst
13824 !! wikitext
13825 {{subst:SafeSubstTest}}{{safesubst:SubstTest}}
13826 !! html/php
13827 FoobarFoobar
13828 !! end
13829
13830 !! test
13831 T24297: safesubst: works during normal parse
13832 !! wikitext
13833 {{SafeSubstTest}}
13834 !! html
13835 <p>Foobar
13836 </p>
13837 !! end
13838
13839 !! test
13840 subst: does not work during normal parse
13841 !! wikitext
13842 {{SubstTest}}
13843 !! html
13844 <p>{{subst:Includes}}
13845 </p>
13846 !! end
13847
13848 !! test
13849 pre-save transform: context links ("pipe trick")
13850 !! options
13851 pst
13852 !! wikitext
13853 [[Article (context)|]]
13854 [[Bar:Article|]]
13855 [[:Bar:Article|]]
13856 [[Bar:Article (context)|]]
13857 [[:Bar:Article (context)|]]
13858 [[|Article]]
13859 [[|Article (context)]]
13860 [[Bar:X (Y) Z|]]
13861 [[:Bar:X (Y) Z|]]
13862 !! html/php
13863 [[Article (context)|Article]]
13864 [[Bar:Article|Article]]
13865 [[:Bar:Article|Article]]
13866 [[Bar:Article (context)|Article]]
13867 [[:Bar:Article (context)|Article]]
13868 [[Article]]
13869 [[Article (context)]]
13870 [[Bar:X (Y) Z|X (Y) Z]]
13871 [[:Bar:X (Y) Z|X (Y) Z]]
13872 !! end
13873
13874 !! test
13875 pre-save transform: context links ("pipe trick") with interwiki prefix
13876 !! options
13877 pst
13878 !! wikitext
13879 [[interwiki:Article|]]
13880 [[:interwiki:Article|]]
13881 [[interwiki:Bar:Article|]]
13882 [[:interwiki:Bar:Article|]]
13883 !! html/php
13884 [[interwiki:Article|Article]]
13885 [[:interwiki:Article|Article]]
13886 [[interwiki:Bar:Article|Bar:Article]]
13887 [[:interwiki:Bar:Article|Bar:Article]]
13888 !! end
13889
13890 !! test
13891 pre-save transform: context links ("pipe trick") with parens in title
13892 !! options
13893 pst title=[[Somearticle (context)]]
13894 !! wikitext
13895 [[|Article]]
13896 !! html/php
13897 [[Article (context)|Article]]
13898 !! end
13899
13900 !! test
13901 pre-save transform: context links ("pipe trick") with comma in title
13902 !! options
13903 pst title=[[Someplace, Somewhere]]
13904 !! wikitext
13905 [[|Otherplace]]
13906 [[Otherplace, Elsewhere|]]
13907 [[Otherplace, Elsewhere, Anywhere|]]
13908 !! html/php
13909 [[Otherplace, Somewhere|Otherplace]]
13910 [[Otherplace, Elsewhere|Otherplace]]
13911 [[Otherplace, Elsewhere, Anywhere|Otherplace]]
13912 !! end
13913
13914 !! test
13915 pre-save transform: context links ("pipe trick") with parens and comma
13916 !! options
13917 pst title=[[Someplace (IGNORED), Somewhere]]
13918 !! wikitext
13919 [[|Otherplace]]
13920 [[Otherplace (place), Elsewhere|]]
13921 !! html/php
13922 [[Otherplace, Somewhere|Otherplace]]
13923 [[Otherplace (place), Elsewhere|Otherplace]]
13924 !! end
13925
13926 !! test
13927 pre-save transform: context links ("pipe trick") with comma and parens
13928 !! options
13929 pst title=[[Who, me? (context)]]
13930 !! wikitext
13931 [[|Yes, you.]]
13932 [[Me, Myself, and I (1937 song)|]]
13933 !! html/php
13934 [[Yes, you. (context)|Yes, you.]]
13935 [[Me, Myself, and I (1937 song)|Me, Myself, and I]]
13936 !! end
13937
13938 !! test
13939 pre-save transform: context links ("pipe trick") with namespace
13940 !! options
13941 pst title=[[Ns:Somearticle]]
13942 !! wikitext
13943 [[|Article]]
13944 !! html/php
13945 [[Ns:Article|Article]]
13946 !! end
13947
13948 !! test
13949 pre-save transform: context links ("pipe trick") with namespace and parens
13950 !! options
13951 pst title=[[Ns:Somearticle (context)]]
13952 !! wikitext
13953 [[|Article]]
13954 !! html/php
13955 [[Ns:Article (context)|Article]]
13956 !! end
13957
13958 !! test
13959 pre-save transform: context links ("pipe trick") with namespace and comma
13960 !! options
13961 pst title=[[Ns:Somearticle, Context, Whatever]]
13962 !! wikitext
13963 [[|Article]]
13964 !! html/php
13965 [[Ns:Article, Context, Whatever|Article]]
13966 !! end
13967
13968 !! test
13969 pre-save transform: context links ("pipe trick") with namespace, comma and parens
13970 !! options
13971 pst title=[[Ns:Somearticle, Context (context)]]
13972 !! wikitext
13973 [[|Article]]
13974 !! html/php
13975 [[Ns:Article (context)|Article]]
13976 !! end
13977
13978 !! test
13979 pre-save transform: context links ("pipe trick") with namespace, parens and comma
13980 !! options
13981 pst title=[[Ns:Somearticle (IGNORED), Context]]
13982 !! wikitext
13983 [[|Article]]
13984 !! html/php
13985 [[Ns:Article, Context|Article]]
13986 !! end
13987
13988 !! test
13989 pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, T32149)
13990 !! options
13991 pst
13992 !! wikitext
13993 [[Article(context)|]]
13994 [[Bar:Article(context)|]]
13995 [[:Bar:Article(context)|]]
13996 [[|Article(context)]]
13997 [[Bar:X(Y)Z|]]
13998 [[:Bar:X(Y)Z|]]
13999 !! html/php
14000 [[Article(context)|Article]]
14001 [[Bar:Article(context)|Article]]
14002 [[:Bar:Article(context)|Article]]
14003 [[Article(context)]]
14004 [[Bar:X(Y)Z|X(Y)Z]]
14005 [[:Bar:X(Y)Z|X(Y)Z]]
14006 !! end
14007
14008 !! test
14009 pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, T32149)
14010 !! options
14011 pst
14012 !! wikitext
14013 [[Article (context)|]]
14014 [[Bar:Article (context)|]]
14015 [[:Bar:Article (context)|]]
14016 [[|Article (context)]]
14017 [[Bar:X (Y) Z|]]
14018 [[:Bar:X (Y) Z|]]
14019 !! html/php
14020 [[Article (context)|Article]]
14021 [[Bar:Article (context)|Article]]
14022 [[:Bar:Article (context)|Article]]
14023 [[Article (context)]]
14024 [[Bar:X (Y) Z|X (Y) Z]]
14025 [[:Bar:X (Y) Z|X (Y) Z]]
14026 !! end
14027
14028 !! test
14029 pre-save transform: context links ("pipe trick") with parens and no space (Korean style, T32149)
14030 !! options
14031 pst
14032 !! wikitext
14033 [[Article(context)|]]
14034 [[Bar:Article(context)|]]
14035 [[:Bar:Article(context)|]]
14036 [[|Article(context)]]
14037 [[Bar:X(Y)Z|]]
14038 [[:Bar:X(Y)Z|]]
14039 !! html/php
14040 [[Article(context)|Article]]
14041 [[Bar:Article(context)|Article]]
14042 [[:Bar:Article(context)|Article]]
14043 [[Article(context)]]
14044 [[Bar:X(Y)Z|X(Y)Z]]
14045 [[:Bar:X(Y)Z|X(Y)Z]]
14046 !! end
14047
14048 !! test
14049 pre-save transform: context links ("pipe trick") with commas (T23660)
14050 !! options
14051 pst
14052 !! wikitext
14053 [[Article (context), context|]]
14054 [[Article (context),context|]]
14055 [[Bar:Article (context), context|]]
14056 [[Bar:Article (context),context|]]
14057 [[:Bar:Article (context), context|]]
14058 [[:Bar:Article (context),context|]]
14059 !! html/php
14060 [[Article (context), context|Article]]
14061 [[Article (context),context|Article]]
14062 [[Bar:Article (context), context|Article]]
14063 [[Bar:Article (context),context|Article]]
14064 [[:Bar:Article (context), context|Article]]
14065 [[:Bar:Article (context),context|Article]]
14066 !! end
14067
14068 !! test
14069 Parsoid: backwards pipe trick
14070 !! wikitext
14071 [[|'''bar''']]
14072 !! html/php
14073 <p>[[|<b>bar</b>]]
14074 </p>
14075 !! html/parsoid
14076 <p>[[|<b>bar</b>]]</p>
14077 !! end
14078
14079 !! test
14080 pre-save transform: trim trailing empty lines
14081 !! options
14082 pst
14083 !! wikitext
14084 Empty lines are trimmed
14085
14086
14087
14088
14089 !! html/php
14090 Empty lines are trimmed
14091 !! end
14092
14093 !! test
14094 pre-save transform: Signature expansion
14095 !! options
14096 pst
14097 !! wikitext
14098 * ~~~
14099 * ~~~~
14100 * ~~~~~
14101 * <noinclude>~~~</noinclude>
14102 * <includeonly>~~~</includeonly>
14103 * <onlyinclude>~~~</onlyinclude>
14104 !! html/php
14105 * [[Special:Contributions/127.0.0.1|127.0.0.1]]
14106 * [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
14107 * 00:02, 1 January 1970 (UTC)
14108 * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
14109 * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
14110 * <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>
14111 !! end
14112
14113
14114 !! test
14115 ParserOutput flags from signature expansion (T84843)
14116 !! options
14117 pst
14118 showflags
14119 !! wikitext
14120 ~~~~
14121 !! html/php
14122 [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
14123 flags=user-signature
14124 !! end
14125
14126
14127 !! test
14128 pre-save transform: Signature expansion in nowiki tags (T2093)
14129 !! options
14130 pst disabled
14131 !! wikitext
14132 Shall not expand:
14133
14134 <nowiki>~~~~</nowiki>
14135
14136 <includeonly><nowiki>~~~~</nowiki></includeonly>
14137
14138 <noinclude><nowiki>~~~~</nowiki></noinclude>
14139
14140 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14141
14142 {{subst:Foo}} shall be converted to FOO
14143
14144 As well as inside noinclude/onlyinclude
14145 <noinclude>{{subst:Foo}}</noinclude>
14146 <onlyinclude>{{subst:Foo}}</onlyinclude>
14147
14148 But not inside includeonly
14149 <includeonly>{{subst:Foo}}</includeonly>
14150 !! html/php
14151 Shall not expand:
14152
14153 <nowiki>~~~~</nowiki>
14154
14155 <includeonly><nowiki>~~~~</nowiki></includeonly>
14156
14157 <noinclude><nowiki>~~~~</nowiki></noinclude>
14158
14159 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14160
14161 FOO shall be converted to FOO
14162
14163 As well as inside noinclude/onlyinclude
14164 <noinclude>FOO</noinclude>
14165 <onlyinclude>FOO</onlyinclude>
14166
14167 But not inside includeonly
14168 <includeonly>{{subst:Foo}}</includeonly>
14169 !! end
14170
14171 !! test
14172 Parsoid: Recognize nowiki with trailing space in tags
14173 !! options
14174 parsoid=wt2html
14175 !! wikitext
14176 <nowiki ><div>[[foo]]</nowiki >
14177
14178 a<nowiki / >b
14179
14180 c<nowiki />d
14181
14182 e<nowiki/ >f
14183 !! html
14184 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
14185 <p>ab</p>
14186 <p>cd</p>
14187 <p>ef</p>
14188 !! end
14189
14190 !! test
14191 Parsoid: Recognize nowiki with odd capitalization
14192 !! options
14193 parsoid=wt2html
14194 !! wikitext
14195 <noWikI ><div>[[foo]]</Nowiki >
14196 !! html
14197 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
14198 !! end
14199
14200
14201 !! test
14202 Parsoid: Escape nowiki with trailing space in tags
14203 !! options
14204 parsoid=html2wt
14205 !! html/parsoid
14206 <p>&lt;nowiki &gt; foo &lt/nowiki ></p>
14207 <p>a&lt;nowiki /&gt;b</p>
14208 <p>c&lt;nowiki/ &gt;d</p>
14209 !! wikitext
14210 &lt;nowiki &gt; foo &lt;/nowiki &gt;
14211
14212 a&lt;nowiki /&gt;b
14213
14214 c&lt;nowiki/ &gt;d
14215 !! end
14216
14217 !! test
14218 Parsoid: Escape weird noWikI capitalizations
14219 !! options
14220 parsoid=html2wt
14221 !! html/parsoid
14222 <p>&lt;noWikI &gt; foo &lt/NoWikI ></p>
14223 !! wikitext
14224 &lt;noWikI &gt; foo &lt;/NoWikI &gt;
14225 !! end
14226
14227 ###
14228 ### Message transform tests
14229 ###
14230 !! test
14231 message transform: magic variables
14232 !! options
14233 msg
14234 !! wikitext
14235 {{SITENAME}}
14236 !! html
14237 MediaWiki
14238 !! end
14239
14240 !! test
14241 message transform: should not transform wiki markup
14242 !! options
14243 msg
14244 !! wikitext
14245 ''test''
14246 !! html
14247 ''test''
14248 !! end
14249
14250 !! test
14251 message transform: <noinclude> in transcluded template (T6926)
14252 !! options
14253 msg
14254 !! wikitext
14255 {{Includes}}
14256 !! html
14257 Foobar
14258 !! end
14259
14260 !! test
14261 message transform: <onlyinclude> in transcluded template (T6926)
14262 !! options
14263 msg
14264 !! wikitext
14265 {{Includes2}}
14266 !! html
14267 Foo
14268 !! end
14269
14270 !! test
14271 {{#special:}} page name, known
14272 !! options
14273 msg
14274 !! wikitext
14275 {{#special:Recentchanges}}
14276 !! html
14277 Special:RecentChanges
14278 !! end
14279
14280 !! test
14281 {{#special:}} page name with subpage, known
14282 !! options
14283 msg
14284 !! wikitext
14285 {{#special:Recentchanges/param}}
14286 !! html
14287 Special:RecentChanges/param
14288 !! end
14289
14290 !! test
14291 {{#special:}} page name, unknown
14292 !! options
14293 msg
14294 !! wikitext
14295 {{#special:foobar nonexistent}}
14296 !! html
14297 Special:Foobar nonexistent
14298 !! end
14299
14300 !! test
14301 {{#speciale:}} page name, known
14302 !! options
14303 msg
14304 !! wikitext
14305 {{#speciale:Recentchanges}}
14306 !! html
14307 Special:RecentChanges
14308 !! end
14309
14310 !! test
14311 {{#speciale:}} page name with subpage, known
14312 !! options
14313 msg
14314 !! wikitext
14315 {{#speciale:Recentchanges/param}}
14316 !! html
14317 Special:RecentChanges/param
14318 !! end
14319
14320 !! test
14321 {{#speciale:}} page name, unknown
14322 !! options
14323 msg
14324 !! wikitext
14325 {{#speciale:foobar nonexistent}}
14326 !! html
14327 Special:Foobar_nonexistent
14328 !! end
14329
14330 ###
14331 ### Images
14332 ###
14333 ### For Parsoid-specific tests, see
14334 #### https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
14335
14336 !! test
14337 Simple image
14338 !! options
14339 parsoid=wt2html,wt2wt,html2html
14340 !! wikitext
14341 [[Image:foobar.jpg]]
14342 !! html/php
14343 <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>
14344 </p>
14345 !! html/parsoid
14346 <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>
14347 !! end
14348
14349 !! test
14350 Serialize simple image with span wrapper
14351 !! options
14352 parsoid=html2wt
14353 !! html/parsoid
14354 <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>
14355 !! wikitext
14356 [[File:Foobar.jpg]]
14357 !! end
14358
14359 !! test
14360 Simple image (using File: namespace, now canonical)
14361 !! wikitext
14362 [[File:Foobar.jpg]]
14363 !! html/php
14364 <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>
14365 </p>
14366 !! html/parsoid
14367 <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>
14368 !! end
14369
14370 !! test
14371 Right-aligned image
14372 !! wikitext
14373 [[File:Foobar.jpg|right]]
14374 !! html/php
14375 <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>
14376
14377 !! html/parsoid
14378 <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>
14379 !! end
14380
14381 !! test
14382 Image with caption
14383 !! wikitext
14384 [[File:Foobar.jpg|right|Caption text]]
14385 !! html/php
14386 <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>
14387
14388 !! html/parsoid
14389 <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>
14390 !! end
14391
14392 !! test
14393 Image with caption, T55312 #1
14394 !! wikitext
14395 [[File:Foobar.jpg|right|Caption page stuff]]
14396 !! html/php
14397 <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>
14398
14399 !! html/parsoid
14400 <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>
14401 !! end
14402
14403 !! test
14404 Image with caption, T55312 #2
14405 !! wikitext
14406 [[File:Foobar.jpg|right|Caption page=]]
14407 !! html/php
14408 <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>
14409
14410 !! html/parsoid
14411 <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>
14412 !! end
14413
14414 !! test
14415 Image with caption, T55312 #3
14416 !! wikitext
14417 [[File:Foobar.jpg|right|Caption page=stuff]]
14418 !! html/php
14419 <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>
14420
14421 !! html/parsoid
14422 <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>
14423 !! end
14424
14425 !! test
14426 Image caption with pipe entity
14427 !! wikitext
14428 [[File:Foobar.jpg|thumb|one &#x7C; two]]
14429 [[File:Foobar.jpg|thumb|one ''two'' &#x7C; three]]
14430 !! html/php
14431 <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>
14432 <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>
14433
14434 !! html/parsoid
14435 <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>
14436 <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>
14437 !! end
14438
14439 !! test
14440 Allow empty links in image captions (T62753)
14441 !! options
14442 thumbsize=220
14443 !! wikitext
14444 [[File:Foobar.jpg|thumb|Caption [[Link1]]
14445 [[]]
14446 [[Link2]]
14447 ]]
14448 !! html/php
14449 <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>
14450
14451 !! html/parsoid
14452 <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>
14453 [[]]
14454 <a rel="mw:WikiLink" href="./Link2" title="Link2" data-parsoid='{"stx":"simple","a":{"href":"./Link2"},"sa":{"href":"Link2"}}'>Link2</a>
14455 </figcaption></figure>
14456 !! end
14457
14458 !! test
14459 Titles in unlinked images (T23454)
14460 !! wikitext
14461 [[File:Foobar.jpg|link=|stuff]]
14462 !! html/php
14463 <p><img alt="stuff" src="http://example.com/images/3/3a/Foobar.jpg" title="stuff" width="1941" height="220" />
14464 </p>
14465 !! html/parsoid
14466 <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>
14467 !! end
14468
14469 !! test
14470 Link with empty target
14471 !! wikitext
14472 [[]]
14473 !! html
14474 <p>[[]]
14475 </p>
14476 !! end
14477
14478 !! test
14479 Image with link trail
14480 !! wikitext
14481 Linktrails should not work for images: [[File:Foobar.jpg]]s
14482 !! html/php
14483 <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
14484 </p>
14485 !! html/parsoid
14486 <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>
14487 !! end
14488
14489 !! test
14490 Image with empty attribute
14491 !! options
14492 parsoid=wt2html,wt2wt,html2html
14493 !! wikitext
14494 [[File:Foobar.jpg|right||Caption text]]
14495 !! html/php
14496 <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>
14497
14498 !! html/parsoid
14499 <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>
14500 !! end
14501
14502 !! test
14503 1. Block image with individual attributes from templates
14504 !! wikitext
14505 [[File:Foobar.jpg|thumb|{{echo|137px}}|This is a caption]]
14506 !! html/php
14507 <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>
14508
14509 !! html/parsoid
14510 <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>
14511 !! end
14512
14513 !! test
14514 2. Block Image with individual attributes from templates
14515 !! wikitext
14516 [[File:Foobar.jpg|{{echo|thumb}}|{{echo|137px}}|This is a caption]]
14517 !! html/php
14518 <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>
14519
14520 !! html/parsoid
14521 <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>
14522 !! end
14523
14524 !! test
14525 3. Inline image with individual attributes from templates
14526 !! wikitext
14527 [[File:Foobar.jpg|{{echo|50px}}]]
14528 !! html/php
14529 <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>
14530 </p>
14531 !! html/parsoid
14532 <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>
14533 !! end
14534
14535 ## Parsoid does not provide editing support for images where templates produce multiple image attributes.
14536 ## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
14537 !! test
14538 Image with multiple attributes from the same template
14539 !! wikitext
14540 [[File:Foobar.jpg|{{image_attribs}}]]
14541 !! html/php
14542 <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>
14543
14544 !! html/parsoid
14545 <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>
14546 !! end
14547
14548 !! test
14549 Image with link tails
14550 !! options
14551 thumbsize=220
14552 !! wikitext
14553 123[[File:Foobar.jpg]]456
14554 123[[File:Foobar.jpg|right]]456
14555 123[[File:Foobar.jpg|thumb]]456
14556 !! html/php
14557 <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
14558 </p>
14559 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
14560 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
14561
14562 !! html/php+tidy
14563 <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
14564 </p><p>
14565 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
14566 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
14567 </p>
14568 !! html/parsoid
14569 <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>
14570 <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</p>
14571 <p>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>
14572 !! end
14573
14574 !! test
14575 Image with multiple captions -- only last one is accepted
14576 !! wikitext
14577 [[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]]
14578 !! html/php
14579 <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>
14580
14581 !! html/parsoid
14582 <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>
14583 !! end
14584
14585 !! test
14586 Image with multiple widths -- use last
14587 !! wikitext
14588 [[File:Foobar.jpg|200px|300px|caption]]
14589 !! html/php
14590 <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>
14591 </p>
14592 !! html/parsoid
14593 <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>
14594 !! end
14595
14596 !! test
14597 Image with multiple alignments -- use first (T50664)
14598 !! options
14599 thumbsize=220
14600 !! wikitext
14601 [[File:Foobar.jpg|thumb|left|right|center|caption]]
14602
14603 [[File:Foobar.jpg|middle|text-top|caption]]
14604 !! html/php
14605 <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>
14606 <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>
14607 </p>
14608 !! html/parsoid
14609 <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>
14610 <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>
14611 !! end
14612
14613 !! test
14614 Image with width attribute at different positions
14615 !! wikitext
14616 [[File:Foobar.jpg|200px|right|Caption]]
14617 [[File:Foobar.jpg|right|200px|Caption]]
14618 [[File:Foobar.jpg|right|Caption|200px]]
14619 !! html/php
14620 <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>
14621 <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>
14622 <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>
14623
14624 !! html/parsoid
14625 <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>
14626 <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>
14627 <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>
14628 !! end
14629
14630 # a sad bit of backward-compatibility
14631 !! test
14632 Image with size specified with pxpx (T15500, T53628)
14633 !! options
14634 parsoid=wt2html,wt2wt,html2html
14635 !! wikitext
14636 [[File:Foobar.jpg|20pxpx]]
14637 [[File:Foobar.jpg|200x20pxpx]]
14638 !! html/php
14639 <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>
14640 <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>
14641 </p>
14642 !! html/parsoid
14643 <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>
14644 !! end
14645
14646 !! test
14647 Image with link parameter, wiki target
14648 !! wikitext
14649 [[File:Foobar.jpg|link=Main Page]]
14650 !! html/php
14651 <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>
14652 </p>
14653 !! html/parsoid
14654 <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>
14655 !! end
14656
14657 # parsoid T51293 (part 1)
14658 !! test
14659 Image with link parameter, URL target
14660 !! wikitext
14661 [[File:Foobar.jpg|link=http://example.com/]]
14662 !! html/php
14663 <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>
14664 </p>
14665 !! html/parsoid
14666 <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>
14667 !! end
14668
14669 # parsoid T51293 (part 2)
14670 !! test
14671 Image with link parameter, protocol-less URL target
14672 !! wikitext
14673 [[File:Foobar.jpg|link=//example.com/]]
14674 !! html/php
14675 <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>
14676 </p>
14677 !! html/parsoid
14678 <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>
14679 !! end
14680
14681 !! test
14682 Escaping non-block captions (T107435)
14683 !! options
14684 parsoid={
14685 "modes": ["wt2wt"],
14686 "changes": [
14687 ["[typeof~='mw:Image']", "attr", "data-mw", "{\"caption\": \"|\"}"]
14688 ]
14689 }
14690 !! wikitext
14691 [[Image:Foobar.jpg|caption]]
14692 !! wikitext/edited
14693 [[Image:Foobar.jpg|<nowiki>|</nowiki>]]
14694 !! end
14695
14696 # wgExternalLinkTarget not supported by Parsoid
14697 !! test
14698 Image with link parameter, wgExternalLinkTarget
14699 !! wikitext
14700 [[Image:foobar.jpg|link=http://example.com/]]
14701 !! config
14702 wgExternalLinkTarget='foobar'
14703 !! html/php
14704 <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>
14705 </p>
14706 !! end
14707
14708 !! test
14709 Image with link parameter, wgNoFollowLinks set to false
14710 !! wikitext
14711 [[Image:foobar.jpg|link=http://example.com/]]
14712 !! config
14713 wgNoFollowLinks=false
14714 !! html/php
14715 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14716 </p>
14717 !! end
14718
14719 !! test
14720 Image with link parameter, wgNoFollowDomainExceptions
14721 !! wikitext
14722 [[Image:foobar.jpg|link=http://example.com/]]
14723 !! config
14724 wgNoFollowDomainExceptions='example.com'
14725 !! html/php
14726 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14727 </p>
14728 !! end
14729
14730 # wgExternalLinkTarget not supported by Parsoid
14731 !! test
14732 Image with link parameter, wgExternalLinkTarget, unnamed parameter
14733 !! wikitext
14734 [[Image:foobar.jpg|link=http://example.com/|Title]]
14735 !! config
14736 wgExternalLinkTarget='foobar'
14737 !! html/php
14738 <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>
14739 </p>
14740 !! end
14741
14742 !! test
14743 Image with empty link parameter
14744 !! wikitext
14745 [[File:Foobar.jpg|link=]]
14746 !! html/php
14747 <p><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" />
14748 </p>
14749 !! html/parsoid
14750 <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>
14751 !! end
14752
14753 !! test
14754 Image with link parameter (wiki target) and unnamed parameter
14755 !! wikitext
14756 [[File:Foobar.jpg|link=Main_Page|Title]]
14757 !! html/php
14758 <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>
14759 </p>
14760 !! html/parsoid
14761 <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>
14762 !! end
14763
14764 !! test
14765 Image with link parameter (URL target) and unnamed parameter
14766 !! wikitext
14767 [[File:Foobar.jpg|link=http://example.com/|Title]]
14768 !! html/php
14769 <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>
14770 </p>
14771 !! html/parsoid
14772 <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>
14773 !! end
14774
14775 !! test
14776 Thumbnail image with link parameter
14777 !! options
14778 thumbsize=220
14779 parsoid=wt2html,wt2wt,html2html
14780 !! wikitext
14781 [[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
14782 !! html/php
14783 <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>
14784
14785 !! html/parsoid
14786 <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>
14787 !! end
14788
14789 !! test
14790 Manually-specified thumbnail image
14791 !! options
14792 thumbsize=220
14793 !! wikitext
14794 [[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
14795 !! html/php
14796 <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>
14797
14798 !! html/parsoid
14799 <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>
14800 !! end
14801
14802 !! test
14803 Manually-specified thumbnail image with explicit link to wiki page
14804 !! options
14805 thumbsize=220
14806 parsoid=wt2html,wt2wt,html2html
14807 !! wikitext
14808 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
14809 !! html/php
14810 <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>
14811
14812 !! html/parsoid
14813 <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>
14814 !! end
14815
14816 !! test
14817 Manually-specified thumbnail image with explicit link to url
14818 !! options
14819 thumbsize=220
14820 parsoid=wt2html,wt2wt,html2html
14821 !! wikitext
14822 [[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
14823 !! html/php
14824 <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>
14825
14826 !! html/parsoid
14827 <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>
14828 !! end
14829
14830 !! test
14831 Manually-specified thumbnail image with explicit no link
14832 !! options
14833 thumbsize=220
14834 parsoid=wt2html,wt2wt,html2html
14835 !! wikitext
14836 [[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
14837 !! html/php
14838 <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>
14839
14840 !! html/parsoid
14841 <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>
14842 !! end
14843
14844 !! test
14845 Manually-specified thumbnail image with explicit link and alt text
14846 !! options
14847 thumbsize=220
14848 parsoid=wt2html,wt2wt,html2html
14849 !! wikitext
14850 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
14851 !! html/php
14852 <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>
14853
14854 !! html/parsoid
14855 <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>
14856 !! end
14857
14858 !! test
14859 Image with frame and link
14860 !! options
14861 parsoid=wt2html,wt2wt,html2html
14862 !! wikitext
14863 [[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
14864 !! html/php
14865 <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>
14866
14867 !! html/parsoid
14868 <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>
14869 !! end
14870
14871 !! test
14872 Image with frame and link and explicit alt
14873 !! options
14874 parsoid=wt2html,wt2wt,html2html
14875 !! wikitext
14876 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]]
14877 !! html/php
14878 <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>
14879
14880 !! html/parsoid
14881 <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>
14882 !! end
14883
14884 !! test
14885 Image with wiki markup in implicit alt
14886 !! wikitext
14887 [[Image:Foobar.jpg|testing '''bold''' in alt]]
14888
14889 [[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
14890 !! html/php
14891 <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>
14892 </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>
14893 </p>
14894 !! html/parsoid
14895 <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>
14896
14897 <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>
14898 !! end
14899
14900 !! test
14901 Alt image option should handle most kinds of wikitext without barfing
14902 !! wikitext
14903 [[Image:Foobar.jpg|thumb|This is the image caption|alt=This is a [[link]] and a {{echo|''bold template''}}.]]
14904 !! html/php
14905 <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>
14906
14907 !! html/parsoid
14908 <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>
14909 !! end
14910
14911 !! test
14912 Image with table with attributes in caption
14913 !! options
14914 parsoid=wt2html,html2html
14915 !! wikitext
14916 [[File:Foobar.jpg|thumb|
14917 {| class="123" |
14918 |- class="456" |
14919 | ha
14920 |}
14921 ]]
14922 !! html/parsoid
14923 <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>
14924 <table class="123">
14925 <tbody><tr class="456" data-parsoid='{"startTagSrc":"|-"}'>
14926 <td> ha</td></tr>
14927 </tbody></table>
14928 </figcaption></figure>
14929 !! end
14930
14931 !! test
14932 Image with table with rows from templates in caption
14933 !! wikitext
14934 [[File:Foobar.jpg|thumb|
14935 {|
14936 {{echo|{{!}} hi}}
14937 |}
14938 ]]
14939 !! html/parsoid
14940 <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>
14941 <table>
14942 <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>
14943 </tbody></table>
14944 </figcaption></figure>
14945 !! end
14946
14947 !! test
14948 Image with nested tables in caption
14949 !! wikitext
14950 [[File:Foobar.jpg|thumb|Foo<br />
14951 {|
14952 |
14953 {|
14954 |z
14955 |}
14956 |}
14957 ]]
14958 !! html/parsoid
14959 <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}'/>
14960 <table>
14961 <tbody><tr><td>
14962 <table>
14963 <tbody><tr><td>z</td></tr>
14964 </tbody></table></td></tr>
14965 </tbody></table>
14966 </figcaption></figure>
14967 !! end
14968
14969 !! test
14970 Image with heading and horizontal rule in caption
14971 !! wikitext
14972 [[File:Foobar.jpg|thumb|
14973 ===Testing===
14974 123
14975 --------------
14976 ]]
14977 !! html/php
14978 <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>
14979
14980 !! html/parsoid
14981 <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>
14982 <h3 id="Testing">Testing</h3>
14983 123
14984 <hr data-parsoid='{"extra_dashes":10}'/>
14985 </figcaption></figure>
14986 !! end
14987
14988 ###################
14989 # Conflicting image format options.
14990 # First option specified should 'win'.
14991 # All three cases in each test should be identical.
14992
14993 !! test
14994 Image with 'frameless' first.
14995 !! options
14996 parsoid=wt2html,wt2wt,html2html
14997 !! wikitext
14998 [[File:Foobar.jpg|frameless|caption]]
14999
15000 [[File:Foobar.jpg|frameless|frame|caption]]
15001
15002 [[File:Foobar.jpg|frameless|thumb|caption]]
15003 !! html/php
15004 <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>
15005 </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>
15006 </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>
15007 </p>
15008 !! html/parsoid
15009 <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>
15010 <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>
15011 <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>
15012 !! end
15013
15014 !! test
15015 Image with 'frame' first.
15016 !! options
15017 parsoid=wt2html,wt2wt,html2html
15018 !! wikitext
15019 [[File:Foobar.jpg|frame|caption]]
15020 [[File:Foobar.jpg|frame|frameless|caption]]
15021 [[File:Foobar.jpg|frame|thumb|caption]]
15022 !! html/php
15023 <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>
15024 <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>
15025 <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>
15026
15027 !! html/parsoid
15028 <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>
15029 <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>
15030 <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>
15031 !! end
15032
15033 !! test
15034 Image with 'thumb' first.
15035 !! options
15036 parsoid=wt2html,wt2wt,html2html
15037 !! wikitext
15038 [[File:Foobar.jpg|thumb|caption]]
15039 [[File:Foobar.jpg|thumb|frameless|caption]]
15040 [[File:Foobar.jpg|thumb|frame|caption]]
15041 !! html/php
15042 <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>
15043 <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>
15044 <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>
15045
15046 !! html/parsoid
15047 <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>
15048 <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>
15049 <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>
15050 !! end
15051
15052 ###################
15053 # Image sizing.
15054 # See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
15055 # and https://phabricator.wikimedia.org/T64258
15056 # Foobar has actual size of 1941x220
15057 # 1. Thumbs & frameless always reduce, can't be enlarged unless it's
15058 # a scalable format.
15059 # 2. Framed images always ignore size options; always render at default size.
15060 # 3. "Unspecified format" and border are the only types which can be
15061 # enlarged.
15062
15063 !! test
15064 Image: unspecified format and border enlarge
15065 !! options
15066 parsoid=wt2html,wt2wt,html2html
15067 !! wikitext
15068 [[File:Foobar.jpg|2000px]]
15069
15070 [[File:Foobar.jpg|border|2000px]]
15071 !! html/php
15072 <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>
15073 </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>
15074 </p>
15075 !! html/parsoid
15076 <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>
15077 <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>
15078 !! end
15079
15080 !! test
15081 Image: "unspecified format" and border reduce
15082 !! options
15083 parsoid=wt2html,wt2wt,html2html
15084 !! wikitext
15085 [[File:Foobar.jpg|1000px]]
15086
15087 [[File:Foobar.jpg|border|1000px]]
15088 !! html/php
15089 <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>
15090 </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>
15091 </p>
15092 !! html/parsoid
15093 <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>
15094 <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>
15095 !! end
15096
15097 !! test
15098 Image: thumbs reduce
15099 !! options
15100 parsoid=wt2html,wt2wt,html2html
15101 !! wikitext
15102 [[File:Foobar.jpg|thumb|50px]]
15103 !! html/php
15104 <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>
15105
15106 !! html/parsoid
15107 <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>
15108 !! end
15109
15110 !! test
15111 Image: bitmap thumbs can't be enlarged past original size, but vector can.
15112 !! options
15113 parsoid=wt2html,wt2wt,html2html
15114 !! wikitext
15115 [[File:Foobar.jpg|thumb|2000px]]
15116
15117 [[File:Foobar.svg|thumb|2000px]]
15118 !! html/php
15119 <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>
15120 <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>
15121
15122 !! html/parsoid
15123 <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>
15124 <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>
15125 !! end
15126
15127 !! test
15128 Image: frameless can reduce in size
15129 !! options
15130 parsoid=wt2html,wt2wt,html2html
15131 !! wikitext
15132 [[File:Foobar.jpg|frameless|50px]]
15133 !! html/php
15134 <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>
15135 </p>
15136 !! html/parsoid
15137 <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>
15138 !! end
15139
15140 !! test
15141 Image: bitmap frameless can't be enlarged past original size, but vector can
15142 !! options
15143 parsoid=wt2html,wt2wt,html2html
15144 !! wikitext
15145 [[File:Foobar.jpg|frameless|2000px]]
15146
15147 [[File:Foobar.svg|frameless|2000px]]
15148 !! html/php
15149 <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>
15150 </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>
15151 </p>
15152 !! html/parsoid
15153 <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>
15154 <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>
15155 !! end
15156
15157 !! test
15158 Image: framed images are always unscaled.
15159 !! options
15160 parsoid=wt2html,wt2wt,html2html
15161 !! wikitext
15162 [[File:Foobar.jpg|frame]]
15163
15164 [[File:Foobar.jpg|frame|50px]]
15165
15166 [[File:Foobar.jpg|frame|50x50px]]
15167
15168 [[File:Foobar.jpg|frame|2000px]]
15169 !! html/php
15170 <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>
15171 <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>
15172 <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>
15173 <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>
15174
15175 !! html/parsoid
15176 <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>
15177 <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>
15178 <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>
15179 <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>
15180 !! end
15181
15182 ###################
15183
15184 !! test
15185 Link to image page- image page normally doesn't exists, hence edit link
15186 Add test with existing image page
15187 #<p><a href="/wiki/File:Test" title="Image:Test">Image:test</a>
15188 !! wikitext
15189 [[:Image:test]]
15190 !! html
15191 <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>
15192 </p>
15193 !! end
15194
15195 !! test
15196 T20784 Link to non-existent image page with caption should use caption as link text
15197 !! wikitext
15198 [[:Image:test|caption]]
15199 !! html
15200 <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>
15201 </p>
15202 !! end
15203
15204 !! test
15205 Frameless image caption with a free URL
15206 !! wikitext
15207 [[File:Foobar.jpg|http://example.com]]
15208 !! html/php
15209 <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>
15210 </p>
15211 !! html/parsoid
15212 <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>
15213 !! end
15214
15215 !! test
15216 Thumbnail image caption with a free URL
15217 !! options
15218 thumbsize=220
15219 !! wikitext
15220 [[File:Foobar.jpg|thumb|http://example.com]]
15221 !! html/php
15222 <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>
15223
15224 !! html/parsoid
15225 <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>
15226 !! end
15227
15228 !! test
15229 Thumbnail image caption with a free URL and explicit alt
15230 !! options
15231 thumbsize=220
15232 parsoid=wt2html,wt2wt,html2html
15233 !! wikitext
15234 [[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]]
15235 !! html/php
15236 <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>
15237
15238 !! html/parsoid
15239 <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>
15240 !! end
15241
15242 !! test
15243 SVG thumbnails with no language set
15244 !! options
15245 !! wikitext
15246 [[File:Foobar.svg|thumb|caption]]
15247 !! html/php
15248 <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>
15249
15250 !! html/parsoid
15251 <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>
15252 !! end
15253
15254 !! test
15255 SVG thumbnails with language de
15256 !! options
15257 parsoid=wt2html,wt2wt,html2html
15258 !! wikitext
15259 [[File:Foobar.svg|thumb|caption|lang=de]]
15260 !! html/php
15261 <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>
15262
15263 !! html/parsoid
15264 <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>
15265 !! end
15266
15267 !! test
15268 SVG thumbnails with invalid language code
15269 !! options
15270 parsoid=wt2html,wt2wt,html2html
15271 !! wikitext
15272 [[File:Foobar.svg|thumb|caption|lang=invalid:language:code]]
15273 !! html/php
15274 <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>
15275
15276 !! html/parsoid
15277 <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>
15278 !! end
15279
15280 !! test
15281 T3887: A ISBN with a thumbnail
15282 !! wikitext
15283 [[File:Foobar.jpg|thumb|ISBN 1235467890]]
15284 !! html/php
15285 <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>
15286
15287 !! html/parsoid
15288 <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>
15289 !! end
15290
15291 !! test
15292 T3887: A RFC with a thumbnail
15293 !! wikitext
15294 [[File:Foobar.jpg|thumb|This is RFC 12354]]
15295 !! html/php
15296 <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>
15297
15298 !! html/parsoid
15299 <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>
15300 !! end
15301
15302 !! test
15303 T3887: A mailto link with a thumbnail
15304 !! wikitext
15305 [[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
15306 !! html/php
15307 <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>
15308
15309 !! html/parsoid
15310 <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>
15311 !! end
15312
15313 # Pending resolution to T2368
15314 !! test
15315 T2648: Frameless image caption with a link
15316 !! wikitext
15317 [[File:Foobar.jpg|text with a [[link]] in it]]
15318 !! html/php
15319 <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>
15320 </p>
15321 !! html/parsoid
15322 <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>
15323 !! end
15324
15325 !! test
15326 T2648: Frameless image caption with a link (suffix)
15327 !! wikitext
15328 [[File:Foobar.jpg|text with a [[link]]foo in it]]
15329 !! html/php
15330 <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>
15331 </p>
15332 !! html/parsoid
15333 <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>
15334 !! end
15335
15336 !! test
15337 T2648: Frameless image caption with an interwiki link
15338 !! wikitext
15339 [[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
15340 !! html/php
15341 <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>
15342 </p>
15343 !! html/parsoid
15344 <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>
15345 !! end
15346
15347 !! test
15348 T2648: Frameless image caption with a piped interwiki link
15349 !! wikitext
15350 [[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
15351 !! html/php
15352 <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>
15353 </p>
15354 !! html/parsoid
15355 <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>
15356 !! end
15357
15358 !! test
15359 T107474: Frameless image caption with <nowiki>
15360 !! wikitext
15361 [[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]]
15362 !! html/parsoid
15363 <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>
15364 !! end
15365
15366 !! test
15367 Escape HTML special chars in image alt text
15368 !! wikitext
15369 [[File:Foobar.jpg|& < > "]]
15370 !! html/php
15371 <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>
15372 </p>
15373 !! html/parsoid
15374 <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>
15375 !! end
15376
15377 !! test
15378 Escape HTML special chars in image alt text with LanguageConverter
15379 !! options
15380 language=zh
15381 !! wikitext
15382 [[File:Foobar.jpg|& < > "]]
15383 !! html/php
15384 <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>
15385 </p>
15386 !! html/parsoid
15387 <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>
15388 !! end
15389
15390 !! test
15391 Entities in file name and attributes
15392 !! wikitext
15393 [[File:7%25 solution.gif|manualthumb=7%25 solution.gif|link=7%25 solution|[[7%25 solution]]]]
15394 !! html/php
15395 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=7%25_solution.gif" class="new" title="File:7% solution.gif">7% solution</a>
15396 </p>
15397 !! html/parsoid
15398 <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>
15399 !! end
15400
15401 !! test
15402 T2499: Alt text should have &#1234;, not &amp;1234;
15403 !! wikitext
15404 [[File:Foobar.jpg|&#9792;]]
15405 !! html/php
15406 <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>
15407 </p>
15408 !! html/parsoid
15409 <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>
15410 !! end
15411
15412 !! test
15413 Broken image caption with link
15414 !! options
15415 parsoid=wt2html,wt2wt,html2html
15416 !! wikitext
15417 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
15418 !! html/php
15419 <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.
15420 </p>
15421 !! html/parsoid
15422 <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>
15423 !! end
15424
15425 !! test
15426 Image caption containing another image
15427 !! wikitext
15428 [[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
15429 !! html/php
15430 <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>
15431
15432 !! html/parsoid
15433 <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>
15434 !! end
15435
15436 !! test
15437 Image: caption containing a newline
15438 !! wikitext
15439 [[File:Foobar.jpg|This
15440 *is some text]]
15441 !! html/php
15442 <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>
15443 </p>
15444 !! html/parsoid
15445 <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>
15446 !!end
15447
15448 !!test
15449 Image: caption containing leading space
15450 (The leading space should not trigger nowiki escaping in wt2wt mode)
15451 !! wikitext
15452 [[File:Foobar.jpg|thumb| bar]]
15453 !! html/php
15454 <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>
15455
15456 !! html/parsoid
15457 <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>
15458 !!end
15459
15460 # html/php output not have newlines after table, td, th, etc. because
15461 # Linker::makeThumbLink2() replaces the newlines with spaces since
15462 # the table is inside a caption.
15463 # FIXME: Verify if that circa 2004 fix is still required.
15464 !! test
15465 Image: caption containing a table
15466 !! options
15467 parsoid=wt2html,wt2wt,html2html
15468 !! wikitext
15469 [[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
15470 {|
15471 !Foo!!Bar
15472 |-
15473 |Foo1||Bar1
15474 |}
15475 and some more text.]]
15476 !! html/php
15477 <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>
15478
15479 !! html/parsoid
15480 <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
15481 <table>
15482 <tbody>
15483 <tr><th>Foo</th><th>Bar</th></tr>
15484 <tr>
15485 <td>Foo1</td>
15486 <td>Bar1</td></tr></tbody></table>and some more text.</figcaption></figure>
15487 !! end
15488
15489 !! test
15490 T5090: External links other than http: in image captions
15491 !! wikitext
15492 [[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
15493 !! html/php
15494 <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>
15495
15496 !! html/parsoid
15497 <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>
15498 !! end
15499
15500 !! test
15501 Custom class
15502 !! options
15503 parsoid=wt2html,wt2wt,html2html
15504 !! wikitext
15505 [[Image:foobar.jpg|a|class=b]]
15506 !! html/php
15507 <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>
15508 </p>
15509 !! html/parsoid
15510 <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>
15511 !! end
15512
15513 !! test
15514 Localized image handling (1).
15515 !! options
15516 parsoid=wt2html,wt2wt,html2html
15517 language=es
15518 !! wikitext
15519 [[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]]
15520 !! html/php
15521 <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>
15522
15523 !! html/parsoid
15524 <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>
15525 !! end
15526
15527 !! test
15528 Localized image handling (2).
15529 !! options
15530 thumbsize=220
15531 parsoid=wt2html,wt2wt,html2html
15532 language=es
15533 !! wikitext
15534 [[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
15535 !! html/php
15536 <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>
15537
15538 !! html/parsoid
15539 <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>
15540 !! end
15541
15542 !! test
15543 Localized image handling (3).
15544 !! options
15545 language=fa
15546 parsoid=html2wt
15547 !! html/parsoid
15548 <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>
15549 !! wikitext
15550 [[File:Foobar.jpg|بندانگشتی]]
15551 !! end
15552
15553 !! test
15554 "border", "frameless" and "class" attributes on an image.
15555 !! options
15556 thumbsize=220
15557 parsoid=wt2html,wt2wt,html2html
15558 !! wikitext
15559 [[File:Foobar.jpg|frameless|border|class=extra|caption]]
15560 !! html/php
15561 <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>
15562 </p>
15563 !! html/parsoid
15564 <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>
15565 !! end
15566
15567 # Note that 'right' is the default alignment, despite the misspelled 'righ' below
15568 !! test
15569 Invalid image attributes (T64500)
15570 !! options
15571 thumbsize=220
15572 parsoid=wt2html,wt2wt,html2html
15573 !! wikitext
15574 [[File:Foobar.jpg|thumb|float|left|caption]]
15575
15576 [[File:Foobar.jpg|thumb|righ|caption]]
15577
15578 [[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]]
15579 !! html/php
15580 <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>
15581 <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>
15582 <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>
15583
15584 !! html/parsoid
15585 <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>
15586 <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>
15587 <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>
15588 !! end
15589
15590 !! article
15591 File:Barfoo.jpg
15592 !! text
15593 #REDIRECT [[File:Barfoo.jpg]]
15594 !! endarticle
15595
15596 # FIXME: Parsoid should run this test -- but we'd need to teach the
15597 # mockAPI about the redirected Barfoo.jpg image.
15598 !! test
15599 Redirected image
15600 !! wikitext
15601 [[Image:Barfoo.jpg]]
15602 !! html/php
15603 <p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
15604 </p>
15605 !! end
15606
15607 !! test
15608 Missing image with uploads disabled
15609 !! options
15610 wgEnableUploads=0
15611 !! wikitext
15612 [[File:Foobaz.jpg]]
15613 !! html/php
15614 <p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a>
15615 </p>
15616 !! html/parsoid
15617 <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>
15618 !! end
15619
15620 # Parsoid-specific testing for images
15621 # https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
15622 # Currently imperfect due to a flaw in the Parsoid testrunner
15623 # Work in progress
15624 # THESE TESTS SHOULD BE MOVED UP and merged with the php-specific
15625 # image tests.
15626
15627 !! test
15628 Parsoid-specific image handling - simple image with size and middle alignment
15629 !! wikitext
15630 [[File:Foobar.jpg|middle|50px]]
15631 !! html/parsoid
15632 <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>
15633 !! end
15634
15635 !! test
15636 Parsoid-specific image handling - simple image with size, middle alignment, non-standard namespace alias
15637 !! options
15638 parsoid=wt2wt,wt2html,html2html
15639 !! wikitext
15640 [[Image:Foobar.jpg|middle|50px]]
15641 !! html/parsoid
15642 <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>
15643 !! end
15644
15645 !! test
15646 Parsoid-specific image handling - simple image with size and middle alignment (existing content)
15647 !! wikitext
15648 [[File:Foobar.jpg|50px|middle]]
15649 !! html/parsoid
15650 <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>
15651 !! end
15652
15653 !! test
15654 Parsoid-specific image handling - simple image with size and middle alignment and non-standard namespace name
15655 !! options
15656 parsoid=wt2html,wt2wt,html2html
15657 !! wikitext
15658 [[Image:Foobar.jpg|50px|middle]]
15659 !! html/parsoid
15660 <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>
15661 !! end
15662
15663 !! test
15664 Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
15665 !! wikitext
15666 [[File:Foobar.jpg|500x10px|baseline|caption]]
15667 !! html/parsoid
15668 <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>
15669 !! end
15670
15671 !! test
15672 Parsoid-specific image handling - simple image with border and size spec
15673 !! wikitext
15674 [[File:Foobar.jpg|50px|border|caption]]
15675 !! html/parsoid
15676 <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>
15677 !! end
15678
15679 !! test
15680 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15681 !! options
15682 parsoid=wt2html,html2html
15683 !! wikitext
15684 [[File:Foobar.jpg|left|baseline|thumb|caption content]]
15685 !! html/parsoid
15686 <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>
15687 !! end
15688
15689 !! test
15690 Parsoid-specific image handling - thumbnail with halign, valign, and caption (existing content)
15691 !! options
15692 parsoid=wt2html,html2html
15693 !! wikitext
15694 [[File:Foobar.jpg|thumb|left|baseline|caption content]]
15695 !! html/parsoid
15696 <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>
15697 !! end
15698
15699 !! test
15700 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption
15701 !! options
15702 parsoid=wt2html,html2html
15703 !! wikitext
15704 [[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
15705 !! html/parsoid
15706 <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>
15707 !! end
15708
15709 !! test
15710 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption (existing content)
15711 !! options
15712 parsoid=wt2html,html2html
15713 !! wikitext
15714 [[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
15715 !! html/parsoid
15716 <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>
15717 !! end
15718
15719 !! test
15720 Parsoid-specific image handling - framed image with specific size and caption (size is ignored)
15721 !! options
15722 parsoid=wt2html,wt2wt,html2html
15723 !! wikitext
15724 [[File:Foobar.jpg|frame|500x50px|caption]]
15725 !! html/parsoid
15726 <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>
15727 !! end
15728
15729 !! test
15730 Parsoid-specific image handling - framed image with specific size, halign, valign, and caption (size is ignored)
15731 !! options
15732 parsoid=wt2html,html2html
15733 !! wikitext
15734 [[File:Foobar.jpg|left|baseline|frame|500x50px|caption]]
15735 !! html/parsoid
15736 <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>
15737 !! end
15738
15739 !! test
15740 Parsoid-specific image handling - frameless image with specific size, border, and caption
15741 !! wikitext
15742 [[File:Foobar.jpg|frameless|442x50px|border|caption]]
15743 !! html/parsoid
15744 <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>
15745 !! end
15746
15747 !! test
15748 Parsoid-specific image handling - simple image with a formatted caption
15749 !! wikitext
15750 [[File:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]]
15751 !! html/parsoid
15752 <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>
15753 !! end
15754
15755 !! test
15756 Parsoid-specific image handling - caption with a template in it
15757 !! wikitext
15758 [[File:Foobar.jpg|thumb|200x23px|This caption has a {{echo|transclusion}} in it.]]
15759 !! html/parsoid
15760 <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>
15761 !! end
15762
15763 !! test
15764 Parsoid-specific image handling - caption with unbalanced tags in it
15765 !! options
15766 parsoid=wt2html,wt2wt,html2html
15767 !! wikitext
15768 foo
15769 [[File:Foobar.jpg|thumb|200x200px|This caption has a <center>unbalanced tag in it.]]
15770 bar
15771 !! html/parsoid
15772 <p>foo</p>
15773 <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>
15774 <p>bar</p>
15775 !! end
15776
15777 !! test
15778 Parsoid-specific image handling - empty caption (1)
15779 !! options
15780 parsoid=wt2html,wt2wt
15781 !! wikitext
15782 [[File:Foobar.jpg|thumb|]]
15783 !! html/parsoid
15784 <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>
15785 !! end
15786
15787 # empty captions don't get serialized unless we're in the "round trip" case
15788 !! test
15789 Parsoid-specific image handling - empty caption (2)
15790 !! options
15791 parsoid=html2wt
15792 !! html/parsoid
15793 <figure class="mw-default-size" typeof="mw:Image/Thumb">
15794 <a href="./File:Foobar.jpg">
15795 <img resource="./File:Foobar.jpg"
15796 src="//example.com/images/3/3a/Foobar.jpg"
15797 data-file-width="1941" data-file-height="220" data-file-type="bitmap"
15798 height="25" width="220"/>
15799 </a>
15800 <figcaption></figcaption>
15801 </figure>
15802 !! wikitext
15803 [[File:Foobar.jpg|thumb]]
15804 !! end
15805
15806 !! test
15807 Parsoid-specific image handling - whitespace caption
15808 !! wikitext
15809 [[File:Foobar.jpg|thumb| ]]
15810 !! html/parsoid
15811 <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>
15812 !! end
15813
15814 !! test
15815 Parsoid-specific image handling - lang option
15816 !! wikitext
15817 foo
15818 [[File:Foobar.svg|lang=de|caption]]
15819 bar
15820 !! html/parsoid
15821 <p>foo
15822 <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>
15823 bar</p>
15824 !! end
15825
15826 ## Edge case bugs in Parsoid from T93580
15827 !! test
15828 T93580: 1. Templated <ref> inside block images
15829 !! wikitext
15830 [[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]]
15831
15832 <references />
15833 !! html/parsoid
15834 <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>
15835
15836 <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>
15837 !! end
15838
15839 !! test
15840 T93580: 2. <ref> inside inline images
15841 !! wikitext
15842 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: <ref>foo</ref>]]
15843
15844 <references />
15845 !! html/parsoid
15846 <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\",\"body\":{\"id\":\"mw-reference-text-cite_note-1\"},\"attrs\":{}}&#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>
15847
15848 <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>
15849 !! end
15850
15851 !! test
15852 T93580: 3. Templated <ref> inside inline images
15853 !! wikitext
15854 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}]]
15855
15856 <references />
15857 !! html/parsoid
15858 <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>
15859
15860 <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>
15861 !! end
15862
15863 ###
15864 ### Subpages
15865 ###
15866 !! article
15867 Subpage test/subpage
15868 !! text
15869 foo
15870 !! endarticle
15871
15872 !! test
15873 Subpage link
15874 !! options
15875 subpage title=[[Subpage test]]
15876 !! wikitext
15877 [[/subpage]]
15878 !! html
15879 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
15880 </p>
15881 !! end
15882
15883 !! test
15884 Subpage noslash link
15885 !! options
15886 subpage title=[[Subpage test]]
15887 !! wikitext
15888 [[/subpage/]]
15889 !! html
15890 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
15891 </p>
15892 !! end
15893
15894 !! article
15895 Subpage test/1/2/subpage
15896 !! text
15897 blah
15898 !! endarticle
15899
15900 !! test
15901 Relative subpage noslash link
15902 !! options
15903 parsoid=wt2wt,wt2html,html2html
15904 subpage title=[[Subpage test/1/2/3/4]]
15905 !! wikitext
15906 [[../../subpage/]]
15907
15908 [[../../subpage]]
15909 !! html/php
15910 <p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a>
15911 </p><p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage test/1/2/subpage</a>
15912 </p>
15913 !! html/parsoid
15914 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a></p>
15915 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage_test/1/2/subpage</a></p>
15916 !! end
15917
15918 !! test
15919 Parsoid: dot-slash prefixed wikilinks
15920 !! wikitext
15921 [[./foo]]
15922
15923 [[././bar]]
15924
15925 [[././baz/]]
15926 !! html/php
15927 <p>[[./foo]]
15928 </p><p>[[././bar]]
15929 </p><p>[[././baz/]]
15930 </p>
15931 !! html/parsoid
15932 <p>[[./foo]]
15933 </p><p>[[././bar]]
15934 </p><p>[[././baz/]]
15935 </p>
15936 !! end
15937
15938 !! test
15939 Render invalid page names as plain text (T53090)
15940 !! wikitext
15941 [[./../foo|bar]]
15942 [[foo�|bar]]
15943 [[foo/.|bar]]
15944 [[foo/..|bar]]
15945 [[foo~~~bar]]
15946 [[foo>bar]]
15947 [[foo[bar]]
15948 [[.]]
15949 [[..]]
15950 [[foo././bar]]
15951 [[foo[http://example.com]xyz]]
15952
15953 [[{{echo|./../foo}}|bar]]
15954 [[{{echo|foo/.}}|bar]]
15955 [[{{echo|foo/..}}|bar]]
15956 [[{{echo|foo~~~~bar}}]]
15957 [[{{echo|foo>bar}}]]
15958 [[{{echo|foo././bar}}]]
15959 [[{{echo|foo{bar}}]]
15960 [[{{echo|foo}bar}}]]
15961 [[{{echo|foo[bar}}]]
15962 [[{{echo|foo]bar}}]]
15963 [[{{echo|foo<bar}}]]
15964 !!html/php
15965 <p>[[./../foo|bar]]
15966 [[foo�|bar]]
15967 [[foo/.|bar]]
15968 [[foo/..|bar]]
15969 [[foo~~~bar]]
15970 [[foo&gt;bar]]
15971 [[foo[bar]]
15972 [[.]]
15973 [[..]]
15974 [[foo././bar]]
15975 [[foo<a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>xyz]]
15976 </p><p>[[./../foo|bar]]
15977 [[foo/.|bar]]
15978 [[foo/..|bar]]
15979 [[foo~~~~bar]]
15980 [[foo&gt;bar]]
15981 [[foo././bar]]
15982 [[foo{bar]]
15983 [[foo}bar]]
15984 [[foo[bar]]
15985 [[foo]bar]]
15986 [[foo&lt;bar]]
15987 </p>
15988 !!html/parsoid
15989 <p>[[./../foo|bar]]
15990 [[foo�|bar]]
15991 [[foo/.|bar]]
15992 [[foo/..|bar]]
15993 [[foo~~~bar]]
15994 [[foo>bar]]
15995 [[foo[bar]]
15996 [[.]]
15997 [[..]]
15998 [[foo././bar]]
15999 [[foo<a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>xyz]]</p>
16000
16001 <p>[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"./../foo"}},"i":0}}]}'>./../foo</span>|bar]]
16002 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/."}},"i":0}}]}'>foo/.</span>|bar]]
16003 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/.."}},"i":0}}]}'>foo/..</span>|bar]]
16004 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo~~~~bar"}},"i":0}}]}'>foo~~~~bar</span>]]
16005 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo>bar"}},"i":0}}]}'>foo>bar</span>]]
16006 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo././bar"}},"i":0}}]}'>foo././bar</span>]]
16007 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo{bar"}},"i":0}}]}'>foo{bar</span>]]
16008 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}bar"}},"i":0}}]}'>foo}bar</span>]]
16009 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo[bar"}},"i":0}}]}'>foo[bar</span>]]
16010 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo]bar"}},"i":0}}]}'>foo]bar</span>]]
16011 [[<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>
16012 !!end
16013
16014 !! test
16015 Disabled subpages
16016 !! wikitext
16017 [[/subpage]]
16018 !! html
16019 <p><a href="/index.php?title=/subpage&amp;action=edit&amp;redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a>
16020 </p>
16021 !! end
16022
16023 !! test
16024 T2561: {{/Subpage}}
16025 !! options
16026 subpage title=[[Page]]
16027 !! wikitext
16028 {{/Subpage}}
16029 !! html
16030 <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>
16031 </p>
16032 !! end
16033
16034 ###
16035 ### Categories
16036 ###
16037 !! article
16038 Category:MediaWiki User's Guide
16039 !! text
16040 blah
16041 !! endarticle
16042
16043 !! test
16044 Link to category
16045 !! wikitext
16046 [[:Category:MediaWiki User's Guide]]
16047 !! html
16048 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User&#39;s Guide">Category:MediaWiki User's Guide</a>
16049 </p>
16050 !! end
16051
16052 !! test
16053 Simple category
16054 !! options
16055 cat
16056 !! wikitext
16057 [[Category:MediaWiki User's Guide]]
16058 !! html/php
16059 cat=MediaWiki_User's_Guide sort=
16060 !! html/parsoid
16061 <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"}}'/>
16062 !! end
16063
16064 !! test
16065 PAGESINCATEGORY invalid title fatal (r33546 fix)
16066 !! wikitext
16067 {{PAGESINCATEGORY:<bogus>}}
16068 !! html
16069 <p>0
16070 </p>
16071 !! end
16072
16073 !! test
16074 Category with different sort key
16075 !! options
16076 cat
16077 !! wikitext
16078 [[Category:MediaWiki User's Guide|Foo]]
16079 !! html/php
16080 cat=MediaWiki_User's_Guide sort=Foo
16081 !! html/parsoid
16082 <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"}}'/>
16083 !! end
16084
16085 !! test
16086 Category with identical sort key
16087 !! options
16088 cat
16089 !! wikitext
16090 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
16091 !! html/php
16092 cat=MediaWiki_User's_Guide sort=MediaWiki User's Guide
16093 !! html/parsoid
16094 <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"}}'/>
16095 !! end
16096
16097 !! test
16098 Category with empty sort key
16099 !! options
16100 cat
16101 pst
16102 !! wikitext
16103 [[Category:MediaWiki User's Guide|]]
16104 !! html/php
16105 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
16106 !! end
16107
16108 !! test
16109 Category with empty sort key and parentheses
16110 !! options
16111 cat
16112 pst
16113 !! wikitext
16114 [[Category:Foo (bar)|]]
16115 !! html/php
16116 [[Category:Foo (bar)|Foo]]
16117 !! end
16118
16119 !! test
16120 Category with link tail
16121 !! options
16122 cat
16123 pst
16124 !! wikitext
16125 123[[Category:Foo]]456
16126 !! html/php
16127 123[[Category:Foo]]456
16128 !! end
16129
16130 !! test
16131 Category with template
16132 !! options
16133 cat
16134 pst
16135 !! wikitext
16136 [[Category:{{echo|Foo}}]]
16137 !! html/php
16138 [[Category:{{echo|Foo}}]]
16139 !! end
16140
16141 !! test
16142 Category with template in sort key
16143 !! options
16144 cat
16145 pst
16146 !! wikitext
16147 [[Category:Foo|{{echo|Bar}}]]
16148 !! html/php
16149 [[Category:Foo|{{echo|Bar}}]]
16150 !! end
16151
16152 !! test
16153 Category with template in sort key and title
16154 !! options
16155 cat
16156 pst
16157 !! wikitext
16158 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16159 !! html/php
16160 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16161 !! end
16162
16163 ## We used to, but no longer wt2wt this test since the default serializer
16164 ## will normalize all categories to serialize on their own line.
16165 ## This wikitext usage is going to be fairly uncommon in production and
16166 ## selser will take care of preserving formatting in those scenarios.
16167 !! test
16168 Category / paragraph interactions
16169 !! options
16170 parsoid=wt2html
16171 !! wikitext
16172 Foo [[Category:Baz]] Bar
16173
16174 Foo [[Category:Baz]]
16175 Bar
16176
16177 Foo
16178 [[Category:Baz]]
16179 Bar
16180
16181 Foo
16182 [[Category:Baz]] Bar
16183
16184 Foo
16185 [[Category:Baz]]
16186 [[Category:Baz]]
16187 [[Category:Baz]]
16188 Bar
16189
16190 [[Category:Baz]]
16191 [[Category:Baz]]
16192 [[Category:Baz]]
16193
16194 [[Category:Baz]]
16195 {{echo|[[Category:Baz]]}}
16196 [[Category:Baz]]
16197 !! html/php
16198 <p>Foo Bar
16199 </p><p>Foo
16200 Bar
16201 </p><p>Foo
16202 Bar
16203 </p><p>Foo Bar
16204 </p><p>Foo
16205 Bar
16206 </p>
16207 !! html/parsoid
16208 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16209 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16210 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16211 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16212 <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>
16213 <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}}]}'/>
16214 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
16215 !! end
16216
16217 ## We used to, but no longer wt2wt this test since the default serializer
16218 ## will normalize all categories to serialize on their own line.
16219 ## This wikitext usage is going to be fairly uncommon in production and
16220 ## selser will take care of preserving formatting in those scenarios.
16221 ##
16222 ## The whitespace on the empty line is part of the test. Please do not delete
16223 !! test
16224 1. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16225 !! options
16226 parsoid=wt2html
16227 !! wikitext
16228 This
16229
16230 [[Category:Foo]] and this should be part of same paragraph (not an indent-pre)
16231
16232 {{echo|[[Category:Foo]] and so should this!}}
16233 !! html/php
16234 <p>This and this should be part of same paragraph (not an indent-pre) and so should this!
16235 </p>
16236 !! html/parsoid
16237 <p>This
16238
16239 <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of same paragraph (not an indent-pre)
16240
16241 <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>
16242 !! end
16243
16244 ## Parsoid will not try to wt2wt this while preserving newlines because
16245 ## it suppresses excess newlines within list items -- and we don't want to
16246 ## introduce a special case just for categories, which is, in reality somewhat
16247 ## odd behavior -- categories are unlikely to be used in list items like this
16248 ## in top-level pages and are only likely to show up in template-generated
16249 ## list items where this RT-ing is a non-issue.
16250 ##
16251 ## The whitespace on the empty line is part of the test. Please do not delete
16252 !! test
16253 2. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16254 !! options
16255 parsoid=wt2html
16256 !! wikitext
16257 * This
16258
16259 [[Category:Foo]] and this should be part of the same list item
16260 * So should this
16261
16262 {{echo|[[Category:Foo]] and this should be part of the same list item}}
16263 !! html
16264 <ul><li>This and this should be part of the same list item</li>
16265 <li>So should this and this should be part of the same list item</li></ul>
16266 !! html/parsoid
16267 <ul>
16268 <li>This <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of the same list item</li>
16269 <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>
16270 </ul>
16271 !! end
16272
16273 ## Newlines and categories that follow the last item of a list
16274 ## are treated differently because this (list followed by categories)
16275 ## is an extremely common pattern on wikis.
16276 !! test
16277 3. Categories and newlines: newline suppression for last list item should RT properly
16278 !! wikitext
16279 *a
16280 *b
16281
16282 [[Category:Foo]]
16283
16284 [[Category:Bar]]
16285 [[Category:Baz]]
16286
16287 :c
16288
16289 [[Category:C]]
16290
16291 ;d
16292
16293 [[Category:D]]
16294 !! html/parsoid
16295 <ul><li>a</li>
16296 <li>b</li></ul>
16297
16298 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
16299
16300 <link rel="mw:PageProp/Category" href="./Category:Bar"/>
16301 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
16302
16303 <dl><dd>c</dd></dl>
16304
16305 <link rel="mw:PageProp/Category" href="./Category:C"/>
16306
16307 <dl><dt>d</dt></dl>
16308
16309 <link rel="mw:PageProp/Category" href="./Category:D"/>
16310 !! end
16311
16312 !! test
16313 4. Categories and newlines: newline suppression for last list item should RT properly
16314 !! wikitext
16315 *a
16316 ****b
16317
16318 [[Category:Foo]]
16319 !! html/parsoid
16320 <ul><li>a
16321 <ul><li><ul><li><ul><li>b</li></ul></li></ul></li></ul></li></ul>
16322
16323 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16324 !! end
16325
16326 ## only wt2html for this to make sure the algo only applies to the rightmost path
16327 !! test
16328 5. Categories and newlines: migrateTrailingCategories dom pass should only run on the rightmost path of nested lists
16329 !! options
16330 parsoid=wt2html
16331 !! wikitext
16332 *a
16333 **b
16334 [[Category:Foo]]
16335 *c
16336 **d
16337 [[Category:Foo]]
16338 !! html/parsoid
16339 <ul><li>a
16340 <ul><li>b
16341 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul></li>
16342 <li>c
16343 <ul><li>d</li></ul></li></ul>
16344 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16345 !! end
16346
16347 ## We used to, but no longer wt2wt this test since the default serializer
16348 ## will normalize all categories to serialize on their own line.
16349 ## This wikitext usage is going to be fairly uncommon in production and
16350 ## selser will take care of preserving formatting in those scenarios.
16351 !! test
16352 6. Categories and newlines: migrateTrailingCategories dom pass should not migrate categories not preceded by newlines
16353 !! options
16354 parsoid=wt2html
16355 !! wikitext
16356 *a [[Category:Foo]]
16357 !! html/parsoid
16358 <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>
16359 !! end
16360
16361 # This test also demonstrates because of newline+category tunneling
16362 # through the list hander, template wrapping doesn't expand to the
16363 # containing list when the list item swallows the category.
16364 !! test
16365 7. Categories and newlines: migrateTrailingCategories dom pass should leave template content alone
16366 !! wikitext
16367 *{{echo|a
16368 [[Category:Foo]]}}
16369 !! html/parsoid
16370 <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
16371 </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>
16372 !! end
16373
16374 !! test
16375 8. Categories and newlines: migrateTrailingCategories dom pass should not get tripped by intervening templates
16376 !! wikitext
16377 *a
16378
16379 {{echo|[[Category:Foo]]
16380 [[Category:Bar]]}}
16381 [[Category:Baz]]
16382 !! html/parsoid
16383 <ul><li>a</li></ul>
16384
16385 <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">
16386 </span><link rel="mw:PageProp/Category" href="./Category:Bar" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
16387 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
16388 !! end
16389
16390 !! test
16391 Categories and newlines: migrateTrailingCategories dom pass should not get tripped by comments and whitespace
16392 !! wikitext
16393 *a
16394
16395 [[Category:Bar]]<!--boo1--> <!--boo2-->
16396 [[Category:Baz]]<!--boo3--> <!--boo4-->
16397 !! html/parsoid
16398 <ul><li>a</li></ul>
16399
16400 <link rel="mw:PageProp/Category" href="./Category:Bar"/><!--boo1--> <!--boo2-->
16401 <link rel="mw:PageProp/Category" href="./Category:Baz"/><!--boo3--> <!--boo4-->
16402 !! end
16403
16404 !! test
16405 Categories and newlines: should behave properly with linkprefix (T87753)
16406 !! options
16407 language=ar
16408 !! wikitext
16409 foo bar
16410 foo bar
16411 [[تصنيف:Foo]]
16412 [[تصنيف:Bar]]
16413 !! html/php
16414 <p>foo bar
16415 foo bar
16416 </p>
16417 !! html/parsoid
16418 <p>foo bar
16419 foo bar</p>
16420 <link rel="mw:PageProp/Category" href="./تصنيف:Foo"/>
16421 <link rel="mw:PageProp/Category" href="./تصنيف:Bar"/>
16422 !! end
16423
16424 !! test
16425 No regressions on internal links following category (T174639)
16426 !! options
16427 parsoid=wt2html,html2html
16428 !! wikitext
16429 [[Category:Foo]]<div>a
16430
16431 [[Foo]]</div>
16432 !! html/php
16433 <div>a
16434 <a href="/wiki/Foo" title="Foo">Foo</a></div>
16435
16436 !! html/parsoid
16437 <link rel="mw:PageProp/Category" href="./Category:Foo"/><div>a
16438
16439 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></div>
16440 !! end
16441
16442 # Note that Parsoid differs slightly from PHP due to T175421
16443 !! test
16444 11. Special case where only newlines separate links (T175416)
16445 !! options
16446 parsoid=wt2html,html2html
16447 !! wikitext
16448 [[Category:Foo]]
16449
16450 [[Foo]][[es:Alimento]]
16451
16452 [[Foo]]
16453 !! html/php
16454 <p><br />
16455 <a href="/wiki/Foo" title="Foo">Foo</a>
16456 </p><p><a href="/wiki/Foo" title="Foo">Foo</a>
16457 </p>
16458 !! html/parsoid
16459 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
16460
16461 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p><link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
16462
16463 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p>
16464 !! end
16465
16466 !! test
16467 Category links with multiple namespaces
16468 !! wikitext
16469 [[Category:Project:Foo]]
16470 !! html/parsoid
16471 <link rel="mw:PageProp/Category" href="./Category:Project:Foo" />
16472 !! end
16473
16474 !! test
16475 Parsoid: Serialize link to category page with colon escape
16476 !! options
16477 parsoid
16478 !! wikitext
16479
16480 [[:Category:Foo]]
16481 [[:Category:Foo|Bar]]
16482 !! html
16483 <p>
16484 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Category:Foo</a>
16485 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Bar</a>
16486 </p>
16487 !! end
16488
16489 # We used to, but no longer wt2wt this test since the default serializer
16490 # will normalize all categories to serialize on their own line.
16491 # This wikitext usage is going to be fairly uncommon in production and
16492 # selser will take care of preventing whitespace insertion if this
16493 # occurs in an article.
16494 #
16495 # html2html disabled for the same reason (whitespace insertion between
16496 # x and y).
16497 #
16498 # html2wt disabled because it localizes the "Category" namespace.
16499 !! test
16500 Link prefix/suffixes aren't applied to category links
16501 !! options
16502 parsoid=wt2html
16503 language=is
16504 !! wikitext
16505 x[[Category:Foo]]y
16506 !! html/php
16507 <p>xy
16508 </p>
16509 !! html/parsoid
16510 <p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p>
16511 !! end
16512
16513 !! test
16514 Link prefix/suffixes aren't applied to language links
16515 !! options
16516 parsoid=wt2html
16517 language=is
16518 !! wikitext
16519 x[[es:Foo]]y
16520 !! html/php
16521 <p>xy
16522 </p>
16523 !! html/parsoid
16524 <p>x<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo" data-parsoid=""/>y</p>
16525 !! end
16526
16527 !! test
16528 Parsoid: Serialize link to file page with colon escape
16529 !! options
16530 parsoid
16531 !! wikitext
16532
16533 [[:File:Foo.png]]
16534 [[:File:Foo.png|Bar]]
16535 !! html
16536 <p>
16537 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">File:Foo.png</a>
16538 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">Bar</a>
16539 </p>
16540 !! end
16541
16542 !! test
16543 Parsoid: Serialize a genuine category link without colon escape
16544 !! options
16545 parsoid
16546 !! wikitext
16547 [[Category:Foo]]
16548 [[Category:Foo|Bar]]
16549 !! html
16550 <link rel="mw:PageProp/Category" href="./Category:Foo">
16551 <link rel="mw:PageProp/Category" href="./Category:Foo#Bar">
16552 !! end
16553
16554 !! test
16555 Normalize hrefs properly before testing for invalid link targets (T72894)
16556 !! options
16557 parsoid=html2wt
16558 !! html/parsoid
16559 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/>
16560 !! wikitext
16561 [[Category:Toxine bactérienne]]
16562 !! end
16563
16564 !! test
16565 Parsoid: Defaultsort
16566 !! wikitext
16567 {{DEFAULTSORT:Foo}}
16568 !! html/parsoid
16569 <meta property="mw:PageProp/categorydefaultsort" content="Foo"/>
16570 !! end
16571
16572 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
16573 # But, this is a limitation of our representation and is documented in
16574 # TemplateHandler.js in processSpecialMagicWord
16575 !! test
16576 Parsoid: Defaultsort (template-generated)
16577 !! wikitext
16578 {{{{echo|DEFAULTSORT}}:Foo}}
16579 !! html/parsoid
16580 <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"}]]}'/>
16581 !! end
16582
16583 ###
16584 ### Inter-language links
16585 ###
16586 !! test
16587 Interlanguage links
16588 !! options
16589 ill
16590 !! wikitext
16591 [[es:Alimento]]
16592 [[fr:Nourriture]]
16593 [[zh:食品]]
16594 !! html/php
16595 es:Alimento fr:Nourriture zh:食品
16596 !! html/parsoid
16597 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
16598 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Nourriture"/>
16599 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/食品"/>
16600 !! end
16601
16602 !! test
16603 Duplicate interlanguage links (T26502)
16604 !! options
16605 ill
16606 !! wikitext
16607 [[es:1]]
16608 [[es:2]]
16609 [[fr:1]]
16610 [[fr:2]]
16611 !! html/php
16612 es:1 fr:1
16613 !! html/parsoid
16614 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/1"/>
16615 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/2"/>
16616 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/1"/>
16617 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/2"/>
16618 !! end
16619
16620 ###
16621 ### Sections
16622 ###
16623 !! test
16624 Basic section headings
16625 !! wikitext
16626 ==Headline 1==
16627 Some text
16628
16629 ==Headline 2==
16630 More
16631 ===Smaller headline===
16632 Blah blah
16633 !! html
16634 <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>
16635 <p>Some text
16636 </p>
16637 <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>
16638 <p>More
16639 </p>
16640 <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>
16641 <p>Blah blah
16642 </p>
16643 !! end
16644
16645 !! test
16646 Section headings with TOC
16647 !! wikitext
16648 ==Headline 1==
16649 ===Subheadline 1===
16650 =====Skipping a level=====
16651 ======Skipping a level======
16652
16653 ==Headline 2==
16654 Some text
16655 ===Another headline===
16656 !! html
16657 <div id="toc" class="toc"><input type="checkbox" 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>
16658 <ul>
16659 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
16660 <ul>
16661 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
16662 <ul>
16663 <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>
16664 <ul>
16665 <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>
16666 </ul>
16667 </li>
16668 </ul>
16669 </li>
16670 </ul>
16671 </li>
16672 <li class="toclevel-1 tocsection-5"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
16673 <ul>
16674 <li class="toclevel-2 tocsection-6"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
16675 </ul>
16676 </li>
16677 </ul>
16678 </div>
16679
16680 <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>
16681 <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>
16682 <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>
16683 <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>
16684 <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>
16685 <p>Some text
16686 </p>
16687 <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>
16688
16689 !! end
16690
16691 !! test
16692 TOC anchors don't collide
16693 !! wikitext
16694 __FORCETOC__
16695 ==Headline 2==
16696 ==Headline==
16697 ==Headline 2==
16698 ==Headline==
16699 !! html/php
16700 <div id="toc" class="toc"><input type="checkbox" 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>
16701 <ul>
16702 <li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
16703 <li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
16704 <li class="toclevel-1 tocsection-3"><a href="#Headline_2_2"><span class="tocnumber">3</span> <span class="toctext">Headline 2</span></a></li>
16705 <li class="toclevel-1 tocsection-4"><a href="#Headline_3"><span class="tocnumber">4</span> <span class="toctext">Headline</span></a></li>
16706 </ul>
16707 </div>
16708
16709 <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>
16710 <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>
16711 <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>
16712 <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>
16713
16714 !! end
16715
16716 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
16717 # Parsoid html2wt direction adds <nowiki> for level 7 and up.
16718 !! test
16719 Handling of sections up to level 6 and beyond
16720 !! options
16721 parsoid=wt2html
16722 !! wikitext
16723 =Level 1 Heading=
16724 ==Level 2 Heading==
16725 ===Level 3 Heading===
16726 ====Level 4 Heading====
16727 =====Level 5 Heading=====
16728 ======Level 6 Heading======
16729 =======Level 7 Heading=======
16730 ========Level 8 Heading========
16731 =========Level 9 Heading=========
16732 ==========Level 10 Heading==========
16733 !! html/php
16734 <div id="toc" class="toc"><input type="checkbox" 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>
16735 <ul>
16736 <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
16737 <ul>
16738 <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>
16739 <ul>
16740 <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>
16741 <ul>
16742 <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>
16743 <ul>
16744 <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>
16745 <ul>
16746 <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>
16747 <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>
16748 <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>
16749 <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>
16750 <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>
16751 </ul>
16752 </li>
16753 </ul>
16754 </li>
16755 </ul>
16756 </li>
16757 </ul>
16758 </li>
16759 </ul>
16760 </li>
16761 </ul>
16762 </div>
16763
16764 <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>
16765 <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>
16766 <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>
16767 <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>
16768 <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>
16769 <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>
16770 <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>
16771 <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>
16772 <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>
16773 <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>
16774
16775 !! html/parsoid
16776 <h1 id="Level_1_Heading" data-parsoid='{}'>Level 1 Heading</h1>
16777 <h2 id="Level_2_Heading" data-parsoid='{}'>Level 2 Heading</h2>
16778 <h3 id="Level_3_Heading" data-parsoid='{}'>Level 3 Heading</h3>
16779 <h4 id="Level_4_Heading" data-parsoid='{}'>Level 4 Heading</h4>
16780 <h5 id="Level_5_Heading" data-parsoid='{}'>Level 5 Heading</h5>
16781 <h6 id="Level_6_Heading" data-parsoid='{}'>Level 6 Heading</h6>
16782 <h6 id="=Level_7_Heading=" data-parsoid='{}'><span id=".3DLevel_7_Heading.3D" typeof="mw:FallbackId"></span>=Level 7 Heading=</h6>
16783 <h6 id="==Level_8_Heading==" data-parsoid='{}'><span id=".3D.3DLevel_8_Heading.3D.3D" typeof="mw:FallbackId"></span>==Level 8 Heading==</h6>
16784 <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>
16785 <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>
16786 !! end
16787
16788 !! test
16789 TOC regression (T11764)
16790 !! wikitext
16791 ==title 1==
16792 ===title 1.1===
16793 ====title 1.1.1====
16794 ===title 1.2===
16795 ==title 2==
16796 ===title 2.1===
16797 !! html
16798 <div id="toc" class="toc"><input type="checkbox" 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>
16799 <ul>
16800 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16801 <ul>
16802 <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>
16803 <ul>
16804 <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>
16805 </ul>
16806 </li>
16807 <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>
16808 </ul>
16809 </li>
16810 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16811 <ul>
16812 <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>
16813 </ul>
16814 </li>
16815 </ul>
16816 </div>
16817
16818 <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>
16819 <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>
16820 <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>
16821 <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>
16822 <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>
16823 <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>
16824
16825 !! end
16826
16827 !! test
16828 TOC for heading containing <span id="..."></span> (T96153)
16829 !! wikitext
16830 __FORCETOC__
16831 ==<span id="old-anchor"></span>New title==
16832 !! html/php
16833 <div id="toc" class="toc"><input type="checkbox" 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>
16834 <ul>
16835 <li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
16836 </ul>
16837 </div>
16838
16839 <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>
16840
16841 !! end
16842
16843 !! test
16844 TOC with wgMaxTocLevel=3 (T8204)
16845 !! options
16846 wgMaxTocLevel=3
16847 !! wikitext
16848 ==title 1==
16849 ===title 1.1===
16850 ====title 1.1.1====
16851 ===title 1.2===
16852 ==title 2==
16853 ===title 2.1===
16854 !! html
16855 <div id="toc" class="toc"><input type="checkbox" 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>
16856 <ul>
16857 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16858 <ul>
16859 <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>
16860 <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>
16861 </ul>
16862 </li>
16863 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16864 <ul>
16865 <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>
16866 </ul>
16867 </li>
16868 </ul>
16869 </div>
16870
16871 <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>
16872 <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>
16873 <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>
16874 <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>
16875 <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>
16876 <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>
16877
16878 !! end
16879
16880 !! test
16881 TOC with wgMaxTocLevel=3 and two level four headings (T8204)
16882 !! options
16883 wgMaxTocLevel=3
16884 !! wikitext
16885 ==Section 1==
16886 ===Section 1.1===
16887 ====Section 1.1.1====
16888 ====Section 1.1.1.1====
16889 ==Section 2==
16890 !! html
16891 <div id="toc" class="toc"><input type="checkbox" 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>
16892 <ul>
16893 <li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
16894 <ul>
16895 <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>
16896 </ul>
16897 </li>
16898 <li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li>
16899 </ul>
16900 </div>
16901
16902 <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>
16903 <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>
16904 <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>
16905 <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>
16906 <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>
16907
16908 !! end
16909
16910
16911 !! test
16912 Resolving duplicate section names
16913 !! wikitext
16914 ==Foo bar==
16915 ==Foo bar==
16916 !! html
16917 <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>
16918 <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>
16919
16920 !! end
16921
16922 !! test
16923 Resolving duplicate section names with differing case (T12721)
16924 !! wikitext
16925 ==Foo bar==
16926 ==Foo Bar==
16927 !! html
16928 <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>
16929 <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>
16930
16931 !! end
16932
16933 !! article
16934 Template:sections
16935 !! text
16936 ===Section 1===
16937 ==Section 2==
16938 !! endarticle
16939
16940 !! test
16941 Template with sections, __NOTOC__
16942 !! wikitext
16943 __NOTOC__
16944 ==Section 0==
16945 {{sections}}
16946 ==Section 4==
16947 !! html
16948 <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>
16949 <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>
16950 <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>
16951 <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>
16952
16953 !! end
16954
16955 !! test
16956 __NOEDITSECTION__ keyword
16957 !! wikitext
16958 __NOEDITSECTION__
16959 ==Section 1==
16960 ==Section 2==
16961 !! html
16962 <h2><span class="mw-headline" id="Section_1">Section 1</span></h2>
16963 <h2><span class="mw-headline" id="Section_2">Section 2</span></h2>
16964
16965 !! end
16966
16967 !! test
16968 Link inside a section heading
16969 !! wikitext
16970 ==Section with a [[Main Page|link]] in it==
16971 !! html
16972 <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>
16973
16974 !! end
16975
16976 !! test
16977 TOC regression (T14077)
16978 !! wikitext
16979 __TOC__
16980 ==title 1==
16981 ===title 1.1===
16982 ==title 2==
16983 !! html
16984 <div id="toc" class="toc"><input type="checkbox" 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>
16985 <ul>
16986 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16987 <ul>
16988 <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>
16989 </ul>
16990 </li>
16991 <li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li>
16992 </ul>
16993 </div>
16994
16995 <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>
16996 <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>
16997 <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>
16998
16999 !! end
17000
17001 !! test
17002 T3219 URL next to image (good)
17003 !! wikitext
17004 http://example.com [[File:Foobar.jpg]]
17005 !! html/php
17006 <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>
17007 </p>
17008 !! html/parsoid
17009 <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>
17010 !!end
17011
17012 # Parsoid doesn't wt2wt this cleanly because it adds <nowiki>s.
17013 !! test
17014 Short headings with trailing space should match behavior of Parser::doHeadings (T21910)
17015 !! options
17016 parsoid=wt2html,html2html
17017 !! wikitext
17018 ===
17019 The line above must have a trailing space!
17020 === <!--
17021 --> <!-- -->
17022 But just in case it doesn't...
17023 !! html/php
17024 <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>
17025 <p>The line above must have a trailing space!
17026 </p>
17027 <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>
17028 <p>But just in case it doesn't...
17029 </p>
17030 !! html/parsoid
17031 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
17032 <p>The line above must have a trailing space!</p>
17033 <h1 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h1> <!--
17034 --> <!-- -->
17035 <p>But just in case it doesn't...</p>
17036 !! end
17037
17038 !! test
17039 Header with special characters (T27462)
17040 !! wikitext
17041 The tooltips shall not show entities to the user (ie. be double escaped)
17042
17043 ==text > text==
17044 section 1
17045
17046 ==text < text==
17047 section 2
17048
17049 ==text & text==
17050 section 3
17051
17052 ==text ' text==
17053 section 4
17054
17055 ==text " text==
17056 section 5
17057 !! html/php
17058 <p>The tooltips shall not show entities to the user (ie. be double escaped)
17059 </p>
17060 <div id="toc" class="toc"><input type="checkbox" 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>
17061 <ul>
17062 <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>
17063 <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>
17064 <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>
17065 <li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li>
17066 <li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li>
17067 </ul>
17068 </div>
17069
17070 <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>
17071 <p>section 1
17072 </p>
17073 <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>
17074 <p>section 2
17075 </p>
17076 <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>
17077 <p>section 3
17078 </p>
17079 <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>
17080 <p>section 4
17081 </p>
17082 <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>
17083 <p>section 5
17084 </p>
17085 !! html/parsoid
17086 <p>The tooltips shall not show entities to the user (ie. be double escaped)</p>
17087
17088 <h2 id="text_>_text"><span id="text_.3E_text" typeof="mw:FallbackId"></span>text > text</h2>
17089 <p>section 1</p>
17090
17091 <h2 id="text_&lt;_text"><span id="text_.3C_text" typeof="mw:FallbackId"></span>text &lt; text</h2>
17092 <p>section 2</p>
17093
17094 <h2 id="text_&amp;_text"><span id="text_.26_text" typeof="mw:FallbackId"></span>text &amp; text</h2>
17095 <p>section 3</p>
17096
17097 <h2 id="text_'_text"><span id="text_.27_text" typeof="mw:FallbackId"></span>text ' text</h2>
17098 <p>section 4</p>
17099
17100 <h2 id='text_"_text'><span id="text_.22_text" typeof="mw:FallbackId"></span>text " text</h2>
17101 <p>section 5</p>
17102 !! end
17103
17104 !! test
17105 Header with space, plus and underscore as entity
17106 !! wikitext
17107 Id should not contain + for spaces
17108
17109 ==Space between Text==
17110 section 1
17111
17112 ==Space-Entity&#32;between&#32;Text==
17113 section 2
17114
17115 ==Plus+between+Text==
17116 section 3
17117
17118 ==Plus-Entity&#43;between&#43;Text==
17119 section 4
17120
17121 ==Underscore_between_Text==
17122 section 5
17123
17124 ==Underscore-Entity&#95;between&#95;Text==
17125 section 6
17126
17127 [[#Space between Text]]
17128 [[#Space-Entity&#32;between&#32;Text]]
17129 [[#Plus+between+Text]]
17130 [[#Plus-Entity&#43;between&#43;Text]]
17131 [[#Underscore_between_Text]]
17132 [[#Underscore-Entity&#95;between&#95;Text]]
17133 !! html/php
17134 <p>Id should not contain + for spaces
17135 </p>
17136 <div id="toc" class="toc"><input type="checkbox" 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>
17137 <ul>
17138 <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>
17139 <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>
17140 <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>
17141 <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>
17142 <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>
17143 <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>
17144 </ul>
17145 </div>
17146
17147 <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>
17148 <p>section 1
17149 </p>
17150 <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>
17151 <p>section 2
17152 </p>
17153 <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>
17154 <p>section 3
17155 </p>
17156 <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>
17157 <p>section 4
17158 </p>
17159 <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>
17160 <p>section 5
17161 </p>
17162 <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>
17163 <p>section 6
17164 </p><p><a href="#Space_between_Text">#Space between Text</a>
17165 <a href="#Space-Entity_between_Text">#Space-Entity&#32;between&#32;Text</a>
17166 <a href="#Plus.2Bbetween.2BText">#Plus+between+Text</a>
17167 <a href="#Plus-Entity.2Bbetween.2BText">#Plus-Entity&#43;between&#43;Text</a>
17168 <a href="#Underscore_between_Text">#Underscore_between_Text</a>
17169 <a href="#Underscore-Entity_between_Text">#Underscore-Entity&#95;between&#95;Text</a>
17170 </p>
17171 !! html/parsoid
17172 <p>Id should not contain + for spaces</p>
17173
17174 <h2 id="Space_between_Text">Space between Text</h2>
17175 <p>section 1</p>
17176
17177 <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>
17178 <p>section 2</p>
17179
17180 <h2 id="Plus+between+Text"><span id="Plus.2Bbetween.2BText" typeof="mw:FallbackId"></span>Plus+between+Text</h2>
17181 <p>section 3</p>
17182
17183 <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>
17184 <p>section 4</p>
17185
17186 <h2 id="Underscore_between_Text">Underscore_between_Text</h2>
17187 <p>section 5</p>
17188
17189 <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>
17190 <p>section 6</p>
17191
17192 <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>
17193 <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>
17194 <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>
17195 <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>
17196 <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>
17197 <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>
17198 !! end
17199
17200 # Parsoid html2wt disabled because it adds padding spaces around =
17201 !! test
17202 Headers with excess '=' characters
17203 (Are similar tests necessary beyond the 1st level?)
17204 !! options
17205 parsoid=wt2html,wt2wt,html2html
17206 !! wikitext
17207 =foo==
17208 ==foo=
17209 =''italic'' heading==
17210 ==''italic'' heading=
17211 !! html/php
17212 <div id="toc" class="toc"><input type="checkbox" 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>
17213 <ul>
17214 <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
17215 <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
17216 <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>
17217 <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>
17218 </ul>
17219 </div>
17220
17221 <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>
17222 <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>
17223 <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>
17224 <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>
17225
17226 !! html/parsoid
17227 <h1 id="foo="><span id="foo.3D" typeof="mw:FallbackId"></span>foo=</h1>
17228 <h1 id="=foo"><span id=".3Dfoo" typeof="mw:FallbackId"></span>=foo</h1>
17229 <h1 id="italic_heading="><span id="italic_heading.3D" typeof="mw:FallbackId"></span><i>italic</i> heading=</h1>
17230 <h1 id="=italic_heading"><span id=".3Ditalic_heading" typeof="mw:FallbackId"></span>=<i>italic</i> heading</h1>
17231 !! end
17232
17233 !! test
17234 HTML headers vs TOC (T25393)
17235 (__NOEDITSECTION__ for clearer output, doesn't matter here)
17236 !! wikitext
17237 <h1>Header 1</h1>
17238 ==Header 1.1==
17239 ==Header 1.2==
17240
17241 <h1>Header 2
17242 </h1>
17243 ==Header 2.1==
17244 ==Header 2.2==
17245 __NOEDITSECTION__
17246 !! html/php
17247 <div id="toc" class="toc"><input type="checkbox" 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>
17248 <ul>
17249 <li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
17250 <ul>
17251 <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>
17252 <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>
17253 </ul>
17254 </li>
17255 <li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a>
17256 <ul>
17257 <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>
17258 <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>
17259 </ul>
17260 </li>
17261 </ul>
17262 </div>
17263
17264 <h1><span class="mw-headline" id="Header_1">Header 1</span></h1>
17265 <h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2>
17266 <h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2>
17267 <h1><span class="mw-headline" id="Header_2">Header 2
17268 </span></h1>
17269 <h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2>
17270 <h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2>
17271
17272 !! html/parsoid
17273 <h1 id="Header_1" data-parsoid='{"stx":"html"}'>Header 1</h1>
17274 <h2 id="Header_1.1" data-parsoid='{}'>Header 1.1</h2>
17275 <h2 id="Header_1.2" data-parsoid='{}'>Header 1.2</h2>
17276
17277 <h1 id="Header_2" data-parsoid='{"stx":"html"}'>Header 2
17278 </h1>
17279 <h2 id="Header_2.1" data-parsoid='{}'>Header 2.1</h2>
17280 <h2 id="Header_2.2" data-parsoid='{}'>Header 2.2</h2>
17281 <meta property="mw:PageProp/noeditsection"/>
17282 !! end
17283
17284 !! test
17285 Single-line or multiline-comments can follow headings
17286 !! options
17287 parsoid=wt2html,wt2wt
17288 !! wikitext
17289 ==foo==<!---->
17290 ==bar==<!--c1-->
17291 ==baz==<!--
17292 c2
17293 c3-->
17294 !! html/php
17295 <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>
17296 <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>
17297 <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>
17298
17299 !! html/parsoid
17300 <h2 id="foo">foo</h2><!---->
17301 <h2 id="bar">bar</h2><!--c1-->
17302 <h2 id="baz">baz</h2><!--
17303 c2
17304 c3-->
17305 !! end
17306
17307 !! test
17308 T3219 URL next to image (broken)
17309 !! wikitext
17310 http://example.com[[File:Foobar.jpg]]
17311 !! html/php
17312 <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>
17313 </p>
17314 !! html/parsoid
17315 <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>
17316 !!end
17317
17318 !! test
17319 T3186 news: in the middle of text
17320 !! wikitext
17321 http://en.wikinews.org/wiki/Wikinews:Workplace
17322 !! html
17323 <p><a rel="nofollow" class="external free" href="http://en.wikinews.org/wiki/Wikinews:Workplace">http://en.wikinews.org/wiki/Wikinews:Workplace</a>
17324 </p>
17325 !!end
17326
17327
17328 !! test
17329 Namespaced link must have a title
17330 !! wikitext
17331 [[Project:]]
17332 !! html
17333 <p>[[Project:]]
17334 </p>
17335 !!end
17336
17337 !! test
17338 Namespaced link must have a title (bad fragment version)
17339 !! wikitext
17340 [[Project:#fragment]]
17341 !! html
17342 <p>[[Project:#fragment]]
17343 </p>
17344 !!end
17345
17346
17347 ###
17348 ### HTML tags and HTML attributes
17349 ###
17350
17351 !! test
17352 div with no attributes
17353 !! wikitext
17354 <div>HTML rocks</div>
17355 !! html
17356 <div>HTML rocks</div>
17357
17358 !! end
17359
17360 !! test
17361 div with double-quoted attribute
17362 !! wikitext
17363 <div id="rock">HTML rocks</div>
17364 !! html
17365 <div id="rock">HTML rocks</div>
17366
17367 !! end
17368
17369 !! test
17370 div with single-quoted attribute
17371 !! wikitext
17372 <div id='rock'>HTML rocks</div>
17373 !! html
17374 <div id="rock">HTML rocks</div>
17375
17376 !! end
17377
17378 !! test
17379 div with unquoted attribute
17380 !! wikitext
17381 <div id=rock>HTML rocks</div>
17382 !! html
17383 <div id="rock">HTML rocks</div>
17384
17385 !! end
17386
17387 !! test
17388 div with illegal double attributes
17389 !! wikitext
17390 <div id="a" id="b">HTML rocks</div>
17391 !! html
17392 <div id="b">HTML rocks</div>
17393
17394 !!end
17395
17396 !! test
17397 div with empty attribute value, space before equals
17398 !! options
17399 parsoid=wt2html,html2html
17400 !! wikitext
17401 <div class =>HTML rocks</div>
17402 !! html/php
17403 <div class="">HTML rocks</div>
17404
17405 !! html/parsoid
17406 <div class="" data-parsoid='{"stx":"html"}'>HTML rocks</div>
17407 !! end
17408
17409 !! test
17410 div with multiple empty attribute values
17411 !! config
17412 wgFragmentMode=[ 'html5', 'legacy' ]
17413 !! options
17414 parsoid=wt2html,html2html
17415 !! wikitext
17416 <div id= title=>HTML rocks</div>
17417 !! html/php
17418 <div id="title=">HTML rocks</div>
17419
17420 !! html/parsoid
17421 <div id="title=" data-parsoid='{"stx":"html"}'>HTML rocks</div>
17422 !! end
17423
17424 # FIXME Parsoid doesn't actually match PHP here.
17425 # Probably we should use the synthetic <foo /> or <indicator>
17426 # extensions for this test, which are enabled when running parser tests.
17427 !! test
17428 Extension tag in attribute value
17429 !! wikitext
17430 <span title="<translate>123</translate>">ok</span>
17431 !! html/php+disabled
17432 <p>&lt;span title="&lt;translate&gt;123&lt;/translate&gt;"&gt;ok&lt;/span&gt;
17433 </p>
17434 !! html/parsoid
17435 <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>
17436 !! end
17437
17438 !! test
17439 table with multiple empty attribute values
17440 !! options
17441 parsoid=wt2html,html2html
17442 !! wikitext
17443 {| title= id=
17444 |hi
17445 |}
17446 !! html/php
17447 <table title="id=">
17448 <tr>
17449 <td>hi
17450 </td></tr></table>
17451
17452 !! html/parsoid
17453 <table title="id=">
17454 <tbody><tr><td>hi</td></tr>
17455 </tbody></table>
17456 !! end
17457
17458 !! test
17459 div with braces in attribute value
17460 !! wikitext
17461 <div title="{}">Foo</div>
17462 !! html/php
17463 <div title="&#123;&#125;">Foo</div>
17464
17465 !! html/parsoid
17466 <div title="{}">Foo</div>
17467 !! end
17468
17469 !! test
17470 div with empty attribute value, no space before equals
17471 !! options
17472 parsoid=wt2html,html2html
17473 !! wikitext
17474 <div class=>HTML rocks</div>
17475 !! html/php
17476 <div class="">HTML rocks</div>
17477
17478 !! html/parsoid
17479 <div class="">HTML rocks</div>
17480 !! end
17481
17482 !! test
17483 HTML multiple attributes correction
17484 !! wikitext
17485 <p class="error" class="awesome">Awesome!</p>
17486 !! html
17487 <p class="awesome">Awesome!</p>
17488
17489 !!end
17490
17491 !! test
17492 Table multiple attributes correction
17493 !! wikitext
17494 {|
17495 !+ class="error" class="awesome"|status
17496 |}
17497 !! html
17498 <table>
17499 <tr>
17500 <th class="awesome">status
17501 </th></tr></table>
17502
17503 !!end
17504
17505 !! test
17506 DIV IN UPPERCASE
17507 !! wikitext
17508 <DIV ID="x">HTML ROCKS</DIV>
17509 !! html
17510 <div id="x">HTML ROCKS</div>
17511
17512 !!end
17513
17514 !! test
17515 Non-ASCII pseudo-tags are rendered as text
17516 !! wikitext
17517 <khyô>
17518 !! html
17519 <p>&lt;khyô&gt;
17520 </p>
17521 !! end
17522
17523 !! test
17524 Pseudo-tag with URL 'name' renders as url link
17525 !! wikitext
17526 <http://example.com/>
17527 !! html
17528 <p>&lt;<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&gt;
17529 </p>
17530 !! end
17531
17532 !! test
17533 text with amp in the middle of nowhere
17534 !! wikitext
17535 Remember AT&T?
17536 !! html
17537 <p>Remember AT&amp;T?
17538 </p>
17539 !! end
17540
17541 !! test
17542 text with character entity: eacute
17543 !! wikitext
17544 I always thought &eacute; was a cute letter.
17545 !! html+tidy
17546 <p>I always thought &#233; was a cute letter.
17547 </p>
17548 !! end
17549
17550 !! test
17551 text with entity-escaped character entity-like string: eacute
17552 !! wikitext
17553 I always thought &amp;eacute; was a cute letter.
17554 !! html
17555 <p>I always thought &amp;eacute; was a cute letter.
17556 </p>
17557 !! end
17558
17559 !! test
17560 text with undefined character entity: xacute
17561 !! wikitext
17562 I always thought &xacute; was a cute letter.
17563 !! html
17564 <p>I always thought &amp;xacute; was a cute letter.
17565 </p>
17566 !! end
17567
17568 !! test
17569 HTML5 tags
17570 !! wikitext
17571 <data value="5">five</data>
17572 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
17573 <mark>This highlighted text</mark>
17574 !! html
17575 <p><data value="5">five</data>
17576 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
17577 <mark>This highlighted text</mark>
17578 </p>
17579 !! end
17580
17581 !! test
17582 HTML tag with leading space is parsed as text
17583 !! wikitext
17584 < div>foo< /div>
17585 !! html
17586 <p>&lt; div&gt;foo&lt; /div&gt;
17587 </p>
17588 !! end
17589
17590 ## Don't expect Parsoid and PHP to match, since PHP isn't exactly following
17591 ## the HTML5 parsing spec.
17592 !! test
17593 Element with broken attribute syntax
17594 !! options
17595 parsoid=wt2html
17596 !! wikitext
17597 <div style=" style="123">hi</div>
17598 <div =>ho</div>
17599 !! html/php
17600 <div style="123">hi</div>
17601 <div>ho</div>
17602
17603 !! html/parsoid
17604 <div style=" style=" data-parsoid='{"stx":"html","a":{"123\"":null},"sa":{"123\"":""}}'>hi</div>
17605 <div data-parsoid='{"stx":"html","a":{"=":null},"sa":{"=":""}}'>ho</div>
17606 !! end
17607
17608 ###
17609 ### Nesting tests (see T43545, T52604, T53081)
17610 ###
17611
17612 # This test case is fixed in Parsoid by domino 1.0.12. (T52604)
17613 # Note that html2wt is considerably more difficult if we use <b> in
17614 # the test case, instead of <small>
17615 !! test
17616 Ensure that HTML adoption agency algorithm is properly implemented.
17617 !! wikitext
17618 <small>X<small>Y</small>Z</small>
17619 !! html
17620 <p><small>X<small>Y</small>Z</small>
17621 </p>
17622 !! end
17623
17624 # This was T43545 in the PHP parser.
17625 !! test
17626 Nesting of <kbd>
17627 !! wikitext
17628 <kbd>X<kbd>Y</kbd>Z</kbd>
17629 !! html+tidy
17630 <p><kbd>X<kbd>Y</kbd>Z</kbd>
17631 </p>
17632 !! end
17633
17634 # The following cases were T53081 in the PHP parser.
17635 # Note that there are some other nestable tags (b, i, etc) which are
17636 # not covered; see T53081 for discussion.
17637
17638 !! test
17639 Nesting of <em>
17640 !! wikitext
17641 <em>X<em>Y</em>Z</em>
17642 !! html+tidy
17643 <p><em>X<em>Y</em>Z</em>
17644 </p>
17645 !! end
17646
17647 !! test
17648 Nesting of <strong>
17649 !! wikitext
17650 <strong>X<strong>Y</strong>Z</strong>
17651 !! html+tidy
17652 <p><strong>X<strong>Y</strong>Z</strong>
17653 </p>
17654 !! end
17655
17656 !! test
17657 Nesting of <q>
17658 !! wikitext
17659 <q>X<q>Y</q>Z</q>
17660 !! html+tidy
17661 <p><q>X<q>Y</q>Z</q>
17662 </p>
17663 !! end
17664
17665 !! test
17666 Nesting of <ruby>
17667 !! wikitext
17668 <ruby>X<ruby>Y</ruby>Z</ruby>
17669 !! html
17670 <p><ruby>X<ruby>Y</ruby>Z</ruby>
17671 </p>
17672 !! end
17673
17674 !! test
17675 Nesting of <bdo>
17676 !! wikitext
17677 <bdo>X<bdo>Y</bdo>Z</bdo>
17678 !! html
17679 <p><bdo>X<bdo>Y</bdo>Z</bdo>
17680 </p>
17681 !! end
17682
17683
17684 ###
17685 ### Media links
17686 ###
17687
17688 !! test
17689 Media link
17690 !! wikitext
17691 [[Media:Foobar.jpg]]
17692 [[Media:Video.ogv]]
17693 [[:Media:Video.ogv]]
17694 !! html/php
17695 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a>
17696 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
17697 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
17698 </p>
17699 !! html/parsoid
17700 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a>
17701 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" title="Video.ogv">Media:Video.ogv</a>
17702 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" title="Video.ogv" data-parsoid='{"a":{"namespace":"Media"},"sa":{"namespace":":Media"}}'>Media:Video.ogv</a></p>
17703 !! end
17704
17705 !! test
17706 Media link with text
17707 !! wikitext
17708 [[Media:Foobar.jpg|A neat file to look at]]
17709 !! html/php
17710 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">A neat file to look at</a>
17711 </p>
17712 !! html/parsoid
17713 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
17714 !! end
17715
17716 # FIXME: this is still bad HTML tag nesting
17717 # FIXME: doBlockLevels won't wrap this in a paragraph because it contains a div
17718 # Parsoid & Remex fix the p-wrapping since they operate on the DOM.
17719 !! test
17720 Media link with nasty text
17721 !! wikitext
17722 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
17723 !! html/php
17724 <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>
17725
17726 !! html/php+tidy
17727 <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>
17728 !! html/parsoid
17729 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg" data-parsoid='{"autoInsertedEnd":true}'>Safe Link</a></p><div style="display:none" data-parsoid='{"stx":"html"}'><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg" data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'>" onmouseover="alert(document.cookie)" onfoo="</a></div>
17730
17731 !! end
17732
17733 !! test
17734 Media link to nonexistent file (T3702)
17735 !! wikitext
17736 [[Media:No such.jpg]]
17737 [[Media:No_such file.jpg]]
17738 !! html/php
17739 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a>
17740 <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>
17741 </p>
17742 !! html/parsoid
17743 <p><a rel="mw:MediaLink" href="./Special:FilePath/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":{"fileName":"No_such.jpg"},"sa":{"fileName":"No such.jpg"}}'>Media:No such.jpg</a>
17744 <a rel="mw:MediaLink" href="./Special:FilePath/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":{"fileName":"No_such_file.jpg"},"sa":{"fileName":"No_such file.jpg"}}'>Media:No_such file.jpg</a></p>
17745 !! end
17746
17747 !! test
17748 Image link to nonexistent file (T3850 - good)
17749 !! wikitext
17750 [[File:No_such.jpg]]
17751 !! html/php
17752 <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>
17753 </p>
17754 !! html/parsoid
17755 <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>
17756 !! end
17757
17758 !! test
17759 :Image link to nonexistent file (T3850 - bad)
17760 !! wikitext
17761 [[:Image:No such.jpg]]
17762 !! html/php
17763 <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>
17764 </p>
17765 !! html/parsoid
17766 <p><a rel="mw:WikiLink" href="./File:No_such.jpg" title="File:No such.jpg">Image:No such.jpg</a></p>
17767 !! end
17768
17769 !! test
17770 Character reference normalization in link text (T3938)
17771 !! wikitext
17772 [[Main Page|this&that]]
17773 !! html
17774 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
17775 </p>
17776 !!end
17777
17778 !! article
17779 אַ
17780 !! text
17781 Test for unicode normalization
17782
17783 The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
17784 !! endarticle
17785
17786 !! test
17787 (T21451) Links should refer to the normalized form.
17788 !! wikitext
17789 [[&#xFB2E;]]
17790 [[&#x5d0;&#x5b7;]]
17791 [[&#x5d0;ַ]]
17792 [[א&#x5b7;]]
17793 [[אַ]]
17794 !! html
17795 <p><a href="/wiki/%D7%90%D6%B7" title="אַ">&#xfb2e;</a>
17796 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;&#x5b7;</a>
17797 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;ַ</a>
17798 <a href="/wiki/%D7%90%D6%B7" title="אַ">א&#x5b7;</a>
17799 <a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a>
17800 </p>
17801 !! end
17802
17803 !! test
17804 Empty attribute crash test (T4067)
17805 !! wikitext
17806 <font color="">foo</font>
17807 !! html
17808 <p><font color="">foo</font>
17809 </p>
17810 !! end
17811
17812 !! test
17813 Empty attribute crash test single-quotes (T4067)
17814 !! wikitext
17815 <font color=''>foo</font>
17816 !! html
17817 <p><font color="">foo</font>
17818 </p>
17819 !! end
17820
17821 !! test
17822 Attribute test: equals, then nothing
17823 !! options
17824 parsoid=wt2html,html2html
17825 !! wikitext
17826 <font color=>foo</font>
17827 !! html/php
17828 <p><font color="">foo</font>
17829 </p>
17830 !! html/parsoid
17831 <p><font color="" data-parsoid='{"stx":"html"}'>foo</font></p>
17832 !! end
17833
17834 !! test
17835 Attribute test: unquoted value
17836 !! options
17837 parsoid=wt2html,html2html
17838 !! wikitext
17839 <font color=x>foo</font>
17840 !! html/php
17841 <p><font color="x">foo</font>
17842 </p>
17843 !! html/parsoid
17844 <p><font color="x" data-parsoid='{"stx":"html"}'>foo</font></p>
17845 !! end
17846
17847 !! test
17848 Attribute test: unquoted but illegal value (hash)
17849 !! wikitext
17850 <font color=#x>foo</font>
17851 !! html
17852 <p><font color="#x">foo</font>
17853 </p>
17854 !! end
17855
17856 # Parsoid does not serialize to empty attribute syntax,
17857 # so wt2wt and html2wt cases are skipped
17858 !! test
17859 Attribute test: no value (T54330)
17860 !! options
17861 parsoid=wt2html,html2html
17862 !! wikitext
17863 <font color>foo</font>
17864 !! html/php
17865 <p><font color="">foo</font>
17866 </p>
17867 !! html/parsoid
17868 <p><font color="">foo</font></p>
17869 !! end
17870
17871 !! test
17872 T4095: link with three closing brackets
17873 !! wikitext
17874 [[Main Page]]]
17875 !! html/php
17876 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
17877 </p>
17878 !! html/parsoid
17879 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>]</p>
17880 !! end
17881
17882 !! test
17883 T4095: link with pipe and three closing brackets
17884 !! wikitext
17885 [[Main Page|link]]]
17886 !! html/php
17887 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
17888 </p>
17889 !! html/parsoid
17890 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">link</a>]</p>
17891 !! end
17892
17893 !! test
17894 T4095: link with pipe and three closing brackets, version 2
17895 !! wikitext
17896 [[Main Page|[http://example.com/]]]
17897 !! html/php
17898 <p><a href="/wiki/Main_Page" title="Main Page">[http://example.com/]</a>
17899 </p>
17900 !! html/parsoid
17901 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">[http://example.com/]</a></p>
17902 !! end
17903
17904
17905 ###
17906 ### Safety
17907 ###
17908
17909 !! article
17910 Template:Dangerous attribute
17911 !! text
17912 " onmouseover="alert(document.cookie)
17913 !! endarticle
17914
17915 !! article
17916 Template:Dangerous style attribute
17917 !! text
17918 border-size: expression(alert(document.cookie))
17919 !! endarticle
17920
17921 !! article
17922 Template:Div style
17923 !! text
17924 <div style="float: right; {{{1}}}">Magic div</div>
17925 !! endarticle
17926
17927 !! test
17928 T4304: HTML attribute safety (safe template; regression T4309)
17929 !! wikitext
17930 <div title="{{test}}"></div>
17931 !! html/php
17932 <div title="This is a test template"></div>
17933
17934 !! html/parsoid
17935 <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>
17936 !! end
17937
17938 # Parsoid has enough context to handle this case
17939 !! test
17940 T4304: HTML attribute safety (dangerous template; 2309)
17941 !! wikitext
17942 <div title="{{dangerous attribute}}"></div>
17943 !! html/php
17944 <div title=""></div>
17945
17946 !! html/parsoid
17947 <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>
17948 !! end
17949
17950 !! test
17951 T4304: HTML attribute safety (dangerous style template; 2309)
17952 !! wikitext
17953 <div style="{{dangerous style attribute}}"></div>
17954 !! html/php
17955 <div style="/* insecure input */"></div>
17956
17957 !! html/parsoid
17958 <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>
17959 !! end
17960
17961 !! test
17962 T4304: HTML attribute safety (safe parameter; 2309)
17963 !! wikitext
17964 {{div style|width: 200px}}
17965 !! html/php
17966 <div style="float: right; width: 200px">Magic div</div>
17967
17968 !! html/parsoid
17969 <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>
17970 !! end
17971
17972 !! test
17973 T4304: HTML attribute safety (unsafe parameter; 2309)
17974 !! wikitext
17975 {{div style|width: expression(alert(document.cookie))}}
17976 !! html/php
17977 <div style="/* insecure input */">Magic div</div>
17978
17979 !! html/parsoid
17980 <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>
17981 !! end
17982
17983 ## Parsoid output here differs; needs investigation.
17984 !! test
17985 T4304: HTML attribute safety (unsafe breakout parameter; 2309)
17986 !! wikitext
17987 {{div style|"><script>alert(document.cookie)</script>}}
17988 !! html
17989 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17990
17991 !! end
17992
17993 ## Parsoid output here differs; needs investigation.
17994 !! test
17995 T4304: HTML attribute safety (unsafe breakout parameter 2; 2309)
17996 !! wikitext
17997 {{div style|" ><script>alert(document.cookie)</script>}}
17998 !! html
17999 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
18000
18001 !! end
18002
18003 !! test
18004 T4304: HTML attribute safety (link)
18005 !! wikitext
18006 <div title="[[Main Page]]"></div>
18007 !! html/php
18008 <div title="&#91;&#91;Main Page&#93;&#93;"></div>
18009
18010 !! html/parsoid
18011 <div title="[[Main Page]]"></div>
18012 !! end
18013
18014 !! test
18015 T4304: HTML attribute safety (italics)
18016 !! wikitext
18017 <div title="''foobar''"></div>
18018 !! html
18019 <div title="&#39;&#39;foobar&#39;&#39;"></div>
18020
18021 !! end
18022
18023 !! test
18024 T4304: HTML attribute safety (bold)
18025 !! wikitext
18026 <div title="'''foobar'''"></div>
18027 !! html
18028 <div title="&#39;&#39;&#39;foobar&#39;&#39;&#39;"></div>
18029
18030 !! end
18031
18032 !! test
18033 T4304: HTML attribute safety (ISBN)
18034 !! wikitext
18035 <div title="ISBN 1234567890"></div>
18036 !! html
18037 <div title="&#73;SBN 1234567890"></div>
18038
18039 !! end
18040
18041 !! test
18042 T4304: HTML attribute safety (RFC)
18043 !! wikitext
18044 <div title="RFC 1234"></div>
18045 !! html
18046 <div title="&#82;FC 1234"></div>
18047
18048 !! end
18049
18050 !! test
18051 T4304: HTML attribute safety (PMID)
18052 !! wikitext
18053 <div title="PMID 1234567890"></div>
18054 !! html
18055 <div title="&#80;MID 1234567890"></div>
18056
18057 !! end
18058
18059 !! test
18060 T4304: HTML attribute safety (web link)
18061 !! wikitext
18062 <div title="http://example.com/"></div>
18063 !! html
18064 <div title="http&#58;//example.com/"></div>
18065
18066 !! end
18067
18068 !! test
18069 T4304: HTML attribute safety (named web link)
18070 !! wikitext
18071 <div title="[http://example.com/ link]"></div>
18072 !! html/php
18073 <div title="&#91;http&#58;//example.com/ link&#93;"></div>
18074
18075 !! html/parsoid
18076 <div title="[http://example.com/ link]"></div>
18077 !! end
18078
18079 !! test
18080 T5244: HTML attribute safety (extension; safe)
18081 !! wikitext
18082 <div style="<nowiki>background:blue</nowiki>"></div>
18083 !! html/php
18084 <div style="background:blue"></div>
18085
18086 !! html/parsoid
18087 <div style="background:blue" data-parsoid='{"stx":"html","a":{"style":"background:blue"},"sa":{"style":"&lt;nowiki>background:blue&lt;/nowiki>"}}'></div>
18088 !! end
18089
18090 !! test
18091 T5244: HTML attribute safety (extension; unsafe)
18092 !! wikitext
18093 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
18094 !! html/php
18095 <div style="/* insecure input */"></div>
18096
18097 !! html/parsoid
18098 <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>
18099 !! end
18100
18101 # More MSIE fun discovered by Tom Gilder
18102
18103 !! test
18104 MSIE CSS safety test: spurious slash
18105 !! wikitext
18106 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
18107 !! html/php
18108 <div style="/* insecure input */">evil</div>
18109
18110 !! html/parsoid
18111 <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>
18112 !! end
18113
18114 !! test
18115 MSIE CSS safety test: hex code
18116 !! wikitext
18117 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
18118 !! html/php
18119 <div style="/* insecure input */">evil</div>
18120
18121 !! html/parsoid
18122 <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>
18123 !! end
18124
18125 !! test
18126 MSIE CSS safety test: comment in url
18127 !! wikitext
18128 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
18129 !! html/php
18130 <div style="background-image:u rl(javascript:alert(&#39;boo&#39;))">evil</div>
18131
18132 !! html/parsoid
18133 <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>
18134 !! end
18135
18136 !! test
18137 MSIE CSS safety test: comment in expression
18138 !! wikitext
18139 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
18140 !! html/php
18141 <div style="background-image:expres sion(alert(&#39;boo4&#39;))">evil4</div>
18142
18143 !! html/parsoid
18144 <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>
18145 !! end
18146
18147 !! test
18148 CSS safety test (all browsers): vertical tab (T57332 / CVE-2013-4567)
18149 !! wikitext
18150 <p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p>
18151 !! html/php
18152 <p style="/* invalid control char */">A</p>
18153
18154 !! html/parsoid
18155 <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>
18156 !! end
18157
18158 !! test
18159 MSIE 6 CSS safety test: Fullwidth (T57332)
18160 !! wikitext
18161 <p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p>
18162 <div style="top:EXPRESSION(alert())">B</div>
18163 !! html/php
18164 <p style="/* insecure input */">A</p>
18165 <div style="/* insecure input */">B</div>
18166
18167 !! html/parsoid
18168 <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>
18169 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"top:EXPRESSION(alert())"}}'>B</div>
18170 !! end
18171
18172 !! test
18173 MSIE 6 CSS safety test: IPA extensions (T57332)
18174 !! wikitext
18175 <div style="background-image:uʀʟ(javascript:alert())">A</div>
18176 <p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p>
18177 !! html/php
18178 <div style="/* insecure input */">A</div>
18179 <p style="/* insecure input */">B</p>
18180
18181 !! html/parsoid
18182 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:uʀʟ(javascript:alert())"}}'>A</div>
18183 <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>
18184 !! end
18185
18186 !! test
18187 MSIE 6 CSS safety test: sup/sub script (T57332)
18188 !! wikitext
18189 <div style="background-image:url⁽javascript:alert())">A</div>
18190 <div style="background-image:url₍javascript:alert())">B</div>
18191 <p style="font-size: 100px; color: expressioⁿ((title='XSSed'),'red')">C</p>
18192 !! html/php
18193 <div style="/* insecure input */">A</div>
18194 <div style="/* insecure input */">B</div>
18195 <p style="/* insecure input */">C</p>
18196
18197 !! html/parsoid
18198 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url⁽javascript:alert())"}}'>A</div>
18199 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url₍javascript:alert())"}}'>B</div>
18200 <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>
18201 !! end
18202
18203 !! test
18204 Opera -o-link CSS
18205 !! options
18206 parsoid=wt2html,html2html
18207 !! wikitext
18208 <div
18209 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;"
18210 style="-o-link:attr(title);-o-link-source:current">X</div>
18211 !! html/php
18212 <div title="data:text/html,&lt;img src=1 onerror=alert(1)&gt;" style="/* insecure input */">X</div>
18213
18214 !! html/parsoid
18215 <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>
18216 !! end
18217
18218 !! test
18219 MSIE 6 CSS safety test: Repetition markers (T57332)
18220 !! wikitext
18221 <p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p>
18222 <p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p>
18223 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">C</p>
18224 <p style="font-size: 100px; color: expresヽion((title='XSSed'),'red')">D</p>
18225 <p style="font-size: 100px; color: expresﹽion((title='XSSed'),'red')">E</p>
18226 <p style="font-size: 100px; color: expresﹼion((title='XSSed'),'red')">F</p>
18227 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">G</p>
18228 !! html/php
18229 <p style="/* insecure input */">A</p>
18230 <p style="/* insecure input */">B</p>
18231 <p style="/* insecure input */">C</p>
18232 <p style="/* insecure input */">D</p>
18233 <p style="/* insecure input */">E</p>
18234 <p style="/* insecure input */">F</p>
18235 <p style="/* insecure input */">G</p>
18236
18237 !! html/parsoid
18238 <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>
18239 <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>
18240 <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>
18241 <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>
18242 <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>
18243 <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>
18244 <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>
18245 !! end
18246
18247 !! test
18248 Table attribute legitimate extension
18249 !! wikitext
18250 {|
18251 !+ style="<nowiki>color:blue</nowiki>"|status
18252 |}
18253 !! html
18254 <table>
18255 <tr>
18256 <th style="color:blue">status
18257 </th></tr></table>
18258
18259 !!end
18260
18261 !! test
18262 Table attribute safety
18263 !! wikitext
18264 {|
18265 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"|status
18266 |}
18267 !! html
18268 <table>
18269 <tr>
18270 <th style="/* insecure input */">status
18271 </th></tr></table>
18272
18273 !! end
18274
18275 !! test
18276 CSS line continuation 1
18277 !! wikitext
18278 <div style="background-image: u\&#10;rl(test.jpg);"></div>
18279 !! html
18280 <div style="/* insecure input */"></div>
18281
18282 !! end
18283
18284 !! test
18285 CSS line continuation 2
18286 !! wikitext
18287 <div style="background-image: u\&#13;rl(test.jpg); "></div>
18288 !! html
18289 <div style="/* invalid control char */"></div>
18290
18291 !! end
18292
18293 !! article
18294 Template:Identity
18295 !! text
18296 {{{1}}}
18297 !! endarticle
18298
18299 !! test
18300 Expansion of multi-line templates in attribute values (T8255)
18301 !! wikitext
18302 <div style="background: {{identity|#00FF00}}">-</div>
18303 !! html
18304 <div style="background: #00FF00">-</div>
18305
18306 !! end
18307
18308 !! test
18309 Expansion of multi-line templates in attribute values (T8255 sanity check)
18310 !! wikitext
18311 <div style="background:
18312 #00FF00">-</div>
18313 !! html/php
18314 <div style="background: #00FF00">-</div>
18315
18316 !! html/parsoid
18317 <div style="background:
18318 #00FF00">-</div>
18319 !! end
18320
18321 !! test
18322 Expansion of multi-line templates in attribute values (T8255 sanity check 2)
18323 !! wikitext
18324 <div style="background: &#10;#00FF00">-</div>
18325 !! html
18326 <div style="background: &#10;#00FF00">-</div>
18327
18328 !! end
18329
18330 !! test
18331 Tags which are hidden from tidiers cannot pass through the Sanitizer
18332 !! wikitext
18333 <mw:toc><script>alert();</script></mw:toc>
18334 !! html+tidy
18335 <p>&lt;mw:toc&gt;&lt;script&gt;alert();&lt;/script&gt;&lt;/mw:toc&gt;
18336 </p>
18337 !! end
18338
18339 ###
18340 ### Parser hooks (see tests/parser/parserTestsParserHook.php for the <tag> extension)
18341 ###
18342
18343 !! test
18344 Parser hook: empty input
18345 !! wikitext
18346 <tag></tag>
18347 !! html/php
18348 <pre>
18349 ''
18350 array (
18351 )
18352 </pre>
18353
18354 !! html/parsoid
18355 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18356 !! end
18357
18358 ## Don't expect parsoid to rt this form.
18359 !! test
18360 Parser hook: empty input using terminated empty elements
18361 !! options
18362 parsoid=wt2html,html2html
18363 !! wikitext
18364 <tag/>
18365 !! html/php
18366 <pre>
18367 NULL
18368 array (
18369 )
18370 </pre>
18371
18372 !! html/parsoid
18373 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
18374 !! end
18375
18376 !! test
18377 Parser hook: empty input using terminated empty elements (space before)
18378 !! wikitext
18379 <tag />
18380 !! html/php
18381 <pre>
18382 NULL
18383 array (
18384 )
18385 </pre>
18386
18387 !! html/parsoid
18388 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
18389 !! end
18390
18391 !! test
18392 Parser hook: basic input
18393 !! wikitext
18394 <tag>input</tag>
18395 !! html/php
18396 <pre>
18397 'input'
18398 array (
18399 )
18400 </pre>
18401
18402 !! html/parsoid
18403 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18404 !! end
18405
18406 ## Don't expect parsoid to rt this form.
18407 !! test
18408 Parser hook: case insensitive
18409 !! options
18410 parsoid=wt2html,html2html
18411 !! wikitext
18412 <TAG>input</TAG>
18413 !! html/php
18414 <pre>
18415 'input'
18416 array (
18417 )
18418 </pre>
18419
18420 !! html/parsoid
18421 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18422 !! end
18423
18424 ## Don't expect parsoid to rt this form.
18425 !! test
18426 Parser hook: case insensitive, redux
18427 !! options
18428 parsoid=wt2html,html2html
18429 !! wikitext
18430 <TaG>input</TAg>
18431 !! html/php
18432 <pre>
18433 'input'
18434 array (
18435 )
18436 </pre>
18437
18438 !! html/parsoid
18439 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18440 !! end
18441
18442 !! test
18443 Parser hook: nested tags
18444 !! wikitext
18445 <tag><tag></tag></tag>
18446 !! html/php
18447 <pre>
18448 '<tag>'
18449 array (
18450 )
18451 </pre>&lt;/tag&gt;
18452
18453 !! html/parsoid
18454 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"&lt;tag>"}}' data-parsoid='{}' about="#mwt2"></pre>&lt;/tag>
18455 !! end
18456
18457 !! test
18458 Parser hook: basic arguments
18459 !! wikitext
18460 <tag width="200" height="100" depth="50" square=""></tag>
18461 !! html/php
18462 <pre>
18463 ''
18464 array (
18465 'width' => '200',
18466 'height' => '100',
18467 'depth' => '50',
18468 'square' => '',
18469 )
18470 </pre>
18471
18472 !! html/parsoid
18473 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18474 !! end
18475
18476 ## Don't expect parsoid to rt this form.
18477 !! test
18478 Parser hook: basic arguments, variations
18479 !! options
18480 parsoid=wt2html,html2html
18481 !! wikitext
18482 <tag width=200 height = "100" depth = '50' square></tag>
18483 !! html/php
18484 <pre>
18485 ''
18486 array (
18487 'width' => '200',
18488 'height' => '100',
18489 'depth' => '50',
18490 'square' => '',
18491 )
18492 </pre>
18493
18494 !! html/parsoid
18495 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18496 !! end
18497
18498 !! test
18499 Parser hook: argument containing a forward slash (T7344)
18500 !! wikitext
18501 <tag filename="/tmp/bla"></tag>
18502 !! html/php
18503 <pre>
18504 ''
18505 array (
18506 'filename' => '/tmp/bla',
18507 )
18508 </pre>
18509
18510 !! html/parsoid
18511 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"filename":"/tmp/bla"},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18512 !! end
18513
18514 ## Don't expect parsoid to rt this form.
18515 !! test
18516 Parser hook: empty input using terminated empty elements (T4374)
18517 !! options
18518 parsoid=wt2html,html2html
18519 !! wikitext
18520 <tag foo=bar/>text
18521 !! html/php
18522 <pre>
18523 NULL
18524 array (
18525 'foo' => 'bar',
18526 )
18527 </pre>text
18528
18529 !! html/parsoid
18530 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"foo":"bar"},"body":null}' data-parsoid='{}' about="#mwt2"></pre>text
18531 !! end
18532
18533 ## </tag> should be output literally since there is no matching tag that begins it
18534 ## Don't expect parsoid to rt this form.
18535 !! test
18536 Parser hook: basic arguments using terminated empty elements (T4374)
18537 !! options
18538 parsoid=wt2html
18539 !! wikitext
18540 <tag width=200 height = "100" depth = '50' square/>
18541 other stuff
18542 </tag>
18543 !! html/php
18544 <pre>
18545 NULL
18546 array (
18547 'width' => '200',
18548 'height' => '100',
18549 'depth' => '50',
18550 'square' => '',
18551 )
18552 </pre>
18553 <p>other stuff
18554 &lt;/tag&gt;
18555 </p>
18556 !! html/parsoid
18557 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":null}' about="#mwt2"></pre><p>other stuff
18558 &lt;/tag></p>
18559 !! end
18560
18561 ## Don't expect parsoid to rt this form.
18562 !! test
18563 Parser hook: Don't allow unclosed extension tags
18564 !! options
18565 parsoid=wt2html
18566 !! wikitext
18567 test <tag>123
18568
18569 this is a '''test'''
18570 !! html/php
18571 <p>test &lt;tag&gt;123
18572 </p><p>this is a <b>test</b>
18573 </p>
18574 !! html/parsoid
18575 <p>test &lt;tag>123</p>
18576
18577 <p>this is a <b>test</b></p>
18578 !! end
18579
18580 !! test
18581 Parser hook: horizontal rule inside extension tag that outputs <pre>
18582 !! wikitext
18583 <tag>
18584 Hello
18585 <hr/>
18586 Goodbye
18587 </tag>
18588 !! html/php
18589 <pre>
18590 '
18591 Hello
18592 <hr/>
18593 Goodbye
18594 '
18595 array (
18596 )
18597 </pre>
18598
18599 !! end
18600
18601 ###
18602 ### (see tests/parser/parserTestsParserHook.php for the <statictag> extension)
18603 ###
18604
18605 !! test
18606 Parser hook: static parser hook not inside a comment
18607 !! wikitext
18608 <statictag>hello, world</statictag>
18609
18610 <statictag action="flush" />
18611 !! html/php
18612 <p><br />
18613 hello, world
18614 </p>
18615 !! html/parsoid
18616 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{},"body":{"extsrc":"hello, world"}}' data-parsoid='{}' about="#mwt2"></span></p>
18617 <p typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about="#mwt4">hello, world</p>
18618 !! end
18619
18620 !! test
18621 Parser hook: static parser hook inside a comment
18622 !! wikitext
18623 <!-- <statictag>hello, world</statictag> -->
18624 <statictag action="flush" />
18625 !! html/php
18626 <p><br />
18627 </p>
18628 !! html/parsoid
18629 <!-- <statictag&#x3E;hello, world</statictag&#x3E; -->
18630 <p typeof='mw:Extension/statictag' data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about='#mwt2'></p>
18631 !! end
18632
18633 # Nested template calls; this case was broken by Parser.php rev 1.506,
18634 # since reverted.
18635
18636 !! article
18637 Template:One-parameter
18638 !! text
18639 (My parameter is: {{{1}}})
18640 !! endarticle
18641
18642 !! article
18643 Template:Map-one-parameter
18644 !! text
18645 {{{{{1}}}|{{{2}}}}}
18646 !! endarticle
18647
18648 !! test
18649 Nested template calls
18650 !! wikitext
18651 {{Map-one-parameter|One-parameter|param}}
18652 !! html
18653 <p>(My parameter is: param)
18654 </p>
18655 !! end
18656
18657
18658 ###
18659 ### Sanitizer
18660 ###
18661
18662 # Remex wraps empty tag runs with p-tags.
18663 # Parsoid strips them out during p-wrapping.
18664 !! test
18665 Sanitizer: Closing of open tags
18666 !! wikitext
18667 <s></s><table></table>
18668 !! html/php+tidy
18669 <p><s></s></p><table></table>
18670 !! html/parsoid
18671 <s></s><table></table>
18672 !! end
18673
18674 !! test
18675 Sanitizer: Closing of open but not closed tags
18676 !! wikitext
18677 <s>foo
18678 !! html
18679 <p><s>foo</s>
18680 </p>
18681 !! end
18682
18683 !! test
18684 Sanitizer: Closing of closed but not open tags
18685 !! options
18686 parsoid=wt2html
18687 !! wikitext
18688 </s>
18689 !! html/php+tidy
18690 <p class="mw-empty-elt">
18691 </p>
18692 !! html/parsoid
18693 !! end
18694
18695 !! test
18696 Sanitizer: Closing of closed but not open table tags
18697 !! options
18698 parsoid=wt2html
18699 !! wikitext
18700 Table not started</td></tr></table>
18701 !! html+tidy
18702 <p>Table not started
18703 </p>
18704 !! end
18705
18706 !! test
18707 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
18708 !! config
18709 wgFragmentMode=[ 'html5', 'legacy' ]
18710 !! wikitext
18711 <span id="æ: v">byte</span>[[#æ: v|backlink]]
18712 !! html/php
18713 <p><span id="æ:_v">byte</span><a href="#æ:_v">backlink</a>
18714 </p>
18715 !! html/parsoid
18716 <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>
18717 !! end
18718
18719 !! test
18720 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id="" (legacy)
18721 !! config
18722 wgFragmentMode=[ 'legacy' ]
18723 !! wikitext
18724 <span id="æ: v">byte</span>[[#æ: v|backlink]]
18725 !! html/php
18726 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v">backlink</a>
18727 </p>
18728 !! end
18729
18730 # In HTML5, the restrictions are that id must contain at least one character,
18731 # and must not contain any space characters.
18732 !! test
18733 Sanitizer: Validating the contents of the id attribute (T6515)
18734 !! options
18735 disabled
18736 !! wikitext
18737 <br id="" /><br id="a space" />
18738 !! html
18739 Something ...
18740 !! end
18741
18742 # In HTML5, id must be unique amongst all the ids in the element's home subtree.
18743 !! test
18744 Sanitizer: Validating id attribute uniqueness (T6515, T8301)
18745 !! options
18746 disabled
18747 !! wikitext
18748 <br id="foo" /><br id="foo" />
18749 !! html
18750 Something need to be done. foo-2 ?
18751 !! end
18752
18753 !! test
18754 Sanitizer: Validating that <meta> and <link> work, but only for Microdata
18755 !! wikitext
18756 <div itemscope>
18757 <meta itemprop="hello" content="world">
18758 <meta http-equiv="refresh" content="5">
18759 <meta itemprop="hello" http-equiv="refresh" content="5">
18760 <link itemprop="hello" href="{{SERVER}}">
18761 <link rel="stylesheet" href="{{SERVER}}">
18762 <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
18763 </div>
18764 !! html
18765 <div itemscope="">
18766 <p> <meta itemprop="hello" content="world" />
18767 &lt;meta http-equiv="refresh" content="5"&gt;
18768 <meta itemprop="hello" content="5" />
18769 <link itemprop="hello" href="http&#58;//example.org" />
18770 &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"&gt;
18771 <link itemprop="hello" href="http&#58;//example.org" />
18772 </p>
18773 </div>
18774
18775 !! end
18776
18777 !! test
18778 Sanitizer: Strip comments from CSS attributes
18779 !! options
18780 parsoid=wt2html,wt2wt
18781 !! wikitext
18782 <span style="margin:/*negate mbox-text padding */-0.125em -0.45em; /*rainbow*/rgba(255, 0, 0, 0.3)">2013</span>
18783 !! html/php
18784 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span>
18785 </p>
18786 !! html/parsoid
18787 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span></p>
18788 !! end
18789
18790 !! test
18791 Sanitizer: Avoid unnecessary percent encoded characters in interwiki links
18792 !! wikitext
18793 [[meatball:Soft"Security]]
18794 !! html/php
18795 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Soft%22Security" class="extiw" title="meatball:Soft&quot;Security">meatball:Soft"Security</a>
18796 </p>
18797 !! html/parsoid
18798 <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>
18799 !! end
18800
18801 !! test
18802 Sanitizer: angle brackets are invalid, even in interwiki links (T182338)
18803 !! wikitext
18804 [[meatball:Foo<Bar]]
18805 [[meatball:Foo>Bar]]
18806 [[meatball:Foo&lt;bar]]
18807 [[meatball:Foo&gt;bar]]
18808 !! html/php
18809 <p>[[meatball:Foo&lt;Bar]]
18810 [[meatball:Foo&gt;Bar]]
18811 [[meatball:Foo&lt;bar]]
18812 [[meatball:Foo&gt;bar]]
18813 </p>
18814 !! html/parsoid
18815 <p>[[meatball:Foo&lt;Bar]]
18816 [[meatball:Foo>Bar]]
18817 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span>bar]]
18818 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;gt;","srcContent":">"}'>></span>bar]]</p>
18819 !! end
18820
18821 !! test
18822 Language converter: output gets cut off unexpectedly (T7757)
18823 !! options
18824 language=zh
18825 !! wikitext
18826 this bit is safe: }-
18827
18828 but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}-
18829
18830 then we get cut off here: }-
18831
18832 all additional text is vanished
18833 !! html/php
18834 <p>this bit is safe: }-
18835 </p><p>but if we add a conversion instance: xxx
18836 </p><p>then we get cut off here: }-
18837 </p><p>all additional text is vanished
18838 </p>
18839 !! html/parsoid
18840 <p>this bit is safe: }-</p>
18841 <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>
18842 <p>then we get cut off here: }-</p>
18843 <p>all additional text is vanished</p>
18844 !! end
18845
18846 !! test
18847 Language converter glossary rules inside attributes (T119158)
18848 !! options
18849 language=sr variant=sr-el
18850 !! wikitext
18851 -{H|foAjrjvi=>sr-el:" onload="alert(1)" data-foo="}-
18852
18853 [[File:Foobar.jpg|alt=-{}-foAjrjvi-{}-]]
18854 !! html/php
18855 <p>
18856 </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>
18857 </p>
18858 !! html/parsoid
18859 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"foAjrjvi","l":"sr-el","t":"\" onload=\"alert(1)\" data-foo=\""}]}'/></p>
18860
18861 <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>
18862 !! end
18863
18864 !! test
18865 Self closed html pairs (T7487)
18866 !! wikitext
18867 <center><font id="bug" />Centered text</center>
18868 <div><font id="bug2" />In div text</div>
18869 !! html+tidy
18870 <center><font id="bug"></font>Centered text</center>
18871 <div><font id="bug2"></font>In div text</div>
18872 !! end
18873
18874 !! test
18875 Punctuation: nbsp before exclamation
18876 !! wikitext
18877 C'est grave !
18878 !! html
18879 <p>C'est grave&#160;!
18880 </p>
18881 !! end
18882
18883 !! test
18884 Punctuation: CSS !important (T13874)
18885 !! wikitext
18886 <div style="width:50% !important">important</div>
18887 !! html
18888 <div style="width:50%&#32;!important">important</div>
18889
18890 !!end
18891
18892 !! test
18893 Punctuation: CSS ! important (T13874; with space after)
18894 !! wikitext
18895 <div style="width:50% ! important">important</div>
18896 !! html
18897 <div style="width:50%&#32;! important">important</div>
18898
18899 !!end
18900
18901 !! test
18902 HTML bullet list, closed tags (T7497)
18903 !! wikitext
18904 <ul>
18905 <li>One</li>
18906 <li>Two</li>
18907 </ul>
18908 !! html/php
18909 <ul>
18910 <li>One</li>
18911 <li>Two</li>
18912 </ul>
18913
18914 !! html/parsoid
18915 <ul data-parsoid='{"stx":"html"}'>
18916 <li data-parsoid='{"stx":"html"}'>One</li>
18917 <li data-parsoid='{"stx":"html"}'>Two</li>
18918 </ul>
18919
18920 !! end
18921
18922 !! test
18923 HTML bullet list, unclosed tags (T7497)
18924 !! wikitext
18925 <ul>
18926 <li>One
18927 <li>Two
18928 </ul>
18929 !! html/php+tidy
18930 <ul>
18931 <li>One
18932 </li><li>Two
18933 </li></ul>
18934 !! html/parsoid
18935 <ul data-parsoid='{"stx":"html"}'>
18936 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18937 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18938 </ul>
18939
18940 !! end
18941
18942 !! test
18943 HTML ordered list, closed tags (T7497)
18944 !! wikitext
18945 <ol>
18946 <li>One</li>
18947 <li>Two</li>
18948 </ol>
18949 !! html/php
18950 <ol>
18951 <li>One</li>
18952 <li>Two</li>
18953 </ol>
18954
18955 !! html/parsoid
18956 <ol data-parsoid='{"stx":"html"}'>
18957 <li data-parsoid='{"stx":"html"}'>One</li>
18958 <li data-parsoid='{"stx":"html"}'>Two</li>
18959 </ol>
18960
18961 !! end
18962
18963 !! test
18964 HTML ordered list, unclosed tags (T7497)
18965 !! options
18966 !! wikitext
18967 <ol>
18968 <li>One
18969 <li>Two
18970 </ol>
18971 !! html/php+tidy
18972 <ol>
18973 <li>One
18974 </li><li>Two
18975 </li></ol>
18976 !! html/parsoid
18977 <ol data-parsoid='{"stx":"html"}'>
18978 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18979 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18980 </ol>
18981
18982 !! end
18983
18984 !! test
18985 HTML nested bullet list, closed tags (T7497)
18986 !! wikitext
18987 <ul>
18988 <li>One</li>
18989 <li>Two:
18990 <ul>
18991 <li>Sub-one</li>
18992 <li>Sub-two</li>
18993 </ul>
18994 </li>
18995 </ul>
18996 !! html/php
18997 <ul>
18998 <li>One</li>
18999 <li>Two:
19000 <ul>
19001 <li>Sub-one</li>
19002 <li>Sub-two</li>
19003 </ul>
19004 </li>
19005 </ul>
19006
19007 !! html/parsoid
19008 <ul data-parsoid='{"stx":"html"}'>
19009 <li data-parsoid='{"stx":"html"}'>One</li>
19010 <li data-parsoid='{"stx":"html"}'>Two:
19011 <ul data-parsoid='{"stx":"html"}'>
19012 <li data-parsoid='{"stx":"html"}'>Sub-one</li>
19013 <li data-parsoid='{"stx":"html"}'>Sub-two</li>
19014 </ul>
19015 </li>
19016 </ul>
19017 !! end
19018
19019 !! test
19020 HTML nested bullet list, open tags (T7497)
19021 !! wikitext
19022 <ul>
19023 <li>One
19024 <li>Two:
19025 <ul>
19026 <li>Sub-one
19027 <li>Sub-two
19028 </ul>
19029 </ul>
19030 !! html+tidy
19031 <ul>
19032 <li>One
19033 </li><li>Two:
19034 <ul>
19035 <li>Sub-one
19036 </li><li>Sub-two
19037 </li></ul>
19038 </li></ul>
19039 !! end
19040
19041 !! test
19042 HTML nested ordered list, closed tags (T7497)
19043 !! wikitext
19044 <ol>
19045 <li>One</li>
19046 <li>Two:
19047 <ol>
19048 <li>Sub-one</li>
19049 <li>Sub-two</li>
19050 </ol>
19051 </li>
19052 </ol>
19053 !! html
19054 <ol>
19055 <li>One</li>
19056 <li>Two:
19057 <ol>
19058 <li>Sub-one</li>
19059 <li>Sub-two</li>
19060 </ol>
19061 </li>
19062 </ol>
19063
19064 !! end
19065
19066 !! test
19067 HTML nested ordered list, open tags (T7497)
19068 !! wikitext
19069 <ol>
19070 <li>One
19071 <li>Two:
19072 <ol>
19073 <li>Sub-one
19074 <li>Sub-two
19075 </ol>
19076 </ol>
19077 !! html/php
19078 <ol>
19079 <li>One
19080 <li>Two:
19081 <ol>
19082 <li>Sub-one
19083 <li>Sub-two
19084 </ol>
19085 </ol>
19086
19087 !! html/parsoid
19088 <ol>
19089 <li>One
19090 </li>
19091 <li>Two:
19092 <ol>
19093 <li>Sub-one
19094 </li>
19095 <li>Sub-two
19096 </li>
19097 </ol>
19098 </li>
19099 </ol>
19100
19101 !! end
19102
19103 !! test
19104 HTML ordered list item with parameters oddity
19105 !! wikitext
19106 <ol><li id="fragment">One</li>
19107 </ol>
19108 !! html
19109 <ol><li id="fragment">One</li>
19110 </ol>
19111
19112 !! end
19113
19114 # parsoid doesn't explicitly mark autonumbered links, see T55505
19115 !!test
19116 T7918: autonumbering
19117 !! wikitext
19118 [http://first/] [http://second] [ftp://ftp]
19119
19120 ftp://inlineftp
19121
19122 [mailto:enclosed@mail.tld With target]
19123
19124 [mailto:enclosed@mail.tld]
19125
19126 mailto:inline@mail.tld
19127 !! html/php
19128 <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>
19129 </p><p><a rel="nofollow" class="external free" href="ftp://inlineftp">ftp://inlineftp</a>
19130 </p><p><a rel="nofollow" class="external text" href="mailto:enclosed@mail.tld">With target</a>
19131 </p><p><a rel="nofollow" class="external autonumber" href="mailto:enclosed@mail.tld">[4]</a>
19132 </p><p><a rel="nofollow" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a>
19133 </p>
19134 !! html/parsoid
19135 <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>
19136 <p><a rel="mw:ExtLink" class="external free" href="ftp://inlineftp">ftp://inlineftp</a></p>
19137 <p><a rel="mw:ExtLink" class="external text" href="mailto:enclosed@mail.tld">With target</a></p>
19138 <p><a rel="mw:ExtLink" class="external autonumber" href="mailto:enclosed@mail.tld"></a></p>
19139 <p><a rel="mw:ExtLink" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a></p>
19140 !! end
19141
19142
19143 #
19144 # Security and HTML correctness
19145 # From Nick Jenkins' fuzz testing
19146 #
19147
19148 !! test
19149 Fuzz testing: Parser13
19150 !! wikitext
19151 {|
19152 | http://a|
19153 !! html
19154 <table>
19155 <tr>
19156 <td>
19157 </td>
19158 </tr>
19159 </table>
19160
19161 !! end
19162
19163 # Note that Parsoid output differs from the PHP parser here: the PHP
19164 # parser breaks the URL for the magic word, while in Parsoid the URL
19165 # production takes precedence.
19166 !! test
19167 Fuzz testing: Parser14
19168 !! wikitext
19169 ==onmouseover===
19170 http://__TOC__
19171 !! html/php
19172 <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>
19173 http://<div id="toc" class="toc"><input type="checkbox" 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>
19174 <ul>
19175 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
19176 </ul>
19177 </div>
19178
19179
19180 !! html/php+tidy
19181 <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>
19182 http://</p><div id="toc" class="toc"><input type="checkbox" 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>
19183 <ul>
19184 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
19185 </ul>
19186 </div>
19187 !! html/parsoid
19188 <h2 id="onmouseover="><span id="onmouseover.3D" typeof="mw:FallbackId"></span>onmouseover=</h2>
19189 <p><a rel="mw:ExtLink" class="external free" href="http://__TOC__" data-parsoid='{"stx":"url"}'>http://__TOC__</a></p>
19190 !! end
19191
19192 !! test
19193 Fuzz testing: Parser14-table
19194 !! options
19195 parsoid=wt2html,html2html
19196 !! wikitext
19197 ==a==
19198 {| STYLE=__TOC__
19199 !! html
19200 <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>
19201 <table style="&#95;_TOC&#95;_">
19202 <tr><td></td></tr>
19203 </table>
19204
19205 !! html+tidy
19206 <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>
19207 <table style="__TOC__">
19208 <tr>
19209 <td></td>
19210 </tr>
19211 </table>
19212 !! html/parsoid
19213 <h2 id="a">a</h2>
19214 <table style="__TOC__"></table>
19215 !! end
19216
19217 # Known to produce bogus xml (extra </td>)
19218 # Don't add the html/php section since it generates broken HTML
19219 !! test
19220 Fuzz testing: Parser16
19221 !! wikitext
19222 {|
19223 !https://||||||
19224 !! html+tidy
19225 <table>
19226 <tbody><tr>
19227 <th>https://</th>
19228 <th></th>
19229 <th></th>
19230 <th>
19231
19232 </th></tr>
19233 </tbody></table>
19234 !! end
19235
19236 !! test
19237 Fuzz testing: Parser21
19238 !! wikitext
19239 {|
19240 !irc://{{ftp://a" onmouseover="alert('hello world');"
19241 |
19242 !! html
19243 <table>
19244 <tr>
19245 <th><a rel="nofollow" class="external free" href="irc://{{ftp://a">irc://{{ftp://a</a>" onmouseover="alert('hello world');"
19246 </th>
19247 <td>
19248 </td>
19249 </tr>
19250 </table>
19251
19252 !! end
19253
19254 !! test
19255 Fuzz testing: Parser22
19256 !! wikitext
19257 http://===r:::https://b
19258
19259 {|
19260 !! html
19261 <p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a>
19262 </p>
19263 <table>
19264 <tr><td></td></tr>
19265 </table>
19266
19267 !! end
19268
19269 # Known to produce bad XML for now
19270 !! test
19271 Fuzz testing: Parser24
19272 !! options
19273 parsoid=wt2html
19274 !! wikitext
19275 {|
19276 {{{|
19277 <u CLASS=
19278 | {{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}} >
19279 <br style="onmouseover='alert(document.cookie);' " />
19280
19281 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19282 |
19283 !! html/php
19284 <table>
19285 {{{|
19286 <u class="&#124;">}}}} &gt;
19287 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
19288
19289 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19290 <tr>
19291 <td></u>
19292 </td>
19293 </tr>
19294 </table>
19295
19296 !! html/parsoid
19297 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>{{{|
19298 <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>"}'/>}}}} >
19299 <br style="onmouseover='alert(document.cookie);' " data-parsoid='{"stx":"html","selfClose":true}'/></u></p><p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><u class="|" data-parsoid='{"stx":"html","a":{"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--":null},"sa":{"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--":""},"autoInsertedEnd":true,"autoInsertedStart":true}'>MOVE YOUR MOUSE CURSOR OVER THIS TEXT</u></p><table data-parsoid='{"autoInsertedEnd":true}'>
19300
19301
19302
19303 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'></td></tr></tbody></table>
19304 !! end
19305
19306 # Note: the current result listed for this is not what the original one was,
19307 # but the original bug was JavaScript injection, which is fixed in any case.
19308 # It's not clear that the original result listed was any more correct than the
19309 # current one. Original result:
19310 # <p>{{{|
19311 # </p>
19312 # <li class="&#124;&#124;">
19313 # }}}blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
19314 !!test
19315 Fuzz testing: Parser25 (T8055)
19316 !! wikitext
19317 {{{
19318 |
19319 <LI CLASS=||
19320 >
19321 }}}blah" onmouseover="alert('hello world');" align="left"'''MOVE MOUSE CURSOR OVER HERE
19322 !! html/php
19323 <p>&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
19324 </p>
19325 !! html/parsoid
19326 <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"]}'>
19327 </span><p about="#mwt1">&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b></p>
19328 !! end
19329
19330 !!test
19331 Fuzz testing: URL adjacent extension (with space, clean)
19332 !! wikitext
19333 http://example.com <nowiki>junk</nowiki>
19334 !! html/php
19335 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> junk
19336 </p>
19337 !! html/parsoid
19338 <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>
19339 !! end
19340
19341 !!test
19342 Fuzz testing: URL adjacent extension (no space, dirty; nowiki)
19343 !! wikitext
19344 http://example.com<nowiki>junk</nowiki>
19345 !! html/php
19346 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>junk
19347 </p>
19348 !! html/parsoid
19349 <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>
19350 !! end
19351
19352 !! test
19353 Fuzz testing: URL adjacent extension (no space, dirty; pre)
19354 !! wikitext
19355 http://example.com<pre>junk</pre>
19356 !! html/php
19357 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre>
19358
19359 !! html/php+tidy
19360 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p><pre>junk</pre>
19361 !! html/parsoid
19362 <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>
19363 !! end
19364
19365 !! test
19366 Fuzz testing: image with bogus manual thumbnail
19367 !! wikitext
19368 [[Image:foobar.jpg|thumbnail= ]]
19369 !! html/php
19370 <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div>
19371
19372 !! html/parsoid
19373 <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>
19374 !! end
19375
19376 # Parsoid will emit the newline literally in wt2wt; see next test case.
19377 !! test
19378 Fuzz testing: encoded newline in generated HTML replacements (T8577)
19379 !! options
19380 parsoid=wt2html
19381 !! wikitext
19382 <pre dir="&#10;"></pre>
19383 !! html/php
19384 <pre dir="&#10;"></pre>
19385
19386 !! html/parsoid
19387 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
19388 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
19389 !! end
19390
19391 !! test
19392 Fuzz testing: encoded newline in generated HTML replacements, html2wt (T8577)
19393 !! options
19394 parsoid=html2wt
19395 !! html/parsoid
19396 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
19397 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
19398 !! wikitext
19399 <pre dir="
19400 "></pre>
19401 !! html/php
19402 <pre dir=""></pre>
19403
19404 !! end
19405
19406 !! test
19407 Templates in extension attributes are not expanded
19408 !! wikitext
19409 <pre dir="{{echo|ltr}}"></pre>
19410 !! html/php
19411 <pre dir="{{echo|ltr}}"></pre>
19412
19413 !! html/parsoid
19414 <pre typeof="mw:Extension/pre" about="#mwt2" dir="{{echo|ltr}}" data-mw='{"name":"pre","attrs":{"dir":"{{echo|ltr}}"},"body":{"extsrc":""}}'></pre>
19415 !! end
19416
19417 !! test
19418 Parsing optional HTML elements (T8171)
19419 !! options
19420 !! wikitext
19421 <table>
19422 <tr>
19423 <td> Some tabular data</td>
19424 <td> More tabular data ...
19425 <td> And yet som tabular data</td>
19426 </tr>
19427 </table>
19428 !! html
19429 <table>
19430 <tr>
19431 <td> Some tabular data</td>
19432 <td> More tabular data ...
19433 </td><td> And yet som tabular data</td>
19434 </tr>
19435 </table>
19436
19437 !! end
19438
19439 !! test
19440 Correct handling of <td>, <tr> (T8171)
19441 !! options
19442 !! wikitext
19443 <table>
19444 <tr>
19445 <td> Some tabular data</td>
19446 <td> More tabular data ...</td>
19447 <td> And yet som tabular data</td>
19448 </tr>
19449 </table>
19450 !! html
19451 <table>
19452 <tr>
19453 <td> Some tabular data</td>
19454 <td> More tabular data ...</td>
19455 <td> And yet som tabular data</td>
19456 </tr>
19457 </table>
19458
19459 !! end
19460
19461
19462 !! test
19463 Parsing crashing regression (fr:JavaScript)
19464 !! wikitext
19465 </body></x>
19466 !! html
19467 <p>&lt;/body&gt;&lt;/x&gt;
19468 </p>
19469 !! end
19470
19471 !! test
19472 Inline wiki vs wiki block nesting
19473 !! wikitext
19474 '''Bold paragraph
19475
19476 New wiki paragraph
19477 !! html
19478 <p><b>Bold paragraph</b>
19479 </p><p>New wiki paragraph
19480 </p>
19481 !! end
19482
19483 # FIXME: The current php output is documented
19484 # and desired output is the parsoid target.
19485 !! test
19486 Inline HTML vs wiki block nesting
19487 !! wikitext
19488 <b>Bold paragraph
19489
19490 New wiki paragraph
19491 !! html/php
19492 <p><b>Bold paragraph
19493 </p><p>New wiki paragraph</b>
19494 </p>
19495 !! html/parsoid
19496 <p><b>Bold paragraph</b>
19497 </p><p>New wiki paragraph
19498 </p>
19499 !! end
19500
19501 # Original result was this:
19502 # <p><b>bold</b><b>bold<i>bolditalics</i></b>
19503 # </p>
19504 # While that might be marginally more intuitive, maybe, the six-apostrophe
19505 # construct is clearly pathological and the result stated here (which is what
19506 # the parser actually does) is about as reasonable as anything.
19507 !!test
19508 Mixing markup for italics and bold
19509 !! options
19510 !! wikitext
19511 '''bold''''''bold''bolditalics'''''
19512 !! html
19513 <p>'<i>bold'</i><b>bold<i>bolditalics</i></b>
19514 </p>
19515 !! end
19516
19517
19518 !! article
19519 Xyzzyx
19520 !! text
19521 Article for special page transclusion test
19522 !! endarticle
19523
19524 !! test
19525 Special page transclusion
19526 !! options
19527 !! wikitext
19528 {{Special:Prefixindex/Xyzzyx}}
19529 !! html
19530 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19531 </ul>
19532
19533 !! end
19534
19535 !! test
19536 Special page transclusion twice (T7021)
19537 !! options
19538 !! wikitext
19539 {{Special:Prefixindex/Xyzzyx}}
19540 {{Special:Prefixindex/Xyzzyx}}
19541 !! html
19542 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19543 </ul>
19544 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19545 </ul>
19546
19547 !! end
19548
19549 !! test
19550 Transclusion of default MediaWiki message
19551 !! wikitext
19552 {{MediaWiki:Mainpage}}
19553 !! html
19554 <p>Main Page
19555 </p>
19556 !! end
19557
19558 !! test
19559 Transclusion of nonexistent MediaWiki message
19560 !! wikitext
19561 {{MediaWiki:Mainpagexxx}}
19562 !! html
19563 <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>
19564 </p>
19565 !! end
19566
19567 !! test
19568 Transclusion of MediaWiki message with underscore
19569 !! wikitext
19570 {{MediaWiki:history_short}}
19571 !! html
19572 <p>History
19573 </p>
19574 !! end
19575
19576 !! test
19577 Transclusion of MediaWiki message with space
19578 !! wikitext
19579 {{MediaWiki:history short}}
19580 !! html
19581 <p>History
19582 </p>
19583 !! end
19584
19585 !! test
19586 Invalid header with following text
19587 !! wikitext
19588 = x = y
19589 !! html
19590 <p>= x = y
19591 </p>
19592 !! end
19593
19594
19595 !! test
19596 Section extraction test (section 0)
19597 !! options
19598 section=0
19599 !! wikitext
19600 start
19601 ==a==
19602 ===aa===
19603 ====aaa====
19604 ==b==
19605 ===ba===
19606 ===bb===
19607 ====bba====
19608 ===bc===
19609 ==c==
19610 ===ca===
19611 !! html/php
19612 start
19613 !! end
19614
19615 !! test
19616 Section extraction test (section 1)
19617 !! options
19618 section=1
19619 !! wikitext
19620 start
19621 ==a==
19622 ===aa===
19623 ====aaa====
19624 ==b==
19625 ===ba===
19626 ===bb===
19627 ====bba====
19628 ===bc===
19629 ==c==
19630 ===ca===
19631 !! html/php
19632 ==a==
19633 ===aa===
19634 ====aaa====
19635 !! end
19636
19637 !! test
19638 Section extraction test (section 2)
19639 !! options
19640 section=2
19641 !! wikitext
19642 start
19643 ==a==
19644 ===aa===
19645 ====aaa====
19646 ==b==
19647 ===ba===
19648 ===bb===
19649 ====bba====
19650 ===bc===
19651 ==c==
19652 ===ca===
19653 !! html/php
19654 ===aa===
19655 ====aaa====
19656 !! end
19657
19658 !! test
19659 Section extraction test (section 3)
19660 !! options
19661 section=3
19662 !! wikitext
19663 start
19664 ==a==
19665 ===aa===
19666 ====aaa====
19667 ==b==
19668 ===ba===
19669 ===bb===
19670 ====bba====
19671 ===bc===
19672 ==c==
19673 ===ca===
19674 !! html/php
19675 ====aaa====
19676 !! end
19677
19678 !! test
19679 Section extraction test (section 4)
19680 !! options
19681 section=4
19682 !! wikitext
19683 start
19684 ==a==
19685 ===aa===
19686 ====aaa====
19687 ==b==
19688 ===ba===
19689 ===bb===
19690 ====bba====
19691 ===bc===
19692 ==c==
19693 ===ca===
19694 !! html/php
19695 ==b==
19696 ===ba===
19697 ===bb===
19698 ====bba====
19699 ===bc===
19700 !! end
19701
19702 !! test
19703 Section extraction test (section 5)
19704 !! options
19705 section=5
19706 !! wikitext
19707 start
19708 ==a==
19709 ===aa===
19710 ====aaa====
19711 ==b==
19712 ===ba===
19713 ===bb===
19714 ====bba====
19715 ===bc===
19716 ==c==
19717 ===ca===
19718 !! html/php
19719 ===ba===
19720 !! end
19721
19722 !! test
19723 Section extraction test (section 6)
19724 !! options
19725 section=6
19726 !! wikitext
19727 start
19728 ==a==
19729 ===aa===
19730 ====aaa====
19731 ==b==
19732 ===ba===
19733 ===bb===
19734 ====bba====
19735 ===bc===
19736 ==c==
19737 ===ca===
19738 !! html/php
19739 ===bb===
19740 ====bba====
19741 !! end
19742
19743 !! test
19744 Section extraction test (section 7)
19745 !! options
19746 section=7
19747 !! wikitext
19748 start
19749 ==a==
19750 ===aa===
19751 ====aaa====
19752 ==b==
19753 ===ba===
19754 ===bb===
19755 ====bba====
19756 ===bc===
19757 ==c==
19758 ===ca===
19759 !! html/php
19760 ====bba====
19761 !! end
19762
19763 !! test
19764 Section extraction test (section 8)
19765 !! options
19766 section=8
19767 !! wikitext
19768 start
19769 ==a==
19770 ===aa===
19771 ====aaa====
19772 ==b==
19773 ===ba===
19774 ===bb===
19775 ====bba====
19776 ===bc===
19777 ==c==
19778 ===ca===
19779 !! html/php
19780 ===bc===
19781 !! end
19782
19783 !! test
19784 Section extraction test (section 9)
19785 !! options
19786 section=9
19787 !! wikitext
19788 start
19789 ==a==
19790 ===aa===
19791 ====aaa====
19792 ==b==
19793 ===ba===
19794 ===bb===
19795 ====bba====
19796 ===bc===
19797 ==c==
19798 ===ca===
19799 !! html/php
19800 ==c==
19801 ===ca===
19802 !! end
19803
19804 !! test
19805 Section extraction test (section 10)
19806 !! options
19807 section=10
19808 !! wikitext
19809 start
19810 ==a==
19811 ===aa===
19812 ====aaa====
19813 ==b==
19814 ===ba===
19815 ===bb===
19816 ====bba====
19817 ===bc===
19818 ==c==
19819 ===ca===
19820 !! html/php
19821 ===ca===
19822 !! end
19823
19824 !! test
19825 Section extraction test (nonexistent section 11)
19826 !! options
19827 section=11
19828 !! wikitext
19829 start
19830 ==a==
19831 ===aa===
19832 ====aaa====
19833 ==b==
19834 ===ba===
19835 ===bb===
19836 ====bba====
19837 ===bc===
19838 ==c==
19839 ===ca===
19840 !! html/php
19841 !! end
19842
19843 !! test
19844 Section extraction test with bogus heading (section 1)
19845 !! options
19846 section=1
19847 !! wikitext
19848 ==a==
19849 ==bogus== not a legal section
19850 ==b==
19851 !! html/php
19852 ==a==
19853 ==bogus== not a legal section
19854 !! end
19855
19856 !! test
19857 Section extraction test with bogus heading (section 2)
19858 !! options
19859 section=2
19860 !! wikitext
19861 ==a==
19862 ==bogus== not a legal section
19863 ==b==
19864 !! html/php
19865 ==b==
19866 !! end
19867
19868 !! test
19869 Section extraction test with comment after heading (section 1)
19870 !! options
19871 section=1
19872 !! wikitext
19873 ==a==
19874 ==b== <!-- -->
19875 ==c==
19876 !! html/php
19877 ==a==
19878 !! end
19879
19880 !! test
19881 Section extraction test with comment after heading (section 2)
19882 !! options
19883 section=2
19884 !! wikitext
19885 ==a==
19886 ==b== <!-- -->
19887 ==c==
19888 !! html/php
19889 ==b== <!-- -->
19890 !! end
19891
19892 !! test
19893 Section extraction test with bogus <nowiki> heading (section 1)
19894 !! options
19895 section=1
19896 !! wikitext
19897 ==a==
19898 ==bogus== <nowiki>not a legal section</nowiki>
19899 ==b==
19900 !! html/php
19901 ==a==
19902 ==bogus== <nowiki>not a legal section</nowiki>
19903 !! end
19904
19905 !! test
19906 Section extraction test with bogus <nowiki> heading (section 2)
19907 !! options
19908 section=2
19909 !! wikitext
19910 ==a==
19911 ==bogus== <nowiki>not a legal section</nowiki>
19912 ==b==
19913 !! html/php
19914 ==b==
19915 !! end
19916
19917 # Formerly testing for T4587, now resolved by the use of unmarked sections
19918 # instead of respecting commented sections
19919 !! test
19920 Section extraction prefixed by comment (section 1)
19921 !! options
19922 section=1
19923 !! wikitext
19924 <!-- -->==sec1==
19925 ==sec2==
19926 !! html/php
19927 ==sec2==
19928 !!end
19929
19930 !! test
19931 Section extraction prefixed by comment (section 2)
19932 !! options
19933 section=2
19934 !! wikitext
19935 <!-- -->==sec1==
19936 ==sec2==
19937 !! html/php
19938
19939 !!end
19940
19941 # Formerly testing for T4607, now resolved by the use of unmarked sections
19942 # instead of respecting HTML-style headings
19943 !! test
19944 Section extraction, mixed wiki and html (section 1)
19945 !! options
19946 section=1
19947 !! wikitext
19948 <h2>unmarked</h2>
19949 unmarked
19950 ==1==
19951 one
19952 ==2==
19953 two
19954 !! html/php
19955 ==1==
19956 one
19957 !! end
19958
19959 !! test
19960 Section extraction, mixed wiki and html (section 2)
19961 !! options
19962 section=2
19963 !! wikitext
19964 <h2>unmarked</h2>
19965 unmarked
19966 ==1==
19967 one
19968 ==2==
19969 two
19970 !! html/php
19971 ==2==
19972 two
19973 !! end
19974
19975
19976 # Formerly testing for T5342
19977 !! test
19978 Section extraction, heading surrounded by <noinclude>
19979 !! options
19980 section=1
19981 !! wikitext
19982 <noinclude>==unmarked==</noinclude>
19983 ==marked==
19984 !! html/php
19985 ==marked==
19986 !!end
19987
19988 # Test behavior of T21910
19989 !! test
19990 Sectiion with all-equals
19991 !! options
19992 section=2
19993 !! wikitext
19994 ===
19995 The line above must have a trailing space
19996 === <!--
19997 --> <!-- -->
19998 But just in case it doesn't...
19999 !! html/php
20000 === <!--
20001 --> <!-- -->
20002 But just in case it doesn't...
20003 !! end
20004
20005 !! test
20006 Section replacement test (section 0)
20007 !! options
20008 replace=0,"xxx"
20009 !! wikitext
20010 start
20011 ==a==
20012 ===aa===
20013 ====aaa====
20014 ==b==
20015 ===ba===
20016 ===bb===
20017 ====bba====
20018 ===bc===
20019 ==c==
20020 ===ca===
20021 !! html/php
20022 xxx
20023
20024 ==a==
20025 ===aa===
20026 ====aaa====
20027 ==b==
20028 ===ba===
20029 ===bb===
20030 ====bba====
20031 ===bc===
20032 ==c==
20033 ===ca===
20034 !! end
20035
20036 !! test
20037 Section replacement test (section 1)
20038 !! options
20039 replace=1,"xxx"
20040 !! wikitext
20041 start
20042 ==a==
20043 ===aa===
20044 ====aaa====
20045 ==b==
20046 ===ba===
20047 ===bb===
20048 ====bba====
20049 ===bc===
20050 ==c==
20051 ===ca===
20052 !! html/php
20053 start
20054 xxx
20055
20056 ==b==
20057 ===ba===
20058 ===bb===
20059 ====bba====
20060 ===bc===
20061 ==c==
20062 ===ca===
20063 !! end
20064
20065 !! test
20066 Section replacement test (section 2)
20067 !! options
20068 replace=2,"xxx"
20069 !! wikitext
20070 start
20071 ==a==
20072 ===aa===
20073 ====aaa====
20074 ==b==
20075 ===ba===
20076 ===bb===
20077 ====bba====
20078 ===bc===
20079 ==c==
20080 ===ca===
20081 !! html/php
20082 start
20083 ==a==
20084 xxx
20085
20086 ==b==
20087 ===ba===
20088 ===bb===
20089 ====bba====
20090 ===bc===
20091 ==c==
20092 ===ca===
20093 !! end
20094
20095 !! test
20096 Section replacement test (section 3)
20097 !! options
20098 replace=3,"xxx"
20099 !! wikitext
20100 start
20101 ==a==
20102 ===aa===
20103 ====aaa====
20104 ==b==
20105 ===ba===
20106 ===bb===
20107 ====bba====
20108 ===bc===
20109 ==c==
20110 ===ca===
20111 !! html/php
20112 start
20113 ==a==
20114 ===aa===
20115 xxx
20116
20117 ==b==
20118 ===ba===
20119 ===bb===
20120 ====bba====
20121 ===bc===
20122 ==c==
20123 ===ca===
20124 !! end
20125
20126 !! test
20127 Section replacement test (section 4)
20128 !! options
20129 replace=4,"xxx"
20130 !! wikitext
20131 start
20132 ==a==
20133 ===aa===
20134 ====aaa====
20135 ==b==
20136 ===ba===
20137 ===bb===
20138 ====bba====
20139 ===bc===
20140 ==c==
20141 ===ca===
20142 !! html/php
20143 start
20144 ==a==
20145 ===aa===
20146 ====aaa====
20147 xxx
20148
20149 ==c==
20150 ===ca===
20151 !! end
20152
20153 !! test
20154 Section replacement test (section 5)
20155 !! options
20156 replace=5,"xxx"
20157 !! wikitext
20158 start
20159 ==a==
20160 ===aa===
20161 ====aaa====
20162 ==b==
20163 ===ba===
20164 ===bb===
20165 ====bba====
20166 ===bc===
20167 ==c==
20168 ===ca===
20169 !! html/php
20170 start
20171 ==a==
20172 ===aa===
20173 ====aaa====
20174 ==b==
20175 xxx
20176
20177 ===bb===
20178 ====bba====
20179 ===bc===
20180 ==c==
20181 ===ca===
20182 !! end
20183
20184 !! test
20185 Section replacement test (section 6)
20186 !! options
20187 replace=6,"xxx"
20188 !! wikitext
20189 start
20190 ==a==
20191 ===aa===
20192 ====aaa====
20193 ==b==
20194 ===ba===
20195 ===bb===
20196 ====bba====
20197 ===bc===
20198 ==c==
20199 ===ca===
20200 !! html/php
20201 start
20202 ==a==
20203 ===aa===
20204 ====aaa====
20205 ==b==
20206 ===ba===
20207 xxx
20208
20209 ===bc===
20210 ==c==
20211 ===ca===
20212 !! end
20213
20214 !! test
20215 Section replacement test (section 7)
20216 !! options
20217 replace=7,"xxx"
20218 !! wikitext
20219 start
20220 ==a==
20221 ===aa===
20222 ====aaa====
20223 ==b==
20224 ===ba===
20225 ===bb===
20226 ====bba====
20227 ===bc===
20228 ==c==
20229 ===ca===
20230 !! html/php
20231 start
20232 ==a==
20233 ===aa===
20234 ====aaa====
20235 ==b==
20236 ===ba===
20237 ===bb===
20238 xxx
20239
20240 ===bc===
20241 ==c==
20242 ===ca===
20243 !! end
20244
20245 !! test
20246 Section replacement test (section 8)
20247 !! options
20248 replace=8,"xxx"
20249 !! wikitext
20250 start
20251 ==a==
20252 ===aa===
20253 ====aaa====
20254 ==b==
20255 ===ba===
20256 ===bb===
20257 ====bba====
20258 ===bc===
20259 ==c==
20260 ===ca===
20261 !! html/php
20262 start
20263 ==a==
20264 ===aa===
20265 ====aaa====
20266 ==b==
20267 ===ba===
20268 ===bb===
20269 ====bba====
20270 xxx
20271
20272 ==c==
20273 ===ca===
20274 !!end
20275
20276 !! test
20277 Section replacement test (section 9)
20278 !! options
20279 replace=9,"xxx"
20280 !! wikitext
20281 start
20282 ==a==
20283 ===aa===
20284 ====aaa====
20285 ==b==
20286 ===ba===
20287 ===bb===
20288 ====bba====
20289 ===bc===
20290 ==c==
20291 ===ca===
20292 !! html/php
20293 start
20294 ==a==
20295 ===aa===
20296 ====aaa====
20297 ==b==
20298 ===ba===
20299 ===bb===
20300 ====bba====
20301 ===bc===
20302 xxx
20303 !! end
20304
20305 !! test
20306 Section replacement test (section 10)
20307 !! options
20308 replace=10,"xxx"
20309 !! wikitext
20310 start
20311 ==a==
20312 ===aa===
20313 ====aaa====
20314 ==b==
20315 ===ba===
20316 ===bb===
20317 ====bba====
20318 ===bc===
20319 ==c==
20320 ===ca===
20321 !! html/php
20322 start
20323 ==a==
20324 ===aa===
20325 ====aaa====
20326 ==b==
20327 ===ba===
20328 ===bb===
20329 ====bba====
20330 ===bc===
20331 ==c==
20332 xxx
20333 !! end
20334
20335 !! test
20336 Section replacement test with initial whitespace (T15728)
20337 !! options
20338 replace=2,"xxx"
20339 !! wikitext
20340 Preformatted initial line
20341 ==a==
20342 ===a===
20343 !! html/php
20344 Preformatted initial line
20345 ==a==
20346 xxx
20347 !! end
20348
20349
20350 !! test
20351 Section extraction, heading followed by pre with 20 spaces (T8398)
20352 !! options
20353 section=1
20354 !! wikitext
20355 ==a==
20356 a
20357 !! html/php
20358 ==a==
20359 a
20360 !! end
20361
20362 !! test
20363 Section extraction, heading followed by pre with 19 spaces (T8398 sanity check)
20364 !! options
20365 section=1
20366 !! wikitext
20367 ==a==
20368 a
20369 !! html/php
20370 ==a==
20371 a
20372 !! end
20373
20374
20375 !! test
20376 Section extraction, <pre> around bogus header (T12309)
20377 !! options
20378 section=2
20379 !! wikitext
20380 == Section One ==
20381 <pre>
20382 =======
20383 </pre>
20384
20385 == Section Two ==
20386 stuff
20387 !! html/php
20388 == Section Two ==
20389 stuff
20390 !! end
20391
20392 !! test
20393 Section replacement, <pre> around bogus header (T12309)
20394 !! options
20395 replace=2,"xxx"
20396 !! wikitext
20397 == Section One ==
20398 <pre>
20399 =======
20400 </pre>
20401
20402 == Section Two ==
20403 stuff
20404 !! html/php
20405 == Section One ==
20406 <pre>
20407 =======
20408 </pre>
20409
20410 xxx
20411 !! end
20412
20413 !! test
20414 Handling of &#x0A; in URLs
20415 !! wikitext
20416 *irc://&#x0A;a
20417 !! html/php
20418 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
20419
20420 !! html/parsoid
20421 <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>
20422 !! end
20423
20424 !! test
20425 Handling of %0A in URLs
20426 !! wikitext
20427 *irc://%0Aa
20428 !! html/php
20429 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
20430
20431 !! html/parsoid
20432 <ul><li><a rel="mw:ExtLink" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
20433 !! end
20434
20435 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
20436 !! test
20437 5 quotes, code coverage +1 line
20438 !! options
20439 parsoid=wt2html
20440 !! wikitext
20441 '''''
20442 !! html/php
20443 !! html/parsoid
20444 <b><i></i></b>
20445 !! end
20446
20447 # same html as previous, but wikitext adjusted to match parsoid html2wt
20448 # note that wt2html and html2html will put the <i> before the <b>
20449 !! test
20450 5 quotes, code coverage +1 line w/ nowiki (1)
20451 !! options
20452 parsoid=wt2wt,html2wt
20453 !! wikitext
20454 '''''<nowiki/>'''''
20455 !! html/php
20456 <p><i></i>
20457 </p>
20458 !! html/parsoid
20459 <p><b><i></i></b></p>
20460 !! end
20461
20462 # same as previous, just swapping the <i> and <b>
20463 !! test
20464 5 quotes, code coverage +1 line w/ nowiki (2)
20465 !! wikitext
20466 '''''<nowiki/>'''''
20467 !! html/php
20468 <p><i></i>
20469 </p>
20470 !! html/parsoid
20471 <p><i><b></b></i></p>
20472 !! end
20473
20474 !! test
20475 Special:Search page linking.
20476 !! wikitext
20477 {{Special:search}}
20478 !! html
20479 <p><a href="/wiki/Special:Search" title="Special:Search">Special:Search</a>
20480 </p>
20481 !! end
20482
20483 !! test
20484 {{!}} is a magic word
20485 !! wikitext
20486 {{!}} is a magic word there and {{!}} is still a magic word here
20487 | is not a magic word here but {{!}} is still a magic word here
20488 !! html/php
20489 <p>| is a magic word there and | is still a magic word here
20490 | is not a magic word here but | is still a magic word here
20491 </p>
20492 !! html/parsoid
20493 <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
20494 | 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>
20495 !! end
20496
20497 !! test
20498 Say the magic word
20499 !! options
20500 title=[[Parser test]]
20501 !! wikitext
20502 *{{PAGENAME}}
20503 *{{PAGENAMEE}}
20504 *{{FULLPAGENAME}}
20505 *{{FULLPAGENAMEE}}
20506 *{{BASEPAGENAME}}
20507 *{{BASEPAGENAMEE}}
20508 *{{SUBPAGENAME}}
20509 *{{SUBPAGENAMEE}}
20510 *{{ROOTPAGENAME}}
20511 *{{ROOTPAGENAMEE}}
20512 *{{TALKPAGENAME}}
20513 *{{TALKPAGENAMEE}}
20514 *{{SUBJECTPAGENAME}}
20515 *{{SUBJECTPAGENAMEE}}
20516 *{{NAMESPACEE}}
20517 *{{NAMESPACE}}
20518 *{{NAMESPACENUMBER}}
20519 *{{TALKSPACE}}
20520 *{{TALKSPACEE}}
20521 *{{SUBJECTSPACE}}
20522 *{{SUBJECTSPACEE}}
20523 *{{Dynamic|{{NUMBEROFUSERS}}|{{NUMBEROFPAGES}}|{{CURRENTVERSION}}|{{CONTENTLANGUAGE}}|{{DIRECTIONMARK}}|{{CURRENTTIMESTAMP}}|{{NUMBEROFARTICLES}}}}
20524 !! html
20525 <ul><li>Parser test</li>
20526 <li>Parser_test</li>
20527 <li>Parser test</li>
20528 <li>Parser_test</li>
20529 <li>Parser test</li>
20530 <li>Parser_test</li>
20531 <li>Parser test</li>
20532 <li>Parser_test</li>
20533 <li>Parser test</li>
20534 <li>Parser_test</li>
20535 <li>Talk:Parser test</li>
20536 <li>Talk:Parser_test</li>
20537 <li>Parser test</li>
20538 <li>Parser_test</li>
20539 <li></li>
20540 <li></li>
20541 <li>0</li>
20542 <li>Talk</li>
20543 <li>Talk</li>
20544 <li></li>
20545 <li></li>
20546 <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>
20547
20548 !! end
20549 ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included.
20550
20551 !! test
20552 Gallery with valid attributes
20553 !! wikitext
20554 <gallery type="123" summary="345">
20555 File:File:Foobar.jpg
20556 </gallery>
20557 !! html/php
20558 <ul class="gallery mw-gallery-traditional" type="123">
20559 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20560 <div class="thumb" style="height: 150px;">File:Foobar.jpg</div>
20561 <div class="gallerytext">
20562 </div>
20563 </div></li>
20564 </ul>
20565
20566 !! html/parsoid
20567 <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"}}'>
20568 <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>
20569 </ul>
20570 !! end
20571
20572 ## Parsoid thinks the "centre" here is a property, not a caption.
20573 !! test
20574 Gallery
20575 !! options
20576 parsoid={
20577 "modes": ["wt2html"],
20578 "nativeGallery": true
20579 }
20580 !! wikitext
20581 <gallery>
20582 image1.png |
20583 image2.gif|||||
20584
20585 image3|
20586 image4 |300px| centre
20587 image5.svg| http://///////
20588 [[x|xx]]]]
20589 * image6
20590 </gallery>
20591 !! html/php
20592 <ul class="gallery mw-gallery-traditional">
20593 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20594 <div class="thumb" style="height: 150px;">Image1.png</div>
20595 <div class="gallerytext">
20596 </div>
20597 </div></li>
20598 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20599 <div class="thumb" style="height: 150px;">Image2.gif</div>
20600 <div class="gallerytext">
20601 </div>
20602 </div></li>
20603 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20604 <div class="thumb" style="height: 150px;">Image3</div>
20605 <div class="gallerytext">
20606 </div>
20607 </div></li>
20608 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20609 <div class="thumb" style="height: 150px;">Image4</div>
20610 <div class="gallerytext">
20611 <pre>centre
20612 </pre>
20613 </div>
20614 </div></li>
20615 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20616 <div class="thumb" style="height: 150px;">Image5.svg</div>
20617 <div class="gallerytext">
20618 <p><a rel="nofollow" class="external free" href="http://///////">http://///////</a>
20619 </p>
20620 </div>
20621 </div></li>
20622 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20623 <div class="thumb" style="height: 150px;">* image6</div>
20624 <div class="gallerytext">
20625 </div>
20626 </div></li>
20627 </ul>
20628
20629 !! html/parsoid
20630 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20631 <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>
20632 <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>
20633 <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>
20634 <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>
20635 <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>
20636 <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>
20637 </ul>
20638 !! end
20639
20640 !! test
20641 Gallery (with options, html)
20642 !! options
20643 parsoid={
20644 "modes": ["wt2html", "html2html"],
20645 "nativeGallery": true
20646 }
20647 !! wikitext
20648 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
20649 File:Nonexistent.jpg|caption
20650 File:Nonexistent.jpg
20651 image:foobar.jpg|some '''caption''' [[Main Page]]
20652 image:foobar.jpg
20653 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
20654 </gallery>
20655 !! html/php
20656 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
20657 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
20658 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20659 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20660 <div class="gallerytext">
20661 <p>caption
20662 </p>
20663 </div>
20664 </div></li>
20665 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20666 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20667 <div class="gallerytext">
20668 </div>
20669 </div></li>
20670 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20671 <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>
20672 <div class="gallerytext">
20673 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20674 </p>
20675 </div>
20676 </div></li>
20677 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20678 <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>
20679 <div class="gallerytext">
20680 </div>
20681 </div></li>
20682 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20683 <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>
20684 <div class="gallerytext">
20685 <p>blabla.
20686 </p>
20687 </div>
20688 </div></li>
20689 </ul>
20690
20691 !! html/parsoid
20692 <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":{}}'>
20693 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
20694 <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>
20695 <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>
20696 <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>
20697 <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>
20698 <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>
20699 </ul>
20700 !! end
20701
20702 !! test
20703 Gallery (with options, extsrc)
20704 !! options
20705 parsoid={
20706 "nativeGallery": false
20707 }
20708 !! wikitext
20709 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
20710 File:Nonexistent.jpg|caption
20711 File:Nonexistent.jpg
20712 image:foobar.jpg|some '''caption''' [[Main Page]]
20713 image:foobar.jpg
20714 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
20715 </gallery>
20716 !! html/php
20717 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
20718 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
20719 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20720 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20721 <div class="gallerytext">
20722 <p>caption
20723 </p>
20724 </div>
20725 </div></li>
20726 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20727 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20728 <div class="gallerytext">
20729 </div>
20730 </div></li>
20731 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20732 <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>
20733 <div class="gallerytext">
20734 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20735 </p>
20736 </div>
20737 </div></li>
20738 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20739 <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>
20740 <div class="gallerytext">
20741 </div>
20742 </div></li>
20743 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20744 <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>
20745 <div class="gallerytext">
20746 <p>blabla.
20747 </p>
20748 </div>
20749 </div></li>
20750 </ul>
20751
20752 !! html/parsoid
20753 <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"}}'>
20754 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
20755 <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>
20756 <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>
20757 <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>
20758 <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>
20759 <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>
20760 </ul>
20761 !! end
20762
20763 !! test
20764 Gallery (without px units)
20765 !! wikitext
20766 <gallery widths="70" heights="40">
20767 File:Foobar.jpg
20768 </gallery>
20769 !! html/php
20770 <ul class="gallery mw-gallery-traditional">
20771 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20772 <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>
20773 <div class="gallerytext">
20774 </div>
20775 </div></li>
20776 </ul>
20777
20778 !! html/parsoid
20779 <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"}}'>
20780 <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>
20781 </ul>
20782 !! end
20783
20784 !! test
20785 Gallery (with invalid units)
20786 !! wikitext
20787 <gallery widths="70em" heights="40em">
20788 File:Foobar.jpg
20789 </gallery>
20790 !! html/php
20791 <ul class="gallery mw-gallery-traditional">
20792 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20793 <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>
20794 <div class="gallerytext">
20795 </div>
20796 </div></li>
20797 </ul>
20798
20799 !! html/parsoid
20800 <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"}}'>
20801 <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>
20802 </ul>
20803 !! end
20804
20805 !! test
20806 Gallery with link that has fragment
20807 !! options
20808 parsoid={
20809 "modes": ["wt2html", "html2html"],
20810 "nativeGallery": true
20811 }
20812 !! wikitext
20813 <gallery>
20814 image:foobar.jpg|link=Main_Page
20815 image:foobar.jpg|link=Main_Page#section
20816 image:foobar.jpg|link=Main Page#section|caption
20817 </gallery>
20818 !! html/php
20819 <ul class="gallery mw-gallery-traditional">
20820 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20821 <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>
20822 <div class="gallerytext">
20823 </div>
20824 </div></li>
20825 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20826 <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>
20827 <div class="gallerytext">
20828 </div>
20829 </div></li>
20830 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20831 <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>
20832 <div class="gallerytext">
20833 <p>caption
20834 </p>
20835 </div>
20836 </div></li>
20837 </ul>
20838
20839 !! html/parsoid
20840 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20841 <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>
20842 <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>
20843 <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>
20844 </ul>
20845 !! end
20846
20847 ## Whoops, Parsoid shouldn't be parsing templates in the attribute caption!
20848 !! test
20849 Gallery with template inside caption
20850 !! options
20851 parsoid={
20852 "nativeGallery": true
20853 }
20854 !! wikitext
20855 <gallery caption="{{echo|hi}}">
20856 File:Foobar.jpg|{{echo|ho}}
20857 </gallery>
20858 !! html/php
20859 <ul class="gallery mw-gallery-traditional">
20860 <li class='gallerycaption'>{{echo|hi}}</li>
20861 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20862 <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>
20863 <div class="gallerytext">
20864 <p>ho
20865 </p>
20866 </div>
20867 </div></li>
20868 </ul>
20869
20870 !! html/parsoid
20871 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20872 <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>
20873 <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>
20874 </ul>
20875 !! end
20876
20877 !! test
20878 Gallery with wikitext inside caption
20879 !! options
20880 parsoid={
20881 "nativeGallery": true
20882 }
20883 !! wikitext
20884 <gallery>
20885 File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]]
20886 File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}}
20887 </gallery>
20888 !! html/php
20889 <ul class="gallery mw-gallery-traditional">
20890 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20891 <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>
20892 <div class="gallerytext">
20893 <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>
20894 </p>
20895 </div>
20896 </div></li>
20897 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20898 <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>
20899 <div class="gallerytext">
20900 <p>This is a test template
20901 </p>
20902 </div>
20903 </div></li>
20904 </ul>
20905
20906 !! html/parsoid
20907 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20908 <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>
20909 <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>
20910 </ul>
20911 !! end
20912
20913 !! test
20914 Gallery (with showfilename option)
20915 !! options
20916 parsoid={
20917 "nativeGallery": true
20918 }
20919 !! wikitext
20920 <gallery showfilename="">
20921 File:Nonexistent.jpg|caption
20922 File:Nonexistent.jpg
20923 File:Foobar.jpg|some '''caption''' [[Main Page]]
20924 File:Foobar.jpg
20925 </gallery>
20926 !! html/php
20927 <ul class="gallery mw-gallery-traditional">
20928 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20929 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20930 <div class="gallerytext">
20931 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
20932 caption
20933 </p>
20934 </div>
20935 </div></li>
20936 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20937 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20938 <div class="gallerytext">
20939 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
20940 </p>
20941 </div>
20942 </div></li>
20943 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20944 <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>
20945 <div class="gallerytext">
20946 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
20947 some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20948 </p>
20949 </div>
20950 </div></li>
20951 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20952 <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>
20953 <div class="gallerytext">
20954 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
20955 </p>
20956 </div>
20957 </div></li>
20958 </ul>
20959
20960 !! html/parsoid
20961 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
20962 <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>
20963 <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>
20964 <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>
20965 <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>
20966 </ul>
20967 !! end
20968
20969 ## Should Parsoid be preserving these variations? See T151367
20970 !! test
20971 Gallery (with namespace-less filenames)
20972 !! options
20973 parsoid={
20974 "modes": ["wt2html", "html2html"],
20975 "nativeGallery": true
20976 }
20977 !! wikitext
20978 <gallery>
20979 File:Nonexistent.jpg
20980 Nonexistent.jpg
20981 image:foobar.jpg
20982 foobar.jpg
20983 </gallery>
20984 !! html/php
20985 <ul class="gallery mw-gallery-traditional">
20986 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20987 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20988 <div class="gallerytext">
20989 </div>
20990 </div></li>
20991 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20992 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20993 <div class="gallerytext">
20994 </div>
20995 </div></li>
20996 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20997 <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>
20998 <div class="gallerytext">
20999 </div>
21000 </div></li>
21001 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21002 <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>
21003 <div class="gallerytext">
21004 </div>
21005 </div></li>
21006 </ul>
21007
21008 !! html/parsoid
21009 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21010 <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>
21011 <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>
21012 <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>
21013 <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>
21014 </ul>
21015 !! end
21016
21017 !! test
21018 Gallery override link with wikilink (T36852)
21019 !! options
21020 parsoid={
21021 "nativeGallery": true
21022 }
21023 !! wikitext
21024 <gallery>
21025 File:Foobar.jpg|alt=galleryalt|link=Wikilink
21026 </gallery>
21027 !! html/php
21028 <ul class="gallery mw-gallery-traditional">
21029 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21030 <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>
21031 <div class="gallerytext">
21032 </div>
21033 </div></li>
21034 </ul>
21035
21036 !! html/parsoid
21037 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21038 <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>
21039 </ul>
21040 !! end
21041
21042 !! test
21043 Gallery override link with absolute external link (T36852)
21044 !! options
21045 parsoid={
21046 "nativeGallery": true
21047 }
21048 !! wikitext
21049 <gallery>
21050 File:Foobar.jpg|alt=galleryalt|link=http://www.example.org
21051 </gallery>
21052 !! html/php
21053 <ul class="gallery mw-gallery-traditional">
21054 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21055 <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>
21056 <div class="gallerytext">
21057 </div>
21058 </div></li>
21059 </ul>
21060
21061 !! html/parsoid
21062 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21063 <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>
21064 </ul>
21065 !! end
21066
21067 !! test
21068 Gallery override link with absolute external link with LanguageConverter
21069 !! options
21070 language=zh
21071 !! wikitext
21072 <gallery>
21073 File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org
21074 </gallery>
21075 !! html/php
21076 <ul class="gallery mw-gallery-traditional">
21077 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21078 <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>
21079 <div class="gallerytext">
21080 <p>caption
21081 </p>
21082 </div>
21083 </div></li>
21084 </ul>
21085
21086 !! html/parsoid
21087 <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"}}'>
21088 <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>
21089 </ul>
21090 !! end
21091
21092 !! test
21093 Gallery override link with malicious javascript (T36852)
21094 !! options
21095 parsoid={
21096 "modes": ["wt2html", "html2html"],
21097 "nativeGallery": true
21098 }
21099 !! wikitext
21100 <gallery>
21101 File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!');
21102 </gallery>
21103 !! html/php
21104 <ul class="gallery mw-gallery-traditional">
21105 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21106 <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>
21107 <div class="gallerytext">
21108 </div>
21109 </div></li>
21110 </ul>
21111
21112 !! html/parsoid
21113 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21114 <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>
21115 </ul>
21116 !! end
21117
21118 # Note that parsoid uses the invalid link as a caption, PHP does not.
21119 !! test
21120 Gallery with invalid title as link (T45964)
21121 !! options
21122 parsoid={
21123 "modes": ["wt2html", "html2html"],
21124 "nativeGallery": true
21125 }
21126 !! wikitext
21127 <gallery>
21128 File:Foobar.jpg|link=<
21129 </gallery>
21130 !! html/php
21131 <ul class="gallery mw-gallery-traditional">
21132 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21133 <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>
21134 <div class="gallerytext">
21135 </div>
21136 </div></li>
21137 </ul>
21138
21139 !! html/parsoid
21140 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21141 <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>
21142 </ul>
21143 !! end
21144
21145 !! test
21146 Serialize gallery without attrs in data-mw
21147 !! options
21148 parsoid={
21149 "modes": ["html2wt"],
21150 "nativeGallery": true
21151 }
21152 !! html/parsoid
21153 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'>
21154 <li class="gallerycaption">123</li>
21155 <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>
21156 </ul>
21157 !! wikitext
21158 <gallery caption="123">
21159 File:Test.png
21160 </gallery>
21161 !! end
21162
21163 !! test
21164 Gallery with class and style attributes
21165 !! options
21166 parsoid={
21167 "nativeGallery": true
21168 }
21169 !! wikitext
21170 <gallery class="center" style="text-align: center;">
21171 File:Foobar.jpg
21172 </gallery>
21173 !! html/php
21174 <ul class="gallery mw-gallery-traditional center" style="text-align: center;">
21175 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21176 <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>
21177 <div class="gallerytext">
21178 </div>
21179 </div></li>
21180 </ul>
21181
21182 !! html/parsoid
21183 <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":{}}'>
21184 <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>
21185 </ul>
21186 !! end
21187
21188 !! test
21189 Gallery in slideshow mode
21190 !! options
21191 parsoid={
21192 "nativeGallery": true
21193 }
21194 !! wikitext
21195 <gallery mode="slideshow" showthumbnails="">
21196 File:Foobar.jpg
21197 </gallery>
21198 !! html/php
21199 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1">
21200 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21201 <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>
21202 <div class="gallerytext">
21203 </div>
21204 </div></li>
21205 </ul>
21206
21207 !! html/parsoid
21208 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'>
21209 <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>
21210 </ul>
21211 !! end
21212
21213 !! test
21214 Serialize gallery image captions on a line
21215 !! options
21216 parsoid={
21217 "modes": ["html2wt"],
21218 "nativeGallery": true
21219 }
21220 !! html/parsoid
21221 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21222 <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>
21223 <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>
21224 </ul>
21225 !! wikitext
21226 <gallery>
21227 File:Foobar.jpg| hi ho
21228 File:Foobar.jpg|hi<br />ho
21229 </gallery>
21230 !! end
21231
21232 !! test
21233 HTML Hex character encoding (spells the word "JavaScript")
21234 !! options
21235 parsoid=wt2html,wt2wt,html2html
21236 !! wikitext
21237 &#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
21238 !! html/php
21239 <p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
21240 </p>
21241 !! html/parsoid
21242 <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>
21243 !! end
21244
21245 !! test
21246 HTML Hex character encoding bogus encoding (T28437 regression check)
21247 !! wikitext
21248 &#xsee;&#XSEE;
21249 !! html
21250 <p>&amp;#xsee;&amp;#XSEE;
21251 </p>
21252 !! end
21253
21254 !! test
21255 HTML Hex character encoding mixed case
21256 !! options
21257 parsoid=wt2html,wt2wt,html2html
21258 !! wikitext
21259 &#xEE;&#Xee;
21260 !! html/php
21261 <p>&#xee;&#xee;
21262 </p>
21263 !! html/parsoid
21264 <p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
21265 !! end
21266
21267 # See: https://www.w3.org/TR/html5/syntax.html#character-references
21268 # Note that U+000C (form feed) is not a valid XML character, so
21269 # it is banned even though allowed in HTML5.
21270 !! test
21271 Illegal character references (T106578)
21272 !! wikitext
21273 ; Null: &#00;
21274 ; FF: &#xC;
21275 ; CR: &#xD;
21276 ; Control (low): &#8;
21277 ; Control (high): &#x7F; &#x9F;
21278 ; Surrogate: &#xD83D;&#xDCA9;
21279 ; This is an okay astral character: &#x1F4A9;
21280 !! html+tidy
21281 <dl><dt>Null</dt>
21282 <dd>&amp;#00;</dd>
21283 <dt>FF</dt>
21284 <dd>&amp;#xC;</dd>
21285 <dt>CR</dt>
21286 <dd>&amp;#xD;</dd>
21287 <dt>Control (low)</dt>
21288 <dd>&amp;#8;</dd>
21289 <dt>Control (high)</dt>
21290 <dd>&amp;#x7F; &amp;#x9F;</dd>
21291 <dt>Surrogate</dt>
21292 <dd>&amp;#xD83D;&amp;#xDCA9;</dd>
21293 <dt>This is an okay astral character</dt>
21294 <dd>&#x1f4a9;</dd></dl>
21295 !! end
21296
21297 !! test
21298 __FORCETOC__ override
21299 !! wikitext
21300 __NEWSECTIONLINK__
21301 __FORCETOC__
21302 !! html/php
21303 <p><br />
21304 </p>
21305 !! end
21306
21307 !! test
21308 ISBN code coverage
21309 !! wikitext
21310 ISBN 978-0-1234-56&#x20;789
21311 !! html/php
21312 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a>&#x20;789
21313 </p>
21314 !! html/parsoid
21315 <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>
21316 !! end
21317
21318 !! test
21319 ISBN followed by 5 spaces
21320 !! wikitext
21321 ISBN
21322 !! html
21323 <p>ISBN
21324 </p>
21325 !! end
21326
21327 !! test
21328 Double ISBN
21329 !! wikitext
21330 ISBN ISBN 1234567890
21331 !! html/php
21332 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21333 </p>
21334 !! html/parsoid
21335 <p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
21336 !! end
21337
21338 # Uppercase X and lowercase x as well
21339 !! test
21340 ISBN with an X
21341 !! wikitext
21342 ISBN 3-462-04561-X
21343 ISBN 3-462-04561-x
21344 ISBN 080442957X
21345 ISBN 080442957x
21346 ISBN 978080442957X
21347 ISBN 978080442957x
21348 !! html/php
21349 <p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a>
21350 <a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a>
21351 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a>
21352 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a>
21353 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a>
21354 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
21355 </p>
21356 !! html/parsoid
21357 <p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
21358 <a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
21359 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
21360 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
21361 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
21362 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
21363 !! end
21364
21365 !! test
21366 ISBN with empty prefix (parsoid test)
21367 !! wikitext
21368 ISBN 1234567890
21369 !! html/php
21370 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21371 </p>
21372 !! html/parsoid
21373 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p>
21374 !! end
21375
21376 !! test
21377 T24905: <abbr> followed by ISBN followed by </a>
21378 !! wikitext
21379 <abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
21380 !! html/php
21381 <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>
21382 </p>
21383 !! html/parsoid
21384 <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>
21385 !! end
21386
21387 !! test
21388 Double RFC
21389 !! wikitext
21390 RFC RFC 1234
21391 !! html/php
21392 <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a>
21393 </p>
21394 !! html/parsoid
21395 <p>RFC <a href="https://tools.ietf.org/html/rfc1234" rel="mw:ExtLink" class="external mw-magiclink">RFC 1234</a></p>
21396 !! end
21397
21398 !! test
21399 Double RFC with a wiki link
21400 !! wikitext
21401 RFC [[RFC 1234]]
21402 !! html/php
21403 <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>
21404 </p>
21405 !! html/parsoid
21406 <p>RFC <a rel="mw:WikiLink" href="./RFC_1234" title="RFC 1234">RFC 1234</a></p>
21407 !! end
21408
21409 !! test
21410 RFC code coverage
21411 !! wikitext
21412 RFC 983&#x20;987
21413 !! html/php
21414 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
21415 </p>
21416 !! html/parsoid
21417 <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>
21418 !! end
21419
21420 !! test
21421 Centre-aligned image
21422 !! wikitext
21423 [[Image:foobar.jpg|centre]]
21424 !! html/php
21425 <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>
21426
21427 !! html/parsoid
21428 <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>
21429 !! end
21430
21431 !! test
21432 None-aligned image
21433 !! wikitext
21434 [[Image:foobar.jpg|none]]
21435 !! html/php
21436 <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>
21437
21438 !! html/parsoid
21439 <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>
21440 !! end
21441
21442 !! test
21443 Width + Height sized image (using px) (height is ignored)
21444 !! wikitext
21445 [[Image:foobar.jpg|640x480px]]
21446 !! html/php
21447 <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>
21448 </p>
21449 !! html/parsoid
21450 <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>
21451 !! end
21452
21453 !! test
21454 Width-sized image (using px, no following whitespace)
21455 !! wikitext
21456 [[Image:foobar.jpg|640px]]
21457 !! html/php
21458 <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>
21459 </p>
21460 !! html/parsoid
21461 <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>
21462 !! end
21463
21464 !! test
21465 Width-sized image (using px, with following whitespace - test regression from r39467)
21466 !! wikitext
21467 [[Image:foobar.jpg|640px ]]
21468 !! html/php
21469 <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>
21470 </p>
21471 !! html/parsoid
21472 <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>
21473 !!end
21474
21475 !! test
21476 Width-sized image (using px, with preceding whitespace - test regression from r39467)
21477 !! wikitext
21478 [[Image:foobar.jpg| 640px]]
21479 !! html/php
21480 <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>
21481 </p>
21482 !! html/parsoid
21483 <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>
21484 !! end
21485
21486 !! test
21487 Image with page parameter
21488 !! options
21489 djvu
21490 !! wikitext
21491 [[File:LoremIpsum.djvu|page=2]]
21492 !! html/php
21493 <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>
21494 </p>
21495 !! html/parsoid
21496 <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>
21497 !! end
21498
21499 !! test
21500 Another italics / bold test
21501 !! wikitext
21502 ''' ''x'
21503 !! html
21504 <pre>'<i> </i>x'
21505 </pre>
21506 !!end
21507
21508 # FIXME: The php output seems broken. It's interleaving some open/close tags.
21509 !! test
21510 dt/dd/dl test
21511 !! wikitext
21512 :;;;::
21513 !! html/php
21514 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dt></dl></dd></dl></dd></dl></dd></dl></dd></dl></dd></dl>
21515
21516 !! html/parsoid
21517 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dd></dl></dd></dl></dt></dl></dt></dl></dt></dl></dd></dl>
21518
21519 !!end
21520
21521 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
21522 !! test
21523 Images with the "|" character in the comment
21524 !! wikitext
21525 [[File:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
21526 !! html/php
21527 <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>
21528
21529 !! html/parsoid
21530 <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>
21531 !! end
21532
21533 !! test
21534 [Before] HTML without raw HTML enabled ($wgRawHtml==false)
21535 !! wikitext
21536 <html><script>alert(1);</script></html>
21537 !! html
21538 <p>&lt;html&gt;&lt;script&gt;alert(1);&lt;/script&gt;&lt;/html&gt;
21539 </p>
21540 !! end
21541
21542 !! test
21543 HTML with raw HTML ($wgRawHtml==true)
21544 !! options
21545 wgRawHtml=1
21546 !! wikitext
21547 <html><script>alert(1);</script></html>
21548 !! html/php
21549 <p><script>alert(1);</script>
21550 </p>
21551 !! end
21552
21553 !! test
21554 Parents of subpages, one level up
21555 !! options
21556 subpage title=[[Subpage test/L1/L2/L3]]
21557 !! wikitext
21558 [[../|L2]]
21559 !! html
21560 <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>
21561 </p>
21562 !! end
21563
21564
21565 !! test
21566 Parents of subpages, one level up, not named
21567 !! options
21568 subpage title=[[Subpage test/L1/L2/L3]]
21569 !! wikitext
21570 [[../]]
21571 !! html
21572 <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>
21573 </p>
21574 !! end
21575
21576
21577
21578 !! test
21579 Parents of subpages, two levels up
21580 !! options
21581 subpage title=[[Subpage test/L1/L2/L3]]
21582 !! wikitext
21583 [[../../|L1]]2
21584
21585 [[../../|L1]]l
21586 !! html
21587 <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
21588 </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>
21589 </p>
21590 !! end
21591
21592 !! test
21593 Parents of subpages, two levels up, without trailing slash or name.
21594 !! options
21595 subpage title=[[Subpage test/L1/L2/L3]]
21596 !! wikitext
21597 [[../..]]
21598 !! html
21599 <p>[[../..]]
21600 </p>
21601 !! end
21602
21603 !! test
21604 Parents of subpages, two levels up, with lots of extra trailing slashes.
21605 !! options
21606 subpage title=[[Subpage test/L1/L2/L3]]
21607 !! wikitext
21608 [[../../////]]
21609 !! html
21610 <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>
21611 </p>
21612 !! end
21613
21614 !! article
21615 Subpage test/L1/L2/L3Sibling
21616 !! text
21617 Sibling article
21618 !! endarticle
21619
21620 !! test
21621 Transclusion of a sibling page (one level up)
21622 !! options
21623 subpage title=[[Subpage test/L1/L2/L3]]
21624 !! wikitext
21625 {{../L3Sibling}}
21626 !! html
21627 <p>Sibling article
21628 </p>
21629 !! end
21630
21631 !! test
21632 Transclusion of a child page
21633 !! options
21634 subpage title=[[Subpage test/L1/L2]]
21635 !! wikitext
21636 {{/L3Sibling}}
21637 !! html
21638 <p>Sibling article
21639 </p>
21640 !! end
21641
21642 # This is wt2html only in Parsoid because we add <nowiki>
21643 # because of {{..}} and we don't expect to fix that to
21644 # eliminate the nowikis selective for {{..}} markup.
21645 !! test
21646 Non-transclusion because of too many up levels
21647 !! options
21648 subpage title=[[Subpage test/L1/L2/L3]]
21649 parsoid=wt2html
21650 !! wikitext
21651 {{../../../../More than parent}}
21652 !! html/php
21653 <p>{{../../../../More than parent}}
21654 </p>
21655 !! html/parsoid
21656 <p>{{../../../../More than parent}}</p>
21657 !! end
21658
21659 !! test
21660 Definition list code coverage
21661 !! wikitext
21662 ;title :def
21663 ;title :def
21664 ;title:def
21665 !! html/php
21666 <dl><dt>title &#160;</dt>
21667 <dd>def</dd>
21668 <dt>title&#160;</dt>
21669 <dd>def</dd>
21670 <dt>title</dt>
21671 <dd>def</dd></dl>
21672
21673 !! html/parsoid
21674 <dl><dt>title <span typeof="mw:Placeholder"> </span></dt><dd>def</dd>
21675 <dt>title<span typeof="mw:Placeholder"> </span></dt><dd>def</dd>
21676 <dt>title</dt><dd>def</dd></dl>
21677 !! end
21678
21679 !! test
21680 Don't fall for the self-closing div
21681 !! wikitext
21682 <div>hello world</div/>
21683 !! html
21684 <div>hello world</div>
21685
21686 !! end
21687
21688 !! test
21689 MSGNW magic word
21690 !! wikitext
21691 {{MSGNW:msg}}
21692 !! html/php
21693 <p>&#91;&#91;:Template:Msg&#93;&#93;
21694 </p>
21695 !! end
21696
21697 !! test
21698 RAW magic word
21699 !! wikitext
21700 {{RAW:QUERTY}}
21701 !! html
21702 <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>
21703 </p>
21704 !! end
21705
21706 # This isn't needed for XHTML conformance, but would be handy as a fallback security measure
21707 !! test
21708 Always escape literal '>' in output, not just after '<'
21709 !! wikitext
21710 ><>
21711 !! html
21712 <p>&gt;&lt;&gt;
21713 </p>
21714 !! end
21715
21716 !! test
21717 Template caching
21718 !! wikitext
21719 {{Test}}
21720 {{Test}}
21721 !! html
21722 <p>This is a test template
21723 This is a test template
21724 </p>
21725 !! end
21726
21727
21728 !! article
21729 MediaWiki:Fake
21730 !! text
21731 ==header==
21732 !! endarticle
21733
21734 !! test
21735 Inclusion of !userCanEdit() content
21736 !! wikitext
21737 {{MediaWiki:Fake}}
21738 !! html
21739 <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>
21740
21741 !! end
21742
21743
21744 !! test
21745 Out-of-order TOC heading levels
21746 !! wikitext
21747 ==2==
21748 ======6======
21749 ===3===
21750 =1=
21751 =====5=====
21752 ==2==
21753 !! html
21754 <div id="toc" class="toc"><input type="checkbox" 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>
21755 <ul>
21756 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
21757 <ul>
21758 <li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
21759 <li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
21760 </ul>
21761 </li>
21762 <li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
21763 <ul>
21764 <li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
21765 <li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
21766 </ul>
21767 </li>
21768 </ul>
21769 </div>
21770
21771 <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>
21772 <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>
21773 <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>
21774 <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>
21775 <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>
21776 <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>
21777
21778 !! end
21779
21780
21781 !! test
21782 ISBN with a dummy number
21783 !! wikitext
21784 ISBN ---
21785 !! html
21786 <p>ISBN ---
21787 </p>
21788 !! end
21789
21790
21791 !! test
21792 ISBN with space-delimited number
21793 !! wikitext
21794 ISBN 92 9017 032 8
21795 !! html/php
21796 <p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a>
21797 </p>
21798 !! html/parsoid
21799 <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>
21800 !! end
21801
21802
21803 !! test
21804 ISBN with multiple spaces, no number
21805 !! wikitext
21806 ISBN foo
21807 !! html
21808 <p>ISBN foo
21809 </p>
21810 !! end
21811
21812
21813 !! test
21814 ISBN length
21815 !! wikitext
21816 ISBN 123456789
21817
21818 ISBN 1234567890
21819
21820 ISBN 12345678901
21821 !! html/php
21822 <p>ISBN 123456789
21823 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21824 </p><p>ISBN 12345678901
21825 </p>
21826 !! html/parsoid
21827 <p>ISBN 123456789</p>
21828
21829 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
21830
21831 <p>ISBN 12345678901</p>
21832 !! end
21833
21834
21835 !! test
21836 ISBN with trailing year (T9110)
21837 !! wikitext
21838 ISBN 1-234-56789-0 - 2006
21839
21840 ISBN 1 234 56789 0 - 2006
21841 !! html/php
21842 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006
21843 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006
21844 </p>
21845 !! html/parsoid
21846 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p>
21847
21848 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p>
21849 !! end
21850
21851
21852 !! test
21853 anchorencode
21854 !! config
21855 wgFragmentMode=[ 'html5', 'legacy' ]
21856 !! wikitext
21857 {{anchorencode:foo bar©#%n}}
21858 !! html/php
21859 <p>foo_bar©#%n
21860 </p>
21861 !! html/parsoid
21862 <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>
21863 !! end
21864
21865 !! test
21866 anchorencode (legacy)
21867 !! config
21868 wgFragmentMode=[ 'legacy' ]
21869 !! wikitext
21870 {{anchorencode:foo bar©#%n}}
21871 !! html/php
21872 <p>foo_bar.C2.A9.23.25n
21873 </p>
21874 !! end
21875
21876 !! test
21877 anchorencode trims spaces
21878 !! config
21879 wgFragmentMode=[ 'html5', 'legacy' ]
21880 !! wikitext
21881 {{anchorencode: __pretty__please__}}
21882 !! html/php
21883 <p>pretty_please
21884 </p>
21885 !! html/parsoid
21886 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: __pretty__please__","function":"anchorencode"},"params":{},"i":0}}]}'>pretty_please</p>
21887 !! end
21888
21889 !! test
21890 anchorencode deals with links
21891 !! config
21892 wgFragmentMode=[ 'html5', 'legacy' ]
21893 !! wikitext
21894 {{anchorencode: [[hello|world]] [[hi]]}}
21895 !! html/php
21896 <p>world_hi
21897 </p>
21898 !! html/parsoid
21899 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: [[hello|world]] [[hi]]","function":"anchorencode"},"params":{},"i":0}}]}'>world_hi</p>
21900 !! end
21901
21902 !! test
21903 anchorencode deals with templates
21904 !! config
21905 wgFragmentMode=[ 'html5', 'legacy' ]
21906 !! wikitext
21907 {{anchorencode: {{Foo}} x}}
21908 !! html/php
21909 <p>FOO_x
21910 </p>
21911 !! html/parsoid
21912 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: {{Foo}} x","function":"anchorencode"},"params":{},"i":0}}]}'>FOO_x</p>
21913 !! end
21914
21915 !! test
21916 anchorencode encodes like the TOC generator: (T20431)
21917 !! config
21918 wgFragmentMode=[ 'html5', 'legacy' ]
21919 !! wikitext
21920 ===_ +:.3A%3A _ &&amp;]] x===
21921 {{anchorencode: _ +:.3A%3A _ &&amp;]] x}}
21922 __NOEDITSECTION__
21923 !! html/php
21924 <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>
21925 <p>+:.3A%3A_&amp;&amp;&#93;&#93;_x
21926 </p>
21927 !! html/parsoid
21928 <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>
21929 <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>
21930 <meta property="mw:PageProp/noeditsection"/>
21931 !! end
21932
21933 !! test
21934 anchorencode encodes like the TOC generator: (T20431) (legacy)
21935 !! config
21936 wgFragmentMode=[ 'legacy' ]
21937 !! wikitext
21938 ===_ +:.3A%3A&&amp;]]===
21939 {{anchorencode: _ +:.3A%3A&&amp;]] }}
21940 __NOEDITSECTION__
21941 !! html/php
21942 <h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&amp;&amp;]]</span></h3>
21943 <p>.2B:.3A.253A.26.26.5D.5D
21944 </p>
21945 !! end
21946
21947 !! test
21948 T8200: blockquotes and paragraph formatting
21949 !! wikitext
21950 <blockquote>
21951 foo
21952 </blockquote>
21953
21954 bar
21955
21956 baz
21957 !! html
21958 <blockquote>
21959 <p>foo
21960 </p>
21961 </blockquote>
21962 <p>bar
21963 </p>
21964 <pre>baz
21965 </pre>
21966 !! end
21967
21968 !! test
21969 T10293: Use of center tag ruins paragraph formatting
21970 !! wikitext
21971 <center>
21972 foo
21973 </center>
21974
21975 bar
21976
21977 baz
21978 !! html
21979 <center>
21980 <p>foo
21981 </p>
21982 </center>
21983 <p>bar
21984 </p>
21985 <pre>baz
21986 </pre>
21987 !! end
21988
21989 !!test
21990 Parsing of overlapping (improperly nested) inline html tags
21991 !! wikitext
21992 <span><s>x</span></s>
21993 !! html/php
21994 <p><span><s>x&lt;/span&gt;</s></span>
21995 </p>
21996 !! html/parsoid
21997 <p><span><s>x</s></span>
21998 </p>
21999 !!end
22000
22001 ###
22002 ### Language variants related tests
22003 ###
22004
22005 # Parsoid does not mark self-links.
22006 # Parsoid does not convert links; PHP will do any necessary redirects.
22007
22008 !! test
22009 Self-link in language variants
22010 !! options
22011 title=[[Dunav]] language=sr
22012 !! wikitext
22013 Both [[Dunav]] and [[Дунав]] are names for this river.
22014 !! html/php
22015 <p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
22016 </p>
22017 !! html/parsoid
22018 <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>
22019 !! end
22020
22021 !! article
22022 Дуна
22023 !! text
22024 content
22025 !! endarticle
22026
22027 !! test
22028 Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
22029 !! options
22030 title=[[Duna]] language=sr
22031 !! wikitext
22032 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
22033 !! html/php
22034 <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.
22035 </p>
22036 !! html/parsoid
22037 <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>
22038 !! end
22039
22040 !! test
22041 Link to a section of a variant of this title shouldn't be parsed as self-link
22042 !! options
22043 title=[[Duna]] language=sr
22044 !! wikitext
22045 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
22046 !! html/php
22047 <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.
22048 </p>
22049 !! html/parsoid
22050 <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>
22051 !! end
22052
22053 !! test
22054 Link to pages in language variants
22055 !! options
22056 language=sr
22057 !! wikitext
22058 Main Page can be written as [[Маин Паге]]
22059 !! html/php
22060 <p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>
22061 </p>
22062 !! html/parsoid
22063 <p>Main Page can be written as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a></p>
22064 !! end
22065
22066
22067 !! test
22068 Multiple links to pages in language variants
22069 !! options
22070 language=sr
22071 !! wikitext
22072 [[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
22073 !! html/php
22074 <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>.
22075 </p>
22076 !! html/parsoid
22077 <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>
22078 !! end
22079
22080
22081 !! test
22082 Simple template in language variants
22083 !! options
22084 language=sr
22085 !! wikitext
22086 {{тест}}
22087 !! html/php
22088 <p>This is a test template
22089 </p>
22090 !! end
22091
22092
22093 !! test
22094 Template with explicit namespace in language variants
22095 !! options
22096 language=sr
22097 !! wikitext
22098 {{Template:тест}}
22099 !! html/php
22100 <p>This is a test template
22101 </p>
22102 !! end
22103
22104
22105 !! test
22106 Basic test for template parameter in language variants
22107 !! options
22108 language=sr
22109 !! wikitext
22110 {{парамтест|param=foo}}
22111 !! html/php
22112 <p>This is a test template with parameter foo
22113 </p>
22114 !! end
22115
22116 !! test
22117 Simple category in language variants
22118 !! options
22119 language=sr cat
22120 !! wikitext
22121 [[Category:МедиаWики Усер'с Гуиде]]
22122 !! html/php
22123 cat=МедиаWики_Усер'с_Гуиде sort=
22124 !! html/parsoid
22125 <link rel="mw:PageProp/Category" href="./Категорија:МедиаWики_Усер'с_Гуиде" data-parsoid='{"stx":"simple","a":{"href":"./Категорија:МедиаWики_Усер&#39;с_Гуиде"},"sa":{"href":"Category:МедиаWики Усер&#39;с Гуиде"}}'/>
22126 !! end
22127
22128 !! article
22129 Category:分类
22130 !! text
22131 blah
22132 !! endarticle
22133
22134 !! article
22135 Category:分類
22136 !! text
22137 blah
22138 !! endarticle
22139
22140 ## We used to, but no longer wt2wt this test since the default serializer
22141 ## will normalize all categories to serialize on their own line.
22142 ## This wikitext usage is going to be fairly uncommon in production and
22143 ## selser will take care of preserving formatting in those scenarios.
22144 !! test
22145 Don't convert blue categorylinks to another variant (T35210)
22146 !! options
22147 cat
22148 language=zh
22149 parsoid=wt2html
22150 !! wikitext
22151 [[A]][[Category:分类]]
22152 !! html/php
22153 cat=分类 sort=
22154 !! html/parsoid
22155 <p><a rel="mw:WikiLink" href="./A" title="A">A</a></p>
22156 <link rel="mw:PageProp/Category" href="./Category:分类"/>
22157 !! end
22158
22159 !! test
22160 Stripping -{}- tags (language variants)
22161 !! options
22162 language=sr
22163 !! wikitext
22164 Latin proverb: -{Ne nuntium necare}-
22165 !! html/php
22166 <p>Latin proverb: Ne nuntium necare
22167 </p>
22168 !! html/parsoid
22169 <p>Latin proverb: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22170 !! end
22171
22172
22173 !! test
22174 Prevent conversion with -{}- tags (language variants)
22175 !! options
22176 language=sr variant=sr-ec
22177 !! wikitext
22178 Latinski: -{Ne nuntium necare}-
22179 !! html/php
22180 <p>Латински: Ne nuntium necare
22181 </p>
22182 !! html/parsoid
22183 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22184 !! end
22185
22186
22187 !! test
22188 Prevent conversion of text with -{}- tags (language variants)
22189 !! options
22190 language=sr variant=sr-ec
22191 !! wikitext
22192 Latinski: -{Ne nuntium necare}-
22193 !! html/php
22194 <p>Латински: Ne nuntium necare
22195 </p>
22196 !! html/parsoid
22197 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22198 !! end
22199
22200
22201 !! test
22202 Prevent conversion of links with -{}- tags (language variants)
22203 !! options
22204 language=sr variant=sr-ec
22205 !! wikitext
22206 -{[[Main Page]]}-
22207 !! html/php
22208 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
22209 </p>
22210 !! html/parsoid
22211 <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>
22212 !! end
22213
22214
22215 !! test
22216 -{}- tags within headlines (within html for parserConvert())
22217 !! config
22218 wgFragmentMode=[ 'html5', 'legacy' ]
22219 !! options
22220 language=sr variant=sr-ec
22221 !! wikitext
22222 ==-{Naslov}-==
22223
22224 Note that even an unprotected headline ID is not affected by language
22225 conversion:
22226
22227 ==Latinski==
22228 !! html/php
22229 <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>
22230 <p>Ноте тхат евен ан унпротецтед хеадлине ИД ис нот аффецтед бy лангуаге
22231 цонверсион:
22232 </p>
22233 <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>
22234
22235 !! html/parsoid
22236 <h2 id="-{Naslov}-"><span id="-.7BNaslov.7D-" typeof="mw:FallbackId"></span><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Naslov"}}'></span></h2>
22237
22238 <p>Note that even an unprotected headline ID is not affected by language
22239 conversion:</p>
22240
22241 <h2 id="Latinski">Latinski</h2>
22242 !! end
22243
22244 !! test
22245 Explicit definition of language variant alternatives
22246 !! options
22247 language=zh variant=zh-tw
22248 !! wikitext
22249 -{zh:China;zh-tw:Taiwan}-, not China
22250 !! html/php
22251 <p>Taiwan, not China
22252 </p>
22253 !! html/parsoid
22254 <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>
22255 !! end
22256
22257 !! test
22258 Filter syntax for language variants
22259 !! options
22260 language=zh variant=zh-tw
22261 !! wikitext
22262 foo-{zh;zh-hans;zh-hant|blog, WEBJOURNAL, WEBLOG}-quux
22263 !! html/php
22264 <p>fooblog, WEBJOURNAL, WEBLOGquux
22265 </p>
22266 !! html/parsoid
22267 <p>foo<span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"blog, WEBJOURNAL, WEBLOG"}}'></span>quux</p>
22268 !! end
22269
22270 # Note that Parsoid post-processing for language variants needs to
22271 # update the `title` attribute here, based on the mw:ExpandedAttrs property
22272 !! test
22273 Conversion around HTML tags
22274 !! options
22275 language=sr variant=sr-ec
22276 !! wikitext
22277 -{H|span=>sr-ec:script;title=>sr-ec:src}-
22278 <span title="La-{sr-el:L;sr-ec:C}-tin">ski</span>
22279 !! html/php
22280 <p>
22281 <span title="ЛаCтин">ски</span>
22282 </p>
22283 !! html/parsoid
22284 <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"}]}'/>
22285 <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>
22286 !! end
22287
22288 !! test
22289 Explicit session-wise two-way language variant mapping (A flag and - flag)
22290 !! options
22291 language=zh variant=zh-tw
22292 !! wikitext
22293 This is -{zh:China; zh-tw:Taiwan}-, but we'll forget that now.
22294
22295 Taiwan is not China.
22296
22297 But -{A|zh:China; zh-tw:Taiwan}- is China,
22298
22299 (This-{-|zh:China; zh-tw:Taiwan}- should be stripped!)
22300
22301 and -{China}- is China.
22302 !! html/php
22303 <p>This is Taiwan, but we'll forget that now.
22304 </p><p>Taiwan is not China.
22305 </p><p>But Taiwan is Taiwan,
22306 </p><p>(This should be stripped!)
22307 </p><p>and China is China.
22308 </p>
22309 !! html/parsoid
22310 <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>
22311 <p>Taiwan is not China.</p>
22312 <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>
22313 <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>
22314 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"China"}}'></span> is China.</p>
22315 !! end
22316
22317 !! test
22318 Explicit session-wise one-way language variant mapping (A flag and - flag)
22319 !! options
22320 language=zh variant=zh-tw
22321 !! wikitext
22322 This is -{COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}-, but we'll forget that now.
22323
22324 COUNTRY is China or Taiwan.
22325
22326 But -{A|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- is COUNTRY,
22327
22328 (This-{-|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
22329
22330 and -{COUNTRY}- is COUNTRY.
22331 !! html/php
22332 <p>This is Taiwan, but we'll forget that now.
22333 </p><p>COUNTRY is China or Taiwan.
22334 </p><p>But Taiwan is Taiwan,
22335 </p><p>(This should be stripped!)
22336 </p><p>and COUNTRY is COUNTRY.
22337 </p>
22338 !! html/parsoid
22339 <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>
22340 <p>COUNTRY is China or Taiwan.</p>
22341 <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>
22342 <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>
22343 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"COUNTRY"}}'></span> is COUNTRY.</p>
22344 !! end
22345
22346 !! test
22347 Explicit session-wise two-way language variant mapping (H flag for hide)
22348 !! options
22349 language=zh variant=zh-tw
22350 !! wikitext
22351 (This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
22352
22353 Taiwan is China.
22354 !! html/php
22355 <p>(This should be stripped!)
22356 </p><p>Taiwan is Taiwan.
22357 </p>
22358 !! html/parsoid
22359 <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>
22360 <p>Taiwan is China.</p>
22361 !! end
22362
22363 !! test
22364 Explicit session-wise one-way language variant mapping (H flag for hide)
22365 !! options
22366 language=zh variant=zh-tw
22367 !! wikitext
22368 (This-{H|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
22369
22370 COUNTRY is Taiwan or China.
22371 !! html/php
22372 <p>(This should be stripped!)
22373 </p><p>Taiwan is Taiwan or China.
22374 </p>
22375 !! html/parsoid
22376 <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>
22377 <p>COUNTRY is Taiwan or China.</p>
22378 !! end
22379
22380 ## Note that parsoid test runner does not support 'showtitle' option.
22381 !! test
22382 Adding explicit conversion rule for title (T flag)
22383 !! options
22384 language=zh variant=zh-tw showtitle
22385 !! wikitext
22386 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
22387
22388 Taiwan is China.
22389 !! html/php
22390 Taiwan
22391 <p>Should be stripped!
22392 </p><p>Taiwan is China.
22393 </p>
22394 !! html/parsoid
22395 <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>
22396 <p>Taiwan is China.</p>
22397 !! end
22398
22399 !! test
22400 Code coverage: T combined with H flag
22401 !! options
22402 language=zh variant=zh-tw showtitle
22403 !! wikitext
22404 Should be stripped-{T;H|zh:China; zh-tw:Taiwan}-!
22405
22406 Taiwan is China.
22407 !! html/php
22408 Taiwan
22409 <p>Should be stripped!
22410 </p><p>Taiwan is Taiwan.
22411 </p>
22412 !! html/parsoid
22413 <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>
22414 <p>Taiwan is China.</p>
22415 !! end
22416
22417 !! test
22418 Code coverage: T with no variants
22419 !! options
22420 language=zh variant=zh-tw showtitle
22421 !! wikitext
22422 -{H|zh:China; zh-tw:Taiwan}-
22423 Taiwan is China.-{T|Taiwan is China}-
22424 !! html/php
22425 Taiwan is China
22426 <p>
22427 Taiwan is Taiwan.
22428 </p>
22429 !! html/parsoid
22430 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
22431 Taiwan is China.<meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Taiwan is China"},"title":true}'/></p>
22432 !! end
22433
22434 !! test
22435 Code coverage: rules with no variants
22436 !! options
22437 language=zh variant=zh-tw
22438 !! wikitext
22439 -{H|zh:China; zh-tw:Taiwan}-
22440 Taiwan is China.
22441 -{H|China}-
22442 Taiwan is China.
22443 !! html/php
22444 <p>
22445 Taiwan is Taiwan.
22446
22447 Taiwan is China.
22448 </p>
22449 !! html/parsoid
22450 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
22451 Taiwan is China.
22452 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":"China"}]}'/>
22453 Taiwan is China.</p>
22454 !! end
22455
22456
22457 !! test
22458 Code coverage: D flag for conversion rule
22459 !! options
22460 language=zh variant=zh-tw
22461 !! wikitext
22462 -{D|zh-cn:XA; zh-tw:YA}-
22463 -{A;D|zh-cn:XB; zh-tw:YB}-
22464 -{D;H|zh-cn:XC; zh-tw:YC}-
22465
22466 -{D;H|FOO=>zh-tw:BAR;FOO=>zh-cn:BAT}-
22467
22468 -{D|0=>zh-tw:1}-
22469 -{A;D|2=>zh-tw:3}-
22470 -{D;H|4=>zh-tw:5}-
22471
22472 XA XB XC YA YB YC FOO BAR BAT 012345
22473 !! html/php
22474 <p>大陆:XA;台灣:YA;
22475
22476 大陆:XC;台灣:YC;
22477 </p><p>FOO⇒台灣:BAR;FOO⇒大陆:BAT;
22478 </p><p>0⇒台灣:1;
22479
22480 4⇒台灣:5;
22481 </p><p>XA YB YC YA YB YC BAR BAR BAT 013355
22482 </p>
22483 !! html/parsoid
22484 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"twoway":[{"l":"zh-cn","t":"XA"},{"l":"zh-tw","t":"YA"}]}'></span>
22485 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XB"},{"l":"zh-tw","t":"YB"}]}'/>
22486 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XC"},{"l":"zh-tw","t":"YC"}]}'></span></p>
22487 <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>
22488 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"oneway":[{"f":"0","l":"zh-tw","t":"1"}]}'></span>
22489 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"2","l":"zh-tw","t":"3"}]}'/>
22490 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"4","l":"zh-tw","t":"5"}]}'></span></p>
22491 <p>XA XB XC YA YB YC FOO BAR BAT 012345</p>
22492 !! end
22493
22494 !! test
22495 Code coverage: N flag for conversion rule
22496 !! options
22497 language=zh variant=zh-cn
22498 !! wikitext
22499 -{N|zh-cn}-
22500
22501 -{N|zh-tw}-
22502
22503 -{N|sr-ec}-
22504 !! html/php
22505 <p>大陆
22506 </p><p>台灣
22507 </p><p>српски (ћирилица)‎
22508 </p>
22509 !! html/parsoid
22510 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-cn"}}'></span></p>
22511 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-tw"}}'></span></p>
22512 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"sr-ec"}}'></span></p>
22513 !! end
22514
22515 # html2wt suppresses the bogus 'D' flag, so this is wt2html only
22516 !! test
22517 Code coverage: N flag for conversion rule (wt2html only)
22518 !! options
22519 language=zh variant=zh-cn
22520 parsoid=wt2html,html2html
22521 !! wikitext
22522 -{D;N|en}-
22523 !! html/php
22524 <p>English
22525 </p>
22526 !! html/parsoid
22527 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"en"}}' data-parsoid='{"fl":["D","N"]}'></span></p>
22528 !! end
22529
22530 !! test
22531 Testing that changing the language variant here in the tests actually works
22532 !! options
22533 language=zh variant=zh showtitle
22534 !! wikitext
22535 Should be stripped-{T|zh:China; zh-tw:Taiwan}-!
22536 !! html/php
22537 China
22538 <p>Should be stripped!
22539 </p>
22540 !! html/parsoid
22541 <p>Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
22542 !! end
22543
22544 !! test
22545 Recursive conversion of alt and title attrs shouldn't clear converter state
22546 !! options
22547 language=zh variant=zh-cn
22548 showtitle
22549 !! wikitext
22550 -{H|zh-cn:Exclamation; zh-tw:exclamation}-
22551 Should be stripped-{T|zh-cn:China; zh-tw:Taiwan}-<span title="exclamation">!</span>
22552 !! html/php
22553 China
22554 <p>
22555 Should be stripped<span title="Exclamation">!</span>
22556 </p>
22557 !! html/parsoid
22558 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh-cn","t":"Exclamation"},{"l":"zh-tw","t":"exclamation"}]}'/>
22559 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>
22560 !! end
22561
22562 !! test
22563 T26072: more test on conversion rule for title
22564 !! options
22565 language=zh variant=zh-tw showtitle
22566 !! wikitext
22567 This should be stripped-{T|zh:China; zh-tw:Taiwan}-!
22568
22569 This won't take interferes with the title rule-{H|zh:Beijing; zh-tw:Taipei}-.
22570 !! html/php
22571 Taiwan
22572 <p>This should be stripped!
22573 </p><p>This won't take interferes with the title rule.
22574 </p>
22575 !! html/parsoid
22576 <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>
22577 <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>
22578 !! end
22579
22580 !! test
22581 Partly disable title conversion if variant == main language code
22582 !! options
22583 language=zh variant=zh title=[[ZH]] showtitle
22584 !! wikitext
22585 -{T|zh-cn:CN;zh-tw:TW}-
22586 !! html/php
22587 ZH
22588 <p>
22589 </p>
22590 !! html/parsoid
22591 <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>
22592 !! end
22593
22594 !! test
22595 Partly disable title conversion if variant == main language code, more
22596 !! options
22597 language=zh variant=zh title=[[ZH]] showtitle
22598 !! wikitext
22599 -{T|TW}-
22600 !! html/php
22601 ZH
22602 <p>
22603 </p>
22604 !! html/parsoid
22605 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"TW"},"title":true}'/></p>
22606 !! end
22607
22608 !! test
22609 Raw output of variant escape tags (R flag)
22610 !! options
22611 language=zh variant=zh-tw
22612 !! wikitext
22613 Raw: -{R|zh:China;zh-tw:Taiwan}-
22614 !! html/php
22615 <p>Raw: zh:China;zh-tw:Taiwan
22616 </p>
22617 !! html/parsoid
22618 <p>Raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"zh:China;zh-tw:Taiwan"}}'></span></p>
22619 !! end
22620
22621 # html2wt suppresses the bogus 'D' flags, so this is wt2html only
22622 !! test
22623 Raw output of variant escape tags (R flag) (wt2html only)
22624 !! options
22625 language=zh variant=zh-tw
22626 parsoid=wt2html,html2html
22627 !! wikitext
22628 -{Variant}- -{D|syntax}- -{D;R|options}-
22629 !! html/php
22630 <p>Variant syntax options
22631 </p>
22632 !! html/parsoid
22633 <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>
22634 !! end
22635
22636 !! test
22637 Nested markup inside raw output of variant escape tags (R flag)
22638 !! options
22639 language=zh variant=zh-tw
22640 !! wikitext
22641 Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
22642 !! html/php
22643 <p>Nested raw: nested Taiwan nested
22644 </p>
22645 !! html/parsoid
22646 <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>
22647 !! end
22648
22649 !! test
22650 Nested markup and spaces inside raw output of variant escape tags (R flag)
22651 !! options
22652 language=zh variant=zh-tw
22653 !! wikitext
22654 X-{ outer -{ inner }- outer }-X
22655 !! html/php
22656 <p>X outer inner outer X
22657 </p>
22658 !! html/parsoid
22659 <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>
22660 !! end
22661
22662 !! test
22663 Templates inside raw output of variant escape tags (R flag)
22664 !! options
22665 language=zh variant=zh-tw
22666 !! wikitext
22667 Nested raw: -{R|nested {{echo|hi}} templates}-
22668 !! html/php
22669 <p>Nested raw: nested hi templates
22670 </p>
22671 !! html/parsoid
22672 <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>
22673 !! end
22674
22675 !! test
22676 Strings evaluating false shouldn't be ignored by Language converter (T51072)
22677 !! options
22678 language=zh variant=zh-cn
22679 !! wikitext
22680 -{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
22681 !! html/php
22682 <p>0
22683 </p>
22684 !! html/parsoid
22685 <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>
22686 !! end
22687
22688 !! test
22689 Conversion rules from [numeric-only string] to [something else] (T48634)
22690 !! options
22691 language=zh variant=zh-cn
22692 !! wikitext
22693 -{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
22694 !! html/php
22695 <p>D12345EE12345
22696 </p>
22697 !! html/parsoid
22698 <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>
22699 !! end
22700
22701 !! test
22702 Two-way converter rule entries with an empty value should be ignored (T53551)
22703 !! options
22704 language=zh variant=zh-cn
22705 !! wikitext
22706 -{H|zh-cn:foo;zh-tw:;}-foobar
22707 !! html/php
22708 <p>foobar
22709 </p>
22710 !! html/parsoid
22711 <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>
22712 !! end
22713
22714 !! test
22715 One-way converter rule entries with an empty "from" string should be ignored (T53551)
22716 !! options
22717 language=zh variant=zh-cn
22718 !! wikitext
22719 -{H|=>zh-cn:foo;}-foobar
22720 !! html/php
22721 <p>foobar
22722 </p>
22723 !! html/parsoid
22724 <p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[5]}' data-mw-variant='{"add":true,"oneway":[{"f":"","l":"zh-cn","t":"foo"}]}'/>foobar</p>
22725 !! end
22726
22727 !! test
22728 Empty converter rule entries shouldn't be inserted into the conversion table (T53551)
22729 !! options
22730 language=zh variant=zh-cn
22731 !! wikitext
22732 -{H|}-foobar
22733 !! html/php
22734 <p>foobar
22735 </p>
22736 !! html/parsoid
22737 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":""}]}'/>foobar</p>
22738 !! end
22739
22740 !! test
22741 Nested using of manual convert syntax
22742 !! options
22743 language=zh variant=zh-hk
22744 !! wikitext
22745 Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
22746 !! html/php
22747 <p>Nested: Hello Hong Kong!
22748 </p>
22749 !! html/parsoid
22750 <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>
22751 !! end
22752
22753 !! test
22754 HTML markups with conversion syntax in attribs, nested in other conversion blocks
22755 !! options
22756 language=zh variant=zh-cn
22757 !! wikitext
22758 -{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}-
22759 !! html/php
22760 <p><span title="X">A</span>
22761 </p>
22762 !! html/parsoid
22763 <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>
22764 !! end
22765
22766 !! test
22767 HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet in PHP parser)
22768 !! options
22769 language=zh variant=zh-cn
22770 !! wikitext
22771 -{<span title="-{X}-">A</span>}-
22772 !! html/php+disabled
22773 <p><span title="X">A</span>
22774 </p>
22775 !! html/parsoid
22776 <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>
22777 !! end
22778
22779 # Parsoid and PHP disagree on how to parse this example: Parsoid
22780 # insists that the content of a language converter element be a valid
22781 # DOM fragment or attribute string
22782 !! test
22783 Language converter markup with block content
22784 !! options
22785 language=zh variant=zh-cn
22786 !! wikitext
22787 <span>a-{b<div>c}-d
22788
22789 <span>a-{zh;zh-hans;zh-hant|b<div>c}-d
22790
22791 <span>a-{H|0=>zh-cn:x<span>y;0=>zh-tw:b<div>c}-d
22792 !! html/php+tidy
22793 <span>ab<div>cd
22794 <span>ab<div>cd
22795 <span>ad
22796 </span></div></span></div></span>
22797 !! html/parsoid
22798 <p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</span></p><div typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"b&lt;div data-parsoid=&#39;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[10,16,5,0]}&#39;>c&lt;/div>"}}'></div><p>d</p>
22799
22800 <p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</span></p><div typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"b&lt;div data-parsoid=&#39;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[50,56,5,0]}&#39;>c&lt;/div>"}}'></div><p>d</p>
22801
22802 <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=&#39;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[82,89,6,0]}&#39;>y&lt;/span>"},{"f":"0","l":"zh-tw","t":"b&lt;div data-parsoid=&#39;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[100,106,5,0]}&#39;>c&lt;/div>"}]}'/>d</span></p>
22803 !! end
22804
22805 !! test
22806 LanguageConverter selser (1)
22807 !! options
22808 language=zh variant=zh-cn
22809 parsoid={
22810 "modes": ["wt2wt", "selser"],
22811 "changes": [
22812 ["span[typeof]", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
22813 ]
22814 }
22815 !! wikitext
22816 -{raw}-
22817 !! wikitext/edited
22818 -{edited}-
22819 !! end
22820
22821 !! test
22822 LanguageConverter selser (2)
22823 !! options
22824 language=zh variant=zh-cn
22825 parsoid={
22826 "modes": ["wt2wt", "selser"],
22827 "changes": [
22828 ["span[class='x']", "contents", "text", "-{foo}-"],
22829 ["a", "contents", "text", "-{"],
22830 ["span[typeof]", "attr", "data-mw", "{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"-{\"}},\"i\":0}}]}"]
22831 ]
22832 }
22833 !! wikitext
22834 <span class="x">TEXT1</span>
22835 [http://example.com TEXT2]
22836 [[Foo|TEXT3]]
22837 {{echo|TEXT4}}
22838 !! wikitext/edited
22839 <span class="x"><nowiki>-{foo}-</nowiki></span>
22840 [http://example.com -{]
22841 [[Foo|<nowiki>-{</nowiki>]]
22842 {{1x|<nowiki>-{</nowiki>}}
22843 !! end
22844
22845 # Tests LanguageVariantText in ConstrainedText
22846 !! test
22847 LanguageConverter selser (3)
22848 !! options
22849 language=zh variant=zh-cn
22850 parsoid={
22851 "modes": ["wt2wt", "selser"],
22852 "changes": [
22853 ["td > span", "attr", "typeof", "mw:LanguageVariant"],
22854 ["td > span", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
22855 ]
22856 }
22857 !! wikitext
22858 {|
22859 |-
22860 |<span>Foo</span>
22861 |}
22862 !! wikitext/edited
22863 {|
22864 |-
22865 |<nowiki/>-{edited}-
22866 |}
22867 !! end
22868
22869 # Tests LanguageVariantText._fromSelSer
22870 !! test
22871 LanguageConverter selser (4)
22872 !! options
22873 language=zh variant=zh-cn
22874 parsoid={
22875 "modes": ["wt2wt", "selser"],
22876 "changes": [
22877 ["td > span.x", "remove"]
22878 ]
22879 }
22880 !! wikitext
22881 {|
22882 |-
22883 |<span class="x">Foo</span>-{Bar}-
22884 ||<span class="x">Foo</span>-{Bar}-
22885 |}
22886 !! wikitext/edited
22887 {|
22888 |-
22889 |<nowiki/>-{Bar}-
22890 ||-{Bar}-
22891 |}
22892 !! end
22893
22894 # Since Parsoid is starting to emit canonical wikitext for links,
22895 # [http://example.com http://example.com] will not RT back to that
22896 # form anymore.
22897 # Parsoid does not language-convert links (it is done in a
22898 # post-processing step)
22899 !! test
22900 Proper conversion of text in external links
22901 !! options
22902 language=sr variant=sr-ec
22903 parsoid=wt2html
22904 !! wikitext
22905 http://www.google.com
22906 gopher://www.google.com
22907 [http://www.google.com http://www.google.com]
22908 [gopher://www.google.com gopher://www.google.com]
22909 [https://www.google.com irc://www.google.com]
22910 [ftp://www.google.com www.google.com/ftp://dir]
22911 [//www.google.com www.google.com]
22912 !! html/php
22913 <p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
22914 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
22915 <a rel="nofollow" class="external text" href="http://www.google.com">http://www.google.com</a>
22916 <a rel="nofollow" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
22917 <a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
22918 <a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
22919 <a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
22920 </p>
22921 !! html/parsoid
22922 <p><a rel="mw:ExtLink" class="external free" href="http://www.google.com">http://www.google.com</a>
22923 <a rel="mw:ExtLink" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
22924 <a rel="mw:ExtLink" class="external text" href="http://www.google.com">http://www.google.com</a>
22925 <a rel="mw:ExtLink" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
22926 <a rel="mw:ExtLink" class="external text" href="https://www.google.com">irc://www.google.com</a>
22927 <a rel="mw:ExtLink" class="external text" href="ftp://www.google.com">www.google.com/ftp://dir</a>
22928 <a rel="mw:ExtLink" class="external text" href="//www.google.com">www.google.com</a></p>
22929 !! end
22930
22931 !! test
22932 Do not convert roman numbers to language variants
22933 !! options
22934 language=sr variant=sr-ec
22935 !! wikitext
22936 Fridrih IV je car.
22937 !! html/php
22938 <p>Фридрих IV је цар.
22939 </p>
22940 !! html/parsoid
22941 <p>Fridrih IV je car.</p>
22942 !! end
22943
22944 !! test
22945 Unclosed language converter markup "-{"
22946 !! options
22947 language=sr
22948 !! wikitext
22949 -{T|hello
22950 !! html
22951 <p>-{T|hello
22952 </p>
22953 !! end
22954
22955 !! test
22956 Don't convert raw rule "-{R|=&gt;}-" to "=>"
22957 !! options
22958 language=sr
22959 !! wikitext
22960 -{R|=&gt;}-
22961 !! html/php
22962 <p>=&gt;
22963 </p>
22964 !! html/parsoid
22965 <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>
22966 !!end
22967
22968 !! test
22969 Don't break link parsing if language converter markup is in the caption.
22970 !! options
22971 language=sr variant=sr-ec
22972 !! wikitext
22973 [[Main Page|-{R|main page}-]]
22974 !! html/php
22975 <p><a href="/wiki/Main_Page" title="Маин Паге">main page</a>
22976 </p>
22977 !! html/parsoid
22978 <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>
22979 !! end
22980
22981 !! test
22982 T146304: Don't break template parsing if language converter markup is in the parameter.
22983 !! options
22984 language=sr variant=sr-ec
22985 !! wikitext
22986 {{echo|-{R|foo}-}}
22987 !! html/php
22988 <p>foo
22989 </p>
22990 !! html/parsoid
22991 <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>
22992 !! end
22993
22994 !! test
22995 T146305: Don't break image parsing if language converter markup is in the caption.
22996 !! options
22997 language=sr
22998 !! wikitext
22999 [[Датотека:Foobar.jpg|thumb|-{R|caption:}-]]
23000 !! html/php
23001 <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>
23002
23003 !! html/parsoid
23004 <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>
23005 !! end
23006
23007 !! test
23008 T146305: Don't break image parsing if nested language converter markup is in the caption.
23009 !! options
23010 language=zh variant=zh-cn
23011 !! wikitext
23012 [[File:Foobar.jpg|thumb|-{|zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
23013 !! html/php
23014 <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>
23015
23016 !! html/parsoid
23017 <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>
23018 !! end
23019
23020 # XXX html2wt disabled because rich markup in alt is not preserved.
23021 !! test
23022 Don't break gallery if language converter markup is inside.
23023 !! options
23024 language=zh
23025 !! wikitext
23026 <gallery>
23027 File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-
23028 File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt
23029 </gallery>
23030 !! html/php
23031 <ul class="gallery mw-gallery-traditional">
23032 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
23033 <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>
23034 <div class="gallerytext">
23035 <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>
23036 </p>
23037 </div>
23038 </div></li>
23039 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
23040 <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>
23041 <div class="gallerytext">
23042 <p>This is a test template
23043 </p>
23044 </div>
23045 </div></li>
23046 </ul>
23047
23048 !! html/parsoid
23049 <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"}}'>
23050 <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>
23051 <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>
23052 </ul>
23053 !! end
23054
23055 !! test
23056 T153135: Don't break list handling if language converter markup is in the item.
23057 !! options
23058 language=zh variant=zh-cn
23059 !! wikitext
23060 ;-{zh-cn:AAA;zh-tw:BBB}-
23061 ;-{R|foo:bar}-
23062 !! html/php
23063 <dl><dt>AAA</dt>
23064 <dt>foo:bar</dt></dl>
23065
23066 !! html/parsoid
23067 <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>
23068 <dt data-parsoid='{"dsr":[25,39,1,0]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"foo:bar"}}'></span></dt>
23069 </dl>
23070 !! end
23071
23072 // Note that parsoid does not protect colons unless language converter
23073 // markup is properly nested, because it is a backtracking parser.
23074 !! test
23075 T153135: Unclosed markup in definition list (code coverage)
23076 !! options
23077 language=zh variant=zh-cn
23078 !! wikitext
23079 ;<b>foo:bar
23080 ;-{zh-cn:AAA
23081 !! html/php+tidy
23082 <dl><dt><b>foo:bar</b></dt><b>
23083 <dt>-{zh-cn:AAA</dt></b></dl><p><b>
23084 </b></p>
23085 !! html/parsoid
23086 <dl><dt data-parsoid='{"dsr":[0,11,1,0]}'><b data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo:bar</b></dt><b data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
23087 <dt data-parsoid='{"dsr":[12,20,1,0]}'>-{zh-cn</dt>
23088 <dd data-parsoid='{"stx":"row","dsr":[20,24,1,0]}'>AAA</dd>
23089 </b></dl>
23090 !! end
23091
23092 !! test
23093 T153135: Nested language converter markup in definition list (code coverage)
23094 !! options
23095 language=zh variant=zh-cn
23096 !! wikitext
23097 ;-{|zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
23098 !! html/php
23099 <dl><dt>AAA foo:bar bat:baz</dt>
23100 <dd>def</dd></dl>
23101
23102 !! html/parsoid
23103 <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>
23104 <dd data-parsoid='{"stx":"row","dsr":[49,53,1,0]}'>def</dd>
23105 </dl>
23106 !! end
23107
23108 # html2wt mode disabled due to <nowiki> insertion.
23109 !! test
23110 T153140: Don't break table handling if language converter markup is in the cell.
23111 !! options
23112 language=sr variant=sr-ec
23113 parsoid=wt2html,wt2wt,html2html
23114 !! wikitext
23115 {|
23116 |-
23117 | -{R|B}-
23118 |}
23119 !! html/php
23120 <table>
23121
23122 <tr>
23123 <td>B
23124 </td></tr></table>
23125
23126 !! html/parsoid
23127 <table>
23128 <tbody>
23129 <tr>
23130 <td><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"B"}}'></span></td>
23131 </tr>
23132 </tbody>
23133 </table>
23134 !! end
23135
23136 !! test
23137 Language converter tricky html2wt cases (1)
23138 !! options
23139 language=sr
23140 parsoid=html2wt,wt2wt
23141 !! html/parsoid
23142 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"}-"}}'></span></p>
23143 !! wikitext
23144 -{<nowiki>}-</nowiki>}-
23145 !! html/php
23146 <p>&#125;-
23147 </p>
23148 !! end
23149
23150 !! test
23151 Language converter tricky html2wt cases (2)
23152 !! options
23153 language=sr
23154 parsoid=html2wt,wt2wt
23155 !! html/parsoid
23156 <p>-{foo}-</p>
23157 !! wikitext
23158 <nowiki>-{foo}-</nowiki>
23159 !! html/php
23160 <p>-&#123;foo&#125;-
23161 </p>
23162 !! end
23163
23164 !! test
23165 Language converter tricky html2wt cases (3)
23166 !! options
23167 language=sr
23168 parsoid=html2wt,wt2wt
23169 !! html/parsoid
23170 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"|"}}'></span></p>
23171 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"R|raw"}}'></span></p>
23172 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"-{foo}-"}}'></span></p>
23173 !! wikitext
23174 -{R||}-
23175
23176 -{R|R|raw}-
23177
23178 -{<nowiki>-{foo}-</nowiki>}-
23179 !! html/php
23180 <p>|
23181 </p><p>R|raw
23182 </p><p>-&#123;foo&#125;-
23183 </p>
23184 !! end
23185
23186 !! test
23187 Language converter tricky html2wt cases (4)
23188 !! options
23189 language=sr
23190 parsoid=html2wt,wt2wt
23191 !! html/parsoid
23192 <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>
23193 !! wikitext
23194 -{R|{{echo|hey}}}-
23195 !! html/php
23196 <p>hey
23197 </p>
23198 !! end
23199
23200 # Note that the <nowiki> escaping added by parsoid for source text,
23201 # destination text, and language names only works on the PHP side
23202 # for *destination text*. (HTML entity escaping wouldn't work
23203 # any better.) This is probably a bug, at least for source texts.
23204 # (For language names PHP uses a precise regexp based on the languages
23205 # it currently knows have variants, which is fragile since this set
23206 # can grow/shrink over time.)
23207 !! test
23208 Language converter tricky html2wt cases (5)
23209 !! options
23210 language=zh variant=zh-cn
23211 !! html/parsoid
23212 <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>
23213 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"A","l":"bo:g;us","t":"B"}]}'/></p>
23214 <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>
23215 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"bo:g;us","t":"xyz"},{"l":"zh-cn","t":"abc"}]}'></span></p>
23216 <p>a:b=>c xyz</p>
23217 !! wikitext
23218 -{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
23219
23220 -{H|A=><nowiki>bo:g;us</nowiki>:B}-
23221
23222 -{A|zh-tw:xyz; zh-cn:<nowiki>0;zh-tw:bar</nowiki>}-
23223
23224 -{<nowiki>bo:g;us</nowiki>:xyz; zh-cn:abc}-
23225
23226 a:b=>c xyz
23227 !! html/php+disabled
23228 <p>foobat;xyz=&gt;zh-cn:abc
23229 </p><p>A
23230 </p><p>0;zh-tw:bar
23231 </p><p>abc
23232 </p><p>a:b=&gt;c 0;zh-tw:bar
23233 </p>
23234 !! end
23235
23236 !! test
23237 T179579: Nowiki and lc interaction
23238 !! options
23239 parsoid=wt2html
23240 language=sr
23241 !! wikitext
23242 -{</nowiki>123}-
23243
23244 -{123<nowiki>|</nowiki>456}-
23245 !! html/parsoid
23246 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&amp;lt;/nowiki>123"}}' data-parsoid='{"fl":[],"src":"-{&lt;/nowiki>123}-"}'></span></p>
23247
23248 <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>
23249 !! end
23250
23251 !! test
23252 T2529: Uncovered bullet
23253 !! wikitext
23254 *Foo {{bullet}}
23255 !! html
23256 <ul><li>Foo</li>
23257 <li>Bar</li></ul>
23258
23259 !! end
23260
23261 !! test
23262 T2529: Uncovered bullet in a deeply nested list
23263 !! wikitext
23264 *******Foo {{bullet}}
23265 !! html
23266 <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>
23267 <li>Bar</li></ul>
23268
23269 !! end
23270
23271 !! test
23272 T2529: Uncovered table already at line-start
23273 !! wikitext
23274 x
23275
23276 {{table}}
23277 y
23278 !! html
23279 <p>x
23280 </p>
23281 <table>
23282 <tr>
23283 <td>1</td>
23284 <td>2
23285 </td></tr>
23286 <tr>
23287 <td>3</td>
23288 <td>4
23289 </td></tr></table>
23290 <p>y
23291 </p>
23292 !! end
23293
23294 !! test
23295 T2529: Uncovered bullet in parser function result
23296 !! wikitext
23297 *Foo {{lc:{{bullet}} }}
23298 !! html
23299 <ul><li>Foo</li>
23300 <li>bar</li></ul>
23301
23302 !! end
23303
23304 !! test
23305 T7678: Double-parsed template argument
23306 !! wikitext
23307 {{lc:{{{1}}}|hello}}
23308 !! html
23309 <p>{{{1}}}
23310 </p>
23311 !! end
23312
23313 !! test
23314 T7678: Double-parsed template invocation
23315 !! wikitext
23316 {{lc:{{paramtest {{!}} param = hello }} }}
23317 !! html
23318 <p>{{paramtest | param = hello }}
23319 </p>
23320 !! end
23321
23322 !! test
23323 Case insensitivity of parser functions for non-ASCII characters (T10143)
23324 !! options
23325 language=cs
23326 title=[[Main Page]]
23327 !! wikitext
23328 {{PRVNÍVELKÉ:ěščř}}
23329 {{prvnívelké:ěščř}}
23330 {{PRVNÍMALÉ:ěščř}}
23331 {{prvnímalé:ěščř}}
23332 {{MALÁ:ěščř}}
23333 {{malá:ěščř}}
23334 {{VELKÁ:ěščř}}
23335 {{velká:ěščř}}
23336 !! html
23337 <p>Ěščř
23338 Ěščř
23339 ěščř
23340 ěščř
23341 ěščř
23342 ěščř
23343 ĚŠČŘ
23344 ĚŠČŘ
23345 </p>
23346 !! end
23347
23348 !! test
23349 Morwen/13: Unclosed link followed by heading
23350 !! wikitext
23351 [[link
23352 ==heading==
23353 !! html
23354 <p>[[link
23355 </p>
23356 <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>
23357
23358 !! end
23359
23360 !! test
23361 HHP2.1: Heuristics for headings in preprocessor parenthetical structures
23362 !! wikitext
23363 {{foo|
23364 =heading=
23365 !! html
23366 <p>{{foo|
23367 </p>
23368 <h1><span class="mw-headline" id="heading">heading</span></h1>
23369
23370 !! end
23371
23372 !! test
23373 HHP2.2: Heuristics for headings in preprocessor parenthetical structures
23374 !! wikitext
23375 {{foo|
23376 ==heading==
23377 !! html
23378 <p>{{foo|
23379 </p>
23380 <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>
23381
23382 !! end
23383
23384 !! test
23385 Tildes in comments
23386 !! options
23387 pst
23388 !! wikitext
23389 <!-- ~~~~ -->
23390 !! html/php
23391 <!-- ~~~~ -->
23392 !! end
23393
23394 !! test
23395 Paragraphs inside divs (no extra line breaks)
23396 !! wikitext
23397 <div>Line one
23398
23399 Line two</div>
23400 !! html
23401 <div>Line one
23402 Line two</div>
23403
23404 !! end
23405
23406 !! test
23407 Paragraphs inside divs (extra line break on open)
23408 !! wikitext
23409 <div>
23410 Line one
23411
23412 Line two</div>
23413 !! html
23414 <div>
23415 <p>Line one
23416 </p>
23417 Line two</div>
23418
23419 !! end
23420
23421 !! test
23422 Paragraphs inside divs (extra line break on close)
23423 !! wikitext
23424 <div>Line one
23425
23426 Line two
23427 </div>
23428 !! html
23429 <div>Line one
23430 <p>Line two
23431 </p>
23432 </div>
23433
23434 !! end
23435
23436 !! test
23437 Paragraphs inside divs (extra line break on open and close)
23438 !! wikitext
23439 <div>
23440 Line one
23441
23442 Line two
23443 </div>
23444 !! html
23445 <div>
23446 <p>Line one
23447 </p><p>Line two
23448 </p>
23449 </div>
23450
23451 !! end
23452
23453 # doBlockLevels screws up this output and Remex cleans up as much as it can.
23454 # Parsoid seems to do a better job here since its p-wrapper is probably smarter.
23455 !! test
23456 Nesting tags, paragraphs on lines which begin with <div>
23457 !! wikitext
23458 <div></div><strong>A
23459 B</strong>
23460 !! html/php+tidy
23461 <div></div><p><strong>A
23462 </strong></p><strong></strong><p><strong>B</strong>
23463 </p>
23464 !! html/parsoid
23465 <div></div>
23466 <p><strong>A
23467 B</strong>
23468 </p>
23469 !! end
23470
23471 # T8200: <blockquote> should behave like <div> with respect to line breaks
23472 !! test
23473 T8200: paragraphs inside blockquotes (no extra line breaks)
23474 !! wikitext
23475 <blockquote>Line one
23476
23477 Line two</blockquote>
23478 !! html
23479 <blockquote>Line one
23480 Line two</blockquote>
23481
23482 !! html+tidy
23483 <blockquote><p>Line one
23484 Line two</p></blockquote>
23485 !! end
23486
23487 !! test
23488 T8200: paragraphs inside blockquotes (extra line break on open)
23489 !! wikitext
23490 <blockquote>
23491 Line one
23492
23493 Line two</blockquote>
23494 !! html
23495 <blockquote>
23496 <p>Line one
23497 </p>
23498 Line two</blockquote>
23499
23500 !! html+tidy
23501 <blockquote>
23502 <p>Line one
23503 </p><p>
23504 Line two</p></blockquote>
23505 !! end
23506
23507 # Parsoid's output is broken on this because of Tidy-compatibility cruft
23508 !! test
23509 T8200: paragraphs inside blockquotes (extra line break on close)
23510 !! wikitext
23511 <blockquote>Line one
23512
23513 Line two
23514 </blockquote>
23515 !! html
23516 <blockquote>Line one
23517 <p>Line two
23518 </p>
23519 </blockquote>
23520
23521 !! html+tidy
23522 <blockquote><p>Line one
23523 </p><p>Line two
23524 </p>
23525 </blockquote>
23526 !! end
23527
23528 !! test
23529 T8200: paragraphs inside blockquotes (extra line break on open and close)
23530 !! wikitext
23531 <blockquote>
23532 Line one
23533
23534 Line two
23535 </blockquote>
23536 !! html
23537 <blockquote>
23538 <p>Line one
23539 </p><p>Line two
23540 </p>
23541 </blockquote>
23542
23543 !! end
23544
23545 ## This is a corner case interaction between the paragraph wrapping in the
23546 ## php parser's BlockLevelPass and Remex. `doBlockLevels` has a notion of
23547 ## some tags which close paragraphs (and thus prevent wrapping on their line),
23548 ## of which "div" is one, but do p-wrapping inside them. These are referred
23549 ## to as "never suppressing". Remex, for its part, doesn't traverse into
23550 ## "div"s to p-wrap. Hence, we only get this partial wrapping.
23551 !! test
23552 Paragraphs inside blockquotes/divs (no extra line breaks)
23553 !! wikitext
23554 <blockquote><div>Line one
23555
23556 Line two</div></blockquote>
23557 !! html
23558 <blockquote><div>Line one
23559 Line two</div></blockquote>
23560
23561 !! end
23562
23563 !! test
23564 Paragraphs inside blockquotes/divs (extra line break on open)
23565 !! wikitext
23566 <blockquote><div>
23567 Line one
23568
23569 Line two</div></blockquote>
23570 !! html
23571 <blockquote><div>
23572 <p>Line one
23573 </p>
23574 Line two</div></blockquote>
23575
23576 !! end
23577
23578 !! test
23579 Paragraphs inside blockquotes/divs (extra line break on close)
23580 !! wikitext
23581 <blockquote><div>Line one
23582
23583 Line two
23584 </div></blockquote>
23585 !! html
23586 <blockquote><div>Line one
23587 <p>Line two
23588 </p>
23589 </div></blockquote>
23590
23591 !! end
23592
23593 !! test
23594 Paragraphs inside blockquotes/divs (extra line break on open and close)
23595 !! wikitext
23596 <blockquote><div>
23597 Line one
23598
23599 Line two
23600 </div></blockquote>
23601 !! html
23602 <blockquote><div>
23603 <p>Line one
23604 </p><p>Line two
23605 </p>
23606 </div></blockquote>
23607
23608 !! end
23609
23610 !! test
23611 Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion
23612 !! options
23613 wgLinkHolderBatchSize=0
23614 !! wikitext
23615 [[meatball:1]]
23616 [[meatball:2]]
23617 [[meatball:3]]
23618 !! html
23619 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?1" class="extiw" title="meatball:1">meatball:1</a>
23620 <a href="http://www.usemod.com/cgi-bin/mb.pl?2" class="extiw" title="meatball:2">meatball:2</a>
23621 <a href="http://www.usemod.com/cgi-bin/mb.pl?3" class="extiw" title="meatball:3">meatball:3</a>
23622 </p>
23623 !! end
23624
23625 !! test
23626 Free external link invading image caption
23627 !! wikitext
23628 [[Image:Foobar.jpg|thumb|http://x|hello]]
23629 !! html/php
23630 <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>
23631
23632 !! html/parsoid
23633 <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>
23634 !! end
23635
23636 !! test
23637 T17196: localised external link numbers
23638 !! options
23639 language=fa
23640 !! wikitext
23641 [http://en.wikipedia.org/]
23642 !! html/php
23643 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/">[۱]</a>
23644 </p>
23645 !! html/parsoid
23646 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/"></a></p>
23647 !! end
23648
23649 !! test
23650 Multibyte character in padleft
23651 !! wikitext
23652 {{padleft:-Hello|7|Æ}}
23653 !! html/php
23654 <p>Æ-Hello
23655 </p>
23656 !! html/parsoid
23657 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:-Hello","function":"padleft"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Æ-Hello</p>
23658 !! end
23659
23660 !! test
23661 Multibyte character in padright
23662 !! wikitext
23663 {{padright:Hello-|7|Æ}}
23664 !! html/php
23665 <p>Hello-Æ
23666 </p>
23667 !! html/parsoid
23668 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:Hello-","function":"padright"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Hello-Æ</p>
23669 !! end
23670
23671 !!test
23672 formatdate parser function
23673 !! wikitext
23674 {{#formatdate:2009-03-24}}
23675 !! html
23676 <p><span class="mw-formatted-date" title="2009-03-24">2009-03-24</span>
23677 </p>
23678 !! end
23679
23680 !!test
23681 formatdate parser function, with default format
23682 !! wikitext
23683 {{#formatdate:2009-03-24|mdy}}
23684 !! html
23685 <p><span class="mw-formatted-date" title="2009-03-24">March 24, 2009</span>
23686 </p>
23687 !! end
23688
23689 !! test
23690 Spacing of numbers in formatted dates
23691 !! wikitext
23692 {{#formatdate:January 15}}
23693 !! html
23694 <p><span class="mw-formatted-date" title="01-15">January 15</span>
23695 </p>
23696 !! end
23697
23698 !! test
23699 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
23700 !! options
23701 language=nl title=[[MediaWiki:Common.css]]
23702 !! wikitext
23703 {{#formatdate:2009-03-24|dmy}}
23704 !! html
23705 <p><span class="mw-formatted-date" title="2009-03-24">24 March 2009</span>
23706 </p>
23707 !! end
23708
23709 #
23710 #
23711 #
23712
23713 #
23714 # Edit comments
23715 #
23716
23717 !! test
23718 Edit comment with link
23719 !! options
23720 comment
23721 !! wikitext
23722 I like the [[Main Page]] a lot
23723 !! html/php
23724 I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot
23725 !!end
23726
23727 !! test
23728 Edit comment with link and link text
23729 !! options
23730 comment
23731 !! wikitext
23732 I like the [[Main Page|best pages]] a lot
23733 !! html/php
23734 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
23735 !!end
23736
23737 !! test
23738 Edit comment with link and link text with suffix
23739 !! options
23740 comment
23741 !! wikitext
23742 I like the [[Main Page|best page]]s a lot
23743 !! html/php
23744 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
23745 !!end
23746
23747 !! test
23748 Edit comment with section link (non-local, eg in history list)
23749 !! options
23750 comment title=[[Main Page]]
23751 !! wikitext
23752 /* External links */ removed bogus entries
23753 !! html/php
23754 <a href="/wiki/Main_Page#External_links" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
23755 !!end
23756
23757 !! test
23758 Edit comment with section link and text before it (non-local, eg in history list)
23759 !! options
23760 comment title=[[Main Page]]
23761 !! wikitext
23762 pre-comment text /* External links */ removed bogus entries
23763 !! html/php
23764 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>
23765 !!end
23766
23767 !! test
23768 Edit comment with section link (local, eg in diff view)
23769 !! options
23770 comment local title=[[Main Page]]
23771 !! wikitext
23772 /* External links */ removed bogus entries
23773 !! html/php
23774 <a href="#External_links">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
23775 !!end
23776
23777 !! test
23778 Edit comment with subpage link (T16080)
23779 !! options
23780 comment
23781 subpage
23782 title=[[Subpage test]]
23783 !! wikitext
23784 Poked at a [[/subpage]] here...
23785 !! html/php
23786 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> here...
23787 !!end
23788
23789 !! test
23790 Edit comment with subpage link and link text (T16080)
23791 !! options
23792 comment
23793 subpage
23794 title=[[Subpage test]]
23795 !! wikitext
23796 Poked at a [[/subpage|neat little page]] here...
23797 !! html/php
23798 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">neat little page</a> here...
23799 !!end
23800
23801 !! test
23802 Edit comment with bogus subpage link in non-subpage NS (T16080)
23803 !! options
23804 comment
23805 title=[[Subpage test]]
23806 !! wikitext
23807 Poked at a [[/subpage]] here...
23808 !! html/php
23809 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...
23810 !!end
23811
23812 !! test
23813 Edit comment with bare anchor link (local, as on diff)
23814 !! options
23815 comment
23816 local
23817 title=[[Main Page]]
23818 !! wikitext
23819 [[#section]]
23820 !! html/php
23821 <a href="#section">#section</a>
23822 !! end
23823
23824 !! test
23825 Edit comment with bare anchor link (non-local, as on history)
23826 !! options
23827 comment
23828 title=[[Main Page]]
23829 !! wikitext
23830 [[#section]]
23831 !! html/php
23832 <a href="/wiki/Main_Page#section" title="Main Page">#section</a>
23833 !! end
23834
23835 !! test
23836 Anchor starting with underscore
23837 !! options
23838 title=[[Foo]]
23839 !! wikitext
23840 [[#_ref|One]]
23841 !! html/php
23842 <p><a href="#_ref">One</a>
23843 </p>
23844 !! html/parsoid
23845 <p><a rel="mw:WikiLink" href="./Foo#_ref" data-parsoid='{"stx":"piped","a":{"href":"./Foo#_ref"},"sa":{"href":"#_ref"}}'>One</a></p>
23846 !! end
23847
23848 !! test
23849 Id starting with underscore
23850 !! wikitext
23851 <div id="_ref"></div>
23852 !! html/*
23853 <div id="_ref"></div>
23854
23855 !! end
23856
23857 !! test
23858 Edit comment with link with more than one pipe (T99346)
23859 !! options
23860 comment
23861 !! wikitext
23862 [[Main Page|Many|pipes]]
23863 !! html/php
23864 <a href="/wiki/Main_Page" title="Main Page">Many|pipes</a>
23865 !! end
23866
23867 !! test
23868 Complex edit comment with link with more than one pipe (T99346)
23869 !! options
23870 comment
23871 !! wikitext
23872 Created page with "<noinclude>[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]]</noinclude> === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..."
23873 !! html/php
23874 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;
23875 !! end
23876
23877 !! test
23878 Space normalisation on autocomment (T24784)
23879 !! options
23880 comment
23881 title=[[Main Page]]
23882 !! wikitext
23883 /* __hello__world__ */
23884 !! html/php
23885 <a href="/wiki/Main_Page#hello_world" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">__hello__world__</span></span>
23886 !! end
23887
23888 !! test
23889 percent-encoding and + signs in comments (T28410)
23890 !! options
23891 comment
23892 !! wikitext
23893 [[ABC%33D% ++]] [[ABC%33D% ++|+%20]]
23894 !! html/php
23895 <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>
23896 !! end
23897
23898 # Parsoid doesn't support this yet: see T75581
23899 # but it *should* omit the 'src' attribute if the image is bad.
23900 # PHP side of tests was disabled in
23901 # mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
23902 # because of issues in the PHP parserTests infrastructure
23903 # (but the output below is indeed what the PHP side emits)
23904 !! test
23905 Bad images - basic functionality
23906 !! wikitext
23907 [[File:Bad.jpg]]
23908 !! html/php+disabled
23909 !! html/parsoid
23910 <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>
23911 !! end
23912
23913 !! test
23914 Bad images - T18039: text after bad image disappears
23915 !! wikitext
23916 Foo bar
23917 [[File:Bad.jpg]]
23918 Bar foo
23919 !! html/php+disabled
23920 <p>Foo bar
23921 </p><p>Bar foo
23922 </p>
23923 !! html/parsoid
23924 <p>Foo bar
23925 <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>
23926 Bar foo</p>
23927 !! end
23928
23929 !! test
23930 Verify that displaytitle works (T24501) no displaytitle
23931 !! options
23932 showtitle
23933 !! config
23934 wgAllowDisplayTitle=true
23935 wgRestrictDisplayTitle=false
23936 !! wikitext
23937 this is not the the title
23938 !! html/php
23939 Parser test
23940 <p>this is not the the title
23941 </p>
23942 !! end
23943
23944 !! test
23945 Verify that displaytitle works (T24501) RestrictDisplayTitle=false
23946 !! options
23947 showtitle
23948 title=[[Screen]]
23949 !! config
23950 wgAllowDisplayTitle=true
23951 wgRestrictDisplayTitle=false
23952 !! wikitext
23953 this is not the the title
23954 {{DISPLAYTITLE:whatever}}
23955 !! html/php
23956 whatever
23957 <p>this is not the the title
23958 </p>
23959 !! end
23960
23961 !! test
23962 Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch
23963 !! options
23964 showtitle
23965 title=[[Screen]]
23966 !! config
23967 wgAllowDisplayTitle=true
23968 wgRestrictDisplayTitle=true
23969 !! wikitext
23970 this is not the the title
23971 {{DISPLAYTITLE:whatever}}
23972 !! html/php
23973 Screen
23974 <p>this is not the the title
23975 </p>
23976 !! end
23977
23978 !! test
23979 Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching
23980 !! options
23981 showtitle
23982 title=[[Screen]]
23983 !! config
23984 wgAllowDisplayTitle=true
23985 wgRestrictDisplayTitle=true
23986 !! wikitext
23987 this is not the the title
23988 {{DISPLAYTITLE:screen}}
23989 !! html/php
23990 screen
23991 <p>this is not the the title
23992 </p>
23993 !! end
23994
23995 !! test
23996 Verify that displaytitle works (T24501) AllowDisplayTitle=false
23997 !! options
23998 showtitle
23999 title=[[Screen]]
24000 !! config
24001 wgAllowDisplayTitle=false
24002 !! wikitext
24003 this is not the the title
24004 {{DISPLAYTITLE:screen}}
24005 !! html/php
24006 Screen
24007 <p>this is not the the title
24008 <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>
24009 </p>
24010 !! end
24011
24012 !! test
24013 Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE
24014 !! options
24015 showtitle
24016 title=[[Screen]]
24017 !! config
24018 wgAllowDisplayTitle=false
24019 !! wikitext
24020 this is not the the title
24021 !! html/php
24022 Screen
24023 <p>this is not the the title
24024 </p>
24025 !! end
24026
24027 !! test
24028 Verify that displaytitle handles inline CSS styles (T28547) - rejected value
24029 !! options
24030 showtitle
24031 title=[[Screen]]
24032 !! config
24033 wgAllowDisplayTitle=true
24034 wgRestrictDisplayTitle=true
24035 !! wikitext
24036 this is not the the title
24037 {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
24038 !! html/php
24039 <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
24040 <p>this is not the the title
24041 </p>
24042 !! end
24043
24044 !! test
24045 Verify that displaytitle handles inline CSS styles (T28547) - accepted value
24046 !! options
24047 showtitle
24048 title=[[Screen]]
24049 !! config
24050 wgAllowDisplayTitle=true
24051 wgRestrictDisplayTitle=true
24052 !! wikitext
24053 this is not the the title
24054 {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
24055 !! html/php
24056 <span style="color: red;">s</span>creen
24057 <p>this is not the the title
24058 </p>
24059 !! end
24060
24061 !! test
24062 Page status indicators: Empty name is invalid
24063 !! options
24064 showindicators
24065 !! wikitext
24066 <indicator name=" "></indicator>
24067 <indicator></indicator>
24068 !! html/php
24069 <p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
24070 <span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
24071 </p>
24072 !! end
24073
24074 !! test
24075 Page status indicators: Weird syntaxes that are okay
24076 !! options
24077 showindicators
24078 !! wikitext
24079 <indicator name="empty" />
24080 <indicator name="name"></indicator>
24081 !! html/php
24082 empty=
24083 name=
24084 <p><br />
24085 </p>
24086 !! end
24087
24088 !! test
24089 Page status indicators: Torture test
24090 !! options
24091 showindicators
24092 !! wikitext
24093 <indicator name="01">hello world</indicator>
24094 <indicator name="02">[[Main Page]]</indicator>
24095 <indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator>
24096 <indicator name="04">[[File:Foobar.jpg|25px]]</indicator>
24097 <indicator name="05">*foo
24098 *bar</indicator>
24099 <indicator name="06"><nowiki>foo</nowiki></indicator>
24100 <indicator name="07"> Preformatted</indicator>
24101 <indicator name="08"><div>Broken tag</indicator>
24102 <indicator name="09">{| class=wikitable
24103 |cell
24104 |}</indicator>
24105 <indicator name="10">Two
24106
24107 paragraphs</indicator>
24108 !! html/php
24109 01=hello world
24110 02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
24111 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" />
24112 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>
24113 05=<ul><li>foo</li>
24114 <li>bar</li></ul>
24115
24116 06=foo
24117 07=<pre>Preformatted
24118 </pre>
24119 08=<div>Broken tag</div>
24120
24121 09=<table class="wikitable">
24122 <tr>
24123 <td>cell
24124 </td></tr></table>
24125
24126 10=<p>Two
24127 </p><p>paragraphs
24128 </p>
24129 <p><br />
24130 </p><p><br />
24131 </p><p><br />
24132 </p><p><br />
24133 </p><p><br />
24134 </p>
24135 !! end
24136
24137 !! test
24138 preload: check <noinclude> and <includeonly>
24139 !! options
24140 preload
24141 !! wikitext
24142 Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
24143 !! html/php
24144 Hello kind world.
24145 !! end
24146
24147 !! test
24148 preload: check <onlyinclude>
24149 !! options
24150 preload
24151 !! wikitext
24152 Goodbye <onlyinclude>Hello world</onlyinclude>
24153 !! html/php
24154 Hello world
24155 !! end
24156
24157 !! test
24158 preload: can pass tags through if we want to
24159 !! options
24160 preload
24161 !! wikitext
24162 <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
24163 !! html/php
24164 <includeonly>Hello world</includeonly>
24165 !! end
24166
24167 !! test
24168 preload: check that it doesn't try to do tricks
24169 !! options
24170 preload
24171 !! wikitext
24172 * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
24173 !! html/php
24174 * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
24175 !! end
24176
24177 !! test
24178 Play a bit with r67090 and T5158
24179 !! wikitext
24180 <div style="width:50% !important">&nbsp;</div>
24181 <div style="width:50%&nbsp;!important">&nbsp;</div>
24182 <div style="width:50%&#160;!important">&nbsp;</div>
24183 <div style="border : solid;">&nbsp;</div>
24184 !! html/php
24185 <div style="width:50%&#32;!important">&#160;</div>
24186 <div style="width:50% !important">&#160;</div>
24187 <div style="width:50% !important">&#160;</div>
24188 <div style="border&#32;: solid;">&#160;</div>
24189
24190 !! html/parsoid
24191 <div style="width:50% !important" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
24192 <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>
24193 <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>
24194 <div style="border : solid;" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
24195
24196 !! end
24197
24198 !! test
24199 T5158: Test for French spaces in attributes
24200 !! wikitext
24201 <br style=" clear : both ; " />
24202 !! html/php
24203 <p><br style="clear&#32;: both&#32;;" />
24204 </p>
24205 !! end
24206
24207 !! test
24208 HTML5 data attributes
24209 !! wikitext
24210 <span data-foo="bar">Baz</span>
24211 <p data-abc-def_hij="">Quuz</p>
24212 !! html/php
24213 <p><span data-foo="bar">Baz</span>
24214 </p>
24215 <p data-abc-def_hij="">Quuz</p>
24216
24217 !! html/parsoid
24218 <p><span data-foo="bar" data-parsoid='{"stx":"html"}'>Baz</span></p>
24219 <p data-abc-def_hij="" data-parsoid='{"stx":"html"}'>Quuz</p>
24220 !! end
24221
24222 !! test
24223 Strip reserved data attributes
24224 !! wikitext
24225 <div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
24226 !! html/php
24227 <div data-ok="fred">d</div>
24228
24229 !! html/parsoid
24230 <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>
24231 !! end
24232
24233 !! test
24234 percent-encoding and + signs in internal links (T28410)
24235 !! wikitext
24236 [[User:+%]] [[Page+title%]]
24237 [[%+]] [[%+|%20]] [[%+ ]] [[%+r]]
24238 [[%]] [[+]] [[File:%+abc%39|foo|[[bar]]]]
24239 [[%33%45]] [[%33%45+]]
24240 !! html/php
24241 <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>
24242 <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>
24243 <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>
24244 <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>
24245 </p>
24246 !! html/parsoid
24247 <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>
24248 <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>
24249 <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>
24250 <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>
24251 !! end
24252
24253 !! test
24254 Special characters in embedded file links (T29679)
24255 !! wikitext
24256 [[File:Contains & ampersand.jpg]]
24257 [[File:Does not exist.jpg|Title with & ampersand]]
24258 !! html/php
24259 <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>
24260 <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>
24261 </p>
24262 !! html/parsoid
24263 <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>
24264 <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>
24265 !! end
24266
24267 !! test
24268 Confirm that 'apos' named character reference doesn't make it to output (not legal in HTML 4)
24269 !! wikitext
24270 Text&apos;s been normalized?
24271 !! html
24272 <p>Text&#39;s been normalized?
24273 </p>
24274 !! end
24275
24276 !! test
24277 T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
24278 !! wikitext
24279 http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
24280 !! html
24281 <p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> &lt;-- U+3000 (vim: ^Vu3000)
24282 </p>
24283 !! end
24284
24285 !! test
24286 T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
24287 !! wikitext
24288 [http://www.example.org/ ideograms]
24289 !! html
24290 <p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a>
24291 </p>
24292 !! end
24293
24294 !! test
24295 T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
24296 !! wikitext
24297 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
24298 !! html
24299 <p><img src="http://www.example.org/pic.png" alt="pic.png"/> &lt;-- U+3000 (vim: ^Vu3000)
24300 </p>
24301 !! end
24302
24303 !! article
24304 Mediawiki:loop1
24305 !! text
24306 {{Identical|A}}
24307 !! endarticle
24308
24309 !! article
24310 Mediawiki:loop2
24311 !! text
24312 {{Identical|B}}
24313 !! endarticle
24314
24315 !! article
24316 Template:Identical
24317 !! text
24318 {{int:loop1}}
24319 {{int:loop2}}
24320 !! endarticle
24321
24322 !! test
24323 T33098 Template which includes system messages which includes the template
24324 !! wikitext
24325 {{Identical}}
24326 !! html
24327 <p><span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
24328 <span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
24329 </p>
24330 !! end
24331
24332 !! test
24333 T33490 Turkish: ucfirst 'blah'
24334 !! options
24335 language=tr
24336 !! wikitext
24337 {{ucfirst:blah}}
24338 !! html
24339 <p>Blah
24340 </p>
24341 !! end
24342
24343 !! test
24344 T33490 Turkish: ucfirst 'ix'
24345 !! options
24346 language=tr
24347 !! wikitext
24348 {{ucfirst:ix}}
24349 !! html
24350 <p>İx
24351 </p>
24352 !! end
24353
24354 !! test
24355 T33490 Turkish: lcfirst 'BLAH'
24356 !! options
24357 language=tr
24358 !! wikitext
24359 {{lcfirst:BLAH}}
24360 !! html
24361 <p>bLAH
24362 </p>
24363 !! end
24364
24365 !! test
24366 T33490 Turkish: ucfırst (with a dotless i)
24367 !! options
24368 language=tr
24369 !! wikitext
24370 {{ucfırst:blah}}
24371 !! html
24372 <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>
24373 </p>
24374 !! end
24375
24376 !! test
24377 T33490 ucfırst (with a dotless i) with English language
24378 !! options
24379 language=en
24380 !! wikitext
24381 {{ucfırst:blah}}
24382 !! html
24383 <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>
24384 </p>
24385 !! end
24386
24387 # Note that Parsoid doesn't emit an explicit TOC.
24388 # Note also that the html2wt direction tends to emit an extra newline
24389 # between the __TOC__ magicword and the first heading unless *both*
24390 # the <meta> and the <h2> have a data-parsoid attribute set (even if
24391 # it's "{}").
24392
24393 !! test
24394 T28375: TOC with italics
24395 !! options
24396 title=[[Main Page]]
24397 !! wikitext
24398 __TOC__
24399 ==''Lost'' episodes==
24400 !! html/php
24401 <div id="toc" class="toc"><input type="checkbox" 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>
24402 <ul>
24403 <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>
24404 </ul>
24405 </div>
24406
24407 <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>
24408
24409 !! html/parsoid
24410 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24411 <h2 id="Lost_episodes" data-parsoid='{}'><i>Lost</i> episodes</h2>
24412 !! end
24413
24414 !! test
24415 T28375: TOC with bold
24416 !! options
24417 title=[[Main Page]]
24418 !! wikitext
24419 __TOC__
24420 =='''should be bold''' then normal text==
24421 !! html/php
24422 <div id="toc" class="toc"><input type="checkbox" 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>
24423 <ul>
24424 <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>
24425 </ul>
24426 </div>
24427
24428 <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>
24429
24430 !! html/parsoid
24431 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24432 <h2 id="should_be_bold_then_normal_text" data-parsoid='{}'><b>should be bold</b> then normal text</h2>
24433 !! end
24434
24435 !! test
24436 T35845: Headings become cursive in TOC when they contain an image
24437 !! options
24438 title=[[Main Page]]
24439 !! wikitext
24440 __TOC__
24441 ==Image [[Image:foobar.jpg]]==
24442 !! html/php
24443 <div id="toc" class="toc"><input type="checkbox" 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>
24444 <ul>
24445 <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
24446 </ul>
24447 </div>
24448
24449 <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>
24450
24451 !! html/parsoid
24452 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24453 <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>
24454 !! end
24455
24456 !! test
24457 T35845 (2): Headings become bold in TOC when they contain a blockquote
24458 !! options
24459 title=[[Main Page]]
24460 !! wikitext
24461 __TOC__
24462 ==<blockquote>Quote</blockquote>==
24463 !! html/php
24464 <div id="toc" class="toc"><input type="checkbox" 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>
24465 <ul>
24466 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
24467 </ul>
24468 </div>
24469
24470 <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>
24471
24472 !! html/php+tidy
24473 <div id="toc" class="toc"><input type="checkbox" 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>
24474 <ul>
24475 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
24476 </ul>
24477 </div>
24478
24479 <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>
24480 !! html/parsoid
24481 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24482 <h2 id="Quote" data-parsoid='{}'><blockquote>Quote</blockquote></h2>
24483 !! end
24484
24485 !! test
24486 Unclosed tags in TOC
24487 !! config
24488 wgFragmentMode=[ 'html5', 'legacy' ]
24489 !! options
24490 title=[[Main Page]]
24491 !! wikitext
24492 __TOC__
24493 ==Proof: 2 < 3==
24494 <small>Hanc marginis exiguitas non caperet.</small>
24495 QED
24496 !! html/php
24497 <div id="toc" class="toc"><input type="checkbox" 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>
24498 <ul>
24499 <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>
24500 </ul>
24501 </div>
24502
24503 <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>
24504 <p><small>Hanc marginis exiguitas non caperet.</small>
24505 QED
24506 </p>
24507 !! html/parsoid
24508 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24509 <h2 id="Proof:_2_&lt;_3" data-parsoid='{}'><span id="Proof:_2_.3C_3" typeof="mw:FallbackId"></span>Proof: 2 &lt; 3</h2>
24510 <p><small>Hanc marginis exiguitas non caperet.</small>
24511 QED</p>
24512 !! end
24513
24514 !! test
24515 Multiple tags in TOC
24516 !! wikitext
24517 __TOC__
24518 ==<i>Foo</i> <b>Bar</b>==
24519
24520 ==<i>Foo</i> <blockquote>Bar</blockquote>==
24521 !! html/php
24522 <div id="toc" class="toc"><input type="checkbox" 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>
24523 <ul>
24524 <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>
24525 <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>
24526 </ul>
24527 </div>
24528
24529 <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>
24530 <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>
24531
24532 !! html/php+tidy
24533 <div id="toc" class="toc"><input type="checkbox" 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>
24534 <ul>
24535 <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>
24536 <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>
24537 </ul>
24538 </div>
24539
24540 <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>
24541 <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>
24542 !! html/parsoid
24543 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24544 <h2 id="Foo_Bar" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b></h2>
24545
24546 <h2 id="Foo_Bar_2" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote>Bar</blockquote></h2>
24547 !! end
24548
24549 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
24550 # html5 tag parsing.
24551 !! test
24552 Tags with parameters in TOC
24553 !! options
24554 parsoid=wt2html
24555 !! wikitext
24556 __TOC__
24557 ==<sup class="in-h2">Hello</sup>==
24558
24559 ==<sup class="a > b">Evilbye</sup>==
24560 !! html/php
24561 <div id="toc" class="toc"><input type="checkbox" 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>
24562 <ul>
24563 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
24564 <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>
24565 </ul>
24566 </div>
24567
24568 <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>
24569 <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>
24570
24571 !! html/parsoid
24572 <meta property="mw:PageProp/toc" />
24573 <h2 id="Hello"><sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup></h2>
24574
24575 <h2 id='b">Evilbye'><span id="b.22.3EEvilbye" typeof="mw:FallbackId"></span><sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup></h2>
24576 !! end
24577
24578 !! test
24579 span tags with directionality in TOC
24580 !! wikitext
24581 __TOC__
24582 ==<span dir="ltr">C++</span>==
24583
24584 ==<span dir="rtl">זבנג!</span>==
24585
24586 ==<span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span>==
24587
24588 ==<span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span>==
24589
24590 ==<span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span>==
24591 !! html/php
24592 <div id="toc" class="toc"><input type="checkbox" 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>
24593 <ul>
24594 <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>
24595 <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>
24596 <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>
24597 <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>
24598 <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>
24599 </ul>
24600 </div>
24601
24602 <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>
24603 <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>
24604 <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>
24605 <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>
24606 <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>
24607
24608 !! html/parsoid
24609 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24610 <h2 id="C++" data-parsoid='{}'><span id="C.2B.2B" typeof="mw:FallbackId"></span><span dir="ltr">C++</span></h2>
24611 <h2 id="זבנג!"><span id=".D7.96.D7.91.D7.A0.D7.92.21" typeof="mw:FallbackId"></span><span dir="rtl">זבנג!</span></h2>
24612 <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>
24613 <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>
24614 <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>
24615 !! end
24616
24617 !! test
24618 T74884: bdi element in ToC
24619 !! wikitext
24620 __TOC__
24621 ==<bdi>test</bdi>==
24622 !! html/php
24623 <div id="toc" class="toc"><input type="checkbox" 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>
24624 <ul>
24625 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
24626 </ul>
24627 </div>
24628
24629 <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>
24630
24631 !! html/parsoid
24632 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24633 <h2 id="test" data-parsoid='{}'><bdi>test</bdi></h2>
24634 !! end
24635
24636 !! test
24637 T35715: s/strike element in ToC
24638 !! wikitext
24639 __TOC__
24640 ==<s>test</s> test <strike>test</strike>==
24641 !! html/php
24642 <div id="toc" class="toc"><input type="checkbox" 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>
24643 <ul>
24644 <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>
24645 </ul>
24646 </div>
24647
24648 <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>
24649
24650 !! html/parsoid
24651 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24652 <h2 id="test_test_test" data-parsoid='{}'><s>test</s> test <strike>test</strike></h2>
24653 !! end
24654
24655 !! test
24656 Empty <p> tag in TOC, removed by Sanitizer (T92892)
24657 !! wikitext
24658 __TOC__
24659 ==x==
24660 !! html/php
24661 <div id="toc" class="toc"><input type="checkbox" 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>
24662 <ul>
24663 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
24664 </ul>
24665 </div>
24666
24667 <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>
24668
24669 !! html/parsoid
24670 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24671 <h2 id="x" data-parsoid='{}'>x</h2>
24672 !! end
24673
24674 !! article
24675 MediaWiki:T34057
24676 !! text
24677 == {{int:headline_sample}} ==
24678 !! endarticle
24679
24680 !! test
24681 T34057: Title needed when expanding <h> nodes.
24682 !! options
24683 title=[[Main Page]]
24684 !! wikitext
24685 {{int:T34057}}
24686 !! html
24687 <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>
24688
24689 !! end
24690
24691 !! test
24692 Strip marker in urlencode
24693 !! wikitext
24694 {{urlencode:x<nowiki/>y}}
24695 {{urlencode:x<nowiki/>y|wiki}}
24696 {{urlencode:x<nowiki/>y|path}}
24697 {{urlencode:x<pre id="one">two</pre>y}}
24698 !! html/php
24699 <p>xy
24700 xy
24701 xy
24702 xy
24703 </p>
24704 !! end
24705
24706 !! test
24707 Strip marker in lc
24708 !! wikitext
24709 {{lc:x<nowiki/>y}}
24710 !! html
24711 <p>xy
24712 </p>
24713 !! end
24714
24715 !! test
24716 Strip marker in uc
24717 !! wikitext
24718 {{uc:x<nowiki/>y}}
24719 !! html
24720 <p>XY
24721 </p>
24722 !! end
24723
24724 !! test
24725 Strip marker in formatNum
24726 !! wikitext
24727 {{formatnum:1<nowiki/>2}}
24728 {{formatnum:1<nowiki/>2|R}}
24729 !! html
24730 <p>12
24731 12
24732 </p>
24733 !! end
24734
24735 !! test
24736 Check noCommafy in formatNum
24737 !! options
24738 language=be-tarask
24739 !! wikitext
24740 {{formatnum:123456.78}}
24741 {{formatnum:123456.78|NOSEP}}
24742 !! html
24743 <p>123 456,78
24744 123456.78
24745 </p>
24746 !! end
24747
24748 !! test
24749 Wrong option for formatNum (T58199)
24750 !! wikitext
24751 {{formatnum:1,234.56|Random}}
24752 {{formatnum:1,234.56|EVERYTHING}}
24753 {{formatnum:1234.56|any argument that has the string 'NOSEP'}}
24754 !! html
24755 <p>1,234.56
24756 1,234.56
24757 1,234.56
24758 </p>
24759 !! end
24760
24761 !! test
24762 Strip marker in grammar
24763 !! options
24764 language=fi
24765 !! wikitext
24766 {{grammar:elative|foo<nowiki/>bar}}
24767 !! html
24768 <p>foobarista
24769 </p>
24770 !! end
24771
24772 !! test
24773 Strip marker in padleft
24774 !! wikitext
24775 {{padleft:|2|x<nowiki/>y}}
24776 !! html
24777 <p>xy
24778 </p>
24779 !! end
24780
24781 !! test
24782 Strip marker in padright
24783 !! wikitext
24784 {{padright:|2|x<nowiki/>y}}
24785 !! html
24786 <p>xy
24787 </p>
24788 !! end
24789
24790 !! test
24791 Strip marker in anchorencode
24792 !! wikitext
24793 {{anchorencode:x<nowiki/>y}}
24794 !! html/php
24795 <p>xy
24796 </p>
24797 !! html/parsoid
24798 <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>
24799 !! end
24800
24801 !! test
24802 nowiki inside link inside heading (T20295)
24803 !! wikitext
24804 ==[[foo|x<nowiki>y</nowiki>z]]==
24805 !! html
24806 <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>
24807
24808 !! end
24809
24810 !! test
24811 new support for bdi element (T33817)
24812 !! wikitext
24813 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
24814 !! html
24815 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
24816
24817 !!end
24818
24819 !! test
24820 Ignore pipe between table row attributes
24821 !! wikitext
24822 {|
24823 |quux
24824 |- id=foo | style='color: red'
24825 |bar
24826 |}
24827 !! html
24828 <table>
24829 <tr>
24830 <td>quux
24831 </td></tr>
24832 <tr id="foo" style="color: red">
24833 <td>bar
24834 </td></tr></table>
24835
24836 !! end
24837
24838 !!test
24839 Language parser function
24840 !! wikitext
24841 {{#language:ar}}
24842 !! html
24843 <p>العربية
24844 </p>
24845 !! end
24846
24847 !!test
24848 Padleft and padright (default 0-padding)
24849 !! wikitext
24850 {{padleft:xyz|5}}
24851 {{padright:xyz|5}}
24852 !! html/php
24853 <p>00xyz
24854 xyz00
24855 </p>
24856 !! html/parsoid
24857 <p><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:xyz","function":"padleft"},"params":{"1":{"wt":"5"}},"i":0}}]}'>00xyz</span>
24858 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:xyz","function":"padright"},"params":{"1":{"wt":"5"}},"i":0}}]}'>xyz00</span></p>
24859 !! end
24860
24861 !!test
24862 Padleft and padright (partial fill)
24863 !! wikitext
24864 {{padleft:xyz|6|ab}}
24865 {{padright:xyz|6|ab}}
24866 !! html/php
24867 <p>abaxyz
24868 xyzaba
24869 </p>
24870 !! html/parsoid
24871 <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>
24872 <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>
24873 !! end
24874
24875 !!test
24876 Padleft and padright as substr
24877 !! wikitext
24878 {{padleft:|3|abcde}}
24879 {{padright:|3|abcde}}
24880 !! html/php
24881 <p>abc
24882 abc
24883 </p>
24884 !! html/parsoid
24885 <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>
24886 <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>
24887 !! end
24888
24889 !! test
24890 Padleft and padright with non-numerical length (T180403)
24891 !! wikitext
24892 {{padleft:abcdef|junk}}
24893 {{padright:abcdef|junk}}
24894 !! html/php
24895 <p>abcdef
24896 abcdef
24897 </p>
24898 !! end
24899
24900 !!test
24901 Special parser function
24902 !! wikitext
24903 {{#special:RandomPage}}
24904 {{#special:BaDtItLe}}
24905 {{#special:Foobar}}
24906 !! html
24907 <p>Special:Random
24908 Special:Badtitle
24909 Special:Foobar
24910 </p>
24911 !! end
24912
24913 !!test
24914 T36939 - Case insensitive link parsing ([HttP://])
24915 !! wikitext
24916 [HttP://MediaWiki.Org/]
24917 !! html/php
24918 <p><a rel="nofollow" class="external autonumber" href="HttP://MediaWiki.Org/">[1]</a>
24919 </p>
24920 !! html/parsoid
24921 <p><a rel="mw:ExtLink" class="external autonumber" href="HttP://MediaWiki.Org/"></a></p>
24922 !! end
24923
24924 !!test
24925 T36939 - Case insensitive link parsing ([HttP:// title])
24926 !! wikitext
24927 [HttP://MediaWiki.Org/ MediaWiki]
24928 !! html
24929 <p><a rel="nofollow" class="external text" href="HttP://MediaWiki.Org/">MediaWiki</a>
24930 </p>
24931 !! end
24932
24933 !!test
24934 T36939 - Case insensitive link parsing (HttP://)
24935 !! wikitext
24936 HttP://MediaWiki.Org/
24937 !! html/php
24938 <p><a rel="nofollow" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a>
24939 </p>
24940 !! html/parsoid
24941 <p><a rel="mw:ExtLink" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a></p>
24942 !! end
24943
24944 !!test
24945 Disable TOC
24946 !! options
24947 notoc
24948 !! wikitext
24949 Lead
24950 ==Section 1==
24951 ==Section 2==
24952 ==Section 3==
24953 ==Section 4==
24954 ==Section 5==
24955 !! html
24956 <p>Lead
24957 </p>
24958
24959 <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>
24960 <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>
24961 <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>
24962 <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>
24963 <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>
24964
24965 !! end
24966
24967
24968 ###
24969 ### Parsoid-specific tests
24970 ### Parsoid-PHP parser incompatibilities
24971 ###
24972 !!test
24973 1. SOL-sensitive wikitext tokens as template-args
24974 !!options
24975 parsoid=wt2html,wt2wt
24976 !! wikitext
24977 {{echo|*a}}
24978 {{echo|#a}}
24979 {{echo|:a}}
24980 !! html
24981 <span about="#mwt1" typeof="mw:Transclusion">
24982 </span><ul about="#mwt1"><li>a</li>
24983 </ul>
24984 <span about="#mwt2" typeof="mw:Transclusion">
24985 </span><ol about="#mwt2"><li>a</li>
24986 </ol>
24987 <span about="#mwt3" typeof="mw:Transclusion">
24988 </span><dl about="#mwt3"><dd>a</dd>
24989 </dl>
24990 !!end
24991
24992 #### -----------------------------------------------------------------
24993 #### Parsoid-specific functionality tests
24994 #### -----------------------------------------------------------------
24995
24996 # T65642/T68749: Formatting elt fixup around images is cleaned up.
24997 # We know wt2wt will fail, but we expect selser to pass.
24998 # Due to the nature of our testing, wt2wt and selser tests will enter the
24999 # blacklist and we'll catch selser regressions based on changes to the
25000 # blacklist entries for selser tests.
25001 !! test
25002 1. Bad treebuilder fixup of formatting elt is cleaned up
25003 !! options
25004 parsoid=wt2html,wt2wt
25005 !! wikitext
25006 {|
25007 |
25008 <small>
25009 [[Image:Foobar.jpg|right|Test]]
25010 </small>
25011 |}
25012 !! html/parsoid
25013 <table>
25014 <tbody><tr><td>
25015 <small>
25016 <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>
25017 </small>
25018 </td></tr>
25019 </tbody></table>
25020 !! end
25021
25022 !! test
25023 2. Bad treebuilder fixup of formatting elt is cleaned up
25024 !! options
25025 parsoid=wt2html,wt2wt
25026 !! wikitext
25027 '''foo[[File:Foobar.jpg|thumb|caption]]bar'''
25028
25029 <small>[[Image:Foobar.jpg|right|300px]]</small>
25030 !! html/parsoid
25031
25032 <p><b>foo</b></p>
25033 <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><b>caption</b></figcaption></figure>
25034 <p><b>bar</b></p>
25035 <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>
25036 !! end
25037
25038 !! test
25039 3. Bad treebuilder fixup of formatting elt is cleaned up
25040 !! options
25041 parsoid=wt2html,wt2wt
25042 !! wikitext
25043 <small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
25044 !! html/parsoid
25045 <p><small><b>foo</b></small></p>
25046 <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><small><b>caption</b></small></figcaption></figure>
25047 <p><small><b>bar</b></small></p>
25048 !! end
25049
25050 !! test
25051 4. Bad treebuilder fixup of formatting elt is cleaned up: formatting tags around captionless images are ignored
25052 !! options
25053 parsoid=wt2html,wt2wt
25054 !! wikitext
25055 '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
25056 !! html/parsoid
25057 <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>
25058 !! end
25059
25060 #### ----------------------------------------------------------------
25061 #### Parsoid-only testing of Parsoid's impl of LST
25062 #### Not implemented yet, see
25063 #### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
25064 #### ----------------------------------------------------------------
25065
25066 ## We still need to support serializing the older format while content is stored.
25067 !! test
25068 LST Sections: Backwards compatibility
25069 !! options
25070 parsoid={
25071 "suppressErrors": true,
25072 "modes": ["html2wt"]
25073 }
25074 !! wikitext
25075 <section begin="2011-05-16" />
25076 <section end="2014-04-10 (MW 1.23wmf22)" />
25077 !! html/parsoid
25078 <p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/>
25079 <meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p>
25080 !! end
25081
25082 !! test
25083 LST Sections: Newfangled approach
25084 !! wikitext
25085 <section begin="2011-05-16" />
25086 <section end="2014-04-10 (MW 1.23wmf22)" />
25087 !! html/parsoid
25088 <p><span typeof="mw:Extension/section" about="#mwt4" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"},"body":null}'>
25089 </span>
25090 <span typeof="mw:Extension/section" about="#mwt6" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"},"body":null}'>
25091 </span></p>
25092 !! end
25093
25094 #--------- Test stripping of empty nodes in template content ----------
25095
25096 !! test
25097 Empty LI and TR nodes should be stripped from template content
25098 !! wikitext
25099 {{EmptyLITest}}
25100 {{EmptyTRTest}}
25101 !! html/parsoid
25102 <ul about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyLITest","href":"./Template:EmptyLITest"},"params":{},"i":0}}]}'>
25103 <li>a</li>
25104 <li>b</li>
25105 </ul>
25106 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRTest","href":"./Template:EmptyTRTest"},"params":{},"i":0}}]}'>
25107 <tbody>
25108 <tr>
25109 <td>foo</td>
25110 </tr>
25111 <tr>
25112 <td>bar</td>
25113 </tr>
25114 </tbody>
25115 </table>
25116 !! end
25117
25118 !! test
25119 Empty LI and TR nodes should not be stripped from top-level content
25120 !! wikitext
25121 *a
25122 *
25123 *b
25124
25125 {|
25126 |-
25127 |-
25128 |foo
25129 |}
25130 !! html/parsoid
25131 <ul>
25132 <li>a</li>
25133 <li class='mw-empty-elt'></li>
25134 <li>b</li>
25135 </ul>
25136 <table>
25137 <tbody>
25138 <tr class='mw-empty-elt'></tr>
25139 <tr>
25140 <td>foo</td>
25141 </tr>
25142 </tbody>
25143 </table>
25144 !! end
25145
25146 !! test
25147 Empty TR nodes should not be stripped if they have any attributes set
25148 !! wikitext
25149 {{EmptyTRWithHTMLAttrTest}}
25150 !! html/parsoid
25151 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'>
25152 <tr align='center'></tr>
25153 <tr><td>foo</td></tr>
25154 <tr align='center'></tr>
25155 <tr><td>bar</td></tr>
25156 </table>
25157 !! end
25158
25159 #### ----------------------------------------------------------------
25160 #### The following section of tests are primarily to test
25161 #### wikitext escaping capabilities of Parsoid. Given that
25162 #### escaping can be done any number of ways, the wikitext (input)
25163 #### is always adjusted to reflect how Parsoid adds nowiki
25164 #### escape tags.
25165 ####
25166 #### We are marking several tests as parsoid-only since the
25167 #### HTML in the result section is different from what the
25168 #### PHP parser generates for it.
25169 #### ----------------------------------------------------------------
25170
25171
25172 #### --------------- Headings ---------------
25173 #### 0. Unnested
25174 #### 1. Nested inside html <h1>=foo=</h1>
25175 #### 2. Outside heading nest on a single line <h1>foo</h1>*bar
25176 #### 3. Nested inside html with wikitext split by html tags
25177 #### 4. No escape needed
25178 #### 5. Empty headings <h1></h1>
25179 #### 6. Heading chars in SOL context
25180 #### ----------------------------------------
25181 !! test
25182 Headings: 0. Unnested
25183 !! options
25184 parsoid=html2wt
25185 !! html/parsoid
25186 <p>=foo=</p>
25187
25188 <p> =foo=
25189 <!--cmt-->
25190 =foo=</p>
25191
25192 <p>=foo<i>a</i>=</p>
25193 !! wikitext
25194 <nowiki>=foo=</nowiki>
25195
25196 <nowiki> </nowiki>=foo=
25197 <!--cmt-->
25198 <nowiki>=foo=</nowiki>
25199
25200 =foo''a''<nowiki>=</nowiki>
25201 !!end
25202
25203 # New headings and existing headings are handled differently
25204 !! test
25205 Headings: 1. Nested inside html
25206 !! options
25207 parsoid=html2wt
25208 !! html/parsoid
25209 <h1>=foo=</h1>
25210 <h2>=foo=</h2>
25211 <h3>=foo=</h3>
25212
25213 <h1 data-parsoid=''>=foo=</h1>
25214 <h2 data-parsoid=''>=foo=</h2>
25215 <h3 data-parsoid=''>=foo=</h3>
25216 <h4 data-parsoid=''>=foo=</h4>
25217 <h5 data-parsoid=''>=foo=</h5>
25218 <h6 data-parsoid=''>=foo=</h6>
25219 !! wikitext
25220 = =foo= =
25221
25222 == =foo= ==
25223
25224 === =foo= ===
25225
25226 =<nowiki>=foo=</nowiki>=
25227 ==<nowiki>=foo=</nowiki>==
25228 ===<nowiki>=foo=</nowiki>===
25229 ====<nowiki>=foo=</nowiki>====
25230 =====<nowiki>=foo=</nowiki>=====
25231 ======<nowiki>=foo=</nowiki>======
25232
25233 !!end
25234
25235 !! test
25236 Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
25237 !! options
25238 parsoid=html2wt
25239 !! html/parsoid
25240 <h1>foo</h1>*bar
25241 <h1>foo</h1>=bar
25242 <h1>foo</h1>=bar=
25243 !! wikitext
25244 = foo =
25245 <nowiki>*</nowiki>bar
25246
25247 = foo =
25248 =bar
25249
25250 = foo =
25251 <nowiki>=bar=</nowiki>
25252 !!end
25253
25254 !! test
25255 Headings: 3. Nested inside html with wikitext split by html tags
25256 !! options
25257 parsoid=html2wt
25258 !! html/parsoid
25259 <h1>=<b>bold</b>foo=</h1>
25260 !! wikitext
25261 = ='''bold'''foo= =
25262 !!end
25263
25264 !! test
25265 Headings: 4a. No escaping needed (testing just h1 and h2)
25266 !! options
25267 parsoid=html2wt
25268 !! html/parsoid
25269 <h1>=foo</h1>
25270 <h1>foo=</h1>
25271 <h1> =foo= </h1>
25272 <h1>=foo= bar</h1>
25273 <h2>=foo</h2>
25274 <h2>foo=</h2>
25275 <h1>=</h1>
25276 <h1><i>=</i>foo=</h1>
25277 !! wikitext
25278 = =foo =
25279
25280 = foo= =
25281
25282 = =foo= =
25283
25284 = =foo= bar =
25285
25286 == =foo ==
25287
25288 == foo= ==
25289
25290 = = =
25291
25292 = ''=''foo= =
25293 !!end
25294
25295 !! test
25296 Headings: 4b. No escaping needed (inside p-tags)
25297 !! options
25298 parsoid=html2wt
25299 !! html/parsoid
25300 <p>=foo= x
25301 =foo= <s></s>
25302 </p>
25303 !! wikitext
25304 =foo= x
25305 =foo= <s></s>
25306 !! html/php
25307 <p>=foo= x
25308 =foo= <s></s>
25309 </p>
25310 !!end
25311
25312 !! test
25313 Headings: 4c. Short headings (1)
25314 !! options
25315 parsoid=html2wt
25316 !! html/parsoid
25317 <p>===
25318 </p>
25319 !! wikitext
25320 <nowiki>===</nowiki>
25321 !! html/php
25322 <p>===
25323 </p>
25324 !! end
25325
25326 # in the html2wt direction we emit '= = =' or '=<nowiki>=</nowiki>='
25327 !! test
25328 Headings: 4d. Short headings (2)
25329 !! options
25330 parsoid=wt2html,html2html
25331 !! wikitext
25332 =
25333 ==
25334 ===
25335 ====
25336 =====
25337 !! html/php
25338 <p>=
25339 ==
25340 </p>
25341 <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>
25342 <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>
25343 <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>
25344
25345 !! html/parsoid
25346 <p>=
25347 ==</p>
25348 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
25349 <h1 id="=="><span id=".3D.3D" typeof="mw:FallbackId"></span>==</h1>
25350 <h2 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h2>
25351 !! end
25352
25353 !! test
25354 Headings: 5. Empty headings
25355 !! options
25356 parsoid=html2wt
25357 !! html/parsoid
25358 <h1 data-parsoid='{}'></h1>
25359
25360 <h2 data-parsoid='{}'></h2>
25361
25362 <h3 data-parsoid='{}'></h3>
25363
25364 <h4 data-parsoid='{}'></h4>
25365
25366 <h5 data-parsoid='{}'></h5>
25367
25368 <h6 data-parsoid='{}'></h6>
25369 !! wikitext
25370 =<nowiki/>=
25371
25372 ==<nowiki/>==
25373
25374 ===<nowiki/>===
25375
25376 ====<nowiki/>====
25377
25378 =====<nowiki/>=====
25379
25380 ======<nowiki/>======
25381 !!end
25382
25383 !! test
25384 Headings: 6a. Heading chars in SOL context (with trailing spaces)
25385 !! options
25386 parsoid=html2wt
25387 !! html/parsoid
25388 <p>=a=</p>
25389
25390 <p>=a=</p>
25391
25392 <p>=a=</p>
25393 !! wikitext
25394 <nowiki>=a=</nowiki>
25395
25396 <nowiki>=a=</nowiki>
25397
25398 <nowiki>=a=</nowiki>
25399 !!end
25400
25401 !! test
25402 Headings: 6b. Heading chars in SOL context (with trailing newlines)
25403 !! options
25404 parsoid=html2wt
25405 !! html/parsoid
25406 <p>=a=
25407 b</p>
25408
25409 <p>=a=
25410 b</p>
25411
25412 <p>=a=
25413 b</p>
25414 !! wikitext
25415 <nowiki>=a=</nowiki>
25416 b
25417
25418 <nowiki>=a=</nowiki>
25419 b
25420
25421 <nowiki>=a=</nowiki>
25422 b
25423 !!end
25424
25425 !! test
25426 Headings: 6c. Heading chars in SOL context (leading newline break)
25427 !! options
25428 parsoid=html2wt
25429 !! html/parsoid
25430 <p>a
25431 =b=</p>
25432 !! wikitext
25433 a
25434 <nowiki>=b=</nowiki>
25435 !!end
25436
25437 !! test
25438 Headings: 6d. Heading chars in SOL context (with interspersed comments)
25439 !! options
25440 parsoid=html2wt
25441 !! html/parsoid
25442 <!--c0--><p>=a=</p>
25443
25444 <!--c1--><p>=a=</p> <!--c2--> <!--c3-->
25445 !! wikitext
25446 <!--c0--><nowiki>=a=</nowiki>
25447
25448 <!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3-->
25449 !!end
25450
25451 !! test
25452 Headings: 6d. Heading chars in SOL context (No escaping needed)
25453 !! options
25454 parsoid=html2wt
25455 !! html/parsoid
25456 =a=<div>b</div>
25457 !! wikitext
25458 =a=<div>b</div>
25459 !!end
25460
25461 !! test
25462 Headings: 7. Insert a newline between new content and headings
25463 !! options
25464 parsoid=html2wt
25465 !! html/parsoid
25466 <h2>NEW</h2>
25467 <p>new</p>
25468 <h2 data-parsoid='{}'>A</h2>
25469 <p data-parsoid='{}'>a</p>
25470 !! wikitext
25471 == NEW ==
25472 new
25473
25474 ==A==
25475 a
25476
25477 !! end
25478
25479 !! test
25480 Headings: Used as horizontal rule
25481 !! config
25482 wgFragmentMode=[ 'html5', 'legacy' ]
25483 !! options
25484 parsoid=wt2html
25485 !! wikitext
25486 ===============
25487 !! html/php
25488 <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>
25489
25490 !! html/parsoid
25491 <h6 id="==="><span id=".3D.3D.3D" typeof="mw:FallbackId"></span>===</h6>
25492 !! end
25493
25494 #### --------------- Lists ---------------
25495 #### 0. Outside nests (*foo, etc.)
25496 #### 1. Nested inside html <ul><li>*foo</li></ul>
25497 #### 2. Inside definition lists
25498 #### 3. Only bullets at start should be escaped
25499 #### 4. No escapes needed
25500 #### 5. No unnecessary escapes
25501 #### 6. Escape bullets in SOL position
25502 #### 7. Escape bullets in a multi-line context
25503 #### ----------------------------------------
25504
25505 !! test
25506 Lists: 0. Outside nests
25507 !! options
25508 parsoid=html2wt
25509 !! html/parsoid
25510 <p>*foo</p>
25511
25512 <p>#foo</p>
25513
25514 <p>;Foo:bar</p>
25515 !! wikitext
25516 <nowiki>*</nowiki>foo
25517
25518 <nowiki>#</nowiki>foo
25519
25520 <nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar
25521 !!end
25522
25523 ## Making these next 3 tests Parsoid-only since they are html2wt tests
25524 ## to test wikitext escaping, and insignificant whitespace diffs
25525 ## cause PHP parser tests to barf
25526 !! test
25527 Lists: 1. Nested inside html (No unnecessary escapes)
25528 !! options
25529 parsoid=html2wt
25530 !! html/parsoid
25531 <ul>
25532 <li>*foo</li>
25533 <li>#foo</li>
25534 <li>:foo</li>
25535 <li>;foo</li>
25536 <li data-parsoid='{}'>*foo</li>
25537 <li data-parsoid='{}'>#foo</li>
25538 <li data-parsoid='{}'>:foo</li>
25539 <li data-parsoid='{}'>;foo</li>
25540 </ul>
25541
25542 <ol>
25543 <li>*foo</li>
25544 <li>#foo</li>
25545 <li>:foo</li>
25546 <li>;foo</li>
25547 <li data-parsoid='{}'>*foo</li>
25548 <li data-parsoid='{}'>#foo</li>
25549 <li data-parsoid='{}'>:foo</li>
25550 <li data-parsoid='{}'>;foo</li>
25551 </ol>
25552 !! wikitext
25553 * *foo
25554 * #foo
25555 * :foo
25556 * ;foo
25557 *<nowiki>*foo</nowiki>
25558 *<nowiki>#foo</nowiki>
25559 *<nowiki>:foo</nowiki>
25560 *<nowiki>;foo</nowiki>
25561
25562 # *foo
25563 # #foo
25564 # :foo
25565 # ;foo
25566 #<nowiki>*foo</nowiki>
25567 #<nowiki>#foo</nowiki>
25568 #<nowiki>:foo</nowiki>
25569 #<nowiki>;foo</nowiki>
25570 !!end
25571
25572 !! test
25573 Lists: 2. Inside definition lists
25574 !! options
25575 parsoid=html2wt
25576 !! html/parsoid
25577 <dl><dt>;foo</dt></dl>
25578 <dl><dt>:foo</dt></dl>
25579 <dl><dt>:foo</dt>
25580 <dd>bar</dd></dl>
25581 <dl><dd>:foo</dd></dl>
25582 !! wikitext
25583 ; ;foo
25584
25585 ; <nowiki>:foo</nowiki>
25586
25587 ; <nowiki>:foo</nowiki>
25588 : bar
25589
25590 : :foo
25591 !!end
25592
25593 !! test
25594 Lists: 3. Only bullets at start of text in wikitext-generated HTML should be escaped
25595 !! options
25596 parsoid=html2wt
25597 !! html/parsoid
25598 <ul>
25599 <li>*foo*bar</li>
25600 <li data-parsoid='{}'>*foo<i>it</i>*bar</li>
25601 </ul>
25602 !! wikitext
25603 * *foo*bar
25604 *<nowiki>*foo</nowiki>''it''*bar
25605 !!end
25606
25607 !! test
25608 Lists: 4. No escapes needed
25609 !! options
25610 parsoid=html2wt
25611 !! html/parsoid
25612 <ul>
25613 <li>foo*bar
25614 </li>
25615 </ul>
25616 <ul>
25617 <li><i>foo</i>*bar
25618 </li>
25619 </ul>
25620 <ul>
25621 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>: bar
25622 </li>
25623 </ul>
25624 <ul>
25625 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar
25626 </li>
25627 </ul>
25628 !! wikitext
25629 *foo*bar
25630
25631 *''foo''*bar
25632
25633 *[[Foo]]: bar
25634
25635 *[[Foo]]*bar
25636 !!end
25637
25638 !! test
25639 Lists: 5. No unnecessary escapes
25640 !! options
25641 parsoid=html2wt
25642 !! html/parsoid
25643 <ul><li> bar <span>[[foo]]</span></li></ul>
25644 <ul><li> =bar <span>[[foo]]</span></li></ul>
25645 <ul><li> [[bar <span>[[foo]]</span></li></ul>
25646 <ul><li> ]]bar <span>[[foo]]</span></li></ul>
25647 <ul><li> =bar <span>foo]]</span>=</li></ul>
25648 <ul><li> <s></s>: a</li></ul>
25649 <ul><li> <i>* foo</i></li></ul>
25650
25651 !! wikitext
25652 * bar <span><nowiki>[[foo]]</nowiki></span>
25653
25654 * =bar <span><nowiki>[[foo]]</nowiki></span>
25655
25656 * [[bar <span><nowiki>[[foo]]</nowiki></span>
25657
25658 * ]]bar <span><nowiki>[[foo]]</nowiki></span>
25659
25660 * =bar <span>foo]]</span>=
25661
25662 * <s></s>: a
25663
25664 * ''* foo''
25665 !!end
25666
25667 !! test
25668 Lists: 6. Escape bullets in SOL position
25669 !! options
25670 parsoid=html2wt
25671 !! html/parsoid
25672 <p><!--cmt-->*foo</p>
25673 !! wikitext
25674 <!--cmt--><nowiki>*</nowiki>foo
25675 !!end
25676
25677 !! test
25678 Lists: 7. Escape bullets in a multi-line context
25679 !! options
25680 parsoid=html2wt
25681 !! html/parsoid
25682 <p>a
25683 *b
25684 </p>
25685 !! wikitext
25686 a
25687 <nowiki>*</nowiki>b
25688 !!end
25689
25690 !! test
25691 Lists: 8. Escape colons only if not present in tags
25692 !! options
25693 parsoid=html2wt
25694 !! html/parsoid
25695 <dl><dt>a:b<i>c:d</i></dt></dl>
25696 !! wikitext
25697 ; <nowiki>a:b</nowiki>''c:d''
25698 !! end
25699
25700 #### --------------- HRs ---------------
25701 #### 1. Single line
25702 #### -----------------------------------
25703
25704 !! test
25705 HRs: 1. Single line
25706 !! options
25707 parsoid=html2wt
25708 !! html/parsoid
25709 <hr />----
25710 <hr />=foo=
25711 <hr />*foo
25712 !! wikitext
25713 ----<nowiki>----</nowiki>
25714 ----=foo=
25715 ----*foo
25716 !! end
25717
25718 #### --------------- Tables ---------------
25719 #### 1a. Simple example
25720 #### 1b. No escaping needed (!foo)
25721 #### 1c. No escaping needed (|foo)
25722 #### 1d. No escaping needed (|}foo)
25723 ####
25724 #### 2a. Nested in td (<td>foo|bar</td>)
25725 #### 2b. Nested in td (<td>foo||bar</td>)
25726 #### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
25727 ####
25728 #### 3a. Nested in th (<th>foo!bar</th>)
25729 #### 3b. Nested in th (<th>foo!!bar</th>)
25730 #### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
25731 ####
25732 #### 4a. Escape -
25733 #### 4b. Escape +
25734 #### 4c. No escaping needed
25735 #### --------------------------------------
25736
25737 !! test
25738 Tables: 1a. Simple example
25739 !! options
25740 parsoid=html2wt
25741 !! html/parsoid
25742 <p>{|
25743 |}
25744 </p>
25745 !! wikitext
25746 <nowiki>{|</nowiki>
25747 |}
25748 !! end
25749
25750 !! test
25751 Tables: 1b. No escaping needed
25752 !! options
25753 parsoid=html2wt
25754 !! html/parsoid
25755 <p>!foo
25756 </p>
25757 !! wikitext
25758 !foo
25759 !! end
25760
25761 !! test
25762 Tables: 1c. No escaping needed
25763 !! options
25764 parsoid=html2wt
25765 !! html/parsoid
25766 <p>|foo
25767 </p>
25768 !! wikitext
25769 |foo
25770 !! end
25771
25772 !! test
25773 Tables: 1d. No escaping needed
25774 !! options
25775 parsoid=html2wt
25776 !! html/parsoid
25777 <p>|}foo
25778 </p>
25779 !! wikitext
25780 |}foo
25781 !! end
25782
25783 !! test
25784 Tables: 2a. Nested in td
25785 !! options
25786 parsoid=html2wt
25787 !! html/parsoid
25788 <table><tbody><tr>
25789 <td>foo|bar</td></tr>
25790 <tr><td>x<div>a|b</div></td>
25791 </tbody></table>
25792 !! wikitext
25793 {|
25794 |<nowiki>foo|bar</nowiki>
25795 |-
25796 |x<div><nowiki>a|b</nowiki></div>
25797 |}
25798 !! html/php+tidy
25799 <table>
25800 <tbody><tr>
25801 <td>foo|bar
25802 </td></tr>
25803 <tr>
25804 <td>x<div>a|b</div>
25805 </td></tr></tbody></table>
25806 !! end
25807
25808 !! test
25809 Tables: 2b. Nested in td
25810 !! options
25811 parsoid=html2wt
25812 !! html/parsoid
25813 <table><tbody><tr>
25814 <td>foo||bar</td>
25815 <td>a<i>b||c</i></td>
25816 <td>a<i><div>b||c</div></i></td>
25817 </tr></tbody></table>
25818 !! wikitext
25819 {|
25820 |<nowiki>foo||bar</nowiki>
25821 |a''<nowiki>b||c</nowiki>''
25822 |a''<div><nowiki>b||c</nowiki></div>''
25823 |}
25824 !! html/php
25825 <table>
25826 <tr>
25827 <td>foo||bar
25828 </td>
25829 <td>a<i>b||c</i>
25830 </td>
25831 <td>a<i><div>b||c</div></i>
25832 </td></tr></table>
25833
25834 !! end
25835
25836 !! test
25837 Tables: 2c. Nested in td -- no escaping needed
25838 !! options
25839 parsoid=html2wt
25840 !! html/*
25841 <table>
25842 <tr>
25843 <td>foo!!bar
25844 </td></tr></table>
25845
25846 !! wikitext
25847 {|
25848 |foo!!bar
25849 |}
25850 !! end
25851
25852 !! test
25853 Tables: 3a. Nested in th
25854 !! options
25855 parsoid=html2wt
25856 !! html/*
25857 <table>
25858 <tr>
25859 <th>foo!bar
25860 </th></tr></table>
25861
25862 !! wikitext
25863 {|
25864 !foo!bar
25865 |}
25866 !! end
25867
25868 !! test
25869 Tables: 3b. Nested in th
25870 !! options
25871 parsoid=html2wt
25872 !! html/parsoid
25873 <table><tbody>
25874 <tr><th>foo!!bar</th>
25875 <th><i>foo|bar</i></th>
25876 <th><i>foo!!bar</i></th>
25877 <th><i><span>foo!!bar</span></i></th>
25878 </tr></tbody></table>
25879 !! wikitext
25880 {|
25881 !<nowiki>foo!!bar</nowiki>
25882 !''<nowiki>foo|bar</nowiki>''
25883 !''<nowiki>foo!!bar</nowiki>''
25884 !''<span><nowiki>foo!!bar</nowiki></span>''
25885 |}
25886 !! html/php
25887 <table>
25888 <tr>
25889 <th>foo!!bar
25890 </th>
25891 <th><i>foo|bar</i>
25892 </th>
25893 <th><i>foo!!bar</i>
25894 </th>
25895 <th><i><span>foo!!bar</span></i>
25896 </th></tr></table>
25897
25898 !! end
25899
25900 !! test
25901 Tables: 3c. Nested in th
25902 !! options
25903 parsoid=html2wt
25904 !! html/parsoid
25905 <table><tbody>
25906 <tr><th>foo||bar</th>
25907 <th><span typeof="mw:Nowiki">foo||bar</span></th>
25908 </tr></tbody></table>
25909 !! wikitext
25910 {|
25911 !<nowiki>foo||bar</nowiki>
25912 !<nowiki>foo||bar</nowiki>
25913 |}
25914 !! html/php
25915 <table>
25916 <tr>
25917 <th>foo||bar
25918 </th>
25919 <th>foo||bar
25920 </th></tr></table>
25921
25922 !! end
25923
25924 !! test
25925 Tables: 4a. Escape -
25926 !! options
25927 parsoid=html2wt
25928 !! html/*
25929 <table>
25930 <tr>
25931 <th>-bar
25932 </th></tr>
25933 <tr>
25934 <td>-bar
25935 </td></tr></table>
25936
25937 !! wikitext
25938 {|
25939 !-bar
25940 |-
25941 |<nowiki>-bar</nowiki>
25942 |}
25943 !! end
25944
25945 !! test
25946 Tables: 4b. Escape +
25947 !! options
25948 parsoid=html2wt
25949 !! html/*
25950 <table>
25951 <tr>
25952 <th>+bar
25953 </th></tr>
25954 <tr>
25955 <td>+bar
25956 </td></tr></table>
25957
25958 !! wikitext
25959 {|
25960 !+bar
25961 |-
25962 |<nowiki>+bar</nowiki>
25963 |}
25964 !! end
25965
25966 !! test
25967 Tables: 4c. No escaping needed
25968 !! options
25969 parsoid=html2wt
25970 !! html/parsoid
25971 <table><tbody>
25972 <tr><td>foo-bar</td><td>foo+bar</td></tr>
25973 <tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
25974 <tr><td>foo
25975 <p>bar|baz
25976 +bar
25977 -bar</p></td></tr>
25978 <tr><td>x
25979 <div>a|b</div></td>
25980 </tbody></table>
25981 !! wikitext
25982 {|
25983 |foo-bar
25984 |foo+bar
25985 |-
25986 |''foo''-bar
25987 |''foo''+bar
25988 |-
25989 |foo
25990 bar|baz
25991 +bar
25992 -bar
25993 |-
25994 |x
25995 <div>a|b</div>
25996 |}
25997 !! html/php
25998 <table>
25999 <tr>
26000 <td>foo-bar
26001 </td>
26002 <td>foo+bar
26003 </td></tr>
26004 <tr>
26005 <td><i>foo</i>-bar
26006 </td>
26007 <td><i>foo</i>+bar
26008 </td></tr>
26009 <tr>
26010 <td>foo
26011 <p>bar|baz
26012 +bar
26013 -bar
26014 </p>
26015 </td></tr>
26016 <tr>
26017 <td>x
26018 <div>a|b</div>
26019 </td></tr></table>
26020
26021 !! end
26022
26023 !! test
26024 Tables: 4d. No escaping needed
26025 !! options
26026 parsoid=html2wt
26027 !! html/parsoid
26028 <table>
26029 <tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
26030 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
26031 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
26032 </tbody></table>
26033 !! wikitext
26034 {|
26035 |[[Foo]]-bar
26036 ||+1
26037 ||-2
26038 |}
26039 !! html/php
26040 <table>
26041 <tr>
26042 <td><a href="/wiki/Foo" title="Foo">Foo</a>-bar
26043 </td>
26044 <td>+1
26045 </td>
26046 <td>-2
26047 </td></tr></table>
26048
26049 !! end
26050
26051 !! test
26052 Tables: 5. Empty table cells should get whitespace to avoid need for nowikis
26053 !! options
26054 parsoid=html2wt
26055 !! html/parsoid
26056 <table><tr><td></td><td align="center" data-parsoid='{"stx":"row"}'></td><td data-parsoid='{"stx":"row"}'></td></tr></table>
26057
26058 <table><tr><td></td><td align="center"></td><td></td></tr></table>
26059
26060 <table><tr><td></td><td align="center" data-parsoid='{"stx":"row", "startTagSrc":"{{!}}{{!}}"}'></td><td data-parsoid='{"stx":"row"}'></td></tr></table>
26061
26062 <table><tr><th></th><th align="center" data-parsoid='{"stx":"row"}'></th><th data-parsoid='{"stx":"row"}'></th></tr></table>
26063 !! wikitext
26064 {|
26065 | || align="center" | ||
26066 |}
26067
26068 {|
26069 |
26070 | align="center" |
26071 |
26072 |}
26073
26074 {|
26075 | {{!}}{{!}} align="center" | ||
26076 |}
26077
26078 {|
26079 ! !! align="center" | !!
26080 |}
26081 !! html/php+tidy
26082 <table>
26083 <tbody><tr>
26084 <td></td>
26085 <td align="center"></td>
26086 <td>
26087 </td></tr></tbody></table>
26088 <table>
26089 <tbody><tr>
26090 <td>
26091 </td>
26092 <td align="center">
26093 </td>
26094 <td>
26095 </td></tr></tbody></table>
26096 <table>
26097 <tbody><tr>
26098 <td></td>
26099 <td align="center"></td>
26100 <td>
26101 </td></tr></tbody></table>
26102 <table>
26103 <tbody><tr>
26104 <th></th>
26105 <th align="center"></th>
26106 <th>
26107 </th></tr></tbody></table>
26108 !! end
26109
26110 !! test
26111 T97430: Don't emit empty nowiki pairs around marker meta tags
26112 !! options
26113 parsoid=html2wt
26114 !! html/parsoid
26115 <p>*This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
26116 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
26117 !! wikitext
26118 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
26119 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
26120 !! end
26121
26122 !! test
26123 Unclosed xmlish element in table line shouldn't eat end delimiters
26124 !! options
26125 parsoid=html2wt
26126 !! html/parsoid
26127 <table>
26128 <tbody><tr><td> &lt;foo</td>
26129 <td> bar></td></tr>
26130 </tbody></table>
26131 !! wikitext
26132 {|
26133 | <foo
26134 | bar>
26135 |}
26136 !! html/php
26137 <table>
26138 <tr>
26139 <td>&lt;foo
26140 </td>
26141 <td>bar&gt;
26142 </td></tr></table>
26143
26144 !! end
26145
26146 #### --------------- Links ----------------
26147 #### 1. Quote marks in link text
26148 #### 2. Wikilinks: Escapes needed
26149 #### 3. Wikilinks: No escapes needed
26150 #### 4. Extlinks: Escapes needed
26151 #### 5. Extlinks: No escapes needed
26152 #### --------------------------------------
26153 !! test
26154 Links 1. WikiLinks: No escapes needed
26155 !! options
26156 parsoid=html2wt
26157 !! html/parsoid
26158 <p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
26159 <a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
26160 <a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
26161 !! wikitext
26162 [[Foo|Foo''boo'']]
26163 [[Foo|[Foobar]]]
26164 [[Foo|x [Foobar] x]]
26165 !! html/php
26166 <p><a href="/wiki/Foo" title="Foo">Foo<i>boo</i></a>
26167 <a href="/wiki/Foo" title="Foo">[Foobar]</a>
26168 <a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
26169 </p>
26170 !! end
26171
26172 !! test
26173 Links 2. WikiLinks: Escapes needed
26174 !! options
26175 parsoid=html2wt
26176 !! html/parsoid
26177 <a href="Foo" rel="mw:WikiLink">Foobar]</a>
26178 <a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
26179 <a href="Foo" rel="mw:WikiLink">[[Bar]]</a>
26180 <a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a>
26181 <a href="Foo" rel="mw:WikiLink">|Bar</a>
26182 <a href="Foo" rel="mw:WikiLink">]]bar</a>
26183 <a href="Foo" rel="mw:WikiLink">[[bar</a>
26184 <a href="Foo" rel="mw:WikiLink">x [[ y</a>
26185 <a href="Foo" rel="mw:WikiLink">x ]] y</a>
26186 <a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a>
26187 !! wikitext
26188 [[Foo|<nowiki>Foobar]</nowiki>]]
26189 [[Foo|x <nowiki>[http://google.com g]</nowiki> x]]
26190 [[Foo|<nowiki>[[Bar]]</nowiki>]]
26191 [[Foo|<nowiki>x [[Bar]] x</nowiki>]]
26192 [[Foo|<nowiki>|Bar</nowiki>]]
26193 [[Foo|<nowiki>]]bar</nowiki>]]
26194 [[Foo|<nowiki>[[bar</nowiki>]]
26195 [[Foo|<nowiki>x [[ y</nowiki>]]
26196 [[Foo|<nowiki>x ]] y</nowiki>]]
26197 [[Foo|<nowiki>x ]] y [[ z</nowiki>]]
26198 !! html/php
26199 <p><a href="/wiki/Foo" title="Foo">Foobar]</a>
26200 <a href="/wiki/Foo" title="Foo">x [http://google.com g] x</a>
26201 <a href="/wiki/Foo" title="Foo">[[Bar]]</a>
26202 <a href="/wiki/Foo" title="Foo">x [[Bar]] x</a>
26203 <a href="/wiki/Foo" title="Foo">|Bar</a>
26204 <a href="/wiki/Foo" title="Foo">]]bar</a>
26205 <a href="/wiki/Foo" title="Foo">[[bar</a>
26206 <a href="/wiki/Foo" title="Foo">x [[ y</a>
26207 <a href="/wiki/Foo" title="Foo">x ]] y</a>
26208 <a href="/wiki/Foo" title="Foo">x ]] y [[ z</a>
26209 </p>
26210 !! end
26211
26212 !! test
26213 Links 3. WikiLinks: No escapes needed
26214 !! options
26215 parsoid=html2wt
26216 !! html/parsoid
26217 <p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
26218 <a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
26219 !! wikitext
26220 [[Foo|[Foobar]]
26221 [[Foo|foo|bar]]
26222 !! html/php
26223 <p><a href="/wiki/Foo" title="Foo">[Foobar</a>
26224 <a href="/wiki/Foo" title="Foo">foo|bar</a>
26225 </p>
26226 !! end
26227
26228 !! test
26229 Links 4. ExtLinks: Escapes needed
26230 !! options
26231 parsoid=html2wt
26232 !! html/parsoid
26233 <p><a rel="mw:ExtLink" href="http://google.com">[google]</a>
26234 <a rel="mw:ExtLink" href="http://google.com">google]</a>
26235 <a rel="mw:ExtLink" href="http://google.com">goog] le</a></p>
26236 <p>[http://google.com]</p>
26237 <p>[http://google.com google]</p>
26238 <p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p>
26239 <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>
26240 !! wikitext
26241 [http://google.com <nowiki>[google]</nowiki>]
26242 [http://google.com <nowiki>google]</nowiki>]
26243 [http://google.com <nowiki>goog] le</nowiki>]
26244
26245 <nowiki>[http://google.com]</nowiki>
26246
26247 <nowiki>[http://google.com google]</nowiki>
26248
26249 [http://google.com<nowiki>]</nowiki>
26250
26251 [{{echo|http://google.com}}<nowiki>]</nowiki>
26252 !! html/php
26253 <p><a rel="nofollow" class="external text" href="http://google.com">[google]</a>
26254 <a rel="nofollow" class="external text" href="http://google.com">google]</a>
26255 <a rel="nofollow" class="external text" href="http://google.com">goog] le</a>
26256 </p><p>[http://google.com]
26257 </p><p>[http://google.com google]
26258 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
26259 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
26260 </p>
26261 !! end
26262
26263 !! test
26264 Links 5. ExtLinks: No escapes needed
26265 !! options
26266 parsoid=html2wt
26267 !! html/parsoid
26268 <p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
26269 <p>[<a ref="mw:ExtLink" href="http://google.com"></a>]</p>
26270 !! wikitext
26271 [http://google.com [google]
26272
26273 [[http://google.com]]
26274 !! html/php
26275 <p><a rel="nofollow" class="external text" href="http://google.com">[google</a>
26276 </p><p>[<a rel="nofollow" class="external autonumber" href="http://google.com">[1]</a>]
26277 </p>
26278 !! end
26279
26280 !! test
26281 Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300)
26282 !! options
26283 parsoid=html2wt
26284 !! html/parsoid
26285 <p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y
26286 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>?x
26287 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>&amp;x
26288 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>'x
26289 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,x
26290 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.x
26291 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
26292 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>:x
26293 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
26294 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>!x
26295 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>=x
26296 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>(x)
26297 <a rel="mw:ExtLink" href="http://example.com(x" data-parsoid='{"stx":"url"}'>http://example.com(x</a>)
26298 </p>
26299 !! wikitext
26300 x<nowiki/>http://example.com<nowiki/>y
26301 http://example.com<nowiki/>?x
26302 http://example.com<nowiki/>&x
26303 http://example.com<nowiki/>'x
26304 http://example.com<nowiki/>,x
26305 http://example.com<nowiki/>.x
26306 http://example.com<nowiki/>;x
26307 http://example.com<nowiki/>:x
26308 http://example.com<nowiki/>;x
26309 http://example.com<nowiki/>!x
26310 http://example.com<nowiki/>=x
26311 http://example.com<nowiki/>(x)
26312 http://example.com(x<nowiki/>)
26313 !! end
26314
26315 !! test
26316 Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
26317 !! options
26318 parsoid=html2wt
26319 !! html/parsoid
26320 <p>x
26321 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>
26322 y
26323 "<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>"
26324 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>)
26325 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>) foo
26326 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,
26327 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, foo
26328 </p>
26329 !! wikitext
26330 x
26331 http://example.com
26332 y
26333 "http://example.com"
26334 (http://example.com)
26335 (http://example.com) foo
26336 http://example.com,
26337 http://example.com, foo
26338 !! html/php
26339 <p>x
26340 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
26341 y
26342 "<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>"
26343 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
26344 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) foo
26345 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
26346 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, foo
26347 </p>
26348 !! end
26349
26350 !! test
26351 Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
26352 !! options
26353 parsoid=html2wt
26354 !! html/parsoid
26355 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\
26356 -<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p>
26357 !! wikitext
26358 http://example.com.,;:!?\
26359 -http://example.com:
26360 !! html/php
26361 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.,;:!?\
26362 -<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
26363 </p>
26364 !! end
26365
26366 !! test
26367 Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
26368 !! options
26369 parsoid=html2wt
26370 !! html/parsoid
26371 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
26372 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
26373 X<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
26374 !! wikitext
26375 RFC 123<nowiki/>4
26376 RFC 123<nowiki/>y
26377 X<nowiki/>RFC 123<nowiki/>y
26378 !! end
26379
26380 !! test
26381 Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
26382 !! options
26383 parsoid=html2wt
26384 !! html/parsoid
26385 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
26386 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
26387 -<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
26388 </p>
26389 !! wikitext
26390 RFC 123?foo
26391 RFC 123&foo
26392 -RFC 123-
26393 !! html/php
26394 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>?foo
26395 <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
26396 -<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>-
26397 </p>
26398 !! end
26399
26400 !! test
26401 Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300)
26402 !! options
26403 parsoid=html2wt
26404 !! html/parsoid
26405 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4
26406 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
26407 X<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
26408 !! wikitext
26409 PMID 123<nowiki/>4
26410 PMID 123<nowiki/>y
26411 X<nowiki/>PMID 123<nowiki/>y
26412 !! end
26413
26414 !! test
26415 Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300)
26416 !! options
26417 parsoid=html2wt
26418 !! html/parsoid
26419 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo
26420 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo
26421 -<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>-
26422 </p>
26423 !! wikitext
26424 PMID 123?foo
26425 PMID 123&foo
26426 -PMID 123-
26427 !! html/php
26428 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>?foo
26429 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>&amp;foo
26430 -<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>-
26431 </p>
26432 !! end
26433
26434 !! test
26435 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300)
26436 !! options
26437 parsoid=html2wt
26438 !! html/parsoid
26439 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
26440 <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
26441 a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
26442 </p>
26443 !! wikitext
26444 ISBN 1234567890<nowiki/>1
26445 ISBN 1234567890<nowiki/>x
26446 a<nowiki/>ISBN 1234567890<nowiki/>b
26447 !! end
26448
26449 !! test
26450 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (T66300)
26451 !! options
26452 parsoid=html2wt
26453 !! html/parsoid
26454 <p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
26455 !! wikitext
26456 -ISBN 1234567890's
26457 !! html/php
26458 <p>-<a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>'s
26459 </p>
26460 !! end
26461
26462 !! test
26463 Links 14. Protect link-like plain text. (Parsoid bug T78425)
26464 !! options
26465 parsoid=html2wt
26466 !! html/*
26467 <p>this is not a link: http://example.com
26468 </p>
26469 !! wikitext
26470 this is not a link: <nowiki>http://example.com</nowiki>
26471 !! end
26472
26473 !! test
26474 Links 15. Link trails can't become link prefixes.
26475 !! options
26476 language=is
26477 parsoid=html2wt
26478 !! html/parsoid
26479 <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>
26480 !! wikitext
26481 [[Söfnuður]]-[[00]]
26482 !! html/php
26483 <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>
26484 </p>
26485 !! end
26486
26487 #### --------------- Quotes ---------------
26488 #### 1. Quotes inside <b> and <i>
26489 #### 2. Link fragments separated by <i> and <b> tags
26490 #### 3. Link fragments inside <i> and <b>
26491 #### 4. No escaping needed
26492 #### --------------------------------------
26493 !! test
26494 1a. Quotes inside <b> and <i>
26495 !! options
26496 parsoid=html2wt
26497 !! html/*
26498 <p><i>'foo'</i>
26499 <i>''foo''</i>
26500 <i>'''foo'''</i>
26501 <i>foo</i>'s
26502 <b>'foo'</b>
26503 <b>''foo''</b>
26504 <b>'''foo'''</b>
26505 <b>foo'<i>bar'</i>baz</b>
26506 <b>foo</b>'s
26507 '<i>foo</i>
26508 <i>foo</i>'
26509 <i>foo'</i>'
26510 '<i>foo</i>'
26511 '<b>foo</b>
26512 <b>foo</b>'
26513 '<b>foo</b>'
26514 <i>fools'<span> errand</span></i>
26515 <i><span>fool</span>'s errand</i>
26516 '<i>foo</i> bar '<i>baz</i>
26517 a|!*#-:;+-~[]{}b'<i>x</i>
26518 </p>
26519 !! wikitext
26520 ''<nowiki/>'foo'''
26521 ''<nowiki>''foo''</nowiki>''
26522 ''<nowiki>'''foo'''</nowiki>''
26523 ''foo''<nowiki/>'s
26524 '''<nowiki/>'foo''''
26525 '''<nowiki>''foo''</nowiki>'''
26526 '''<nowiki>'''foo'''</nowiki>'''
26527 '''foo'<nowiki/>''bar'<nowiki/>''baz'''
26528 '''foo'''<nowiki/>'s
26529 '''foo''
26530 ''foo''<nowiki/>'
26531 ''foo'''<nowiki/>'
26532 '''foo''<nowiki/>'
26533 ''''foo'''
26534 '''foo'''<nowiki/>'
26535 ''''foo'''<nowiki/>'
26536 ''fools'<span> errand</span>''
26537 ''<span>fool</span>'s errand''
26538 '<nowiki/>''foo'' bar '''baz''
26539 a|!*#-:;+-~[]{}b'''x''
26540 !! end
26541
26542 !! test
26543 1b. Quotes inside <b> and <i> with other tags on same line
26544 !! options
26545 parsoid=html2wt
26546 !! html/parsoid
26547 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
26548 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
26549 <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>
26550 <a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" rel="mw:WikiLink" title="Bar">bar</a></i>
26551 '<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>
26552 '<i>foo</i> <div title="name">test</div>
26553 '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
26554 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
26555 <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>
26556 </ol>
26557 !! wikitext
26558 '''a'' foo ''[[bar]]''
26559 ''a''' foo ''[[bar]]''
26560 ''a''' foo '''{{echo|[[bar]]}}'''
26561 [[foo]] x'''[[bar]]''
26562 '''foo'' <ref>test</ref>
26563 '''foo'' <div title="name">test</div>
26564 '''foo'' and <br> bar
26565 <references />
26566 !! end
26567
26568 !! test
26569 2. Link fragments separated by <i> and <b> tags
26570 !! options
26571 parsoid=html2wt
26572 !! html/parsoid
26573 <p>[[<i>foo</i>hello]]</p>
26574 <p>[[<b>foo</b>hello]]</p>
26575 !! wikitext
26576 [[''foo''<nowiki>hello]]</nowiki>
26577
26578 [['''foo'''<nowiki>hello]]</nowiki>
26579 !! end
26580
26581 # FIXME: Escaping one or both of [[ and ]] is also acceptable --
26582 # this is one of the shortcomings of this format
26583 !! test
26584 3. Link fragments inside <i> and <b>
26585 !! options
26586 parsoid=html2wt
26587 !! html/parsoid
26588 <p><i>[[foo</i>]]</p>
26589 <p><b>[[foo</b>]]</p>
26590 !! wikitext
26591 ''[[foo''<nowiki>]]</nowiki>
26592
26593 '''[[foo'''<nowiki>]]</nowiki>
26594 !! end
26595
26596 !! test
26597 4. No escaping needed
26598 !! options
26599 parsoid=html2wt
26600 !! html/parsoid
26601 <p>'<span><i>bar</i></span>'
26602 '<span><b>bar</b></span>'
26603 'a:b'foo
26604 </p>
26605 !! wikitext
26606 '<span>''bar''</span>'
26607 '<span>'''bar'''</span>'
26608 'a:b'foo
26609 !! end
26610
26611 #### ----------- Paragraphs ---------------
26612 #### 1. No unnecessary escapes
26613 #### --------------------------------------
26614
26615 !! test
26616 1. No unnecessary escapes
26617 !! options
26618 parsoid=html2wt
26619 !! html/parsoid
26620 <p>bar <span>[[foo]]</span>
26621 </p><p>=bar <span>[[foo]]</span>
26622 </p><p>[[bar <span>[[foo]]</span>
26623 </p><p>]]bar <span>[[foo]]</span>
26624 </p><p>=bar <span>foo]]</span>=
26625 </p>
26626 !! wikitext
26627 bar <span><nowiki>[[foo]]</nowiki></span>
26628
26629 =bar <span><nowiki>[[foo]]</nowiki></span>
26630
26631 [[bar <span><nowiki>[[foo]]</nowiki></span>
26632
26633 ]]bar <span><nowiki>[[foo]]</nowiki></span>
26634
26635 =bar <span>foo]]</span><nowiki>=</nowiki>
26636 !!end
26637
26638 #### ----------------------- PRE --------------------------
26639 !! test
26640 1. Leading whitespace in SOL context should be escaped
26641 !! options
26642 parsoid=html2wt
26643 !! html/parsoid
26644 <p> a</p>
26645
26646 <p> a</p>
26647
26648 <p> a(tab)</p>
26649
26650 <p> a
26651 <!--cmt-->
26652 a</p>
26653
26654 <p>a
26655 b</p>
26656
26657 <p>a
26658 b</p>
26659
26660 <p>a
26661 b</p>
26662 !! wikitext
26663 <nowiki> </nowiki>a
26664
26665 <nowiki> </nowiki> a
26666
26667 a(tab)
26668
26669 <nowiki> </nowiki> a
26670 <!--cmt-->
26671 <nowiki> </nowiki>a
26672
26673 a
26674 <nowiki> </nowiki>b
26675
26676 a
26677 b
26678
26679 a
26680 b
26681 !! html/php
26682 <p> a
26683 </p><p> a
26684 </p><p> a(tab)
26685 </p><p> a
26686 a
26687 </p><p>a
26688 b
26689 </p><p>a
26690 b
26691 </p><p>a
26692 b
26693 </p>
26694 !! end
26695
26696 !! test
26697 2. Leading whitespace in non-indent-pre contexts should not be escaped
26698 !! options
26699 parsoid=html2wt
26700 !! html/parsoid
26701 <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>
26702 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
26703 <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>
26704 b</span></li>
26705 </ol>
26706 !! wikitext
26707 foo <ref>''a''
26708 b</ref>
26709 <references />
26710 !! end
26711
26712 !! test
26713 3. Leading whitespace in indent-pre suppressing contexts should not be escaped
26714 !! options
26715 parsoid=html2wt
26716 !! html/parsoid
26717 <blockquote>
26718 <p>
26719 a
26720 <span>b</span>
26721 c</p>
26722 </blockquote>
26723 !! wikitext
26724 <blockquote>
26725 a
26726 <span>b</span>
26727 c
26728 </blockquote>
26729 !! end
26730
26731 !! test
26732 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
26733 !! options
26734 parsoid=html2wt
26735 !! html/parsoid
26736 <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>
26737 !! wikitext
26738 [[File:Foobar.jpg|thumb|caption]]
26739 !! end
26740
26741 !! test
26742 5. Nowiki escaping should account for indent-pres
26743 !! options
26744 parsoid=html2wt
26745 !! html/parsoid
26746 <pre>==foo==</pre>
26747 !! wikitext
26748 ==foo==
26749 !! end
26750
26751 !! test
26752 T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
26753 !! options
26754 parsoid=html2wt
26755 !! html/parsoid
26756 <pre>
26757 * foo
26758 * bar
26759 </pre>
26760 !! wikitext
26761 * foo
26762 * bar
26763 !! end
26764
26765 !! test
26766 Whitespace scrubbing in SOL position should account for SOL-sensitive wikitext markup
26767 !! options
26768 parsoid = {
26769 "modes": ["html2wt"],
26770 "scrubWikitext": true
26771 }
26772 !! html/parsoid
26773 <p> foo</p>
26774 <p> %foo</p>
26775 <p> *foo</p>
26776 <p> #foo</p>
26777 <p> =foo=</p>
26778 <p><link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid="{}"> *foo</p>
26779 <p> <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid="{}">*foo</p>
26780 <p> <!--boo-->*foo</p>
26781 <p><!--boo--> *foo</p>
26782 <p><!--a--> <!--b--> <!--c--> <!--d--> <!--e--> foo</p>
26783 <p><!--a--> <!--b--> <!--c--> <!--d--> <!--e--> *foo</p>
26784 !! wikitext
26785 foo
26786
26787 %foo
26788
26789 <nowiki/>*foo
26790
26791 <nowiki/>#foo
26792
26793 <nowiki/>=foo=
26794
26795 [[Category:Foo]]
26796 <nowiki/>*foo
26797
26798 [[Category:Foo]]
26799 <nowiki>*</nowiki>foo
26800
26801 <nowiki/><!--boo-->*foo
26802
26803 <!--boo--><nowiki/>*foo
26804
26805 <!--a--><!--b--><!--c--><!--d--><!--e-->foo
26806
26807 <!--a--><nowiki/><!--b--><!--c--><!--d--><!--e-->*foo
26808 !! end
26809
26810 #### --------------- Behavior Switches --------------------
26811
26812 !! test
26813 1. Valid behavior switches should be escaped
26814 !! options
26815 parsoid=html2wt
26816 !! html/parsoid
26817 __TOC__
26818 <i>__TOC__</i>
26819 !! wikitext
26820 <nowiki>__TOC__</nowiki>
26821 ''<nowiki>__TOC__</nowiki>''
26822 !! end
26823
26824 !! test
26825 2. Invalid behavior switches should not be escaped
26826 !! options
26827 parsoid=html2wt
26828 !! html/parsoid
26829 __TOO__
26830 __|__
26831 !! wikitext
26832 __TOO__
26833 __|__
26834 !! end
26835
26836 # We use indent-pre as an indirect way to test for sol-transparent behavior.
26837 !! test
26838 Behavior switches should be SOL-transparent
26839 !! options
26840 parsoid=html2wt
26841 !! html/parsoid
26842 <meta property="mw:PageProp/toc" />
26843
26844 <!-- this one's bogus -->
26845 <pre>__TOO__</pre>
26846
26847 <pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre>
26848
26849 <meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre>
26850 !! wikitext
26851 __TOC__
26852
26853 <!-- this one's bogus -->
26854 __TOO__
26855
26856 __TOC__ foo
26857
26858 __TOC__
26859 bar
26860 !! end
26861
26862 #### --------------- HTML tags ---------------
26863 #### 1. a tags
26864 #### 2. other tags
26865 #### 3. multi-line html tag
26866 #### 4. extension tags
26867 #### -----------------------------------------
26868 !! test
26869 1. a tags
26870 !! options
26871 parsoid=html2wt
26872 !! html/parsoid
26873 &lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
26874 !! wikitext
26875 <a href="http://google.com">google</a>
26876 !! end
26877
26878 !! test
26879 2. other tags
26880 !! options
26881 parsoid=html2wt
26882 !! html/parsoid
26883 <ul><li> &lt;div&gt;foo&lt;/div&gt;</li>
26884 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
26885 <li> &lt;td&gt;</li></ul>
26886
26887 !! wikitext
26888 * <nowiki><div>foo</div></nowiki>
26889 * <nowiki><div style="color:red">foo</div></nowiki>
26890 * <nowiki><td></nowiki>
26891 !! end
26892
26893 !! test
26894 3. multi-line html tag
26895 !! options
26896 parsoid=html2wt
26897 !! html/parsoid
26898 <p>&lt;div
26899 &gt;foo&lt;/div
26900 &gt;
26901 </p>
26902 !! wikitext
26903 <nowiki><div
26904 >foo</div
26905 ></nowiki>
26906 !! end
26907
26908 !! test
26909 4. extension tags
26910 !! options
26911 parsoid=html2wt
26912 !! html/parsoid
26913 <p>&lt;ref&gt;foo&lt;/ref&gt;
26914 </p><p>&lt;ref&gt;bar
26915 </p><p>baz&lt;/ref&gt;
26916 </p>
26917 !! wikitext
26918 <nowiki><ref>foo</ref></nowiki>
26919
26920 <nowiki><ref>bar</nowiki>
26921
26922 baz<nowiki></ref></nowiki>
26923 !! end
26924
26925 !! test
26926 Parsoid: newline inducing block nodes don't suppress <nowiki>
26927 !! options
26928 parsoid=html2wt
26929 !! html/parsoid
26930 a<h1>foo</h1>
26931 !! wikitext
26932 <nowiki> </nowiki>a
26933
26934 = foo =
26935 !! end
26936
26937 #### --------------- Others ---------------
26938 !! test
26939 Escaping nowikis
26940 !! options
26941 parsoid=html2wt
26942 !! html/parsoid
26943 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
26944 </p>
26945 !! wikitext
26946 &lt;nowiki&gt;foo&lt;/nowiki&gt;
26947 !! end
26948
26949 ## The quote-char in the input is necessary for triggering the bug
26950 !! test
26951 (T54035) Nowiki-escaping should not get tripped by " :" in text
26952 !! options
26953 parsoid=html2wt
26954 !! html/parsoid
26955 <p>foo's bar :</p>
26956 !! wikitext
26957 foo's bar :
26958 !! end
26959
26960 #----------- End of wikitext escaping tests --------------
26961
26962 !! test
26963
26964 Tag-like HTML structures are passed through as text
26965 !! wikitext
26966 <x y>
26967
26968 <x.y>
26969
26970 <x-y>
26971
26972 1>2
26973
26974 x<y
26975
26976 a>b
26977
26978 1<d e>f
26979 !! html
26980 <p>&lt;x y&gt;
26981 </p><p>&lt;x.y&gt;
26982 </p><p>&lt;x-y&gt;
26983 </p><p>1&gt;2
26984 </p><p>x&lt;y
26985 </p><p>a&gt;b
26986 </p><p>1&lt;d e&gt;f
26987 </p>
26988 !! end
26989
26990 !! test
26991 HTML tag with necessary entities in attributes
26992 !! wikitext
26993 <span title="&amp;amp;">foo</span>
26994 !! html
26995 <p><span title="&amp;amp;">foo</span>
26996 </p>
26997 !! end
26998
26999 !! test
27000 HTML tag with 'unnecessary' entity encoding in attributes
27001 !! wikitext
27002 <span title="&amp;">foo</span>
27003 !! html
27004 <p><span title="&amp;">foo</span>
27005 </p>
27006 !! end
27007
27008 !! test
27009 HTML tag with broken attribute value quoting
27010 !! options
27011 parsoid=wt2html,html2html
27012 !! wikitext
27013 <span title="Hello world>Foo</span>
27014 !! html/php
27015 <p><span title="Hello world">Foo</span>
27016 </p>
27017 !! html/parsoid
27018 <p><span title="Hello world">Foo</span></p>
27019 !! end
27020
27021 !! test
27022 Self-closed tag with broken attribute value quoting
27023 !! options
27024 parsoid=wt2html,html2html
27025 !! wikitext
27026 <div title="Hello world />Foo
27027 !! html/php+tidy
27028 <div title="Hello world"></div><p>Foo
27029 </p>
27030 !! html/parsoid
27031 <div title="Hello world " data-parsoid='{"stx":"html","selfClose":true}'></div><p>Foo</p>
27032 !! end
27033
27034 !! test
27035 Table with broken attribute value quoting
27036 !! options
27037 parsoid=wt2html,html2html
27038 !! wikitext
27039 {|
27040 | title="Hello world|Foo
27041 |}
27042 !! html/php
27043 <table>
27044 <tr>
27045 <td title="Hello world">Foo
27046 </td></tr></table>
27047
27048 !! html/parsoid
27049 <table>
27050 <tr>
27051 <td title="Hello world">Foo
27052 </td></tr></table>
27053
27054 !! end
27055
27056 !! test
27057 Table with broken attribute value quoting on consecutive lines
27058 !! options
27059 parsoid=wt2html,html2html
27060 !! wikitext
27061 {|
27062 | title="Hello world|Foo
27063 | style="color:red|Bar
27064 |}
27065 !! html/php
27066 <table>
27067 <tr>
27068 <td title="Hello world">Foo
27069 </td>
27070 <td style="color:red">Bar
27071 </td></tr></table>
27072
27073 !! html/parsoid
27074 <table><tbody>
27075 <tr>
27076 <td title="Hello world">Foo
27077 </td><td style="color: red">Bar
27078 </td></tr></tbody></table>
27079
27080 !! end
27081
27082 !!test
27083 Accept empty td cell attribute
27084 !! wikitext
27085 {|
27086 | align="center" |foo|| |
27087 |}
27088 !! html
27089 <table>
27090 <tr>
27091 <td align="center">foo</td>
27092 <td>
27093 </td></tr></table>
27094
27095 !!end
27096
27097 !!test
27098 Non-empty attributes in th-cells
27099 !! wikitext
27100 {|
27101 !Foo!! style="color: red" |Bar
27102 |}
27103 !! html
27104 <table>
27105 <tr>
27106 <th>Foo</th>
27107 <th style="color: red">Bar
27108 </th></tr></table>
27109
27110 !!end
27111
27112 !!test
27113 Accept empty attributes in th-cells
27114 !! wikitext
27115 {|
27116 !|foo!!|bar
27117 |}
27118 !! html
27119 <table>
27120 <tr>
27121 <th>foo</th>
27122 <th>bar
27123 </th></tr></table>
27124
27125 !!end
27126
27127 !!test
27128 Empty table rows go away
27129 !! wikitext
27130 {|
27131 |Hello
27132 |there
27133 |- class="foo"
27134 |-
27135 |}
27136 !! html
27137 <table>
27138 <tr>
27139 <td>Hello
27140 </td>
27141 <td>there
27142 </td></tr>
27143
27144 </table>
27145
27146 !! end
27147
27148 ###
27149 ### Parsoid-centric tests for testing RTing of inter-element separators
27150 ### Edge cases not tested by existing parser tests and specific to
27151 ### Parsoid-specific serialization strategies.
27152 ###
27153
27154 !!test
27155 RT-ed inter-element separators should be valid separators
27156 !! wikitext
27157 {|
27158 |- [[foo]]
27159 |}
27160 !! html/php
27161 <table>
27162
27163 </table>
27164
27165 !! html/parsoid
27166 <table>
27167 <tbody><tr class='mw-empty-elt' data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
27168 </tbody></table>
27169 !!end
27170
27171 # Parsoid-only test of a DOM pass
27172 !!test
27173 Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out
27174 !! wikitext
27175 {|
27176 |<small>foo
27177 bar
27178 |}
27179
27180 {|
27181 |<small>foo<small>
27182 |}
27183 !! html/parsoid
27184 <table>
27185 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo
27186 <p>bar</p></small></td></tr>
27187 </tbody></table>
27188
27189 <table>
27190 <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>
27191 </tbody></table>
27192 !!end
27193
27194 # Note that the "style" attribute is really a template parameter here.
27195 # The = would have to be {{=}} if you wanted the literal.
27196 !!test
27197 Empty TD followed by TD with tpl-generated attribute
27198 !! wikitext
27199 {|
27200 |-
27201 |
27202 |{{echo|style='color:red'}}|foo
27203 |}
27204 !! html
27205 <table>
27206
27207 <tr>
27208 <td>
27209 </td>
27210 <td>foo
27211 </td></tr></table>
27212
27213 !!end
27214
27215 !!test
27216 Indented table with an empty td
27217 !! wikitext
27218 {|
27219 |-
27220 |
27221 |foo
27222 |}
27223 !! html
27224 <table>
27225
27226 <tr>
27227 <td>
27228 </td>
27229 <td>foo
27230 </td></tr></table>
27231
27232 !!end
27233
27234 ## We have some newline diffs RT-ing this edge case
27235 ## and it is not important enough -- we seem to be emitting
27236 ## at most 2 newlines after a </tr> and this is unrelated to
27237 ## the issue from T85627 that this is testing.
27238 !!test
27239 Indented table with blank lines in between (T85627)
27240 !! options
27241 parsoid=wt2html
27242 !! wikitext
27243 {|
27244 |foo
27245
27246
27247 |}
27248 !! html
27249 <table>
27250
27251 <tr>
27252 <td>foo
27253 </td></tr></table>
27254
27255 !!end
27256
27257 !!test
27258 Indented block & table
27259 !! wikitext
27260 <div>foo</div>
27261 {|
27262 |foo
27263 |}
27264 !! html/php
27265 <div>foo</div>
27266 <table>
27267 <tr>
27268 <td>foo
27269 </td></tr></table>
27270
27271 !! html/parsoid
27272 <div data-parsoid='{"stx":"html"}'>foo</div>
27273 <table><tbody>
27274 <tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>foo</td></tr>
27275 </tbody></table>
27276 !!end
27277
27278 !! test
27279 Indent and comment before table row
27280 !! wikitext
27281 {|
27282 <!--hi-->|-
27283 |there
27284 |}
27285 !! html/php
27286 <table>
27287
27288 <tr>
27289 <td>there
27290 </td></tr></table>
27291
27292 !! html/parsoid
27293 <table>
27294 <!--hi--><tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
27295 <td data-parsoid='{"autoInsertedEnd":true}'> there</td></tr>
27296 </tbody></table>
27297 !! end
27298
27299 # Parsoid-specific since PHP parser doesn't handle this mixed tbl-wikitext
27300 !!test
27301 Empty TR followed by a template-generated TR
27302 !!options
27303 parsoid
27304 !! wikitext
27305 {|
27306 |-
27307 {{echo|<tr><td>foo</td></tr>}}
27308 |}
27309 !! html
27310 <table>
27311 <tbody>
27312 <tr class='mw-empty-elt'></tr>
27313 <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}}]}'>
27314 <td>foo</td></tr>
27315 </tbody></table>
27316 !!end
27317
27318 ## PHP and parsoid output differ for this, and since this is primarily
27319 ## for testing Parsoid's serializer, marking this Parsoid only
27320 !!test
27321 Empty TR followed by mixed-ws-comment line should RT correctly
27322 !!options
27323 parsoid
27324 !! wikitext
27325 {|
27326 |-
27327 <!--c-->
27328 |-
27329 <!--c--> <!--d-->
27330 |}
27331 !! html
27332 <table>
27333 <tbody>
27334 <tr class='mw-empty-elt'></tr>
27335 <!--c-->
27336 <tr>
27337 <!--c--> </tr><!--d-->
27338 </tbody></table>
27339
27340 !!end
27341
27342 !!test
27343 Multi-line image caption generated by templates with/without trailing newlines
27344 !! wikitext
27345 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]]
27346 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]]
27347 !! html/parsoid
27348 <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>
27349 <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>
27350 !!end
27351
27352 !! test
27353 New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly
27354 !! options
27355 parsoid=html2wt
27356 !! html/parsoid
27357 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>foo&lt;/includeonly>"}'/><meta typeof="mw:Includes/IncludeOnly/End" data-parsoid='{"src":""}'/><p>new para</p>
27358
27359 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{}'/><h1>new heading</h1>
27360 !! wikitext
27361 <includeonly>foo</includeonly>
27362 new para
27363
27364 [[Category:Foo]]
27365
27366 = new heading =
27367 !! end
27368
27369 ## PHP emits broken html for this, and since this is primarily
27370 ## a Parsoid serializer test, marking this Parsoid only
27371 !!test
27372 Improperly nested inline or quotes tags with whitespace in between
27373 !! wikitext
27374 <span> <s>x</span> </s>
27375 ''' ''x''' ''
27376 !! html/parsoid
27377 <p><span> <s>x</s></span><s> </s>
27378 <b> <i>x</i></b><i> </i>
27379 </p>
27380 !!end
27381
27382 !!test
27383 Encapsulate protected attributes from wt
27384 !! wikitext
27385 <div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
27386
27387 {| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true"
27388 |ok
27389 |}
27390 !! html/parsoid
27391 <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>
27392
27393 <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">
27394 <tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'>ok</td></tr>
27395 </tbody></table>
27396 !!end
27397
27398 ## Currently the p-wrapper is fragile in how it adds / removes transformations.
27399 ## Having nested or stray pre tags results in the attempt to add duplicates,
27400 ## causing an assertion fail. This test tries to prevent that situation.
27401 !!test
27402 Ensure ParagraphWrapper can deal with stray closing pre tags
27403 !!options
27404 parsoid=wt2html
27405 !! wikitext
27406 plain text</pre>
27407 !! html/parsoid
27408 plain text
27409 !!end
27410
27411 !! test
27412 1. Ensure fostered text content is wrapped in element nodes
27413 !! options
27414 parsoid=wt2html
27415 !! wikitext
27416 <table>hi</table><table>ho</table>
27417 !! html/php+tidy
27418 hi<table></table>ho<table></table>
27419 !! html/parsoid
27420 <span data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>hi</span><table data-parsoid='{"stx":"html"}'></table><span data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>ho</span><table data-parsoid='{"stx":"html"}'></table>
27421 !! end
27422
27423 !! test
27424 2. Ensure fostered text content is wrapped in element nodes (traps regressions around fostered marker on the element getting lost)
27425 !! options
27426 parsoid=wt2html,wt2wt
27427 !! wikitext
27428 <table>
27429 <tr> || ||
27430 <td> a
27431 </table>
27432 !! html/php+tidy
27433 || ||
27434 <table>
27435 <tbody><tr><td> a
27436 </td></tr></tbody></table>
27437 !! html/parsoid
27438 <span data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'> || ||
27439 </span><table data-parsoid='{"stx":"html"}'>
27440 <tbody><tr data-parsoid='{"stx":"html","autoInsertedEnd":true}'><td data-parsoid='{"stx":"html","autoInsertedEnd":true}'> a
27441 </td></tr></tbody></table>
27442 !! end
27443
27444 !! test
27445 Encapsulation properly handles null DSR information from foster box
27446 !! options
27447 parsoid=wt2html,wt2wt
27448 !! wikitext
27449 {{echo|<table>foo<tr><td>bar</td></tr></table>}}
27450 !! html/parsoid
27451 <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;<table>foo<tr><td>bar</td></tr></table>&quot;}},&quot;i&quot;:0}}]}">foo</span><table><tbody><tr><td>bar</td></tr></tbody></table>
27452 !! end
27453
27454 !! test
27455 1. Encapsulate foster-parented transclusion content
27456 !! options
27457 parsoid=wt2wt,wt2html
27458 !! wikitext
27459 <table>{{echo|foo<tr><td>bar</td></tr>}}</table>
27460 !! html/php+tidy
27461 foo<table><tbody><tr><td>bar</td></tr></tbody></table>
27462 !! html/parsoid
27463 <span 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</span><table about="#mwt2" data-parsoid='{"stx":"html}'><tbody><tr><td>bar</td></tr></tbody></table>
27464 !! end
27465
27466 !! test
27467 2. Encapsulate foster-parented transclusion content
27468 !! options
27469 parsoid=wt2wt,wt2html
27470 !! wikitext
27471 <table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table>
27472 !! html/parsoid
27473 <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>
27474 <table>
27475 <tbody>
27476 <tr>
27477 <td>bar</td>
27478 </tr>
27479 </tbody>
27480 </table>
27481 !! end
27482
27483 !! test
27484 3. Encapsulate foster-parented transclusion content
27485 !! options
27486 parsoid=wt2wt,wt2html
27487 !! wikitext
27488 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
27489 !! html/parsoid
27490 <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;]}">
27491 <p>foo</p>
27492 </div>
27493 <table>
27494 <tbody>
27495 <tr>
27496 <td>bar</td>
27497 </tr>
27498 </tbody>
27499 </table>
27500 !! end
27501
27502 !! test
27503 4. Encapsulate foster-parented transclusion content
27504 !! options
27505 parsoid=wt2wt,wt2html
27506 !! wikitext
27507 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
27508 !! html/parsoid
27509 <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;]}">
27510 <p>foo</p>
27511 </div>
27512 <table>
27513 <tbody>
27514 <tr>
27515 <td>bar</td>
27516 </tr>
27517 </tbody>
27518 </table>
27519 !! end
27520
27521 !! test
27522 5. Encapsulate foster-parented transclusion content
27523 !!options
27524 parsoid=wt2wt,wt2html
27525 !! wikitext
27526 <table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table>
27527 !! html/php+tidy
27528 foo<table><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table>
27529 !! html/parsoid
27530 <span 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</span><table about="#mwt2" data-parsoid='{"stx":"html"}'><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table>
27531 !! end
27532
27533 !! test
27534 6. Encapsulate foster-parented transclusion content
27535 !! options
27536 parsoid=wt2wt,wt2html
27537 !! wikitext
27538 <table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p>
27539 !! html/php+tidy
27540 foo<table><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table><p>ok</p>
27541 !! html/parsoid
27542 <span 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</span><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>
27543 !! end
27544
27545 !! test
27546 7. Encapsulate foster-parented transclusion content
27547 !!options
27548 parsoid=wt2wt,wt2html
27549 !! wikitext
27550 <table>{{echo|<p>foo</p>}}<td>bar</td></table>
27551 !! html/parsoid
27552 <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>
27553 <table>
27554 <tbody>
27555 <tr>
27556 <td>bar</td>
27557 </tr>
27558 </tbody>
27559 </table>
27560 !! end
27561
27562 # Note that the wt is broken on purpose: the = should be {{=}} if you
27563 # don't want it to be a template parameter key.
27564 !! test
27565 8. Encapsulate foster-parented transclusion content
27566 !! options
27567 parsoid=wt2wt,wt2html
27568 !! wikitext
27569 {{echo|a
27570 }}{|{{echo|style='color:red'}}
27571 |-
27572 |b
27573 |}
27574 !! html/php+tidy
27575 <p>a
27576 </p>
27577 <table>
27578
27579 <tbody><tr>
27580 <td>b
27581 </td></tr></tbody></table>
27582 !! html/parsoid
27583 <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">
27584 </span><span 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}}}</span><table about="#mwt3">
27585 <tbody><tr>
27586 <td>b
27587 </td></tr></tbody></table>
27588 !! end
27589
27590 !! test
27591 9. Encapsulate foster-parented transclusion content
27592 !!options
27593 parsoid=wt2wt,wt2html
27594 !! wikitext
27595 <table>{{echo|hi</table>hello}}
27596 !! html/php+tidy
27597 hi<table></table><p>hello
27598 </p>
27599 !! html/parsoid
27600 <span 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</span><table about="#mwt2"></table><p about="#mwt2">hello</p>
27601 !! end
27602
27603 !! test
27604 Table in fosterable position
27605 !!options
27606 parsoid=wt2html
27607 !! wikitext
27608 {{OpenTable}}
27609 <div>
27610 {|
27611 |}
27612 </div>
27613 |}
27614 !! html/parsoid
27615 <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">
27616 </span>
27617 <table about="#mwt1" data-parsoid='{"autoInsertedEnd":true}'></table>
27618
27619 <table>
27620 </table>
27621 !! end
27622
27623 # Parsoid only for T66747
27624 !! test
27625 Properly encapsulate empty-content transclusions in fosterable positions
27626 !! wikitext
27627 <table>
27628 {{#if:|
27629 <td>foo</td>
27630 }}
27631 </table>
27632 !! html/parsoid
27633 <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"}]]}'>
27634
27635 </table>
27636 !! end
27637
27638 !! test
27639 Always encapsulate foster box when template range is expanded to table
27640 !! options
27641 parsoid=wt2wt
27642 !! wikitext
27643 {|
27644 hello
27645 {{OpenTable}}
27646 |}
27647 !! html/parsoid
27648
27649 !! end
27650
27651 !! test
27652 T115289: Unclosed table
27653 !! wikitext
27654 {{echo|<table>}}<!--c-->[[Category:Two]]
27655 !! html/parsoid
27656 <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>
27657 !! end
27658
27659 !! test
27660 T115289: Don't migrate newlines out of tables with fostered content
27661 !! wikitext
27662 <table><td></td>{{echo|<tr>[[Category:One]]}}<!--c-->[[Category:Two]]
27663 !! html/parsoid
27664 <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>
27665 !! end
27666
27667 !! test
27668 T73074: More fostering fun
27669 !! wikitext
27670 <table><td></td>{{echo|<tr>}}<!--c-->[[Category:Two]]
27671 !! html/parsoid
27672 <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>
27673 !! end
27674
27675 !!test
27676 Support <object> element with .data attribute
27677 !!options
27678 parsoid=html2wt
27679 !! html/parsoid
27680 <object data="test.swf"></object>
27681 !! wikitext
27682 <object data="test.swf"></object>
27683 !!end
27684
27685 !! test
27686 Don't block XML namespace declaration
27687 !! wikitext
27688 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span>
27689 !! html/php
27690 <p><span xmlns:dct="http&#58;//purl.org/dc/terms/" property="dct:title">MediaWiki</span>
27691 </p>
27692 !! html/parsoid
27693 <p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p>
27694 !! end
27695
27696 # -----------------------------------------------------------------
27697 # The following section of tests are primarily to spec requirements
27698 # around Parsoid's serialization (old, new, edited content)
27699 #
27700 # All these tests are marked Parsoid html2wt and html2html only
27701 # ----------------------------------------------------------------
27702
27703 !! test
27704 Ignore rel attribute in a-tags during serialization to url-links
27705 !! options
27706 parsoid=html2wt
27707 !! html/parsoid
27708 <a href='http://en.wikipedia.org/wiki/Foobar'>http://en.wikipedia.org/wiki/Foobar</a>
27709 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:ExtLink'>http://en.wikipedia.org/wiki/Foobar</a>
27710 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:WikiLink'>http://en.wikipedia.org/wiki/Foobar</a>
27711 !! wikitext
27712 http://en.wikipedia.org/wiki/Foobar
27713 http://en.wikipedia.org/wiki/Foobar
27714 http://en.wikipedia.org/wiki/Foobar
27715 !! end
27716
27717 # 'mi' is a localinterwiki prefix as well as a language
27718 !! test
27719 Serialize interwiki links pointing to the current wiki as plain wiki links (T67869)
27720 !! options
27721 parsoid=html2wt
27722 !! html/parsoid
27723 <p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p>
27724 !! wikitext
27725 [[Foo]]
27726 !! end
27727
27728 !! test
27729 Parsoid should accept interwiki shortcuts
27730 !! options
27731 parsoid=html2wt
27732 !! html/parsoid
27733 <p><a rel='mw:WikiLink' href='./fr:Foo'>Foo</a>
27734 <a rel='mw:ExtLink' href='./fr:Foo'>Foo</a>
27735 <a href='./fr:Foo'>Foo</a></p>
27736 <p><a rel='mw:WikiLink' href='fr%3AFoo'>Foo</a>
27737 <a rel='mw:ExtLink' href='fr%3AFoo'>Foo</a>
27738 <a href='fr%3AFoo'>Foo</a></p>
27739 <p><a href='FR%3AFoo'>Foo</a>
27740 <a href='./FR:Foo'>Foo</a></p>
27741 !! wikitext
27742 [[:fr:Foo|Foo]]
27743 [[:fr:Foo|Foo]]
27744 [[:fr:Foo|Foo]]
27745
27746 [[:fr:Foo|Foo]]
27747 [[:fr:Foo|Foo]]
27748 [[:fr:Foo|Foo]]
27749
27750 [[:fr:Foo|Foo]]
27751 [[:fr:Foo|Foo]]
27752 !! end
27753
27754 !! test
27755 Parsoid should not accept invalid interwiki shortcuts
27756 !! options
27757 parsoid=html2wt
27758 !! html/parsoid
27759 <p><a rel='mw:WikiLink' href='news:Foo'>Foo</a>
27760 <a rel='mw:ExtLink' href='news:Foo'>Foo</a>
27761 <a href='news:Foo'>Foo</a></p>
27762 !! wikitext
27763 [news:Foo Foo]
27764 [news:Foo Foo]
27765 [news:Foo Foo]
27766 !! end
27767
27768 # See T93839
27769 !! test
27770 New wikilinks should be serialized properly
27771 !! options
27772 parsoid=html2wt
27773 !! html/parsoid
27774 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
27775 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
27776 <a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a>
27777 <a href="http://en.wikipedia.org/wiki/Foo">http://en.wikipedia.org/wiki/Foo</a>
27778 <a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a>
27779 !! wikitext
27780 [[Foo]]
27781 [[Foo]]
27782 [[:en:Foo|//en.wikipedia.org/wiki/Foo]]
27783 http://en.wikipedia.org/wiki/Foo
27784 [[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]]
27785 !! end
27786
27787 !! test
27788 New wiki links (href variations)
27789 !! options
27790 parsoid=html2wt
27791 !! html/parsoid
27792 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
27793 <a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a>
27794 <a rel="mw:WikiLink" href="Foo bar">Foo_bar</a>
27795 <a rel="mw:WikiLink" href="./Toxine_bact%C3%A9rienne">Toxine bactérienne</a>
27796 !! wikitext
27797 [[Foo_bar]]
27798 [[Foo_bar]]
27799 [[Foo_bar]]
27800 [[Toxine bactérienne]]
27801 !! end
27802
27803 !! test
27804 New wiki links (content string variations)
27805 !! options
27806 parsoid=html2wt
27807 !! html/parsoid
27808 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
27809 <a rel="mw:WikiLink" href="./Foo_bar">Foo bar</a>
27810 <a rel="mw:WikiLink" href="./Foo_bar">./Foo_bar</a>
27811 !! wikitext
27812 [[Foo_bar]]
27813 [[Foo bar]]
27814 [[Foo_bar|./Foo_bar]]
27815 !! end
27816
27817 !! test
27818 New category links (href variations)
27819 !! options
27820 parsoid=html2wt
27821 !! html/parsoid
27822 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" />
27823 <link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" />
27824 <link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" />
27825 !! wikitext
27826 [[Category:Toxine bactérienne]]
27827 [[Category:Toxine bactérienne]]
27828 [[Category:Toxine bactérienne]]
27829 !! end
27830
27831 !! test
27832 New sol transparent links don't need indent-pre nowiki protection
27833 !! options
27834 parsoid=html2wt
27835 language=de
27836 !! html/parsoid
27837 <link rel="mw:PageProp/redirect" href="./Main_Page">
27838 <!-- this is good --> <link rel="mw:PageProp/Category" href="./Category:Good" />
27839 <!-- this is great --> <link rel="mw:PageProp/Category" href="./Kategorie:Great" />
27840 !! wikitext
27841 #WEITERLEITUNG [[Main Page]]
27842 <!-- this is good --> [[Category:Good]]
27843 <!-- this is great --> [[Kategorie:Great]]
27844 !! end
27845
27846 !! test
27847 New interlanguage links (href variations)
27848 !! options
27849 parsoid=html2wt
27850 !! html/parsoid
27851 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" />
27852 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" />
27853 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" />
27854 !! wikitext
27855 [[es:Toxine bactérienne]]
27856 [[es:Toxine_bactérienne]]
27857 [[es:Toxine_bactérienne]]
27858 !! end
27859
27860 !! test
27861 Image: Modifying size of an image (1)
27862 !! options
27863 parsoid={
27864 "modes": ["wt2wt"],
27865 "changes": [
27866 ["img[height]", "attr", "height", "22"],
27867 ["img[width]", "attr", "width", "200"]
27868 ]
27869 }
27870 !! wikitext
27871 [[Image:Foobar.jpg|230x230px]]
27872 !! wikitext/edited
27873 [[Image:Foobar.jpg|200x200px]]
27874 !!end
27875
27876 !! test
27877 Image: Modifying size of an image (2)
27878 !! options
27879 parsoid={
27880 "modes": ["wt2wt"],
27881 "changes": [
27882 ["img[height]", "attr", "height", "100"],
27883 ["img[width]", "attr", "width", "500"]
27884 ]
27885 }
27886 !! wikitext
27887 [[Image:Foobar.jpg|230x230px]]
27888 !! wikitext/edited
27889 [[Image:Foobar.jpg|500x500px]]
27890 !!end
27891
27892 # Change in size is ignored so long as class='mw-default-size'
27893 !! test
27894 Image: Modifying size of an image (3)
27895 !! options
27896 parsoid={
27897 "modes": ["wt2wt"],
27898 "changes": [
27899 ["figure[class]", "removeClass", "mw-default-size"],
27900 ["figure img", "attr", "height", "19"],
27901 ["figure img", "attr", "width", "170"]
27902 ]
27903 }
27904 !! wikitext
27905 [[Image:Foobar.jpg|thumb]]
27906 !! wikitext/edited
27907 [[Image:Foobar.jpg|thumb|170x170px]]
27908 !!end
27909
27910 !! test
27911 Image: Modifying alignment of an image (T50665)
27912 !! options
27913 parsoid={
27914 "modes": ["wt2wt"],
27915 "changes": [
27916 ["figure[class]", "removeClass", "mw-halign-right"],
27917 ["figure[class]", "addClass", "mw-halign-left"]
27918 ]
27919 }
27920 !! wikitext
27921 [[Image:Foobar.jpg|thumb|caption|right]]
27922 !! wikitext/edited
27923 [[Image:Foobar.jpg|thumb|caption|left]]
27924 !! end
27925
27926 !! test
27927 Image: Modifying mw-default-size of an frameless image (T64805)
27928 !! options
27929 parsoid={
27930 "modes": ["wt2wt"],
27931 "changes": [
27932 ["figure.mw-default-size", "removeClass", "mw-default-size"]
27933 ]
27934 }
27935 !! wikitext
27936 [[Image:Foobar.jpg|frameless|right]]
27937 !! wikitext/edited
27938 [[Image:Foobar.jpg|frameless|right|220x220px]]
27939 !! end
27940
27941 !! test
27942 Image: Modifying valign of an image (T51221)
27943 !! options
27944 parsoid={
27945 "modes": ["wt2wt"],
27946 "changes": [
27947 ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
27948 ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
27949 ]
27950 }
27951 !! wikitext
27952 [[File:Foobar.jpg|20px|middle]]
27953 !! wikitext/edited
27954 [[File:Foobar.jpg|20px|text-top]]
27955 !! end
27956
27957 !! test
27958 Image: Modifying alt attribute of an image (T58400)
27959 !! options
27960 parsoid={
27961 "modes": ["wt2wt"],
27962 "changes": [
27963 ["img[alt]", "attr", "alt", "some alternate edited text"]
27964 ]
27965 }
27966 !! wikitext
27967 [[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
27968 !! wikitext/edited
27969 [[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
27970 !!end
27971
27972 !! test
27973 Image: Modifying caption of an image
27974 !! options
27975 parsoid={
27976 "modes": ["wt2wt"],
27977 "changes": [
27978 ["figcaption", "text", "new caption"]
27979 ]
27980 }
27981 !! wikitext
27982 [[Image:Foobar.jpg|thumb|original caption]]
27983 !! wikitext/edited
27984 [[Image:Foobar.jpg|thumb|new caption]]
27985 !!end
27986
27987 !! test
27988 Image: empty alt attribute (T50924)
27989 !! options
27990 parsoid
27991 !! wikitext
27992 [[File:Foobar.jpg|thumb|alt=|bar]]
27993 !! html
27994 <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>
27995 !! end
27996
27997 !! test
27998 Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
27999 !! options
28000 parsoid=html2wt
28001 language=ar
28002 disabled
28003 !! html/parsoid
28004 <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>
28005 !! wikitext
28006 [[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
28007 !! end
28008
28009 !! test
28010 Image: Block level image should have \n before and after
28011 !! wikitext
28012 123
28013 [[File:Foobar.jpg|right|thumb|150x150px]]
28014 456
28015 !! html/parsoid
28016 <p>123</p>
28017 <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>
28018 <p>456</p>
28019 !! end
28020
28021 !! test
28022 Image: New block level image should have \n before and after (existing content)
28023 !! wikitext
28024 123
28025 [[File:Foobar.jpg|right|thumb|150x150px]]
28026 456
28027 !! html/parsoid
28028 <p>123</p>
28029 <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>
28030 <p>456</p>
28031 !! end
28032
28033 !! test
28034 Image: upright option (parsoid)
28035 !! wikitext
28036 [[File:Foobar.jpg|thumb|upright|caption]]
28037 [[File:Foobar.jpg|thumb|upright=0.5|caption]]
28038 [[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]]
28039 !! html/parsoid
28040 <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>
28041 <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>
28042 <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>
28043 !! end
28044
28045 !! test
28046 Image: upright option is ignored on inline and frame images (parsoid)
28047 !! wikitext
28048 [[File:Foobar.jpg|500x500px|upright=0.5|caption]]
28049 !! html/parsoid
28050 <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>
28051 !! end
28052
28053 !! test
28054 Image: in template parameter with empty parameter
28055 !! wikitext
28056 {{echo|[[File:Foobar.jpg|link=]]}}
28057 !! html/parsoid
28058 <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>
28059 !! end
28060
28061 !! test
28062 Image: from basic HTML (1)
28063 !! options
28064 parsoid=html2wt
28065 !! html/parsoid
28066 <span typeof="mw:Image">
28067 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
28068 </span>
28069 !! wikitext
28070 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
28071 !! end
28072
28073 !! test
28074 Image: from basic HTML (2)
28075 !! options
28076 parsoid=html2wt
28077 !! html/parsoid
28078 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
28079 !! wikitext
28080 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
28081 !! end
28082
28083 !! test
28084 Image: from basic HTML (3)
28085 !! options
28086 parsoid=html2wt
28087 !! html/parsoid
28088 <a href="Main"><img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"></a>
28089 !! wikitext
28090 [[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
28091 !! end
28092
28093 !! test
28094 Image: from basic HTML (4)
28095 !! options
28096 parsoid=html2wt
28097 !! html/parsoid
28098 <img src="./File:Foobar.jpg">
28099 !! wikitext
28100 [[File:Foobar.jpg|link=]]
28101 !! end
28102
28103 !! test
28104 Image: Invalid title as link
28105 !! wikitext
28106 [[File:Foobar.jpg|link=<]]
28107 !! html/php
28108 <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>
28109 </p>
28110 !! html/parsoid
28111 <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>
28112 !! end
28113
28114 !! test
28115 Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
28116 !! options
28117 parsoid=html2wt
28118 !! html/parsoid
28119 <ul>
28120 <li><p>foo</p></li>
28121 </ul>
28122 !! wikitext
28123 * foo
28124 !! end
28125
28126 !! test
28127 Lists: Serialize correctly even when list tags has unneeded whitespace between tags
28128 !! options
28129 parsoid=html2wt
28130 !! html/parsoid
28131 <ul> <li>foo</li></ul>
28132 !! wikitext
28133 * foo
28134 !! end
28135
28136 !! test
28137 Don't strip leading whitespace when handling indent-pre suppressing tags
28138 !! options
28139 parsoid=html2wt
28140 !! html/parsoid
28141 <table>
28142 <tr><td> indented row</td></tr>
28143 </table>
28144 <blockquote><p>
28145 <b>This is very bold of you!</b>
28146 </p>
28147 <table><tr><td>
28148 indented cell (no pre-wrapping!)
28149 </td></tr></table>
28150 </blockquote>
28151 <p>foo</p>
28152 <div>bar</div>
28153 !! wikitext
28154 {|
28155 | indented row
28156 |}
28157 <blockquote>
28158 '''This is very bold of you!'''
28159
28160 {|
28161 |
28162 indented cell (no pre-wrapping!)
28163 |}
28164 </blockquote>
28165 foo
28166 <div>bar</div>
28167 !! end
28168
28169 !! test
28170 Nowiki-wrap leading whitespace when handling indent-pre inducing tags
28171 !! options
28172 parsoid=html2wt
28173 !! html/parsoid
28174 <p>foo</p>
28175 <span>bar</span>
28176
28177 <span>foo2
28178 </span>bar2
28179
28180 <div>foo</div>
28181 <span>bar</span>
28182
28183 <div>
28184 <span>foo</span>
28185 </div>
28186 !! wikitext
28187 foo
28188
28189 <span>bar</span>
28190
28191 <span>foo2
28192 <nowiki> </nowiki></span>bar2
28193
28194 <div>foo</div>
28195 <nowiki> </nowiki><span>bar</span>
28196
28197 <div>
28198 <nowiki> </nowiki><span>foo</span>
28199 </div>
28200 !! end
28201
28202 !! test
28203 Lists: Dont insert newlines in a serialized list item.
28204 !! options
28205 parsoid=html2wt
28206 !! html/parsoid
28207 <ul><li>a<br>b</li><li>c</li></ul>
28208 !! wikitext
28209 * a<br />b
28210 * c
28211 !! end
28212
28213 !! test
28214 1. Headings: Force sol-transparent links and behavior switches to serialize before/after
28215 !! options
28216 parsoid={
28217 "modes": ["html2wt"],
28218 "scrubWikitext": false
28219 }
28220 !! html/parsoid
28221 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
28222 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
28223
28224 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
28225 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
28226
28227 <h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2>
28228
28229 <h2><meta property="mw:PageProp/toc" /> ok</h2>
28230 !! wikitext
28231 == hello there [[Category:A1]] ==
28232
28233 == [[Category:A2]] hi pal ==
28234
28235 == <!--foo--> [[Category:A3]] how goes it ==
28236
28237 == it goes well [[Category:A4]] <!--bar--> ==
28238
28239 ==howdy [[Category:A5]]==
28240
28241 == __TOC__ ok ==
28242 !! end
28243
28244 !! test
28245 2. Headings: Force sol-transparent links and behavior switches to serialize before/after
28246 !! options
28247 parsoid={
28248 "modes": ["html2wt"],
28249 "scrubWikitext": true
28250 }
28251 !! html/parsoid
28252 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
28253 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
28254
28255 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
28256 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
28257
28258 <h2><meta property="mw:PageProp/toc" /> ok</h2>
28259 !! wikitext
28260 == hello there ==
28261 [[Category:A1]]
28262 [[Category:A2]]
28263
28264 == hi pal ==
28265
28266 <!--foo-->[[Category:A3]]
28267
28268 == how goes it ==
28269
28270 == it goes well ==
28271 [[Category:A4]] <!--bar-->
28272
28273 __TOC__
28274
28275 == ok ==
28276 !! end
28277
28278 !! test
28279 Headings: Don't hoist metas that come from templates
28280 !! options
28281 parsoid={
28282 "modes": ["html2wt"],
28283 "scrubWikitext": true
28284 }
28285 !! html/parsoid
28286 <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>
28287 !! wikitext
28288 == {{echo|foo [[Category:Foo]]}} ==
28289 !! end
28290
28291 !! test
28292 Headings: Category in ref isn't hoisted
28293 !! options
28294 parsoid={
28295 "modes": ["html2wt"],
28296 "scrubWikitext": true
28297 }
28298 !! html/parsoid
28299 <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>
28300
28301 <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>
28302 !! wikitext
28303 == foo <ref>bar
28304 [[Category:Baz]] </ref> ==
28305
28306 <references />
28307 !! end
28308
28309 !! test
28310 Parsoid: Serialize positional parameters with = in them as named parameter
28311 !! options
28312 parsoid=html2wt
28313 !! html/parsoid
28314 <p about="#mwt1" typeof="mw:Transclusion"
28315 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p>
28316
28317 <p about="#mwt1" typeof="mw:Transclusion"
28318 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p>
28319
28320 <!--Orig params with data-parsoid has heuristics for handling = chars-->
28321 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
28322 <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>
28323 !! wikitext
28324 {{echo|1=f=oo}}
28325
28326 {{echo|1=f=oo|2=bar}}
28327
28328 <!--Orig params with data-parsoid has heuristics for handling = chars-->
28329 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
28330 {{echo|<nowiki>f=oo</nowiki>|bar}}
28331 !! end
28332
28333 !! test
28334 Parsoid: Serialize positional parameters with = in extlink as named parameter
28335 !! options
28336 parsoid=html2wt
28337 !! html/parsoid
28338 <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>
28339 !! wikitext
28340 {{echo|1=http://stuff?is=ok}}
28341 !! end
28342
28343 !! test
28344 Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes
28345 !! options
28346 parsoid=html2wt
28347 !! html/parsoid
28348 <div>a<p>b</p></div>
28349 <div>a
28350 <p>b</p></div>
28351 <div>
28352 a
28353 <p>b</p></div>
28354 !! wikitext
28355 <div>a
28356 b
28357 </div>
28358 <div>a
28359 b
28360 </div>
28361 <div>
28362 a
28363
28364 b
28365 </div>
28366 !! end
28367
28368 !! test
28369 Substrings resembling wikitext in hrefs should not get nowiki escapes
28370 !! options
28371 parsoid=html2wt
28372 !! html/parsoid
28373 <a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a>
28374 !! wikitext
28375 [[Foo''bar''baz]]
28376 !! end
28377
28378 !! test
28379 Enforce single-line context in the serializer
28380 !! options
28381 parsoid=html2wt
28382 !! html/parsoid
28383 <h2>testing
28384 123</h2>
28385
28386 <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">
28387 </span><span about="#mwt1">you</span> </h2>
28388
28389 <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>
28390
28391 <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
28392 there</span></li></ol>
28393
28394 <ul><li>asd
28395 sdf</li></ul>
28396
28397 <ul><li>foo
28398 bar
28399 baz</li>
28400 <li>foo <b>bar</b>
28401 baz</li></ul>
28402
28403 <dl><dt>hi
28404 ho </dt><dd data-parsoid='{"stx":"row"}'> hi
28405 ho</dd></dl>
28406
28407 <dl><dd> <table>
28408 <tbody><tr><td> ha
28409 ha
28410 ha</td></tr>
28411 </tbody></table></dd></dl>
28412 !! wikitext
28413 == testing 123 ==
28414
28415 == hi {{bogus|there
28416 you}} ==
28417
28418 == foo <ref>hello
28419 there</ref> ==
28420
28421 <references />
28422
28423 * asd sdf
28424
28425 * foo bar baz
28426 * foo '''bar''' baz
28427
28428 ; hi ho : hi ho
28429
28430 : {|
28431 | ha
28432 ha
28433 ha
28434 |}
28435 !! end
28436
28437 !! test
28438 Serialize new placeholder space without spans
28439 !! options
28440 parsoid=html2wt
28441 !! html/parsoid
28442 <p>foo<span typeof="mw:Placeholder"> </span>: bar</p>
28443
28444 <p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p>
28445
28446 <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>
28447 !! wikitext
28448 foo : bar
28449
28450 foo : bar
28451
28452 <ref>foo : bar</ref>ok
28453 !! end
28454
28455
28456 #-----------------------
28457 # Tag minimization tests
28458 #-----------------------
28459
28460 !! test
28461 1. I/B quote minimization: wikitext-only tags should be combined
28462 !! options
28463 parsoid=html2wt
28464 !! html/parsoid
28465 <p><i>A</i><i>B</i></p>
28466 <p><b>A</b><b>B</b></p>
28467 <p><i>A</i><b><i>B</i></b></p>
28468 <p><b>A</b><i><b>B</b></i></p>
28469 <p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p>
28470 <p><i><b>A</b></i><i><b>B</b></i></p>
28471 <p><i><b>A</b></i><b><i>B</i></b></p>
28472 <p><b><i>A</i></b><i><b>B</b></i></p>
28473 !! wikitext
28474 ''AB''
28475
28476 '''AB'''
28477
28478 ''A'''B'''''
28479
28480 '''A''B'''''
28481
28482 '''A''BC''D'''
28483
28484 '''''AB'''''
28485
28486 '''''AB'''''
28487
28488 '''''AB'''''
28489 !! end
28490
28491 !! test
28492 2. I/B quote minimization: wikitext and html tags should not be combined
28493 !! options
28494 parsoid=html2wt
28495 !! html/parsoid
28496 <p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
28497 <p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
28498 !! wikitext
28499 ''A''<i>B</i>
28500
28501 ''A''<nowiki/>'''<i>B</i>'''
28502 !! end
28503
28504 !! test
28505 3. I/B quote minimization: templated content stops minimization
28506 !! options
28507 parsoid=html2wt
28508 !! html/parsoid
28509 <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>
28510 <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>
28511 !! wikitext
28512 ''A''{{echo|''B''}}
28513
28514 ''A''{{echo|'''''B'''''}}
28515 !! end
28516
28517 !! test
28518 4. I/B quote minimization: new content should be mimimized with adjacent old content
28519 !! options
28520 parsoid=html2wt
28521 !! html/parsoid
28522 <p><i>A</i><i>B</i></p>
28523 <p><b>A</b><b>B</b></p>
28524 <p><i>A</i><b><i>B</i></b></p>
28525 !! wikitext
28526 ''AB''
28527
28528 '''AB'''
28529
28530 ''A'''B'''''
28531 !! end
28532
28533 !! test
28534 5a. Merge adjacent quote nodes if they've been edited
28535 !! options
28536 parsoid={
28537 "modes": ["wt2wt", "selser"],
28538 "changes": [
28539 ["p", "contents", "remove", ":contains('b')"]
28540 ]
28541 }
28542 !! wikitext
28543 ''a''b''c''
28544 !! wikitext/edited
28545 ''ac''
28546 !! end
28547
28548 !! test
28549 5b. Merge adjacent quote nodes if they've been edited
28550 !! options
28551 parsoid={
28552 "modes": ["wt2wt", "selser"],
28553 "changes": [
28554 ["#x", "remove"]
28555 ]
28556 }
28557 !! wikitext
28558 ''a''<span id="x">b</span>''c''
28559 !! wikitext/edited
28560 ''ac''
28561 !! end
28562
28563 !! test
28564 1. Merge adjacent link nodes as long as at least one element is new
28565 !! options
28566 parsoid={
28567 "modes": ["html2wt"],
28568 "scrubWikitext": true
28569 }
28570 !! html/parsoid
28571 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28572 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28573 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a>
28574 !! wikitext
28575 [[Football]]
28576 [[Football]]
28577 [[Football|Foot]][[Football|ball]]
28578 !! end
28579
28580 !! test
28581 2. Merge adjacent link nodes and enable additional normalizations
28582 !! options
28583 parsoid={
28584 "modes": ["html2wt"],
28585 "scrubWikitext": true
28586 }
28587 !! html/parsoid
28588 <a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a>
28589 !! wikitext
28590 ''[[Football]]''
28591 !! end
28592
28593 !! test
28594 3. Don't merge adjacent link nodes if scrubWikitext is false
28595 !! options
28596 parsoid={
28597 "modes": ["html2wt"],
28598 "scrubWikitext": false
28599 }
28600 !! html/parsoid
28601 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28602 !! wikitext
28603 [[Football|Foot]][[Football|ball]]
28604 !! end
28605
28606 !! test
28607 1. Move format tags outside of WikiLink
28608 !! options
28609 parsoid={
28610 "modes": ["html2wt"],
28611 "scrubWikitext": true
28612 }
28613 !! html/parsoid
28614 <a rel="mw:WikiLink" href="./Football"><i>Football</i></a>
28615 <a rel="mw:WikiLink" href="./Football"><i><b>Football</b></i></a>
28616 <a rel="mw:WikiLink" href="./Football"><u><i><b>Football</b></i></u></a>
28617 !! wikitext
28618 ''[[Football]]''
28619 '''''[[Football]]'''''
28620 <u>'''''[[Football]]'''''</u>
28621 !! end
28622
28623 !! test
28624 2. Move format tags outside of WikiLink with mergable A tags
28625 !! options
28626 parsoid={
28627 "modes": ["html2wt"],
28628 "scrubWikitext": true
28629 }
28630 !! html/parsoid
28631 <a rel="mw:WikiLink" href="./Football"><i><b>Foot</b></i></a><a rel="mw:WikiLink" href="./Football"><i><b>ball</b></i></a>
28632 !! wikitext
28633 '''''[[Football]]'''''
28634 !! end
28635
28636 !! test
28637 3. Move format tags outside of WikiLink while preserving formats already outside WikiLink
28638 !! options
28639 parsoid={
28640 "modes": ["html2wt"],
28641 "scrubWikitext": true
28642 }
28643 !! html/parsoid
28644 <font color="red"><a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><u><b>Foo</b></u></a></font>
28645 !! wikitext
28646 <font color="red"><u>'''[[Foo]]'''</u></font>
28647 !! end
28648
28649 !! test
28650 4. Do not move format tags outside of WikiLink which includes attributes color, style and class
28651 !! options
28652 parsoid={
28653 "modes": ["html2wt"],
28654 "scrubWikitext": true
28655 }
28656 !! html/parsoid
28657 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><font color="red">Foo</font></a>
28658 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><span style="color: blue; font-size: 46px;">Foo></span></a>
28659 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><span class="Bar">Foo</span></a>
28660 !! wikitext
28661 [[Foo|<font color="red">Foo</font>]]
28662 [[Foo|<span style="color: blue; font-size: 46px;">Foo></span>]]
28663 [[Foo|<span class="Bar">Foo</span>]]
28664 !! end
28665
28666 !! test
28667 5. T194083 Regression test: Manual edit test that also enables scrubWikitext to move format tags outside wikilinks
28668 !! options
28669 parsoid={
28670 "modes": ["selser"],
28671 "scrubWikitext": true,
28672 "changes": [
28673 ["a", "html", "<i>Foo</i>"]
28674 ]
28675 }
28676 !! wikitext
28677 [[Foo]]
28678 !! wikitext/edited
28679 ''[[Foo]]''
28680 !! end
28681
28682 !! test
28683 6. Regression test: Manual edit test to ensure diff markers are not lost
28684 !! options
28685 parsoid={
28686 "modes": ["selser"],
28687 "scrubWikitext": true,
28688 "changes": [
28689 ["i", "wrap", "<a href='./Foo' rel='mw:WikiLink'></a>"]
28690 ]
28691 }
28692 !! wikitext
28693 ''Foo''
28694 !! wikitext/edited
28695 ''[[Foo]]''
28696 !! end
28697
28698 #------------------------------
28699 # End of tag minimization tests
28700 #------------------------------
28701
28702 !!test
28703 T56262: New entities
28704 !! options
28705 parsoid=html2wt
28706 !! html/parsoid
28707 <span typeof="mw:Entity">&nbsp;</span>
28708 !! wikitext
28709 &nbsp;
28710 !! end
28711
28712 ## Note that there is no wikitext output for 'unknownproperty' ##
28713 ## Unknown magic words are silently dropped ##
28714
28715 !! test
28716 Magic words
28717 !! options
28718 parsoid=html2wt
28719 !! html/parsoid
28720 <meta property='mw:PageProp/toc' />
28721 <meta property='mw:PageProp/notoc' />
28722 <meta property='mw:PageProp/forcetoc' />
28723 <meta property='mw:PageProp/index' />
28724 <meta property='mw:PageProp/noindex' />
28725 <meta property='mw:PageProp/nogallery' />
28726 <meta property='mw:PageProp/noeditsection' />
28727 <meta property='mw:PageProp/notitleconvert' />
28728 <meta property='mw:PageProp/nocontentconvert' />
28729 <meta property='mw:PageProp/unknownproperty' />
28730 !! wikitext
28731 __TOC__
28732 __NOTOC__
28733 __FORCETOC__
28734 __INDEX__
28735 __NOINDEX__
28736 __NOGALLERY__
28737 __NOEDITSECTION__
28738 __NOTITLECONVERT__
28739 __NOCONTENTCONVERT__
28740 !! end
28741
28742 !! test
28743 Consecutive <pre>s should not get merged
28744 !! options
28745 parsoid=html2wt,html2html
28746 !! html/parsoid
28747 <pre>a</pre><pre>b</pre>
28748
28749 <pre>c
28750 </pre><pre>
28751 d</pre>
28752
28753 <pre>e
28754
28755 </pre><pre>
28756
28757 f</pre>
28758 !! wikitext
28759 a
28760
28761 b
28762
28763 c
28764
28765 d
28766
28767 e
28768
28769
28770
28771 f
28772 !! end
28773
28774 !! test
28775 Edited ISBN links not serializable as ISBN links should serialize as wikilinks
28776 !! options
28777 parsoid=html2wt
28778 !! html/parsoid
28779 <a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a>
28780 !! wikitext
28781 [[Special:BookSources/1234567890|ISBN 1234567895]]
28782 !! end
28783
28784 !! test
28785 Edited RFC links not serializable as RFC links should serialize as extlinks
28786 !! options
28787 parsoid=html2wt
28788 !! html/parsoid
28789 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
28790 !! wikitext
28791 [https://tools.ietf.org/html/rfc123 New RFC]
28792 !! end
28793
28794 !! test
28795 Edited PMID links not serializable as PMID links should serialize as extlinks
28796 !! options
28797 parsoid=html2wt
28798 !! html/parsoid
28799 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a>
28800 !! wikitext
28801 [//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID]
28802 !! end
28803
28804 !! test
28805 WTS of autolinks with trailing/surrounding context
28806 !! options
28807 parsoid=html2wt
28808 !! html/parsoid
28809 <p><a href="http://cscott.net">http://cscott.net</a><b>foo</b></p>
28810 <p><a href="http://cscott.net">http://cscott.net</a><b data-parsoid='{"stx":"html"}'>foo</b></p>
28811 <p><b><a href="http://cscott.net">http://cscott.net</a></b></p>
28812 <p><b><a href="http://cscott.net">http://cscott.net</a> </b></p>
28813 <p><b><a href="http://cscott.net">http://cscott.net</a>x</b></p>
28814 <p><a href="http://cscott.net">http://cscott.net</a>x</p>
28815 !! wikitext
28816 http://cscott.net'''foo'''
28817
28818 http://cscott.net<b>foo</b>
28819
28820 '''http://cscott.net'''
28821
28822 '''http://cscott.net '''
28823
28824 '''http://cscott.net<nowiki/>x'''
28825
28826 http://cscott.net<nowiki/>x
28827 !! end
28828
28829 !! test
28830 WTS of autolinks with nowikis (round-trip)
28831 !! wikitext
28832 x<nowiki/>http://cscott.net<nowiki/>x
28833 !! html/parsoid
28834 <p>x<a rel="mw:ExtLink" class="external free" href="http://cscott.net">http://cscott.net</a>x</p>
28835 !! end
28836
28837 # this is the "easy" test because it leaves in place all the
28838 # data-parsoid information indicating this is an autolink
28839 !! test
28840 WTS of autolinks with escapes (editing)
28841 !! options
28842 parsoid={
28843 "modes": ["wt2wt"],
28844 "changes": [
28845 [ "span", "remove" ]
28846 ]
28847 }
28848 !! wikitext
28849 x<nowiki/>http://cscott.net<nowiki/>x
28850 !! wikitext/edited
28851 x<nowiki/>http://cscott.net<nowiki/>x
28852 !! end
28853
28854 !! test
28855 WTS of edited autolink-like text (T103364)
28856 !! options
28857 parsoid={
28858 "modes": ["wt2wt"],
28859 "changes": [
28860 [ "span[typeof]", "removeAttr", "typeof" ]
28861 ]
28862 }
28863 !! wikitext
28864 Not a link: <nowiki>http://example.com</nowiki>.
28865 !! wikitext/edited
28866 Not a link: <span><nowiki>http://example.com</nowiki></span>.
28867 !! end
28868
28869 !! test
28870 WTS of newly-authored autolink-like text (T103364)
28871 !! options
28872 parsoid=html2wt
28873 !! html/parsoid
28874 <p>http://example.com is not a link.</p>
28875 !! wikitext
28876 <nowiki>http://example.com</nowiki> is not a link.
28877 !! end
28878
28879 !! test
28880 WTS of autolink-like text after an autolink (T108563)
28881 !! options
28882 parsoid=html2wt
28883 !! html/parsoid
28884 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p>
28885 !! wikitext
28886 http://example.com <nowiki>http://example.com</nowiki> is not a link.
28887 !! end
28888
28889 !! test
28890 Magic links inside links (not autolinked)
28891 !! wikitext
28892 [[Foo|http://example.com]]
28893 [[Foo|RFC 1234]]
28894 [[Foo|PMID 1234]]
28895 [[Foo|ISBN 123456789x]]
28896
28897 [http://foo.com http://example.com]
28898 [http://foo.com RFC 1234]
28899 [http://foo.com PMID 1234]
28900 [http://foo.com ISBN 123456789x]
28901 !! html+tidy
28902 <p><a href="/wiki/Foo" title="Foo">http://example.com</a>
28903 <a href="/wiki/Foo" title="Foo">RFC 1234</a>
28904 <a href="/wiki/Foo" title="Foo">PMID 1234</a>
28905 <a href="/wiki/Foo" title="Foo">ISBN 123456789x</a>
28906 </p><p><a rel="nofollow" class="external text" href="http://foo.com">http://example.com</a>
28907 <a rel="nofollow" class="external text" href="http://foo.com">RFC 1234</a>
28908 <a rel="nofollow" class="external text" href="http://foo.com">PMID 1234</a>
28909 <a rel="nofollow" class="external text" href="http://foo.com">ISBN 123456789x</a>
28910 </p>
28911 !! html/parsoid
28912 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a>
28913 <a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a>
28914 <a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a>
28915 <a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p>
28916
28917 <p><a rel="mw:ExtLink" class="external text" href="http://foo.com">http://example.com</a>
28918 <a rel="mw:ExtLink" class="external text" href="http://foo.com">RFC 1234</a>
28919 <a rel="mw:ExtLink" class="external text" href="http://foo.com">PMID 1234</a>
28920 <a rel="mw:ExtLink" class="external text" href="http://foo.com">ISBN 123456789x</a></p>
28921 !! end
28922
28923 !! test
28924 Magic links inside image captions (autolinked)
28925 !! wikitext
28926 [[File:Foobar.jpg|thumb|http://example.com]]
28927 [[File:Foobar.jpg|thumb|RFC 1234]]
28928 [[File:Foobar.jpg|thumb|PMID 1234]]
28929 [[File:Foobar.jpg|thumb|ISBN 123456789x]]
28930 !! html+tidy
28931 <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>
28932 <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>
28933 <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>
28934 <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>
28935 !! html/parsoid
28936 <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>
28937 <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>
28938 <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>
28939 <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>
28940 !! end
28941
28942 !! test
28943 WTS of magic word text (T109371)
28944 !! options
28945 parsoid=html2wt
28946 !! html/parsoid
28947 <p>RFC 1234</p>
28948 <p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p>
28949 <p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p>
28950 !! wikitext
28951 <nowiki>RFC 1234</nowiki>
28952
28953 [http://foo.com RFC 1234]
28954
28955 [[Foo|RFC 1234]]
28956 !! end
28957
28958 !! test
28959 Edited Redirect link should emit a non-piped wikitext link
28960 !! options
28961 parsoid=html2wt
28962 !! html/parsoid
28963 <link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>
28964 !! wikitext
28965 #REDIRECT [[Bar]]
28966 !! end
28967
28968 !! test
28969 T75121: Infer extension name from typeOf if data-mw is not present
28970 !! options
28971 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28972 !! html/parsoid
28973 <div typeOf="mw:Extension/foo"></div>
28974 !! wikitext
28975 <foo />
28976 !! end
28977
28978 # Note that the <p> wrapping isn't present in PHP parser output
28979 # The important thing for this test is that P-wrapping doesn't
28980 # interfere with the <nowiki> protection for leading - in <td>
28981 # (which isn't necessary for <th>).
28982 !! test
28983 T88318: p-wrapped dash in table.
28984 !! options
28985 parsoid=html2wt,wt2wt
28986 !! html/parsoid
28987 <table><tbody>
28988 <tr><th><p>-</p></th><th><p>- </p></th></tr>
28989 <tr><td><p>-</p></td><td><p>- </p></td></tr>
28990 <tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr>
28991 </tbody></table>
28992 !! wikitext
28993 {|
28994 !-
28995 !-
28996 |-
28997 |<nowiki>-</nowiki>
28998 |<nowiki>- </nowiki>
28999 |-
29000 |<small>-</small>
29001 |<br />
29002 -
29003 |<br />-
29004 |}
29005 !! html/php+tidy
29006 <table>
29007 <tbody><tr>
29008 <th>-
29009 </th>
29010 <th>-
29011 </th></tr>
29012 <tr>
29013 <td>-
29014 </td>
29015 <td>-
29016 </td></tr>
29017 <tr>
29018 <td><small>-</small>
29019 </td>
29020 <td><br />
29021 <p>-
29022 </p>
29023 </td>
29024 <td><br />-
29025 </td></tr></tbody></table>
29026 !! end
29027
29028 !! test
29029 T149209: WTS: Handle newlines in table cells properly
29030 !! options
29031 parsoid=html2wt
29032 !! html/parsoid
29033 <table>
29034 <tbody>
29035 <tr><td>a
29036 b
29037 </td><td data-parsoid='{"stx":"row"}'>c</td></tr>
29038 <tr><td><p>x</p>
29039 </td><td data-parsoid='{"stx":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr>
29040 </tbody></table>
29041 <table>
29042 <tbody>
29043 <tr><th>a
29044 b
29045 </th><th data-parsoid='{"stx":"row"}'>c</th></tr>
29046 <tr><th><p>x</h>
29047 </th><th data-parsoid='{"stx":"row"}'>y</th></tr>
29048 </tbody></table>
29049 !! wikitext
29050 {|
29051 |a
29052 b
29053 |c
29054 |-
29055 |x
29056 {{!}}y
29057 |}
29058 {|
29059 !a
29060 b
29061 !c
29062 |-
29063 !x
29064 !y
29065 |}
29066 !! end
29067
29068 !! test
29069 T149209: Selser: Handle newlines in table cells properly
29070 !! options
29071 parsoid={
29072 "modes": ["selser"],
29073 "changes": [
29074 [ "#h1", "html", "a\nb\n" ],
29075 [ "#h2", "html", "a\nb\n" ],
29076 [ "#c1", "html", "a\nb\n" ],
29077 [ "#c2", "html", "<p>a</p>" ],
29078 [ "#c3", "html", "<p>a</p>" ],
29079 [ "#c4", "html", "edit-me<p>a</p>" ]
29080 ]
29081 }
29082 !! wikitext
29083 {|
29084 ! id="h1" |edit-me!!1
29085 |-
29086 ! id="h2" |edit-me||2
29087 |-
29088 | id="c1" |edit-me||3
29089 |-
29090 | id="c2" |edit-me||4
29091 |-
29092 | id="c3" |edit-me||p||q||r
29093 |-
29094 | id="c4" |edit-me||p||q||r
29095 |}
29096 !! wikitext/edited
29097 {|
29098 ! id="h1" |a
29099 b
29100 !1
29101 |-
29102 ! id="h2" |a
29103 b
29104 !2
29105 |-
29106 | id="c1" |a
29107 b
29108 |3
29109 |-
29110 | id="c2" |a
29111 |4
29112 |-
29113 | id="c3" |a
29114 |p||q||r
29115 |-
29116 | id="c4" |edit-me
29117 a
29118 |p||q||r
29119 |}
29120 !! end
29121
29122 !! test
29123 HTML id attribute with Parsoid-like element ids should not be serialized to wikitext
29124 !! options
29125 parsoid=html2wt
29126 !! html/parsoid
29127 <table id='mwAb'>
29128 <td id='mwAc'>foo</td>
29129 <td id='serialize-this'>bar</td>
29130 </table>
29131 !! wikitext
29132 {|
29133 |foo
29134 | id="serialize-this" |bar
29135 |}
29136 !! end
29137
29138 !! test
29139 Parsoid-like element ids should not be serialized to wikitext unless shadowed
29140 !! options
29141 parsoid=html2wt
29142 !! html/parsoid
29143 <div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div>
29144 !! wikitext
29145 <div id="hello">ok</div>
29146 !! end
29147
29148 !! test
29149 Testing serialization after deletion in references
29150 !! options
29151 parsoid={
29152 "modes": ["wt2wt"],
29153 "changes": [
29154 ["#x", "remove"]
29155 ]
29156 }
29157 !! wikitext
29158 hi <ref><div id="x">ho</div></ref>
29159
29160 <references />
29161 !! wikitext/edited
29162 hi <ref></ref>
29163
29164 <references />
29165 !! end
29166
29167 !!test
29168 Testing serialization after deletion of table cells
29169 !!options
29170 parsoid={
29171 "modes": ["wt2wt", "selser"],
29172 "changes": [
29173 ["#x", "remove"]
29174 ]
29175 }
29176 !!wikitext
29177 {|
29178 !h1 !!h2 !!h3
29179 | id="x" |c1 {{!}}{{!}}{{!}}c2 |||c3
29180 |}
29181 !! wikitext/edited
29182 {|
29183 !h1!!h2!!h3
29184 |c2|||c3
29185 |}
29186 !!end
29187
29188 !! test
29189 Testing selser after addition of new row before first row (T125419)
29190 !! options
29191 parsoid={
29192 "modes": ["wt2wt", "selser"],
29193 "changes": [
29194 [ "tr", "before", "<tr><td>X</td></tr>" ]
29195 ]
29196 }
29197 !! wikitext
29198 {|
29199 |a
29200 |}
29201 !! wikitext/edited
29202 {|
29203 |X
29204 |-
29205 |a
29206 |}
29207 !! end
29208
29209 !! test
29210 Serialize new table rows in a HTML table using HTML tags
29211 !! options
29212 parsoid={
29213 "modes": ["wt2wt", "selser"],
29214 "changes": [
29215 [ "tr", "before", "<tr><td>X</td></tr>" ]
29216 ]
29217 }
29218 !! wikitext
29219 <table><tr><td>a</td></tr></table>
29220 !! wikitext/edited
29221 <table><tr><td>X</td></tr><tr><td>a</td></tr></table>
29222 !! end
29223
29224 !! test
29225 Serialize new table cells in a HTML row using HTML tags
29226 !! options
29227 parsoid={
29228 "modes": ["wt2wt", "selser"],
29229 "changes": [
29230 [ "td", "before", "<td>X</td>" ]
29231 ]
29232 }
29233 !! wikitext
29234 <table><tr><td>a</td></tr></table>
29235 !! wikitext/edited
29236 <table><tr><td>X</td><td>a</td></tr></table>
29237 !! end
29238
29239 !! test
29240 Serialize wikitext list items as HTML list items when embedded in a HTML list
29241 !! options
29242 parsoid=html2wt
29243 !! html
29244 <ul data-parsoid='{"stx": "html"}'>
29245 <li data-parsoid='{}'>a</li>
29246 <li>b</li>
29247 </ul>
29248 !! wikitext
29249 <ul>
29250 <li>a</li>
29251 <li>b</li>
29252 </ul>
29253 !! end
29254
29255 # SSS FIXME: Is this actually a good thing given the
29256 # odd nested list output that is generated by MW?
29257 # <ul><li>foo<ul>..</ul></li></ul> instead of
29258 # <ul><li>foo</li><ul>..</ul></ul>
29259 !! test
29260 Wikitext lists can be nested inside HTML lists
29261 !! options
29262 parsoid=html2wt
29263 !! html
29264 <ul data-parsoid='{"stx": "html"}'>
29265 <li data-parsoid='{"stx": "html"}'>a
29266 <ul><li>b</li></ul>
29267 </li>
29268 </ul>
29269
29270 <ul data-parsoid='{"stx": "html"}'>
29271 <li>x
29272 <ul><li>y</li></ul>
29273 </li>
29274 </ul>
29275 !! wikitext
29276 <ul>
29277 <li>a
29278 * b
29279 </li>
29280 </ul>
29281
29282 <ul>
29283 <li>x
29284 * y
29285 </li>
29286 </ul>
29287 !! end
29288
29289 !! test
29290 WTS change modes
29291 !! options
29292 parsoid={
29293 "modes": ["wt2wt"],
29294 "changes": [
29295 [ "#xyz", "before", "<b>before</b> stuff " ],
29296 [ "#xyz", "after", " stuff <i>after</i>" ],
29297 [ "#xyz", "html", "x <b>y</b> z" ]
29298 ]
29299 }
29300 !! wikitext
29301 <span id="xyz">hello</span>
29302 !! wikitext/edited
29303 '''before''' stuff <span id="xyz">x '''y''' z</span> stuff ''after''
29304 !! end
29305
29306 !! test
29307 Never serialize a-tag as html, regardless of what data-parsoid has to say
29308 !! options
29309 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
29310 !! html/parsoid
29311 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a>
29312 !! wikitext
29313 [[Foo]]
29314 !! end
29315
29316 ## SSS FIXME: This is broken output nevertheless.
29317 ## What might be a reasonable non-broken output for this?
29318 ## This is an edge case unlikely to be seen in production
29319 ## that I am not wasting more time on this right now.
29320 !! test
29321 Never serialize a-tag as html, no matter what attributes it has
29322 !! options
29323 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
29324 !! html/parsoid
29325 <a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a>
29326 !! wikitext
29327 [http://boo.org http://boohoo.org]
29328 !! end
29329
29330 # Misnested is an indication that selser can reuse the source but these have
29331 # shown to sneak through on occasion. See T101768.
29332 # The original wikitext here is: [http://test.com [[one]] two three]
29333 !! test
29334 Strip span tags added to mark misnested links
29335 !! options
29336 parsoid=html2wt
29337 !! html/parsoid
29338 <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>
29339 !! wikitext
29340 [http://test.com][[one]] two three
29341 !! end
29342
29343 !! test
29344 Catch regression when unpacking misnested links
29345 !! options
29346 parsoid=wt2html
29347 !! wikitext
29348 {{echo|hi}}[http://example.com [[ho]]]
29349 !! html/parsoid
29350 <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>
29351 !! end
29352
29353 !! test
29354 Catch regression when unpacking with trailing content
29355 !! wikitext
29356 {{echo|Foo <references/> bar}}
29357 !! html/parsoid
29358 <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>
29359 !! end
29360
29361 !! test
29362 Use data-parsoid.firstWikitextNode to compute newline constraints for template content
29363 !! options
29364 parsoid=html2wt
29365 !! html/parsoid
29366 <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|}"]}'>
29367 <tbody><tr><td>d
29368 </td></tr>
29369 </tbody></table>
29370 !! wikitext
29371 {{echo|a}}
29372 {|{{echo|c
29373 {{!}}d
29374 }}
29375 |}
29376 !! end
29377
29378 ## This test verifies the presence and computation of this attribute indirectly
29379 ## by making an edit and ensuring that the serialization is correct (which it would be
29380 ## only if firstWikitextNode is properly set).
29381 !! test
29382 data-parsoid.firstWikitextNode should be computed properly in the presence of fostered content
29383 !! options
29384 parsoid= {
29385 "modes": ["wt2wt"],
29386 "changes": [
29387 [ "div#x", "remove" ],
29388 [ "div", "before", "<div>new</div>" ]
29389 ]
29390 }
29391 !! wikitext
29392 <div id="x">foo</div>
29393 {|
29394 {{echo|<div>boo</div>
29395 {{!}}b}}
29396 |c
29397 |}
29398 !! wikitext/edited
29399
29400 <div>new</div>
29401 {|
29402 {{echo|<div>boo</div>
29403 {{!}}b}}
29404 |c
29405 |}
29406 !! end
29407
29408 # --------------------------------------------
29409 # Tests spec'ing wikitext serialization norms |
29410 # --------------------------------------------
29411
29412 !! test
29413 Serialize multi-line indent-pre starting with wikitext syntax
29414 !! options
29415 parsoid=html2wt
29416 !! html/parsoid
29417 <pre>* 1
29418 ** 2
29419 * 3</pre>
29420 !! wikitext
29421 * 1
29422 ** 2
29423 * 3
29424 !! end
29425
29426 !! test
29427 1. Categories should always be serialized on their own line
29428 !! options
29429 parsoid=html2wt
29430 !! html/parsoid
29431 foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar
29432 !! wikitext
29433 foo
29434 [[Category:Foo]]
29435 bar
29436 !! end
29437
29438 !! test
29439 2. Categories that are part of templates should not introduce a line break
29440 !! wikitext
29441 foo {{echo|<span>bar</span> [[Category:baz]]}} bar
29442 !! html/parsoid
29443 <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>
29444 !! end
29445
29446 # Careful while editing these next 2 tests. There are \u200f characters
29447 # before and after the <link> tags in the HTML and following some
29448 # of the categories in wikitext
29449 # Do not remove these characters in edits.
29450 #
29451 # As part of the serialization, these bidi characters will get stripped.
29452 !! test
29453 RTL (\u200f) and LTR (\u200e) markers around category tags should be stripped
29454 !! options
29455 parsoid={
29456 "modes": ["html2wt"],
29457 "scrubWikitext": true
29458 }
29459 !! html/parsoid
29460 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏
29461 ‏<link rel="mw:PageProp/Category" href="./קטגוריה:_שיטות_משפט" />‏</p>
29462 !! wikitext
29463 [[קטגוריה:טקסים]]
29464 [[קטגוריה: שיטות משפט]]
29465 !! end
29466
29467 !! test
29468 RTL (\u200f) and LTR (\u200e) markers should not be stripped if followed by a text node
29469 !! options
29470 parsoid={
29471 "modes": ["html2wt"],
29472 "scrubWikitext": true
29473 }
29474 !! html/parsoid
29475 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏y</p>
29476 !! wikitext
29477 [[קטגוריה:טקסים]]
29478 ‏y
29479 !! end
29480
29481 !! test
29482 Lists: Add space after bullets
29483 !! options
29484 parsoid=html2wt
29485 !! html/parsoid
29486 <ul>
29487 <li>foo</li>
29488 <li> bar</li>
29489 <li><span> baz</span></li>
29490 </ul>
29491 !! wikitext
29492 * foo
29493 * bar
29494 * <span> baz</span>
29495 !! end
29496
29497 !! test
29498 1. Headings: Add space before/after == (T53744)
29499 !! options
29500 parsoid=html2wt
29501 !! html/parsoid
29502 <h2>foo</h2>
29503 <h2> bar</h2>
29504 <h2>baz </h2>
29505 <h2><span> baz</span></h2>
29506 !! wikitext
29507 == foo ==
29508
29509 == bar ==
29510
29511 == baz ==
29512
29513 == <span> baz</span> ==
29514 !! end
29515
29516 !! test
29517 2. Headings: Add space before/after == even after hoisted content
29518 !! options
29519 parsoid={
29520 "modes": ["html2wt"],
29521 "scrubWikitext": true
29522 }
29523 !! html/parsoid
29524 <h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2>
29525 !! wikitext
29526 [[Category:A2]]
29527
29528 == ok ==
29529 !! end
29530
29531 !! test
29532 1. Headings: suppress newly created empty headings
29533 !! options
29534 parsoid={
29535 "modes": ["html2wt"],
29536 "scrubWikitext": true
29537 }
29538 !! html/parsoid
29539 <h2></h2>
29540 !! wikitext
29541 !! end
29542
29543 !! test
29544 2. Headings: don't suppress empty headings if scrubWikitext is false
29545 !! options
29546 parsoid=html2wt
29547 !! html/parsoid
29548 <h2></h2>
29549 !! wikitext
29550 ==<nowiki/>==
29551 !! end
29552
29553 !! test
29554 3. Headings: suppress empty headings on edits
29555 !! options
29556 parsoid={
29557 "modes": ["selser"],
29558 "scrubWikitext": true,
29559 "changes": [
29560 [ "#x", "remove"]
29561 ]
29562 }
29563 !! wikitext
29564 ==<span id="x">foo</span>==
29565 !! wikitext/edited
29566 !! end
29567
29568 !! test
29569 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = true)
29570 !! options
29571 parsoid={
29572 "modes": ["html2wt"],
29573 "scrubWikitext": true
29574 }
29575 !! html/parsoid
29576 <h2>foo<br/>bar</h2>
29577 <h2>foo <span><br/>bar</span> baz</h2>
29578 !! wikitext
29579 == foo bar ==
29580
29581 == foo <span> bar</span> baz ==
29582 !! end
29583
29584 !! test
29585 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = false)
29586 !! options
29587 parsoid={
29588 "modes": ["html2wt"],
29589 "scrubWikitext": false
29590 }
29591 !! html/parsoid
29592 <h2>foo<br/>bar</h2>
29593 !! wikitext
29594 == foo<br />bar ==
29595 !! end
29596
29597 !! test
29598 1. WT Quote Tags: suppress newly created empty style tags
29599 !! options
29600 parsoid={
29601 "modes": ["html2wt"],
29602 "scrubWikitext": true
29603 }
29604 !! html/parsoid
29605 <i></i><b></b>
29606 !! wikitext
29607 !! end
29608
29609 !! test
29610 2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false
29611 !! options
29612 parsoid=html2wt
29613 !! html/parsoid
29614 <i></i><b></b>
29615 !! wikitext
29616 ''<nowiki/>'''''<nowiki/>'''
29617 !! end
29618
29619 !! test
29620 3. WT Quote Tags: suppress empty style tags on edits
29621 !! options
29622 parsoid={
29623 "modes": ["selser"],
29624 "scrubWikitext": true,
29625 "changes": [
29626 [ "#x", "remove"]
29627 ]
29628 }
29629 !! wikitext
29630 '''<span id="x">foo</span>'''
29631 !! wikitext/edited
29632 !! end
29633
29634 !! test
29635 1. Anchors: suppress newly created empty anchors
29636 !! options
29637 parsoid={
29638 "modes": ["html2wt"],
29639 "scrubWikitext": true
29640 }
29641 !! html/parsoid
29642 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
29643 !! wikitext
29644 !! end
29645
29646 !! test
29647 2. Anchors: don't suppress empty anchors if scrubWikitext is false
29648 !! options
29649 parsoid={
29650 "modes": ["html2wt"],
29651 "scrubWikitext": false
29652 }
29653 !! html/parsoid
29654 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
29655 !! wikitext
29656 [[Test|<nowiki/>]]
29657 !! end
29658
29659 !! test
29660 3. Anchors: suppress empty anchors on edits
29661 !! options
29662 parsoid={
29663 "modes": ["selser"],
29664 "scrubWikitext": true,
29665 "changes": [
29666 [ "#x", "remove"]
29667 ]
29668 }
29669 !! wikitext
29670 [[Test|<span id="x">foo</span>]]
29671 !! wikitext/edited
29672 !! end
29673
29674 !! test
29675 3a. Anchors: do not suppress numbered extlinks
29676 !! options
29677 parsoid={
29678 "modes": ["wt2wt"],
29679 "scrubWikitext": true
29680 }
29681 !! wikitext
29682 [http://foo.com]
29683 !! html/parsoid
29684 <a rel="mw:ExtLink" href="http://foo.com"></a>
29685 !! end
29686
29687 !! test
29688 3b. Anchors: do not suppress numbered extlinks
29689 !! options
29690 parsoid={
29691 "modes": ["wt2wt"],
29692 "scrubWikitext": true,
29693 "changes": [
29694 [ "#x", "remove"]
29695 ]
29696 }
29697 !! wikitext
29698 [http://foo.com <span id="x">foo</span>]
29699 !! wikitext/edited
29700 [http://foo.com]
29701 !! end
29702
29703 !!test
29704 Normalizations should be restricted to edited content
29705 !!options
29706 parsoid={
29707 "modes": ["selser"],
29708 "scrubWikitext": true,
29709 "changes": [
29710 [ "h1", "before", "<i></i>"]
29711 ]
29712 }
29713 !!wikitext
29714 a
29715 = =
29716 b
29717 !!wikitext/edited
29718 a
29719 = =
29720 b
29721 !!end
29722
29723 !! test
29724 1. Multiple normalizations (html2wt)
29725 !! options
29726 parsoid={
29727 "modes": ["html2wt"],
29728 "scrubWikitext": true
29729 }
29730 !! html
29731 <h2><i></i></h2>
29732 <p><a href='Foo' rel='mw:WikiLink'>foo<i></i>
29733 </a><b><i></i></b>x</p>
29734 !! wikitext
29735
29736 [[foo]]
29737 x
29738
29739 !! end
29740
29741 !! test
29742 2. Multiple normalizations (selser)
29743 !! options
29744 parsoid={
29745 "modes": ["selser"],
29746 "scrubWikitext": true,
29747 "changes": [
29748 [ "#x", "after", "<h1><i></i></h1>\n<p> x<b></b></p>"]
29749 ]
29750 }
29751 !! wikitext
29752 <span id="x">foo</span>
29753 !! wikitext/edited
29754 <span id="x">foo</span>
29755
29756 x
29757 !! end
29758
29759 !! test
29760 1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
29761 !! options
29762 parsoid={
29763 "modes": ["html2wt"],
29764 "scrubWikitext": true
29765 }
29766 !! html/parsoid
29767 <p> hi</p>
29768 <p> hello</p>
29769 !! wikitext
29770 hi
29771
29772 hello
29773 !! end
29774
29775 !! test
29776 2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false
29777 !! options
29778 parsoid=html2wt
29779 !! html/parsoid
29780 <p> hi</p>
29781 <p> hello</p>
29782 !! wikitext
29783 <nowiki> </nowiki>hi
29784
29785 <nowiki> </nowiki> hello
29786 !! end
29787
29788 !! test
29789 3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
29790 !! options
29791 parsoid={
29792 "modes": ["html2wt"],
29793 "scrubWikitext": true
29794 }
29795 !! html/parsoid
29796 <p>Foo
29797 bar
29798 baz</p>
29799
29800 <table><tr><td>Foo
29801 bar
29802 baz bang</td></tr></table>
29803
29804 <p><!--boo--> foo
29805 bar</p>
29806
29807 <p> foo
29808 bar<span>boo</span></p>
29809 !! wikitext
29810 Foo
29811 bar
29812 baz
29813
29814 {|
29815 |Foo
29816 bar
29817 baz bang
29818 |}
29819
29820 <!--boo-->foo
29821 bar
29822
29823 foo
29824 bar<span>boo</span>
29825 !! end
29826
29827 !! test
29828 4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs
29829 !! options
29830 parsoid={
29831 "modes": ["selser"],
29832 "scrubWikitext": true,
29833 "changes": [
29834 [ "p", "html", " a\n b" ]
29835 ]
29836 }
29837 !! wikitext
29838 xyz
29839 !! wikitext/edited
29840 a
29841 b
29842 !! end
29843
29844 !! test
29845 1. New links that end in spaces
29846 !! options
29847 parsoid={
29848 "modes": ["html2wt"],
29849 "scrubWikitext": false
29850 }
29851 !! html/parsoid
29852 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
29853 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
29854 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
29855 !! wikitext
29856 [[Berlin ]]<nowiki/>is the capital of Germany.
29857
29858 [[Foo ]]'''bar'''
29859
29860 [[Boston ]] is a city.
29861 !! end
29862
29863 !! test
29864 2. New links that end in spaces
29865 !! options
29866 parsoid={
29867 "modes": ["html2wt"],
29868 "scrubWikitext": true
29869 }
29870 !! html/parsoid
29871 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
29872 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
29873 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
29874 !! wikitext
29875 [[Berlin]] is the capital of Germany.
29876
29877 [[Foo]] '''bar'''
29878
29879 [[Boston]] is a city.
29880 !! end
29881
29882 !! test
29883 1. Table cells with escapable prefixes
29884 !! options
29885 parsoid={
29886 "modes": ["html2wt"],
29887 "scrubWikitext": false
29888 }
29889 !! html
29890 <table>
29891 <tr><td>a</td></tr>
29892 <tr><td>-</td></tr>
29893 <tr><td>+</td></tr>
29894 </table>
29895 !! wikitext
29896 {|
29897 |a
29898 |-
29899 |<nowiki>-</nowiki>
29900 |-
29901 |<nowiki>+</nowiki>
29902 |}
29903 !! end
29904
29905 !! test
29906 2. Table cells with escapable prefixes
29907 !! options
29908 parsoid={
29909 "modes": ["html2wt"],
29910 "scrubWikitext": true
29911 }
29912 !! html
29913 <table>
29914 <tr><td>a</td></tr>
29915 <tr><td>-</td></tr>
29916 <tr><td>+</td></tr>
29917 </table>
29918 !! wikitext
29919 {|
29920 |a
29921 |-
29922 | -
29923 |-
29924 | +
29925 |}
29926 !! end
29927
29928 !! test
29929 3a. Table cells with escapable prefixes after edits
29930 !! options
29931 parsoid={
29932 "modes": ["selser"],
29933 "scrubWikitext": true,
29934 "changes": [
29935 [ "table tbody tr:first-child td:first-child", "remove"]
29936 ]
29937 }
29938 !! wikitext
29939 {|
29940 |a||-
29941 |}
29942 !! wikitext/edited
29943 {|
29944 | -
29945 |}
29946 !! end
29947
29948 !! test
29949 3b. Table cells with escapable prefixes after edits
29950 !! options
29951 parsoid={
29952 "modes": ["selser"],
29953 "scrubWikitext": true,
29954 "changes": [
29955 [ "table tbody tr:first-child td:first-child", "html", "-" ],
29956 [ "#x", "remove" ]
29957 ]
29958 }
29959 !! wikitext
29960 {|
29961 |pqr
29962 |<span id="x">foo</span>+
29963 |}
29964 !! wikitext/edited
29965 {|
29966 | -
29967 | +
29968 |}
29969 !! end
29970
29971 # FIXME: This test will fail because
29972 # normalization doesn't realize that the id attribute
29973 # will eliminate the escapable scenario
29974 !! test
29975 4a. Table cells without escapable prefixes after edits
29976 !! options
29977 parsoid={
29978 "modes": ["selser"],
29979 "scrubWikitext": true,
29980 "changes": [
29981 [ "#x", "html", "-" ]
29982 ]
29983 }
29984 !! wikitext
29985 {|
29986 | id="x" |abcd
29987 |}
29988 !! wikitext/edited
29989 {|
29990 | id="x" |-
29991 |}
29992 !! end
29993
29994 ## This tests normalizer's ability to discriminate between
29995 ## cells having identical content.
29996 !! test
29997 4b. Table cells without escapable prefixes after edits
29998 !! options
29999 parsoid={
30000 "modes": ["selser"],
30001 "scrubWikitext": true,
30002 "changes": [
30003 [ "td", "html", "-" ]
30004 ]
30005 }
30006 !! wikitext
30007 {|
30008 |a||b
30009 |}
30010 !! wikitext/edited
30011 {|
30012 | -||-
30013 |}
30014 !! end
30015
30016 ## This tests normalizer's ability to not be tripped by
30017 ## comments (and whitespace)
30018 !! test
30019 4c. Table cells without escapable prefixes after edits
30020 !! options
30021 parsoid={
30022 "modes": ["selser"],
30023 "scrubWikitext": true,
30024 "changes": [
30025 [ "table tbody tr td:first-child", "remove" ]
30026 ]
30027 }
30028 !! wikitext
30029 {|
30030 |-
30031 <!--foo--> |a||-
30032 |}
30033 !! wikitext/edited
30034 {|
30035 |-
30036 <!--foo--> | -
30037 |}
30038 !! end
30039
30040 ## This tests normalizer's ability to handle HTML cells
30041 !! test
30042 4d. Table cells without escapable prefixes after edits
30043 !! options
30044 parsoid={
30045 "modes": ["selser"],
30046 "scrubWikitext": true,
30047 "changes": [
30048 [ "td", "html", "-" ]
30049 ]
30050 }
30051 !! wikitext
30052 <table>
30053 <tr><td>a</td></tr>
30054 </table>
30055 !! wikitext/edited
30056 <table>
30057 <tr><td>-</td></tr>
30058 </table>
30059 !! end
30060
30061 ## T111151 Remove font elements without attributes
30062 !! test
30063 5a. font tags without attributes should be dropped in scrubWikitext mode
30064 !! options
30065 parsoid={
30066 "modes": ["html2wt"],
30067 "scrubWikitext": true
30068 }
30069 !! html
30070 <font>foo</font>
30071 <font><font>bar</font></font>
30072 <font class="x">boo</font>
30073 !! wikitext
30074 foo
30075 bar
30076 <font class="x">boo</font>
30077 !! end
30078
30079 !! test
30080 5b. font tags should not be dropped without scrubWikitext being enabled
30081 !! options
30082 parsoid={
30083 "modes": ["html2wt"],
30084 "scrubWikitext": false
30085 }
30086 !! html
30087 <font>foo</font>
30088 !! wikitext
30089 <font>foo</font>
30090 !! end
30091
30092 !! test
30093 Escape nowiki DOM elements
30094 !! options
30095 parsoid=html2wt
30096 !! html/parsoid
30097 <nowiki><i>foo</i></nowiki>
30098 !! wikitext
30099 &lt;nowiki&gt;''foo''&lt;/nowiki&gt;
30100 !! end
30101
30102 # This is meant to be an interim fix while we go about figuring out
30103 # how to not introduce these trailing <nowiki/>s in the first place.
30104 !! test
30105 T115717: Strip trailing <nowiki/>s (without affecting valid uses)
30106 !! options
30107 parsoid=html2wt
30108 !! html/parsoid
30109 <p>x<meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/>
30110 y</p>
30111 <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>
30112 <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>
30113 !! wikitext
30114 x
30115 y
30116
30117 {{echo|
30118 1 = <nowiki/>}}
30119
30120 {{echo|
30121 1 = <nowiki/>
30122 }}
30123 !! end
30124
30125 !! test
30126 New list is serialized on newlines
30127 !! options
30128 parsoid=html2wt
30129 !! html/parsoid
30130 <p>The quick brown fox jumps over the lazy dog.</p><ul>
30131 <li>Yesterday</li>
30132 <li>Today</li>
30133 <li>Tomorrow</li>
30134 </ul><p>The quick onyx goblin jumps over the lazy dwarf.</p>
30135 !! wikitext
30136 The quick brown fox jumps over the lazy dog.
30137
30138 * Yesterday
30139 * Today
30140 * Tomorrow
30141
30142 The quick onyx goblin jumps over the lazy dwarf.
30143 !! end
30144
30145 !! test
30146 New lists in formatting elements serialized w/o newlines
30147 !! options
30148 parsoid=html2wt
30149 !! html/parsoid
30150 <small>
30151
30152 <ul>
30153 <li>123</li>
30154 </ul>
30155
30156 </small>
30157
30158 <small><ul><li>hi</li></ul></small>
30159 !! wikitext
30160 <small>
30161 * 123
30162 </small>
30163
30164 <small>
30165 * hi
30166 </small>
30167 !! end
30168
30169 !! test
30170 New list in table doesn't need newlines
30171 !! options
30172 parsoid=html2wt
30173 !! html/parsoid
30174 <table><tr><td><ul><li>test</li><li>123</li></td></tr></table>
30175 !! wikitext
30176 {|
30177 |
30178 * test
30179 * 123
30180 |}
30181 !! end
30182
30183 # ---------------------------------------------------
30184 # End of tests spec'ing wikitext serialization norms |
30185 # ---------------------------------------------------
30186
30187 # T104032
30188 !! test
30189 Bare inline nodes not wrapped inside p-tags should be treated as p-wrapped
30190 !! options
30191 parsoid=html2wt
30192 !! html/parsoid
30193 a<p>b</p>
30194 <b>c</b><p>d</p>
30195 <table><tr>
30196 <td>a<p>b</p></td>
30197 <td><b>c</b><p>d</p></td>
30198 </tr></table>
30199 !! wikitext
30200 a
30201
30202 b
30203
30204 '''c'''
30205
30206 d
30207 {|
30208 |a
30209 b
30210 |'''c'''
30211 d
30212 |}
30213 !! end
30214
30215 !! test
30216 Anchor without href scenarios
30217 !! options
30218 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
30219 !! html/parsoid
30220 <a class="bc"></a>
30221 <a class="no">dice</a>
30222 <a name="foo"></a>
30223 !! wikitext
30224
30225 dice
30226 <span name="foo"></span>
30227 !! end
30228
30229 !! test
30230 New transclusion added after a list should be serialized after the list
30231 !! options
30232 parsoid=html2wt
30233 !! html/parsoid
30234 <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>
30235 !! wikitext
30236 * a
30237 {{echo|foo}}
30238 !! end
30239
30240 # -----------------------------------------------------------------
30241 # End of section for Parsoid-only html2wt tests for serialization
30242 # of new content
30243 # -----------------------------------------------------------------
30244
30245 # -----------------------------------------------------------------
30246 # The following section of tests are primarily to spec behavior of
30247 # the selective serializer. All these tests have manual selser
30248 # changes. The automated selser changes for all tests handle the
30249 # wide variation of changes, but these tests here capture specs
30250 # deterministically.
30251 # ----------------------------------------------------------------
30252
30253 ## T90517
30254 !! test
30255 Selser: New comments should not be lost
30256 !! options
30257 parsoid={
30258 "modes": ["selser"],
30259 "changes": [
30260 [ "#a", "after", "<!--c1-->" ],
30261 [ "#b", "before", "<!--c2-->" ]
30262 ]
30263 }
30264 !! wikitext
30265 <span id="a">a</span>
30266
30267 <span id="b">b</span>
30268 !! wikitext/edited
30269 <span id="a">a</span><!--c1-->
30270
30271 <!--c2--><span id="b">b</span>
30272 !! end
30273
30274 ## T89383
30275 !! test
30276 Selser: Check for validity of DSR before using it
30277 !! options
30278 parsoid={
30279 "modes": ["selser"],
30280 "changes": [
30281 [ "#a", "before", "<meta property='mw:PageProp/displaytitle' content='foo'>" ]
30282 ]
30283 }
30284 !! wikitext
30285 <span id="a">a</span>
30286 !! wikitext/edited
30287 {{DISPLAYTITLE:foo}}
30288 <span id="a">a</span>
30289 !! end
30290
30291 !! test
30292 1. DOMDiff: Changes to <ref> content should be looked up using id
30293 !! options
30294 parsoid={
30295 "modes": ["selser"],
30296 "changes": [
30297 ["#X", "after", "bar"],
30298 ["#Y", "after", "baz"]
30299 ]
30300 }
30301 !! wikitext
30302 X <ref><span id="X">foo</span></ref>
30303 Y <ref name="a" />
30304 <references>
30305 <ref name="a"><span id="Y">foo</span></ref>
30306 </references>
30307 !! wikitext/edited
30308 X <ref><span id="X">foo</span>bar</ref>
30309 Y <ref name="a" />
30310 <references>
30311 <ref name="a"><span id="Y">foo</span>baz</ref>
30312 </references>
30313 !! end
30314
30315 !! test
30316 2. DOMDiff: Changes to <ref> content should be looked up using id
30317 !! options
30318 parsoid={
30319 "modes": ["selser"],
30320 "changes": [
30321 ["#Z", "after", "bar"]
30322 ]
30323 }
30324 !! wikitext
30325 A <ref>foo bar for a</ref>
30326 B <ref group="X" name="b" />
30327
30328 <references />
30329
30330 <references group="X">
30331 <ref name="b"><span id="Z">foo</span></ref>
30332 </references>
30333 !! wikitext/edited
30334 A <ref>foo bar for a</ref>
30335 B <ref group="X" name="b" />
30336
30337 <references />
30338
30339 <references group="X">
30340 <ref name="b"><span id="Z">foo</span>bar</ref>
30341 </references>
30342 !! end
30343
30344 !! test
30345 DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388)
30346 !! options
30347 parsoid={
30348 "modes": ["selser"],
30349 "changes": [
30350 [ "div:first-child", "text", "bar" ]
30351 ]
30352 }
30353 !! wikitext
30354 <div style="{{1x|color:red;}}%">foo</div>
30355 !! wikitext/edited
30356 <div style="{{1x|color:red;}}%">bar</div>
30357 !! end
30358
30359 !! test
30360 Empty LI (T49673)
30361 !! wikitext
30362 *a
30363 *
30364 *
30365 *b
30366 !! html+tidy
30367 <ul><li>a</li>
30368 <li class="mw-empty-elt"></li>
30369 <li class="mw-empty-elt"></li>
30370 <li>b</li></ul>
30371 !! end
30372
30373 !! test
30374 Thumbnail output
30375 !! wikitext
30376 [[File:Thumb.png|thumb]]
30377 !! html/php+tidy
30378 <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>
30379 !! html/parsoid
30380 <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>
30381 !! end
30382
30383 !! test
30384 unclosed internal link XSS (T137264)
30385 !! wikitext
30386 [[#%3Cscript%3Ealert(1)%3C/script%3E|
30387 !! html/php
30388 <p>[[#&lt;script&gt;alert(1)&lt;/script&gt;|
30389 </p>
30390 !! html/parsoid
30391 <p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p>
30392 !! end
30393
30394 !! test
30395 Validating that <style> isn't eaten by tidy (T167349)
30396 !! options
30397 styletag=1
30398 !! wikitext
30399 <div class="foo">
30400 <style>.foo::before { content: "<foo>"; }</style>
30401 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
30402 </div>
30403 !! html/php+tidy
30404 <div class="foo">
30405 <style>.foo::before { content: "<foo>"; }</style>
30406 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
30407 </div>
30408 !! end
30409
30410 !! test
30411 Validating that <style> isn't wrapped in a paragraph (T186965)
30412 !! options
30413 styletag=1
30414 !! wikitext
30415 A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
30416
30417 <style>.foo::before { content: "<foo>"; }</style>
30418
30419 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
30420
30421 But if it's on a line with other content, let it be wrapped.
30422
30423 <style>.foo::before { content: "<foo>"; }</style> bar
30424
30425 foo <style>.foo::before { content: "<foo>"; }</style>
30426
30427 foo <style>.foo::before { content: "<foo>"; }</style> bar
30428
30429 And the same if we have non-paragraph-breaking whitespace
30430
30431 foo
30432 <style>.foo::before { content: "<foo>"; }</style>
30433 bar
30434 !! html/php
30435 <p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
30436 </p>
30437 <style>.foo::before { content: "<foo>"; }</style>
30438 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
30439 <p>But if it's on a line with other content, let it be wrapped.
30440 </p><p><style>.foo::before { content: "<foo>"; }</style> bar
30441 </p><p>foo <style>.foo::before { content: "<foo>"; }</style>
30442 </p><p>foo <style>.foo::before { content: "<foo>"; }</style> bar
30443 </p><p>And the same if we have non-paragraph-breaking whitespace
30444 </p><p>foo
30445 <style>.foo::before { content: "<foo>"; }</style>
30446 bar
30447 </p>
30448 !! end
30449
30450 !! test
30451 Validating that <link> isn't wrapped in a paragraph (T186965)
30452 !! options
30453 styletag=1
30454 !! wikitext
30455 A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
30456
30457 <link rel="foo" href="bar"/>
30458
30459 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
30460
30461 But if it's on a line with other content, let it be wrapped.
30462
30463 <link rel="foo" href="bar"/> bar
30464
30465 foo <link rel="foo" href="bar"/>
30466
30467 foo <link rel="foo" href="bar"/> bar
30468
30469 And the same if we have non-paragraph-breaking whitespace
30470
30471 foo
30472 <link rel="foo" href="bar"/>
30473 bar
30474 !! html/php
30475 <p>A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
30476 </p>
30477 <link rel="foo" href="bar"/>
30478 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
30479 <p>But if it's on a line with other content, let it be wrapped.
30480 </p><p><link rel="foo" href="bar"/> bar
30481 </p><p>foo <link rel="foo" href="bar"/>
30482 </p><p>foo <link rel="foo" href="bar"/> bar
30483 </p><p>And the same if we have non-paragraph-breaking whitespace
30484 </p><p>foo
30485 <link rel="foo" href="bar"/>
30486 bar
30487 </p>
30488 !! end
30489
30490 !! test
30491 Decoding of HTML entities in headings and links for IDs and link fragments (T103714)
30492 !! config
30493 wgFragmentMode=[ 'html5', 'legacy' ]
30494 !! wikitext
30495 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
30496 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
30497 !! html/php
30498 <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>
30499 <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>
30500 </p>
30501 !! html/parsoid
30502 <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>
30503 <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>
30504 !! end
30505
30506 !! test
30507 Decoding of HTML entities in headings and links for IDs and link fragments (T103714) (legacy)
30508 !! config
30509 wgFragmentMode=[ 'legacy' ]
30510 !! wikitext
30511 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
30512 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
30513 !! html/php
30514 <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>
30515 <p><a href="#A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a>
30516 </p>
30517 !! end
30518
30519 !! test
30520 Decoding of HTML entities in embedded HTML tags
30521 !! wikitext
30522 <table class="1&2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
30523 !! html/php
30524 <table class="1&amp;2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
30525
30526 !! html/parsoid
30527 <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>
30528 !! end
30529
30530 !! test
30531 Decoding of HTML entities in indicator names for IDs (T104196)
30532 !! options
30533 parsoid=wt2html,html2html
30534 showindicators
30535 !! wikitext
30536 <indicator name="1&2&amp;3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
30537 !! html/php
30538 1&2&3&amp;4&amp;amp;5=Indicator
30539
30540 !! html/parsoid
30541 <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>
30542 !! end
30543
30544 # this version of the test strips out the ambiguity so Parsoid rts cleanly
30545 !! test
30546 Decoding of HTML entities in indicator names for IDs (unambiguous) (T104196)
30547 !! options
30548 showindicators
30549 !! wikitext
30550 <indicator name="1&2&3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
30551 !! html/php
30552 1&2&3&amp;4&amp;amp;5=Indicator
30553
30554 !! html/parsoid
30555 <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>
30556 !! end
30557
30558 # This fragment mode is what Parsoid supports.
30559 !! test
30560 HTML5 ids: fallback to legacy
30561 !! config
30562 wgFragmentMode=[ 'html5', 'legacy' ]
30563 !! wikitext
30564 ==Foo bar==
30565
30566 ==foo Bar==
30567
30568 ==Тест==
30569
30570 ==Тест==
30571
30572 ==тест==
30573
30574 ==Hey < # " > % : '==
30575 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
30576
30577 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
30578
30579 <!-- These two links should produce identical HTML -->
30580 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
30581
30582 !! html/php
30583 <div id="toc" class="toc"><input type="checkbox" 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>
30584 <ul>
30585 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
30586 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
30587 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
30588 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
30589 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
30590 <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>
30591 </ul>
30592 </div>
30593
30594 <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>
30595 <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>
30596 <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>
30597 <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>
30598 <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>
30599 <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>
30600 <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>
30601 </p><p>💩 <span id="💩"></span>
30602 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
30603 </p>
30604 !! html/parsoid
30605 <h2 id="Foo_bar">Foo bar</h2>
30606
30607 <h2 id="foo_Bar_2">foo Bar</h2>
30608
30609 <h2 id="Тест"><span id=".D0.A2.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>Тест</h2>
30610
30611 <h2 id="Тест_2"><span id=".D0.A2.D0.B5.D1.81.D1.82_2" typeof="mw:FallbackId"></span>Тест</h2>
30612
30613 <h2 id="тест"><span id=".D1.82.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>тест</h2>
30614
30615 <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>
30616 <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>
30617
30618 <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>
30619
30620 <!-- These two links should produce identical HTML -->
30621 <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>
30622 !! end
30623
30624 # Parsoid doesn't support this mode
30625 !! test
30626 HTML5 ids: legacy with a fallback to modern
30627 !! config
30628 wgFragmentMode=[ 'legacy', 'html5' ]
30629 !! wikitext
30630 ==Foo bar==
30631
30632 ==foo Bar==
30633
30634 ==Тест==
30635
30636 ==Тест==
30637
30638 ==тест==
30639
30640 ==Hey < # " > % : '==
30641 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
30642
30643 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
30644
30645 <!-- These two links should produce identical HTML -->
30646 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
30647
30648 !! html/php
30649 <div id="toc" class="toc"><input type="checkbox" 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>
30650 <ul>
30651 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
30652 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
30653 <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>
30654 <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>
30655 <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>
30656 <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>
30657 </ul>
30658 </div>
30659
30660 <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>
30661 <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>
30662 <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>
30663 <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>
30664 <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>
30665 <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>
30666 <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>
30667 </p><p>.F0.9F.92.A9 <span id=".F0.9F.92.A9"></span>
30668 </p><p><a href="#.E5.95.A4.E9.85.92">#啤酒</a> <a href="#.E5.95.A4.E9.85.92">#啤酒</a>
30669 </p>
30670 !! end
30671
30672 # Parsoid doesn't support this mode.
30673 !! test
30674 HTML5 ids: no legacy
30675 !! config
30676 wgFragmentMode=[ 'html5' ]
30677 !! wikitext
30678 ==Foo bar==
30679
30680 ==foo Bar==
30681
30682 ==Тест==
30683
30684 ==Тест==
30685
30686 ==тест==
30687
30688 ==Hey < # " > % : '==
30689 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
30690
30691 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
30692
30693 <!-- These two links should produce identical HTML -->
30694 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
30695
30696 !! html/php
30697 <div id="toc" class="toc"><input type="checkbox" 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>
30698 <ul>
30699 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
30700 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
30701 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
30702 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
30703 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
30704 <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>
30705 </ul>
30706 </div>
30707
30708 <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>
30709 <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>
30710 <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>
30711 <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>
30712 <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>
30713 <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>
30714 <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>
30715 </p><p>💩 <span id="💩"></span>
30716 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
30717 </p>
30718 !! end
30719
30720 !! test
30721 T90902: Normalize weird characters in section IDs
30722 !! config
30723 wgFragmentMode=[ 'html5', 'legacy' ]
30724 !! wikitext
30725 ==Foo&nbsp;bar==
30726 [[#Foo&nbsp;bar]]
30727
30728 !! html/php
30729 <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>
30730 <p><a href="#Foo_bar">#Foo&#160;bar</a>
30731 </p>
30732 !! html/parsoid
30733 <h2 id="Foo_bar"> Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span>bar </h2>
30734 <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>
30735 !! end
30736
30737 !! test
30738 T51672: Test for brackets in attributes of elements in external link texts
30739 !! wikitext
30740 [http://example.com/ link <span title="title with [brackets]">span</span>]
30741 [http://example.com/ link <span title="title with &#91;brackets&#93;">span</span>]
30742
30743 !! html/php
30744 <p><a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
30745 <a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
30746 </p>
30747 !! html/parsoid
30748 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/">link <span title="title with [brackets]">span</span></a>
30749 <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>
30750 !! end
30751
30752 !! test
30753 T72875: Test for brackets in attributes of elements in internal link texts
30754 !! wikitext
30755 [[Foo|link <span title="title with [[double brackets]]">span</span>]]
30756 [[Foo|link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span>]]
30757
30758 !! html/php
30759 <p><a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
30760 <a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
30761 </p>
30762 !! html/parsoid
30763 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">link <span title="title with [[double brackets]]">span</span></a>
30764 <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>
30765 !! end
30766
30767 !! test
30768 T179544: {{anchorencode:}} output should be always usable in links
30769 !! config
30770 wgFragmentMode=[ 'html5' ]
30771 !! wikitext
30772 <span id="{{anchorencode:[foo]}}"></span>[[#{{anchorencode:[foo]}}]]
30773 !! html/php
30774 <p><span id="&#91;foo&#93;"></span><a href="#[foo]">#&#91;foo&#93;</a>
30775 </p>
30776 !! html/parsoid
30777 <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>
30778 !! end
30779
30780 ## ------------------------------
30781 ## Parsoid section-wrapping tests
30782 ## ------------------------------
30783 !! test
30784 Section wrapping for well-nested sections (no leading content)
30785 !! options
30786 parsoid={
30787 "wrapSections": true
30788 }
30789 !! wikitext
30790 =1=
30791 a
30792
30793 =2=
30794 b
30795
30796 ==2.1==
30797 c
30798
30799 ==2.2==
30800 d
30801
30802 ===2.2.1===
30803 e
30804
30805 =3=
30806 f
30807 !! html/parsoid
30808 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
30809 <p>a</p>
30810
30811 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
30812 <p>b</p>
30813
30814 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
30815 <p>c</p>
30816
30817 </section><section data-mw-section-id="4"><h2 id="2.2">2.2</h2>
30818 <p>d</p>
30819
30820 <section data-mw-section-id="5"><h3 id="2.2.1">2.2.1</h3>
30821 <p>e</p>
30822
30823 </section></section></section><section data-mw-section-id="6"><h1 id="3">3</h1>
30824 <p>f</p>
30825
30826 </section>
30827 !! end
30828
30829 !! test
30830 Section wrapping for well-nested sections (with leading content)
30831 !! options
30832 parsoid={
30833 "wrapSections": true
30834 }
30835 !! wikitext
30836 Para 1.
30837
30838 Para 2 with a <div>nested in it</div>
30839
30840 Para 3.
30841
30842 =1=
30843 a
30844
30845 =2=
30846 b
30847
30848 ==2.1==
30849 c
30850 !! html/parsoid
30851 <section data-mw-section-id="0"><p>Para 1.</p>
30852
30853 <p>Para 2 with a </p><div>nested in it</div>
30854
30855 <p>Para 3.</p>
30856
30857 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
30858 <p>a</p>
30859
30860 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
30861 <p>b</p>
30862
30863 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
30864 <p>c</p>
30865
30866 </section></section>
30867 !! end
30868
30869 !! test
30870 Section wrapping with template-generated sections (good nesting 1)
30871 !! options
30872 parsoid={
30873 "wrapSections": true
30874 }
30875 !! wikitext
30876 =1=
30877 a
30878
30879 {{echo|1=
30880 ==1.1==
30881 b
30882 }}
30883
30884 ==1.2==
30885 c
30886
30887 =2=
30888 d
30889 !! html/parsoid
30890 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
30891 <p>a</p>
30892
30893 <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">
30894 </span><p about="#mwt1">b</p>
30895 </section><section data-mw-section-id="3"><h2 id="1.2">1.2</h2>
30896 <p>c</p>
30897
30898 </section></section><section data-mw-section-id="4"><h1 id="2">2</h1>
30899 <p>d</p></section>
30900 !! end
30901
30902 # In this example, the template scope is mildly expanded to incorporate the
30903 # trailing newline after the transclusion since that is part of section 1.1.1
30904 !! test
30905 Section wrapping with template-generated sections (good nesting 2)
30906 !! options
30907 parsoid={
30908 "wrapSections": true,
30909 "modes": ["wt2html", "wt2wt"]
30910 }
30911 !! wikitext
30912 =1=
30913 a
30914
30915 {{echo|1=
30916 ==1.1==
30917 b
30918 ===1.1.1===
30919 d
30920 }}
30921 =2=
30922 e
30923 !! html/parsoid
30924 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
30925 <p>a</p>
30926
30927 <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">
30928 </span><p about="#mwt1">b</p><span about="#mwt1">
30929 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.1.1">1.1.1</h3><span about="#mwt1">
30930 </span><p about="#mwt1">d</p><span about="#mwt1">
30931 </span></section></section></section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="2">2</h1>
30932 <p>e</p></section>
30933 !! end
30934
30935 # In this example, the template scope is mildly expanded to incorporate the
30936 # trailing newline after the transclusion since that is part of section 1.2.1
30937 !! test
30938 Section wrapping with template-generated sections (good nesting 3)
30939 !! options
30940 parsoid={
30941 "wrapSections": true,
30942 "modes": ["wt2html", "wt2wt"]
30943 }
30944 !! wikitext
30945 =1=
30946 a
30947
30948 {{echo|1=
30949 x
30950 ==1.1==
30951 b
30952 ==1.2==
30953 c
30954 ===1.2.1===
30955 d
30956 }}
30957 =2=
30958 e
30959 !! html/parsoid
30960 <section data-mw-section-id="0"></section><section data-mw-section-id="1" data-parsoid="{}"><h1 id="1"> 1 </h1>
30961 <p>a</p>
30962
30963 <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">
30964 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.1">1.1</h2><span about="#mwt1">
30965 </span><p about="#mwt1">b</p><span about="#mwt1">
30966 </span></section><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.2">1.2</h2><span about="#mwt1">
30967 </span><p about="#mwt1">c</p><span about="#mwt1">
30968 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.2.1">1.2.1</h3><span about="#mwt1">
30969 </span><p about="#mwt1">d</p><span about="#mwt1">
30970 </span></section></section></section><section data-mw-section-id="5"><h1 id="2">2</h1>
30971 <p>e</p></section>
30972 !! end
30973
30974 # Because of section-wrapping and template-wrapping interactions,
30975 # the scope of the template is expanded so that the template markup
30976 # is valid in the presence of <section> tags.
30977 # This exercises the s1 is null scenario in the wrapSections code
30978 !! test
30979 Section wrapping with template-generated sections (bad nesting 1)
30980 !! options
30981 parsoid={
30982 "wrapSections": true
30983 }
30984 !! wikitext
30985 <div>
30986 a
30987
30988 {{echo|
30989 =1=
30990 b
30991 }}
30992
30993 c
30994 </div>
30995 !! html/parsoid
30996 <section data-mw-section-id="-1"></section><section data-mw-section-id="-2"><div data-parsoid='{"stx":"html"}'>
30997 <p>a</p>
30998
30999 <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"]}'>
31000 </span><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="1">1</h1><span about="#mwt1">
31001 </span><p about="#mwt1">b
31002 </p><span about="#mwt1">
31003
31004 </span><p about="#mwt1">c</p><span about="#mwt1">
31005 </span></section></div></section>
31006 !! end
31007
31008 # Because of section-wrapping and template-wrapping interactions,
31009 # the scope of the template is expanded so that the template markup
31010 # is valid in the presence of <section> tags.
31011 # This exercises the s1 is ancestor of s2 scenario in the wrapSections code
31012 !! test
31013 Section wrapping with template-generated sections (bad nesting 2)
31014 !! options
31015 parsoid={
31016 "wrapSections": true
31017 }
31018 !! wikitext
31019 =1=
31020 a
31021
31022 {{echo|1=
31023 =2=
31024 b
31025 ==2.1==
31026 c
31027 }}
31028
31029 d
31030
31031 =3=
31032 e
31033 !! html/parsoid
31034 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
31035 <p>a</p>
31036
31037 </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">
31038 </span><p about="#mwt1">b</p><span about="#mwt1">
31039 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="2.1">2.1</h2><span about="#mwt1">
31040 </span><p about="#mwt1">c</p><span about="#mwt1">
31041
31042 </span><p about="#mwt1">d</p><span about="#mwt1">
31043
31044 </span></section></section><section data-mw-section-id="4"><h1 id="3">3</h1>
31045 <p>e</p></section>
31046 !! end
31047
31048 # Because of section-wrapping and template-wrapping interactions,
31049 # additional template wrappers are added to <section> tags
31050 # so that template wrapping semantics are valid whether section
31051 # tags are retained or stripped. But, the template scope can expand
31052 # greatly when accounting for section tags.
31053 # This exercises the s1 and s2 are in different subtrees scenario
31054 !! test
31055 Section wrapping with template-generated sections (bad nesting 3)
31056 !! options
31057 parsoid={
31058 "wrapSections": true,
31059 "modes": ["wt2html", "wt2wt"]
31060 }
31061 !! wikitext
31062 =1=
31063 a
31064
31065 {{echo|1=
31066 ==1.2==
31067 b
31068 =2=
31069 c
31070 }}
31071
31072 d
31073
31074 =3=
31075 e
31076 !! html/parsoid
31077 <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>
31078 <p>a</p>
31079
31080 <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">
31081 </span><p about="#mwt1">b</p><span about="#mwt1">
31082 </span></section></section><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="2">2</h1><span about="#mwt1">
31083 </span><p about="#mwt1">c</p>
31084
31085 <p>d</p>
31086 </section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="3">3</h1>
31087 <p>e</p></section>
31088 !! end
31089
31090 !! test
31091 Section wrapping with uneditable lead section + div wrapping multiple sections
31092 !! options
31093 parsoid={
31094 "wrapSections": true
31095 }
31096 !! wikitext
31097 foo
31098
31099 <div style="border:1px solid red;">
31100 =1=
31101 a
31102
31103 ==1.1==
31104 b
31105
31106 =2=
31107 c
31108 </div>
31109
31110 =3=
31111 d
31112
31113 ==3.1==
31114 e
31115 !! html/parsoid
31116 <section data-mw-section-id="-1"><p>foo</p>
31117
31118 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
31119 <section data-mw-section-id="1"><h1 id="1">1</h1>
31120 <p>a</p>
31121
31122 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
31123 <p>b</p>
31124
31125 </section></section><section data-mw-section-id="-1"><h1 id="2">2</h1>
31126 <p>c</p>
31127 </section></div>
31128
31129 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
31130 <p>d</p>
31131
31132 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
31133 <p>e</p>
31134 </section></section>
31135 !! end
31136
31137 !! test
31138 Section wrapping with editable lead section + div overlapping multiple sections
31139 !! options
31140 parsoid={
31141 "wrapSections": true
31142 }
31143 !! wikitext
31144 foo
31145
31146 =1=
31147 a
31148 <div style="border:1px solid red;">
31149 b
31150
31151 ==1.1==
31152 c
31153
31154 =2=
31155 d
31156 </div>
31157 e
31158
31159 =3=
31160 f
31161
31162 ==3.1==
31163 g
31164 !! html/parsoid
31165 <section data-mw-section-id="0"><p>foo</p>
31166
31167 </section><section data-mw-section-id="-1"><h1 id="1">1</h1>
31168 <p>a</p>
31169 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
31170 <p>b</p>
31171
31172 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
31173 <p>c</p>
31174
31175 </section><section data-mw-section-id="-1"><h1 id="2">2</h1>
31176 <p>d</p>
31177 </section></div>
31178 <p>e</p>
31179
31180 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
31181 <p>f</p>
31182
31183 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
31184 <p>g</p>
31185 </section></section>
31186 !! end
31187
31188 !! test
31189 HTML header tags should not be wrapped in section tags
31190 !! options
31191 parsoid={
31192 "wrapSections": true
31193 }
31194 !! wikitext
31195 foo
31196
31197 <h1>a</h1>
31198
31199 =b=
31200
31201 <h1>c</h1>
31202
31203 =d=
31204 !! html/parsoid
31205 <section data-mw-section-id="0"><p>foo</p>
31206
31207 <h1 id="a" data-parsoid='{"stx":"html"}'>a</h1>
31208
31209 </section><section data-mw-section-id="1"><h1 id="b">b</h1>
31210
31211 <h1 id="c" data-parsoid='{"stx":"html"}'>c</h1>
31212
31213 </section><section data-mw-section-id="2"><h1 id="d">d</h1></section>
31214 !! end
31215
31216 !! test
31217 Lead section containing only whitespace and comments.
31218 !! options
31219 parsoid={
31220 "wrapSections": true
31221 }
31222 !! wikitext
31223
31224 <!-- this is a comment, presumably significant to editors -->
31225 =1=
31226 a
31227
31228 =2=
31229 b
31230 !! html/parsoid
31231 <section data-mw-section-id="0" data-parsoid="{}">
31232 <!-- this is a comment, presumably significant to editors -->
31233 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
31234 <p>a</p>
31235
31236 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
31237 <p>b</p></section>
31238 !! end
31239
31240 !! test
31241 Pseudo-sections emitted by templates should have id -2
31242 !! options
31243 parsoid={
31244 "wrapSections": true
31245 }
31246 !! wikitext
31247 foo
31248 {{echo|<div>
31249 ==a==
31250 ==b==
31251 </div>
31252 }}
31253 !! html/parsoid
31254 <section data-mw-section-id="-1"><p>foo</p>
31255 </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}}]}'>
31256 <section data-mw-section-id="-1"><h2 id="a">a</h2>
31257 </section><section data-mw-section-id="-1"><h2 id="b">b</h2>
31258 </section></div><span about="#mwt1">
31259 </span></section>
31260 !! end
31261
31262 ##########################################################################
31263 Tests demonstrating white-space insensitivity in input wikitext
31264 for wikitext headings, wikitext list items, and wikitext table captions,
31265 headings, and cells. HTML versions of the same should preserve whitespace.
31266 ##########################################################################
31267 !! test
31268 Trim whitespace in wikitext headings, list items, table captions, headings, and cells
31269 !! options
31270 parsoid={
31271 "modes": ["wt2html"],
31272 "preserveIEW": true
31273 }
31274 !! wikitext
31275 __NOTOC__
31276 == <!--c1--> <!--c2--> Spaces <!--c3--> <!--c4--> ==
31277 == <!--c1--> <!--c2--> Tabs <!--c3--><!--c4--> ==
31278 == <!--Headings with fallback ids--> Личная жизнь ==
31279 * <!--c1--> <!--c2--> List item <!--c3--> <!--c4-->
31280 ; <!--term to define--> term : <!--term's definition--> definition
31281 {|
31282 |+ <!--c1--> <!--c2--> Table Caption <!--c3--> <!--c4-->
31283 |-
31284 ! <!--c1--> <!--c2--> Table Heading 1 <!--c3--> <!--c4--> !! Table Heading 2 <!--c5-->
31285 |-
31286 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
31287 |-
31288 | class="foo" || <!--c1--> <!--c2--> Table Cell 3 <!--c3--> <!--c4-->
31289 |-
31290 | <!--c1--> testing [[one|two]] <!--c2--> | <!--c3--> some content
31291 |}
31292 : {|
31293 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
31294 |} foo <!--c1-->
31295 !! html/php+tidy
31296 <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>
31297 <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>
31298 <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>
31299 <ul><li>List item</li></ul>
31300 <dl><dt>term&#160;</dt>
31301 <dd>definition</dd></dl>
31302 <table>
31303 <caption>Table Caption
31304 </caption>
31305 <tbody><tr>
31306 <th>Table Heading 1</th>
31307 <th>Table Heading 2
31308 </th></tr>
31309 <tr>
31310 <td>Table Cell 1</td>
31311 <td>Table Cell 2
31312 </td></tr>
31313 <tr>
31314 <td>class="foo"</td>
31315 <td>Table Cell 3
31316 </td></tr>
31317 <tr>
31318 <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
31319 </td></tr></tbody></table>
31320 <dl><dd><table>
31321 <tbody><tr>
31322 <td>Table Cell 1</td>
31323 <td>Table Cell 2
31324 </td></tr></tbody></table> foo</dd></dl>
31325 !! html/parsoid
31326 <meta property="mw:PageProp/notoc">
31327 <h2 id="Spaces"><!--c1--><!--c2-->Spaces<!--c3--><!--c4--></h2>
31328 <h2 id="Tabs"><!--c1--><!--c2-->Tabs<!--c3--><!--c4--></h2>
31329 <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>
31330 <ul><li><!--c1--><!--c2-->List item<!--c3--><!--c4--></li></ul>
31331 <dl><dt><!--term to define-->term&nbsp;</dt><dd><!--term's definition-->definition</dd></dl>
31332 <table>
31333 <caption><!--c1--><!--c2-->Table Caption<!--c3--><!--c4--></caption>
31334 <tbody><tr>
31335 <th><!--c1--><!--c2-->Table Heading 1<!--c3--><!--c4--></th><th>Table Heading 2<!--c5--></th></tr>
31336 <tr>
31337 <td><!--c1--><!--c2-->Table Cell 1<!--c3--><!--c4--></td><td>Table Cell 2<!--c5--></td></tr>
31338 <tr>
31339 <td>class="foo"</td><td><!--c1--><!--c2-->Table Cell 3<!--c3--><!--c4--></td></tr>
31340 <tr>
31341 <td><!--c1-->testing <a rel="mw:WikiLink" href="./One" title="One">two</a> <!--c2--> | <!--c3--> some content</td></tr>
31342 </tbody></table>
31343 <dl><dd><table>
31344 <tbody><tr><td><!--c1--><!--c2-->Table Cell 1<!--c3--><!--c4--></td><td>Table Cell 2<!--c5--></td></tr>
31345 </tbody></table><p> foo </p><!--c1--></dd></dl>
31346 !! end
31347
31348 # Looks like <caption> is not accepted in HTML
31349 !! test
31350 Do not trim whitespace in HTML headings, list items, table captions, headings, and cells
31351 !! options
31352 parsoid={
31353 "modes": ["wt2html"],
31354 "preserveIEW": true
31355 }
31356 !! wikitext
31357 __NOTOC__
31358 <h2> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
31359 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
31360 <table>
31361 <tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> <th></tr>
31362 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> <th></tr>
31363 </table>
31364 !! html/php+tidy
31365 <h2><span class="mw-headline" id="Heading"> Heading </span></h2>
31366 <ul><li> List item </li></ul>
31367 <table>
31368 <tbody><tr><th> Table Heading </th><th></th></tr>
31369 <tr><td> Table Cell </td><th></th></tr>
31370 </tbody></table>
31371 !! html/parsoid
31372 <meta property="mw:PageProp/notoc"/>
31373 <h2 id="Heading"> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
31374 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
31375 <table>
31376 <tbody><tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> </th><th></th></tr>
31377 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> </td><th></th></tr>
31378 </tbody></table>
31379 !! end
31380
31381 !! test
31382 Do not trim whitespace in links and quotes
31383 !! options
31384 parsoid={
31385 "modes": ["wt2html"],
31386 "preserveIEW": true
31387 }
31388 !! wikitext
31389 foo '' <!--c1--> italic <!--c2--> '' and ''' <!--c3--> bold <!--c4--> '''
31390 [[Foo| some text ]]
31391 !! html/php+tidy
31392 <p>foo <i> italic </i> and <b> bold </b>
31393 <a href="/wiki/Foo" title="Foo"> some text </a>
31394 </p>
31395 !! html/parsoid
31396 <p>foo <i> <!--c1--> italic <!--c2--> </i> and <b> <!--c3--> bold <!--c4--> </b>
31397 <a rel="mw:WikiLink" href="./Foo" title="Foo"> some text </a></p>
31398 !! end
31399
31400 !! test
31401 Remove p tags surrounding a single element in a figcaption
31402 !! options
31403 parsoid=html2wt
31404 !! wikitext
31405 [[File:Foobar.jpg|right|200x200px|Caption]]
31406 !! html/parsoid
31407 <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>
31408 !! end
31409
31410 !! test
31411 Selser preserves lack of newline before list and allows newline after the list
31412 !! options
31413 parsoid={
31414 "modes": ["selser"],
31415 "scrubWikitext": true,
31416 "changes": [
31417 [ "ul", "after", "<p>footer</p>" ]
31418 ]
31419 }
31420 !! wikitext
31421 header
31422 *foo
31423 *bar
31424 !! wikitext/edited
31425 header
31426 *foo
31427 *bar
31428
31429 footer
31430 !! end
31431
31432
31433 !! test
31434 Selser does not introduce newlines between unedited paragraph preceding the list
31435 !! options
31436 parsoid={
31437 "modes": ["selser"],
31438 "changes": [
31439 [ "table tbody tr td p:last-child", "empty" ]
31440 ]
31441 }
31442 !! wikitext
31443 {|
31444 |
31445 header
31446 *foo
31447 *bar
31448 footer
31449 |}
31450 !! wikitext/edited
31451 {|
31452 |
31453 header
31454 *foo
31455 *bar
31456
31457 |}
31458 !! end
31459
31460 !! test
31461 Selser does not introduce newlines between unedited paragraph following the list
31462 !! options
31463 parsoid={
31464 "modes": ["selser"],
31465 "changes": [
31466 [ "table tbody tr td p:first-child", "empty" ]
31467 ]
31468 }
31469 !! wikitext
31470 {|
31471 |
31472 header
31473 *foo
31474 *bar
31475 footer
31476 |}
31477 !! wikitext/edited
31478 {|
31479 |
31480
31481 *foo
31482 *bar
31483 footer
31484 |}
31485 !! end
31486
31487 !! test
31488 Remove a list item but do not insert newline above list
31489 !! options
31490 parsoid={
31491 "modes": ["selser"],
31492 "changes": [
31493 [ "ul li:last-child", "remove" ]
31494 ]
31495 }
31496 !! wikitext
31497 header
31498 *foo
31499 *bar
31500 footer
31501 !! wikitext/edited
31502 header
31503 *foo
31504 footer
31505 !! end