0ae3f5352d4b459c69de5db05ce36e5feacfa80e
[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 !! end
2500
2501 !! test
2502 T17491: <ins>/<del> in blockquote (2)
2503 !! wikitext
2504 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2505 </blockquote>
2506 !! html
2507 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2508 </blockquote>
2509
2510 !! html+tidy
2511 <blockquote><p>Foo </p><del>bar</del> <ins>baz</ins><p> quux
2512 </p></blockquote>
2513 !! end
2514
2515 !! test
2516 <pre> with attributes (T5202)
2517 !! wikitext
2518 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2519 !! html
2520 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2521
2522 !! end
2523
2524 !! test
2525 <pre> with width attribute (T5202)
2526 !! wikitext
2527 <pre width="8">Narrow screen goodies</pre>
2528 !! html
2529 <pre width="8">Narrow screen goodies</pre>
2530
2531 !! end
2532
2533 !! test
2534 <pre> with forbidden attribute (T5202)
2535 !! wikitext
2536 <pre width="8" onmouseover="alert(document.cookie)">Narrow screen goodies</pre>
2537 !! html
2538 <pre width="8">Narrow screen goodies</pre>
2539
2540 !! end
2541
2542 !! test
2543 Entities inside <pre>
2544 !! wikitext
2545 <pre>&lt;</pre>
2546 !! html
2547 <pre>&lt;</pre>
2548
2549 !! end
2550
2551 !! test
2552 <pre> with forbidden attribute values (T5202)
2553 !! wikitext
2554 <pre width="8" style="border-width: expression(alert(document.cookie))">Narrow screen goodies</pre>
2555 !! html
2556 <pre width="8" style="/* insecure input */">Narrow screen goodies</pre>
2557
2558 !! end
2559
2560 !! test
2561 <nowiki> inside <pre> (T15238)
2562 !! wikitext
2563 <pre>
2564 <nowiki>
2565 </pre>
2566 <pre>
2567 <nowiki></nowiki>
2568 </pre>
2569 <pre><nowiki><nowiki></nowiki>Foo<nowiki></nowiki></nowiki></pre>
2570 !! html
2571 <pre>
2572 &lt;nowiki&gt;
2573 </pre>
2574 <pre>
2575
2576 </pre>
2577 <pre>&lt;nowiki&gt;Foo&lt;/nowiki&gt;</pre>
2578
2579 !! end
2580
2581 !! test
2582 <nowiki> inside of #tag:pre
2583 !! wikitext
2584 {{#tag:pre|Foo <nowiki>&rarr;bar</nowiki>}}
2585 !! html/php
2586 <pre>Foo &#8594;bar</pre>
2587
2588 !! html/parsoid
2589 <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>
2590 !! end
2591
2592 ## Don't expect this to rt, Parsoid drops the unmatched closing pre tags that
2593 ## aren't enclosed in nowikis.
2594 !! test
2595 <nowiki> and <pre> preference (first one wins)
2596 !! options
2597 parsoid=wt2html
2598 !! wikitext
2599 <pre>
2600 <nowiki>
2601 </pre>
2602 </nowiki>
2603 </pre>
2604
2605 <nowiki>
2606 <pre>
2607 <nowiki>
2608 </pre>
2609 </nowiki>
2610 </pre>
2611
2612 !! html/php
2613 <pre>
2614 &lt;nowiki&gt;
2615 </pre>
2616 <p>&lt;/nowiki&gt;
2617 &lt;/pre&gt;
2618 </p><p>
2619 &lt;pre&gt;
2620 &lt;nowiki&gt;
2621 &lt;/pre&gt;
2622
2623 &lt;/pre&gt;
2624 </p>
2625 !! html/parsoid
2626 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n&lt;nowiki>\n"}}'>&lt;nowiki>
2627 </pre>
2628 <p>&lt;/nowiki></p>
2629
2630
2631 <p><span typeof="mw:Nowiki">
2632 &lt;pre>
2633 &lt;nowiki>
2634 &lt;/pre>
2635 </span></p>
2636 !! end
2637
2638 !! test
2639 </pre> inside nowiki
2640 !! wikitext
2641 <nowiki></pre></nowiki>
2642 !! html
2643 <p>&lt;/pre&gt;
2644 </p>
2645 !! end
2646
2647 !! test
2648 Empty pre; pre inside other HTML tags (T56946)
2649 !! wikitext
2650 a
2651
2652 <div><pre>
2653 foo
2654 </pre></div>
2655 <pre></pre>
2656 !! html/php+tidy
2657 <p>a
2658 </p>
2659 <div><pre>foo
2660 </pre></div>
2661 <pre></pre>
2662 !! html/parsoid
2663 <p>a</p>
2664
2665 <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
2666 </pre></div>
2667 <pre typeof="mw:Extension/pre" about="#mwt4" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":""}}'></pre>
2668 !! end
2669
2670 !! test
2671 HTML pre followed by indent-pre
2672 !! wikitext
2673 <pre>foo</pre>
2674 bar
2675 !! html
2676 <pre>foo</pre>
2677 <pre>bar
2678 </pre>
2679 !! end
2680
2681 !! test
2682 Block tag pre
2683 !! wikitext
2684 <p><pre>foo</pre></p>
2685 !! html/php+tidy
2686 <p class="mw-empty-elt"></p><pre>foo</pre><p class="mw-empty-elt"></p>
2687 !! html/parsoid
2688 <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>
2689 !! end
2690
2691 !!test
2692 Templates: Indent-Pre: 1a. Templates that break a line should suppress <pre>
2693 !! wikitext
2694 {{echo|}}
2695 !! html
2696
2697 !!end
2698
2699 !!test
2700 Templates: Indent-Pre: 1b. Templates that break a line should suppress <pre>
2701 !! wikitext
2702 {{echo|
2703 foo}}
2704 !! html
2705 <p>foo
2706 </p>
2707 !!end
2708
2709 !! test
2710 Templates: Indent-Pre: 1c: Wrapping should be based on expanded content
2711 !! wikitext
2712 {{echo|a
2713 b}}
2714 !! html
2715 <pre>a
2716 </pre>
2717 <p>b
2718 </p>
2719 !!end
2720
2721 !! test
2722 Templates: Indent-Pre: 1d: Wrapping should be based on expanded content
2723 !! wikitext
2724 {{echo|a
2725 b
2726 c
2727 d
2728 e
2729 }}
2730 !! html
2731 <pre>a
2732 </pre>
2733 <p>b
2734 c
2735 </p>
2736 <pre>d
2737 </pre>
2738 <p>e
2739 </p>
2740 !!end
2741
2742 !!test
2743 Templates: Indent-Pre: 1e. Wrapping should be based on expanded content
2744 !! wikitext
2745 {{echo| foo}}
2746
2747 {{echo| foo}}{{echo| bar}}
2748
2749 {{echo| foo}}
2750 {{echo| bar}}
2751
2752 {{echo|<!--cmt--> foo}}
2753
2754 <!--cmt-->{{echo| foo}}
2755
2756 {{echo|{{echo| }}bar}}
2757 !! html
2758 <pre>foo
2759 </pre>
2760 <pre>foo bar
2761 </pre>
2762 <pre>foo
2763 bar
2764 </pre>
2765 <pre>foo
2766 </pre>
2767 <pre>foo
2768 </pre>
2769 <pre>bar
2770 </pre>
2771 !!end
2772
2773 !! test
2774 Templates: Indent-Pre: 1f: Wrapping should be based on expanded content
2775 !! wikitext
2776 {{echo| }}a
2777
2778 {{echo|
2779 }}a
2780
2781 {{echo|
2782 b}}
2783
2784 {{echo|a
2785 }}b
2786
2787 {{echo|a
2788 }} b
2789 !! html
2790 <pre>a
2791 </pre>
2792 <p><br />
2793 </p>
2794 <pre>a
2795 </pre>
2796 <p><br />
2797 </p>
2798 <pre>b
2799 </pre>
2800 <p>a
2801 </p>
2802 <pre>b
2803 </pre>
2804 <p>a
2805 </p>
2806 <pre>b
2807 </pre>
2808 !!end
2809
2810 ## Hmm, should Parsoid rt this?
2811 !! test
2812 Pres with newline attributes
2813 !! options
2814 parsoid=wt2html,html2html
2815 !! wikitext
2816 <pre class="one
2817 two">hi</pre>
2818 !! html/php
2819 <pre class="one two">hi</pre>
2820
2821 !! html/parsoid
2822 <pre typeof="mw:Extension/pre" about="#mwt2" class="one two" data-mw='{"name":"pre","attrs":{"class":"one two"},"body":{"extsrc":"hi"}}'>hi</pre>
2823 !! end
2824
2825 !! test
2826 Things that look like <pre> tags aren't treated as such
2827 !! wikitext
2828 Barack Obama <President> of the United States
2829 <President></President>
2830 !! html
2831 <p>Barack Obama &lt;President&gt; of the United States
2832 &lt;President&gt;&lt;/President&gt;
2833 </p>
2834 !! end
2835
2836 !! test
2837 Handle broken pre-like tags (T66025)
2838 !! options
2839 parsoid=wt2html
2840 !! wikitext
2841 {{echo|<pre <pre>x</pre>}}
2842
2843 <table><pre </table>
2844 !! html/php
2845 <pre>x</pre>
2846 <table>&lt;pre </table>
2847
2848 !! html/php+tidy
2849 <pre>x</pre>
2850 &lt;pre <table></table>
2851 !! html/parsoid
2852 <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>
2853
2854 <span data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>&lt;pre </span><table data-parsoid='{"stx":"html"}'></table>
2855 !! end
2856
2857 !! test
2858 Parsoid: handle pre with space after attribute
2859 !! options
2860 parsoid=wt2html
2861 !! wikitext
2862 <pre style="width:50%;" >{{echo|foo}}</pre>
2863 !! html/php
2864 <pre style="width:50%;">{{echo|foo}}</pre>
2865
2866 !! html/parsoid
2867 <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>
2868 !! end
2869
2870 # TODO / maybe: fix wt2wt for this
2871 !! test
2872 Parsoid: Don't paragraph-wrap fosterable content
2873 !! options
2874 parsoid=wt2html
2875 !! wikitext
2876 {|
2877 <td></td>
2878 <td></td>
2879
2880
2881
2882 |}
2883 !! html
2884 <table>
2885
2886 <tbody>
2887 <tr>
2888 <td></td>
2889
2890 <td></td></tr>
2891
2892
2893
2894 </tbody></table>
2895 !! end
2896
2897 !! test
2898 Self-closed pre
2899 !! wikitext
2900 <pre />
2901 !! html/php
2902 <pre></pre>
2903
2904 !! html/parsoid
2905 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":null}'></pre>
2906 !! end
2907
2908 !! test
2909 Parsoid: Don't paragraph-wrap fosterable content even if table syntax is unbalanced
2910 !! options
2911 parsoid=wt2html
2912 !! wikitext
2913 {|
2914 <td>
2915 <td>
2916 </td>
2917
2918
2919
2920 |}
2921 !! html
2922 <table>
2923
2924 <tbody>
2925 <tr>
2926 <td></td>
2927
2928 <td>
2929 </td></tr>
2930
2931
2932
2933 </tbody></table>
2934 !! end
2935
2936
2937 #--------------------------------------------------------------------
2938 # Transclusion parameter whitespace stripping tests
2939 # Behavior is different for positional and named parameters
2940 #--------------------------------------------------------------------
2941 !! test
2942 Templates: Strip leading and trailing whitespace from named-param values
2943 !! wikitext
2944 {{echo|1= a }}
2945
2946 {{echo|1= {{echo|b}} }}
2947
2948 {{echo| 1 =
2949 c }}
2950
2951 {{echo| 1 =
2952 * d
2953 }}
2954 !! html
2955 <p>a
2956 </p><p>b
2957 </p><p>c
2958 </p>
2959 <ul><li>d</li></ul>
2960
2961 !! end
2962
2963 !! test
2964 Templates: Don't strip whitespace from positional-param values
2965 !! wikitext
2966 {{echo|a }}
2967
2968 {{echo|{{echo|b}} }}
2969
2970 {{echo| c
2971 }}
2972
2973 {{echo| {{echo|d}}
2974 }}
2975
2976 {{echo|
2977 e}}
2978
2979 {{echo|
2980 *f}}
2981
2982 {{echo|
2983 }}g
2984 !! html
2985 <p>a
2986 </p><p>b
2987 </p>
2988 <pre>c
2989 </pre>
2990 <p><br />
2991 </p>
2992 <pre>d
2993 </pre>
2994 <p><br />
2995 </p>
2996 <pre>e
2997 </pre>
2998 <p><br />
2999 </p>
3000 <ul><li>f</li></ul>
3001 <p><br />
3002 </p>
3003 <pre>g
3004 </pre>
3005 !! end
3006
3007 !! test
3008 Templates: Don't recognize targets split by newlines
3009 !! options
3010 parsoid=wt2html
3011 !! wikitext
3012 {{ech
3013 o|foo}}
3014 !! html/php
3015 <p>{{ech
3016 o|foo}}
3017 </p>
3018 !! html/parsoid
3019 <p>{{ech
3020 o|foo}}</p>
3021 !! end
3022
3023 !! test
3024 Templates: Recognize targets when newlines and comments don't split the target
3025 !! options
3026 parsoid=wt2html
3027 !! wikitext
3028 {{
3029 <!--X--> ech<!--X-->o<!--X-->
3030 <!--X--> <!--X-->
3031
3032 |foo}}
3033 !! html/php
3034 <p>foo
3035 </p>
3036 !! html/parsoid
3037 <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>
3038 !! end
3039
3040 !! test
3041 Templates: Handle empty comment-and-ws-only lines correctly
3042 !! wikitext
3043 {{echo|foo
3044 <!--should be ignored-->
3045 <!--should be ignored as well-->
3046 bar}}
3047 !! html/php
3048 <p>foo
3049 bar
3050 </p>
3051 !! html/parsoid
3052 <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>
3053 !! end
3054
3055 !! test
3056 Templates: Handle comments in the target
3057 !! wikitext
3058 {{echo
3059 <!-- should be ignored -->
3060 |foo}}
3061
3062 {{echo
3063 <!-- should be ignored and spaces on next line should not trip us up (T147742) -->
3064 |foo}}
3065
3066 {{echo<!-- should be ignored -->
3067 |foo}}
3068
3069 {{echo<!-- should be ignored -->|foo}}
3070
3071 {{<!-- should be ignored -->echo|foo}}
3072 !! html/php
3073 <p>foo
3074 </p><p>foo
3075 </p><p>foo
3076 </p><p>foo
3077 </p><p>foo
3078 </p>
3079 !! html/parsoid
3080 <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>
3081
3082 <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>
3083
3084 <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>
3085
3086 <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>
3087
3088 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
3089 !! end
3090
3091 !! test
3092 Templates: Handle comments in parameter names (T69657)
3093 !! wikitext
3094 {{echo|1
3095 <!-- should be ignored -->
3096 =foo}}
3097
3098 {{echo|
3099 <!-- should be ignored -->
3100 1 = foo}}
3101
3102 {{echo|1<!-- should be ignored -->=foo}}
3103
3104 {{echo|<!-- should be ignored -->1=foo}}
3105 !! html/php
3106 <p>foo
3107 </p><p>foo
3108 </p><p>foo
3109 </p><p>foo
3110 </p>
3111 !! html/parsoid
3112 <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>
3113
3114 <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>
3115
3116 <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>
3117
3118 <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>
3119 !! end
3120
3121 !! test
3122 Templates: Other wikitext in parameter names (T69657)
3123 !! wikitext
3124 {{echo|''1''=foo}}
3125 !! html/php
3126 <p>{{{1}}}
3127 </p>
3128 !! html/parsoid
3129 <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>
3130 !! end
3131
3132 !! test
3133 Templates: With colons
3134 !! wikitext
3135 {{With: Colon}}
3136 !! html/php
3137 <p>Template with colon
3138 </p>
3139 !! html/parsoid
3140 <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>
3141 !! end
3142
3143 #--------------------------------------------------------------------
3144 # Transclusion parameter escaping tests
3145 #--------------------------------------------------------------------
3146
3147 !! test
3148 Templates: Parsoid parameter escaping test 1
3149 !! wikitext
3150 {{echo|[foo]|{{echo|[bar]}}}}
3151 !! html/php+tidy
3152 <p>[foo]
3153 </p>
3154 !! html/parsoid
3155 <p about="#mwt1" typeof="mw:Transclusion"
3156 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[foo]"},"2":{"wt":"{{echo|[bar]}}"}},"i":0}}]}'>[foo]</p>
3157 !! end
3158
3159 !! test
3160 Parsoid: Pipes in external links in template parameter
3161 !! wikitext
3162 {{echo|[{{echo|http://example.com}} link]}}
3163 !! html/php+tidy
3164 <p><a rel="nofollow" class="external text" href="http://example.com">link</a>
3165 </p>
3166 !! html/parsoid
3167 <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>
3168 !! end
3169
3170 !! test
3171 Parsoid: pipe in transclusion parameter
3172 !! wikitext
3173 {{echo|http://foo.com/a&#124;b}}
3174 !! html/php+tidy
3175 <p><a rel="nofollow" class="external free" href="http://foo.com/a%7Cb">http://foo.com/a%7Cb</a>
3176 </p>
3177 !! html/parsoid
3178 <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>
3179 !! end
3180
3181 !! test
3182 Parsoid: Pipe in external link target and content in template parameter
3183 !! options
3184 parsoid=html2wt,wt2wt
3185 !! wikitext
3186 {{echo|[http://foo.com/a&#124;b a&#124;b]}}
3187 !! html/php+tidy
3188 <p><a rel="nofollow" class="external text" href="http://foo.com/a%7Cb">a&#124;b</a>
3189 </p>
3190 !! html/parsoid
3191 <p><a rel="mw:ExtLink" href="http://foo.com/a|b" about="#mwt1"
3192 typeof="mw:Transclusion"
3193 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},
3194 "params":{"1":{"wt":"[http://foo.com/a|b a|b]"}},"i":0}}]}'>a|b</a></p>
3195 !! end
3196
3197 !! test
3198 Parsoid: Pipe in template with nested template in external link target in template parameter (seriously)
3199 !! options
3200 parsoid
3201 !! wikitext
3202 {{echo|[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]}}
3203 !! html
3204 <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>
3205 !! end
3206
3207 !! test
3208 Templates: Don't escape already nowiki-escaped text in template parameters
3209 !! options
3210 parsoid=html2wt,wt2wt
3211 !! wikitext
3212 {{echo|foo<nowiki>|</nowiki>bar}}
3213 {{echo|<nowiki>&lt;div&gt;</nowiki>}}
3214 {{echo|<nowiki></nowiki>}}
3215 !! html/php+tidy
3216 <p>foo|bar
3217 &lt;div&gt;
3218
3219 </p>
3220 !! html/parsoid
3221 <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>
3222 <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>
3223 <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>
3224 </p>
3225 !! end
3226
3227 ## T54824
3228 !! test
3229 Templates: '=' char in nested transclusions should not trigger nowiki escapes or conversion to named param
3230 !! options
3231 parsoid=html2wt,wt2wt
3232 !! wikitext
3233 {{echo|{{echo|1=bar}}}}
3234 !! html/php+tidy
3235 <p>bar
3236 </p>
3237 !! html/parsoid
3238 <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>
3239 !! end
3240
3241 ## T58733
3242 !! test
3243 Templates parameters with special tokenizing behavior dont get modified because of arg escaping
3244 !! wikitext
3245 {{echo|a : b}}
3246 !! html/php+tidy
3247 <p>a&#160;: b
3248 </p>
3249 !! html/parsoid
3250 <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>
3251 !! end
3252
3253 ## T73412
3254 !! test
3255 Templates: Preserve blank parameter names
3256 !! wikitext
3257 {{echo|=foo}}
3258 !! html/php+tidy
3259 <p>{{{1}}}
3260 </p>
3261 !! html/parsoid
3262 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"":{"wt":"foo"}},"i":0}}]}'>{{{1}}}</p>
3263 !! end
3264
3265 !! test
3266 Templates: Preserve blank parameter names in other positions
3267 !! wikitext
3268 {{blank_param|bar|=foo}}
3269 !! html/php+tidy
3270 <p>bar
3271 foo
3272 </p>
3273 !! html/parsoid
3274 <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
3275 foo</p>
3276 !! end
3277
3278 ###
3279 ### Parsoid-centric tests for testing RT edge cases for pre
3280 ###
3281
3282 !!test
3283 1a. Indent-Pre and Comments
3284 !! wikitext
3285 a
3286 <!--a-->
3287 c
3288 !! html
3289 <pre>a
3290 </pre>
3291 <p>c
3292 </p>
3293 !!end
3294
3295 !!test
3296 1b. Indent-Pre and Comments
3297 !! wikitext
3298 a
3299 <!--a-->
3300 c
3301 !! html
3302 <pre>a
3303 </pre>
3304 <p>c
3305 </p>
3306 !!end
3307
3308 !!test
3309 1c. Indent-Pre and Comments
3310 !! wikitext
3311 <!--a--> a
3312
3313 <!--a--> a
3314 !! html
3315 <pre> a
3316 </pre>
3317 <pre> a
3318 </pre>
3319 !!end
3320
3321 !!test
3322 1d. Indent-Pre and Comments
3323 (Pre-handler currently cannot distinguish between comment/ws order and normalizes them to [comment,ws] order)
3324 !! wikitext
3325 <!--a--> a
3326
3327 <!--b-->b
3328 !! html
3329 <pre>a
3330 </pre>
3331 <pre>b
3332 </pre>
3333 !!end
3334
3335 !!test
3336 2a. Indent-Pre and tables
3337 !! wikitext
3338 {|
3339 |-
3340 !h1!!h2
3341 |foo||bar
3342 |}
3343 !! html
3344 <table>
3345
3346 <tr>
3347 <th>h1</th>
3348 <th>h2
3349 </th>
3350 <td>foo</td>
3351 <td>bar
3352 </td></tr></table>
3353
3354 !!end
3355
3356 !!test
3357 2b. Indent-Pre and tables
3358 !! wikitext
3359 {|
3360 |-
3361 |foo
3362 |}
3363 !! html
3364 <table>
3365
3366 <tr>
3367 <td>foo
3368 </td></tr></table>
3369
3370 !!end
3371
3372 !!test
3373 2c. Indent-Pre and tables (T44252)
3374 !! wikitext
3375 {|
3376 |+foo
3377 ! |bar
3378 |}
3379 !! html
3380 <table>
3381 <caption>foo
3382 </caption>
3383 <tr>
3384 <th>bar
3385 </th></tr></table>
3386
3387 !!end
3388
3389 !!test
3390 2d. Indent-Pre and tables
3391 !! wikitext
3392 a
3393 {|
3394 |b
3395 |}
3396 !! html/php
3397 <pre>a
3398 </pre>
3399 <table>
3400 <tr>
3401 <td>b
3402 </td></tr></table>
3403
3404 !! html/parsoid
3405 <pre>a</pre>
3406 <table>
3407 <tbody><tr><td> b</td></tr>
3408 </tbody></table>
3409 !!end
3410
3411 !!test
3412 2e. Indent-Pre and table-line syntax
3413 !! wikitext
3414 a
3415 | b
3416 | c
3417 !! html/php
3418 <pre>a
3419 | b
3420 | c
3421 </pre>
3422 !!end
3423
3424 !!test
3425 2f. Indent-pre started by table-line syntax
3426 !! wikitext
3427 a
3428 | b
3429 | c
3430 !! html/php
3431 <p>a
3432 </p>
3433 <pre>| b
3434 | c
3435 </pre>
3436 !! html/parsoid
3437 <p>a</p>
3438 <pre>
3439 | b
3440 | c</pre>
3441 !!end
3442
3443 !! test
3444 2g. Indented table markup mixed with indented pre content (proposed in T8200)
3445 !! wikitext
3446 <table>
3447 <tr>
3448 <td>
3449 Text that should be rendered preformatted
3450 </td>
3451 </tr>
3452 </table>
3453 !! html
3454 <table>
3455 <tr>
3456 <td>
3457 <pre>Text that should be rendered preformatted
3458 </pre>
3459 </td>
3460 </tr>
3461 </table>
3462
3463 !! end
3464
3465 !! test
3466 2h. Indent pre in tables
3467 !! options
3468 parsoid=wt2html,html2html
3469 !! wikitext
3470 {|
3471 !
3472 foo
3473 !
3474 bar
3475 |-
3476 |
3477 baz
3478 {{!}}
3479 bam
3480 |}
3481 !! html/php
3482 <table>
3483 <tr>
3484 <th>
3485 <pre>foo
3486 </pre>
3487 </th>
3488 <th>
3489 <pre>bar
3490 </pre>
3491 </th></tr>
3492 <tr>
3493 <td>
3494 <pre>baz
3495 </pre>
3496 </td>
3497 <td>
3498 <pre>bam
3499 </pre>
3500 </td></tr></table>
3501
3502 !! html/parsoid
3503 <table>
3504 <tbody><tr><th>
3505 <pre>foo</pre>
3506 </th><th>
3507 <pre>bar</pre>
3508 </th></tr><tr>
3509 <td>
3510 <pre>baz</pre>
3511 </td><td data-parsoid='{"startTagSrc":"{{!}}"}'>
3512 <pre>bam</pre>
3513 </td></tr></tbody></table>
3514 !! end
3515
3516 !!test
3517 3a. Indent-Pre and block tags (single-line html)
3518 !! wikitext
3519 a <p> foo </p>
3520 b <div> foo </div>
3521 c <blockquote> foo </blockquote>
3522 <span> foo </span>
3523 !! html
3524 a <p> foo </p>
3525 b <div> foo </div>
3526 c <blockquote> foo </blockquote>
3527 <pre><span> foo </span>
3528 </pre>
3529 !! html/parsoid
3530 <p>a </p><p data-parsoid='{"stx":"html"}'> foo </p>
3531 <p>b </p><div data-parsoid='{"stx":"html"}'> foo </div>
3532 <p>c </p><blockquote data-parsoid='{"stx":"html"}'> foo </blockquote>
3533 <pre><span> foo </span>
3534 </pre>
3535 !! html/php+tidy
3536 <p> a </p><p> foo </p><p>
3537 b </p><div> foo </div><p>
3538 c </p><blockquote><p> foo </p></blockquote>
3539 <pre><span> foo </span>
3540 </pre>
3541 !! end
3542
3543 !! test
3544 3b. Indent-Pre and block tags (multi-line html)
3545 !! wikitext
3546 a <span>foo</span>
3547 <!-- comment --> b <div> foo </div>
3548 !! html/php
3549 <pre>a <span>foo</span>
3550 </pre>
3551 b <div> foo </div>
3552
3553 !! html/parsoid
3554 <pre>a <span data-parsoid='{"stx":"html"}'>foo</span></pre>
3555 <!-- comment --> <p>b </p><div data-parsoid='{"stx":"html"}'> foo </div>
3556 !! html/php+tidy
3557 <pre>a <span>foo</span>
3558 </pre><p>
3559 b </p><div> foo </div>
3560 !! end
3561
3562 !!test
3563 3c. Indent-Pre and block tags (pre-content on separate line)
3564 !! wikitext
3565 <p>
3566 foo
3567 </p>
3568
3569 <div>
3570 foo
3571 </div>
3572
3573 <center>
3574 foo
3575 </center>
3576
3577 <blockquote>
3578 foo
3579 </blockquote>
3580
3581 <blockquote>
3582 <pre>
3583 foo
3584 </pre>
3585 </blockquote>
3586
3587 <table><tr><td>
3588 foo
3589 </td></tr></table>
3590
3591 <ul><li>
3592 foo
3593 </li></ul>
3594
3595 !! html
3596 <p>
3597 foo
3598 </p>
3599 <div>
3600 <pre>foo
3601 </pre>
3602 </div>
3603 <center>
3604 <pre>foo
3605 </pre>
3606 </center>
3607 <blockquote>
3608 <p> foo
3609 </p>
3610 </blockquote>
3611 <blockquote>
3612 <pre>
3613 foo
3614 </pre>
3615 </blockquote>
3616 <table><tr><td>
3617 <pre>foo
3618 </pre>
3619 </td></tr></table>
3620 <ul><li>
3621 foo
3622 </li></ul>
3623
3624 !!end
3625
3626 !! test
3627 4. Indent-Pre and extension tags
3628 !! wikitext
3629 a <tag />
3630 !! html/php
3631 a <pre>
3632 NULL
3633 array (
3634 )
3635 </pre>
3636
3637 !! html/parsoid
3638 a <pre typeof="mw:Extension/tag" about="#mwt2" data-parsoid='{}' data-mw='{"name":"tag","attrs":{},"body":null}'></pre>
3639 !! end
3640
3641 !! test
3642 5. Indent-Pre and html pre
3643 !! wikitext
3644 <pre class="123">hi</pre>
3645 !! html/php
3646 <pre class="123">hi</pre>
3647
3648 !! html/parsoid
3649 <pre typeof="mw:Extension/pre" about="#mwt2" class="123" data-mw='{"name":"pre","attrs":{"class":"123"},"body":{"extsrc":"hi"}}'>hi</pre>
3650 !! end
3651
3652 !!test
3653 Render paragraphs when indent-pre is suppressed in blocklevels
3654 !! wikitext
3655 <blockquote>
3656 foo
3657
3658 bar
3659 </blockquote>
3660 !! html
3661 <blockquote>
3662 <p> foo
3663 </p><p> bar
3664 </p>
3665 </blockquote>
3666
3667 !!end
3668
3669 !!test
3670 4. Multiple spaces at start-of-line
3671 !! wikitext
3672 <p> foo </p>
3673 foo
3674 {|
3675 |foo
3676 |}
3677 !! html
3678 <p> foo </p>
3679 <pre> foo
3680 </pre>
3681 <table>
3682 <tr>
3683 <td>foo
3684 </td></tr></table>
3685
3686 !!end
3687
3688 ## NOTE: the leading white-space chars on empty line are significant
3689 !! test
3690 5a. White-space in indent-pre
3691 !! wikitext
3692 a<br />
3693
3694 b
3695 !! html
3696 <pre>a<br />
3697
3698 b
3699 </pre>
3700 !! end
3701
3702 ## NOTE: the leading white-space chars on empty line are significant
3703 !! test
3704 5b. White-space in indent-pre
3705 !! wikitext
3706 a
3707
3708 b
3709
3710
3711 c
3712 !! html
3713 <pre>a
3714
3715 b
3716
3717
3718 c
3719 </pre>
3720 !! end
3721
3722 !! test
3723 5c. White-space in indent-pre
3724 !! wikitext
3725 ''a''
3726 ''b''
3727 ''c''
3728 !! html
3729 <pre><i>a</i>
3730 <i>b</i>
3731 <i>c</i>
3732 </pre>
3733 !! end
3734
3735 !! test
3736 6. Pre-blocks should extend across lines with leading WS even when there is no wrappable content
3737 !! wikitext
3738 a
3739
3740 <!-- continue -->
3741 b
3742
3743 c
3744
3745 d
3746 !! html
3747 <pre>a
3748
3749 b
3750 </pre>
3751 <pre>c
3752
3753 </pre>
3754 <p>d
3755 </p>
3756 !! end
3757
3758 !! test
3759 7a. Indent-pre and category links
3760 !! options
3761 parsoid=wt2html,wt2wt
3762 !! wikitext
3763 [[Category:foo]] <!-- No pre-wrapping -->
3764 {{echo| [[Category:foo]]}} <!-- No pre-wrapping -->
3765 !! html/php+tidy
3766 !! html/parsoid
3767 <link rel="mw:PageProp/Category" href="./Category:Foo"> <!-- No pre&#x2D;wrapping -->
3768 <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 -->
3769 !! end
3770
3771 ## We used to, but no longer wt2wt this test since the default serializer
3772 ## will normalize all categories to serialize on their own line.
3773 ## This wikitext usage is going to be fairly uncommon in production and
3774 ## selser will take care of preserving formatting in those scenarios.
3775 !! test
3776 7b. Indent-pre and category links
3777 !! options
3778 parsoid=wt2html
3779 !! wikitext
3780 [[Category:foo]] a
3781 [[Category:foo]] {{echo|b}}
3782 !! html/parsoid
3783 <pre><link rel="mw:PageProp/Category" href="./Category:Foo"> a
3784 <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>
3785 !! end
3786
3787 !! test
3788 Indent-Pre: Newlines in comments shouldn't affect sol state
3789 !! wikitext
3790 a <!--
3791 foo
3792 --> b
3793 !! html/php+tidy
3794 <p>a b
3795 </p>
3796 !! html/parsoid
3797 <p>a <!--
3798 foo
3799 --> b</p>
3800 !! end
3801
3802 ###
3803 ### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric)
3804 ###
3805
3806 !!test
3807 HTML-pre: 1. embedded newlines
3808 !! wikitext
3809 <pre>foo</pre>
3810
3811 <pre>
3812 foo
3813 </pre>
3814
3815 <pre>
3816
3817 foo
3818 </pre>
3819
3820 <pre>
3821
3822
3823 foo
3824 </pre>
3825 !! html/php+tidy
3826 <pre>foo</pre>
3827 <pre>foo
3828 </pre>
3829 <pre>
3830
3831 foo
3832 </pre>
3833 <pre>
3834
3835
3836 foo
3837 </pre>
3838 !! html/parsoid
3839 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre>
3840
3841 <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
3842 </pre>
3843
3844 <pre typeof="mw:Extension/pre" about="#mwt6" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\nfoo\n"}}'>
3845
3846 foo
3847 </pre>
3848
3849 <pre typeof="mw:Extension/pre" about="#mwt8" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\nfoo\n"}}'>
3850
3851
3852 foo
3853 </pre>
3854 !!end
3855
3856 !! test
3857 HTML-pre: big spaces
3858 !! wikitext
3859 <pre>
3860
3861
3862
3863
3864 haha
3865
3866
3867
3868
3869 haha
3870
3871
3872
3873
3874 </pre>
3875 !! html/php+tidy
3876 <pre>
3877
3878
3879
3880
3881 haha
3882
3883
3884
3885
3886 haha
3887
3888
3889
3890
3891 </pre>
3892 !! html/parsoid
3893 <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"}}'>
3894
3895
3896
3897
3898 haha
3899
3900
3901
3902
3903 haha
3904
3905
3906
3907
3908 </pre>
3909 !! end
3910
3911 !!test
3912 HTML-pre: 2: indented text
3913 !! wikitext
3914 <pre>
3915 foo
3916 </pre>
3917 !! html
3918 <pre>
3919 foo
3920 </pre>
3921
3922 !!end
3923
3924 !!test
3925 HTML-pre: 3: other wikitext
3926 !! wikitext
3927 <pre>
3928 * foo
3929 # bar
3930 = no-h =
3931 '' no-italic ''
3932 [[ NoLink ]]
3933 </pre>
3934 !! html/php
3935 <pre>
3936 * foo
3937 # bar
3938 = no-h =
3939 '' no-italic ''
3940 [[ NoLink ]]
3941 </pre>
3942
3943 !! html/parsoid
3944 <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
3945 # bar
3946 = no-h =
3947 '' no-italic ''
3948 [[ NoLink ]]
3949 </pre>
3950 !!end
3951
3952 ###
3953 ### Definition lists
3954 ###
3955 !! test
3956 Simple definition
3957 !! wikitext
3958 ;name :Definition
3959 !! html
3960 <dl><dt>name&#160;</dt>
3961 <dd>Definition</dd></dl>
3962
3963 !! end
3964
3965 !! test
3966 Definition list for indentation only
3967 !! wikitext
3968 :Indented text
3969 !! html
3970 <dl><dd>Indented text</dd></dl>
3971
3972 !! end
3973
3974 !! test
3975 Definition list with no space
3976 !! wikitext
3977 ;name:Definition
3978 !! html
3979 <dl><dt>name</dt>
3980 <dd>Definition</dd></dl>
3981
3982 !!end
3983
3984 !! test
3985 Definition list with URL link
3986 !! wikitext
3987 ;http://example.com/ :definition
3988 !! html
3989 <dl><dt><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&#160;</dt>
3990 <dd>definition</dd></dl>
3991
3992 !! end
3993
3994 !! test
3995 Definition list with bracketed URL link
3996 !! wikitext
3997 ;[http://www.example.com/ Example]:Something about it
3998 !! html
3999 <dl><dt><a rel="nofollow" class="external text" href="http://www.example.com/">Example</a></dt>
4000 <dd>Something about it</dd></dl>
4001
4002 !! end
4003
4004 !! test
4005 Definition list with wikilink containing colon
4006 !! wikitext
4007 ;[[Help:FAQ]]:The least-read page on Wikipedia
4008 !! html
4009 <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>
4010 <dd>The least-read page on Wikipedia</dd></dl>
4011
4012 !! end
4013
4014 # At Brion's and JeLuF's insistence... :)
4015 !! test
4016 Definition list with news link containing colon
4017 !! wikitext
4018 ;news:alt.wikipedia.rox :This isn't even a real newsgroup!
4019 !! html/php
4020 <dl><dt><a rel="nofollow" class="external free" href="news:alt.wikipedia.rox">news:alt.wikipedia.rox</a>&#160;</dt>
4021 <dd>This isn't even a real newsgroup!</dd></dl>
4022
4023 !! html/parsoid
4024 <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>
4025 !! end
4026
4027 !! test
4028 Malformed definition list with colon
4029 !! wikitext
4030 ;news:alt.wikipedia.rox -- don't crash or enter an infinite loop
4031 !! html
4032 <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>
4033
4034 !! end
4035
4036 !! test
4037 Definition lists: colon in external link text
4038 !! wikitext
4039 ;[http://www.wikipedia2.org/ Wikipedia :The Next Generation] :OK, I made that up
4040 !! html
4041 <dl><dt><a rel="nofollow" class="external text" href="http://www.wikipedia2.org/">Wikipedia&#160;:The Next Generation</a>&#160;</dt>
4042 <dd>OK, I made that up</dd></dl>
4043
4044 !! end
4045
4046 !! test
4047 Definition lists: colon in HTML attribute
4048 !! wikitext
4049 ;<b style="display: inline">bold</b>
4050 !! html
4051 <dl><dt><b style="display: inline">bold</b></dt></dl>
4052
4053 !! end
4054
4055 !! test
4056 Definition lists: self-closed tag
4057 !! wikitext
4058 ;one<br/>two :two-line fun
4059 !! html
4060 <dl><dt>one<br />two&#160;</dt>
4061 <dd>two-line fun</dd></dl>
4062
4063 !! end
4064
4065 !! test
4066 Definition lists: ignore colons inside tags
4067 !! wikitext
4068 ;one <b>two : tag <i>fun:</i>:</b>:def
4069 !! html
4070 <dl><dt>one <b>two&#160;: tag <i>fun:</i>:</b></dt>
4071 <dd>def</dd></dl>
4072
4073 !! end
4074
4075 !! test
4076 Definition lists: excess closed tags
4077 !! wikitext
4078 ;one</b>two :bad tag fun
4079 !! html/php+tidy
4080 <dl><dt>onetwo&#160;</dt>
4081 <dd>bad tag fun</dd></dl>
4082 !! html/parsoid
4083 <dl>
4084 <dt>onetwo</dt>
4085 <dd>bad tag fun</dd>
4086 </dl>
4087 !! end
4088
4089 !! test
4090 T13748: Literal closing tags
4091 !! wikitext
4092 <dl>
4093 <dt>test 1</dt>
4094 <dd>test test test test test</dd>
4095 <dt>test 2</dt>
4096 <dd>test test test test test</dd>
4097 </dl>
4098 !! html
4099 <dl>
4100 <dt>test 1</dt>
4101 <dd>test test test test test</dd>
4102 <dt>test 2</dt>
4103 <dd>test test test test test</dd>
4104 </dl>
4105
4106 !! end
4107
4108 !! test
4109 Definition and unordered list using wiki syntax nested in unordered list using html tags.
4110 !! wikitext
4111 <ul><li>
4112 ;term :description
4113 *unordered
4114 </li></ul>
4115 !! html
4116 <ul><li>
4117 <dl><dt>term&#160;</dt>
4118 <dd>description</dd></dl>
4119 <ul><li>unordered</li></ul>
4120 </li></ul>
4121
4122 !! end
4123
4124 !! test
4125 Definition list with empty definition and following paragraph
4126 !! wikitext
4127 ;term:
4128
4129 Paragraph text
4130 !! html
4131 <dl><dt>term</dt>
4132 <dd></dd></dl>
4133 <p>Paragraph text
4134 </p>
4135 !! end
4136
4137 !! test
4138 Nested definition lists using html syntax
4139 !! wikitext
4140 <dl><dt>x</dt>
4141 <dd>a</dd>
4142 <dd>b</dd></dl>
4143 !! html
4144 <dl><dt>x</dt>
4145 <dd>a</dd>
4146 <dd>b</dd></dl>
4147
4148 !! end
4149
4150 !! test
4151 Definition Lists: No nesting: Multiple dd's
4152 !! wikitext
4153 ;x
4154 :a
4155 :b
4156 !! html
4157 <dl><dt>x</dt>
4158 <dd>a</dd>
4159 <dd>b</dd></dl>
4160
4161 !! end
4162
4163 !! test
4164 Definition Lists: Indentation: Regular
4165 !! wikitext
4166 :i1
4167 ::i2
4168 :::i3
4169 !! html
4170 <dl><dd>i1
4171 <dl><dd>i2
4172 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
4173
4174 !! end
4175
4176 !! test
4177 Definition Lists: Indentation: Missing 1st level
4178 !! wikitext
4179 ::i2
4180 :::i3
4181 !! html
4182 <dl><dd><dl><dd>i2
4183 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
4184
4185 !! end
4186
4187 !! test
4188 Definition Lists: Indentation: Multi-level indent
4189 !! wikitext
4190 :::i3
4191 !! html
4192 <dl><dd><dl><dd><dl><dd>i3</dd></dl></dd></dl></dd></dl>
4193
4194 !! end
4195
4196 !! test
4197 Definition Lists: Hacky use to indent tables
4198 !! wikitext
4199 ::{|
4200 |foo
4201 |bar
4202 |}
4203 this text
4204 should be left alone
4205 !! html
4206 <dl><dd><dl><dd><table>
4207 <tr>
4208 <td>foo
4209 </td>
4210 <td>bar
4211 </td></tr></table></dd></dl></dd></dl>
4212 <p>this text
4213 should be left alone
4214 </p>
4215 !! end
4216
4217 !! test
4218 Definition Lists: Hacky use to indent tables (with content following table)
4219 !! wikitext
4220 :{|
4221 |foo
4222 |bar
4223 |} <!--c1--> this text should be part of the dl
4224 !! html/php+tidy
4225 <dl><dd><table>
4226 <tbody><tr>
4227 <td>foo
4228 </td>
4229 <td>bar
4230 </td></tr></tbody></table> this text should be part of the dl</dd></dl>
4231 !! html/parsoid
4232 <dl><dd><table>
4233 <tbody><tr>
4234 <td>foo
4235 </td>
4236 <td>bar
4237 </td></tr></tbody></table> <!--c1--> this text should be part of the dl</dd></dl>
4238 !! end
4239
4240 !! test
4241 Definition Lists: Hacky use to indent tables, with comments (T65979)
4242 !! wikitext
4243 <!-- foo -->
4244 ::{|
4245 |foo
4246 |bar
4247 |}<!-- bar -->
4248 this text
4249 should be left alone
4250 !! html/parsoid
4251 <!-- foo -->
4252 <dl><dd><dl><dd><table><tr>
4253 <td>foo</td>
4254 <td>bar</td>
4255 </tr></table><!-- bar --></dd></dl></dd></dl>
4256 <p>this text
4257 should be left alone</p>
4258 !! end
4259
4260 !! test
4261 Definition Lists: Hacky use to indent tables, with comment before table
4262 !!options
4263 parsoid=wt2html
4264 !! wikitext
4265 ::<!-- foo -->{|
4266 |foo
4267 |}
4268 !! html/parsoid
4269 <dl><dd><dl><dd><!-- foo --><table><tr>
4270 <td>foo</td>
4271 </tr></table></dd></dl></dd></dl>
4272 !! end
4273
4274 # The trailing whitespace in this test is to catch a regression in
4275 # Parsoid after T54473.
4276 !! test
4277 Definition Lists: Hacky use to indent tables (WS-insensitive)
4278 !! wikitext
4279 :{|
4280 |a
4281 |}
4282 !! html/php
4283 <dl><dd><table>
4284 <tr>
4285 <td>a
4286 </td></tr></table></dd></dl>
4287
4288 !! html/parsoid
4289 <dl><dd><table>
4290 <tbody><tr><td>a</td></tr>
4291 </tbody></table></dd></dl>
4292 !! end
4293
4294 ## The PHP parser treats : items (dd) without a corresponding ; item (dt)
4295 ## as an empty dt item. It also ignores all but the last ";" when followed
4296 ## by ":" later on. So, ";" are not ignored in ";;;t3" but are ignored in
4297 ## ";;;t3 :d1". So, PHP parser behavior is a little inconsistent wrt multiple
4298 ## ";"s.
4299 ##
4300 ## Ex: ";;t2 ::d2" is transformed into:
4301 ##
4302 ## <dl>
4303 ## <dt>t2 </dt>
4304 ## <dd>
4305 ## <dl>
4306 ## <dt></dt>
4307 ## <dd>d2</dd>
4308 ## </dl>
4309 ## </dd>
4310 ## </dl>
4311 ##
4312 ## But, Parsoid treats "; :" as a tight atomic unit and excess ":" as plain text
4313 ## So, the same wikitext above (;;t2 ::d2) is transformed into:
4314 ##
4315 ## <dl>
4316 ## <dt>
4317 ## <dl>
4318 ## <dt>t2 </dt>
4319 ## <dd>:d2</dd>
4320 ## </dl>
4321 ## </dt>
4322 ## </dl>
4323 ##
4324 ## All Parsoid only definition list tests have this difference.
4325 ##
4326 ## See also: https://phabricator.wikimedia.org/T8569
4327 ## and https://lists.wikimedia.org/pipermail/wikitext-l/2011-November/000483.html
4328
4329 !! test
4330 Table / list interaction: indented table with lists in table contents
4331 !! wikitext
4332 :{|
4333 |-
4334 |a
4335
4336 *b
4337 |-
4338 |c
4339
4340 *d
4341 |}
4342 !! html
4343 <dl><dd><table>
4344
4345 <tr>
4346 <td>a
4347 <ul><li>b</li></ul>
4348 </td></tr>
4349 <tr>
4350 <td>c
4351 <ul><li>d</li></ul>
4352 </td></tr></table></dd></dl>
4353
4354 !! end
4355
4356 !!test
4357 Table / list interaction: lists nested in tables nested in indented lists
4358 !! wikitext
4359 :{|
4360 |
4361 :a
4362 :b
4363 |
4364 *c
4365 *d
4366 |}
4367
4368 *e
4369 *f
4370 !! html
4371 <dl><dd><table>
4372 <tr>
4373 <td>
4374 <dl><dd>a</dd>
4375 <dd>b</dd></dl>
4376 </td>
4377 <td>
4378 <ul><li>c</li>
4379 <li>d</li></ul>
4380 </td></tr></table></dd></dl>
4381 <ul><li>e</li>
4382 <li>f</li></ul>
4383
4384 !!end
4385
4386 !! test
4387 Definition Lists: Nesting: Multi-level (Parsoid only)
4388 !! wikitext
4389 ;t1 :d1
4390 ;;t2 ::d2
4391 ;;;t3 :::d3
4392 !! html/parsoid
4393 <dl>
4394 <dt>t1 </dt>
4395 <dd>d1</dd>
4396 <dt>
4397 <dl>
4398 <dt>t2 </dt>
4399 <dd>:d2</dd>
4400 <dt>
4401 <dl>
4402 <dt>t3 </dt>
4403 <dd>::d3</dd>
4404 </dl>
4405 </dt>
4406 </dl>
4407 </dt>
4408 </dl>
4409
4410
4411 !! end
4412
4413
4414 !! test
4415 Definition Lists: Nesting: Test 2
4416 !! wikitext
4417 ;t1
4418 ::d2
4419 !! html+tidy
4420 <dl><dt>t1</dt>
4421 <dd>
4422 <dl><dd>d2</dd></dl></dd></dl>
4423 !! end
4424
4425
4426 !! test
4427 Definition Lists: Nesting: Test 3
4428 !! wikitext
4429 :;t1
4430 ::::d2
4431 !! html+tidy
4432 <dl><dd><dl><dt>t1</dt>
4433 <dd>
4434 <dl><dd><dl><dd>d2</dd></dl></dd></dl></dd></dl></dd></dl>
4435 !! end
4436
4437
4438 !! test
4439 Definition Lists: Nesting: Test 4
4440 !! wikitext
4441 ::;t3
4442 :::d3
4443 !! html
4444 <dl><dd><dl><dd><dl><dt>t3</dt>
4445 <dd>d3</dd></dl></dd></dl></dd></dl>
4446
4447 !! end
4448
4449
4450 ## The Parsoid team believes the following three test exposes a
4451 ## bug in the PHP parser. (Parsoid team thinks the PHP parser is
4452 ## wrong to close the <dl> after the <dt> containing the <ul>.)
4453 ## It also exposes a "misfeature" in tidy, which doesn't like
4454 ## <dl> tags with a single <dt> child; it converts the <dt> into
4455 ## a <dd> in that case. (Parsoid leaves the <dt> alone!)
4456 !! test
4457 Definition Lists: Mixed Lists: Test 1
4458 !! wikitext
4459 :;*foo
4460 ::*bar
4461 :;baz
4462 !! html/php
4463 <dl><dd><dl><dt><ul><li>foo</li>
4464 <li>bar</li></ul></dt></dl>
4465 <dl><dt>baz</dt></dl></dd></dl>
4466
4467 !! html/php+tidy
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 !! html/parsoid
4472 <dl>
4473 <dd><dl>
4474 <dt><ul>
4475 <li>foo
4476 </li>
4477 </ul></dt>
4478 <dd><ul>
4479 <li>bar
4480 </li>
4481 </ul></dd>
4482 <dt>baz</dt>
4483 </dl></dd>
4484 </dl>
4485 !! end
4486
4487 !! test
4488 Definition Lists: Mixed Lists: Test 2
4489 !! wikitext
4490 *:d1
4491 *:d2
4492 !! html
4493 <ul><li><dl><dd>d1</dd>
4494 <dd>d2</dd></dl></li></ul>
4495
4496 !! end
4497
4498
4499 !! test
4500 Definition Lists: Mixed Lists: Test 3
4501 !! wikitext
4502 *:::d1
4503 *:::d2
4504 !! html
4505 <ul><li><dl><dd><dl><dd><dl><dd>d1</dd>
4506 <dd>d2</dd></dl></dd></dl></dd></dl></li></ul>
4507
4508 !! end
4509
4510
4511 !! test
4512 Definition Lists: Mixed Lists: Test 4
4513 !! wikitext
4514 *;d1 :d2
4515 *;d3 :d4
4516 !! html
4517 <ul><li><dl><dt>d1&#160;</dt>
4518 <dd>d2</dd>
4519 <dt>d3&#160;</dt>
4520 <dd>d4</dd></dl></li></ul>
4521
4522 !! end
4523
4524
4525 !! test
4526 Definition Lists: Mixed Lists: Test 5
4527 !! wikitext
4528 *:d1
4529 *::d2
4530 !! html
4531 <ul><li><dl><dd>d1
4532 <dl><dd>d2</dd></dl></dd></dl></li></ul>
4533
4534 !! end
4535
4536
4537 !! test
4538 Definition Lists: Mixed Lists: Test 6
4539 !! wikitext
4540 #*:d1
4541 #*:::d3
4542 !! html
4543 <ol><li><ul><li><dl><dd>d1
4544 <dl><dd><dl><dd>d3</dd></dl></dd></dl></dd></dl></li></ul></li></ol>
4545
4546 !! end
4547
4548
4549 !! test
4550 Definition Lists: Mixed Lists: Test 7
4551 !! wikitext
4552 :*d1
4553 :*d2
4554 !! html
4555 <dl><dd><ul><li>d1</li>
4556 <li>d2</li></ul></dd></dl>
4557
4558 !! end
4559
4560
4561 !! test
4562 Definition Lists: Mixed Lists: Test 8
4563 !! wikitext
4564 :*d1
4565 ::*d2
4566 !! html
4567 <dl><dd><ul><li>d1</li></ul>
4568 <dl><dd><ul><li>d2</li></ul></dd></dl></dd></dl>
4569
4570 !! end
4571
4572
4573 !! test
4574 Definition Lists: Mixed Lists: Test 9
4575 !! wikitext
4576 *;foo :bar
4577 !! html
4578 <ul><li><dl><dt>foo&#160;</dt>
4579 <dd>bar</dd></dl></li></ul>
4580
4581 !! end
4582
4583
4584 !! test
4585 Definition Lists: Mixed Lists: Test 10
4586 !! wikitext
4587 *#;foo :bar
4588 !! html
4589 <ul><li><ol><li><dl><dt>foo&#160;</dt>
4590 <dd>bar</dd></dl></li></ol></li></ul>
4591
4592 !! end
4593
4594 # The Parsoid team disagrees with the PHP parser's seemingly-random
4595 # rules regarding dd/dt on the next few tests. Parsoid is more
4596 # consistent, and recognizes the shared nesting and keeps the
4597 # still-open tags around until the nesting is complete.
4598
4599 # This is a regression test for T175099
4600 !! test
4601 Definition Lists: Mixed Lists: Test 11
4602 !! wikitext
4603 ;a
4604 :*b
4605 !! html/php
4606 <dl><dt>a</dt>
4607 <dd>
4608 <ul><li>b</li></ul></dd></dl>
4609
4610 !! html/parsoid
4611 <dl><dt>a
4612 <dd><ul><li>b</li></ul></dd></dl>
4613 !! end
4614
4615 # FIXME: Maybe get rid of this test?
4616 !! test
4617 Definition Lists: Mixed Lists: Test 12
4618 !! wikitext
4619 *#*#;*;;foo :bar
4620 *#*#;boo :baz
4621 !! html/php
4622 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</dt>
4623 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dd></dl></li></ul></dd></dl>
4624 <dl><dt>boo&#160;</dt>
4625 <dd>baz</dd></dl></li></ol></li></ul></li></ol></li></ul>
4626
4627 !! html/php+tidy
4628 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</dt>
4629 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dt></dl></li></ul></dd></dl></li></ol></li></ul>
4630 <dl><dt>boo&#160;</dt>
4631 <dd>baz</dd></dl></li></ol></li></ul>
4632 !! html/parsoid
4633 <ul>
4634 <li>
4635 <ol>
4636 <li>
4637 <ul>
4638 <li>
4639 <ol>
4640 <li>
4641 <dl>
4642 <dt>
4643 <ul>
4644 <li>
4645 <dl>
4646 <dt>
4647 <dl>
4648 <dt>foo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
4649 <dd data-parsoid='{"stx":"row"}'>bar</dd>
4650 </dl></dt>
4651 </dl></li>
4652 </ul></dt>
4653 <dt>boo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
4654 <dd data-parsoid='{"stx":"row"}'>baz</dd>
4655 </dl></li>
4656 </ol></li>
4657 </ul></li>
4658 </ol></li>
4659 </ul>
4660 !! end
4661
4662 # FIXME: Maybe get rid of this test?
4663 # From whitelist:
4664 # * The test is wrong, there are two colons where there should be :;
4665 # * The PHP parser is wrong to close the <dl> after the <dt> containing the <ul>.
4666 !! test
4667 Definition Lists: Weird Ones: Test 1
4668 !! wikitext
4669 *#;*::;;foo :bar (who uses this?)
4670 !! html/php+tidy
4671 <ul><li><ol><li><dl><dt>foo&#160;</dt>
4672 <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>
4673 !! html/parsoid
4674 <ul>
4675 <li>
4676 <ol>
4677 <li>
4678 <dl>
4679 <dt>
4680 <ul>
4681 <li>
4682 <dl>
4683 <dd>
4684 <dl>
4685 <dd>
4686 <dl>
4687 <dt>
4688 <dl>
4689 <dt>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span></dt>
4690 <dd data-parsoid='{"stx":"row"}'>bar (who uses this?)</dd>
4691 </dl></dt>
4692 </dl></dd>
4693 </dl></dd>
4694 </dl></li>
4695 </ul></dt>
4696 </dl></li>
4697 </ol></li>
4698 </ul>
4699 !! end
4700
4701 !! test
4702 Definition Lists: colons occurring in tags
4703 !! wikitext
4704 ;a:b
4705 ;'''a:b'''
4706 ;<i>a:b</i>
4707 ;<span>a:b</span>
4708 ;<div>a:b</div>
4709 ;<div>a
4710 :b</div>
4711 ;{{echo|a:b}}
4712 ;{{echo|''a:b''}}
4713 ;;;''a:b''
4714 !! html+tidy
4715 <dl><dt>a</dt>
4716 <dd>b</dd>
4717 <dt><b>a:b</b></dt>
4718 <dt><i>a:b</i></dt>
4719 <dt><span>a:b</span></dt>
4720 <dt><div>a:b</div></dt>
4721 <dt><div>a</div></dt>
4722 <dd>b</dd>
4723 <dt>a</dt>
4724 <dd>b</dd>
4725 <dt><i>a:b</i></dt></dl>
4726 <dl><dt><dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4727 !! html/parsoid
4728 <dl><dt>a</dt><dd data-parsoid='{"stx":"row"}'>b</dd>
4729 <dt><b>a:b</b></dt>
4730 <dt><i data-parsoid='{"stx":"html"}'>a:b</i></dt>
4731 <dt><span data-parsoid='{"stx":"html"}'>a:b</span></dt>
4732 <dt><div data-parsoid='{"stx":"html"}'>a:b</div></dt>
4733 <dt><div data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</div></dt>
4734 <dd>b</dd>
4735 <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>
4736 <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>
4737 <dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4738 !! end
4739
4740 # Parsoid's output differs here again because it shares
4741 # nesting between the two lists unlike the PHP parser.
4742 # Unsure which is more desirable.
4743 !! test
4744 Definition Lists: colons and tables 1
4745 !! wikitext
4746 :{|
4747 |x
4748 |}
4749 :{|
4750 |y
4751 |}
4752 !! html/php
4753 <dl><dd><table>
4754 <tr>
4755 <td>x
4756 </td></tr></table></dd></dl>
4757 <dl><dd><table>
4758 <tr>
4759 <td>y
4760 </td></tr></table></dd></dl>
4761
4762 !! html/parsoid
4763 <dl><dd><table>
4764 <tr>
4765 <td>x
4766 </td></tr></table></dd>
4767 <dd><table>
4768 <tr>
4769 <td>y
4770 </td></tr></table></dd></dl>
4771 !! end
4772
4773 # FIXME: Does this need a html/php section?
4774 !! test
4775 Definition Lists: template interaction
4776 !! wikitext
4777 ::{{definition_list}}
4778
4779 :one
4780 ::{{definition_list}}
4781 :::two
4782 :::three
4783 ::four
4784 !! html/parsoid
4785 <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">
4786 </span><dd about="#mwt1">two</dd></dl></dd></dl>
4787
4788 <dl><dd data-parsoid='{}'>one
4789 <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">
4790 </span><dd about="#mwt2">two
4791 <dl><dd>two</dd>
4792 <dd>three</dd></dl></dd>
4793 <dd data-parsoid='{}'>four</dd></dl></dd></dl>
4794 !! end
4795
4796
4797 ###
4798 ### External links
4799 ###
4800 !! test
4801 External links: non-bracketed
4802 !! wikitext
4803 Non-bracketed: http://example.com
4804 !! html
4805 <p>Non-bracketed: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4806 </p>
4807 !! end
4808
4809 # parsoid doesn't explicitly mark autonumbered links, see T55505
4810 !! test
4811 External links: numbered
4812 !! wikitext
4813 Numbered: [http://example.com]
4814 Numbered: [http://example.net]
4815 Numbered: [http://example.com]
4816 !! html/php
4817 <p>Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>
4818 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.net">[2]</a>
4819 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[3]</a>
4820 </p>
4821 !! html/parsoid
4822 <p>Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>
4823 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.net"></a>
4824 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a></p>
4825 !!end
4826
4827 !! test
4828 External links: specified text
4829 !! wikitext
4830 Specified text: [http://example.com link]
4831 !! html
4832 <p>Specified text: <a rel="nofollow" class="external text" href="http://example.com">link</a>
4833 </p>
4834 !!end
4835
4836 !! test
4837 External links: trail
4838 !! wikitext
4839 Linktrails should not work for external links: [http://example.com link]s
4840 !! html
4841 <p>Linktrails should not work for external links: <a rel="nofollow" class="external text" href="http://example.com">link</a>s
4842 </p>
4843 !! end
4844
4845 !! test
4846 External links: dollar sign in URL
4847 !! wikitext
4848 http://example.com/1$2345
4849 !! html
4850 <p><a rel="nofollow" class="external free" href="http://example.com/1$2345">http://example.com/1$2345</a>
4851 </p>
4852 !! end
4853
4854 # parsoid doesn't explicitly mark autonumbered links, see T55505
4855 !! test
4856 External links: dollar sign in URL (autonumber)
4857 !! wikitext
4858 [http://example.com/1$2345]
4859 !! html/php
4860 <p><a rel="nofollow" class="external autonumber" href="http://example.com/1$2345">[1]</a>
4861 </p>
4862 !! html/parsoid
4863 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/1$2345"></a></p>
4864 !!end
4865
4866 !! test
4867 External links: open square bracket forbidden in URL (T6377)
4868 !! options
4869 parsoid=wt2html,wt2wt,html2html
4870 !! wikitext
4871 http://example.com/1[2345
4872 !! html/php
4873 <p><a rel="nofollow" class="external free" href="http://example.com/1">http://example.com/1</a>[2345
4874 </p>
4875 !! html/parsoid
4876 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/1">http://example.com/1</a>[2345</p>
4877 !! end
4878
4879 !! test
4880 External links: open square bracket forbidden in URL (named) (T6377)
4881 !! options
4882 parsoid=wt2html,html2html
4883 !! wikitext
4884 [http://example.com/1[2345]
4885 !! html/php
4886 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4887 </p>
4888 !! html/parsoid
4889 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/1">[2345</a></p>
4890 !!end
4891
4892 # parsoid adds a space before the link name
4893 !! test
4894 External links: open square bracket forbidden in URL (named) (T6377)
4895 Parsoid variant.
4896 !! wikitext
4897 [http://example.com/1 [2345]
4898 !! html
4899 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4900 </p>
4901 !!end
4902
4903 !! test
4904 External links: nowiki in URL link text (T8230)
4905 !! wikitext
4906 [http://example.com/ <nowiki>''example site''</nowiki>]
4907 !! html
4908 <p><a rel="nofollow" class="external text" href="http://example.com/">''example site''</a>
4909 </p>
4910 !! end
4911
4912 !! test
4913 External links: newline forbidden in text (T8230 regression check)
4914 !! wikitext
4915 [http://example.com/ first
4916 second]
4917 !! html
4918 <p>[<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a> first
4919 second]
4920 </p>
4921 !!end
4922
4923 !! test
4924 External links: Pipe char between url and text
4925 !! wikitext
4926 [http://example.com | link]
4927 !! html
4928 <p><a rel="nofollow" class="external text" href="http://example.com">| link</a>
4929 </p>
4930 !!end
4931
4932 !! test
4933 External links: protocol-relative URL in brackets
4934 !! wikitext
4935 [//example.com/ Test]
4936 !! html
4937 <p><a rel="nofollow" class="external text" href="//example.com/">Test</a>
4938 </p>
4939 !! end
4940
4941 # parsoid doesn't explicitly mark autonumbered links, see T55505
4942 !! test
4943 External links: protocol-relative URL in brackets without text
4944 !! wikitext
4945 [//example.com]
4946 !! html/php
4947 <p><a rel="nofollow" class="external autonumber" href="//example.com">[1]</a>
4948 </p>
4949 !! html/parsoid
4950 <p><a rel="mw:ExtLink" class="external autonumber" href="//example.com"></a></p>
4951 !! end
4952
4953 !! test
4954 External links: protocol-relative URL in free text is left alone
4955 !! wikitext
4956 //example.com/Foo
4957 !! html
4958 <p>//example.com/Foo
4959 </p>
4960 !!end
4961
4962 !! test
4963 External links: protocol-relative URL in the middle of a word is left alone (T32269)
4964 !! wikitext
4965 foo//example.com/Foo
4966 !! html
4967 <p>foo//example.com/Foo
4968 </p>
4969 !! end
4970
4971 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
4972 !! test
4973 External links: with no contents
4974 !! options
4975 parsoid=wt2html,wt2wt
4976 !! wikitext
4977 [http://en.wikipedia.org/wiki/Foo]
4978
4979 [[wikipedia:Foo|Bar]]
4980
4981 [[wikipedia:Foo|<span>Bar</span>]]
4982 !! html/php
4983 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo">[1]</a>
4984 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
4985 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo"><span>Bar</span></a>
4986 </p>
4987 !! html/parsoid
4988 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo"></a></p>
4989 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo">Bar</a></p>
4990 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo"><span>Bar</span></a></p>
4991 !! end
4992
4993 !! test
4994 External links: Free with trailing punctuation
4995 !! wikitext
4996 http://example.com,
4997 http://example.com;
4998 http://example.com\
4999 http://example.com.
5000 http://example.com:
5001 http://example.com!
5002 http://example.com?
5003 http://example.com)
5004 http://example.com/url_with_(brackets)
5005 (http://example.com/url_without_brackets)
5006 http://example.com/url_with_entity&amp;
5007 http://example.com/url_with_entity&#x26;
5008 http://example.com/url_with_entity&#038;
5009 http://example.com/url_with_entity&nbsp;
5010 http://example.com/url_with_entity&#xA0;
5011 http://example.com/url_with_entity&#160;
5012 http://example.com/url_with_entity&lt;
5013 http://example.com/url_with_entity&#x3C;
5014 http://example.com/url_with_entity&#60;
5015 !! html/php
5016 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
5017 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>;
5018 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>\
5019 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.
5020 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
5021 <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/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
5025 (<a rel="nofollow" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
5026 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5027 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5028 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5029 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
5030 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#xa0;
5031 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
5032 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&lt;
5033 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#x3c;
5034 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#60;
5035 </p>
5036 !! html/parsoid
5037 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>,
5038 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>;
5039 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>\
5040 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>.
5041 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>:
5042 <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/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
5046 (<a rel="mw:ExtLink" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
5047 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5048 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5049 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5050 <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>
5051 <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>
5052 <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>
5053 <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>
5054 <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>
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;#60;","srcContent":"&lt;"}'>&lt;</span></p>
5056 !! end
5057
5058 !! test
5059 External links: tricky Parsoid html2html case
5060 !! options
5061 parsoid=wt2html,wt2wt,html2html
5062 !! wikitext
5063 http://example.com/url_with_entity&amp;amp;
5064 !! html/php
5065 <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>;
5066 </p>
5067 !! html/parsoid
5068 <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>
5069 !! end
5070
5071 !! test
5072 External links: Free with trailing quotes (T113666)
5073 !! wikitext
5074 '''News:''' Stuff here
5075
5076 news:'a'b''c''d e
5077 !! html/php
5078 <p><b>News:</b> Stuff here
5079 </p><p><a rel="nofollow" class="external free" href="news:&#39;a&#39;b">news:'a'b</a><i>c</i>d e
5080 </p>
5081 !! html/parsoid
5082 <p><b>News:</b> Stuff here</p>
5083 <p><a rel="mw:ExtLink" class="external free" href="news:'a'b">news:'a'b</a><i>c</i>d e</p>
5084 !! end
5085
5086 !! test
5087 External links: with entity
5088 !! wikitext
5089 [http://&#x20;www.librarieswithoutborders.org Libraries without borders]
5090 !! html/php
5091 <p><a rel="nofollow" class="external text" href="http://+www.librarieswithoutborders.org">Libraries without borders</a>
5092 </p>
5093 !! html/parsoid
5094 <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>
5095 !! end
5096
5097 !! test
5098 External links: Lone protocols are never linked (T105697)
5099 !! wikitext
5100 http://
5101 http://;
5102 (http://)
5103 bitcoin:
5104 bitcoin:;
5105 (bitcoin:)
5106 !! html
5107 <p>http://
5108 http://;
5109 (http://)
5110 bitcoin:
5111 bitcoin:;
5112 (bitcoin:)
5113 </p>
5114 !! end
5115
5116 !! test
5117 External links: No preceding word characters allowed (T67278)
5118 !! wikitext
5119 NOPEhttp://example.com
5120 N0http://example.com
5121 ok:http://example.com
5122 ok-http://example.com
5123 !! html
5124 <p>NOPEhttp://example.com
5125 N0http://example.com
5126 ok:<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5127 ok-<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5128 </p>
5129 !! end
5130
5131 !! test
5132 External links: nofollow domain exception
5133 !! wikitext
5134 A [https://no-nofollow.org/foobar link], and another [https://example.org link].
5135 !! html
5136 <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>.
5137 </p>
5138 !!end
5139
5140 !! test
5141 External image
5142 !! wikitext
5143 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5144 !! html
5145 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
5146 </p>
5147 !! end
5148
5149 !! test
5150 External image from https
5151 !! wikitext
5152 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5153 !! html
5154 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
5155 </p>
5156 !! end
5157
5158 !! test
5159 External image (when not allowed)
5160 !! options
5161 wgAllowExternalImages=0
5162 !! wikitext
5163 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5164 !! html
5165 <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>
5166 </p>
5167 !! end
5168
5169 !! test
5170 Link to non-http image, no img tag
5171 !! wikitext
5172 Link to non-http image, no img tag: ftp://example.com/test.jpg
5173 !! html
5174 <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>
5175 </p>
5176 !! end
5177
5178 !! test
5179 External links: terminating separator
5180 !! wikitext
5181 Terminating separator: http://example.com/thing,
5182 !! html
5183 <p>Terminating separator: <a rel="nofollow" class="external free" href="http://example.com/thing">http://example.com/thing</a>,
5184 </p>
5185 !! end
5186
5187 !! test
5188 External links: intervening separator
5189 !! wikitext
5190 Intervening separator: http://example.com/1,2,3
5191 !! html
5192 <p>Intervening separator: <a rel="nofollow" class="external free" href="http://example.com/1,2,3">http://example.com/1,2,3</a>
5193 </p>
5194 !! end
5195
5196 !! test
5197 External links: old bug with URL in query
5198 !! wikitext
5199 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
5200 !! html
5201 <p>Old bug with URL in query: <a rel="nofollow" class="external text" href="http://example.com/thing?url=http://example.com">link</a>
5202 </p>
5203 !! end
5204
5205 !! test
5206 External links: old URL-in-URL bug, mixed protocols
5207 !! wikitext
5208 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
5209 !! html
5210 <p>And again with mixed protocols: <a rel="nofollow" class="external text" href="ftp://example.com?url=http://example.com">link</a>
5211 </p>
5212 !!end
5213
5214 # Since Parsoid is starting to emit canonical wikitext for links,
5215 # [http://example.com http://example.com] will not RT back to that
5216 # form anymore.
5217 !! test
5218 External links: URL in text
5219 !! options
5220 parsoid=wt2html
5221 !! wikitext
5222 URL in text: [http://example.com http://example.com]
5223 !! html/php
5224 <p>URL in text: <a rel="nofollow" class="external text" href="http://example.com">http://example.com</a>
5225 </p>
5226 !! html/parsoid
5227 <p>URL in text: <a rel="mw:ExtLink" class="external text" href="http://example.com">http://example.com</a></p>
5228 !! end
5229
5230 !! test
5231 External links: Clickable images
5232 !! wikitext
5233 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
5234 !! html/php
5235 <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>
5236 </p>
5237 !! html/parsoid
5238 <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>
5239 !! end
5240
5241 !! test
5242 External links: raw ampersand
5243 !! wikitext
5244 Old &amp; use: http://x&y
5245 !! html
5246 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5247 </p>
5248 !! end
5249
5250 !! test
5251 External links: encoded ampersand
5252 !! wikitext
5253 Old &amp; use: http://x&amp;y
5254 !! html/php
5255 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5256 </p>
5257 !! html/parsoid
5258 <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>
5259 !! end
5260
5261 !! test
5262 External links: encoded equals (T8102)
5263 !! wikitext
5264 http://example.com/?foo&#61;bar
5265 !! html/php
5266 <p><a rel="nofollow" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a>
5267 </p>
5268 !! html/parsoid
5269 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a></p>
5270 !! end
5271
5272 ##
5273 ## Note that parsoid doesn't explicit mark autonumbered links, nor
5274 ## does it number them. As discussed in T55505, we can identify
5275 ## autonumbered links via CSS.
5276 ##
5277
5278 !! test
5279 External links: [raw ampersand]
5280 !! wikitext
5281 Old &amp; use: [http://x&y]
5282 !! html/php
5283 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5284 </p>
5285 !! html/parsoid
5286 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&amp;y"></a></p>
5287 !! end
5288
5289 # note that parsoid html is identical to [raw ampersand] case; so html2wt
5290 # mode will return the [raw ampersand] wikitext
5291 !! test
5292 External links: [encoded ampersand]
5293 !! options
5294 parsoid=wt2html,wt2wt,html2html
5295 !! wikitext
5296 Old &amp; use: [http://x&amp;y]
5297 !! html/php
5298 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5299 </p>
5300 !! html/parsoid
5301 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&amp;y"></a></p>
5302 !! end
5303
5304 !! test
5305 External links: [raw equals]
5306 !! wikitext
5307 [http://example.com/?foo=bar]
5308 !! html/php
5309 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5310 </p>
5311 !! html/parsoid
5312 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/?foo=bar"></a></p>
5313 !! end
5314
5315 # note that parsoid html is identical to [raw equals] case; so html2wt
5316 # mode will return the [raw equals] wikitext
5317 !! test
5318 External links: [encoded equals] (T8102)
5319 !! options
5320 parsoid=wt2html,wt2wt,html2html
5321 !! wikitext
5322 [http://example.com/?foo&#61;bar]
5323 !! html/php
5324 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5325 </p>
5326 !! html/parsoid
5327 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/?foo=bar"></a></p>
5328 !! end
5329
5330 # xxx parsoid strips the IDN character, so the round-trip tests will
5331 # obviously fail and are disabled. --cscott
5332 !! test
5333 External links: [IDN ignored character reference in hostname; strip it right off]
5334 !! options
5335 parsoid=wt2html,wt2wt,html2html
5336 !! wikitext
5337 [http://e&zwnj;xample.com/]
5338 !! html/php
5339 <p><a rel="nofollow" class="external autonumber" href="http://example.com/">[1]</a>
5340 </p>
5341 !! html/parsoid
5342 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/"></a></p>
5343 !! end
5344
5345 # FIXME: This test (the IDN characters in the text of a link) is an inconsistency.
5346 # Where an external link could easily circumvent the sanitization of the text of
5347 # a link like this (where an IDN-ignore character is in the URL somewhere), this
5348 # test demands a higher standard. That's a bit strange.
5349 #
5350 # Example:
5351 #
5352 # http://e‌xample.com -> [http://example.com|http://example.com]
5353 # [http://example.com|http://e‌xample.com] -> [http://example.com|http://e‌xample.com]
5354 #
5355 # The first example is sanitized, but the second is not. Any security benefits
5356 # from this production are trivial to circumvent. Either remove this test and
5357 # let the parser(s) do their thing unaccosted, or fix the inconsistency and change
5358 # the test accordingly.
5359 #
5360 # All our love,
5361 # The Parsoid team.
5362 # xxx parsoid strips the IDN character, so the round-trip tests will
5363 # obviously fail and are disabled. --cscott
5364 !! test
5365 External links: IDN ignored character reference in hostname; strip it right off
5366 !! options
5367 parsoid=wt2html,html2html
5368 !! wikitext
5369 http://e&zwnj;xample.com/
5370 !! html/php
5371 <p><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>
5372 </p>
5373 !! html/parsoid
5374 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/">http://example.com/</a></p>
5375 !! end
5376
5377 !! test
5378 External links: www.jpeg.org (T2554)
5379 !! wikitext
5380 http://www.jpeg.org
5381 !! html
5382 <p><a rel="nofollow" class="external free" href="http://www.jpeg.org">http://www.jpeg.org</a>
5383 </p>
5384 !! end
5385
5386 # parsoid doesn't explicitly mark autonumbered links, see T55505
5387 !! test
5388 External links: URL within URL (T2002)
5389 !! wikitext
5390 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
5391 !! html/php
5392 <p><a rel="nofollow" class="external autonumber" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp">[1]</a>
5393 </p>
5394 !! html/parsoid
5395 <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>
5396 !! end
5397
5398 !! test
5399 T2361: URL inside bracketed URL
5400 !! wikitext
5401 [http://www.example.com/foo http://www.example.com/bar]
5402 !! html
5403 <p><a rel="nofollow" class="external text" href="http://www.example.com/foo">http://www.example.com/bar</a>
5404 </p>
5405 !! end
5406
5407 !! test
5408 T2361: URL within URL, not bracketed
5409 !! wikitext
5410 http://www.example.com/foo?=http://www.example.com/bar
5411 !! html
5412 <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>
5413 </p>
5414 !! end
5415
5416 !! test
5417 T2289: ">"-token in URL-tail
5418 !! wikitext
5419 http://www.example.com/<hello>
5420 !! html
5421 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>&lt;hello&gt;
5422 </p>
5423 !!end
5424
5425 !! test
5426 T2289: literal ">"-token in URL-tail
5427 !! wikitext
5428 http://www.example.com/<b>html</b>
5429 !! html/php
5430 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a><b>html</b>
5431 </p>
5432 !! html/parsoid
5433 <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>
5434 !! end
5435
5436 !! test
5437 T2289: ">"-token in bracketed URL
5438 !! wikitext
5439 [http://www.example.com/<hello> stuff]
5440 !! html
5441 <p><a rel="nofollow" class="external text" href="http://www.example.com/">&lt;hello&gt; stuff</a>
5442 </p>
5443 !!end
5444
5445 !! test
5446 T2289: literal ">"-token in bracketed URL
5447 !! wikitext
5448 [http://www.example.com/<b>html</b> stuff]
5449 !! html
5450 <p><a rel="nofollow" class="external text" href="http://www.example.com/"><b>html</b> stuff</a>
5451 </p>
5452 !!end
5453
5454 !! test
5455 T2289: literal double quote at end of URL
5456 !! wikitext
5457 http://www.example.com/"hello"
5458 !! html
5459 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>"hello"
5460 </p>
5461 !!end
5462
5463 !! test
5464 T2289: literal double quote in bracketed URL
5465 !! wikitext
5466 [http://www.example.com/"hello" stuff]
5467 !! html
5468 <p><a rel="nofollow" class="external text" href="http://www.example.com/">"hello" stuff</a>
5469 </p>
5470 !!end
5471
5472 !! test
5473 External links: multiple legal whitespace is fine, Magnus. Don't break it please. (T7081)
5474 !! wikitext
5475 [http://www.example.com test]
5476 !! html
5477 <p><a rel="nofollow" class="external text" href="http://www.example.com">test</a>
5478 </p>
5479 !! end
5480
5481 !! test
5482 External links: link text with spaces
5483 !! wikitext
5484 [http://www.example.com a b c]
5485 [http://www.example.com ''a'' ''b'']
5486 !! html
5487 <p><a rel="nofollow" class="external text" href="http://www.example.com">a b c</a>
5488 <a rel="nofollow" class="external text" href="http://www.example.com"><i>a</i> <i>b</i></a>
5489 </p>
5490 !! end
5491
5492 # Note edge case difference between PHP and Parsoid here.
5493 !! test
5494 External links: wiki links within external link (T5695)
5495 !! options
5496 parsoid=wt2html,html2html
5497 !! wikitext
5498 [http://example.com [[wikilink]] embedded in ext link]
5499
5500 [http://example.com test [[wikilink]] embedded in ext link]
5501 !! html/php
5502 <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>
5503 </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>
5504 </p>
5505 !! html/parsoid
5506 <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>
5507 <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>
5508 !! end
5509
5510 !! test
5511 T2787: Links with one slash after the url protocol are invalid
5512 !! wikitext
5513 http:/example.com
5514
5515 [http:/example.com title]
5516 !! html
5517 <p>http:/example.com
5518 </p><p>[http:/example.com title]
5519 </p>
5520 !! end
5521
5522 !! test
5523 Bracketed external links with template-generated invalid target
5524 !! wikitext
5525 [{{echo|http:/example.com}} title]
5526 !! html
5527 <p>[http:/example.com title]
5528 </p>
5529 !! end
5530
5531 # wt2html only because Parsoid would want to add <nowiki>s coming from html
5532 !! test
5533 Broken wikilinks (but not external links) prevent templates from closing
5534 !! options
5535 parsoid=wt2html
5536 !! wikitext
5537 [http://example.com x
5538
5539 {{echo|[http://example.com x}}
5540
5541 [[Foo
5542
5543 {{echo|[[Foo}}
5544 !! html/php
5545 <p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5546 </p><p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5547 </p><p>[[Foo
5548 </p><p>{{echo|[[Foo}}
5549 </p>
5550 !! html/parsoid
5551 <p>[<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a> x</p>
5552 <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>
5553 <p>[[Foo</p>
5554 <p>{{echo|[[Foo}}</p>
5555 !! end
5556
5557 !! test
5558 Wikilinks with embedded newlines are not broken
5559 !! wikitext
5560 {{echo|[[ Foo
5561 B
5562 C]]}}
5563 !! html/php
5564 <p>[[ Foo
5565 B
5566 C]]
5567 </p>
5568 !! html/parsoid
5569 <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>
5570 !! end
5571
5572 !! test
5573 Broken templates
5574 !! options
5575 parsoid=wt2html
5576 !! wikitext
5577 {{echo|[[Foo|}}]]
5578
5579 [[Foo|{{echo|]]}}
5580 !! html/php
5581 <p>{{echo|<a href="/wiki/Foo" title="Foo">}}</a>
5582 </p><p>[[Foo|]]
5583 </p>
5584 !! html/parsoid
5585 <p>{{echo|<a rel="mw:WikiLink" href="./Foo" title="Foo">}}</a></p>
5586 <p>[[Foo|<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"]]"}},"i":0}}]}'>]]</span></p>
5587 !! end
5588
5589 !! test
5590 T4702: Mismatched <i>, <b> and <a> tags are invalid
5591 !! wikitext
5592 ''[http://example.com text'']
5593 [http://example.com '''text]'''
5594 ''Something [http://example.com in italic'']
5595 ''Something [http://example.com mixed''''', even bold]'''
5596 '''''Now [http://example.com both''''']
5597 !! html
5598 <p><a rel="nofollow" class="external text" href="http://example.com"><i>text</i></a>
5599 <a rel="nofollow" class="external text" href="http://example.com"><b>text</b></a>
5600 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>in italic</i></a>
5601 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>mixed</i><b>, even bold</b></a>
5602 <i><b>Now </b></i><a rel="nofollow" class="external text" href="http://example.com"><i><b>both</b></i></a>
5603 </p>
5604 !! end
5605
5606
5607 !! test
5608 T6781: %26 in URL
5609 !! wikitext
5610 http://www.example.com/?title=AT%26T
5611 !! html/php
5612 <p><a rel="nofollow" class="external free" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a>
5613 </p>
5614 !! html/parsoid
5615 <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>
5616 !! end
5617
5618 # According to https://www.w3.org/TR/2011/WD-html5-20110525/Overview.html#parsing-urls a plain
5619 # % is actually legal in HTML5. Any change in output would need testing though.
5620 !! test
5621 T6781, T7267: %25 in URL
5622 !! wikitext
5623 http://www.example.com/?title=100%25_Bran
5624 !! html/php
5625 <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>
5626 </p>
5627 !! html/parsoid
5628 <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>
5629 !! end
5630
5631 !! test
5632 T6781, T7267: %28, %29 in URL
5633 !! wikitext
5634 http://www.example.com/?title=Ben-Hur_%281959_film%29
5635 !! html/php
5636 <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>
5637 </p>
5638 !! html/parsoid
5639 <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>
5640 !! end
5641
5642
5643 !! test
5644 T6781: %26 in autonumber URL
5645 !! wikitext
5646 [http://www.example.com/?title=AT%26T]
5647 !! html/php
5648 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=AT%26T">[1]</a>
5649 </p>
5650 !! html/parsoid
5651 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=AT%26T"></a></p>
5652 !! end
5653
5654 !! test
5655 T6781, T7267: %26 in autonumber URL
5656 !! wikitext
5657 [http://www.example.com/?title=100%25_Bran]
5658 !! html/php
5659 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=100%25_Bran">[1]</a>
5660 </p>
5661 !! html/parsoid
5662 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=100%25_Bran"></a></p>
5663 !! end
5664
5665 !! test
5666 T6781, T7267: %28, %29 in autonumber URL
5667 !! wikitext
5668 [http://www.example.com/?title=Ben-Hur_%281959_film%29]
5669 !! html/php
5670 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">[1]</a>
5671 </p>
5672 !! html/parsoid
5673 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29"></a></p>
5674 !! end
5675
5676
5677 !! test
5678 T6781: %26 in bracketed URL
5679 !! wikitext
5680 [http://www.example.com/?title=AT%26T link]
5681 !! html/php
5682 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=AT%26T">link</a>
5683 </p>
5684 !! html/parsoid
5685 <p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=AT%26T">link</a></p>
5686 !! end
5687
5688 !! test
5689 T6781, T7267: %25 in bracketed URL
5690 !! wikitext
5691 [http://www.example.com/?title=100%25_Bran link]
5692 !! html
5693 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=100%25_Bran">link</a>
5694 </p>
5695 !! end
5696
5697 !! test
5698 T6781, T7267: %28, %29 in bracketed URL
5699 !! wikitext
5700 [http://www.example.com/?title=Ben-Hur_%281959_film%29 link]
5701 !! html/php
5702 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a>
5703 </p>
5704 !! html/parsoid
5705 <p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a></p>
5706 !! end
5707
5708 !! test
5709 External link containing a period in the anchor. (T65947)
5710 !! wikitext
5711 [//foo.org/bar#baz. bang]
5712
5713 [//foo.org/bar. bang]
5714 !! html/php
5715 <p><a rel="nofollow" class="external text" href="//foo.org/bar#baz.">bang</a>
5716 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar.">bang</a>
5717 </p>
5718 !! html/parsoid
5719 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar#baz.">bang</a></p>
5720 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar.">bang</a></p>
5721 !! end
5722
5723 !! test
5724 External link containing a single quote. (T65947)
5725 !! wikitext
5726 [//foo.org/bar'baz]
5727
5728 [//foo.org/bar'baz bang]
5729 !! html/php
5730 <p><a rel="nofollow" class="external autonumber" href="//foo.org/bar&#39;baz">[1]</a>
5731 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar&#39;baz">bang</a>
5732 </p>
5733 !! html/parsoid
5734 <p><a rel="mw:ExtLink" class="external autonumber" href="//foo.org/bar'baz"></a></p>
5735 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar'baz">bang</a></p>
5736 !! end
5737
5738 !! test
5739 External link containing double-single-quotes in text '' (T6598 sanity check)
5740 !! wikitext
5741 Some [http://example.com/ pretty ''italics'' and stuff]!
5742 !! html
5743 <p>Some <a rel="nofollow" class="external text" href="http://example.com/">pretty <i>italics</i> and stuff</a>!
5744 </p>
5745 !! end
5746
5747 !! test
5748 External link containing double-single-quotes in text embedded in italics (T6598 sanity check)
5749 !! wikitext
5750 ''Some [http://example.com/ pretty ''italics'' and stuff]!''
5751 !! html
5752 <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>
5753 </p>
5754 !! end
5755
5756 # Don't add the html/php section since the output is broken and there isn't any reason to spec it
5757 !! test
5758 External link containing double-single-quotes with no space separating the url from text in italics
5759 !! wikitext
5760 [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]].]
5761 !! html/php+tidy
5762 <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>.
5763 </p>
5764 !! html/parsoid
5765 <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>
5766 !! end
5767
5768 !! test
5769 External link with comments in link text
5770 !! wikitext
5771 [http://www.google.com Google <!-- comment -->]
5772 !! html/php
5773 <p><a rel="nofollow" class="external text" href="http://www.google.com">Google </a>
5774 </p>
5775 !! html/parsoid
5776 <p><a rel="mw:ExtLink" class="external text" href="http://www.google.com">Google <!-- comment --></a></p>
5777 !! end
5778
5779 !! test
5780 External link to bare IPv4 address
5781 !! wikitext
5782 [http://192.168.0.1 Link]
5783 !! html/php
5784 <p><a rel="nofollow" class="external text" href="http://192.168.0.1">Link</a>
5785 </p>
5786 !! html/parsoid
5787 <p><a rel="mw:ExtLink" class="external text" href="http://192.168.0.1">Link</a></p>
5788 !! end
5789
5790 !! test
5791 URL-encoding in URL functions (single parameter)
5792 !! wikitext
5793 {{localurl:Some page|amp=&}}
5794 !! html
5795 <p>/index.php?title=Some_page&amp;amp=&amp;
5796 </p>
5797 !! end
5798
5799 !! test
5800 URL-encoding in URL functions (multiple parameters)
5801 !! wikitext
5802 {{localurl:Some page|q=?&amp=&}}
5803 !! html
5804 <p>/index.php?title=Some_page&amp;q=?&amp;amp=&amp;
5805 </p>
5806 !! end
5807
5808 !! test
5809 Brackets in urls
5810 !! wikitext
5811 http://example.com/index.php?foozoid%5B%5D=bar
5812
5813 http://example.com/index.php?foozoid&#x5B;&#x5D;=bar
5814 !! html/php
5815 <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>
5816 </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>
5817 </p>
5818 !! html/parsoid
5819 <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>
5820
5821 <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>
5822 !! end
5823
5824 !! test
5825 IPv6 urls, autolink format (T23261)
5826 !! wikitext
5827 http://[2404:130:0:1000::187:2]/index.php
5828
5829 Examples from RFC 2373, section 2.2:
5830
5831 *http://[1080::8:800:200C:417A]/unicast
5832 *http://[FF01::101]/multicast
5833 *http://[::1]/loopback
5834 *http://[::]/unspecified
5835 *http://[::13.1.68.3]/ipv4compat
5836 *http://[::FFFF:129.144.52.38]/ipv4compat
5837
5838 Examples from RFC 2732, section 2:
5839
5840 *http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
5841 *http://[1080:0:0:0:8:800:200C:417A]/index.html
5842 *http://[3ffe:2a00:100:7031::1]
5843 *http://[1080::8:800:200C:417A]/foo
5844 *http://[::192.9.5.5]/ipng
5845 *http://[::FFFF:129.144.52.38]:80/index.html
5846 *http://[2010:836B:4179::836B:4179]
5847 !! html/php
5848 <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>
5849 </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:
5850 </p>
5851 <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>
5852 <li><a rel="nofollow" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5853 <li><a rel="nofollow" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5854 <li><a rel="nofollow" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5855 <li><a rel="nofollow" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5856 <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>
5857 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5858 </p>
5859 <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>
5860 <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>
5861 <li><a rel="nofollow" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5862 <li><a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
5863 <li><a rel="nofollow" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5864 <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>
5865 <li><a rel="nofollow" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5866
5867 !! html/parsoid
5868 <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>
5869
5870 <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>
5871 <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>
5872 <li><a rel="mw:ExtLink" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5873 <li><a rel="mw:ExtLink" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5874 <li><a rel="mw:ExtLink" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5875 <li><a rel="mw:ExtLink" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5876 <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>
5877
5878 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external mw-magiclink">RFC 2732</a>, section 2:</p>
5879 <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>
5880 <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>
5881 <li><a rel="mw:ExtLink" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5882 <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>
5883 <li><a rel="mw:ExtLink" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5884 <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>
5885 <li><a rel="mw:ExtLink" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5886 !! end
5887
5888 !! test
5889 IPv6 urls, bracketed format (T23261)
5890 !! wikitext
5891 [http://[2404:130:0:1000::187:2]/index.php test]
5892
5893 Examples from RFC 2373, section 2.2:
5894
5895 *[http://[1080::8:800:200C:417A] unicast]
5896 *[http://[FF01::101] multicast]
5897 *[http://[::1]/ loopback]
5898 *[http://[::] unspecified]
5899 *[http://[::13.1.68.3] ipv4compat]
5900 *[http://[::FFFF:129.144.52.38] ipv4compat]
5901
5902 Examples from RFC 2732, section 2:
5903
5904 *[http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html 1]
5905 *[http://[1080:0:0:0:8:800:200C:417A]/index.html 2]
5906 *[http://[3ffe:2a00:100:7031::1] 3]
5907 *[http://[1080::8:800:200C:417A]/foo 4]
5908 *[http://[::192.9.5.5]/ipng 5]
5909 *[http://[::FFFF:129.144.52.38]:80/index.html 6]
5910 *[http://[2010:836B:4179::836B:4179] 7]
5911 !! html/php
5912 <p><a rel="nofollow" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a>
5913 </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:
5914 </p>
5915 <ul><li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5916 <li><a rel="nofollow" class="external text" href="http://[FF01::101]">multicast</a></li>
5917 <li><a rel="nofollow" class="external text" href="http://[::1]/">loopback</a></li>
5918 <li><a rel="nofollow" class="external text" href="http://[::]">unspecified</a></li>
5919 <li><a rel="nofollow" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5920 <li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5921 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5922 </p>
5923 <ul><li><a rel="nofollow" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
5924 <li><a rel="nofollow" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5925 <li><a rel="nofollow" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5926 <li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5927 <li><a rel="nofollow" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
5928 <li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5929 <li><a rel="nofollow" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5930
5931 !! html/parsoid
5932 <p><a rel="mw:ExtLink" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a></p>
5933
5934 <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>
5935 <ul><li><a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5936 <li><a rel="mw:ExtLink" class="external text" href="http://[FF01::101]">multicast</a></li>
5937 <li><a rel="mw:ExtLink" class="external text" href="http://[::1]/">loopback</a></li>
5938 <li><a rel="mw:ExtLink" class="external text" href="http://[::]">unspecified</a></li>
5939 <li><a rel="mw:ExtLink" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5940 <li><a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5941
5942 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external mw-magiclink">RFC 2732</a>, section 2:</p>
5943 <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>
5944 <li><a rel="mw:ExtLink" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5945 <li><a rel="mw:ExtLink" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5946 <li><a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5947 <li><a rel="mw:ExtLink" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
5948 <li><a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5949 <li><a rel="mw:ExtLink" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5950 !! end
5951
5952 !! test
5953 Non-extlinks in brackets
5954 !! wikitext
5955 [foo]
5956 [foo bar]
5957 [foo ''bar'']
5958 [fool's] errand
5959 [fool's errand]
5960 [{{echo|foo}}]
5961 [{{echo|foo}} bar]
5962 [{{echo|foo}} ''bar'']
5963 [{{echo|foo}}l's] errand
5964 [{{echo|foo}}l's errand]
5965 [url={{echo|foo}}]
5966 [url=http://example.com]
5967 [http:// bare protocols don't count]
5968 !! html/php
5969 <p>[foo]
5970 [foo bar]
5971 [foo <i>bar</i>]
5972 [fool's] errand
5973 [fool's errand]
5974 [foo]
5975 [foo bar]
5976 [foo <i>bar</i>]
5977 [fool's] errand
5978 [fool's errand]
5979 [url=foo]
5980 [url=<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>]
5981 [http:// bare protocols don't count]
5982 </p>
5983 !! html/parsoid
5984 <p>[foo]
5985 [foo bar]
5986 [foo <i>bar</i>]
5987 [fool's] errand
5988 [fool's errand]
5989 [<span about="#mwt19" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>]
5990 [<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]
5991 [<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>]
5992 [<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
5993 [<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]
5994 [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>]
5995 [url=<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>]
5996 [http:// bare protocols don't count]</p>
5997 !! end
5998
5999 !! test
6000 Percent encoding in external links
6001 !! wikitext
6002 [https://github.com/search?l=&q=ResourceLoader+%40wikimedia Search]
6003 !! html/php
6004 <p><a rel="nofollow" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a>
6005 </p>
6006 !! html/parsoid
6007 <p><a rel="mw:ExtLink" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a></p>
6008 !! end
6009
6010 !! test
6011 Use url link syntax for links where the content is equal the link target
6012 !! wikitext
6013 http://example.com
6014 !! html/php
6015 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
6016 </p>
6017 !! html/parsoid
6018 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a></p>
6019 !! end
6020
6021 !! test
6022 Parenthesis in external links, especially URL links
6023 !! wikitext
6024 http://example.com)
6025
6026 http://example.com/test)
6027
6028 http://example.com/(test)
6029
6030 http://example.com/((test)
6031
6032 (http://example.com/(test))
6033
6034 (http://example.com/(test)))))
6035
6036 http://example.com/a)b
6037
6038 [http://example.com) foo]
6039 !! html/php
6040 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
6041 </p><p><a rel="nofollow" class="external free" href="http://example.com/test">http://example.com/test</a>)
6042 </p><p><a rel="nofollow" class="external free" href="http://example.com/(test)">http://example.com/(test)</a>
6043 </p><p><a rel="nofollow" class="external free" href="http://example.com/((test)">http://example.com/((test)</a>
6044 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test))">http://example.com/(test))</a>
6045 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a>
6046 </p><p><a rel="nofollow" class="external free" href="http://example.com/a)b">http://example.com/a)b</a>
6047 </p><p><a rel="nofollow" class="external text" href="http://example.com)">foo</a>
6048 </p>
6049 !! html/parsoid
6050 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>)</p>
6051 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/test">http://example.com/test</a>)</p>
6052 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/(test)">http://example.com/(test)</a></p>
6053 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/((test)">http://example.com/((test)</a></p>
6054 <p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test))">http://example.com/(test))</a></p>
6055 <p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a></p>
6056 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/a)b">http://example.com/a)b</a></p>
6057 <p><a rel="mw:ExtLink" class="external text" href="http://example.com)">foo</a></p>
6058 !! end
6059
6060 !! test
6061 Parenthesis in external links, w/ transclusion or comment
6062 !! wikitext
6063 (http://example.com/{{echo|hi}})
6064
6065 (http://example.com<!-- hi -->)
6066 !! html/php
6067 <p>(<a rel="nofollow" class="external free" href="http://example.com/hi">http://example.com/hi</a>)
6068 </p><p>(<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
6069 </p>
6070 !! html/parsoid
6071 <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>
6072
6073 <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>
6074 !! end
6075
6076 !! test
6077 Serialize <a> tags with invalid link targets as plain text
6078 !! options
6079 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
6080 !! html/parsoid
6081 <a rel="mw:WikiLink" href="[[foo]]">text</a>
6082 <a rel="mw:WikiLink" href="[[foo]]">*text</a>
6083 <a rel="mw:WikiLink" href="[[foo]]">[[foo]]</a>
6084 <a rel="mw:WikiLink" href="[[foo]]">*a [[foo]]</a>
6085 !! wikitext
6086 text
6087 <nowiki>*</nowiki>text
6088 <nowiki>[[foo]]</nowiki>
6089 <nowiki>*</nowiki>a <nowiki>[[foo]]</nowiki>
6090 !! end
6091
6092 !! test
6093 mw:ExtLink -vs- mw:WikiLink (T94723)
6094 !! options
6095 parsoid=html2wt
6096 !! html/parsoid
6097 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"piped","a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>Bar</a>
6098 <a rel="mw:WikiLink" href="./Foo" title="Foo">Bar</a>
6099 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
6100 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
6101 <p>
6102 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
6103 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
6104 </p>
6105 !! wikitext
6106 [[Foo|Bar]]
6107 [[Foo|Bar]]
6108 [[:en:Foo|Bar]]
6109 [[:en:Foo|Bar]]
6110
6111 [[:en:European_Robin|European Robin]]
6112 [[:en:European_Robin|European Robin]]
6113 !! end
6114
6115 !! test
6116 mw:ExtLink linking to a interwiki URL can be round-tripped losslessly (T94723)
6117 !! options
6118 parsoid=wt2wt
6119 !! wikitext
6120 [http://en.wikipedia.org/wiki/European_Robin European Robin]
6121 !! html/parsoid
6122 THIS SECTION IS NOT USED (but Parsoid won't run the test without it)
6123 !! end
6124
6125
6126 ###
6127 ### Quotes
6128 ###
6129
6130 !! test
6131 Quotes
6132 !! wikitext
6133 Normal text. '''Bold text.''' Normal text. ''Italic text.''
6134
6135 Normal text. '''''Bold italic text.''''' Normal text.
6136 !! html
6137 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
6138 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
6139 </p>
6140 !! end
6141
6142
6143 # Parsoid inserts an empty bold tag pair at the end of the line, that the PHP
6144 # parser strips. The wikitext contains just the first half of the bold
6145 # quote pair.
6146 !! test
6147 Unclosed and unmatched quotes
6148 !! wikitext
6149 '''''Bold italic text '''with bold deactivated''' in between.'''''
6150
6151 '''''Bold italic text ''with italic deactivated'' in between.'''''
6152
6153 '''Bold text..
6154
6155 ..spanning two paragraphs (should not work).'''
6156
6157 '''Bold tag left open
6158
6159 ''Italic tag left open
6160
6161 Normal text.
6162
6163 <!-- Unmatching number of opening, closing tags: -->
6164 '''This year''''s election ''should'' beat '''last year''''s.
6165
6166 ''Tom'''s car is bigger than ''Susan'''s.
6167
6168 Plain ''italic'''s plain
6169 !! html/php
6170 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
6171 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
6172 </p><p><b>Bold text..</b>
6173 </p><p>..spanning two paragraphs (should not work).
6174 </p><p><b>Bold tag left open</b>
6175 </p><p><i>Italic tag left open</i>
6176 </p><p>Normal text.
6177 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
6178 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
6179 </p><p>Plain <i>italic'</i>s plain
6180 </p>
6181 !! html/parsoid
6182 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
6183 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
6184 </p><p><b>Bold text..</b>
6185 </p><p>..spanning two paragraphs (should not work).<b></b>
6186 </p><p><b>Bold tag left open</b>
6187 </p><p><i>Italic tag left open</i>
6188 </p><p>Normal text.
6189 </p>
6190 <!-- Unmatching number of opening, closing tags: -->
6191 <p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
6192 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
6193 </p><p>Plain <i>italic'</i>s plain
6194 </p>
6195 !! end
6196
6197 ###
6198 ### Tables
6199 ###
6200 ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
6201 ###
6202
6203 # This should not produce <table></table> as <table><tr><td></td></tr></table>
6204 # is the bare minimum required by the spec, see:
6205 # https://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
6206 # Parsoid team replies: empty table tags are legal in HTML5
6207 !! test
6208 A table with no data.
6209 !! options
6210 parsoid=wt2html
6211 !! wikitext
6212 {||}
6213 !! html/php
6214
6215 !! html/parsoid
6216 <table></table>
6217
6218 !! end
6219
6220 !! test
6221 A table with stray table end tags on start tag line (wt2html)
6222 !! options
6223 parsoid=wt2html
6224 !! wikitext
6225 {|style="color: red;"|}
6226
6227 {|style="color: red;" |}
6228 |foo
6229 |}
6230
6231 {|style="color: red;"|} id="foo"
6232 |foo
6233 |}
6234
6235 {|style="color: red;" |} id="foo"
6236 |foo
6237 |}
6238 !! html
6239 <table style="color: red;"></table>
6240
6241 <table style="color: red;">
6242 <tbody><tr>
6243 <td>foo</td>
6244 </tr></tbody>
6245 </table>
6246
6247 <table style="color: red;" id="foo">
6248 <tbody><tr>
6249 <td>foo</td>
6250 </tr></tbody>
6251 </table>
6252
6253 <table style="color: red;" id="foo">
6254 <tbody><tr>
6255 <td>foo</td>
6256 </tr></tbody>
6257 </table>
6258
6259 !! end
6260
6261 !! test
6262 A table with no data (take 2)
6263 !! wikitext
6264 {|
6265 |}
6266 !! html/parsoid
6267 <table></table>
6268 !! end
6269
6270 # A table with nothing but a caption is invalid XHTML, we might want to render
6271 # this as <p>caption</p>
6272 # Parsoid team replies: table with only a caption is legal in HTML5
6273 !! test
6274 A table with nothing but a caption
6275 !! wikitext
6276 {|
6277 |+caption
6278 |}
6279 !! html/php
6280 <table>
6281 <caption>caption
6282 </caption><tr><td></td></tr></table>
6283
6284 !! html/parsoid
6285 <table><caption>caption</caption></table>
6286 !! end
6287
6288 !! test
6289 A table with caption with default-spaced attributes and a table row
6290 !! wikitext
6291 {|
6292 |+ style="color: red;" |caption1
6293 |-
6294 |foo
6295 |}
6296 !! html
6297 <table>
6298 <caption style="color: red;">caption1
6299 </caption>
6300 <tr>
6301 <td>foo
6302 </td></tr></table>
6303
6304 !! end
6305
6306 !! test
6307 A table with captions with non-default spaced attributes and a table row
6308 !! wikitext
6309 {|
6310 |+style="color: red;"|caption2
6311 |+ style="color: red;"|caption3
6312 |-
6313 |foo
6314 |}
6315 !! html
6316 <table>
6317 <caption style="color: red;">caption2
6318 </caption>
6319 <caption style="color: red;">caption3
6320 </caption>
6321 <tr>
6322 <td>foo
6323 </td></tr></table>
6324
6325 !! end
6326
6327 !! test
6328 Table td-cell syntax variations
6329 !! wikitext
6330 {|
6331 |foo bar foo|baz
6332 |foo bar foo||baz
6333 |style='color:red;'|baz
6334 |style='color:red;'||baz
6335 |}
6336 !! html
6337 <table>
6338 <tr>
6339 <td>baz
6340 </td>
6341 <td>foo bar foo</td>
6342 <td>baz
6343 </td>
6344 <td style="color:red;">baz
6345 </td>
6346 <td>style='color:red;'</td>
6347 <td>baz
6348 </td></tr></table>
6349
6350 !! end
6351
6352 !! test
6353 Simple table
6354 !! wikitext
6355 {|
6356 |1||2
6357 |-
6358 |3||4
6359 |}
6360 !! html
6361 <table>
6362 <tr>
6363 <td>1</td>
6364 <td>2
6365 </td></tr>
6366 <tr>
6367 <td>3</td>
6368 <td>4
6369 </td></tr></table>
6370
6371 !! end
6372
6373 !! test
6374 Simple table but with multiple dashes for row wikitext
6375 !! wikitext
6376 {|
6377 |foo
6378 |-----
6379 |bar
6380 |}
6381 !! html
6382 <table>
6383 <tr>
6384 <td>foo
6385 </td></tr>
6386 <tr>
6387 <td>bar
6388 </td></tr></table>
6389
6390 !! end
6391
6392 !! test
6393 Multiplication table
6394 !! wikitext
6395 {| border="1" cellpadding="2"
6396 |+Multiplication table
6397 |-
6398 !&times;!!1!!2!!3
6399 |-
6400 !1
6401 |1||2||3
6402 |-
6403 !2
6404 |2||4||6
6405 |-
6406 !3
6407 |3||6||9
6408 |-
6409 !4
6410 |4||8||12
6411 |-
6412 !5
6413 |5||10||15
6414 |}
6415 !! html
6416 <table border="1" cellpadding="2">
6417 <caption>Multiplication table
6418 </caption>
6419 <tr>
6420 <th>&#215;</th>
6421 <th>1</th>
6422 <th>2</th>
6423 <th>3
6424 </th></tr>
6425 <tr>
6426 <th>1
6427 </th>
6428 <td>1</td>
6429 <td>2</td>
6430 <td>3
6431 </td></tr>
6432 <tr>
6433 <th>2
6434 </th>
6435 <td>2</td>
6436 <td>4</td>
6437 <td>6
6438 </td></tr>
6439 <tr>
6440 <th>3
6441 </th>
6442 <td>3</td>
6443 <td>6</td>
6444 <td>9
6445 </td></tr>
6446 <tr>
6447 <th>4
6448 </th>
6449 <td>4</td>
6450 <td>8</td>
6451 <td>12
6452 </td></tr>
6453 <tr>
6454 <th>5
6455 </th>
6456 <td>5</td>
6457 <td>10</td>
6458 <td>15
6459 </td></tr></table>
6460
6461 !! end
6462
6463 !! test
6464 Accept "||" in table headings
6465 !! wikitext
6466 {|
6467 !h1||h2
6468 |}
6469 !! html
6470 <table>
6471 <tr>
6472 <th>h1</th>
6473 <th>h2
6474 </th></tr></table>
6475
6476 !! end
6477
6478 !! test
6479 Accept "!!" in table data
6480 !! wikitext
6481 {|
6482 |Foo!!||
6483 |}
6484 !! html
6485 <table>
6486 <tr>
6487 <td>Foo!!</td>
6488 <td>
6489 </td></tr></table>
6490
6491 !! html/parsoid
6492 <table>
6493 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'> Foo!! </td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'></td></tr>
6494 </tbody></table>
6495 !! end
6496
6497 !! test
6498 Accept "||" in indented table headings
6499 !! wikitext
6500 :{|
6501 !h1||h2
6502 |}
6503 !! html
6504 <dl><dd><table>
6505 <tr>
6506 <th>h1</th>
6507 <th>h2
6508 </th></tr></table></dd></dl>
6509
6510 !! end
6511
6512 !! test
6513 Accept "!!" in templates
6514 !! wikitext
6515 {|
6516 !a {{echo|b!!c}}
6517 |}
6518 !! html/php
6519 <table>
6520 <tr>
6521 <th>a b</th>
6522 <th>c
6523 </th></tr></table>
6524
6525 !! html/parsoid
6526 <table>
6527 <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>
6528 !! end
6529
6530 !! test
6531 Accept "!!" in table headings after newline
6532 !! wikitext
6533 {|
6534 !a
6535 b!!c
6536 |}
6537 !! html/php
6538 <table>
6539 <tr>
6540 <th>a
6541 <p>b!!c
6542 </p>
6543 </th></tr></table>
6544
6545 !! html/parsoid
6546 <table>
6547 <tbody><tr><th>a
6548 <p>b!!c</p></th></tr>
6549 </tbody></table>
6550 !! end
6551
6552 !! test
6553 Accept "!!" in table data of mixed wikitext / html syntax
6554 !! wikitext
6555 {|
6556 !a
6557 <tr><td>b!!c</td></tr>
6558 |}
6559 !! html/php+tidy
6560 <table>
6561 <tbody><tr>
6562 <th>a
6563 </th></tr><tr><td>b!!c</td></tr>
6564 </tbody></table>
6565 !! html/parsoid
6566 <table>
6567 <tbody><tr><th>a</th></tr>
6568 <tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>b!!c</td></tr>
6569 </tbody></table>
6570 !! end
6571
6572 !! test
6573 Accept empty attributes in td/th cells (td/th cells starting with leading ||)
6574 !! wikitext
6575 {|
6576 !|h1
6577 ||a
6578 |}
6579 !! html
6580 <table>
6581 <tr>
6582 <th>h1
6583 </th>
6584 <td>a
6585 </td></tr></table>
6586
6587 !! end
6588
6589 !!test
6590 Accept "| !" at start of line in tables (ignore !-attribute)
6591 !! wikitext
6592 {|
6593 |-
6594 |!style="color:red"|bar
6595 |}
6596 !! html
6597 <table>
6598
6599 <tr>
6600 <td>bar
6601 </td></tr></table>
6602
6603 !!end
6604
6605 !!test
6606 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 +/-
6607 !! wikitext
6608 {|
6609 |-
6610 |style='color:red;'|+1
6611 |style='color:blue;'|-1
6612 |-
6613 |1||2||3
6614 |1||+2||-3
6615 |-
6616 | +1
6617 | -1
6618 |}
6619 !! html
6620 <table>
6621
6622 <tr>
6623 <td style="color:red;">+1
6624 </td>
6625 <td style="color:blue;">-1
6626 </td></tr>
6627 <tr>
6628 <td>1</td>
6629 <td>2</td>
6630 <td>3
6631 </td>
6632 <td>1</td>
6633 <td>+2</td>
6634 <td>-3
6635 </td></tr>
6636 <tr>
6637 <td>+1
6638 </td>
6639 <td>-1
6640 </td></tr></table>
6641
6642 !!end
6643
6644 !! test
6645 Table rowspan
6646 !! wikitext
6647 {| border=1
6648 |Cell 1, row 1
6649 |rowspan=2|Cell 2, row 1 (and 2)
6650 |Cell 3, row 1
6651 |-
6652 |Cell 1, row 2
6653 |Cell 3, row 2
6654 |}
6655 !! html
6656 <table border="1">
6657 <tr>
6658 <td>Cell 1, row 1
6659 </td>
6660 <td rowspan="2">Cell 2, row 1 (and 2)
6661 </td>
6662 <td>Cell 3, row 1
6663 </td></tr>
6664 <tr>
6665 <td>Cell 1, row 2
6666 </td>
6667 <td>Cell 3, row 2
6668 </td></tr></table>
6669
6670 !! end
6671
6672 !! test
6673 Nested table
6674 !! wikitext
6675 {| border=1
6676 | &alpha;
6677 |
6678 {| bgcolor=#ABCDEF border=2
6679 |nested
6680 |-
6681 |table
6682 |}
6683 |the original table again
6684 |}
6685 !! html
6686 <table border="1">
6687 <tr>
6688 <td>&#945;
6689 </td>
6690 <td>
6691 <table bgcolor="#ABCDEF" border="2">
6692 <tr>
6693 <td>nested
6694 </td></tr>
6695 <tr>
6696 <td>table
6697 </td></tr></table>
6698 </td>
6699 <td>the original table again
6700 </td></tr></table>
6701
6702 !! end
6703
6704 !! test
6705 Invalid attributes in table cell (T3830)
6706 !! wikitext
6707 {|
6708 |Cell:|broken
6709 |}
6710 !! html
6711 <table>
6712 <tr>
6713 <td>broken
6714 </td></tr></table>
6715
6716 !! end
6717
6718 !! test
6719 Table cell attributes: Pipes protected by nowikis should be treated as a plain character
6720 !! wikitext
6721 {|
6722 |title="foo" |bar
6723 |title="foo<nowiki>|</nowiki>" |bar
6724 |title="foo<nowiki>|</nowiki>" bar
6725 |}
6726 !! html/php
6727 <table>
6728 <tr>
6729 <td title="foo">bar
6730 </td>
6731 <td title="foo&#124;">bar
6732 </td>
6733 <td>title="foo|" bar
6734 </td></tr></table>
6735
6736 !! html/parsoid
6737 <table>
6738 <tbody><tr><td title="foo">bar</td>
6739 <td title="foo|" data-parsoid='{"a":{"title":"foo|"},"sa":{"title":"foo&lt;nowiki>|&lt;/nowiki>"},"autoInsertedEnd":true}'>bar</td>
6740 <td> title="foo<span typeof="mw:Nowiki">|</span>" bar</td></tr>
6741 </tbody></table>
6742 !! end
6743
6744 # See: http://lists.wikimedia.org/mailman/htdig/wikitech-l/2006-April/022293.html
6745 # N.B. The "|}" to close the table is missing from the input, so parsoid's
6746 # *2wt modes will fail.
6747 !! test
6748 Table security: embedded pipes
6749 !! options
6750 parsoid=wt2html,html2html
6751 !! wikitext
6752 {|
6753 | |[ftp://|x||]" onmouseover="alert(document.cookie)">test
6754 !! html/php
6755 <table>
6756 <tr>
6757 <td>[<a rel="nofollow" class="external free" href="ftp://%7Cx">ftp://%7Cx</a></td>
6758 <td>]" onmouseover="alert(document.cookie)"&gt;test
6759 </td>
6760 </tr>
6761 </table>
6762
6763 !! html/parsoid
6764 <table><tbody>
6765 <tr>
6766 <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>
6767 !! end
6768
6769 !! test
6770 Element attributes with double ! should not be broken up by <th>
6771 !! wikitext
6772 {|
6773 !hi <div class="!!">ha</div> ho
6774 |}
6775 !! html/php
6776 <table>
6777 <tr>
6778 <th>hi <div class="!!">ha</div> ho
6779 </th></tr></table>
6780
6781 !! html/parsoid
6782 <table>
6783 <tbody><tr><th>hi <div class="!!" data-parsoid='{"stx":"html"}'>ha</div> ho</th></tr>
6784 </tbody></table>
6785 !! end
6786
6787 !! test
6788 ! and || in element attributes should not be parsed as <th>/<td>
6789 !! wikitext
6790 {|
6791 |<div style="color: red !important;" data-contrived="put this here ||">hi</div>
6792 |}
6793 !! html/php
6794 <table>
6795 <tr>
6796 <td><div style="color: red&#32;!important;" data-contrived="put this here &#124;&#124;">hi</div>
6797 </td></tr></table>
6798
6799 !! html/parsoid
6800 <table>
6801 <tbody><tr><td><div style="color: red !important;" data-contrived="put this here ||" data-parsoid='{"stx":"html"}'>hi</div></td></tr>
6802 </tbody></table>
6803 !! end
6804
6805 # FIXME: The output seems broken. Filed as T110268.
6806 !! test
6807 ! and || in td attributes should not be parsed as <th>/<td>
6808 !! options
6809 parsoid=wt2html
6810 !! wikitext
6811 {|
6812 |style="color: red !important;" data-contrived="put this here ||"|foo
6813 |}
6814 !! html/php
6815 <table>
6816 <tr>
6817 <td>style="color: red&#160;!important;" data-contrived="put this here</td>
6818 <td>foo
6819 </td></tr></table>
6820
6821 !! html/parsoid
6822 <table>
6823 <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>
6824 </tbody></table>
6825 !! end
6826
6827 !! test
6828 Break on | in element attribute in template
6829 !! options
6830 parsoid=wt2html,html2html
6831 !! wikitext
6832 {{echo|1=<div class="hi|ho">ha</div>}}
6833 !! html/php
6834 <p>ho"&gt;ha&lt;/div&gt;
6835 </p>
6836 !! html/parsoid
6837 <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>
6838 !! end
6839
6840 !! test
6841 Break on | in element attribute name in template
6842 !! wikitext
6843 {{echo|<div cla|ss="hiho">ha</div>}}
6844 !! html/parsoid
6845 <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>
6846 !! end
6847
6848 !! test
6849 Don't break on | in extension attribute in template
6850 !! wikitext
6851 {{echo|<ref name="hi|ho">ha</ref>}}
6852
6853 <references />
6854 !! html/parsoid
6855 <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>
6856
6857 <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>
6858 !! end
6859
6860 ## We don't support roundtripping of these attributes in Parsoid.
6861 ## Selective serialization takes care of preventing dirty diffs.
6862 ## But, on edits, we dirty-diff the invalid attribute text.
6863 !! test
6864 Invalid text in table attributes should be discarded
6865 !! options
6866 parsoid=wt2html
6867 !! wikitext
6868 {| <span>boo</span> style='border:1px solid black'
6869 | <span>boo</span> style='color:blue' |1
6870 |<span>boo</span> style='color:blue'|2
6871 |}
6872 !! html/php
6873 <table style="border:1px solid black">
6874 <tr>
6875 <td style="color:blue">1
6876 </td>
6877 <td style="color:blue">2
6878 </td></tr></table>
6879
6880 !! html/parsoid
6881 <table style="border:1px solid black">
6882 <tr>
6883 <td style="color:blue">1</td>
6884 <td style="color:blue">2</td>
6885 </tr>
6886 </table>
6887 !! end
6888
6889 !! test
6890 Invalid text in table attributes should be preserved by selective serializer
6891 !! options
6892 parsoid={
6893 "modes": ["selser"],
6894 "changes": [
6895 ["td:first-child", "text", "abc"],
6896 ["td + td", "text", "xyz"]
6897 ]
6898 }
6899 !! wikitext
6900 {| <span>boo</span> style='border:1px solid black'
6901 | <span>boo</span> style='color:blue' | 1
6902 |<span>boo</span> style='color:blue'| 2
6903 |}
6904 !! wikitext/edited
6905 {| <span>boo</span> style='border:1px solid black'
6906 | <span>boo</span> style='color:blue' | abc
6907 |<span>boo</span> style='color:blue'| xyz
6908 |}
6909 !! end
6910
6911 !! test
6912 1. Template-generated table cell attributes and cell content
6913 !! wikitext
6914 {|
6915 |{{table_attribs}}
6916 | {{table_attribs}}
6917 || {{table_attribs_5}}
6918 | <!--foo--> <!--bar--> <!--baz--> {{table_attribs}}
6919 |align=center {{table_attribs}}
6920 | <!--foo--> align=center <!--bar--> {{table_attribs}}
6921 |}
6922 !! html
6923 <table>
6924 <tr>
6925 <td style="color:red;">Foo
6926 </td>
6927 <td style="color:red;">Foo
6928 </td>
6929 <td>style="color:red;"</td>
6930 <td>Bar
6931 </td>
6932 <td style="color:red;">Foo
6933 </td>
6934 <td align="center" style="color:red;">Foo
6935 </td>
6936 <td align="center" style="color:red;">Foo
6937 </td></tr></table>
6938
6939 !! end
6940
6941 !! test
6942 2. Template-generated table cell attributes and cell content
6943 !! wikitext
6944 {|
6945 |{{table_attribs_2}}
6946 |}
6947 !! html/php
6948 <table>
6949 <tr>
6950 <td style="color:red;">Foo
6951 </td>
6952 <td>Bar</td>
6953 <td>Baz
6954 </td></tr></table>
6955
6956 !! html/parsoid
6957 <table>
6958 <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>
6959 <td about="#mwt1">Bar</td><td about="#mwt1">Baz</td></tr>
6960 </tbody></table>
6961 !! end
6962
6963 !! test
6964 3. Template-generated table cell attributes and cell content
6965 !! wikitext
6966 {|
6967 !align=center {{table_header_cells}}
6968 |-
6969 |align=center {{table_cells}}
6970 |}
6971 !! html/php
6972 <table>
6973 <tr>
6974 <th align="center" style="color:red;">Foo</th>
6975 <th style="color:red;"><i>Bar</i></th>
6976 <th style="color:brown;"><i>Foo</i> and Baz
6977 </th></tr>
6978 <tr>
6979 <td align="center" style="color:red;">Foo</td>
6980 <td style="color:red;"><i>Bar</i></td>
6981 <td style="color:brown;"><i>Foo</i> and Baz
6982 </td></tr></table>
6983
6984 !! html/parsoid
6985 <table>
6986 <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>
6987 <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>
6988 </tbody></table>
6989 !! end
6990
6991 !! test
6992 4. Template-generated table cell attributes and cell content inside a templated table
6993 !! wikitext
6994 {{tbl-start}}
6995 !align=center {{table_header_cells}}
6996 |-
6997 |align=center {{table_cells}}
6998 {{tbl-end}}
6999 !! html/php
7000 <table>
7001 <tr>
7002 <th align="center" style="color:red;">Foo</th>
7003 <th style="color:red;"><i>Bar</i></th>
7004 <th style="color:brown;"><i>Foo</i> and Baz
7005 </th></tr>
7006 <tr>
7007 <td align="center" style="color:red;">Foo</td>
7008 <td style="color:red;"><i>Bar</i></td>
7009 <td style="color:brown;"><i>Foo</i> and Baz
7010 </td></tr></table>
7011
7012 !! html/parsoid
7013 <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}}]}'>
7014 <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>
7015 <tr>
7016 <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>
7017 </tbody></table>
7018 !! end
7019
7020 ## Edge case fix to prevent future regressions
7021 !! test
7022 T107652: <ref>s in templates that also generate table cell attributes should be rendered properly
7023 !! wikitext
7024 {|
7025 |{{table_attribs_7}}
7026 |}
7027 <references />
7028 !! html/parsoid
7029 <table>
7030 <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>
7031 </tbody></table>
7032 <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>
7033 !! end
7034
7035 !! test
7036 Table with row followed by newlines and table heading
7037 !! options
7038 parsoid=wt2html,html2html
7039 !! wikitext
7040 {|
7041 |-
7042
7043 !foo
7044 |}
7045 !! html/*
7046 <table>
7047
7048
7049 <tr>
7050 <th>foo
7051 </th></tr></table>
7052
7053 !! end
7054
7055 !! test
7056 Table with empty line following the start tag
7057 !! options
7058 parsoid=wt2html,html2html
7059 !! wikitext
7060 {|
7061
7062 |-
7063 |foo
7064 |}
7065 !! html/*
7066 <table>
7067
7068
7069 <tr>
7070 <td>foo
7071 </td></tr></table>
7072
7073 !! end
7074
7075 !! test
7076 Table attributes with empty value
7077 !! options
7078 parsoid=wt2html,html2html
7079 !! wikitext
7080 {|
7081 | style=|hello
7082 |}
7083 !! html/php
7084 <table>
7085 <tr>
7086 <td style="">hello
7087 </td></tr></table>
7088
7089 !! html/parsoid
7090 <table>
7091 <tbody><tr><td style="">hello</td></tr>
7092 </tbody></table>
7093 !! end
7094
7095 !! test
7096 Wikitext table with a lot of comments
7097 !! wikitext
7098 {|
7099 <!-- c0 -->
7100 |foo
7101 <!-- c1 -->
7102 |-<!-- c2 -->
7103 <!-- c3 -->
7104 |<!-- c4 -->
7105 <!-- c5 -->
7106 |}
7107 !! html
7108 <table>
7109 <tr>
7110 <td>foo
7111 </td></tr>
7112 <tr>
7113 <td>
7114 </td></tr></table>
7115
7116 !! end
7117
7118 !! test
7119 Wikitext table comments represented in parsoid dom
7120 !! wikitext
7121 {|<!--c1--><!--c2-->
7122 |-<!--c3-->
7123 |x
7124 |}
7125 !! html/php+tidy
7126 <table>
7127
7128 <tbody><tr>
7129 <td>x
7130 </td></tr></tbody></table>
7131 !! html/parsoid
7132 <table><!--c1--><!--c2-->
7133 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'><!--c3-->
7134 <td data-parsoid='{"autoInsertedEnd":true}'>x</td></tr>
7135 </tbody></table>
7136 !! end
7137
7138 !! test
7139 Wikitext table with double-line table cell
7140 !! wikitext
7141 {|
7142 |a
7143 b
7144 |}
7145 !! html
7146 <table>
7147 <tr>
7148 <td>a
7149 <p>b
7150 </p>
7151 </td></tr></table>
7152
7153 !! end
7154
7155 !! test
7156 Table cell with a single comment
7157 !! wikitext
7158 {|
7159 |<!-- c1 -->
7160 |a
7161 |}
7162 !! html
7163 <table>
7164 <tr>
7165 <td>
7166 </td>
7167 <td>a
7168 </td></tr></table>
7169
7170 !! end
7171
7172 !! test
7173 Table-cell after a comment-only-empty-line
7174 !! wikitext
7175 {|
7176 |a
7177 <!--c1-->
7178 <!--c2-->|b
7179 |}
7180 !! html
7181 <table>
7182 <tr>
7183 <td>a
7184 </td>
7185 <td>b
7186 </td></tr></table>
7187
7188 !! html/parsoid
7189 <table>
7190 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>a</td>
7191 <!--c1-->
7192 <!--c2--><td data-parsoid='{"autoInsertedEnd":true}'>b</td></tr>
7193 </tbody></table>
7194
7195 !! end
7196
7197 !! test
7198 Build table with {{!}}
7199 !! wikitext
7200 {{{!}} class="wikitable"
7201 !header
7202 !second header
7203 {{!}}- style="color:red;"
7204 {{!}}data{{!}}{{!}} style="color:red;" {{!}}second data
7205 {{!}}}
7206 !! html
7207 <table class="wikitable">
7208 <tr>
7209 <th>header
7210 </th>
7211 <th>second header
7212 </th></tr>
7213 <tr style="color:red;">
7214 <td>data</td>
7215 <td style="color:red;">second data
7216 </td></tr></table>
7217
7218 !! end
7219
7220 !! test
7221 Build table with pipe as data
7222 !! wikitext
7223 {| class="wikitable"
7224 !header
7225 !second header
7226 |- style="color:red;"
7227 |data|| style="color:red;" |second data
7228 |-
7229 | style="color:red;" |data with | || style="color:red;" | second data with |
7230 |-
7231 ||data with | |||second data with |
7232 |}
7233 !! html
7234 <table class="wikitable">
7235 <tr>
7236 <th>header
7237 </th>
7238 <th>second header
7239 </th></tr>
7240 <tr style="color:red;">
7241 <td>data</td>
7242 <td style="color:red;">second data
7243 </td></tr>
7244 <tr>
7245 <td style="color:red;">data with |</td>
7246 <td style="color:red;">second data with |
7247 </td></tr>
7248 <tr>
7249 <td>data with |</td>
7250 <td>second data with |
7251 </td></tr></table>
7252
7253 !! end
7254
7255 !! test
7256 Build table with wikilink
7257 !! wikitext
7258 {| class="wikitable"
7259 !header||second header
7260 |- style="color:red;"
7261 |data [[Main Page|linktext]]||second data [[Main Page|linktext]]
7262 |-
7263 |data||second data [[Main Page|link|text with pipe]]
7264 |}
7265 !! html
7266 <table class="wikitable">
7267 <tr>
7268 <th>header</th>
7269 <th>second header
7270 </th></tr>
7271 <tr style="color:red;">
7272 <td>data <a href="/wiki/Main_Page" title="Main Page">linktext</a></td>
7273 <td>second data <a href="/wiki/Main_Page" title="Main Page">linktext</a>
7274 </td></tr>
7275 <tr>
7276 <td>data</td>
7277 <td>second data <a href="/wiki/Main_Page" title="Main Page">link|text with pipe</a>
7278 </td></tr></table>
7279
7280 !! end
7281
7282 # The expected HTML structure in this test is debatable. The PHP parser does
7283 # not parse this kind of table at all. The main focus for Parsoid is on
7284 # round-tripping, so this output is ok for now. TODO: revisit!
7285 !! test
7286 Wikitext table with html-syntax row
7287 !! wikitext
7288 {|
7289 |-
7290 <td>foo</td>
7291 |}
7292 !! html/parsoid
7293 <table>
7294 <tbody>
7295 <tr>
7296 <td>foo</td></tr></tbody></table>
7297 !! end
7298
7299 !! test
7300 Fostered content in tables: Plain text
7301 !! options
7302 parsoid=wt2html,html2html
7303 !! wikitext
7304 {|
7305 |-
7306 a
7307 |}
7308 !! html/php
7309 <table>
7310
7311 a
7312 </table>
7313
7314 !! html/php+tidy
7315
7316
7317 a
7318 <table></table>
7319 !! html/parsoid
7320 <span data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>
7321 a
7322 </span><table>
7323 <tbody><tr class="mw-empty-elt" data-parsoid='{"startTagSrc":"|-"}'></tr></tbody></table>
7324 !! end
7325
7326 !! test
7327 Fostered content in tables: Lists
7328 !! options
7329 parsoid=wt2html,html2html
7330 !! wikitext
7331 {|
7332 |-
7333 *a
7334 |}
7335 !! html/php
7336 <table>
7337
7338 <ul><li>a</li></ul>
7339 </table>
7340
7341 !! html/php+tidy
7342 <ul><li>a</li></ul><table>
7343
7344
7345 </table>
7346 !! html/parsoid
7347 <ul data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><li>a</li></ul><table>
7348 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7349
7350 </tr></tbody></table>
7351 !! end
7352
7353 !! test
7354 Template generated table cell with attributes
7355 !! wikitext
7356 {|
7357 |-
7358 {{table_attribs_4}} ||a||b
7359 |}
7360 !! html/php+tidy
7361 <table>
7362
7363 <tbody><tr>
7364 <td style="background-color:#DC241f;" width="10px"></td>
7365 <td>a</td>
7366 <td>b
7367 </td></tr></tbody></table>
7368 !! html/parsoid
7369 <table>
7370 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7371 <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>
7372 !! end
7373
7374 !! test
7375 Parsoid: Round-trip tables directly followed by content (T53219)
7376 !! options
7377 parsoid=wt2html,wt2wt
7378 !! wikitext
7379 {|
7380 |foo
7381 |} bar
7382
7383 {|
7384 |baz
7385 |}<b>quux</b>
7386 !! html+tidy
7387 <table>
7388 <tbody><tr>
7389 <td>foo
7390 </td></tr></tbody></table><p> bar
7391 </p><table>
7392 <tbody><tr>
7393 <td>baz
7394 </td></tr></tbody></table><p><b>quux</b>
7395 </p>
7396 !! end
7397
7398 !! test
7399 Parsoid: Default to a newline after tables in new content (T53219)
7400 !! options
7401 parsoid=html2wt
7402 !! html/parsoid
7403 <table><tbody>
7404 <tr><td>foo</td></tr></tbody></table> bar
7405 <table><tbody>
7406 <tr><td>baz</td></tr></tbody></table><b>quux</b>
7407 !! wikitext
7408 {|
7409 |foo
7410 |}
7411 <nowiki> </nowiki>bar
7412 {|
7413 |baz
7414 |}
7415 '''quux'''
7416 !! end
7417
7418 !! test
7419 Parsoid: Row-syntax table headings followed by comment & table cells
7420 !! options
7421 parsoid=wt2html,wt2wt
7422 !! wikitext
7423 {|
7424 !foo||bar
7425 <!-- foo --> ||baz||quux
7426 |}
7427 !! html/php
7428 <table>
7429 <tr>
7430 <th>foo</th>
7431 <th>bar
7432 </th>
7433 <td>baz</td>
7434 <td>quux
7435 </td></tr></table>
7436
7437 !! html/parsoid
7438 <table>
7439 <tbody><tr><th>foo</th><th>bar
7440 <!-- foo --></th><td> baz </td><td>quux</td></tr>
7441 </tbody></table>
7442 !! end
7443
7444 !!test
7445 Parsoid: Recover better from broken table attributes
7446 !!options
7447 parsoid=wt2html
7448 !!wikitext
7449 {| class="foo
7450 | class="bar" |
7451 foo
7452 |}
7453 !!html/php+tidy
7454 <table class="foo">
7455 <tbody><tr>
7456 <td class="bar">
7457 <p>foo
7458 </p>
7459 </td></tr></tbody></table>
7460 !!html/parsoid
7461 <table class="foo">
7462 <tr>
7463 <td class="bar">
7464 <p>foo</p></td></tr>
7465 </tbody></table>
7466 !!end
7467
7468 !! test
7469 Tables: Digest broken attributes on table and tr tag
7470 !! options
7471 parsoid=wt2html
7472 !! wikitext
7473 {| || |} ++
7474 |- || || ++ --
7475 |- > [
7476 |}
7477 !! html
7478 <table>
7479 <tbody>
7480 <tr class='mw-empty-elt'></tr>
7481 <tr class='mw-empty-elt'></tr>
7482 </tbody></table>
7483 !! end
7484
7485 !! test
7486 Table with missing opening <tr> tag
7487 !! options
7488 parsoid=wt2html,wt2wt
7489 !! wikitext
7490 <table>
7491 <td>foo</td>
7492 </tr>
7493 </table>
7494 !! html+tidy
7495 <table>
7496 <tbody><tr><td>foo</td>
7497 </tr>
7498 </tbody></table>
7499 !! end
7500
7501 # T137406: Whitespace in the HTML
7502 !! test
7503 1. Generate correct wikitext for tables with thead/tbody/tfoot
7504 !! options
7505 parsoid=html2wt
7506 !! html/parsoid
7507 <table>
7508 <caption>Test</caption>
7509 <thead>
7510 <tr>
7511 <th>Month</th>
7512 <th>Savings</th>
7513 </tr>
7514 </thead>
7515 <tbody>
7516 <tr>
7517 <td>January</td>
7518 <td>$100</td>
7519 </tr>
7520 <tr>
7521 <td>February</td>
7522 <td>$80</td>
7523 </tr>
7524 </tbody>
7525 <tfoot>
7526 <tr>
7527 <td>Sum</td>
7528 <td>$180</td>
7529 </tr>
7530 </tfoot>
7531 </table>
7532 !! wikitext
7533 {|
7534 |+Test
7535 !Month
7536 !Savings
7537 |-
7538 |January
7539 |$100
7540 |-
7541 |February
7542 |$80
7543 |-
7544 |Sum
7545 |$180
7546 |}
7547 !! html/php+tidy
7548 <table>
7549 <caption>Test
7550 </caption>
7551 <tbody><tr>
7552 <th>Month
7553 </th>
7554 <th>Savings
7555 </th></tr>
7556 <tr>
7557 <td>January
7558 </td>
7559 <td>$100
7560 </td></tr>
7561 <tr>
7562 <td>February
7563 </td>
7564 <td>$80
7565 </td></tr>
7566 <tr>
7567 <td>Sum
7568 </td>
7569 <td>$180
7570 </td></tr></tbody></table>
7571 !! end
7572
7573 # T137406: No whitespace in the HTML
7574 !! test
7575 2. Generate correct wikitext for tables with thead/tbody/tfoot
7576 !! options
7577 parsoid=html2wt
7578 !! html/parsoid
7579 <table><thead><tr><th>heading</th></tr></thead><tbody><tr><td>foo</td></tr></tbody></table>
7580 !! wikitext
7581 {|
7582 !heading
7583 |-
7584 |foo
7585 |}
7586 !! end
7587
7588 !! test
7589 Wikitext tables can be nested inside HTML tables
7590 !! options
7591 parsoid=html2wt
7592 !! html
7593 <table data-parsoid='{"stx":"html"}'>
7594 <tr><td>
7595 <table>
7596 <tr><td>foo</td></tr>
7597 </table>
7598 </td></tr>
7599 </table>
7600 !! wikitext
7601 <table>
7602 <tr><td>
7603 {|
7604 |foo
7605 |}
7606 </td></tr>
7607 </table>
7608 !! end
7609
7610 ###
7611 ### Internal links
7612 ###
7613 !! test
7614 Plain link, capitalized
7615 !! wikitext
7616 [[Main Page]]
7617 !! html
7618 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
7619 </p>
7620 !! end
7621
7622 !! test
7623 Plain link, uncapitalized
7624 !! wikitext
7625 [[main Page]]
7626 !! html
7627 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
7628 </p>
7629 !! end
7630
7631 !! test
7632 Piped link
7633 !! wikitext
7634 [[Main Page|The Main Page]]
7635 !! html
7636 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7637 </p>
7638 !! end
7639
7640 !! test
7641 Piped link with comment in link text
7642 !! wikitext
7643 [[Main Page|The Main<!--front--> Page]]
7644 !! html
7645 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7646 </p>
7647 !! end
7648
7649 !! test
7650 Piped link with multiple pipe characters in link text
7651 !! wikitext
7652 [[Main Page||The|Main|Page|]]
7653 !! html/php
7654 <p><a href="/wiki/Main_Page" title="Main Page">|The|Main|Page|</a>
7655 </p>
7656 !! html/parsoid
7657 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">|The|Main|Page|</a></p>
7658 !! end
7659
7660 !! test
7661 Piped link with no link text
7662 !! wikitext
7663 [[Thomas Bek (bishop of St David's)|]]
7664 !! html/php
7665 <p>[[Thomas Bek (bishop of St David's)|]]
7666 </p>
7667 !! html/parsoid
7668 <p>[[Thomas Bek (bishop of St David's)|]]</p>
7669 !! end
7670
7671 !! test
7672 Piped link with empty link text
7673 !! wikitext
7674 [[Main Page|<nowiki/>]] - empty nowiki
7675 [[Main Page| ]] - empty space
7676 [[Main Page|&nbsp;]] - empty non breaking space
7677 !! html/php
7678 <p><a href="/wiki/Main_Page" title="Main Page"></a> - empty nowiki
7679 <a href="/wiki/Main_Page" title="Main Page"> </a> - empty space
7680 <a href="/wiki/Main_Page" title="Main Page">&#160;</a> - empty non breaking space
7681 </p>
7682 !! html/parsoid
7683 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:Nowiki"></span></a> - empty nowiki
7684 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page"> </a> - empty space
7685 <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>
7686 !! end
7687
7688 !! test
7689 Broken link
7690 !! wikitext
7691 [[Zigzagzogzagzig]]
7692 !! html
7693 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig</a>
7694 </p>
7695 !! end
7696
7697 !! test
7698 Broken link with fragment
7699 !! wikitext
7700 [[Zigzagzogzagzig#zug]]
7701 !! html
7702 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig#zug</a>
7703 </p>
7704 !! end
7705
7706 !! test
7707 Special page link with fragment
7708 !! wikitext
7709 [[Special:Version#anchor]]
7710 !! html
7711 <p><a href="/wiki/Special:Version#anchor" title="Special:Version">Special:Version#anchor</a>
7712 </p>
7713 !! end
7714
7715 !! test
7716 Nonexistent special page link with fragment
7717 !! wikitext
7718 [[Special:ThisNameWillHopefullyNeverBeUsed#anchor]]
7719 !! html
7720 <p><a href="/wiki/Special:ThisNameWillHopefullyNeverBeUsed" class="new" title="Special:ThisNameWillHopefullyNeverBeUsed (page does not exist)">Special:ThisNameWillHopefullyNeverBeUsed#anchor</a>
7721 </p>
7722 !! end
7723
7724 !! test
7725 Link with prefix
7726 !! wikitext
7727 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
7728 !! html
7729 <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>
7730 </p>
7731 !! end
7732
7733 !! test
7734 Link with suffix
7735 !! wikitext
7736 [[Main Page]]xxx, [[Main Page]]XXX, [[Main Page]]!!!
7737 !! html
7738 <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>!!!
7739 </p>
7740 !! end
7741
7742 !! article
7743 prefixed article
7744 !! text
7745 Some text
7746 !! endarticle
7747
7748 !! test
7749 T45661: Piped links with identical prefixes
7750 !! wikitext
7751 [[prefixed article|prefixed articles with spaces]]
7752
7753 [[prefixed article|prefixed articlesaoeu]]
7754
7755 [[Main Page|Main Page test]]
7756 !! html
7757 <p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articles with spaces</a>
7758 </p><p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articlesaoeu</a>
7759 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page test</a>
7760 </p>
7761 !! end
7762
7763
7764 !! test
7765 Link with HTML entity in suffix / tail
7766 !! wikitext
7767 [[Main Page]]&quot;, [[Main Page]]&#97;
7768 !! html/php
7769 <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;
7770 </p>
7771 !! html/parsoid
7772 <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>
7773 !! end
7774
7775 !! test
7776 Link with 3 brackets
7777 !! wikitext
7778 [[[Main Page]]]
7779 Foo [[[Main Page]]]
7780 !! html
7781 <p>[[[Main Page]]]
7782 Foo [[[Main Page]]]
7783 </p>
7784 !! end
7785
7786 !! test
7787 Link with 4 brackets
7788 !! wikitext
7789 [[[[Main Page]]]]
7790 !! html
7791 <p>[[<a href="/wiki/Main_Page" title="Main Page">Main Page</a>]]
7792 </p>
7793 !! end
7794
7795 !! test
7796 Piped link with 3 brackets
7797 !! wikitext
7798 [[[main page|the main page]]]
7799 !! html
7800 <p>[[[main page|the main page]]]
7801 </p>
7802 !! end
7803
7804 !! test
7805 Piped link with extlink-like text
7806 !! wikitext
7807 [[Main Page|[bar]]]
7808 [[Main Page|This is a [bar]]]
7809 [[Main Page|[bar]]
7810 !! html/php
7811 <p><a href="/wiki/Main_Page" title="Main Page">[bar]</a>
7812 <a href="/wiki/Main_Page" title="Main Page">This is a [bar]</a>
7813 <a href="/wiki/Main_Page" title="Main Page">[bar</a>
7814 </p>
7815 !! html/parsoid
7816 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar]</a>
7817 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>This is a [bar]</a>
7818 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar</a></p>
7819 !! end
7820
7821 !! test
7822 Link with multiple pipes
7823 !! wikitext
7824 [[Main Page|The|Main|Page]]
7825 !! html
7826 <p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a>
7827 </p>
7828 !! end
7829
7830 !! test
7831 Anchor containing a #. (T65430)
7832 !! config
7833 wgFragmentMode=[ 'html5', 'legacy' ]
7834 !! wikitext
7835 [[Main Page#And#Link]]
7836 !! html/php
7837 <p><a href="/wiki/Main_Page#And#Link" title="Main Page">Main Page#And#Link</a>
7838 </p>
7839 !! html/parsoid
7840 <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>
7841 !! end
7842
7843 !! test
7844 Link to namespaces
7845 !! wikitext
7846 [[Talk:Parser testing]], [[Meta:Disclaimers]]
7847 !! html
7848 <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>
7849 </p>
7850 !! end
7851
7852 !! test
7853 Link with space in namespace
7854 !! wikitext
7855 [[User talk:Foo bar]]
7856 !! html
7857 <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>
7858 </p>
7859 !! end
7860
7861 !! article
7862 MemoryAlpha:AlphaTest
7863 !! text
7864 This is an article in the MemoryAlpha namespace
7865 (which shadows the memoryalpha interwiki link).
7866 !! endarticle
7867
7868 !! test
7869 Namespace takes precedence over interwiki link (T53680)
7870 !! wikitext
7871 [[MemoryAlpha:AlphaTest]]
7872 !! html
7873 <p><a href="/wiki/MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a>
7874 </p>
7875 !! end
7876
7877 # The previous test doesn't work correctly in html2*, due to not recognizing the
7878 # link as an internal one. This one checks for the correct behavior.
7879 !! test
7880 Link to namespace preferred over interwiki with correct rel attribute
7881 !! options
7882 parsoid=html2wt,html2html
7883 !! html/parsoid
7884 <p><a rel="mw:WikiLink" href="./MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a></p>
7885 !! wikitext
7886 [[MemoryAlpha:AlphaTest]]
7887 !! end
7888
7889 !! test
7890 Piped link to namespace
7891 !! wikitext
7892 [[Meta:Disclaimers|The disclaimers]]
7893 !! html
7894 <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>
7895 </p>
7896 !! end
7897
7898 !! test
7899 Link containing }
7900 !! wikitext
7901 [[Usually caused by a typo (oops}]]
7902 !! html
7903 <p>[[Usually caused by a typo (oops}]]
7904 </p>
7905 !! end
7906
7907 !! article
7908 7% Solution
7909 !! text
7910 Just a test of an article title containing a percent.
7911 !! endarticle
7912
7913 !! test
7914 Link containing % (not as a hex sequence)
7915 !! wikitext
7916 [[7% Solution]]
7917 [[7% Solution|7%25 Solution]]
7918 !! html/php
7919 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
7920 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
7921 </p>
7922 !! html/parsoid
7923 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
7924 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
7925 !! end
7926
7927 # note that the parsoid HTML is identical to the previous test output,
7928 # so the previous test ensures that the html2wt mode will generate the
7929 # "not as a hex sequence" wikitext.
7930 !! test
7931 Link containing % as a single hex sequence interpreted to char
7932 !! options
7933 parsoid=wt2wt,wt2html,html2html
7934 !! wikitext
7935 [[7%25 Solution]]
7936 [[7%25 Solution|7%25 Solution]]
7937 !! html/php
7938 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
7939 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
7940 </p>
7941 !! html/parsoid
7942 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
7943 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
7944 !!end
7945
7946 !! test
7947 Link containing % as a double hex sequence interpreted to hex sequence
7948 !! wikitext
7949 [[7%2525 Solution]]
7950 !! html
7951 <p>[[7%2525 Solution]]
7952 </p>
7953 !!end
7954
7955 ## Example for such a section: == < ==
7956 !! test
7957 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors
7958 !! config
7959 wgFragmentMode=[ 'html5', 'legacy' ]
7960 !! wikitext
7961 [[%23%3c]][[%23%3e]]
7962 !! html/php
7963 <p><a href="#&lt;">#&lt;</a><a href="#&gt;">#&gt;</a>
7964 </p>
7965 !! html/parsoid
7966 <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>
7967 !! end
7968
7969 ## Example for such a section: == < ==
7970 !! test
7971 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors (legacy)
7972 !! config
7973 wgFragmentMode=[ 'legacy' ]
7974 !! wikitext
7975 [[%23%3c]][[%23%3e]]
7976 !! html/php
7977 <p><a href="#.3C">#&lt;</a><a href="#.3E">#&gt;</a>
7978 </p>
7979 !! end
7980
7981 !! test
7982 Link containing "<#" and ">#" as a hex sequences
7983 !! wikitext
7984 [[%3c%23]][[%3e%23]]
7985 !! html
7986 <p>[[%3c%23]][[%3e%23]]
7987 </p>
7988 !! end
7989
7990 !! test
7991 Link containing an equals sign
7992 !! wikitext
7993 [[Special:BookSources/isbn=4-00-026157-6]]
7994 !! html/php
7995 <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>
7996 </p>
7997 !! html/parsoid
7998 <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>
7999 !! end
8000
8001 !! article
8002 Foo~bar
8003 !! text
8004 Just a test of an article title containing a tilde.
8005 !! endarticle
8006
8007 # note that links containing signatures, like [[Foo~~~~]], are
8008 # massaged by the pre-save transform (PST) and so the tildes are never
8009 # seen by the parser.
8010 !! test
8011 Link containing a tilde
8012 !! wikitext
8013 [[Foo~bar]]
8014 !! html/php
8015 <p><a href="/wiki/Foo~bar" title="Foo~bar">Foo~bar</a>
8016 </p>
8017 !! html/parsoid
8018 <p><a rel="mw:WikiLink" href="./Foo~bar" title="Foo~bar">Foo~bar</a></p>
8019 !! end
8020
8021 !! test
8022 Link containing double-single-quotes '' (T6598)
8023 !! wikitext
8024 [[Lista d''e paise d''o munno]]
8025 !! html/php
8026 <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>
8027 </p>
8028 !! html/parsoid
8029 <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>
8030 !! end
8031
8032 !! test
8033 Link containing double quotes and spaces
8034 !! wikitext
8035 [[Cool "Gator"]]
8036 !! html/php
8037 <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>
8038 </p>
8039 !! html/parsoid
8040 <p><a rel="mw:WikiLink" href='./Cool_"Gator"' title='Cool "Gator"'>Cool "Gator"</a></p>
8041 !! end
8042
8043 !! test
8044 File containing double quotes and spaces
8045 !! wikitext
8046 [[File:Cool "Gator".png]]
8047 !! html/parsoid
8048 <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>
8049 !! end
8050
8051 !! test
8052 Redirect containing double quotes and spaces
8053 !! wikitext
8054 #REDIRECT [[Cool "Gator"]]
8055 !! html/parsoid
8056 <link rel="mw:PageProp/redirect" href="./Cool_%22Gator%22" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Cool_%22Gator%22"},"sa":{"href":"Cool \"Gator\""}}'/>
8057 !! end
8058
8059 !! test
8060 Link containing double-single-quotes '' in text (T6598 sanity check)
8061 !! wikitext
8062 Some [[Link|pretty ''italics'' and stuff]]!
8063 !! html/php
8064 <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>!
8065 </p>
8066 !! html/parsoid
8067 <p>Some <a rel="mw:WikiLink" href="./Link" title="Link">pretty <i>italics</i> and stuff</a>!</p>
8068 !! end
8069
8070 !! test
8071 Link containing double-single-quotes '' in text embedded in italics (T6598 sanity check)
8072 !! wikitext
8073 ''Some [[Link|pretty ''italics'' and stuff]]!''
8074 !! html
8075 <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>
8076 </p>
8077 !! end
8078
8079 !! test
8080 Link with double quotes in title part (literal) and alternate part (interpreted)
8081 !! wikitext
8082 [[File:Denys_Savchenko_''Pentecoste''.jpg]]
8083
8084 [[''Pentecoste'']]
8085
8086 [[''Pentecoste''|Pentecoste]]
8087
8088 [[''Pentecoste''|''Pentecoste'']]
8089 !! html/php
8090 <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>
8091 </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>
8092 </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>
8093 </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>
8094 </p>
8095 !! html/parsoid
8096 <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>
8097 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">''Pentecoste''</a></p>
8098 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">Pentecoste</a></p>
8099 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''"><i>Pentecoste</i></a></p>
8100 !! end
8101
8102 !! test
8103 Broken image links with HTML captions (T41700)
8104 !! wikitext
8105 [[File:Nonexistent|<script></script>]]
8106 [[File:Nonexistent|100x100px|<script></script>]]
8107 [[File:Nonexistent|&lt;]]
8108 [[File:Nonexistent|a<i>b</i>c]]
8109 !! html/php
8110 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8111 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8112 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;</a>
8113 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">abc</a>
8114 </p>
8115 !! html/parsoid
8116 <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>
8117 <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>
8118 <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>
8119 <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>
8120 !! end
8121
8122 !! test
8123 Plain link to URL
8124 !! wikitext
8125 [[http://www.example.com]]
8126 !! html/php
8127 <p>[<a rel="nofollow" class="external autonumber" href="http://www.example.com">[1]</a>]
8128 </p>
8129 !! html/parsoid
8130 <p>[<a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com"></a>]</p>
8131 !! end
8132
8133 !! test
8134 Plain link to URL with link text
8135 !! wikitext
8136 [[http://www.example.com Link text]]
8137 !! html
8138 <p>[<a rel="nofollow" class="external text" href="http://www.example.com">Link text</a>]
8139 </p>
8140 !! end
8141
8142 !! test
8143 Plain link to protocol-relative URL
8144 !! wikitext
8145 [[//www.example.com]]
8146 !! html/php
8147 <p>[<a rel="nofollow" class="external autonumber" href="//www.example.com">[1]</a>]
8148 </p>
8149 !! html/parsoid
8150 <p>[<a rel="mw:ExtLink" class="external autonumber" href="//www.example.com"></a>]</p>
8151 !! end
8152
8153 !! test
8154 Plain link to protocol-relative URL with link text
8155 !! wikitext
8156 [[//www.example.com Link text]]
8157 !! html
8158 <p>[<a rel="nofollow" class="external text" href="//www.example.com">Link text</a>]
8159 </p>
8160 !! end
8161
8162 !! test
8163 Plain link to page with question mark in title
8164 !! wikitext
8165 [[A?b]]
8166
8167 [[A?b|Baz]]
8168 !! html
8169 <p><a href="/wiki/A%3Fb" title="A?b">A?b</a>
8170 </p><p><a href="/wiki/A%3Fb" title="A?b">Baz</a>
8171 </p>
8172 !! end
8173
8174 # I'm fairly sure the expected result here is wrong.
8175 # We want these to be URL links, not pseudo-pages with URLs for titles....
8176 # However the current output is also pretty screwy.
8177 #
8178 # ----
8179 # I'm changing it to match the current output--it arguably makes more
8180 # sense in the light of the test above. Old expected result was:
8181 #<p>Piped link to URL: <a href="/index.php?title=Http://www.example.com&amp;action=edit" class="new">an example URL</a>
8182 #</p>
8183 # But I think this test is bordering on "garbage in, garbage out" anyway.
8184 # -- wtm
8185 !! test
8186 Piped link to URL
8187 !! wikitext
8188 Piped link to URL: [[http://www.example.com|an example URL]]
8189 !! html/php
8190 <p>Piped link to URL: [<a rel="nofollow" class="external text" href="http://www.example.com%7Can">example URL</a>]
8191 </p>
8192 !! html/parsoid
8193 <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>
8194 !! end
8195
8196 !! test
8197 Plain link in template argument
8198 !! options
8199 parsoid=wt2html
8200 !! wikitext
8201 {{echo|[http://www.example.com |123]}}
8202
8203 {{echo|[[http://www.example.com |123]]}}
8204
8205 {{echo|[[http://www.example.com |123]}}
8206
8207 {{echo|[http://www.example.com |123]]}}
8208 !! html/php
8209 <p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8210 </p><p>[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>]
8211 </p><p>{{echo|[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>}}
8212 </p><p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8213 </p>
8214 !! html/parsoid
8215 <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>
8216
8217 <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>
8218
8219 <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>
8220
8221 <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>
8222 !! end
8223
8224 !! test
8225 T2002: [[page|http://url/]] should link to page, not http://url/
8226 !! wikitext
8227 [[Main Page|http://url/]]
8228 !! html/php
8229 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
8230 </p>
8231 !! html/parsoid
8232 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">http://url/</a></p>
8233 !! end
8234
8235 # Parsoid does not mark self-links, by design.
8236 !! test
8237 T2337: Escaped self-links should be bold
8238 !! options
8239 title=[[Bug462]]
8240 !! wikitext
8241 [[Bu&#103;462]] [[Bug462]]
8242 !! html/php+tidy
8243 <p><a class="mw-selflink selflink">Bu&#103;462</a> <a class="mw-selflink selflink">Bug462</a>
8244 </p>
8245 !! html/parsoid
8246 <p><a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a> <a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a></p>
8247 !! end
8248
8249 !! test
8250 Self-link to section should not be bold
8251 !! options
8252 title=[[Main Page]]
8253 !! wikitext
8254 [[Main Page#section]]
8255 !! html
8256 <p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
8257 </p>
8258 !! end
8259
8260 !! article
8261 00
8262 !! text
8263 This is 00.
8264 !! endarticle
8265
8266 !!test
8267 Self-link to numeric title
8268 !!options
8269 title=[[0]]
8270 !! wikitext
8271 [[0]]
8272 !! html
8273 <p><a class="mw-selflink selflink">0</a>
8274 </p>
8275 !!end
8276
8277 !!test
8278 Link to numeric-equivalent title
8279 !!options
8280 title=[[0]]
8281 !! wikitext
8282 [[00]]
8283 !! html
8284 <p><a href="/wiki/00" title="00">00</a>
8285 </p>
8286 !!end
8287
8288 !! test
8289 <nowiki> inside a link
8290 !! wikitext
8291 [[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
8292 !! html
8293 <p>[[Main Page]] <a href="/wiki/Main_Page" title="Main Page">the main page [it's not very good]</a>
8294 </p>
8295 !! end
8296
8297 !! test
8298 Non-breaking spaces in title
8299 !! wikitext
8300 [[&nbsp; Main &nbsp; Page &nbsp;]]
8301 !! html
8302 <p><a href="/wiki/Main_Page" title="Main Page">&#160; Main &#160; Page &#160;</a>
8303 </p>
8304 !!end
8305
8306 # Add new article for the test below so that it doesn't red-link
8307 !! article
8308 Foo bar baz
8309 !! text
8310 boo
8311 !! endarticle
8312
8313 !! test
8314 Multiple spaces in titles should normalize to a single underscore
8315 !! options
8316 parsoid=wt2html,wt2wt
8317 !! wikitext
8318 [[Foo bar baz|x]]
8319 [[Foo bar baz|x]]
8320 [[Foo bar baz|x]]
8321 !! html/php
8322 <p><a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8323 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8324 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8325 </p>
8326 !! html/parsoid
8327 <p><a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8328 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8329 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8330 </p>
8331 !! end
8332
8333 !! test
8334 Internal link with ca linktrail, surrounded by bold apostrophes (T29473 primary issue)
8335 !! options
8336 language=ca
8337 !! wikitext
8338 '''[[Main Page]]'''
8339 !! html
8340 <p><b><a href="/wiki/Main_Page" title="Main Page">Main Page</a></b>
8341 </p>
8342 !! end
8343
8344 !! test
8345 Internal link with ca linktrail, surrounded by italic apostrophes (T29473 primary issue)
8346 !! options
8347 language=ca
8348 !! wikitext
8349 ''[[Main Page]]''
8350 !! html
8351 <p><i><a href="/wiki/Main_Page" title="Main Page">Main Page</a></i>
8352 </p>
8353 !! end
8354
8355 !! test
8356 Internal link with en linktrail: no apostrophes (T29473)
8357 !! options
8358 language=en
8359 !! wikitext
8360 [[Something]]'nice
8361 !! html
8362 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (page does not exist)">Something</a>'nice
8363 </p>
8364 !! end
8365
8366 !! test
8367 Internal link with ca linktrail with apostrophes (T29473)
8368 !! options
8369 language=ca
8370 !! wikitext
8371 [[Something]]'nice
8372 !! html
8373 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (encara no existeix)">Something'nice</a>
8374 </p>
8375 !! end
8376
8377 !! test
8378 Internal link with kaa linktrail with apostrophes (T29473)
8379 !! options
8380 language=kaa
8381 !! wikitext
8382 [[Something]]'nice
8383 !! html
8384 <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>
8385 </p>
8386 !! end
8387
8388 !! test
8389 Link with multiple ":" in a subpage-supporting namespace (T65636)
8390 !! wikitext
8391 [[User:Foo/Test/63636:Bar|Test]]
8392 !! html/php
8393 <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>
8394 </p>
8395 !! html/parsoid
8396 <p><a rel="mw:WikiLink" href="./User:Foo/Test/63636:Bar" title="User:Foo/Test/63636:Bar">Test</a></p>
8397 !! end
8398
8399 ## Mainly a sanity check for Parsoid
8400 !! test
8401 Handle title parsing for subpages
8402 !! options
8403 title=[[/123123]]
8404 subpage
8405 !! wikitext
8406 123
8407 !! html/php
8408 <p>123
8409 </p>
8410 !! html/parsoid
8411 <p>123</p>
8412 !! end
8413
8414 !! article
8415 User:Test/123
8416 !! text
8417 test 123
8418 !! endarticle
8419
8420 !! test
8421 Link to a subpage from a namespace other than main
8422 !! options
8423 title=[[User:Test]]
8424 subpage
8425 !! wikitext
8426 [[/123]]
8427 !! html/php
8428 <p><a href="/wiki/User:Test/123" title="User:Test/123">/123</a>
8429 </p>
8430 !! html/parsoid
8431 <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>
8432 !! end
8433
8434 !! test
8435 Ensure that transclusion titles are not url-decoded
8436 !! options
8437 subpage title=[[Test]]
8438 parsoid=wt2html
8439 !! wikitext
8440 {{Bar%C3%A9}} {{/Bar%C3%A9}}
8441 !! html/php
8442 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}
8443 </p>
8444 !! html/parsoid
8445 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}</p>
8446 !! end
8447
8448 !! test
8449 Purely hash wikilink
8450 !! options
8451 title=[[User:Test/123]]
8452 subpage
8453 !! wikitext
8454 [[#a|b]]
8455 !! html/php
8456 <p><a href="#a">b</a>
8457 </p>
8458 !! html/parsoid
8459 <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>
8460 !! end
8461
8462 !! test
8463 Serialization of purely hash wikilink
8464 !! options
8465 title=[[User:Test/123]]
8466 subpage
8467 parsoid=html2wt
8468 !! html/parsoid
8469 <p><a href="#a">[[</a></p>
8470 !! wikitext
8471 [[#a|<nowiki>[[</nowiki>]]
8472 !! html/php
8473 <p><a href="#a">[[</a>
8474 </p>
8475 !! end
8476
8477 !! test
8478 1. Interaction of linktrail and template encapsulation
8479 !! wikitext
8480 {{echo|[[Foo]]}}l
8481 !! html/parsoid
8482 <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>
8483 !! end
8484
8485 !! test
8486 2. Interaction of linktrail and template encapsulation
8487 !! options
8488 parsoid
8489 !! wikitext
8490 {{echo|Some [[Fool]]}}s
8491 !! html
8492 <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>
8493 !! end
8494
8495 !! test
8496 3. Interaction of linktrail and template encapsulation
8497 !! options
8498 parsoid
8499 !! wikitext
8500 {{echo|Some [[Fool]]s are '''bold and foolish'''}}
8501 !! html
8502 <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>
8503 !! end
8504
8505 !! article
8506 Söfnuður
8507 !! text
8508 Test.
8509 !! endarticle
8510
8511 !! test
8512 Internal link with is link prefix
8513 !! options
8514 language=is
8515 !! wikitext
8516 Aðrir mótmælenda[[söfnuður|söfnuðir]] og
8517 !! html
8518 <p>Aðrir <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a> og
8519 </p>
8520 !! end
8521
8522 !! article
8523 Mótmælendatrú
8524 !! text
8525 Test.
8526 !! endarticle
8527
8528 !! test
8529 Internal link with is link trail and link prefix
8530 !! options
8531 language=is
8532 !! wikitext
8533 [[mótmælendatrú|xxx]]ar
8534 [[mótmælendatrú]]ar
8535 mótmælenda[[söfnuður]]
8536 mótmælenda[[söfnuður|söfnuðir]]
8537 mótmælenda[[söfnuður|söfnuðir]]xxx
8538 !! html
8539 <p><a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">xxxar</a>
8540 <a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">mótmælendatrúar</a>
8541 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuður</a>
8542 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a>
8543 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðirxxx</a>
8544 </p>
8545 !! end
8546
8547 !! test
8548 Parsoid link trail escaping
8549 !! options
8550 parsoid=html2wt,html2html
8551 !! html/parsoid
8552 <p><a rel="mw:WikiLink" href="./Apple" title="Apple">apple</a>s</p>
8553 !! wikitext
8554 [[apple]]<nowiki/>s
8555 !! end
8556
8557 !! test
8558 Parsoid link prefix escaping
8559 !! options
8560 language=is
8561 parsoid=html2wt,html2html
8562 !! html/parsoid
8563 <p>Aðrir mótmælenda<a rel="mw:WikiLink" href="./Söfnuður" title="Söfnuður">söfnuður</a></p>
8564 !! wikitext
8565 Aðrir mótmælenda<nowiki/>[[söfnuður]]
8566 !! end
8567
8568 !! test
8569 Parsoid link bracket escaping
8570 !! options
8571 parsoid=html2wt,html2html
8572 !! html/parsoid
8573 <p><a rel="mw:WikiLink" href="./Test" title="Test">Test</a></p>
8574 <p>[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]</p>
8575 <p>[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]</p>
8576 <p>[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]</p>
8577 <p>[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]</p>
8578 <p>[[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]]</p>
8579 !! wikitext
8580 [[Test]]
8581
8582 [<nowiki/>[[Test]]]
8583
8584 [[[[Test]]]]
8585
8586 [[[<nowiki/>[[Test]]]]]
8587
8588 [[[[[[Test]]]]]]
8589
8590 [[[[[<nowiki/>[[Test]]]]]]]
8591 !! end
8592
8593 !! test
8594 Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved
8595 !! wikitext
8596 [[Foo| bar]]
8597
8598 [[Foo| ''bar'']]
8599
8600 [http://wp.org foo]
8601
8602 [http://wp.org ''foo'']
8603 !! html
8604 <p><a href="/wiki/Foo" title="Foo"> bar</a>
8605 </p><p><a href="/wiki/Foo" title="Foo"> <i>bar</i></a>
8606 </p><p><a rel="nofollow" class="external text" href="http://wp.org">foo</a>
8607 </p><p><a rel="nofollow" class="external text" href="http://wp.org"><i>foo</i></a>
8608 </p>
8609 !! end
8610
8611 !! test
8612 Parsoid: Scoped parsing should handle mixed transclusions and plain text
8613 !! wikitext
8614 [[Foo|{{echo|a}} b {{echo|c}}]]
8615 !! html/parsoid
8616 <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>
8617 !! end
8618
8619 !! test
8620 Link with angle bracket after anchor
8621 !! config
8622 wgFragmentMode=[ 'html5', 'legacy' ]
8623 !! wikitext
8624 [[Foo#<bar>]]
8625 !! html/php
8626 <p><a href="/wiki/Foo#&lt;bar&gt;" title="Foo">Foo#&lt;bar&gt;</a>
8627 </p>
8628 !! html/parsoid
8629 <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>
8630 !! end
8631
8632 !! test
8633 Link with angle bracket after anchor (legacy)
8634 !! config
8635 wgFragmentMode=[ 'legacy' ]
8636 !! wikitext
8637 [[Foo#<bar>]]
8638 !! html/php
8639 <p><a href="/wiki/Foo#.3Cbar.3E" title="Foo">Foo#&lt;bar&gt;</a>
8640 </p>
8641 !! end
8642
8643 ###
8644 ### Interwiki links (see maintenance/interwiki.sql)
8645 ###
8646
8647 !! test
8648 Inline interwiki link
8649 !! options
8650 parsoid=wt2html,wt2wt,html2html
8651 !! wikitext
8652 [[MeatBall:SoftSecurity]]
8653 !! html/php
8654 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
8655 </p>
8656 !! html/parsoid
8657 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a></p>
8658 !! end
8659
8660 !! test
8661 Inline interwiki link with empty title (T4372)
8662 !! options
8663 parsoid=wt2html,wt2wt,html2html
8664 !! wikitext
8665 [[MeatBall:]]
8666 !! html/php
8667 <p><a href="http://www.usemod.com/cgi-bin/mb.pl" class="extiw" title="meatball:">MeatBall:</a>
8668 </p>
8669 !! html/parsoid
8670 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?" title="meatball:">MeatBall:</a></p>
8671 !! end
8672
8673 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
8674 !! test
8675 Interwiki link encoding conversion (T3636)
8676 !! options
8677 parsoid=wt2html,wt2wt
8678 !! wikitext
8679 *[[Wikipedia:ro:Olteni&#0355;a]]
8680 *[[Wikipedia:ro:Olteni&#355;a]]
8681 !! html
8682 <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>
8683 <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>
8684
8685 !! html/php+tidy
8686 <ul>
8687 <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>
8688 <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>
8689 </ul>
8690 !! html/parsoid
8691 <ul>
8692 <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>
8693 <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>
8694 </ul>
8695 !! end
8696
8697 !! test
8698 Interwiki link with fragment (T4130)
8699 !! wikitext
8700 [[MeatBall:SoftSecurity#foo]]
8701 !! html
8702 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity#foo</a>
8703 </p>
8704 !! end
8705
8706 !! test
8707 Link scenarios with escaped fragments
8708 !! config
8709 wgFragmentMode=[ 'html5', 'legacy' ]
8710 !! wikitext
8711 [[#Is this great?]]
8712 [[Foo#Is this great?]]
8713 [[meatball:Foo#Is this great?]]
8714 !! html/php
8715 <p><a href="#Is_this_great?">#Is this great?</a>
8716 <a href="/wiki/Foo#Is_this_great?" title="Foo">Foo#Is this great?</a>
8717 <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>
8718 </p>
8719 !! html/parsoid
8720 <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>
8721 <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>
8722 <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>
8723 !! end
8724
8725 !! test
8726 Link scenarios with escaped fragments (legacy)
8727 !! config
8728 wgFragmentMode=[ 'legacy' ]
8729 !! wikitext
8730 [[#Is this great?]]
8731 [[Foo#Is this great?]]
8732 [[meatball:Foo#Is this great?]]
8733 !! html/php
8734 <p><a href="#Is_this_great.3F">#Is this great?</a>
8735 <a href="/wiki/Foo#Is_this_great.3F" title="Foo">Foo#Is this great?</a>
8736 <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>
8737 </p>
8738 !! end
8739
8740 # Ideally the wikipedia: prefix here should be proto-relative too
8741 # [CSA]: this is kind of a bogus test, as the PHP parser test doesn't
8742 # define the 'en' prefix, and originally the test used 'wikipedia',
8743 # which isn't a localinterwiki prefix hence the links to the 'en:Foo'
8744 # article.
8745 !! test
8746 Different interwiki prefixes mapping to the same URL
8747 !! wikitext
8748 [[:en:Foo]]
8749
8750 [[:en:Foo|Foo]]
8751
8752 [[wikipedia:Foo]]
8753
8754 [[:wikipedia:Foo|Foo]]
8755
8756 [[wikipedia:en:Foo]]
8757
8758 [[:wikipedia:en:Foo]]
8759
8760 [[ wikiPEdia :Foo]]
8761 !! html/parsoid
8762 <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>
8763
8764 <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>
8765
8766 <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>
8767
8768 <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>
8769
8770 <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>
8771
8772 <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>
8773
8774 <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>
8775 !! end
8776
8777 !! test
8778 Interwiki links that cannot be represented in wiki syntax
8779 !! wikitext
8780 [[meatball:ok]]
8781 [[meatball:ok#foo|ok with fragment]]
8782 [[meatball:ok_as_well?|ok ending with ? mark]]
8783 [http://de.wikipedia.org/wiki/Foo?action=history has query]
8784 [http://de.wikipedia.org/wiki/#foo is just fragment]
8785
8786 !! html/php
8787 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?ok" class="extiw" title="meatball:ok">meatball:ok</a>
8788 <a href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" class="extiw" title="meatball:ok">ok with fragment</a>
8789 <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>
8790 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8791 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a>
8792 </p>
8793 !! html/parsoid
8794 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok" title="meatball:ok">meatball:ok</a>
8795 <a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" title="meatball:ok">ok with fragment</a>
8796 <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>
8797 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8798 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a></p>
8799 !! end
8800
8801 !! test
8802 Interwiki links: trail
8803 !! wikitext
8804 [[wikipedia:Foo|Ba]]r
8805 !! html/php
8806 <p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
8807 </p>
8808 !! html/parsoid
8809 <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>
8810 !! end
8811
8812 !! test
8813 Local interwiki link
8814 !! options
8815 parsoid=wt2html,wt2wt,html2html
8816 !! wikitext
8817 [[local:Template:Foo]]
8818 !! html/php
8819 <p><a href="/wiki/Template:Foo" title="Template:Foo">local:Template:Foo</a>
8820 </p>
8821 !! html/parsoid
8822 <p><a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">local:Template:Foo</a></p>
8823 !! end
8824
8825 # Parsoid does not mark self-links, by design.
8826 !! test
8827 Local interwiki link: self-link to current page
8828 !! options
8829 title=[[Main Page]]
8830 parsoid=wt2html,wt2wt,html2html
8831 !! wikitext
8832 [[local:Main Page]]
8833 !! html/php
8834 <p><a class="mw-selflink selflink">local:Main Page</a>
8835 </p>
8836 !! html/parsoid
8837 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:Main Page</a></p>
8838 !! end
8839
8840 !! test
8841 Local interwiki link: prefix only (T66167)
8842 !! options
8843 parsoid=wt2html,wt2wt,html2html
8844 !! wikitext
8845 [[local:]]
8846 !! html/php
8847 <p><a href="/wiki/Main_Page" title="Main Page">local:</a>
8848 </p>
8849 !! html/parsoid
8850 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:</a></p>
8851 !! end
8852
8853 !! test
8854 Local interwiki link: with additional interwiki prefix (T63357)
8855 !! options
8856 parsoid=wt2html,wt2wt,html2html
8857 !! wikitext
8858 [[local:meatball:Hello]]
8859 !! html/php
8860 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Hello" class="extiw" title="meatball:Hello">local:meatball:Hello</a>
8861 </p>
8862 !! html/parsoid
8863 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?Hello" title="meatball:Hello">local:meatball:Hello</a></p>
8864 !! end
8865
8866 !! test
8867 Multiple local interwiki link prefixes
8868 !! wikitext
8869 [[local:local:local:local:mi:local:Foo]]
8870 !! options
8871 parsoid=wt2html,wt2wt,html2html
8872 !! html/php
8873 <p><a href="/wiki/Foo" title="Foo">local:local:local:local:mi:local:Foo</a>
8874 </p>
8875 !! html/parsoid
8876 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">local:local:local:local:mi:local:Foo</a></p>
8877 !! end
8878
8879 ###
8880 ### Interlanguage links
8881 ### Language links (so that searching for '### language' matches..)
8882 ###
8883
8884 !! test
8885 Interlanguage link
8886 !! wikitext
8887 Blah blah blah
8888 [[zh:Chinese]]
8889 !! html/php
8890 <p>Blah blah blah
8891 </p>
8892 !! html/parsoid
8893 <p>Blah blah blah</p>
8894 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8895 !! end
8896
8897 ## parsoid html2wt will lose the space variations
8898 !! test
8899 Interlanguage link with spacing
8900 !! options
8901 parsoid=wt2html,wt2wt,html2html
8902 !! wikitext
8903 Blah blah blah
8904 [[ zh : Chinese ]]
8905 !! html/php
8906 <p>Blah blah blah
8907 </p>
8908 !! html/parsoid
8909 <p>Blah blah blah</p>
8910 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8911 !! end
8912
8913 !! test
8914 Double interlanguage link
8915 !! wikitext
8916 Blah blah blah
8917 [[es:Spanish]]
8918 [[zh:Chinese]]
8919 !! html/php
8920 <p>Blah blah blah
8921 </p>
8922 !! html/parsoid
8923 <p>Blah blah blah</p>
8924 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
8925 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8926 !! end
8927
8928 ## parsoid html2wt will lose the space variations
8929 !! test
8930 Interlanguage link variations
8931 !! options
8932 parsoid=wt2html,wt2wt,html2html
8933 !! wikitext
8934 Blah blah blah
8935 [[ es :Spanish]]
8936 [[ ZH :Chinese]]
8937 [[es:Foo_bar]]
8938 !! html/php
8939 <p>Blah blah blah
8940 </p>
8941 !! html/parsoid
8942 <p>Blah blah blah</p>
8943 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish" />
8944 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese" />
8945 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar" />
8946 !! end
8947
8948 !! test
8949 Escaping of interlanguage links (T129218, T156308)
8950 !! wikitext
8951 Blah blah blah
8952 [[:es:Spanish]]
8953 [[ : zh : Chinese ]]
8954 !! html/php
8955 <p>Blah blah blah
8956 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
8957 <a href="http://zh.wikipedia.org/wiki/Chinese" class="extiw" title="zh:Chinese"> zh : Chinese </a>
8958 </p>
8959 !! html/parsoid
8960 <p>Blah blah blah
8961 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
8962 <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh : Chinese </a></p>
8963 !! end
8964
8965 !! test
8966 Multiple colons escaping interlanguage links
8967 !! options
8968 parsoid=wt2html
8969 !! wikitext
8970 [[:es:Spanish]]
8971 [[::es:Spanish]]
8972 [[:::es:Spanish]]
8973 !! html/php
8974 <p><a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
8975 [[::es:Spanish]]
8976 [[:::es:Spanish]]
8977 </p>
8978 !! html/parsoid
8979 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
8980 [[::es:Spanish]]
8981 [[:::es:Spanish]]</p>
8982 !! end
8983
8984 ## parsoid html2wt will normalize the space to _
8985 !! test
8986 Space and question mark encoding in interlanguage links (T95473)
8987 !! options
8988 parsoid=wt2html,wt2wt,html2html
8989 !! wikitext
8990 Blah blah blah
8991 [[es:Foo bar?]]
8992 !! html/php
8993 <p>Blah blah blah
8994 </p>
8995 !! html/parsoid
8996 <p>Blah blah blah</p>
8997 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar%3F" />
8998 !! end
8999
9000 !! test
9001 Interlanguage link, with prefix links
9002 !! options
9003 language=ln
9004 !! wikitext
9005 Blah blah blah
9006 [[zh:Chinese]]
9007 !! html/php
9008 <p>Blah blah blah
9009 </p>
9010 !! html/parsoid
9011 <p>Blah blah blah</p>
9012 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9013 !! end
9014
9015 !! test
9016 Double interlanguage link, with prefix links (T10897)
9017 !! options
9018 language=ln
9019 !! wikitext
9020 Blah blah blah
9021 [[es:Spanish]]
9022 [[zh:Chinese]]
9023 !! html/php
9024 <p>Blah blah blah
9025 </p>
9026 !! html/parsoid
9027 <p>Blah blah blah</p>
9028 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
9029 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9030 !! end
9031
9032 !! test
9033 "Extra" interlanguage links (T34189 / gerrit 111390)
9034 !! wikitext
9035 Blah blah blah
9036 [[mul:Article]]
9037 !! html/php
9038 <p>Blah blah blah
9039 </p>
9040 !! html/parsoid
9041 <p>Blah blah blah</p>
9042 <link rel="mw:PageProp/Language" title="Multilingual" href="http://wikisource.org/wiki/Article"/>
9043 !! end
9044
9045 ## PHP parser tests script needs an update
9046 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
9047 !! test
9048 Language links render as inline links if $wgInterwikiMagic=false
9049 !! options
9050 wgInterwikiMagic=false
9051 parsoid=wt2html,wt2wt,html2html
9052 !! wikitext
9053 Blah blah blah
9054 [[zh:Chinese]]
9055 !! html/parsoid
9056 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
9057 !! end
9058
9059 ## PHP parser tests script needs an update
9060 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
9061 !! test
9062 Language links render as inline links in the Talk namespace
9063 !! options
9064 title=Talk:Foo
9065 parsoid=wt2html,wt2wt,html2html
9066 !! wikitext
9067 Blah blah blah
9068 [[zh:Chinese]]
9069 !! html/parsoid
9070 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
9071 !! end
9072
9073 !! test
9074 Parsoid-specific test: Wikilinks with &nbsp; should RT properly
9075 !! options
9076 language=ln
9077 !! wikitext
9078 [[WW&nbsp;II]]
9079 !! html
9080 <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>
9081 </p>
9082 !! end
9083
9084 !! test
9085 Parsoid T55221: Wikilinks should be properly entity-escaped
9086 !! options
9087 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
9088 !! html/parsoid
9089 <p>He&amp;nbsp;llo <a href="./Foo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9090 <p>He&amp;nbsp;llo <a href="./He&amp;nbsp;llo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9091 !! wikitext
9092 He&amp;nbsp;llo [[Foo|He&amp;nbsp;llo]]
9093
9094 He&amp;nbsp;llo He&amp;nbsp;llo
9095 !! html/php
9096 <p>He&amp;nbsp;llo <a href="/wiki/Foo" title="Foo">He&amp;nbsp;llo</a>
9097 </p><p>He&amp;nbsp;llo He&amp;nbsp;llo
9098 </p>
9099 !! end
9100
9101 # html2wt will fail because of title normalization without data-parsoid
9102 !! test
9103 Parsoid: handle constructor well
9104 !! options
9105 parsoid=wt2html,wt2wt
9106 !! wikitext
9107 [[constructor]]
9108
9109 [[constructor:foo]]
9110 !! html/php
9111 <p><a href="/index.php?title=Constructor&amp;action=edit&amp;redlink=1" class="new" title="Constructor (page does not exist)">constructor</a>
9112 </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>
9113 </p>
9114 !! html/parsoid
9115 <p><a rel="mw:WikiLink" href="./Constructor" title="Constructor" data-parsoid='{"stx":"simple","a":{"href":"./Constructor"},"sa":{"href":"constructor"}}'>constructor</a></p>
9116
9117 <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>
9118 !! end
9119
9120 !! test
9121 Template parameter named "constructor"
9122 !! wikitext
9123 {{echo| constructor = |hi}}
9124 !! html/parsoid
9125 <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>
9126 !! end
9127
9128 !! article
9129 ko:
9130 !! text
9131 Test.
9132 !! endarticle
9133
9134 # Note that `ko` isn't a known interlanguage prefix
9135 !! test
9136 Parsoid: recognize interlanguage links without a target page
9137 !! options
9138 ill
9139 !! wikitext
9140 [[es:]]
9141
9142 [[ko:]]
9143 !! html/php
9144 es:
9145 !! html/parsoid
9146 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/"/>
9147
9148 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9149 !! end
9150
9151 # Note that `ko` isn't a known interwiki prefix
9152 !! test
9153 Parsoid: recognize interwiki links without a target page
9154 !! options
9155 parsoid=wt2html,wt2wt,html2html
9156 !! wikitext
9157 [[:es:]]
9158
9159 [[:ko:]]
9160 !! html/php
9161 <p><a href="http://es.wikipedia.org/wiki/" class="extiw" title="es:">es:</a>
9162 </p><p><a href="/wiki/Ko:" title="Ko:">ko:</a>
9163 </p>
9164 !! html/parsoid
9165 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/" title="es:">es:</a></p>
9166 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9167 !! end
9168
9169 !! test
9170 Handle interwiki links pointing to the current wiki as plain wiki links (T47209)
9171 !! wikitext
9172 [[mi:Foo]]
9173 !! html/php
9174 <p><a href="/wiki/Foo" title="Foo">mi:Foo</a>
9175 </p>
9176 !! html/parsoid
9177 <p><a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo"},"sa":{"href":"mi:Foo"}}'>mi:Foo</a></p>
9178 !! end
9179
9180 !! test
9181 Interlanguage link with preceding local interwiki link (T70085)
9182 !! options
9183 parsoid=wt2html,wt2wt,html2html
9184 !! wikitext
9185 Blah blah blah
9186 [[local:es:Spanish]]
9187 !! html/php
9188 <p>Blah blah blah
9189 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">local:es:Spanish</a>
9190 </p>
9191 !! html/parsoid
9192 <p>Blah blah blah
9193 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">local:es:Spanish</a></p>
9194 !! end
9195
9196 !! test
9197 Looks like an interlanguage link, but is actually a local interwiki
9198 !! options
9199 parsoid=wt2html,wt2wt,html2html
9200 !! wikitext
9201 Blah blah blah
9202 [[mi:Template:Foo]]
9203 !! html/php
9204 <p>Blah blah blah
9205 <a href="/wiki/Template:Foo" title="Template:Foo">mi:Template:Foo</a>
9206 </p>
9207 !! html/parsoid
9208 <p>Blah blah blah
9209 <a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">mi:Template:Foo</a></p>
9210 !! end
9211
9212 ###
9213 ### Redirects, Parsoid-only
9214 ###
9215
9216 !! test
9217 1. Simple redirect to page
9218 !! wikitext
9219 #REDIRECT [[Main Page]]
9220 !! html/parsoid
9221 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9222 !! end
9223
9224 !! test
9225 2. Other redirect variants
9226 !! wikitext
9227 #REDIRECT [[Main_Page]]
9228 !! html/parsoid
9229 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Main_Page"},"sa":{"href":"Main_Page"}}'/>
9230 !! end
9231
9232 # Not a valid redirect in PHP (although perhaps it was, once upon a time)
9233 # This tests the Parsoid bail-out code.
9234 !! test
9235 3. Other redirect variants
9236 !! options
9237 parsoid=wt2html
9238 !! wikitext
9239 #REDIRECT [[<nowiki>[[Bar]]</nowiki>]]
9240 !! html/parsoid
9241 <ol><li>REDIRECT [[<span typeof="mw:Nowiki">[[Bar]]</span>]]</li></ol>
9242 !! end
9243
9244 !! test
9245 4. Redirect to a templated destination
9246 !! wikitext
9247 #REDIRECT [[{{echo|Foo}}bar]]
9248 !! html/parsoid
9249 <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"}]]}'/>
9250 !! end
9251
9252 !! test
9253 Empty redirect
9254 !! options
9255 parsoid=wt2html,wt2wt
9256 !! wikitext
9257 #REDIRECT [[]]
9258 !! html/parsoid
9259 <ol>
9260 <li>REDIRECT [[]]</li></ol>
9261 !! end
9262
9263 !! test
9264 Optional colon in #REDIRECT
9265 !! options
9266 # the colon is archaic syntax. we support it for wt2html, but we
9267 # don't care that it roundtrips back to the modern syntax.
9268 parsoid=wt2html,html2html
9269 !! wikitext
9270 #REDIRECT:[[Main Page]]
9271 !! html/parsoid
9272 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9273 !! end
9274
9275 !! test
9276 Whitespace in #REDIRECT with optional colon
9277 !! options
9278 # the colon and gratuitous whitespace is archaic syntax. we support
9279 # it for wt2html, but we don't care that it roundtrips back to the
9280 # modern syntax (without extra whitespace)
9281 parsoid=wt2html,html2html
9282 !! wikitext
9283
9284 #REDIRECT
9285 :
9286 [[Main Page]]
9287 !! html/parsoid
9288 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9289 !! end
9290
9291 !! test
9292 Piped link in #REDIRECT
9293 !! options
9294 # content after piped link is ignored. we support this syntax,
9295 # but don't care that the piped link is lost when we roundtrip this.
9296 parsoid=wt2html
9297 !! wikitext
9298 #REDIRECT [[Main Page|bar]]
9299 !! html/parsoid
9300 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9301 !! end
9302
9303 !! test
9304 Redirect to category (T104502)
9305 !! options
9306 parsoid=wt2html,wt2wt
9307 !! wikitext
9308 #REDIRECT [[Category:Foo]]
9309 !! html/parsoid
9310 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9311 !! end
9312
9313 !! test
9314 Redirect to category with URL encoding (T104502)
9315 !! options
9316 parsoid=wt2html
9317 !! wikitext
9318 #REDIRECT [[Category%3AFoo]]
9319 !! html/parsoid
9320 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9321 !! end
9322
9323 !! test
9324 Redirect to category page
9325 !! wikitext
9326 #REDIRECT [[:Category:Foo]]
9327 !! html/parsoid
9328 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9329 !! end
9330
9331 !! test
9332 Redirect to image page (1)
9333 !! wikitext
9334 #REDIRECT [[File:Wiki.png]]
9335 !! html/parsoid
9336 <link rel="mw:PageProp/redirect" href="./File:Wiki.png"/>
9337 !! end
9338
9339 !! test
9340 Redirect to image page (2)
9341 !! wikitext
9342 #REDIRECT [[Image:Wiki.png]]
9343 !! html/parsoid
9344 <link rel="mw:PageProp/redirect" href="./File:Wiki.png" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./File:Wiki.png"},"sa":{"href":"Image:Wiki.png"}}'/>
9345 !! end
9346
9347 # html2wt disabled because wts serializes as "#REDIRECT [[:en:File:Wiki.png]]"
9348 # Next test confirms this.
9349 !! test
9350 Redirect to language (1) (T104918)
9351 !! options
9352 parsoid=wt2html,wt2wt,html2html
9353 !! wikitext
9354 #REDIRECT [[en:File:Wiki.png]]
9355 !! html/parsoid
9356 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9357 !! end
9358
9359 !! test
9360 Redirect to language (2) (T104918)
9361 !! wikitext
9362 #REDIRECT [[:en:File:Wiki.png]]
9363 !! html/parsoid
9364 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9365 !! end
9366
9367 !! test
9368 Redirect to interwiki (T104918)
9369 !! wikitext
9370 #REDIRECT [[meatball:File:Wiki.png]]
9371 !! html/parsoid
9372 <link rel="mw:PageProp/redirect" href="http://www.usemod.com/cgi-bin/mb.pl?File:Wiki.png"/>
9373 !! end
9374
9375 !! test
9376 Non-English #REDIRECT
9377 !! options
9378 language=is
9379 !! wikitext
9380 #TILVÍSUN [[Main Page]]
9381 !! html/parsoid
9382 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#TILVÍSUN ","a":{"href":"./Main_Page"},"sa":{"href":"Main Page"}}'/>
9383 !! end
9384
9385 !! test
9386 Redirect syntax under text isn't considered a redirect
9387 !! wikitext
9388 some text
9389
9390 #redirect [[Main Page]]
9391 !! html/parsoid
9392 <p>some text</p>
9393 <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>
9394 !! end
9395
9396 !! test
9397 New redirect
9398 !! options
9399 parsoid=html2wt
9400 !! html/parsoid
9401 <p>Foo<link rel="mw:PageProp/redirect" href="./Foo"/></p>
9402 !! wikitext
9403 #REDIRECT [[Foo]]
9404 Foo
9405 !! end
9406
9407 !! test
9408 Redirect followed by block on the same line
9409 !! options
9410 parsoid=wt2html
9411 !! wikitext
9412 #REDIRECT [[Main Page]]<!-- haha -->==hi==
9413 !! html/parsoid
9414 <link rel="mw:PageProp/redirect" href="./Main_Page"/><!-- haha --><h2 id="hi">hi</h2>
9415 !! end
9416
9417 !! test
9418 Redirect followed by a newline
9419 !! wikitext
9420 #REDIRECT [[Main Page]]
9421 A newline
9422 !! html/parsoid
9423 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9424 <p>A newline</p>
9425 !! end
9426
9427 !! test
9428 Redirect followed by multiple newlines
9429 !! wikitext
9430 #REDIRECT [[Main Page]]
9431
9432
9433 A newline
9434 !! html/parsoid
9435 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9436
9437 <p><br/>
9438 A newline</p>
9439 !! end
9440
9441 !! test
9442 Drop duplicate redirects
9443 !! options
9444 parsoid=html2wt
9445 !! html/parsoid
9446 <link rel="mw:PageProp/redirect" href="./Foo"/>
9447 <link rel="mw:PageProp/redirect" href="./Bar"/>
9448 <link rel="mw:PageProp/redirect" href="./Baz"/>
9449 !! wikitext
9450 #REDIRECT [[Foo]]
9451 !! end
9452
9453 ##
9454 ## XHTML tidiness
9455 ###
9456
9457 !! test
9458 <br> to <br />
9459 !! wikitext
9460 1<br>2<br />3
9461 !! html
9462 <p>1<br />2<br />3
9463 </p>
9464 !! end
9465
9466 !! test
9467 Broken br tag sanitization
9468 !! wikitext
9469 </br>
9470 !! html/php
9471 <p>&lt;/br&gt;
9472 </p>
9473 !! end
9474
9475 # TODO: Fix html2html mode (T53055)!
9476 !! test
9477 Parsoid: Broken br tag recognition
9478 !! options
9479 parsoid=wt2html
9480 !! wikitext
9481 </br>
9482
9483 <br/ >
9484 !! html+tidy
9485 <p><br />
9486 </p><p><br />
9487 </p>
9488 !! end
9489
9490 !! test
9491 Incorrecly removing closing slashes from correctly formed XHTML
9492 !! wikitext
9493 <br style="clear:both;" />
9494 !! html
9495 <p><br style="clear:both;" />
9496 </p>
9497 !! end
9498
9499 !! test
9500 Failing to transform badly formed HTML into correct XHTML
9501 !! wikitext
9502 <br style="clear: left;">
9503 <br style="clear: right;">
9504 <br style="clear: both;">
9505 !! html
9506 <p><br style="clear: left;" />
9507 <br style="clear: right;" />
9508 <br style="clear: both;" />
9509 </p>
9510 !!end
9511
9512 ## FIXME: Is Parsoid's acceptance of self-closing html-tags
9513 ## a feature or a bug? See https://phabricator.wikimedia.org/T76962
9514 !! test
9515 Handling html with a div self-closing tag
9516 !! wikitext
9517 <div title />
9518 <div title/>
9519 <div title/ >
9520 <div title=bar />
9521 <div title=bar/>
9522 <div title=bar/ >
9523 !! html/php
9524 <p>&lt;div title /&gt;
9525 &lt;div title/&gt;
9526 </p>
9527 <div>
9528 <p>&lt;div title=bar /&gt;
9529 &lt;div title=bar/&gt;
9530 </p>
9531 <div title="bar/"></div>
9532 </div>
9533
9534 !! html/parsoid
9535 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9536 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9537 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9538 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9539 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9540 <div title="bar/" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></div>
9541 !! end
9542
9543 !! test
9544 Handling html with a br self-closing tag
9545 !! wikitext
9546 <br title />
9547 <br title/>
9548 <br title/ >
9549 <br title=bar />
9550 <br title=bar/>
9551 <br title=bar/ >
9552 !! html/php
9553 <p><br title="" />
9554 <br title="" />
9555 <br />
9556 <br title="bar" />
9557 <br title="bar" />
9558 <br title="bar/" />
9559 </p>
9560 !! html/parsoid
9561 <p><br title="" />
9562 <br title="" />
9563 <br title="" />
9564 <br title="bar" />
9565 <br title="bar" />
9566 <br title="bar/" />
9567 </p>
9568 !! end
9569
9570 !! test
9571 Horizontal ruler (should it add that extra space?)
9572 !! wikitext
9573 <hr>
9574 <hr >
9575 foo <hr
9576 > bar
9577 !! html+tidy
9578 <hr />
9579 <hr /><p>
9580 foo </p><hr /><p> bar
9581 </p>
9582 !! end
9583
9584 !! test
9585 Horizontal ruler -- 4+ dashes render hr
9586 !! wikitext
9587 ----
9588 !! html
9589 <hr />
9590
9591 !! end
9592
9593 !! test
9594 Horizontal ruler -- eats additional dashes on the same line
9595 !! wikitext
9596 ---------
9597 !! html
9598 <hr />
9599
9600 !! end
9601
9602 !! test
9603 Horizontal ruler -- does not collapse dashes on consecutive lines
9604 !! wikitext
9605 ----
9606 ----
9607 !! html
9608 <hr />
9609 <hr />
9610
9611 !! end
9612
9613 !! test
9614 Horizontal ruler -- <4 dashes render as plain text
9615 !! wikitext
9616 ---
9617 !! html
9618 <p>---
9619 </p>
9620 !! end
9621
9622 !! test
9623 Horizontal ruler -- Supports content following dashes on same line
9624 !! wikitext
9625 ---- Foo
9626 !! html
9627 <hr /> Foo
9628
9629 !! html+tidy
9630 <hr /><p> Foo
9631 </p>
9632 !! end
9633
9634 ###
9635 ### Block-level elements
9636 ###
9637 !! test
9638 Common list
9639 !! wikitext
9640 *Common list
9641 *item 2
9642 *item 3
9643 !! html
9644 <ul><li>Common list</li>
9645 <li>item 2</li>
9646 <li>item 3</li></ul>
9647
9648 !! end
9649
9650 !! test
9651 Numbered list
9652 !! wikitext
9653 #Numbered list
9654 #item 2
9655 #item 3
9656 !! html
9657 <ol><li>Numbered list</li>
9658 <li>item 2</li>
9659 <li>item 3</li></ol>
9660
9661 !! end
9662
9663 # the switch from level 3 to ordered should not introduce a newline between
9664 !! test
9665 Mixed list
9666 !! wikitext
9667 *Mixed list
9668 *#with numbers
9669 **and bullets
9670 *#and numbers
9671 *bullets again
9672 **bullet level 2
9673 ***bullet level 3
9674 ***#Number on level 4
9675 **bullet level 2
9676 **#Number on level 3
9677 **#Number on level 3
9678 *#number level 2
9679 *Level 1
9680 ***Level 3
9681 #**Level 3, but ordered
9682 !! html
9683 <ul><li>Mixed list
9684 <ol><li>with numbers</li></ol>
9685 <ul><li>and bullets</li></ul>
9686 <ol><li>and numbers</li></ol></li>
9687 <li>bullets again
9688 <ul><li>bullet level 2
9689 <ul><li>bullet level 3
9690 <ol><li>Number on level 4</li></ol></li></ul></li>
9691 <li>bullet level 2
9692 <ol><li>Number on level 3</li>
9693 <li>Number on level 3</li></ol></li></ul>
9694 <ol><li>number level 2</li></ol></li>
9695 <li>Level 1
9696 <ul><li><ul><li>Level 3</li></ul></li></ul></li></ul>
9697 <ol><li><ul><li><ul><li>Level 3, but ordered</li></ul></li></ul></li></ol>
9698
9699 !! end
9700
9701 !! test
9702 1. Nested mixed wikitext and html list
9703 !! wikitext
9704 *hi
9705 *<ul><li>ho</li></ul>
9706 *hi
9707 **ho
9708 !! html/php
9709 <ul><li>hi</li>
9710 <li><ul><li>ho</li></ul></li>
9711 <li>hi
9712 <ul><li>ho</li></ul></li></ul>
9713
9714 !! html/parsoid
9715 <ul><li>hi</li>
9716 <li><ul data-parsoid='{"stx":"html"}'><li data-parsoid='{"stx":"html"}'>ho</li></ul></li>
9717 <li>hi
9718 <ul><li>ho</li></ul></li></ul>
9719 !! end
9720
9721 !! test
9722 2. Nested mixed wikitext and html list (incompatible)
9723 !! wikitext
9724 ;hi
9725 :{{echo|<li>ho</li>}}
9726 !! html/php
9727 <dl><dt>hi</dt>
9728 <dd><li>ho</li></dd></dl>
9729
9730 !! html/parsoid
9731 <dl><dt>hi</dt>
9732 <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>
9733 !! end
9734
9735 !! test
9736 Nested lists 1
9737 !! wikitext
9738 *foo
9739 **bar
9740 !! html
9741 <ul><li>foo
9742 <ul><li>bar</li></ul></li></ul>
9743
9744 !! end
9745
9746 !! test
9747 Nested lists 2
9748 !! wikitext
9749 **foo
9750 *bar
9751 !! html
9752 <ul><li><ul><li>foo</li></ul></li>
9753 <li>bar</li></ul>
9754
9755 !! end
9756
9757 !! test
9758 Nested lists 3 (first element empty)
9759 !! wikitext
9760 *
9761 **bar
9762 !! html
9763 <ul><li>
9764 <ul><li>bar</li></ul></li></ul>
9765
9766 !! end
9767
9768 !! test
9769 Nested lists 4 (first element empty)
9770 !! wikitext
9771 **
9772 *bar
9773 !! html
9774 <ul><li><ul><li></li></ul></li>
9775 <li>bar</li></ul>
9776
9777 !! end
9778
9779 !! test
9780 Nested lists 5 (both elements empty)
9781 !! wikitext
9782 **
9783 *
9784 !! html
9785 <ul><li><ul><li></li></ul></li>
9786 <li></li></ul>
9787
9788 !! end
9789
9790 !! test
9791 Nested lists 6 (both elements empty)
9792 !! wikitext
9793 *
9794 **
9795 !! html
9796 <ul><li>
9797 <ul><li></li></ul></li></ul>
9798
9799 !! end
9800
9801 !! test
9802 Nested lists 7 (skip initial nesting levels)
9803 !! wikitext
9804 ***foo
9805 !! html
9806 <ul><li><ul><li><ul><li>foo</li></ul></li></ul></li></ul>
9807
9808 !! end
9809
9810 !! test
9811 Nested lists 8 (multiple nesting transitions)
9812 !! wikitext
9813 *foo
9814 ***bar
9815 **baz
9816 *boo
9817 !! html
9818 <ul><li>foo
9819 <ul><li><ul><li>bar</li></ul></li>
9820 <li>baz</li></ul></li>
9821 <li>boo</li></ul>
9822
9823 !! end
9824
9825 !! test
9826 Nested lists 9 (extension interaction)
9827 !! options
9828 parsoid
9829 !! wikitext
9830 *<references />
9831 !! html/parsoid
9832 <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>
9833 !! end
9834
9835 !! test
9836 1. Lists with start-of-line-transparent tokens before bullets: Comments
9837 !! wikitext
9838 *foo
9839 *<!--cmt-->bar
9840 <!--cmt-->*baz
9841 !! html
9842 <ul><li>foo</li>
9843 <li>bar</li>
9844 <li>baz</li></ul>
9845
9846 !! end
9847
9848 !! test
9849 Nested lists 10 (list and span siblings: wt2wt regression)
9850 !! wikitext
9851 *a <span>x</span>
9852 **b <span>y</span>
9853 !! html/parsoid
9854 <ul><li>a <span>x</span>
9855 <ul><li>b <span>y</span></li></ul></li></ul>
9856 !! end
9857
9858 !! test
9859 2. Lists with start-of-line-transparent tokens before bullets: Template close
9860 !! wikitext
9861 *foo {{echo|bar
9862 }}*baz
9863 !! html
9864 <ul><li>foo bar</li>
9865 <li>baz</li></ul>
9866
9867 !! end
9868
9869 !! test
9870 List items are not parsed correctly following a <pre> block (T2785)
9871 !! wikitext
9872 *<pre>foo</pre>
9873 *<pre>bar</pre>
9874 *zar
9875 !! html/php
9876 <ul><li><pre>foo</pre></li>
9877 <li><pre>bar</pre></li>
9878 <li>zar</li></ul>
9879
9880 !! html/parsoid
9881 <ul><li><pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre></li>
9882 <li><pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"bar"}}'>bar</pre></li>
9883 <li>zar</li></ul>
9884 !! end
9885
9886 # FIXME: Might benefit from a html/parsoid since this has a template
9887 !! test
9888 List items from template
9889 !! wikitext
9890
9891 {{inner list}}
9892 *item 2
9893
9894 *item 0
9895 {{inner list}}
9896 *item 2
9897
9898 *item 0
9899 *notSOL{{inner list}}
9900 *item 2
9901 !! html
9902 <ul><li>item 1</li>
9903 <li>item 2</li></ul>
9904 <ul><li>item 0</li>
9905 <li>item 1</li>
9906 <li>item 2</li></ul>
9907 <ul><li>item 0</li>
9908 <li>notSOL</li>
9909 <li>item 1</li>
9910 <li>item 2</li></ul>
9911
9912 !! end
9913
9914 !! test
9915 List interrupted by empty line or heading
9916 !! wikitext
9917 *foo
9918
9919 **bar
9920 ==A heading==
9921 *Another list item
9922 !! html
9923 <ul><li>foo</li></ul>
9924 <ul><li><ul><li>bar</li></ul></li></ul>
9925 <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>
9926 <ul><li>Another list item</li></ul>
9927
9928 !!end
9929
9930 !!test
9931 Multiple list tags generated by templates
9932 !! wikitext
9933 {{echo|<li>}}a
9934 {{echo|<li>}}b
9935 {{echo|<li>}}c
9936 !! html
9937 <li>a
9938 <li>b
9939 <li>c</li>
9940 </li>
9941 </li>
9942
9943 !! html+tidy
9944 <li>a
9945 </li><li>b
9946 </li><li>c
9947 </li>
9948 !! html/parsoid
9949 <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
9950 </li><li about="#mwt1">b
9951 </li><li about="#mwt1" data-parsoid='{"stx":"html","autoInsertedEnd":true,"dsr":[null,44,null,0]}'>c</li>
9952 !!end
9953
9954 !!test
9955 Single-comment whitespace lines dont break lists, and neither do multi-comment whitespace lines
9956 !! wikitext
9957 *a
9958 <!--This line will NOT split the list-->
9959 *b
9960 <!--This line will NOT split the list either-->
9961 *c
9962 <!--foo--> <!----> <!--This line NOT split the list either-->
9963 *d
9964 !! html
9965 <ul><li>a</li>
9966 <li>b</li>
9967 <li>c</li>
9968 <li>d</li></ul>
9969
9970 !!end
9971
9972 !!test
9973 Replacing whitespace with tabs still doesn't break the list (gerrit 78327)
9974 !! wikitext
9975 *a
9976 <!--This line will NOT split the list-->
9977 *b
9978 <!--This line will NOT split the list either-->
9979 *c
9980 <!--foo--> <!----> <!--This line NOT split the list
9981 either-->
9982 *d
9983 !! html
9984 <ul><li>a</li>
9985 <li>b</li>
9986 <li>c</li>
9987 <li>d</li></ul>
9988
9989 !!end
9990
9991 # FIXME: Parsoid has a dedicated DOM pass to mimic this Tidy-specific li-hack
9992 # That pass could possibly be removed.
9993 !!test
9994 Test the li-hack (a hack from Tidy days, but doesn't work as advertised with Remex)
9995 !!options
9996 parsoid=wt2html,wt2wt
9997 !! wikitext
9998 *foo
9999 *<li>li-hack
10000 *{{echo|<li>templated li-hack}}
10001 *<!--foo--><li> unsupported li-hack with preceding comments
10002
10003 <ul>
10004 <li><li>not a li-hack
10005 </li>
10006 </ul>
10007 !! html+tidy
10008 <ul><li>foo</li>
10009 <li class="mw-empty-elt"></li><li>li-hack</li>
10010 <li class="mw-empty-elt"></li><li>templated li-hack</li>
10011 <li class="mw-empty-elt"></li><li> unsupported li-hack with preceding comments</li></ul>
10012 <ul>
10013 <li class="mw-empty-elt"></li><li>not a li-hack
10014 </li>
10015 </ul>
10016 !! html/parsoid
10017 <ul><li> foo</li>
10018 <li data-parsoid='{"stx":"html","autoInsertedEnd":true,"liHackSrc":"*"}'>li-hack</li>
10019 <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>
10020 <li data-parsoid='{"autoInsertedEnd":true}'><!--foo--></li><li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>unsupported li-hack with preceding comments</li></ul>
10021
10022 <ul data-parsoid='{"stx":"html"}'>
10023 <li class="mw-empty-elt" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></li><li data-parsoid='{"stx":"html"}'>not a li-hack
10024 </li>
10025 </ul>
10026
10027 !!end
10028
10029 !! test
10030 Parsoid: Make sure nested lists are serialized on their own line even if HTML contains no newlines
10031 !! options
10032 parsoid
10033 !! wikitext
10034 #foo
10035 ##bar
10036
10037 *foo
10038 **bar
10039
10040 :foo
10041 ::bar
10042 !! html
10043 <ol>
10044 <li>foo<ol>
10045 <li>bar</li>
10046 </ol></li>
10047 </ol><ul>
10048 <li>foo<ul>
10049 <li>bar</li>
10050 </ul></li>
10051 </ul><dl>
10052 <dd>foo<dl>
10053 <dd>bar</dd>
10054 </dl></dd>
10055 </dl>
10056 !! end
10057
10058 !! test
10059 Parsoid: Test of whitespace serialization with Templated bullets
10060 !! options
10061 parsoid=wt2html
10062 !! wikitext
10063 * {{bullet}}
10064 !! html/parsoid
10065 <ul>
10066 <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>
10067 </ul>
10068 !! end
10069
10070 # ------------------------------------------------------------------------
10071 # The next set of tests are about Parsoid's ability to handle badly nested
10072 # tags (parse, minimize scope of fixup, and roundtrip back)
10073 # ------------------------------------------------------------------------
10074
10075 # Remex and Parsoid output stems from list handling diffs because Parsoid & PHP parser.
10076 # Parsoid's list handling is more aware of block structure.
10077 !! test
10078 Unbalanced closing block tags break a list
10079 !! wikitext
10080 <div>
10081 *a</div><div>
10082 *b</div>
10083 !! html+tidy
10084 <div>
10085 <ul><li>a</li></ul></div><div>
10086 <li>b</li></div>
10087 !! html/parsoid
10088 <div><ul>
10089 <li>a</li>
10090 </ul></div>
10091 <div><ul>
10092 <li>b</li>
10093 </ul></div>
10094 !! end
10095
10096 !! test
10097 Unbalanced closing non-block tags don't break a list
10098 !! wikitext
10099 <span>
10100 *a</span><span>
10101 *b</span>
10102 !! html/php+tidy
10103 <p><span>
10104 </span></p>
10105 <ul><li>a<span></span></li>
10106 <li>b</li></ul>
10107 !! html/parsoid
10108 <span>
10109 <ul>
10110 <li>a<span></span></li>
10111 <li>b</li>
10112 </ul>
10113 </span>
10114 !! end
10115
10116 # Parsoid does some post-dom-building cleanup
10117 # which is why its output differs from Remex.
10118 !! test
10119 Unclosed formatting tags that straddle lists are closed and reopened
10120 !! options
10121 parsoid=wt2html,wt2wt,html2html
10122 !! wikitext
10123 #<s> a
10124 #b </s>
10125 !! html/php+tidy
10126 <ol><li><s> a</s></li><s>
10127 </s><li><s>b </s></li></ol>
10128 !! html/parsoid
10129 <ol><li><s> a</s></li>
10130 <li><s>b </s></li></ol>
10131 !! end
10132
10133 # Output is ugly because of all the misnested tag fixups.
10134 # Remex is wrapping p-tags around empty elements.
10135 # Parsoid has special-case handling of this pattern of
10136 # wrapping lists in formatting tags.
10137 # FIXME: Should we remove this code from Parsoid? Or add
10138 # special support in Remex? If the latter, maybe just wait
10139 # for Parsoid to become the default parser.
10140 # See T70395.
10141 !!test
10142 1. List embedded in a formatting tag
10143 !! wikitext
10144 <small>
10145 *foo
10146 </small>
10147 !! html/php+tidy
10148 <p><small>
10149 </small></p><small><ul><li>foo</li></ul></small><small></small><p><small></small>
10150 </p>
10151 !! html/parsoid
10152 <small>
10153 <ul>
10154 <li>foo</li>
10155 </ul>
10156 </small>
10157 !!end
10158
10159 # Output is ugly because of all the misnested tag fixups
10160 # Remex is wrapping p-tags around empty elements.
10161 # Parsoid has code that strips useless p-tags.
10162 !!test
10163 2. List embedded in a formatting tag in a misnested way
10164 !! wikitext
10165 <small>
10166 *a
10167 *b</small>
10168 !! html/php+tidy
10169 <p><small>
10170 </small></p><small></small><ul><small><li>a</li>
10171 </small><li><small>b</small></li></ul>
10172 !! html/parsoid
10173 <small></small>
10174 <ul><small>
10175 <li>a</li>
10176 </small>
10177 <li><small>b</small></li>
10178 </ul>
10179 !!end
10180
10181 ###
10182 ### Magic Words
10183 ###
10184
10185 # Note that the current date is hard-coded as
10186 # 1970-01-01T00:02:03Z (a Thursday)
10187 # when running parser tests. The timezone is also fixed to GMT, so
10188 # local date will be identical to current date.
10189
10190 !! test
10191 Magic Word: {{CURRENTDAY}}
10192 !! wikitext
10193 {{CURRENTDAY}}
10194 !! html
10195 <p>1
10196 </p>
10197 !! end
10198
10199 !! test
10200 Magic Word: {{CURRENTDAY2}}
10201 !! wikitext
10202 {{CURRENTDAY2}}
10203 !! html
10204 <p>01
10205 </p>
10206 !! end
10207
10208 !! test
10209 Magic Word: {{CURRENTDAYNAME}}
10210 !! wikitext
10211 {{CURRENTDAYNAME}}
10212 !! html
10213 <p>Thursday
10214 </p>
10215 !! end
10216
10217 !! test
10218 Magic Word: {{CURRENTDOW}}
10219 !! wikitext
10220 {{CURRENTDOW}}
10221 !! html
10222 <p>4
10223 </p>
10224 !! end
10225
10226 !! test
10227 Magic Word: {{CURRENTMONTH}}
10228 !! wikitext
10229 {{CURRENTMONTH}}
10230 !! html
10231 <p>01
10232 </p>
10233 !! end
10234
10235 !! test
10236 Magic Word: {{CURRENTMONTH1}}
10237 !! wikitext
10238 {{CURRENTMONTH1}}
10239 !! html
10240 <p>1
10241 </p>
10242 !! end
10243
10244 !! test
10245 Magic Word: {{CURRENTMONTHABBREV}}
10246 !! wikitext
10247 {{CURRENTMONTHABBREV}}
10248 !! html
10249 <p>Jan
10250 </p>
10251 !! end
10252
10253 !! test
10254 Magic Word: {{CURRENTMONTHNAME}}
10255 !! wikitext
10256 {{CURRENTMONTHNAME}}
10257 !! html
10258 <p>January
10259 </p>
10260 !! end
10261
10262 !! test
10263 Magic Word: {{CURRENTMONTHNAMEGEN}}
10264 !! wikitext
10265 {{CURRENTMONTHNAMEGEN}}
10266 !! html
10267 <p>January
10268 </p>
10269 !! end
10270
10271 !! test
10272 Magic Word: {{CURRENTTIME}}
10273 !! wikitext
10274 {{CURRENTTIME}}
10275 !! html
10276 <p>00:02
10277 </p>
10278 !! end
10279
10280 !! test
10281 Magic Word: {{CURRENTHOUR}}
10282 !! wikitext
10283 {{CURRENTHOUR}}
10284 !! html
10285 <p>00
10286 </p>
10287 !! end
10288
10289 !! test
10290 Magic Word: {{CURRENTWEEK}} (T6594)
10291 !! wikitext
10292 {{CURRENTWEEK}}
10293 !! html
10294 <p>1
10295 </p>
10296 !! end
10297
10298 !! test
10299 Magic Word: {{CURRENTYEAR}}
10300 !! wikitext
10301 {{CURRENTYEAR}}
10302 !! html
10303 <p>1970
10304 </p>
10305 !! end
10306
10307 !! test
10308 Magic Word: {{CURRENTTIMESTAMP}}
10309 !! wikitext
10310 {{CURRENTTIMESTAMP}}
10311 !! html
10312 <p>19700101000203
10313 </p>
10314 !! end
10315
10316 !! test
10317 Magic Words LOCAL (UTC)
10318 !! wikitext
10319 *{{LOCALMONTH}}
10320 *{{LOCALMONTH1}}
10321 *{{LOCALMONTHNAME}}
10322 *{{LOCALMONTHNAMEGEN}}
10323 *{{LOCALMONTHABBREV}}
10324 *{{LOCALDAY}}
10325 *{{LOCALDAY2}}
10326 *{{LOCALDAYNAME}}
10327 *{{LOCALYEAR}}
10328 *{{LOCALTIME}}
10329 *{{LOCALHOUR}}
10330 *{{LOCALWEEK}}
10331 *{{LOCALDOW}}
10332 *{{LOCALTIMESTAMP}}
10333 !! html
10334 <ul><li>01</li>
10335 <li>1</li>
10336 <li>January</li>
10337 <li>January</li>
10338 <li>Jan</li>
10339 <li>1</li>
10340 <li>01</li>
10341 <li>Thursday</li>
10342 <li>1970</li>
10343 <li>00:02</li>
10344 <li>00</li>
10345 <li>1</li>
10346 <li>4</li>
10347 <li>19700101000203</li></ul>
10348
10349 !! end
10350
10351 !! test
10352 Magic Word: {{FULLPAGENAME}}
10353 !! options
10354 title=[[User:Ævar Arnfjörð Bjarmason]]
10355 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10356 !! wikitext
10357 {{FULLPAGENAME}}
10358 !! html/*
10359 <p>User:Ævar Arnfjörð Bjarmason
10360 </p>
10361 !! end
10362
10363 !! test
10364 Magic Word: {{FULLPAGENAMEE}}
10365 !! options
10366 title=[[User:Ævar Arnfjörð Bjarmason]]
10367 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10368 !! wikitext
10369 {{FULLPAGENAMEE}}
10370 !! html/*
10371 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10372 </p>
10373 !! end
10374
10375 !! test
10376 Magic Word: {{TALKSPACE}}
10377 !! options
10378 title=[[User:Ævar Arnfjörð Bjarmason]]
10379 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10380 !! wikitext
10381 {{TALKSPACE}}
10382 !! html/*
10383 <p>User talk
10384 </p>
10385 !! end
10386
10387 !! test
10388 Magic Word: {{TALKSPACE}}, same namespace
10389 !! options
10390 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10391 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10392 !! wikitext
10393 {{TALKSPACE}}
10394 !! html/*
10395 <p>User talk
10396 </p>
10397 !! end
10398
10399 !! test
10400 Magic Word: {{TALKSPACE}}, main namespace
10401 !! options
10402 title=[[Parser Test]]
10403 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10404 !! wikitext
10405 {{TALKSPACE}}
10406 !! html/*
10407 <p>Talk
10408 </p>
10409 !! end
10410
10411 !! test
10412 Magic Word: {{TALKSPACEE}}
10413 !! options
10414 title=[[User:Ævar Arnfjörð Bjarmason]]
10415 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10416 !! wikitext
10417 {{TALKSPACEE}}
10418 !! html/*
10419 <p>User_talk
10420 </p>
10421 !! end
10422
10423 !! test
10424 Magic Word: {{SUBJECTSPACE}}
10425 !! options
10426 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10427 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10428 !! wikitext
10429 {{SUBJECTSPACE}}
10430 !! html/*
10431 <p>User
10432 </p>
10433 !! end
10434
10435 !! test
10436 Magic Word: {{SUBJECTSPACE}}, same namespace
10437 !! options
10438 title=[[User:Ævar Arnfjörð Bjarmason]]
10439 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10440 !! wikitext
10441 {{SUBJECTSPACE}}
10442 !! html/*
10443 <p>User
10444 </p>
10445 !! end
10446
10447 !! test
10448 Magic Word: {{SUBJECTSPACE}}, main namespace
10449 !! options
10450 title=[[Parser Test]]
10451 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10452 !! wikitext
10453 {{SUBJECTSPACE}}
10454 !! html/*
10455
10456 !! end
10457
10458 !! test
10459 Magic Word: {{SUBJECTSPACEE}}
10460 !! options
10461 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10462 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10463 !! wikitext
10464 {{SUBJECTSPACEE}}
10465 !! html/*
10466 <p>User
10467 </p>
10468 !! end
10469
10470 !! test
10471 Magic Word: {{NAMESPACE}}
10472 !! options
10473 title=[[User:Ævar Arnfjörð Bjarmason]]
10474 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10475 !! wikitext
10476 {{NAMESPACE}}
10477 !! html/*
10478 <p>User
10479 </p>
10480 !! end
10481
10482 !! test
10483 Magic Word: {{NAMESPACEE}}
10484 !! options
10485 title=[[User:Ævar Arnfjörð Bjarmason]]
10486 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10487 !! wikitext
10488 {{NAMESPACEE}}
10489 !! html/*
10490 <p>User
10491 </p>
10492 !! end
10493
10494 !! test
10495 Magic Word: {{NAMESPACENUMBER}}
10496 !! options
10497 title=[[User:Ævar Arnfjörð Bjarmason]]
10498 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10499 !! wikitext
10500 {{NAMESPACENUMBER}}
10501 !! html/*
10502 <p>2
10503 </p>
10504 !! end
10505
10506 !! test
10507 Magic Word: {{SUBPAGENAME}}
10508 !! options
10509 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10510 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10511 !! wikitext
10512 {{SUBPAGENAME}}
10513 !! html/*
10514 <p>sub ö
10515 </p>
10516 !! end
10517
10518 !! test
10519 Magic Word: {{SUBPAGENAMEE}}
10520 !! options
10521 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10522 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10523 !! wikitext
10524 {{SUBPAGENAMEE}}
10525 !! html/*
10526 <p>sub_%C3%B6
10527 </p>
10528 !! end
10529
10530 !! test
10531 Magic Word: {{ROOTPAGENAME}}
10532 !! options
10533 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10534 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10535 !! wikitext
10536 {{ROOTPAGENAME}}
10537 !! html/*
10538 <p>Ævar Arnfjörð Bjarmason
10539 </p>
10540 !! end
10541
10542 !! test
10543 Magic Word: {{ROOTPAGENAMEE}}
10544 !! options
10545 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10546 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10547 !! wikitext
10548 {{ROOTPAGENAMEE}}
10549 !! html/*
10550 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10551 </p>
10552 !! end
10553
10554 !! test
10555 Magic Word: {{BASEPAGENAME}}
10556 !! options
10557 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10558 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10559 !! wikitext
10560 {{BASEPAGENAME}}
10561 !! html/*
10562 <p>Ævar Arnfjörð Bjarmason
10563 </p>
10564 !! end
10565
10566 !! test
10567 Magic Word: {{BASEPAGENAMEE}}
10568 !! options
10569 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10570 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10571 !! wikitext
10572 {{BASEPAGENAMEE}}
10573 !! html/*
10574 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10575 </p>
10576 !! end
10577
10578 !! test
10579 Magic Word: {{TALKPAGENAME}}
10580 !! options
10581 title=[[User:Ævar Arnfjörð Bjarmason]]
10582 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10583 !! wikitext
10584 {{TALKPAGENAME}}
10585 !! html/*
10586 <p>User talk:Ævar Arnfjörð Bjarmason
10587 </p>
10588 !! end
10589
10590 !! test
10591 Magic Word: {{TALKPAGENAMEE}}
10592 !! options
10593 title=[[User:Ævar Arnfjörð Bjarmason]]
10594 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10595 !! wikitext
10596 {{TALKPAGENAMEE}}
10597 !! html/*
10598 <p>User_talk:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10599 </p>
10600 !! end
10601
10602 !! test
10603 Magic Word: {{SUBJECTPAGENAME}}
10604 !! options
10605 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10606 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10607 !! wikitext
10608 {{SUBJECTPAGENAME}}
10609 !! html/*
10610 <p>User:Ævar Arnfjörð Bjarmason
10611 </p>
10612 !! end
10613
10614 !! test
10615 Magic Word: {{SUBJECTPAGENAMEE}}
10616 !! options
10617 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10618 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10619 !! wikitext
10620 {{SUBJECTPAGENAMEE}}
10621 !! html/*
10622 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10623 </p>
10624 !! end
10625
10626 !! test
10627 Magic Word: {{NUMBEROFFILES}}
10628 !! options
10629 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10630 !! wikitext
10631 {{NUMBEROFFILES}}
10632 !! html/*
10633 <p>7
10634 </p>
10635 !! end
10636
10637 !! test
10638 Magic Word: {{PAGENAME}}
10639 !! options
10640 title=[[User:Ævar Arnfjörð Bjarmason]]
10641 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10642 !! wikitext
10643 {{PAGENAME}}
10644 !! html/*
10645 <p>Ævar Arnfjörð Bjarmason
10646 </p>
10647 !! end
10648
10649 !! test
10650 Magic Word: {{PAGENAME}} with metacharacters
10651 !! options
10652 title=[['foo & bar = baz']]
10653 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10654 !! wikitext
10655 ''{{PAGENAME}}''
10656 !! html+tidy
10657 <p><i>&#39;foo &#38; bar &#61; baz&#39;</i>
10658 </p>
10659 !! end
10660
10661 !! test
10662 Magic Word: {{PAGENAME}} with metacharacters (T28781)
10663 !! options
10664 title=[[*RFC 1234 http://example.com/]]
10665 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10666 !! wikitext
10667 {{PAGENAME}}
10668 !! html+tidy
10669 <p>&#42;RFC&#32;1234 http&#58;//example.com/
10670 </p>
10671 !! end
10672
10673 !! test
10674 Magic Word: {{PAGENAMEE}}
10675 !! options
10676 title=[[User:Ævar Arnfjörð Bjarmason]]
10677 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10678 !! wikitext
10679 {{PAGENAMEE}}
10680 !! html/*
10681 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10682 </p>
10683 !! end
10684
10685 !! test
10686 Magic Word: {{PAGENAMEE}} with metacharacters (T28781)
10687 !! options
10688 title=[[*RFC 1234 http://example.com/]]
10689 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10690 !! wikitext
10691 {{PAGENAMEE}}
10692 !! html+tidy
10693 <p>&#42;RFC_1234_http&#58;//example.com/
10694 </p>
10695 !! end
10696
10697 !! test
10698 Magic Word: {{REVISIONID}}
10699 !! options
10700 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10701 showflags
10702 !! wikitext
10703 {{REVISIONID}}
10704 !! html/*
10705 <p>1337
10706 </p>
10707 flags=vary-revision-id
10708 !! end
10709
10710 !! test
10711 Magic Word: {{SCRIPTPATH}}
10712 !! options
10713 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10714 !! wikitext
10715 {{SCRIPTPATH}}
10716 !! html/*
10717
10718 !! end
10719
10720 !! test
10721 Magic Word: {{STYLEPATH}}
10722 !! options
10723 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10724 !! wikitext
10725 {{STYLEPATH}}
10726 !! html/*
10727 <p>/skins
10728 </p>
10729 !! end
10730
10731 !! test
10732 Magic Word: {{SERVER}}
10733 !! options
10734 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10735 !! wikitext
10736 {{SERVER}}
10737 !! html/*
10738 <p><a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10739 </p>
10740 !! end
10741
10742 !! test
10743 Magic Word: {{SERVERNAME}}
10744 !! options
10745 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10746 !! wikitext
10747 {{SERVERNAME}}
10748 !! html/*
10749 <p>example.org
10750 </p>
10751 !! end
10752
10753 !! test
10754 Magic Word: {{SITENAME}}
10755 !! options
10756 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10757 !! wikitext
10758 {{SITENAME}}
10759 !! html/*
10760 <p>MediaWiki
10761 </p>
10762 !! end
10763
10764 !! test
10765 Magic Word: {{PAGELANGUAGE}}
10766 !! options
10767 language=fr
10768 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10769 !! wikitext
10770 {{PAGELANGUAGE}}
10771 !! html/*
10772 <p>fr
10773 </p>
10774 !! end
10775
10776 !! test
10777 Magic Word: {{PAGELANGUAGE}} on a page with no explicitly set language
10778 !! options
10779 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10780 !! wikitext
10781 {{PAGELANGUAGE}}
10782 !! html/*
10783 <p>en
10784 </p>
10785 !! end
10786
10787 !! test
10788 Case-sensitive magic words, when cased differently, should just be template transclusions
10789 !! wikitext
10790 {{CurrentMonth}}
10791 {{currentday}}
10792 {{cURreNTweEK}}
10793 {{currentHour}}
10794 !! html
10795 <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>
10796 <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>
10797 <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>
10798 <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>
10799 </p>
10800 !! end
10801
10802 !! test
10803 Case-insensitive magic words should still work with weird casing.
10804 !! wikitext
10805 {{sErVeRNaMe}}
10806 {{LCFirst:AOEU}}
10807 {{ucFIRST:aoeu}}
10808 {{SERver}}
10809 !! html
10810 <p>example.org
10811 aOEU
10812 Aoeu
10813 <a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10814 </p>
10815 !! end
10816
10817 # From plwiki:PLOS_ONE
10818 !! test
10819 Parsoid: Page property magic word with magic word contents
10820 !! wikitext
10821 {{DISPLAYTITLE:''{{PAGENAME}}''}}
10822 !! html/parsoid
10823 <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>"}]]}'/>
10824 !! end
10825
10826 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
10827 # But, this is a limitation of our representation and is documented in
10828 # TemplateHandler.js in processSpecialMagicWord
10829 !! test
10830 Parsoid: Template-generated DISPLAYTITLE
10831 !! wikitext
10832 {{{{echo|DISPLAYTITLE}}:Foo}}
10833 !! options
10834 showtitle
10835 !! config
10836 wgAllowDisplayTitle=true
10837 wgRestrictDisplayTitle=false
10838 !! html/php
10839 Foo
10840
10841 !! html/parsoid
10842 <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"}]]}'/>
10843 !! end
10844
10845 !! test
10846 Namespace 1 {{ns:1}}
10847 !! wikitext
10848 {{ns:1}}
10849 !! html
10850 <p>Talk
10851 </p>
10852 !! end
10853
10854 !! test
10855 Namespace 1 {{ns:01}}
10856 !! wikitext
10857 {{ns:01}}
10858 !! html
10859 <p>Talk
10860 </p>
10861 !! end
10862
10863 !! test
10864 Namespace 0 {{ns:0}} (T6783)
10865 !! wikitext
10866 {{ns:0}}
10867 !! html
10868
10869 !! end
10870
10871 !! test
10872 Namespace 0 {{ns:00}} (T6783)
10873 !! wikitext
10874 {{ns:00}}
10875 !! html
10876
10877 !! end
10878
10879 !! test
10880 Namespace -1 {{ns:-1}}
10881 !! wikitext
10882 {{ns:-1}}
10883 !! html
10884 <p>Special
10885 </p>
10886 !! end
10887
10888 !! test
10889 Namespace User {{ns:User}}
10890 !! wikitext
10891 {{ns:User}}
10892 !! html
10893 <p>User
10894 </p>
10895 !! end
10896
10897 !! test
10898 Namespace User talk {{ns:User_talk}}
10899 !! wikitext
10900 {{ns:User_talk}}
10901 !! html
10902 <p>User talk
10903 </p>
10904 !! end
10905
10906 !! test
10907 Namespace User talk {{ns:uSeR tAlK}}
10908 !! wikitext
10909 {{ns:uSeR tAlK}}
10910 !! html
10911 <p>User talk
10912 </p>
10913 !! end
10914
10915 !! test
10916 Namespace File {{ns:File}}
10917 !! wikitext
10918 {{ns:File}}
10919 !! html
10920 <p>File
10921 </p>
10922 !! end
10923
10924 !! test
10925 Namespace File {{ns:Image}}
10926 !! wikitext
10927 {{ns:Image}}
10928 !! html
10929 <p>File
10930 </p>
10931 !! end
10932
10933 !! test
10934 Namespace (lang=de) Benutzer {{ns:User}}
10935 !! options
10936 language=de
10937 !! wikitext
10938 {{ns:User}}
10939 !! html
10940 <p>Benutzer
10941 </p>
10942 !! end
10943
10944 !! test
10945 Namespace (lang=de) Benutzer Diskussion {{ns:3}}
10946 !! options
10947 language=de
10948 !! wikitext
10949 {{ns:3}}
10950 !! html
10951 <p>Benutzer Diskussion
10952 </p>
10953 !! end
10954
10955 !! test
10956 Urlencode
10957 !! wikitext
10958 {{urlencode:hi world?!}}
10959 {{urlencode:hi world?!|WIKI}}
10960 {{urlencode:hi world?!|PATH}}
10961 {{urlencode:hi world?!|QUERY}}
10962 !! html/php
10963 <p>hi+world%3F%21
10964 hi_world%3F!
10965 hi%20world%3F%21
10966 hi+world%3F%21
10967 </p>
10968 !! end
10969
10970 !! test
10971 Magic Word: prioritize type info over data-parsoid
10972 !! options
10973 parsoid=html2wt
10974 !! html/parsoid
10975 <meta property="mw:PageProp/forcetoc" data-parsoid='{"magicSrc":"__NOTOC__"}'/>
10976 !! wikitext
10977 __FORCETOC__
10978 !! end
10979
10980 !! test
10981 Magic Word: serialize on separate line (parsoid)
10982 !! options
10983 parsoid=wt2wt,html2wt
10984 !! wikitext
10985 foo
10986 __NOTOC__
10987 bar
10988 !! html/parsoid
10989 foo<meta property="mw:PageProp/notoc"/>bar
10990 !! end
10991
10992 !! test
10993 Magic Word: rt non-english wikis
10994 !! options
10995 parsoid=wt2wt
10996 language=de
10997 !! wikitext
10998 __NOEDITSECTION__
10999 !! html/parsoid
11000 <meta property="mw:PageProp/noeditsection" data-parsoid='{"magicSrc":"__NOEDITSECTION__"}'/>
11001 !! end
11002
11003 !!test
11004 __proto__ is treated as normal wikitext (T105997)
11005 !!wikitext
11006 __proto__
11007 !!html
11008 <p>__proto__
11009 </p>
11010 !!end
11011
11012 ###
11013 ### Magic links
11014 ###
11015 !! test
11016 Magic links: internal link to RFC (T2479)
11017 !! wikitext
11018 [[RFC 123]]
11019 !! html/php
11020 <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>
11021 </p>
11022 !! html/parsoid
11023 <p><a rel="mw:WikiLink" href="./RFC_123" title="RFC 123">RFC 123</a></p>
11024 !! end
11025
11026 !! test
11027 Magic links: RFC (T2479)
11028 !! wikitext
11029 RFC 822
11030 !! html/php
11031 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
11032 </p>
11033 !! html/parsoid
11034 <p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external mw-magiclink">RFC 822</a></p>
11035 !! end
11036
11037 !! test
11038 Magic links: RFC (T67278)
11039 !! wikitext
11040 This is RFC 822 but thisRFC 822 is not RFC 822linked.
11041 !! html/php
11042 <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.
11043 </p>
11044 !! html/parsoid
11045 <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>
11046 !! end
11047
11048 !! test
11049 Magic links: RFC (w/ non-newline whitespace, T30950/T31025)
11050 !! wikitext
11051 RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 822
11052 RFC
11053 822
11054 !! html/php
11055 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
11056 RFC
11057 822
11058 </p>
11059 !! html/parsoid
11060 <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>
11061 RFC
11062 822</p>
11063 !! end
11064
11065 !! test
11066 Magic links: ISBN (T3937)
11067 !! wikitext
11068 ISBN 0-306-40615-2
11069 !! html/php
11070 <p><a href="/wiki/Special:BookSources/0306406152" class="internal mw-magiclink-isbn">ISBN 0-306-40615-2</a>
11071 </p>
11072 !! html/parsoid
11073 <p><a href="./Special:BookSources/0306406152" rel="mw:WikiLink">ISBN 0-306-40615-2</a></p>
11074 !! end
11075
11076 !! test
11077 Magic links: ISBN (T67278)
11078 !! wikitext
11079 This is ISBN 978-0-316-09811-3 but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.
11080 !! html/php
11081 <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.
11082 </p>
11083 !! html/parsoid
11084 <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>
11085 !! end
11086
11087 !! test
11088 Magic links: ISBN (w/ non-newline whitespace, T30950/T31025)
11089 !! wikitext
11090 ISBN &nbsp;&#160;&#0160;&#xA0;&#Xa0; 978&nbsp;0&#160;316&#0160;09811&#xA0;3
11091 ISBN
11092 9780316098113
11093 ISBN 978
11094 0316098113
11095 !! html/php
11096 <p><a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978 0 316 09811 3</a>
11097 ISBN
11098 9780316098113
11099 ISBN 978
11100 0316098113
11101 </p>
11102 !! html/parsoid
11103 <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>
11104 ISBN
11105 9780316098113
11106 ISBN 978
11107 0316098113</p>
11108 !! end
11109
11110 !! test
11111 Magic links: PMID incorrectly converts space to underscore
11112 !! wikitext
11113 PMID 1234
11114 !! html/php
11115 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11116 </p>
11117 !! html/parsoid
11118 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external mw-magiclink">PMID 1234</a></p>
11119 !! end
11120
11121 !! test
11122 Magic links: PMID (T67278)
11123 !! wikitext
11124 This is PMID 1234 but thisPMID 1234 is not PMID 1234linked.
11125 !! html/php
11126 <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.
11127 </p>
11128 !! html/parsoid
11129 <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>
11130 !! end
11131
11132 !! test
11133 Magic links: PMID (w/ non-newline whitespace, T30950/T31025)
11134 !! wikitext
11135 PMID &nbsp;&#160;&#0160;&#xA0;&#Xa0; 1234
11136 PMID
11137 1234
11138 !! html/php
11139 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11140 PMID
11141 1234
11142 </p>
11143 !! html/parsoid
11144 <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>
11145 PMID
11146 1234</p>
11147 !! end
11148
11149 # <nowiki> nodes shouldn't be inserted during html2wt by Parsoid,
11150 # since these are ExtLinkText, not MagicLinkText
11151 !! test
11152 Magic links: use appropriate serialization for "almost" magic links.
11153 !! wikitext
11154 X[[Special:BookSources/0978739256|foo]]
11155
11156 X[https://tools.ietf.org/html/rfc1234 foo]
11157 !! html/php
11158 <p>X<a href="/wiki/Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a>
11159 </p><p>X<a rel="nofollow" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a>
11160 </p>
11161 !! html/parsoid
11162 <p>X<a rel="mw:WikiLink" href="./Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a></p>
11163 <p>X<a rel="mw:ExtLink" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a></p>
11164 !! end
11165
11166 !! test
11167 Magic links: All disabled (T47942)
11168 !! options
11169 wgEnableMagicLinks={"ISBN":false, "PMID":false, "RFC":false}
11170 !! wikitext
11171 ISBN 0-306-40615-2
11172 PMID 1234
11173 RFC 4321
11174 !! html/php
11175 <p>ISBN 0-306-40615-2
11176 PMID 1234
11177 RFC 4321
11178 </p>
11179 !! end
11180
11181 ###
11182 ### Templates
11183 ####
11184
11185 !! test
11186 Nonexistent template
11187 !! wikitext
11188 {{thistemplatedoesnotexist}}
11189 !! html
11190 <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>
11191 </p>
11192 !! end
11193
11194 !! test
11195 Template with invalid target containing tags
11196 !! wikitext
11197 {{a<b>b</b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11198 !! html
11199 <p>{{a<b>b</b>|foo|a=b|a = b}}
11200 </p>
11201 !! end
11202
11203 !! test
11204 Template with invalid target containing unclosed tag
11205 !! wikitext
11206 {{a<b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11207 !! html
11208 <p>{{a<b>|foo|a=b|a = b}}</b>
11209 </p>
11210 !! end
11211
11212 !! test
11213 Template with invalid target containing wikilink
11214 !! wikitext
11215 {{[[Main Page]]}}
11216 !! html/php
11217 <p>{{<a href="/wiki/Main_Page" title="Main Page">Main Page</a>}}
11218 </p>
11219 !! html/parsoid
11220 <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>
11221 !! end
11222
11223 !! test
11224 Template with just whitespace in it, T70421
11225 !! wikitext
11226 {{echo|{{ }}}}
11227 !! html/parsoid
11228 <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>
11229 !! end
11230
11231 !! article
11232 Template:test
11233 !! text
11234 This is a test template
11235 !! endarticle
11236
11237 !! test
11238 Simple template
11239 !! wikitext
11240 {{test}}
11241 !! html
11242 <p>This is a test template
11243 </p>
11244 !! end
11245
11246 !! test
11247 Template with explicit namespace
11248 !! wikitext
11249 {{Template:test}}
11250 !! html
11251 <p>This is a test template
11252 </p>
11253 !! end
11254
11255
11256 !! article
11257 Template:paramtest
11258 !! text
11259 This is a test template with parameter {{{param}}}
11260 !! endarticle
11261
11262 !! test
11263 Template parameter
11264 !! wikitext
11265 {{paramtest|param=foo}}
11266 !! html
11267 <p>This is a test template with parameter foo
11268 </p>
11269 !! end
11270
11271 !! article
11272 Template:paramtestnum
11273 !! text
11274 [[{{{1}}}|{{{2}}}]]
11275 !! endarticle
11276
11277 !! test
11278 Template unnamed parameter
11279 !! wikitext
11280 {{paramtestnum|Main Page|the main page}}
11281 !! html
11282 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
11283 </p>
11284 !! end
11285
11286 !! article
11287 Template:templatesimple
11288 !! text
11289 (test)
11290 !! endarticle
11291
11292 !! article
11293 Template:templateredirect
11294 !! text
11295 #redirect [[Template:templatesimple]]
11296 !! endarticle
11297
11298 !! article
11299 Template:templateasargtestnum
11300 !! text
11301 {{{{{1}}}}}
11302 !! endarticle
11303
11304 !! article
11305 Template:templateasargtest
11306 !! text
11307 {{template{{{templ}}}}}
11308 !! endarticle
11309
11310 !! article
11311 Template:templateasargtest2
11312 !! text
11313 {{{{{templ}}}}}
11314 !! endarticle
11315
11316 !! test
11317 Template with template name as unnamed argument
11318 !! wikitext
11319 {{templateasargtestnum|templatesimple}}
11320 !! html
11321 <p>(test)
11322 </p>
11323 !! end
11324
11325 !! test
11326 Template with template name as argument
11327 !! wikitext
11328 {{templateasargtest|templ=simple}}
11329 !! html
11330 <p>(test)
11331 </p>
11332 !! end
11333
11334 !! test
11335 Template with template name as argument (2)
11336 !! wikitext
11337 {{templateasargtest2|templ=templatesimple}}
11338 !! html
11339 <p>(test)
11340 </p>
11341 !! end
11342
11343 !! article
11344 Template:templateasargtestdefault
11345 !! text
11346 {{{{{templ|templatesimple}}}}}
11347 !! endarticle
11348
11349 !! article
11350 Template:templa
11351 !! text
11352 '''templ'''
11353 !! endarticle
11354
11355 !! test
11356 Template with default value
11357 !! wikitext
11358 {{templateasargtestdefault}}
11359 !! html
11360 <p>(test)
11361 </p>
11362 !! end
11363
11364 !! test
11365 Template with default value (value set)
11366 !! wikitext
11367 {{templateasargtestdefault|templ=templa}}
11368 !! html
11369 <p><b>templ</b>
11370 </p>
11371 !! end
11372
11373 !! test
11374 Template redirect
11375 !! wikitext
11376 {{templateredirect}}
11377 !! html/php
11378 <p>(test)
11379 </p>
11380 !! html/parsoid
11381 <link rel="mw:PageProp/redirect" href="./Template:Templatesimple" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"templateredirect","href":"./Template:Templateredirect"},"params":{},"i":0}}]}'/>
11382 !! end
11383
11384 !! test
11385 Template with argument in separate line
11386 !! wikitext
11387 {{ templateasargtest |
11388 templ = simple }}
11389 !! html
11390 <p>(test)
11391 </p>
11392 !! end
11393
11394 !! test
11395 Template with complex template as argument
11396 !! wikitext
11397 {{paramtest|
11398 param ={{ templateasargtest |
11399 templ = simple }}}}
11400 !! html
11401 <p>This is a test template with parameter (test)
11402 </p>
11403 !! end
11404
11405 !! test
11406 Templates with templated name
11407 !! wikitext
11408 {{{{echo|echo}}|foo}}
11409 {{{{echo|inner list}} }}
11410 !! html
11411 <p>foo
11412 </p>
11413 <ul><li>item 1</li></ul>
11414
11415 !! html/parsoid
11416 <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>
11417 <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>
11418 !! end
11419
11420 ## Regression test; the output here isn't really that interesting.
11421 !! test
11422 Templates with templated name and top level template args
11423 !! wikitext
11424 {{1{{2{{{3}}}|4=5}}}}
11425 !! html/parsoid
11426 <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>
11427 !! end
11428
11429 # Parsoid markup is deliberate "broken". This is an edge case.
11430 # See long comment in TemplateHandler.js:convertAttribsToString.
11431 !! test
11432 Templates with invalid templated targets
11433 !! wikitext
11434 {{echo
11435 {{echo|foo}}
11436 }}
11437 !! html/php
11438 <p>{{echo
11439 foo
11440 }}
11441 </p>
11442 !! html/parsoid
11443 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n{{echo|foo}}\n"},"params":{},"i":0}}]}'>{{echo
11444 foo }}</p>
11445 !! end
11446
11447 !! test
11448 Template with thumb image (with link in description)
11449 !! wikitext
11450 {{paramtest|param=[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
11451 !! html/php
11452 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>
11453
11454 !! html+tidy
11455 <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>
11456 !! html/parsoid
11457 <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>
11458 !! end
11459
11460 !! article
11461 Template:complextemplate
11462 !! text
11463 {{{1}}} {{paramtest|
11464 param ={{{param}}}}}
11465 !! endarticle
11466
11467 !! test
11468 Template with complex arguments
11469 !! wikitext
11470 {{complextemplate|
11471 param ={{ templateasargtest |
11472 templ = simple }}|[[Template:complextemplate|link]]}}
11473 !! html
11474 <p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test)
11475 </p>
11476 !! end
11477
11478 !! test
11479 T2553: link with two variables in a piped link
11480 !! wikitext
11481 {|
11482 |[[{{{1}}}|{{{2}}}]]
11483 |}
11484 !! html/php
11485 <table>
11486 <tr>
11487 <td>[[{{{1}}}|{{{2}}}]]
11488 </td></tr></table>
11489
11490 !! html/parsoid
11491 <table>
11492 <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>
11493 </tbody></table>
11494 !! end
11495
11496 # See: T2553
11497 !! test
11498 Abort table cell attribute parsing on wikilink
11499 !! wikitext
11500 {|
11501 |testing [[one|two]] |three||four
11502 |testing one two |three||four
11503 |testing="[[one|two]]" |three||four
11504 |}
11505 !! html/php
11506 <table>
11507 <tr>
11508 <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>
11509 <td>four
11510 </td>
11511 <td>three</td>
11512 <td>four
11513 </td>
11514 <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>
11515 <td>four
11516 </td></tr></table>
11517
11518 !! html/parsoid
11519 <table>
11520 <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>
11521 <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>
11522 <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>
11523 </tbody></table>
11524 !! end
11525
11526 !! test
11527 Don't abort table cell attribute parsing if wikilink is found in template arg
11528 !! wikitext
11529 {|
11530 |Test {{#tag:ref|One two "[[three]]" four}}
11531 |}
11532 !! html/parsoid
11533 <table>
11534 <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>
11535 </tbody></table>
11536 !! end
11537
11538 !! test
11539 Magic variable as template parameter
11540 !! wikitext
11541 {{paramtest|param={{SITENAME}}}}
11542 !! html
11543 <p>This is a test template with parameter MediaWiki
11544 </p>
11545 !! end
11546
11547 !! article
11548 Template:linktest
11549 !! text
11550 [[{{{param}}}|link]]
11551 !! endarticle
11552
11553 !! test
11554 Template parameter as link source
11555 !! wikitext
11556 {{linktest|param=Main Page}}
11557 !! html
11558 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
11559 </p>
11560 !! end
11561
11562 !!article
11563 Template:paramtest2
11564 !! text
11565 including another template, {{paramtest|param={{{arg}}}}}
11566 !! endarticle
11567
11568 !! test
11569 Template passing argument to another template
11570 !! wikitext
11571 {{paramtest2|arg='hmm'}}
11572 !! html
11573 <p>including another template, This is a test template with parameter 'hmm'
11574 </p>
11575 !! end
11576
11577 !! article
11578 Template:Linktest2
11579 !! text
11580 Main Page
11581 !! endarticle
11582
11583 !! test
11584 Template as link source
11585 !! wikitext
11586 [[{{linktest2}}]]
11587
11588 [[{{linktest2}}|Main Page]]
11589
11590 [[{{linktest2}}]]Page
11591 !! html
11592 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11593 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11594 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>Page
11595 </p>
11596 !! end
11597
11598
11599 !! article
11600 Template:loop1
11601 !! text
11602 {{loop2}}
11603 !! endarticle
11604
11605 !! article
11606 Template:loop2
11607 !! text
11608 {{loop1}}
11609 !! endarticle
11610
11611 !! test
11612 Template infinite loop
11613 !! wikitext
11614 {{loop1}}
11615 !! html
11616 <p><span class="error">Template loop detected: <a href="/wiki/Template:Loop1" title="Template:Loop1">Template:Loop1</a></span>
11617 </p>
11618 !! end
11619
11620 !! test
11621 Template from main namespace
11622 !! wikitext
11623 {{:Main Page}}
11624 !! html
11625 <p>blah blah
11626 </p>
11627 !! end
11628
11629 !! test
11630 Template from non-includable namespace
11631 !! options
11632 wgNonincludableNamespaces=10
11633 !! wikitext
11634 {{echo|uh oh!}}
11635 !! html
11636 <p><a href="/wiki/Template:Echo" title="Template:Echo">Template:Echo</a>
11637 </p>
11638 !! end
11639
11640 !! article
11641 Template:table
11642 !! text
11643 {|
11644 | 1 || 2
11645 |-
11646 | 3 || 4
11647 |}
11648 !! endarticle
11649
11650 !! test
11651 T2529: Template with table, not included at beginning of line
11652 !! wikitext
11653 foo {{table}}
11654 !! html
11655 <p>foo
11656 </p>
11657 <table>
11658 <tr>
11659 <td>1</td>
11660 <td>2
11661 </td></tr>
11662 <tr>
11663 <td>3</td>
11664 <td>4
11665 </td></tr></table>
11666
11667 !! end
11668
11669 !! test
11670 T2523: Template shouldn't eat newline (or add an extra one before table)
11671 !! wikitext
11672 foo
11673 {{table}}
11674 !! html
11675 <p>foo
11676 </p>
11677 <table>
11678 <tr>
11679 <td>1</td>
11680 <td>2
11681 </td></tr>
11682 <tr>
11683 <td>3</td>
11684 <td>4
11685 </td></tr></table>
11686
11687 !! end
11688
11689 !! test
11690 T2041: Template parameters shown as broken links
11691 !! wikitext
11692 {{{parameter}}}
11693 !! html
11694 <p>{{{parameter}}}
11695 </p>
11696 !! end
11697
11698 !! test
11699 Template with targets containing wikilinks
11700 !! options
11701 parsoid=wt2html
11702 !! wikitext
11703 {{[[foo]]}}
11704
11705 {{[[{{echo|foo}}]]}}
11706
11707 {{{{echo|[[foo}}]]}}
11708 !! html/php
11709 <p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11710 </p><p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11711 </p><p>{{[[foo}}]]
11712 </p>
11713 !! html/parsoid
11714 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">foo</a>}}</p>
11715 <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>
11716 <p>{{<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[foo}}]]"}},"i":0}}]}'>[[foo}}]]</span></p>
11717 !! end
11718
11719 !! article
11720 Template:''
11721 !! text
11722 bar
11723 !! endarticle
11724
11725 !! test
11726 Templates: Double quotes as template target
11727 !! wikitext
11728 foo {{''}} baz
11729 !! html/php
11730 <p>foo bar baz
11731 </p>
11732 !! html/parsoid
11733 <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
11734 </p>
11735 !! end
11736
11737 ## This test is about making sure Parsoid's data-mw is well formed in the
11738 ## face of multiple templates with intersecting and overlapping ranges. The
11739 ## wikitext itself is wretched.
11740 !! test
11741 Templates with intersecting and overlapping ranges
11742 !! wikitext
11743 {|{{echo|
11744 <p>ha</p>}}
11745 {|{{echo|
11746 <p>ho</p>}}
11747 {{echo|{{!}}hi}}
11748 |}
11749 !! html/php+tidy
11750 <p>ha</p><table>
11751
11752 </table><p>ho</p><table>
11753
11754 <tbody><tr>
11755 <td>hi
11756 </td></tr></tbody></table>
11757 !! html/parsoid
11758 <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":""}]]}'>
11759
11760 </table><p about="#mwt1">ho</p><table about="#mwt1" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"","html":""},{"html":""}]]}'>
11761
11762 <tbody><tr><td>hi</td></tr>
11763 </tbody></table>
11764 !! end
11765
11766 !! article
11767 Template:MSGNW test
11768 !! text
11769 ''None'' of '''this''' should be
11770 * interpreted
11771 but rather passed unmodified
11772 {{test}}
11773 <gallery>
11774 File:Foobar.jpg
11775 </gallery>
11776 <!-- comment -->
11777 !! endarticle
11778
11779 # hmm, fix this or just deprecate msgnw and document its behavior?
11780 !! test
11781 msgnw keyword
11782 !! wikitext
11783 {{msgnw:MSGNW test}}
11784 !! html/php
11785 <p>&#39;&#39;None&#39;&#39; of &#39;&#39;&#39;this&#39;&#39;&#39; should be
11786 &#42; interpreted
11787 &#32;but rather passed unmodified
11788 &#123;&#123;test&#125;&#125;
11789 &#60;gallery&#62;
11790 File:Foobar.jpg
11791 &#60;/gallery&#62;
11792 &#60;!-- comment --&#62;
11793 </p>
11794 !! end
11795
11796 !! test
11797 int keyword
11798 !! wikitext
11799 {{int:youhavenewmessages|lots of money|not!}}
11800 !! html
11801 <p>You have lots of money (not!).
11802 </p>
11803 !! end
11804
11805 !! test
11806 int keyword - non-existing message
11807 !! wikitext
11808 {{int:var}}
11809 !! html
11810 <p>⧼var⧽
11811 </p>
11812 !! end
11813
11814 !! article
11815 Template:Includes
11816 !! text
11817 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11818 !! endarticle
11819
11820 !! test
11821 <includeonly> and <noinclude> being included
11822 !! wikitext
11823 {{Includes}}
11824 !! html
11825 <p>Foobar
11826 </p>
11827 !! end
11828
11829 !! article
11830 Template:Includes2
11831 !! text
11832 <onlyinclude>Foo</onlyinclude>bar
11833 !! endarticle
11834
11835 !! test
11836 <onlyinclude> being included
11837 !! wikitext
11838 {{Includes2}}
11839 !! html
11840 <p>Foo
11841 </p>
11842 !! end
11843
11844
11845 !! article
11846 Template:Includes3
11847 !! text
11848 <onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly>
11849 !! endarticle
11850
11851 !! test
11852 <onlyinclude> and <includeonly> being included
11853 !! wikitext
11854 {{Includes3}}
11855 !! html
11856 <p>Foo
11857 </p>
11858 !! end
11859
11860 !! test
11861 <includeonly> and <noinclude> on a page
11862 !! wikitext
11863 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11864 !! html
11865 <p>Foozar
11866 </p>
11867 !! end
11868
11869 !! test
11870 Un-closed <noinclude>
11871 !! wikitext
11872 <noinclude>
11873 !! html
11874 !! end
11875
11876 !! test
11877 <onlyinclude> on a page
11878 !! wikitext
11879 <onlyinclude>Foo</onlyinclude>bar
11880 !! html
11881 <p>Foobar
11882 </p>
11883 !! end
11884
11885 !! test
11886 Un-closed <onlyinclude>
11887 !! wikitext
11888 <onlyinclude>
11889 !! html
11890 !! end
11891
11892 !!test
11893 Self-closed noinclude, includeonly, onlyinclude tags
11894 !! wikitext
11895 <noinclude />
11896 <includeonly />
11897 <onlyinclude />
11898 !! html
11899 <p><br />
11900 </p>
11901 !!end
11902
11903 !!test
11904 Unbalanced includeonly and noinclude tags
11905 !! wikitext
11906 {|
11907 |a</noinclude>
11908 |b</noinclude></noinclude>
11909 |c</noinclude></includeonly>
11910 |d</includeonly></includeonly>
11911 |}
11912 !! html
11913 <table>
11914 <tr>
11915 <td>a
11916 </td>
11917 <td>b
11918 </td>
11919 <td>c&lt;/includeonly&gt;
11920 </td>
11921 <td>d&lt;/includeonly&gt;&lt;/includeonly&gt;
11922 </td></tr></table>
11923
11924 !!end
11925
11926 !! article
11927 Template:Includeonly section
11928 !! text
11929 <includeonly>
11930 ==Includeonly section==
11931 </includeonly>
11932 ==Section T-1==
11933 !!endarticle
11934
11935 !! test
11936 T8563: Edit link generation for section shown by <includeonly>
11937 !! wikitext
11938 {{includeonly section}}
11939 !! html
11940 <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>
11941 <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>
11942
11943 !! end
11944
11945 # Uses same input as the contents of [[Template:Includeonly section]]
11946 !! test
11947 T8563: Section extraction for section shown by <includeonly>
11948 !! options
11949 section=T-2
11950 !! wikitext
11951 <includeonly>
11952 ==Includeonly section==
11953 </includeonly>
11954 ==Section T-2==
11955 !! html
11956 ==Section T-2==
11957 !! end
11958
11959 !! test
11960 T8563: Edit link generation for section suppressed by <includeonly>
11961 !! wikitext
11962 <includeonly>
11963 ==Includeonly section==
11964 </includeonly>
11965 ==Section 1==
11966 !! html
11967 <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>
11968
11969 !! end
11970
11971 !! test
11972 T8563: Section extraction for section suppressed by <includeonly>
11973 !! options
11974 section=1
11975 !! wikitext
11976 <includeonly>
11977 ==Includeonly section==
11978 </includeonly>
11979 ==Section 1==
11980 !! html
11981 ==Section 1==
11982 !! end
11983
11984 !! test
11985 Un-closed <includeonly>
11986 !! wikitext
11987 <includeonly>
11988 !! html/php
11989 !! html/parsoid
11990 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>"}'/>
11991 !! end
11992
11993 ## We used to, but no longer wt2wt this test since the default serializer
11994 ## will normalize the include directives to serialize on their own line.
11995 ## Selser will take care of preserving formatting in scenarios where they
11996 ## intermingled with other wikitext.
11997 !! test
11998 Includes and comments at SOL
11999 !! options
12000 parsoid=wt2html,html2html
12001 !! wikitext
12002 <!-- comment --><noinclude><!-- comment --></noinclude><!-- comment -->==hu==
12003
12004 <noinclude>
12005 some
12006 </noinclude>*stuff
12007 *here
12008
12009 <includeonly>can have stuff</includeonly>===here===
12010
12011 !! html/php
12012 <h2><span class="mw-headline" id="hu">hu</span></h2>
12013 <p>some
12014 </p>
12015 <ul><li>stuff</li>
12016 <li>here</li></ul>
12017 <h3><span class="mw-headline" id="here">here</span></h3>
12018
12019 !! html/parsoid
12020 <!-- 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>
12021
12022 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
12023 <p>some</p>
12024 <meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/><ul><li>stuff</li>
12025 <li>here</li></ul>
12026
12027 <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>
12028
12029 !! end
12030
12031 # TODO: test with DOM fragment reuse!
12032 !! test
12033 Parsoid: DOM fragment reuse
12034 !! options
12035 parsoid=wt2wt,wt2html
12036 !! wikitext
12037 a{{echo|b<table></table>c}}d
12038
12039 a{{echo|b
12040 <table></table>
12041 c}}d
12042
12043 {{echo|a
12044
12045 <table></table>
12046
12047 b}}
12048 !! html
12049 <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>
12050
12051 <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">
12052 </span><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><span about="#mwt2">
12053 </span><p about="#mwt2">cd</p>
12054
12055 <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">
12056
12057 </span><table about="#mwt3" data-parsoid='{"stx":"html"}'></table><span about="#mwt3">
12058
12059 </span><p about="#mwt3">b</p>
12060 !! end
12061
12062 !! test
12063 Parsoid: Merge double tds (T52603)
12064 !! options
12065 parsoid
12066 !! wikitext
12067 {|
12068 |{{echo|{{!}} foo}}
12069 |}
12070 !! html
12071 <table><tbody>
12072 <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>
12073 </tbody></table>
12074 !! end
12075
12076 !! test
12077 Parsoid: Merge double tds in nested transclusion content (T52603)
12078 !! options
12079 parsoid
12080 !! wikitext
12081 {{echo|<div>}}
12082 {|
12083 |{{echo|{{!}} foo}}
12084 |}
12085 {{echo|</div>}}
12086 !! html
12087 <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}}]}'>
12088 <table><tbody>
12089 <tr><td data-mw='{"parts":["|"]}'> foo</td></tr>
12090 </tbody></table>
12091 </div>
12092 !! end
12093
12094 ###
12095 ### <includeonly> and <noinclude> in attributes
12096 ###
12097 !!test
12098 0. includeonly around the entire attribute
12099 !! wikitext
12100 <span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
12101 !! html
12102 <p><span id="v2">bar</span>
12103 </p>
12104 !!end
12105
12106 !!test
12107 1. includeonly in html attr key
12108 !! wikitext
12109 <span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
12110 !! html
12111 <p><span id="foo">bar</span>
12112 </p>
12113 !!end
12114
12115 !!test
12116 2. includeonly in html attr value
12117 !! wikitext
12118 <span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
12119 <span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
12120 !! html
12121 <p><span id="v1">bar</span>
12122 <span id="v1">bar</span>
12123 </p>
12124 !!end
12125
12126 !!test
12127 3. includeonly in part of an attr value
12128 !! wikitext
12129 <span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
12130 !! html
12131 <p><span style="color:red;">bar</span>
12132 </p>
12133 !!end
12134
12135 !!test
12136 4. includeonly in table attributes
12137 !! wikitext
12138 {|
12139 |- <noinclude>
12140 |-
12141 |a
12142 </noinclude>
12143 |- <includeonly>
12144 |-
12145 |b
12146 </includeonly>
12147 |}
12148 !! html
12149 <table>
12150
12151
12152 <tr>
12153 <td>a
12154 </td></tr>
12155 </table>
12156
12157 !!end
12158
12159 ###
12160 ### Preprocessor precedence tests
12161 ### See: https://www.mediawiki.org/wiki/Preprocessor_ABNF
12162 ###
12163 ##{{[[-{{{{{{[[Foo|bar}}]]}-}}}}}]]
12164 !! test
12165 Preprocessor precedence 1: link is rightmost opening
12166 !! options
12167 parsoid=wt2html
12168 !! wikitext
12169 {{[[Foo|bar}}]]
12170
12171 But close-brace is not a valid character in a link title:
12172 {{[[Foo}}|bar]]
12173
12174 However, we can still tell this was handled as a link in the preprocessor:
12175 {{echo|[[Foo}}|bar]]|bat}}
12176 !! html/php
12177 <p>{{<a href="/wiki/Foo" title="Foo">bar}}</a>
12178 </p><p>But close-brace is not a valid character in a link title:
12179 {{[[Foo}}|bar]]
12180 </p><p>However, we can still tell this was handled as a link in the preprocessor:
12181 [[Foo}}|bar]]
12182 </p>
12183 !! html/parsoid
12184 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">bar}}</a></p>
12185 <p>But close-brace is not a valid character in a link title: {{[[Foo}}|bar]]</p>
12186 <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>
12187 !! end
12188
12189 !! test
12190 Preprocessor precedence 2: template is rightmost opening
12191 !! options
12192 language=zh
12193 !! wikitext
12194 -{{echo|foo}-}}-
12195 !! html/php
12196 <p>-foo}--
12197 </p>
12198 !! html/parsoid
12199 <p>-<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}-"}},"i":0}}]}'>foo}-</span>-</p>
12200 !! end
12201
12202 !! test
12203 Preprocessor precedence 3: language converter is rightmost opening
12204 !! options
12205 language=zh
12206 parsoid=wt2html
12207 !! wikitext
12208 {{echo|hi}}
12209
12210 {{-{R|echo|hi}}}-
12211
12212 [[-{R|raw]]}-
12213 !! html/php
12214 <p>hi
12215 </p><p>{{echo|hi}}
12216 </p><p>[[raw]]
12217 </p>
12218 !! html/parsoid
12219 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"}},"i":0}}]}'>hi</p>
12220 <p>{{<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"echo|hi}}"}}'></span></p>
12221 <p>[[<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw]]"}}'></span></p>
12222 !! end
12223
12224 !! test
12225 Preprocessor precedence 4: left-most angle bracket
12226 !! options
12227 language=zh
12228 !! wikitext
12229 <!--{raw}-->
12230 !! html/php
12231 !! html/parsoid
12232 <!--{raw}-->
12233 !! end
12234
12235 !! article
12236 Template:Precedence5
12237 !! text
12238 {{{{{1}}}}}
12239 !! endarticle
12240
12241 !! test
12242 Preprocessor precedence 5: tplarg takes precedence over template
12243 !! wikitext
12244 {{Precedence5|Bullet}}
12245 !! html/php
12246 <ul><li>Bar</li></ul>
12247
12248 !! html/parsoid
12249 <ul typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Precedence5","href":"./Template:Precedence5"},"params":{"1":{"wt":"Bullet"}},"i":0}}]}'><li>Bar</li></ul>
12250 !! end
12251
12252 !! test
12253 Preprocessor precedence 6: broken link is rightmost opening
12254 !! options
12255 parsoid=wt2html
12256 !! wikitext
12257 {{echo|[[Foo}}
12258
12259 {{echo|[[Foo|bar|bat=baz}}
12260 !! html/php
12261 <p>{{echo|[[Foo}}
12262 </p><p>{{echo|[[Foo|bar|bat=baz}}
12263 </p>
12264 !! html/parsoid
12265 <p>{{echo|[[Foo}}</p>
12266 <p>{{echo|[[Foo|bar|bat=baz}}</p>
12267 !! end
12268
12269 # This next test exposes a difference between PHP and Parsoid:
12270 # Given [[Foo|{{echo|Bar]]x}}y]]z:
12271 # 1) Both PHP and Parsoid ignore the `]]` inside the `echo` in the
12272 # "preprocessor" stage. The `{{echo` extends until the `x}}`, and the
12273 # outer `[[Foo` extends until the `y]]`
12274 # 2a) But then the PHP preprocessor emits `[[Foo|Bar]]xy]]z` as an
12275 # intermediate result (after template expansion), and link processing
12276 # happens on this intermediate result, which moves the wikilink
12277 # boundary leftward to `[[Foo|Bar]]`
12278 # 2b) Parsoid works in a single step, so it's going to keep the
12279 # wikilink as extending to the `y]]`
12280 # 3a) Then PHP does linktrail processing which slurps up the trailing
12281 # `xy` inside the link.
12282 # 3b) Parsoid will do linktrail processing to slurp up the trailing
12283 # `z` inside the link.
12284 # This is "correct" behavior. Parsoid's basic worldview is that the
12285 # `]]` inside the template shouldn't be allowed to leak out to affect
12286 # the surrounding wikilink. PHP may match Parsoid (in the future)
12287 # if you use {{#balance}} (T114445).
12288
12289 !! test
12290 Preprocessor precedence 7: broken template is rightmost opening
12291 !! options
12292 parsoid=wt2html
12293 !! wikitext
12294 [[Foo|{{echo|Bar]]
12295
12296 [[Foo|{{echo|Bar]]-x}}-y]]-z
12297
12298 Careful: linktrails can move the end of the wikilink:
12299 [[Foo|{{echo|y']]a}}l]]l
12300 !! html/php
12301 <p><a href="/wiki/Foo" title="Foo">{{echo|Bar</a>
12302 </p><p><a href="/wiki/Foo" title="Foo">Bar</a>-x-y]]-z
12303 </p><p>Careful: linktrails can move the end of the wikilink:
12304 <a href="/wiki/Foo" title="Foo">y'al</a>]]l
12305 </p>
12306 !! html/parsoid
12307 <p>[[Foo|{{echo|Bar]]</p>
12308 <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>
12309 <p>Careful: linktrails can move the end of the wikilink:
12310 <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>
12311 !! end
12312
12313 !! test
12314 Preprocessor precedence 8: broken language converter is rightmost opening
12315 !! options
12316 language=zh
12317 !! wikitext
12318 [[Foo-{R|raw]]
12319 !! html
12320 <p>[[Foo-{R|raw]]
12321 </p>
12322 !! end
12323
12324 !! article
12325 Template:Preprocessor_precedence_9
12326 !! text
12327 ;4: {{{{1}}}}
12328 ;5: {{{{{2}}}}}
12329 ;6: {{{{{{3}}}}}}
12330 ;7: {{{{{{{4}}}}}}}
12331 !! endarticle
12332
12333 !! test
12334 Preprocessor precedence 9: groups of braces
12335 !! wikitext
12336 {{Preprocessor precedence 9|Four|Bullet|1|2}}
12337 !! html/php
12338 <dl><dt>4</dt>
12339 <dd>{Four}</dd>
12340 <dt>5</dt>
12341 <dd></dd></dl>
12342 <ul><li>Bar</li></ul>
12343 <dl><dt>6</dt>
12344 <dd>Four</dd>
12345 <dt>7</dt>
12346 <dd>{Bullet}</dd></dl>
12347
12348 !! html/parsoid
12349 <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}}]}'>
12350 <dt>4</dt>
12351 <dd>{Four}</dd>
12352 <dt>5</dt>
12353 <dd></dd>
12354 </dl><ul about="#mwt1">
12355 <li>Bar</li>
12356 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12357 <dt>6</dt>
12358 <dd>Four</dd>
12359 <dt>7</dt>
12360 <dd>{Bullet}</dd>
12361 </dl>
12362 !! end
12363
12364 !! article
12365 Template:Preprocessor_precedence_10
12366 !! text
12367 ;1: -{R|raw}-
12368 ;2: -{{Bullet}}-
12369 ;3: -{{{1}}}-
12370 ;4: -{{{{2}}}}-
12371 ;5: -{{{{{3}}}}}-
12372 ;6: -{{{{{{4}}}}}}-
12373 ;7: -{{{{{{{5}}}}}}}-
12374 !! endarticle
12375
12376 !! test
12377 Preprocessor precedence 10: groups of braces with leading dash
12378 !! options
12379 language=zh
12380 !! wikitext
12381 {{Preprocessor precedence 10|Three|raw2|Bullet|1|2}}
12382 !! html/php
12383 <dl><dt>1</dt>
12384 <dd>raw</dd>
12385 <dt>2</dt>
12386 <dd>-</dd></dl>
12387 <ul><li>Bar-</li></ul>
12388 <dl><dt>3</dt>
12389 <dd>-Three-</dd>
12390 <dt>4</dt>
12391 <dd>raw2</dd>
12392 <dt>5</dt>
12393 <dd>-</dd></dl>
12394 <ul><li>Bar-</li></ul>
12395 <dl><dt>6</dt>
12396 <dd>-Three-</dd>
12397 <dt>7</dt>
12398 <dd>raw2</dd></dl>
12399
12400 !! html/parsoid
12401 <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}}]}'>
12402 <dt>1</dt>
12403 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw"}}'></span></dd>
12404 <dt>2</dt>
12405 <dd>-</dd>
12406 </dl><ul about="#mwt1">
12407 <li>Bar-</li>
12408 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12409 <dt>3</dt>
12410 <dd>-Three-</dd>
12411 <dt>4</dt>
12412 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12413 <dt>5</dt>
12414 <dd>-</dd>
12415 </dl><ul about="#mwt1">
12416 <li>Bar-</li>
12417 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12418 <dt>6</dt>
12419 <dd>-Three-</dd>
12420 <dt>7</dt>
12421 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12422 </dl>
12423 !! end
12424
12425 !! test
12426 Preprocessor precedence 11: found during visual diff testing
12427 !! wikitext
12428 {{#tag:span|-{{#tag:span|-{{echo|x}}}}}}
12429
12430 {{echo|-{{echo|-{{echo|x}}}}}}
12431
12432 {{echo|-{{echo|x}}}}
12433 !! html/php
12434 <p><span>-<span>-x</span></span>
12435 </p><p>--x
12436 </p><p>-x
12437 </p>
12438 !! html/parsoid
12439 <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>
12440
12441 <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>
12442
12443 <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>
12444 !! end
12445
12446 !! test
12447 Preprocessor precedence 12: broken language converter closed by brace.
12448 !! options
12449 parsoid=wt2html
12450 !! wikitext
12451 This form breaks the template, which is unfortunate:
12452 *{{echo|foo-{bar}bat}}
12453
12454 But if the broken language converter markup is inside an extension
12455 tag, nothing bad happens:
12456 *<nowiki>foo-{bar}bat</nowiki>
12457 *{{echo|<nowiki>foo-{bar}bat</nowiki>}}
12458 *<pre>foo-{bar}bat</pre>
12459 *{{echo|<pre>foo-{bar}bat</pre>}}
12460
12461 <tag>foo-{bar}bat</tag>
12462 {{echo|<tag>foo-{bar}bat</tag>}}
12463
12464 !! html/php+tidy
12465 <p>This form breaks the template, which is unfortunate:
12466 </p>
12467 <ul><li>{{echo|foo-{bar}bat}}</li></ul>
12468 <p>But if the broken language converter markup is inside an extension
12469 tag, nothing bad happens:
12470 </p>
12471 <ul><li>foo-&#123;bar}bat</li>
12472 <li>foo-&#123;bar}bat</li>
12473 <li><pre>foo-{bar}bat</pre></li>
12474 <li><pre>foo-{bar}bat</pre></li></ul>
12475 <pre>'foo-{bar}bat'
12476 array (
12477 )
12478 </pre>
12479 <pre>'foo-{bar}bat'
12480 array (
12481 )
12482 </pre>
12483 !! html/parsoid
12484 <p>This form breaks the template, which is unfortunate:</p>
12485 <ul>
12486 <li>{{echo|foo-{bar}bat}}</li>
12487 </ul>
12488 <p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p>
12489 <ul>
12490 <li><span typeof="mw:Nowiki">foo-{bar}bat</span></li>
12491 <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>
12492 <li><pre typeof="mw:Extension/pre" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo-{bar}bat"}}'>foo-{bar}bat</pre></li>
12493 <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>
12494 </ul>
12495 <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>
12496 !! end
12497
12498 !! test
12499 Preprocessor precedence 13: broken language converter in external link
12500 !! options
12501 parsoid=wt2html
12502 !! wikitext
12503 *[http://example.com/-{foo Example in URL]
12504 *[http://example.com Example in -{link} description]
12505 *{{echo|[http://example.com/-{foo Breaks template, however]}}
12506 !! html/php+tidy
12507 <ul><li><a rel="nofollow" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12508 <li><a rel="nofollow" class="external text" href="http://example.com">Example in -{link} description</a></li>
12509 <li>{{echo|<a rel="nofollow" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li></ul>
12510 !! html/parsoid
12511 <ul>
12512 <li><a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12513 <li><a rel="mw:ExtLink" class="external text" href="http://example.com">Example in -{link} description</a></li>
12514 <li>{{echo|<a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
12515 </ul>
12516 !! end
12517
12518 !! test
12519 Preprocessor precedence 14: broken language converter in comment
12520 !! wikitext
12521 *<!--{{foo}}-->...should be ok
12522 *<!---{{foo}}-->...extra dashes
12523 *{{echo|foo<!-- -{bar} -->bat}}...should be ok
12524 !! html/php+tidy
12525 <ul><li>...should be ok</li>
12526 <li>...extra dashes</li>
12527 <li>foobat...should be ok</li></ul>
12528 !! html/parsoid
12529 <ul>
12530 <li><!--{{foo}}-->...should be ok</li>
12531 <li><!--&#x2D;{{foo}}-->...extra dashes</li>
12532 <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>
12533 </ul>
12534 !! end
12535
12536 !! test
12537 Preprocessor precedence 15: broken brace markup in headings
12538 !! config
12539 wgFragmentMode=[ 'html5', 'legacy' ]
12540 !! options
12541 parsoid=wt2html
12542 !! wikitext
12543 __NOTOC__ __NOEDITSECTION__
12544 ===1 foo[bar 1===
12545 1
12546 ===2 foo[[bar 2===
12547 2
12548 ===3 foo{bar 3===
12549 3
12550 ===4 foo{{bar 4===
12551 4
12552 ===5 foo{{{bar 5===
12553 5
12554 ===6 foo-{bar 6===
12555 6
12556 !! html/php+tidy
12557 <h3><span id="1_foo.5Bbar_1"></span><span class="mw-headline" id="1_foo[bar_1">1 foo[bar 1</span></h3>
12558 <p>1
12559 </p>
12560 <h3><span id="2_foo.5B.5Bbar_2"></span><span class="mw-headline" id="2_foo[[bar_2">2 foo[[bar 2</span></h3>
12561 <p>2
12562 </p>
12563 <h3><span id="3_foo.7Bbar_3"></span><span class="mw-headline" id="3_foo{bar_3">3 foo{bar 3</span></h3>
12564 <p>3
12565 </p>
12566 <h3><span id="4_foo.7B.7Bbar_4"></span><span class="mw-headline" id="4_foo{{bar_4">4 foo{{bar 4</span></h3>
12567 <p>4
12568 </p>
12569 <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>
12570 <p>5
12571 </p>
12572 <h3><span id="6_foo-.7Bbar_6"></span><span class="mw-headline" id="6_foo-{bar_6">6 foo-{bar 6</span></h3>
12573 <p>6
12574 </p>
12575 !! html/parsoid
12576 <meta property="mw:PageProp/notoc"/> <meta property="mw:PageProp/noeditsection"/>
12577 <h3 id="1_foo[bar_1"><span id="1_foo.5Bbar_1" typeof="mw:FallbackId"></span>1 foo[bar 1</h3>
12578 <p>1</p>
12579 <h3 id="2_foo[[bar_2"><span id="2_foo.5B.5Bbar_2" typeof="mw:FallbackId"></span>2 foo[[bar 2</h3>
12580 <p>2</p>
12581 <h3 id="3_foo{bar_3"><span id="3_foo.7Bbar_3" typeof="mw:FallbackId"></span>3 foo{bar 3</h3>
12582 <p>3</p>
12583 <h3 id="4_foo{{bar_4"><span id="4_foo.7B.7Bbar_4" typeof="mw:FallbackId"></span>4 foo{{bar 4</h3>
12584 <p>4</p>
12585 <h3 id="5_foo{{{bar_5"><span id="5_foo.7B.7B.7Bbar_5" typeof="mw:FallbackId"></span>5 foo{{{bar 5</h3>
12586 <p>5</p>
12587 <h3 id="6_foo-{bar_6"><span id="6_foo-.7Bbar_6" typeof="mw:FallbackId"></span>6 foo-{bar 6</h3>
12588 <p>6</p>
12589 !! end
12590
12591 !! test
12592 Preprocessor precedence 16: matching closing braces to opening braces
12593 !! options
12594 language=zh
12595 parsoid=wt2html
12596 !! wikitext
12597 -{{{echo|foo}}bar}-
12598 !! html/php
12599 <p>foobar
12600 </p>
12601 !! html/parsoid
12602 <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>
12603 !! end
12604
12605 !! test
12606 Preprocessor precedence 17: template w/o target shouldn't prevent closing
12607 !! options
12608 parsoid=wt2html
12609 !! wikitext
12610 {{echo|hi {{}}}}
12611 !! html/php
12612 <p>hi {{}}
12613 </p>
12614 !! html/parsoid
12615 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi {{}}"}},"i":0}}]}'>hi {{}}</p>
12616 !! end
12617
12618 !! test
12619 Preprocessor precedence 18: another rightmost wins scenario
12620 !! options
12621 parsoid=wt2html
12622 !! wikitext
12623 {{ -{{{{1|tplarg}}} }} }-
12624 !! html/php
12625 <p>{{ -{tplarg }} }-
12626 </p>
12627 !! html/parsoid
12628 <p>{{ -{<span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"1"},"params":{"1":{"wt":"tplarg"}},"i":0}}]}'>tplarg</span> }} }-</p>
12629 !! end
12630
12631 !! test
12632 Preprocessor precedence 19: break syntax
12633 !! options
12634 parsoid=wt2html
12635 !! wikitext
12636 -{{
12637 !! html/php
12638 <p>-{{
12639 </p>
12640 !! html/parsoid
12641 <p>-{{</p>
12642 !! end
12643
12644 ###
12645 ### Token Stream Patcher tests
12646 ###
12647 ### These tests won't always pass wt2wt and other modes because
12648 ### on serialization, the table will be output on a new line.
12649 ### For now, we are blacklisting them, and using this to test selser.
12650 ###
12651
12652 !!test
12653 1. Table tag in SOL posn. should get reparsed correctly with valid TSR
12654 !!options
12655 parsoid=wt2html,wt2wt
12656 !!wikitext
12657 {{echo|}}{| width = '100%'
12658 |foo
12659 |}
12660 !!html/parsoid
12661 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":""}},"i":0}}]}'></span><table width="100%">
12662 <tbody><tr><td>foo</td></tr>
12663 </tbody></table>
12664 !!end
12665
12666 ## We used to, but no longer wt2wt this test since the default serializer
12667 ## will normalize the include directives to serialize on their own line.
12668 ## Selser will take care of preserving formatting in scenarios where they
12669 ## intermingled with other wikitext.
12670 !!test
12671 2. Table tag in SOL posn. should get reparsed correctly with valid TSR
12672 !!options
12673 parsoid=wt2html
12674 !!wikitext
12675 <includeonly>a</includeonly>{| {{{b}}}
12676 |c
12677 |}
12678 !!html/parsoid
12679 <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":""}]]}'>
12680 <tbody><tr><td>c</td></tr>
12681 </tbody></table>
12682 !!end
12683
12684 !! test
12685 Table wikitext syntax outside wiki-tables
12686 !! wikitext
12687 a
12688 |+ not a caption
12689 ! not a table heading
12690 |- not a table row
12691 | not a table cell
12692 | class="foo bar" | baz
12693 b
12694 |}
12695 |-
12696 c
12697 !! html
12698 <p>a
12699 |+ not a caption
12700 ! not a table heading
12701 |- not a table row
12702 | not a table cell
12703 | class="foo bar" | baz
12704 b
12705 |}
12706 |-
12707 c
12708 </p>
12709 !! end
12710
12711 ###
12712 ### Testing parsing of templates where a template arg
12713 ### has the same name as the template itself.
12714 ###
12715
12716 !! article
12717 Template:quote
12718 !! text
12719 {{{quote|{{{1}}}}}}
12720 !! endarticle
12721
12722 !!test
12723 Templates: Template Name/Arg clash: 1. Use of positional param
12724 !! wikitext
12725 {{quote|foo}}
12726 !! html
12727 <p>foo
12728 </p>
12729 !!end
12730
12731 !!test
12732 Templates: Template Name/Arg clash: 2. Use of named param
12733 !! wikitext
12734 {{quote|quote=foo}}
12735 !! html
12736 <p>foo
12737 </p>
12738 !!end
12739
12740 !!test
12741 Templates: Template Name/Arg clash: 3. Use of named param with empty input
12742 !! wikitext
12743 {{quote|quote}}
12744 !! html
12745 <p>quote
12746 </p>
12747 !!end
12748
12749 ###
12750 ### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
12751 ###
12752
12753 !!test
12754 Templates: 1. Simple use
12755 !! wikitext
12756 {{echo|Foo}}
12757 !! html
12758 <p>Foo
12759 </p>
12760 !!end
12761
12762 !!test
12763 Templates: 2. Inside a block tag
12764 !! wikitext
12765 <div>{{echo|Foo}}</div>
12766 <blockquote>{{echo|Foo}}</blockquote>
12767 !! html
12768 <div>Foo</div>
12769 <blockquote>Foo</blockquote>
12770
12771 !! html+tidy
12772 <div>Foo</div>
12773 <blockquote><p>Foo</p></blockquote>
12774 !!end
12775
12776 !!test
12777 Templates: P-wrapping: 1a. Templates on consecutive lines
12778 !! wikitext
12779 {{echo|Foo}}
12780 {{echo|bar}}
12781 !! html
12782 <p>Foo
12783 bar
12784 </p>
12785 !!end
12786
12787 !!test
12788 Templates: P-wrapping: 1b. Templates on consecutive lines
12789 !! wikitext
12790 Foo
12791
12792 {{echo|bar}}
12793 {{echo|baz}}
12794 !! html
12795 <p>Foo
12796 </p><p>bar
12797 baz
12798 </p>
12799 !!end
12800
12801 !!test
12802 Templates: P-wrapping: 1c. Templates on consecutive lines
12803 !! wikitext
12804 {{echo|Foo}}
12805 {{echo|bar}} <div>baz</div>
12806 !! html
12807 <p>Foo
12808 </p>
12809 bar <div>baz</div>
12810
12811 !! html+tidy
12812 <p>Foo
12813 </p><p>
12814 bar </p><div>baz</div>
12815 !! end
12816
12817 !!test
12818 Templates: P-wrapping: 1d. Template preceded by comment-only line
12819 !!options
12820 parsoid
12821 !! wikitext
12822 <!-- foo -->
12823 {{echo|Bar}}
12824 !! html
12825 <!-- foo -->
12826
12827 <p about="#mwt223" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar"}},"i":0}}]}'>Bar</p>
12828 !!end
12829
12830 !!test
12831 Templates: Inline Text: 1. Multiple template uses
12832 !! wikitext
12833 {{echo|Foo}}bar{{echo|baz}}
12834 !! html
12835 <p>Foobarbaz
12836 </p>
12837 !!end
12838
12839 !!test
12840 Templates: Inline Text: 2. Back-to-back template uses
12841 !! wikitext
12842 {{echo|Foo}}{{echo|bar}}
12843 !! html
12844 <p>Foobar
12845 </p>
12846 !!end
12847
12848 !!test
12849 Templates: Block Tags: 1. Multiple template uses
12850 !! wikitext
12851 {{echo|<div>Foo</div>}}<div>bar</div>{{echo|<div>baz</div>}}
12852 !! html
12853 <div>Foo</div><div>bar</div><div>baz</div>
12854
12855 !!end
12856
12857 !!test
12858 Templates: Block Tags: 2. Back-to-back template uses
12859 !! wikitext
12860 {{echo|<div>Foo</div>}}{{echo|<div>bar</div>}}
12861 !! html
12862 <div>Foo</div><div>bar</div>
12863
12864 !!end
12865
12866 ## This is an edge case relating to paragraph wrapping.
12867 ## Note that Parsoid fails to match Remex because it's using the closing tag
12868 ## as a heuristic to determine if it's in a block, rather than SAX based events.
12869 ## And Parsoid drops empty elements in templates.
12870 !! test
12871 Templates: Correctly encapsulate templates producing </p> tag without a corresponding <p> tag
12872 !! wikitext
12873 {{echo|a
12874 b</p>}}
12875 !! html/php+tidy
12876 <p>a
12877 </p><p>
12878 b</p><p class="mw-empty-elt"></p>
12879 !! html/parsoid
12880 <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">
12881 </span><span about="#mwt1">b</span>
12882 !! end
12883
12884 !!test
12885 Templates: Links: 1. Simple example
12886 !! wikitext
12887 {{echo|[[Foo|bar]]}}
12888 !! html
12889 <p><a href="/wiki/Foo" title="Foo">bar</a>
12890 </p>
12891 !!end
12892
12893 !!test
12894 Templates: Links: 2. Generation of link href
12895 !! wikitext
12896 [[{{echo|Foo}}|bar]]
12897 !! html
12898 <p><a href="/wiki/Foo" title="Foo">bar</a>
12899 </p>
12900 !!end
12901
12902 !!test
12903 Templates: Links: 3. Generation of part of a link href
12904 !! wikitext
12905 [[Fo{{echo|o}}|bar]]
12906
12907 [[Foo{{echo|bar}}]]
12908
12909 [[Foo{{echo|bar}}baz]]
12910
12911 [[Foo{{echo|bar}}|bar]]
12912
12913 [[:Foo{{echo|bar}}]]
12914
12915 [[:Foo{{echo|bar}}|bar]]
12916 !! html
12917 <p><a href="/wiki/Foo" title="Foo">bar</a>
12918 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12919 </p><p><a href="/index.php?title=Foobarbaz&amp;action=edit&amp;redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a>
12920 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12921 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12922 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12923 </p>
12924 !!end
12925
12926 !!test
12927 Templates: Links: 4. Multiple templates generating link href
12928 !! wikitext
12929 [[{{echo|F}}{{echo|o}}ob{{echo|ar}}]]
12930 !! html
12931 <p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12932 </p>
12933 !!end
12934
12935 !!test
12936 Templates: Links: 5. Generation of link text
12937 !! wikitext
12938 [[Foo|{{echo|bar}}]]
12939 !! html
12940 <p><a href="/wiki/Foo" title="Foo">bar</a>
12941 </p>
12942 !!end
12943
12944 !!test
12945 Templates: Links: 5. Nested templates (only outermost template should be marked)
12946 !! wikitext
12947 {{echo|[[{{echo|Foo}}|bar]]}}
12948 !! html
12949 <p><a href="/wiki/Foo" title="Foo">bar</a>
12950 </p>
12951 !!end
12952
12953 !!test
12954 Templates: HTML Tag: 1. Generation of HTML attr. key
12955 !! wikitext
12956 <div {{echo|style}}="color:red;">foo</div>
12957 !! html
12958 <div style="color:red;">foo</div>
12959
12960 !!end
12961
12962 !!test
12963 Templates: HTML Tag: 2. Generation of HTML attr. value
12964 !! wikitext
12965 <div style={{echo|'color:red;'}}>foo</div>
12966 !! html
12967 <div style="color:red;">foo</div>
12968
12969 !!end
12970
12971 !!test
12972 Templates: HTML Tag: 3. Generation of HTML attr key and value
12973 !! wikitext
12974 <div {{echo|style}}={{echo|'color:red;'}}>foo</div>
12975 !! html
12976 <div style="color:red;">foo</div>
12977
12978 !!end
12979
12980 !!test
12981 Templates: HTML Tag: 4. Generation of starting piece of HTML attr value
12982 !! wikitext
12983 <div title="{{echo|This is a long title}} with just one piece templated">foo</div>
12984 !! html
12985 <div title="This is a long title with just one piece templated">foo</div>
12986
12987 !!end
12988
12989 !!test
12990 Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
12991 !! wikitext
12992 <div title="This is a long title with just {{echo|one piece}} templated">foo</div>
12993 !! html
12994 <div title="This is a long title with just one piece templated">foo</div>
12995
12996 !!end
12997
12998 !!test
12999 Templates: HTML Tag: 6. Generation of end piece of HTML attr value
13000 !! wikitext
13001 <div title="This is a long title with just one piece {{echo|templated}}">foo</div>
13002 !! html
13003 <div title="This is a long title with just one piece templated">foo</div>
13004
13005 !!end
13006
13007 # SSS FIXME: While it is great we added support for all this,
13008 # do we want to make this part of the spec? Maybe we want to
13009 # deprecate this kind of usage in the future?
13010 !!test
13011 Templates: HTML Tag: 7. Generation of partial attribute key string
13012 !! wikitext
13013 <div st{{echo|yle}}="color:red;">foo</div>
13014 !! html
13015 <div style="color:red;">foo</div>
13016
13017 !!end
13018
13019 !! test
13020 Templates: HTML Tag: 8. Template-generated attribute (k=v)
13021 !! wikitext
13022 <div {{echo|1=id="v1"}}>bar</div>
13023 !! html
13024 <div id="v1">bar</div>
13025
13026 !!end
13027
13028 !! test
13029 Templates: HTML Tag: 9. Multiple template-generated attributes
13030 !! wikitext
13031 <div {{echo|1=id="v1" title="foo"}}>bar</div>
13032 !! html
13033 <div id="v1" title="foo">bar</div>
13034
13035 !!end
13036
13037 !! test
13038 Templates: Support for templates generating attributes and content
13039 !! wikitext
13040 {| {{mixed_attr_content_template}}
13041 |-
13042 |bar
13043 |}
13044 !! html/php
13045 <table style="color:red;" title="T48811">
13046
13047 <tr>
13048 <td>foo
13049 </td></tr>
13050 <tr>
13051 <td>bar
13052 </td></tr></table>
13053
13054 !! html/parsoid
13055 <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|}"]}'>
13056 <tbody><tr>
13057 <td>foo</td></tr>
13058 <tr>
13059 <td>bar</td></tr>
13060 </tbody></table>
13061 !!end
13062
13063 !! article
13064 Template:attribute_from_template
13065 !! text
13066 class="123"
13067 !! endarticle
13068
13069 !! test
13070 Table cell with attribute before expanded attribute
13071 !! wikitext
13072 {|
13073 | align="center" {{attribute_from_template}} |456
13074 |}
13075 !! html/parsoid
13076 <table>
13077 <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>
13078 </tbody></table>
13079 !! end
13080
13081 !! test
13082 1. Entities and nowikis inside templated attributes should be handled correctly
13083 !! wikitext
13084 <div {{echo|style{{=}}"background:&#35;f9f9f9;"}}>foo</div>
13085 !! html/php
13086 <div style="background:#f9f9f9;">foo</div>
13087
13088 !! html/parsoid
13089 <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>
13090 !! end
13091
13092 !! test
13093 2. Entities and nowikis inside templated attributes should be handled correctly
13094 !! wikitext
13095 {|
13096 |{{table_attribs_3}}
13097 |}
13098 !! html/php
13099 <table>
13100 <tr>
13101 <td style="background:#f9f9f9;">Foo
13102 </td></tr></table>
13103
13104 !! html/parsoid
13105 <table>
13106 <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>
13107 </tbody></table>
13108 !! end
13109
13110 !! test
13111 3. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13112 !! wikitext
13113 {{tbl-start}}
13114 |{{table_attribs_3}}
13115 {{tbl-end}}
13116 !! html/php
13117 <table>
13118 <tr>
13119 <td style="background:#f9f9f9;">Foo
13120 </td></tr></table>
13121
13122 !! html/parsoid
13123 <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}}]}'>
13124 <tbody><tr><td style="background:#f9f9f9;">Foo</td></tr>
13125 </tbody></table>
13126 !! end
13127
13128 # T107622
13129 !! test
13130 4. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13131 !! wikitext
13132 {|
13133 |{{table_attribs_6}} hi
13134 |}
13135 !! html/php
13136 <table>
13137 <tr>
13138 <td style="background: red;">hi
13139 </td></tr></table>
13140
13141 !! html/parsoid
13142 <table>
13143 <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>
13144 </tbody></table>
13145 !! end
13146
13147 !!test
13148 Templates: HTML Tables: 1. Generating start of a HTML table
13149 !! wikitext
13150 {{echo|<table><tr><td>foo</td>}}</tr></table>
13151 !! html
13152 <table><tr><td>foo</td></tr></table>
13153
13154 !!end
13155
13156 !!test
13157 Templates: HTML Tables: 2a. Generating middle of a HTML table
13158 !! wikitext
13159 <table><tr>{{echo|<td>foo</td>}}</tr></table>
13160 !! html
13161 <table><tr><td>foo</td></tr></table>
13162
13163 !!end
13164
13165 !!test
13166 Templates: HTML Tables: 2b. Generating middle of a HTML table
13167 !! wikitext
13168 <table>{{echo|<tr><td>foo</td></tr>}}</table>
13169 !! html
13170 <table><tr><td>foo</td></tr></table>
13171
13172 !!end
13173
13174 !!test
13175 Templates: HTML Tables: 3. Generating end of a HTML table
13176 !! wikitext
13177 <table><tr>{{echo|<td>foo</td></tr></table>}}
13178 !! html
13179 <table><tr><td>foo</td></tr></table>
13180
13181 !!end
13182
13183 !!test
13184 Templates: HTML Tables: 4a. Generating a single tag of a HTML table
13185 !! wikitext
13186 {{echo|<table>}}<tr><td>foo</td></tr></table>
13187 !! html
13188 <table><tr><td>foo</td></tr></table>
13189
13190 !!end
13191
13192 !!test
13193 Templates: HTML Tables: 4b. Generating a single tag of a HTML table
13194 !! wikitext
13195 <table>{{echo|<tr>}}<td>foo</td></tr></table>
13196 !! html
13197 <table><tr><td>foo</td></tr></table>
13198
13199 !!end
13200
13201 !!test
13202 Templates: HTML Tables: 4c. Generating a single tag of a HTML table
13203 !! wikitext
13204 <table><tr>{{echo|<td>}}foo</td></tr></table>
13205 !! html
13206 <table><tr><td>foo</td></tr></table>
13207
13208 !!end
13209
13210 !!test
13211 Templates: HTML Tables: 4d. Generating a single tag of a HTML table
13212 !! wikitext
13213 <table><tr><td>foo{{echo|</td>}}</tr></table>
13214 !! html
13215 <table><tr><td>foo</td></tr></table>
13216
13217 !!end
13218
13219 !!test
13220 Templates: HTML Tables: 4e. Generating a single tag of a HTML table
13221 !! wikitext
13222 <table><tr><td>foo</td>{{echo|</tr>}}</table>
13223 !! html
13224 <table><tr><td>foo</td></tr></table>
13225
13226 !!end
13227
13228 !!test
13229 Templates: HTML Tables: 4f. Generating a single tag of a HTML table
13230 !! wikitext
13231 <table><tr><td>foo</td></tr>{{echo|</table>}}
13232 !! html
13233 <table><tr><td>foo</td></tr></table>
13234
13235 !!end
13236
13237 !!test
13238 Templates: HTML Tables: 5. Proper fostering of categories from inside
13239 !!options
13240 parsoid=wt2html,wt2wt
13241 !! wikitext
13242 <table>[[Category:foo1]]<tr><td>foo</td></tr></table>
13243 <!--Two categories (T52330)-->
13244 <table>[[Category:bar1]][[Category:bar2]]<tr><td>foo</td></tr></table>
13245 !! html
13246 <link rel="mw:PageProp/Category" href="./Category:Foo1"><table><tbody><tr><td>foo</td></tr></tbody></table>
13247 <!--Two categories (T52330)-->
13248 <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>
13249 !!end
13250
13251 !! test
13252 Templates: Wiki Tables: 1a. Fostering of entire template content
13253 !! wikitext
13254 {|
13255 {{echo|a}}
13256 |}
13257 !! html/php
13258 <table>
13259 a
13260 <tr><td></td></tr></table>
13261
13262 !! html/php+tidy
13263
13264 a
13265 <table><tbody><tr><td></td></tr></tbody></table>
13266 !! html/parsoid
13267 <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">
13268
13269 </table>
13270 !! end
13271
13272 !!test
13273 Templates: Wiki Tables: 1b. Fostering of entire template content
13274 !! wikitext
13275 {|
13276 {{echo|<div>}}
13277 foo
13278 {{echo|</div>}}
13279 |}
13280 !! html
13281 <table>
13282 <div>
13283 <p>foo
13284 </p>
13285 </div>
13286 <tr><td></td></tr></table>
13287
13288 !! html/php+tidy
13289 <div>
13290 <p>foo
13291 </p>
13292 </div><table>
13293
13294 <tbody><tr><td></td></tr></tbody></table>
13295 !! html/parsoid
13296 <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|}"]}'>
13297 <p>foo</p>
13298 </div><table about="#mwt3">
13299
13300 </table>
13301 !! end
13302
13303 !! test
13304 Templates: Wiki Tables: 2. Fostering of partial template content
13305 !! wikitext
13306 {|
13307 {{echo|a
13308 <div>b</div>}}
13309 |}
13310 !! html/php
13311 <table>
13312 a
13313 <div>b</div>
13314 <tr><td></td></tr></table>
13315
13316 !! html/php+tidy
13317
13318 a
13319 <div>b</div><table>
13320 <tbody><tr><td></td></tr></tbody></table>
13321 !! html/parsoid
13322 <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">
13323
13324
13325 </table>
13326 !! end
13327
13328 !!test
13329 Templates: Wiki Tables: 3. td-content via multiple templates
13330 !! wikitext
13331 {|
13332 {{echo|{{pipe}}a}}{{echo|b}}
13333 |}
13334 !! html
13335 <table>
13336 <tr>
13337 <td>ab
13338 </td></tr></table>
13339
13340 !!end
13341
13342 !!test
13343 Templates: Wiki Tables: 4. Templated tags, no content
13344 !! wikitext
13345 {{tbl-start}}
13346 {{tbl-end}}
13347 !! html
13348 <table>
13349 <tr><td></td></tr></table>
13350
13351 !!end
13352
13353 !!test
13354 Templates: Wiki Tables: 5. Templated tags, regular td-tags
13355 !! wikitext
13356 {{tbl-start}}
13357 |foo
13358 {{tbl-end}}
13359 !! html
13360 <table>
13361 <tr>
13362 <td>foo
13363 </td></tr></table>
13364
13365 !!end
13366
13367 !!test
13368 Templates: Wiki Tables: 6. Templated tags, templated td-tags
13369 !! wikitext
13370 {{tbl-start}}
13371 {{!}}foo
13372 {{tbl-end}}
13373 !! html
13374 <table>
13375 <tr>
13376 <td>foo
13377 </td></tr></table>
13378
13379 !!end
13380
13381 ## This test case is very specific to Parsoid's internals
13382 ## and is hence only tested for Parsoid's code. Parsoid uses
13383 ## a <meta> marker tag for <ref> tags and they are expanded
13384 ## much later. We are verifying that this <meta> tag usage
13385 ## doesn't prevent foster parenting.
13386 !!test
13387 Templates: Wiki Tables: 7. Fosterable <ref>s should get fostered
13388 !!wikitext
13389 {{PartialTable}}<ref>foo</ref>
13390 |}
13391
13392 <references />
13393 !!html/parsoid
13394 <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">
13395 <tbody>
13396 </tbody></table>
13397
13398 <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>
13399 !!end
13400
13401 !! test
13402 Templates: Wiki Tables: 8. Fosterable meta-tags should get fostered
13403 !! wikitext
13404 {{echo|
13405 {{{!}}
13406 {{!}}-}}
13407 <onlyinclude>
13408 |foo
13409 </onlyinclude>
13410 {{!}}}
13411 !! html/parsoid
13412 <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{{!}}}"]}'>
13413 </span><meta typeof="mw:Includes/OnlyInclude" about="#mwt1"/><table about="#mwt1">
13414 <tbody><tr>
13415
13416 <td>foo
13417 <meta typeof="mw:Includes/OnlyInclude/End"/></td></tr>
13418 </tbody></table>
13419 !! end
13420
13421 !!test
13422 Templates: Lists: Multi-line list-items via templates
13423 !! wikitext
13424 *{{echo|a {{nonexistent|
13425 unused}}}}
13426 *{{echo|b {{nonexistent|
13427 unused}}}}
13428 !! html
13429 <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>
13430 <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>
13431
13432 !!end
13433
13434 !!test
13435 Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo)
13436 !! wikitext
13437 {{echo|''a}}{{echo|b''c''d}}{{echo|''e}}
13438 !! html
13439 <p><i>ab</i>c<i>d</i>e
13440 </p>
13441 !!end
13442
13443 !!test
13444 Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span)
13445 (PHP parser generates misnested html)
13446 !! wikitext
13447 {{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}}
13448 !! html/parsoid
13449 <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>
13450 !!end
13451
13452 !!test
13453 Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div)
13454 (PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s)
13455 !! options
13456 parsoid=wt2html,wt2wt
13457 !! wikitext
13458 {{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}}
13459 !! html
13460 <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>
13461 <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>
13462 <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>
13463 !!end
13464
13465 !!test
13466 Templates: Ugly nesting: 4. Divs opened/closed across templates
13467 !! wikitext
13468 a<div>b{{echo|c</div>d}}e
13469 !! html
13470 a<div>bc</div>de
13471
13472 !! html+tidy
13473 <p>a</p><div>bc</div><p>de
13474 </p>
13475 !! end
13476
13477 !! test
13478 Templates: Ugly templates: 3. newline-only template parameter
13479 !! wikitext
13480 foo {{echo|
13481 }}
13482 !! html
13483 <p>foo
13484 </p>
13485 !! end
13486
13487 # This looks like a bug: a single newline triggers p/br for some reason.
13488 !! test
13489 Templates: Ugly templates: 4. newline-only template parameter inconsistency
13490 !! wikitext
13491 {{echo|
13492 }}
13493 !! html
13494 <p><br />
13495 </p>
13496 !! end
13497
13498 # T66017 -- ugly wikitext with fostered content generates two template ranges that
13499 # have a true overlap (T1-start - T2-start - T1-end - T2-end).
13500 !! test
13501 Templates: Ugly templates: 5. Template encapsulation test: Non-trivial overlap of template ranges is properly handled
13502 !! wikitext
13503 {{echo|<table>}}
13504 {{echo|<div>foo}}
13505 {{echo|</table>}}
13506 !! html/parsoid
13507 <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
13508 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13509 </table>
13510 !! end
13511
13512 # T66017 -- ugly wikitext with fostered content generates two template ranges
13513 # that are "identical" and generate nesting cycles in the algorithm
13514 !! test
13515 Templates: Ugly templates: 6. Template encapsulation test: Cyclical nesting of template ranges is properly handled
13516 !! wikitext
13517 {{echo|<table><tr><td><table>}}
13518 {{echo|<div>}}
13519 {{echo|</div>}}
13520 !! html/parsoid
13521 <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"}'>
13522 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13523 </table></td></tr></tbody></table>
13524 !! end
13525
13526 !! test
13527 Templates: Parameters substituted at the top-level
13528 !! wikitext
13529 {{{foo|''who'' {{echo|me}}? '''never!'''}}}
13530
13531 {{{foo|bar|baz}}}
13532 !! html/php
13533 <p><i>who</i> me? <b>never!</b>
13534 </p><p>bar
13535 </p>
13536 !! html/parsoid
13537 <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>
13538
13539 <p about="#mwt3" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"foo"},"params":{"1":{"wt":"bar"},"2":{"wt":"baz"}},"i":0}}]}'>bar</p>
13540 !! end
13541
13542 !! test
13543 Templates: Param with empty arg in the final position
13544 !! wikitext
13545 {{{hi|}}}
13546 !! html/parsoid
13547 <span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"hi"},"params":{"1":{"wt":""}},"i":0}}]}'></span>
13548 !! end
13549
13550 !!test
13551 Parser Functions: 1. Simple example
13552 !! wikitext
13553 {{uc:foo}}
13554 !! html
13555 <p>FOO
13556 </p>
13557 !!end
13558
13559 !!test
13560 Parser Functions: 2. Nested use (only outermost should be marked up)
13561 !! wikitext
13562 {{uc:{{lc:FOO}}}}
13563 !! html
13564 <p>FOO
13565 </p>
13566 !!end
13567
13568 ## Note that the templates inside the references are not wrapped
13569 !! test
13570 Template nested in extension tag in template
13571 !! wikitext
13572 {{echo|hi<ref>[[ho|{{echo|hi}}]]</ref>}}
13573 {{echo|hi<ref>[http://test.com?q={{echo|ho}}]</ref>}}
13574 <references />
13575 !! html/parsoid
13576 <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>
13577 <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>
13578 <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>
13579 !! end
13580
13581 ###
13582 ### Pre-save transform tests
13583 ###
13584 !! test
13585 pre-save transform: subst:
13586 !! options
13587 pst
13588 !! wikitext
13589 {{subst:test}}
13590 !! html/php
13591 This is a test template
13592 !! end
13593
13594 !! test
13595 pre-save transform: normal template
13596 !! options
13597 pst
13598 !! wikitext
13599 {{test}}
13600 !! html/php
13601 {{test}}
13602 !! end
13603
13604 !! test
13605 pre-save transform: nonexistent template
13606 !! options
13607 pst
13608 !! wikitext
13609 {{thistemplatedoesnotexist}}
13610 !! html/php
13611 {{thistemplatedoesnotexist}}
13612 !! end
13613
13614 !! test
13615 pre-save transform: subst magic variables
13616 !! options
13617 pst
13618 !! wikitext
13619 {{subst:SITENAME}}
13620 !! html/php
13621 MediaWiki
13622 !! end
13623
13624 # This is T2089, which I fixed. -- wtm
13625 !! test
13626 pre-save transform: subst: templates with parameters
13627 !! options
13628 pst
13629 !! wikitext
13630 {{subst:paramtest|param="something else"}}
13631 !! html/php
13632 This is a test template with parameter "something else"
13633 !! end
13634
13635 !! article
13636 Template:nowikitest
13637 !! text
13638 <nowiki>'''not wiki'''</nowiki>
13639 !! endarticle
13640
13641 !! test
13642 pre-save transform: nowiki in subst (T3188)
13643 !! options
13644 pst
13645 !! wikitext
13646 {{subst:nowikitest}}
13647 !! html/php
13648 <nowiki>'''not wiki'''</nowiki>
13649 !! end
13650
13651 !! article
13652 Template:commenttest
13653 !! text
13654 This template has <!-- a comment --> in it.
13655 !! endarticle
13656
13657 !! test
13658 pre-save transform: comment in subst (T3936)
13659 !! options
13660 pst
13661 !! wikitext
13662 {{subst:commenttest}}
13663 !! html/php
13664 This template has <!-- a comment --> in it.
13665 !! end
13666
13667 !! test
13668 pre-save transform: unclosed tag
13669 !! options
13670 pst
13671 !! wikitext
13672 <nowiki>'''not wiki'''
13673 !! html/php
13674 <nowiki>'''not wiki'''
13675 !! end
13676
13677 !! test
13678 pre-save transform: mixed tag case
13679 !! options
13680 pst
13681 !! wikitext
13682 <NOwiki>'''not wiki'''</noWIKI>
13683 !! html/php
13684 <NOwiki>'''not wiki'''</noWIKI>
13685 !! end
13686
13687 !! test
13688 pre-save transform: unclosed comment in <nowiki>
13689 !! options
13690 pst
13691 !! wikitext
13692 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13693 !! html/php
13694 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13695 !!end
13696
13697 # Leading @ in this template definition works around a limitation
13698 # in parsoid's parserTests which otherwise strips the <span> from the
13699 # result (confusing it for a template wrapper)
13700 !! article
13701 Template:dangerous
13702 !!text
13703 @<span onmouseover="alert('crap')">Oh no</span>
13704 !!endarticle
13705
13706 !!test
13707 (confirming safety of fix for subst T3936)
13708 !! wikitext
13709 {{Template:dangerous}}
13710 !! html
13711 <p>@<span>Oh no</span>
13712 </p>
13713 !! end
13714
13715 !! test
13716 pre-save transform: comment containing gallery (T7024)
13717 !! options
13718 pst
13719 !! wikitext
13720 <!-- <gallery>data</gallery> -->
13721 !! html/php
13722 <!-- <gallery>data</gallery> -->
13723 !!end
13724
13725 !! test
13726 pre-save transform: comment containing extension
13727 !! options
13728 pst
13729 !! wikitext
13730 <!-- <tag>data</tag> -->
13731 !! html/php
13732 <!-- <tag>data</tag> -->
13733 !!end
13734
13735 !! test
13736 pre-save transform: comment containing nowiki
13737 !! options
13738 pst
13739 !! wikitext
13740 <!-- <nowiki>data</nowiki> -->
13741 !! html/php
13742 <!-- <nowiki>data</nowiki> -->
13743 !!end
13744
13745 !! test
13746 pre-save transform: <noinclude> in subst (T5298)
13747 !! options
13748 pst
13749 !! wikitext
13750 {{subst:Includes}}
13751 !! html/php
13752 Foobar
13753 !! end
13754
13755 !! test
13756 pre-save transform: <onlyinclude> in subst (T5298)
13757 !! options
13758 pst
13759 !! wikitext
13760 {{subst:Includes2}}
13761 !! html/php
13762 Foo
13763 !! end
13764
13765 !! article
13766 Template:SubstTest
13767 !!text
13768 {{<includeonly>subst:</includeonly>Includes}}
13769 !! endarticle
13770
13771 !! article
13772 Template:SafeSubstTest
13773 !! text
13774 {{<includeonly>safesubst:</includeonly>Includes}}
13775 !! endarticle
13776
13777 !! test
13778 T24297: safesubst: works during PST
13779 !! options
13780 pst
13781 !! wikitext
13782 {{subst:SafeSubstTest}}{{safesubst:SubstTest}}
13783 !! html/php
13784 FoobarFoobar
13785 !! end
13786
13787 !! test
13788 T24297: safesubst: works during normal parse
13789 !! wikitext
13790 {{SafeSubstTest}}
13791 !! html
13792 <p>Foobar
13793 </p>
13794 !! end
13795
13796 !! test
13797 subst: does not work during normal parse
13798 !! wikitext
13799 {{SubstTest}}
13800 !! html
13801 <p>{{subst:Includes}}
13802 </p>
13803 !! end
13804
13805 !! test
13806 pre-save transform: context links ("pipe trick")
13807 !! options
13808 pst
13809 !! wikitext
13810 [[Article (context)|]]
13811 [[Bar:Article|]]
13812 [[:Bar:Article|]]
13813 [[Bar:Article (context)|]]
13814 [[:Bar:Article (context)|]]
13815 [[|Article]]
13816 [[|Article (context)]]
13817 [[Bar:X (Y) Z|]]
13818 [[:Bar:X (Y) Z|]]
13819 !! html/php
13820 [[Article (context)|Article]]
13821 [[Bar:Article|Article]]
13822 [[:Bar:Article|Article]]
13823 [[Bar:Article (context)|Article]]
13824 [[:Bar:Article (context)|Article]]
13825 [[Article]]
13826 [[Article (context)]]
13827 [[Bar:X (Y) Z|X (Y) Z]]
13828 [[:Bar:X (Y) Z|X (Y) Z]]
13829 !! end
13830
13831 !! test
13832 pre-save transform: context links ("pipe trick") with interwiki prefix
13833 !! options
13834 pst
13835 !! wikitext
13836 [[interwiki:Article|]]
13837 [[:interwiki:Article|]]
13838 [[interwiki:Bar:Article|]]
13839 [[:interwiki:Bar:Article|]]
13840 !! html/php
13841 [[interwiki:Article|Article]]
13842 [[:interwiki:Article|Article]]
13843 [[interwiki:Bar:Article|Bar:Article]]
13844 [[:interwiki:Bar:Article|Bar:Article]]
13845 !! end
13846
13847 !! test
13848 pre-save transform: context links ("pipe trick") with parens in title
13849 !! options
13850 pst title=[[Somearticle (context)]]
13851 !! wikitext
13852 [[|Article]]
13853 !! html/php
13854 [[Article (context)|Article]]
13855 !! end
13856
13857 !! test
13858 pre-save transform: context links ("pipe trick") with comma in title
13859 !! options
13860 pst title=[[Someplace, Somewhere]]
13861 !! wikitext
13862 [[|Otherplace]]
13863 [[Otherplace, Elsewhere|]]
13864 [[Otherplace, Elsewhere, Anywhere|]]
13865 !! html/php
13866 [[Otherplace, Somewhere|Otherplace]]
13867 [[Otherplace, Elsewhere|Otherplace]]
13868 [[Otherplace, Elsewhere, Anywhere|Otherplace]]
13869 !! end
13870
13871 !! test
13872 pre-save transform: context links ("pipe trick") with parens and comma
13873 !! options
13874 pst title=[[Someplace (IGNORED), Somewhere]]
13875 !! wikitext
13876 [[|Otherplace]]
13877 [[Otherplace (place), Elsewhere|]]
13878 !! html/php
13879 [[Otherplace, Somewhere|Otherplace]]
13880 [[Otherplace (place), Elsewhere|Otherplace]]
13881 !! end
13882
13883 !! test
13884 pre-save transform: context links ("pipe trick") with comma and parens
13885 !! options
13886 pst title=[[Who, me? (context)]]
13887 !! wikitext
13888 [[|Yes, you.]]
13889 [[Me, Myself, and I (1937 song)|]]
13890 !! html/php
13891 [[Yes, you. (context)|Yes, you.]]
13892 [[Me, Myself, and I (1937 song)|Me, Myself, and I]]
13893 !! end
13894
13895 !! test
13896 pre-save transform: context links ("pipe trick") with namespace
13897 !! options
13898 pst title=[[Ns:Somearticle]]
13899 !! wikitext
13900 [[|Article]]
13901 !! html/php
13902 [[Ns:Article|Article]]
13903 !! end
13904
13905 !! test
13906 pre-save transform: context links ("pipe trick") with namespace and parens
13907 !! options
13908 pst title=[[Ns:Somearticle (context)]]
13909 !! wikitext
13910 [[|Article]]
13911 !! html/php
13912 [[Ns:Article (context)|Article]]
13913 !! end
13914
13915 !! test
13916 pre-save transform: context links ("pipe trick") with namespace and comma
13917 !! options
13918 pst title=[[Ns:Somearticle, Context, Whatever]]
13919 !! wikitext
13920 [[|Article]]
13921 !! html/php
13922 [[Ns:Article, Context, Whatever|Article]]
13923 !! end
13924
13925 !! test
13926 pre-save transform: context links ("pipe trick") with namespace, comma and parens
13927 !! options
13928 pst title=[[Ns:Somearticle, Context (context)]]
13929 !! wikitext
13930 [[|Article]]
13931 !! html/php
13932 [[Ns:Article (context)|Article]]
13933 !! end
13934
13935 !! test
13936 pre-save transform: context links ("pipe trick") with namespace, parens and comma
13937 !! options
13938 pst title=[[Ns:Somearticle (IGNORED), Context]]
13939 !! wikitext
13940 [[|Article]]
13941 !! html/php
13942 [[Ns:Article, Context|Article]]
13943 !! end
13944
13945 !! test
13946 pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, T32149)
13947 !! options
13948 pst
13949 !! wikitext
13950 [[Article(context)|]]
13951 [[Bar:Article(context)|]]
13952 [[:Bar:Article(context)|]]
13953 [[|Article(context)]]
13954 [[Bar:X(Y)Z|]]
13955 [[:Bar:X(Y)Z|]]
13956 !! html/php
13957 [[Article(context)|Article]]
13958 [[Bar:Article(context)|Article]]
13959 [[:Bar:Article(context)|Article]]
13960 [[Article(context)]]
13961 [[Bar:X(Y)Z|X(Y)Z]]
13962 [[:Bar:X(Y)Z|X(Y)Z]]
13963 !! end
13964
13965 !! test
13966 pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, T32149)
13967 !! options
13968 pst
13969 !! wikitext
13970 [[Article (context)|]]
13971 [[Bar:Article (context)|]]
13972 [[:Bar:Article (context)|]]
13973 [[|Article (context)]]
13974 [[Bar:X (Y) Z|]]
13975 [[:Bar:X (Y) Z|]]
13976 !! html/php
13977 [[Article (context)|Article]]
13978 [[Bar:Article (context)|Article]]
13979 [[:Bar:Article (context)|Article]]
13980 [[Article (context)]]
13981 [[Bar:X (Y) Z|X (Y) Z]]
13982 [[:Bar:X (Y) Z|X (Y) Z]]
13983 !! end
13984
13985 !! test
13986 pre-save transform: context links ("pipe trick") with parens and no space (Korean style, T32149)
13987 !! options
13988 pst
13989 !! wikitext
13990 [[Article(context)|]]
13991 [[Bar:Article(context)|]]
13992 [[:Bar:Article(context)|]]
13993 [[|Article(context)]]
13994 [[Bar:X(Y)Z|]]
13995 [[:Bar:X(Y)Z|]]
13996 !! html/php
13997 [[Article(context)|Article]]
13998 [[Bar:Article(context)|Article]]
13999 [[:Bar:Article(context)|Article]]
14000 [[Article(context)]]
14001 [[Bar:X(Y)Z|X(Y)Z]]
14002 [[:Bar:X(Y)Z|X(Y)Z]]
14003 !! end
14004
14005 !! test
14006 pre-save transform: context links ("pipe trick") with commas (T23660)
14007 !! options
14008 pst
14009 !! wikitext
14010 [[Article (context), context|]]
14011 [[Article (context),context|]]
14012 [[Bar:Article (context), context|]]
14013 [[Bar:Article (context),context|]]
14014 [[:Bar:Article (context), context|]]
14015 [[:Bar:Article (context),context|]]
14016 !! html/php
14017 [[Article (context), context|Article]]
14018 [[Article (context),context|Article]]
14019 [[Bar:Article (context), context|Article]]
14020 [[Bar:Article (context),context|Article]]
14021 [[:Bar:Article (context), context|Article]]
14022 [[:Bar:Article (context),context|Article]]
14023 !! end
14024
14025 !! test
14026 Parsoid: backwards pipe trick
14027 !! wikitext
14028 [[|'''bar''']]
14029 !! html/php
14030 <p>[[|<b>bar</b>]]
14031 </p>
14032 !! html/parsoid
14033 <p>[[|<b>bar</b>]]</p>
14034 !! end
14035
14036 !! test
14037 pre-save transform: trim trailing empty lines
14038 !! options
14039 pst
14040 !! wikitext
14041 Empty lines are trimmed
14042
14043
14044
14045
14046 !! html/php
14047 Empty lines are trimmed
14048 !! end
14049
14050 !! test
14051 pre-save transform: Signature expansion
14052 !! options
14053 pst
14054 !! wikitext
14055 * ~~~
14056 * ~~~~
14057 * ~~~~~
14058 * <noinclude>~~~</noinclude>
14059 * <includeonly>~~~</includeonly>
14060 * <onlyinclude>~~~</onlyinclude>
14061 !! html/php
14062 * [[Special:Contributions/127.0.0.1|127.0.0.1]]
14063 * [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
14064 * 00:02, 1 January 1970 (UTC)
14065 * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
14066 * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
14067 * <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>
14068 !! end
14069
14070
14071 !! test
14072 ParserOutput flags from signature expansion (T84843)
14073 !! options
14074 pst
14075 showflags
14076 !! wikitext
14077 ~~~~
14078 !! html/php
14079 [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
14080 flags=user-signature
14081 !! end
14082
14083
14084 !! test
14085 pre-save transform: Signature expansion in nowiki tags (T2093)
14086 !! options
14087 pst disabled
14088 !! wikitext
14089 Shall not expand:
14090
14091 <nowiki>~~~~</nowiki>
14092
14093 <includeonly><nowiki>~~~~</nowiki></includeonly>
14094
14095 <noinclude><nowiki>~~~~</nowiki></noinclude>
14096
14097 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14098
14099 {{subst:Foo}} shall be converted to FOO
14100
14101 As well as inside noinclude/onlyinclude
14102 <noinclude>{{subst:Foo}}</noinclude>
14103 <onlyinclude>{{subst:Foo}}</onlyinclude>
14104
14105 But not inside includeonly
14106 <includeonly>{{subst:Foo}}</includeonly>
14107 !! html/php
14108 Shall not expand:
14109
14110 <nowiki>~~~~</nowiki>
14111
14112 <includeonly><nowiki>~~~~</nowiki></includeonly>
14113
14114 <noinclude><nowiki>~~~~</nowiki></noinclude>
14115
14116 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14117
14118 FOO shall be converted to FOO
14119
14120 As well as inside noinclude/onlyinclude
14121 <noinclude>FOO</noinclude>
14122 <onlyinclude>FOO</onlyinclude>
14123
14124 But not inside includeonly
14125 <includeonly>{{subst:Foo}}</includeonly>
14126 !! end
14127
14128 !! test
14129 Parsoid: Recognize nowiki with trailing space in tags
14130 !! options
14131 parsoid=wt2html
14132 !! wikitext
14133 <nowiki ><div>[[foo]]</nowiki >
14134
14135 a<nowiki / >b
14136
14137 c<nowiki />d
14138
14139 e<nowiki/ >f
14140 !! html
14141 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
14142 <p>ab</p>
14143 <p>cd</p>
14144 <p>ef</p>
14145 !! end
14146
14147 !! test
14148 Parsoid: Recognize nowiki with odd capitalization
14149 !! options
14150 parsoid=wt2html
14151 !! wikitext
14152 <noWikI ><div>[[foo]]</Nowiki >
14153 !! html
14154 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
14155 !! end
14156
14157
14158 !! test
14159 Parsoid: Escape nowiki with trailing space in tags
14160 !! options
14161 parsoid=html2wt
14162 !! html/parsoid
14163 <p>&lt;nowiki &gt; foo &lt/nowiki ></p>
14164 <p>a&lt;nowiki /&gt;b</p>
14165 <p>c&lt;nowiki/ &gt;d</p>
14166 !! wikitext
14167 &lt;nowiki &gt; foo &lt;/nowiki &gt;
14168
14169 a&lt;nowiki /&gt;b
14170
14171 c&lt;nowiki/ &gt;d
14172 !! end
14173
14174 !! test
14175 Parsoid: Escape weird noWikI capitalizations
14176 !! options
14177 parsoid=html2wt
14178 !! html/parsoid
14179 <p>&lt;noWikI &gt; foo &lt/NoWikI ></p>
14180 !! wikitext
14181 &lt;noWikI &gt; foo &lt;/NoWikI &gt;
14182 !! end
14183
14184 ###
14185 ### Message transform tests
14186 ###
14187 !! test
14188 message transform: magic variables
14189 !! options
14190 msg
14191 !! wikitext
14192 {{SITENAME}}
14193 !! html
14194 MediaWiki
14195 !! end
14196
14197 !! test
14198 message transform: should not transform wiki markup
14199 !! options
14200 msg
14201 !! wikitext
14202 ''test''
14203 !! html
14204 ''test''
14205 !! end
14206
14207 !! test
14208 message transform: <noinclude> in transcluded template (T6926)
14209 !! options
14210 msg
14211 !! wikitext
14212 {{Includes}}
14213 !! html
14214 Foobar
14215 !! end
14216
14217 !! test
14218 message transform: <onlyinclude> in transcluded template (T6926)
14219 !! options
14220 msg
14221 !! wikitext
14222 {{Includes2}}
14223 !! html
14224 Foo
14225 !! end
14226
14227 !! test
14228 {{#special:}} page name, known
14229 !! options
14230 msg
14231 !! wikitext
14232 {{#special:Recentchanges}}
14233 !! html
14234 Special:RecentChanges
14235 !! end
14236
14237 !! test
14238 {{#special:}} page name with subpage, known
14239 !! options
14240 msg
14241 !! wikitext
14242 {{#special:Recentchanges/param}}
14243 !! html
14244 Special:RecentChanges/param
14245 !! end
14246
14247 !! test
14248 {{#special:}} page name, unknown
14249 !! options
14250 msg
14251 !! wikitext
14252 {{#special:foobar nonexistent}}
14253 !! html
14254 Special:Foobar nonexistent
14255 !! end
14256
14257 !! test
14258 {{#speciale:}} page name, known
14259 !! options
14260 msg
14261 !! wikitext
14262 {{#speciale:Recentchanges}}
14263 !! html
14264 Special:RecentChanges
14265 !! end
14266
14267 !! test
14268 {{#speciale:}} page name with subpage, known
14269 !! options
14270 msg
14271 !! wikitext
14272 {{#speciale:Recentchanges/param}}
14273 !! html
14274 Special:RecentChanges/param
14275 !! end
14276
14277 !! test
14278 {{#speciale:}} page name, unknown
14279 !! options
14280 msg
14281 !! wikitext
14282 {{#speciale:foobar nonexistent}}
14283 !! html
14284 Special:Foobar_nonexistent
14285 !! end
14286
14287 ###
14288 ### Images
14289 ###
14290 ### For Parsoid-specific tests, see
14291 #### https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
14292
14293 !! test
14294 Simple image
14295 !! options
14296 parsoid=wt2html,wt2wt,html2html
14297 !! wikitext
14298 [[Image:foobar.jpg]]
14299 !! html/php
14300 <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>
14301 </p>
14302 !! html/parsoid
14303 <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>
14304 !! end
14305
14306 !! test
14307 Serialize simple image with span wrapper
14308 !! options
14309 parsoid=html2wt
14310 !! html/parsoid
14311 <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>
14312 !! wikitext
14313 [[File:Foobar.jpg]]
14314 !! end
14315
14316 !! test
14317 Simple image (using File: namespace, now canonical)
14318 !! wikitext
14319 [[File:Foobar.jpg]]
14320 !! html/php
14321 <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>
14322 </p>
14323 !! html/parsoid
14324 <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>
14325 !! end
14326
14327 !! test
14328 Right-aligned image
14329 !! wikitext
14330 [[File:Foobar.jpg|right]]
14331 !! html/php
14332 <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>
14333
14334 !! html/parsoid
14335 <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>
14336 !! end
14337
14338 !! test
14339 Image with caption
14340 !! wikitext
14341 [[File:Foobar.jpg|right|Caption text]]
14342 !! html/php
14343 <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>
14344
14345 !! html/parsoid
14346 <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>
14347 !! end
14348
14349 !! test
14350 Image with caption, T55312 #1
14351 !! wikitext
14352 [[File:Foobar.jpg|right|Caption page stuff]]
14353 !! html/php
14354 <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>
14355
14356 !! html/parsoid
14357 <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>
14358 !! end
14359
14360 !! test
14361 Image with caption, T55312 #2
14362 !! wikitext
14363 [[File:Foobar.jpg|right|Caption page=]]
14364 !! html/php
14365 <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>
14366
14367 !! html/parsoid
14368 <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>
14369 !! end
14370
14371 !! test
14372 Image with caption, T55312 #3
14373 !! wikitext
14374 [[File:Foobar.jpg|right|Caption page=stuff]]
14375 !! html/php
14376 <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>
14377
14378 !! html/parsoid
14379 <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>
14380 !! end
14381
14382 !! test
14383 Image caption with pipe entity
14384 !! wikitext
14385 [[File:Foobar.jpg|thumb|one &#x7C; two]]
14386 [[File:Foobar.jpg|thumb|one ''two'' &#x7C; three]]
14387 !! html/php
14388 <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>
14389 <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>
14390
14391 !! html/parsoid
14392 <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>
14393 <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>
14394 !! end
14395
14396 !! test
14397 Allow empty links in image captions (T62753)
14398 !! options
14399 thumbsize=220
14400 !! wikitext
14401 [[File:Foobar.jpg|thumb|Caption [[Link1]]
14402 [[]]
14403 [[Link2]]
14404 ]]
14405 !! html/php
14406 <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>
14407
14408 !! html/parsoid
14409 <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>
14410 [[]]
14411 <a rel="mw:WikiLink" href="./Link2" title="Link2" data-parsoid='{"stx":"simple","a":{"href":"./Link2"},"sa":{"href":"Link2"}}'>Link2</a>
14412 </figcaption></figure>
14413 !! end
14414
14415 !! test
14416 Titles in unlinked images (T23454)
14417 !! wikitext
14418 [[File:Foobar.jpg|link=|stuff]]
14419 !! html/php
14420 <p><img alt="stuff" src="http://example.com/images/3/3a/Foobar.jpg" title="stuff" width="1941" height="220" />
14421 </p>
14422 !! html/parsoid
14423 <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>
14424 !! end
14425
14426 !! test
14427 Link with empty target
14428 !! wikitext
14429 [[]]
14430 !! html
14431 <p>[[]]
14432 </p>
14433 !! end
14434
14435 !! test
14436 Image with link trail
14437 !! wikitext
14438 Linktrails should not work for images: [[File:Foobar.jpg]]s
14439 !! html/php
14440 <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
14441 </p>
14442 !! html/parsoid
14443 <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>
14444 !! end
14445
14446 !! test
14447 Image with empty attribute
14448 !! options
14449 parsoid=wt2html,wt2wt,html2html
14450 !! wikitext
14451 [[File:Foobar.jpg|right||Caption text]]
14452 !! html/php
14453 <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>
14454
14455 !! html/parsoid
14456 <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>
14457 !! end
14458
14459 !! test
14460 1. Block image with individual attributes from templates
14461 !! wikitext
14462 [[File:Foobar.jpg|thumb|{{echo|137px}}|This is a caption]]
14463 !! html/php
14464 <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>
14465
14466 !! html/parsoid
14467 <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>
14468 !! end
14469
14470 !! test
14471 2. Block Image with individual attributes from templates
14472 !! wikitext
14473 [[File:Foobar.jpg|{{echo|thumb}}|{{echo|137px}}|This is a caption]]
14474 !! html/php
14475 <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>
14476
14477 !! html/parsoid
14478 <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>
14479 !! end
14480
14481 !! test
14482 3. Inline image with individual attributes from templates
14483 !! wikitext
14484 [[File:Foobar.jpg|{{echo|50px}}]]
14485 !! html/php
14486 <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>
14487 </p>
14488 !! html/parsoid
14489 <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>
14490 !! end
14491
14492 ## Parsoid does not provide editing support for images where templates produce multiple image attributes.
14493 ## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
14494 !! test
14495 Image with multiple attributes from the same template
14496 !! wikitext
14497 [[File:Foobar.jpg|{{image_attribs}}]]
14498 !! html/php
14499 <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>
14500
14501 !! html/parsoid
14502 <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>
14503 !! end
14504
14505 !! test
14506 Image with link tails
14507 !! options
14508 thumbsize=220
14509 !! wikitext
14510 123[[File:Foobar.jpg]]456
14511 123[[File:Foobar.jpg|right]]456
14512 123[[File:Foobar.jpg|thumb]]456
14513 !! html/php
14514 <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
14515 </p>
14516 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
14517 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
14518
14519 !! html/php+tidy
14520 <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
14521 </p><p>
14522 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
14523 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
14524 </p>
14525 !! html/parsoid
14526 <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>
14527 <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>
14528 <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>
14529 !! end
14530
14531 !! test
14532 Image with multiple captions -- only last one is accepted
14533 !! wikitext
14534 [[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]]
14535 !! html/php
14536 <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>
14537
14538 !! html/parsoid
14539 <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>
14540 !! end
14541
14542 !! test
14543 Image with multiple widths -- use last
14544 !! wikitext
14545 [[File:Foobar.jpg|200px|300px|caption]]
14546 !! html/php
14547 <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>
14548 </p>
14549 !! html/parsoid
14550 <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>
14551 !! end
14552
14553 !! test
14554 Image with multiple alignments -- use first (T50664)
14555 !! options
14556 thumbsize=220
14557 !! wikitext
14558 [[File:Foobar.jpg|thumb|left|right|center|caption]]
14559
14560 [[File:Foobar.jpg|middle|text-top|caption]]
14561 !! html/php
14562 <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>
14563 <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>
14564 </p>
14565 !! html/parsoid
14566 <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>
14567 <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>
14568 !! end
14569
14570 !! test
14571 Image with width attribute at different positions
14572 !! wikitext
14573 [[File:Foobar.jpg|200px|right|Caption]]
14574 [[File:Foobar.jpg|right|200px|Caption]]
14575 [[File:Foobar.jpg|right|Caption|200px]]
14576 !! html/php
14577 <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>
14578 <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>
14579 <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>
14580
14581 !! html/parsoid
14582 <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>
14583 <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>
14584 <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>
14585 !! end
14586
14587 # a sad bit of backward-compatibility
14588 !! test
14589 Image with size specified with pxpx (T15500, T53628)
14590 !! options
14591 parsoid=wt2html,wt2wt,html2html
14592 !! wikitext
14593 [[File:Foobar.jpg|20pxpx]]
14594 [[File:Foobar.jpg|200x20pxpx]]
14595 !! html/php
14596 <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>
14597 <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>
14598 </p>
14599 !! html/parsoid
14600 <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>
14601 !! end
14602
14603 !! test
14604 Image with link parameter, wiki target
14605 !! wikitext
14606 [[File:Foobar.jpg|link=Main Page]]
14607 !! html/php
14608 <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>
14609 </p>
14610 !! html/parsoid
14611 <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>
14612 !! end
14613
14614 # parsoid T51293 (part 1)
14615 !! test
14616 Image with link parameter, URL target
14617 !! wikitext
14618 [[File:Foobar.jpg|link=http://example.com/]]
14619 !! html/php
14620 <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>
14621 </p>
14622 !! html/parsoid
14623 <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>
14624 !! end
14625
14626 # parsoid T51293 (part 2)
14627 !! test
14628 Image with link parameter, protocol-less URL target
14629 !! wikitext
14630 [[File:Foobar.jpg|link=//example.com/]]
14631 !! html/php
14632 <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>
14633 </p>
14634 !! html/parsoid
14635 <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>
14636 !! end
14637
14638 !! test
14639 Escaping non-block captions (T107435)
14640 !! options
14641 parsoid={
14642 "modes": ["wt2wt"],
14643 "changes": [
14644 ["[typeof~='mw:Image']", "attr", "data-mw", "{\"caption\": \"|\"}"]
14645 ]
14646 }
14647 !! wikitext
14648 [[Image:Foobar.jpg|caption]]
14649 !! wikitext/edited
14650 [[Image:Foobar.jpg|<nowiki>|</nowiki>]]
14651 !! end
14652
14653 # wgExternalLinkTarget not supported by Parsoid
14654 !! test
14655 Image with link parameter, wgExternalLinkTarget
14656 !! wikitext
14657 [[Image:foobar.jpg|link=http://example.com/]]
14658 !! config
14659 wgExternalLinkTarget='foobar'
14660 !! html/php
14661 <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>
14662 </p>
14663 !! end
14664
14665 !! test
14666 Image with link parameter, wgNoFollowLinks set to false
14667 !! wikitext
14668 [[Image:foobar.jpg|link=http://example.com/]]
14669 !! config
14670 wgNoFollowLinks=false
14671 !! html/php
14672 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14673 </p>
14674 !! end
14675
14676 !! test
14677 Image with link parameter, wgNoFollowDomainExceptions
14678 !! wikitext
14679 [[Image:foobar.jpg|link=http://example.com/]]
14680 !! config
14681 wgNoFollowDomainExceptions='example.com'
14682 !! html/php
14683 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14684 </p>
14685 !! end
14686
14687 # wgExternalLinkTarget not supported by Parsoid
14688 !! test
14689 Image with link parameter, wgExternalLinkTarget, unnamed parameter
14690 !! wikitext
14691 [[Image:foobar.jpg|link=http://example.com/|Title]]
14692 !! config
14693 wgExternalLinkTarget='foobar'
14694 !! html/php
14695 <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>
14696 </p>
14697 !! end
14698
14699 !! test
14700 Image with empty link parameter
14701 !! wikitext
14702 [[File:Foobar.jpg|link=]]
14703 !! html/php
14704 <p><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" />
14705 </p>
14706 !! html/parsoid
14707 <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>
14708 !! end
14709
14710 !! test
14711 Image with link parameter (wiki target) and unnamed parameter
14712 !! wikitext
14713 [[File:Foobar.jpg|link=Main_Page|Title]]
14714 !! html/php
14715 <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>
14716 </p>
14717 !! html/parsoid
14718 <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>
14719 !! end
14720
14721 !! test
14722 Image with link parameter (URL target) and unnamed parameter
14723 !! wikitext
14724 [[File:Foobar.jpg|link=http://example.com/|Title]]
14725 !! html/php
14726 <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>
14727 </p>
14728 !! html/parsoid
14729 <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>
14730 !! end
14731
14732 !! test
14733 Thumbnail image with link parameter
14734 !! options
14735 thumbsize=220
14736 parsoid=wt2html,wt2wt,html2html
14737 !! wikitext
14738 [[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
14739 !! html/php
14740 <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>
14741
14742 !! html/parsoid
14743 <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>
14744 !! end
14745
14746 !! test
14747 Manually-specified thumbnail image
14748 !! options
14749 thumbsize=220
14750 !! wikitext
14751 [[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
14752 !! html/php
14753 <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>
14754
14755 !! html/parsoid
14756 <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>
14757 !! end
14758
14759 !! test
14760 Manually-specified thumbnail image with explicit link to wiki page
14761 !! options
14762 thumbsize=220
14763 parsoid=wt2html,wt2wt,html2html
14764 !! wikitext
14765 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
14766 !! html/php
14767 <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>
14768
14769 !! html/parsoid
14770 <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>
14771 !! end
14772
14773 !! test
14774 Manually-specified thumbnail image with explicit link to url
14775 !! options
14776 thumbsize=220
14777 parsoid=wt2html,wt2wt,html2html
14778 !! wikitext
14779 [[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
14780 !! html/php
14781 <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>
14782
14783 !! html/parsoid
14784 <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>
14785 !! end
14786
14787 !! test
14788 Manually-specified thumbnail image with explicit no link
14789 !! options
14790 thumbsize=220
14791 parsoid=wt2html,wt2wt,html2html
14792 !! wikitext
14793 [[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
14794 !! html/php
14795 <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>
14796
14797 !! html/parsoid
14798 <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>
14799 !! end
14800
14801 !! test
14802 Manually-specified thumbnail image with explicit link and alt text
14803 !! options
14804 thumbsize=220
14805 parsoid=wt2html,wt2wt,html2html
14806 !! wikitext
14807 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
14808 !! html/php
14809 <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>
14810
14811 !! html/parsoid
14812 <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>
14813 !! end
14814
14815 !! test
14816 Image with frame and link
14817 !! options
14818 parsoid=wt2html,wt2wt,html2html
14819 !! wikitext
14820 [[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
14821 !! html/php
14822 <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>
14823
14824 !! html/parsoid
14825 <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>
14826 !! end
14827
14828 !! test
14829 Image with frame and link and explicit alt
14830 !! options
14831 parsoid=wt2html,wt2wt,html2html
14832 !! wikitext
14833 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]]
14834 !! html/php
14835 <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>
14836
14837 !! html/parsoid
14838 <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>
14839 !! end
14840
14841 !! test
14842 Image with wiki markup in implicit alt
14843 !! wikitext
14844 [[Image:Foobar.jpg|testing '''bold''' in alt]]
14845
14846 [[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
14847 !! html/php
14848 <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>
14849 </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>
14850 </p>
14851 !! html/parsoid
14852 <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>
14853
14854 <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>
14855 !! end
14856
14857 !! test
14858 Alt image option should handle most kinds of wikitext without barfing
14859 !! wikitext
14860 [[Image:Foobar.jpg|thumb|This is the image caption|alt=This is a [[link]] and a {{echo|''bold template''}}.]]
14861 !! html/php
14862 <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>
14863
14864 !! html/parsoid
14865 <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>
14866 !! end
14867
14868 !! test
14869 Image with table with attributes in caption
14870 !! options
14871 parsoid=wt2html,html2html
14872 !! wikitext
14873 [[File:Foobar.jpg|thumb|
14874 {| class="123" |
14875 |- class="456" |
14876 | ha
14877 |}
14878 ]]
14879 !! html/parsoid
14880 <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>
14881 <table class="123">
14882 <tbody><tr class="456" data-parsoid='{"startTagSrc":"|-"}'>
14883 <td> ha</td></tr>
14884 </tbody></table>
14885 </figcaption></figure>
14886 !! end
14887
14888 !! test
14889 Image with table with rows from templates in caption
14890 !! wikitext
14891 [[File:Foobar.jpg|thumb|
14892 {|
14893 {{echo|{{!}} hi}}
14894 |}
14895 ]]
14896 !! html/parsoid
14897 <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>
14898 <table>
14899 <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>
14900 </tbody></table>
14901 </figcaption></figure>
14902 !! end
14903
14904 !! test
14905 Image with nested tables in caption
14906 !! wikitext
14907 [[File:Foobar.jpg|thumb|Foo<br />
14908 {|
14909 |
14910 {|
14911 |z
14912 |}
14913 |}
14914 ]]
14915 !! html/parsoid
14916 <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}'/>
14917 <table>
14918 <tbody><tr><td>
14919 <table>
14920 <tbody><tr><td>z</td></tr>
14921 </tbody></table></td></tr>
14922 </tbody></table>
14923 </figcaption></figure>
14924 !! end
14925
14926 !! test
14927 Image with heading and horizontal rule in caption
14928 !! wikitext
14929 [[File:Foobar.jpg|thumb|
14930 ===Testing===
14931 123
14932 --------------
14933 ]]
14934 !! html/php
14935 <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>
14936
14937 !! html/parsoid
14938 <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>
14939 <h3 id="Testing">Testing</h3>
14940 123
14941 <hr data-parsoid='{"extra_dashes":10}'/>
14942 </figcaption></figure>
14943 !! end
14944
14945 ###################
14946 # Conflicting image format options.
14947 # First option specified should 'win'.
14948 # All three cases in each test should be identical.
14949
14950 !! test
14951 Image with 'frameless' first.
14952 !! options
14953 parsoid=wt2html,wt2wt,html2html
14954 !! wikitext
14955 [[File:Foobar.jpg|frameless|caption]]
14956
14957 [[File:Foobar.jpg|frameless|frame|caption]]
14958
14959 [[File:Foobar.jpg|frameless|thumb|caption]]
14960 !! html/php
14961 <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>
14962 </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>
14963 </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>
14964 </p>
14965 !! html/parsoid
14966 <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>
14967 <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>
14968 <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>
14969 !! end
14970
14971 !! test
14972 Image with 'frame' first.
14973 !! options
14974 parsoid=wt2html,wt2wt,html2html
14975 !! wikitext
14976 [[File:Foobar.jpg|frame|caption]]
14977 [[File:Foobar.jpg|frame|frameless|caption]]
14978 [[File:Foobar.jpg|frame|thumb|caption]]
14979 !! html/php
14980 <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>
14981 <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>
14982 <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>
14983
14984 !! html/parsoid
14985 <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>
14986 <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>
14987 <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>
14988 !! end
14989
14990 !! test
14991 Image with 'thumb' first.
14992 !! options
14993 parsoid=wt2html,wt2wt,html2html
14994 !! wikitext
14995 [[File:Foobar.jpg|thumb|caption]]
14996 [[File:Foobar.jpg|thumb|frameless|caption]]
14997 [[File:Foobar.jpg|thumb|frame|caption]]
14998 !! html/php
14999 <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>
15000 <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>
15001 <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>
15002
15003 !! html/parsoid
15004 <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>
15005 <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>
15006 <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>
15007 !! end
15008
15009 ###################
15010 # Image sizing.
15011 # See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
15012 # and https://phabricator.wikimedia.org/T64258
15013 # Foobar has actual size of 1941x220
15014 # 1. Thumbs & frameless always reduce, can't be enlarged unless it's
15015 # a scalable format.
15016 # 2. Framed images always ignore size options; always render at default size.
15017 # 3. "Unspecified format" and border are the only types which can be
15018 # enlarged.
15019
15020 !! test
15021 Image: unspecified format and border enlarge
15022 !! options
15023 parsoid=wt2html,wt2wt,html2html
15024 !! wikitext
15025 [[File:Foobar.jpg|2000px]]
15026
15027 [[File:Foobar.jpg|border|2000px]]
15028 !! html/php
15029 <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>
15030 </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>
15031 </p>
15032 !! html/parsoid
15033 <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>
15034 <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>
15035 !! end
15036
15037 !! test
15038 Image: "unspecified format" and border reduce
15039 !! options
15040 parsoid=wt2html,wt2wt,html2html
15041 !! wikitext
15042 [[File:Foobar.jpg|1000px]]
15043
15044 [[File:Foobar.jpg|border|1000px]]
15045 !! html/php
15046 <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>
15047 </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>
15048 </p>
15049 !! html/parsoid
15050 <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>
15051 <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>
15052 !! end
15053
15054 !! test
15055 Image: thumbs reduce
15056 !! options
15057 parsoid=wt2html,wt2wt,html2html
15058 !! wikitext
15059 [[File:Foobar.jpg|thumb|50px]]
15060 !! html/php
15061 <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>
15062
15063 !! html/parsoid
15064 <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>
15065 !! end
15066
15067 !! test
15068 Image: bitmap thumbs can't be enlarged past original size, but vector can.
15069 !! options
15070 parsoid=wt2html,wt2wt,html2html
15071 !! wikitext
15072 [[File:Foobar.jpg|thumb|2000px]]
15073
15074 [[File:Foobar.svg|thumb|2000px]]
15075 !! html/php
15076 <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>
15077 <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>
15078
15079 !! html/parsoid
15080 <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>
15081 <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>
15082 !! end
15083
15084 !! test
15085 Image: frameless can reduce in size
15086 !! options
15087 parsoid=wt2html,wt2wt,html2html
15088 !! wikitext
15089 [[File:Foobar.jpg|frameless|50px]]
15090 !! html/php
15091 <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>
15092 </p>
15093 !! html/parsoid
15094 <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>
15095 !! end
15096
15097 !! test
15098 Image: bitmap frameless can't be enlarged past original size, but vector can
15099 !! options
15100 parsoid=wt2html,wt2wt,html2html
15101 !! wikitext
15102 [[File:Foobar.jpg|frameless|2000px]]
15103
15104 [[File:Foobar.svg|frameless|2000px]]
15105 !! html/php
15106 <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>
15107 </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>
15108 </p>
15109 !! html/parsoid
15110 <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>
15111 <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>
15112 !! end
15113
15114 !! test
15115 Image: framed images are always unscaled.
15116 !! options
15117 parsoid=wt2html,wt2wt,html2html
15118 !! wikitext
15119 [[File:Foobar.jpg|frame]]
15120
15121 [[File:Foobar.jpg|frame|50px]]
15122
15123 [[File:Foobar.jpg|frame|50x50px]]
15124
15125 [[File:Foobar.jpg|frame|2000px]]
15126 !! html/php
15127 <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>
15128 <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>
15129 <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>
15130 <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>
15131
15132 !! html/parsoid
15133 <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>
15134 <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>
15135 <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>
15136 <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>
15137 !! end
15138
15139 ###################
15140
15141 !! test
15142 Link to image page- image page normally doesn't exists, hence edit link
15143 Add test with existing image page
15144 #<p><a href="/wiki/File:Test" title="Image:Test">Image:test</a>
15145 !! wikitext
15146 [[:Image:test]]
15147 !! html
15148 <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>
15149 </p>
15150 !! end
15151
15152 !! test
15153 T20784 Link to non-existent image page with caption should use caption as link text
15154 !! wikitext
15155 [[:Image:test|caption]]
15156 !! html
15157 <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>
15158 </p>
15159 !! end
15160
15161 !! test
15162 Frameless image caption with a free URL
15163 !! wikitext
15164 [[File:Foobar.jpg|http://example.com]]
15165 !! html/php
15166 <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>
15167 </p>
15168 !! html/parsoid
15169 <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>
15170 !! end
15171
15172 !! test
15173 Thumbnail image caption with a free URL
15174 !! options
15175 thumbsize=220
15176 !! wikitext
15177 [[File:Foobar.jpg|thumb|http://example.com]]
15178 !! html/php
15179 <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>
15180
15181 !! html/parsoid
15182 <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>
15183 !! end
15184
15185 !! test
15186 Thumbnail image caption with a free URL and explicit alt
15187 !! options
15188 thumbsize=220
15189 parsoid=wt2html,wt2wt,html2html
15190 !! wikitext
15191 [[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]]
15192 !! html/php
15193 <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>
15194
15195 !! html/parsoid
15196 <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>
15197 !! end
15198
15199 !! test
15200 SVG thumbnails with no language set
15201 !! options
15202 !! wikitext
15203 [[File:Foobar.svg|thumb|caption]]
15204 !! html/php
15205 <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>
15206
15207 !! html/parsoid
15208 <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>
15209 !! end
15210
15211 !! test
15212 SVG thumbnails with language de
15213 !! options
15214 parsoid=wt2html,wt2wt,html2html
15215 !! wikitext
15216 [[File:Foobar.svg|thumb|caption|lang=de]]
15217 !! html/php
15218 <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>
15219
15220 !! html/parsoid
15221 <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>
15222 !! end
15223
15224 !! test
15225 SVG thumbnails with invalid language code
15226 !! options
15227 parsoid=wt2html,wt2wt,html2html
15228 !! wikitext
15229 [[File:Foobar.svg|thumb|caption|lang=invalid:language:code]]
15230 !! html/php
15231 <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>
15232
15233 !! html/parsoid
15234 <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>
15235 !! end
15236
15237 !! test
15238 T3887: A ISBN with a thumbnail
15239 !! wikitext
15240 [[File:Foobar.jpg|thumb|ISBN 1235467890]]
15241 !! html/php
15242 <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>
15243
15244 !! html/parsoid
15245 <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>
15246 !! end
15247
15248 !! test
15249 T3887: A RFC with a thumbnail
15250 !! wikitext
15251 [[File:Foobar.jpg|thumb|This is RFC 12354]]
15252 !! html/php
15253 <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>
15254
15255 !! html/parsoid
15256 <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>
15257 !! end
15258
15259 !! test
15260 T3887: A mailto link with a thumbnail
15261 !! wikitext
15262 [[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
15263 !! html/php
15264 <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>
15265
15266 !! html/parsoid
15267 <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>
15268 !! end
15269
15270 # Pending resolution to T2368
15271 !! test
15272 T2648: Frameless image caption with a link
15273 !! wikitext
15274 [[File:Foobar.jpg|text with a [[link]] in it]]
15275 !! html/php
15276 <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>
15277 </p>
15278 !! html/parsoid
15279 <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>
15280 !! end
15281
15282 !! test
15283 T2648: Frameless image caption with a link (suffix)
15284 !! wikitext
15285 [[File:Foobar.jpg|text with a [[link]]foo in it]]
15286 !! html/php
15287 <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>
15288 </p>
15289 !! html/parsoid
15290 <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>
15291 !! end
15292
15293 !! test
15294 T2648: Frameless image caption with an interwiki link
15295 !! wikitext
15296 [[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
15297 !! html/php
15298 <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>
15299 </p>
15300 !! html/parsoid
15301 <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>
15302 !! end
15303
15304 !! test
15305 T2648: Frameless image caption with a piped interwiki link
15306 !! wikitext
15307 [[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
15308 !! html/php
15309 <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>
15310 </p>
15311 !! html/parsoid
15312 <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>
15313 !! end
15314
15315 !! test
15316 T107474: Frameless image caption with <nowiki>
15317 !! wikitext
15318 [[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]]
15319 !! html/parsoid
15320 <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>
15321 !! end
15322
15323 !! test
15324 Escape HTML special chars in image alt text
15325 !! wikitext
15326 [[File:Foobar.jpg|& < > "]]
15327 !! html/php
15328 <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>
15329 </p>
15330 !! html/parsoid
15331 <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>
15332 !! end
15333
15334 !! test
15335 Escape HTML special chars in image alt text with LanguageConverter
15336 !! options
15337 language=zh
15338 !! wikitext
15339 [[File:Foobar.jpg|& < > "]]
15340 !! html/php
15341 <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>
15342 </p>
15343 !! html/parsoid
15344 <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>
15345 !! end
15346
15347 !! test
15348 Entities in file name and attributes
15349 !! wikitext
15350 [[File:7%25 solution.gif|manualthumb=7%25 solution.gif|link=7%25 solution|[[7%25 solution]]]]
15351 !! html/php
15352 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=7%25_solution.gif" class="new" title="File:7% solution.gif">7% solution</a>
15353 </p>
15354 !! html/parsoid
15355 <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>
15356 !! end
15357
15358 !! test
15359 T2499: Alt text should have &#1234;, not &amp;1234;
15360 !! wikitext
15361 [[File:Foobar.jpg|&#9792;]]
15362 !! html/php
15363 <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>
15364 </p>
15365 !! html/parsoid
15366 <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>
15367 !! end
15368
15369 !! test
15370 Broken image caption with link
15371 !! options
15372 parsoid=wt2html,wt2wt,html2html
15373 !! wikitext
15374 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
15375 !! html/php
15376 <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.
15377 </p>
15378 !! html/parsoid
15379 <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>
15380 !! end
15381
15382 !! test
15383 Image caption containing another image
15384 !! wikitext
15385 [[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
15386 !! html/php
15387 <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>
15388
15389 !! html/parsoid
15390 <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>
15391 !! end
15392
15393 !! test
15394 Image: caption containing a newline
15395 !! wikitext
15396 [[File:Foobar.jpg|This
15397 *is some text]]
15398 !! html/php
15399 <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>
15400 </p>
15401 !! html/parsoid
15402 <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>
15403 !!end
15404
15405 !!test
15406 Image: caption containing leading space
15407 (The leading space should not trigger nowiki escaping in wt2wt mode)
15408 !! wikitext
15409 [[File:Foobar.jpg|thumb| bar]]
15410 !! html/php
15411 <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>
15412
15413 !! html/parsoid
15414 <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>
15415 !!end
15416
15417 # html/php output not have newlines after table, td, th, etc. because
15418 # Linker::makeThumbLink2() replaces the newlines with spaces since
15419 # the table is inside a caption.
15420 # FIXME: Verify if that circa 2004 fix is still required.
15421 !! test
15422 Image: caption containing a table
15423 !! options
15424 parsoid=wt2html,wt2wt,html2html
15425 !! wikitext
15426 [[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
15427 {|
15428 !Foo!!Bar
15429 |-
15430 |Foo1||Bar1
15431 |}
15432 and some more text.]]
15433 !! html/php
15434 <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>
15435
15436 !! html/parsoid
15437 <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
15438 <table>
15439 <tbody>
15440 <tr><th>Foo</th><th>Bar</th></tr>
15441 <tr>
15442 <td>Foo1</td>
15443 <td>Bar1</td></tr></tbody></table>and some more text.</figcaption></figure>
15444 !! end
15445
15446 !! test
15447 T5090: External links other than http: in image captions
15448 !! wikitext
15449 [[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
15450 !! html/php
15451 <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>
15452
15453 !! html/parsoid
15454 <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>
15455 !! end
15456
15457 !! test
15458 Custom class
15459 !! options
15460 parsoid=wt2html,wt2wt,html2html
15461 !! wikitext
15462 [[Image:foobar.jpg|a|class=b]]
15463 !! html/php
15464 <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>
15465 </p>
15466 !! html/parsoid
15467 <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>
15468 !! end
15469
15470 !! test
15471 Localized image handling (1).
15472 !! options
15473 parsoid=wt2html,wt2wt,html2html
15474 language=es
15475 !! wikitext
15476 [[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]]
15477 !! html/php
15478 <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>
15479
15480 !! html/parsoid
15481 <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>
15482 !! end
15483
15484 !! test
15485 Localized image handling (2).
15486 !! options
15487 thumbsize=220
15488 parsoid=wt2html,wt2wt,html2html
15489 language=es
15490 !! wikitext
15491 [[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
15492 !! html/php
15493 <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>
15494
15495 !! html/parsoid
15496 <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>
15497 !! end
15498
15499 !! test
15500 Localized image handling (3).
15501 !! options
15502 language=fa
15503 parsoid=html2wt
15504 !! html/parsoid
15505 <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>
15506 !! wikitext
15507 [[File:Foobar.jpg|بندانگشتی]]
15508 !! end
15509
15510 !! test
15511 "border", "frameless" and "class" attributes on an image.
15512 !! options
15513 thumbsize=220
15514 parsoid=wt2html,wt2wt,html2html
15515 !! wikitext
15516 [[File:Foobar.jpg|frameless|border|class=extra|caption]]
15517 !! html/php
15518 <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>
15519 </p>
15520 !! html/parsoid
15521 <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>
15522 !! end
15523
15524 # Note that 'right' is the default alignment, despite the misspelled 'righ' below
15525 !! test
15526 Invalid image attributes (T64500)
15527 !! options
15528 thumbsize=220
15529 parsoid=wt2html,wt2wt,html2html
15530 !! wikitext
15531 [[File:Foobar.jpg|thumb|float|left|caption]]
15532
15533 [[File:Foobar.jpg|thumb|righ|caption]]
15534
15535 [[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]]
15536 !! html/php
15537 <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>
15538 <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>
15539 <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>
15540
15541 !! html/parsoid
15542 <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>
15543 <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>
15544 <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>
15545 !! end
15546
15547 !! article
15548 File:Barfoo.jpg
15549 !! text
15550 #REDIRECT [[File:Barfoo.jpg]]
15551 !! endarticle
15552
15553 # FIXME: Parsoid should run this test -- but we'd need to teach the
15554 # mockAPI about the redirected Barfoo.jpg image.
15555 !! test
15556 Redirected image
15557 !! wikitext
15558 [[Image:Barfoo.jpg]]
15559 !! html/php
15560 <p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
15561 </p>
15562 !! end
15563
15564 !! test
15565 Missing image with uploads disabled
15566 !! options
15567 wgEnableUploads=0
15568 !! wikitext
15569 [[File:Foobaz.jpg]]
15570 !! html/php
15571 <p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a>
15572 </p>
15573 !! html/parsoid
15574 <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>
15575 !! end
15576
15577 # Parsoid-specific testing for images
15578 # https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
15579 # Currently imperfect due to a flaw in the Parsoid testrunner
15580 # Work in progress
15581 # THESE TESTS SHOULD BE MOVED UP and merged with the php-specific
15582 # image tests.
15583
15584 !! test
15585 Parsoid-specific image handling - simple image with size and middle alignment
15586 !! wikitext
15587 [[File:Foobar.jpg|middle|50px]]
15588 !! html/parsoid
15589 <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>
15590 !! end
15591
15592 !! test
15593 Parsoid-specific image handling - simple image with size, middle alignment, non-standard namespace alias
15594 !! options
15595 parsoid=wt2wt,wt2html,html2html
15596 !! wikitext
15597 [[Image:Foobar.jpg|middle|50px]]
15598 !! html/parsoid
15599 <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>
15600 !! end
15601
15602 !! test
15603 Parsoid-specific image handling - simple image with size and middle alignment (existing content)
15604 !! wikitext
15605 [[File:Foobar.jpg|50px|middle]]
15606 !! html/parsoid
15607 <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>
15608 !! end
15609
15610 !! test
15611 Parsoid-specific image handling - simple image with size and middle alignment and non-standard namespace name
15612 !! options
15613 parsoid=wt2html,wt2wt,html2html
15614 !! wikitext
15615 [[Image:Foobar.jpg|50px|middle]]
15616 !! html/parsoid
15617 <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>
15618 !! end
15619
15620 !! test
15621 Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
15622 !! wikitext
15623 [[File:Foobar.jpg|500x10px|baseline|caption]]
15624 !! html/parsoid
15625 <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>
15626 !! end
15627
15628 !! test
15629 Parsoid-specific image handling - simple image with border and size spec
15630 !! wikitext
15631 [[File:Foobar.jpg|50px|border|caption]]
15632 !! html/parsoid
15633 <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>
15634 !! end
15635
15636 !! test
15637 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15638 !! options
15639 parsoid=wt2html,html2html
15640 !! wikitext
15641 [[File:Foobar.jpg|left|baseline|thumb|caption content]]
15642 !! html/parsoid
15643 <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>
15644 !! end
15645
15646 !! test
15647 Parsoid-specific image handling - thumbnail with halign, valign, and caption (existing content)
15648 !! options
15649 parsoid=wt2html,html2html
15650 !! wikitext
15651 [[File:Foobar.jpg|thumb|left|baseline|caption content]]
15652 !! html/parsoid
15653 <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>
15654 !! end
15655
15656 !! test
15657 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption
15658 !! options
15659 parsoid=wt2html,html2html
15660 !! wikitext
15661 [[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
15662 !! html/parsoid
15663 <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>
15664 !! end
15665
15666 !! test
15667 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption (existing content)
15668 !! options
15669 parsoid=wt2html,html2html
15670 !! wikitext
15671 [[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
15672 !! html/parsoid
15673 <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>
15674 !! end
15675
15676 !! test
15677 Parsoid-specific image handling - framed image with specific size and caption (size is ignored)
15678 !! options
15679 parsoid=wt2html,wt2wt,html2html
15680 !! wikitext
15681 [[File:Foobar.jpg|frame|500x50px|caption]]
15682 !! html/parsoid
15683 <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>
15684 !! end
15685
15686 !! test
15687 Parsoid-specific image handling - framed image with specific size, halign, valign, and caption (size is ignored)
15688 !! options
15689 parsoid=wt2html,html2html
15690 !! wikitext
15691 [[File:Foobar.jpg|left|baseline|frame|500x50px|caption]]
15692 !! html/parsoid
15693 <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>
15694 !! end
15695
15696 !! test
15697 Parsoid-specific image handling - frameless image with specific size, border, and caption
15698 !! wikitext
15699 [[File:Foobar.jpg|frameless|442x50px|border|caption]]
15700 !! html/parsoid
15701 <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>
15702 !! end
15703
15704 !! test
15705 Parsoid-specific image handling - simple image with a formatted caption
15706 !! wikitext
15707 [[File:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]]
15708 !! html/parsoid
15709 <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>
15710 !! end
15711
15712 !! test
15713 Parsoid-specific image handling - caption with a template in it
15714 !! wikitext
15715 [[File:Foobar.jpg|thumb|200x23px|This caption has a {{echo|transclusion}} in it.]]
15716 !! html/parsoid
15717 <figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/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>
15718 !! end
15719
15720 !! test
15721 Parsoid-specific image handling - caption with unbalanced tags in it
15722 !! options
15723 parsoid=wt2html,wt2wt,html2html
15724 !! wikitext
15725 foo
15726 [[File:Foobar.jpg|thumb|200x200px|This caption has a <center>unbalanced tag in it.]]
15727 bar
15728 !! html/parsoid
15729 <p>foo</p>
15730 <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>
15731 <p>bar</p>
15732 !! end
15733
15734 !! test
15735 Parsoid-specific image handling - empty caption (1)
15736 !! options
15737 parsoid=wt2html,wt2wt
15738 !! wikitext
15739 [[File:Foobar.jpg|thumb|]]
15740 !! html/parsoid
15741 <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>
15742 !! end
15743
15744 # empty captions don't get serialized unless we're in the "round trip" case
15745 !! test
15746 Parsoid-specific image handling - empty caption (2)
15747 !! options
15748 parsoid=html2wt
15749 !! html/parsoid
15750 <figure class="mw-default-size" typeof="mw:Image/Thumb">
15751 <a href="./File:Foobar.jpg">
15752 <img resource="./File:Foobar.jpg"
15753 src="//example.com/images/3/3a/Foobar.jpg"
15754 data-file-width="1941" data-file-height="220" data-file-type="bitmap"
15755 height="25" width="220"/>
15756 </a>
15757 <figcaption></figcaption>
15758 </figure>
15759 !! wikitext
15760 [[File:Foobar.jpg|thumb]]
15761 !! end
15762
15763 !! test
15764 Parsoid-specific image handling - whitespace caption
15765 !! wikitext
15766 [[File:Foobar.jpg|thumb| ]]
15767 !! html/parsoid
15768 <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>
15769 !! end
15770
15771 !! test
15772 Parsoid-specific image handling - lang option
15773 !! wikitext
15774 foo
15775 [[File:Foobar.svg|lang=de|caption]]
15776 bar
15777 !! html/parsoid
15778 <p>foo
15779 <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>
15780 bar</p>
15781 !! end
15782
15783 ## Edge case bugs in Parsoid from T93580
15784 !! test
15785 T93580: 1. Templated <ref> inside block images
15786 !! wikitext
15787 [[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]]
15788
15789 <references />
15790 !! html/parsoid
15791 <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>
15792
15793 <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>
15794 !! end
15795
15796 !! test
15797 T93580: 2. <ref> inside inline images
15798 !! wikitext
15799 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: <ref>foo</ref>]]
15800
15801 <references />
15802 !! html/parsoid
15803 <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>
15804
15805 <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>
15806 !! end
15807
15808 !! test
15809 T93580: 3. Templated <ref> inside inline images
15810 !! wikitext
15811 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}]]
15812
15813 <references />
15814 !! html/parsoid
15815 <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>
15816
15817 <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>
15818 !! end
15819
15820 ###
15821 ### Subpages
15822 ###
15823 !! article
15824 Subpage test/subpage
15825 !! text
15826 foo
15827 !! endarticle
15828
15829 !! test
15830 Subpage link
15831 !! options
15832 subpage title=[[Subpage test]]
15833 !! wikitext
15834 [[/subpage]]
15835 !! html
15836 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
15837 </p>
15838 !! end
15839
15840 !! test
15841 Subpage noslash link
15842 !! options
15843 subpage title=[[Subpage test]]
15844 !! wikitext
15845 [[/subpage/]]
15846 !! html
15847 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
15848 </p>
15849 !! end
15850
15851 !! article
15852 Subpage test/1/2/subpage
15853 !! text
15854 blah
15855 !! endarticle
15856
15857 !! test
15858 Relative subpage noslash link
15859 !! options
15860 parsoid=wt2wt,wt2html,html2html
15861 subpage title=[[Subpage test/1/2/3/4]]
15862 !! wikitext
15863 [[../../subpage/]]
15864
15865 [[../../subpage]]
15866 !! html/php
15867 <p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a>
15868 </p><p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage test/1/2/subpage</a>
15869 </p>
15870 !! html/parsoid
15871 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a></p>
15872 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage_test/1/2/subpage</a></p>
15873 !! end
15874
15875 !! test
15876 Parsoid: dot-slash prefixed wikilinks
15877 !! wikitext
15878 [[./foo]]
15879
15880 [[././bar]]
15881
15882 [[././baz/]]
15883 !! html/php
15884 <p>[[./foo]]
15885 </p><p>[[././bar]]
15886 </p><p>[[././baz/]]
15887 </p>
15888 !! html/parsoid
15889 <p>[[./foo]]
15890 </p><p>[[././bar]]
15891 </p><p>[[././baz/]]
15892 </p>
15893 !! end
15894
15895 !! test
15896 Render invalid page names as plain text (T53090)
15897 !! wikitext
15898 [[./../foo|bar]]
15899 [[foo�|bar]]
15900 [[foo/.|bar]]
15901 [[foo/..|bar]]
15902 [[foo~~~bar]]
15903 [[foo>bar]]
15904 [[foo[bar]]
15905 [[.]]
15906 [[..]]
15907 [[foo././bar]]
15908 [[foo[http://example.com]xyz]]
15909
15910 [[{{echo|./../foo}}|bar]]
15911 [[{{echo|foo/.}}|bar]]
15912 [[{{echo|foo/..}}|bar]]
15913 [[{{echo|foo~~~~bar}}]]
15914 [[{{echo|foo>bar}}]]
15915 [[{{echo|foo././bar}}]]
15916 [[{{echo|foo{bar}}]]
15917 [[{{echo|foo}bar}}]]
15918 [[{{echo|foo[bar}}]]
15919 [[{{echo|foo]bar}}]]
15920 [[{{echo|foo<bar}}]]
15921 !!html/php
15922 <p>[[./../foo|bar]]
15923 [[foo�|bar]]
15924 [[foo/.|bar]]
15925 [[foo/..|bar]]
15926 [[foo~~~bar]]
15927 [[foo&gt;bar]]
15928 [[foo[bar]]
15929 [[.]]
15930 [[..]]
15931 [[foo././bar]]
15932 [[foo<a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>xyz]]
15933 </p><p>[[./../foo|bar]]
15934 [[foo/.|bar]]
15935 [[foo/..|bar]]
15936 [[foo~~~~bar]]
15937 [[foo&gt;bar]]
15938 [[foo././bar]]
15939 [[foo{bar]]
15940 [[foo}bar]]
15941 [[foo[bar]]
15942 [[foo]bar]]
15943 [[foo&lt;bar]]
15944 </p>
15945 !!html/parsoid
15946 <p>[[./../foo|bar]]
15947 [[foo�|bar]]
15948 [[foo/.|bar]]
15949 [[foo/..|bar]]
15950 [[foo~~~bar]]
15951 [[foo>bar]]
15952 [[foo[bar]]
15953 [[.]]
15954 [[..]]
15955 [[foo././bar]]
15956 [[foo<a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>xyz]]</p>
15957
15958 <p>[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"./../foo"}},"i":0}}]}'>./../foo</span>|bar]]
15959 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/."}},"i":0}}]}'>foo/.</span>|bar]]
15960 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/.."}},"i":0}}]}'>foo/..</span>|bar]]
15961 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo~~~~bar"}},"i":0}}]}'>foo~~~~bar</span>]]
15962 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo>bar"}},"i":0}}]}'>foo>bar</span>]]
15963 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo././bar"}},"i":0}}]}'>foo././bar</span>]]
15964 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo{bar"}},"i":0}}]}'>foo{bar</span>]]
15965 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}bar"}},"i":0}}]}'>foo}bar</span>]]
15966 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo[bar"}},"i":0}}]}'>foo[bar</span>]]
15967 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo]bar"}},"i":0}}]}'>foo]bar</span>]]
15968 [[<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>
15969 !!end
15970
15971 !! test
15972 Disabled subpages
15973 !! wikitext
15974 [[/subpage]]
15975 !! html
15976 <p><a href="/index.php?title=/subpage&amp;action=edit&amp;redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a>
15977 </p>
15978 !! end
15979
15980 !! test
15981 T2561: {{/Subpage}}
15982 !! options
15983 subpage title=[[Page]]
15984 !! wikitext
15985 {{/Subpage}}
15986 !! html
15987 <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>
15988 </p>
15989 !! end
15990
15991 ###
15992 ### Categories
15993 ###
15994 !! article
15995 Category:MediaWiki User's Guide
15996 !! text
15997 blah
15998 !! endarticle
15999
16000 !! test
16001 Link to category
16002 !! wikitext
16003 [[:Category:MediaWiki User's Guide]]
16004 !! html
16005 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User&#39;s Guide">Category:MediaWiki User's Guide</a>
16006 </p>
16007 !! end
16008
16009 !! test
16010 Simple category
16011 !! options
16012 cat
16013 !! wikitext
16014 [[Category:MediaWiki User's Guide]]
16015 !! html/php
16016 cat=MediaWiki_User's_Guide sort=
16017 !! html/parsoid
16018 <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"}}'/>
16019 !! end
16020
16021 !! test
16022 PAGESINCATEGORY invalid title fatal (r33546 fix)
16023 !! wikitext
16024 {{PAGESINCATEGORY:<bogus>}}
16025 !! html
16026 <p>0
16027 </p>
16028 !! end
16029
16030 !! test
16031 Category with different sort key
16032 !! options
16033 cat
16034 !! wikitext
16035 [[Category:MediaWiki User's Guide|Foo]]
16036 !! html/php
16037 cat=MediaWiki_User's_Guide sort=Foo
16038 !! html/parsoid
16039 <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"}}'/>
16040 !! end
16041
16042 !! test
16043 Category with identical sort key
16044 !! options
16045 cat
16046 !! wikitext
16047 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
16048 !! html/php
16049 cat=MediaWiki_User's_Guide sort=MediaWiki User's Guide
16050 !! html/parsoid
16051 <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"}}'/>
16052 !! end
16053
16054 !! test
16055 Category with empty sort key
16056 !! options
16057 cat
16058 pst
16059 !! wikitext
16060 [[Category:MediaWiki User's Guide|]]
16061 !! html/php
16062 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
16063 !! end
16064
16065 !! test
16066 Category with empty sort key and parentheses
16067 !! options
16068 cat
16069 pst
16070 !! wikitext
16071 [[Category:Foo (bar)|]]
16072 !! html/php
16073 [[Category:Foo (bar)|Foo]]
16074 !! end
16075
16076 !! test
16077 Category with link tail
16078 !! options
16079 cat
16080 pst
16081 !! wikitext
16082 123[[Category:Foo]]456
16083 !! html/php
16084 123[[Category:Foo]]456
16085 !! end
16086
16087 !! test
16088 Category with template
16089 !! options
16090 cat
16091 pst
16092 !! wikitext
16093 [[Category:{{echo|Foo}}]]
16094 !! html/php
16095 [[Category:{{echo|Foo}}]]
16096 !! end
16097
16098 !! test
16099 Category with template in sort key
16100 !! options
16101 cat
16102 pst
16103 !! wikitext
16104 [[Category:Foo|{{echo|Bar}}]]
16105 !! html/php
16106 [[Category:Foo|{{echo|Bar}}]]
16107 !! end
16108
16109 !! test
16110 Category with template in sort key and title
16111 !! options
16112 cat
16113 pst
16114 !! wikitext
16115 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16116 !! html/php
16117 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16118 !! end
16119
16120 ## We used to, but no longer wt2wt this test since the default serializer
16121 ## will normalize all categories to serialize on their own line.
16122 ## This wikitext usage is going to be fairly uncommon in production and
16123 ## selser will take care of preserving formatting in those scenarios.
16124 !! test
16125 Category / paragraph interactions
16126 !! options
16127 parsoid=wt2html
16128 !! wikitext
16129 Foo [[Category:Baz]] Bar
16130
16131 Foo [[Category:Baz]]
16132 Bar
16133
16134 Foo
16135 [[Category:Baz]]
16136 Bar
16137
16138 Foo
16139 [[Category:Baz]] Bar
16140
16141 Foo
16142 [[Category:Baz]]
16143 [[Category:Baz]]
16144 [[Category:Baz]]
16145 Bar
16146
16147 [[Category:Baz]]
16148 [[Category:Baz]]
16149 [[Category:Baz]]
16150
16151 [[Category:Baz]]
16152 {{echo|[[Category:Baz]]}}
16153 [[Category:Baz]]
16154 !! html/php
16155 <p>Foo Bar
16156 </p><p>Foo
16157 Bar
16158 </p><p>Foo
16159 Bar
16160 </p><p>Foo Bar
16161 </p><p>Foo
16162 Bar
16163 </p>
16164 !! html/parsoid
16165 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16166 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16167 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16168 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16169 <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>
16170 <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}}]}'/>
16171 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
16172 !! end
16173
16174 ## We used to, but no longer wt2wt this test since the default serializer
16175 ## will normalize all categories to serialize on their own line.
16176 ## This wikitext usage is going to be fairly uncommon in production and
16177 ## selser will take care of preserving formatting in those scenarios.
16178 ##
16179 ## The whitespace on the empty line is part of the test. Please do not delete
16180 !! test
16181 1. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16182 !! options
16183 parsoid=wt2html
16184 !! wikitext
16185 This
16186
16187 [[Category:Foo]] and this should be part of same paragraph (not an indent-pre)
16188
16189 {{echo|[[Category:Foo]] and so should this!}}
16190 !! html/php
16191 <p>This and this should be part of same paragraph (not an indent-pre) and so should this!
16192 </p>
16193 !! html/parsoid
16194 <p>This
16195
16196 <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of same paragraph (not an indent-pre)
16197
16198 <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>
16199 !! end
16200
16201 ## Parsoid will not try to wt2wt this while preserving newlines because
16202 ## it suppresses excess newlines within list items -- and we don't want to
16203 ## introduce a special case just for categories, which is, in reality somewhat
16204 ## odd behavior -- categories are unlikely to be used in list items like this
16205 ## in top-level pages and are only likely to show up in template-generated
16206 ## list items where this RT-ing is a non-issue.
16207 ##
16208 ## The whitespace on the empty line is part of the test. Please do not delete
16209 !! test
16210 2. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16211 !! options
16212 parsoid=wt2html
16213 !! wikitext
16214 * This
16215
16216 [[Category:Foo]] and this should be part of the same list item
16217 * So should this
16218
16219 {{echo|[[Category:Foo]] and this should be part of the same list item}}
16220 !! html
16221 <ul><li>This and this should be part of the same list item</li>
16222 <li>So should this and this should be part of the same list item</li></ul>
16223 !! html/parsoid
16224 <ul>
16225 <li>This <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of the same list item</li>
16226 <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>
16227 </ul>
16228 !! end
16229
16230 ## Newlines and categories that follow the last item of a list
16231 ## are treated differently because this (list followed by categories)
16232 ## is an extremely common pattern on wikis.
16233 !! test
16234 3. Categories and newlines: newline suppression for last list item should RT properly
16235 !! wikitext
16236 *a
16237 *b
16238
16239 [[Category:Foo]]
16240
16241 [[Category:Bar]]
16242 [[Category:Baz]]
16243
16244 :c
16245
16246 [[Category:C]]
16247
16248 ;d
16249
16250 [[Category:D]]
16251 !! html/parsoid
16252 <ul><li>a</li>
16253 <li>b</li></ul>
16254
16255 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
16256
16257 <link rel="mw:PageProp/Category" href="./Category:Bar"/>
16258 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
16259
16260 <dl><dd>c</dd></dl>
16261
16262 <link rel="mw:PageProp/Category" href="./Category:C"/>
16263
16264 <dl><dt>d</dt></dl>
16265
16266 <link rel="mw:PageProp/Category" href="./Category:D"/>
16267 !! end
16268
16269 !! test
16270 4. Categories and newlines: newline suppression for last list item should RT properly
16271 !! wikitext
16272 *a
16273 ****b
16274
16275 [[Category:Foo]]
16276 !! html/parsoid
16277 <ul><li>a
16278 <ul><li><ul><li><ul><li>b</li></ul></li></ul></li></ul></li></ul>
16279
16280 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16281 !! end
16282
16283 ## only wt2html for this to make sure the algo only applies to the rightmost path
16284 !! test
16285 5. Categories and newlines: migrateTrailingCategories dom pass should only run on the rightmost path of nested lists
16286 !! options
16287 parsoid=wt2html
16288 !! wikitext
16289 *a
16290 **b
16291 [[Category:Foo]]
16292 *c
16293 **d
16294 [[Category:Foo]]
16295 !! html/parsoid
16296 <ul><li>a
16297 <ul><li>b
16298 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul></li>
16299 <li>c
16300 <ul><li>d</li></ul></li></ul>
16301 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16302 !! end
16303
16304 ## We used to, but no longer wt2wt this test since the default serializer
16305 ## will normalize all categories to serialize on their own line.
16306 ## This wikitext usage is going to be fairly uncommon in production and
16307 ## selser will take care of preserving formatting in those scenarios.
16308 !! test
16309 6. Categories and newlines: migrateTrailingCategories dom pass should not migrate categories not preceded by newlines
16310 !! options
16311 parsoid=wt2html
16312 !! wikitext
16313 *a [[Category:Foo]]
16314 !! html/parsoid
16315 <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>
16316 !! end
16317
16318 # This test also demonstrates because of newline+category tunneling
16319 # through the list hander, template wrapping doesn't expand to the
16320 # containing list when the list item swallows the category.
16321 !! test
16322 7. Categories and newlines: migrateTrailingCategories dom pass should leave template content alone
16323 !! wikitext
16324 *{{echo|a
16325 [[Category:Foo]]}}
16326 !! html/parsoid
16327 <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
16328 </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>
16329 !! end
16330
16331 !! test
16332 8. Categories and newlines: migrateTrailingCategories dom pass should not get tripped by intervening templates
16333 !! wikitext
16334 *a
16335
16336 {{echo|[[Category:Foo]]
16337 [[Category:Bar]]}}
16338 [[Category:Baz]]
16339 !! html/parsoid
16340 <ul><li>a</li></ul>
16341
16342 <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">
16343 </span><link rel="mw:PageProp/Category" href="./Category:Bar" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
16344 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
16345 !! end
16346
16347 !! test
16348 Categories and newlines: migrateTrailingCategories dom pass should not get tripped by comments and whitespace
16349 !! wikitext
16350 *a
16351
16352 [[Category:Bar]]<!--boo1--> <!--boo2-->
16353 [[Category:Baz]]<!--boo3--> <!--boo4-->
16354 !! html/parsoid
16355 <ul><li>a</li></ul>
16356
16357 <link rel="mw:PageProp/Category" href="./Category:Bar"/><!--boo1--> <!--boo2-->
16358 <link rel="mw:PageProp/Category" href="./Category:Baz"/><!--boo3--> <!--boo4-->
16359 !! end
16360
16361 !! test
16362 Categories and newlines: should behave properly with linkprefix (T87753)
16363 !! options
16364 language=ar
16365 !! wikitext
16366 foo bar
16367 foo bar
16368 [[تصنيف:Foo]]
16369 [[تصنيف:Bar]]
16370 !! html/php
16371 <p>foo bar
16372 foo bar
16373 </p>
16374 !! html/parsoid
16375 <p>foo bar
16376 foo bar</p>
16377 <link rel="mw:PageProp/Category" href="./تصنيف:Foo"/>
16378 <link rel="mw:PageProp/Category" href="./تصنيف:Bar"/>
16379 !! end
16380
16381 !! test
16382 No regressions on internal links following category (T174639)
16383 !! options
16384 parsoid=wt2html,html2html
16385 !! wikitext
16386 [[Category:Foo]]<div>a
16387
16388 [[Foo]]</div>
16389 !! html/php
16390 <div>a
16391 <a href="/wiki/Foo" title="Foo">Foo</a></div>
16392
16393 !! html/parsoid
16394 <link rel="mw:PageProp/Category" href="./Category:Foo"/><div>a
16395
16396 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></div>
16397 !! end
16398
16399 # Note that Parsoid differs slightly from PHP due to T175421
16400 !! test
16401 11. Special case where only newlines separate links (T175416)
16402 !! options
16403 parsoid=wt2html,html2html
16404 !! wikitext
16405 [[Category:Foo]]
16406
16407 [[Foo]][[es:Alimento]]
16408
16409 [[Foo]]
16410 !! html/php
16411 <p><br />
16412 <a href="/wiki/Foo" title="Foo">Foo</a>
16413 </p><p><a href="/wiki/Foo" title="Foo">Foo</a>
16414 </p>
16415 !! html/parsoid
16416 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
16417
16418 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p><link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
16419
16420 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p>
16421 !! end
16422
16423 !! test
16424 Category links with multiple namespaces
16425 !! wikitext
16426 [[Category:Project:Foo]]
16427 !! html/parsoid
16428 <link rel="mw:PageProp/Category" href="./Category:Project:Foo" />
16429 !! end
16430
16431 !! test
16432 Parsoid: Serialize link to category page with colon escape
16433 !! options
16434 parsoid
16435 !! wikitext
16436
16437 [[:Category:Foo]]
16438 [[:Category:Foo|Bar]]
16439 !! html
16440 <p>
16441 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Category:Foo</a>
16442 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Bar</a>
16443 </p>
16444 !! end
16445
16446 # We used to, but no longer wt2wt this test since the default serializer
16447 # will normalize all categories to serialize on their own line.
16448 # This wikitext usage is going to be fairly uncommon in production and
16449 # selser will take care of preventing whitespace insertion if this
16450 # occurs in an article.
16451 #
16452 # html2html disabled for the same reason (whitespace insertion between
16453 # x and y).
16454 #
16455 # html2wt disabled because it localizes the "Category" namespace.
16456 !! test
16457 Link prefix/suffixes aren't applied to category links
16458 !! options
16459 parsoid=wt2html
16460 language=is
16461 !! wikitext
16462 x[[Category:Foo]]y
16463 !! html/php
16464 <p>xy
16465 </p>
16466 !! html/parsoid
16467 <p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p>
16468 !! end
16469
16470 !! test
16471 Link prefix/suffixes aren't applied to language links
16472 !! options
16473 parsoid=wt2html
16474 language=is
16475 !! wikitext
16476 x[[es:Foo]]y
16477 !! html/php
16478 <p>xy
16479 </p>
16480 !! html/parsoid
16481 <p>x<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo" data-parsoid=""/>y</p>
16482 !! end
16483
16484 !! test
16485 Parsoid: Serialize link to file page with colon escape
16486 !! options
16487 parsoid
16488 !! wikitext
16489
16490 [[:File:Foo.png]]
16491 [[:File:Foo.png|Bar]]
16492 !! html
16493 <p>
16494 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">File:Foo.png</a>
16495 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">Bar</a>
16496 </p>
16497 !! end
16498
16499 !! test
16500 Parsoid: Serialize a genuine category link without colon escape
16501 !! options
16502 parsoid
16503 !! wikitext
16504 [[Category:Foo]]
16505 [[Category:Foo|Bar]]
16506 !! html
16507 <link rel="mw:PageProp/Category" href="./Category:Foo">
16508 <link rel="mw:PageProp/Category" href="./Category:Foo#Bar">
16509 !! end
16510
16511 !! test
16512 Normalize hrefs properly before testing for invalid link targets (T72894)
16513 !! options
16514 parsoid=html2wt
16515 !! html/parsoid
16516 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/>
16517 !! wikitext
16518 [[Category:Toxine bactérienne]]
16519 !! end
16520
16521 !! test
16522 Parsoid: Defaultsort
16523 !! wikitext
16524 {{DEFAULTSORT:Foo}}
16525 !! html/parsoid
16526 <meta property="mw:PageProp/categorydefaultsort" content="Foo"/>
16527 !! end
16528
16529 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
16530 # But, this is a limitation of our representation and is documented in
16531 # TemplateHandler.js in processSpecialMagicWord
16532 !! test
16533 Parsoid: Defaultsort (template-generated)
16534 !! wikitext
16535 {{{{echo|DEFAULTSORT}}:Foo}}
16536 !! html/parsoid
16537 <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"}]]}'/>
16538 !! end
16539
16540 ###
16541 ### Inter-language links
16542 ###
16543 !! test
16544 Interlanguage links
16545 !! options
16546 ill
16547 !! wikitext
16548 [[es:Alimento]]
16549 [[fr:Nourriture]]
16550 [[zh:食品]]
16551 !! html/php
16552 es:Alimento fr:Nourriture zh:食品
16553 !! html/parsoid
16554 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
16555 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Nourriture"/>
16556 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/食品"/>
16557 !! end
16558
16559 !! test
16560 Duplicate interlanguage links (T26502)
16561 !! options
16562 ill
16563 !! wikitext
16564 [[es:1]]
16565 [[es:2]]
16566 [[fr:1]]
16567 [[fr:2]]
16568 !! html/php
16569 es:1 fr:1
16570 !! html/parsoid
16571 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/1"/>
16572 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/2"/>
16573 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/1"/>
16574 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/2"/>
16575 !! end
16576
16577 ###
16578 ### Sections
16579 ###
16580 !! test
16581 Basic section headings
16582 !! wikitext
16583 ==Headline 1==
16584 Some text
16585
16586 ==Headline 2==
16587 More
16588 ===Smaller headline===
16589 Blah blah
16590 !! html
16591 <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>
16592 <p>Some text
16593 </p>
16594 <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>
16595 <p>More
16596 </p>
16597 <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>
16598 <p>Blah blah
16599 </p>
16600 !! end
16601
16602 !! test
16603 Section headings with TOC
16604 !! wikitext
16605 ==Headline 1==
16606 ===Subheadline 1===
16607 =====Skipping a level=====
16608 ======Skipping a level======
16609
16610 ==Headline 2==
16611 Some text
16612 ===Another headline===
16613 !! html
16614 <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>
16615 <ul>
16616 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
16617 <ul>
16618 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
16619 <ul>
16620 <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>
16621 <ul>
16622 <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>
16623 </ul>
16624 </li>
16625 </ul>
16626 </li>
16627 </ul>
16628 </li>
16629 <li class="toclevel-1 tocsection-5"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
16630 <ul>
16631 <li class="toclevel-2 tocsection-6"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
16632 </ul>
16633 </li>
16634 </ul>
16635 </div>
16636
16637 <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>
16638 <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>
16639 <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>
16640 <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>
16641 <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>
16642 <p>Some text
16643 </p>
16644 <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>
16645
16646 !! end
16647
16648 !! test
16649 TOC anchors don't collide
16650 !! wikitext
16651 __FORCETOC__
16652 ==Headline 2==
16653 ==Headline==
16654 ==Headline 2==
16655 ==Headline==
16656 !! html/php
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_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
16660 <li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
16661 <li class="toclevel-1 tocsection-3"><a href="#Headline_2_2"><span class="tocnumber">3</span> <span class="toctext">Headline 2</span></a></li>
16662 <li class="toclevel-1 tocsection-4"><a href="#Headline_3"><span class="tocnumber">4</span> <span class="toctext">Headline</span></a></li>
16663 </ul>
16664 </div>
16665
16666 <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>
16667 <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>
16668 <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>
16669 <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>
16670
16671 !! end
16672
16673 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
16674 # Parsoid html2wt direction adds <nowiki> for level 7 and up.
16675 !! test
16676 Handling of sections up to level 6 and beyond
16677 !! options
16678 parsoid=wt2html
16679 !! wikitext
16680 =Level 1 Heading=
16681 ==Level 2 Heading==
16682 ===Level 3 Heading===
16683 ====Level 4 Heading====
16684 =====Level 5 Heading=====
16685 ======Level 6 Heading======
16686 =======Level 7 Heading=======
16687 ========Level 8 Heading========
16688 =========Level 9 Heading=========
16689 ==========Level 10 Heading==========
16690 !! html/php
16691 <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>
16692 <ul>
16693 <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
16694 <ul>
16695 <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>
16696 <ul>
16697 <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>
16698 <ul>
16699 <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>
16700 <ul>
16701 <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>
16702 <ul>
16703 <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>
16704 <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>
16705 <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>
16706 <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>
16707 <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>
16708 </ul>
16709 </li>
16710 </ul>
16711 </li>
16712 </ul>
16713 </li>
16714 </ul>
16715 </li>
16716 </ul>
16717 </li>
16718 </ul>
16719 </div>
16720
16721 <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>
16722 <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>
16723 <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>
16724 <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>
16725 <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>
16726 <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>
16727 <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>
16728 <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>
16729 <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>
16730 <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>
16731
16732 !! html/parsoid
16733 <h1 id="Level_1_Heading" data-parsoid='{}'>Level 1 Heading</h1>
16734 <h2 id="Level_2_Heading" data-parsoid='{}'>Level 2 Heading</h2>
16735 <h3 id="Level_3_Heading" data-parsoid='{}'>Level 3 Heading</h3>
16736 <h4 id="Level_4_Heading" data-parsoid='{}'>Level 4 Heading</h4>
16737 <h5 id="Level_5_Heading" data-parsoid='{}'>Level 5 Heading</h5>
16738 <h6 id="Level_6_Heading" data-parsoid='{}'>Level 6 Heading</h6>
16739 <h6 id="=Level_7_Heading=" data-parsoid='{}'><span id=".3DLevel_7_Heading.3D" typeof="mw:FallbackId"></span>=Level 7 Heading=</h6>
16740 <h6 id="==Level_8_Heading==" data-parsoid='{}'><span id=".3D.3DLevel_8_Heading.3D.3D" typeof="mw:FallbackId"></span>==Level 8 Heading==</h6>
16741 <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>
16742 <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>
16743 !! end
16744
16745 !! test
16746 TOC regression (T11764)
16747 !! wikitext
16748 ==title 1==
16749 ===title 1.1===
16750 ====title 1.1.1====
16751 ===title 1.2===
16752 ==title 2==
16753 ===title 2.1===
16754 !! html
16755 <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>
16756 <ul>
16757 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16758 <ul>
16759 <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>
16760 <ul>
16761 <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>
16762 </ul>
16763 </li>
16764 <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>
16765 </ul>
16766 </li>
16767 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16768 <ul>
16769 <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>
16770 </ul>
16771 </li>
16772 </ul>
16773 </div>
16774
16775 <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>
16776 <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>
16777 <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>
16778 <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>
16779 <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>
16780 <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>
16781
16782 !! end
16783
16784 !! test
16785 TOC for heading containing <span id="..."></span> (T96153)
16786 !! wikitext
16787 __FORCETOC__
16788 ==<span id="old-anchor"></span>New title==
16789 !! html/php
16790 <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>
16791 <ul>
16792 <li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
16793 </ul>
16794 </div>
16795
16796 <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>
16797
16798 !! end
16799
16800 !! test
16801 TOC with wgMaxTocLevel=3 (T8204)
16802 !! options
16803 wgMaxTocLevel=3
16804 !! wikitext
16805 ==title 1==
16806 ===title 1.1===
16807 ====title 1.1.1====
16808 ===title 1.2===
16809 ==title 2==
16810 ===title 2.1===
16811 !! html
16812 <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>
16813 <ul>
16814 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16815 <ul>
16816 <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>
16817 <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>
16818 </ul>
16819 </li>
16820 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16821 <ul>
16822 <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>
16823 </ul>
16824 </li>
16825 </ul>
16826 </div>
16827
16828 <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>
16829 <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>
16830 <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>
16831 <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>
16832 <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>
16833 <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>
16834
16835 !! end
16836
16837 !! test
16838 TOC with wgMaxTocLevel=3 and two level four headings (T8204)
16839 !! options
16840 wgMaxTocLevel=3
16841 !! wikitext
16842 ==Section 1==
16843 ===Section 1.1===
16844 ====Section 1.1.1====
16845 ====Section 1.1.1.1====
16846 ==Section 2==
16847 !! html
16848 <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>
16849 <ul>
16850 <li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
16851 <ul>
16852 <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>
16853 </ul>
16854 </li>
16855 <li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li>
16856 </ul>
16857 </div>
16858
16859 <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>
16860 <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>
16861 <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>
16862 <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>
16863 <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>
16864
16865 !! end
16866
16867
16868 !! test
16869 Resolving duplicate section names
16870 !! wikitext
16871 ==Foo bar==
16872 ==Foo bar==
16873 !! html
16874 <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>
16875 <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>
16876
16877 !! end
16878
16879 !! test
16880 Resolving duplicate section names with differing case (T12721)
16881 !! wikitext
16882 ==Foo bar==
16883 ==Foo Bar==
16884 !! html
16885 <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>
16886 <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>
16887
16888 !! end
16889
16890 !! article
16891 Template:sections
16892 !! text
16893 ===Section 1===
16894 ==Section 2==
16895 !! endarticle
16896
16897 !! test
16898 Template with sections, __NOTOC__
16899 !! wikitext
16900 __NOTOC__
16901 ==Section 0==
16902 {{sections}}
16903 ==Section 4==
16904 !! html
16905 <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>
16906 <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>
16907 <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>
16908 <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>
16909
16910 !! end
16911
16912 !! test
16913 __NOEDITSECTION__ keyword
16914 !! wikitext
16915 __NOEDITSECTION__
16916 ==Section 1==
16917 ==Section 2==
16918 !! html
16919 <h2><span class="mw-headline" id="Section_1">Section 1</span></h2>
16920 <h2><span class="mw-headline" id="Section_2">Section 2</span></h2>
16921
16922 !! end
16923
16924 !! test
16925 Link inside a section heading
16926 !! wikitext
16927 ==Section with a [[Main Page|link]] in it==
16928 !! html
16929 <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>
16930
16931 !! end
16932
16933 !! test
16934 TOC regression (T14077)
16935 !! wikitext
16936 __TOC__
16937 ==title 1==
16938 ===title 1.1===
16939 ==title 2==
16940 !! html
16941 <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>
16942 <ul>
16943 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16944 <ul>
16945 <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>
16946 </ul>
16947 </li>
16948 <li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li>
16949 </ul>
16950 </div>
16951
16952 <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>
16953 <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>
16954 <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>
16955
16956 !! end
16957
16958 !! test
16959 T3219 URL next to image (good)
16960 !! wikitext
16961 http://example.com [[File:Foobar.jpg]]
16962 !! html/php
16963 <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>
16964 </p>
16965 !! html/parsoid
16966 <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>
16967 !!end
16968
16969 # Parsoid doesn't wt2wt this cleanly because it adds <nowiki>s.
16970 !! test
16971 Short headings with trailing space should match behavior of Parser::doHeadings (T21910)
16972 !! options
16973 parsoid=wt2html,html2html
16974 !! wikitext
16975 ===
16976 The line above must have a trailing space!
16977 === <!--
16978 --> <!-- -->
16979 But just in case it doesn't...
16980 !! html/php
16981 <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>
16982 <p>The line above must have a trailing space!
16983 </p>
16984 <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>
16985 <p>But just in case it doesn't...
16986 </p>
16987 !! html/parsoid
16988 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
16989 <p>The line above must have a trailing space!</p>
16990 <h1 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h1> <!--
16991 --> <!-- -->
16992 <p>But just in case it doesn't...</p>
16993 !! end
16994
16995 !! test
16996 Header with special characters (T27462)
16997 !! wikitext
16998 The tooltips shall not show entities to the user (ie. be double escaped)
16999
17000 ==text > text==
17001 section 1
17002
17003 ==text < text==
17004 section 2
17005
17006 ==text & text==
17007 section 3
17008
17009 ==text ' text==
17010 section 4
17011
17012 ==text " text==
17013 section 5
17014 !! html/php
17015 <p>The tooltips shall not show entities to the user (ie. be double escaped)
17016 </p>
17017 <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>
17018 <ul>
17019 <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>
17020 <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>
17021 <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>
17022 <li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li>
17023 <li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li>
17024 </ul>
17025 </div>
17026
17027 <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>
17028 <p>section 1
17029 </p>
17030 <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>
17031 <p>section 2
17032 </p>
17033 <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>
17034 <p>section 3
17035 </p>
17036 <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>
17037 <p>section 4
17038 </p>
17039 <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>
17040 <p>section 5
17041 </p>
17042 !! html/parsoid
17043 <p>The tooltips shall not show entities to the user (ie. be double escaped)</p>
17044
17045 <h2 id="text_>_text"><span id="text_.3E_text" typeof="mw:FallbackId"></span>text > text</h2>
17046 <p>section 1</p>
17047
17048 <h2 id="text_&lt;_text"><span id="text_.3C_text" typeof="mw:FallbackId"></span>text &lt; text</h2>
17049 <p>section 2</p>
17050
17051 <h2 id="text_&amp;_text"><span id="text_.26_text" typeof="mw:FallbackId"></span>text &amp; text</h2>
17052 <p>section 3</p>
17053
17054 <h2 id="text_'_text"><span id="text_.27_text" typeof="mw:FallbackId"></span>text ' text</h2>
17055 <p>section 4</p>
17056
17057 <h2 id='text_"_text'><span id="text_.22_text" typeof="mw:FallbackId"></span>text " text</h2>
17058 <p>section 5</p>
17059 !! end
17060
17061 !! test
17062 Header with space, plus and underscore as entity
17063 !! wikitext
17064 Id should not contain + for spaces
17065
17066 ==Space between Text==
17067 section 1
17068
17069 ==Space-Entity&#32;between&#32;Text==
17070 section 2
17071
17072 ==Plus+between+Text==
17073 section 3
17074
17075 ==Plus-Entity&#43;between&#43;Text==
17076 section 4
17077
17078 ==Underscore_between_Text==
17079 section 5
17080
17081 ==Underscore-Entity&#95;between&#95;Text==
17082 section 6
17083
17084 [[#Space between Text]]
17085 [[#Space-Entity&#32;between&#32;Text]]
17086 [[#Plus+between+Text]]
17087 [[#Plus-Entity&#43;between&#43;Text]]
17088 [[#Underscore_between_Text]]
17089 [[#Underscore-Entity&#95;between&#95;Text]]
17090 !! html/php
17091 <p>Id should not contain + for spaces
17092 </p>
17093 <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>
17094 <ul>
17095 <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>
17096 <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>
17097 <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>
17098 <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>
17099 <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>
17100 <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>
17101 </ul>
17102 </div>
17103
17104 <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>
17105 <p>section 1
17106 </p>
17107 <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>
17108 <p>section 2
17109 </p>
17110 <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>
17111 <p>section 3
17112 </p>
17113 <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>
17114 <p>section 4
17115 </p>
17116 <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>
17117 <p>section 5
17118 </p>
17119 <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>
17120 <p>section 6
17121 </p><p><a href="#Space_between_Text">#Space between Text</a>
17122 <a href="#Space-Entity_between_Text">#Space-Entity&#32;between&#32;Text</a>
17123 <a href="#Plus.2Bbetween.2BText">#Plus+between+Text</a>
17124 <a href="#Plus-Entity.2Bbetween.2BText">#Plus-Entity&#43;between&#43;Text</a>
17125 <a href="#Underscore_between_Text">#Underscore_between_Text</a>
17126 <a href="#Underscore-Entity_between_Text">#Underscore-Entity&#95;between&#95;Text</a>
17127 </p>
17128 !! html/parsoid
17129 <p>Id should not contain + for spaces</p>
17130
17131 <h2 id="Space_between_Text">Space between Text</h2>
17132 <p>section 1</p>
17133
17134 <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>
17135 <p>section 2</p>
17136
17137 <h2 id="Plus+between+Text"><span id="Plus.2Bbetween.2BText" typeof="mw:FallbackId"></span>Plus+between+Text</h2>
17138 <p>section 3</p>
17139
17140 <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>
17141 <p>section 4</p>
17142
17143 <h2 id="Underscore_between_Text">Underscore_between_Text</h2>
17144 <p>section 5</p>
17145
17146 <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>
17147 <p>section 6</p>
17148
17149 <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>
17150 <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>
17151 <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>
17152 <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>
17153 <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>
17154 <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>
17155 !! end
17156
17157 # Parsoid html2wt disabled because it adds padding spaces around =
17158 !! test
17159 Headers with excess '=' characters
17160 (Are similar tests necessary beyond the 1st level?)
17161 !! options
17162 parsoid=wt2html,wt2wt,html2html
17163 !! wikitext
17164 =foo==
17165 ==foo=
17166 =''italic'' heading==
17167 ==''italic'' heading=
17168 !! html/php
17169 <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>
17170 <ul>
17171 <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
17172 <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
17173 <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>
17174 <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>
17175 </ul>
17176 </div>
17177
17178 <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>
17179 <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>
17180 <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>
17181 <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>
17182
17183 !! html/parsoid
17184 <h1 id="foo="><span id="foo.3D" typeof="mw:FallbackId"></span>foo=</h1>
17185 <h1 id="=foo"><span id=".3Dfoo" typeof="mw:FallbackId"></span>=foo</h1>
17186 <h1 id="italic_heading="><span id="italic_heading.3D" typeof="mw:FallbackId"></span><i>italic</i> heading=</h1>
17187 <h1 id="=italic_heading"><span id=".3Ditalic_heading" typeof="mw:FallbackId"></span>=<i>italic</i> heading</h1>
17188 !! end
17189
17190 !! test
17191 HTML headers vs TOC (T25393)
17192 (__NOEDITSECTION__ for clearer output, doesn't matter here)
17193 !! wikitext
17194 <h1>Header 1</h1>
17195 ==Header 1.1==
17196 ==Header 1.2==
17197
17198 <h1>Header 2
17199 </h1>
17200 ==Header 2.1==
17201 ==Header 2.2==
17202 __NOEDITSECTION__
17203 !! html/php
17204 <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>
17205 <ul>
17206 <li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
17207 <ul>
17208 <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>
17209 <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>
17210 </ul>
17211 </li>
17212 <li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a>
17213 <ul>
17214 <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>
17215 <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>
17216 </ul>
17217 </li>
17218 </ul>
17219 </div>
17220
17221 <h1><span class="mw-headline" id="Header_1">Header 1</span></h1>
17222 <h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2>
17223 <h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2>
17224 <h1><span class="mw-headline" id="Header_2">Header 2
17225 </span></h1>
17226 <h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2>
17227 <h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2>
17228
17229 !! html/parsoid
17230 <h1 id="Header_1" data-parsoid='{"stx":"html"}'>Header 1</h1>
17231 <h2 id="Header_1.1" data-parsoid='{}'>Header 1.1</h2>
17232 <h2 id="Header_1.2" data-parsoid='{}'>Header 1.2</h2>
17233
17234 <h1 id="Header_2" data-parsoid='{"stx":"html"}'>Header 2
17235 </h1>
17236 <h2 id="Header_2.1" data-parsoid='{}'>Header 2.1</h2>
17237 <h2 id="Header_2.2" data-parsoid='{}'>Header 2.2</h2>
17238 <meta property="mw:PageProp/noeditsection"/>
17239 !! end
17240
17241 !! test
17242 Single-line or multiline-comments can follow headings
17243 !! options
17244 parsoid=wt2html,wt2wt
17245 !! wikitext
17246 ==foo==<!---->
17247 ==bar==<!--c1-->
17248 ==baz==<!--
17249 c2
17250 c3-->
17251 !! html/php
17252 <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>
17253 <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>
17254 <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>
17255
17256 !! html/parsoid
17257 <h2 id="foo">foo</h2><!---->
17258 <h2 id="bar">bar</h2><!--c1-->
17259 <h2 id="baz">baz</h2><!--
17260 c2
17261 c3-->
17262 !! end
17263
17264 !! test
17265 T3219 URL next to image (broken)
17266 !! wikitext
17267 http://example.com[[File:Foobar.jpg]]
17268 !! html/php
17269 <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>
17270 </p>
17271 !! html/parsoid
17272 <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>
17273 !!end
17274
17275 !! test
17276 T3186 news: in the middle of text
17277 !! wikitext
17278 http://en.wikinews.org/wiki/Wikinews:Workplace
17279 !! html
17280 <p><a rel="nofollow" class="external free" href="http://en.wikinews.org/wiki/Wikinews:Workplace">http://en.wikinews.org/wiki/Wikinews:Workplace</a>
17281 </p>
17282 !!end
17283
17284
17285 !! test
17286 Namespaced link must have a title
17287 !! wikitext
17288 [[Project:]]
17289 !! html
17290 <p>[[Project:]]
17291 </p>
17292 !!end
17293
17294 !! test
17295 Namespaced link must have a title (bad fragment version)
17296 !! wikitext
17297 [[Project:#fragment]]
17298 !! html
17299 <p>[[Project:#fragment]]
17300 </p>
17301 !!end
17302
17303
17304 ###
17305 ### HTML tags and HTML attributes
17306 ###
17307
17308 !! test
17309 div with no attributes
17310 !! wikitext
17311 <div>HTML rocks</div>
17312 !! html
17313 <div>HTML rocks</div>
17314
17315 !! end
17316
17317 !! test
17318 div with double-quoted attribute
17319 !! wikitext
17320 <div id="rock">HTML rocks</div>
17321 !! html
17322 <div id="rock">HTML rocks</div>
17323
17324 !! end
17325
17326 !! test
17327 div with single-quoted attribute
17328 !! wikitext
17329 <div id='rock'>HTML rocks</div>
17330 !! html
17331 <div id="rock">HTML rocks</div>
17332
17333 !! end
17334
17335 !! test
17336 div with unquoted attribute
17337 !! wikitext
17338 <div id=rock>HTML rocks</div>
17339 !! html
17340 <div id="rock">HTML rocks</div>
17341
17342 !! end
17343
17344 !! test
17345 div with illegal double attributes
17346 !! wikitext
17347 <div id="a" id="b">HTML rocks</div>
17348 !! html
17349 <div id="b">HTML rocks</div>
17350
17351 !!end
17352
17353 !! test
17354 div with empty attribute value, space before equals
17355 !! options
17356 parsoid=wt2html,html2html
17357 !! wikitext
17358 <div class =>HTML rocks</div>
17359 !! html/php
17360 <div class="">HTML rocks</div>
17361
17362 !! html/parsoid
17363 <div class="" data-parsoid='{"stx":"html"}'>HTML rocks</div>
17364 !! end
17365
17366 !! test
17367 div with multiple empty attribute values
17368 !! config
17369 wgFragmentMode=[ 'html5', 'legacy' ]
17370 !! options
17371 parsoid=wt2html,html2html
17372 !! wikitext
17373 <div id= title=>HTML rocks</div>
17374 !! html/php
17375 <div id="title=">HTML rocks</div>
17376
17377 !! html/parsoid
17378 <div id="title=" data-parsoid='{"stx":"html"}'>HTML rocks</div>
17379 !! end
17380
17381 # FIXME Parsoid doesn't actually match PHP here.
17382 # Probably we should use the synthetic <foo /> or <indicator>
17383 # extensions for this test, which are enabled when running parser tests.
17384 !! test
17385 Extension tag in attribute value
17386 !! wikitext
17387 <span title="<translate>123</translate>">ok</span>
17388 !! html/php+disabled
17389 <p>&lt;span title="&lt;translate&gt;123&lt;/translate&gt;"&gt;ok&lt;/span&gt;
17390 </p>
17391 !! html/parsoid
17392 <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>
17393 !! end
17394
17395 !! test
17396 table with multiple empty attribute values
17397 !! options
17398 parsoid=wt2html,html2html
17399 !! wikitext
17400 {| title= id=
17401 |hi
17402 |}
17403 !! html/php
17404 <table title="id=">
17405 <tr>
17406 <td>hi
17407 </td></tr></table>
17408
17409 !! html/parsoid
17410 <table title="id=">
17411 <tbody><tr><td>hi</td></tr>
17412 </tbody></table>
17413 !! end
17414
17415 !! test
17416 div with braces in attribute value
17417 !! wikitext
17418 <div title="{}">Foo</div>
17419 !! html/php
17420 <div title="&#123;&#125;">Foo</div>
17421
17422 !! html/parsoid
17423 <div title="{}">Foo</div>
17424 !! end
17425
17426 !! test
17427 div with empty attribute value, no space before equals
17428 !! options
17429 parsoid=wt2html,html2html
17430 !! wikitext
17431 <div class=>HTML rocks</div>
17432 !! html/php
17433 <div class="">HTML rocks</div>
17434
17435 !! html/parsoid
17436 <div class="">HTML rocks</div>
17437 !! end
17438
17439 !! test
17440 HTML multiple attributes correction
17441 !! wikitext
17442 <p class="error" class="awesome">Awesome!</p>
17443 !! html
17444 <p class="awesome">Awesome!</p>
17445
17446 !!end
17447
17448 !! test
17449 Table multiple attributes correction
17450 !! wikitext
17451 {|
17452 !+ class="error" class="awesome"|status
17453 |}
17454 !! html
17455 <table>
17456 <tr>
17457 <th class="awesome">status
17458 </th></tr></table>
17459
17460 !!end
17461
17462 !! test
17463 DIV IN UPPERCASE
17464 !! wikitext
17465 <DIV ID="x">HTML ROCKS</DIV>
17466 !! html
17467 <div id="x">HTML ROCKS</div>
17468
17469 !!end
17470
17471 !! test
17472 Non-ASCII pseudo-tags are rendered as text
17473 !! wikitext
17474 <khyô>
17475 !! html
17476 <p>&lt;khyô&gt;
17477 </p>
17478 !! end
17479
17480 !! test
17481 Pseudo-tag with URL 'name' renders as url link
17482 !! wikitext
17483 <http://example.com/>
17484 !! html
17485 <p>&lt;<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&gt;
17486 </p>
17487 !! end
17488
17489 !! test
17490 text with amp in the middle of nowhere
17491 !! wikitext
17492 Remember AT&T?
17493 !! html
17494 <p>Remember AT&amp;T?
17495 </p>
17496 !! end
17497
17498 !! test
17499 text with character entity: eacute
17500 !! wikitext
17501 I always thought &eacute; was a cute letter.
17502 !! html+tidy
17503 <p>I always thought &#233; was a cute letter.
17504 </p>
17505 !! end
17506
17507 !! test
17508 text with entity-escaped character entity-like string: eacute
17509 !! wikitext
17510 I always thought &amp;eacute; was a cute letter.
17511 !! html
17512 <p>I always thought &amp;eacute; was a cute letter.
17513 </p>
17514 !! end
17515
17516 !! test
17517 text with undefined character entity: xacute
17518 !! wikitext
17519 I always thought &xacute; was a cute letter.
17520 !! html
17521 <p>I always thought &amp;xacute; was a cute letter.
17522 </p>
17523 !! end
17524
17525 !! test
17526 HTML5 tags
17527 !! wikitext
17528 <data value="5">five</data>
17529 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
17530 <mark>This highlighted text</mark>
17531 !! html
17532 <p><data value="5">five</data>
17533 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
17534 <mark>This highlighted text</mark>
17535 </p>
17536 !! end
17537
17538 !! test
17539 HTML tag with leading space is parsed as text
17540 !! wikitext
17541 < div>foo< /div>
17542 !! html
17543 <p>&lt; div&gt;foo&lt; /div&gt;
17544 </p>
17545 !! end
17546
17547 ## Don't expect Parsoid and PHP to match, since PHP isn't exactly following
17548 ## the HTML5 parsing spec.
17549 !! test
17550 Element with broken attribute syntax
17551 !! options
17552 parsoid=wt2html
17553 !! wikitext
17554 <div style=" style="123">hi</div>
17555 <div =>ho</div>
17556 !! html/php
17557 <div style="123">hi</div>
17558 <div>ho</div>
17559
17560 !! html/parsoid
17561 <div style=" style=" data-parsoid='{"stx":"html","a":{"123\"":null},"sa":{"123\"":""}}'>hi</div>
17562 <div data-parsoid='{"stx":"html","a":{"=":null},"sa":{"=":""}}'>ho</div>
17563 !! end
17564
17565 ###
17566 ### Nesting tests (see T43545, T52604, T53081)
17567 ###
17568
17569 # This test case is fixed in Parsoid by domino 1.0.12. (T52604)
17570 # Note that html2wt is considerably more difficult if we use <b> in
17571 # the test case, instead of <small>
17572 !! test
17573 Ensure that HTML adoption agency algorithm is properly implemented.
17574 !! wikitext
17575 <small>X<small>Y</small>Z</small>
17576 !! html
17577 <p><small>X<small>Y</small>Z</small>
17578 </p>
17579 !! end
17580
17581 # This was T43545 in the PHP parser.
17582 !! test
17583 Nesting of <kbd>
17584 !! wikitext
17585 <kbd>X<kbd>Y</kbd>Z</kbd>
17586 !! html+tidy
17587 <p><kbd>X<kbd>Y</kbd>Z</kbd>
17588 </p>
17589 !! end
17590
17591 # The following cases were T53081 in the PHP parser.
17592 # Note that there are some other nestable tags (b, i, etc) which are
17593 # not covered; see T53081 for discussion.
17594
17595 !! test
17596 Nesting of <em>
17597 !! wikitext
17598 <em>X<em>Y</em>Z</em>
17599 !! html+tidy
17600 <p><em>X<em>Y</em>Z</em>
17601 </p>
17602 !! end
17603
17604 !! test
17605 Nesting of <strong>
17606 !! wikitext
17607 <strong>X<strong>Y</strong>Z</strong>
17608 !! html+tidy
17609 <p><strong>X<strong>Y</strong>Z</strong>
17610 </p>
17611 !! end
17612
17613 !! test
17614 Nesting of <q>
17615 !! wikitext
17616 <q>X<q>Y</q>Z</q>
17617 !! html+tidy
17618 <p><q>X<q>Y</q>Z</q>
17619 </p>
17620 !! end
17621
17622 !! test
17623 Nesting of <ruby>
17624 !! wikitext
17625 <ruby>X<ruby>Y</ruby>Z</ruby>
17626 !! html
17627 <p><ruby>X<ruby>Y</ruby>Z</ruby>
17628 </p>
17629 !! end
17630
17631 !! test
17632 Nesting of <bdo>
17633 !! wikitext
17634 <bdo>X<bdo>Y</bdo>Z</bdo>
17635 !! html
17636 <p><bdo>X<bdo>Y</bdo>Z</bdo>
17637 </p>
17638 !! end
17639
17640
17641 ###
17642 ### Media links
17643 ###
17644
17645 !! test
17646 Media link
17647 !! wikitext
17648 [[Media:Foobar.jpg]]
17649 [[Media:Video.ogv]]
17650 [[:Media:Video.ogv]]
17651 !! html/php
17652 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a>
17653 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
17654 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
17655 </p>
17656 !! html/parsoid
17657 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a>
17658 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" title="Video.ogv">Media:Video.ogv</a>
17659 <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>
17660 !! end
17661
17662 !! test
17663 Media link with text
17664 !! wikitext
17665 [[Media:Foobar.jpg|A neat file to look at]]
17666 !! html/php
17667 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">A neat file to look at</a>
17668 </p>
17669 !! html/parsoid
17670 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
17671 !! end
17672
17673 # FIXME: this is still bad HTML tag nesting
17674 # FIXME: doBlockLevels won't wrap this in a paragraph because it contains a div
17675 # Parsoid & Remex fix the p-wrapping since they operate on the DOM.
17676 !! test
17677 Media link with nasty text
17678 !! wikitext
17679 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
17680 !! html/php
17681 <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>
17682
17683 !! html/php+tidy
17684 <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>
17685 !! html/parsoid
17686 <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>
17687
17688 !! end
17689
17690 !! test
17691 Media link to nonexistent file (T3702)
17692 !! wikitext
17693 [[Media:No such.jpg]]
17694 [[Media:No_such file.jpg]]
17695 !! html/php
17696 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a>
17697 <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>
17698 </p>
17699 !! html/parsoid
17700 <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>
17701 <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>
17702 !! end
17703
17704 !! test
17705 Image link to nonexistent file (T3850 - good)
17706 !! wikitext
17707 [[File:No_such.jpg]]
17708 !! html/php
17709 <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>
17710 </p>
17711 !! html/parsoid
17712 <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>
17713 !! end
17714
17715 !! test
17716 :Image link to nonexistent file (T3850 - bad)
17717 !! wikitext
17718 [[:Image:No such.jpg]]
17719 !! html/php
17720 <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>
17721 </p>
17722 !! html/parsoid
17723 <p><a rel="mw:WikiLink" href="./File:No_such.jpg" title="File:No such.jpg">Image:No such.jpg</a></p>
17724 !! end
17725
17726 !! test
17727 Character reference normalization in link text (T3938)
17728 !! wikitext
17729 [[Main Page|this&that]]
17730 !! html
17731 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
17732 </p>
17733 !!end
17734
17735 !! article
17736 אַ
17737 !! text
17738 Test for unicode normalization
17739
17740 The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
17741 !! endarticle
17742
17743 !! test
17744 (T21451) Links should refer to the normalized form.
17745 !! wikitext
17746 [[&#xFB2E;]]
17747 [[&#x5d0;&#x5b7;]]
17748 [[&#x5d0;ַ]]
17749 [[א&#x5b7;]]
17750 [[אַ]]
17751 !! html
17752 <p><a href="/wiki/%D7%90%D6%B7" title="אַ">&#xfb2e;</a>
17753 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;&#x5b7;</a>
17754 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;ַ</a>
17755 <a href="/wiki/%D7%90%D6%B7" title="אַ">א&#x5b7;</a>
17756 <a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a>
17757 </p>
17758 !! end
17759
17760 !! test
17761 Empty attribute crash test (T4067)
17762 !! wikitext
17763 <font color="">foo</font>
17764 !! html
17765 <p><font color="">foo</font>
17766 </p>
17767 !! end
17768
17769 !! test
17770 Empty attribute crash test single-quotes (T4067)
17771 !! wikitext
17772 <font color=''>foo</font>
17773 !! html
17774 <p><font color="">foo</font>
17775 </p>
17776 !! end
17777
17778 !! test
17779 Attribute test: equals, then nothing
17780 !! options
17781 parsoid=wt2html,html2html
17782 !! wikitext
17783 <font color=>foo</font>
17784 !! html/php
17785 <p><font color="">foo</font>
17786 </p>
17787 !! html/parsoid
17788 <p><font color="" data-parsoid='{"stx":"html"}'>foo</font></p>
17789 !! end
17790
17791 !! test
17792 Attribute test: unquoted value
17793 !! options
17794 parsoid=wt2html,html2html
17795 !! wikitext
17796 <font color=x>foo</font>
17797 !! html/php
17798 <p><font color="x">foo</font>
17799 </p>
17800 !! html/parsoid
17801 <p><font color="x" data-parsoid='{"stx":"html"}'>foo</font></p>
17802 !! end
17803
17804 !! test
17805 Attribute test: unquoted but illegal value (hash)
17806 !! wikitext
17807 <font color=#x>foo</font>
17808 !! html
17809 <p><font color="#x">foo</font>
17810 </p>
17811 !! end
17812
17813 # Parsoid does not serialize to empty attribute syntax,
17814 # so wt2wt and html2wt cases are skipped
17815 !! test
17816 Attribute test: no value (T54330)
17817 !! options
17818 parsoid=wt2html,html2html
17819 !! wikitext
17820 <font color>foo</font>
17821 !! html/php
17822 <p><font color="">foo</font>
17823 </p>
17824 !! html/parsoid
17825 <p><font color="">foo</font></p>
17826 !! end
17827
17828 !! test
17829 T4095: link with three closing brackets
17830 !! wikitext
17831 [[Main Page]]]
17832 !! html/php
17833 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
17834 </p>
17835 !! html/parsoid
17836 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>]</p>
17837 !! end
17838
17839 !! test
17840 T4095: link with pipe and three closing brackets
17841 !! wikitext
17842 [[Main Page|link]]]
17843 !! html/php
17844 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
17845 </p>
17846 !! html/parsoid
17847 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">link</a>]</p>
17848 !! end
17849
17850 !! test
17851 T4095: link with pipe and three closing brackets, version 2
17852 !! wikitext
17853 [[Main Page|[http://example.com/]]]
17854 !! html/php
17855 <p><a href="/wiki/Main_Page" title="Main Page">[http://example.com/]</a>
17856 </p>
17857 !! html/parsoid
17858 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">[http://example.com/]</a></p>
17859 !! end
17860
17861
17862 ###
17863 ### Safety
17864 ###
17865
17866 !! article
17867 Template:Dangerous attribute
17868 !! text
17869 " onmouseover="alert(document.cookie)
17870 !! endarticle
17871
17872 !! article
17873 Template:Dangerous style attribute
17874 !! text
17875 border-size: expression(alert(document.cookie))
17876 !! endarticle
17877
17878 !! article
17879 Template:Div style
17880 !! text
17881 <div style="float: right; {{{1}}}">Magic div</div>
17882 !! endarticle
17883
17884 !! test
17885 T4304: HTML attribute safety (safe template; regression T4309)
17886 !! wikitext
17887 <div title="{{test}}"></div>
17888 !! html/php
17889 <div title="This is a test template"></div>
17890
17891 !! html/parsoid
17892 <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>
17893 !! end
17894
17895 # Parsoid has enough context to handle this case
17896 !! test
17897 T4304: HTML attribute safety (dangerous template; 2309)
17898 !! wikitext
17899 <div title="{{dangerous attribute}}"></div>
17900 !! html/php
17901 <div title=""></div>
17902
17903 !! html/parsoid
17904 <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>
17905 !! end
17906
17907 !! test
17908 T4304: HTML attribute safety (dangerous style template; 2309)
17909 !! wikitext
17910 <div style="{{dangerous style attribute}}"></div>
17911 !! html/php
17912 <div style="/* insecure input */"></div>
17913
17914 !! html/parsoid
17915 <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>
17916 !! end
17917
17918 !! test
17919 T4304: HTML attribute safety (safe parameter; 2309)
17920 !! wikitext
17921 {{div style|width: 200px}}
17922 !! html/php
17923 <div style="float: right; width: 200px">Magic div</div>
17924
17925 !! html/parsoid
17926 <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>
17927 !! end
17928
17929 !! test
17930 T4304: HTML attribute safety (unsafe parameter; 2309)
17931 !! wikitext
17932 {{div style|width: expression(alert(document.cookie))}}
17933 !! html/php
17934 <div style="/* insecure input */">Magic div</div>
17935
17936 !! html/parsoid
17937 <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>
17938 !! end
17939
17940 ## Parsoid output here differs; needs investigation.
17941 !! test
17942 T4304: HTML attribute safety (unsafe breakout parameter; 2309)
17943 !! wikitext
17944 {{div style|"><script>alert(document.cookie)</script>}}
17945 !! html
17946 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17947
17948 !! end
17949
17950 ## Parsoid output here differs; needs investigation.
17951 !! test
17952 T4304: HTML attribute safety (unsafe breakout parameter 2; 2309)
17953 !! wikitext
17954 {{div style|" ><script>alert(document.cookie)</script>}}
17955 !! html
17956 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17957
17958 !! end
17959
17960 !! test
17961 T4304: HTML attribute safety (link)
17962 !! wikitext
17963 <div title="[[Main Page]]"></div>
17964 !! html/php
17965 <div title="&#91;&#91;Main Page&#93;&#93;"></div>
17966
17967 !! html/parsoid
17968 <div title="[[Main Page]]"></div>
17969 !! end
17970
17971 !! test
17972 T4304: HTML attribute safety (italics)
17973 !! wikitext
17974 <div title="''foobar''"></div>
17975 !! html
17976 <div title="&#39;&#39;foobar&#39;&#39;"></div>
17977
17978 !! end
17979
17980 !! test
17981 T4304: HTML attribute safety (bold)
17982 !! wikitext
17983 <div title="'''foobar'''"></div>
17984 !! html
17985 <div title="&#39;&#39;&#39;foobar&#39;&#39;&#39;"></div>
17986
17987 !! end
17988
17989 !! test
17990 T4304: HTML attribute safety (ISBN)
17991 !! wikitext
17992 <div title="ISBN 1234567890"></div>
17993 !! html
17994 <div title="&#73;SBN 1234567890"></div>
17995
17996 !! end
17997
17998 !! test
17999 T4304: HTML attribute safety (RFC)
18000 !! wikitext
18001 <div title="RFC 1234"></div>
18002 !! html
18003 <div title="&#82;FC 1234"></div>
18004
18005 !! end
18006
18007 !! test
18008 T4304: HTML attribute safety (PMID)
18009 !! wikitext
18010 <div title="PMID 1234567890"></div>
18011 !! html
18012 <div title="&#80;MID 1234567890"></div>
18013
18014 !! end
18015
18016 !! test
18017 T4304: HTML attribute safety (web link)
18018 !! wikitext
18019 <div title="http://example.com/"></div>
18020 !! html
18021 <div title="http&#58;//example.com/"></div>
18022
18023 !! end
18024
18025 !! test
18026 T4304: HTML attribute safety (named web link)
18027 !! wikitext
18028 <div title="[http://example.com/ link]"></div>
18029 !! html/php
18030 <div title="&#91;http&#58;//example.com/ link&#93;"></div>
18031
18032 !! html/parsoid
18033 <div title="[http://example.com/ link]"></div>
18034 !! end
18035
18036 !! test
18037 T5244: HTML attribute safety (extension; safe)
18038 !! wikitext
18039 <div style="<nowiki>background:blue</nowiki>"></div>
18040 !! html/php
18041 <div style="background:blue"></div>
18042
18043 !! html/parsoid
18044 <div style="background:blue" data-parsoid='{"stx":"html","a":{"style":"background:blue"},"sa":{"style":"&lt;nowiki>background:blue&lt;/nowiki>"}}'></div>
18045 !! end
18046
18047 !! test
18048 T5244: HTML attribute safety (extension; unsafe)
18049 !! wikitext
18050 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
18051 !! html/php
18052 <div style="/* insecure input */"></div>
18053
18054 !! html/parsoid
18055 <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>
18056 !! end
18057
18058 # More MSIE fun discovered by Tom Gilder
18059
18060 !! test
18061 MSIE CSS safety test: spurious slash
18062 !! wikitext
18063 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
18064 !! html/php
18065 <div style="/* insecure input */">evil</div>
18066
18067 !! html/parsoid
18068 <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>
18069 !! end
18070
18071 !! test
18072 MSIE CSS safety test: hex code
18073 !! wikitext
18074 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
18075 !! html/php
18076 <div style="/* insecure input */">evil</div>
18077
18078 !! html/parsoid
18079 <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>
18080 !! end
18081
18082 !! test
18083 MSIE CSS safety test: comment in url
18084 !! wikitext
18085 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
18086 !! html/php
18087 <div style="background-image:u rl(javascript:alert(&#39;boo&#39;))">evil</div>
18088
18089 !! html/parsoid
18090 <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>
18091 !! end
18092
18093 !! test
18094 MSIE CSS safety test: comment in expression
18095 !! wikitext
18096 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
18097 !! html/php
18098 <div style="background-image:expres sion(alert(&#39;boo4&#39;))">evil4</div>
18099
18100 !! html/parsoid
18101 <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>
18102 !! end
18103
18104 !! test
18105 CSS safety test (all browsers): vertical tab (T57332 / CVE-2013-4567)
18106 !! wikitext
18107 <p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p>
18108 !! html/php
18109 <p style="/* invalid control char */">A</p>
18110
18111 !! html/parsoid
18112 <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>
18113 !! end
18114
18115 !! test
18116 MSIE 6 CSS safety test: Fullwidth (T57332)
18117 !! wikitext
18118 <p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p>
18119 <div style="top:EXPRESSION(alert())">B</div>
18120 !! html/php
18121 <p style="/* insecure input */">A</p>
18122 <div style="/* insecure input */">B</div>
18123
18124 !! html/parsoid
18125 <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>
18126 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"top:EXPRESSION(alert())"}}'>B</div>
18127 !! end
18128
18129 !! test
18130 MSIE 6 CSS safety test: IPA extensions (T57332)
18131 !! wikitext
18132 <div style="background-image:uʀʟ(javascript:alert())">A</div>
18133 <p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p>
18134 !! html/php
18135 <div style="/* insecure input */">A</div>
18136 <p style="/* insecure input */">B</p>
18137
18138 !! html/parsoid
18139 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:uʀʟ(javascript:alert())"}}'>A</div>
18140 <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>
18141 !! end
18142
18143 !! test
18144 MSIE 6 CSS safety test: sup/sub script (T57332)
18145 !! wikitext
18146 <div style="background-image:url⁽javascript:alert())">A</div>
18147 <div style="background-image:url₍javascript:alert())">B</div>
18148 <p style="font-size: 100px; color: expressioⁿ((title='XSSed'),'red')">C</p>
18149 !! html/php
18150 <div style="/* insecure input */">A</div>
18151 <div style="/* insecure input */">B</div>
18152 <p style="/* insecure input */">C</p>
18153
18154 !! html/parsoid
18155 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url⁽javascript:alert())"}}'>A</div>
18156 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url₍javascript:alert())"}}'>B</div>
18157 <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>
18158 !! end
18159
18160 !! test
18161 Opera -o-link CSS
18162 !! options
18163 parsoid=wt2html,html2html
18164 !! wikitext
18165 <div
18166 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;"
18167 style="-o-link:attr(title);-o-link-source:current">X</div>
18168 !! html/php
18169 <div title="data:text/html,&lt;img src=1 onerror=alert(1)&gt;" style="/* insecure input */">X</div>
18170
18171 !! html/parsoid
18172 <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>
18173 !! end
18174
18175 !! test
18176 MSIE 6 CSS safety test: Repetition markers (T57332)
18177 !! wikitext
18178 <p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p>
18179 <p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p>
18180 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">C</p>
18181 <p style="font-size: 100px; color: expresヽion((title='XSSed'),'red')">D</p>
18182 <p style="font-size: 100px; color: expresﹽion((title='XSSed'),'red')">E</p>
18183 <p style="font-size: 100px; color: expresﹼion((title='XSSed'),'red')">F</p>
18184 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">G</p>
18185 !! html/php
18186 <p style="/* insecure input */">A</p>
18187 <p style="/* insecure input */">B</p>
18188 <p style="/* insecure input */">C</p>
18189 <p style="/* insecure input */">D</p>
18190 <p style="/* insecure input */">E</p>
18191 <p style="/* insecure input */">F</p>
18192 <p style="/* insecure input */">G</p>
18193
18194 !! html/parsoid
18195 <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>
18196 <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>
18197 <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>
18198 <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>
18199 <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>
18200 <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>
18201 <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>
18202 !! end
18203
18204 !! test
18205 Table attribute legitimate extension
18206 !! wikitext
18207 {|
18208 !+ style="<nowiki>color:blue</nowiki>"|status
18209 |}
18210 !! html
18211 <table>
18212 <tr>
18213 <th style="color:blue">status
18214 </th></tr></table>
18215
18216 !!end
18217
18218 !! test
18219 Table attribute safety
18220 !! wikitext
18221 {|
18222 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"|status
18223 |}
18224 !! html
18225 <table>
18226 <tr>
18227 <th style="/* insecure input */">status
18228 </th></tr></table>
18229
18230 !! end
18231
18232 !! test
18233 CSS line continuation 1
18234 !! wikitext
18235 <div style="background-image: u\&#10;rl(test.jpg);"></div>
18236 !! html
18237 <div style="/* insecure input */"></div>
18238
18239 !! end
18240
18241 !! test
18242 CSS line continuation 2
18243 !! wikitext
18244 <div style="background-image: u\&#13;rl(test.jpg); "></div>
18245 !! html
18246 <div style="/* invalid control char */"></div>
18247
18248 !! end
18249
18250 !! article
18251 Template:Identity
18252 !! text
18253 {{{1}}}
18254 !! endarticle
18255
18256 !! test
18257 Expansion of multi-line templates in attribute values (T8255)
18258 !! wikitext
18259 <div style="background: {{identity|#00FF00}}">-</div>
18260 !! html
18261 <div style="background: #00FF00">-</div>
18262
18263 !! end
18264
18265 !! test
18266 Expansion of multi-line templates in attribute values (T8255 sanity check)
18267 !! wikitext
18268 <div style="background:
18269 #00FF00">-</div>
18270 !! html/php
18271 <div style="background: #00FF00">-</div>
18272
18273 !! html/parsoid
18274 <div style="background:
18275 #00FF00">-</div>
18276 !! end
18277
18278 !! test
18279 Expansion of multi-line templates in attribute values (T8255 sanity check 2)
18280 !! wikitext
18281 <div style="background: &#10;#00FF00">-</div>
18282 !! html
18283 <div style="background: &#10;#00FF00">-</div>
18284
18285 !! end
18286
18287 !! test
18288 Tags which are hidden from tidiers cannot pass through the Sanitizer
18289 !! wikitext
18290 <mw:toc><script>alert();</script></mw:toc>
18291 !! html+tidy
18292 <p>&lt;mw:toc&gt;&lt;script&gt;alert();&lt;/script&gt;&lt;/mw:toc&gt;
18293 </p>
18294 !! end
18295
18296 ###
18297 ### Parser hooks (see tests/parser/parserTestsParserHook.php for the <tag> extension)
18298 ###
18299
18300 !! test
18301 Parser hook: empty input
18302 !! wikitext
18303 <tag></tag>
18304 !! html/php
18305 <pre>
18306 ''
18307 array (
18308 )
18309 </pre>
18310
18311 !! html/parsoid
18312 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18313 !! end
18314
18315 ## Don't expect parsoid to rt this form.
18316 !! test
18317 Parser hook: empty input using terminated empty elements
18318 !! options
18319 parsoid=wt2html,html2html
18320 !! wikitext
18321 <tag/>
18322 !! html/php
18323 <pre>
18324 NULL
18325 array (
18326 )
18327 </pre>
18328
18329 !! html/parsoid
18330 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
18331 !! end
18332
18333 !! test
18334 Parser hook: empty input using terminated empty elements (space before)
18335 !! wikitext
18336 <tag />
18337 !! html/php
18338 <pre>
18339 NULL
18340 array (
18341 )
18342 </pre>
18343
18344 !! html/parsoid
18345 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
18346 !! end
18347
18348 !! test
18349 Parser hook: basic input
18350 !! wikitext
18351 <tag>input</tag>
18352 !! html/php
18353 <pre>
18354 'input'
18355 array (
18356 )
18357 </pre>
18358
18359 !! html/parsoid
18360 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18361 !! end
18362
18363 ## Don't expect parsoid to rt this form.
18364 !! test
18365 Parser hook: case insensitive
18366 !! options
18367 parsoid=wt2html,html2html
18368 !! wikitext
18369 <TAG>input</TAG>
18370 !! html/php
18371 <pre>
18372 'input'
18373 array (
18374 )
18375 </pre>
18376
18377 !! html/parsoid
18378 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18379 !! end
18380
18381 ## Don't expect parsoid to rt this form.
18382 !! test
18383 Parser hook: case insensitive, redux
18384 !! options
18385 parsoid=wt2html,html2html
18386 !! wikitext
18387 <TaG>input</TAg>
18388 !! html/php
18389 <pre>
18390 'input'
18391 array (
18392 )
18393 </pre>
18394
18395 !! html/parsoid
18396 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18397 !! end
18398
18399 !! test
18400 Parser hook: nested tags
18401 !! wikitext
18402 <tag><tag></tag></tag>
18403 !! html/php
18404 <pre>
18405 '<tag>'
18406 array (
18407 )
18408 </pre>&lt;/tag&gt;
18409
18410 !! html/parsoid
18411 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"&lt;tag>"}}' data-parsoid='{}' about="#mwt2"></pre>&lt;/tag>
18412 !! end
18413
18414 !! test
18415 Parser hook: basic arguments
18416 !! wikitext
18417 <tag width="200" height="100" depth="50" square=""></tag>
18418 !! html/php
18419 <pre>
18420 ''
18421 array (
18422 'width' => '200',
18423 'height' => '100',
18424 'depth' => '50',
18425 'square' => '',
18426 )
18427 </pre>
18428
18429 !! html/parsoid
18430 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18431 !! end
18432
18433 ## Don't expect parsoid to rt this form.
18434 !! test
18435 Parser hook: basic arguments, variations
18436 !! options
18437 parsoid=wt2html,html2html
18438 !! wikitext
18439 <tag width=200 height = "100" depth = '50' square></tag>
18440 !! html/php
18441 <pre>
18442 ''
18443 array (
18444 'width' => '200',
18445 'height' => '100',
18446 'depth' => '50',
18447 'square' => '',
18448 )
18449 </pre>
18450
18451 !! html/parsoid
18452 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18453 !! end
18454
18455 !! test
18456 Parser hook: argument containing a forward slash (T7344)
18457 !! wikitext
18458 <tag filename="/tmp/bla"></tag>
18459 !! html/php
18460 <pre>
18461 ''
18462 array (
18463 'filename' => '/tmp/bla',
18464 )
18465 </pre>
18466
18467 !! html/parsoid
18468 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"filename":"/tmp/bla"},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18469 !! end
18470
18471 ## Don't expect parsoid to rt this form.
18472 !! test
18473 Parser hook: empty input using terminated empty elements (T4374)
18474 !! options
18475 parsoid=wt2html,html2html
18476 !! wikitext
18477 <tag foo=bar/>text
18478 !! html/php
18479 <pre>
18480 NULL
18481 array (
18482 'foo' => 'bar',
18483 )
18484 </pre>text
18485
18486 !! html/parsoid
18487 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"foo":"bar"},"body":null}' data-parsoid='{}' about="#mwt2"></pre>text
18488 !! end
18489
18490 ## </tag> should be output literally since there is no matching tag that begins it
18491 ## Don't expect parsoid to rt this form.
18492 !! test
18493 Parser hook: basic arguments using terminated empty elements (T4374)
18494 !! options
18495 parsoid=wt2html
18496 !! wikitext
18497 <tag width=200 height = "100" depth = '50' square/>
18498 other stuff
18499 </tag>
18500 !! html/php
18501 <pre>
18502 NULL
18503 array (
18504 'width' => '200',
18505 'height' => '100',
18506 'depth' => '50',
18507 'square' => '',
18508 )
18509 </pre>
18510 <p>other stuff
18511 &lt;/tag&gt;
18512 </p>
18513 !! html/parsoid
18514 <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
18515 &lt;/tag></p>
18516 !! end
18517
18518 ## Don't expect parsoid to rt this form.
18519 !! test
18520 Parser hook: Don't allow unclosed extension tags
18521 !! options
18522 parsoid=wt2html
18523 !! wikitext
18524 test <tag>123
18525
18526 this is a '''test'''
18527 !! html/php
18528 <p>test &lt;tag&gt;123
18529 </p><p>this is a <b>test</b>
18530 </p>
18531 !! html/parsoid
18532 <p>test &lt;tag>123</p>
18533
18534 <p>this is a <b>test</b></p>
18535 !! end
18536
18537 !! test
18538 Parser hook: horizontal rule inside extension tag that outputs <pre>
18539 !! wikitext
18540 <tag>
18541 Hello
18542 <hr/>
18543 Goodbye
18544 </tag>
18545 !! html/php
18546 <pre>
18547 '
18548 Hello
18549 <hr/>
18550 Goodbye
18551 '
18552 array (
18553 )
18554 </pre>
18555
18556 !! end
18557
18558 ###
18559 ### (see tests/parser/parserTestsParserHook.php for the <statictag> extension)
18560 ###
18561
18562 !! test
18563 Parser hook: static parser hook not inside a comment
18564 !! wikitext
18565 <statictag>hello, world</statictag>
18566
18567 <statictag action="flush" />
18568 !! html/php
18569 <p><br />
18570 hello, world
18571 </p>
18572 !! html/parsoid
18573 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{},"body":{"extsrc":"hello, world"}}' data-parsoid='{}' about="#mwt2"></span></p>
18574 <p typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about="#mwt4">hello, world</p>
18575 !! end
18576
18577 !! test
18578 Parser hook: static parser hook inside a comment
18579 !! wikitext
18580 <!-- <statictag>hello, world</statictag> -->
18581 <statictag action="flush" />
18582 !! html/php
18583 <p><br />
18584 </p>
18585 !! html/parsoid
18586 <!-- <statictag&#x3E;hello, world</statictag&#x3E; -->
18587 <p typeof='mw:Extension/statictag' data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about='#mwt2'></p>
18588 !! end
18589
18590 # Nested template calls; this case was broken by Parser.php rev 1.506,
18591 # since reverted.
18592
18593 !! article
18594 Template:One-parameter
18595 !! text
18596 (My parameter is: {{{1}}})
18597 !! endarticle
18598
18599 !! article
18600 Template:Map-one-parameter
18601 !! text
18602 {{{{{1}}}|{{{2}}}}}
18603 !! endarticle
18604
18605 !! test
18606 Nested template calls
18607 !! wikitext
18608 {{Map-one-parameter|One-parameter|param}}
18609 !! html
18610 <p>(My parameter is: param)
18611 </p>
18612 !! end
18613
18614
18615 ###
18616 ### Sanitizer
18617 ###
18618
18619 # Remex wraps empty tag runs with p-tags.
18620 # Parsoid strips them out during p-wrapping.
18621 !! test
18622 Sanitizer: Closing of open tags
18623 !! wikitext
18624 <s></s><table></table>
18625 !! html/php+tidy
18626 <p><s></s></p><table></table>
18627 !! html/parsoid
18628 <s></s><table></table>
18629 !! end
18630
18631 !! test
18632 Sanitizer: Closing of open but not closed tags
18633 !! wikitext
18634 <s>foo
18635 !! html
18636 <p><s>foo</s>
18637 </p>
18638 !! end
18639
18640 !! test
18641 Sanitizer: Closing of closed but not open tags
18642 !! options
18643 parsoid=wt2html
18644 !! wikitext
18645 </s>
18646 !! html/php+tidy
18647 <p class="mw-empty-elt">
18648 </p>
18649 !! html/parsoid
18650 !! end
18651
18652 !! test
18653 Sanitizer: Closing of closed but not open table tags
18654 !! options
18655 parsoid=wt2html
18656 !! wikitext
18657 Table not started</td></tr></table>
18658 !! html+tidy
18659 <p>Table not started
18660 </p>
18661 !! end
18662
18663 !! test
18664 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
18665 !! config
18666 wgFragmentMode=[ 'html5', 'legacy' ]
18667 !! wikitext
18668 <span id="æ: v">byte</span>[[#æ: v|backlink]]
18669 !! html/php
18670 <p><span id="æ:_v">byte</span><a href="#æ:_v">backlink</a>
18671 </p>
18672 !! html/parsoid
18673 <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>
18674 !! end
18675
18676 !! test
18677 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id="" (legacy)
18678 !! config
18679 wgFragmentMode=[ 'legacy' ]
18680 !! wikitext
18681 <span id="æ: v">byte</span>[[#æ: v|backlink]]
18682 !! html/php
18683 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v">backlink</a>
18684 </p>
18685 !! end
18686
18687 # In HTML5, the restrictions are that id must contain at least one character,
18688 # and must not contain any space characters.
18689 !! test
18690 Sanitizer: Validating the contents of the id attribute (T6515)
18691 !! options
18692 disabled
18693 !! wikitext
18694 <br id="" /><br id="a space" />
18695 !! html
18696 Something ...
18697 !! end
18698
18699 # In HTML5, id must be unique amongst all the ids in the element's home subtree.
18700 !! test
18701 Sanitizer: Validating id attribute uniqueness (T6515, T8301)
18702 !! options
18703 disabled
18704 !! wikitext
18705 <br id="foo" /><br id="foo" />
18706 !! html
18707 Something need to be done. foo-2 ?
18708 !! end
18709
18710 !! test
18711 Sanitizer: Validating that <meta> and <link> work, but only for Microdata
18712 !! wikitext
18713 <div itemscope>
18714 <meta itemprop="hello" content="world">
18715 <meta http-equiv="refresh" content="5">
18716 <meta itemprop="hello" http-equiv="refresh" content="5">
18717 <link itemprop="hello" href="{{SERVER}}">
18718 <link rel="stylesheet" href="{{SERVER}}">
18719 <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
18720 </div>
18721 !! html
18722 <div itemscope="">
18723 <p> <meta itemprop="hello" content="world" />
18724 &lt;meta http-equiv="refresh" content="5"&gt;
18725 <meta itemprop="hello" content="5" />
18726 <link itemprop="hello" href="http&#58;//example.org" />
18727 &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"&gt;
18728 <link itemprop="hello" href="http&#58;//example.org" />
18729 </p>
18730 </div>
18731
18732 !! end
18733
18734 !! test
18735 Sanitizer: Strip comments from CSS attributes
18736 !! options
18737 parsoid=wt2html,wt2wt
18738 !! wikitext
18739 <span style="margin:/*negate mbox-text padding */-0.125em -0.45em; /*rainbow*/rgba(255, 0, 0, 0.3)">2013</span>
18740 !! html/php
18741 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span>
18742 </p>
18743 !! html/parsoid
18744 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span></p>
18745 !! end
18746
18747 !! test
18748 Sanitizer: Avoid unnecessary percent encoded characters in interwiki links
18749 !! wikitext
18750 [[meatball:Soft"Security]]
18751 !! html/php
18752 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Soft%22Security" class="extiw" title="meatball:Soft&quot;Security">meatball:Soft"Security</a>
18753 </p>
18754 !! html/parsoid
18755 <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>
18756 !! end
18757
18758 !! test
18759 Sanitizer: angle brackets are invalid, even in interwiki links (T182338)
18760 !! wikitext
18761 [[meatball:Foo<Bar]]
18762 [[meatball:Foo>Bar]]
18763 [[meatball:Foo&lt;bar]]
18764 [[meatball:Foo&gt;bar]]
18765 !! html/php
18766 <p>[[meatball:Foo&lt;Bar]]
18767 [[meatball:Foo&gt;Bar]]
18768 [[meatball:Foo&lt;bar]]
18769 [[meatball:Foo&gt;bar]]
18770 </p>
18771 !! html/parsoid
18772 <p>[[meatball:Foo&lt;Bar]]
18773 [[meatball:Foo>Bar]]
18774 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span>bar]]
18775 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;gt;","srcContent":">"}'>></span>bar]]</p>
18776 !! end
18777
18778 !! test
18779 Language converter: output gets cut off unexpectedly (T7757)
18780 !! options
18781 language=zh
18782 !! wikitext
18783 this bit is safe: }-
18784
18785 but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}-
18786
18787 then we get cut off here: }-
18788
18789 all additional text is vanished
18790 !! html/php
18791 <p>this bit is safe: }-
18792 </p><p>but if we add a conversion instance: xxx
18793 </p><p>then we get cut off here: }-
18794 </p><p>all additional text is vanished
18795 </p>
18796 !! html/parsoid
18797 <p>this bit is safe: }-</p>
18798 <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>
18799 <p>then we get cut off here: }-</p>
18800 <p>all additional text is vanished</p>
18801 !! end
18802
18803 !! test
18804 Language converter glossary rules inside attributes (T119158)
18805 !! options
18806 language=sr variant=sr-el
18807 !! wikitext
18808 -{H|foAjrjvi=>sr-el:" onload="alert(1)" data-foo="}-
18809
18810 [[File:Foobar.jpg|alt=-{}-foAjrjvi-{}-]]
18811 !! html/php
18812 <p>
18813 </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>
18814 </p>
18815 !! html/parsoid
18816 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"foAjrjvi","l":"sr-el","t":"\" onload=\"alert(1)\" data-foo=\""}]}'/></p>
18817
18818 <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>
18819 !! end
18820
18821 !! test
18822 Self closed html pairs (T7487)
18823 !! wikitext
18824 <center><font id="bug" />Centered text</center>
18825 <div><font id="bug2" />In div text</div>
18826 !! html+tidy
18827 <center><font id="bug"></font>Centered text</center>
18828 <div><font id="bug2"></font>In div text</div>
18829 !! end
18830
18831 !! test
18832 Punctuation: nbsp before exclamation
18833 !! wikitext
18834 C'est grave !
18835 !! html
18836 <p>C'est grave&#160;!
18837 </p>
18838 !! end
18839
18840 !! test
18841 Punctuation: CSS !important (T13874)
18842 !! wikitext
18843 <div style="width:50% !important">important</div>
18844 !! html
18845 <div style="width:50%&#32;!important">important</div>
18846
18847 !!end
18848
18849 !! test
18850 Punctuation: CSS ! important (T13874; with space after)
18851 !! wikitext
18852 <div style="width:50% ! important">important</div>
18853 !! html
18854 <div style="width:50%&#32;! important">important</div>
18855
18856 !!end
18857
18858 !! test
18859 HTML bullet list, closed tags (T7497)
18860 !! wikitext
18861 <ul>
18862 <li>One</li>
18863 <li>Two</li>
18864 </ul>
18865 !! html/php
18866 <ul>
18867 <li>One</li>
18868 <li>Two</li>
18869 </ul>
18870
18871 !! html/parsoid
18872 <ul data-parsoid='{"stx":"html"}'>
18873 <li data-parsoid='{"stx":"html"}'>One</li>
18874 <li data-parsoid='{"stx":"html"}'>Two</li>
18875 </ul>
18876
18877 !! end
18878
18879 !! test
18880 HTML bullet list, unclosed tags (T7497)
18881 !! wikitext
18882 <ul>
18883 <li>One
18884 <li>Two
18885 </ul>
18886 !! html/php+tidy
18887 <ul>
18888 <li>One
18889 </li><li>Two
18890 </li></ul>
18891 !! html/parsoid
18892 <ul data-parsoid='{"stx":"html"}'>
18893 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18894 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18895 </ul>
18896
18897 !! end
18898
18899 !! test
18900 HTML ordered list, closed tags (T7497)
18901 !! wikitext
18902 <ol>
18903 <li>One</li>
18904 <li>Two</li>
18905 </ol>
18906 !! html/php
18907 <ol>
18908 <li>One</li>
18909 <li>Two</li>
18910 </ol>
18911
18912 !! html/parsoid
18913 <ol data-parsoid='{"stx":"html"}'>
18914 <li data-parsoid='{"stx":"html"}'>One</li>
18915 <li data-parsoid='{"stx":"html"}'>Two</li>
18916 </ol>
18917
18918 !! end
18919
18920 !! test
18921 HTML ordered list, unclosed tags (T7497)
18922 !! options
18923 !! wikitext
18924 <ol>
18925 <li>One
18926 <li>Two
18927 </ol>
18928 !! html/php+tidy
18929 <ol>
18930 <li>One
18931 </li><li>Two
18932 </li></ol>
18933 !! html/parsoid
18934 <ol data-parsoid='{"stx":"html"}'>
18935 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18936 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18937 </ol>
18938
18939 !! end
18940
18941 !! test
18942 HTML nested bullet list, closed tags (T7497)
18943 !! wikitext
18944 <ul>
18945 <li>One</li>
18946 <li>Two:
18947 <ul>
18948 <li>Sub-one</li>
18949 <li>Sub-two</li>
18950 </ul>
18951 </li>
18952 </ul>
18953 !! html/php
18954 <ul>
18955 <li>One</li>
18956 <li>Two:
18957 <ul>
18958 <li>Sub-one</li>
18959 <li>Sub-two</li>
18960 </ul>
18961 </li>
18962 </ul>
18963
18964 !! html/parsoid
18965 <ul data-parsoid='{"stx":"html"}'>
18966 <li data-parsoid='{"stx":"html"}'>One</li>
18967 <li data-parsoid='{"stx":"html"}'>Two:
18968 <ul data-parsoid='{"stx":"html"}'>
18969 <li data-parsoid='{"stx":"html"}'>Sub-one</li>
18970 <li data-parsoid='{"stx":"html"}'>Sub-two</li>
18971 </ul>
18972 </li>
18973 </ul>
18974 !! end
18975
18976 !! test
18977 HTML nested bullet list, open tags (T7497)
18978 !! wikitext
18979 <ul>
18980 <li>One
18981 <li>Two:
18982 <ul>
18983 <li>Sub-one
18984 <li>Sub-two
18985 </ul>
18986 </ul>
18987 !! html+tidy
18988 <ul>
18989 <li>One
18990 </li><li>Two:
18991 <ul>
18992 <li>Sub-one
18993 </li><li>Sub-two
18994 </li></ul>
18995 </li></ul>
18996 !! end
18997
18998 !! test
18999 HTML nested ordered list, closed tags (T7497)
19000 !! wikitext
19001 <ol>
19002 <li>One</li>
19003 <li>Two:
19004 <ol>
19005 <li>Sub-one</li>
19006 <li>Sub-two</li>
19007 </ol>
19008 </li>
19009 </ol>
19010 !! html
19011 <ol>
19012 <li>One</li>
19013 <li>Two:
19014 <ol>
19015 <li>Sub-one</li>
19016 <li>Sub-two</li>
19017 </ol>
19018 </li>
19019 </ol>
19020
19021 !! end
19022
19023 !! test
19024 HTML nested ordered list, open tags (T7497)
19025 !! wikitext
19026 <ol>
19027 <li>One
19028 <li>Two:
19029 <ol>
19030 <li>Sub-one
19031 <li>Sub-two
19032 </ol>
19033 </ol>
19034 !! html/php
19035 <ol>
19036 <li>One
19037 <li>Two:
19038 <ol>
19039 <li>Sub-one
19040 <li>Sub-two
19041 </ol>
19042 </ol>
19043
19044 !! html/parsoid
19045 <ol>
19046 <li>One
19047 </li>
19048 <li>Two:
19049 <ol>
19050 <li>Sub-one
19051 </li>
19052 <li>Sub-two
19053 </li>
19054 </ol>
19055 </li>
19056 </ol>
19057
19058 !! end
19059
19060 !! test
19061 HTML ordered list item with parameters oddity
19062 !! wikitext
19063 <ol><li id="fragment">One</li>
19064 </ol>
19065 !! html
19066 <ol><li id="fragment">One</li>
19067 </ol>
19068
19069 !! end
19070
19071 # parsoid doesn't explicitly mark autonumbered links, see T55505
19072 !!test
19073 T7918: autonumbering
19074 !! wikitext
19075 [http://first/] [http://second] [ftp://ftp]
19076
19077 ftp://inlineftp
19078
19079 [mailto:enclosed@mail.tld With target]
19080
19081 [mailto:enclosed@mail.tld]
19082
19083 mailto:inline@mail.tld
19084 !! html/php
19085 <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>
19086 </p><p><a rel="nofollow" class="external free" href="ftp://inlineftp">ftp://inlineftp</a>
19087 </p><p><a rel="nofollow" class="external text" href="mailto:enclosed@mail.tld">With target</a>
19088 </p><p><a rel="nofollow" class="external autonumber" href="mailto:enclosed@mail.tld">[4]</a>
19089 </p><p><a rel="nofollow" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a>
19090 </p>
19091 !! html/parsoid
19092 <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>
19093 <p><a rel="mw:ExtLink" class="external free" href="ftp://inlineftp">ftp://inlineftp</a></p>
19094 <p><a rel="mw:ExtLink" class="external text" href="mailto:enclosed@mail.tld">With target</a></p>
19095 <p><a rel="mw:ExtLink" class="external autonumber" href="mailto:enclosed@mail.tld"></a></p>
19096 <p><a rel="mw:ExtLink" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a></p>
19097 !! end
19098
19099
19100 #
19101 # Security and HTML correctness
19102 # From Nick Jenkins' fuzz testing
19103 #
19104
19105 !! test
19106 Fuzz testing: Parser13
19107 !! wikitext
19108 {|
19109 | http://a|
19110 !! html
19111 <table>
19112 <tr>
19113 <td>
19114 </td>
19115 </tr>
19116 </table>
19117
19118 !! end
19119
19120 # Note that Parsoid output differs from the PHP parser here: the PHP
19121 # parser breaks the URL for the magic word, while in Parsoid the URL
19122 # production takes precedence.
19123 !! test
19124 Fuzz testing: Parser14
19125 !! wikitext
19126 ==onmouseover===
19127 http://__TOC__
19128 !! html/php
19129 <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>
19130 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>
19131 <ul>
19132 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
19133 </ul>
19134 </div>
19135
19136
19137 !! html/php+tidy
19138 <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>
19139 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>
19140 <ul>
19141 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
19142 </ul>
19143 </div>
19144 !! html/parsoid
19145 <h2 id="onmouseover="><span id="onmouseover.3D" typeof="mw:FallbackId"></span>onmouseover=</h2>
19146 <p><a rel="mw:ExtLink" class="external free" href="http://__TOC__" data-parsoid='{"stx":"url"}'>http://__TOC__</a></p>
19147 !! end
19148
19149 !! test
19150 Fuzz testing: Parser14-table
19151 !! options
19152 parsoid=wt2html,html2html
19153 !! wikitext
19154 ==a==
19155 {| STYLE=__TOC__
19156 !! html
19157 <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>
19158 <table style="&#95;_TOC&#95;_">
19159 <tr><td></td></tr>
19160 </table>
19161
19162 !! html+tidy
19163 <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>
19164 <table style="__TOC__">
19165 <tr>
19166 <td></td>
19167 </tr>
19168 </table>
19169 !! html/parsoid
19170 <h2 id="a">a</h2>
19171 <table style="__TOC__"></table>
19172 !! end
19173
19174 # Known to produce bogus xml (extra </td>)
19175 # Don't add the html/php section since it generates broken HTML
19176 !! test
19177 Fuzz testing: Parser16
19178 !! wikitext
19179 {|
19180 !https://||||||
19181 !! html+tidy
19182 <table>
19183 <tbody><tr>
19184 <th>https://</th>
19185 <th></th>
19186 <th></th>
19187 <th>
19188
19189 </th></tr>
19190 </tbody></table>
19191 !! end
19192
19193 !! test
19194 Fuzz testing: Parser21
19195 !! wikitext
19196 {|
19197 !irc://{{ftp://a" onmouseover="alert('hello world');"
19198 |
19199 !! html
19200 <table>
19201 <tr>
19202 <th><a rel="nofollow" class="external free" href="irc://{{ftp://a">irc://{{ftp://a</a>" onmouseover="alert('hello world');"
19203 </th>
19204 <td>
19205 </td>
19206 </tr>
19207 </table>
19208
19209 !! end
19210
19211 !! test
19212 Fuzz testing: Parser22
19213 !! wikitext
19214 http://===r:::https://b
19215
19216 {|
19217 !! html
19218 <p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a>
19219 </p>
19220 <table>
19221 <tr><td></td></tr>
19222 </table>
19223
19224 !! end
19225
19226 # Known to produce bad XML for now
19227 !! test
19228 Fuzz testing: Parser24
19229 !! options
19230 parsoid=wt2html
19231 !! wikitext
19232 {|
19233 {{{|
19234 <u CLASS=
19235 | {{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}} >
19236 <br style="onmouseover='alert(document.cookie);' " />
19237
19238 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19239 |
19240 !! html/php
19241 <table>
19242 {{{|
19243 <u class="&#124;">}}}} &gt;
19244 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
19245
19246 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19247 <tr>
19248 <td></u>
19249 </td>
19250 </tr>
19251 </table>
19252
19253 !! html/parsoid
19254 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>{{{|
19255 <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>"}'/>}}}} >
19256 <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}'>
19257
19258
19259
19260 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'></td></tr></tbody></table>
19261 !! end
19262
19263 # Note: the current result listed for this is not what the original one was,
19264 # but the original bug was JavaScript injection, which is fixed in any case.
19265 # It's not clear that the original result listed was any more correct than the
19266 # current one. Original result:
19267 # <p>{{{|
19268 # </p>
19269 # <li class="&#124;&#124;">
19270 # }}}blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
19271 !!test
19272 Fuzz testing: Parser25 (T8055)
19273 !! wikitext
19274 {{{
19275 |
19276 <LI CLASS=||
19277 >
19278 }}}blah" onmouseover="alert('hello world');" align="left"'''MOVE MOUSE CURSOR OVER HERE
19279 !! html/php
19280 <p>&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
19281 </p>
19282 !! html/parsoid
19283 <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"]}'>
19284 </span><p about="#mwt1">&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b></p>
19285 !! end
19286
19287 !!test
19288 Fuzz testing: URL adjacent extension (with space, clean)
19289 !! wikitext
19290 http://example.com <nowiki>junk</nowiki>
19291 !! html/php
19292 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> junk
19293 </p>
19294 !! html/parsoid
19295 <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>
19296 !! end
19297
19298 !!test
19299 Fuzz testing: URL adjacent extension (no space, dirty; nowiki)
19300 !! wikitext
19301 http://example.com<nowiki>junk</nowiki>
19302 !! html/php
19303 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>junk
19304 </p>
19305 !! html/parsoid
19306 <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>
19307 !! end
19308
19309 !! test
19310 Fuzz testing: URL adjacent extension (no space, dirty; pre)
19311 !! wikitext
19312 http://example.com<pre>junk</pre>
19313 !! html/php
19314 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre>
19315
19316 !! html/php+tidy
19317 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p><pre>junk</pre>
19318 !! html/parsoid
19319 <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>
19320 !! end
19321
19322 !! test
19323 Fuzz testing: image with bogus manual thumbnail
19324 !! wikitext
19325 [[Image:foobar.jpg|thumbnail= ]]
19326 !! html/php
19327 <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div>
19328
19329 !! html/parsoid
19330 <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>
19331 !! end
19332
19333 # Parsoid will emit the newline literally in wt2wt; see next test case.
19334 !! test
19335 Fuzz testing: encoded newline in generated HTML replacements (T8577)
19336 !! options
19337 parsoid=wt2html
19338 !! wikitext
19339 <pre dir="&#10;"></pre>
19340 !! html/php
19341 <pre dir="&#10;"></pre>
19342
19343 !! html/parsoid
19344 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
19345 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
19346 !! end
19347
19348 !! test
19349 Fuzz testing: encoded newline in generated HTML replacements, html2wt (T8577)
19350 !! options
19351 parsoid=html2wt
19352 !! html/parsoid
19353 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
19354 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
19355 !! wikitext
19356 <pre dir="
19357 "></pre>
19358 !! html/php
19359 <pre dir=""></pre>
19360
19361 !! end
19362
19363 !! test
19364 Templates in extension attributes are not expanded
19365 !! wikitext
19366 <pre dir="{{echo|ltr}}"></pre>
19367 !! html/php
19368 <pre dir="{{echo|ltr}}"></pre>
19369
19370 !! html/parsoid
19371 <pre typeof="mw:Extension/pre" about="#mwt2" dir="{{echo|ltr}}" data-mw='{"name":"pre","attrs":{"dir":"{{echo|ltr}}"},"body":{"extsrc":""}}'></pre>
19372 !! end
19373
19374 !! test
19375 Parsing optional HTML elements (T8171)
19376 !! options
19377 !! wikitext
19378 <table>
19379 <tr>
19380 <td> Some tabular data</td>
19381 <td> More tabular data ...
19382 <td> And yet som tabular data</td>
19383 </tr>
19384 </table>
19385 !! html
19386 <table>
19387 <tr>
19388 <td> Some tabular data</td>
19389 <td> More tabular data ...
19390 </td><td> And yet som tabular data</td>
19391 </tr>
19392 </table>
19393
19394 !! end
19395
19396 !! test
19397 Correct handling of <td>, <tr> (T8171)
19398 !! options
19399 !! wikitext
19400 <table>
19401 <tr>
19402 <td> Some tabular data</td>
19403 <td> More tabular data ...</td>
19404 <td> And yet som tabular data</td>
19405 </tr>
19406 </table>
19407 !! html
19408 <table>
19409 <tr>
19410 <td> Some tabular data</td>
19411 <td> More tabular data ...</td>
19412 <td> And yet som tabular data</td>
19413 </tr>
19414 </table>
19415
19416 !! end
19417
19418
19419 !! test
19420 Parsing crashing regression (fr:JavaScript)
19421 !! wikitext
19422 </body></x>
19423 !! html
19424 <p>&lt;/body&gt;&lt;/x&gt;
19425 </p>
19426 !! end
19427
19428 !! test
19429 Inline wiki vs wiki block nesting
19430 !! wikitext
19431 '''Bold paragraph
19432
19433 New wiki paragraph
19434 !! html
19435 <p><b>Bold paragraph</b>
19436 </p><p>New wiki paragraph
19437 </p>
19438 !! end
19439
19440 # FIXME: The current php output is documented
19441 # and desired output is the parsoid target.
19442 !! test
19443 Inline HTML vs wiki block nesting
19444 !! wikitext
19445 <b>Bold paragraph
19446
19447 New wiki paragraph
19448 !! html/php
19449 <p><b>Bold paragraph
19450 </p><p>New wiki paragraph</b>
19451 </p>
19452 !! html/parsoid
19453 <p><b>Bold paragraph</b>
19454 </p><p>New wiki paragraph
19455 </p>
19456 !! end
19457
19458 # Original result was this:
19459 # <p><b>bold</b><b>bold<i>bolditalics</i></b>
19460 # </p>
19461 # While that might be marginally more intuitive, maybe, the six-apostrophe
19462 # construct is clearly pathological and the result stated here (which is what
19463 # the parser actually does) is about as reasonable as anything.
19464 !!test
19465 Mixing markup for italics and bold
19466 !! options
19467 !! wikitext
19468 '''bold''''''bold''bolditalics'''''
19469 !! html
19470 <p>'<i>bold'</i><b>bold<i>bolditalics</i></b>
19471 </p>
19472 !! end
19473
19474
19475 !! article
19476 Xyzzyx
19477 !! text
19478 Article for special page transclusion test
19479 !! endarticle
19480
19481 !! test
19482 Special page transclusion
19483 !! options
19484 !! wikitext
19485 {{Special:Prefixindex/Xyzzyx}}
19486 !! html
19487 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19488 </ul>
19489
19490 !! end
19491
19492 !! test
19493 Special page transclusion twice (T7021)
19494 !! options
19495 !! wikitext
19496 {{Special:Prefixindex/Xyzzyx}}
19497 {{Special:Prefixindex/Xyzzyx}}
19498 !! html
19499 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19500 </ul>
19501 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19502 </ul>
19503
19504 !! end
19505
19506 !! test
19507 Transclusion of default MediaWiki message
19508 !! wikitext
19509 {{MediaWiki:Mainpage}}
19510 !! html
19511 <p>Main Page
19512 </p>
19513 !! end
19514
19515 !! test
19516 Transclusion of nonexistent MediaWiki message
19517 !! wikitext
19518 {{MediaWiki:Mainpagexxx}}
19519 !! html
19520 <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>
19521 </p>
19522 !! end
19523
19524 !! test
19525 Transclusion of MediaWiki message with underscore
19526 !! wikitext
19527 {{MediaWiki:history_short}}
19528 !! html
19529 <p>History
19530 </p>
19531 !! end
19532
19533 !! test
19534 Transclusion of MediaWiki message with space
19535 !! wikitext
19536 {{MediaWiki:history short}}
19537 !! html
19538 <p>History
19539 </p>
19540 !! end
19541
19542 !! test
19543 Invalid header with following text
19544 !! wikitext
19545 = x = y
19546 !! html
19547 <p>= x = y
19548 </p>
19549 !! end
19550
19551
19552 !! test
19553 Section extraction test (section 0)
19554 !! options
19555 section=0
19556 !! wikitext
19557 start
19558 ==a==
19559 ===aa===
19560 ====aaa====
19561 ==b==
19562 ===ba===
19563 ===bb===
19564 ====bba====
19565 ===bc===
19566 ==c==
19567 ===ca===
19568 !! html/php
19569 start
19570 !! end
19571
19572 !! test
19573 Section extraction test (section 1)
19574 !! options
19575 section=1
19576 !! wikitext
19577 start
19578 ==a==
19579 ===aa===
19580 ====aaa====
19581 ==b==
19582 ===ba===
19583 ===bb===
19584 ====bba====
19585 ===bc===
19586 ==c==
19587 ===ca===
19588 !! html/php
19589 ==a==
19590 ===aa===
19591 ====aaa====
19592 !! end
19593
19594 !! test
19595 Section extraction test (section 2)
19596 !! options
19597 section=2
19598 !! wikitext
19599 start
19600 ==a==
19601 ===aa===
19602 ====aaa====
19603 ==b==
19604 ===ba===
19605 ===bb===
19606 ====bba====
19607 ===bc===
19608 ==c==
19609 ===ca===
19610 !! html/php
19611 ===aa===
19612 ====aaa====
19613 !! end
19614
19615 !! test
19616 Section extraction test (section 3)
19617 !! options
19618 section=3
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 ====aaa====
19633 !! end
19634
19635 !! test
19636 Section extraction test (section 4)
19637 !! options
19638 section=4
19639 !! wikitext
19640 start
19641 ==a==
19642 ===aa===
19643 ====aaa====
19644 ==b==
19645 ===ba===
19646 ===bb===
19647 ====bba====
19648 ===bc===
19649 ==c==
19650 ===ca===
19651 !! html/php
19652 ==b==
19653 ===ba===
19654 ===bb===
19655 ====bba====
19656 ===bc===
19657 !! end
19658
19659 !! test
19660 Section extraction test (section 5)
19661 !! options
19662 section=5
19663 !! wikitext
19664 start
19665 ==a==
19666 ===aa===
19667 ====aaa====
19668 ==b==
19669 ===ba===
19670 ===bb===
19671 ====bba====
19672 ===bc===
19673 ==c==
19674 ===ca===
19675 !! html/php
19676 ===ba===
19677 !! end
19678
19679 !! test
19680 Section extraction test (section 6)
19681 !! options
19682 section=6
19683 !! wikitext
19684 start
19685 ==a==
19686 ===aa===
19687 ====aaa====
19688 ==b==
19689 ===ba===
19690 ===bb===
19691 ====bba====
19692 ===bc===
19693 ==c==
19694 ===ca===
19695 !! html/php
19696 ===bb===
19697 ====bba====
19698 !! end
19699
19700 !! test
19701 Section extraction test (section 7)
19702 !! options
19703 section=7
19704 !! wikitext
19705 start
19706 ==a==
19707 ===aa===
19708 ====aaa====
19709 ==b==
19710 ===ba===
19711 ===bb===
19712 ====bba====
19713 ===bc===
19714 ==c==
19715 ===ca===
19716 !! html/php
19717 ====bba====
19718 !! end
19719
19720 !! test
19721 Section extraction test (section 8)
19722 !! options
19723 section=8
19724 !! wikitext
19725 start
19726 ==a==
19727 ===aa===
19728 ====aaa====
19729 ==b==
19730 ===ba===
19731 ===bb===
19732 ====bba====
19733 ===bc===
19734 ==c==
19735 ===ca===
19736 !! html/php
19737 ===bc===
19738 !! end
19739
19740 !! test
19741 Section extraction test (section 9)
19742 !! options
19743 section=9
19744 !! wikitext
19745 start
19746 ==a==
19747 ===aa===
19748 ====aaa====
19749 ==b==
19750 ===ba===
19751 ===bb===
19752 ====bba====
19753 ===bc===
19754 ==c==
19755 ===ca===
19756 !! html/php
19757 ==c==
19758 ===ca===
19759 !! end
19760
19761 !! test
19762 Section extraction test (section 10)
19763 !! options
19764 section=10
19765 !! wikitext
19766 start
19767 ==a==
19768 ===aa===
19769 ====aaa====
19770 ==b==
19771 ===ba===
19772 ===bb===
19773 ====bba====
19774 ===bc===
19775 ==c==
19776 ===ca===
19777 !! html/php
19778 ===ca===
19779 !! end
19780
19781 !! test
19782 Section extraction test (nonexistent section 11)
19783 !! options
19784 section=11
19785 !! wikitext
19786 start
19787 ==a==
19788 ===aa===
19789 ====aaa====
19790 ==b==
19791 ===ba===
19792 ===bb===
19793 ====bba====
19794 ===bc===
19795 ==c==
19796 ===ca===
19797 !! html/php
19798 !! end
19799
19800 !! test
19801 Section extraction test with bogus heading (section 1)
19802 !! options
19803 section=1
19804 !! wikitext
19805 ==a==
19806 ==bogus== not a legal section
19807 ==b==
19808 !! html/php
19809 ==a==
19810 ==bogus== not a legal section
19811 !! end
19812
19813 !! test
19814 Section extraction test with bogus heading (section 2)
19815 !! options
19816 section=2
19817 !! wikitext
19818 ==a==
19819 ==bogus== not a legal section
19820 ==b==
19821 !! html/php
19822 ==b==
19823 !! end
19824
19825 !! test
19826 Section extraction test with comment after heading (section 1)
19827 !! options
19828 section=1
19829 !! wikitext
19830 ==a==
19831 ==b== <!-- -->
19832 ==c==
19833 !! html/php
19834 ==a==
19835 !! end
19836
19837 !! test
19838 Section extraction test with comment after heading (section 2)
19839 !! options
19840 section=2
19841 !! wikitext
19842 ==a==
19843 ==b== <!-- -->
19844 ==c==
19845 !! html/php
19846 ==b== <!-- -->
19847 !! end
19848
19849 !! test
19850 Section extraction test with bogus <nowiki> heading (section 1)
19851 !! options
19852 section=1
19853 !! wikitext
19854 ==a==
19855 ==bogus== <nowiki>not a legal section</nowiki>
19856 ==b==
19857 !! html/php
19858 ==a==
19859 ==bogus== <nowiki>not a legal section</nowiki>
19860 !! end
19861
19862 !! test
19863 Section extraction test with bogus <nowiki> heading (section 2)
19864 !! options
19865 section=2
19866 !! wikitext
19867 ==a==
19868 ==bogus== <nowiki>not a legal section</nowiki>
19869 ==b==
19870 !! html/php
19871 ==b==
19872 !! end
19873
19874 # Formerly testing for T4587, now resolved by the use of unmarked sections
19875 # instead of respecting commented sections
19876 !! test
19877 Section extraction prefixed by comment (section 1)
19878 !! options
19879 section=1
19880 !! wikitext
19881 <!-- -->==sec1==
19882 ==sec2==
19883 !! html/php
19884 ==sec2==
19885 !!end
19886
19887 !! test
19888 Section extraction prefixed by comment (section 2)
19889 !! options
19890 section=2
19891 !! wikitext
19892 <!-- -->==sec1==
19893 ==sec2==
19894 !! html/php
19895
19896 !!end
19897
19898 # Formerly testing for T4607, now resolved by the use of unmarked sections
19899 # instead of respecting HTML-style headings
19900 !! test
19901 Section extraction, mixed wiki and html (section 1)
19902 !! options
19903 section=1
19904 !! wikitext
19905 <h2>unmarked</h2>
19906 unmarked
19907 ==1==
19908 one
19909 ==2==
19910 two
19911 !! html/php
19912 ==1==
19913 one
19914 !! end
19915
19916 !! test
19917 Section extraction, mixed wiki and html (section 2)
19918 !! options
19919 section=2
19920 !! wikitext
19921 <h2>unmarked</h2>
19922 unmarked
19923 ==1==
19924 one
19925 ==2==
19926 two
19927 !! html/php
19928 ==2==
19929 two
19930 !! end
19931
19932
19933 # Formerly testing for T5342
19934 !! test
19935 Section extraction, heading surrounded by <noinclude>
19936 !! options
19937 section=1
19938 !! wikitext
19939 <noinclude>==unmarked==</noinclude>
19940 ==marked==
19941 !! html/php
19942 ==marked==
19943 !!end
19944
19945 # Test behavior of T21910
19946 !! test
19947 Sectiion with all-equals
19948 !! options
19949 section=2
19950 !! wikitext
19951 ===
19952 The line above must have a trailing space
19953 === <!--
19954 --> <!-- -->
19955 But just in case it doesn't...
19956 !! html/php
19957 === <!--
19958 --> <!-- -->
19959 But just in case it doesn't...
19960 !! end
19961
19962 !! test
19963 Section replacement test (section 0)
19964 !! options
19965 replace=0,"xxx"
19966 !! wikitext
19967 start
19968 ==a==
19969 ===aa===
19970 ====aaa====
19971 ==b==
19972 ===ba===
19973 ===bb===
19974 ====bba====
19975 ===bc===
19976 ==c==
19977 ===ca===
19978 !! html/php
19979 xxx
19980
19981 ==a==
19982 ===aa===
19983 ====aaa====
19984 ==b==
19985 ===ba===
19986 ===bb===
19987 ====bba====
19988 ===bc===
19989 ==c==
19990 ===ca===
19991 !! end
19992
19993 !! test
19994 Section replacement test (section 1)
19995 !! options
19996 replace=1,"xxx"
19997 !! wikitext
19998 start
19999 ==a==
20000 ===aa===
20001 ====aaa====
20002 ==b==
20003 ===ba===
20004 ===bb===
20005 ====bba====
20006 ===bc===
20007 ==c==
20008 ===ca===
20009 !! html/php
20010 start
20011 xxx
20012
20013 ==b==
20014 ===ba===
20015 ===bb===
20016 ====bba====
20017 ===bc===
20018 ==c==
20019 ===ca===
20020 !! end
20021
20022 !! test
20023 Section replacement test (section 2)
20024 !! options
20025 replace=2,"xxx"
20026 !! wikitext
20027 start
20028 ==a==
20029 ===aa===
20030 ====aaa====
20031 ==b==
20032 ===ba===
20033 ===bb===
20034 ====bba====
20035 ===bc===
20036 ==c==
20037 ===ca===
20038 !! html/php
20039 start
20040 ==a==
20041 xxx
20042
20043 ==b==
20044 ===ba===
20045 ===bb===
20046 ====bba====
20047 ===bc===
20048 ==c==
20049 ===ca===
20050 !! end
20051
20052 !! test
20053 Section replacement test (section 3)
20054 !! options
20055 replace=3,"xxx"
20056 !! wikitext
20057 start
20058 ==a==
20059 ===aa===
20060 ====aaa====
20061 ==b==
20062 ===ba===
20063 ===bb===
20064 ====bba====
20065 ===bc===
20066 ==c==
20067 ===ca===
20068 !! html/php
20069 start
20070 ==a==
20071 ===aa===
20072 xxx
20073
20074 ==b==
20075 ===ba===
20076 ===bb===
20077 ====bba====
20078 ===bc===
20079 ==c==
20080 ===ca===
20081 !! end
20082
20083 !! test
20084 Section replacement test (section 4)
20085 !! options
20086 replace=4,"xxx"
20087 !! wikitext
20088 start
20089 ==a==
20090 ===aa===
20091 ====aaa====
20092 ==b==
20093 ===ba===
20094 ===bb===
20095 ====bba====
20096 ===bc===
20097 ==c==
20098 ===ca===
20099 !! html/php
20100 start
20101 ==a==
20102 ===aa===
20103 ====aaa====
20104 xxx
20105
20106 ==c==
20107 ===ca===
20108 !! end
20109
20110 !! test
20111 Section replacement test (section 5)
20112 !! options
20113 replace=5,"xxx"
20114 !! wikitext
20115 start
20116 ==a==
20117 ===aa===
20118 ====aaa====
20119 ==b==
20120 ===ba===
20121 ===bb===
20122 ====bba====
20123 ===bc===
20124 ==c==
20125 ===ca===
20126 !! html/php
20127 start
20128 ==a==
20129 ===aa===
20130 ====aaa====
20131 ==b==
20132 xxx
20133
20134 ===bb===
20135 ====bba====
20136 ===bc===
20137 ==c==
20138 ===ca===
20139 !! end
20140
20141 !! test
20142 Section replacement test (section 6)
20143 !! options
20144 replace=6,"xxx"
20145 !! wikitext
20146 start
20147 ==a==
20148 ===aa===
20149 ====aaa====
20150 ==b==
20151 ===ba===
20152 ===bb===
20153 ====bba====
20154 ===bc===
20155 ==c==
20156 ===ca===
20157 !! html/php
20158 start
20159 ==a==
20160 ===aa===
20161 ====aaa====
20162 ==b==
20163 ===ba===
20164 xxx
20165
20166 ===bc===
20167 ==c==
20168 ===ca===
20169 !! end
20170
20171 !! test
20172 Section replacement test (section 7)
20173 !! options
20174 replace=7,"xxx"
20175 !! wikitext
20176 start
20177 ==a==
20178 ===aa===
20179 ====aaa====
20180 ==b==
20181 ===ba===
20182 ===bb===
20183 ====bba====
20184 ===bc===
20185 ==c==
20186 ===ca===
20187 !! html/php
20188 start
20189 ==a==
20190 ===aa===
20191 ====aaa====
20192 ==b==
20193 ===ba===
20194 ===bb===
20195 xxx
20196
20197 ===bc===
20198 ==c==
20199 ===ca===
20200 !! end
20201
20202 !! test
20203 Section replacement test (section 8)
20204 !! options
20205 replace=8,"xxx"
20206 !! wikitext
20207 start
20208 ==a==
20209 ===aa===
20210 ====aaa====
20211 ==b==
20212 ===ba===
20213 ===bb===
20214 ====bba====
20215 ===bc===
20216 ==c==
20217 ===ca===
20218 !! html/php
20219 start
20220 ==a==
20221 ===aa===
20222 ====aaa====
20223 ==b==
20224 ===ba===
20225 ===bb===
20226 ====bba====
20227 xxx
20228
20229 ==c==
20230 ===ca===
20231 !!end
20232
20233 !! test
20234 Section replacement test (section 9)
20235 !! options
20236 replace=9,"xxx"
20237 !! wikitext
20238 start
20239 ==a==
20240 ===aa===
20241 ====aaa====
20242 ==b==
20243 ===ba===
20244 ===bb===
20245 ====bba====
20246 ===bc===
20247 ==c==
20248 ===ca===
20249 !! html/php
20250 start
20251 ==a==
20252 ===aa===
20253 ====aaa====
20254 ==b==
20255 ===ba===
20256 ===bb===
20257 ====bba====
20258 ===bc===
20259 xxx
20260 !! end
20261
20262 !! test
20263 Section replacement test (section 10)
20264 !! options
20265 replace=10,"xxx"
20266 !! wikitext
20267 start
20268 ==a==
20269 ===aa===
20270 ====aaa====
20271 ==b==
20272 ===ba===
20273 ===bb===
20274 ====bba====
20275 ===bc===
20276 ==c==
20277 ===ca===
20278 !! html/php
20279 start
20280 ==a==
20281 ===aa===
20282 ====aaa====
20283 ==b==
20284 ===ba===
20285 ===bb===
20286 ====bba====
20287 ===bc===
20288 ==c==
20289 xxx
20290 !! end
20291
20292 !! test
20293 Section replacement test with initial whitespace (T15728)
20294 !! options
20295 replace=2,"xxx"
20296 !! wikitext
20297 Preformatted initial line
20298 ==a==
20299 ===a===
20300 !! html/php
20301 Preformatted initial line
20302 ==a==
20303 xxx
20304 !! end
20305
20306
20307 !! test
20308 Section extraction, heading followed by pre with 20 spaces (T8398)
20309 !! options
20310 section=1
20311 !! wikitext
20312 ==a==
20313 a
20314 !! html/php
20315 ==a==
20316 a
20317 !! end
20318
20319 !! test
20320 Section extraction, heading followed by pre with 19 spaces (T8398 sanity check)
20321 !! options
20322 section=1
20323 !! wikitext
20324 ==a==
20325 a
20326 !! html/php
20327 ==a==
20328 a
20329 !! end
20330
20331
20332 !! test
20333 Section extraction, <pre> around bogus header (T12309)
20334 !! options
20335 section=2
20336 !! wikitext
20337 == Section One ==
20338 <pre>
20339 =======
20340 </pre>
20341
20342 == Section Two ==
20343 stuff
20344 !! html/php
20345 == Section Two ==
20346 stuff
20347 !! end
20348
20349 !! test
20350 Section replacement, <pre> around bogus header (T12309)
20351 !! options
20352 replace=2,"xxx"
20353 !! wikitext
20354 == Section One ==
20355 <pre>
20356 =======
20357 </pre>
20358
20359 == Section Two ==
20360 stuff
20361 !! html/php
20362 == Section One ==
20363 <pre>
20364 =======
20365 </pre>
20366
20367 xxx
20368 !! end
20369
20370 !! test
20371 Handling of &#x0A; in URLs
20372 !! wikitext
20373 *irc://&#x0A;a
20374 !! html/php
20375 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
20376
20377 !! html/parsoid
20378 <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>
20379 !! end
20380
20381 !! test
20382 Handling of %0A in URLs
20383 !! wikitext
20384 *irc://%0Aa
20385 !! html/php
20386 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
20387
20388 !! html/parsoid
20389 <ul><li><a rel="mw:ExtLink" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
20390 !! end
20391
20392 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
20393 !! test
20394 5 quotes, code coverage +1 line
20395 !! options
20396 parsoid=wt2html
20397 !! wikitext
20398 '''''
20399 !! html/php
20400 !! html/parsoid
20401 <b><i></i></b>
20402 !! end
20403
20404 # same html as previous, but wikitext adjusted to match parsoid html2wt
20405 # note that wt2html and html2html will put the <i> before the <b>
20406 !! test
20407 5 quotes, code coverage +1 line w/ nowiki (1)
20408 !! options
20409 parsoid=wt2wt,html2wt
20410 !! wikitext
20411 '''''<nowiki/>'''''
20412 !! html/php
20413 <p><i></i>
20414 </p>
20415 !! html/parsoid
20416 <p><b><i></i></b></p>
20417 !! end
20418
20419 # same as previous, just swapping the <i> and <b>
20420 !! test
20421 5 quotes, code coverage +1 line w/ nowiki (2)
20422 !! wikitext
20423 '''''<nowiki/>'''''
20424 !! html/php
20425 <p><i></i>
20426 </p>
20427 !! html/parsoid
20428 <p><i><b></b></i></p>
20429 !! end
20430
20431 !! test
20432 Special:Search page linking.
20433 !! wikitext
20434 {{Special:search}}
20435 !! html
20436 <p><a href="/wiki/Special:Search" title="Special:Search">Special:Search</a>
20437 </p>
20438 !! end
20439
20440 !! test
20441 {{!}} is a magic word
20442 !! wikitext
20443 {{!}} is a magic word there and {{!}} is still a magic word here
20444 | is not a magic word here but {{!}} is still a magic word here
20445 !! html/php
20446 <p>| is a magic word there and | is still a magic word here
20447 | is not a magic word here but | is still a magic word here
20448 </p>
20449 !! html/parsoid
20450 <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
20451 | 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>
20452 !! end
20453
20454 !! test
20455 Say the magic word
20456 !! options
20457 title=[[Parser test]]
20458 !! wikitext
20459 *{{PAGENAME}}
20460 *{{PAGENAMEE}}
20461 *{{FULLPAGENAME}}
20462 *{{FULLPAGENAMEE}}
20463 *{{BASEPAGENAME}}
20464 *{{BASEPAGENAMEE}}
20465 *{{SUBPAGENAME}}
20466 *{{SUBPAGENAMEE}}
20467 *{{ROOTPAGENAME}}
20468 *{{ROOTPAGENAMEE}}
20469 *{{TALKPAGENAME}}
20470 *{{TALKPAGENAMEE}}
20471 *{{SUBJECTPAGENAME}}
20472 *{{SUBJECTPAGENAMEE}}
20473 *{{NAMESPACEE}}
20474 *{{NAMESPACE}}
20475 *{{NAMESPACENUMBER}}
20476 *{{TALKSPACE}}
20477 *{{TALKSPACEE}}
20478 *{{SUBJECTSPACE}}
20479 *{{SUBJECTSPACEE}}
20480 *{{Dynamic|{{NUMBEROFUSERS}}|{{NUMBEROFPAGES}}|{{CURRENTVERSION}}|{{CONTENTLANGUAGE}}|{{DIRECTIONMARK}}|{{CURRENTTIMESTAMP}}|{{NUMBEROFARTICLES}}}}
20481 !! html
20482 <ul><li>Parser test</li>
20483 <li>Parser_test</li>
20484 <li>Parser test</li>
20485 <li>Parser_test</li>
20486 <li>Parser test</li>
20487 <li>Parser_test</li>
20488 <li>Parser test</li>
20489 <li>Parser_test</li>
20490 <li>Parser test</li>
20491 <li>Parser_test</li>
20492 <li>Talk:Parser test</li>
20493 <li>Talk:Parser_test</li>
20494 <li>Parser test</li>
20495 <li>Parser_test</li>
20496 <li></li>
20497 <li></li>
20498 <li>0</li>
20499 <li>Talk</li>
20500 <li>Talk</li>
20501 <li></li>
20502 <li></li>
20503 <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>
20504
20505 !! end
20506 ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included.
20507
20508 !! test
20509 Gallery with valid attributes
20510 !! wikitext
20511 <gallery type="123" summary="345">
20512 File:File:Foobar.jpg
20513 </gallery>
20514 !! html/php
20515 <ul class="gallery mw-gallery-traditional" type="123">
20516 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20517 <div class="thumb" style="height: 150px;">File:Foobar.jpg</div>
20518 <div class="gallerytext">
20519 </div>
20520 </div></li>
20521 </ul>
20522
20523 !! html/parsoid
20524 <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"}}'>
20525 <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>
20526 </ul>
20527 !! end
20528
20529 ## Parsoid thinks the "centre" here is a property, not a caption.
20530 !! test
20531 Gallery
20532 !! options
20533 parsoid={
20534 "modes": ["wt2html"],
20535 "nativeGallery": true
20536 }
20537 !! wikitext
20538 <gallery>
20539 image1.png |
20540 image2.gif|||||
20541
20542 image3|
20543 image4 |300px| centre
20544 image5.svg| http://///////
20545 [[x|xx]]]]
20546 * image6
20547 </gallery>
20548 !! html/php
20549 <ul class="gallery mw-gallery-traditional">
20550 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20551 <div class="thumb" style="height: 150px;">Image1.png</div>
20552 <div class="gallerytext">
20553 </div>
20554 </div></li>
20555 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20556 <div class="thumb" style="height: 150px;">Image2.gif</div>
20557 <div class="gallerytext">
20558 </div>
20559 </div></li>
20560 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20561 <div class="thumb" style="height: 150px;">Image3</div>
20562 <div class="gallerytext">
20563 </div>
20564 </div></li>
20565 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20566 <div class="thumb" style="height: 150px;">Image4</div>
20567 <div class="gallerytext">
20568 <pre>centre
20569 </pre>
20570 </div>
20571 </div></li>
20572 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20573 <div class="thumb" style="height: 150px;">Image5.svg</div>
20574 <div class="gallerytext">
20575 <p><a rel="nofollow" class="external free" href="http://///////">http://///////</a>
20576 </p>
20577 </div>
20578 </div></li>
20579 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20580 <div class="thumb" style="height: 150px;">* image6</div>
20581 <div class="gallerytext">
20582 </div>
20583 </div></li>
20584 </ul>
20585
20586 !! html/parsoid
20587 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20588 <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>
20589 <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>
20590 <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>
20591 <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>
20592 <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>
20593 <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>
20594 </ul>
20595 !! end
20596
20597 !! test
20598 Gallery (with options, html)
20599 !! options
20600 parsoid={
20601 "modes": ["wt2html", "html2html"],
20602 "nativeGallery": true
20603 }
20604 !! wikitext
20605 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
20606 File:Nonexistent.jpg|caption
20607 File:Nonexistent.jpg
20608 image:foobar.jpg|some '''caption''' [[Main Page]]
20609 image:foobar.jpg
20610 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
20611 </gallery>
20612 !! html/php
20613 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
20614 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
20615 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20616 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20617 <div class="gallerytext">
20618 <p>caption
20619 </p>
20620 </div>
20621 </div></li>
20622 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20623 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20624 <div class="gallerytext">
20625 </div>
20626 </div></li>
20627 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20628 <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>
20629 <div class="gallerytext">
20630 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20631 </p>
20632 </div>
20633 </div></li>
20634 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20635 <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>
20636 <div class="gallerytext">
20637 </div>
20638 </div></li>
20639 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20640 <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>
20641 <div class="gallerytext">
20642 <p>blabla.
20643 </p>
20644 </div>
20645 </div></li>
20646 </ul>
20647
20648 !! html/parsoid
20649 <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":{}}'>
20650 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
20651 <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>
20652 <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>
20653 <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>
20654 <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>
20655 <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>
20656 </ul>
20657 !! end
20658
20659 !! test
20660 Gallery (with options, extsrc)
20661 !! options
20662 parsoid={
20663 "nativeGallery": false
20664 }
20665 !! wikitext
20666 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
20667 File:Nonexistent.jpg|caption
20668 File:Nonexistent.jpg
20669 image:foobar.jpg|some '''caption''' [[Main Page]]
20670 image:foobar.jpg
20671 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
20672 </gallery>
20673 !! html/php
20674 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
20675 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
20676 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20677 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20678 <div class="gallerytext">
20679 <p>caption
20680 </p>
20681 </div>
20682 </div></li>
20683 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20684 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20685 <div class="gallerytext">
20686 </div>
20687 </div></li>
20688 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20689 <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>
20690 <div class="gallerytext">
20691 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20692 </p>
20693 </div>
20694 </div></li>
20695 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20696 <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>
20697 <div class="gallerytext">
20698 </div>
20699 </div></li>
20700 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20701 <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>
20702 <div class="gallerytext">
20703 <p>blabla.
20704 </p>
20705 </div>
20706 </div></li>
20707 </ul>
20708
20709 !! html/parsoid
20710 <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"}}'>
20711 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
20712 <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>
20713 <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>
20714 <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>
20715 <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>
20716 <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>
20717 </ul>
20718 !! end
20719
20720 !! test
20721 Gallery (without px units)
20722 !! wikitext
20723 <gallery widths="70" heights="40">
20724 File:Foobar.jpg
20725 </gallery>
20726 !! html/php
20727 <ul class="gallery mw-gallery-traditional">
20728 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20729 <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>
20730 <div class="gallerytext">
20731 </div>
20732 </div></li>
20733 </ul>
20734
20735 !! html/parsoid
20736 <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"}}'>
20737 <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>
20738 </ul>
20739 !! end
20740
20741 !! test
20742 Gallery (with invalid units)
20743 !! wikitext
20744 <gallery widths="70em" heights="40em">
20745 File:Foobar.jpg
20746 </gallery>
20747 !! html/php
20748 <ul class="gallery mw-gallery-traditional">
20749 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20750 <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>
20751 <div class="gallerytext">
20752 </div>
20753 </div></li>
20754 </ul>
20755
20756 !! html/parsoid
20757 <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"}}'>
20758 <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>
20759 </ul>
20760 !! end
20761
20762 !! test
20763 Gallery with link that has fragment
20764 !! options
20765 parsoid={
20766 "modes": ["wt2html", "html2html"],
20767 "nativeGallery": true
20768 }
20769 !! wikitext
20770 <gallery>
20771 image:foobar.jpg|link=Main_Page
20772 image:foobar.jpg|link=Main_Page#section
20773 image:foobar.jpg|link=Main Page#section|caption
20774 </gallery>
20775 !! html/php
20776 <ul class="gallery mw-gallery-traditional">
20777 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20778 <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>
20779 <div class="gallerytext">
20780 </div>
20781 </div></li>
20782 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20783 <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>
20784 <div class="gallerytext">
20785 </div>
20786 </div></li>
20787 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20788 <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>
20789 <div class="gallerytext">
20790 <p>caption
20791 </p>
20792 </div>
20793 </div></li>
20794 </ul>
20795
20796 !! html/parsoid
20797 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20798 <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>
20799 <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>
20800 <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>
20801 </ul>
20802 !! end
20803
20804 ## Whoops, Parsoid shouldn't be parsing templates in the attribute caption!
20805 !! test
20806 Gallery with template inside caption
20807 !! options
20808 parsoid={
20809 "nativeGallery": true
20810 }
20811 !! wikitext
20812 <gallery caption="{{echo|hi}}">
20813 File:Foobar.jpg|{{echo|ho}}
20814 </gallery>
20815 !! html/php
20816 <ul class="gallery mw-gallery-traditional">
20817 <li class='gallerycaption'>{{echo|hi}}</li>
20818 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20819 <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>
20820 <div class="gallerytext">
20821 <p>ho
20822 </p>
20823 </div>
20824 </div></li>
20825 </ul>
20826
20827 !! html/parsoid
20828 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20829 <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>
20830 <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>
20831 </ul>
20832 !! end
20833
20834 !! test
20835 Gallery with wikitext inside caption
20836 !! options
20837 parsoid={
20838 "nativeGallery": true
20839 }
20840 !! wikitext
20841 <gallery>
20842 File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]]
20843 File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}}
20844 </gallery>
20845 !! html/php
20846 <ul class="gallery mw-gallery-traditional">
20847 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20848 <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>
20849 <div class="gallerytext">
20850 <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>
20851 </p>
20852 </div>
20853 </div></li>
20854 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20855 <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>
20856 <div class="gallerytext">
20857 <p>This is a test template
20858 </p>
20859 </div>
20860 </div></li>
20861 </ul>
20862
20863 !! html/parsoid
20864 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20865 <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>
20866 <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>
20867 </ul>
20868 !! end
20869
20870 !! test
20871 Gallery (with showfilename option)
20872 !! options
20873 parsoid={
20874 "nativeGallery": true
20875 }
20876 !! wikitext
20877 <gallery showfilename="">
20878 File:Nonexistent.jpg|caption
20879 File:Nonexistent.jpg
20880 File:Foobar.jpg|some '''caption''' [[Main Page]]
20881 File:Foobar.jpg
20882 </gallery>
20883 !! html/php
20884 <ul class="gallery mw-gallery-traditional">
20885 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20886 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20887 <div class="gallerytext">
20888 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
20889 caption
20890 </p>
20891 </div>
20892 </div></li>
20893 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20894 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20895 <div class="gallerytext">
20896 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
20897 </p>
20898 </div>
20899 </div></li>
20900 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20901 <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>
20902 <div class="gallerytext">
20903 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
20904 some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20905 </p>
20906 </div>
20907 </div></li>
20908 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20909 <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>
20910 <div class="gallerytext">
20911 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
20912 </p>
20913 </div>
20914 </div></li>
20915 </ul>
20916
20917 !! html/parsoid
20918 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
20919 <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>
20920 <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>
20921 <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>
20922 <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>
20923 </ul>
20924 !! end
20925
20926 ## Should Parsoid be preserving these variations? See T151367
20927 !! test
20928 Gallery (with namespace-less filenames)
20929 !! options
20930 parsoid={
20931 "modes": ["wt2html", "html2html"],
20932 "nativeGallery": true
20933 }
20934 !! wikitext
20935 <gallery>
20936 File:Nonexistent.jpg
20937 Nonexistent.jpg
20938 image:foobar.jpg
20939 foobar.jpg
20940 </gallery>
20941 !! html/php
20942 <ul class="gallery mw-gallery-traditional">
20943 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20944 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20945 <div class="gallerytext">
20946 </div>
20947 </div></li>
20948 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20949 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20950 <div class="gallerytext">
20951 </div>
20952 </div></li>
20953 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20954 <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>
20955 <div class="gallerytext">
20956 </div>
20957 </div></li>
20958 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20959 <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>
20960 <div class="gallerytext">
20961 </div>
20962 </div></li>
20963 </ul>
20964
20965 !! html/parsoid
20966 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20967 <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>
20968 <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>
20969 <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>
20970 <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>
20971 </ul>
20972 !! end
20973
20974 !! test
20975 Gallery override link with wikilink (T36852)
20976 !! options
20977 parsoid={
20978 "nativeGallery": true
20979 }
20980 !! wikitext
20981 <gallery>
20982 File:Foobar.jpg|alt=galleryalt|link=Wikilink
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="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>
20988 <div class="gallerytext">
20989 </div>
20990 </div></li>
20991 </ul>
20992
20993 !! html/parsoid
20994 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20995 <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>
20996 </ul>
20997 !! end
20998
20999 !! test
21000 Gallery override link with absolute external link (T36852)
21001 !! options
21002 parsoid={
21003 "nativeGallery": true
21004 }
21005 !! wikitext
21006 <gallery>
21007 File:Foobar.jpg|alt=galleryalt|link=http://www.example.org
21008 </gallery>
21009 !! html/php
21010 <ul class="gallery mw-gallery-traditional">
21011 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21012 <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>
21013 <div class="gallerytext">
21014 </div>
21015 </div></li>
21016 </ul>
21017
21018 !! html/parsoid
21019 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21020 <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>
21021 </ul>
21022 !! end
21023
21024 !! test
21025 Gallery override link with absolute external link with LanguageConverter
21026 !! options
21027 language=zh
21028 !! wikitext
21029 <gallery>
21030 File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org
21031 </gallery>
21032 !! html/php
21033 <ul class="gallery mw-gallery-traditional">
21034 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21035 <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>
21036 <div class="gallerytext">
21037 <p>caption
21038 </p>
21039 </div>
21040 </div></li>
21041 </ul>
21042
21043 !! html/parsoid
21044 <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"}}'>
21045 <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>
21046 </ul>
21047 !! end
21048
21049 !! test
21050 Gallery override link with malicious javascript (T36852)
21051 !! options
21052 parsoid={
21053 "modes": ["wt2html", "html2html"],
21054 "nativeGallery": true
21055 }
21056 !! wikitext
21057 <gallery>
21058 File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!');
21059 </gallery>
21060 !! html/php
21061 <ul class="gallery mw-gallery-traditional">
21062 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21063 <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>
21064 <div class="gallerytext">
21065 </div>
21066 </div></li>
21067 </ul>
21068
21069 !! html/parsoid
21070 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21071 <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>
21072 </ul>
21073 !! end
21074
21075 # Note that parsoid uses the invalid link as a caption, PHP does not.
21076 !! test
21077 Gallery with invalid title as link (T45964)
21078 !! options
21079 parsoid={
21080 "modes": ["wt2html", "html2html"],
21081 "nativeGallery": true
21082 }
21083 !! wikitext
21084 <gallery>
21085 File:Foobar.jpg|link=<
21086 </gallery>
21087 !! html/php
21088 <ul class="gallery mw-gallery-traditional">
21089 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21090 <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>
21091 <div class="gallerytext">
21092 </div>
21093 </div></li>
21094 </ul>
21095
21096 !! html/parsoid
21097 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21098 <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>
21099 </ul>
21100 !! end
21101
21102 !! test
21103 Serialize gallery without attrs in data-mw
21104 !! options
21105 parsoid={
21106 "modes": ["html2wt"],
21107 "nativeGallery": true
21108 }
21109 !! html/parsoid
21110 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'>
21111 <li class="gallerycaption">123</li>
21112 <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>
21113 </ul>
21114 !! wikitext
21115 <gallery caption="123">
21116 File:Test.png
21117 </gallery>
21118 !! end
21119
21120 !! test
21121 Gallery with class and style attributes
21122 !! options
21123 parsoid={
21124 "nativeGallery": true
21125 }
21126 !! wikitext
21127 <gallery class="center" style="text-align: center;">
21128 File:Foobar.jpg
21129 </gallery>
21130 !! html/php
21131 <ul class="gallery mw-gallery-traditional center" style="text-align: center;">
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 center" style="text-align: center;" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"class":"center","style":"text-align: center;"},"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"></div></li>
21142 </ul>
21143 !! end
21144
21145 !! test
21146 Gallery in slideshow mode
21147 !! options
21148 parsoid={
21149 "nativeGallery": true
21150 }
21151 !! wikitext
21152 <gallery mode="slideshow" showthumbnails="">
21153 File:Foobar.jpg
21154 </gallery>
21155 !! html/php
21156 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1">
21157 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21158 <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>
21159 <div class="gallerytext">
21160 </div>
21161 </div></li>
21162 </ul>
21163
21164 !! html/parsoid
21165 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'>
21166 <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>
21167 </ul>
21168 !! end
21169
21170 !! test
21171 Serialize gallery image captions on a line
21172 !! options
21173 parsoid={
21174 "modes": ["html2wt"],
21175 "nativeGallery": true
21176 }
21177 !! html/parsoid
21178 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21179 <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>
21180 <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>
21181 </ul>
21182 !! wikitext
21183 <gallery>
21184 File:Foobar.jpg| hi ho
21185 File:Foobar.jpg|hi<br />ho
21186 </gallery>
21187 !! end
21188
21189 !! test
21190 HTML Hex character encoding (spells the word "JavaScript")
21191 !! options
21192 parsoid=wt2html,wt2wt,html2html
21193 !! wikitext
21194 &#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
21195 !! html/php
21196 <p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
21197 </p>
21198 !! html/parsoid
21199 <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>
21200 !! end
21201
21202 !! test
21203 HTML Hex character encoding bogus encoding (T28437 regression check)
21204 !! wikitext
21205 &#xsee;&#XSEE;
21206 !! html
21207 <p>&amp;#xsee;&amp;#XSEE;
21208 </p>
21209 !! end
21210
21211 !! test
21212 HTML Hex character encoding mixed case
21213 !! options
21214 parsoid=wt2html,wt2wt,html2html
21215 !! wikitext
21216 &#xEE;&#Xee;
21217 !! html/php
21218 <p>&#xee;&#xee;
21219 </p>
21220 !! html/parsoid
21221 <p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
21222 !! end
21223
21224 # See: https://www.w3.org/TR/html5/syntax.html#character-references
21225 # Note that U+000C (form feed) is not a valid XML character, so
21226 # it is banned even though allowed in HTML5.
21227 !! test
21228 Illegal character references (T106578)
21229 !! wikitext
21230 ; Null: &#00;
21231 ; FF: &#xC;
21232 ; CR: &#xD;
21233 ; Control (low): &#8;
21234 ; Control (high): &#x7F; &#x9F;
21235 ; Surrogate: &#xD83D;&#xDCA9;
21236 ; This is an okay astral character: &#x1F4A9;
21237 !! html+tidy
21238 <dl><dt>Null</dt>
21239 <dd>&amp;#00;</dd>
21240 <dt>FF</dt>
21241 <dd>&amp;#xC;</dd>
21242 <dt>CR</dt>
21243 <dd>&amp;#xD;</dd>
21244 <dt>Control (low)</dt>
21245 <dd>&amp;#8;</dd>
21246 <dt>Control (high)</dt>
21247 <dd>&amp;#x7F; &amp;#x9F;</dd>
21248 <dt>Surrogate</dt>
21249 <dd>&amp;#xD83D;&amp;#xDCA9;</dd>
21250 <dt>This is an okay astral character</dt>
21251 <dd>&#x1f4a9;</dd></dl>
21252 !! end
21253
21254 !! test
21255 __FORCETOC__ override
21256 !! wikitext
21257 __NEWSECTIONLINK__
21258 __FORCETOC__
21259 !! html/php
21260 <p><br />
21261 </p>
21262 !! end
21263
21264 !! test
21265 ISBN code coverage
21266 !! wikitext
21267 ISBN 978-0-1234-56&#x20;789
21268 !! html/php
21269 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a>&#x20;789
21270 </p>
21271 !! html/parsoid
21272 <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>
21273 !! end
21274
21275 !! test
21276 ISBN followed by 5 spaces
21277 !! wikitext
21278 ISBN
21279 !! html
21280 <p>ISBN
21281 </p>
21282 !! end
21283
21284 !! test
21285 Double ISBN
21286 !! wikitext
21287 ISBN ISBN 1234567890
21288 !! html/php
21289 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21290 </p>
21291 !! html/parsoid
21292 <p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
21293 !! end
21294
21295 # Uppercase X and lowercase x as well
21296 !! test
21297 ISBN with an X
21298 !! wikitext
21299 ISBN 3-462-04561-X
21300 ISBN 3-462-04561-x
21301 ISBN 080442957X
21302 ISBN 080442957x
21303 ISBN 978080442957X
21304 ISBN 978080442957x
21305 !! html/php
21306 <p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a>
21307 <a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a>
21308 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a>
21309 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a>
21310 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a>
21311 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
21312 </p>
21313 !! html/parsoid
21314 <p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
21315 <a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
21316 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
21317 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
21318 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
21319 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
21320 !! end
21321
21322 !! test
21323 ISBN with empty prefix (parsoid test)
21324 !! wikitext
21325 ISBN 1234567890
21326 !! html/php
21327 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21328 </p>
21329 !! html/parsoid
21330 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p>
21331 !! end
21332
21333 !! test
21334 T24905: <abbr> followed by ISBN followed by </a>
21335 !! wikitext
21336 <abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
21337 !! html/php
21338 <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>
21339 </p>
21340 !! html/parsoid
21341 <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>
21342 !! end
21343
21344 !! test
21345 Double RFC
21346 !! wikitext
21347 RFC RFC 1234
21348 !! html/php
21349 <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a>
21350 </p>
21351 !! html/parsoid
21352 <p>RFC <a href="https://tools.ietf.org/html/rfc1234" rel="mw:ExtLink" class="external mw-magiclink">RFC 1234</a></p>
21353 !! end
21354
21355 !! test
21356 Double RFC with a wiki link
21357 !! wikitext
21358 RFC [[RFC 1234]]
21359 !! html/php
21360 <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>
21361 </p>
21362 !! html/parsoid
21363 <p>RFC <a rel="mw:WikiLink" href="./RFC_1234" title="RFC 1234">RFC 1234</a></p>
21364 !! end
21365
21366 !! test
21367 RFC code coverage
21368 !! wikitext
21369 RFC 983&#x20;987
21370 !! html/php
21371 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
21372 </p>
21373 !! html/parsoid
21374 <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>
21375 !! end
21376
21377 !! test
21378 Centre-aligned image
21379 !! wikitext
21380 [[Image:foobar.jpg|centre]]
21381 !! html/php
21382 <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>
21383
21384 !! html/parsoid
21385 <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>
21386 !! end
21387
21388 !! test
21389 None-aligned image
21390 !! wikitext
21391 [[Image:foobar.jpg|none]]
21392 !! html/php
21393 <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>
21394
21395 !! html/parsoid
21396 <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>
21397 !! end
21398
21399 !! test
21400 Width + Height sized image (using px) (height is ignored)
21401 !! wikitext
21402 [[Image:foobar.jpg|640x480px]]
21403 !! html/php
21404 <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>
21405 </p>
21406 !! html/parsoid
21407 <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>
21408 !! end
21409
21410 !! test
21411 Width-sized image (using px, no following whitespace)
21412 !! wikitext
21413 [[Image:foobar.jpg|640px]]
21414 !! html/php
21415 <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>
21416 </p>
21417 !! html/parsoid
21418 <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>
21419 !! end
21420
21421 !! test
21422 Width-sized image (using px, with following whitespace - test regression from r39467)
21423 !! wikitext
21424 [[Image:foobar.jpg|640px ]]
21425 !! html/php
21426 <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>
21427 </p>
21428 !! html/parsoid
21429 <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>
21430 !!end
21431
21432 !! test
21433 Width-sized image (using px, with preceding whitespace - test regression from r39467)
21434 !! wikitext
21435 [[Image:foobar.jpg| 640px]]
21436 !! html/php
21437 <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>
21438 </p>
21439 !! html/parsoid
21440 <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>
21441 !! end
21442
21443 !! test
21444 Image with page parameter
21445 !! options
21446 djvu
21447 !! wikitext
21448 [[File:LoremIpsum.djvu|page=2]]
21449 !! html/php
21450 <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>
21451 </p>
21452 !! html/parsoid
21453 <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>
21454 !! end
21455
21456 !! test
21457 Another italics / bold test
21458 !! wikitext
21459 ''' ''x'
21460 !! html
21461 <pre>'<i> </i>x'
21462 </pre>
21463 !!end
21464
21465 # FIXME: The php output seems broken. It's interleaving some open/close tags.
21466 !! test
21467 dt/dd/dl test
21468 !! wikitext
21469 :;;;::
21470 !! html/php
21471 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dt></dl></dd></dl></dd></dl></dd></dl></dd></dl></dd></dl>
21472
21473 !! html/parsoid
21474 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dd></dl></dd></dl></dt></dl></dt></dl></dt></dl></dd></dl>
21475
21476 !!end
21477
21478 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
21479 !! test
21480 Images with the "|" character in the comment
21481 !! wikitext
21482 [[File:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
21483 !! html/php
21484 <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>
21485
21486 !! html/parsoid
21487 <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>
21488 !! end
21489
21490 !! test
21491 [Before] HTML without raw HTML enabled ($wgRawHtml==false)
21492 !! wikitext
21493 <html><script>alert(1);</script></html>
21494 !! html
21495 <p>&lt;html&gt;&lt;script&gt;alert(1);&lt;/script&gt;&lt;/html&gt;
21496 </p>
21497 !! end
21498
21499 !! test
21500 HTML with raw HTML ($wgRawHtml==true)
21501 !! options
21502 wgRawHtml=1
21503 !! wikitext
21504 <html><script>alert(1);</script></html>
21505 !! html/php
21506 <p><script>alert(1);</script>
21507 </p>
21508 !! end
21509
21510 !! test
21511 Parents of subpages, one level up
21512 !! options
21513 subpage title=[[Subpage test/L1/L2/L3]]
21514 !! wikitext
21515 [[../|L2]]
21516 !! html
21517 <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>
21518 </p>
21519 !! end
21520
21521
21522 !! test
21523 Parents of subpages, one level up, not named
21524 !! options
21525 subpage title=[[Subpage test/L1/L2/L3]]
21526 !! wikitext
21527 [[../]]
21528 !! html
21529 <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>
21530 </p>
21531 !! end
21532
21533
21534
21535 !! test
21536 Parents of subpages, two levels up
21537 !! options
21538 subpage title=[[Subpage test/L1/L2/L3]]
21539 !! wikitext
21540 [[../../|L1]]2
21541
21542 [[../../|L1]]l
21543 !! html
21544 <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
21545 </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>
21546 </p>
21547 !! end
21548
21549 !! test
21550 Parents of subpages, two levels up, without trailing slash or name.
21551 !! options
21552 subpage title=[[Subpage test/L1/L2/L3]]
21553 !! wikitext
21554 [[../..]]
21555 !! html
21556 <p>[[../..]]
21557 </p>
21558 !! end
21559
21560 !! test
21561 Parents of subpages, two levels up, with lots of extra trailing slashes.
21562 !! options
21563 subpage title=[[Subpage test/L1/L2/L3]]
21564 !! wikitext
21565 [[../../////]]
21566 !! html
21567 <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>
21568 </p>
21569 !! end
21570
21571 !! article
21572 Subpage test/L1/L2/L3Sibling
21573 !! text
21574 Sibling article
21575 !! endarticle
21576
21577 !! test
21578 Transclusion of a sibling page (one level up)
21579 !! options
21580 subpage title=[[Subpage test/L1/L2/L3]]
21581 !! wikitext
21582 {{../L3Sibling}}
21583 !! html
21584 <p>Sibling article
21585 </p>
21586 !! end
21587
21588 !! test
21589 Transclusion of a child page
21590 !! options
21591 subpage title=[[Subpage test/L1/L2]]
21592 !! wikitext
21593 {{/L3Sibling}}
21594 !! html
21595 <p>Sibling article
21596 </p>
21597 !! end
21598
21599 # This is wt2html only in Parsoid because we add <nowiki>
21600 # because of {{..}} and we don't expect to fix that to
21601 # eliminate the nowikis selective for {{..}} markup.
21602 !! test
21603 Non-transclusion because of too many up levels
21604 !! options
21605 subpage title=[[Subpage test/L1/L2/L3]]
21606 parsoid=wt2html
21607 !! wikitext
21608 {{../../../../More than parent}}
21609 !! html/php
21610 <p>{{../../../../More than parent}}
21611 </p>
21612 !! html/parsoid
21613 <p>{{../../../../More than parent}}</p>
21614 !! end
21615
21616 !! test
21617 Definition list code coverage
21618 !! wikitext
21619 ;title :def
21620 ;title :def
21621 ;title:def
21622 !! html/php
21623 <dl><dt>title &#160;</dt>
21624 <dd>def</dd>
21625 <dt>title&#160;</dt>
21626 <dd>def</dd>
21627 <dt>title</dt>
21628 <dd>def</dd></dl>
21629
21630 !! html/parsoid
21631 <dl><dt>title <span typeof="mw:Placeholder"> </span></dt><dd>def</dd>
21632 <dt>title<span typeof="mw:Placeholder"> </span></dt><dd>def</dd>
21633 <dt>title</dt><dd>def</dd></dl>
21634 !! end
21635
21636 !! test
21637 Don't fall for the self-closing div
21638 !! wikitext
21639 <div>hello world</div/>
21640 !! html
21641 <div>hello world</div>
21642
21643 !! end
21644
21645 !! test
21646 MSGNW magic word
21647 !! wikitext
21648 {{MSGNW:msg}}
21649 !! html/php
21650 <p>&#91;&#91;:Template:Msg&#93;&#93;
21651 </p>
21652 !! end
21653
21654 !! test
21655 RAW magic word
21656 !! wikitext
21657 {{RAW:QUERTY}}
21658 !! html
21659 <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>
21660 </p>
21661 !! end
21662
21663 # This isn't needed for XHTML conformance, but would be handy as a fallback security measure
21664 !! test
21665 Always escape literal '>' in output, not just after '<'
21666 !! wikitext
21667 ><>
21668 !! html
21669 <p>&gt;&lt;&gt;
21670 </p>
21671 !! end
21672
21673 !! test
21674 Template caching
21675 !! wikitext
21676 {{Test}}
21677 {{Test}}
21678 !! html
21679 <p>This is a test template
21680 This is a test template
21681 </p>
21682 !! end
21683
21684
21685 !! article
21686 MediaWiki:Fake
21687 !! text
21688 ==header==
21689 !! endarticle
21690
21691 !! test
21692 Inclusion of !userCanEdit() content
21693 !! wikitext
21694 {{MediaWiki:Fake}}
21695 !! html
21696 <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>
21697
21698 !! end
21699
21700
21701 !! test
21702 Out-of-order TOC heading levels
21703 !! wikitext
21704 ==2==
21705 ======6======
21706 ===3===
21707 =1=
21708 =====5=====
21709 ==2==
21710 !! html
21711 <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>
21712 <ul>
21713 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
21714 <ul>
21715 <li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
21716 <li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
21717 </ul>
21718 </li>
21719 <li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
21720 <ul>
21721 <li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
21722 <li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
21723 </ul>
21724 </li>
21725 </ul>
21726 </div>
21727
21728 <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>
21729 <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>
21730 <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>
21731 <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>
21732 <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>
21733 <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>
21734
21735 !! end
21736
21737
21738 !! test
21739 ISBN with a dummy number
21740 !! wikitext
21741 ISBN ---
21742 !! html
21743 <p>ISBN ---
21744 </p>
21745 !! end
21746
21747
21748 !! test
21749 ISBN with space-delimited number
21750 !! wikitext
21751 ISBN 92 9017 032 8
21752 !! html/php
21753 <p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a>
21754 </p>
21755 !! html/parsoid
21756 <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>
21757 !! end
21758
21759
21760 !! test
21761 ISBN with multiple spaces, no number
21762 !! wikitext
21763 ISBN foo
21764 !! html
21765 <p>ISBN foo
21766 </p>
21767 !! end
21768
21769
21770 !! test
21771 ISBN length
21772 !! wikitext
21773 ISBN 123456789
21774
21775 ISBN 1234567890
21776
21777 ISBN 12345678901
21778 !! html/php
21779 <p>ISBN 123456789
21780 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21781 </p><p>ISBN 12345678901
21782 </p>
21783 !! html/parsoid
21784 <p>ISBN 123456789</p>
21785
21786 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
21787
21788 <p>ISBN 12345678901</p>
21789 !! end
21790
21791
21792 !! test
21793 ISBN with trailing year (T9110)
21794 !! wikitext
21795 ISBN 1-234-56789-0 - 2006
21796
21797 ISBN 1 234 56789 0 - 2006
21798 !! html/php
21799 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006
21800 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006
21801 </p>
21802 !! html/parsoid
21803 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p>
21804
21805 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p>
21806 !! end
21807
21808
21809 !! test
21810 anchorencode
21811 !! config
21812 wgFragmentMode=[ 'html5', 'legacy' ]
21813 !! wikitext
21814 {{anchorencode:foo bar©#%n}}
21815 !! html/php
21816 <p>foo_bar©#%n
21817 </p>
21818 !! html/parsoid
21819 <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>
21820 !! end
21821
21822 !! test
21823 anchorencode (legacy)
21824 !! config
21825 wgFragmentMode=[ 'legacy' ]
21826 !! wikitext
21827 {{anchorencode:foo bar©#%n}}
21828 !! html/php
21829 <p>foo_bar.C2.A9.23.25n
21830 </p>
21831 !! end
21832
21833 !! test
21834 anchorencode trims spaces
21835 !! config
21836 wgFragmentMode=[ 'html5', 'legacy' ]
21837 !! wikitext
21838 {{anchorencode: __pretty__please__}}
21839 !! html/php
21840 <p>pretty_please
21841 </p>
21842 !! html/parsoid
21843 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: __pretty__please__","function":"anchorencode"},"params":{},"i":0}}]}'>pretty_please</p>
21844 !! end
21845
21846 !! test
21847 anchorencode deals with links
21848 !! config
21849 wgFragmentMode=[ 'html5', 'legacy' ]
21850 !! wikitext
21851 {{anchorencode: [[hello|world]] [[hi]]}}
21852 !! html/php
21853 <p>world_hi
21854 </p>
21855 !! html/parsoid
21856 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: [[hello|world]] [[hi]]","function":"anchorencode"},"params":{},"i":0}}]}'>world_hi</p>
21857 !! end
21858
21859 !! test
21860 anchorencode deals with templates
21861 !! config
21862 wgFragmentMode=[ 'html5', 'legacy' ]
21863 !! wikitext
21864 {{anchorencode: {{Foo}} x}}
21865 !! html/php
21866 <p>FOO_x
21867 </p>
21868 !! html/parsoid
21869 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: {{Foo}} x","function":"anchorencode"},"params":{},"i":0}}]}'>FOO_x</p>
21870 !! end
21871
21872 !! test
21873 anchorencode encodes like the TOC generator: (T20431)
21874 !! config
21875 wgFragmentMode=[ 'html5', 'legacy' ]
21876 !! wikitext
21877 ===_ +:.3A%3A _ &&amp;]] x===
21878 {{anchorencode: _ +:.3A%3A _ &&amp;]] x}}
21879 __NOEDITSECTION__
21880 !! html/php
21881 <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>
21882 <p>+:.3A%3A_&amp;&amp;&#93;&#93;_x
21883 </p>
21884 !! html/parsoid
21885 <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>
21886 <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>
21887 <meta property="mw:PageProp/noeditsection"/>
21888 !! end
21889
21890 !! test
21891 anchorencode encodes like the TOC generator: (T20431) (legacy)
21892 !! config
21893 wgFragmentMode=[ 'legacy' ]
21894 !! wikitext
21895 ===_ +:.3A%3A&&amp;]]===
21896 {{anchorencode: _ +:.3A%3A&&amp;]] }}
21897 __NOEDITSECTION__
21898 !! html/php
21899 <h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&amp;&amp;]]</span></h3>
21900 <p>.2B:.3A.253A.26.26.5D.5D
21901 </p>
21902 !! end
21903
21904 !! test
21905 T8200: blockquotes and paragraph formatting
21906 !! wikitext
21907 <blockquote>
21908 foo
21909 </blockquote>
21910
21911 bar
21912
21913 baz
21914 !! html
21915 <blockquote>
21916 <p>foo
21917 </p>
21918 </blockquote>
21919 <p>bar
21920 </p>
21921 <pre>baz
21922 </pre>
21923 !! end
21924
21925 !! test
21926 T10293: Use of center tag ruins paragraph formatting
21927 !! wikitext
21928 <center>
21929 foo
21930 </center>
21931
21932 bar
21933
21934 baz
21935 !! html
21936 <center>
21937 <p>foo
21938 </p>
21939 </center>
21940 <p>bar
21941 </p>
21942 <pre>baz
21943 </pre>
21944 !! end
21945
21946 !!test
21947 Parsing of overlapping (improperly nested) inline html tags
21948 !! wikitext
21949 <span><s>x</span></s>
21950 !! html/php
21951 <p><span><s>x&lt;/span&gt;</s></span>
21952 </p>
21953 !! html/parsoid
21954 <p><span><s>x</s></span>
21955 </p>
21956 !!end
21957
21958 ###
21959 ### Language variants related tests
21960 ###
21961
21962 # Parsoid does not mark self-links.
21963 # Parsoid does not convert links; PHP will do any necessary redirects.
21964
21965 !! test
21966 Self-link in language variants
21967 !! options
21968 title=[[Dunav]] language=sr
21969 !! wikitext
21970 Both [[Dunav]] and [[Дунав]] are names for this river.
21971 !! html/php
21972 <p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
21973 </p>
21974 !! html/parsoid
21975 <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>
21976 !! end
21977
21978 !! article
21979 Дуна
21980 !! text
21981 content
21982 !! endarticle
21983
21984 !! test
21985 Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
21986 !! options
21987 title=[[Duna]] language=sr
21988 !! wikitext
21989 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
21990 !! html/php
21991 <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.
21992 </p>
21993 !! html/parsoid
21994 <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>
21995 !! end
21996
21997 !! test
21998 Link to a section of a variant of this title shouldn't be parsed as self-link
21999 !! options
22000 title=[[Duna]] language=sr
22001 !! wikitext
22002 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
22003 !! html/php
22004 <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.
22005 </p>
22006 !! html/parsoid
22007 <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>
22008 !! end
22009
22010 !! test
22011 Link to pages in language variants
22012 !! options
22013 language=sr
22014 !! wikitext
22015 Main Page can be written as [[Маин Паге]]
22016 !! html/php
22017 <p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>
22018 </p>
22019 !! html/parsoid
22020 <p>Main Page can be written as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a></p>
22021 !! end
22022
22023
22024 !! test
22025 Multiple links to pages in language variants
22026 !! options
22027 language=sr
22028 !! wikitext
22029 [[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
22030 !! html/php
22031 <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>.
22032 </p>
22033 !! html/parsoid
22034 <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>
22035 !! end
22036
22037
22038 !! test
22039 Simple template in language variants
22040 !! options
22041 language=sr
22042 !! wikitext
22043 {{тест}}
22044 !! html/php
22045 <p>This is a test template
22046 </p>
22047 !! end
22048
22049
22050 !! test
22051 Template with explicit namespace in language variants
22052 !! options
22053 language=sr
22054 !! wikitext
22055 {{Template:тест}}
22056 !! html/php
22057 <p>This is a test template
22058 </p>
22059 !! end
22060
22061
22062 !! test
22063 Basic test for template parameter in language variants
22064 !! options
22065 language=sr
22066 !! wikitext
22067 {{парамтест|param=foo}}
22068 !! html/php
22069 <p>This is a test template with parameter foo
22070 </p>
22071 !! end
22072
22073 !! test
22074 Simple category in language variants
22075 !! options
22076 language=sr cat
22077 !! wikitext
22078 [[Category:МедиаWики Усер'с Гуиде]]
22079 !! html/php
22080 cat=МедиаWики_Усер'с_Гуиде sort=
22081 !! html/parsoid
22082 <link rel="mw:PageProp/Category" href="./Категорија:МедиаWики_Усер'с_Гуиде" data-parsoid='{"stx":"simple","a":{"href":"./Категорија:МедиаWики_Усер&#39;с_Гуиде"},"sa":{"href":"Category:МедиаWики Усер&#39;с Гуиде"}}'/>
22083 !! end
22084
22085 !! article
22086 Category:分类
22087 !! text
22088 blah
22089 !! endarticle
22090
22091 !! article
22092 Category:分類
22093 !! text
22094 blah
22095 !! endarticle
22096
22097 ## We used to, but no longer wt2wt this test since the default serializer
22098 ## will normalize all categories to serialize on their own line.
22099 ## This wikitext usage is going to be fairly uncommon in production and
22100 ## selser will take care of preserving formatting in those scenarios.
22101 !! test
22102 Don't convert blue categorylinks to another variant (T35210)
22103 !! options
22104 cat
22105 language=zh
22106 parsoid=wt2html
22107 !! wikitext
22108 [[A]][[Category:分类]]
22109 !! html/php
22110 cat=分类 sort=
22111 !! html/parsoid
22112 <p><a rel="mw:WikiLink" href="./A" title="A">A</a></p>
22113 <link rel="mw:PageProp/Category" href="./Category:分类"/>
22114 !! end
22115
22116 !! test
22117 Stripping -{}- tags (language variants)
22118 !! options
22119 language=sr
22120 !! wikitext
22121 Latin proverb: -{Ne nuntium necare}-
22122 !! html/php
22123 <p>Latin proverb: Ne nuntium necare
22124 </p>
22125 !! html/parsoid
22126 <p>Latin proverb: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22127 !! end
22128
22129
22130 !! test
22131 Prevent conversion with -{}- tags (language variants)
22132 !! options
22133 language=sr variant=sr-ec
22134 !! wikitext
22135 Latinski: -{Ne nuntium necare}-
22136 !! html/php
22137 <p>Латински: Ne nuntium necare
22138 </p>
22139 !! html/parsoid
22140 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22141 !! end
22142
22143
22144 !! test
22145 Prevent conversion of text with -{}- tags (language variants)
22146 !! options
22147 language=sr variant=sr-ec
22148 !! wikitext
22149 Latinski: -{Ne nuntium necare}-
22150 !! html/php
22151 <p>Латински: Ne nuntium necare
22152 </p>
22153 !! html/parsoid
22154 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22155 !! end
22156
22157
22158 !! test
22159 Prevent conversion of links with -{}- tags (language variants)
22160 !! options
22161 language=sr variant=sr-ec
22162 !! wikitext
22163 -{[[Main Page]]}-
22164 !! html/php
22165 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
22166 </p>
22167 !! html/parsoid
22168 <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>
22169 !! end
22170
22171
22172 !! test
22173 -{}- tags within headlines (within html for parserConvert())
22174 !! config
22175 wgFragmentMode=[ 'html5', 'legacy' ]
22176 !! options
22177 language=sr variant=sr-ec
22178 !! wikitext
22179 ==-{Naslov}-==
22180
22181 Note that even an unprotected headline ID is not affected by language
22182 conversion:
22183
22184 ==Latinski==
22185 !! html/php
22186 <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>
22187 <p>Ноте тхат евен ан унпротецтед хеадлине ИД ис нот аффецтед бy лангуаге
22188 цонверсион:
22189 </p>
22190 <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>
22191
22192 !! html/parsoid
22193 <h2 id="-{Naslov}-"><span id="-.7BNaslov.7D-" typeof="mw:FallbackId"></span><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Naslov"}}'></span></h2>
22194
22195 <p>Note that even an unprotected headline ID is not affected by language
22196 conversion:</p>
22197
22198 <h2 id="Latinski">Latinski</h2>
22199 !! end
22200
22201 !! test
22202 Explicit definition of language variant alternatives
22203 !! options
22204 language=zh variant=zh-tw
22205 !! wikitext
22206 -{zh:China;zh-tw:Taiwan}-, not China
22207 !! html/php
22208 <p>Taiwan, not China
22209 </p>
22210 !! html/parsoid
22211 <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>
22212 !! end
22213
22214 !! test
22215 Filter syntax for language variants
22216 !! options
22217 language=zh variant=zh-tw
22218 !! wikitext
22219 foo-{zh;zh-hans;zh-hant|blog, WEBJOURNAL, WEBLOG}-quux
22220 !! html/php
22221 <p>fooblog, WEBJOURNAL, WEBLOGquux
22222 </p>
22223 !! html/parsoid
22224 <p>foo<span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"blog, WEBJOURNAL, WEBLOG"}}'></span>quux</p>
22225 !! end
22226
22227 # Note that Parsoid post-processing for language variants needs to
22228 # update the `title` attribute here, based on the mw:ExpandedAttrs property
22229 !! test
22230 Conversion around HTML tags
22231 !! options
22232 language=sr variant=sr-ec
22233 !! wikitext
22234 -{H|span=>sr-ec:script;title=>sr-ec:src}-
22235 <span title="La-{sr-el:L;sr-ec:C}-tin">ski</span>
22236 !! html/php
22237 <p>
22238 <span title="ЛаCтин">ски</span>
22239 </p>
22240 !! html/parsoid
22241 <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"}]}'/>
22242 <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>
22243 !! end
22244
22245 !! test
22246 Explicit session-wise two-way language variant mapping (A flag and - flag)
22247 !! options
22248 language=zh variant=zh-tw
22249 !! wikitext
22250 This is -{zh:China; zh-tw:Taiwan}-, but we'll forget that now.
22251
22252 Taiwan is not China.
22253
22254 But -{A|zh:China; zh-tw:Taiwan}- is China,
22255
22256 (This-{-|zh:China; zh-tw:Taiwan}- should be stripped!)
22257
22258 and -{China}- is China.
22259 !! html/php
22260 <p>This is Taiwan, but we'll forget that now.
22261 </p><p>Taiwan is not China.
22262 </p><p>But Taiwan is Taiwan,
22263 </p><p>(This should be stripped!)
22264 </p><p>and China is China.
22265 </p>
22266 !! html/parsoid
22267 <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>
22268 <p>Taiwan is not China.</p>
22269 <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>
22270 <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>
22271 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"China"}}'></span> is China.</p>
22272 !! end
22273
22274 !! test
22275 Explicit session-wise one-way language variant mapping (A flag and - flag)
22276 !! options
22277 language=zh variant=zh-tw
22278 !! wikitext
22279 This is -{COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}-, but we'll forget that now.
22280
22281 COUNTRY is China or Taiwan.
22282
22283 But -{A|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- is COUNTRY,
22284
22285 (This-{-|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
22286
22287 and -{COUNTRY}- is COUNTRY.
22288 !! html/php
22289 <p>This is Taiwan, but we'll forget that now.
22290 </p><p>COUNTRY is China or Taiwan.
22291 </p><p>But Taiwan is Taiwan,
22292 </p><p>(This should be stripped!)
22293 </p><p>and COUNTRY is COUNTRY.
22294 </p>
22295 !! html/parsoid
22296 <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>
22297 <p>COUNTRY is China or Taiwan.</p>
22298 <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>
22299 <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>
22300 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"COUNTRY"}}'></span> is COUNTRY.</p>
22301 !! end
22302
22303 !! test
22304 Explicit session-wise two-way language variant mapping (H flag for hide)
22305 !! options
22306 language=zh variant=zh-tw
22307 !! wikitext
22308 (This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
22309
22310 Taiwan is China.
22311 !! html/php
22312 <p>(This should be stripped!)
22313 </p><p>Taiwan is Taiwan.
22314 </p>
22315 !! html/parsoid
22316 <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>
22317 <p>Taiwan is China.</p>
22318 !! end
22319
22320 !! test
22321 Explicit session-wise one-way language variant mapping (H flag for hide)
22322 !! options
22323 language=zh variant=zh-tw
22324 !! wikitext
22325 (This-{H|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
22326
22327 COUNTRY is Taiwan or China.
22328 !! html/php
22329 <p>(This should be stripped!)
22330 </p><p>Taiwan is Taiwan or China.
22331 </p>
22332 !! html/parsoid
22333 <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>
22334 <p>COUNTRY is Taiwan or China.</p>
22335 !! end
22336
22337 ## Note that parsoid test runner does not support 'showtitle' option.
22338 !! test
22339 Adding explicit conversion rule for title (T flag)
22340 !! options
22341 language=zh variant=zh-tw showtitle
22342 !! wikitext
22343 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
22344
22345 Taiwan is China.
22346 !! html/php
22347 Taiwan
22348 <p>Should be stripped!
22349 </p><p>Taiwan is China.
22350 </p>
22351 !! html/parsoid
22352 <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>
22353 <p>Taiwan is China.</p>
22354 !! end
22355
22356 !! test
22357 Code coverage: T combined with H flag
22358 !! options
22359 language=zh variant=zh-tw showtitle
22360 !! wikitext
22361 Should be stripped-{T;H|zh:China; zh-tw:Taiwan}-!
22362
22363 Taiwan is China.
22364 !! html/php
22365 Taiwan
22366 <p>Should be stripped!
22367 </p><p>Taiwan is Taiwan.
22368 </p>
22369 !! html/parsoid
22370 <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>
22371 <p>Taiwan is China.</p>
22372 !! end
22373
22374 !! test
22375 Code coverage: T with no variants
22376 !! options
22377 language=zh variant=zh-tw showtitle
22378 !! wikitext
22379 -{H|zh:China; zh-tw:Taiwan}-
22380 Taiwan is China.-{T|Taiwan is China}-
22381 !! html/php
22382 Taiwan is China
22383 <p>
22384 Taiwan is Taiwan.
22385 </p>
22386 !! html/parsoid
22387 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
22388 Taiwan is China.<meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Taiwan is China"},"title":true}'/></p>
22389 !! end
22390
22391 !! test
22392 Code coverage: rules with no variants
22393 !! options
22394 language=zh variant=zh-tw
22395 !! wikitext
22396 -{H|zh:China; zh-tw:Taiwan}-
22397 Taiwan is China.
22398 -{H|China}-
22399 Taiwan is China.
22400 !! html/php
22401 <p>
22402 Taiwan is Taiwan.
22403
22404 Taiwan is China.
22405 </p>
22406 !! html/parsoid
22407 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
22408 Taiwan is China.
22409 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":"China"}]}'/>
22410 Taiwan is China.</p>
22411 !! end
22412
22413
22414 !! test
22415 Code coverage: D flag for conversion rule
22416 !! options
22417 language=zh variant=zh-tw
22418 !! wikitext
22419 -{D|zh-cn:XA; zh-tw:YA}-
22420 -{A;D|zh-cn:XB; zh-tw:YB}-
22421 -{D;H|zh-cn:XC; zh-tw:YC}-
22422
22423 -{D;H|FOO=>zh-tw:BAR;FOO=>zh-cn:BAT}-
22424
22425 -{D|0=>zh-tw:1}-
22426 -{A;D|2=>zh-tw:3}-
22427 -{D;H|4=>zh-tw:5}-
22428
22429 XA XB XC YA YB YC FOO BAR BAT 012345
22430 !! html/php
22431 <p>大陆:XA;台灣:YA;
22432
22433 大陆:XC;台灣:YC;
22434 </p><p>FOO⇒台灣:BAR;FOO⇒大陆:BAT;
22435 </p><p>0⇒台灣:1;
22436
22437 4⇒台灣:5;
22438 </p><p>XA YB YC YA YB YC BAR BAR BAT 013355
22439 </p>
22440 !! html/parsoid
22441 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"twoway":[{"l":"zh-cn","t":"XA"},{"l":"zh-tw","t":"YA"}]}'></span>
22442 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XB"},{"l":"zh-tw","t":"YB"}]}'/>
22443 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XC"},{"l":"zh-tw","t":"YC"}]}'></span></p>
22444 <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>
22445 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"oneway":[{"f":"0","l":"zh-tw","t":"1"}]}'></span>
22446 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"2","l":"zh-tw","t":"3"}]}'/>
22447 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"4","l":"zh-tw","t":"5"}]}'></span></p>
22448 <p>XA XB XC YA YB YC FOO BAR BAT 012345</p>
22449 !! end
22450
22451 !! test
22452 Code coverage: N flag for conversion rule
22453 !! options
22454 language=zh variant=zh-cn
22455 !! wikitext
22456 -{N|zh-cn}-
22457
22458 -{N|zh-tw}-
22459
22460 -{N|sr-ec}-
22461 !! html/php
22462 <p>大陆
22463 </p><p>台灣
22464 </p><p>српски (ћирилица)‎
22465 </p>
22466 !! html/parsoid
22467 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-cn"}}'></span></p>
22468 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-tw"}}'></span></p>
22469 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"sr-ec"}}'></span></p>
22470 !! end
22471
22472 # html2wt suppresses the bogus 'D' flag, so this is wt2html only
22473 !! test
22474 Code coverage: N flag for conversion rule (wt2html only)
22475 !! options
22476 language=zh variant=zh-cn
22477 parsoid=wt2html,html2html
22478 !! wikitext
22479 -{D;N|en}-
22480 !! html/php
22481 <p>English
22482 </p>
22483 !! html/parsoid
22484 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"en"}}' data-parsoid='{"fl":["D","N"]}'></span></p>
22485 !! end
22486
22487 !! test
22488 Testing that changing the language variant here in the tests actually works
22489 !! options
22490 language=zh variant=zh showtitle
22491 !! wikitext
22492 Should be stripped-{T|zh:China; zh-tw:Taiwan}-!
22493 !! html/php
22494 China
22495 <p>Should be stripped!
22496 </p>
22497 !! html/parsoid
22498 <p>Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
22499 !! end
22500
22501 !! test
22502 Recursive conversion of alt and title attrs shouldn't clear converter state
22503 !! options
22504 language=zh variant=zh-cn
22505 showtitle
22506 !! wikitext
22507 -{H|zh-cn:Exclamation; zh-tw:exclamation}-
22508 Should be stripped-{T|zh-cn:China; zh-tw:Taiwan}-<span title="exclamation">!</span>
22509 !! html/php
22510 China
22511 <p>
22512 Should be stripped<span title="Exclamation">!</span>
22513 </p>
22514 !! html/parsoid
22515 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh-cn","t":"Exclamation"},{"l":"zh-tw","t":"exclamation"}]}'/>
22516 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>
22517 !! end
22518
22519 !! test
22520 T26072: more test on conversion rule for title
22521 !! options
22522 language=zh variant=zh-tw showtitle
22523 !! wikitext
22524 This should be stripped-{T|zh:China; zh-tw:Taiwan}-!
22525
22526 This won't take interferes with the title rule-{H|zh:Beijing; zh-tw:Taipei}-.
22527 !! html/php
22528 Taiwan
22529 <p>This should be stripped!
22530 </p><p>This won't take interferes with the title rule.
22531 </p>
22532 !! html/parsoid
22533 <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>
22534 <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>
22535 !! end
22536
22537 !! test
22538 Partly disable title conversion if variant == main language code
22539 !! options
22540 language=zh variant=zh title=[[ZH]] showtitle
22541 !! wikitext
22542 -{T|zh-cn:CN;zh-tw:TW}-
22543 !! html/php
22544 ZH
22545 <p>
22546 </p>
22547 !! html/parsoid
22548 <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>
22549 !! end
22550
22551 !! test
22552 Partly disable title conversion if variant == main language code, more
22553 !! options
22554 language=zh variant=zh title=[[ZH]] showtitle
22555 !! wikitext
22556 -{T|TW}-
22557 !! html/php
22558 ZH
22559 <p>
22560 </p>
22561 !! html/parsoid
22562 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"TW"},"title":true}'/></p>
22563 !! end
22564
22565 !! test
22566 Raw output of variant escape tags (R flag)
22567 !! options
22568 language=zh variant=zh-tw
22569 !! wikitext
22570 Raw: -{R|zh:China;zh-tw:Taiwan}-
22571 !! html/php
22572 <p>Raw: zh:China;zh-tw:Taiwan
22573 </p>
22574 !! html/parsoid
22575 <p>Raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"zh:China;zh-tw:Taiwan"}}'></span></p>
22576 !! end
22577
22578 # html2wt suppresses the bogus 'D' flags, so this is wt2html only
22579 !! test
22580 Raw output of variant escape tags (R flag) (wt2html only)
22581 !! options
22582 language=zh variant=zh-tw
22583 parsoid=wt2html,html2html
22584 !! wikitext
22585 -{Variant}- -{D|syntax}- -{D;R|options}-
22586 !! html/php
22587 <p>Variant syntax options
22588 </p>
22589 !! html/parsoid
22590 <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>
22591 !! end
22592
22593 !! test
22594 Nested markup inside raw output of variant escape tags (R flag)
22595 !! options
22596 language=zh variant=zh-tw
22597 !! wikitext
22598 Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
22599 !! html/php
22600 <p>Nested raw: nested Taiwan nested
22601 </p>
22602 !! html/parsoid
22603 <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>
22604 !! end
22605
22606 !! test
22607 Nested markup and spaces inside raw output of variant escape tags (R flag)
22608 !! options
22609 language=zh variant=zh-tw
22610 !! wikitext
22611 X-{ outer -{ inner }- outer }-X
22612 !! html/php
22613 <p>X outer inner outer X
22614 </p>
22615 !! html/parsoid
22616 <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>
22617 !! end
22618
22619 !! test
22620 Templates inside raw output of variant escape tags (R flag)
22621 !! options
22622 language=zh variant=zh-tw
22623 !! wikitext
22624 Nested raw: -{R|nested {{echo|hi}} templates}-
22625 !! html/php
22626 <p>Nested raw: nested hi templates
22627 </p>
22628 !! html/parsoid
22629 <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>
22630 !! end
22631
22632 !! test
22633 Strings evaluating false shouldn't be ignored by Language converter (T51072)
22634 !! options
22635 language=zh variant=zh-cn
22636 !! wikitext
22637 -{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
22638 !! html/php
22639 <p>0
22640 </p>
22641 !! html/parsoid
22642 <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>
22643 !! end
22644
22645 !! test
22646 Conversion rules from [numeric-only string] to [something else] (T48634)
22647 !! options
22648 language=zh variant=zh-cn
22649 !! wikitext
22650 -{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
22651 !! html/php
22652 <p>D12345EE12345
22653 </p>
22654 !! html/parsoid
22655 <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>
22656 !! end
22657
22658 !! test
22659 Two-way converter rule entries with an empty value should be ignored (T53551)
22660 !! options
22661 language=zh variant=zh-cn
22662 !! wikitext
22663 -{H|zh-cn:foo;zh-tw:;}-foobar
22664 !! html/php
22665 <p>foobar
22666 </p>
22667 !! html/parsoid
22668 <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>
22669 !! end
22670
22671 !! test
22672 One-way converter rule entries with an empty "from" string should be ignored (T53551)
22673 !! options
22674 language=zh variant=zh-cn
22675 !! wikitext
22676 -{H|=>zh-cn:foo;}-foobar
22677 !! html/php
22678 <p>foobar
22679 </p>
22680 !! html/parsoid
22681 <p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[5]}' data-mw-variant='{"add":true,"oneway":[{"f":"","l":"zh-cn","t":"foo"}]}'/>foobar</p>
22682 !! end
22683
22684 !! test
22685 Empty converter rule entries shouldn't be inserted into the conversion table (T53551)
22686 !! options
22687 language=zh variant=zh-cn
22688 !! wikitext
22689 -{H|}-foobar
22690 !! html/php
22691 <p>foobar
22692 </p>
22693 !! html/parsoid
22694 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":""}]}'/>foobar</p>
22695 !! end
22696
22697 !! test
22698 Nested using of manual convert syntax
22699 !! options
22700 language=zh variant=zh-hk
22701 !! wikitext
22702 Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
22703 !! html/php
22704 <p>Nested: Hello Hong Kong!
22705 </p>
22706 !! html/parsoid
22707 <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>
22708 !! end
22709
22710 !! test
22711 HTML markups with conversion syntax in attribs, nested in other conversion blocks
22712 !! options
22713 language=zh variant=zh-cn
22714 !! wikitext
22715 -{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}-
22716 !! html/php
22717 <p><span title="X">A</span>
22718 </p>
22719 !! html/parsoid
22720 <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>
22721 !! end
22722
22723 !! test
22724 HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet in PHP parser)
22725 !! options
22726 language=zh variant=zh-cn
22727 !! wikitext
22728 -{<span title="-{X}-">A</span>}-
22729 !! html/php+disabled
22730 <p><span title="X">A</span>
22731 </p>
22732 !! html/parsoid
22733 <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>
22734 !! end
22735
22736 # Parsoid and PHP disagree on how to parse this example: Parsoid
22737 # insists that the content of a language converter element be a valid
22738 # DOM fragment or attribute string
22739 !! test
22740 Language converter markup with block content
22741 !! options
22742 language=zh variant=zh-cn
22743 !! wikitext
22744 <span>a-{b<div>c}-d
22745
22746 <span>a-{zh;zh-hans;zh-hant|b<div>c}-d
22747
22748 <span>a-{H|0=>zh-cn:x<span>y;0=>zh-tw:b<div>c}-d
22749 !! html/php+tidy
22750 <span>ab<div>cd
22751 <span>ab<div>cd
22752 <span>ad
22753 </span></div></span></div></span>
22754 !! html/parsoid
22755 <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>
22756
22757 <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>
22758
22759 <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>
22760 !! end
22761
22762 !! test
22763 LanguageConverter selser (1)
22764 !! options
22765 language=zh variant=zh-cn
22766 parsoid={
22767 "modes": ["wt2wt", "selser"],
22768 "changes": [
22769 ["span[typeof]", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
22770 ]
22771 }
22772 !! wikitext
22773 -{raw}-
22774 !! wikitext/edited
22775 -{edited}-
22776 !! end
22777
22778 !! test
22779 LanguageConverter selser (2)
22780 !! options
22781 language=zh variant=zh-cn
22782 parsoid={
22783 "modes": ["wt2wt", "selser"],
22784 "changes": [
22785 ["span[class='x']", "contents", "text", "-{foo}-"],
22786 ["a", "contents", "text", "-{"],
22787 ["span[typeof]", "attr", "data-mw", "{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"-{\"}},\"i\":0}}]}"]
22788 ]
22789 }
22790 !! wikitext
22791 <span class="x">TEXT1</span>
22792 [http://example.com TEXT2]
22793 [[Foo|TEXT3]]
22794 {{echo|TEXT4}}
22795 !! wikitext/edited
22796 <span class="x"><nowiki>-{foo}-</nowiki></span>
22797 [http://example.com -{]
22798 [[Foo|<nowiki>-{</nowiki>]]
22799 {{1x|<nowiki>-{</nowiki>}}
22800 !! end
22801
22802 # Tests LanguageVariantText in ConstrainedText
22803 !! test
22804 LanguageConverter selser (3)
22805 !! options
22806 language=zh variant=zh-cn
22807 parsoid={
22808 "modes": ["wt2wt", "selser"],
22809 "changes": [
22810 ["td > span", "attr", "typeof", "mw:LanguageVariant"],
22811 ["td > span", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
22812 ]
22813 }
22814 !! wikitext
22815 {|
22816 |-
22817 |<span>Foo</span>
22818 |}
22819 !! wikitext/edited
22820 {|
22821 |-
22822 |<nowiki/>-{edited}-
22823 |}
22824 !! end
22825
22826 # Tests LanguageVariantText._fromSelSer
22827 !! test
22828 LanguageConverter selser (4)
22829 !! options
22830 language=zh variant=zh-cn
22831 parsoid={
22832 "modes": ["wt2wt", "selser"],
22833 "changes": [
22834 ["td > span.x", "remove"]
22835 ]
22836 }
22837 !! wikitext
22838 {|
22839 |-
22840 |<span class="x">Foo</span>-{Bar}-
22841 ||<span class="x">Foo</span>-{Bar}-
22842 |}
22843 !! wikitext/edited
22844 {|
22845 |-
22846 |<nowiki/>-{Bar}-
22847 ||-{Bar}-
22848 |}
22849 !! end
22850
22851 # Since Parsoid is starting to emit canonical wikitext for links,
22852 # [http://example.com http://example.com] will not RT back to that
22853 # form anymore.
22854 # Parsoid does not language-convert links (it is done in a
22855 # post-processing step)
22856 !! test
22857 Proper conversion of text in external links
22858 !! options
22859 language=sr variant=sr-ec
22860 parsoid=wt2html
22861 !! wikitext
22862 http://www.google.com
22863 gopher://www.google.com
22864 [http://www.google.com http://www.google.com]
22865 [gopher://www.google.com gopher://www.google.com]
22866 [https://www.google.com irc://www.google.com]
22867 [ftp://www.google.com www.google.com/ftp://dir]
22868 [//www.google.com www.google.com]
22869 !! html/php
22870 <p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
22871 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
22872 <a rel="nofollow" class="external text" href="http://www.google.com">http://www.google.com</a>
22873 <a rel="nofollow" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
22874 <a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
22875 <a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
22876 <a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
22877 </p>
22878 !! html/parsoid
22879 <p><a rel="mw:ExtLink" class="external free" href="http://www.google.com">http://www.google.com</a>
22880 <a rel="mw:ExtLink" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
22881 <a rel="mw:ExtLink" class="external text" href="http://www.google.com">http://www.google.com</a>
22882 <a rel="mw:ExtLink" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
22883 <a rel="mw:ExtLink" class="external text" href="https://www.google.com">irc://www.google.com</a>
22884 <a rel="mw:ExtLink" class="external text" href="ftp://www.google.com">www.google.com/ftp://dir</a>
22885 <a rel="mw:ExtLink" class="external text" href="//www.google.com">www.google.com</a></p>
22886 !! end
22887
22888 !! test
22889 Do not convert roman numbers to language variants
22890 !! options
22891 language=sr variant=sr-ec
22892 !! wikitext
22893 Fridrih IV je car.
22894 !! html/php
22895 <p>Фридрих IV је цар.
22896 </p>
22897 !! html/parsoid
22898 <p>Fridrih IV je car.</p>
22899 !! end
22900
22901 !! test
22902 Unclosed language converter markup "-{"
22903 !! options
22904 language=sr
22905 !! wikitext
22906 -{T|hello
22907 !! html
22908 <p>-{T|hello
22909 </p>
22910 !! end
22911
22912 !! test
22913 Don't convert raw rule "-{R|=&gt;}-" to "=>"
22914 !! options
22915 language=sr
22916 !! wikitext
22917 -{R|=&gt;}-
22918 !! html/php
22919 <p>=&gt;
22920 </p>
22921 !! html/parsoid
22922 <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>
22923 !!end
22924
22925 !! test
22926 Don't break link parsing if language converter markup is in the caption.
22927 !! options
22928 language=sr variant=sr-ec
22929 !! wikitext
22930 [[Main Page|-{R|main page}-]]
22931 !! html/php
22932 <p><a href="/wiki/Main_Page" title="Маин Паге">main page</a>
22933 </p>
22934 !! html/parsoid
22935 <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>
22936 !! end
22937
22938 !! test
22939 T146304: Don't break template parsing if language converter markup is in the parameter.
22940 !! options
22941 language=sr variant=sr-ec
22942 !! wikitext
22943 {{echo|-{R|foo}-}}
22944 !! html/php
22945 <p>foo
22946 </p>
22947 !! html/parsoid
22948 <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>
22949 !! end
22950
22951 !! test
22952 T146305: Don't break image parsing if language converter markup is in the caption.
22953 !! options
22954 language=sr
22955 !! wikitext
22956 [[Датотека:Foobar.jpg|thumb|-{R|caption:}-]]
22957 !! html/php
22958 <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>
22959
22960 !! html/parsoid
22961 <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>
22962 !! end
22963
22964 !! test
22965 T146305: Don't break image parsing if nested language converter markup is in the caption.
22966 !! options
22967 language=zh variant=zh-cn
22968 !! wikitext
22969 [[File:Foobar.jpg|thumb|-{|zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
22970 !! html/php
22971 <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>
22972
22973 !! html/parsoid
22974 <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>
22975 !! end
22976
22977 # XXX html2wt disabled because rich markup in alt is not preserved.
22978 !! test
22979 Don't break gallery if language converter markup is inside.
22980 !! options
22981 language=zh
22982 !! wikitext
22983 <gallery>
22984 File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-
22985 File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt
22986 </gallery>
22987 !! html/php
22988 <ul class="gallery mw-gallery-traditional">
22989 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
22990 <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>
22991 <div class="gallerytext">
22992 <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>
22993 </p>
22994 </div>
22995 </div></li>
22996 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
22997 <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>
22998 <div class="gallerytext">
22999 <p>This is a test template
23000 </p>
23001 </div>
23002 </div></li>
23003 </ul>
23004
23005 !! html/parsoid
23006 <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"}}'>
23007 <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>
23008 <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>
23009 </ul>
23010 !! end
23011
23012 !! test
23013 T153135: Don't break list handling if language converter markup is in the item.
23014 !! options
23015 language=zh variant=zh-cn
23016 !! wikitext
23017 ;-{zh-cn:AAA;zh-tw:BBB}-
23018 ;-{R|foo:bar}-
23019 !! html/php
23020 <dl><dt>AAA</dt>
23021 <dt>foo:bar</dt></dl>
23022
23023 !! html/parsoid
23024 <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>
23025 <dt data-parsoid='{"dsr":[25,39,1,0]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"foo:bar"}}'></span></dt>
23026 </dl>
23027 !! end
23028
23029 // Note that parsoid does not protect colons unless language converter
23030 // markup is properly nested, because it is a backtracking parser.
23031 !! test
23032 T153135: Unclosed markup in definition list (code coverage)
23033 !! options
23034 language=zh variant=zh-cn
23035 !! wikitext
23036 ;<b>foo:bar
23037 ;-{zh-cn:AAA
23038 !! html/php+tidy
23039 <dl><dt><b>foo:bar</b></dt><b>
23040 <dt>-{zh-cn:AAA</dt></b></dl><p><b>
23041 </b></p>
23042 !! html/parsoid
23043 <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}'>
23044 <dt data-parsoid='{"dsr":[12,20,1,0]}'>-{zh-cn</dt>
23045 <dd data-parsoid='{"stx":"row","dsr":[20,24,1,0]}'>AAA</dd>
23046 </b></dl>
23047 !! end
23048
23049 !! test
23050 T153135: Nested language converter markup in definition list (code coverage)
23051 !! options
23052 language=zh variant=zh-cn
23053 !! wikitext
23054 ;-{|zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
23055 !! html/php
23056 <dl><dt>AAA foo:bar bat:baz</dt>
23057 <dd>def</dd></dl>
23058
23059 !! html/parsoid
23060 <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>
23061 <dd data-parsoid='{"stx":"row","dsr":[49,53,1,0]}'>def</dd>
23062 </dl>
23063 !! end
23064
23065 # html2wt mode disabled due to <nowiki> insertion.
23066 !! test
23067 T153140: Don't break table handling if language converter markup is in the cell.
23068 !! options
23069 language=sr variant=sr-ec
23070 parsoid=wt2html,wt2wt,html2html
23071 !! wikitext
23072 {|
23073 |-
23074 | -{R|B}-
23075 |}
23076 !! html/php
23077 <table>
23078
23079 <tr>
23080 <td>B
23081 </td></tr></table>
23082
23083 !! html/parsoid
23084 <table>
23085 <tbody>
23086 <tr>
23087 <td><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"B"}}'></span></td>
23088 </tr>
23089 </tbody>
23090 </table>
23091 !! end
23092
23093 !! test
23094 Language converter tricky html2wt cases (1)
23095 !! options
23096 language=sr
23097 parsoid=html2wt,wt2wt
23098 !! html/parsoid
23099 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"}-"}}'></span></p>
23100 !! wikitext
23101 -{<nowiki>}-</nowiki>}-
23102 !! html/php
23103 <p>&#125;-
23104 </p>
23105 !! end
23106
23107 !! test
23108 Language converter tricky html2wt cases (2)
23109 !! options
23110 language=sr
23111 parsoid=html2wt,wt2wt
23112 !! html/parsoid
23113 <p>-{foo}-</p>
23114 !! wikitext
23115 <nowiki>-{foo}-</nowiki>
23116 !! html/php
23117 <p>-&#123;foo&#125;-
23118 </p>
23119 !! end
23120
23121 !! test
23122 Language converter tricky html2wt cases (3)
23123 !! options
23124 language=sr
23125 parsoid=html2wt,wt2wt
23126 !! html/parsoid
23127 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"|"}}'></span></p>
23128 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"R|raw"}}'></span></p>
23129 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"-{foo}-"}}'></span></p>
23130 !! wikitext
23131 -{R||}-
23132
23133 -{R|R|raw}-
23134
23135 -{<nowiki>-{foo}-</nowiki>}-
23136 !! html/php
23137 <p>|
23138 </p><p>R|raw
23139 </p><p>-&#123;foo&#125;-
23140 </p>
23141 !! end
23142
23143 !! test
23144 Language converter tricky html2wt cases (4)
23145 !! options
23146 language=sr
23147 parsoid=html2wt,wt2wt
23148 !! html/parsoid
23149 <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>
23150 !! wikitext
23151 -{R|{{echo|hey}}}-
23152 !! html/php
23153 <p>hey
23154 </p>
23155 !! end
23156
23157 # Note that the <nowiki> escaping added by parsoid for source text,
23158 # destination text, and language names only works on the PHP side
23159 # for *destination text*. (HTML entity escaping wouldn't work
23160 # any better.) This is probably a bug, at least for source texts.
23161 # (For language names PHP uses a precise regexp based on the languages
23162 # it currently knows have variants, which is fragile since this set
23163 # can grow/shrink over time.)
23164 !! test
23165 Language converter tricky html2wt cases (5)
23166 !! options
23167 language=zh variant=zh-cn
23168 !! html/parsoid
23169 <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>
23170 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"A","l":"bo:g;us","t":"B"}]}'/></p>
23171 <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>
23172 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"bo:g;us","t":"xyz"},{"l":"zh-cn","t":"abc"}]}'></span></p>
23173 <p>a:b=>c xyz</p>
23174 !! wikitext
23175 -{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
23176
23177 -{H|A=><nowiki>bo:g;us</nowiki>:B}-
23178
23179 -{A|zh-tw:xyz; zh-cn:<nowiki>0;zh-tw:bar</nowiki>}-
23180
23181 -{<nowiki>bo:g;us</nowiki>:xyz; zh-cn:abc}-
23182
23183 a:b=>c xyz
23184 !! html/php+disabled
23185 <p>foobat;xyz=&gt;zh-cn:abc
23186 </p><p>A
23187 </p><p>0;zh-tw:bar
23188 </p><p>abc
23189 </p><p>a:b=&gt;c 0;zh-tw:bar
23190 </p>
23191 !! end
23192
23193 !! test
23194 T179579: Nowiki and lc interaction
23195 !! options
23196 parsoid=wt2html
23197 language=sr
23198 !! wikitext
23199 -{</nowiki>123}-
23200
23201 -{123<nowiki>|</nowiki>456}-
23202 !! html/parsoid
23203 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&amp;lt;/nowiki>123"}}' data-parsoid='{"fl":[],"src":"-{&lt;/nowiki>123}-"}'></span></p>
23204
23205 <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>
23206 !! end
23207
23208 !! test
23209 T2529: Uncovered bullet
23210 !! wikitext
23211 *Foo {{bullet}}
23212 !! html
23213 <ul><li>Foo</li>
23214 <li>Bar</li></ul>
23215
23216 !! end
23217
23218 !! test
23219 T2529: Uncovered bullet in a deeply nested list
23220 !! wikitext
23221 *******Foo {{bullet}}
23222 !! html
23223 <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>
23224 <li>Bar</li></ul>
23225
23226 !! end
23227
23228 !! test
23229 T2529: Uncovered table already at line-start
23230 !! wikitext
23231 x
23232
23233 {{table}}
23234 y
23235 !! html
23236 <p>x
23237 </p>
23238 <table>
23239 <tr>
23240 <td>1</td>
23241 <td>2
23242 </td></tr>
23243 <tr>
23244 <td>3</td>
23245 <td>4
23246 </td></tr></table>
23247 <p>y
23248 </p>
23249 !! end
23250
23251 !! test
23252 T2529: Uncovered bullet in parser function result
23253 !! wikitext
23254 *Foo {{lc:{{bullet}} }}
23255 !! html
23256 <ul><li>Foo</li>
23257 <li>bar</li></ul>
23258
23259 !! end
23260
23261 !! test
23262 T7678: Double-parsed template argument
23263 !! wikitext
23264 {{lc:{{{1}}}|hello}}
23265 !! html
23266 <p>{{{1}}}
23267 </p>
23268 !! end
23269
23270 !! test
23271 T7678: Double-parsed template invocation
23272 !! wikitext
23273 {{lc:{{paramtest {{!}} param = hello }} }}
23274 !! html
23275 <p>{{paramtest | param = hello }}
23276 </p>
23277 !! end
23278
23279 !! test
23280 Case insensitivity of parser functions for non-ASCII characters (T10143)
23281 !! options
23282 language=cs
23283 title=[[Main Page]]
23284 !! wikitext
23285 {{PRVNÍVELKÉ:ěščř}}
23286 {{prvnívelké:ěščř}}
23287 {{PRVNÍMALÉ:ěščř}}
23288 {{prvnímalé:ěščř}}
23289 {{MALÁ:ěščř}}
23290 {{malá:ěščř}}
23291 {{VELKÁ:ěščř}}
23292 {{velká:ěščř}}
23293 !! html
23294 <p>Ěščř
23295 Ěščř
23296 ěščř
23297 ěščř
23298 ěščř
23299 ěščř
23300 ĚŠČŘ
23301 ĚŠČŘ
23302 </p>
23303 !! end
23304
23305 !! test
23306 Morwen/13: Unclosed link followed by heading
23307 !! wikitext
23308 [[link
23309 ==heading==
23310 !! html
23311 <p>[[link
23312 </p>
23313 <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>
23314
23315 !! end
23316
23317 !! test
23318 HHP2.1: Heuristics for headings in preprocessor parenthetical structures
23319 !! wikitext
23320 {{foo|
23321 =heading=
23322 !! html
23323 <p>{{foo|
23324 </p>
23325 <h1><span class="mw-headline" id="heading">heading</span></h1>
23326
23327 !! end
23328
23329 !! test
23330 HHP2.2: Heuristics for headings in preprocessor parenthetical structures
23331 !! wikitext
23332 {{foo|
23333 ==heading==
23334 !! html
23335 <p>{{foo|
23336 </p>
23337 <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>
23338
23339 !! end
23340
23341 !! test
23342 Tildes in comments
23343 !! options
23344 pst
23345 !! wikitext
23346 <!-- ~~~~ -->
23347 !! html/php
23348 <!-- ~~~~ -->
23349 !! end
23350
23351 !! test
23352 Paragraphs inside divs (no extra line breaks)
23353 !! wikitext
23354 <div>Line one
23355
23356 Line two</div>
23357 !! html
23358 <div>Line one
23359 Line two</div>
23360
23361 !! end
23362
23363 !! test
23364 Paragraphs inside divs (extra line break on open)
23365 !! wikitext
23366 <div>
23367 Line one
23368
23369 Line two</div>
23370 !! html
23371 <div>
23372 <p>Line one
23373 </p>
23374 Line two</div>
23375
23376 !! end
23377
23378 !! test
23379 Paragraphs inside divs (extra line break on close)
23380 !! wikitext
23381 <div>Line one
23382
23383 Line two
23384 </div>
23385 !! html
23386 <div>Line one
23387 <p>Line two
23388 </p>
23389 </div>
23390
23391 !! end
23392
23393 !! test
23394 Paragraphs inside divs (extra line break on open and close)
23395 !! wikitext
23396 <div>
23397 Line one
23398
23399 Line two
23400 </div>
23401 !! html
23402 <div>
23403 <p>Line one
23404 </p><p>Line two
23405 </p>
23406 </div>
23407
23408 !! end
23409
23410 # doBlockLevels screws up this output and Remex cleans up as much as it can.
23411 # Parsoid seems to do a better job here since its p-wrapper is probably smarter.
23412 !! test
23413 Nesting tags, paragraphs on lines which begin with <div>
23414 !! wikitext
23415 <div></div><strong>A
23416 B</strong>
23417 !! html/php+tidy
23418 <div></div><p><strong>A
23419 </strong></p><strong></strong><p><strong>B</strong>
23420 </p>
23421 !! html/parsoid
23422 <div></div>
23423 <p><strong>A
23424 B</strong>
23425 </p>
23426 !! end
23427
23428 # T8200: <blockquote> should behave like <div> with respect to line breaks
23429 !! test
23430 T8200: paragraphs inside blockquotes (no extra line breaks)
23431 !! wikitext
23432 <blockquote>Line one
23433
23434 Line two</blockquote>
23435 !! html
23436 <blockquote>Line one
23437 Line two</blockquote>
23438
23439 !! html+tidy
23440 <blockquote><p>Line one
23441 Line two</p></blockquote>
23442 !! end
23443
23444 !! test
23445 T8200: paragraphs inside blockquotes (extra line break on open)
23446 !! wikitext
23447 <blockquote>
23448 Line one
23449
23450 Line two</blockquote>
23451 !! html
23452 <blockquote>
23453 <p>Line one
23454 </p>
23455 Line two</blockquote>
23456
23457 !! html+tidy
23458 <blockquote>
23459 <p>Line one
23460 </p><p>
23461 Line two</p></blockquote>
23462 !! end
23463
23464 # Parsoid's output is broken on this because of Tidy-compatibility cruft
23465 !! test
23466 T8200: paragraphs inside blockquotes (extra line break on close)
23467 !! wikitext
23468 <blockquote>Line one
23469
23470 Line two
23471 </blockquote>
23472 !! html
23473 <blockquote>Line one
23474 <p>Line two
23475 </p>
23476 </blockquote>
23477
23478 !! html+tidy
23479 <blockquote><p>Line one
23480 </p><p>Line two
23481 </p>
23482 </blockquote>
23483 !! end
23484
23485 !! test
23486 T8200: paragraphs inside blockquotes (extra line break on open and close)
23487 !! wikitext
23488 <blockquote>
23489 Line one
23490
23491 Line two
23492 </blockquote>
23493 !! html
23494 <blockquote>
23495 <p>Line one
23496 </p><p>Line two
23497 </p>
23498 </blockquote>
23499
23500 !! end
23501
23502 ## This is a corner case interaction between the paragraph wrapping in the
23503 ## php parser's BlockLevelPass and Remex. `doBlockLevels` has a notion of
23504 ## some tags which close paragraphs (and thus prevent wrapping on their line),
23505 ## of which "div" is one, but do p-wrapping inside them. These are referred
23506 ## to as "never suppressing". Remex, for its part, doesn't traverse into
23507 ## "div"s to p-wrap. Hence, we only get this partial wrapping.
23508 !! test
23509 Paragraphs inside blockquotes/divs (no extra line breaks)
23510 !! wikitext
23511 <blockquote><div>Line one
23512
23513 Line two</div></blockquote>
23514 !! html
23515 <blockquote><div>Line one
23516 Line two</div></blockquote>
23517
23518 !! end
23519
23520 !! test
23521 Paragraphs inside blockquotes/divs (extra line break on open)
23522 !! wikitext
23523 <blockquote><div>
23524 Line one
23525
23526 Line two</div></blockquote>
23527 !! html
23528 <blockquote><div>
23529 <p>Line one
23530 </p>
23531 Line two</div></blockquote>
23532
23533 !! end
23534
23535 !! test
23536 Paragraphs inside blockquotes/divs (extra line break on close)
23537 !! wikitext
23538 <blockquote><div>Line one
23539
23540 Line two
23541 </div></blockquote>
23542 !! html
23543 <blockquote><div>Line one
23544 <p>Line two
23545 </p>
23546 </div></blockquote>
23547
23548 !! end
23549
23550 !! test
23551 Paragraphs inside blockquotes/divs (extra line break on open and close)
23552 !! wikitext
23553 <blockquote><div>
23554 Line one
23555
23556 Line two
23557 </div></blockquote>
23558 !! html
23559 <blockquote><div>
23560 <p>Line one
23561 </p><p>Line two
23562 </p>
23563 </div></blockquote>
23564
23565 !! end
23566
23567 !! test
23568 Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion
23569 !! options
23570 wgLinkHolderBatchSize=0
23571 !! wikitext
23572 [[meatball:1]]
23573 [[meatball:2]]
23574 [[meatball:3]]
23575 !! html
23576 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?1" class="extiw" title="meatball:1">meatball:1</a>
23577 <a href="http://www.usemod.com/cgi-bin/mb.pl?2" class="extiw" title="meatball:2">meatball:2</a>
23578 <a href="http://www.usemod.com/cgi-bin/mb.pl?3" class="extiw" title="meatball:3">meatball:3</a>
23579 </p>
23580 !! end
23581
23582 !! test
23583 Free external link invading image caption
23584 !! wikitext
23585 [[Image:Foobar.jpg|thumb|http://x|hello]]
23586 !! html/php
23587 <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>
23588
23589 !! html/parsoid
23590 <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>
23591 !! end
23592
23593 !! test
23594 T17196: localised external link numbers
23595 !! options
23596 language=fa
23597 !! wikitext
23598 [http://en.wikipedia.org/]
23599 !! html/php
23600 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/">[۱]</a>
23601 </p>
23602 !! html/parsoid
23603 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/"></a></p>
23604 !! end
23605
23606 !! test
23607 Multibyte character in padleft
23608 !! wikitext
23609 {{padleft:-Hello|7|Æ}}
23610 !! html/php
23611 <p>Æ-Hello
23612 </p>
23613 !! html/parsoid
23614 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:-Hello","function":"padleft"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Æ-Hello</p>
23615 !! end
23616
23617 !! test
23618 Multibyte character in padright
23619 !! wikitext
23620 {{padright:Hello-|7|Æ}}
23621 !! html/php
23622 <p>Hello-Æ
23623 </p>
23624 !! html/parsoid
23625 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:Hello-","function":"padright"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Hello-Æ</p>
23626 !! end
23627
23628 !!test
23629 formatdate parser function
23630 !! wikitext
23631 {{#formatdate:2009-03-24}}
23632 !! html
23633 <p><span class="mw-formatted-date" title="2009-03-24">2009-03-24</span>
23634 </p>
23635 !! end
23636
23637 !!test
23638 formatdate parser function, with default format
23639 !! wikitext
23640 {{#formatdate:2009-03-24|mdy}}
23641 !! html
23642 <p><span class="mw-formatted-date" title="2009-03-24">March 24, 2009</span>
23643 </p>
23644 !! end
23645
23646 !! test
23647 Spacing of numbers in formatted dates
23648 !! wikitext
23649 {{#formatdate:January 15}}
23650 !! html
23651 <p><span class="mw-formatted-date" title="01-15">January 15</span>
23652 </p>
23653 !! end
23654
23655 !! test
23656 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
23657 !! options
23658 language=nl title=[[MediaWiki:Common.css]]
23659 !! wikitext
23660 {{#formatdate:2009-03-24|dmy}}
23661 !! html
23662 <p><span class="mw-formatted-date" title="2009-03-24">24 March 2009</span>
23663 </p>
23664 !! end
23665
23666 #
23667 #
23668 #
23669
23670 #
23671 # Edit comments
23672 #
23673
23674 !! test
23675 Edit comment with link
23676 !! options
23677 comment
23678 !! wikitext
23679 I like the [[Main Page]] a lot
23680 !! html/php
23681 I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot
23682 !!end
23683
23684 !! test
23685 Edit comment with link and link text
23686 !! options
23687 comment
23688 !! wikitext
23689 I like the [[Main Page|best pages]] a lot
23690 !! html/php
23691 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
23692 !!end
23693
23694 !! test
23695 Edit comment with link and link text with suffix
23696 !! options
23697 comment
23698 !! wikitext
23699 I like the [[Main Page|best page]]s a lot
23700 !! html/php
23701 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
23702 !!end
23703
23704 !! test
23705 Edit comment with section link (non-local, eg in history list)
23706 !! options
23707 comment title=[[Main Page]]
23708 !! wikitext
23709 /* External links */ removed bogus entries
23710 !! html/php
23711 <a href="/wiki/Main_Page#External_links" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
23712 !!end
23713
23714 !! test
23715 Edit comment with section link and text before it (non-local, eg in history list)
23716 !! options
23717 comment title=[[Main Page]]
23718 !! wikitext
23719 pre-comment text /* External links */ removed bogus entries
23720 !! html/php
23721 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>
23722 !!end
23723
23724 !! test
23725 Edit comment with section link (local, eg in diff view)
23726 !! options
23727 comment local title=[[Main Page]]
23728 !! wikitext
23729 /* External links */ removed bogus entries
23730 !! html/php
23731 <a href="#External_links">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
23732 !!end
23733
23734 !! test
23735 Edit comment with subpage link (T16080)
23736 !! options
23737 comment
23738 subpage
23739 title=[[Subpage test]]
23740 !! wikitext
23741 Poked at a [[/subpage]] here...
23742 !! html/php
23743 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> here...
23744 !!end
23745
23746 !! test
23747 Edit comment with subpage link and link text (T16080)
23748 !! options
23749 comment
23750 subpage
23751 title=[[Subpage test]]
23752 !! wikitext
23753 Poked at a [[/subpage|neat little page]] here...
23754 !! html/php
23755 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">neat little page</a> here...
23756 !!end
23757
23758 !! test
23759 Edit comment with bogus subpage link in non-subpage NS (T16080)
23760 !! options
23761 comment
23762 title=[[Subpage test]]
23763 !! wikitext
23764 Poked at a [[/subpage]] here...
23765 !! html/php
23766 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...
23767 !!end
23768
23769 !! test
23770 Edit comment with bare anchor link (local, as on diff)
23771 !! options
23772 comment
23773 local
23774 title=[[Main Page]]
23775 !! wikitext
23776 [[#section]]
23777 !! html/php
23778 <a href="#section">#section</a>
23779 !! end
23780
23781 !! test
23782 Edit comment with bare anchor link (non-local, as on history)
23783 !! options
23784 comment
23785 title=[[Main Page]]
23786 !! wikitext
23787 [[#section]]
23788 !! html/php
23789 <a href="/wiki/Main_Page#section" title="Main Page">#section</a>
23790 !! end
23791
23792 !! test
23793 Anchor starting with underscore
23794 !! options
23795 title=[[Foo]]
23796 !! wikitext
23797 [[#_ref|One]]
23798 !! html/php
23799 <p><a href="#_ref">One</a>
23800 </p>
23801 !! html/parsoid
23802 <p><a rel="mw:WikiLink" href="./Foo#_ref" data-parsoid='{"stx":"piped","a":{"href":"./Foo#_ref"},"sa":{"href":"#_ref"}}'>One</a></p>
23803 !! end
23804
23805 !! test
23806 Id starting with underscore
23807 !! wikitext
23808 <div id="_ref"></div>
23809 !! html/*
23810 <div id="_ref"></div>
23811
23812 !! end
23813
23814 !! test
23815 Edit comment with link with more than one pipe (T99346)
23816 !! options
23817 comment
23818 !! wikitext
23819 [[Main Page|Many|pipes]]
23820 !! html/php
23821 <a href="/wiki/Main_Page" title="Main Page">Many|pipes</a>
23822 !! end
23823
23824 !! test
23825 Complex edit comment with link with more than one pipe (T99346)
23826 !! options
23827 comment
23828 !! wikitext
23829 Created page with "<noinclude>[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]]</noinclude> === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..."
23830 !! html/php
23831 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;
23832 !! end
23833
23834 !! test
23835 Space normalisation on autocomment (T24784)
23836 !! options
23837 comment
23838 title=[[Main Page]]
23839 !! wikitext
23840 /* __hello__world__ */
23841 !! html/php
23842 <a href="/wiki/Main_Page#hello_world" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">__hello__world__</span></span>
23843 !! end
23844
23845 !! test
23846 percent-encoding and + signs in comments (T28410)
23847 !! options
23848 comment
23849 !! wikitext
23850 [[ABC%33D% ++]] [[ABC%33D% ++|+%20]]
23851 !! html/php
23852 <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>
23853 !! end
23854
23855 # Parsoid doesn't support this yet: see T75581
23856 # but it *should* omit the 'src' attribute if the image is bad.
23857 # PHP side of tests was disabled in
23858 # mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
23859 # because of issues in the PHP parserTests infrastructure
23860 # (but the output below is indeed what the PHP side emits)
23861 !! test
23862 Bad images - basic functionality
23863 !! wikitext
23864 [[File:Bad.jpg]]
23865 !! html/php+disabled
23866 !! html/parsoid
23867 <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>
23868 !! end
23869
23870 !! test
23871 Bad images - T18039: text after bad image disappears
23872 !! wikitext
23873 Foo bar
23874 [[File:Bad.jpg]]
23875 Bar foo
23876 !! html/php+disabled
23877 <p>Foo bar
23878 </p><p>Bar foo
23879 </p>
23880 !! html/parsoid
23881 <p>Foo bar
23882 <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>
23883 Bar foo</p>
23884 !! end
23885
23886 !! test
23887 Verify that displaytitle works (T24501) no displaytitle
23888 !! options
23889 showtitle
23890 !! config
23891 wgAllowDisplayTitle=true
23892 wgRestrictDisplayTitle=false
23893 !! wikitext
23894 this is not the the title
23895 !! html/php
23896 Parser test
23897 <p>this is not the the title
23898 </p>
23899 !! end
23900
23901 !! test
23902 Verify that displaytitle works (T24501) RestrictDisplayTitle=false
23903 !! options
23904 showtitle
23905 title=[[Screen]]
23906 !! config
23907 wgAllowDisplayTitle=true
23908 wgRestrictDisplayTitle=false
23909 !! wikitext
23910 this is not the the title
23911 {{DISPLAYTITLE:whatever}}
23912 !! html/php
23913 whatever
23914 <p>this is not the the title
23915 </p>
23916 !! end
23917
23918 !! test
23919 Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch
23920 !! options
23921 showtitle
23922 title=[[Screen]]
23923 !! config
23924 wgAllowDisplayTitle=true
23925 wgRestrictDisplayTitle=true
23926 !! wikitext
23927 this is not the the title
23928 {{DISPLAYTITLE:whatever}}
23929 !! html/php
23930 Screen
23931 <p>this is not the the title
23932 </p>
23933 !! end
23934
23935 !! test
23936 Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching
23937 !! options
23938 showtitle
23939 title=[[Screen]]
23940 !! config
23941 wgAllowDisplayTitle=true
23942 wgRestrictDisplayTitle=true
23943 !! wikitext
23944 this is not the the title
23945 {{DISPLAYTITLE:screen}}
23946 !! html/php
23947 screen
23948 <p>this is not the the title
23949 </p>
23950 !! end
23951
23952 !! test
23953 Verify that displaytitle works (T24501) AllowDisplayTitle=false
23954 !! options
23955 showtitle
23956 title=[[Screen]]
23957 !! config
23958 wgAllowDisplayTitle=false
23959 !! wikitext
23960 this is not the the title
23961 {{DISPLAYTITLE:screen}}
23962 !! html/php
23963 Screen
23964 <p>this is not the the title
23965 <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>
23966 </p>
23967 !! end
23968
23969 !! test
23970 Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE
23971 !! options
23972 showtitle
23973 title=[[Screen]]
23974 !! config
23975 wgAllowDisplayTitle=false
23976 !! wikitext
23977 this is not the the title
23978 !! html/php
23979 Screen
23980 <p>this is not the the title
23981 </p>
23982 !! end
23983
23984 !! test
23985 Verify that displaytitle handles inline CSS styles (T28547) - rejected value
23986 !! options
23987 showtitle
23988 title=[[Screen]]
23989 !! config
23990 wgAllowDisplayTitle=true
23991 wgRestrictDisplayTitle=true
23992 !! wikitext
23993 this is not the the title
23994 {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
23995 !! html/php
23996 <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
23997 <p>this is not the the title
23998 </p>
23999 !! end
24000
24001 !! test
24002 Verify that displaytitle handles inline CSS styles (T28547) - accepted value
24003 !! options
24004 showtitle
24005 title=[[Screen]]
24006 !! config
24007 wgAllowDisplayTitle=true
24008 wgRestrictDisplayTitle=true
24009 !! wikitext
24010 this is not the the title
24011 {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
24012 !! html/php
24013 <span style="color: red;">s</span>creen
24014 <p>this is not the the title
24015 </p>
24016 !! end
24017
24018 !! test
24019 Page status indicators: Empty name is invalid
24020 !! options
24021 showindicators
24022 !! wikitext
24023 <indicator name=" "></indicator>
24024 <indicator></indicator>
24025 !! html/php
24026 <p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
24027 <span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
24028 </p>
24029 !! end
24030
24031 !! test
24032 Page status indicators: Weird syntaxes that are okay
24033 !! options
24034 showindicators
24035 !! wikitext
24036 <indicator name="empty" />
24037 <indicator name="name"></indicator>
24038 !! html/php
24039 empty=
24040 name=
24041 <p><br />
24042 </p>
24043 !! end
24044
24045 !! test
24046 Page status indicators: Torture test
24047 !! options
24048 showindicators
24049 !! wikitext
24050 <indicator name="01">hello world</indicator>
24051 <indicator name="02">[[Main Page]]</indicator>
24052 <indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator>
24053 <indicator name="04">[[File:Foobar.jpg|25px]]</indicator>
24054 <indicator name="05">*foo
24055 *bar</indicator>
24056 <indicator name="06"><nowiki>foo</nowiki></indicator>
24057 <indicator name="07"> Preformatted</indicator>
24058 <indicator name="08"><div>Broken tag</indicator>
24059 <indicator name="09">{| class=wikitable
24060 |cell
24061 |}</indicator>
24062 <indicator name="10">Two
24063
24064 paragraphs</indicator>
24065 !! html/php
24066 01=hello world
24067 02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
24068 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" />
24069 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>
24070 05=<ul><li>foo</li>
24071 <li>bar</li></ul>
24072
24073 06=foo
24074 07=<pre>Preformatted
24075 </pre>
24076 08=<div>Broken tag</div>
24077
24078 09=<table class="wikitable">
24079 <tr>
24080 <td>cell
24081 </td></tr></table>
24082
24083 10=<p>Two
24084 </p><p>paragraphs
24085 </p>
24086 <p><br />
24087 </p><p><br />
24088 </p><p><br />
24089 </p><p><br />
24090 </p><p><br />
24091 </p>
24092 !! end
24093
24094 !! test
24095 preload: check <noinclude> and <includeonly>
24096 !! options
24097 preload
24098 !! wikitext
24099 Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
24100 !! html/php
24101 Hello kind world.
24102 !! end
24103
24104 !! test
24105 preload: check <onlyinclude>
24106 !! options
24107 preload
24108 !! wikitext
24109 Goodbye <onlyinclude>Hello world</onlyinclude>
24110 !! html/php
24111 Hello world
24112 !! end
24113
24114 !! test
24115 preload: can pass tags through if we want to
24116 !! options
24117 preload
24118 !! wikitext
24119 <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
24120 !! html/php
24121 <includeonly>Hello world</includeonly>
24122 !! end
24123
24124 !! test
24125 preload: check that it doesn't try to do tricks
24126 !! options
24127 preload
24128 !! wikitext
24129 * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
24130 !! html/php
24131 * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
24132 !! end
24133
24134 !! test
24135 Play a bit with r67090 and T5158
24136 !! wikitext
24137 <div style="width:50% !important">&nbsp;</div>
24138 <div style="width:50%&nbsp;!important">&nbsp;</div>
24139 <div style="width:50%&#160;!important">&nbsp;</div>
24140 <div style="border : solid;">&nbsp;</div>
24141 !! html/php
24142 <div style="width:50%&#32;!important">&#160;</div>
24143 <div style="width:50% !important">&#160;</div>
24144 <div style="width:50% !important">&#160;</div>
24145 <div style="border&#32;: solid;">&#160;</div>
24146
24147 !! html/parsoid
24148 <div style="width:50% !important" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
24149 <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>
24150 <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>
24151 <div style="border : solid;" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
24152
24153 !! end
24154
24155 !! test
24156 T5158: Test for French spaces in attributes
24157 !! wikitext
24158 <br style=" clear : both ; " />
24159 !! html/php
24160 <p><br style="clear&#32;: both&#32;;" />
24161 </p>
24162 !! end
24163
24164 !! test
24165 HTML5 data attributes
24166 !! wikitext
24167 <span data-foo="bar">Baz</span>
24168 <p data-abc-def_hij="">Quuz</p>
24169 !! html/php
24170 <p><span data-foo="bar">Baz</span>
24171 </p>
24172 <p data-abc-def_hij="">Quuz</p>
24173
24174 !! html/parsoid
24175 <p><span data-foo="bar" data-parsoid='{"stx":"html"}'>Baz</span></p>
24176 <p data-abc-def_hij="" data-parsoid='{"stx":"html"}'>Quuz</p>
24177 !! end
24178
24179 !! test
24180 Strip reserved data attributes
24181 !! wikitext
24182 <div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
24183 !! html/php
24184 <div data-ok="fred">d</div>
24185
24186 !! html/parsoid
24187 <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>
24188 !! end
24189
24190 !! test
24191 percent-encoding and + signs in internal links (T28410)
24192 !! wikitext
24193 [[User:+%]] [[Page+title%]]
24194 [[%+]] [[%+|%20]] [[%+ ]] [[%+r]]
24195 [[%]] [[+]] [[File:%+abc%39|foo|[[bar]]]]
24196 [[%33%45]] [[%33%45+]]
24197 !! html/php
24198 <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>
24199 <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>
24200 <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>
24201 <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>
24202 </p>
24203 !! html/parsoid
24204 <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>
24205 <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>
24206 <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>
24207 <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>
24208 !! end
24209
24210 !! test
24211 Special characters in embedded file links (T29679)
24212 !! wikitext
24213 [[File:Contains & ampersand.jpg]]
24214 [[File:Does not exist.jpg|Title with & ampersand]]
24215 !! html/php
24216 <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>
24217 <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>
24218 </p>
24219 !! html/parsoid
24220 <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>
24221 <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>
24222 !! end
24223
24224 !! test
24225 Confirm that 'apos' named character reference doesn't make it to output (not legal in HTML 4)
24226 !! wikitext
24227 Text&apos;s been normalized?
24228 !! html
24229 <p>Text&#39;s been normalized?
24230 </p>
24231 !! end
24232
24233 !! test
24234 T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
24235 !! wikitext
24236 http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
24237 !! html
24238 <p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> &lt;-- U+3000 (vim: ^Vu3000)
24239 </p>
24240 !! end
24241
24242 !! test
24243 T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
24244 !! wikitext
24245 [http://www.example.org/ ideograms]
24246 !! html
24247 <p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a>
24248 </p>
24249 !! end
24250
24251 !! test
24252 T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
24253 !! wikitext
24254 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
24255 !! html
24256 <p><img src="http://www.example.org/pic.png" alt="pic.png"/> &lt;-- U+3000 (vim: ^Vu3000)
24257 </p>
24258 !! end
24259
24260 !! article
24261 Mediawiki:loop1
24262 !! text
24263 {{Identical|A}}
24264 !! endarticle
24265
24266 !! article
24267 Mediawiki:loop2
24268 !! text
24269 {{Identical|B}}
24270 !! endarticle
24271
24272 !! article
24273 Template:Identical
24274 !! text
24275 {{int:loop1}}
24276 {{int:loop2}}
24277 !! endarticle
24278
24279 !! test
24280 T33098 Template which includes system messages which includes the template
24281 !! wikitext
24282 {{Identical}}
24283 !! html
24284 <p><span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
24285 <span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
24286 </p>
24287 !! end
24288
24289 !! test
24290 T33490 Turkish: ucfirst 'blah'
24291 !! options
24292 language=tr
24293 !! wikitext
24294 {{ucfirst:blah}}
24295 !! html
24296 <p>Blah
24297 </p>
24298 !! end
24299
24300 !! test
24301 T33490 Turkish: ucfirst 'ix'
24302 !! options
24303 language=tr
24304 !! wikitext
24305 {{ucfirst:ix}}
24306 !! html
24307 <p>İx
24308 </p>
24309 !! end
24310
24311 !! test
24312 T33490 Turkish: lcfirst 'BLAH'
24313 !! options
24314 language=tr
24315 !! wikitext
24316 {{lcfirst:BLAH}}
24317 !! html
24318 <p>bLAH
24319 </p>
24320 !! end
24321
24322 !! test
24323 T33490 Turkish: ucfırst (with a dotless i)
24324 !! options
24325 language=tr
24326 !! wikitext
24327 {{ucfırst:blah}}
24328 !! html
24329 <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>
24330 </p>
24331 !! end
24332
24333 !! test
24334 T33490 ucfırst (with a dotless i) with English language
24335 !! options
24336 language=en
24337 !! wikitext
24338 {{ucfırst:blah}}
24339 !! html
24340 <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>
24341 </p>
24342 !! end
24343
24344 # Note that Parsoid doesn't emit an explicit TOC.
24345 # Note also that the html2wt direction tends to emit an extra newline
24346 # between the __TOC__ magicword and the first heading unless *both*
24347 # the <meta> and the <h2> have a data-parsoid attribute set (even if
24348 # it's "{}").
24349
24350 !! test
24351 T28375: TOC with italics
24352 !! options
24353 title=[[Main Page]]
24354 !! wikitext
24355 __TOC__
24356 ==''Lost'' episodes==
24357 !! html/php
24358 <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>
24359 <ul>
24360 <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>
24361 </ul>
24362 </div>
24363
24364 <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>
24365
24366 !! html/parsoid
24367 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24368 <h2 id="Lost_episodes" data-parsoid='{}'><i>Lost</i> episodes</h2>
24369 !! end
24370
24371 !! test
24372 T28375: TOC with bold
24373 !! options
24374 title=[[Main Page]]
24375 !! wikitext
24376 __TOC__
24377 =='''should be bold''' then normal text==
24378 !! html/php
24379 <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>
24380 <ul>
24381 <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>
24382 </ul>
24383 </div>
24384
24385 <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>
24386
24387 !! html/parsoid
24388 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24389 <h2 id="should_be_bold_then_normal_text" data-parsoid='{}'><b>should be bold</b> then normal text</h2>
24390 !! end
24391
24392 !! test
24393 T35845: Headings become cursive in TOC when they contain an image
24394 !! options
24395 title=[[Main Page]]
24396 !! wikitext
24397 __TOC__
24398 ==Image [[Image:foobar.jpg]]==
24399 !! html/php
24400 <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>
24401 <ul>
24402 <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
24403 </ul>
24404 </div>
24405
24406 <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>
24407
24408 !! html/parsoid
24409 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24410 <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>
24411 !! end
24412
24413 !! test
24414 T35845 (2): Headings become bold in TOC when they contain a blockquote
24415 !! options
24416 title=[[Main Page]]
24417 !! wikitext
24418 __TOC__
24419 ==<blockquote>Quote</blockquote>==
24420 !! html/php
24421 <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>
24422 <ul>
24423 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
24424 </ul>
24425 </div>
24426
24427 <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>
24428
24429 !! html/php+tidy
24430 <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>
24431 <ul>
24432 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
24433 </ul>
24434 </div>
24435
24436 <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>
24437 !! html/parsoid
24438 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24439 <h2 id="Quote" data-parsoid='{}'><blockquote>Quote</blockquote></h2>
24440 !! end
24441
24442 !! test
24443 Unclosed tags in TOC
24444 !! config
24445 wgFragmentMode=[ 'html5', 'legacy' ]
24446 !! options
24447 title=[[Main Page]]
24448 !! wikitext
24449 __TOC__
24450 ==Proof: 2 < 3==
24451 <small>Hanc marginis exiguitas non caperet.</small>
24452 QED
24453 !! html/php
24454 <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>
24455 <ul>
24456 <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>
24457 </ul>
24458 </div>
24459
24460 <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>
24461 <p><small>Hanc marginis exiguitas non caperet.</small>
24462 QED
24463 </p>
24464 !! html/parsoid
24465 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24466 <h2 id="Proof:_2_&lt;_3" data-parsoid='{}'><span id="Proof:_2_.3C_3" typeof="mw:FallbackId"></span>Proof: 2 &lt; 3</h2>
24467 <p><small>Hanc marginis exiguitas non caperet.</small>
24468 QED</p>
24469 !! end
24470
24471 !! test
24472 Multiple tags in TOC
24473 !! wikitext
24474 __TOC__
24475 ==<i>Foo</i> <b>Bar</b>==
24476
24477 ==<i>Foo</i> <blockquote>Bar</blockquote>==
24478 !! html/php
24479 <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>
24480 <ul>
24481 <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>
24482 <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>
24483 </ul>
24484 </div>
24485
24486 <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>
24487 <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>
24488
24489 !! html/php+tidy
24490 <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>
24491 <ul>
24492 <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>
24493 <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>
24494 </ul>
24495 </div>
24496
24497 <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>
24498 <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>
24499 !! html/parsoid
24500 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24501 <h2 id="Foo_Bar" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b></h2>
24502
24503 <h2 id="Foo_Bar_2" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote>Bar</blockquote></h2>
24504 !! end
24505
24506 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
24507 # html5 tag parsing.
24508 !! test
24509 Tags with parameters in TOC
24510 !! options
24511 parsoid=wt2html
24512 !! wikitext
24513 __TOC__
24514 ==<sup class="in-h2">Hello</sup>==
24515
24516 ==<sup class="a > b">Evilbye</sup>==
24517 !! html/php
24518 <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>
24519 <ul>
24520 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
24521 <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>
24522 </ul>
24523 </div>
24524
24525 <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>
24526 <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>
24527
24528 !! html/parsoid
24529 <meta property="mw:PageProp/toc" />
24530 <h2 id="Hello"><sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup></h2>
24531
24532 <h2 id='b">Evilbye'><span id="b.22.3EEvilbye" typeof="mw:FallbackId"></span><sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup></h2>
24533 !! end
24534
24535 !! test
24536 span tags with directionality in TOC
24537 !! wikitext
24538 __TOC__
24539 ==<span dir="ltr">C++</span>==
24540
24541 ==<span dir="rtl">זבנג!</span>==
24542
24543 ==<span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span>==
24544
24545 ==<span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span>==
24546
24547 ==<span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span>==
24548 !! html/php
24549 <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>
24550 <ul>
24551 <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>
24552 <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>
24553 <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>
24554 <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>
24555 <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>
24556 </ul>
24557 </div>
24558
24559 <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>
24560 <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>
24561 <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>
24562 <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>
24563 <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>
24564
24565 !! html/parsoid
24566 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24567 <h2 id="C++" data-parsoid='{}'><span id="C.2B.2B" typeof="mw:FallbackId"></span><span dir="ltr">C++</span></h2>
24568 <h2 id="זבנג!"><span id=".D7.96.D7.91.D7.A0.D7.92.21" typeof="mw:FallbackId"></span><span dir="rtl">זבנג!</span></h2>
24569 <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>
24570 <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>
24571 <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>
24572 !! end
24573
24574 !! test
24575 T74884: bdi element in ToC
24576 !! wikitext
24577 __TOC__
24578 ==<bdi>test</bdi>==
24579 !! html/php
24580 <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>
24581 <ul>
24582 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
24583 </ul>
24584 </div>
24585
24586 <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>
24587
24588 !! html/parsoid
24589 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24590 <h2 id="test" data-parsoid='{}'><bdi>test</bdi></h2>
24591 !! end
24592
24593 !! test
24594 T35715: s/strike element in ToC
24595 !! wikitext
24596 __TOC__
24597 ==<s>test</s> test <strike>test</strike>==
24598 !! html/php
24599 <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>
24600 <ul>
24601 <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>
24602 </ul>
24603 </div>
24604
24605 <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>
24606
24607 !! html/parsoid
24608 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24609 <h2 id="test_test_test" data-parsoid='{}'><s>test</s> test <strike>test</strike></h2>
24610 !! end
24611
24612 !! test
24613 Empty <p> tag in TOC, removed by Sanitizer (T92892)
24614 !! wikitext
24615 __TOC__
24616 ==x==
24617 !! html/php
24618 <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>
24619 <ul>
24620 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
24621 </ul>
24622 </div>
24623
24624 <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>
24625
24626 !! html/parsoid
24627 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24628 <h2 id="x" data-parsoid='{}'>x</h2>
24629 !! end
24630
24631 !! article
24632 MediaWiki:T34057
24633 !! text
24634 == {{int:headline_sample}} ==
24635 !! endarticle
24636
24637 !! test
24638 T34057: Title needed when expanding <h> nodes.
24639 !! options
24640 title=[[Main Page]]
24641 !! wikitext
24642 {{int:T34057}}
24643 !! html
24644 <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>
24645
24646 !! end
24647
24648 !! test
24649 Strip marker in urlencode
24650 !! wikitext
24651 {{urlencode:x<nowiki/>y}}
24652 {{urlencode:x<nowiki/>y|wiki}}
24653 {{urlencode:x<nowiki/>y|path}}
24654 {{urlencode:x<pre id="one">two</pre>y}}
24655 !! html/php
24656 <p>xy
24657 xy
24658 xy
24659 xy
24660 </p>
24661 !! end
24662
24663 !! test
24664 Strip marker in lc
24665 !! wikitext
24666 {{lc:x<nowiki/>y}}
24667 !! html
24668 <p>xy
24669 </p>
24670 !! end
24671
24672 !! test
24673 Strip marker in uc
24674 !! wikitext
24675 {{uc:x<nowiki/>y}}
24676 !! html
24677 <p>XY
24678 </p>
24679 !! end
24680
24681 !! test
24682 Strip marker in formatNum
24683 !! wikitext
24684 {{formatnum:1<nowiki/>2}}
24685 {{formatnum:1<nowiki/>2|R}}
24686 !! html
24687 <p>12
24688 12
24689 </p>
24690 !! end
24691
24692 !! test
24693 Check noCommafy in formatNum
24694 !! options
24695 language=be-tarask
24696 !! wikitext
24697 {{formatnum:123456.78}}
24698 {{formatnum:123456.78|NOSEP}}
24699 !! html
24700 <p>123 456,78
24701 123456.78
24702 </p>
24703 !! end
24704
24705 !! test
24706 Wrong option for formatNum (T58199)
24707 !! wikitext
24708 {{formatnum:1,234.56|Random}}
24709 {{formatnum:1,234.56|EVERYTHING}}
24710 {{formatnum:1234.56|any argument that has the string 'NOSEP'}}
24711 !! html
24712 <p>1,234.56
24713 1,234.56
24714 1,234.56
24715 </p>
24716 !! end
24717
24718 !! test
24719 Strip marker in grammar
24720 !! options
24721 language=fi
24722 !! wikitext
24723 {{grammar:elative|foo<nowiki/>bar}}
24724 !! html
24725 <p>foobarista
24726 </p>
24727 !! end
24728
24729 !! test
24730 Strip marker in padleft
24731 !! wikitext
24732 {{padleft:|2|x<nowiki/>y}}
24733 !! html
24734 <p>xy
24735 </p>
24736 !! end
24737
24738 !! test
24739 Strip marker in padright
24740 !! wikitext
24741 {{padright:|2|x<nowiki/>y}}
24742 !! html
24743 <p>xy
24744 </p>
24745 !! end
24746
24747 !! test
24748 Strip marker in anchorencode
24749 !! wikitext
24750 {{anchorencode:x<nowiki/>y}}
24751 !! html/php
24752 <p>xy
24753 </p>
24754 !! html/parsoid
24755 <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>
24756 !! end
24757
24758 !! test
24759 nowiki inside link inside heading (T20295)
24760 !! wikitext
24761 ==[[foo|x<nowiki>y</nowiki>z]]==
24762 !! html
24763 <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>
24764
24765 !! end
24766
24767 !! test
24768 new support for bdi element (T33817)
24769 !! wikitext
24770 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
24771 !! html
24772 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
24773
24774 !!end
24775
24776 !! test
24777 Ignore pipe between table row attributes
24778 !! wikitext
24779 {|
24780 |quux
24781 |- id=foo | style='color: red'
24782 |bar
24783 |}
24784 !! html
24785 <table>
24786 <tr>
24787 <td>quux
24788 </td></tr>
24789 <tr id="foo" style="color: red">
24790 <td>bar
24791 </td></tr></table>
24792
24793 !! end
24794
24795 !!test
24796 Language parser function
24797 !! wikitext
24798 {{#language:ar}}
24799 !! html
24800 <p>العربية
24801 </p>
24802 !! end
24803
24804 !!test
24805 Padleft and padright (default 0-padding)
24806 !! wikitext
24807 {{padleft:xyz|5}}
24808 {{padright:xyz|5}}
24809 !! html/php
24810 <p>00xyz
24811 xyz00
24812 </p>
24813 !! html/parsoid
24814 <p><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:xyz","function":"padleft"},"params":{"1":{"wt":"5"}},"i":0}}]}'>00xyz</span>
24815 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:xyz","function":"padright"},"params":{"1":{"wt":"5"}},"i":0}}]}'>xyz00</span></p>
24816 !! end
24817
24818 !!test
24819 Padleft and padright (partial fill)
24820 !! wikitext
24821 {{padleft:xyz|6|ab}}
24822 {{padright:xyz|6|ab}}
24823 !! html/php
24824 <p>abaxyz
24825 xyzaba
24826 </p>
24827 !! html/parsoid
24828 <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>
24829 <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>
24830 !! end
24831
24832 !!test
24833 Padleft and padright as substr
24834 !! wikitext
24835 {{padleft:|3|abcde}}
24836 {{padright:|3|abcde}}
24837 !! html/php
24838 <p>abc
24839 abc
24840 </p>
24841 !! html/parsoid
24842 <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>
24843 <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>
24844 !! end
24845
24846 !! test
24847 Padleft and padright with non-numerical length (T180403)
24848 !! wikitext
24849 {{padleft:abcdef|junk}}
24850 {{padright:abcdef|junk}}
24851 !! html/php
24852 <p>abcdef
24853 abcdef
24854 </p>
24855 !! end
24856
24857 !!test
24858 Special parser function
24859 !! wikitext
24860 {{#special:RandomPage}}
24861 {{#special:BaDtItLe}}
24862 {{#special:Foobar}}
24863 !! html
24864 <p>Special:Random
24865 Special:Badtitle
24866 Special:Foobar
24867 </p>
24868 !! end
24869
24870 !!test
24871 T36939 - Case insensitive link parsing ([HttP://])
24872 !! wikitext
24873 [HttP://MediaWiki.Org/]
24874 !! html/php
24875 <p><a rel="nofollow" class="external autonumber" href="HttP://MediaWiki.Org/">[1]</a>
24876 </p>
24877 !! html/parsoid
24878 <p><a rel="mw:ExtLink" class="external autonumber" href="HttP://MediaWiki.Org/"></a></p>
24879 !! end
24880
24881 !!test
24882 T36939 - Case insensitive link parsing ([HttP:// title])
24883 !! wikitext
24884 [HttP://MediaWiki.Org/ MediaWiki]
24885 !! html
24886 <p><a rel="nofollow" class="external text" href="HttP://MediaWiki.Org/">MediaWiki</a>
24887 </p>
24888 !! end
24889
24890 !!test
24891 T36939 - Case insensitive link parsing (HttP://)
24892 !! wikitext
24893 HttP://MediaWiki.Org/
24894 !! html/php
24895 <p><a rel="nofollow" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a>
24896 </p>
24897 !! html/parsoid
24898 <p><a rel="mw:ExtLink" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a></p>
24899 !! end
24900
24901 !!test
24902 Disable TOC
24903 !! options
24904 notoc
24905 !! wikitext
24906 Lead
24907 ==Section 1==
24908 ==Section 2==
24909 ==Section 3==
24910 ==Section 4==
24911 ==Section 5==
24912 !! html
24913 <p>Lead
24914 </p>
24915
24916 <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>
24917 <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>
24918 <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>
24919 <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>
24920 <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>
24921
24922 !! end
24923
24924
24925 ###
24926 ### Parsoid-specific tests
24927 ### Parsoid-PHP parser incompatibilities
24928 ###
24929 !!test
24930 1. SOL-sensitive wikitext tokens as template-args
24931 !!options
24932 parsoid=wt2html,wt2wt
24933 !! wikitext
24934 {{echo|*a}}
24935 {{echo|#a}}
24936 {{echo|:a}}
24937 !! html
24938 <span about="#mwt1" typeof="mw:Transclusion">
24939 </span><ul about="#mwt1"><li>a</li>
24940 </ul>
24941 <span about="#mwt2" typeof="mw:Transclusion">
24942 </span><ol about="#mwt2"><li>a</li>
24943 </ol>
24944 <span about="#mwt3" typeof="mw:Transclusion">
24945 </span><dl about="#mwt3"><dd>a</dd>
24946 </dl>
24947 !!end
24948
24949 #### -----------------------------------------------------------------
24950 #### Parsoid-specific functionality tests
24951 #### -----------------------------------------------------------------
24952
24953 # T65642/T68749: Formatting elt fixup around images is cleaned up.
24954 # We know wt2wt will fail, but we expect selser to pass.
24955 # Due to the nature of our testing, wt2wt and selser tests will enter the
24956 # blacklist and we'll catch selser regressions based on changes to the
24957 # blacklist entries for selser tests.
24958 !! test
24959 1. Bad treebuilder fixup of formatting elt is cleaned up
24960 !! options
24961 parsoid=wt2html,wt2wt
24962 !! wikitext
24963 {|
24964 |
24965 <small>
24966 [[Image:Foobar.jpg|right|Test]]
24967 </small>
24968 |}
24969 !! html/parsoid
24970 <table>
24971 <tbody><tr><td>
24972 <small>
24973 <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>
24974 </small>
24975 </td></tr>
24976 </tbody></table>
24977 !! end
24978
24979 !! test
24980 2. Bad treebuilder fixup of formatting elt is cleaned up
24981 !! options
24982 parsoid=wt2html,wt2wt
24983 !! wikitext
24984 '''foo[[File:Foobar.jpg|thumb|caption]]bar'''
24985
24986 <small>[[Image:Foobar.jpg|right|300px]]</small>
24987 !! html/parsoid
24988
24989 <p><b>foo</b></p>
24990 <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>
24991 <p><b>bar</b></p>
24992 <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>
24993 !! end
24994
24995 !! test
24996 3. Bad treebuilder fixup of formatting elt is cleaned up
24997 !! options
24998 parsoid=wt2html,wt2wt
24999 !! wikitext
25000 <small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
25001 !! html/parsoid
25002 <p><small><b>foo</b></small></p>
25003 <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>
25004 <p><small><b>bar</b></small></p>
25005 !! end
25006
25007 !! test
25008 4. Bad treebuilder fixup of formatting elt is cleaned up: formatting tags around captionless images are ignored
25009 !! options
25010 parsoid=wt2html,wt2wt
25011 !! wikitext
25012 '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
25013 !! html/parsoid
25014 <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>
25015 !! end
25016
25017 #### ----------------------------------------------------------------
25018 #### Parsoid-only testing of Parsoid's impl of LST
25019 #### Not implemented yet, see
25020 #### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
25021 #### ----------------------------------------------------------------
25022
25023 ## We still need to support serializing the older format while content is stored.
25024 !! test
25025 LST Sections: Backwards compatibility
25026 !! options
25027 parsoid={
25028 "suppressErrors": true,
25029 "modes": ["html2wt"]
25030 }
25031 !! wikitext
25032 <section begin="2011-05-16" />
25033 <section end="2014-04-10 (MW 1.23wmf22)" />
25034 !! html/parsoid
25035 <p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/>
25036 <meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p>
25037 !! end
25038
25039 !! test
25040 LST Sections: Newfangled approach
25041 !! wikitext
25042 <section begin="2011-05-16" />
25043 <section end="2014-04-10 (MW 1.23wmf22)" />
25044 !! html/parsoid
25045 <p><span typeof="mw:Extension/section" about="#mwt4" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"},"body":null}'>
25046 </span>
25047 <span typeof="mw:Extension/section" about="#mwt6" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"},"body":null}'>
25048 </span></p>
25049 !! end
25050
25051 #--------- Test stripping of empty nodes in template content ----------
25052
25053 !! test
25054 Empty LI and TR nodes should be stripped from template content
25055 !! wikitext
25056 {{EmptyLITest}}
25057 {{EmptyTRTest}}
25058 !! html/parsoid
25059 <ul about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyLITest","href":"./Template:EmptyLITest"},"params":{},"i":0}}]}'>
25060 <li>a</li>
25061 <li>b</li>
25062 </ul>
25063 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRTest","href":"./Template:EmptyTRTest"},"params":{},"i":0}}]}'>
25064 <tbody>
25065 <tr>
25066 <td>foo</td>
25067 </tr>
25068 <tr>
25069 <td>bar</td>
25070 </tr>
25071 </tbody>
25072 </table>
25073 !! end
25074
25075 !! test
25076 Empty LI and TR nodes should not be stripped from top-level content
25077 !! wikitext
25078 *a
25079 *
25080 *b
25081
25082 {|
25083 |-
25084 |-
25085 |foo
25086 |}
25087 !! html/parsoid
25088 <ul>
25089 <li>a</li>
25090 <li class='mw-empty-elt'></li>
25091 <li>b</li>
25092 </ul>
25093 <table>
25094 <tbody>
25095 <tr class='mw-empty-elt'></tr>
25096 <tr>
25097 <td>foo</td>
25098 </tr>
25099 </tbody>
25100 </table>
25101 !! end
25102
25103 !! test
25104 Empty TR nodes should not be stripped if they have any attributes set
25105 !! wikitext
25106 {{EmptyTRWithHTMLAttrTest}}
25107 !! html/parsoid
25108 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'>
25109 <tr align='center'></tr>
25110 <tr><td>foo</td></tr>
25111 <tr align='center'></tr>
25112 <tr><td>bar</td></tr>
25113 </table>
25114 !! end
25115
25116 #### ----------------------------------------------------------------
25117 #### The following section of tests are primarily to test
25118 #### wikitext escaping capabilities of Parsoid. Given that
25119 #### escaping can be done any number of ways, the wikitext (input)
25120 #### is always adjusted to reflect how Parsoid adds nowiki
25121 #### escape tags.
25122 ####
25123 #### We are marking several tests as parsoid-only since the
25124 #### HTML in the result section is different from what the
25125 #### PHP parser generates for it.
25126 #### ----------------------------------------------------------------
25127
25128
25129 #### --------------- Headings ---------------
25130 #### 0. Unnested
25131 #### 1. Nested inside html <h1>=foo=</h1>
25132 #### 2. Outside heading nest on a single line <h1>foo</h1>*bar
25133 #### 3. Nested inside html with wikitext split by html tags
25134 #### 4. No escape needed
25135 #### 5. Empty headings <h1></h1>
25136 #### 6. Heading chars in SOL context
25137 #### ----------------------------------------
25138 !! test
25139 Headings: 0. Unnested
25140 !! options
25141 parsoid=html2wt
25142 !! html/parsoid
25143 <p>=foo=</p>
25144
25145 <p> =foo=
25146 <!--cmt-->
25147 =foo=</p>
25148
25149 <p>=foo<i>a</i>=</p>
25150 !! wikitext
25151 <nowiki>=foo=</nowiki>
25152
25153 <nowiki> </nowiki>=foo=
25154 <!--cmt-->
25155 <nowiki>=foo=</nowiki>
25156
25157 =foo''a''<nowiki>=</nowiki>
25158 !!end
25159
25160 # New headings and existing headings are handled differently
25161 !! test
25162 Headings: 1. Nested inside html
25163 !! options
25164 parsoid=html2wt
25165 !! html/parsoid
25166 <h1>=foo=</h1>
25167 <h2>=foo=</h2>
25168 <h3>=foo=</h3>
25169
25170 <h1 data-parsoid=''>=foo=</h1>
25171 <h2 data-parsoid=''>=foo=</h2>
25172 <h3 data-parsoid=''>=foo=</h3>
25173 <h4 data-parsoid=''>=foo=</h4>
25174 <h5 data-parsoid=''>=foo=</h5>
25175 <h6 data-parsoid=''>=foo=</h6>
25176 !! wikitext
25177 = =foo= =
25178
25179 == =foo= ==
25180
25181 === =foo= ===
25182
25183 =<nowiki>=foo=</nowiki>=
25184 ==<nowiki>=foo=</nowiki>==
25185 ===<nowiki>=foo=</nowiki>===
25186 ====<nowiki>=foo=</nowiki>====
25187 =====<nowiki>=foo=</nowiki>=====
25188 ======<nowiki>=foo=</nowiki>======
25189
25190 !!end
25191
25192 !! test
25193 Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
25194 !! options
25195 parsoid=html2wt
25196 !! html/parsoid
25197 <h1>foo</h1>*bar
25198 <h1>foo</h1>=bar
25199 <h1>foo</h1>=bar=
25200 !! wikitext
25201 = foo =
25202 <nowiki>*</nowiki>bar
25203
25204 = foo =
25205 =bar
25206
25207 = foo =
25208 <nowiki>=bar=</nowiki>
25209 !!end
25210
25211 !! test
25212 Headings: 3. Nested inside html with wikitext split by html tags
25213 !! options
25214 parsoid=html2wt
25215 !! html/parsoid
25216 <h1>=<b>bold</b>foo=</h1>
25217 !! wikitext
25218 = ='''bold'''foo= =
25219 !!end
25220
25221 !! test
25222 Headings: 4a. No escaping needed (testing just h1 and h2)
25223 !! options
25224 parsoid=html2wt
25225 !! html/parsoid
25226 <h1>=foo</h1>
25227 <h1>foo=</h1>
25228 <h1> =foo= </h1>
25229 <h1>=foo= bar</h1>
25230 <h2>=foo</h2>
25231 <h2>foo=</h2>
25232 <h1>=</h1>
25233 <h1><i>=</i>foo=</h1>
25234 !! wikitext
25235 = =foo =
25236
25237 = foo= =
25238
25239 = =foo= =
25240
25241 = =foo= bar =
25242
25243 == =foo ==
25244
25245 == foo= ==
25246
25247 = = =
25248
25249 = ''=''foo= =
25250 !!end
25251
25252 !! test
25253 Headings: 4b. No escaping needed (inside p-tags)
25254 !! options
25255 parsoid=html2wt
25256 !! html/parsoid
25257 <p>=foo= x
25258 =foo= <s></s>
25259 </p>
25260 !! wikitext
25261 =foo= x
25262 =foo= <s></s>
25263 !! html/php
25264 <p>=foo= x
25265 =foo= <s></s>
25266 </p>
25267 !!end
25268
25269 !! test
25270 Headings: 4c. Short headings (1)
25271 !! options
25272 parsoid=html2wt
25273 !! html/parsoid
25274 <p>===
25275 </p>
25276 !! wikitext
25277 <nowiki>===</nowiki>
25278 !! html/php
25279 <p>===
25280 </p>
25281 !! end
25282
25283 # in the html2wt direction we emit '= = =' or '=<nowiki>=</nowiki>='
25284 !! test
25285 Headings: 4d. Short headings (2)
25286 !! options
25287 parsoid=wt2html,html2html
25288 !! wikitext
25289 =
25290 ==
25291 ===
25292 ====
25293 =====
25294 !! html/php
25295 <p>=
25296 ==
25297 </p>
25298 <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>
25299 <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>
25300 <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>
25301
25302 !! html/parsoid
25303 <p>=
25304 ==</p>
25305 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
25306 <h1 id="=="><span id=".3D.3D" typeof="mw:FallbackId"></span>==</h1>
25307 <h2 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h2>
25308 !! end
25309
25310 !! test
25311 Headings: 5. Empty headings
25312 !! options
25313 parsoid=html2wt
25314 !! html/parsoid
25315 <h1 data-parsoid='{}'></h1>
25316
25317 <h2 data-parsoid='{}'></h2>
25318
25319 <h3 data-parsoid='{}'></h3>
25320
25321 <h4 data-parsoid='{}'></h4>
25322
25323 <h5 data-parsoid='{}'></h5>
25324
25325 <h6 data-parsoid='{}'></h6>
25326 !! wikitext
25327 =<nowiki/>=
25328
25329 ==<nowiki/>==
25330
25331 ===<nowiki/>===
25332
25333 ====<nowiki/>====
25334
25335 =====<nowiki/>=====
25336
25337 ======<nowiki/>======
25338 !!end
25339
25340 !! test
25341 Headings: 6a. Heading chars in SOL context (with trailing spaces)
25342 !! options
25343 parsoid=html2wt
25344 !! html/parsoid
25345 <p>=a=</p>
25346
25347 <p>=a=</p>
25348
25349 <p>=a=</p>
25350 !! wikitext
25351 <nowiki>=a=</nowiki>
25352
25353 <nowiki>=a=</nowiki>
25354
25355 <nowiki>=a=</nowiki>
25356 !!end
25357
25358 !! test
25359 Headings: 6b. Heading chars in SOL context (with trailing newlines)
25360 !! options
25361 parsoid=html2wt
25362 !! html/parsoid
25363 <p>=a=
25364 b</p>
25365
25366 <p>=a=
25367 b</p>
25368
25369 <p>=a=
25370 b</p>
25371 !! wikitext
25372 <nowiki>=a=</nowiki>
25373 b
25374
25375 <nowiki>=a=</nowiki>
25376 b
25377
25378 <nowiki>=a=</nowiki>
25379 b
25380 !!end
25381
25382 !! test
25383 Headings: 6c. Heading chars in SOL context (leading newline break)
25384 !! options
25385 parsoid=html2wt
25386 !! html/parsoid
25387 <p>a
25388 =b=</p>
25389 !! wikitext
25390 a
25391 <nowiki>=b=</nowiki>
25392 !!end
25393
25394 !! test
25395 Headings: 6d. Heading chars in SOL context (with interspersed comments)
25396 !! options
25397 parsoid=html2wt
25398 !! html/parsoid
25399 <!--c0--><p>=a=</p>
25400
25401 <!--c1--><p>=a=</p> <!--c2--> <!--c3-->
25402 !! wikitext
25403 <!--c0--><nowiki>=a=</nowiki>
25404
25405 <!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3-->
25406 !!end
25407
25408 !! test
25409 Headings: 6d. Heading chars in SOL context (No escaping needed)
25410 !! options
25411 parsoid=html2wt
25412 !! html/parsoid
25413 =a=<div>b</div>
25414 !! wikitext
25415 =a=<div>b</div>
25416 !!end
25417
25418 !! test
25419 Headings: 7. Insert a newline between new content and headings
25420 !! options
25421 parsoid=html2wt
25422 !! html/parsoid
25423 <h2>NEW</h2>
25424 <p>new</p>
25425 <h2 data-parsoid='{}'>A</h2>
25426 <p data-parsoid='{}'>a</p>
25427 !! wikitext
25428 == NEW ==
25429 new
25430
25431 ==A==
25432 a
25433
25434 !! end
25435
25436 !! test
25437 Headings: Used as horizontal rule
25438 !! config
25439 wgFragmentMode=[ 'html5', 'legacy' ]
25440 !! options
25441 parsoid=wt2html
25442 !! wikitext
25443 ===============
25444 !! html/php
25445 <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>
25446
25447 !! html/parsoid
25448 <h6 id="==="><span id=".3D.3D.3D" typeof="mw:FallbackId"></span>===</h6>
25449 !! end
25450
25451 #### --------------- Lists ---------------
25452 #### 0. Outside nests (*foo, etc.)
25453 #### 1. Nested inside html <ul><li>*foo</li></ul>
25454 #### 2. Inside definition lists
25455 #### 3. Only bullets at start should be escaped
25456 #### 4. No escapes needed
25457 #### 5. No unnecessary escapes
25458 #### 6. Escape bullets in SOL position
25459 #### 7. Escape bullets in a multi-line context
25460 #### ----------------------------------------
25461
25462 !! test
25463 Lists: 0. Outside nests
25464 !! options
25465 parsoid=html2wt
25466 !! html/parsoid
25467 <p>*foo</p>
25468
25469 <p>#foo</p>
25470
25471 <p>;Foo:bar</p>
25472 !! wikitext
25473 <nowiki>*</nowiki>foo
25474
25475 <nowiki>#</nowiki>foo
25476
25477 <nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar
25478 !!end
25479
25480 ## Making these next 3 tests Parsoid-only since they are html2wt tests
25481 ## to test wikitext escaping, and insignificant whitespace diffs
25482 ## cause PHP parser tests to barf
25483 !! test
25484 Lists: 1. Nested inside html (No unnecessary escapes)
25485 !! options
25486 parsoid=html2wt
25487 !! html/parsoid
25488 <ul>
25489 <li>*foo</li>
25490 <li>#foo</li>
25491 <li>:foo</li>
25492 <li>;foo</li>
25493 <li data-parsoid='{}'>*foo</li>
25494 <li data-parsoid='{}'>#foo</li>
25495 <li data-parsoid='{}'>:foo</li>
25496 <li data-parsoid='{}'>;foo</li>
25497 </ul>
25498
25499 <ol>
25500 <li>*foo</li>
25501 <li>#foo</li>
25502 <li>:foo</li>
25503 <li>;foo</li>
25504 <li data-parsoid='{}'>*foo</li>
25505 <li data-parsoid='{}'>#foo</li>
25506 <li data-parsoid='{}'>:foo</li>
25507 <li data-parsoid='{}'>;foo</li>
25508 </ol>
25509 !! wikitext
25510 * *foo
25511 * #foo
25512 * :foo
25513 * ;foo
25514 *<nowiki>*foo</nowiki>
25515 *<nowiki>#foo</nowiki>
25516 *<nowiki>:foo</nowiki>
25517 *<nowiki>;foo</nowiki>
25518
25519 # *foo
25520 # #foo
25521 # :foo
25522 # ;foo
25523 #<nowiki>*foo</nowiki>
25524 #<nowiki>#foo</nowiki>
25525 #<nowiki>:foo</nowiki>
25526 #<nowiki>;foo</nowiki>
25527 !!end
25528
25529 !! test
25530 Lists: 2. Inside definition lists
25531 !! options
25532 parsoid=html2wt
25533 !! html/parsoid
25534 <dl><dt>;foo</dt></dl>
25535 <dl><dt>:foo</dt></dl>
25536 <dl><dt>:foo</dt>
25537 <dd>bar</dd></dl>
25538 <dl><dd>:foo</dd></dl>
25539 !! wikitext
25540 ; ;foo
25541
25542 ; <nowiki>:foo</nowiki>
25543
25544 ; <nowiki>:foo</nowiki>
25545 : bar
25546
25547 : :foo
25548 !!end
25549
25550 !! test
25551 Lists: 3. Only bullets at start of text in wikitext-generated HTML should be escaped
25552 !! options
25553 parsoid=html2wt
25554 !! html/parsoid
25555 <ul>
25556 <li>*foo*bar</li>
25557 <li data-parsoid='{}'>*foo<i>it</i>*bar</li>
25558 </ul>
25559 !! wikitext
25560 * *foo*bar
25561 *<nowiki>*foo</nowiki>''it''*bar
25562 !!end
25563
25564 !! test
25565 Lists: 4. No escapes needed
25566 !! options
25567 parsoid=html2wt
25568 !! html/parsoid
25569 <ul>
25570 <li>foo*bar
25571 </li>
25572 </ul>
25573 <ul>
25574 <li><i>foo</i>*bar
25575 </li>
25576 </ul>
25577 <ul>
25578 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>: bar
25579 </li>
25580 </ul>
25581 <ul>
25582 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar
25583 </li>
25584 </ul>
25585 !! wikitext
25586 *foo*bar
25587
25588 *''foo''*bar
25589
25590 *[[Foo]]: bar
25591
25592 *[[Foo]]*bar
25593 !!end
25594
25595 !! test
25596 Lists: 5. No unnecessary escapes
25597 !! options
25598 parsoid=html2wt
25599 !! html/parsoid
25600 <ul><li> bar <span>[[foo]]</span></li></ul>
25601 <ul><li> =bar <span>[[foo]]</span></li></ul>
25602 <ul><li> [[bar <span>[[foo]]</span></li></ul>
25603 <ul><li> ]]bar <span>[[foo]]</span></li></ul>
25604 <ul><li> =bar <span>foo]]</span>=</li></ul>
25605 <ul><li> <s></s>: a</li></ul>
25606 <ul><li> <i>* foo</i></li></ul>
25607
25608 !! wikitext
25609 * bar <span><nowiki>[[foo]]</nowiki></span>
25610
25611 * =bar <span><nowiki>[[foo]]</nowiki></span>
25612
25613 * [[bar <span><nowiki>[[foo]]</nowiki></span>
25614
25615 * ]]bar <span><nowiki>[[foo]]</nowiki></span>
25616
25617 * =bar <span>foo]]</span>=
25618
25619 * <s></s>: a
25620
25621 * ''* foo''
25622 !!end
25623
25624 !! test
25625 Lists: 6. Escape bullets in SOL position
25626 !! options
25627 parsoid=html2wt
25628 !! html/parsoid
25629 <p><!--cmt-->*foo</p>
25630 !! wikitext
25631 <!--cmt--><nowiki>*</nowiki>foo
25632 !!end
25633
25634 !! test
25635 Lists: 7. Escape bullets in a multi-line context
25636 !! options
25637 parsoid=html2wt
25638 !! html/parsoid
25639 <p>a
25640 *b
25641 </p>
25642 !! wikitext
25643 a
25644 <nowiki>*</nowiki>b
25645 !!end
25646
25647 !! test
25648 Lists: 8. Escape colons only if not present in tags
25649 !! options
25650 parsoid=html2wt
25651 !! html/parsoid
25652 <dl><dt>a:b<i>c:d</i></dt></dl>
25653 !! wikitext
25654 ; <nowiki>a:b</nowiki>''c:d''
25655 !! end
25656
25657 #### --------------- HRs ---------------
25658 #### 1. Single line
25659 #### -----------------------------------
25660
25661 !! test
25662 HRs: 1. Single line
25663 !! options
25664 parsoid=html2wt
25665 !! html/parsoid
25666 <hr />----
25667 <hr />=foo=
25668 <hr />*foo
25669 !! wikitext
25670 ----<nowiki>----</nowiki>
25671 ----=foo=
25672 ----*foo
25673 !! end
25674
25675 #### --------------- Tables ---------------
25676 #### 1a. Simple example
25677 #### 1b. No escaping needed (!foo)
25678 #### 1c. No escaping needed (|foo)
25679 #### 1d. No escaping needed (|}foo)
25680 ####
25681 #### 2a. Nested in td (<td>foo|bar</td>)
25682 #### 2b. Nested in td (<td>foo||bar</td>)
25683 #### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
25684 ####
25685 #### 3a. Nested in th (<th>foo!bar</th>)
25686 #### 3b. Nested in th (<th>foo!!bar</th>)
25687 #### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
25688 ####
25689 #### 4a. Escape -
25690 #### 4b. Escape +
25691 #### 4c. No escaping needed
25692 #### --------------------------------------
25693
25694 !! test
25695 Tables: 1a. Simple example
25696 !! options
25697 parsoid=html2wt
25698 !! html/parsoid
25699 <p>{|
25700 |}
25701 </p>
25702 !! wikitext
25703 <nowiki>{|</nowiki>
25704 |}
25705 !! end
25706
25707 !! test
25708 Tables: 1b. No escaping needed
25709 !! options
25710 parsoid=html2wt
25711 !! html/parsoid
25712 <p>!foo
25713 </p>
25714 !! wikitext
25715 !foo
25716 !! end
25717
25718 !! test
25719 Tables: 1c. No escaping needed
25720 !! options
25721 parsoid=html2wt
25722 !! html/parsoid
25723 <p>|foo
25724 </p>
25725 !! wikitext
25726 |foo
25727 !! end
25728
25729 !! test
25730 Tables: 1d. No escaping needed
25731 !! options
25732 parsoid=html2wt
25733 !! html/parsoid
25734 <p>|}foo
25735 </p>
25736 !! wikitext
25737 |}foo
25738 !! end
25739
25740 !! test
25741 Tables: 2a. Nested in td
25742 !! options
25743 parsoid=html2wt
25744 !! html/parsoid
25745 <table><tbody><tr>
25746 <td>foo|bar</td></tr>
25747 <tr><td>x<div>a|b</div></td>
25748 </tbody></table>
25749 !! wikitext
25750 {|
25751 |<nowiki>foo|bar</nowiki>
25752 |-
25753 |x<div><nowiki>a|b</nowiki></div>
25754 |}
25755 !! html/php+tidy
25756 <table>
25757 <tbody><tr>
25758 <td>foo|bar
25759 </td></tr>
25760 <tr>
25761 <td>x<div>a|b</div>
25762 </td></tr></tbody></table>
25763 !! end
25764
25765 !! test
25766 Tables: 2b. Nested in td
25767 !! options
25768 parsoid=html2wt
25769 !! html/parsoid
25770 <table><tbody><tr>
25771 <td>foo||bar</td>
25772 <td>a<i>b||c</i></td>
25773 <td>a<i><div>b||c</div></i></td>
25774 </tr></tbody></table>
25775 !! wikitext
25776 {|
25777 |<nowiki>foo||bar</nowiki>
25778 |a''<nowiki>b||c</nowiki>''
25779 |a''<div><nowiki>b||c</nowiki></div>''
25780 |}
25781 !! html/php
25782 <table>
25783 <tr>
25784 <td>foo||bar
25785 </td>
25786 <td>a<i>b||c</i>
25787 </td>
25788 <td>a<i><div>b||c</div></i>
25789 </td></tr></table>
25790
25791 !! end
25792
25793 !! test
25794 Tables: 2c. Nested in td -- no escaping needed
25795 !! options
25796 parsoid=html2wt
25797 !! html/*
25798 <table>
25799 <tr>
25800 <td>foo!!bar
25801 </td></tr></table>
25802
25803 !! wikitext
25804 {|
25805 |foo!!bar
25806 |}
25807 !! end
25808
25809 !! test
25810 Tables: 3a. Nested in th
25811 !! options
25812 parsoid=html2wt
25813 !! html/*
25814 <table>
25815 <tr>
25816 <th>foo!bar
25817 </th></tr></table>
25818
25819 !! wikitext
25820 {|
25821 !foo!bar
25822 |}
25823 !! end
25824
25825 !! test
25826 Tables: 3b. Nested in th
25827 !! options
25828 parsoid=html2wt
25829 !! html/parsoid
25830 <table><tbody>
25831 <tr><th>foo!!bar</th>
25832 <th><i>foo|bar</i></th>
25833 <th><i>foo!!bar</i></th>
25834 <th><i><span>foo!!bar</span></i></th>
25835 </tr></tbody></table>
25836 !! wikitext
25837 {|
25838 !<nowiki>foo!!bar</nowiki>
25839 !''<nowiki>foo|bar</nowiki>''
25840 !''<nowiki>foo!!bar</nowiki>''
25841 !''<span><nowiki>foo!!bar</nowiki></span>''
25842 |}
25843 !! html/php
25844 <table>
25845 <tr>
25846 <th>foo!!bar
25847 </th>
25848 <th><i>foo|bar</i>
25849 </th>
25850 <th><i>foo!!bar</i>
25851 </th>
25852 <th><i><span>foo!!bar</span></i>
25853 </th></tr></table>
25854
25855 !! end
25856
25857 !! test
25858 Tables: 3c. Nested in th
25859 !! options
25860 parsoid=html2wt
25861 !! html/parsoid
25862 <table><tbody>
25863 <tr><th>foo||bar</th>
25864 <th><span typeof="mw:Nowiki">foo||bar</span></th>
25865 </tr></tbody></table>
25866 !! wikitext
25867 {|
25868 !<nowiki>foo||bar</nowiki>
25869 !<nowiki>foo||bar</nowiki>
25870 |}
25871 !! html/php
25872 <table>
25873 <tr>
25874 <th>foo||bar
25875 </th>
25876 <th>foo||bar
25877 </th></tr></table>
25878
25879 !! end
25880
25881 !! test
25882 Tables: 4a. Escape -
25883 !! options
25884 parsoid=html2wt
25885 !! html/*
25886 <table>
25887 <tr>
25888 <th>-bar
25889 </th></tr>
25890 <tr>
25891 <td>-bar
25892 </td></tr></table>
25893
25894 !! wikitext
25895 {|
25896 !-bar
25897 |-
25898 |<nowiki>-bar</nowiki>
25899 |}
25900 !! end
25901
25902 !! test
25903 Tables: 4b. Escape +
25904 !! options
25905 parsoid=html2wt
25906 !! html/*
25907 <table>
25908 <tr>
25909 <th>+bar
25910 </th></tr>
25911 <tr>
25912 <td>+bar
25913 </td></tr></table>
25914
25915 !! wikitext
25916 {|
25917 !+bar
25918 |-
25919 |<nowiki>+bar</nowiki>
25920 |}
25921 !! end
25922
25923 !! test
25924 Tables: 4c. No escaping needed
25925 !! options
25926 parsoid=html2wt
25927 !! html/parsoid
25928 <table><tbody>
25929 <tr><td>foo-bar</td><td>foo+bar</td></tr>
25930 <tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
25931 <tr><td>foo
25932 <p>bar|baz
25933 +bar
25934 -bar</p></td></tr>
25935 <tr><td>x
25936 <div>a|b</div></td>
25937 </tbody></table>
25938 !! wikitext
25939 {|
25940 |foo-bar
25941 |foo+bar
25942 |-
25943 |''foo''-bar
25944 |''foo''+bar
25945 |-
25946 |foo
25947 bar|baz
25948 +bar
25949 -bar
25950 |-
25951 |x
25952 <div>a|b</div>
25953 |}
25954 !! html/php
25955 <table>
25956 <tr>
25957 <td>foo-bar
25958 </td>
25959 <td>foo+bar
25960 </td></tr>
25961 <tr>
25962 <td><i>foo</i>-bar
25963 </td>
25964 <td><i>foo</i>+bar
25965 </td></tr>
25966 <tr>
25967 <td>foo
25968 <p>bar|baz
25969 +bar
25970 -bar
25971 </p>
25972 </td></tr>
25973 <tr>
25974 <td>x
25975 <div>a|b</div>
25976 </td></tr></table>
25977
25978 !! end
25979
25980 !! test
25981 Tables: 4d. No escaping needed
25982 !! options
25983 parsoid=html2wt
25984 !! html/parsoid
25985 <table>
25986 <tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
25987 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
25988 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
25989 </tbody></table>
25990 !! wikitext
25991 {|
25992 |[[Foo]]-bar
25993 ||+1
25994 ||-2
25995 |}
25996 !! html/php
25997 <table>
25998 <tr>
25999 <td><a href="/wiki/Foo" title="Foo">Foo</a>-bar
26000 </td>
26001 <td>+1
26002 </td>
26003 <td>-2
26004 </td></tr></table>
26005
26006 !! end
26007
26008 !! test
26009 Tables: 5. Empty table cells should get whitespace to avoid need for nowikis
26010 !! options
26011 parsoid=html2wt
26012 !! html/parsoid
26013 <table><tr><td></td><td align="center" data-parsoid='{"stx":"row"}'></td><td data-parsoid='{"stx":"row"}'></td></tr></table>
26014
26015 <table><tr><td></td><td align="center"></td><td></td></tr></table>
26016
26017 <table><tr><td></td><td align="center" data-parsoid='{"stx":"row", "startTagSrc":"{{!}}{{!}}"}'></td><td data-parsoid='{"stx":"row"}'></td></tr></table>
26018
26019 <table><tr><th></th><th align="center" data-parsoid='{"stx":"row"}'></th><th data-parsoid='{"stx":"row"}'></th></tr></table>
26020 !! wikitext
26021 {|
26022 | || align="center" | ||
26023 |}
26024
26025 {|
26026 |
26027 | align="center" |
26028 |
26029 |}
26030
26031 {|
26032 | {{!}}{{!}} align="center" | ||
26033 |}
26034
26035 {|
26036 ! !! align="center" | !!
26037 |}
26038 !! html/php+tidy
26039 <table>
26040 <tbody><tr>
26041 <td></td>
26042 <td align="center"></td>
26043 <td>
26044 </td></tr></tbody></table>
26045 <table>
26046 <tbody><tr>
26047 <td>
26048 </td>
26049 <td align="center">
26050 </td>
26051 <td>
26052 </td></tr></tbody></table>
26053 <table>
26054 <tbody><tr>
26055 <td></td>
26056 <td align="center"></td>
26057 <td>
26058 </td></tr></tbody></table>
26059 <table>
26060 <tbody><tr>
26061 <th></th>
26062 <th align="center"></th>
26063 <th>
26064 </th></tr></tbody></table>
26065 !! end
26066
26067 !! test
26068 T97430: Don't emit empty nowiki pairs around marker meta tags
26069 !! options
26070 parsoid=html2wt
26071 !! html/parsoid
26072 <p>*This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
26073 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
26074 !! wikitext
26075 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
26076 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
26077 !! end
26078
26079 !! test
26080 Unclosed xmlish element in table line shouldn't eat end delimiters
26081 !! options
26082 parsoid=html2wt
26083 !! html/parsoid
26084 <table>
26085 <tbody><tr><td> &lt;foo</td>
26086 <td> bar></td></tr>
26087 </tbody></table>
26088 !! wikitext
26089 {|
26090 | <foo
26091 | bar>
26092 |}
26093 !! html/php
26094 <table>
26095 <tr>
26096 <td>&lt;foo
26097 </td>
26098 <td>bar&gt;
26099 </td></tr></table>
26100
26101 !! end
26102
26103 #### --------------- Links ----------------
26104 #### 1. Quote marks in link text
26105 #### 2. Wikilinks: Escapes needed
26106 #### 3. Wikilinks: No escapes needed
26107 #### 4. Extlinks: Escapes needed
26108 #### 5. Extlinks: No escapes needed
26109 #### --------------------------------------
26110 !! test
26111 Links 1. WikiLinks: No escapes needed
26112 !! options
26113 parsoid=html2wt
26114 !! html/parsoid
26115 <p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
26116 <a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
26117 <a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
26118 !! wikitext
26119 [[Foo|Foo''boo'']]
26120 [[Foo|[Foobar]]]
26121 [[Foo|x [Foobar] x]]
26122 !! html/php
26123 <p><a href="/wiki/Foo" title="Foo">Foo<i>boo</i></a>
26124 <a href="/wiki/Foo" title="Foo">[Foobar]</a>
26125 <a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
26126 </p>
26127 !! end
26128
26129 !! test
26130 Links 2. WikiLinks: Escapes needed
26131 !! options
26132 parsoid=html2wt
26133 !! html/parsoid
26134 <a href="Foo" rel="mw:WikiLink">Foobar]</a>
26135 <a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
26136 <a href="Foo" rel="mw:WikiLink">[[Bar]]</a>
26137 <a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a>
26138 <a href="Foo" rel="mw:WikiLink">|Bar</a>
26139 <a href="Foo" rel="mw:WikiLink">]]bar</a>
26140 <a href="Foo" rel="mw:WikiLink">[[bar</a>
26141 <a href="Foo" rel="mw:WikiLink">x [[ y</a>
26142 <a href="Foo" rel="mw:WikiLink">x ]] y</a>
26143 <a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a>
26144 !! wikitext
26145 [[Foo|<nowiki>Foobar]</nowiki>]]
26146 [[Foo|x <nowiki>[http://google.com g]</nowiki> x]]
26147 [[Foo|<nowiki>[[Bar]]</nowiki>]]
26148 [[Foo|<nowiki>x [[Bar]] x</nowiki>]]
26149 [[Foo|<nowiki>|Bar</nowiki>]]
26150 [[Foo|<nowiki>]]bar</nowiki>]]
26151 [[Foo|<nowiki>[[bar</nowiki>]]
26152 [[Foo|<nowiki>x [[ y</nowiki>]]
26153 [[Foo|<nowiki>x ]] y</nowiki>]]
26154 [[Foo|<nowiki>x ]] y [[ z</nowiki>]]
26155 !! html/php
26156 <p><a href="/wiki/Foo" title="Foo">Foobar]</a>
26157 <a href="/wiki/Foo" title="Foo">x [http://google.com g] x</a>
26158 <a href="/wiki/Foo" title="Foo">[[Bar]]</a>
26159 <a href="/wiki/Foo" title="Foo">x [[Bar]] x</a>
26160 <a href="/wiki/Foo" title="Foo">|Bar</a>
26161 <a href="/wiki/Foo" title="Foo">]]bar</a>
26162 <a href="/wiki/Foo" title="Foo">[[bar</a>
26163 <a href="/wiki/Foo" title="Foo">x [[ y</a>
26164 <a href="/wiki/Foo" title="Foo">x ]] y</a>
26165 <a href="/wiki/Foo" title="Foo">x ]] y [[ z</a>
26166 </p>
26167 !! end
26168
26169 !! test
26170 Links 3. WikiLinks: No escapes needed
26171 !! options
26172 parsoid=html2wt
26173 !! html/parsoid
26174 <p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
26175 <a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
26176 !! wikitext
26177 [[Foo|[Foobar]]
26178 [[Foo|foo|bar]]
26179 !! html/php
26180 <p><a href="/wiki/Foo" title="Foo">[Foobar</a>
26181 <a href="/wiki/Foo" title="Foo">foo|bar</a>
26182 </p>
26183 !! end
26184
26185 !! test
26186 Links 4. ExtLinks: Escapes needed
26187 !! options
26188 parsoid=html2wt
26189 !! html/parsoid
26190 <p><a rel="mw:ExtLink" href="http://google.com">[google]</a>
26191 <a rel="mw:ExtLink" href="http://google.com">google]</a>
26192 <a rel="mw:ExtLink" href="http://google.com">goog] le</a></p>
26193 <p>[http://google.com]</p>
26194 <p>[http://google.com google]</p>
26195 <p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p>
26196 <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>
26197 !! wikitext
26198 [http://google.com <nowiki>[google]</nowiki>]
26199 [http://google.com <nowiki>google]</nowiki>]
26200 [http://google.com <nowiki>goog] le</nowiki>]
26201
26202 <nowiki>[http://google.com]</nowiki>
26203
26204 <nowiki>[http://google.com google]</nowiki>
26205
26206 [http://google.com<nowiki>]</nowiki>
26207
26208 [{{echo|http://google.com}}<nowiki>]</nowiki>
26209 !! html/php
26210 <p><a rel="nofollow" class="external text" href="http://google.com">[google]</a>
26211 <a rel="nofollow" class="external text" href="http://google.com">google]</a>
26212 <a rel="nofollow" class="external text" href="http://google.com">goog] le</a>
26213 </p><p>[http://google.com]
26214 </p><p>[http://google.com google]
26215 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
26216 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
26217 </p>
26218 !! end
26219
26220 !! test
26221 Links 5. ExtLinks: No escapes needed
26222 !! options
26223 parsoid=html2wt
26224 !! html/parsoid
26225 <p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
26226 <p>[<a ref="mw:ExtLink" href="http://google.com"></a>]</p>
26227 !! wikitext
26228 [http://google.com [google]
26229
26230 [[http://google.com]]
26231 !! html/php
26232 <p><a rel="nofollow" class="external text" href="http://google.com">[google</a>
26233 </p><p>[<a rel="nofollow" class="external autonumber" href="http://google.com">[1]</a>]
26234 </p>
26235 !! end
26236
26237 !! test
26238 Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300)
26239 !! options
26240 parsoid=html2wt
26241 !! html/parsoid
26242 <p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y
26243 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>?x
26244 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>&amp;x
26245 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>'x
26246 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,x
26247 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.x
26248 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
26249 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>:x
26250 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
26251 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>!x
26252 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>=x
26253 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>(x)
26254 <a rel="mw:ExtLink" href="http://example.com(x" data-parsoid='{"stx":"url"}'>http://example.com(x</a>)
26255 </p>
26256 !! wikitext
26257 x<nowiki/>http://example.com<nowiki/>y
26258 http://example.com<nowiki/>?x
26259 http://example.com<nowiki/>&x
26260 http://example.com<nowiki/>'x
26261 http://example.com<nowiki/>,x
26262 http://example.com<nowiki/>.x
26263 http://example.com<nowiki/>;x
26264 http://example.com<nowiki/>:x
26265 http://example.com<nowiki/>;x
26266 http://example.com<nowiki/>!x
26267 http://example.com<nowiki/>=x
26268 http://example.com<nowiki/>(x)
26269 http://example.com(x<nowiki/>)
26270 !! end
26271
26272 !! test
26273 Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
26274 !! options
26275 parsoid=html2wt
26276 !! html/parsoid
26277 <p>x
26278 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>
26279 y
26280 "<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>"
26281 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>)
26282 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>) foo
26283 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,
26284 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, foo
26285 </p>
26286 !! wikitext
26287 x
26288 http://example.com
26289 y
26290 "http://example.com"
26291 (http://example.com)
26292 (http://example.com) foo
26293 http://example.com,
26294 http://example.com, foo
26295 !! html/php
26296 <p>x
26297 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
26298 y
26299 "<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>"
26300 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
26301 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) foo
26302 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
26303 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, foo
26304 </p>
26305 !! end
26306
26307 !! test
26308 Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
26309 !! options
26310 parsoid=html2wt
26311 !! html/parsoid
26312 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\
26313 -<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p>
26314 !! wikitext
26315 http://example.com.,;:!?\
26316 -http://example.com:
26317 !! html/php
26318 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.,;:!?\
26319 -<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
26320 </p>
26321 !! end
26322
26323 !! test
26324 Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
26325 !! options
26326 parsoid=html2wt
26327 !! html/parsoid
26328 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
26329 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
26330 X<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
26331 !! wikitext
26332 RFC 123<nowiki/>4
26333 RFC 123<nowiki/>y
26334 X<nowiki/>RFC 123<nowiki/>y
26335 !! end
26336
26337 !! test
26338 Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
26339 !! options
26340 parsoid=html2wt
26341 !! html/parsoid
26342 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
26343 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
26344 -<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
26345 </p>
26346 !! wikitext
26347 RFC 123?foo
26348 RFC 123&foo
26349 -RFC 123-
26350 !! html/php
26351 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>?foo
26352 <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
26353 -<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>-
26354 </p>
26355 !! end
26356
26357 !! test
26358 Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300)
26359 !! options
26360 parsoid=html2wt
26361 !! html/parsoid
26362 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4
26363 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
26364 X<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
26365 !! wikitext
26366 PMID 123<nowiki/>4
26367 PMID 123<nowiki/>y
26368 X<nowiki/>PMID 123<nowiki/>y
26369 !! end
26370
26371 !! test
26372 Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300)
26373 !! options
26374 parsoid=html2wt
26375 !! html/parsoid
26376 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo
26377 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo
26378 -<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>-
26379 </p>
26380 !! wikitext
26381 PMID 123?foo
26382 PMID 123&foo
26383 -PMID 123-
26384 !! html/php
26385 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>?foo
26386 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>&amp;foo
26387 -<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>-
26388 </p>
26389 !! end
26390
26391 !! test
26392 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300)
26393 !! options
26394 parsoid=html2wt
26395 !! html/parsoid
26396 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
26397 <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
26398 a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
26399 </p>
26400 !! wikitext
26401 ISBN 1234567890<nowiki/>1
26402 ISBN 1234567890<nowiki/>x
26403 a<nowiki/>ISBN 1234567890<nowiki/>b
26404 !! end
26405
26406 !! test
26407 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (T66300)
26408 !! options
26409 parsoid=html2wt
26410 !! html/parsoid
26411 <p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
26412 !! wikitext
26413 -ISBN 1234567890's
26414 !! html/php
26415 <p>-<a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>'s
26416 </p>
26417 !! end
26418
26419 !! test
26420 Links 14. Protect link-like plain text. (Parsoid bug T78425)
26421 !! options
26422 parsoid=html2wt
26423 !! html/*
26424 <p>this is not a link: http://example.com
26425 </p>
26426 !! wikitext
26427 this is not a link: <nowiki>http://example.com</nowiki>
26428 !! end
26429
26430 !! test
26431 Links 15. Link trails can't become link prefixes.
26432 !! options
26433 language=is
26434 parsoid=html2wt
26435 !! html/parsoid
26436 <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>
26437 !! wikitext
26438 [[Söfnuður]]-[[00]]
26439 !! html/php
26440 <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>
26441 </p>
26442 !! end
26443
26444 #### --------------- Quotes ---------------
26445 #### 1. Quotes inside <b> and <i>
26446 #### 2. Link fragments separated by <i> and <b> tags
26447 #### 3. Link fragments inside <i> and <b>
26448 #### 4. No escaping needed
26449 #### --------------------------------------
26450 !! test
26451 1a. Quotes inside <b> and <i>
26452 !! options
26453 parsoid=html2wt
26454 !! html/*
26455 <p><i>'foo'</i>
26456 <i>''foo''</i>
26457 <i>'''foo'''</i>
26458 <i>foo</i>'s
26459 <b>'foo'</b>
26460 <b>''foo''</b>
26461 <b>'''foo'''</b>
26462 <b>foo'<i>bar'</i>baz</b>
26463 <b>foo</b>'s
26464 '<i>foo</i>
26465 <i>foo</i>'
26466 <i>foo'</i>'
26467 '<i>foo</i>'
26468 '<b>foo</b>
26469 <b>foo</b>'
26470 '<b>foo</b>'
26471 <i>fools'<span> errand</span></i>
26472 <i><span>fool</span>'s errand</i>
26473 '<i>foo</i> bar '<i>baz</i>
26474 a|!*#-:;+-~[]{}b'<i>x</i>
26475 </p>
26476 !! wikitext
26477 ''<nowiki/>'foo'''
26478 ''<nowiki>''foo''</nowiki>''
26479 ''<nowiki>'''foo'''</nowiki>''
26480 ''foo''<nowiki/>'s
26481 '''<nowiki/>'foo''''
26482 '''<nowiki>''foo''</nowiki>'''
26483 '''<nowiki>'''foo'''</nowiki>'''
26484 '''foo'<nowiki/>''bar'<nowiki/>''baz'''
26485 '''foo'''<nowiki/>'s
26486 '''foo''
26487 ''foo''<nowiki/>'
26488 ''foo'''<nowiki/>'
26489 '''foo''<nowiki/>'
26490 ''''foo'''
26491 '''foo'''<nowiki/>'
26492 ''''foo'''<nowiki/>'
26493 ''fools'<span> errand</span>''
26494 ''<span>fool</span>'s errand''
26495 '<nowiki/>''foo'' bar '''baz''
26496 a|!*#-:;+-~[]{}b'''x''
26497 !! end
26498
26499 !! test
26500 1b. Quotes inside <b> and <i> with other tags on same line
26501 !! options
26502 parsoid=html2wt
26503 !! html/parsoid
26504 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
26505 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
26506 <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>
26507 <a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" rel="mw:WikiLink" title="Bar">bar</a></i>
26508 '<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>
26509 '<i>foo</i> <div title="name">test</div>
26510 '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
26511 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
26512 <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>
26513 </ol>
26514 !! wikitext
26515 '''a'' foo ''[[bar]]''
26516 ''a''' foo ''[[bar]]''
26517 ''a''' foo '''{{echo|[[bar]]}}'''
26518 [[foo]] x'''[[bar]]''
26519 '''foo'' <ref>test</ref>
26520 '''foo'' <div title="name">test</div>
26521 '''foo'' and <br> bar
26522 <references />
26523 !! end
26524
26525 !! test
26526 2. Link fragments separated by <i> and <b> tags
26527 !! options
26528 parsoid=html2wt
26529 !! html/parsoid
26530 <p>[[<i>foo</i>hello]]</p>
26531 <p>[[<b>foo</b>hello]]</p>
26532 !! wikitext
26533 [[''foo''<nowiki>hello]]</nowiki>
26534
26535 [['''foo'''<nowiki>hello]]</nowiki>
26536 !! end
26537
26538 # FIXME: Escaping one or both of [[ and ]] is also acceptable --
26539 # this is one of the shortcomings of this format
26540 !! test
26541 3. Link fragments inside <i> and <b>
26542 !! options
26543 parsoid=html2wt
26544 !! html/parsoid
26545 <p><i>[[foo</i>]]</p>
26546 <p><b>[[foo</b>]]</p>
26547 !! wikitext
26548 ''[[foo''<nowiki>]]</nowiki>
26549
26550 '''[[foo'''<nowiki>]]</nowiki>
26551 !! end
26552
26553 !! test
26554 4. No escaping needed
26555 !! options
26556 parsoid=html2wt
26557 !! html/parsoid
26558 <p>'<span><i>bar</i></span>'
26559 '<span><b>bar</b></span>'
26560 'a:b'foo
26561 </p>
26562 !! wikitext
26563 '<span>''bar''</span>'
26564 '<span>'''bar'''</span>'
26565 'a:b'foo
26566 !! end
26567
26568 #### ----------- Paragraphs ---------------
26569 #### 1. No unnecessary escapes
26570 #### --------------------------------------
26571
26572 !! test
26573 1. No unnecessary escapes
26574 !! options
26575 parsoid=html2wt
26576 !! html/parsoid
26577 <p>bar <span>[[foo]]</span>
26578 </p><p>=bar <span>[[foo]]</span>
26579 </p><p>[[bar <span>[[foo]]</span>
26580 </p><p>]]bar <span>[[foo]]</span>
26581 </p><p>=bar <span>foo]]</span>=
26582 </p>
26583 !! wikitext
26584 bar <span><nowiki>[[foo]]</nowiki></span>
26585
26586 =bar <span><nowiki>[[foo]]</nowiki></span>
26587
26588 [[bar <span><nowiki>[[foo]]</nowiki></span>
26589
26590 ]]bar <span><nowiki>[[foo]]</nowiki></span>
26591
26592 =bar <span>foo]]</span><nowiki>=</nowiki>
26593 !!end
26594
26595 #### ----------------------- PRE --------------------------
26596 !! test
26597 1. Leading whitespace in SOL context should be escaped
26598 !! options
26599 parsoid=html2wt
26600 !! html/parsoid
26601 <p> a</p>
26602
26603 <p> a</p>
26604
26605 <p> a(tab)</p>
26606
26607 <p> a
26608 <!--cmt-->
26609 a</p>
26610
26611 <p>a
26612 b</p>
26613
26614 <p>a
26615 b</p>
26616
26617 <p>a
26618 b</p>
26619 !! wikitext
26620 <nowiki> </nowiki>a
26621
26622 <nowiki> </nowiki> a
26623
26624 a(tab)
26625
26626 <nowiki> </nowiki> a
26627 <!--cmt-->
26628 <nowiki> </nowiki>a
26629
26630 a
26631 <nowiki> </nowiki>b
26632
26633 a
26634 b
26635
26636 a
26637 b
26638 !! html/php
26639 <p> a
26640 </p><p> a
26641 </p><p> a(tab)
26642 </p><p> a
26643 a
26644 </p><p>a
26645 b
26646 </p><p>a
26647 b
26648 </p><p>a
26649 b
26650 </p>
26651 !! end
26652
26653 !! test
26654 2. Leading whitespace in non-indent-pre contexts should not be escaped
26655 !! options
26656 parsoid=html2wt
26657 !! html/parsoid
26658 <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>
26659 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
26660 <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>
26661 b</span></li>
26662 </ol>
26663 !! wikitext
26664 foo <ref>''a''
26665 b</ref>
26666 <references />
26667 !! end
26668
26669 !! test
26670 3. Leading whitespace in indent-pre suppressing contexts should not be escaped
26671 !! options
26672 parsoid=html2wt
26673 !! html/parsoid
26674 <blockquote>
26675 <p>
26676 a
26677 <span>b</span>
26678 c</p>
26679 </blockquote>
26680 !! wikitext
26681 <blockquote>
26682 a
26683 <span>b</span>
26684 c
26685 </blockquote>
26686 !! end
26687
26688 !! test
26689 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
26690 !! options
26691 parsoid=html2wt
26692 !! html/parsoid
26693 <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>
26694 !! wikitext
26695 [[File:Foobar.jpg|thumb|caption]]
26696 !! end
26697
26698 !! test
26699 5. Nowiki escaping should account for indent-pres
26700 !! options
26701 parsoid=html2wt
26702 !! html/parsoid
26703 <pre>==foo==</pre>
26704 !! wikitext
26705 ==foo==
26706 !! end
26707
26708 !! test
26709 T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
26710 !! options
26711 parsoid=html2wt
26712 !! html/parsoid
26713 <pre>
26714 * foo
26715 * bar
26716 </pre>
26717 !! wikitext
26718 * foo
26719 * bar
26720 !! end
26721
26722 !! test
26723 Whitespace scrubbing in SOL position should account for SOL-sensitive wikitext markup
26724 !! options
26725 parsoid = {
26726 "modes": ["html2wt"],
26727 "scrubWikitext": true
26728 }
26729 !! html/parsoid
26730 <p> foo</p>
26731 <p> %foo</p>
26732 <p> *foo</p>
26733 <p> #foo</p>
26734 <p> =foo=</p>
26735 <p><link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid="{}"> *foo</p>
26736 <p> <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid="{}">*foo</p>
26737 <p> <!--boo-->*foo</p>
26738 <p><!--boo--> *foo</p>
26739 <p><!--a--> <!--b--> <!--c--> <!--d--> <!--e--> foo</p>
26740 <p><!--a--> <!--b--> <!--c--> <!--d--> <!--e--> *foo</p>
26741 !! wikitext
26742 foo
26743
26744 %foo
26745
26746 <nowiki/>*foo
26747
26748 <nowiki/>#foo
26749
26750 <nowiki/>=foo=
26751
26752 [[Category:Foo]]
26753 <nowiki/>*foo
26754
26755 [[Category:Foo]]
26756 <nowiki>*</nowiki>foo
26757
26758 <nowiki/><!--boo-->*foo
26759
26760 <!--boo--><nowiki/>*foo
26761
26762 <!--a--><!--b--><!--c--><!--d--><!--e-->foo
26763
26764 <!--a--><nowiki/><!--b--><!--c--><!--d--><!--e-->*foo
26765 !! end
26766
26767 #### --------------- Behavior Switches --------------------
26768
26769 !! test
26770 1. Valid behavior switches should be escaped
26771 !! options
26772 parsoid=html2wt
26773 !! html/parsoid
26774 __TOC__
26775 <i>__TOC__</i>
26776 !! wikitext
26777 <nowiki>__TOC__</nowiki>
26778 ''<nowiki>__TOC__</nowiki>''
26779 !! end
26780
26781 !! test
26782 2. Invalid behavior switches should not be escaped
26783 !! options
26784 parsoid=html2wt
26785 !! html/parsoid
26786 __TOO__
26787 __|__
26788 !! wikitext
26789 __TOO__
26790 __|__
26791 !! end
26792
26793 # We use indent-pre as an indirect way to test for sol-transparent behavior.
26794 !! test
26795 Behavior switches should be SOL-transparent
26796 !! options
26797 parsoid=html2wt
26798 !! html/parsoid
26799 <meta property="mw:PageProp/toc" />
26800
26801 <!-- this one's bogus -->
26802 <pre>__TOO__</pre>
26803
26804 <pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre>
26805
26806 <meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre>
26807 !! wikitext
26808 __TOC__
26809
26810 <!-- this one's bogus -->
26811 __TOO__
26812
26813 __TOC__ foo
26814
26815 __TOC__
26816 bar
26817 !! end
26818
26819 #### --------------- HTML tags ---------------
26820 #### 1. a tags
26821 #### 2. other tags
26822 #### 3. multi-line html tag
26823 #### 4. extension tags
26824 #### -----------------------------------------
26825 !! test
26826 1. a tags
26827 !! options
26828 parsoid=html2wt
26829 !! html/parsoid
26830 &lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
26831 !! wikitext
26832 <a href="http://google.com">google</a>
26833 !! end
26834
26835 !! test
26836 2. other tags
26837 !! options
26838 parsoid=html2wt
26839 !! html/parsoid
26840 <ul><li> &lt;div&gt;foo&lt;/div&gt;</li>
26841 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
26842 <li> &lt;td&gt;</li></ul>
26843
26844 !! wikitext
26845 * <nowiki><div>foo</div></nowiki>
26846 * <nowiki><div style="color:red">foo</div></nowiki>
26847 * <nowiki><td></nowiki>
26848 !! end
26849
26850 !! test
26851 3. multi-line html tag
26852 !! options
26853 parsoid=html2wt
26854 !! html/parsoid
26855 <p>&lt;div
26856 &gt;foo&lt;/div
26857 &gt;
26858 </p>
26859 !! wikitext
26860 <nowiki><div
26861 >foo</div
26862 ></nowiki>
26863 !! end
26864
26865 !! test
26866 4. extension tags
26867 !! options
26868 parsoid=html2wt
26869 !! html/parsoid
26870 <p>&lt;ref&gt;foo&lt;/ref&gt;
26871 </p><p>&lt;ref&gt;bar
26872 </p><p>baz&lt;/ref&gt;
26873 </p>
26874 !! wikitext
26875 <nowiki><ref>foo</ref></nowiki>
26876
26877 <nowiki><ref>bar</nowiki>
26878
26879 baz<nowiki></ref></nowiki>
26880 !! end
26881
26882 !! test
26883 Parsoid: newline inducing block nodes don't suppress <nowiki>
26884 !! options
26885 parsoid=html2wt
26886 !! html/parsoid
26887 a<h1>foo</h1>
26888 !! wikitext
26889 <nowiki> </nowiki>a
26890
26891 = foo =
26892 !! end
26893
26894 #### --------------- Others ---------------
26895 !! test
26896 Escaping nowikis
26897 !! options
26898 parsoid=html2wt
26899 !! html/parsoid
26900 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
26901 </p>
26902 !! wikitext
26903 &lt;nowiki&gt;foo&lt;/nowiki&gt;
26904 !! end
26905
26906 ## The quote-char in the input is necessary for triggering the bug
26907 !! test
26908 (T54035) Nowiki-escaping should not get tripped by " :" in text
26909 !! options
26910 parsoid=html2wt
26911 !! html/parsoid
26912 <p>foo's bar :</p>
26913 !! wikitext
26914 foo's bar :
26915 !! end
26916
26917 #----------- End of wikitext escaping tests --------------
26918
26919 !! test
26920
26921 Tag-like HTML structures are passed through as text
26922 !! wikitext
26923 <x y>
26924
26925 <x.y>
26926
26927 <x-y>
26928
26929 1>2
26930
26931 x<y
26932
26933 a>b
26934
26935 1<d e>f
26936 !! html
26937 <p>&lt;x y&gt;
26938 </p><p>&lt;x.y&gt;
26939 </p><p>&lt;x-y&gt;
26940 </p><p>1&gt;2
26941 </p><p>x&lt;y
26942 </p><p>a&gt;b
26943 </p><p>1&lt;d e&gt;f
26944 </p>
26945 !! end
26946
26947 !! test
26948 HTML tag with necessary entities in attributes
26949 !! wikitext
26950 <span title="&amp;amp;">foo</span>
26951 !! html
26952 <p><span title="&amp;amp;">foo</span>
26953 </p>
26954 !! end
26955
26956 !! test
26957 HTML tag with 'unnecessary' entity encoding in attributes
26958 !! wikitext
26959 <span title="&amp;">foo</span>
26960 !! html
26961 <p><span title="&amp;">foo</span>
26962 </p>
26963 !! end
26964
26965 !! test
26966 HTML tag with broken attribute value quoting
26967 !! options
26968 parsoid=wt2html,html2html
26969 !! wikitext
26970 <span title="Hello world>Foo</span>
26971 !! html/php
26972 <p><span title="Hello world">Foo</span>
26973 </p>
26974 !! html/parsoid
26975 <p><span title="Hello world">Foo</span></p>
26976 !! end
26977
26978 !! test
26979 Self-closed tag with broken attribute value quoting
26980 !! options
26981 parsoid=wt2html,html2html
26982 !! wikitext
26983 <div title="Hello world />Foo
26984 !! html/php+tidy
26985 <div title="Hello world"></div><p>Foo
26986 </p>
26987 !! html/parsoid
26988 <div title="Hello world " data-parsoid='{"stx":"html","selfClose":true}'></div><p>Foo</p>
26989 !! end
26990
26991 !! test
26992 Table with broken attribute value quoting
26993 !! options
26994 parsoid=wt2html,html2html
26995 !! wikitext
26996 {|
26997 | title="Hello world|Foo
26998 |}
26999 !! html/php
27000 <table>
27001 <tr>
27002 <td title="Hello world">Foo
27003 </td></tr></table>
27004
27005 !! html/parsoid
27006 <table>
27007 <tr>
27008 <td title="Hello world">Foo
27009 </td></tr></table>
27010
27011 !! end
27012
27013 !! test
27014 Table with broken attribute value quoting on consecutive lines
27015 !! options
27016 parsoid=wt2html,html2html
27017 !! wikitext
27018 {|
27019 | title="Hello world|Foo
27020 | style="color:red|Bar
27021 |}
27022 !! html/php
27023 <table>
27024 <tr>
27025 <td title="Hello world">Foo
27026 </td>
27027 <td style="color:red">Bar
27028 </td></tr></table>
27029
27030 !! html/parsoid
27031 <table><tbody>
27032 <tr>
27033 <td title="Hello world">Foo
27034 </td><td style="color: red">Bar
27035 </td></tr></tbody></table>
27036
27037 !! end
27038
27039 !!test
27040 Accept empty td cell attribute
27041 !! wikitext
27042 {|
27043 | align="center" |foo|| |
27044 |}
27045 !! html
27046 <table>
27047 <tr>
27048 <td align="center">foo</td>
27049 <td>
27050 </td></tr></table>
27051
27052 !!end
27053
27054 !!test
27055 Non-empty attributes in th-cells
27056 !! wikitext
27057 {|
27058 !Foo!! style="color: red" |Bar
27059 |}
27060 !! html
27061 <table>
27062 <tr>
27063 <th>Foo</th>
27064 <th style="color: red">Bar
27065 </th></tr></table>
27066
27067 !!end
27068
27069 !!test
27070 Accept empty attributes in th-cells
27071 !! wikitext
27072 {|
27073 !|foo!!|bar
27074 |}
27075 !! html
27076 <table>
27077 <tr>
27078 <th>foo</th>
27079 <th>bar
27080 </th></tr></table>
27081
27082 !!end
27083
27084 !!test
27085 Empty table rows go away
27086 !! wikitext
27087 {|
27088 |Hello
27089 |there
27090 |- class="foo"
27091 |-
27092 |}
27093 !! html
27094 <table>
27095 <tr>
27096 <td>Hello
27097 </td>
27098 <td>there
27099 </td></tr>
27100
27101 </table>
27102
27103 !! end
27104
27105 ###
27106 ### Parsoid-centric tests for testing RTing of inter-element separators
27107 ### Edge cases not tested by existing parser tests and specific to
27108 ### Parsoid-specific serialization strategies.
27109 ###
27110
27111 !!test
27112 RT-ed inter-element separators should be valid separators
27113 !! wikitext
27114 {|
27115 |- [[foo]]
27116 |}
27117 !! html/php
27118 <table>
27119
27120 </table>
27121
27122 !! html/parsoid
27123 <table>
27124 <tbody><tr class='mw-empty-elt' data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
27125 </tbody></table>
27126 !!end
27127
27128 # Parsoid-only test of a DOM pass
27129 !!test
27130 Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out
27131 !! wikitext
27132 {|
27133 |<small>foo
27134 bar
27135 |}
27136
27137 {|
27138 |<small>foo<small>
27139 |}
27140 !! html/parsoid
27141 <table>
27142 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo
27143 <p>bar</p></small></td></tr>
27144 </tbody></table>
27145
27146 <table>
27147 <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>
27148 </tbody></table>
27149 !!end
27150
27151 # Note that the "style" attribute is really a template parameter here.
27152 # The = would have to be {{=}} if you wanted the literal.
27153 !!test
27154 Empty TD followed by TD with tpl-generated attribute
27155 !! wikitext
27156 {|
27157 |-
27158 |
27159 |{{echo|style='color:red'}}|foo
27160 |}
27161 !! html
27162 <table>
27163
27164 <tr>
27165 <td>
27166 </td>
27167 <td>foo
27168 </td></tr></table>
27169
27170 !!end
27171
27172 !!test
27173 Indented table with an empty td
27174 !! wikitext
27175 {|
27176 |-
27177 |
27178 |foo
27179 |}
27180 !! html
27181 <table>
27182
27183 <tr>
27184 <td>
27185 </td>
27186 <td>foo
27187 </td></tr></table>
27188
27189 !!end
27190
27191 ## We have some newline diffs RT-ing this edge case
27192 ## and it is not important enough -- we seem to be emitting
27193 ## at most 2 newlines after a </tr> and this is unrelated to
27194 ## the issue from T85627 that this is testing.
27195 !!test
27196 Indented table with blank lines in between (T85627)
27197 !! options
27198 parsoid=wt2html
27199 !! wikitext
27200 {|
27201 |foo
27202
27203
27204 |}
27205 !! html
27206 <table>
27207
27208 <tr>
27209 <td>foo
27210 </td></tr></table>
27211
27212 !!end
27213
27214 !!test
27215 Indented block & table
27216 !! wikitext
27217 <div>foo</div>
27218 {|
27219 |foo
27220 |}
27221 !! html/php
27222 <div>foo</div>
27223 <table>
27224 <tr>
27225 <td>foo
27226 </td></tr></table>
27227
27228 !! html/parsoid
27229 <div data-parsoid='{"stx":"html"}'>foo</div>
27230 <table><tbody>
27231 <tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>foo</td></tr>
27232 </tbody></table>
27233 !!end
27234
27235 !! test
27236 Indent and comment before table row
27237 !! wikitext
27238 {|
27239 <!--hi-->|-
27240 |there
27241 |}
27242 !! html/php
27243 <table>
27244
27245 <tr>
27246 <td>there
27247 </td></tr></table>
27248
27249 !! html/parsoid
27250 <table>
27251 <!--hi--><tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
27252 <td data-parsoid='{"autoInsertedEnd":true}'> there</td></tr>
27253 </tbody></table>
27254 !! end
27255
27256 # Parsoid-specific since PHP parser doesn't handle this mixed tbl-wikitext
27257 !!test
27258 Empty TR followed by a template-generated TR
27259 !!options
27260 parsoid
27261 !! wikitext
27262 {|
27263 |-
27264 {{echo|<tr><td>foo</td></tr>}}
27265 |}
27266 !! html
27267 <table>
27268 <tbody>
27269 <tr class='mw-empty-elt'></tr>
27270 <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}}]}'>
27271 <td>foo</td></tr>
27272 </tbody></table>
27273 !!end
27274
27275 ## PHP and parsoid output differ for this, and since this is primarily
27276 ## for testing Parsoid's serializer, marking this Parsoid only
27277 !!test
27278 Empty TR followed by mixed-ws-comment line should RT correctly
27279 !!options
27280 parsoid
27281 !! wikitext
27282 {|
27283 |-
27284 <!--c-->
27285 |-
27286 <!--c--> <!--d-->
27287 |}
27288 !! html
27289 <table>
27290 <tbody>
27291 <tr class='mw-empty-elt'></tr>
27292 <!--c-->
27293 <tr>
27294 <!--c--> </tr><!--d-->
27295 </tbody></table>
27296
27297 !!end
27298
27299 !!test
27300 Multi-line image caption generated by templates with/without trailing newlines
27301 !! wikitext
27302 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]]
27303 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]]
27304 !! html/parsoid
27305 <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>
27306 <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>
27307 !!end
27308
27309 !! test
27310 New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly
27311 !! options
27312 parsoid=html2wt
27313 !! html/parsoid
27314 <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>
27315
27316 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{}'/><h1>new heading</h1>
27317 !! wikitext
27318 <includeonly>foo</includeonly>
27319 new para
27320
27321 [[Category:Foo]]
27322
27323 = new heading =
27324 !! end
27325
27326 ## PHP emits broken html for this, and since this is primarily
27327 ## a Parsoid serializer test, marking this Parsoid only
27328 !!test
27329 Improperly nested inline or quotes tags with whitespace in between
27330 !! wikitext
27331 <span> <s>x</span> </s>
27332 ''' ''x''' ''
27333 !! html/parsoid
27334 <p><span> <s>x</s></span><s> </s>
27335 <b> <i>x</i></b><i> </i>
27336 </p>
27337 !!end
27338
27339 !!test
27340 Encapsulate protected attributes from wt
27341 !! wikitext
27342 <div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
27343
27344 {| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true"
27345 |ok
27346 |}
27347 !! html/parsoid
27348 <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>
27349
27350 <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">
27351 <tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'>ok</td></tr>
27352 </tbody></table>
27353 !!end
27354
27355 ## Currently the p-wrapper is fragile in how it adds / removes transformations.
27356 ## Having nested or stray pre tags results in the attempt to add duplicates,
27357 ## causing an assertion fail. This test tries to prevent that situation.
27358 !!test
27359 Ensure ParagraphWrapper can deal with stray closing pre tags
27360 !!options
27361 parsoid=wt2html
27362 !! wikitext
27363 plain text</pre>
27364 !! html/parsoid
27365 plain text
27366 !!end
27367
27368 !! test
27369 1. Ensure fostered text content is wrapped in element nodes
27370 !! options
27371 parsoid=wt2html
27372 !! wikitext
27373 <table>hi</table><table>ho</table>
27374 !! html/php+tidy
27375 hi<table></table>ho<table></table>
27376 !! html/parsoid
27377 <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>
27378 !! end
27379
27380 !! test
27381 2. Ensure fostered text content is wrapped in element nodes (traps regressions around fostered marker on the element getting lost)
27382 !! options
27383 parsoid=wt2html,wt2wt
27384 !! wikitext
27385 <table>
27386 <tr> || ||
27387 <td> a
27388 </table>
27389 !! html/php+tidy
27390 || ||
27391 <table>
27392 <tbody><tr><td> a
27393 </td></tr></tbody></table>
27394 !! html/parsoid
27395 <span data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'> || ||
27396 </span><table data-parsoid='{"stx":"html"}'>
27397 <tbody><tr data-parsoid='{"stx":"html","autoInsertedEnd":true}'><td data-parsoid='{"stx":"html","autoInsertedEnd":true}'> a
27398 </td></tr></tbody></table>
27399 !! end
27400
27401 !! test
27402 Encapsulation properly handles null DSR information from foster box
27403 !! options
27404 parsoid=wt2html,wt2wt
27405 !! wikitext
27406 {{echo|<table>foo<tr><td>bar</td></tr></table>}}
27407 !! html/parsoid
27408 <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>
27409 !! end
27410
27411 !! test
27412 1. Encapsulate foster-parented transclusion content
27413 !! options
27414 parsoid=wt2wt,wt2html
27415 !! wikitext
27416 <table>{{echo|foo<tr><td>bar</td></tr>}}</table>
27417 !! html/php+tidy
27418 foo<table><tbody><tr><td>bar</td></tr></tbody></table>
27419 !! html/parsoid
27420 <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>
27421 !! end
27422
27423 !! test
27424 2. Encapsulate foster-parented transclusion content
27425 !! options
27426 parsoid=wt2wt,wt2html
27427 !! wikitext
27428 <table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table>
27429 !! html/parsoid
27430 <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>
27431 <table>
27432 <tbody>
27433 <tr>
27434 <td>bar</td>
27435 </tr>
27436 </tbody>
27437 </table>
27438 !! end
27439
27440 !! test
27441 3. Encapsulate foster-parented transclusion content
27442 !! options
27443 parsoid=wt2wt,wt2html
27444 !! wikitext
27445 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
27446 !! html/parsoid
27447 <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;]}">
27448 <p>foo</p>
27449 </div>
27450 <table>
27451 <tbody>
27452 <tr>
27453 <td>bar</td>
27454 </tr>
27455 </tbody>
27456 </table>
27457 !! end
27458
27459 !! test
27460 4. Encapsulate foster-parented transclusion content
27461 !! options
27462 parsoid=wt2wt,wt2html
27463 !! wikitext
27464 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
27465 !! html/parsoid
27466 <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;]}">
27467 <p>foo</p>
27468 </div>
27469 <table>
27470 <tbody>
27471 <tr>
27472 <td>bar</td>
27473 </tr>
27474 </tbody>
27475 </table>
27476 !! end
27477
27478 !! test
27479 5. Encapsulate foster-parented transclusion content
27480 !!options
27481 parsoid=wt2wt,wt2html
27482 !! wikitext
27483 <table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table>
27484 !! html/php+tidy
27485 foo<table><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table>
27486 !! html/parsoid
27487 <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>
27488 !! end
27489
27490 !! test
27491 6. Encapsulate foster-parented transclusion content
27492 !! options
27493 parsoid=wt2wt,wt2html
27494 !! wikitext
27495 <table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p>
27496 !! html/php+tidy
27497 foo<table><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table><p>ok</p>
27498 !! html/parsoid
27499 <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>
27500 !! end
27501
27502 !! test
27503 7. Encapsulate foster-parented transclusion content
27504 !!options
27505 parsoid=wt2wt,wt2html
27506 !! wikitext
27507 <table>{{echo|<p>foo</p>}}<td>bar</td></table>
27508 !! html/parsoid
27509 <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>
27510 <table>
27511 <tbody>
27512 <tr>
27513 <td>bar</td>
27514 </tr>
27515 </tbody>
27516 </table>
27517 !! end
27518
27519 # Note that the wt is broken on purpose: the = should be {{=}} if you
27520 # don't want it to be a template parameter key.
27521 !! test
27522 8. Encapsulate foster-parented transclusion content
27523 !! options
27524 parsoid=wt2wt,wt2html
27525 !! wikitext
27526 {{echo|a
27527 }}{|{{echo|style='color:red'}}
27528 |-
27529 |b
27530 |}
27531 !! html/php+tidy
27532 <p>a
27533 </p>
27534 <table>
27535
27536 <tbody><tr>
27537 <td>b
27538 </td></tr></tbody></table>
27539 !! html/parsoid
27540 <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">
27541 </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">
27542 <tbody><tr>
27543 <td>b
27544 </td></tr></tbody></table>
27545 !! end
27546
27547 !! test
27548 9. Encapsulate foster-parented transclusion content
27549 !!options
27550 parsoid=wt2wt,wt2html
27551 !! wikitext
27552 <table>{{echo|hi</table>hello}}
27553 !! html/php+tidy
27554 hi<table></table><p>hello
27555 </p>
27556 !! html/parsoid
27557 <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>
27558 !! end
27559
27560 !! test
27561 Table in fosterable position
27562 !!options
27563 parsoid=wt2html
27564 !! wikitext
27565 {{OpenTable}}
27566 <div>
27567 {|
27568 |}
27569 </div>
27570 |}
27571 !! html/parsoid
27572 <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">
27573 </span>
27574 <table about="#mwt1" data-parsoid='{"autoInsertedEnd":true}'></table>
27575
27576 <table>
27577 </table>
27578 !! end
27579
27580 # Parsoid only for T66747
27581 !! test
27582 Properly encapsulate empty-content transclusions in fosterable positions
27583 !! wikitext
27584 <table>
27585 {{#if:|
27586 <td>foo</td>
27587 }}
27588 </table>
27589 !! html/parsoid
27590 <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"}]]}'>
27591
27592 </table>
27593 !! end
27594
27595 !! test
27596 Always encapsulate foster box when template range is expanded to table
27597 !! options
27598 parsoid=wt2wt
27599 !! wikitext
27600 {|
27601 hello
27602 {{OpenTable}}
27603 |}
27604 !! html/parsoid
27605
27606 !! end
27607
27608 !! test
27609 T115289: Unclosed table
27610 !! wikitext
27611 {{echo|<table>}}<!--c-->[[Category:Two]]
27612 !! html/parsoid
27613 <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>
27614 !! end
27615
27616 !! test
27617 T115289: Don't migrate newlines out of tables with fostered content
27618 !! wikitext
27619 <table><td></td>{{echo|<tr>[[Category:One]]}}<!--c-->[[Category:Two]]
27620 !! html/parsoid
27621 <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>
27622 !! end
27623
27624 !! test
27625 T73074: More fostering fun
27626 !! wikitext
27627 <table><td></td>{{echo|<tr>}}<!--c-->[[Category:Two]]
27628 !! html/parsoid
27629 <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>
27630 !! end
27631
27632 !!test
27633 Support <object> element with .data attribute
27634 !!options
27635 parsoid=html2wt
27636 !! html/parsoid
27637 <object data="test.swf"></object>
27638 !! wikitext
27639 <object data="test.swf"></object>
27640 !!end
27641
27642 !! test
27643 Don't block XML namespace declaration
27644 !! wikitext
27645 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span>
27646 !! html/php
27647 <p><span xmlns:dct="http&#58;//purl.org/dc/terms/" property="dct:title">MediaWiki</span>
27648 </p>
27649 !! html/parsoid
27650 <p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p>
27651 !! end
27652
27653 # -----------------------------------------------------------------
27654 # The following section of tests are primarily to spec requirements
27655 # around Parsoid's serialization (old, new, edited content)
27656 #
27657 # All these tests are marked Parsoid html2wt and html2html only
27658 # ----------------------------------------------------------------
27659
27660 !! test
27661 Ignore rel attribute in a-tags during serialization to url-links
27662 !! options
27663 parsoid=html2wt
27664 !! html/parsoid
27665 <a href='http://en.wikipedia.org/wiki/Foobar'>http://en.wikipedia.org/wiki/Foobar</a>
27666 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:ExtLink'>http://en.wikipedia.org/wiki/Foobar</a>
27667 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:WikiLink'>http://en.wikipedia.org/wiki/Foobar</a>
27668 !! wikitext
27669 http://en.wikipedia.org/wiki/Foobar
27670 http://en.wikipedia.org/wiki/Foobar
27671 http://en.wikipedia.org/wiki/Foobar
27672 !! end
27673
27674 # 'mi' is a localinterwiki prefix as well as a language
27675 !! test
27676 Serialize interwiki links pointing to the current wiki as plain wiki links (T67869)
27677 !! options
27678 parsoid=html2wt
27679 !! html/parsoid
27680 <p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p>
27681 !! wikitext
27682 [[Foo]]
27683 !! end
27684
27685 !! test
27686 Parsoid should accept interwiki shortcuts
27687 !! options
27688 parsoid=html2wt
27689 !! html/parsoid
27690 <p><a rel='mw:WikiLink' href='./fr:Foo'>Foo</a>
27691 <a rel='mw:ExtLink' href='./fr:Foo'>Foo</a>
27692 <a href='./fr:Foo'>Foo</a></p>
27693 <p><a rel='mw:WikiLink' href='fr%3AFoo'>Foo</a>
27694 <a rel='mw:ExtLink' href='fr%3AFoo'>Foo</a>
27695 <a href='fr%3AFoo'>Foo</a></p>
27696 <p><a href='FR%3AFoo'>Foo</a>
27697 <a href='./FR:Foo'>Foo</a></p>
27698 !! wikitext
27699 [[:fr:Foo|Foo]]
27700 [[:fr:Foo|Foo]]
27701 [[:fr:Foo|Foo]]
27702
27703 [[:fr:Foo|Foo]]
27704 [[:fr:Foo|Foo]]
27705 [[:fr:Foo|Foo]]
27706
27707 [[:fr:Foo|Foo]]
27708 [[:fr:Foo|Foo]]
27709 !! end
27710
27711 !! test
27712 Parsoid should not accept invalid interwiki shortcuts
27713 !! options
27714 parsoid=html2wt
27715 !! html/parsoid
27716 <p><a rel='mw:WikiLink' href='news:Foo'>Foo</a>
27717 <a rel='mw:ExtLink' href='news:Foo'>Foo</a>
27718 <a href='news:Foo'>Foo</a></p>
27719 !! wikitext
27720 [news:Foo Foo]
27721 [news:Foo Foo]
27722 [news:Foo Foo]
27723 !! end
27724
27725 # See T93839
27726 !! test
27727 New wikilinks should be serialized properly
27728 !! options
27729 parsoid=html2wt
27730 !! html/parsoid
27731 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
27732 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
27733 <a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a>
27734 <a href="http://en.wikipedia.org/wiki/Foo">http://en.wikipedia.org/wiki/Foo</a>
27735 <a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a>
27736 !! wikitext
27737 [[Foo]]
27738 [[Foo]]
27739 [[:en:Foo|//en.wikipedia.org/wiki/Foo]]
27740 http://en.wikipedia.org/wiki/Foo
27741 [[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]]
27742 !! end
27743
27744 !! test
27745 New wiki links (href variations)
27746 !! options
27747 parsoid=html2wt
27748 !! html/parsoid
27749 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
27750 <a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a>
27751 <a rel="mw:WikiLink" href="Foo bar">Foo_bar</a>
27752 <a rel="mw:WikiLink" href="./Toxine_bact%C3%A9rienne">Toxine bactérienne</a>
27753 !! wikitext
27754 [[Foo_bar]]
27755 [[Foo_bar]]
27756 [[Foo_bar]]
27757 [[Toxine bactérienne]]
27758 !! end
27759
27760 !! test
27761 New wiki links (content string variations)
27762 !! options
27763 parsoid=html2wt
27764 !! html/parsoid
27765 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
27766 <a rel="mw:WikiLink" href="./Foo_bar">Foo bar</a>
27767 <a rel="mw:WikiLink" href="./Foo_bar">./Foo_bar</a>
27768 !! wikitext
27769 [[Foo_bar]]
27770 [[Foo bar]]
27771 [[Foo_bar|./Foo_bar]]
27772 !! end
27773
27774 !! test
27775 New category links (href variations)
27776 !! options
27777 parsoid=html2wt
27778 !! html/parsoid
27779 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" />
27780 <link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" />
27781 <link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" />
27782 !! wikitext
27783 [[Category:Toxine bactérienne]]
27784 [[Category:Toxine bactérienne]]
27785 [[Category:Toxine bactérienne]]
27786 !! end
27787
27788 !! test
27789 New sol transparent links don't need indent-pre nowiki protection
27790 !! options
27791 parsoid=html2wt
27792 language=de
27793 !! html/parsoid
27794 <link rel="mw:PageProp/redirect" href="./Main_Page">
27795 <!-- this is good --> <link rel="mw:PageProp/Category" href="./Category:Good" />
27796 <!-- this is great --> <link rel="mw:PageProp/Category" href="./Kategorie:Great" />
27797 !! wikitext
27798 #WEITERLEITUNG [[Main Page]]
27799 <!-- this is good --> [[Category:Good]]
27800 <!-- this is great --> [[Kategorie:Great]]
27801 !! end
27802
27803 !! test
27804 New interlanguage links (href variations)
27805 !! options
27806 parsoid=html2wt
27807 !! html/parsoid
27808 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" />
27809 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" />
27810 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" />
27811 !! wikitext
27812 [[es:Toxine bactérienne]]
27813 [[es:Toxine_bactérienne]]
27814 [[es:Toxine_bactérienne]]
27815 !! end
27816
27817 !! test
27818 Image: Modifying size of an image (1)
27819 !! options
27820 parsoid={
27821 "modes": ["wt2wt"],
27822 "changes": [
27823 ["img[height]", "attr", "height", "22"],
27824 ["img[width]", "attr", "width", "200"]
27825 ]
27826 }
27827 !! wikitext
27828 [[Image:Foobar.jpg|230x230px]]
27829 !! wikitext/edited
27830 [[Image:Foobar.jpg|200x200px]]
27831 !!end
27832
27833 !! test
27834 Image: Modifying size of an image (2)
27835 !! options
27836 parsoid={
27837 "modes": ["wt2wt"],
27838 "changes": [
27839 ["img[height]", "attr", "height", "100"],
27840 ["img[width]", "attr", "width", "500"]
27841 ]
27842 }
27843 !! wikitext
27844 [[Image:Foobar.jpg|230x230px]]
27845 !! wikitext/edited
27846 [[Image:Foobar.jpg|500x500px]]
27847 !!end
27848
27849 # Change in size is ignored so long as class='mw-default-size'
27850 !! test
27851 Image: Modifying size of an image (3)
27852 !! options
27853 parsoid={
27854 "modes": ["wt2wt"],
27855 "changes": [
27856 ["figure[class]", "removeClass", "mw-default-size"],
27857 ["figure img", "attr", "height", "19"],
27858 ["figure img", "attr", "width", "170"]
27859 ]
27860 }
27861 !! wikitext
27862 [[Image:Foobar.jpg|thumb]]
27863 !! wikitext/edited
27864 [[Image:Foobar.jpg|thumb|170x170px]]
27865 !!end
27866
27867 !! test
27868 Image: Modifying alignment of an image (T50665)
27869 !! options
27870 parsoid={
27871 "modes": ["wt2wt"],
27872 "changes": [
27873 ["figure[class]", "removeClass", "mw-halign-right"],
27874 ["figure[class]", "addClass", "mw-halign-left"]
27875 ]
27876 }
27877 !! wikitext
27878 [[Image:Foobar.jpg|thumb|caption|right]]
27879 !! wikitext/edited
27880 [[Image:Foobar.jpg|thumb|caption|left]]
27881 !! end
27882
27883 !! test
27884 Image: Modifying mw-default-size of an frameless image (T64805)
27885 !! options
27886 parsoid={
27887 "modes": ["wt2wt"],
27888 "changes": [
27889 ["figure.mw-default-size", "removeClass", "mw-default-size"]
27890 ]
27891 }
27892 !! wikitext
27893 [[Image:Foobar.jpg|frameless|right]]
27894 !! wikitext/edited
27895 [[Image:Foobar.jpg|frameless|right|220x220px]]
27896 !! end
27897
27898 !! test
27899 Image: Modifying valign of an image (T51221)
27900 !! options
27901 parsoid={
27902 "modes": ["wt2wt"],
27903 "changes": [
27904 ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
27905 ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
27906 ]
27907 }
27908 !! wikitext
27909 [[File:Foobar.jpg|20px|middle]]
27910 !! wikitext/edited
27911 [[File:Foobar.jpg|20px|text-top]]
27912 !! end
27913
27914 !! test
27915 Image: Modifying alt attribute of an image (T58400)
27916 !! options
27917 parsoid={
27918 "modes": ["wt2wt"],
27919 "changes": [
27920 ["img[alt]", "attr", "alt", "some alternate edited text"]
27921 ]
27922 }
27923 !! wikitext
27924 [[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
27925 !! wikitext/edited
27926 [[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
27927 !!end
27928
27929 !! test
27930 Image: Modifying caption of an image
27931 !! options
27932 parsoid={
27933 "modes": ["wt2wt"],
27934 "changes": [
27935 ["figcaption", "text", "new caption"]
27936 ]
27937 }
27938 !! wikitext
27939 [[Image:Foobar.jpg|thumb|original caption]]
27940 !! wikitext/edited
27941 [[Image:Foobar.jpg|thumb|new caption]]
27942 !!end
27943
27944 !! test
27945 Image: empty alt attribute (T50924)
27946 !! options
27947 parsoid
27948 !! wikitext
27949 [[File:Foobar.jpg|thumb|alt=|bar]]
27950 !! html
27951 <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>
27952 !! end
27953
27954 !! test
27955 Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
27956 !! options
27957 parsoid=html2wt
27958 language=ar
27959 disabled
27960 !! html/parsoid
27961 <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>
27962 !! wikitext
27963 [[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
27964 !! end
27965
27966 !! test
27967 Image: Block level image should have \n before and after
27968 !! wikitext
27969 123
27970 [[File:Foobar.jpg|right|thumb|150x150px]]
27971 456
27972 !! html/parsoid
27973 <p>123</p>
27974 <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>
27975 <p>456</p>
27976 !! end
27977
27978 !! test
27979 Image: New block level image should have \n before and after (existing content)
27980 !! wikitext
27981 123
27982 [[File:Foobar.jpg|right|thumb|150x150px]]
27983 456
27984 !! html/parsoid
27985 <p>123</p>
27986 <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>
27987 <p>456</p>
27988 !! end
27989
27990 !! test
27991 Image: upright option (parsoid)
27992 !! wikitext
27993 [[File:Foobar.jpg|thumb|upright|caption]]
27994 [[File:Foobar.jpg|thumb|upright=0.5|caption]]
27995 [[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]]
27996 !! html/parsoid
27997 <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>
27998 <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>
27999 <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>
28000 !! end
28001
28002 !! test
28003 Image: upright option is ignored on inline and frame images (parsoid)
28004 !! wikitext
28005 [[File:Foobar.jpg|500x500px|upright=0.5|caption]]
28006 !! html/parsoid
28007 <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>
28008 !! end
28009
28010 !! test
28011 Image: in template parameter with empty parameter
28012 !! wikitext
28013 {{echo|[[File:Foobar.jpg|link=]]}}
28014 !! html/parsoid
28015 <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>
28016 !! end
28017
28018 !! test
28019 Image: from basic HTML (1)
28020 !! options
28021 parsoid=html2wt
28022 !! html/parsoid
28023 <span typeof="mw:Image">
28024 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
28025 </span>
28026 !! wikitext
28027 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
28028 !! end
28029
28030 !! test
28031 Image: from basic HTML (2)
28032 !! options
28033 parsoid=html2wt
28034 !! html/parsoid
28035 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
28036 !! wikitext
28037 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
28038 !! end
28039
28040 !! test
28041 Image: from basic HTML (3)
28042 !! options
28043 parsoid=html2wt
28044 !! html/parsoid
28045 <a href="Main"><img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"></a>
28046 !! wikitext
28047 [[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
28048 !! end
28049
28050 !! test
28051 Image: from basic HTML (4)
28052 !! options
28053 parsoid=html2wt
28054 !! html/parsoid
28055 <img src="./File:Foobar.jpg">
28056 !! wikitext
28057 [[File:Foobar.jpg|link=]]
28058 !! end
28059
28060 !! test
28061 Image: Invalid title as link
28062 !! wikitext
28063 [[File:Foobar.jpg|link=<]]
28064 !! html/php
28065 <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>
28066 </p>
28067 !! html/parsoid
28068 <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>
28069 !! end
28070
28071 !! test
28072 Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
28073 !! options
28074 parsoid=html2wt
28075 !! html/parsoid
28076 <ul>
28077 <li><p>foo</p></li>
28078 </ul>
28079 !! wikitext
28080 * foo
28081 !! end
28082
28083 !! test
28084 Lists: Serialize correctly even when list tags has unneeded whitespace between tags
28085 !! options
28086 parsoid=html2wt
28087 !! html/parsoid
28088 <ul> <li>foo</li></ul>
28089 !! wikitext
28090 * foo
28091 !! end
28092
28093 !! test
28094 Don't strip leading whitespace when handling indent-pre suppressing tags
28095 !! options
28096 parsoid=html2wt
28097 !! html/parsoid
28098 <table>
28099 <tr><td> indented row</td></tr>
28100 </table>
28101 <blockquote><p>
28102 <b>This is very bold of you!</b>
28103 </p>
28104 <table><tr><td>
28105 indented cell (no pre-wrapping!)
28106 </td></tr></table>
28107 </blockquote>
28108 <p>foo</p>
28109 <div>bar</div>
28110 !! wikitext
28111 {|
28112 | indented row
28113 |}
28114 <blockquote>
28115 '''This is very bold of you!'''
28116
28117 {|
28118 |
28119 indented cell (no pre-wrapping!)
28120 |}
28121 </blockquote>
28122 foo
28123 <div>bar</div>
28124 !! end
28125
28126 !! test
28127 Nowiki-wrap leading whitespace when handling indent-pre inducing tags
28128 !! options
28129 parsoid=html2wt
28130 !! html/parsoid
28131 <p>foo</p>
28132 <span>bar</span>
28133
28134 <span>foo2
28135 </span>bar2
28136
28137 <div>foo</div>
28138 <span>bar</span>
28139
28140 <div>
28141 <span>foo</span>
28142 </div>
28143 !! wikitext
28144 foo
28145
28146 <span>bar</span>
28147
28148 <span>foo2
28149 <nowiki> </nowiki></span>bar2
28150
28151 <div>foo</div>
28152 <nowiki> </nowiki><span>bar</span>
28153
28154 <div>
28155 <nowiki> </nowiki><span>foo</span>
28156 </div>
28157 !! end
28158
28159 !! test
28160 Lists: Dont insert newlines in a serialized list item.
28161 !! options
28162 parsoid=html2wt
28163 !! html/parsoid
28164 <ul><li>a<br>b</li><li>c</li></ul>
28165 !! wikitext
28166 * a<br />b
28167 * c
28168 !! end
28169
28170 !! test
28171 1. Headings: Force sol-transparent links and behavior switches to serialize before/after
28172 !! options
28173 parsoid={
28174 "modes": ["html2wt"],
28175 "scrubWikitext": false
28176 }
28177 !! html/parsoid
28178 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
28179 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
28180
28181 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
28182 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
28183
28184 <h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2>
28185
28186 <h2><meta property="mw:PageProp/toc" /> ok</h2>
28187 !! wikitext
28188 == hello there [[Category:A1]] ==
28189
28190 == [[Category:A2]] hi pal ==
28191
28192 == <!--foo--> [[Category:A3]] how goes it ==
28193
28194 == it goes well [[Category:A4]] <!--bar--> ==
28195
28196 ==howdy [[Category:A5]]==
28197
28198 == __TOC__ ok ==
28199 !! end
28200
28201 !! test
28202 2. Headings: Force sol-transparent links and behavior switches to serialize before/after
28203 !! options
28204 parsoid={
28205 "modes": ["html2wt"],
28206 "scrubWikitext": true
28207 }
28208 !! html/parsoid
28209 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
28210 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
28211
28212 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
28213 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
28214
28215 <h2><meta property="mw:PageProp/toc" /> ok</h2>
28216 !! wikitext
28217 == hello there ==
28218 [[Category:A1]]
28219 [[Category:A2]]
28220
28221 == hi pal ==
28222
28223 <!--foo-->[[Category:A3]]
28224
28225 == how goes it ==
28226
28227 == it goes well ==
28228 [[Category:A4]] <!--bar-->
28229
28230 __TOC__
28231
28232 == ok ==
28233 !! end
28234
28235 !! test
28236 Headings: Don't hoist metas that come from templates
28237 !! options
28238 parsoid={
28239 "modes": ["html2wt"],
28240 "scrubWikitext": true
28241 }
28242 !! html/parsoid
28243 <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>
28244 !! wikitext
28245 == {{echo|foo [[Category:Foo]]}} ==
28246 !! end
28247
28248 !! test
28249 Headings: Category in ref isn't hoisted
28250 !! options
28251 parsoid={
28252 "modes": ["html2wt"],
28253 "scrubWikitext": true
28254 }
28255 !! html/parsoid
28256 <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>
28257
28258 <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>
28259 !! wikitext
28260 == foo <ref>bar
28261 [[Category:Baz]] </ref> ==
28262
28263 <references />
28264 !! end
28265
28266 !! test
28267 Parsoid: Serialize positional parameters with = in them as named parameter
28268 !! options
28269 parsoid=html2wt
28270 !! html/parsoid
28271 <p about="#mwt1" typeof="mw:Transclusion"
28272 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p>
28273
28274 <p about="#mwt1" typeof="mw:Transclusion"
28275 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p>
28276
28277 <!--Orig params with data-parsoid has heuristics for handling = chars-->
28278 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
28279 <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>
28280 !! wikitext
28281 {{echo|1=f=oo}}
28282
28283 {{echo|1=f=oo|2=bar}}
28284
28285 <!--Orig params with data-parsoid has heuristics for handling = chars-->
28286 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
28287 {{echo|<nowiki>f=oo</nowiki>|bar}}
28288 !! end
28289
28290 !! test
28291 Parsoid: Serialize positional parameters with = in extlink as named parameter
28292 !! options
28293 parsoid=html2wt
28294 !! html/parsoid
28295 <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>
28296 !! wikitext
28297 {{echo|1=http://stuff?is=ok}}
28298 !! end
28299
28300 !! test
28301 Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes
28302 !! options
28303 parsoid=html2wt
28304 !! html/parsoid
28305 <div>a<p>b</p></div>
28306 <div>a
28307 <p>b</p></div>
28308 <div>
28309 a
28310 <p>b</p></div>
28311 !! wikitext
28312 <div>a
28313 b
28314 </div>
28315 <div>a
28316 b
28317 </div>
28318 <div>
28319 a
28320
28321 b
28322 </div>
28323 !! end
28324
28325 !! test
28326 Substrings resembling wikitext in hrefs should not get nowiki escapes
28327 !! options
28328 parsoid=html2wt
28329 !! html/parsoid
28330 <a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a>
28331 !! wikitext
28332 [[Foo''bar''baz]]
28333 !! end
28334
28335 !! test
28336 Enforce single-line context in the serializer
28337 !! options
28338 parsoid=html2wt
28339 !! html/parsoid
28340 <h2>testing
28341 123</h2>
28342
28343 <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">
28344 </span><span about="#mwt1">you</span> </h2>
28345
28346 <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>
28347
28348 <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
28349 there</span></li></ol>
28350
28351 <ul><li>asd
28352 sdf</li></ul>
28353
28354 <ul><li>foo
28355 bar
28356 baz</li>
28357 <li>foo <b>bar</b>
28358 baz</li></ul>
28359
28360 <dl><dt>hi
28361 ho </dt><dd data-parsoid='{"stx":"row"}'> hi
28362 ho</dd></dl>
28363
28364 <dl><dd> <table>
28365 <tbody><tr><td> ha
28366 ha
28367 ha</td></tr>
28368 </tbody></table></dd></dl>
28369 !! wikitext
28370 == testing 123 ==
28371
28372 == hi {{bogus|there
28373 you}} ==
28374
28375 == foo <ref>hello
28376 there</ref> ==
28377
28378 <references />
28379
28380 * asd sdf
28381
28382 * foo bar baz
28383 * foo '''bar''' baz
28384
28385 ; hi ho : hi ho
28386
28387 : {|
28388 | ha
28389 ha
28390 ha
28391 |}
28392 !! end
28393
28394 !! test
28395 Serialize new placeholder space without spans
28396 !! options
28397 parsoid=html2wt
28398 !! html/parsoid
28399 <p>foo<span typeof="mw:Placeholder"> </span>: bar</p>
28400
28401 <p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p>
28402
28403 <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>
28404 !! wikitext
28405 foo : bar
28406
28407 foo : bar
28408
28409 <ref>foo : bar</ref>ok
28410 !! end
28411
28412
28413 #-----------------------
28414 # Tag minimization tests
28415 #-----------------------
28416
28417 !! test
28418 1. I/B quote minimization: wikitext-only tags should be combined
28419 !! options
28420 parsoid=html2wt
28421 !! html/parsoid
28422 <p><i>A</i><i>B</i></p>
28423 <p><b>A</b><b>B</b></p>
28424 <p><i>A</i><b><i>B</i></b></p>
28425 <p><b>A</b><i><b>B</b></i></p>
28426 <p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p>
28427 <p><i><b>A</b></i><i><b>B</b></i></p>
28428 <p><i><b>A</b></i><b><i>B</i></b></p>
28429 <p><b><i>A</i></b><i><b>B</b></i></p>
28430 !! wikitext
28431 ''AB''
28432
28433 '''AB'''
28434
28435 ''A'''B'''''
28436
28437 '''A''B'''''
28438
28439 '''A''BC''D'''
28440
28441 '''''AB'''''
28442
28443 '''''AB'''''
28444
28445 '''''AB'''''
28446 !! end
28447
28448 !! test
28449 2. I/B quote minimization: wikitext and html tags should not be combined
28450 !! options
28451 parsoid=html2wt
28452 !! html/parsoid
28453 <p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
28454 <p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
28455 !! wikitext
28456 ''A''<i>B</i>
28457
28458 ''A''<nowiki/>'''<i>B</i>'''
28459 !! end
28460
28461 !! test
28462 3. I/B quote minimization: templated content stops minimization
28463 !! options
28464 parsoid=html2wt
28465 !! html/parsoid
28466 <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>
28467 <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>
28468 !! wikitext
28469 ''A''{{echo|''B''}}
28470
28471 ''A''{{echo|'''''B'''''}}
28472 !! end
28473
28474 !! test
28475 4. I/B quote minimization: new content should be mimimized with adjacent old content
28476 !! options
28477 parsoid=html2wt
28478 !! html/parsoid
28479 <p><i>A</i><i>B</i></p>
28480 <p><b>A</b><b>B</b></p>
28481 <p><i>A</i><b><i>B</i></b></p>
28482 !! wikitext
28483 ''AB''
28484
28485 '''AB'''
28486
28487 ''A'''B'''''
28488 !! end
28489
28490 !! test
28491 5a. Merge adjacent quote nodes if they've been edited
28492 !! options
28493 parsoid={
28494 "modes": ["wt2wt", "selser"],
28495 "changes": [
28496 ["p", "contents", "remove", ":contains('b')"]
28497 ]
28498 }
28499 !! wikitext
28500 ''a''b''c''
28501 !! wikitext/edited
28502 ''ac''
28503 !! end
28504
28505 !! test
28506 5b. Merge adjacent quote nodes if they've been edited
28507 !! options
28508 parsoid={
28509 "modes": ["wt2wt", "selser"],
28510 "changes": [
28511 ["#x", "remove"]
28512 ]
28513 }
28514 !! wikitext
28515 ''a''<span id="x">b</span>''c''
28516 !! wikitext/edited
28517 ''ac''
28518 !! end
28519
28520 !! test
28521 1. Merge adjacent link nodes as long as at least one element is new
28522 !! options
28523 parsoid={
28524 "modes": ["html2wt"],
28525 "scrubWikitext": true
28526 }
28527 !! html/parsoid
28528 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28529 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28530 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a>
28531 !! wikitext
28532 [[Football]]
28533 [[Football]]
28534 [[Football|Foot]][[Football|ball]]
28535 !! end
28536
28537 !! test
28538 2. Merge adjacent link nodes and enable additional normalizations
28539 !! options
28540 parsoid={
28541 "modes": ["html2wt"],
28542 "scrubWikitext": true
28543 }
28544 !! html/parsoid
28545 <a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a>
28546 !! wikitext
28547 ''[[Football]]''
28548 !! end
28549
28550 !! test
28551 3. Don't merge adjacent link nodes if scrubWikitext is false
28552 !! options
28553 parsoid={
28554 "modes": ["html2wt"],
28555 "scrubWikitext": false
28556 }
28557 !! html/parsoid
28558 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28559 !! wikitext
28560 [[Football|Foot]][[Football|ball]]
28561 !! end
28562
28563 !! test
28564 1. Move format tags outside of WikiLink
28565 !! options
28566 parsoid={
28567 "modes": ["html2wt"],
28568 "scrubWikitext": true
28569 }
28570 !! html/parsoid
28571 <a rel="mw:WikiLink" href="./Football"><i>Football</i></a>
28572 <a rel="mw:WikiLink" href="./Football"><i><b>Football</b></i></a>
28573 <a rel="mw:WikiLink" href="./Football"><u><i><b>Football</b></i></u></a>
28574 !! wikitext
28575 ''[[Football]]''
28576 '''''[[Football]]'''''
28577 <u>'''''[[Football]]'''''</u>
28578 !! end
28579
28580 !! test
28581 2. Move format tags outside of WikiLink with mergable A tags
28582 !! options
28583 parsoid={
28584 "modes": ["html2wt"],
28585 "scrubWikitext": true
28586 }
28587 !! html/parsoid
28588 <a rel="mw:WikiLink" href="./Football"><i><b>Foot</b></i></a><a rel="mw:WikiLink" href="./Football"><i><b>ball</b></i></a>
28589 !! wikitext
28590 '''''[[Football]]'''''
28591 !! end
28592
28593 !! test
28594 3. Move format tags outside of WikiLink while preserving formats already outside WikiLink
28595 !! options
28596 parsoid={
28597 "modes": ["html2wt"],
28598 "scrubWikitext": true
28599 }
28600 !! html/parsoid
28601 <font color="red"><a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><u><b>Foo</b></u></a></font>
28602 !! wikitext
28603 <font color="red"><u>'''[[Foo]]'''</u></font>
28604 !! end
28605
28606 !! test
28607 4. Do not move format tags outside of WikiLink which includes attributes color, style and class
28608 !! options
28609 parsoid={
28610 "modes": ["html2wt"],
28611 "scrubWikitext": true
28612 }
28613 !! html/parsoid
28614 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><font color="red">Foo</font></a>
28615 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><span style="color: blue; font-size: 46px;">Foo></span></a>
28616 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><span class="Bar">Foo</span></a>
28617 !! wikitext
28618 [[Foo|<font color="red">Foo</font>]]
28619 [[Foo|<span style="color: blue; font-size: 46px;">Foo></span>]]
28620 [[Foo|<span class="Bar">Foo</span>]]
28621 !! end
28622
28623 !! test
28624 5. T194083 Regression test: Manual edit test that also enables scrubWikitext to move format tags outside wikilinks
28625 !! options
28626 parsoid={
28627 "modes": ["selser"],
28628 "scrubWikitext": true,
28629 "changes": [
28630 ["a", "html", "<i>Foo</i>"]
28631 ]
28632 }
28633 !! wikitext
28634 [[Foo]]
28635 !! wikitext/edited
28636 ''[[Foo]]''
28637 !! end
28638
28639 !! test
28640 6. Regression test: Manual edit test to ensure diff markers are not lost
28641 !! options
28642 parsoid={
28643 "modes": ["selser"],
28644 "scrubWikitext": true,
28645 "changes": [
28646 ["i", "wrap", "<a href='./Foo' rel='mw:WikiLink'></a>"]
28647 ]
28648 }
28649 !! wikitext
28650 ''Foo''
28651 !! wikitext/edited
28652 ''[[Foo]]''
28653 !! end
28654
28655 #------------------------------
28656 # End of tag minimization tests
28657 #------------------------------
28658
28659 !!test
28660 T56262: New entities
28661 !! options
28662 parsoid=html2wt
28663 !! html/parsoid
28664 <span typeof="mw:Entity">&nbsp;</span>
28665 !! wikitext
28666 &nbsp;
28667 !! end
28668
28669 ## Note that there is no wikitext output for 'unknownproperty' ##
28670 ## Unknown magic words are silently dropped ##
28671
28672 !! test
28673 Magic words
28674 !! options
28675 parsoid=html2wt
28676 !! html/parsoid
28677 <meta property='mw:PageProp/toc' />
28678 <meta property='mw:PageProp/notoc' />
28679 <meta property='mw:PageProp/forcetoc' />
28680 <meta property='mw:PageProp/index' />
28681 <meta property='mw:PageProp/noindex' />
28682 <meta property='mw:PageProp/nogallery' />
28683 <meta property='mw:PageProp/noeditsection' />
28684 <meta property='mw:PageProp/notitleconvert' />
28685 <meta property='mw:PageProp/nocontentconvert' />
28686 <meta property='mw:PageProp/unknownproperty' />
28687 !! wikitext
28688 __TOC__
28689 __NOTOC__
28690 __FORCETOC__
28691 __INDEX__
28692 __NOINDEX__
28693 __NOGALLERY__
28694 __NOEDITSECTION__
28695 __NOTITLECONVERT__
28696 __NOCONTENTCONVERT__
28697 !! end
28698
28699 !! test
28700 Consecutive <pre>s should not get merged
28701 !! options
28702 parsoid=html2wt,html2html
28703 !! html/parsoid
28704 <pre>a</pre><pre>b</pre>
28705
28706 <pre>c
28707 </pre><pre>
28708 d</pre>
28709
28710 <pre>e
28711
28712 </pre><pre>
28713
28714 f</pre>
28715 !! wikitext
28716 a
28717
28718 b
28719
28720 c
28721
28722 d
28723
28724 e
28725
28726
28727
28728 f
28729 !! end
28730
28731 !! test
28732 Edited ISBN links not serializable as ISBN links should serialize as wikilinks
28733 !! options
28734 parsoid=html2wt
28735 !! html/parsoid
28736 <a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a>
28737 !! wikitext
28738 [[Special:BookSources/1234567890|ISBN 1234567895]]
28739 !! end
28740
28741 !! test
28742 Edited RFC links not serializable as RFC links should serialize as extlinks
28743 !! options
28744 parsoid=html2wt
28745 !! html/parsoid
28746 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
28747 !! wikitext
28748 [https://tools.ietf.org/html/rfc123 New RFC]
28749 !! end
28750
28751 !! test
28752 Edited PMID links not serializable as PMID links should serialize as extlinks
28753 !! options
28754 parsoid=html2wt
28755 !! html/parsoid
28756 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a>
28757 !! wikitext
28758 [//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID]
28759 !! end
28760
28761 !! test
28762 WTS of autolinks with trailing/surrounding context
28763 !! options
28764 parsoid=html2wt
28765 !! html/parsoid
28766 <p><a href="http://cscott.net">http://cscott.net</a><b>foo</b></p>
28767 <p><a href="http://cscott.net">http://cscott.net</a><b data-parsoid='{"stx":"html"}'>foo</b></p>
28768 <p><b><a href="http://cscott.net">http://cscott.net</a></b></p>
28769 <p><b><a href="http://cscott.net">http://cscott.net</a> </b></p>
28770 <p><b><a href="http://cscott.net">http://cscott.net</a>x</b></p>
28771 <p><a href="http://cscott.net">http://cscott.net</a>x</p>
28772 !! wikitext
28773 http://cscott.net'''foo'''
28774
28775 http://cscott.net<b>foo</b>
28776
28777 '''http://cscott.net'''
28778
28779 '''http://cscott.net '''
28780
28781 '''http://cscott.net<nowiki/>x'''
28782
28783 http://cscott.net<nowiki/>x
28784 !! end
28785
28786 !! test
28787 WTS of autolinks with nowikis (round-trip)
28788 !! wikitext
28789 x<nowiki/>http://cscott.net<nowiki/>x
28790 !! html/parsoid
28791 <p>x<a rel="mw:ExtLink" class="external free" href="http://cscott.net">http://cscott.net</a>x</p>
28792 !! end
28793
28794 # this is the "easy" test because it leaves in place all the
28795 # data-parsoid information indicating this is an autolink
28796 !! test
28797 WTS of autolinks with escapes (editing)
28798 !! options
28799 parsoid={
28800 "modes": ["wt2wt"],
28801 "changes": [
28802 [ "span", "remove" ]
28803 ]
28804 }
28805 !! wikitext
28806 x<nowiki/>http://cscott.net<nowiki/>x
28807 !! wikitext/edited
28808 x<nowiki/>http://cscott.net<nowiki/>x
28809 !! end
28810
28811 !! test
28812 WTS of edited autolink-like text (T103364)
28813 !! options
28814 parsoid={
28815 "modes": ["wt2wt"],
28816 "changes": [
28817 [ "span[typeof]", "removeAttr", "typeof" ]
28818 ]
28819 }
28820 !! wikitext
28821 Not a link: <nowiki>http://example.com</nowiki>.
28822 !! wikitext/edited
28823 Not a link: <span><nowiki>http://example.com</nowiki></span>.
28824 !! end
28825
28826 !! test
28827 WTS of newly-authored autolink-like text (T103364)
28828 !! options
28829 parsoid=html2wt
28830 !! html/parsoid
28831 <p>http://example.com is not a link.</p>
28832 !! wikitext
28833 <nowiki>http://example.com</nowiki> is not a link.
28834 !! end
28835
28836 !! test
28837 WTS of autolink-like text after an autolink (T108563)
28838 !! options
28839 parsoid=html2wt
28840 !! html/parsoid
28841 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p>
28842 !! wikitext
28843 http://example.com <nowiki>http://example.com</nowiki> is not a link.
28844 !! end
28845
28846 !! test
28847 Magic links inside links (not autolinked)
28848 !! wikitext
28849 [[Foo|http://example.com]]
28850 [[Foo|RFC 1234]]
28851 [[Foo|PMID 1234]]
28852 [[Foo|ISBN 123456789x]]
28853
28854 [http://foo.com http://example.com]
28855 [http://foo.com RFC 1234]
28856 [http://foo.com PMID 1234]
28857 [http://foo.com ISBN 123456789x]
28858 !! html+tidy
28859 <p><a href="/wiki/Foo" title="Foo">http://example.com</a>
28860 <a href="/wiki/Foo" title="Foo">RFC 1234</a>
28861 <a href="/wiki/Foo" title="Foo">PMID 1234</a>
28862 <a href="/wiki/Foo" title="Foo">ISBN 123456789x</a>
28863 </p><p><a rel="nofollow" class="external text" href="http://foo.com">http://example.com</a>
28864 <a rel="nofollow" class="external text" href="http://foo.com">RFC 1234</a>
28865 <a rel="nofollow" class="external text" href="http://foo.com">PMID 1234</a>
28866 <a rel="nofollow" class="external text" href="http://foo.com">ISBN 123456789x</a>
28867 </p>
28868 !! html/parsoid
28869 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a>
28870 <a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a>
28871 <a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a>
28872 <a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p>
28873
28874 <p><a rel="mw:ExtLink" class="external text" href="http://foo.com">http://example.com</a>
28875 <a rel="mw:ExtLink" class="external text" href="http://foo.com">RFC 1234</a>
28876 <a rel="mw:ExtLink" class="external text" href="http://foo.com">PMID 1234</a>
28877 <a rel="mw:ExtLink" class="external text" href="http://foo.com">ISBN 123456789x</a></p>
28878 !! end
28879
28880 !! test
28881 Magic links inside image captions (autolinked)
28882 !! wikitext
28883 [[File:Foobar.jpg|thumb|http://example.com]]
28884 [[File:Foobar.jpg|thumb|RFC 1234]]
28885 [[File:Foobar.jpg|thumb|PMID 1234]]
28886 [[File:Foobar.jpg|thumb|ISBN 123456789x]]
28887 !! html+tidy
28888 <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>
28889 <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>
28890 <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>
28891 <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>
28892 !! html/parsoid
28893 <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>
28894 <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>
28895 <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>
28896 <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>
28897 !! end
28898
28899 !! test
28900 WTS of magic word text (T109371)
28901 !! options
28902 parsoid=html2wt
28903 !! html/parsoid
28904 <p>RFC 1234</p>
28905 <p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p>
28906 <p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p>
28907 !! wikitext
28908 <nowiki>RFC 1234</nowiki>
28909
28910 [http://foo.com RFC 1234]
28911
28912 [[Foo|RFC 1234]]
28913 !! end
28914
28915 !! test
28916 Edited Redirect link should emit a non-piped wikitext link
28917 !! options
28918 parsoid=html2wt
28919 !! html/parsoid
28920 <link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>
28921 !! wikitext
28922 #REDIRECT [[Bar]]
28923 !! end
28924
28925 !! test
28926 T75121: Infer extension name from typeOf if data-mw is not present
28927 !! options
28928 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28929 !! html/parsoid
28930 <div typeOf="mw:Extension/foo"></div>
28931 !! wikitext
28932 <foo />
28933 !! end
28934
28935 # Note that the <p> wrapping isn't present in PHP parser output
28936 # The important thing for this test is that P-wrapping doesn't
28937 # interfere with the <nowiki> protection for leading - in <td>
28938 # (which isn't necessary for <th>).
28939 !! test
28940 T88318: p-wrapped dash in table.
28941 !! options
28942 parsoid=html2wt,wt2wt
28943 !! html/parsoid
28944 <table><tbody>
28945 <tr><th><p>-</p></th><th><p>- </p></th></tr>
28946 <tr><td><p>-</p></td><td><p>- </p></td></tr>
28947 <tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr>
28948 </tbody></table>
28949 !! wikitext
28950 {|
28951 !-
28952 !-
28953 |-
28954 |<nowiki>-</nowiki>
28955 |<nowiki>- </nowiki>
28956 |-
28957 |<small>-</small>
28958 |<br />
28959 -
28960 |<br />-
28961 |}
28962 !! html/php+tidy
28963 <table>
28964 <tbody><tr>
28965 <th>-
28966 </th>
28967 <th>-
28968 </th></tr>
28969 <tr>
28970 <td>-
28971 </td>
28972 <td>-
28973 </td></tr>
28974 <tr>
28975 <td><small>-</small>
28976 </td>
28977 <td><br />
28978 <p>-
28979 </p>
28980 </td>
28981 <td><br />-
28982 </td></tr></tbody></table>
28983 !! end
28984
28985 !! test
28986 T149209: WTS: Handle newlines in table cells properly
28987 !! options
28988 parsoid=html2wt
28989 !! html/parsoid
28990 <table>
28991 <tbody>
28992 <tr><td>a
28993 b
28994 </td><td data-parsoid='{"stx":"row"}'>c</td></tr>
28995 <tr><td><p>x</p>
28996 </td><td data-parsoid='{"stx":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr>
28997 </tbody></table>
28998 <table>
28999 <tbody>
29000 <tr><th>a
29001 b
29002 </th><th data-parsoid='{"stx":"row"}'>c</th></tr>
29003 <tr><th><p>x</h>
29004 </th><th data-parsoid='{"stx":"row"}'>y</th></tr>
29005 </tbody></table>
29006 !! wikitext
29007 {|
29008 |a
29009 b
29010 |c
29011 |-
29012 |x
29013 {{!}}y
29014 |}
29015 {|
29016 !a
29017 b
29018 !c
29019 |-
29020 !x
29021 !y
29022 |}
29023 !! end
29024
29025 !! test
29026 T149209: Selser: Handle newlines in table cells properly
29027 !! options
29028 parsoid={
29029 "modes": ["selser"],
29030 "changes": [
29031 [ "#h1", "html", "a\nb\n" ],
29032 [ "#h2", "html", "a\nb\n" ],
29033 [ "#c1", "html", "a\nb\n" ],
29034 [ "#c2", "html", "<p>a</p>" ],
29035 [ "#c3", "html", "<p>a</p>" ],
29036 [ "#c4", "html", "edit-me<p>a</p>" ]
29037 ]
29038 }
29039 !! wikitext
29040 {|
29041 ! id="h1" |edit-me!!1
29042 |-
29043 ! id="h2" |edit-me||2
29044 |-
29045 | id="c1" |edit-me||3
29046 |-
29047 | id="c2" |edit-me||4
29048 |-
29049 | id="c3" |edit-me||p||q||r
29050 |-
29051 | id="c4" |edit-me||p||q||r
29052 |}
29053 !! wikitext/edited
29054 {|
29055 ! id="h1" |a
29056 b
29057 !1
29058 |-
29059 ! id="h2" |a
29060 b
29061 !2
29062 |-
29063 | id="c1" |a
29064 b
29065 |3
29066 |-
29067 | id="c2" |a
29068 |4
29069 |-
29070 | id="c3" |a
29071 |p||q||r
29072 |-
29073 | id="c4" |edit-me
29074 a
29075 |p||q||r
29076 |}
29077 !! end
29078
29079 !! test
29080 HTML id attribute with Parsoid-like element ids should not be serialized to wikitext
29081 !! options
29082 parsoid=html2wt
29083 !! html/parsoid
29084 <table id='mwAb'>
29085 <td id='mwAc'>foo</td>
29086 <td id='serialize-this'>bar</td>
29087 </table>
29088 !! wikitext
29089 {|
29090 |foo
29091 | id="serialize-this" |bar
29092 |}
29093 !! end
29094
29095 !! test
29096 Parsoid-like element ids should not be serialized to wikitext unless shadowed
29097 !! options
29098 parsoid=html2wt
29099 !! html/parsoid
29100 <div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div>
29101 !! wikitext
29102 <div id="hello">ok</div>
29103 !! end
29104
29105 !! test
29106 Testing serialization after deletion in references
29107 !! options
29108 parsoid={
29109 "modes": ["wt2wt"],
29110 "changes": [
29111 ["#x", "remove"]
29112 ]
29113 }
29114 !! wikitext
29115 hi <ref><div id="x">ho</div></ref>
29116
29117 <references />
29118 !! wikitext/edited
29119 hi <ref></ref>
29120
29121 <references />
29122 !! end
29123
29124 !!test
29125 Testing serialization after deletion of table cells
29126 !!options
29127 parsoid={
29128 "modes": ["wt2wt", "selser"],
29129 "changes": [
29130 ["#x", "remove"]
29131 ]
29132 }
29133 !!wikitext
29134 {|
29135 !h1 !!h2 !!h3
29136 | id="x" |c1 {{!}}{{!}}{{!}}c2 |||c3
29137 |}
29138 !! wikitext/edited
29139 {|
29140 !h1!!h2!!h3
29141 |c2|||c3
29142 |}
29143 !!end
29144
29145 !! test
29146 Testing selser after addition of new row before first row (T125419)
29147 !! options
29148 parsoid={
29149 "modes": ["wt2wt", "selser"],
29150 "changes": [
29151 [ "tr", "before", "<tr><td>X</td></tr>" ]
29152 ]
29153 }
29154 !! wikitext
29155 {|
29156 |a
29157 |}
29158 !! wikitext/edited
29159 {|
29160 |X
29161 |-
29162 |a
29163 |}
29164 !! end
29165
29166 !! test
29167 Serialize new table rows in a HTML table using HTML tags
29168 !! options
29169 parsoid={
29170 "modes": ["wt2wt", "selser"],
29171 "changes": [
29172 [ "tr", "before", "<tr><td>X</td></tr>" ]
29173 ]
29174 }
29175 !! wikitext
29176 <table><tr><td>a</td></tr></table>
29177 !! wikitext/edited
29178 <table><tr><td>X</td></tr><tr><td>a</td></tr></table>
29179 !! end
29180
29181 !! test
29182 Serialize new table cells in a HTML row using HTML tags
29183 !! options
29184 parsoid={
29185 "modes": ["wt2wt", "selser"],
29186 "changes": [
29187 [ "td", "before", "<td>X</td>" ]
29188 ]
29189 }
29190 !! wikitext
29191 <table><tr><td>a</td></tr></table>
29192 !! wikitext/edited
29193 <table><tr><td>X</td><td>a</td></tr></table>
29194 !! end
29195
29196 !! test
29197 Serialize wikitext list items as HTML list items when embedded in a HTML list
29198 !! options
29199 parsoid=html2wt
29200 !! html
29201 <ul data-parsoid='{"stx": "html"}'>
29202 <li data-parsoid='{}'>a</li>
29203 <li>b</li>
29204 </ul>
29205 !! wikitext
29206 <ul>
29207 <li>a</li>
29208 <li>b</li>
29209 </ul>
29210 !! end
29211
29212 # SSS FIXME: Is this actually a good thing given the
29213 # odd nested list output that is generated by MW?
29214 # <ul><li>foo<ul>..</ul></li></ul> instead of
29215 # <ul><li>foo</li><ul>..</ul></ul>
29216 !! test
29217 Wikitext lists can be nested inside HTML lists
29218 !! options
29219 parsoid=html2wt
29220 !! html
29221 <ul data-parsoid='{"stx": "html"}'>
29222 <li data-parsoid='{"stx": "html"}'>a
29223 <ul><li>b</li></ul>
29224 </li>
29225 </ul>
29226
29227 <ul data-parsoid='{"stx": "html"}'>
29228 <li>x
29229 <ul><li>y</li></ul>
29230 </li>
29231 </ul>
29232 !! wikitext
29233 <ul>
29234 <li>a
29235 * b
29236 </li>
29237 </ul>
29238
29239 <ul>
29240 <li>x
29241 * y
29242 </li>
29243 </ul>
29244 !! end
29245
29246 !! test
29247 WTS change modes
29248 !! options
29249 parsoid={
29250 "modes": ["wt2wt"],
29251 "changes": [
29252 [ "#xyz", "before", "<b>before</b> stuff " ],
29253 [ "#xyz", "after", " stuff <i>after</i>" ],
29254 [ "#xyz", "html", "x <b>y</b> z" ]
29255 ]
29256 }
29257 !! wikitext
29258 <span id="xyz">hello</span>
29259 !! wikitext/edited
29260 '''before''' stuff <span id="xyz">x '''y''' z</span> stuff ''after''
29261 !! end
29262
29263 !! test
29264 Never serialize a-tag as html, regardless of what data-parsoid has to say
29265 !! options
29266 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
29267 !! html/parsoid
29268 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a>
29269 !! wikitext
29270 [[Foo]]
29271 !! end
29272
29273 ## SSS FIXME: This is broken output nevertheless.
29274 ## What might be a reasonable non-broken output for this?
29275 ## This is an edge case unlikely to be seen in production
29276 ## that I am not wasting more time on this right now.
29277 !! test
29278 Never serialize a-tag as html, no matter what attributes it has
29279 !! options
29280 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
29281 !! html/parsoid
29282 <a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a>
29283 !! wikitext
29284 [http://boo.org http://boohoo.org]
29285 !! end
29286
29287 # Misnested is an indication that selser can reuse the source but these have
29288 # shown to sneak through on occasion. See T101768.
29289 # The original wikitext here is: [http://test.com [[one]] two three]
29290 !! test
29291 Strip span tags added to mark misnested links
29292 !! options
29293 parsoid=html2wt
29294 !! html/parsoid
29295 <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>
29296 !! wikitext
29297 [http://test.com][[one]] two three
29298 !! end
29299
29300 !! test
29301 Catch regression when unpacking misnested links
29302 !! options
29303 parsoid=wt2html
29304 !! wikitext
29305 {{echo|hi}}[http://example.com [[ho]]]
29306 !! html/parsoid
29307 <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>
29308 !! end
29309
29310 !! test
29311 Catch regression when unpacking with trailing content
29312 !! wikitext
29313 {{echo|Foo <references/> bar}}
29314 !! html/parsoid
29315 <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>
29316 !! end
29317
29318 !! test
29319 Use data-parsoid.firstWikitextNode to compute newline constraints for template content
29320 !! options
29321 parsoid=html2wt
29322 !! html/parsoid
29323 <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|}"]}'>
29324 <tbody><tr><td>d
29325 </td></tr>
29326 </tbody></table>
29327 !! wikitext
29328 {{echo|a}}
29329 {|{{echo|c
29330 {{!}}d
29331 }}
29332 |}
29333 !! end
29334
29335 ## This test verifies the presence and computation of this attribute indirectly
29336 ## by making an edit and ensuring that the serialization is correct (which it would be
29337 ## only if firstWikitextNode is properly set).
29338 !! test
29339 data-parsoid.firstWikitextNode should be computed properly in the presence of fostered content
29340 !! options
29341 parsoid= {
29342 "modes": ["wt2wt"],
29343 "changes": [
29344 [ "div#x", "remove" ],
29345 [ "div", "before", "<div>new</div>" ]
29346 ]
29347 }
29348 !! wikitext
29349 <div id="x">foo</div>
29350 {|
29351 {{echo|<div>boo</div>
29352 {{!}}b}}
29353 |c
29354 |}
29355 !! wikitext/edited
29356
29357 <div>new</div>
29358 {|
29359 {{echo|<div>boo</div>
29360 {{!}}b}}
29361 |c
29362 |}
29363 !! end
29364
29365 # --------------------------------------------
29366 # Tests spec'ing wikitext serialization norms |
29367 # --------------------------------------------
29368
29369 !! test
29370 Serialize multi-line indent-pre starting with wikitext syntax
29371 !! options
29372 parsoid=html2wt
29373 !! html/parsoid
29374 <pre>* 1
29375 ** 2
29376 * 3</pre>
29377 !! wikitext
29378 * 1
29379 ** 2
29380 * 3
29381 !! end
29382
29383 !! test
29384 1. Categories should always be serialized on their own line
29385 !! options
29386 parsoid=html2wt
29387 !! html/parsoid
29388 foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar
29389 !! wikitext
29390 foo
29391 [[Category:Foo]]
29392 bar
29393 !! end
29394
29395 !! test
29396 2. Categories that are part of templates should not introduce a line break
29397 !! wikitext
29398 foo {{echo|<span>bar</span> [[Category:baz]]}} bar
29399 !! html/parsoid
29400 <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>
29401 !! end
29402
29403 # Careful while editing these next 2 tests. There are \u200f characters
29404 # before and after the <link> tags in the HTML and following some
29405 # of the categories in wikitext
29406 # Do not remove these characters in edits.
29407 #
29408 # As part of the serialization, these bidi characters will get stripped.
29409 !! test
29410 RTL (\u200f) and LTR (\u200e) markers around category tags should be stripped
29411 !! options
29412 parsoid={
29413 "modes": ["html2wt"],
29414 "scrubWikitext": true
29415 }
29416 !! html/parsoid
29417 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏
29418 ‏<link rel="mw:PageProp/Category" href="./קטגוריה:_שיטות_משפט" />‏</p>
29419 !! wikitext
29420 [[קטגוריה:טקסים]]
29421 [[קטגוריה: שיטות משפט]]
29422 !! end
29423
29424 !! test
29425 RTL (\u200f) and LTR (\u200e) markers should not be stripped if followed by a text node
29426 !! options
29427 parsoid={
29428 "modes": ["html2wt"],
29429 "scrubWikitext": true
29430 }
29431 !! html/parsoid
29432 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏y</p>
29433 !! wikitext
29434 [[קטגוריה:טקסים]]
29435 ‏y
29436 !! end
29437
29438 !! test
29439 Lists: Add space after bullets
29440 !! options
29441 parsoid=html2wt
29442 !! html/parsoid
29443 <ul>
29444 <li>foo</li>
29445 <li> bar</li>
29446 <li><span> baz</span></li>
29447 </ul>
29448 !! wikitext
29449 * foo
29450 * bar
29451 * <span> baz</span>
29452 !! end
29453
29454 !! test
29455 1. Headings: Add space before/after == (T53744)
29456 !! options
29457 parsoid=html2wt
29458 !! html/parsoid
29459 <h2>foo</h2>
29460 <h2> bar</h2>
29461 <h2>baz </h2>
29462 <h2><span> baz</span></h2>
29463 !! wikitext
29464 == foo ==
29465
29466 == bar ==
29467
29468 == baz ==
29469
29470 == <span> baz</span> ==
29471 !! end
29472
29473 !! test
29474 2. Headings: Add space before/after == even after hoisted content
29475 !! options
29476 parsoid={
29477 "modes": ["html2wt"],
29478 "scrubWikitext": true
29479 }
29480 !! html/parsoid
29481 <h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2>
29482 !! wikitext
29483 [[Category:A2]]
29484
29485 == ok ==
29486 !! end
29487
29488 !! test
29489 1. Headings: suppress newly created empty headings
29490 !! options
29491 parsoid={
29492 "modes": ["html2wt"],
29493 "scrubWikitext": true
29494 }
29495 !! html/parsoid
29496 <h2></h2>
29497 !! wikitext
29498 !! end
29499
29500 !! test
29501 2. Headings: don't suppress empty headings if scrubWikitext is false
29502 !! options
29503 parsoid=html2wt
29504 !! html/parsoid
29505 <h2></h2>
29506 !! wikitext
29507 ==<nowiki/>==
29508 !! end
29509
29510 !! test
29511 3. Headings: suppress empty headings on edits
29512 !! options
29513 parsoid={
29514 "modes": ["selser"],
29515 "scrubWikitext": true,
29516 "changes": [
29517 [ "#x", "remove"]
29518 ]
29519 }
29520 !! wikitext
29521 ==<span id="x">foo</span>==
29522 !! wikitext/edited
29523 !! end
29524
29525 !! test
29526 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = true)
29527 !! options
29528 parsoid={
29529 "modes": ["html2wt"],
29530 "scrubWikitext": true
29531 }
29532 !! html/parsoid
29533 <h2>foo<br/>bar</h2>
29534 <h2>foo <span><br/>bar</span> baz</h2>
29535 !! wikitext
29536 == foo bar ==
29537
29538 == foo <span> bar</span> baz ==
29539 !! end
29540
29541 !! test
29542 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = false)
29543 !! options
29544 parsoid={
29545 "modes": ["html2wt"],
29546 "scrubWikitext": false
29547 }
29548 !! html/parsoid
29549 <h2>foo<br/>bar</h2>
29550 !! wikitext
29551 == foo<br />bar ==
29552 !! end
29553
29554 !! test
29555 1. WT Quote Tags: suppress newly created empty style tags
29556 !! options
29557 parsoid={
29558 "modes": ["html2wt"],
29559 "scrubWikitext": true
29560 }
29561 !! html/parsoid
29562 <i></i><b></b>
29563 !! wikitext
29564 !! end
29565
29566 !! test
29567 2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false
29568 !! options
29569 parsoid=html2wt
29570 !! html/parsoid
29571 <i></i><b></b>
29572 !! wikitext
29573 ''<nowiki/>'''''<nowiki/>'''
29574 !! end
29575
29576 !! test
29577 3. WT Quote Tags: suppress empty style tags on edits
29578 !! options
29579 parsoid={
29580 "modes": ["selser"],
29581 "scrubWikitext": true,
29582 "changes": [
29583 [ "#x", "remove"]
29584 ]
29585 }
29586 !! wikitext
29587 '''<span id="x">foo</span>'''
29588 !! wikitext/edited
29589 !! end
29590
29591 !! test
29592 1. Anchors: suppress newly created empty anchors
29593 !! options
29594 parsoid={
29595 "modes": ["html2wt"],
29596 "scrubWikitext": true
29597 }
29598 !! html/parsoid
29599 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
29600 !! wikitext
29601 !! end
29602
29603 !! test
29604 2. Anchors: don't suppress empty anchors if scrubWikitext is false
29605 !! options
29606 parsoid={
29607 "modes": ["html2wt"],
29608 "scrubWikitext": false
29609 }
29610 !! html/parsoid
29611 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
29612 !! wikitext
29613 [[Test|<nowiki/>]]
29614 !! end
29615
29616 !! test
29617 3. Anchors: suppress empty anchors on edits
29618 !! options
29619 parsoid={
29620 "modes": ["selser"],
29621 "scrubWikitext": true,
29622 "changes": [
29623 [ "#x", "remove"]
29624 ]
29625 }
29626 !! wikitext
29627 [[Test|<span id="x">foo</span>]]
29628 !! wikitext/edited
29629 !! end
29630
29631 !! test
29632 3a. Anchors: do not suppress numbered extlinks
29633 !! options
29634 parsoid={
29635 "modes": ["wt2wt"],
29636 "scrubWikitext": true
29637 }
29638 !! wikitext
29639 [http://foo.com]
29640 !! html/parsoid
29641 <a rel="mw:ExtLink" href="http://foo.com"></a>
29642 !! end
29643
29644 !! test
29645 3b. Anchors: do not suppress numbered extlinks
29646 !! options
29647 parsoid={
29648 "modes": ["wt2wt"],
29649 "scrubWikitext": true,
29650 "changes": [
29651 [ "#x", "remove"]
29652 ]
29653 }
29654 !! wikitext
29655 [http://foo.com <span id="x">foo</span>]
29656 !! wikitext/edited
29657 [http://foo.com]
29658 !! end
29659
29660 !!test
29661 Normalizations should be restricted to edited content
29662 !!options
29663 parsoid={
29664 "modes": ["selser"],
29665 "scrubWikitext": true,
29666 "changes": [
29667 [ "h1", "before", "<i></i>"]
29668 ]
29669 }
29670 !!wikitext
29671 a
29672 = =
29673 b
29674 !!wikitext/edited
29675 a
29676 = =
29677 b
29678 !!end
29679
29680 !! test
29681 1. Multiple normalizations (html2wt)
29682 !! options
29683 parsoid={
29684 "modes": ["html2wt"],
29685 "scrubWikitext": true
29686 }
29687 !! html
29688 <h2><i></i></h2>
29689 <p><a href='Foo' rel='mw:WikiLink'>foo<i></i>
29690 </a><b><i></i></b>x</p>
29691 !! wikitext
29692
29693 [[foo]]
29694 x
29695
29696 !! end
29697
29698 !! test
29699 2. Multiple normalizations (selser)
29700 !! options
29701 parsoid={
29702 "modes": ["selser"],
29703 "scrubWikitext": true,
29704 "changes": [
29705 [ "#x", "after", "<h1><i></i></h1>\n<p> x<b></b></p>"]
29706 ]
29707 }
29708 !! wikitext
29709 <span id="x">foo</span>
29710 !! wikitext/edited
29711 <span id="x">foo</span>
29712
29713 x
29714 !! end
29715
29716 !! test
29717 1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
29718 !! options
29719 parsoid={
29720 "modes": ["html2wt"],
29721 "scrubWikitext": true
29722 }
29723 !! html/parsoid
29724 <p> hi</p>
29725 <p> hello</p>
29726 !! wikitext
29727 hi
29728
29729 hello
29730 !! end
29731
29732 !! test
29733 2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false
29734 !! options
29735 parsoid=html2wt
29736 !! html/parsoid
29737 <p> hi</p>
29738 <p> hello</p>
29739 !! wikitext
29740 <nowiki> </nowiki>hi
29741
29742 <nowiki> </nowiki> hello
29743 !! end
29744
29745 !! test
29746 3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
29747 !! options
29748 parsoid={
29749 "modes": ["html2wt"],
29750 "scrubWikitext": true
29751 }
29752 !! html/parsoid
29753 <p>Foo
29754 bar
29755 baz</p>
29756
29757 <table><tr><td>Foo
29758 bar
29759 baz bang</td></tr></table>
29760
29761 <p><!--boo--> foo
29762 bar</p>
29763
29764 <p> foo
29765 bar<span>boo</span></p>
29766 !! wikitext
29767 Foo
29768 bar
29769 baz
29770
29771 {|
29772 |Foo
29773 bar
29774 baz bang
29775 |}
29776
29777 <!--boo-->foo
29778 bar
29779
29780 foo
29781 bar<span>boo</span>
29782 !! end
29783
29784 !! test
29785 4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs
29786 !! options
29787 parsoid={
29788 "modes": ["selser"],
29789 "scrubWikitext": true,
29790 "changes": [
29791 [ "p", "html", " a\n b" ]
29792 ]
29793 }
29794 !! wikitext
29795 xyz
29796 !! wikitext/edited
29797 a
29798 b
29799 !! end
29800
29801 !! test
29802 1. New links that end in spaces
29803 !! options
29804 parsoid={
29805 "modes": ["html2wt"],
29806 "scrubWikitext": false
29807 }
29808 !! html/parsoid
29809 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
29810 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
29811 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
29812 !! wikitext
29813 [[Berlin ]]<nowiki/>is the capital of Germany.
29814
29815 [[Foo ]]'''bar'''
29816
29817 [[Boston ]] is a city.
29818 !! end
29819
29820 !! test
29821 2. New links that end in spaces
29822 !! options
29823 parsoid={
29824 "modes": ["html2wt"],
29825 "scrubWikitext": true
29826 }
29827 !! html/parsoid
29828 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
29829 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
29830 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
29831 !! wikitext
29832 [[Berlin]] is the capital of Germany.
29833
29834 [[Foo]] '''bar'''
29835
29836 [[Boston]] is a city.
29837 !! end
29838
29839 !! test
29840 1. Table cells with escapable prefixes
29841 !! options
29842 parsoid={
29843 "modes": ["html2wt"],
29844 "scrubWikitext": false
29845 }
29846 !! html
29847 <table>
29848 <tr><td>a</td></tr>
29849 <tr><td>-</td></tr>
29850 <tr><td>+</td></tr>
29851 </table>
29852 !! wikitext
29853 {|
29854 |a
29855 |-
29856 |<nowiki>-</nowiki>
29857 |-
29858 |<nowiki>+</nowiki>
29859 |}
29860 !! end
29861
29862 !! test
29863 2. Table cells with escapable prefixes
29864 !! options
29865 parsoid={
29866 "modes": ["html2wt"],
29867 "scrubWikitext": true
29868 }
29869 !! html
29870 <table>
29871 <tr><td>a</td></tr>
29872 <tr><td>-</td></tr>
29873 <tr><td>+</td></tr>
29874 </table>
29875 !! wikitext
29876 {|
29877 |a
29878 |-
29879 | -
29880 |-
29881 | +
29882 |}
29883 !! end
29884
29885 !! test
29886 3a. Table cells with escapable prefixes after edits
29887 !! options
29888 parsoid={
29889 "modes": ["selser"],
29890 "scrubWikitext": true,
29891 "changes": [
29892 [ "table tbody tr:first-child td:first-child", "remove"]
29893 ]
29894 }
29895 !! wikitext
29896 {|
29897 |a||-
29898 |}
29899 !! wikitext/edited
29900 {|
29901 | -
29902 |}
29903 !! end
29904
29905 !! test
29906 3b. Table cells with escapable prefixes after edits
29907 !! options
29908 parsoid={
29909 "modes": ["selser"],
29910 "scrubWikitext": true,
29911 "changes": [
29912 [ "table tbody tr:first-child td:first-child", "html", "-" ],
29913 [ "#x", "remove" ]
29914 ]
29915 }
29916 !! wikitext
29917 {|
29918 |pqr
29919 |<span id="x">foo</span>+
29920 |}
29921 !! wikitext/edited
29922 {|
29923 | -
29924 | +
29925 |}
29926 !! end
29927
29928 # FIXME: This test will fail because
29929 # normalization doesn't realize that the id attribute
29930 # will eliminate the escapable scenario
29931 !! test
29932 4a. Table cells without escapable prefixes after edits
29933 !! options
29934 parsoid={
29935 "modes": ["selser"],
29936 "scrubWikitext": true,
29937 "changes": [
29938 [ "#x", "html", "-" ]
29939 ]
29940 }
29941 !! wikitext
29942 {|
29943 | id="x" |abcd
29944 |}
29945 !! wikitext/edited
29946 {|
29947 | id="x" |-
29948 |}
29949 !! end
29950
29951 ## This tests normalizer's ability to discriminate between
29952 ## cells having identical content.
29953 !! test
29954 4b. Table cells without escapable prefixes after edits
29955 !! options
29956 parsoid={
29957 "modes": ["selser"],
29958 "scrubWikitext": true,
29959 "changes": [
29960 [ "td", "html", "-" ]
29961 ]
29962 }
29963 !! wikitext
29964 {|
29965 |a||b
29966 |}
29967 !! wikitext/edited
29968 {|
29969 | -||-
29970 |}
29971 !! end
29972
29973 ## This tests normalizer's ability to not be tripped by
29974 ## comments (and whitespace)
29975 !! test
29976 4c. Table cells without escapable prefixes after edits
29977 !! options
29978 parsoid={
29979 "modes": ["selser"],
29980 "scrubWikitext": true,
29981 "changes": [
29982 [ "table tbody tr td:first-child", "remove" ]
29983 ]
29984 }
29985 !! wikitext
29986 {|
29987 |-
29988 <!--foo--> |a||-
29989 |}
29990 !! wikitext/edited
29991 {|
29992 |-
29993 <!--foo--> | -
29994 |}
29995 !! end
29996
29997 ## This tests normalizer's ability to handle HTML cells
29998 !! test
29999 4d. Table cells without escapable prefixes after edits
30000 !! options
30001 parsoid={
30002 "modes": ["selser"],
30003 "scrubWikitext": true,
30004 "changes": [
30005 [ "td", "html", "-" ]
30006 ]
30007 }
30008 !! wikitext
30009 <table>
30010 <tr><td>a</td></tr>
30011 </table>
30012 !! wikitext/edited
30013 <table>
30014 <tr><td>-</td></tr>
30015 </table>
30016 !! end
30017
30018 ## T111151 Remove font elements without attributes
30019 !! test
30020 5a. font tags without attributes should be dropped in scrubWikitext mode
30021 !! options
30022 parsoid={
30023 "modes": ["html2wt"],
30024 "scrubWikitext": true
30025 }
30026 !! html
30027 <font>foo</font>
30028 <font><font>bar</font></font>
30029 <font class="x">boo</font>
30030 !! wikitext
30031 foo
30032 bar
30033 <font class="x">boo</font>
30034 !! end
30035
30036 !! test
30037 5b. font tags should not be dropped without scrubWikitext being enabled
30038 !! options
30039 parsoid={
30040 "modes": ["html2wt"],
30041 "scrubWikitext": false
30042 }
30043 !! html
30044 <font>foo</font>
30045 !! wikitext
30046 <font>foo</font>
30047 !! end
30048
30049 !! test
30050 Escape nowiki DOM elements
30051 !! options
30052 parsoid=html2wt
30053 !! html/parsoid
30054 <nowiki><i>foo</i></nowiki>
30055 !! wikitext
30056 &lt;nowiki&gt;''foo''&lt;/nowiki&gt;
30057 !! end
30058
30059 # This is meant to be an interim fix while we go about figuring out
30060 # how to not introduce these trailing <nowiki/>s in the first place.
30061 !! test
30062 T115717: Strip trailing <nowiki/>s (without affecting valid uses)
30063 !! options
30064 parsoid=html2wt
30065 !! html/parsoid
30066 <p>x<meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/>
30067 y</p>
30068 <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>
30069 <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>
30070 !! wikitext
30071 x
30072 y
30073
30074 {{echo|
30075 1 = <nowiki/>}}
30076
30077 {{echo|
30078 1 = <nowiki/>
30079 }}
30080 !! end
30081
30082 !! test
30083 New list is serialized on newlines
30084 !! options
30085 parsoid=html2wt
30086 !! html/parsoid
30087 <p>The quick brown fox jumps over the lazy dog.</p><ul>
30088 <li>Yesterday</li>
30089 <li>Today</li>
30090 <li>Tomorrow</li>
30091 </ul><p>The quick onyx goblin jumps over the lazy dwarf.</p>
30092 !! wikitext
30093 The quick brown fox jumps over the lazy dog.
30094
30095 * Yesterday
30096 * Today
30097 * Tomorrow
30098
30099 The quick onyx goblin jumps over the lazy dwarf.
30100 !! end
30101
30102 !! test
30103 New lists in formatting elements serialized w/o newlines
30104 !! options
30105 parsoid=html2wt
30106 !! html/parsoid
30107 <small>
30108
30109 <ul>
30110 <li>123</li>
30111 </ul>
30112
30113 </small>
30114
30115 <small><ul><li>hi</li></ul></small>
30116 !! wikitext
30117 <small>
30118 * 123
30119 </small>
30120
30121 <small>
30122 * hi
30123 </small>
30124 !! end
30125
30126 !! test
30127 New list in table doesn't need newlines
30128 !! options
30129 parsoid=html2wt
30130 !! html/parsoid
30131 <table><tr><td><ul><li>test</li><li>123</li></td></tr></table>
30132 !! wikitext
30133 {|
30134 |
30135 * test
30136 * 123
30137 |}
30138 !! end
30139
30140 # ---------------------------------------------------
30141 # End of tests spec'ing wikitext serialization norms |
30142 # ---------------------------------------------------
30143
30144 # T104032
30145 !! test
30146 Bare inline nodes not wrapped inside p-tags should be treated as p-wrapped
30147 !! options
30148 parsoid=html2wt
30149 !! html/parsoid
30150 a<p>b</p>
30151 <b>c</b><p>d</p>
30152 <table><tr>
30153 <td>a<p>b</p></td>
30154 <td><b>c</b><p>d</p></td>
30155 </tr></table>
30156 !! wikitext
30157 a
30158
30159 b
30160
30161 '''c'''
30162
30163 d
30164 {|
30165 |a
30166 b
30167 |'''c'''
30168 d
30169 |}
30170 !! end
30171
30172 !! test
30173 Anchor without href scenarios
30174 !! options
30175 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
30176 !! html/parsoid
30177 <a class="bc"></a>
30178 <a class="no">dice</a>
30179 <a name="foo"></a>
30180 !! wikitext
30181
30182 dice
30183 <span name="foo"></span>
30184 !! end
30185
30186 !! test
30187 New transclusion added after a list should be serialized after the list
30188 !! options
30189 parsoid=html2wt
30190 !! html/parsoid
30191 <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>
30192 !! wikitext
30193 * a
30194 {{echo|foo}}
30195 !! end
30196
30197 # -----------------------------------------------------------------
30198 # End of section for Parsoid-only html2wt tests for serialization
30199 # of new content
30200 # -----------------------------------------------------------------
30201
30202 # -----------------------------------------------------------------
30203 # The following section of tests are primarily to spec behavior of
30204 # the selective serializer. All these tests have manual selser
30205 # changes. The automated selser changes for all tests handle the
30206 # wide variation of changes, but these tests here capture specs
30207 # deterministically.
30208 # ----------------------------------------------------------------
30209
30210 ## T90517
30211 !! test
30212 Selser: New comments should not be lost
30213 !! options
30214 parsoid={
30215 "modes": ["selser"],
30216 "changes": [
30217 [ "#a", "after", "<!--c1-->" ],
30218 [ "#b", "before", "<!--c2-->" ]
30219 ]
30220 }
30221 !! wikitext
30222 <span id="a">a</span>
30223
30224 <span id="b">b</span>
30225 !! wikitext/edited
30226 <span id="a">a</span><!--c1-->
30227
30228 <!--c2--><span id="b">b</span>
30229 !! end
30230
30231 ## T89383
30232 !! test
30233 Selser: Check for validity of DSR before using it
30234 !! options
30235 parsoid={
30236 "modes": ["selser"],
30237 "changes": [
30238 [ "#a", "before", "<meta property='mw:PageProp/displaytitle' content='foo'>" ]
30239 ]
30240 }
30241 !! wikitext
30242 <span id="a">a</span>
30243 !! wikitext/edited
30244 {{DISPLAYTITLE:foo}}
30245 <span id="a">a</span>
30246 !! end
30247
30248 !! test
30249 1. DOMDiff: Changes to <ref> content should be looked up using id
30250 !! options
30251 parsoid={
30252 "modes": ["selser"],
30253 "changes": [
30254 ["#X", "after", "bar"],
30255 ["#Y", "after", "baz"]
30256 ]
30257 }
30258 !! wikitext
30259 X <ref><span id="X">foo</span></ref>
30260 Y <ref name="a" />
30261 <references>
30262 <ref name="a"><span id="Y">foo</span></ref>
30263 </references>
30264 !! wikitext/edited
30265 X <ref><span id="X">foo</span>bar</ref>
30266 Y <ref name="a" />
30267 <references>
30268 <ref name="a"><span id="Y">foo</span>baz</ref>
30269 </references>
30270 !! end
30271
30272 !! test
30273 2. DOMDiff: Changes to <ref> content should be looked up using id
30274 !! options
30275 parsoid={
30276 "modes": ["selser"],
30277 "changes": [
30278 ["#Z", "after", "bar"]
30279 ]
30280 }
30281 !! wikitext
30282 A <ref>foo bar for a</ref>
30283 B <ref group="X" name="b" />
30284
30285 <references />
30286
30287 <references group="X">
30288 <ref name="b"><span id="Z">foo</span></ref>
30289 </references>
30290 !! wikitext/edited
30291 A <ref>foo bar for a</ref>
30292 B <ref group="X" name="b" />
30293
30294 <references />
30295
30296 <references group="X">
30297 <ref name="b"><span id="Z">foo</span>bar</ref>
30298 </references>
30299 !! end
30300
30301 !! test
30302 DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388)
30303 !! options
30304 parsoid={
30305 "modes": ["selser"],
30306 "changes": [
30307 [ "div:first-child", "text", "bar" ]
30308 ]
30309 }
30310 !! wikitext
30311 <div style="{{1x|color:red;}}%">foo</div>
30312 !! wikitext/edited
30313 <div style="{{1x|color:red;}}%">bar</div>
30314 !! end
30315
30316 !! test
30317 Empty LI (T49673)
30318 !! wikitext
30319 *a
30320 *
30321 *
30322 *b
30323 !! html+tidy
30324 <ul><li>a</li>
30325 <li class="mw-empty-elt"></li>
30326 <li class="mw-empty-elt"></li>
30327 <li>b</li></ul>
30328 !! end
30329
30330 !! test
30331 Thumbnail output
30332 !! wikitext
30333 [[File:Thumb.png|thumb]]
30334 !! html/php+tidy
30335 <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>
30336 !! html/parsoid
30337 <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>
30338 !! end
30339
30340 !! test
30341 unclosed internal link XSS (T137264)
30342 !! wikitext
30343 [[#%3Cscript%3Ealert(1)%3C/script%3E|
30344 !! html/php
30345 <p>[[#&lt;script&gt;alert(1)&lt;/script&gt;|
30346 </p>
30347 !! html/parsoid
30348 <p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p>
30349 !! end
30350
30351 !! test
30352 Validating that <style> isn't eaten by tidy (T167349)
30353 !! options
30354 styletag=1
30355 !! wikitext
30356 <div class="foo">
30357 <style>.foo::before { content: "<foo>"; }</style>
30358 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
30359 </div>
30360 !! html/php+tidy
30361 <div class="foo">
30362 <style>.foo::before { content: "<foo>"; }</style>
30363 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
30364 </div>
30365 !! end
30366
30367 !! test
30368 Validating that <style> isn't wrapped in a paragraph (T186965)
30369 !! options
30370 styletag=1
30371 !! wikitext
30372 A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
30373
30374 <style>.foo::before { content: "<foo>"; }</style>
30375
30376 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
30377
30378 But if it's on a line with other content, let it be wrapped.
30379
30380 <style>.foo::before { content: "<foo>"; }</style> bar
30381
30382 foo <style>.foo::before { content: "<foo>"; }</style>
30383
30384 foo <style>.foo::before { content: "<foo>"; }</style> bar
30385
30386 And the same if we have non-paragraph-breaking whitespace
30387
30388 foo
30389 <style>.foo::before { content: "<foo>"; }</style>
30390 bar
30391 !! html/php
30392 <p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
30393 </p>
30394 <style>.foo::before { content: "<foo>"; }</style>
30395 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
30396 <p>But if it's on a line with other content, let it be wrapped.
30397 </p><p><style>.foo::before { content: "<foo>"; }</style> bar
30398 </p><p>foo <style>.foo::before { content: "<foo>"; }</style>
30399 </p><p>foo <style>.foo::before { content: "<foo>"; }</style> bar
30400 </p><p>And the same if we have non-paragraph-breaking whitespace
30401 </p><p>foo
30402 <style>.foo::before { content: "<foo>"; }</style>
30403 bar
30404 </p>
30405 !! end
30406
30407 !! test
30408 Validating that <link> isn't wrapped in a paragraph (T186965)
30409 !! options
30410 styletag=1
30411 !! wikitext
30412 A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
30413
30414 <link rel="foo" href="bar"/>
30415
30416 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
30417
30418 But if it's on a line with other content, let it be wrapped.
30419
30420 <link rel="foo" href="bar"/> bar
30421
30422 foo <link rel="foo" href="bar"/>
30423
30424 foo <link rel="foo" href="bar"/> bar
30425
30426 And the same if we have non-paragraph-breaking whitespace
30427
30428 foo
30429 <link rel="foo" href="bar"/>
30430 bar
30431 !! html/php
30432 <p>A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
30433 </p>
30434 <link rel="foo" href="bar"/>
30435 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
30436 <p>But if it's on a line with other content, let it be wrapped.
30437 </p><p><link rel="foo" href="bar"/> bar
30438 </p><p>foo <link rel="foo" href="bar"/>
30439 </p><p>foo <link rel="foo" href="bar"/> bar
30440 </p><p>And the same if we have non-paragraph-breaking whitespace
30441 </p><p>foo
30442 <link rel="foo" href="bar"/>
30443 bar
30444 </p>
30445 !! end
30446
30447 !! test
30448 Decoding of HTML entities in headings and links for IDs and link fragments (T103714)
30449 !! config
30450 wgFragmentMode=[ 'html5', 'legacy' ]
30451 !! wikitext
30452 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
30453 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
30454 !! html/php
30455 <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>
30456 <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>
30457 </p>
30458 !! html/parsoid
30459 <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>
30460 <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>
30461 !! end
30462
30463 !! test
30464 Decoding of HTML entities in headings and links for IDs and link fragments (T103714) (legacy)
30465 !! config
30466 wgFragmentMode=[ 'legacy' ]
30467 !! wikitext
30468 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
30469 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
30470 !! html/php
30471 <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>
30472 <p><a href="#A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a>
30473 </p>
30474 !! end
30475
30476 !! test
30477 Decoding of HTML entities in embedded HTML tags
30478 !! wikitext
30479 <table class="1&2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
30480 !! html/php
30481 <table class="1&amp;2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
30482
30483 !! html/parsoid
30484 <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>
30485 !! end
30486
30487 !! test
30488 Decoding of HTML entities in indicator names for IDs (T104196)
30489 !! options
30490 parsoid=wt2html,html2html
30491 showindicators
30492 !! wikitext
30493 <indicator name="1&2&amp;3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
30494 !! html/php
30495 1&2&3&amp;4&amp;amp;5=Indicator
30496
30497 !! html/parsoid
30498 <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>
30499 !! end
30500
30501 # this version of the test strips out the ambiguity so Parsoid rts cleanly
30502 !! test
30503 Decoding of HTML entities in indicator names for IDs (unambiguous) (T104196)
30504 !! options
30505 showindicators
30506 !! wikitext
30507 <indicator name="1&2&3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
30508 !! html/php
30509 1&2&3&amp;4&amp;amp;5=Indicator
30510
30511 !! html/parsoid
30512 <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>
30513 !! end
30514
30515 # This fragment mode is what Parsoid supports.
30516 !! test
30517 HTML5 ids: fallback to legacy
30518 !! config
30519 wgFragmentMode=[ 'html5', 'legacy' ]
30520 !! wikitext
30521 ==Foo bar==
30522
30523 ==foo Bar==
30524
30525 ==Тест==
30526
30527 ==Тест==
30528
30529 ==тест==
30530
30531 ==Hey < # " > % : '==
30532 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
30533
30534 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
30535
30536 <!-- These two links should produce identical HTML -->
30537 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
30538
30539 !! html/php
30540 <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>
30541 <ul>
30542 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
30543 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
30544 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
30545 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
30546 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
30547 <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>
30548 </ul>
30549 </div>
30550
30551 <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>
30552 <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>
30553 <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>
30554 <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>
30555 <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>
30556 <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>
30557 <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>
30558 </p><p>💩 <span id="💩"></span>
30559 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
30560 </p>
30561 !! html/parsoid
30562 <h2 id="Foo_bar">Foo bar</h2>
30563
30564 <h2 id="foo_Bar_2">foo Bar</h2>
30565
30566 <h2 id="Тест"><span id=".D0.A2.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>Тест</h2>
30567
30568 <h2 id="Тест_2"><span id=".D0.A2.D0.B5.D1.81.D1.82_2" typeof="mw:FallbackId"></span>Тест</h2>
30569
30570 <h2 id="тест"><span id=".D1.82.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>тест</h2>
30571
30572 <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>
30573 <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>
30574
30575 <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>
30576
30577 <!-- These two links should produce identical HTML -->
30578 <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>
30579 !! end
30580
30581 # Parsoid doesn't support this mode
30582 !! test
30583 HTML5 ids: legacy with a fallback to modern
30584 !! config
30585 wgFragmentMode=[ 'legacy', 'html5' ]
30586 !! wikitext
30587 ==Foo bar==
30588
30589 ==foo Bar==
30590
30591 ==Тест==
30592
30593 ==Тест==
30594
30595 ==тест==
30596
30597 ==Hey < # " > % : '==
30598 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
30599
30600 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
30601
30602 <!-- These two links should produce identical HTML -->
30603 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
30604
30605 !! html/php
30606 <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>
30607 <ul>
30608 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
30609 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
30610 <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>
30611 <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>
30612 <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>
30613 <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>
30614 </ul>
30615 </div>
30616
30617 <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>
30618 <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>
30619 <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>
30620 <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>
30621 <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>
30622 <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>
30623 <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>
30624 </p><p>.F0.9F.92.A9 <span id=".F0.9F.92.A9"></span>
30625 </p><p><a href="#.E5.95.A4.E9.85.92">#啤酒</a> <a href="#.E5.95.A4.E9.85.92">#啤酒</a>
30626 </p>
30627 !! end
30628
30629 # Parsoid doesn't support this mode.
30630 !! test
30631 HTML5 ids: no legacy
30632 !! config
30633 wgFragmentMode=[ 'html5' ]
30634 !! wikitext
30635 ==Foo bar==
30636
30637 ==foo Bar==
30638
30639 ==Тест==
30640
30641 ==Тест==
30642
30643 ==тест==
30644
30645 ==Hey < # " > % : '==
30646 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
30647
30648 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
30649
30650 <!-- These two links should produce identical HTML -->
30651 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
30652
30653 !! html/php
30654 <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>
30655 <ul>
30656 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
30657 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
30658 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
30659 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
30660 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
30661 <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>
30662 </ul>
30663 </div>
30664
30665 <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>
30666 <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>
30667 <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>
30668 <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>
30669 <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>
30670 <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>
30671 <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>
30672 </p><p>💩 <span id="💩"></span>
30673 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
30674 </p>
30675 !! end
30676
30677 !! test
30678 T90902: Normalize weird characters in section IDs
30679 !! config
30680 wgFragmentMode=[ 'html5', 'legacy' ]
30681 !! wikitext
30682 ==Foo&nbsp;bar==
30683 [[#Foo&nbsp;bar]]
30684
30685 !! html/php
30686 <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>
30687 <p><a href="#Foo_bar">#Foo&#160;bar</a>
30688 </p>
30689 !! html/parsoid
30690 <h2 id="Foo_bar"> Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span>bar </h2>
30691 <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>
30692 !! end
30693
30694 !! test
30695 T51672: Test for brackets in attributes of elements in external link texts
30696 !! wikitext
30697 [http://example.com/ link <span title="title with [brackets]">span</span>]
30698 [http://example.com/ link <span title="title with &#91;brackets&#93;">span</span>]
30699
30700 !! html/php
30701 <p><a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
30702 <a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
30703 </p>
30704 !! html/parsoid
30705 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/">link <span title="title with [brackets]">span</span></a>
30706 <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>
30707 !! end
30708
30709 !! test
30710 T72875: Test for brackets in attributes of elements in internal link texts
30711 !! wikitext
30712 [[Foo|link <span title="title with [[double brackets]]">span</span>]]
30713 [[Foo|link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span>]]
30714
30715 !! html/php
30716 <p><a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
30717 <a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
30718 </p>
30719 !! html/parsoid
30720 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">link <span title="title with [[double brackets]]">span</span></a>
30721 <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>
30722 !! end
30723
30724 !! test
30725 T179544: {{anchorencode:}} output should be always usable in links
30726 !! config
30727 wgFragmentMode=[ 'html5' ]
30728 !! wikitext
30729 <span id="{{anchorencode:[foo]}}"></span>[[#{{anchorencode:[foo]}}]]
30730 !! html/php
30731 <p><span id="&#91;foo&#93;"></span><a href="#[foo]">#&#91;foo&#93;</a>
30732 </p>
30733 !! html/parsoid
30734 <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>
30735 !! end
30736
30737 ## ------------------------------
30738 ## Parsoid section-wrapping tests
30739 ## ------------------------------
30740 !! test
30741 Section wrapping for well-nested sections (no leading content)
30742 !! options
30743 parsoid={
30744 "wrapSections": true
30745 }
30746 !! wikitext
30747 =1=
30748 a
30749
30750 =2=
30751 b
30752
30753 ==2.1==
30754 c
30755
30756 ==2.2==
30757 d
30758
30759 ===2.2.1===
30760 e
30761
30762 =3=
30763 f
30764 !! html/parsoid
30765 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
30766 <p>a</p>
30767
30768 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
30769 <p>b</p>
30770
30771 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
30772 <p>c</p>
30773
30774 </section><section data-mw-section-id="4"><h2 id="2.2">2.2</h2>
30775 <p>d</p>
30776
30777 <section data-mw-section-id="5"><h3 id="2.2.1">2.2.1</h3>
30778 <p>e</p>
30779
30780 </section></section></section><section data-mw-section-id="6"><h1 id="3">3</h1>
30781 <p>f</p>
30782
30783 </section>
30784 !! end
30785
30786 !! test
30787 Section wrapping for well-nested sections (with leading content)
30788 !! options
30789 parsoid={
30790 "wrapSections": true
30791 }
30792 !! wikitext
30793 Para 1.
30794
30795 Para 2 with a <div>nested in it</div>
30796
30797 Para 3.
30798
30799 =1=
30800 a
30801
30802 =2=
30803 b
30804
30805 ==2.1==
30806 c
30807 !! html/parsoid
30808 <section data-mw-section-id="0"><p>Para 1.</p>
30809
30810 <p>Para 2 with a </p><div>nested in it</div>
30811
30812 <p>Para 3.</p>
30813
30814 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
30815 <p>a</p>
30816
30817 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
30818 <p>b</p>
30819
30820 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
30821 <p>c</p>
30822
30823 </section></section>
30824 !! end
30825
30826 !! test
30827 Section wrapping with template-generated sections (good nesting 1)
30828 !! options
30829 parsoid={
30830 "wrapSections": true
30831 }
30832 !! wikitext
30833 =1=
30834 a
30835
30836 {{echo|1=
30837 ==1.1==
30838 b
30839 }}
30840
30841 ==1.2==
30842 c
30843
30844 =2=
30845 d
30846 !! html/parsoid
30847 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
30848 <p>a</p>
30849
30850 <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">
30851 </span><p about="#mwt1">b</p>
30852 </section><section data-mw-section-id="3"><h2 id="1.2">1.2</h2>
30853 <p>c</p>
30854
30855 </section></section><section data-mw-section-id="4"><h1 id="2">2</h1>
30856 <p>d</p></section>
30857 !! end
30858
30859 # In this example, the template scope is mildly expanded to incorporate the
30860 # trailing newline after the transclusion since that is part of section 1.1.1
30861 !! test
30862 Section wrapping with template-generated sections (good nesting 2)
30863 !! options
30864 parsoid={
30865 "wrapSections": true,
30866 "modes": ["wt2html", "wt2wt"]
30867 }
30868 !! wikitext
30869 =1=
30870 a
30871
30872 {{echo|1=
30873 ==1.1==
30874 b
30875 ===1.1.1===
30876 d
30877 }}
30878 =2=
30879 e
30880 !! html/parsoid
30881 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
30882 <p>a</p>
30883
30884 <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">
30885 </span><p about="#mwt1">b</p><span about="#mwt1">
30886 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.1.1">1.1.1</h3><span about="#mwt1">
30887 </span><p about="#mwt1">d</p><span about="#mwt1">
30888 </span></section></section></section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="2">2</h1>
30889 <p>e</p></section>
30890 !! end
30891
30892 # In this example, the template scope is mildly expanded to incorporate the
30893 # trailing newline after the transclusion since that is part of section 1.2.1
30894 !! test
30895 Section wrapping with template-generated sections (good nesting 3)
30896 !! options
30897 parsoid={
30898 "wrapSections": true,
30899 "modes": ["wt2html", "wt2wt"]
30900 }
30901 !! wikitext
30902 =1=
30903 a
30904
30905 {{echo|1=
30906 x
30907 ==1.1==
30908 b
30909 ==1.2==
30910 c
30911 ===1.2.1===
30912 d
30913 }}
30914 =2=
30915 e
30916 !! html/parsoid
30917 <section data-mw-section-id="0"></section><section data-mw-section-id="1" data-parsoid="{}"><h1 id="1"> 1 </h1>
30918 <p>a</p>
30919
30920 <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">
30921 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.1">1.1</h2><span about="#mwt1">
30922 </span><p about="#mwt1">b</p><span about="#mwt1">
30923 </span></section><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.2">1.2</h2><span about="#mwt1">
30924 </span><p about="#mwt1">c</p><span about="#mwt1">
30925 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.2.1">1.2.1</h3><span about="#mwt1">
30926 </span><p about="#mwt1">d</p><span about="#mwt1">
30927 </span></section></section></section><section data-mw-section-id="5"><h1 id="2">2</h1>
30928 <p>e</p></section>
30929 !! end
30930
30931 # Because of section-wrapping and template-wrapping interactions,
30932 # the scope of the template is expanded so that the template markup
30933 # is valid in the presence of <section> tags.
30934 # This exercises the s1 is null scenario in the wrapSections code
30935 !! test
30936 Section wrapping with template-generated sections (bad nesting 1)
30937 !! options
30938 parsoid={
30939 "wrapSections": true
30940 }
30941 !! wikitext
30942 <div>
30943 a
30944
30945 {{echo|
30946 =1=
30947 b
30948 }}
30949
30950 c
30951 </div>
30952 !! html/parsoid
30953 <section data-mw-section-id="-1"></section><section data-mw-section-id="-2"><div data-parsoid='{"stx":"html"}'>
30954 <p>a</p>
30955
30956 <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"]}'>
30957 </span><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="1">1</h1><span about="#mwt1">
30958 </span><p about="#mwt1">b
30959 </p><span about="#mwt1">
30960
30961 </span><p about="#mwt1">c</p><span about="#mwt1">
30962 </span></section></div></section>
30963 !! end
30964
30965 # Because of section-wrapping and template-wrapping interactions,
30966 # the scope of the template is expanded so that the template markup
30967 # is valid in the presence of <section> tags.
30968 # This exercises the s1 is ancestor of s2 scenario in the wrapSections code
30969 !! test
30970 Section wrapping with template-generated sections (bad nesting 2)
30971 !! options
30972 parsoid={
30973 "wrapSections": true
30974 }
30975 !! wikitext
30976 =1=
30977 a
30978
30979 {{echo|1=
30980 =2=
30981 b
30982 ==2.1==
30983 c
30984 }}
30985
30986 d
30987
30988 =3=
30989 e
30990 !! html/parsoid
30991 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
30992 <p>a</p>
30993
30994 </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">
30995 </span><p about="#mwt1">b</p><span about="#mwt1">
30996 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="2.1">2.1</h2><span about="#mwt1">
30997 </span><p about="#mwt1">c</p><span about="#mwt1">
30998
30999 </span><p about="#mwt1">d</p><span about="#mwt1">
31000
31001 </span></section></section><section data-mw-section-id="4"><h1 id="3">3</h1>
31002 <p>e</p></section>
31003 !! end
31004
31005 # Because of section-wrapping and template-wrapping interactions,
31006 # additional template wrappers are added to <section> tags
31007 # so that template wrapping semantics are valid whether section
31008 # tags are retained or stripped. But, the template scope can expand
31009 # greatly when accounting for section tags.
31010 # This exercises the s1 and s2 are in different subtrees scenario
31011 !! test
31012 Section wrapping with template-generated sections (bad nesting 3)
31013 !! options
31014 parsoid={
31015 "wrapSections": true,
31016 "modes": ["wt2html", "wt2wt"]
31017 }
31018 !! wikitext
31019 =1=
31020 a
31021
31022 {{echo|1=
31023 ==1.2==
31024 b
31025 =2=
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" 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>
31035 <p>a</p>
31036
31037 <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">
31038 </span><p about="#mwt1">b</p><span about="#mwt1">
31039 </span></section></section><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="2">2</h1><span about="#mwt1">
31040 </span><p about="#mwt1">c</p>
31041
31042 <p>d</p>
31043 </section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="3">3</h1>
31044 <p>e</p></section>
31045 !! end
31046
31047 !! test
31048 Section wrapping with uneditable lead section + div wrapping multiple sections
31049 !! options
31050 parsoid={
31051 "wrapSections": true
31052 }
31053 !! wikitext
31054 foo
31055
31056 <div style="border:1px solid red;">
31057 =1=
31058 a
31059
31060 ==1.1==
31061 b
31062
31063 =2=
31064 c
31065 </div>
31066
31067 =3=
31068 d
31069
31070 ==3.1==
31071 e
31072 !! html/parsoid
31073 <section data-mw-section-id="-1"><p>foo</p>
31074
31075 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
31076 <section data-mw-section-id="1"><h1 id="1">1</h1>
31077 <p>a</p>
31078
31079 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
31080 <p>b</p>
31081
31082 </section></section><section data-mw-section-id="-1"><h1 id="2">2</h1>
31083 <p>c</p>
31084 </section></div>
31085
31086 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
31087 <p>d</p>
31088
31089 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
31090 <p>e</p>
31091 </section></section>
31092 !! end
31093
31094 !! test
31095 Section wrapping with editable lead section + div overlapping multiple sections
31096 !! options
31097 parsoid={
31098 "wrapSections": true
31099 }
31100 !! wikitext
31101 foo
31102
31103 =1=
31104 a
31105 <div style="border:1px solid red;">
31106 b
31107
31108 ==1.1==
31109 c
31110
31111 =2=
31112 d
31113 </div>
31114 e
31115
31116 =3=
31117 f
31118
31119 ==3.1==
31120 g
31121 !! html/parsoid
31122 <section data-mw-section-id="0"><p>foo</p>
31123
31124 </section><section data-mw-section-id="-1"><h1 id="1">1</h1>
31125 <p>a</p>
31126 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
31127 <p>b</p>
31128
31129 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
31130 <p>c</p>
31131
31132 </section><section data-mw-section-id="-1"><h1 id="2">2</h1>
31133 <p>d</p>
31134 </section></div>
31135 <p>e</p>
31136
31137 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
31138 <p>f</p>
31139
31140 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
31141 <p>g</p>
31142 </section></section>
31143 !! end
31144
31145 !! test
31146 HTML header tags should not be wrapped in section tags
31147 !! options
31148 parsoid={
31149 "wrapSections": true
31150 }
31151 !! wikitext
31152 foo
31153
31154 <h1>a</h1>
31155
31156 =b=
31157
31158 <h1>c</h1>
31159
31160 =d=
31161 !! html/parsoid
31162 <section data-mw-section-id="0"><p>foo</p>
31163
31164 <h1 id="a" data-parsoid='{"stx":"html"}'>a</h1>
31165
31166 </section><section data-mw-section-id="1"><h1 id="b">b</h1>
31167
31168 <h1 id="c" data-parsoid='{"stx":"html"}'>c</h1>
31169
31170 </section><section data-mw-section-id="2"><h1 id="d">d</h1></section>
31171 !! end
31172
31173 !! test
31174 Lead section containing only whitespace and comments.
31175 !! options
31176 parsoid={
31177 "wrapSections": true
31178 }
31179 !! wikitext
31180
31181 <!-- this is a comment, presumably significant to editors -->
31182 =1=
31183 a
31184
31185 =2=
31186 b
31187 !! html/parsoid
31188 <section data-mw-section-id="0" data-parsoid="{}">
31189 <!-- this is a comment, presumably significant to editors -->
31190 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
31191 <p>a</p>
31192
31193 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
31194 <p>b</p></section>
31195 !! end
31196
31197 !! test
31198 Pseudo-sections emitted by templates should have id -2
31199 !! options
31200 parsoid={
31201 "wrapSections": true
31202 }
31203 !! wikitext
31204 foo
31205 {{echo|<div>
31206 ==a==
31207 ==b==
31208 </div>
31209 }}
31210 !! html/parsoid
31211 <section data-mw-section-id="-1"><p>foo</p>
31212 </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}}]}'>
31213 <section data-mw-section-id="-1"><h2 id="a">a</h2>
31214 </section><section data-mw-section-id="-1"><h2 id="b">b</h2>
31215 </section></div><span about="#mwt1">
31216 </span></section>
31217 !! end
31218
31219 ##########################################################################
31220 Tests demonstrating white-space insensitivity in input wikitext
31221 for wikitext headings, wikitext list items, and wikitext table captions,
31222 headings, and cells. HTML versions of the same should preserve whitespace.
31223 ##########################################################################
31224 !! test
31225 Trim whitespace in wikitext headings, list items, table captions, headings, and cells
31226 !! options
31227 parsoid={
31228 "modes": ["wt2html"],
31229 "preserveIEW": true
31230 }
31231 !! wikitext
31232 __NOTOC__
31233 == <!--c1--> <!--c2--> Spaces <!--c3--> <!--c4--> ==
31234 == <!--c1--> <!--c2--> Tabs <!--c3--><!--c4--> ==
31235 == <!--Headings with fallback ids--> Личная жизнь ==
31236 * <!--c1--> <!--c2--> List item <!--c3--> <!--c4-->
31237 ; <!--term to define--> term : <!--term's definition--> definition
31238 {|
31239 |+ <!--c1--> <!--c2--> Table Caption <!--c3--> <!--c4-->
31240 |-
31241 ! <!--c1--> <!--c2--> Table Heading 1 <!--c3--> <!--c4--> !! Table Heading 2 <!--c5-->
31242 |-
31243 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
31244 |-
31245 | class="foo" || <!--c1--> <!--c2--> Table Cell 3 <!--c3--> <!--c4-->
31246 |-
31247 | <!--c1--> testing [[one|two]] <!--c2--> | <!--c3--> some content
31248 |}
31249 : {|
31250 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
31251 |} foo <!--c1-->
31252 !! html/php+tidy
31253 <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>
31254 <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>
31255 <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>
31256 <ul><li>List item</li></ul>
31257 <dl><dt>term&#160;</dt>
31258 <dd>definition</dd></dl>
31259 <table>
31260 <caption>Table Caption
31261 </caption>
31262 <tbody><tr>
31263 <th>Table Heading 1</th>
31264 <th>Table Heading 2
31265 </th></tr>
31266 <tr>
31267 <td>Table Cell 1</td>
31268 <td>Table Cell 2
31269 </td></tr>
31270 <tr>
31271 <td>class="foo"</td>
31272 <td>Table Cell 3
31273 </td></tr>
31274 <tr>
31275 <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
31276 </td></tr></tbody></table>
31277 <dl><dd><table>
31278 <tbody><tr>
31279 <td>Table Cell 1</td>
31280 <td>Table Cell 2
31281 </td></tr></tbody></table> foo</dd></dl>
31282 !! html/parsoid
31283 <meta property="mw:PageProp/notoc">
31284 <h2 id="Spaces"><!--c1--><!--c2-->Spaces<!--c3--><!--c4--></h2>
31285 <h2 id="Tabs"><!--c1--><!--c2-->Tabs<!--c3--><!--c4--></h2>
31286 <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>
31287 <ul><li><!--c1--><!--c2-->List item<!--c3--><!--c4--></li></ul>
31288 <dl><dt><!--term to define-->term&nbsp;</dt><dd><!--term's definition-->definition</dd></dl>
31289 <table>
31290 <caption><!--c1--><!--c2-->Table Caption<!--c3--><!--c4--></caption>
31291 <tbody><tr>
31292 <th><!--c1--><!--c2-->Table Heading 1<!--c3--><!--c4--></th><th>Table Heading 2<!--c5--></th></tr>
31293 <tr>
31294 <td><!--c1--><!--c2-->Table Cell 1<!--c3--><!--c4--></td><td>Table Cell 2<!--c5--></td></tr>
31295 <tr>
31296 <td>class="foo"</td><td><!--c1--><!--c2-->Table Cell 3<!--c3--><!--c4--></td></tr>
31297 <tr>
31298 <td><!--c1-->testing <a rel="mw:WikiLink" href="./One" title="One">two</a> <!--c2--> | <!--c3--> some content</td></tr>
31299 </tbody></table>
31300 <dl><dd><table>
31301 <tbody><tr><td><!--c1--><!--c2-->Table Cell 1<!--c3--><!--c4--></td><td>Table Cell 2<!--c5--></td></tr>
31302 </tbody></table><p> foo </p><!--c1--></dd></dl>
31303 !! end
31304
31305 # Looks like <caption> is not accepted in HTML
31306 !! test
31307 Do not trim whitespace in HTML headings, list items, table captions, headings, and cells
31308 !! options
31309 parsoid={
31310 "modes": ["wt2html"],
31311 "preserveIEW": true
31312 }
31313 !! wikitext
31314 __NOTOC__
31315 <h2> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
31316 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
31317 <table>
31318 <tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> <th></tr>
31319 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> <th></tr>
31320 </table>
31321 !! html/php+tidy
31322 <h2><span class="mw-headline" id="Heading"> Heading </span></h2>
31323 <ul><li> List item </li></ul>
31324 <table>
31325 <tbody><tr><th> Table Heading </th><th></th></tr>
31326 <tr><td> Table Cell </td><th></th></tr>
31327 </tbody></table>
31328 !! html/parsoid
31329 <meta property="mw:PageProp/notoc"/>
31330 <h2 id="Heading"> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
31331 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
31332 <table>
31333 <tbody><tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> </th><th></th></tr>
31334 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> </td><th></th></tr>
31335 </tbody></table>
31336 !! end
31337
31338 !! test
31339 Do not trim whitespace in links and quotes
31340 !! options
31341 parsoid={
31342 "modes": ["wt2html"],
31343 "preserveIEW": true
31344 }
31345 !! wikitext
31346 foo '' <!--c1--> italic <!--c2--> '' and ''' <!--c3--> bold <!--c4--> '''
31347 [[Foo| some text ]]
31348 !! html/php+tidy
31349 <p>foo <i> italic </i> and <b> bold </b>
31350 <a href="/wiki/Foo" title="Foo"> some text </a>
31351 </p>
31352 !! html/parsoid
31353 <p>foo <i> <!--c1--> italic <!--c2--> </i> and <b> <!--c3--> bold <!--c4--> </b>
31354 <a rel="mw:WikiLink" href="./Foo" title="Foo"> some text </a></p>
31355 !! end
31356
31357 !! test
31358 Remove p tags surrounding a single element in a figcaption
31359 !! options
31360 parsoid=html2wt
31361 !! wikitext
31362 [[File:Foobar.jpg|right|200x200px|Caption]]
31363 !! html/parsoid
31364 <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>
31365 !! end
31366
31367 !! test
31368 Selser preserves lack of newline before list and allows newline after the list
31369 !! options
31370 parsoid={
31371 "modes": ["selser"],
31372 "scrubWikitext": true,
31373 "changes": [
31374 [ "ul", "after", "<p>footer</p>" ]
31375 ]
31376 }
31377 !! wikitext
31378 header
31379 *foo
31380 *bar
31381 !! wikitext/edited
31382 header
31383 *foo
31384 *bar
31385
31386 footer
31387 !! end
31388
31389
31390 !! test
31391 Selser does not introduce newlines between unedited paragraph preceding the list
31392 !! options
31393 parsoid={
31394 "modes": ["selser"],
31395 "changes": [
31396 [ "table tbody tr td p:last-child", "empty" ]
31397 ]
31398 }
31399 !! wikitext
31400 {|
31401 |
31402 header
31403 *foo
31404 *bar
31405 footer
31406 |}
31407 !! wikitext/edited
31408 {|
31409 |
31410 header
31411 *foo
31412 *bar
31413
31414 |}
31415 !! end
31416
31417 !! test
31418 Selser does not introduce newlines between unedited paragraph following the list
31419 !! options
31420 parsoid={
31421 "modes": ["selser"],
31422 "changes": [
31423 [ "table tbody tr td p:first-child", "empty" ]
31424 ]
31425 }
31426 !! wikitext
31427 {|
31428 |
31429 header
31430 *foo
31431 *bar
31432 footer
31433 |}
31434 !! wikitext/edited
31435 {|
31436 |
31437
31438 *foo
31439 *bar
31440 footer
31441 |}
31442 !! end
31443
31444 !! test
31445 Remove a list item but do not insert newline above list
31446 !! options
31447 parsoid={
31448 "modes": ["selser"],
31449 "changes": [
31450 [ "ul li:last-child", "remove" ]
31451 ]
31452 }
31453 !! wikitext
31454 header
31455 *foo
31456 *bar
31457 footer
31458 !! wikitext/edited
31459 header
31460 *foo
31461 footer
31462 !! end