Protect legacy URL parameter syntax in link and alt options
[lhc/web/wiklou.git] / tests / parser / parserTests.txt
1 # MediaWiki Parser test cases
2 # Some taken from https://meta.wikimedia.org/wiki/Parser_testing
3 # All (C) their respective authors and released under the GPL
4 #
5 # The syntax should be fairly self-explanatory.
6 #
7 # Currently supported test options:
8 # One of the following three:
9 #
10 # (default) generate HTML output
11 # pst apply pre-save transform
12 # msg apply message transform
13 #
14 # Plus any combination of these:
15 #
16 # cat add category links
17 # (ignored by Parsoid, since it emits <link>s)
18 # ill add inter-language links
19 # (ignored by Parsoid, since it emits <link>s)
20 # subpage enable subpages (disabled by default)
21 # title=[[XXX]] run test using article title XXX
22 # language=XXX set content language to XXX for this test
23 # variant=XXX set the variant of language for this test (eg zh-tw)
24 # disabled do not run test
25 # parsoid parsoid-specific options (not run by PHP parser unless
26 # the test includes an html/php section)
27 # php php-only test (not run by the parsoid parser unless
28 # the test includes an html/parsoid section)
29 # showtitle make the first line the title
30 # showindicators make the first lines the page status indicators
31 # comment run through Linker::formatComment() instead of main parser
32 # local format section links in edit comment text as local links
33 # notoc disable table of contents
34 # thumbsize=NNN set the default thumb size to NNNpx for this test
35 # wrap include the normal wrapper <div class="mw-parser-output"> (since 1.30)
36 #
37 # You can also set the following parser properties via test options:
38 # wgEnableUploads, wgAllowExternalImages, wgMaxTocLevel,
39 # wgLinkHolderBatchSize, wgRawHtml, wgInterwikiMagic,
40 # wgEnableMagicLinks, wgMediaInTargetLanguage
41 #
42 # For testing purposes, temporary articles can created:
43 # !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
44 # where '/' denotes a newline.
45
46 # This is the standard article assumed to exist.
47 !! article
48 Main Page
49 !! text
50 blah blah
51 !! endarticle
52
53 !!article
54 Foo
55 !!text
56 FOO
57 !!endarticle
58
59 !!article
60 Foo''s bar''s
61 !!text
62 Article titles can contain single quotes!
63 !!endarticle
64
65 !!article
66 Template:Foo
67 !!text
68 FOO
69 !!endarticle
70
71 !! article
72 Template:redirect to foo
73 !! text
74 #REDIRECT [[Template:Foo]]
75 !! endarticle
76
77 !! article
78 Template:Blank
79 !! text
80 !! endarticle
81
82 !! article
83 Template:pipe
84 !! text
85 |
86 !! endarticle
87
88 !! article
89 Template:=
90 !! text
91 <nowiki>=</nowiki>
92 !! endarticle
93
94 !!article
95 MediaWiki:bad image list
96 !!text
97 * [[File:Bad.jpg]] except [[Nasty page]]
98 !!endarticle
99
100 !! article
101 Template:inner list
102 !! text
103 * item 1
104 !! endarticle
105
106 !! article
107 Template:tbl-start
108 !! text
109 {|
110 !! endarticle
111
112 !! article
113 Template:tbl-end
114 !! text
115 |}
116 !! endarticle
117
118 !! article
119 Template:echo
120 !! text
121 {{{1}}}
122 !! endarticle
123
124 !! article
125 Template:echo3
126 !! text
127 {{{1}}}
128 {{{1}}}
129 {{{1}}}
130 !! endarticle
131
132 // For Serbian; localize Template namespace
133 !! article
134 Шаблон:Echo
135 !! text
136 {{{1}}}
137 !! endarticle
138
139 !! article
140 Template:echo_with_span
141 !! text
142 <span>{{{1}}}</span>
143 !! endarticle
144
145 !! article
146 Template:echo_with_div
147 !! text
148 <div>{{{1}}}</div>
149 !! endarticle
150
151 !! article
152 Template:echo with depth
153 !! text
154 {{echo|{{{1}}}}}
155 !! endarticle
156
157 !! article
158 Template:blank_param
159 !! text
160 {{{1}}}
161 {{{}}}
162 !! endarticle
163
164 !! article
165 Template:table_attribs
166 !! text
167 <noinclude>
168 |</noinclude>style="color:red;"|Foo
169 !! endarticle
170
171 !! article
172 Template:table_attribs_2
173 !! text
174 <noinclude>
175 |</noinclude>style="color:red;"|Foo
176 |Bar||Baz
177 !! endarticle
178
179 !! article
180 Template:table_attribs_3
181 !! text
182 <noinclude>
183 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo
184 !! endarticle
185
186 !! article
187 Template:table_attribs_4
188 !! text
189 | style="background-color:#DC241f;" width="10px" |
190 !! endarticle
191
192 !! article
193 Template:table_attribs_5
194 !! text
195 <noinclude>
196 |</noinclude>style="color:red;"||Bar
197 !! endarticle
198
199 !! article
200 Template:table_attribs_6
201 !! text
202 style="background: <nowiki>
203
204
205 red;</nowiki>" |
206 !! endarticle
207
208 !! article
209 Template:table_attribs_7
210 !! text
211 <noinclude>
212 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo<ref>foo</ref>
213 !! endarticle
214
215 !! article
216 Template:table_header_cells
217 !! text
218 {{table_attribs}}!!style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
219 !! endarticle
220
221 !! article
222 Template:table_cells
223 !! text
224 {{table_attribs}}||style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
225 !! endarticle
226
227 !! article
228 Template:PartialTable
229 !! text
230 {|
231 |-
232 !! endarticle
233
234 !! article
235 Template:image_attribs
236 !! text
237 <noinclude>
238 [[File:foobar.jpg|</noinclude>right|Caption text<noinclude>]]</noinclude>
239 !! endarticle
240
241 ## See T48811 for details
242 !! article
243 Template:mixed_attr_content_template
244 !! text
245 style="color:red;" title="T48811"
246 |-
247 |foo
248 !! endarticle
249
250 !! article
251 Template:definition_list
252 !! text
253 one
254 ::two
255 !! endarticle
256
257 !! article
258 A?b
259 !! text
260 Weirdo titles!
261 !! endarticle
262
263 !!article
264 Template:Bullet
265 !!text
266 *Bar
267 !!endarticle
268
269 !!article
270 Template:OpenTable
271 !!text
272 {|
273 !!endarticle
274
275 !!article
276 Template:EmptyLITest
277 !!text
278 *a
279 *
280 *
281 *b
282 !!endarticle
283
284 !!article
285 Template:EmptyTRTest
286 !!text
287 {|
288 |-
289 |-
290 |foo
291 |-
292 |-
293 |bar
294 |}
295 !!endarticle
296
297 !!article
298 Template:EmptyTRWithHTMLAttrTest
299 !!text
300 <table>
301 <tr align="center"></tr>
302 <tr><td>foo</td></tr>
303 <tr align="center"></tr>
304 <tr><td>bar</td></tr>
305 </table>
306 !!endarticle
307
308 !! article
309 Template:With: Colon
310 !! text
311 Template with colon
312 !! endarticle
313
314 ###
315 ### Basic tests
316 ###
317
318 !! test
319 Blank input
320 !! wikitext
321 !! html
322 !! end
323
324 !! test
325 Simple paragraph
326 !! wikitext
327 This is a simple paragraph.
328 !! html
329 <p>This is a simple paragraph.
330 </p>
331 !! end
332
333 !! test
334 Paragraphs with extra newline spacing
335 !! wikitext
336 a
337
338 b (+2 nls)
339
340
341 c (+3 nls)
342
343
344
345 d (+4 nls)
346
347
348
349
350 e (+5 nls)
351 !! html
352 <p>a
353 </p><p>b (+2 nls)
354 </p><p><br />
355 c (+3 nls)
356 </p><p><br />
357 </p><p>d (+4 nls)
358 </p><p><br />
359 </p><p><br />
360 e (+5 nls)
361 </p>
362 !! end
363
364 !! test
365 Paragraphs with newline spacing with comment lines in between
366 !! wikitext
367 ----
368 a
369 <!--foo-->
370 b
371 ----
372 a
373 <!--foo--><!--More than 1 comment, still stripped-->
374 b
375 ----
376 a
377 <!--foo--> <!----> <!-- bar -->
378 b
379 ----
380 a
381 <!--foo-->
382
383 b
384 ----
385 a
386
387 <!--foo-->
388 b
389 ----
390 a
391 <!--foo-->
392
393
394 b
395 ----
396 a
397
398
399 <!--foo-->
400 b
401 ----
402 !! html
403 <hr />
404 <p>a
405 b
406 </p>
407 <hr />
408 <p>a
409 b
410 </p>
411 <hr />
412 <p>a
413 b
414 </p>
415 <hr />
416 <p>a
417 </p><p>b
418 </p>
419 <hr />
420 <p>a
421 </p><p>b
422 </p>
423 <hr />
424 <p>a
425 </p><p><br />
426 b
427 </p>
428 <hr />
429 <p>a
430 </p><p><br />
431 b
432 </p>
433 <hr />
434
435 !! end
436
437 !! test
438 Paragraphs with newline spacing with non-empty white-space lines in between
439 !! wikitext
440 ----
441 a
442
443 b
444 ----
445 a
446
447
448 b
449 ----
450 !! html
451 <hr />
452 <p>a
453 </p><p>b
454 </p>
455 <hr />
456 <p>a
457 </p><p><br />
458 b
459 </p>
460 <hr />
461
462 !! end
463
464 !! test
465 Paragraphs with newline spacing with non-empty mixed comment and white-space lines in between
466 !! wikitext
467 ----
468 a
469 <!--foo-->
470 b
471 ----
472 a
473 <!--foo--><!--More than 1 comment doesn't disable stripping of this line!-->
474 b
475 ----
476 a
477
478 <!--foo-->
479 <!--bar-->
480 b
481 ----
482 a
483
484 <!--foo-->
485 <!--bar-->
486
487 b
488 ----
489 !! html
490 <hr />
491 <p>a
492 b
493 </p>
494 <hr />
495 <p>a
496 b
497 </p>
498 <hr />
499 <p>a
500 </p><p>b
501 </p>
502 <hr />
503 <p>a
504 </p><p><br />
505 b
506 </p>
507 <hr />
508
509 !! end
510
511 !! test
512 Extra newlines: More paragraphs with indented comment
513 !! wikitext
514 a
515
516 <!--boo-->
517
518 b
519 !! html
520 <p>a
521 </p><p><br />
522 b
523 </p>
524 !!end
525
526 !! test
527 Extra newlines followed by heading
528 !! wikitext
529 a
530
531
532 =b=
533 [[a]]
534
535
536 =b=
537 !! html
538 <p>a
539 </p><p><br />
540 </p>
541 <h1><span class="mw-headline" id="b">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
542 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
543 </p><p><br />
544 </p>
545 <h1><span class="mw-headline" id="b_2">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
546
547 !! end
548
549 !! test
550 Extra newlines between heading and content are swallowed (Parsoid does not)
551 !! wikitext
552 =b=
553
554
555
556 [[a]]
557 !! html/php+tidy
558 <h1><span class="mw-headline" id="b">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
559 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
560 </p>
561 !! html/parsoid
562 <h1 id="b">b</h1>
563 <p>
564 <br></p>
565
566 <p><a rel="mw:WikiLink" href="./A" title="A">a</a></p>
567 !! end
568
569 !! test
570 Extra new lines before and after lists are preserved
571 !! wikitext
572 a
573
574
575 *b
576
577
578 c
579 !! html/php+tidy
580 <p>a
581 </p><p><br />
582 </p>
583 <ul><li>b</li></ul>
584 <p><br />
585 c
586 </p>
587 !! html/parsoid
588 <p>a</p>
589 <p>
590 <br></p>
591 <ul><li>b</li></ul>
592 <p>
593 <br>
594 c</p>
595 !! end
596
597 # Parsoid regression test
598 !!test
599 Multiple newlines after tables are converted to p-br-p tags
600 !!options
601 parsoid=wt2html,wt2wt
602 !!wikitext
603 {|
604 |x
605 |}
606
607
608
609
610 =b=
611 !!html/php+tidy
612 <table>
613 <tbody><tr>
614 <td>x
615 </td></tr></tbody></table>
616 <p><br />
617 </p><p><br />
618 </p>
619 <h1><span class="mw-headline" id="b">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
620 !!html/parsoid
621 <table>
622 <tbody>
623 <tr>
624 <td>x</td>
625 </tr>
626 </tbody>
627 </table>
628 <p><br/></p>
629 <p><br/></p>
630 <h1 id="b">b</h1>
631 !!end
632
633 !! test
634 Heading with line break in nowiki
635 !! options
636 parsoid=wt2html
637 !! config
638 wgFragmentMode=[ 'html5', 'legacy' ]
639 !! wikitext
640 ==A <nowiki>B
641 C</nowiki>==
642 !! html/php
643 <h2><span id="A_B.0AC"></span><span class="mw-headline" id="A_B
644 C">A B
645 C</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: A B&#10;C">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
646
647 !! html/parsoid
648 <h2 id="A_B
649 C"><span id="A_B.0AC" typeof="mw:FallbackId"></span>A <span typeof="mw:Nowiki">B
650 C</span></h2>
651 !! end
652
653 !! test
654 Parsing an URL
655 !! wikitext
656 http://fr.wikipedia.org/wiki/🍺
657 <!-- EasterEgg we love beer, better be able be able to link to it -->
658 !! html
659 <p><a rel="nofollow" class="external free" href="http://fr.wikipedia.org/wiki/🍺">http://fr.wikipedia.org/wiki/🍺</a>
660 </p>
661 !! end
662
663 !! test
664 Simple list
665 !! wikitext
666 *Item 1
667 *Item 2
668 !! html
669 <ul><li>Item 1</li>
670 <li>Item 2</li></ul>
671
672 !! end
673
674 !! test
675 Italics and bold
676 !! wikitext
677 *plain
678 *plain''italic''plain
679 *plain''italic''plain''italic''plain
680 *plain'''bold'''plain
681 *plain'''bold'''plain'''bold'''plain
682 *plain''italic''plain'''bold'''plain
683 *plain'''bold'''plain''italic''plain
684 *plain''italic'''bold-italic'''italic''plain
685 *plain'''bold''bold-italic''bold'''plain
686 *plain'''''bold-italic'''italic''plain
687 *plain'''''bold-italic''bold'''plain
688 *plain''italic'''bold-italic'''''plain
689 *plain'''bold''bold-italic'''''plain
690 *plain l'''italic''plain
691 *plain l''''bold''' plain
692 !! html
693 <ul><li>plain</li>
694 <li>plain<i>italic</i>plain</li>
695 <li>plain<i>italic</i>plain<i>italic</i>plain</li>
696 <li>plain<b>bold</b>plain</li>
697 <li>plain<b>bold</b>plain<b>bold</b>plain</li>
698 <li>plain<i>italic</i>plain<b>bold</b>plain</li>
699 <li>plain<b>bold</b>plain<i>italic</i>plain</li>
700 <li>plain<i>italic<b>bold-italic</b>italic</i>plain</li>
701 <li>plain<b>bold<i>bold-italic</i>bold</b>plain</li>
702 <li>plain<i><b>bold-italic</b>italic</i>plain</li>
703 <li>plain<b><i>bold-italic</i>bold</b>plain</li>
704 <li>plain<i>italic<b>bold-italic</b></i>plain</li>
705 <li>plain<b>bold<i>bold-italic</i></b>plain</li>
706 <li>plain l'<i>italic</i>plain</li>
707 <li>plain l'<b>bold</b> plain</li></ul>
708
709 !! end
710
711 # this example taken from the [[simple:Moon]] article (T49326)
712 !! test
713 Italics and possessives (1)
714 !! wikitext
715 obtained by ''[[Lunar Prospector]]'''s gamma-ray spectrometer
716 !! html
717 <p>obtained by <i><a href="/index.php?title=Lunar_Prospector&amp;action=edit&amp;redlink=1" class="new" title="Lunar Prospector (page does not exist)">Lunar Prospector</a>'</i>s gamma-ray spectrometer
718 </p>
719 !! end
720
721 # this example taken from [[en:Flaming Pie]] (T51926)
722 !! test
723 Italics and possessives (2)
724 !! wikitext
725 '''''Flaming Pie''''' is ... released in 1997. In ''Flaming Pie'''s liner notes
726 !! html
727 <p><i><b>Flaming Pie</b></i> is ... released in 1997. In <i>Flaming Pie'</i>s liner notes
728 </p>
729 !! end
730
731 # this example taken from [[en:Dictionary]] (T51926)
732 !! test
733 Italics and possessives (3)
734 !! wikitext
735 The first monolingual dictionary written in a Romance language was ''Sebastián Covarrubias''' ''Tesoro de la lengua castellana o española'', published in 1611 in Madrid. In 1612 the first edition of the ''Vocabolario dell'[[Accademia della Crusca]]'', for Italian, was published. In 1690 in Rotterdam was published, posthumously, the ''Dictionnaire Universel''.
736 !! html
737 <p>The first monolingual dictionary written in a Romance language was <i>Sebastián Covarrubias'</i> <i>Tesoro de la lengua castellana o española</i>, published in 1611 in Madrid. In 1612 the first edition of the <i>Vocabolario dell'<a href="/index.php?title=Accademia_della_Crusca&amp;action=edit&amp;redlink=1" class="new" title="Accademia della Crusca (page does not exist)">Accademia della Crusca</a></i>, for Italian, was published. In 1690 in Rotterdam was published, posthumously, the <i>Dictionnaire Universel</i>.
738 </p>
739 !! end
740
741
742 ###
743 ### 2-quote opening sequence tests
744 ###
745 !! test
746 Italics and bold: 2-quote opening sequence: (2,2)
747 !! wikitext
748 ''foo''
749 !! html
750 <p><i>foo</i>
751 </p>
752 !!end
753
754 !! test
755 Italics and bold: 2-quote opening sequence: (2,3)
756 !! wikitext
757 ''foo'''
758 !! html/*
759 <p><i>foo'</i>
760 </p>
761 !!end
762
763 !! test
764 Italics and bold: 2-quote opening sequence: (2,4)
765 !! options
766 parsoid=wt2html
767 !! wikitext
768 ''foo''''
769 !! html/*
770 <p><i>foo''</i>
771 </p>
772 !!end
773
774 # same html as previous, but wikitext adjusted to match parsoid html2wt
775 !! test
776 Italics and bold: 2-quote opening sequence: (2,4) w/ nowiki
777 !! wikitext
778 ''foo<nowiki>''</nowiki>''
779 !! html
780 <p><i>foo''</i>
781 </p>
782 !! end
783
784 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
785 !! test
786 Italics and bold: 2-quote opening sequence: (2,5)
787 !! options
788 parsoid=wt2html
789 !! wikitext
790 ''foo'''''
791 !! html/php
792 <p><i>foo</i>
793 </p>
794 !! html/parsoid
795 <p><i>foo</i><b></b>
796 </p>
797 !!end
798
799 # same html as previous, but wikitext adjusted to match parsoid html2wt
800 !! test
801 Italics and bold: 2-quote opening sequence: (2,5+3) w/ nowiki
802 !! wikitext
803 ''foo'''''<nowiki/>'''
804 !! html/php
805 <p><i>foo</i>
806 </p>
807 !! html/parsoid
808 <p><i>foo</i><b></b>
809 </p>
810 !! end
811
812
813 ###
814 ### 3-quote opening sequence tests
815 ###
816
817 !! test
818 Italics and bold: 3-quote opening sequence: (3,2)
819 !! wikitext
820 '''foo''
821 !! html/*
822 <p>'<i>foo</i>
823 </p>
824 !!end
825
826 !! test
827 Italics and bold: 3-quote opening sequence: (3,3)
828 !! wikitext
829 '''foo'''
830 !! html
831 <p><b>foo</b>
832 </p>
833 !!end
834
835 !! test
836 Italics and bold: 3-quote opening sequence: (3,4)
837 !! wikitext
838 '''foo''''
839 !! html/*
840 <p><b>foo'</b>
841 </p>
842 !!end
843
844 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
845 !! test
846 Italics and bold: 3-quote opening sequence: (3,5)
847 !! options
848 parsoid=wt2html
849 !! wikitext
850 '''foo'''''
851 !! html/php
852 <p><b>foo</b>
853 </p>
854 !! html/parsoid
855 <p><b>foo</b><i></i>
856 </p>
857 !!end
858
859 # same html as previous, but wikitext adjusted to match parsoid html2wt
860 !! test
861 Italics and bold: 3-quote opening sequence: (3,5+2) w/ nowiki
862 !! wikitext
863 '''foo'''''<nowiki/>''
864 !! html/php
865 <p><b>foo</b>
866 </p>
867 !! html/parsoid
868 <p><b>foo</b><i></i>
869 </p>
870 !! end
871
872
873 ###
874 ### 4-quote opening sequence tests
875 ###
876
877 !! test
878 Italics and bold: 4-quote opening sequence: (4,2)
879 !! options
880 parsoid=wt2html
881 !! wikitext
882 ''''foo''
883 !! html/*
884 <p>''<i>foo</i>
885 </p>
886 !!end
887
888 # same html as previous, but wikitext adjusted to match parsoid html2wt
889 !! test
890 Italics and bold: 4-quote opening sequence: (4,2) w/ nowiki
891 !! wikitext
892 <nowiki>''</nowiki>''foo''
893 !! html
894 <p>''<i>foo</i>
895 </p>
896 !! end
897
898 !! test
899 Italics and bold: 4-quote opening sequence: (4,3)
900 !! wikitext
901 ''''foo'''
902 !! html/*
903 <p>'<b>foo</b>
904 </p>
905 !!end
906
907 !! test
908 Italics and bold: 4-quote opening sequence: (4,4)
909 !! options
910 parsoid=wt2html
911 !! wikitext
912 ''''foo''''
913 !! html/*
914 <p>'<b>foo'</b>
915 </p>
916 !!end
917
918 # same html as previous, but wikitext adjusted to match parsoid html2wt
919 !! test
920 Italics and bold: 4-quote opening sequence: (4,4) w/ nowiki
921 !! wikitext
922 '<nowiki/>'''foo''''
923 !! html
924 <p>'<b>foo'</b>
925 </p>
926 !! end
927
928 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
929 !! test
930 Italics and bold: 4-quote opening sequence: (4,5)
931 !! options
932 parsoid=wt2html
933 !! wikitext
934 ''''foo'''''
935 !! html/php
936 <p>'<b>foo</b>
937 </p>
938 !! html/parsoid
939 <p>'<b>foo</b><i></i>
940 </p>
941 !!end
942
943 # same html as previous, but wikitext adjusted to match parsoid html2wt
944 !! test
945 Italics and bold: 4-quote opening sequence: (4,5+2) w/ nowiki
946 !! wikitext
947 '<nowiki/>'''foo'''''<nowiki/>''
948 !! html/php
949 <p>'<b>foo</b>
950 </p>
951 !! html/parsoid
952 <p>'<b>foo</b><i></i>
953 </p>
954 !! end
955
956
957 ###
958 ### 5-quote opening sequence tests
959 ###
960
961 !! test
962 Italics and bold: 5-quote opening sequence: (5,2)
963 !! options
964 parsoid=wt2html
965 !! wikitext
966 '''''foo''
967 !! html/*
968 <p><b><i>foo</i></b>
969 </p>
970 !!end
971
972 # same html as previous, but wikitext adjusted to match parsoid html2wt
973 !! test
974 Italics and bold: 5-quote opening sequence: (5,2+3)
975 !! wikitext
976 '''''foo'''''
977 !! html/*
978 <p><i><b>foo</b></i>
979 </p>
980 !! end
981
982 !! test
983 Italics and bold: 5-quote opening sequence: (5,3)
984 !! options
985 parsoid=wt2html
986 !! wikitext
987 '''''foo'''
988 !! html/*
989 <p><i><b>foo</b></i>
990 </p>
991 !!end
992
993 # same html as previous, but wikitext adjusted to match parsoid html2wt
994 !! test
995 Italics and bold: 5-quote opening sequence: (5,3+2)
996 !! wikitext
997 '''''foo'''''
998 !! html
999 <p><i><b>foo</b></i>
1000 </p>
1001 !! end
1002
1003 !! test
1004 Italics and bold: 5-quote opening sequence: (5,4)
1005 !! options
1006 parsoid=wt2html
1007 !! wikitext
1008 '''''foo''''
1009 !! html/*
1010 <p><i><b>foo'</b></i>
1011 </p>
1012 !!end
1013
1014 !! test
1015 Italics and bold: 5-quote opening sequence: (5,5)
1016 !! wikitext
1017 '''''foo'''''
1018 !! html
1019 <p><i><b>foo</b></i>
1020 </p>
1021 !!end
1022
1023 !! test
1024 Italics and bold: 5-quote opening sequence: (5,6)
1025 !! wikitext
1026 '''''foo''''''
1027 !! html/*
1028 <p><i><b>foo'</b></i>
1029 </p>
1030 !! end
1031
1032 ###
1033 ### multiple quote sequences in a line
1034 ###
1035
1036 !! test
1037 Italics and bold: multiple quote sequences: (2,4,2)
1038 !! options
1039 parsoid=wt2html
1040 !! wikitext
1041 ''foo''''bar''
1042 !! html/*
1043 <p><i>foo'<b>bar</b></i>
1044 </p>
1045 !! end
1046
1047 # same html as previous, but wikitext adjusted to match parsoid html2wt
1048 !! test
1049 Italics and bold: multiple quote sequences: (2,4,2+3) w/ nowiki
1050 !! wikitext
1051 ''foo'<nowiki/>'''bar'''''
1052 !! html
1053 <p><i>foo'<b>bar</b></i>
1054 </p>
1055 !! end
1056
1057 !! test
1058 Italics and bold: multiple quote sequences: (2,4,3)
1059 !! options
1060 parsoid=wt2html
1061 !! wikitext
1062 ''foo''''bar'''
1063 !! html/*
1064 <p><i>foo'<b>bar</b></i>
1065 </p>
1066 !! end
1067
1068 # same html as previous, but wikitext adjusted to match parsoid html2wt
1069 !! test
1070 Italics and bold: multiple quote sequences: (2,4,3+2) w/ nowiki
1071 !! wikitext
1072 ''foo'<nowiki/>'''bar'''''
1073 !! html
1074 <p><i>foo'<b>bar</b></i>
1075 </p>
1076 !! end
1077
1078 !! test
1079 Italics and bold: multiple quote sequences: (2,4,4)
1080 !! options
1081 parsoid=wt2html
1082 !! wikitext
1083 ''foo''''bar''''
1084 !! html/*
1085 <p><i>foo'<b>bar'</b></i>
1086 </p>
1087 !! end
1088
1089 # same html as previous, but wikitext adjusted to match parsoid html2wt
1090 !! test
1091 Italics and bold: multiple quote sequences: (2,4,4+2) w/ nowiki
1092 !! wikitext
1093 ''foo'<nowiki/>'''bar'<nowiki/>'''''
1094 !! html
1095 <p><i>foo'<b>bar'</b></i>
1096 </p>
1097 !! end
1098
1099 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1100 !! test
1101 Italics and bold: multiple quote sequences: (3,4,2)
1102 !! options
1103 parsoid=wt2html
1104 !! wikitext
1105 '''foo''''bar''
1106 !! html/php
1107 <p><b>foo'</b>bar
1108 </p>
1109 !! html/parsoid
1110 <p><b>foo'</b>bar<i></i>
1111 </p>
1112 !! end
1113
1114 # same html as previous, but wikitext adjusted to match parsoid html2wt
1115 !! test
1116 Italics and bold: multiple quote sequences: (3,4,2+2) w/ nowiki
1117 !! wikitext
1118 '''foo''''bar''<nowiki/>''
1119 !! html/php
1120 <p><b>foo'</b>bar
1121 </p>
1122 !! html/parsoid
1123 <p><b>foo'</b>bar<i></i>
1124 </p>
1125 !! end
1126
1127 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1128 !! test
1129 Italics and bold: multiple quote sequences: (3,4,3)
1130 !! options
1131 parsoid=wt2html
1132 !! wikitext
1133 '''foo''''bar'''
1134 !! html/php
1135 <p><b>foo'</b>bar
1136 </p>
1137 !! html/parsoid
1138 <p><b>foo'</b>bar<b></b>
1139 </p>
1140 !! end
1141
1142 # same html as previous, but wikitext adjusted to match parsoid html2wt
1143 !! test
1144 Italics and bold: multiple quote sequences: (3,4,3+3) w/ nowiki
1145 !! wikitext
1146 '''foo''''bar'''<nowiki/>'''
1147 !! html/php
1148 <p><b>foo'</b>bar
1149 </p>
1150 !! html/parsoid
1151 <p><b>foo'</b>bar<b></b>
1152 </p>
1153 !! end
1154
1155 ###
1156 ### other quote tests
1157 ###
1158 !! test
1159 Italics and bold: other quote tests: (2,3,5)
1160 !! wikitext
1161 ''this is about '''foo's family'''''
1162 !! html
1163 <p><i>this is about <b>foo's family</b></i>
1164 </p>
1165 !!end
1166
1167
1168 !! test
1169 Italics and bold: other quote tests: (2,(3,3),2)
1170 !! wikitext
1171 ''this is about '''foo's''' family''
1172 !! html
1173 <p><i>this is about <b>foo's</b> family</i>
1174 </p>
1175 !!end
1176
1177
1178 !! test
1179 Italics and bold: other quote tests: (3,2,3,2)
1180 !! options
1181 parsoid=wt2html
1182 !! wikitext
1183 '''this is about ''foo'''s family''
1184 !! html/*
1185 <p><b>this is about <i>foo</i></b><i>s family</i>
1186 </p>
1187 !!end
1188
1189
1190 # same html as previous, but wikitext adjusted to match parsoid html2wt
1191 !! test
1192 Italics and bold: other quote tests: (3,2,3+2+2,2)
1193 !! wikitext
1194 '''this is about ''foo'''''<nowiki/>''s family''
1195 !! html
1196 <p><b>this is about <i>foo</i></b><i>s family</i>
1197 </p>
1198 !! end
1199
1200
1201 !! test
1202 Italics and bold: other quote tests: (3,2,3,3)
1203 !! wikitext
1204 '''this is about ''foo'''s family'''
1205 !! html/*
1206 <p>'<i>this is about </i>foo<b>s family</b>
1207 </p>
1208 !!end
1209
1210
1211 !! test
1212 Italics and bold: other quote tests: (3,(2,2),3)
1213 !! wikitext
1214 '''this is about ''foo's'' family'''
1215 !! html
1216 <p><b>this is about <i>foo's</i> family</b>
1217 </p>
1218 !!end
1219
1220
1221 !! test
1222 Italicized possessive
1223 !! wikitext
1224 The ''[[Main Page]]'''s talk page.
1225 !! html/php
1226 <p>The <i><a href="/wiki/Main_Page" title="Main Page">Main Page</a>'</i>s talk page.
1227 </p>
1228 !! html/parsoid
1229 <p>The <i><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>'</i>s talk page.</p>
1230 !! end
1231
1232 !! test
1233 Quote balancing context should be restricted to td/th cells on the same wikitext line
1234 !! options
1235 parsoid=wt2html,wt2wt
1236 !! wikitext
1237 {|
1238 !''a!!''b
1239 |''a||''b
1240 |}
1241 !! html+tidy
1242 <table>
1243 <tbody><tr>
1244 <th><i>a</i></th>
1245 <th><i>b</i>
1246 </th>
1247 <td><i>a</i></td>
1248 <td><i>b</i>
1249 </td></tr></tbody></table>
1250 !! end
1251
1252 ###
1253 ### Non-html5 tags
1254 ###
1255
1256 !! test
1257 Non-html5 tags should be accepted
1258 !! wikitext
1259 <center>''foo''</center>
1260 <big>''foo''</big>
1261 <font>''foo''</font>
1262 <strike>''foo''</strike>
1263 <tt>''foo''</tt>
1264 !! html
1265 <center><i>foo</i></center>
1266 <p><big><i>foo</i></big>
1267 <font><i>foo</i></font>
1268 <strike><i>foo</i></strike>
1269 <tt><i>foo</i></tt>
1270 </p>
1271 !! end
1272
1273 !! test
1274 <wbr> is valid wikitext (T54468)
1275 !! wikitext
1276 <wbr>
1277 !! html
1278 <p><wbr />
1279 </p>
1280 !! end
1281
1282 # <strike> is HTML4, <s> is HTML4/5.
1283 !! test
1284 <s> or <strike> for strikethrough
1285 !! wikitext
1286 <strike>strike</strike>
1287
1288 <s>s</s>
1289 !! html
1290 <p><strike>strike</strike>
1291 </p><p><s>s</s>
1292 </p>
1293 !! end
1294
1295 ## a not permitted
1296 ## i,b,br omitted
1297 !! test
1298 Text-level semantic html elements in wikitext
1299 !! wikitext
1300 <em>text</em>
1301 <strong>text</strong>
1302 <small>text</small>
1303 <s>text</s>
1304 <cite>text</cite>
1305 <q>text</q>
1306 <dfn>text</dfn>
1307 <abbr>text</abbr>
1308 <data>text</data>
1309 <time>text</time>
1310 <code>text</code>
1311 <var>text</var>
1312 <samp>text</samp>
1313 <kbd>text</kbd>
1314 <sub>text</sub>
1315 <u>text</u>
1316 <mark>text</mark>
1317 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1318 <bdi>text</bdi>
1319 <bdo>text</bdo>
1320 <span>text</span>
1321 <wbr />
1322 !! html
1323 <p><em>text</em>
1324 <strong>text</strong>
1325 <small>text</small>
1326 <s>text</s>
1327 <cite>text</cite>
1328 <q>text</q>
1329 <dfn>text</dfn>
1330 <abbr>text</abbr>
1331 <data>text</data>
1332 <time>text</time>
1333 <code>text</code>
1334 <var>text</var>
1335 <samp>text</samp>
1336 <kbd>text</kbd>
1337 <sub>text</sub>
1338 <u>text</u>
1339 <mark>text</mark>
1340 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1341 <bdi>text</bdi>
1342 <bdo>text</bdo>
1343 <span>text</span>
1344 <wbr />
1345 </p>
1346 !! end
1347
1348 # test cases taken from
1349 # https://www.w3.org/TR/html5/text-level-semantics.html#the-ruby-element
1350 !! test
1351 Ruby markup (W3C-style)
1352 !! wikitext
1353 ;Mono-ruby for individual base characters
1354 :<ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby>
1355 ;Group ruby
1356 :<ruby>今日<rt>きょう</rt></ruby>
1357 ;Jukugo ruby
1358 :<ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby>
1359 ;Inline ruby
1360 :<ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby>
1361 ;Double-sided ruby
1362 :<ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby>
1363
1364 <ruby>
1365 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1366 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1367 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1368 </ruby>
1369 !! html
1370 <dl><dt>Mono-ruby for individual base characters</dt>
1371 <dd><ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby></dd>
1372 <dt>Group ruby</dt>
1373 <dd><ruby>今日<rt>きょう</rt></ruby></dd>
1374 <dt>Jukugo ruby</dt>
1375 <dd><ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby></dd>
1376 <dt>Inline ruby</dt>
1377 <dd><ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby></dd>
1378 <dt>Double-sided ruby</dt>
1379 <dd><ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby></dd></dl>
1380 <p><ruby>
1381 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1382 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1383 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1384 </ruby>
1385 </p>
1386 !! end
1387
1388 # The next two test different paths in the sanitizer.
1389 !! test
1390 Non-word characters don't terminate tag names (T19663, T42670, T54022)
1391 !! wikitext
1392 <blockquote|>a</blockquote>
1393
1394 <b→> doesn't terminate </b→>
1395
1396 <bä> doesn't terminate </bä>
1397
1398 <boo> doesn't terminate </boo>
1399
1400 <s.foo> doesn't terminate </s.foo>
1401
1402 <sub-ID#1>
1403 !! html/php
1404 <p>&lt;blockquote|&gt;a&lt;/blockquote&gt;
1405 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1406 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1407 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1408 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1409 </p><p>&lt;sub-ID#1&gt;
1410 </p>
1411 !! end
1412
1413 !! test
1414 Non-word characters don't terminate tag names
1415 !! wikitext
1416 <blockquote|>a</blockquote>
1417
1418 <b→> doesn't terminate </b→>
1419
1420 <bä> doesn't terminate </bä>
1421
1422 <boo> doesn't terminate </boo>
1423
1424 <s.foo> doesn't terminate </s.foo>
1425
1426 <sub-ID#1>
1427 !! html+tidy
1428 <p>&lt;blockquote|&gt;a
1429 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1430 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1431 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1432 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1433 </p><p>&lt;sub-ID#1&gt;
1434 </p>
1435 !! end
1436
1437 ###
1438 ### See tests/parser/ParserTestParserHook.php for the <tåg> extension)
1439 ### This checks that HTML5 tags (with non-word characters in the tag
1440 ### name) make it safely through the parser -- the Sanitizer will
1441 ### munge them later, as it should.
1442 ###
1443 !! test
1444 Non-word characters are valid in extension tags (T19663)
1445 !! wikitext
1446 <tåg>tåg</tåg>
1447 !! html/php
1448 <pre>
1449 'tåg'
1450 array (
1451 )
1452 </pre>
1453
1454 !! html/parsoid
1455 <pre typeof="mw:Extension/tåg" data-mw='{"name":"tåg","attrs":{},"body":{"extsrc":"tåg"}}' data-parsoid='{}' about="#mwt2"></pre>
1456 !! end
1457
1458 !! test
1459 Isolated close tags should be treated as literal text (T54760)
1460 !! options
1461 parsoid=wt2html
1462 !! wikitext
1463 </b>
1464
1465 <s.foo>s</s>
1466 !! html+tidy
1467 <p class="mw-empty-elt">
1468 </p><p>&lt;s.foo&gt;s
1469 </p>
1470 !! end
1471
1472 ###
1473 ### Special characters
1474 ###
1475
1476 !! test
1477 Bare pipe character (T54363)
1478 !! wikitext
1479 |
1480 !! html
1481 <p>|
1482 </p>
1483 !! end
1484
1485 !! test
1486 Bare pipe character from a template (T54363)
1487 !! wikitext
1488 {{pipe}}
1489 !! html
1490 <p>|
1491 </p>
1492 !! end
1493
1494 ###
1495 ### <nowiki> test cases
1496 ###
1497
1498 !! test
1499 <nowiki> unordered list
1500 !! wikitext
1501 <nowiki>* This is not an unordered list item.</nowiki>
1502 !! html/php
1503 <p>* This is not an unordered list item.
1504 </p>
1505 !! html/parsoid
1506 <p><span typeof="mw:Nowiki">* This is not an unordered list item.</span></p>
1507 !! end
1508
1509 !! test
1510 <nowiki> spacing
1511 !! wikitext
1512 <nowiki>Lorem ipsum dolor
1513
1514 sed abit.
1515 sed nullum.
1516
1517 :and a colon
1518 </nowiki>
1519 !! html/php
1520 <p>Lorem ipsum dolor
1521
1522 sed abit.
1523 sed nullum.
1524
1525 :and a colon
1526
1527 </p>
1528 !! html/parsoid
1529 <p><span typeof="mw:Nowiki">Lorem ipsum dolor
1530
1531 sed abit.
1532 sed nullum.
1533
1534 :and a colon
1535 </span></p>
1536 !! end
1537
1538 !! test
1539 Don't parse <nowiki><span class="error"></nowiki> (T149622)
1540 !! wikitext
1541 <nowiki><span class="error"></nowiki>
1542 !! html/php
1543 <p>&lt;span class="error"&gt;
1544 </p>
1545 !! html/parsoid
1546 <p><span typeof="mw:Nowiki">&lt;span class="error"></span></p>
1547 !! end
1548
1549 !! test
1550 nowiki 3
1551 !! wikitext
1552 :There is not nowiki.
1553 :There is <nowiki>nowiki</nowiki>.
1554
1555 #There is not nowiki.
1556 #There is <nowiki>nowiki</nowiki>.
1557
1558 *There is not nowiki.
1559 *There is <nowiki>nowiki</nowiki>.
1560 !! html/php
1561 <dl><dd>There is not nowiki.</dd>
1562 <dd>There is nowiki.</dd></dl>
1563 <ol><li>There is not nowiki.</li>
1564 <li>There is nowiki.</li></ol>
1565 <ul><li>There is not nowiki.</li>
1566 <li>There is nowiki.</li></ul>
1567
1568 !! html/parsoid
1569 <dl><dd data-parsoid='{}'>There is not nowiki.</dd>
1570 <dd data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</dd></dl>
1571
1572 <ol><li data-parsoid='{}'>There is not nowiki.</li>
1573 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ol>
1574
1575 <ul><li data-parsoid='{}'>There is not nowiki.</li>
1576 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ul>
1577 !! end
1578
1579 !! test
1580 Entities inside <nowiki>
1581 !! wikitext
1582 <nowiki>&lt;</nowiki>
1583 !! html/php
1584 <p>&lt;
1585 </p>
1586 !! html/parsoid
1587 <p><span typeof="mw:Nowiki"><span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span></span></p>
1588 !! end
1589
1590 !! test
1591 Entities inside template parameters
1592 !! wikitext
1593 {{echo|&ndash;}}
1594 !! html/php+tidy
1595 <p>&#8211;
1596 </p>
1597 !! html/parsoid
1598 <p><span typeof="mw:Transclusion mw:Entity" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&amp;ndash;"}},"i":0}}]}'>&ndash;</span></p>
1599 !! end
1600
1601 !! test
1602 Properly escape nowiki when combined with other wiki markup
1603 !! options
1604 parsoid=html2wt
1605 !! html/parsoid
1606 <p>* &lt;/nowiki&gt; tag</p>
1607 !! wikitext
1608 <nowiki>*</nowiki> <nowiki>&lt;/nowiki&gt;</nowiki> tag
1609 !! end
1610
1611 !! test
1612 T93824: Put escaped HTML tags inside nowiki
1613 !! options
1614 parsoid=html2wt
1615 !! html/parsoid
1616 <p>&lt;h2&gt;foo&lt;/h2&gt;</p>
1617 !! wikitext
1618 <nowiki><h2>foo</h2></nowiki>
1619 !! end
1620
1621 !! test
1622 T71950: 1. Put nowiki as close to cause as possible, even with non-quote escapable chars
1623 !! options
1624 parsoid=html2wt
1625 !! html/parsoid
1626 <p>This text: L'<a rel="mw:WikiLink" href="./Foo">Foo</a>
1627 This text: L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1628 This text: L'''<a rel="mw:WikiLink" href="./Foo">Foo</a>''</p>
1629 !! wikitext
1630 This text: L'[[Foo]]
1631 This text: L<nowiki>''</nowiki>[[Foo]]
1632 This text: L<nowiki>'''</nowiki>[[Foo]]<nowiki>''</nowiki>
1633 !! end
1634
1635 # This test fails because wikitext whitespace is not normalized before comparing.
1636 !! test
1637 T71950: 2. Put nowiki as close to cause as possible, after ' :'
1638 !! options
1639 parsoid=html2wt
1640 !! html/parsoid
1641 <p>This text : L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1642 </p>
1643 !! wikitext
1644 This text : L<nowiki>''</nowiki>[[Foo]]
1645 !! end
1646
1647 # This test and the next one are html2wt only as they test that incorrect wikitext
1648 # passed in template arguments gets escaped or wrapped in nowikis where required.
1649 !! test
1650 T71482: Use {{!}} instead of nowiki for single pipe in template argument
1651 !! options
1652 parsoid=html2wt
1653 !! html/parsoid
1654 <p><span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo|bar&quot;}},&quot;i&quot;:0}}]}" about="#mwt1"></span>
1655 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo|bar |[[&quot;}},&quot;i&quot;:0}}]}" about="#mwt2"></p>
1656 !! wikitext
1657 {{echo|foo{{!}}bar}}
1658 {{echo|<nowiki>foo|bar |[[</nowiki>}}
1659 !! end
1660
1661 !! test
1662 T53961: Output correct nowikis in template arguments
1663 !! options
1664 parsoid=html2wt
1665 !! html/parsoid
1666 <p><span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a [ b&quot;}},&quot;i&quot;:0}}]}" about="#mwt1"></span>
1667 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a }} b&quot;}},&quot;i&quot;:0}}]}" about="#mwt2"></span>
1668 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a [[ b&quot;}},&quot;i&quot;:0}}]}" about="#mwt3"></span>
1669 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a | {{ ]]&quot;}},&quot;i&quot;:0}}]}" about="#mwt4"></span>
1670 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a }&quot;}},&quot;i&quot;:0}}]}" about="#mwt5"></span></p>
1671 !! wikitext
1672 {{echo|a [ b}}
1673 {{echo|<nowiki>a }} b</nowiki>}}
1674 {{echo|<nowiki>a [[ b</nowiki>}}
1675 {{echo|<nowiki>a | {{ ]]</nowiki>}}
1676 {{echo|a <nowiki>}</nowiki>}}
1677 !! end
1678
1679 !! test
1680 Cases where "!!" needs nowiki protection
1681 !! options
1682 parsoid=html2wt
1683 !! html/parsoid
1684 <table>
1685 <tr><th>this needs protection !! here</th></tr>
1686 </table>
1687
1688 <table>
1689 <tr><th>this does not need
1690 protection !! here</th></tr>
1691 </table>
1692 !! wikitext
1693 {|
1694 !<nowiki>this needs protection !! here</nowiki>
1695 |}
1696
1697 {|
1698 !this does not need
1699 protection !! here
1700 |}
1701 !! end
1702
1703 ###
1704 ### Comments
1705 ###
1706 !! test
1707 Comments and Indent-Pre
1708 !! wikitext
1709 <!-- comment 1 --> asdf
1710
1711 <!-- comment 1 --> asdf
1712 <!-- comment 2 -->
1713
1714 <!-- comment 1 --> asdf
1715 <!-- comment 2 -->xyz
1716
1717 <!-- comment 1 --> asdf
1718 <!-- comment 2 --> xyz
1719 !! html
1720 <pre>asdf
1721 </pre>
1722 <pre>asdf
1723 </pre>
1724 <pre>asdf
1725 </pre>
1726 <p>xyz
1727 </p>
1728 <pre>asdf
1729 xyz
1730 </pre>
1731 !! end
1732
1733 !! test
1734 Comment test 2a
1735 !! wikitext
1736 asdf
1737 <!-- comment 1 -->
1738 jkl
1739 !! html
1740 <p>asdf
1741 jkl
1742 </p>
1743 !! end
1744
1745 !! test
1746 Comment test 2b
1747 !! wikitext
1748 asdf
1749 <!-- comment 1 -->
1750
1751 jkl
1752 !! html
1753 <p>asdf
1754 </p><p>jkl
1755 </p>
1756 !! end
1757
1758 !! test
1759 Comment test 3
1760 !! wikitext
1761 asdf
1762 <!-- comment 1 -->
1763 <!-- comment 2 -->
1764 jkl
1765 !! html
1766 <p>asdf
1767 jkl
1768 </p>
1769 !! end
1770
1771 !! test
1772 Comment test 4
1773 !! wikitext
1774 asdf<!-- comment 1 -->jkl
1775 !! html
1776 <p>asdfjkl
1777 </p>
1778 !! end
1779
1780 !! test
1781 Comment spacing
1782 !! wikitext
1783 a
1784 <!-- foo --> b <!-- bar -->
1785 c
1786 !! html
1787 <p>a
1788 </p>
1789 <pre> b
1790 </pre>
1791 <p>c
1792 </p>
1793 !! end
1794
1795 !! test
1796 Comment whitespace
1797 !! wikitext
1798 <!-- returns a single newline, not nothing, since the newline after > is not stripped -->
1799 !! html
1800
1801 !! end
1802
1803 !! test
1804 Comment semantics and delimiters
1805 !! wikitext
1806 <!-- --><!----><!-----><!------>
1807 !! html/php
1808
1809 !! html/parsoid
1810 <!-- --><!----><!--&#x2D;--><!--&#x2D;&#x2D;-->
1811 !! end
1812
1813 !! test
1814 Comment semantics and delimiters, redux
1815 !! wikitext
1816 <!-- In SGML every "foo" here would actually show up in the text -- foo -- bar
1817 -- foo -- funky huh? ... -->
1818 !! html/php
1819
1820 !! html/parsoid
1821 <!-- In SGML every "foo" here would actually show up in the text &#x2D;&#x2D; foo &#x2D;&#x2D; bar
1822 &#x2D;&#x2D; foo &#x2D;&#x2D; funky huh? ... -->
1823 !! end
1824
1825 !! test
1826 Comment semantics and delimiters: directors cut
1827 !! wikitext
1828 <!-- ... However we like to keep things simple and somewhat XML-ish so we eat
1829 everything starting with < followed by !-- until the first -- and > we see,
1830 that wouldn't be valid XML however, since in XML -- has to terminate a comment
1831 -->-->
1832 !! html/php
1833 <p>--&gt;
1834 </p>
1835 !! html/parsoid
1836 <!-- ... However we like to keep things simple and somewhat XML&#x2D;ish so we eat
1837 everything starting with < followed by !&#x2D;&#x2D; until the first &#x2D;&#x2D; and &#x3E; we see,
1838 that wouldn't be valid XML however, since in XML &#x2D;&#x2D; has to terminate a comment
1839 --><p>--></p>
1840 !! end
1841
1842 !! test
1843 Comment semantics: nesting
1844 !! wikitext
1845 <!--<!-- no, we're not going to do anything fancy here -->-->
1846 !! html/php
1847 <p>--&gt;
1848 </p>
1849 !! html/parsoid
1850 <!--<!&#x2D;&#x2D; no, we're not going to do anything fancy here --><p>--></p>
1851 !! end
1852
1853 # Parsoid closes the unclosed comment, even if it means a slight
1854 # round-trip diff.
1855 !! test
1856 Comment semantics: unclosed comment at end
1857 !! options
1858 parsoid=wt2html,html2html
1859 !! wikitext
1860 <!--This comment will run out to the end of the document
1861 !! html/php
1862
1863 !! html/parsoid
1864 <!--This comment will run out to the end of the document-->
1865 !! end
1866
1867 !! test
1868 Comment semantics: normalize comments to play nice with XML and browsers
1869 !! wikitext
1870 <!-- Browsers --!> think this is closed -->
1871 <!--> This would normally be text -->
1872 <!---> As would this -->
1873 <!-- XML doesn't like trailing dashes -------->
1874 <!-- Nor doubled hyphens -- anywhere in the data -->
1875 But this is not a comment.
1876 !! html/php
1877 <p>But this is not a comment.
1878 </p>
1879 !! html/parsoid
1880 <!-- Browsers &#x2D;&#x2D;!&#x3E; think this is closed -->
1881 <!--&#x3E; This would normally be text -->
1882 <!--&#x2D;&#x3E; As would this -->
1883 <!-- XML doesn't like trailing dashes &#x2D;&#x2D;&#x2D;&#x2D;&#x2D;&#x2D;-->
1884 <!-- Nor doubled hyphens &#x2D;&#x2D; anywhere in the data -->
1885 <p>But this is not a comment.</p>
1886 !! end
1887
1888 !! test
1889 Comment semantics: round-trip even text which contains encoded -->
1890 !! wikitext
1891 <!-- hello & goodbye - > --&gt; --&amp;gt; --&xx -->
1892 !! html/parsoid
1893 <!-- hello &#x26; goodbye &#x2D; &#x3E; &#x2D;&#x2D;&#x3E; &#x2D;&#x2D;&#x26;gt; &#x2D;&#x2D;&#x26;xx -->
1894 !! end
1895
1896 !! test
1897 Comment in template title
1898 !! wikitext
1899 {{f<!---->oo}}
1900 !! html
1901 <p>FOO
1902 </p>
1903 !! end
1904
1905 !! test
1906 Comment on its own line post-expand
1907 !! wikitext
1908 a
1909 {{blank}}<!---->
1910 b
1911 !! html
1912 <p>a
1913 </p><p>b
1914 </p>
1915 !! end
1916
1917 !! test
1918 Comment on its own line post-expand with non-significant whitespace
1919 !! wikitext
1920 a
1921 {{blank}} <!---->
1922 b
1923 !! html
1924 <p>a
1925 </p><p>b
1926 </p>
1927 !! end
1928
1929 !! test
1930 post-expand include size being exceeded
1931 !! options
1932 maxincludesize=20
1933 !! wikitext
1934 {{echo3|1234567890}}
1935 !! html
1936 <p><a href="/wiki/Template:Echo3" title="Template:Echo3">Template:Echo3</a><!-- WARNING: template omitted, post-expand include size too large -->
1937 </p>
1938 !! end
1939
1940 !! test
1941 max template depth being reached
1942 !! options
1943 maxtemplatedepth=1
1944 !! wikitext
1945 {{echo with depth|too deep!}}
1946 !! html
1947 <p><span class="error">Template recursion depth limit exceeded (1)</span>
1948 </p>
1949 !! end
1950
1951 !! test
1952 multiple templates that are redirects
1953 !! wikitext
1954 {{redirect to foo}}
1955 {{redirect to foo}}
1956 !! html
1957 <p>FOO
1958 FOO
1959 </p>
1960 !! end
1961
1962 !! test
1963 Multiple comments should still parse as SOL-transparent
1964 !! options
1965 parsoid=wt2html,wt2wt
1966 !! wikitext
1967 <!--c1-->*a
1968 <!--c2--><!--c3--><!--c4-->*b
1969 !! html/php
1970 <ul><li>a</li>
1971 <li>b</li></ul>
1972
1973 !! html/parsoid
1974 <!--c1--><ul>
1975 <li>a
1976 </li>
1977 <!--c2--><!--c3--><!--c4-->
1978 <li>b
1979 </li>
1980 </ul>
1981 !! end
1982
1983 ## Make sure ">" gets escaped in comments to avoid XSS
1984 !! test
1985 IE conditional comments
1986 !! wikitext
1987 <!--[if lt IE 9]>
1988 <script>alert('hi');</script>
1989 <![endif]-->
1990 !! html/parsoid
1991 <!--[if lt IE 9]&#x3E;
1992 <script&#x3E;alert('hi');</script&#x3E;
1993 <![endif]-->
1994 !! end
1995
1996 ###
1997 ### paragraph wrapping tests
1998 ###
1999
2000 !! test
2001 No block tags
2002 !! wikitext
2003 a
2004
2005 b
2006 !! html
2007 <p>a
2008 </p><p>b
2009 </p>
2010 !! end
2011
2012 !! test
2013 Block tag on one line (<div>)
2014 !! wikitext
2015 a <div>foo</div>
2016
2017 b
2018 !! html
2019 a <div>foo</div>
2020 <p>b
2021 </p>
2022 !! html+tidy
2023 <p>a </p><div>foo</div>
2024 <p>b
2025 </p>
2026 !! end
2027
2028 !! test
2029 No p-wrappable content
2030 !! options
2031 parsoid=wt2html,html2html
2032 !! wikitext
2033 <span><div>x</div></span>
2034 <span><s><div>x</div></s></span>
2035 <small><em></em></small><span><s><div>x</div></s></span>
2036 !! html+tidy
2037 <span><div>x</div></span>
2038 <span><s><div>x</div></s></span>
2039 <p><small><em></em></small></p><span><s><div>x</div></s></span>
2040 !! end
2041
2042 # T177612: Parsoid-only test
2043 !! test
2044 Transclusion meta tags shouldn't trip Parsoid's useless p-wrapper stripping code
2045 !! wikitext
2046 {{echo|<span><div>x</div></span>}}
2047 x
2048 !! html/parsoid
2049 <span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;span>&lt;div>x&lt;/div>&lt;/span>"}},"i":0}}]}'><div>x</div></span>
2050 <p>x</p>
2051 !! end
2052
2053 !! test
2054 Block tag on one line (<blockquote>)
2055 !! wikitext
2056 a <blockquote>foo</blockquote>
2057
2058 b
2059 !! html
2060 a <blockquote>foo</blockquote>
2061 <p>b
2062 </p>
2063 !! html+tidy
2064 <p>a </p><blockquote><p>foo</p></blockquote>
2065 <p>b
2066 </p>
2067 !! end
2068
2069 !! test
2070 Block tag on both lines (<div>)
2071 !! wikitext
2072 a <div>foo</div>
2073
2074 b <div>foo</div>
2075 !! html
2076 a <div>foo</div>
2077 b <div>foo</div>
2078
2079 !! html+tidy
2080 <p>a </p><div>foo</div><p>
2081 b </p><div>foo</div>
2082 !! end
2083
2084 !! test
2085 Block tag on both lines (<blockquote>)
2086 !! wikitext
2087 a <blockquote>foo</blockquote>
2088
2089 b <blockquote>foo</blockquote>
2090 !! html
2091 a <blockquote>foo</blockquote>
2092 b <blockquote>foo</blockquote>
2093
2094 !! html+tidy
2095 <p>a </p><blockquote><p>foo</p></blockquote><p>
2096 b </p><blockquote><p>foo</p></blockquote>
2097 !! end
2098
2099 !! test
2100 Multiple lines without block tags
2101 !! wikitext
2102 <div>foo</div> a
2103 b
2104 c
2105 d<!--foo--> e
2106 x <div>foo</div> z
2107 !! html
2108 <div>foo</div> a
2109 <p>b
2110 c
2111 d e
2112 </p>
2113 x <div>foo</div> z
2114
2115 !! html+tidy
2116 <div>foo</div><p> a
2117 </p><p>b
2118 c
2119 d e
2120 </p><p>
2121 x </p><div>foo</div><p> z
2122 </p>
2123 !! end
2124
2125 !! test
2126 Empty lines between lines with block tags
2127 !! wikitext
2128 <div></div>
2129
2130
2131 <div></div>a
2132
2133 b
2134 <div>a</div>b
2135
2136 <div>b</div>d
2137
2138
2139 <div>e</div>
2140 !! html
2141 <div></div>
2142 <p><br />
2143 </p>
2144 <div></div>a
2145 <p>b
2146 </p>
2147 <div>a</div>b
2148 <div>b</div>d
2149 <p><br />
2150 </p>
2151 <div>e</div>
2152
2153 !! html+tidy
2154 <div></div>
2155 <p><br />
2156 </p>
2157 <div></div><p>a
2158 </p><p>b
2159 </p>
2160 <div>a</div><p>b
2161 </p><div>b</div><p>d
2162 </p><p><br />
2163 </p>
2164 <div>e</div>
2165 !! html/parsoid
2166 <div data-parsoid='{"stx":"html"}'></div>
2167
2168 <p><br /></p>
2169 <div data-parsoid='{"stx":"html"}'></div><p>a</p>
2170
2171 <p>b</p>
2172 <div data-parsoid='{"stx":"html"}'>a</div><p>b</p>
2173
2174 <div data-parsoid='{"stx":"html"}'>b</div><p>d</p>
2175
2176 <p><br /></p>
2177 <div data-parsoid='{"stx":"html"}'>e</div>
2178 !! end
2179
2180 !! test
2181 Unclosed HTML p-tags should be handled properly
2182 !! wikitext
2183 <div><p>foo</div>
2184 a
2185
2186 b
2187 !! html/php+tidy
2188 <div><p>foo</p></div>
2189 <p>a
2190 </p><p>b
2191 </p>
2192 !! html/parsoid
2193 <div data-parsoid='{"stx":"html"}'><p data-parsoid='{"stx":"html", "autoInsertedEnd":true}'>foo</p></div>
2194 <p>a</p>
2195 <p>b</p>
2196 !! end
2197
2198 ## SSS FIXME: I can come up with other scenarios where this doesn't work because
2199 ## of eager output of buffered tokens in the p-wrapper. But, I'm going to ignore
2200 ## them for now.
2201 !! test
2202 1. P-wrapping should leave sol-transparent tags outside p-tags where possible
2203 !! options
2204 parsoid=wt2html
2205 !! wikitext
2206 a [[Category:A1]] [[Category:A2]]
2207 [[Category:A3]]
2208 [[Category:A4]]
2209 !! html/parsoid
2210 <p>a</p>
2211 <link rel="mw:PageProp/Category" href="./Category:A1"/> <link rel="mw:PageProp/Category" href="./Category:A2"/> <link rel="mw:PageProp/Category" href="./Category:A3"/> <link rel="mw:PageProp/Category" href="./Category:A4"/>
2212 !! end
2213
2214 !! test
2215 2. P-wrapping should leave sol-transparent tags outside p-tags where possible
2216 !! options
2217 parsoid=wt2html
2218 !! wikitext
2219 [[Category:A1]]a
2220 !! html/parsoid
2221 <link rel="mw:PageProp/Category" href="./Category:A1"/><p>a</p>
2222 !! end
2223
2224 !! test
2225 No paragraph necessary for SOL transparent template
2226 !! wikitext
2227 <span><div>foo</div></span>
2228 [[Category:Foo]]
2229
2230 <span><div>foo</div></span>
2231 {{echo|[[Category:Foo]]}}
2232 !! html/php
2233 <span><div>foo</div></span>
2234 <span><div>foo</div></span>
2235
2236 !! html/parsoid
2237 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2238 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
2239
2240 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2241 <link rel="mw:PageProp/Category" href="./Category:Foo" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Category:Foo]]"}},"i":0}}]}'/>
2242 !! end
2243
2244 !! test
2245 Avoid expanding multiline sol transparent template ranges unnecessarily
2246 !! wikitext
2247 hi
2248
2249
2250 {{echo|<br/>
2251 }}
2252
2253 [[Category:Ho]]
2254 !! html/php
2255 <p>hi
2256 </p><p><br />
2257 <br />
2258 </p>
2259 !! html/parsoid
2260 <p>hi</p>
2261
2262 <p><br />
2263 <br about="#mwt1" typeof="mw:Transclusion" data-parsoid='{}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;br/>\n"}},"i":0}}]}'/><span about="#mwt1">
2264 </span></p>
2265
2266 <link rel="mw:PageProp/Category" href="./Category:Ho" />
2267 !! end
2268
2269 !! test
2270 Paragraph wrapping following unclosed table
2271 !! options
2272 parsoid=wt2html,html2html
2273 !! wikitext
2274 {|
2275 |-
2276
2277 {|
2278 | x
2279 |}
2280
2281 a
2282
2283 b
2284
2285 c
2286 !! html/php+tidy
2287 <table>
2288
2289
2290 </table><table>
2291 <tbody><tr>
2292 <td>x
2293 </td></tr></tbody></table>
2294 <p>a
2295 </p><p>b
2296 </p><p>c
2297 </p>
2298 !! html/parsoid
2299 <table data-parsoid='{"autoInsertedEnd":true}'>
2300 <tbody><tr class="mw-empty-elt" data-parsoid='{"startTagSrc":"|-"}'></tr>
2301
2302 </tbody></table><table>
2303 <tbody><tr data-parsoid='{"autoInsertedStart":true}'><td>x</td></tr>
2304 </tbody></table>
2305
2306 <p>a</p>
2307
2308 <p>b</p>
2309
2310 <p>c</p>
2311 !! end
2312
2313 !! test
2314 Paragraph wrapping suppressed in html p
2315 !! options
2316 parsoid=wt2html,html2html
2317 !! wikitext
2318 <p>
2319
2320
2321 hi
2322
2323
2324
2325 </p>
2326 !! html/php+tidy
2327 <p>
2328
2329
2330 hi
2331
2332
2333
2334 </p>
2335 !! html/parsoid
2336 <p data-parsoid='{"stx":"html"}'>
2337
2338
2339 hi
2340
2341
2342
2343 </p>
2344 !! end
2345
2346 !! test
2347 Dangling table row doesn't prevent p-wrapping
2348 !! options
2349 parsoid=wt2html,html2html
2350 !! wikitext
2351 {|
2352 | hi
2353 |-
2354 |} ho
2355 !! html/parsoid
2356 <table>
2357 <tbody><tr><td>hi</td></tr>
2358 <tr class="mw-empty-elt"></tr>
2359 </tbody></table><p> ho</p>
2360 !! end
2361
2362 ###
2363 ### Preformatted text
2364 ###
2365
2366 !! test
2367 Preformatted text
2368 !! wikitext
2369 This is some
2370 Preformatted text
2371 With ''italic''
2372 And '''bold'''
2373 And a [[Main Page|link]]
2374 !! html
2375 <pre>This is some
2376 Preformatted text
2377 With <i>italic</i>
2378 And <b>bold</b>
2379 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
2380 </pre>
2381 !! end
2382
2383 !! test
2384 Tabs don't trigger preformatted text
2385 !! wikitext
2386 This is not
2387 preformatted text.
2388 This is preformatted text.
2389 So is this.
2390 !! html/php
2391 <p> This is not
2392 preformatted text.
2393 </p>
2394 <pre>This is preformatted text.
2395 So is this.
2396 </pre>
2397 !! html/parsoid
2398 <p> This is not
2399 preformatted text.</p>
2400 <pre>This is preformatted text.
2401 So is this.</pre>
2402 !! end
2403
2404 !! test
2405 Space before tab needs nowiki pre protection
2406 !! options
2407 parsoid=html2wt
2408 !! html/parsoid
2409 <p> a</p>
2410 !! wikitext
2411 <nowiki> </nowiki> a
2412 !! end
2413
2414 !! test
2415 Ident preformatting with inline content
2416 !! wikitext
2417 a
2418 ''b''
2419 !! html
2420 <pre>a
2421 <i>b</i>
2422 </pre>
2423 !! end
2424
2425 !! test
2426 <pre> with <nowiki> inside (compatibility with 1.6 and earlier)
2427 !! wikitext
2428 <pre><nowiki>
2429 <b>
2430 <cite>
2431 <em>
2432 </nowiki></pre>
2433 !! html
2434 <pre>
2435 &lt;b&gt;
2436 &lt;cite&gt;
2437 &lt;em&gt;
2438 </pre>
2439
2440 !! end
2441
2442 !! test
2443 Regression with preformatted in <center>
2444 !! wikitext
2445 <center>
2446 Blah
2447 </center>
2448 !! html
2449 <center>
2450 <pre>Blah
2451 </pre>
2452 </center>
2453
2454 !! end
2455
2456 !! test
2457 T54763: Preformatted in <blockquote>
2458 !! wikitext
2459 <blockquote>
2460 Blah
2461 {|
2462 |
2463 indented cell (no pre-wrapping!)
2464 |}
2465 </blockquote>
2466 !! html
2467 <blockquote>
2468 <p> Blah
2469 </p>
2470 <table>
2471 <tr>
2472 <td>
2473 <p> indented cell (no pre-wrapping!)
2474 </p>
2475 </td></tr></table>
2476 </blockquote>
2477
2478 !! end
2479
2480 !! test
2481 T53086: Double newlines in blockquotes should be turned into paragraphs
2482 !! wikitext
2483 <blockquote>
2484 Foo
2485
2486 Bar
2487 </blockquote>
2488 !! html
2489 <blockquote>
2490 <p>Foo
2491 </p><p>Bar
2492 </p>
2493 </blockquote>
2494
2495 !! end
2496
2497 !! test
2498 T17491: <ins>/<del> in blockquote
2499 !! wikitext
2500 <blockquote>
2501 Foo <del>bar</del> <ins>baz</ins> quux
2502 </blockquote>
2503 !! html
2504 <blockquote>
2505 <p>Foo <del>bar</del> <ins>baz</ins> quux
2506 </p>
2507 </blockquote>
2508
2509 !! html+tidy
2510 <blockquote>
2511 <p>Foo <del>bar</del> <ins>baz</ins> quux
2512 </p>
2513 </blockquote>
2514 !! end
2515
2516 !! test
2517 T17491: <ins>/<del> in blockquote (2)
2518 !! wikitext
2519 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2520 </blockquote>
2521 !! html
2522 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2523 </blockquote>
2524
2525 !! html+tidy
2526 <blockquote><p>Foo <del>bar</del> <ins>baz</ins> quux
2527 </p></blockquote>
2528 !! end
2529
2530 !! test
2531 <pre> with attributes (T5202)
2532 !! wikitext
2533 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2534 !! html
2535 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2536
2537 !! end
2538
2539 !! test
2540 <pre> with width attribute (T5202)
2541 !! wikitext
2542 <pre width="8">Narrow screen goodies</pre>
2543 !! html
2544 <pre width="8">Narrow screen goodies</pre>
2545
2546 !! end
2547
2548 !! test
2549 <pre> with forbidden attribute (T5202)
2550 !! wikitext
2551 <pre width="8" onmouseover="alert(document.cookie)">Narrow screen goodies</pre>
2552 !! html
2553 <pre width="8">Narrow screen goodies</pre>
2554
2555 !! end
2556
2557 !! test
2558 Entities inside <pre>
2559 !! wikitext
2560 <pre>&lt;</pre>
2561 !! html
2562 <pre>&lt;</pre>
2563
2564 !! end
2565
2566 !! test
2567 <pre> with forbidden attribute values (T5202)
2568 !! wikitext
2569 <pre width="8" style="border-width: expression(alert(document.cookie))">Narrow screen goodies</pre>
2570 !! html
2571 <pre width="8" style="/* insecure input */">Narrow screen goodies</pre>
2572
2573 !! end
2574
2575 !! test
2576 <nowiki> inside <pre> (T15238)
2577 !! wikitext
2578 <pre>
2579 <nowiki>
2580 </pre>
2581 <pre>
2582 <nowiki></nowiki>
2583 </pre>
2584 <pre><nowiki><nowiki></nowiki>Foo<nowiki></nowiki></nowiki></pre>
2585 !! html
2586 <pre>
2587 &lt;nowiki&gt;
2588 </pre>
2589 <pre>
2590
2591 </pre>
2592 <pre>&lt;nowiki&gt;Foo&lt;/nowiki&gt;</pre>
2593
2594 !! end
2595
2596 !! test
2597 <nowiki> inside of #tag:pre
2598 !! wikitext
2599 {{#tag:pre|Foo <nowiki>&rarr;bar</nowiki>}}
2600 !! html/php
2601 <pre>Foo &#8594;bar</pre>
2602
2603 !! html/parsoid
2604 <pre about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"#tag:pre","function":"tag"},"params":{"1":{"wt":"Foo &lt;nowiki>&amp;rarr;bar&lt;/nowiki>"}},"i":0}}]}'>Foo <span typeof="mw:Entity">→</span>bar</pre>
2605 !! end
2606
2607 ## Don't expect this to rt, Parsoid drops the unmatched closing pre tags that
2608 ## aren't enclosed in nowikis.
2609 !! test
2610 <nowiki> and <pre> preference (first one wins)
2611 !! options
2612 parsoid=wt2html
2613 !! wikitext
2614 <pre>
2615 <nowiki>
2616 </pre>
2617 </nowiki>
2618 </pre>
2619
2620 <nowiki>
2621 <pre>
2622 <nowiki>
2623 </pre>
2624 </nowiki>
2625 </pre>
2626
2627 !! html/php
2628 <pre>
2629 &lt;nowiki&gt;
2630 </pre>
2631 <p>&lt;/nowiki&gt;
2632 &lt;/pre&gt;
2633 </p><p>
2634 &lt;pre&gt;
2635 &lt;nowiki&gt;
2636 &lt;/pre&gt;
2637
2638 &lt;/pre&gt;
2639 </p>
2640 !! html/parsoid
2641 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n&lt;nowiki>\n"}}'>&lt;nowiki>
2642 </pre>
2643 <p>&lt;/nowiki></p>
2644
2645
2646 <p><span typeof="mw:Nowiki">
2647 &lt;pre>
2648 &lt;nowiki>
2649 &lt;/pre>
2650 </span></p>
2651 !! end
2652
2653 !! test
2654 </pre> inside nowiki
2655 !! wikitext
2656 <nowiki></pre></nowiki>
2657 !! html
2658 <p>&lt;/pre&gt;
2659 </p>
2660 !! end
2661
2662 !! test
2663 Empty pre; pre inside other HTML tags (T56946)
2664 !! wikitext
2665 a
2666
2667 <div><pre>
2668 foo
2669 </pre></div>
2670 <pre></pre>
2671 !! html/php+tidy
2672 <p>a
2673 </p>
2674 <div><pre>foo
2675 </pre></div>
2676 <pre></pre>
2677 !! html/parsoid
2678 <p>a</p>
2679
2680 <div data-parsoid='{"stx":"html"}'><pre typeof="mw:Extension/pre" about="#mwt2" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
2681 </pre></div>
2682 <pre typeof="mw:Extension/pre" about="#mwt4" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":""}}'></pre>
2683 !! end
2684
2685 !! test
2686 HTML pre followed by indent-pre
2687 !! wikitext
2688 <pre>foo</pre>
2689 bar
2690 !! html
2691 <pre>foo</pre>
2692 <pre>bar
2693 </pre>
2694 !! end
2695
2696 !! test
2697 Block tag pre
2698 !! wikitext
2699 <p><pre>foo</pre></p>
2700 !! html/php+tidy
2701 <p class="mw-empty-elt"></p><pre>foo</pre><p class="mw-empty-elt"></p>
2702 !! html/parsoid
2703 <p class='mw-empty-elt' data-parsoid='{"stx":"html","autoInsertedEnd":true}'></p><pre typeof="mw:Extension/pre" about="#mwt2" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre><p class='mw-empty-elt' data-parsoid='{"autoInsertedStart":true,"stx":"html"}'></p>
2704 !! end
2705
2706 !!test
2707 Templates: Indent-Pre: 1a. Templates that break a line should suppress <pre>
2708 !! wikitext
2709 {{echo|}}
2710 !! html
2711
2712 !!end
2713
2714 !!test
2715 Templates: Indent-Pre: 1b. Templates that break a line should suppress <pre>
2716 !! wikitext
2717 {{echo|
2718 foo}}
2719 !! html
2720 <p>foo
2721 </p>
2722 !!end
2723
2724 !! test
2725 Templates: Indent-Pre: 1c: Wrapping should be based on expanded content
2726 !! wikitext
2727 {{echo|a
2728 b}}
2729 !! html
2730 <pre>a
2731 </pre>
2732 <p>b
2733 </p>
2734 !!end
2735
2736 !! test
2737 Templates: Indent-Pre: 1d: Wrapping should be based on expanded content
2738 !! wikitext
2739 {{echo|a
2740 b
2741 c
2742 d
2743 e
2744 }}
2745 !! html
2746 <pre>a
2747 </pre>
2748 <p>b
2749 c
2750 </p>
2751 <pre>d
2752 </pre>
2753 <p>e
2754 </p>
2755 !!end
2756
2757 !!test
2758 Templates: Indent-Pre: 1e. Wrapping should be based on expanded content
2759 !! wikitext
2760 {{echo| foo}}
2761
2762 {{echo| foo}}{{echo| bar}}
2763
2764 {{echo| foo}}
2765 {{echo| bar}}
2766
2767 {{echo|<!--cmt--> foo}}
2768
2769 <!--cmt-->{{echo| foo}}
2770
2771 {{echo|{{echo| }}bar}}
2772 !! html
2773 <pre>foo
2774 </pre>
2775 <pre>foo bar
2776 </pre>
2777 <pre>foo
2778 bar
2779 </pre>
2780 <pre>foo
2781 </pre>
2782 <pre>foo
2783 </pre>
2784 <pre>bar
2785 </pre>
2786 !!end
2787
2788 !! test
2789 Templates: Indent-Pre: 1f: Wrapping should be based on expanded content
2790 !! wikitext
2791 {{echo| }}a
2792
2793 {{echo|
2794 }}a
2795
2796 {{echo|
2797 b}}
2798
2799 {{echo|a
2800 }}b
2801
2802 {{echo|a
2803 }} b
2804 !! html
2805 <pre>a
2806 </pre>
2807 <p><br />
2808 </p>
2809 <pre>a
2810 </pre>
2811 <p><br />
2812 </p>
2813 <pre>b
2814 </pre>
2815 <p>a
2816 </p>
2817 <pre>b
2818 </pre>
2819 <p>a
2820 </p>
2821 <pre>b
2822 </pre>
2823 !!end
2824
2825 ## Hmm, should Parsoid rt this?
2826 !! test
2827 Pres with newline attributes
2828 !! options
2829 parsoid=wt2html,html2html
2830 !! wikitext
2831 <pre class="one
2832 two">hi</pre>
2833 !! html/php
2834 <pre class="one two">hi</pre>
2835
2836 !! html/parsoid
2837 <pre class="one two" typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"class":"one two"},"body":{"extsrc":"hi"}}'>hi</pre>
2838 !! end
2839
2840 !! test
2841 Things that look like <pre> tags aren't treated as such
2842 !! wikitext
2843 Barack Obama <President> of the United States
2844 <President></President>
2845 !! html
2846 <p>Barack Obama &lt;President&gt; of the United States
2847 &lt;President&gt;&lt;/President&gt;
2848 </p>
2849 !! end
2850
2851 ## Remex doesn't account for fostered content.
2852 ## The difference between Parsoid and the PHP parser can be attributed to core
2853 ## commit 674e8388cba and 710618f89af in Parsoid's repo. Parsoid doesn't
2854 ## tokenize unmatched extension tags that shadow html tags as strings to ease
2855 ## an escaping mechanism. See the comment in `maybeExtensionTag`.
2856 !! test
2857 Handle broken pre-like tags (T66025)
2858 !! options
2859 parsoid=wt2html
2860 !! wikitext
2861 {{echo|<pre <pre>x</pre>}}
2862
2863 <table><pre </table>
2864 !! html/php
2865 <pre>x</pre>
2866 <table>&lt;pre </table>
2867
2868 !! html/php+tidy
2869 <pre>x</pre>
2870 &lt;pre <table></table>
2871 !! html/parsoid
2872 <pre typeof="mw:Extension/pre mw:Transclusion" about="#mwt2" data-parsoid='{"stx":"html","a":{"&lt;pre":null},"sa":{"&lt;pre":""},"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;pre &lt;pre>x&lt;/pre>"}},"i":0}}]}'>x</pre>
2873
2874 <pre data-parsoid='{"stx":"html","src":"&lt;pre &lt;/table>","tagWidths":[13,0],"a":{"&lt;":null,"table":null},"sa":{"&lt;":"","table":""},"fostered":true,"autoInsertedEnd":true}'></pre><table data-parsoid='{"stx":"html","autoInsertedEnd":true}'></table>
2875 !! end
2876
2877 ## Similar to the above, but shows the difference between extension and html tags
2878 !! test
2879 Less than in attribute position
2880 !! wikitext
2881 <pre <pre>123</pre>
2882
2883 <div <div>123</div>
2884 !! html/php+tidy
2885 <pre>123</pre><p>
2886 &lt;div </p><div>123</div>
2887 !! html/parsoid
2888 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"&lt;pre":""},"body":{"extsrc":"123"}}'>123</pre><p>
2889
2890 &lt;div </p><div>123</div>
2891 !! end
2892
2893 !! test
2894 Parsoid: handle pre with space after attribute
2895 !! options
2896 parsoid=wt2html
2897 !! wikitext
2898 <pre style="width:50%;" >{{echo|foo}}</pre>
2899 !! html/php
2900 <pre style="width:50%;">{{echo|foo}}</pre>
2901
2902 !! html/parsoid
2903 <pre typeof="mw:Extension/pre" about="#mwt2" style="width:50%;" data-mw='{"name":"pre","attrs":{"style":"width:50%;"},"body":{"extsrc":"{{echo|foo}}"}}'>{{echo|foo}}</pre>
2904 !! end
2905
2906 !! test
2907 Self-closed pre
2908 !! wikitext
2909 <pre />
2910 !! html/php
2911 <pre></pre>
2912
2913 !! html/parsoid
2914 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{}}'></pre>
2915 !! end
2916
2917 !! test
2918 Newline before table-close generates empty table row: T208619
2919 !! wikitext
2920 {|
2921
2922 |}
2923 !! html/php+tidy
2924 <table>
2925
2926 <tbody><tr><td></td></tr></tbody></table>
2927 !! html/parsoid
2928 <table data-parsoid='{}'>
2929
2930 </table>
2931 !! end
2932
2933 # PHP has one more row in the output than Parsoid does: T208619
2934 !! test
2935 Parsoid: Don't paragraph-wrap fosterable content even if table syntax is unbalanced
2936 !! options
2937 parsoid=wt2html
2938 !! wikitext
2939 {|
2940 <td>
2941 <td>
2942 </td>
2943
2944
2945
2946 |}
2947 !! html/php+tidy
2948 <table>
2949 <tbody><tr><td>
2950 </td><td>
2951 </td>
2952
2953
2954
2955 </tr><tr><td></td></tr></tbody></table>
2956 !! html/parsoid
2957 <table>
2958
2959 <tbody>
2960 <tr>
2961 <td></td>
2962
2963 <td>
2964 </td></tr>
2965
2966
2967
2968 </tbody></table>
2969 !! end
2970
2971
2972 #--------------------------------------------------------------------
2973 # Transclusion parameter whitespace stripping tests
2974 # Behavior is different for positional and named parameters
2975 #--------------------------------------------------------------------
2976 !! test
2977 Templates: Strip leading and trailing whitespace from named-param values
2978 !! wikitext
2979 {{echo|1= a }}
2980
2981 {{echo|1= {{echo|b}} }}
2982
2983 {{echo| 1 =
2984 c }}
2985
2986 {{echo| 1 =
2987 * d
2988 }}
2989 !! html
2990 <p>a
2991 </p><p>b
2992 </p><p>c
2993 </p>
2994 <ul><li>d</li></ul>
2995
2996 !! end
2997
2998 !! test
2999 Templates: Don't strip whitespace from positional-param values
3000 !! wikitext
3001 {{echo|a }}
3002
3003 {{echo|{{echo|b}} }}
3004
3005 {{echo| c
3006 }}
3007
3008 {{echo| {{echo|d}}
3009 }}
3010
3011 {{echo|
3012 e}}
3013
3014 {{echo|
3015 *f}}
3016
3017 {{echo|
3018 }}g
3019 !! html
3020 <p>a
3021 </p><p>b
3022 </p>
3023 <pre>c
3024 </pre>
3025 <p><br />
3026 </p>
3027 <pre>d
3028 </pre>
3029 <p><br />
3030 </p>
3031 <pre>e
3032 </pre>
3033 <p><br />
3034 </p>
3035 <ul><li>f</li></ul>
3036 <p><br />
3037 </p>
3038 <pre>g
3039 </pre>
3040 !! end
3041
3042 !! test
3043 Templates: Don't recognize targets split by newlines
3044 !! options
3045 parsoid=wt2html
3046 !! wikitext
3047 {{ech
3048 o|foo}}
3049 !! html/php
3050 <p>{{ech
3051 o|foo}}
3052 </p>
3053 !! html/parsoid
3054 <p>{{ech
3055 o|foo}}</p>
3056 !! end
3057
3058 !! test
3059 Templates: Recognize targets when newlines and comments don't split the target
3060 !! options
3061 parsoid=wt2html
3062 !! wikitext
3063 {{
3064 <!--X--> ech<!--X-->o<!--X-->
3065 <!--X--> <!--X-->
3066
3067 |foo}}
3068 !! html/php
3069 <p>foo
3070 </p>
3071 !! html/parsoid
3072 <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>
3073 !! end
3074
3075 !! test
3076 Templates: Handle empty comment-and-ws-only lines correctly
3077 !! wikitext
3078 {{echo|foo
3079 <!--should be ignored-->
3080 <!--should be ignored as well-->
3081 bar}}
3082 !! html/php
3083 <p>foo
3084 bar
3085 </p>
3086 !! html/parsoid
3087 <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>
3088 !! end
3089
3090 !! test
3091 Templates: Handle comments in the target
3092 !! wikitext
3093 {{echo
3094 <!-- should be ignored -->
3095 |foo}}
3096
3097 {{echo
3098 <!-- should be ignored and spaces on next line should not trip us up (T147742) -->
3099 |foo}}
3100
3101 {{echo<!-- should be ignored -->
3102 |foo}}
3103
3104 {{echo<!-- should be ignored -->|foo}}
3105
3106 {{<!-- should be ignored -->echo|foo}}
3107 !! html/php
3108 <p>foo
3109 </p><p>foo
3110 </p><p>foo
3111 </p><p>foo
3112 </p><p>foo
3113 </p>
3114 !! html/parsoid
3115 <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>
3116
3117 <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>
3118
3119 <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>
3120
3121 <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>
3122
3123 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
3124 !! end
3125
3126 !! test
3127 Templates: Handle comments in parameter names (T69657)
3128 !! wikitext
3129 {{echo|1
3130 <!-- should be ignored -->
3131 =foo}}
3132
3133 {{echo|
3134 <!-- should be ignored -->
3135 1 = foo}}
3136
3137 {{echo|1<!-- should be ignored -->=foo}}
3138
3139 {{echo|<!-- should be ignored -->1=foo}}
3140 !! html/php
3141 <p>foo
3142 </p><p>foo
3143 </p><p>foo
3144 </p><p>foo
3145 </p>
3146 !! html/parsoid
3147 <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>
3148
3149 <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>
3150
3151 <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>
3152
3153 <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>
3154 !! end
3155
3156 !! test
3157 Templates: Other wikitext in parameter names (T69657)
3158 !! wikitext
3159 {{echo|''1''=foo}}
3160 !! html/php
3161 <p>{{{1}}}
3162 </p>
3163 !! html/parsoid
3164 <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>
3165 !! end
3166
3167 !! test
3168 Templates: With colons
3169 !! wikitext
3170 {{With: Colon}}
3171 !! html/php
3172 <p>Template with colon
3173 </p>
3174 !! html/parsoid
3175 <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>
3176 !! end
3177
3178 #--------------------------------------------------------------------
3179 # Transclusion parameter escaping tests
3180 #--------------------------------------------------------------------
3181
3182 !! test
3183 Templates: Parsoid parameter escaping test 1
3184 !! wikitext
3185 {{echo|[foo]|{{echo|[bar]}}}}
3186 !! html/php+tidy
3187 <p>[foo]
3188 </p>
3189 !! html/parsoid
3190 <p about="#mwt1" typeof="mw:Transclusion"
3191 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[foo]"},"2":{"wt":"{{echo|[bar]}}"}},"i":0}}]}'>[foo]</p>
3192 !! end
3193
3194 !! test
3195 Parsoid: Pipes in external links in template parameter
3196 !! wikitext
3197 {{echo|[{{echo|http://example.com}} link]}}
3198 !! html/php+tidy
3199 <p><a rel="nofollow" class="external text" href="http://example.com">link</a>
3200 </p>
3201 !! html/parsoid
3202 <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>
3203 !! end
3204
3205 !! test
3206 Parsoid: pipe in transclusion parameter
3207 !! wikitext
3208 {{echo|http://foo.com/a&#124;b}}
3209 !! html/php+tidy
3210 <p><a rel="nofollow" class="external free" href="http://foo.com/a%7Cb">http://foo.com/a%7Cb</a>
3211 </p>
3212 !! html/parsoid
3213 <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>
3214 !! end
3215
3216 !! test
3217 Parsoid: Pipe in external link target and content in template parameter
3218 !! options
3219 parsoid=html2wt,wt2wt
3220 !! wikitext
3221 {{echo|[http://foo.com/a&#124;b a&#124;b]}}
3222 !! html/php+tidy
3223 <p><a rel="nofollow" class="external text" href="http://foo.com/a%7Cb">a&#124;b</a>
3224 </p>
3225 !! html/parsoid
3226 <p><a rel="mw:ExtLink" href="http://foo.com/a|b" about="#mwt1"
3227 typeof="mw:Transclusion"
3228 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},
3229 "params":{"1":{"wt":"[http://foo.com/a|b a|b]"}},"i":0}}]}'>a|b</a></p>
3230 !! end
3231
3232 !! test
3233 Parsoid: Pipe in template with nested template in external link target in template parameter (seriously)
3234 !! wikitext
3235 {{echo|[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]}}
3236 !! html/php+tidy
3237 <p><a rel="nofollow" class="external text" href="http://example.org/index.php?title=Parser_test&amp;action=edit">bar</a>
3238 </p>
3239 !! html/parsoid
3240 <p><a rel="mw:ExtLink" class="external text" href="http://example.org/index.php?title=Parser_test&amp;action=edit" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]"}},"i":0}}]}'>bar</a></p>
3241 !! end
3242
3243 !! test
3244 Templates: Don't escape already nowiki-escaped text in template parameters
3245 !! options
3246 parsoid=html2wt,wt2wt
3247 !! wikitext
3248 {{echo|foo<nowiki>|</nowiki>bar}}
3249 {{echo|<nowiki>&lt;div&gt;</nowiki>}}
3250 {{echo|<nowiki></nowiki>}}
3251 !! html/php+tidy
3252 <p>foo|bar
3253 &lt;div&gt;
3254
3255 </p>
3256 !! html/parsoid
3257 <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>
3258 <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>
3259 <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>
3260 </p>
3261 !! end
3262
3263 ## T54824
3264 !! test
3265 Templates: '=' char in nested transclusions should not trigger nowiki escapes or conversion to named param
3266 !! options
3267 parsoid=html2wt,wt2wt
3268 !! wikitext
3269 {{echo|{{echo|1=bar}}}}
3270 !! html/php+tidy
3271 <p>bar
3272 </p>
3273 !! html/parsoid
3274 <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>
3275 !! end
3276
3277 ## T58733
3278 !! test
3279 Templates parameters with special tokenizing behavior dont get modified because of arg escaping
3280 !! wikitext
3281 {{echo|a : b}}
3282 !! html/php+tidy
3283 <p>a&#160;: b
3284 </p>
3285 !! html/parsoid
3286 <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>
3287 !! end
3288
3289 ## T73412
3290 !! test
3291 Templates: Preserve blank parameter names
3292 !! wikitext
3293 {{echo|=foo}}
3294 !! html/php+tidy
3295 <p>{{{1}}}
3296 </p>
3297 !! html/parsoid
3298 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"":{"wt":"foo"}},"i":0}}]}'>{{{1}}}</p>
3299 !! end
3300
3301 !! test
3302 Templates: Preserve blank parameter names in other positions
3303 !! wikitext
3304 {{blank_param|bar|=foo}}
3305 !! html/php+tidy
3306 <p>bar
3307 foo
3308 </p>
3309 !! html/parsoid
3310 <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
3311 foo</p>
3312 !! end
3313
3314 ###
3315 ### Parsoid-centric tests for testing RT edge cases for pre
3316 ###
3317
3318 !!test
3319 1a. Indent-Pre and Comments
3320 !! wikitext
3321 a
3322 <!--a-->
3323 c
3324 !! html
3325 <pre>a
3326 </pre>
3327 <p>c
3328 </p>
3329 !!end
3330
3331 !!test
3332 1b. Indent-Pre and Comments
3333 !! wikitext
3334 a
3335 <!--a-->
3336 c
3337 !! html
3338 <pre>a
3339 </pre>
3340 <p>c
3341 </p>
3342 !!end
3343
3344 !!test
3345 1c. Indent-Pre and Comments
3346 !! wikitext
3347 <!--a--> a
3348
3349 <!--a--> a
3350 !! html
3351 <pre> a
3352 </pre>
3353 <pre> a
3354 </pre>
3355 !!end
3356
3357 !!test
3358 1d. Indent-Pre and Comments
3359 (Pre-handler currently cannot distinguish between comment/ws order and normalizes them to [comment,ws] order)
3360 !! wikitext
3361 <!--a--> a
3362
3363 <!--b-->b
3364 !! html
3365 <pre>a
3366 </pre>
3367 <pre>b
3368 </pre>
3369 !!end
3370
3371 !!test
3372 2a. Indent-Pre and tables
3373 !! wikitext
3374 {|
3375 |-
3376 !h1!!h2
3377 |foo||bar
3378 |}
3379 !! html
3380 <table>
3381
3382 <tr>
3383 <th>h1</th>
3384 <th>h2
3385 </th>
3386 <td>foo</td>
3387 <td>bar
3388 </td></tr></table>
3389
3390 !!end
3391
3392 !!test
3393 2b. Indent-Pre and tables
3394 !! wikitext
3395 {|
3396 |-
3397 |foo
3398 |}
3399 !! html
3400 <table>
3401
3402 <tr>
3403 <td>foo
3404 </td></tr></table>
3405
3406 !!end
3407
3408 !!test
3409 2c. Indent-Pre and tables (T44252)
3410 !! wikitext
3411 {|
3412 |+foo
3413 ! |bar
3414 |}
3415 !! html
3416 <table>
3417 <caption>foo
3418 </caption>
3419 <tr>
3420 <th>bar
3421 </th></tr></table>
3422
3423 !!end
3424
3425 !!test
3426 2d. Indent-Pre and tables
3427 !! wikitext
3428 a
3429 {|
3430 |b
3431 |}
3432 !! html/php
3433 <pre>a
3434 </pre>
3435 <table>
3436 <tr>
3437 <td>b
3438 </td></tr></table>
3439
3440 !! html/parsoid
3441 <pre>a</pre>
3442 <table>
3443 <tbody><tr><td> b</td></tr>
3444 </tbody></table>
3445 !!end
3446
3447 !!test
3448 2e. Indent-Pre and table-line syntax
3449 !! wikitext
3450 a
3451 | b
3452 | c
3453 !! html/php
3454 <pre>a
3455 | b
3456 | c
3457 </pre>
3458 !!end
3459
3460 !!test
3461 2f. Indent-pre started by table-line syntax
3462 !! wikitext
3463 a
3464 | b
3465 | c
3466 !! html/php
3467 <p>a
3468 </p>
3469 <pre>| b
3470 | c
3471 </pre>
3472 !! html/parsoid
3473 <p>a</p>
3474 <pre>
3475 | b
3476 | c</pre>
3477 !!end
3478
3479 !! test
3480 2g. Indented table markup mixed with indented pre content (proposed in T8200)
3481 !! wikitext
3482 <table>
3483 <tr>
3484 <td>
3485 Text that should be rendered preformatted
3486 </td>
3487 </tr>
3488 </table>
3489 !! html
3490 <table>
3491 <tr>
3492 <td>
3493 <pre>Text that should be rendered preformatted
3494 </pre>
3495 </td>
3496 </tr>
3497 </table>
3498
3499 !! end
3500
3501 !! test
3502 2h. Indent pre in tables
3503 !! options
3504 parsoid=wt2html,html2html
3505 !! wikitext
3506 {|
3507 !
3508 foo
3509 !
3510 bar
3511 |-
3512 |
3513 baz
3514 {{!}}
3515 bam
3516 |}
3517 !! html/php
3518 <table>
3519 <tr>
3520 <th>
3521 <pre>foo
3522 </pre>
3523 </th>
3524 <th>
3525 <pre>bar
3526 </pre>
3527 </th></tr>
3528 <tr>
3529 <td>
3530 <pre>baz
3531 </pre>
3532 </td>
3533 <td>
3534 <pre>bam
3535 </pre>
3536 </td></tr></table>
3537
3538 !! html/parsoid
3539 <table>
3540 <tbody><tr><th>
3541 <pre>foo</pre>
3542 </th><th>
3543 <pre>bar</pre>
3544 </th></tr><tr>
3545 <td>
3546 <pre>baz</pre>
3547 </td><td data-parsoid='{"startTagSrc":"{{!}}"}'>
3548 <pre>bam</pre>
3549 </td></tr></tbody></table>
3550 !! end
3551
3552 !! test
3553 3a. Indent-Pre and block tags (single-line html)
3554 !! wikitext
3555 a <p> foo </p>
3556 b <div> foo </div>
3557 c <blockquote> foo </blockquote>
3558 <span> foo </span>
3559 !! html
3560 a <p> foo </p>
3561 b <div> foo </div>
3562 c <blockquote> foo </blockquote>
3563 <pre><span> foo </span>
3564 </pre>
3565 !! html/php+tidy
3566 <p> a </p><p> foo </p><p>
3567 b </p><div> foo </div><p>
3568 c </p><blockquote><p> foo </p></blockquote>
3569 <pre><span> foo </span>
3570 </pre>
3571 !! html/parsoid
3572 <p> a </p><p data-parsoid='{"stx":"html"}'> foo </p><p>
3573 b </p><div data-parsoid='{"stx":"html"}'> foo </div><p>
3574 c </p><blockquote data-parsoid='{"stx":"html"}'><p> foo </p></blockquote>
3575 <pre><span data-parsoid='{"stx":"html"}'> foo </span></pre>
3576 !! end
3577
3578 !! test
3579 3b. Indent-Pre and block tags (multi-line html)
3580 !! wikitext
3581 a <span>foo</span>
3582 <!-- comment --> b <div> foo </div>
3583 !! html/php
3584 <pre>a <span>foo</span>
3585 </pre>
3586 b <div> foo </div>
3587
3588 !! html/parsoid
3589 <pre>a <span data-parsoid='{"stx":"html"}'>foo</span></pre>
3590 <!-- comment --> <p>b </p><div data-parsoid='{"stx":"html"}'> foo </div>
3591 !! html/php+tidy
3592 <pre>a <span>foo</span>
3593 </pre><p>
3594 b </p><div> foo </div>
3595 !! end
3596
3597 !!test
3598 3c. Indent-Pre and block tags (pre-content on separate line)
3599 !! wikitext
3600 <p>
3601 foo
3602 </p>
3603
3604 <div>
3605 foo
3606 </div>
3607
3608 <center>
3609 foo
3610 </center>
3611
3612 <blockquote>
3613 foo
3614 </blockquote>
3615
3616 <blockquote>
3617 <pre>
3618 foo
3619 </pre>
3620 </blockquote>
3621
3622 <table><tr><td>
3623 foo
3624 </td></tr></table>
3625
3626 <ul><li>
3627 foo
3628 </li></ul>
3629
3630 !! html
3631 <p>
3632 foo
3633 </p>
3634 <div>
3635 <pre>foo
3636 </pre>
3637 </div>
3638 <center>
3639 <pre>foo
3640 </pre>
3641 </center>
3642 <blockquote>
3643 <p> foo
3644 </p>
3645 </blockquote>
3646 <blockquote>
3647 <pre>
3648 foo
3649 </pre>
3650 </blockquote>
3651 <table><tr><td>
3652 <pre>foo
3653 </pre>
3654 </td></tr></table>
3655 <ul><li>
3656 foo
3657 </li></ul>
3658
3659 !!end
3660
3661 !! test
3662 4. Indent-Pre and extension tags
3663 !! options
3664 parsoid=wt2html,html2html
3665 !! wikitext
3666 a <tag />
3667 !! html/php+tidy
3668 <p> a </p><pre>NULL
3669 array (
3670 )
3671 </pre>
3672 !! html/parsoid
3673 <p> a </p><pre typeof="mw:Extension/tag" about="#mwt2" data-mw='{"name":"tag","attrs":{}}'></pre>
3674 !! end
3675
3676 !! test
3677 5. Indent-Pre and html pre
3678 !! wikitext
3679 <pre class="123">hi</pre>
3680 !! html/php
3681 <pre class="123">hi</pre>
3682
3683 !! html/parsoid
3684 <pre class="123" typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"class":"123"},"body":{"extsrc":"hi"}}'>hi</pre>
3685 !! end
3686
3687 !!test
3688 Render paragraphs when indent-pre is suppressed in blocklevels
3689 !! wikitext
3690 <blockquote>
3691 foo
3692
3693 bar
3694 </blockquote>
3695 !! html
3696 <blockquote>
3697 <p> foo
3698 </p><p> bar
3699 </p>
3700 </blockquote>
3701
3702 !!end
3703
3704 !!test
3705 4. Multiple spaces at start-of-line
3706 !! wikitext
3707 <p> foo </p>
3708 foo
3709 {|
3710 |foo
3711 |}
3712 !! html
3713 <p> foo </p>
3714 <pre> foo
3715 </pre>
3716 <table>
3717 <tr>
3718 <td>foo
3719 </td></tr></table>
3720
3721 !!end
3722
3723 ## NOTE: the leading white-space chars on empty line are significant
3724 !! test
3725 5a. White-space in indent-pre
3726 !! wikitext
3727 a<br />
3728
3729 b
3730 !! html
3731 <pre>a<br />
3732
3733 b
3734 </pre>
3735 !! end
3736
3737 ## NOTE: the leading white-space chars on empty line are significant
3738 !! test
3739 5b. White-space in indent-pre
3740 !! wikitext
3741 a
3742
3743 b
3744
3745
3746 c
3747 !! html
3748 <pre>a
3749
3750 b
3751
3752
3753 c
3754 </pre>
3755 !! end
3756
3757 !! test
3758 5c. White-space in indent-pre
3759 !! wikitext
3760 ''a''
3761 ''b''
3762 ''c''
3763 !! html
3764 <pre><i>a</i>
3765 <i>b</i>
3766 <i>c</i>
3767 </pre>
3768 !! end
3769
3770 !! test
3771 6. Pre-blocks should extend across lines with leading WS even when there is no wrappable content
3772 !! wikitext
3773 a
3774
3775 <!-- continue -->
3776 b
3777
3778 c
3779
3780 d
3781 !! html
3782 <pre>a
3783
3784 b
3785 </pre>
3786 <pre>c
3787
3788 </pre>
3789 <p>d
3790 </p>
3791 !! end
3792
3793 !! test
3794 7a. Indent-pre and category links
3795 !! options
3796 parsoid=wt2html,wt2wt
3797 !! wikitext
3798 [[Category:foo]] <!-- No pre-wrapping -->
3799 {{echo| [[Category:foo]]}} <!-- No pre-wrapping -->
3800 !! html/php+tidy
3801 !! html/parsoid
3802 <link rel="mw:PageProp/Category" href="./Category:Foo"> <!-- No pre&#x2D;wrapping -->
3803 <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 -->
3804 !! end
3805
3806 ## We used to, but no longer wt2wt this test since the default serializer
3807 ## will normalize all categories to serialize on their own line.
3808 ## This wikitext usage is going to be fairly uncommon in production and
3809 ## selser will take care of preserving formatting in those scenarios.
3810 !! test
3811 7b. Indent-pre and category links
3812 !! options
3813 parsoid=wt2html
3814 !! wikitext
3815 [[Category:foo]] a
3816 [[Category:foo]] {{echo|b}}
3817 !! html/parsoid
3818 <pre><link rel="mw:PageProp/Category" href="./Category:Foo"> a
3819 <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>
3820 !! end
3821
3822 !! test
3823 Indent-Pre: Newlines in comments shouldn't affect sol state
3824 !! wikitext
3825 a <!--
3826 foo
3827 --> b
3828 !! html/php+tidy
3829 <p>a b
3830 </p>
3831 !! html/parsoid
3832 <p>a <!--
3833 foo
3834 --> b</p>
3835 !! end
3836
3837 ###
3838 ### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric)
3839 ###
3840
3841 !!test
3842 HTML-pre: 1. embedded newlines
3843 !! wikitext
3844 <pre>foo</pre>
3845
3846 <pre>
3847 foo
3848 </pre>
3849
3850 <pre>
3851
3852 foo
3853 </pre>
3854
3855 <pre>
3856
3857
3858 foo
3859 </pre>
3860 !! html/php+tidy
3861 <pre>foo</pre>
3862 <pre>foo
3863 </pre>
3864 <pre>
3865
3866 foo
3867 </pre>
3868 <pre>
3869
3870
3871 foo
3872 </pre>
3873 !! html/parsoid
3874 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre>
3875
3876 <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
3877 </pre>
3878
3879 <pre typeof="mw:Extension/pre" about="#mwt6" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\nfoo\n"}}'>
3880
3881 foo
3882 </pre>
3883
3884 <pre typeof="mw:Extension/pre" about="#mwt8" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\nfoo\n"}}'>
3885
3886
3887 foo
3888 </pre>
3889 !!end
3890
3891 !! test
3892 HTML-pre: big spaces
3893 !! wikitext
3894 <pre>
3895
3896
3897
3898
3899 haha
3900
3901
3902
3903
3904 haha
3905
3906
3907
3908
3909 </pre>
3910 !! html/php+tidy
3911 <pre>
3912
3913
3914
3915
3916 haha
3917
3918
3919
3920
3921 haha
3922
3923
3924
3925
3926 </pre>
3927 !! html/parsoid
3928 <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"}}'>
3929
3930
3931
3932
3933 haha
3934
3935
3936
3937
3938 haha
3939
3940
3941
3942
3943 </pre>
3944 !! end
3945
3946 !!test
3947 HTML-pre: 2: indented text
3948 !! wikitext
3949 <pre>
3950 foo
3951 </pre>
3952 !! html
3953 <pre>
3954 foo
3955 </pre>
3956
3957 !!end
3958
3959 !!test
3960 HTML-pre: 3: other wikitext
3961 !! wikitext
3962 <pre>
3963 * foo
3964 # bar
3965 = no-h =
3966 '' no-italic ''
3967 [[ NoLink ]]
3968 </pre>
3969 !! html/php
3970 <pre>
3971 * foo
3972 # bar
3973 = no-h =
3974 '' no-italic ''
3975 [[ NoLink ]]
3976 </pre>
3977
3978 !! html/parsoid
3979 <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
3980 # bar
3981 = no-h =
3982 '' no-italic ''
3983 [[ NoLink ]]
3984 </pre>
3985 !!end
3986
3987 ###
3988 ### Definition lists
3989 ###
3990 !! test
3991 Simple definition
3992 !! wikitext
3993 ;name :Definition
3994 !! html
3995 <dl><dt>name</dt>
3996 <dd>Definition</dd></dl>
3997
3998 !! end
3999
4000 !! test
4001 Definition list for indentation only
4002 !! wikitext
4003 :Indented text
4004 !! html
4005 <dl><dd>Indented text</dd></dl>
4006
4007 !! end
4008
4009 !! test
4010 Definition list with no space
4011 !! wikitext
4012 ;name:Definition
4013 !! html
4014 <dl><dt>name</dt>
4015 <dd>Definition</dd></dl>
4016
4017 !!end
4018
4019 !! test
4020 Definition list with URL link
4021 !! wikitext
4022 ;http://example.com/ :definition
4023 !! html
4024 <dl><dt><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a></dt>
4025 <dd>definition</dd></dl>
4026
4027 !! end
4028
4029 !! test
4030 Definition list with bracketed URL link
4031 !! wikitext
4032 ;[http://www.example.com/ Example]:Something about it
4033 !! html
4034 <dl><dt><a rel="nofollow" class="external text" href="http://www.example.com/">Example</a></dt>
4035 <dd>Something about it</dd></dl>
4036
4037 !! end
4038
4039 !! test
4040 Definition list with wikilink containing colon
4041 !! wikitext
4042 ;[[Help:FAQ]]:The least-read page on Wikipedia
4043 !! html
4044 <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>
4045 <dd>The least-read page on Wikipedia</dd></dl>
4046
4047 !! end
4048
4049 # At Brion's and JeLuF's insistence... :)
4050 !! test
4051 Definition list with news link containing colon
4052 !! wikitext
4053 ;news:alt.wikipedia.rox :This isn't even a real newsgroup!
4054 !! html/php
4055 <dl><dt><a rel="nofollow" class="external free" href="news:alt.wikipedia.rox">news:alt.wikipedia.rox</a></dt>
4056 <dd>This isn't even a real newsgroup!</dd></dl>
4057
4058 !! html/parsoid
4059 <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>
4060 !! end
4061
4062 !! test
4063 Malformed definition list with colon
4064 !! wikitext
4065 ;news:alt.wikipedia.rox -- don't crash or enter an infinite loop
4066 !! html
4067 <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>
4068
4069 !! end
4070
4071 !! test
4072 Definition lists: colon in external link text
4073 !! wikitext
4074 ;[http://www.wikipedia2.org/ Wikipedia :The Next Generation] :OK, I made that up
4075 !! html
4076 <dl><dt><a rel="nofollow" class="external text" href="http://www.wikipedia2.org/">Wikipedia :The Next Generation</a></dt>
4077 <dd>OK, I made that up</dd></dl>
4078
4079 !! end
4080
4081 !! test
4082 Definition lists: colon in HTML attribute
4083 !! wikitext
4084 ;<b style="display: inline">bold</b>
4085 !! html
4086 <dl><dt><b style="display: inline">bold</b></dt></dl>
4087
4088 !! end
4089
4090 !! test
4091 Definition lists: self-closed tag
4092 !! wikitext
4093 ;one<br/>two :two-line fun
4094 !! html
4095 <dl><dt>one<br />two</dt>
4096 <dd>two-line fun</dd></dl>
4097
4098 !! end
4099
4100 !! test
4101 Definition lists: ignore colons inside tags
4102 !! wikitext
4103 ;one <b>two : tag <i>fun:</i>:</b>:def
4104 !! html
4105 <dl><dt>one <b>two&#160;: tag <i>fun:</i>:</b></dt>
4106 <dd>def</dd></dl>
4107
4108 !! end
4109
4110 !! test
4111 Definition lists: excess closed tags
4112 !! wikitext
4113 ;one</b>two :bad tag fun
4114 !! html/php+tidy
4115 <dl><dt>onetwo</dt>
4116 <dd>bad tag fun</dd></dl>
4117 !! html/parsoid
4118 <dl>
4119 <dt>onetwo</dt>
4120 <dd>bad tag fun</dd>
4121 </dl>
4122 !! end
4123
4124 !! test
4125 T13748: Literal closing tags
4126 !! wikitext
4127 <dl>
4128 <dt>test 1</dt>
4129 <dd>test test test test test</dd>
4130 <dt>test 2</dt>
4131 <dd>test test test test test</dd>
4132 </dl>
4133 !! html
4134 <dl>
4135 <dt>test 1</dt>
4136 <dd>test test test test test</dd>
4137 <dt>test 2</dt>
4138 <dd>test test test test test</dd>
4139 </dl>
4140
4141 !! end
4142
4143 !! test
4144 Definition and unordered list using wiki syntax nested in unordered list using html tags.
4145 !! wikitext
4146 <ul><li>
4147 ;term :description
4148 *unordered
4149 </li></ul>
4150 !! html
4151 <ul><li>
4152 <dl><dt>term</dt>
4153 <dd>description</dd></dl>
4154 <ul><li>unordered</li></ul>
4155 </li></ul>
4156
4157 !! end
4158
4159 !! test
4160 Definition list with empty definition and following paragraph
4161 !! wikitext
4162 ;term:
4163
4164 Paragraph text
4165 !! html
4166 <dl><dt>term</dt>
4167 <dd></dd></dl>
4168 <p>Paragraph text
4169 </p>
4170 !! end
4171
4172 !! test
4173 Nested definition lists using html syntax
4174 !! wikitext
4175 <dl><dt>x</dt>
4176 <dd>a</dd>
4177 <dd>b</dd></dl>
4178 !! html
4179 <dl><dt>x</dt>
4180 <dd>a</dd>
4181 <dd>b</dd></dl>
4182
4183 !! end
4184
4185 !! test
4186 Definition Lists: No nesting: Multiple dd's
4187 !! wikitext
4188 ;x
4189 :a
4190 :b
4191 !! html
4192 <dl><dt>x</dt>
4193 <dd>a</dd>
4194 <dd>b</dd></dl>
4195
4196 !! end
4197
4198 !! test
4199 Definition Lists: Indentation: Regular
4200 !! wikitext
4201 :i1
4202 ::i2
4203 :::i3
4204 !! html
4205 <dl><dd>i1
4206 <dl><dd>i2
4207 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
4208
4209 !! end
4210
4211 !! test
4212 Definition Lists: Indentation: Missing 1st level
4213 !! wikitext
4214 ::i2
4215 :::i3
4216 !! html
4217 <dl><dd><dl><dd>i2
4218 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
4219
4220 !! end
4221
4222 !! test
4223 Definition Lists: Indentation: Multi-level indent
4224 !! wikitext
4225 :::i3
4226 !! html
4227 <dl><dd><dl><dd><dl><dd>i3</dd></dl></dd></dl></dd></dl>
4228
4229 !! end
4230
4231 !! test
4232 Definition Lists: Hacky use to indent tables
4233 !! wikitext
4234 ::{|
4235 |foo
4236 |bar
4237 |}
4238 this text
4239 should be left alone
4240 !! html
4241 <dl><dd><dl><dd><table>
4242 <tr>
4243 <td>foo
4244 </td>
4245 <td>bar
4246 </td></tr></table></dd></dl></dd></dl>
4247 <p>this text
4248 should be left alone
4249 </p>
4250 !! end
4251
4252 !! test
4253 Definition Lists: Hacky use to indent tables (with content following table)
4254 !! wikitext
4255 :{|
4256 |foo
4257 |bar
4258 |} <!--c1--> this text should be part of the dl
4259 !! html/php+tidy
4260 <dl><dd><table>
4261 <tbody><tr>
4262 <td>foo
4263 </td>
4264 <td>bar
4265 </td></tr></tbody></table> this text should be part of the dl</dd></dl>
4266 !! html/parsoid
4267 <dl><dd><table>
4268 <tbody><tr>
4269 <td>foo
4270 </td>
4271 <td>bar
4272 </td></tr></tbody></table> <!--c1--> this text should be part of the dl</dd></dl>
4273 !! end
4274
4275 !! test
4276 Definition Lists: Hacky use to indent tables, with comments (T65979)
4277 !! wikitext
4278 <!-- foo -->
4279 ::{|
4280 |foo
4281 |bar
4282 |}<!-- bar -->
4283 this text
4284 should be left alone
4285 !! html/parsoid
4286 <!-- foo -->
4287 <dl><dd><dl><dd><table><tr>
4288 <td>foo</td>
4289 <td>bar</td>
4290 </tr></table><!-- bar --></dd></dl></dd></dl>
4291 <p>this text
4292 should be left alone</p>
4293 !! end
4294
4295 !! test
4296 Definition Lists: Hacky use to indent tables, with comment before table
4297 !!options
4298 parsoid=wt2html
4299 !! wikitext
4300 ::<!-- foo -->{|
4301 |foo
4302 |}
4303 !! html/parsoid
4304 <dl><dd><dl><dd><!-- foo --><table><tr>
4305 <td>foo</td>
4306 </tr></table></dd></dl></dd></dl>
4307 !! end
4308
4309 # The trailing whitespace in this test is to catch a regression in
4310 # Parsoid after T54473.
4311 !! test
4312 Definition Lists: Hacky use to indent tables (WS-insensitive)
4313 !! wikitext
4314 :{|
4315 |a
4316 |}
4317 !! html/php
4318 <dl><dd><table>
4319 <tr>
4320 <td>a
4321 </td></tr></table></dd></dl>
4322
4323 !! html/parsoid
4324 <dl><dd><table>
4325 <tbody><tr><td>a</td></tr>
4326 </tbody></table></dd></dl>
4327 !! end
4328
4329 ## The PHP parser treats : items (dd) without a corresponding ; item (dt)
4330 ## as an empty dt item. It also ignores all but the last ";" when followed
4331 ## by ":" later on. So, ";" are not ignored in ";;;t3" but are ignored in
4332 ## ";;;t3 :d1". So, PHP parser behavior is a little inconsistent wrt multiple
4333 ## ";"s.
4334 ##
4335 ## Ex: ";;t2 ::d2" is transformed into:
4336 ##
4337 ## <dl>
4338 ## <dt>t2 </dt>
4339 ## <dd>
4340 ## <dl>
4341 ## <dt></dt>
4342 ## <dd>d2</dd>
4343 ## </dl>
4344 ## </dd>
4345 ## </dl>
4346 ##
4347 ## But, Parsoid treats "; :" as a tight atomic unit and excess ":" as plain text
4348 ## So, the same wikitext above (;;t2 ::d2) is transformed into:
4349 ##
4350 ## <dl>
4351 ## <dt>
4352 ## <dl>
4353 ## <dt>t2 </dt>
4354 ## <dd>:d2</dd>
4355 ## </dl>
4356 ## </dt>
4357 ## </dl>
4358 ##
4359 ## All Parsoid only definition list tests have this difference.
4360 ##
4361 ## See also: https://phabricator.wikimedia.org/T8569
4362 ## and https://lists.wikimedia.org/pipermail/wikitext-l/2011-November/000483.html
4363
4364 !! test
4365 Table / list interaction: indented table with lists in table contents
4366 !! wikitext
4367 :{|
4368 |-
4369 |a
4370
4371 *b
4372 |-
4373 |c
4374
4375 *d
4376 |}
4377 !! html
4378 <dl><dd><table>
4379
4380 <tr>
4381 <td>a
4382 <ul><li>b</li></ul>
4383 </td></tr>
4384 <tr>
4385 <td>c
4386 <ul><li>d</li></ul>
4387 </td></tr></table></dd></dl>
4388
4389 !! end
4390
4391 !!test
4392 Table / list interaction: lists nested in tables nested in indented lists
4393 !! wikitext
4394 :{|
4395 |
4396 :a
4397 :b
4398 |
4399 *c
4400 *d
4401 |}
4402
4403 *e
4404 *f
4405 !! html
4406 <dl><dd><table>
4407 <tr>
4408 <td>
4409 <dl><dd>a</dd>
4410 <dd>b</dd></dl>
4411 </td>
4412 <td>
4413 <ul><li>c</li>
4414 <li>d</li></ul>
4415 </td></tr></table></dd></dl>
4416 <ul><li>e</li>
4417 <li>f</li></ul>
4418
4419 !!end
4420
4421 !! test
4422 Definition Lists: Nesting: Multi-level (Parsoid only)
4423 !! wikitext
4424 ;t1 :d1
4425 ;;t2 ::d2
4426 ;;;t3 :::d3
4427 !! html/parsoid
4428 <dl>
4429 <dt>t1 </dt>
4430 <dd>d1</dd>
4431 <dt>
4432 <dl>
4433 <dt>t2 </dt>
4434 <dd>:d2</dd>
4435 <dt>
4436 <dl>
4437 <dt>t3 </dt>
4438 <dd>::d3</dd>
4439 </dl>
4440 </dt>
4441 </dl>
4442 </dt>
4443 </dl>
4444
4445
4446 !! end
4447
4448
4449 !! test
4450 Definition Lists: Nesting: Test 2
4451 !! wikitext
4452 ;t1
4453 ::d2
4454 !! html+tidy
4455 <dl><dt>t1</dt>
4456 <dd>
4457 <dl><dd>d2</dd></dl></dd></dl>
4458 !! end
4459
4460
4461 !! test
4462 Definition Lists: Nesting: Test 3
4463 !! wikitext
4464 :;t1
4465 ::::d2
4466 !! html+tidy
4467 <dl><dd><dl><dt>t1</dt>
4468 <dd>
4469 <dl><dd><dl><dd>d2</dd></dl></dd></dl></dd></dl></dd></dl>
4470 !! end
4471
4472
4473 !! test
4474 Definition Lists: Nesting: Test 4
4475 !! wikitext
4476 ::;t3
4477 :::d3
4478 !! html
4479 <dl><dd><dl><dd><dl><dt>t3</dt>
4480 <dd>d3</dd></dl></dd></dl></dd></dl>
4481
4482 !! end
4483
4484
4485 ## The Parsoid team believes the following three test exposes a
4486 ## bug in the PHP parser. (Parsoid team thinks the PHP parser is
4487 ## wrong to close the <dl> after the <dt> containing the <ul>.)
4488 ## It also exposes a "misfeature" in tidy, which doesn't like
4489 ## <dl> tags with a single <dt> child; it converts the <dt> into
4490 ## a <dd> in that case. (Parsoid leaves the <dt> alone!)
4491 !! test
4492 Definition Lists: Mixed Lists: Test 1
4493 !! wikitext
4494 :;*foo
4495 ::*bar
4496 :;baz
4497 !! html/php
4498 <dl><dd><dl><dt><ul><li>foo</li>
4499 <li>bar</li></ul></dt></dl>
4500 <dl><dt>baz</dt></dl></dd></dl>
4501
4502 !! html/php+tidy
4503 <dl><dd><dl><dt><ul><li>foo</li>
4504 <li>bar</li></ul></dt></dl>
4505 <dl><dt>baz</dt></dl></dd></dl>
4506 !! html/parsoid
4507 <dl>
4508 <dd><dl>
4509 <dt><ul>
4510 <li>foo
4511 </li>
4512 </ul></dt>
4513 <dd><ul>
4514 <li>bar
4515 </li>
4516 </ul></dd>
4517 <dt>baz</dt>
4518 </dl></dd>
4519 </dl>
4520 !! end
4521
4522 !! test
4523 Definition Lists: Mixed Lists: Test 2
4524 !! wikitext
4525 *:d1
4526 *:d2
4527 !! html
4528 <ul><li><dl><dd>d1</dd>
4529 <dd>d2</dd></dl></li></ul>
4530
4531 !! end
4532
4533
4534 !! test
4535 Definition Lists: Mixed Lists: Test 3
4536 !! wikitext
4537 *:::d1
4538 *:::d2
4539 !! html
4540 <ul><li><dl><dd><dl><dd><dl><dd>d1</dd>
4541 <dd>d2</dd></dl></dd></dl></dd></dl></li></ul>
4542
4543 !! end
4544
4545
4546 !! test
4547 Definition Lists: Mixed Lists: Test 4
4548 !! wikitext
4549 *;d1 :d2
4550 *;d3 :d4
4551 !! html
4552 <ul><li><dl><dt>d1</dt>
4553 <dd>d2</dd>
4554 <dt>d3</dt>
4555 <dd>d4</dd></dl></li></ul>
4556
4557 !! end
4558
4559
4560 !! test
4561 Definition Lists: Mixed Lists: Test 5
4562 !! wikitext
4563 *:d1
4564 *::d2
4565 !! html
4566 <ul><li><dl><dd>d1
4567 <dl><dd>d2</dd></dl></dd></dl></li></ul>
4568
4569 !! end
4570
4571
4572 !! test
4573 Definition Lists: Mixed Lists: Test 6
4574 !! wikitext
4575 #*:d1
4576 #*:::d3
4577 !! html
4578 <ol><li><ul><li><dl><dd>d1
4579 <dl><dd><dl><dd>d3</dd></dl></dd></dl></dd></dl></li></ul></li></ol>
4580
4581 !! end
4582
4583
4584 !! test
4585 Definition Lists: Mixed Lists: Test 7
4586 !! wikitext
4587 :*d1
4588 :*d2
4589 !! html
4590 <dl><dd><ul><li>d1</li>
4591 <li>d2</li></ul></dd></dl>
4592
4593 !! end
4594
4595
4596 !! test
4597 Definition Lists: Mixed Lists: Test 8
4598 !! wikitext
4599 :*d1
4600 ::*d2
4601 !! html
4602 <dl><dd><ul><li>d1</li></ul>
4603 <dl><dd><ul><li>d2</li></ul></dd></dl></dd></dl>
4604
4605 !! end
4606
4607
4608 !! test
4609 Definition Lists: Mixed Lists: Test 9
4610 !! wikitext
4611 *;foo :bar
4612 !! html
4613 <ul><li><dl><dt>foo</dt>
4614 <dd>bar</dd></dl></li></ul>
4615
4616 !! end
4617
4618
4619 !! test
4620 Definition Lists: Mixed Lists: Test 10
4621 !! wikitext
4622 *#;foo :bar
4623 !! html
4624 <ul><li><ol><li><dl><dt>foo</dt>
4625 <dd>bar</dd></dl></li></ol></li></ul>
4626
4627 !! end
4628
4629 # The Parsoid team disagrees with the PHP parser's seemingly-random
4630 # rules regarding dd/dt on the next few tests. Parsoid is more
4631 # consistent, and recognizes the shared nesting and keeps the
4632 # still-open tags around until the nesting is complete.
4633
4634 # This is a regression test for T175099
4635 !! test
4636 Definition Lists: Mixed Lists: Test 11
4637 !! wikitext
4638 ;a
4639 :*b
4640 !! html/php
4641 <dl><dt>a</dt>
4642 <dd>
4643 <ul><li>b</li></ul></dd></dl>
4644
4645 !! html/parsoid
4646 <dl><dt>a
4647 <dd><ul><li>b</li></ul></dd></dl>
4648 !! end
4649
4650 # FIXME: Maybe get rid of this test?
4651 !! test
4652 Definition Lists: Mixed Lists: Test 12
4653 !! wikitext
4654 *#*#;*;;foo :bar
4655 *#*#;boo :baz
4656 !! html/php
4657 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo</dt>
4658 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dd></dl></li></ul></dd></dl>
4659 <dl><dt>boo</dt>
4660 <dd>baz</dd></dl></li></ol></li></ul></li></ol></li></ul>
4661
4662 !! html/php+tidy
4663 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo</dt>
4664 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dt></dl></li></ul></dd></dl></li></ol></li></ul>
4665 <dl><dt>boo</dt>
4666 <dd>baz</dd></dl></li></ol></li></ul>
4667 !! html/parsoid
4668 <ul>
4669 <li>
4670 <ol>
4671 <li>
4672 <ul>
4673 <li>
4674 <ol>
4675 <li>
4676 <dl>
4677 <dt>
4678 <ul>
4679 <li>
4680 <dl>
4681 <dt>
4682 <dl>
4683 <dt>foo</dt>
4684 <dd data-parsoid='{"stx":"row"}'>bar</dd>
4685 </dl></dt>
4686 </dl></li>
4687 </ul></dt>
4688 <dt>boo</dt>
4689 <dd data-parsoid='{"stx":"row"}'>baz</dd>
4690 </dl></li>
4691 </ol></li>
4692 </ul></li>
4693 </ol></li>
4694 </ul>
4695 !! end
4696
4697 !! test
4698 Definition Lists: Mixed Lists: Test 13
4699 !! wikitext
4700 *#*#;*;;foo : bar
4701 *#*#;boo : baz
4702 !! html+tidy
4703 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</dt>
4704 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dt></dl></li></ul></dd></dl></li></ol></li></ul>
4705 <dl><dt>boo&#160;</dt>
4706 <dd>baz</dd></dl></li></ol></li></ul>
4707 !! end
4708
4709 # FIXME: Maybe get rid of this test?
4710 # From whitelist:
4711 # * The test is wrong, there are two colons where there should be :;
4712 # * The PHP parser is wrong to close the <dl> after the <dt> containing the <ul>.
4713 !! test
4714 Definition Lists: Weird Ones: Test 1
4715 !! wikitext
4716 *#;*::;;foo :bar (who uses this?)
4717 !! html/php+tidy
4718 <ul><li><ol><li><dl><dt>foo</dt>
4719 <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>
4720 !! html/parsoid
4721 <ul>
4722 <li>
4723 <ol>
4724 <li>
4725 <dl>
4726 <dt>
4727 <ul>
4728 <li>
4729 <dl>
4730 <dd>
4731 <dl>
4732 <dd>
4733 <dl>
4734 <dt>
4735 <dl>
4736 <dt>foo</dt>
4737 <dd data-parsoid='{"stx":"row"}'>bar (who uses this?)</dd>
4738 </dl></dt>
4739 </dl></dd>
4740 </dl></dd>
4741 </dl></li>
4742 </ul></dt>
4743 </dl></li>
4744 </ol></li>
4745 </ul>
4746 !! end
4747
4748 !! test
4749 Definition Lists: colons occurring in tags
4750 !! wikitext
4751 ;a:b
4752 ;'''a:b'''
4753 ;<i>a:b</i>
4754 ;<span>a:b</span>
4755 ;<div>a:b</div>
4756 ;<div>a
4757 :b</div>
4758 ;{{echo|a:b}}
4759 ;{{echo|''a:b''}}
4760 ;;;''a:b''
4761 !! html+tidy
4762 <dl><dt>a</dt>
4763 <dd>b</dd>
4764 <dt><b>a:b</b></dt>
4765 <dt><i>a:b</i></dt>
4766 <dt><span>a:b</span></dt>
4767 <dt><div>a:b</div></dt>
4768 <dt><div>a</div></dt>
4769 <dd>b</dd>
4770 <dt>a</dt>
4771 <dd>b</dd>
4772 <dt><i>a:b</i></dt></dl>
4773 <dl><dt><dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4774 !! html/parsoid
4775 <dl><dt>a</dt><dd data-parsoid='{"stx":"row"}'>b</dd>
4776 <dt><b>a:b</b></dt>
4777 <dt><i data-parsoid='{"stx":"html"}'>a:b</i></dt>
4778 <dt><span data-parsoid='{"stx":"html"}'>a:b</span></dt>
4779 <dt><div data-parsoid='{"stx":"html"}'>a:b</div></dt>
4780 <dt><div data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</div></dt>
4781 <dd>b</dd>
4782 <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>
4783 <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>
4784 <dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4785 !! end
4786
4787 # Parsoid's output differs here again because it shares
4788 # nesting between the two lists unlike the PHP parser.
4789 # Unsure which is more desirable.
4790 !! test
4791 Definition Lists: colons and tables 1
4792 !! wikitext
4793 :{|
4794 |x
4795 |}
4796 :{|
4797 |y
4798 |}
4799 !! html/php
4800 <dl><dd><table>
4801 <tr>
4802 <td>x
4803 </td></tr></table></dd></dl>
4804 <dl><dd><table>
4805 <tr>
4806 <td>y
4807 </td></tr></table></dd></dl>
4808
4809 !! html/parsoid
4810 <dl><dd><table>
4811 <tr>
4812 <td>x
4813 </td></tr></table></dd>
4814 <dd><table>
4815 <tr>
4816 <td>y
4817 </td></tr></table></dd></dl>
4818 !! end
4819
4820 # FIXME: Does this need a html/php section?
4821 !! test
4822 Definition Lists: template interaction
4823 !! wikitext
4824 ::{{definition_list}}
4825
4826 :one
4827 ::{{definition_list}}
4828 :::two
4829 :::three
4830 ::four
4831 !! html/parsoid
4832 <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">
4833 </span><dd about="#mwt1">two</dd></dl></dd></dl>
4834
4835 <dl><dd data-parsoid='{}'>one
4836 <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">
4837 </span><dd about="#mwt2">two
4838 <dl><dd>two</dd>
4839 <dd>three</dd></dl></dd>
4840 <dd data-parsoid='{}'>four</dd></dl></dd></dl>
4841 !! end
4842
4843
4844 ###
4845 ### External links
4846 ###
4847 !! test
4848 External links: non-bracketed
4849 !! wikitext
4850 Non-bracketed: http://example.com
4851 !! html
4852 <p>Non-bracketed: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4853 </p>
4854 !! end
4855
4856 # parsoid doesn't explicitly mark autonumbered links, see T55505
4857 !! test
4858 External links: numbered
4859 !! wikitext
4860 Numbered: [http://example.com]
4861 Numbered: [http://example.net]
4862 Numbered: [http://example.com]
4863 !! html/php
4864 <p>Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>
4865 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.net">[2]</a>
4866 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[3]</a>
4867 </p>
4868 !! html/parsoid
4869 <p>Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>
4870 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.net"></a>
4871 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a></p>
4872 !!end
4873
4874 !! test
4875 External links: specified text
4876 !! wikitext
4877 Specified text: [http://example.com link]
4878 !! html
4879 <p>Specified text: <a rel="nofollow" class="external text" href="http://example.com">link</a>
4880 </p>
4881 !!end
4882
4883 !! test
4884 External links: trail
4885 !! wikitext
4886 Linktrails should not work for external links: [http://example.com link]s
4887 !! html
4888 <p>Linktrails should not work for external links: <a rel="nofollow" class="external text" href="http://example.com">link</a>s
4889 </p>
4890 !! end
4891
4892 !! test
4893 External links: dollar sign in URL
4894 !! wikitext
4895 http://example.com/1$2345
4896 !! html
4897 <p><a rel="nofollow" class="external free" href="http://example.com/1$2345">http://example.com/1$2345</a>
4898 </p>
4899 !! end
4900
4901 # parsoid doesn't explicitly mark autonumbered links, see T55505
4902 !! test
4903 External links: dollar sign in URL (autonumber)
4904 !! wikitext
4905 [http://example.com/1$2345]
4906 !! html/php
4907 <p><a rel="nofollow" class="external autonumber" href="http://example.com/1$2345">[1]</a>
4908 </p>
4909 !! html/parsoid
4910 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/1$2345"></a></p>
4911 !!end
4912
4913 !! test
4914 External links: open square bracket forbidden in URL (T6377)
4915 !! options
4916 parsoid=wt2html,wt2wt,html2html
4917 !! wikitext
4918 http://example.com/1[2345
4919 !! html/php
4920 <p><a rel="nofollow" class="external free" href="http://example.com/1">http://example.com/1</a>[2345
4921 </p>
4922 !! html/parsoid
4923 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/1">http://example.com/1</a>[2345</p>
4924 !! end
4925
4926 !! test
4927 External links: open square bracket forbidden in URL (named) (T6377)
4928 !! options
4929 parsoid=wt2html,html2html
4930 !! wikitext
4931 [http://example.com/1[2345]
4932 !! html/php
4933 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4934 </p>
4935 !! html/parsoid
4936 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/1">[2345</a></p>
4937 !!end
4938
4939 # parsoid adds a space before the link name
4940 !! test
4941 External links: open square bracket forbidden in URL (named) (T6377)
4942 Parsoid variant.
4943 !! wikitext
4944 [http://example.com/1 [2345]
4945 !! html
4946 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4947 </p>
4948 !!end
4949
4950 !! test
4951 External links: nowiki in URL link text (T8230)
4952 !! wikitext
4953 [http://example.com/ <nowiki>''example site''</nowiki>]
4954 !! html
4955 <p><a rel="nofollow" class="external text" href="http://example.com/">''example site''</a>
4956 </p>
4957 !! end
4958
4959 !! test
4960 External links: newline forbidden in text (T8230 regression check)
4961 !! wikitext
4962 [http://example.com/ first
4963 second]
4964 !! html
4965 <p>[<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a> first
4966 second]
4967 </p>
4968 !!end
4969
4970 !! test
4971 External links: Pipe char between url and text
4972 !! wikitext
4973 [http://example.com | link]
4974 !! html
4975 <p><a rel="nofollow" class="external text" href="http://example.com">| link</a>
4976 </p>
4977 !!end
4978
4979 !! test
4980 External links: protocol-relative URL in brackets
4981 !! wikitext
4982 [//example.com/ Test]
4983 !! html
4984 <p><a rel="nofollow" class="external text" href="//example.com/">Test</a>
4985 </p>
4986 !! end
4987
4988 # parsoid doesn't explicitly mark autonumbered links, see T55505
4989 !! test
4990 External links: protocol-relative URL in brackets without text
4991 !! wikitext
4992 [//example.com]
4993 !! html/php
4994 <p><a rel="nofollow" class="external autonumber" href="//example.com">[1]</a>
4995 </p>
4996 !! html/parsoid
4997 <p><a rel="mw:ExtLink" class="external autonumber" href="//example.com"></a></p>
4998 !! end
4999
5000 !! test
5001 External links: protocol-relative URL in free text is left alone
5002 !! wikitext
5003 //example.com/Foo
5004 !! html
5005 <p>//example.com/Foo
5006 </p>
5007 !!end
5008
5009 !! test
5010 External links: protocol-relative URL in the middle of a word is left alone (T32269)
5011 !! wikitext
5012 foo//example.com/Foo
5013 !! html
5014 <p>foo//example.com/Foo
5015 </p>
5016 !! end
5017
5018 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
5019 !! test
5020 External links: with no contents
5021 !! options
5022 parsoid=wt2html,wt2wt
5023 !! wikitext
5024 [http://en.wikipedia.org/wiki/Foo]
5025
5026 [[wikipedia:Foo|Bar]]
5027
5028 [[wikipedia:Foo|<span>Bar</span>]]
5029 !! html/php
5030 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo">[1]</a>
5031 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
5032 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo"><span>Bar</span></a>
5033 </p>
5034 !! html/parsoid
5035 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo"></a></p>
5036 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo">Bar</a></p>
5037 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo"><span>Bar</span></a></p>
5038 !! end
5039
5040 !! test
5041 External links: Free with trailing punctuation
5042 !! wikitext
5043 http://example.com,
5044 http://example.com;
5045 http://example.com\
5046 http://example.com.
5047 http://example.com:
5048 http://example.com!
5049 http://example.com?
5050 http://example.com)
5051 http://example.com/url_with_(brackets)
5052 (http://example.com/url_without_brackets)
5053 http://example.com/url_with_entity&amp;
5054 http://example.com/url_with_entity&#x26;
5055 http://example.com/url_with_entity&#038;
5056 http://example.com/url_with_entity&nbsp;
5057 http://example.com/url_with_entity&#xA0;
5058 http://example.com/url_with_entity&#160;
5059 http://example.com/url_with_entity&lt;
5060 http://example.com/url_with_entity&#x3C;
5061 http://example.com/url_with_entity&#60;
5062 !! html/php
5063 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
5064 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>;
5065 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>\
5066 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.
5067 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
5068 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>!
5069 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>?
5070 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
5071 <a rel="nofollow" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
5072 (<a rel="nofollow" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
5073 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5074 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5075 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5076 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
5077 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#xa0;
5078 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
5079 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&lt;
5080 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#x3c;
5081 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#60;
5082 </p>
5083 !! html/parsoid
5084 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>,
5085 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>;
5086 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>\
5087 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>.
5088 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>:
5089 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>!
5090 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>?
5091 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>)
5092 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
5093 (<a rel="mw:ExtLink" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
5094 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5095 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5096 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5097 <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>
5098 <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>
5099 <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>
5100 <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>
5101 <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>
5102 <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>
5103 !! end
5104
5105 !! test
5106 External links: tricky Parsoid html2html case
5107 !! options
5108 parsoid=wt2html,wt2wt,html2html
5109 !! wikitext
5110 http://example.com/url_with_entity&amp;amp;
5111 !! html/php
5112 <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>;
5113 </p>
5114 !! html/parsoid
5115 <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>
5116 !! end
5117
5118 !! test
5119 External links: Free with trailing quotes (T113666)
5120 !! wikitext
5121 '''News:''' Stuff here
5122
5123 news:'a'b''c''d e
5124 !! html/php
5125 <p><b>News:</b> Stuff here
5126 </p><p><a rel="nofollow" class="external free" href="news:&#39;a&#39;b">news:'a'b</a><i>c</i>d e
5127 </p>
5128 !! html/parsoid
5129 <p><b>News:</b> Stuff here</p>
5130 <p><a rel="mw:ExtLink" class="external free" href="news:'a'b">news:'a'b</a><i>c</i>d e</p>
5131 !! end
5132
5133 !! test
5134 External links: with entity
5135 !! wikitext
5136 [http://&#x20;www.librarieswithoutborders.org Libraries without borders]
5137 !! html/php
5138 <p><a rel="nofollow" class="external text" href="http://+www.librarieswithoutborders.org">Libraries without borders</a>
5139 </p>
5140 !! html/parsoid
5141 <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>
5142 !! end
5143
5144 !! test
5145 External links: Lone protocols are never linked (T105697)
5146 !! wikitext
5147 http://
5148 http://;
5149 (http://)
5150 bitcoin:
5151 bitcoin:;
5152 (bitcoin:)
5153 !! html
5154 <p>http://
5155 http://;
5156 (http://)
5157 bitcoin:
5158 bitcoin:;
5159 (bitcoin:)
5160 </p>
5161 !! end
5162
5163 !! test
5164 External links: No preceding word characters allowed (T67278)
5165 !! wikitext
5166 NOPEhttp://example.com
5167 N0http://example.com
5168 ok:http://example.com
5169 ok-http://example.com
5170 !! html
5171 <p>NOPEhttp://example.com
5172 N0http://example.com
5173 ok:<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5174 ok-<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5175 </p>
5176 !! end
5177
5178 !! test
5179 External links: nofollow domain exception
5180 !! wikitext
5181 A [https://no-nofollow.org/foobar link], and another [https://example.org link].
5182 !! html
5183 <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>.
5184 </p>
5185 !!end
5186
5187 !! test
5188 External image
5189 !! wikitext
5190 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5191 !! html
5192 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
5193 </p>
5194 !! end
5195
5196 !! test
5197 External image from https
5198 !! wikitext
5199 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5200 !! html
5201 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
5202 </p>
5203 !! end
5204
5205 !! test
5206 External image (when not allowed)
5207 !! options
5208 wgAllowExternalImages=0
5209 !! wikitext
5210 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5211 !! html
5212 <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>
5213 </p>
5214 !! end
5215
5216 !! test
5217 Link to non-http image, no img tag
5218 !! wikitext
5219 Link to non-http image, no img tag: ftp://example.com/test.jpg
5220 !! html
5221 <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>
5222 </p>
5223 !! end
5224
5225 !! test
5226 External links: terminating separator
5227 !! wikitext
5228 Terminating separator: http://example.com/thing,
5229 !! html
5230 <p>Terminating separator: <a rel="nofollow" class="external free" href="http://example.com/thing">http://example.com/thing</a>,
5231 </p>
5232 !! end
5233
5234 !! test
5235 External links: intervening separator
5236 !! wikitext
5237 Intervening separator: http://example.com/1,2,3
5238 !! html
5239 <p>Intervening separator: <a rel="nofollow" class="external free" href="http://example.com/1,2,3">http://example.com/1,2,3</a>
5240 </p>
5241 !! end
5242
5243 !! test
5244 External links: old bug with URL in query
5245 !! wikitext
5246 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
5247 !! html
5248 <p>Old bug with URL in query: <a rel="nofollow" class="external text" href="http://example.com/thing?url=http://example.com">link</a>
5249 </p>
5250 !! end
5251
5252 !! test
5253 External links: old URL-in-URL bug, mixed protocols
5254 !! wikitext
5255 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
5256 !! html
5257 <p>And again with mixed protocols: <a rel="nofollow" class="external text" href="ftp://example.com?url=http://example.com">link</a>
5258 </p>
5259 !!end
5260
5261 # Since Parsoid is starting to emit canonical wikitext for links,
5262 # [http://example.com http://example.com] will not RT back to that
5263 # form anymore.
5264 !! test
5265 External links: URL in text
5266 !! options
5267 parsoid=wt2html
5268 !! wikitext
5269 URL in text: [http://example.com http://example.com]
5270 !! html/php
5271 <p>URL in text: <a rel="nofollow" class="external text" href="http://example.com">http://example.com</a>
5272 </p>
5273 !! html/parsoid
5274 <p>URL in text: <a rel="mw:ExtLink" class="external text" href="http://example.com">http://example.com</a></p>
5275 !! end
5276
5277 !! test
5278 External links: Clickable images
5279 !! wikitext
5280 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
5281 !! html/php
5282 <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>
5283 </p>
5284 !! html/parsoid
5285 <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>
5286 !! end
5287
5288 !! test
5289 External links: raw ampersand
5290 !! wikitext
5291 Old &amp; use: http://x&y
5292 !! html
5293 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5294 </p>
5295 !! end
5296
5297 !! test
5298 External links: encoded ampersand
5299 !! wikitext
5300 Old &amp; use: http://x&amp;y
5301 !! html/php
5302 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5303 </p>
5304 !! html/parsoid
5305 <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>
5306 !! end
5307
5308 !! test
5309 External links: encoded equals (T8102)
5310 !! wikitext
5311 http://example.com/?foo&#61;bar
5312 !! html/php
5313 <p><a rel="nofollow" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a>
5314 </p>
5315 !! html/parsoid
5316 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a></p>
5317 !! end
5318
5319 ##
5320 ## Note that parsoid doesn't explicit mark autonumbered links, nor
5321 ## does it number them. As discussed in T55505, we can identify
5322 ## autonumbered links via CSS.
5323 ##
5324
5325 !! test
5326 External links: [raw ampersand]
5327 !! wikitext
5328 Old &amp; use: [http://x&y]
5329 !! html/php
5330 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5331 </p>
5332 !! html/parsoid
5333 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&amp;y"></a></p>
5334 !! end
5335
5336 # note that parsoid html is identical to [raw ampersand] case; so html2wt
5337 # mode will return the [raw ampersand] wikitext
5338 !! test
5339 External links: [encoded ampersand]
5340 !! options
5341 parsoid=wt2html,wt2wt,html2html
5342 !! wikitext
5343 Old &amp; use: [http://x&amp;y]
5344 !! html/php
5345 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5346 </p>
5347 !! html/parsoid
5348 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&amp;y"></a></p>
5349 !! end
5350
5351 !! test
5352 External links: [raw equals]
5353 !! wikitext
5354 [http://example.com/?foo=bar]
5355 !! html/php
5356 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5357 </p>
5358 !! html/parsoid
5359 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/?foo=bar"></a></p>
5360 !! end
5361
5362 # note that parsoid html is identical to [raw equals] case; so html2wt
5363 # mode will return the [raw equals] wikitext
5364 !! test
5365 External links: [encoded equals] (T8102)
5366 !! options
5367 parsoid=wt2html,wt2wt,html2html
5368 !! wikitext
5369 [http://example.com/?foo&#61;bar]
5370 !! html/php
5371 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5372 </p>
5373 !! html/parsoid
5374 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/?foo=bar"></a></p>
5375 !! end
5376
5377 # xxx parsoid strips the IDN character, so the round-trip tests will
5378 # obviously fail and are disabled. --cscott
5379 !! test
5380 External links: [IDN ignored character reference in hostname; strip it right off]
5381 !! options
5382 parsoid=wt2html,wt2wt,html2html
5383 !! wikitext
5384 [http://e&zwnj;xample.com/]
5385 !! html/php
5386 <p><a rel="nofollow" class="external autonumber" href="http://example.com/">[1]</a>
5387 </p>
5388 !! html/parsoid
5389 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/"></a></p>
5390 !! end
5391
5392 # FIXME: This test (the IDN characters in the text of a link) is an inconsistency.
5393 # Where an external link could easily circumvent the sanitization of the text of
5394 # a link like this (where an IDN-ignore character is in the URL somewhere), this
5395 # test demands a higher standard. That's a bit strange.
5396 #
5397 # Example:
5398 #
5399 # http://e‌xample.com -> [http://example.com|http://example.com]
5400 # [http://example.com|http://e‌xample.com] -> [http://example.com|http://e‌xample.com]
5401 #
5402 # The first example is sanitized, but the second is not. Any security benefits
5403 # from this production are trivial to circumvent. Either remove this test and
5404 # let the parser(s) do their thing unaccosted, or fix the inconsistency and change
5405 # the test accordingly.
5406 #
5407 # All our love,
5408 # The Parsoid team.
5409 # xxx parsoid strips the IDN character, so the round-trip tests will
5410 # obviously fail and are disabled. --cscott
5411 !! test
5412 External links: IDN ignored character reference in hostname; strip it right off
5413 !! options
5414 parsoid=wt2html,html2html
5415 !! wikitext
5416 http://e&zwnj;xample.com/
5417 !! html/php
5418 <p><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>
5419 </p>
5420 !! html/parsoid
5421 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/">http://example.com/</a></p>
5422 !! end
5423
5424 !! test
5425 External links: www.jpeg.org (T2554)
5426 !! wikitext
5427 http://www.jpeg.org
5428 !! html
5429 <p><a rel="nofollow" class="external free" href="http://www.jpeg.org">http://www.jpeg.org</a>
5430 </p>
5431 !! end
5432
5433 # parsoid doesn't explicitly mark autonumbered links, see T55505
5434 !! test
5435 External links: URL within URL (T2002)
5436 !! wikitext
5437 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
5438 !! html/php
5439 <p><a rel="nofollow" class="external autonumber" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp">[1]</a>
5440 </p>
5441 !! html/parsoid
5442 <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>
5443 !! end
5444
5445 !! test
5446 T2361: URL inside bracketed URL
5447 !! wikitext
5448 [http://www.example.com/foo http://www.example.com/bar]
5449 !! html
5450 <p><a rel="nofollow" class="external text" href="http://www.example.com/foo">http://www.example.com/bar</a>
5451 </p>
5452 !! end
5453
5454 !! test
5455 T2361: URL within URL, not bracketed
5456 !! wikitext
5457 http://www.example.com/foo?=http://www.example.com/bar
5458 !! html
5459 <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>
5460 </p>
5461 !! end
5462
5463 !! test
5464 T2289: ">"-token in URL-tail
5465 !! wikitext
5466 http://www.example.com/<hello>
5467 !! html
5468 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>&lt;hello&gt;
5469 </p>
5470 !!end
5471
5472 !! test
5473 T2289: literal ">"-token in URL-tail
5474 !! wikitext
5475 http://www.example.com/<b>html</b>
5476 !! html/php
5477 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a><b>html</b>
5478 </p>
5479 !! html/parsoid
5480 <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>
5481 !! end
5482
5483 !! test
5484 T2289: ">"-token in bracketed URL
5485 !! wikitext
5486 [http://www.example.com/<hello> stuff]
5487 !! html
5488 <p><a rel="nofollow" class="external text" href="http://www.example.com/">&lt;hello&gt; stuff</a>
5489 </p>
5490 !!end
5491
5492 !! test
5493 T2289: literal ">"-token in bracketed URL
5494 !! wikitext
5495 [http://www.example.com/<b>html</b> stuff]
5496 !! html
5497 <p><a rel="nofollow" class="external text" href="http://www.example.com/"><b>html</b> stuff</a>
5498 </p>
5499 !!end
5500
5501 !! test
5502 T2289: literal double quote at end of URL
5503 !! wikitext
5504 http://www.example.com/"hello"
5505 !! html
5506 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>"hello"
5507 </p>
5508 !!end
5509
5510 !! test
5511 T2289: literal double quote in bracketed URL
5512 !! wikitext
5513 [http://www.example.com/"hello" stuff]
5514 !! html
5515 <p><a rel="nofollow" class="external text" href="http://www.example.com/">"hello" stuff</a>
5516 </p>
5517 !!end
5518
5519 !! test
5520 External links: multiple legal whitespace is fine, Magnus. Don't break it please. (T7081)
5521 !! wikitext
5522 [http://www.example.com test]
5523 !! html
5524 <p><a rel="nofollow" class="external text" href="http://www.example.com">test</a>
5525 </p>
5526 !! end
5527
5528 !! test
5529 External links: link text with spaces
5530 !! wikitext
5531 [http://www.example.com a b c]
5532 [http://www.example.com ''a'' ''b'']
5533 !! html
5534 <p><a rel="nofollow" class="external text" href="http://www.example.com">a b c</a>
5535 <a rel="nofollow" class="external text" href="http://www.example.com"><i>a</i> <i>b</i></a>
5536 </p>
5537 !! end
5538
5539 # Note edge case difference between PHP and Parsoid here.
5540 !! test
5541 External links: wiki links within external link (T5695)
5542 !! options
5543 parsoid=wt2html,html2html
5544 !! wikitext
5545 [http://example.com [[wikilink]] embedded in ext link]
5546
5547 [http://example.com test [[wikilink]] embedded in ext link]
5548 !! html/php
5549 <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>
5550 </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>
5551 </p>
5552 !! html/parsoid
5553 <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>
5554 <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>
5555 !! end
5556
5557 !! test
5558 T2787: Links with one slash after the url protocol are invalid
5559 !! wikitext
5560 http:/example.com
5561
5562 [http:/example.com title]
5563 !! html
5564 <p>http:/example.com
5565 </p><p>[http:/example.com title]
5566 </p>
5567 !! end
5568
5569 !! test
5570 Bracketed external links with template-generated invalid target
5571 !! wikitext
5572 [{{echo|http:/example.com}} title]
5573 !! html
5574 <p>[http:/example.com title]
5575 </p>
5576 !! end
5577
5578 # wt2html only because Parsoid would want to add <nowiki>s coming from html
5579 !! test
5580 Broken wikilinks (but not external links) prevent templates from closing
5581 !! options
5582 parsoid=wt2html
5583 !! wikitext
5584 [http://example.com x
5585
5586 {{echo|[http://example.com x}}
5587
5588 [[Foo
5589
5590 {{echo|[[Foo}}
5591 !! html/php
5592 <p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5593 </p><p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5594 </p><p>[[Foo
5595 </p><p>{{echo|[[Foo}}
5596 </p>
5597 !! html/parsoid
5598 <p>[<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a> x</p>
5599 <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>
5600 <p>[[Foo</p>
5601 <p>{{echo|[[Foo}}</p>
5602 !! end
5603
5604 !! test
5605 Wikilinks with embedded newlines are not broken
5606 !! wikitext
5607 {{echo|[[ Foo
5608 B
5609 C]]}}
5610 !! html/php
5611 <p>[[ Foo
5612 B
5613 C]]
5614 </p>
5615 !! html/parsoid
5616 <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>
5617 !! end
5618
5619 !! test
5620 Broken templates
5621 !! options
5622 parsoid=wt2html
5623 !! wikitext
5624 {{echo|[[Foo|}}]]
5625
5626 [[Foo|{{echo|]]}}
5627 !! html/php
5628 <p>{{echo|<a href="/wiki/Foo" title="Foo">}}</a>
5629 </p><p>[[Foo|]]
5630 </p>
5631 !! html/parsoid
5632 <p>{{echo|<a rel="mw:WikiLink" href="./Foo" title="Foo">}}</a></p>
5633 <p>[[Foo|<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"]]"}},"i":0}}]}'>]]</span></p>
5634 !! end
5635
5636 !! test
5637 T4702: Mismatched <i>, <b> and <a> tags are invalid
5638 !! wikitext
5639 ''[http://example.com text'']
5640 [http://example.com '''text]'''
5641 ''Something [http://example.com in italic'']
5642 ''Something [http://example.com mixed''''', even bold]'''
5643 '''''Now [http://example.com both''''']
5644 !! html
5645 <p><a rel="nofollow" class="external text" href="http://example.com"><i>text</i></a>
5646 <a rel="nofollow" class="external text" href="http://example.com"><b>text</b></a>
5647 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>in italic</i></a>
5648 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>mixed</i><b>, even bold</b></a>
5649 <i><b>Now </b></i><a rel="nofollow" class="external text" href="http://example.com"><i><b>both</b></i></a>
5650 </p>
5651 !! end
5652
5653
5654 !! test
5655 T6781: %26 in URL
5656 !! wikitext
5657 http://www.example.com/?title=AT%26T
5658 !! html/php
5659 <p><a rel="nofollow" class="external free" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a>
5660 </p>
5661 !! html/parsoid
5662 <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>
5663 !! end
5664
5665 # According to https://www.w3.org/TR/2011/WD-html5-20110525/Overview.html#parsing-urls a plain
5666 # % is actually legal in HTML5. Any change in output would need testing though.
5667 !! test
5668 T6781, T7267: %25 in URL
5669 !! wikitext
5670 http://www.example.com/?title=100%25_Bran
5671 !! html/php
5672 <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>
5673 </p>
5674 !! html/parsoid
5675 <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>
5676 !! end
5677
5678 !! test
5679 T6781, T7267: %28, %29 in URL
5680 !! wikitext
5681 http://www.example.com/?title=Ben-Hur_%281959_film%29
5682 !! html/php
5683 <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>
5684 </p>
5685 !! html/parsoid
5686 <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>
5687 !! end
5688
5689
5690 !! test
5691 T6781: %26 in autonumber URL
5692 !! wikitext
5693 [http://www.example.com/?title=AT%26T]
5694 !! html/php
5695 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=AT%26T">[1]</a>
5696 </p>
5697 !! html/parsoid
5698 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=AT%26T"></a></p>
5699 !! end
5700
5701 !! test
5702 T6781, T7267: %26 in autonumber URL
5703 !! wikitext
5704 [http://www.example.com/?title=100%25_Bran]
5705 !! html/php
5706 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=100%25_Bran">[1]</a>
5707 </p>
5708 !! html/parsoid
5709 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=100%25_Bran"></a></p>
5710 !! end
5711
5712 !! test
5713 T6781, T7267: %28, %29 in autonumber URL
5714 !! wikitext
5715 [http://www.example.com/?title=Ben-Hur_%281959_film%29]
5716 !! html/php
5717 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">[1]</a>
5718 </p>
5719 !! html/parsoid
5720 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29"></a></p>
5721 !! end
5722
5723
5724 !! test
5725 T6781: %26 in bracketed URL
5726 !! wikitext
5727 [http://www.example.com/?title=AT%26T link]
5728 !! html/php
5729 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=AT%26T">link</a>
5730 </p>
5731 !! html/parsoid
5732 <p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=AT%26T">link</a></p>
5733 !! end
5734
5735 !! test
5736 T6781, T7267: %25 in bracketed URL
5737 !! wikitext
5738 [http://www.example.com/?title=100%25_Bran link]
5739 !! html
5740 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=100%25_Bran">link</a>
5741 </p>
5742 !! end
5743
5744 !! test
5745 T6781, T7267: %28, %29 in bracketed URL
5746 !! wikitext
5747 [http://www.example.com/?title=Ben-Hur_%281959_film%29 link]
5748 !! html/php
5749 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a>
5750 </p>
5751 !! html/parsoid
5752 <p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a></p>
5753 !! end
5754
5755 !! test
5756 External link containing a period in the anchor. (T65947)
5757 !! wikitext
5758 [//foo.org/bar#baz. bang]
5759
5760 [//foo.org/bar. bang]
5761 !! html/php
5762 <p><a rel="nofollow" class="external text" href="//foo.org/bar#baz.">bang</a>
5763 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar.">bang</a>
5764 </p>
5765 !! html/parsoid
5766 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar#baz.">bang</a></p>
5767 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar.">bang</a></p>
5768 !! end
5769
5770 !! test
5771 External link containing a single quote. (T65947)
5772 !! wikitext
5773 [//foo.org/bar'baz]
5774
5775 [//foo.org/bar'baz bang]
5776 !! html/php
5777 <p><a rel="nofollow" class="external autonumber" href="//foo.org/bar&#39;baz">[1]</a>
5778 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar&#39;baz">bang</a>
5779 </p>
5780 !! html/parsoid
5781 <p><a rel="mw:ExtLink" class="external autonumber" href="//foo.org/bar'baz"></a></p>
5782 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar'baz">bang</a></p>
5783 !! end
5784
5785 !! test
5786 External link containing double-single-quotes in text '' (T6598 sanity check)
5787 !! wikitext
5788 Some [http://example.com/ pretty ''italics'' and stuff]!
5789 !! html
5790 <p>Some <a rel="nofollow" class="external text" href="http://example.com/">pretty <i>italics</i> and stuff</a>!
5791 </p>
5792 !! end
5793
5794 !! test
5795 External link containing double-single-quotes in text embedded in italics (T6598 sanity check)
5796 !! wikitext
5797 ''Some [http://example.com/ pretty ''italics'' and stuff]!''
5798 !! html
5799 <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>
5800 </p>
5801 !! end
5802
5803 # Don't add the html/php section since the output is broken and there isn't any reason to spec it
5804 !! test
5805 External link containing double-single-quotes with no space separating the url from text in italics
5806 !! wikitext
5807 [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]].]
5808 !! html/php+tidy
5809 <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>.
5810 </p>
5811 !! html/parsoid
5812 <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>
5813 !! end
5814
5815 !! test
5816 External link with comments in link text
5817 !! wikitext
5818 [http://www.google.com Google <!-- comment -->]
5819 !! html/php
5820 <p><a rel="nofollow" class="external text" href="http://www.google.com">Google </a>
5821 </p>
5822 !! html/parsoid
5823 <p><a rel="mw:ExtLink" class="external text" href="http://www.google.com">Google <!-- comment --></a></p>
5824 !! end
5825
5826 !! test
5827 External link to bare IPv4 address
5828 !! wikitext
5829 [http://192.168.0.1 Link]
5830 !! html/php
5831 <p><a rel="nofollow" class="external text" href="http://192.168.0.1">Link</a>
5832 </p>
5833 !! html/parsoid
5834 <p><a rel="mw:ExtLink" class="external text" href="http://192.168.0.1">Link</a></p>
5835 !! end
5836
5837 !! test
5838 URL-encoding in URL functions (single parameter)
5839 !! wikitext
5840 {{localurl:Some page|amp=&}}
5841 !! html
5842 <p>/index.php?title=Some_page&amp;amp=&amp;
5843 </p>
5844 !! end
5845
5846 !! test
5847 URL-encoding in URL functions (multiple parameters)
5848 !! wikitext
5849 {{localurl:Some page|q=?&amp=&}}
5850 !! html
5851 <p>/index.php?title=Some_page&amp;q=?&amp;amp=&amp;
5852 </p>
5853 !! end
5854
5855 !! test
5856 Brackets in urls
5857 !! wikitext
5858 http://example.com/index.php?foozoid%5B%5D=bar
5859
5860 http://example.com/index.php?foozoid&#x5B;&#x5D;=bar
5861 !! html/php
5862 <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>
5863 </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>
5864 </p>
5865 !! html/parsoid
5866 <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>
5867
5868 <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>
5869 !! end
5870
5871 !! test
5872 IPv6 urls, autolink format (T23261)
5873 !! wikitext
5874 http://[2404:130:0:1000::187:2]/index.php
5875
5876 Examples from RFC 2373, section 2.2:
5877
5878 *http://[1080::8:800:200C:417A]/unicast
5879 *http://[FF01::101]/multicast
5880 *http://[::1]/loopback
5881 *http://[::]/unspecified
5882 *http://[::13.1.68.3]/ipv4compat
5883 *http://[::FFFF:129.144.52.38]/ipv4compat
5884
5885 Examples from RFC 2732, section 2:
5886
5887 *http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
5888 *http://[1080:0:0:0:8:800:200C:417A]/index.html
5889 *http://[3ffe:2a00:100:7031::1]
5890 *http://[1080::8:800:200C:417A]/foo
5891 *http://[::192.9.5.5]/ipng
5892 *http://[::FFFF:129.144.52.38]:80/index.html
5893 *http://[2010:836B:4179::836B:4179]
5894 !! html/php
5895 <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>
5896 </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:
5897 </p>
5898 <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>
5899 <li><a rel="nofollow" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5900 <li><a rel="nofollow" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5901 <li><a rel="nofollow" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5902 <li><a rel="nofollow" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5903 <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>
5904 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5905 </p>
5906 <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>
5907 <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>
5908 <li><a rel="nofollow" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5909 <li><a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
5910 <li><a rel="nofollow" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5911 <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>
5912 <li><a rel="nofollow" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5913
5914 !! html/parsoid
5915 <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>
5916
5917 <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>
5918 <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>
5919 <li><a rel="mw:ExtLink" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5920 <li><a rel="mw:ExtLink" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5921 <li><a rel="mw:ExtLink" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5922 <li><a rel="mw:ExtLink" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5923 <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>
5924
5925 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external mw-magiclink">RFC 2732</a>, section 2:</p>
5926 <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>
5927 <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>
5928 <li><a rel="mw:ExtLink" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5929 <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>
5930 <li><a rel="mw:ExtLink" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5931 <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>
5932 <li><a rel="mw:ExtLink" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5933 !! end
5934
5935 !! test
5936 IPv6 urls, bracketed format (T23261)
5937 !! wikitext
5938 [http://[2404:130:0:1000::187:2]/index.php test]
5939
5940 Examples from RFC 2373, section 2.2:
5941
5942 *[http://[1080::8:800:200C:417A] unicast]
5943 *[http://[FF01::101] multicast]
5944 *[http://[::1]/ loopback]
5945 *[http://[::] unspecified]
5946 *[http://[::13.1.68.3] ipv4compat]
5947 *[http://[::FFFF:129.144.52.38] ipv4compat]
5948
5949 Examples from RFC 2732, section 2:
5950
5951 *[http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html 1]
5952 *[http://[1080:0:0:0:8:800:200C:417A]/index.html 2]
5953 *[http://[3ffe:2a00:100:7031::1] 3]
5954 *[http://[1080::8:800:200C:417A]/foo 4]
5955 *[http://[::192.9.5.5]/ipng 5]
5956 *[http://[::FFFF:129.144.52.38]:80/index.html 6]
5957 *[http://[2010:836B:4179::836B:4179] 7]
5958 !! html/php
5959 <p><a rel="nofollow" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a>
5960 </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:
5961 </p>
5962 <ul><li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5963 <li><a rel="nofollow" class="external text" href="http://[FF01::101]">multicast</a></li>
5964 <li><a rel="nofollow" class="external text" href="http://[::1]/">loopback</a></li>
5965 <li><a rel="nofollow" class="external text" href="http://[::]">unspecified</a></li>
5966 <li><a rel="nofollow" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5967 <li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5968 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5969 </p>
5970 <ul><li><a rel="nofollow" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
5971 <li><a rel="nofollow" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5972 <li><a rel="nofollow" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5973 <li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5974 <li><a rel="nofollow" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
5975 <li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5976 <li><a rel="nofollow" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5977
5978 !! html/parsoid
5979 <p><a rel="mw:ExtLink" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a></p>
5980
5981 <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>
5982 <ul><li><a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5983 <li><a rel="mw:ExtLink" class="external text" href="http://[FF01::101]">multicast</a></li>
5984 <li><a rel="mw:ExtLink" class="external text" href="http://[::1]/">loopback</a></li>
5985 <li><a rel="mw:ExtLink" class="external text" href="http://[::]">unspecified</a></li>
5986 <li><a rel="mw:ExtLink" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5987 <li><a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5988
5989 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external mw-magiclink">RFC 2732</a>, section 2:</p>
5990 <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>
5991 <li><a rel="mw:ExtLink" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5992 <li><a rel="mw:ExtLink" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5993 <li><a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5994 <li><a rel="mw:ExtLink" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
5995 <li><a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5996 <li><a rel="mw:ExtLink" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5997 !! end
5998
5999 !! test
6000 Non-extlinks in brackets
6001 !! wikitext
6002 [foo]
6003 [foo bar]
6004 [foo ''bar'']
6005 [fool's] errand
6006 [fool's errand]
6007 [{{echo|foo}}]
6008 [{{echo|foo}} bar]
6009 [{{echo|foo}} ''bar'']
6010 [{{echo|foo}}l's] errand
6011 [{{echo|foo}}l's errand]
6012 [url={{echo|foo}}]
6013 [url=http://example.com]
6014 [http:// bare protocols don't count]
6015 !! html/php
6016 <p>[foo]
6017 [foo bar]
6018 [foo <i>bar</i>]
6019 [fool's] errand
6020 [fool's errand]
6021 [foo]
6022 [foo bar]
6023 [foo <i>bar</i>]
6024 [fool's] errand
6025 [fool's errand]
6026 [url=foo]
6027 [url=<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>]
6028 [http:// bare protocols don't count]
6029 </p>
6030 !! html/parsoid
6031 <p>[foo]
6032 [foo bar]
6033 [foo <i>bar</i>]
6034 [fool's] errand
6035 [fool's errand]
6036 [<span about="#mwt19" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>]
6037 [<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]
6038 [<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>]
6039 [<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
6040 [<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]
6041 [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>]
6042 [url=<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>]
6043 [http:// bare protocols don't count]</p>
6044 !! end
6045
6046 !! test
6047 Percent encoding in external links
6048 !! wikitext
6049 [https://github.com/search?l=&q=ResourceLoader+%40wikimedia Search]
6050 !! html/php
6051 <p><a rel="nofollow" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a>
6052 </p>
6053 !! html/parsoid
6054 <p><a rel="mw:ExtLink" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a></p>
6055 !! end
6056
6057 !! test
6058 Use url link syntax for links where the content is equal the link target
6059 !! wikitext
6060 http://example.com
6061 !! html/php
6062 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
6063 </p>
6064 !! html/parsoid
6065 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a></p>
6066 !! end
6067
6068 !! test
6069 Parenthesis in external links, especially URL links
6070 !! wikitext
6071 http://example.com)
6072
6073 http://example.com/test)
6074
6075 http://example.com/(test)
6076
6077 http://example.com/((test)
6078
6079 (http://example.com/(test))
6080
6081 (http://example.com/(test)))))
6082
6083 http://example.com/a)b
6084
6085 [http://example.com) foo]
6086 !! html/php
6087 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
6088 </p><p><a rel="nofollow" class="external free" href="http://example.com/test">http://example.com/test</a>)
6089 </p><p><a rel="nofollow" class="external free" href="http://example.com/(test)">http://example.com/(test)</a>
6090 </p><p><a rel="nofollow" class="external free" href="http://example.com/((test)">http://example.com/((test)</a>
6091 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test))">http://example.com/(test))</a>
6092 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a>
6093 </p><p><a rel="nofollow" class="external free" href="http://example.com/a)b">http://example.com/a)b</a>
6094 </p><p><a rel="nofollow" class="external text" href="http://example.com)">foo</a>
6095 </p>
6096 !! html/parsoid
6097 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>)</p>
6098 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/test">http://example.com/test</a>)</p>
6099 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/(test)">http://example.com/(test)</a></p>
6100 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/((test)">http://example.com/((test)</a></p>
6101 <p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test))">http://example.com/(test))</a></p>
6102 <p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a></p>
6103 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/a)b">http://example.com/a)b</a></p>
6104 <p><a rel="mw:ExtLink" class="external text" href="http://example.com)">foo</a></p>
6105 !! end
6106
6107 !! test
6108 Parenthesis in external links, w/ transclusion or comment
6109 !! wikitext
6110 (http://example.com/{{echo|hi}})
6111
6112 (http://example.com<!-- hi -->)
6113 !! html/php
6114 <p>(<a rel="nofollow" class="external free" href="http://example.com/hi">http://example.com/hi</a>)
6115 </p><p>(<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
6116 </p>
6117 !! html/parsoid
6118 <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>
6119
6120 <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>
6121 !! end
6122
6123 !! test
6124 Serialize <a> tags with invalid link targets as plain text
6125 !! options
6126 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
6127 !! html/parsoid
6128 <a rel="mw:WikiLink" href="[[foo]]">text</a>
6129 <a rel="mw:WikiLink" href="[[foo]]">*text</a>
6130 <a rel="mw:WikiLink" href="[[foo]]">[[foo]]</a>
6131 <a rel="mw:WikiLink" href="[[foo]]">*a [[foo]]</a>
6132 !! wikitext
6133 text
6134 <nowiki>*</nowiki>text
6135 <nowiki>[[foo]]</nowiki>
6136 <nowiki>*</nowiki>a <nowiki>[[foo]]</nowiki>
6137 !! end
6138
6139 !! test
6140 mw:ExtLink -vs- mw:WikiLink (T94723)
6141 !! options
6142 parsoid=html2wt
6143 !! html/parsoid
6144 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"piped","a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>Bar</a>
6145 <a rel="mw:WikiLink" href="./Foo" title="Foo">Bar</a>
6146 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
6147 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
6148 <p>
6149 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
6150 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
6151 </p>
6152 !! wikitext
6153 [[Foo|Bar]]
6154 [[Foo|Bar]]
6155 [[:en:Foo|Bar]]
6156 [[:en:Foo|Bar]]
6157
6158 [[:en:European_Robin|European Robin]]
6159 [[:en:European_Robin|European Robin]]
6160 !! end
6161
6162 !! test
6163 mw:ExtLink linking to a interwiki URL can be round-tripped losslessly (T94723)
6164 !! options
6165 parsoid=wt2wt
6166 !! wikitext
6167 [http://en.wikipedia.org/wiki/European_Robin European Robin]
6168 !! html/parsoid
6169 THIS SECTION IS NOT USED (but Parsoid won't run the test without it)
6170 !! end
6171
6172
6173 ###
6174 ### Quotes
6175 ###
6176
6177 !! test
6178 Quotes
6179 !! wikitext
6180 Normal text. '''Bold text.''' Normal text. ''Italic text.''
6181
6182 Normal text. '''''Bold italic text.''''' Normal text.
6183 !! html
6184 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
6185 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
6186 </p>
6187 !! end
6188
6189 !! test
6190 Quotes wrapping HTML table
6191 !! wikitext
6192 '''<table><tr><td>hi</td></tr></table>'''
6193 !! html/php+tidy
6194 <b><table><tbody><tr><td>hi</td></tr></tbody></table></b>
6195 !! html/parsoid
6196 <b><table data-parsoid='{"stx":"html"}'><tbody><tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>hi</td></tr></tbody></table></b>
6197 !! end
6198
6199 # Parsoid inserts an empty bold tag pair at the end of the line, that the PHP
6200 # parser strips. The wikitext contains just the first half of the bold
6201 # quote pair.
6202 !! test
6203 Unclosed and unmatched quotes
6204 !! wikitext
6205 '''''Bold italic text '''with bold deactivated''' in between.'''''
6206
6207 '''''Bold italic text ''with italic deactivated'' in between.'''''
6208
6209 '''Bold text..
6210
6211 ..spanning two paragraphs (should not work).'''
6212
6213 '''Bold tag left open
6214
6215 ''Italic tag left open
6216
6217 Normal text.
6218
6219 <!-- Unmatching number of opening, closing tags: -->
6220 '''This year''''s election ''should'' beat '''last year''''s.
6221
6222 ''Tom'''s car is bigger than ''Susan'''s.
6223
6224 Plain ''italic'''s plain
6225 !! html/php
6226 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
6227 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
6228 </p><p><b>Bold text..</b>
6229 </p><p>..spanning two paragraphs (should not work).
6230 </p><p><b>Bold tag left open</b>
6231 </p><p><i>Italic tag left open</i>
6232 </p><p>Normal text.
6233 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
6234 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
6235 </p><p>Plain <i>italic'</i>s plain
6236 </p>
6237 !! html/parsoid
6238 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
6239 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
6240 </p><p><b>Bold text..</b>
6241 </p><p>..spanning two paragraphs (should not work).<b></b>
6242 </p><p><b>Bold tag left open</b>
6243 </p><p><i>Italic tag left open</i>
6244 </p><p>Normal text.
6245 </p>
6246 <!-- Unmatching number of opening, closing tags: -->
6247 <p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
6248 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
6249 </p><p>Plain <i>italic'</i>s plain
6250 </p>
6251 !! end
6252
6253 ###
6254 ### Tables
6255 ###
6256 ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
6257 ###
6258
6259 # This should not produce <table></table> as <table><tr><td></td></tr></table>
6260 # is the bare minimum required by the spec, see:
6261 # https://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
6262 # Parsoid team replies: empty table tags are legal in HTML5
6263 !! test
6264 A table with no data.
6265 !! options
6266 parsoid=wt2html
6267 !! wikitext
6268 {||}
6269 !! html/php
6270
6271 !! html/parsoid
6272 <table></table>
6273
6274 !! end
6275
6276 # Note that the PHP parser output appears to be broken when the table
6277 # end tag is not separated by a space from the style attribute
6278 !! test
6279 A table with stray table end tags on start tag line (wt2html)
6280 !! options
6281 parsoid=wt2html
6282 !! wikitext
6283 {|style="color: red;"|}
6284
6285 {|style="color: red;" |}
6286 |foo
6287 |}
6288
6289 {|style="color: red;"|} id="foo"
6290 |foo
6291 |}
6292
6293 {|style="color: red;" |} id="foo"
6294 |foo
6295 |}
6296 !! html/php+tidy
6297 <table style="&quot;color:">
6298
6299 </table><table style="color: red;">
6300 <tbody><tr>
6301 <td>foo
6302 </td></tr></tbody></table>
6303 <table style="&quot;color:" id="foo">
6304 <tbody><tr>
6305 <td>foo
6306 </td></tr></tbody></table>
6307 <table style="color: red;" id="foo">
6308 <tbody><tr>
6309 <td>foo
6310 </td></tr></tbody></table>
6311 !! html/parsoid
6312 <table style="color: red;"></table>
6313
6314 <table style="color: red;">
6315 <tbody><tr>
6316 <td>foo</td>
6317 </tr></tbody>
6318 </table>
6319
6320 <table style="color: red;" id="foo">
6321 <tbody><tr>
6322 <td>foo</td>
6323 </tr></tbody>
6324 </table>
6325
6326 <table style="color: red;" id="foo">
6327 <tbody><tr>
6328 <td>foo</td>
6329 </tr></tbody>
6330 </table>
6331
6332 !! end
6333
6334 !! test
6335 A table with no data (take 2)
6336 !! wikitext
6337 {|
6338 |}
6339 !! html/parsoid
6340 <table></table>
6341 !! end
6342
6343 # A table with nothing but a caption is invalid XHTML, we might want to render
6344 # this as <p>caption</p>
6345 # Parsoid team replies: table with only a caption is legal in HTML5
6346 !! test
6347 A table with nothing but a caption
6348 !! wikitext
6349 {|
6350 |+caption
6351 |}
6352 !! html/php
6353 <table>
6354 <caption>caption
6355 </caption><tr><td></td></tr></table>
6356
6357 !! html/parsoid
6358 <table><caption>caption</caption></table>
6359 !! end
6360
6361 !! test
6362 A table with caption with default-spaced attributes and a table row
6363 !! wikitext
6364 {|
6365 |+ style="color: red;" |caption1
6366 |-
6367 |foo
6368 |}
6369 !! html
6370 <table>
6371 <caption style="color: red;">caption1
6372 </caption>
6373 <tr>
6374 <td>foo
6375 </td></tr></table>
6376
6377 !! end
6378
6379 !! test
6380 A table with captions with non-default spaced attributes and a table row
6381 !! wikitext
6382 {|
6383 |+style="color: red;"|caption2
6384 |+ style="color: red;"|caption3
6385 |-
6386 |foo
6387 |}
6388 !! html
6389 <table>
6390 <caption style="color: red;">caption2
6391 </caption>
6392 <caption style="color: red;">caption3
6393 </caption>
6394 <tr>
6395 <td>foo
6396 </td></tr></table>
6397
6398 !! end
6399
6400 !! test
6401 Table td-cell syntax variations
6402 !! wikitext
6403 {|
6404 |foo bar foo|baz
6405 |foo bar foo||baz
6406 |style='color:red;'|baz
6407 |style='color:red;'||baz
6408 |}
6409 !! html
6410 <table>
6411 <tr>
6412 <td>baz
6413 </td>
6414 <td>foo bar foo</td>
6415 <td>baz
6416 </td>
6417 <td style="color:red;">baz
6418 </td>
6419 <td>style='color:red;'</td>
6420 <td>baz
6421 </td></tr></table>
6422
6423 !! end
6424
6425 !! test
6426 Simple table
6427 !! wikitext
6428 {|
6429 |1||2
6430 |-
6431 |3||4
6432 |}
6433 !! html
6434 <table>
6435 <tr>
6436 <td>1</td>
6437 <td>2
6438 </td></tr>
6439 <tr>
6440 <td>3</td>
6441 <td>4
6442 </td></tr></table>
6443
6444 !! end
6445
6446 !! test
6447 Simple table but with multiple dashes for row wikitext
6448 !! wikitext
6449 {|
6450 |foo
6451 |-----
6452 |bar
6453 |}
6454 !! html
6455 <table>
6456 <tr>
6457 <td>foo
6458 </td></tr>
6459 <tr>
6460 <td>bar
6461 </td></tr></table>
6462
6463 !! end
6464
6465 !! test
6466 Multiplication table
6467 !! wikitext
6468 {| border="1" cellpadding="2"
6469 |+Multiplication table
6470 |-
6471 !&times;!!1!!2!!3
6472 |-
6473 !1
6474 |1||2||3
6475 |-
6476 !2
6477 |2||4||6
6478 |-
6479 !3
6480 |3||6||9
6481 |-
6482 !4
6483 |4||8||12
6484 |-
6485 !5
6486 |5||10||15
6487 |}
6488 !! html
6489 <table border="1" cellpadding="2">
6490 <caption>Multiplication table
6491 </caption>
6492 <tr>
6493 <th>&#215;</th>
6494 <th>1</th>
6495 <th>2</th>
6496 <th>3
6497 </th></tr>
6498 <tr>
6499 <th>1
6500 </th>
6501 <td>1</td>
6502 <td>2</td>
6503 <td>3
6504 </td></tr>
6505 <tr>
6506 <th>2
6507 </th>
6508 <td>2</td>
6509 <td>4</td>
6510 <td>6
6511 </td></tr>
6512 <tr>
6513 <th>3
6514 </th>
6515 <td>3</td>
6516 <td>6</td>
6517 <td>9
6518 </td></tr>
6519 <tr>
6520 <th>4
6521 </th>
6522 <td>4</td>
6523 <td>8</td>
6524 <td>12
6525 </td></tr>
6526 <tr>
6527 <th>5
6528 </th>
6529 <td>5</td>
6530 <td>10</td>
6531 <td>15
6532 </td></tr></table>
6533
6534 !! end
6535
6536 !! test
6537 Accept "||" in table headings
6538 !! wikitext
6539 {|
6540 !h1||h2
6541 |}
6542 !! html
6543 <table>
6544 <tr>
6545 <th>h1</th>
6546 <th>h2
6547 </th></tr></table>
6548
6549 !! end
6550
6551 !! test
6552 Accept "!!" in table data
6553 !! wikitext
6554 {|
6555 |Foo!!||
6556 |}
6557 !! html
6558 <table>
6559 <tr>
6560 <td>Foo!!</td>
6561 <td>
6562 </td></tr></table>
6563
6564 !! html/parsoid
6565 <table>
6566 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'> Foo!! </td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'></td></tr>
6567 </tbody></table>
6568 !! end
6569
6570 !! test
6571 Accept "||" in indented table headings
6572 !! wikitext
6573 :{|
6574 !h1||h2
6575 |}
6576 !! html
6577 <dl><dd><table>
6578 <tr>
6579 <th>h1</th>
6580 <th>h2
6581 </th></tr></table></dd></dl>
6582
6583 !! end
6584
6585 !! test
6586 Accept "!!" in templates
6587 !! wikitext
6588 {|
6589 !a {{echo|b!!c}}
6590 |}
6591 !! html/php
6592 <table>
6593 <tr>
6594 <th>a b</th>
6595 <th>c
6596 </th></tr></table>
6597
6598 !! html/parsoid
6599 <table>
6600 <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>
6601 !! end
6602
6603 !! test
6604 Accept "!!" in table headings after newline
6605 !! wikitext
6606 {|
6607 !a
6608 b!!c
6609 |}
6610 !! html/php
6611 <table>
6612 <tr>
6613 <th>a
6614 <p>b!!c
6615 </p>
6616 </th></tr></table>
6617
6618 !! html/parsoid
6619 <table>
6620 <tbody><tr><th>a
6621 <p>b!!c</p></th></tr>
6622 </tbody></table>
6623 !! end
6624
6625 !! test
6626 Accept "!!" in table data of mixed wikitext / html syntax
6627 !! wikitext
6628 {|
6629 !a
6630 <tr><td>b!!c</td></tr>
6631 |}
6632 !! html/php+tidy
6633 <table>
6634 <tbody><tr>
6635 <th>a
6636 </th></tr><tr><td>b!!c</td></tr>
6637 </tbody></table>
6638 !! html/parsoid
6639 <table>
6640 <tbody><tr><th>a</th></tr>
6641 <tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>b!!c</td></tr>
6642 </tbody></table>
6643 !! end
6644
6645 !! test
6646 Accept empty attributes in td/th cells (td/th cells starting with leading ||)
6647 !! wikitext
6648 {|
6649 !|h1
6650 ||a
6651 |}
6652 !! html
6653 <table>
6654 <tr>
6655 <th>h1
6656 </th>
6657 <td>a
6658 </td></tr></table>
6659
6660 !! end
6661
6662 !!test
6663 Accept "| !" at start of line in tables (ignore !-attribute)
6664 !! wikitext
6665 {|
6666 |-
6667 |!style="color:red"|bar
6668 |}
6669 !! html
6670 <table>
6671
6672 <tr>
6673 <td>bar
6674 </td></tr></table>
6675
6676 !!end
6677
6678 !!test
6679 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 +/-
6680 !! wikitext
6681 {|
6682 |-
6683 |style='color:red;'|+1
6684 |style='color:blue;'|-1
6685 |-
6686 |1||2||3
6687 |1||+2||-3
6688 |-
6689 | +1
6690 | -1
6691 |}
6692 !! html
6693 <table>
6694
6695 <tr>
6696 <td style="color:red;">+1
6697 </td>
6698 <td style="color:blue;">-1
6699 </td></tr>
6700 <tr>
6701 <td>1</td>
6702 <td>2</td>
6703 <td>3
6704 </td>
6705 <td>1</td>
6706 <td>+2</td>
6707 <td>-3
6708 </td></tr>
6709 <tr>
6710 <td>+1
6711 </td>
6712 <td>-1
6713 </td></tr></table>
6714
6715 !!end
6716
6717 !! test
6718 Table rowspan
6719 !! wikitext
6720 {| border=1
6721 |Cell 1, row 1
6722 |rowspan=2|Cell 2, row 1 (and 2)
6723 |Cell 3, row 1
6724 |-
6725 |Cell 1, row 2
6726 |Cell 3, row 2
6727 |}
6728 !! html
6729 <table border="1">
6730 <tr>
6731 <td>Cell 1, row 1
6732 </td>
6733 <td rowspan="2">Cell 2, row 1 (and 2)
6734 </td>
6735 <td>Cell 3, row 1
6736 </td></tr>
6737 <tr>
6738 <td>Cell 1, row 2
6739 </td>
6740 <td>Cell 3, row 2
6741 </td></tr></table>
6742
6743 !! end
6744
6745 !! test
6746 Nested table
6747 !! wikitext
6748 {| border=1
6749 | &alpha;
6750 |
6751 {| bgcolor=#ABCDEF border=2
6752 |nested
6753 |-
6754 |table
6755 |}
6756 |the original table again
6757 |}
6758 !! html
6759 <table border="1">
6760 <tr>
6761 <td>&#945;
6762 </td>
6763 <td>
6764 <table bgcolor="#ABCDEF" border="2">
6765 <tr>
6766 <td>nested
6767 </td></tr>
6768 <tr>
6769 <td>table
6770 </td></tr></table>
6771 </td>
6772 <td>the original table again
6773 </td></tr></table>
6774
6775 !! end
6776
6777 !! test
6778 Invalid attributes in table cell (T3830)
6779 !! wikitext
6780 {|
6781 |Cell:|broken
6782 |}
6783 !! html
6784 <table>
6785 <tr>
6786 <td>broken
6787 </td></tr></table>
6788
6789 !! end
6790
6791 !! test
6792 Table cell attributes: Pipes protected by nowikis should be treated as a plain character
6793 !! wikitext
6794 {|
6795 |title="foo" |bar
6796 |title="foo<nowiki>|</nowiki>" |bar
6797 |title="foo<nowiki>|</nowiki>" bar
6798 |}
6799 !! html/php
6800 <table>
6801 <tr>
6802 <td title="foo">bar
6803 </td>
6804 <td title="foo&#124;">bar
6805 </td>
6806 <td>title="foo|" bar
6807 </td></tr></table>
6808
6809 !! html/parsoid
6810 <table>
6811 <tbody><tr><td title="foo">bar</td>
6812 <td title="foo|" data-parsoid='{"a":{"title":"foo|"},"sa":{"title":"foo&lt;nowiki>|&lt;/nowiki>"},"autoInsertedEnd":true}'>bar</td>
6813 <td> title="foo<span typeof="mw:Nowiki">|</span>" bar</td></tr>
6814 </tbody></table>
6815 !! end
6816
6817 # See: http://lists.wikimedia.org/mailman/htdig/wikitech-l/2006-April/022293.html
6818 # N.B. The "|}" to close the table is missing from the input, so parsoid's
6819 # *2wt modes will fail.
6820 !! test
6821 Table security: embedded pipes
6822 !! options
6823 parsoid=wt2html,html2html
6824 !! wikitext
6825 {|
6826 | |[ftp://|x||]" onmouseover="alert(document.cookie)">test
6827 !! html/php
6828 <table>
6829 <tr>
6830 <td>[<a rel="nofollow" class="external free" href="ftp://%7Cx">ftp://%7Cx</a></td>
6831 <td>]" onmouseover="alert(document.cookie)"&gt;test
6832 </td>
6833 </tr>
6834 </table>
6835
6836 !! html/parsoid
6837 <table><tbody>
6838 <tr>
6839 <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>
6840 !! end
6841
6842 !! test
6843 Element attributes with double ! should not be broken up by <th>
6844 !! wikitext
6845 {|
6846 !hi <div class="!!">ha</div> ho
6847 |}
6848 !! html/php
6849 <table>
6850 <tr>
6851 <th>hi <div class="!!">ha</div> ho
6852 </th></tr></table>
6853
6854 !! html/parsoid
6855 <table>
6856 <tbody><tr><th>hi <div class="!!" data-parsoid='{"stx":"html"}'>ha</div> ho</th></tr>
6857 </tbody></table>
6858 !! end
6859
6860 !! test
6861 ! and || in element attributes should not be parsed as <th>/<td>
6862 !! wikitext
6863 {|
6864 |<div style="color: red !important;" data-contrived="put this here ||">hi</div>
6865 |}
6866 !! html/php
6867 <table>
6868 <tr>
6869 <td><div style="color: red !important;" data-contrived="put this here &#124;&#124;">hi</div>
6870 </td></tr></table>
6871
6872 !! html/parsoid
6873 <table>
6874 <tbody><tr><td><div style="color: red !important;" data-contrived="put this here ||" data-parsoid='{"stx":"html"}'>hi</div></td></tr>
6875 </tbody></table>
6876 !! end
6877
6878 # FIXME: The output seems broken. Filed as T110268.
6879 !! test
6880 ! and || in td attributes should not be parsed as <th>/<td>
6881 !! options
6882 parsoid=wt2html
6883 !! wikitext
6884 {|
6885 |style="color: red !important;" data-contrived="put this here ||"|foo
6886 |}
6887 !! html/php
6888 <table>
6889 <tr>
6890 <td>style="color: red !important;" data-contrived="put this here</td>
6891 <td>foo
6892 </td></tr></table>
6893
6894 !! html/parsoid
6895 <table>
6896 <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>
6897 </tbody></table>
6898 !! end
6899
6900 !! test
6901 Break on | in element attribute in template
6902 !! options
6903 parsoid=wt2html,html2html
6904 !! wikitext
6905 {{echo|1=<div class="hi|ho">ha</div>}}
6906 !! html/php
6907 <p>ho"&gt;ha&lt;/div&gt;
6908 </p>
6909 !! html/parsoid
6910 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"ho\">ha&lt;/div>"}},"i":0}}]}'>ho">ha</p>
6911 !! end
6912
6913 !! test
6914 Break on | in element attribute name in template
6915 !! wikitext
6916 {{echo|<div cla|ss="hiho">ha</div>}}
6917 !! html/parsoid
6918 <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>
6919 !! end
6920
6921 !! test
6922 Don't break on | in extension attribute in template
6923 !! wikitext
6924 {{echo|<ref name="hi|ho">ha</ref>}}
6925
6926 <references />
6927 !! html/parsoid
6928 <p><sup about="#mwt2" class="mw-ref" id="cite_ref-hi|ho_1-0" rel="dc:references" typeof="mw:Transclusion mw:Extension/ref" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;ref name=\"hi|ho\">ha&lt;/ref>"}},"i":0}}]}'><a href="./Parser_test#cite_note-hi|ho-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup></p>
6929
6930 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-hi|ho-1" id="cite_note-hi|ho-1"><a href="./Parser_test#cite_ref-hi|ho_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-hi|ho-1" class="mw-reference-text">ha</span></li></ol>
6931 !! end
6932
6933 ## We don't support roundtripping of these attributes in Parsoid.
6934 ## Selective serialization takes care of preventing dirty diffs.
6935 ## But, on edits, we dirty-diff the invalid attribute text.
6936 !! test
6937 Invalid text in table attributes should be discarded
6938 !! options
6939 parsoid=wt2html
6940 !! wikitext
6941 {| <span>boo</span> style='border:1px solid black'
6942 | <span>boo</span> style='color:blue' |1
6943 |<span>boo</span> style='color:blue'|2
6944 |}
6945 !! html/php
6946 <table style="border:1px solid black">
6947 <tr>
6948 <td style="color:blue">1
6949 </td>
6950 <td style="color:blue">2
6951 </td></tr></table>
6952
6953 !! html/parsoid
6954 <table style="border:1px solid black">
6955 <tr>
6956 <td style="color:blue">1</td>
6957 <td style="color:blue">2</td>
6958 </tr>
6959 </table>
6960 !! end
6961
6962 !! test
6963 Invalid text in table attributes should be preserved by selective serializer
6964 !! options
6965 parsoid={
6966 "modes": ["selser"],
6967 "changes": [
6968 ["td:first-child", "text", "abc"],
6969 ["td + td", "text", "xyz"]
6970 ]
6971 }
6972 !! wikitext
6973 {| <span>boo</span> style='border:1px solid black'
6974 | <span>boo</span> style='color:blue' | 1
6975 |<span>boo</span> style='color:blue'| 2
6976 |}
6977 !! wikitext/edited
6978 {| <span>boo</span> style='border:1px solid black'
6979 | <span>boo</span> style='color:blue' | abc
6980 |<span>boo</span> style='color:blue'| xyz
6981 |}
6982 !! end
6983
6984 !! test
6985 1. Template-generated table cell attributes and cell content
6986 !! wikitext
6987 {|
6988 |{{table_attribs}}
6989 | {{table_attribs}}
6990 || {{table_attribs_5}}
6991 | <!--foo--> <!--bar--> <!--baz--> {{table_attribs}}
6992 |align=center {{table_attribs}}
6993 | <!--foo--> align=center <!--bar--> {{table_attribs}}
6994 |}
6995 !! html
6996 <table>
6997 <tr>
6998 <td style="color:red;">Foo
6999 </td>
7000 <td style="color:red;">Foo
7001 </td>
7002 <td>style="color:red;"</td>
7003 <td>Bar
7004 </td>
7005 <td style="color:red;">Foo
7006 </td>
7007 <td align="center" style="color:red;">Foo
7008 </td>
7009 <td align="center" style="color:red;">Foo
7010 </td></tr></table>
7011
7012 !! end
7013
7014 !! test
7015 2. Template-generated table cell attributes and cell content
7016 !! wikitext
7017 {|
7018 |{{table_attribs_2}}
7019 |}
7020 !! html/php
7021 <table>
7022 <tr>
7023 <td style="color:red;">Foo
7024 </td>
7025 <td>Bar</td>
7026 <td>Baz
7027 </td></tr></table>
7028
7029 !! html/parsoid
7030 <table>
7031 <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>
7032 <td about="#mwt1">Bar</td><td about="#mwt1">Baz</td></tr>
7033 </tbody></table>
7034 !! end
7035
7036 !! test
7037 3. Template-generated table cell attributes and cell content
7038 !! wikitext
7039 {|
7040 !align=center {{table_header_cells}}
7041 |-
7042 |align=center {{table_cells}}
7043 |}
7044 !! html/php
7045 <table>
7046 <tr>
7047 <th align="center" style="color:red;">Foo</th>
7048 <th style="color:red;"><i>Bar</i></th>
7049 <th style="color:brown;"><i>Foo</i> and Baz
7050 </th></tr>
7051 <tr>
7052 <td align="center" style="color:red;">Foo</td>
7053 <td style="color:red;"><i>Bar</i></td>
7054 <td style="color:brown;"><i>Foo</i> and Baz
7055 </td></tr></table>
7056
7057 !! html/parsoid
7058 <table>
7059 <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>
7060 <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>
7061 </tbody></table>
7062 !! end
7063
7064 !! test
7065 4. Template-generated table cell attributes and cell content inside a templated table
7066 !! wikitext
7067 {{tbl-start}}
7068 !align=center {{table_header_cells}}
7069 |-
7070 |align=center {{table_cells}}
7071 {{tbl-end}}
7072 !! html/php
7073 <table>
7074 <tr>
7075 <th align="center" style="color:red;">Foo</th>
7076 <th style="color:red;"><i>Bar</i></th>
7077 <th style="color:brown;"><i>Foo</i> and Baz
7078 </th></tr>
7079 <tr>
7080 <td align="center" style="color:red;">Foo</td>
7081 <td style="color:red;"><i>Bar</i></td>
7082 <td style="color:brown;"><i>Foo</i> and Baz
7083 </td></tr></table>
7084
7085 !! html/parsoid
7086 <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}}]}'>
7087 <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>
7088 <tr>
7089 <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>
7090 </tbody></table>
7091 !! end
7092
7093 ## Edge case fix to prevent future regressions
7094 !! test
7095 T107652: <ref>s in templates that also generate table cell attributes should be rendered properly
7096 !! wikitext
7097 {|
7098 |{{table_attribs_7}}
7099 |}
7100 <references />
7101 !! html/parsoid
7102 <table>
7103 <tbody><tr><td style="background:#f9f9f9;" typeof="mw:Transclusion" about="#mwt1" data-mw='{"parts":["|",{"template":{"target":{"wt":"table_attribs_7","href":"./Template:Table_attribs_7"},"params":{},"i":0}}]}'>Foo<sup class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{},"body":{"id":"mw-reference-text-cite_note-1"}}'><a href="./Parser_test#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></s></td></tr>
7104 </tbody></table>
7105 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Parser_test#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
7106 !! end
7107
7108 !! test
7109 Table with row followed by newlines and table heading
7110 !! options
7111 parsoid=wt2html,html2html
7112 !! wikitext
7113 {|
7114 |-
7115
7116 !foo
7117 |}
7118 !! html/*
7119 <table>
7120
7121
7122 <tr>
7123 <th>foo
7124 </th></tr></table>
7125
7126 !! end
7127
7128 !! test
7129 Table with empty line following the start tag
7130 !! options
7131 parsoid=wt2html,html2html
7132 !! wikitext
7133 {|
7134
7135 |-
7136 |foo
7137 |}
7138 !! html/*
7139 <table>
7140
7141
7142 <tr>
7143 <td>foo
7144 </td></tr></table>
7145
7146 !! end
7147
7148 !! test
7149 Table attributes with empty value
7150 !! options
7151 parsoid=wt2html,html2html
7152 !! wikitext
7153 {|
7154 | style=|hello
7155 |}
7156 !! html/php
7157 <table>
7158 <tr>
7159 <td style="">hello
7160 </td></tr></table>
7161
7162 !! html/parsoid
7163 <table>
7164 <tbody><tr><td style="">hello</td></tr>
7165 </tbody></table>
7166 !! end
7167
7168 !! test
7169 Wikitext table with a lot of comments
7170 !! wikitext
7171 {|
7172 <!-- c0 -->
7173 |foo
7174 <!-- c1 -->
7175 |-<!-- c2 -->
7176 <!-- c3 -->
7177 |<!-- c4 -->
7178 <!-- c5 -->
7179 |}
7180 !! html
7181 <table>
7182 <tr>
7183 <td>foo
7184 </td></tr>
7185 <tr>
7186 <td>
7187 </td></tr></table>
7188
7189 !! end
7190
7191 !! test
7192 Wikitext table comments represented in parsoid dom
7193 !! wikitext
7194 {|<!--c1--><!--c2-->
7195 |-<!--c3-->
7196 |x
7197 |}
7198 !! html/php+tidy
7199 <table>
7200
7201 <tbody><tr>
7202 <td>x
7203 </td></tr></tbody></table>
7204 !! html/parsoid
7205 <table><!--c1--><!--c2-->
7206 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'><!--c3-->
7207 <td data-parsoid='{"autoInsertedEnd":true}'>x</td></tr>
7208 </tbody></table>
7209 !! end
7210
7211 !! test
7212 Wikitext table with double-line table cell
7213 !! wikitext
7214 {|
7215 |a
7216 b
7217 |}
7218 !! html
7219 <table>
7220 <tr>
7221 <td>a
7222 <p>b
7223 </p>
7224 </td></tr></table>
7225
7226 !! end
7227
7228 !! test
7229 Table cell with a single comment
7230 !! wikitext
7231 {|
7232 |<!-- c1 -->
7233 |a
7234 |}
7235 !! html
7236 <table>
7237 <tr>
7238 <td>
7239 </td>
7240 <td>a
7241 </td></tr></table>
7242
7243 !! end
7244
7245 !! test
7246 Table-cell after a comment-only-empty-line
7247 !! wikitext
7248 {|
7249 |a
7250 <!--c1-->
7251 <!--c2-->|b
7252 |}
7253 !! html
7254 <table>
7255 <tr>
7256 <td>a
7257 </td>
7258 <td>b
7259 </td></tr></table>
7260
7261 !! html/parsoid
7262 <table>
7263 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>a</td>
7264 <!--c1-->
7265 <!--c2--><td data-parsoid='{"autoInsertedEnd":true}'>b</td></tr>
7266 </tbody></table>
7267
7268 !! end
7269
7270 !! test
7271 Build table with {{!}}
7272 !! wikitext
7273 {{{!}} class="wikitable"
7274 !header
7275 !second header
7276 {{!}}- style="color:red;"
7277 {{!}}data{{!}}{{!}} style="color:red;" {{!}}second data
7278 {{!}}}
7279 !! html
7280 <table class="wikitable">
7281 <tr>
7282 <th>header
7283 </th>
7284 <th>second header
7285 </th></tr>
7286 <tr style="color:red;">
7287 <td>data</td>
7288 <td style="color:red;">second data
7289 </td></tr></table>
7290
7291 !! end
7292
7293 !! test
7294 Build table with pipe as data
7295 !! wikitext
7296 {| class="wikitable"
7297 !header
7298 !second header
7299 |- style="color:red;"
7300 |data|| style="color:red;" |second data
7301 |-
7302 | style="color:red;" |data with | || style="color:red;" | second data with |
7303 |-
7304 ||data with | |||second data with |
7305 |}
7306 !! html
7307 <table class="wikitable">
7308 <tr>
7309 <th>header
7310 </th>
7311 <th>second header
7312 </th></tr>
7313 <tr style="color:red;">
7314 <td>data</td>
7315 <td style="color:red;">second data
7316 </td></tr>
7317 <tr>
7318 <td style="color:red;">data with |</td>
7319 <td style="color:red;">second data with |
7320 </td></tr>
7321 <tr>
7322 <td>data with |</td>
7323 <td>second data with |
7324 </td></tr></table>
7325
7326 !! end
7327
7328 !! test
7329 Build table with wikilink
7330 !! wikitext
7331 {| class="wikitable"
7332 !header||second header
7333 |- style="color:red;"
7334 |data [[Main Page|linktext]]||second data [[Main Page|linktext]]
7335 |-
7336 |data||second data [[Main Page|link|text with pipe]]
7337 |}
7338 !! html
7339 <table class="wikitable">
7340 <tr>
7341 <th>header</th>
7342 <th>second header
7343 </th></tr>
7344 <tr style="color:red;">
7345 <td>data <a href="/wiki/Main_Page" title="Main Page">linktext</a></td>
7346 <td>second data <a href="/wiki/Main_Page" title="Main Page">linktext</a>
7347 </td></tr>
7348 <tr>
7349 <td>data</td>
7350 <td>second data <a href="/wiki/Main_Page" title="Main Page">link|text with pipe</a>
7351 </td></tr></table>
7352
7353 !! end
7354
7355 # The expected HTML structure in this test is debatable. The PHP parser does
7356 # not parse this kind of table at all. The main focus for Parsoid is on
7357 # round-tripping, so this output is ok for now. TODO: revisit!
7358 !! test
7359 Wikitext table with html-syntax row
7360 !! wikitext
7361 {|
7362 |-
7363 <td>foo</td>
7364 |}
7365 !! html/parsoid
7366 <table>
7367 <tbody>
7368 <tr>
7369 <td>foo</td></tr></tbody></table>
7370 !! end
7371
7372 ## Remex doesn't account for fostered content.
7373 !! test
7374 Fostered content in tables: Plain text
7375 !! options
7376 parsoid=wt2html
7377 !! wikitext
7378 {|
7379 |-
7380 a
7381 |}
7382 !! html/php
7383 <table>
7384
7385 a
7386 </table>
7387
7388 !! html/php+tidy
7389
7390
7391 a
7392 <table></table>
7393 !! html/parsoid
7394 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>
7395 a</p>
7396 <table>
7397 <tbody><tr class="mw-empty-elt" data-parsoid='{"startTagSrc":"|-"}'></tr></tbody></table>
7398 !! end
7399
7400 !! test
7401 Fostered content in tables: Lists
7402 !! options
7403 parsoid=wt2html,html2html
7404 !! wikitext
7405 {|
7406 |-
7407 *a
7408 |}
7409 !! html/php
7410 <table>
7411
7412 <ul><li>a</li></ul>
7413 </table>
7414
7415 !! html/php+tidy
7416 <ul><li>a</li></ul><table>
7417
7418
7419 </table>
7420 !! html/parsoid
7421 <ul data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><li>a</li></ul><table>
7422 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7423
7424 </tr></tbody></table>
7425 !! end
7426
7427 !! test
7428 Template generated table cell with attributes
7429 !! wikitext
7430 {|
7431 |-
7432 {{table_attribs_4}} ||a||b
7433 |}
7434 !! html/php+tidy
7435 <table>
7436
7437 <tbody><tr>
7438 <td style="background-color:#DC241f;" width="10px"></td>
7439 <td>a</td>
7440 <td>b
7441 </td></tr></tbody></table>
7442 !! html/parsoid
7443 <table>
7444 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7445 <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>
7446 !! end
7447
7448 !! test
7449 Parsoid: Round-trip tables directly followed by content (T53219)
7450 !! options
7451 parsoid=wt2html,wt2wt
7452 !! wikitext
7453 {|
7454 |foo
7455 |} bar
7456
7457 {|
7458 |baz
7459 |}<b>quux</b>
7460 !! html+tidy
7461 <table>
7462 <tbody><tr>
7463 <td>foo
7464 </td></tr></tbody></table><p> bar
7465 </p><table>
7466 <tbody><tr>
7467 <td>baz
7468 </td></tr></tbody></table><p><b>quux</b>
7469 </p>
7470 !! end
7471
7472 !! test
7473 Parsoid: Default to a newline after tables in new content (T53219)
7474 !! options
7475 parsoid=html2wt
7476 !! html/parsoid
7477 <table><tbody>
7478 <tr><td>foo</td></tr></tbody></table> bar
7479 <table><tbody>
7480 <tr><td>baz</td></tr></tbody></table><b>quux</b>
7481 !! wikitext
7482 {|
7483 |foo
7484 |}
7485 <nowiki> </nowiki>bar
7486 {|
7487 |baz
7488 |}
7489 '''quux'''
7490 !! end
7491
7492 !! test
7493 Parsoid: Row-syntax table headings followed by comment & table cells
7494 !! options
7495 parsoid=wt2html,wt2wt
7496 !! wikitext
7497 {|
7498 !foo||bar
7499 <!-- foo --> ||baz||quux
7500 |}
7501 !! html/php
7502 <table>
7503 <tr>
7504 <th>foo</th>
7505 <th>bar
7506 </th>
7507 <td>baz</td>
7508 <td>quux
7509 </td></tr></table>
7510
7511 !! html/parsoid
7512 <table>
7513 <tbody><tr><th>foo</th><th>bar
7514 <!-- foo --></th><td> baz </td><td>quux</td></tr>
7515 </tbody></table>
7516 !! end
7517
7518 !!test
7519 Parsoid: Recover better from broken table attributes
7520 !!options
7521 parsoid=wt2html
7522 !!wikitext
7523 {| class="foo
7524 | class="bar" |
7525 foo
7526 |}
7527 !!html/php+tidy
7528 <table class="foo">
7529 <tbody><tr>
7530 <td class="bar">
7531 <p>foo
7532 </p>
7533 </td></tr></tbody></table>
7534 !!html/parsoid
7535 <table class="foo">
7536 <tr>
7537 <td class="bar">
7538 <p>foo</p></td></tr>
7539 </tbody></table>
7540 !!end
7541
7542 # Note: PHP parser omits empty rows
7543 !! test
7544 Tables: Digest broken attributes on table and tr tag
7545 !! options
7546 parsoid=wt2html
7547 !! wikitext
7548 {| || |} ++
7549 |- || || ++ --
7550 |- > [
7551 |}
7552 !! html/php+tidy
7553 <table>
7554
7555
7556 </table>
7557 !! html/parsoid
7558 <table>
7559 <tbody>
7560 <tr class='mw-empty-elt'></tr>
7561 <tr class='mw-empty-elt'></tr>
7562 </tbody></table>
7563 !! end
7564
7565 !! test
7566 Table with missing opening <tr> tag
7567 !! options
7568 parsoid=wt2html,wt2wt
7569 !! wikitext
7570 <table>
7571 <td>foo</td>
7572 </tr>
7573 </table>
7574 !! html+tidy
7575 <table>
7576 <tbody><tr><td>foo</td>
7577 </tr>
7578 </tbody></table>
7579 !! end
7580
7581 # T137406: Whitespace in the HTML
7582 !! test
7583 1. Generate correct wikitext for tables with thead/tbody/tfoot
7584 !! options
7585 parsoid=html2wt
7586 !! html/parsoid
7587 <table>
7588 <caption>Test</caption>
7589 <thead>
7590 <tr>
7591 <th>Month</th>
7592 <th>Savings</th>
7593 </tr>
7594 </thead>
7595 <tbody>
7596 <tr>
7597 <td>January</td>
7598 <td>$100</td>
7599 </tr>
7600 <tr>
7601 <td>February</td>
7602 <td>$80</td>
7603 </tr>
7604 </tbody>
7605 <tfoot>
7606 <tr>
7607 <td>Sum</td>
7608 <td>$180</td>
7609 </tr>
7610 </tfoot>
7611 </table>
7612 !! wikitext
7613 {|
7614 |+Test
7615 !Month
7616 !Savings
7617 |-
7618 |January
7619 |$100
7620 |-
7621 |February
7622 |$80
7623 |-
7624 |Sum
7625 |$180
7626 |}
7627 !! html/php+tidy
7628 <table>
7629 <caption>Test
7630 </caption>
7631 <tbody><tr>
7632 <th>Month
7633 </th>
7634 <th>Savings
7635 </th></tr>
7636 <tr>
7637 <td>January
7638 </td>
7639 <td>$100
7640 </td></tr>
7641 <tr>
7642 <td>February
7643 </td>
7644 <td>$80
7645 </td></tr>
7646 <tr>
7647 <td>Sum
7648 </td>
7649 <td>$180
7650 </td></tr></tbody></table>
7651 !! end
7652
7653 # T137406: No whitespace in the HTML
7654 !! test
7655 2. Generate correct wikitext for tables with thead/tbody/tfoot
7656 !! options
7657 parsoid=html2wt
7658 !! html/parsoid
7659 <table><thead><tr><th>heading</th></tr></thead><tbody><tr><td>foo</td></tr></tbody></table>
7660 !! wikitext
7661 {|
7662 !heading
7663 |-
7664 |foo
7665 |}
7666 !! end
7667
7668 !! test
7669 Wikitext tables can be nested inside HTML tables
7670 !! options
7671 parsoid=html2wt
7672 !! html/parsoid
7673 <table data-parsoid='{"stx":"html"}'>
7674 <tr><td>
7675 <table>
7676 <tr><td>foo</td></tr>
7677 </table>
7678 </td></tr>
7679 </table>
7680 !! wikitext
7681 <table>
7682 <tr><td>
7683 {|
7684 |foo
7685 |}
7686 </td></tr>
7687 </table>
7688 !! html/php+tidy
7689 <table>
7690 <tbody><tr><td>
7691 <table>
7692 <tbody><tr>
7693 <td>foo
7694 </td></tr></tbody></table>
7695 </td></tr>
7696 </tbody></table>
7697 !! end
7698
7699 ###
7700 ### Internal links
7701 ###
7702 !! test
7703 Plain link, capitalized
7704 !! wikitext
7705 [[Main Page]]
7706 !! html
7707 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
7708 </p>
7709 !! end
7710
7711 !! test
7712 Plain link, uncapitalized
7713 !! wikitext
7714 [[main Page]]
7715 !! html
7716 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
7717 </p>
7718 !! end
7719
7720 !! test
7721 Piped link
7722 !! wikitext
7723 [[Main Page|The Main Page]]
7724 !! html
7725 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7726 </p>
7727 !! end
7728
7729 !! test
7730 Piped link with comment in link text
7731 !! wikitext
7732 [[Main Page|The Main<!--front--> Page]]
7733 !! html
7734 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7735 </p>
7736 !! end
7737
7738 !! test
7739 Piped link with multiple pipe characters in link text
7740 !! wikitext
7741 [[Main Page||The|Main|Page|]]
7742 !! html/php
7743 <p><a href="/wiki/Main_Page" title="Main Page">|The|Main|Page|</a>
7744 </p>
7745 !! html/parsoid
7746 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">|The|Main|Page|</a></p>
7747 !! end
7748
7749 !! test
7750 Piped link with no link text
7751 !! wikitext
7752 [[Thomas Bek (bishop of St David's)|]]
7753 !! html/php
7754 <p>[[Thomas Bek (bishop of St David's)|]]
7755 </p>
7756 !! html/parsoid
7757 <p>[[Thomas Bek (bishop of St David's)|]]</p>
7758 !! end
7759
7760 !! test
7761 Piped link with empty link text
7762 !! wikitext
7763 [[Main Page|<nowiki/>]] - empty nowiki
7764 [[Main Page| ]] - empty space
7765 [[Main Page|&nbsp;]] - empty non breaking space
7766 !! html/php
7767 <p><a href="/wiki/Main_Page" title="Main Page"></a> - empty nowiki
7768 <a href="/wiki/Main_Page" title="Main Page"> </a> - empty space
7769 <a href="/wiki/Main_Page" title="Main Page">&#160;</a> - empty non breaking space
7770 </p>
7771 !! html/parsoid
7772 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:Nowiki"></span></a> - empty nowiki
7773 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page"> </a> - empty space
7774 <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>
7775 !! end
7776
7777 !! test
7778 Broken link
7779 !! wikitext
7780 [[Zigzagzogzagzig]]
7781 !! html
7782 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig</a>
7783 </p>
7784 !! end
7785
7786 !! test
7787 Broken link with fragment
7788 !! wikitext
7789 [[Zigzagzogzagzig#zug]]
7790 !! html
7791 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig#zug</a>
7792 </p>
7793 !! end
7794
7795 !! test
7796 Special page link with fragment
7797 !! wikitext
7798 [[Special:Version#anchor]]
7799 !! html
7800 <p><a href="/wiki/Special:Version#anchor" title="Special:Version">Special:Version#anchor</a>
7801 </p>
7802 !! end
7803
7804 !! test
7805 Nonexistent special page link with fragment
7806 !! wikitext
7807 [[Special:ThisNameWillHopefullyNeverBeUsed#anchor]]
7808 !! html
7809 <p><a href="/wiki/Special:ThisNameWillHopefullyNeverBeUsed" class="new" title="Special:ThisNameWillHopefullyNeverBeUsed (page does not exist)">Special:ThisNameWillHopefullyNeverBeUsed#anchor</a>
7810 </p>
7811 !! end
7812
7813 !! test
7814 Link with prefix
7815 !! wikitext
7816 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
7817 !! html
7818 <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>
7819 </p>
7820 !! end
7821
7822 !! test
7823 Link with suffix
7824 !! wikitext
7825 [[Main Page]]xxx, [[Main Page]]XXX, [[Main Page]]!!!
7826 !! html
7827 <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>!!!
7828 </p>
7829 !! end
7830
7831 !! article
7832 prefixed article
7833 !! text
7834 Some text
7835 !! endarticle
7836
7837 !! test
7838 T45661: Piped links with identical prefixes
7839 !! wikitext
7840 [[prefixed article|prefixed articles with spaces]]
7841
7842 [[prefixed article|prefixed articlesaoeu]]
7843
7844 [[Main Page|Main Page test]]
7845 !! html
7846 <p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articles with spaces</a>
7847 </p><p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articlesaoeu</a>
7848 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page test</a>
7849 </p>
7850 !! end
7851
7852
7853 !! test
7854 Link with HTML entity in suffix / tail
7855 !! wikitext
7856 [[Main Page]]&quot;, [[Main Page]]&#97;
7857 !! html/php
7858 <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;
7859 </p>
7860 !! html/parsoid
7861 <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>
7862 !! end
7863
7864 !! test
7865 Link with 3 brackets
7866 !! wikitext
7867 [[[Main Page]]]
7868 Foo [[[Main Page]]]
7869 !! html
7870 <p>[[[Main Page]]]
7871 Foo [[[Main Page]]]
7872 </p>
7873 !! end
7874
7875 !! test
7876 Link with 4 brackets
7877 !! wikitext
7878 [[[[Main Page]]]]
7879 !! html
7880 <p>[[<a href="/wiki/Main_Page" title="Main Page">Main Page</a>]]
7881 </p>
7882 !! end
7883
7884 !! test
7885 Piped link with 3 brackets
7886 !! wikitext
7887 [[[main page|the main page]]]
7888 !! html
7889 <p>[[[main page|the main page]]]
7890 </p>
7891 !! end
7892
7893 !! test
7894 Piped link with extlink-like text
7895 !! wikitext
7896 [[Main Page|[bar]]]
7897 [[Main Page|This is a [bar]]]
7898 [[Main Page|[bar]]
7899 !! html/php
7900 <p><a href="/wiki/Main_Page" title="Main Page">[bar]</a>
7901 <a href="/wiki/Main_Page" title="Main Page">This is a [bar]</a>
7902 <a href="/wiki/Main_Page" title="Main Page">[bar</a>
7903 </p>
7904 !! html/parsoid
7905 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar]</a>
7906 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>This is a [bar]</a>
7907 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar</a></p>
7908 !! end
7909
7910 !! test
7911 Link with multiple pipes
7912 !! wikitext
7913 [[Main Page|The|Main|Page]]
7914 !! html
7915 <p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a>
7916 </p>
7917 !! end
7918
7919 !! test
7920 Anchor containing a #. (T65430)
7921 !! config
7922 wgFragmentMode=[ 'html5', 'legacy' ]
7923 !! wikitext
7924 [[Main Page#And#Link]]
7925 !! html/php
7926 <p><a href="/wiki/Main_Page#And#Link" title="Main Page">Main Page#And#Link</a>
7927 </p>
7928 !! html/parsoid
7929 <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>
7930 !! end
7931
7932 !! test
7933 Link to namespaces
7934 !! wikitext
7935 [[Talk:Parser testing]], [[Meta:Disclaimers]]
7936 !! html
7937 <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>
7938 </p>
7939 !! end
7940
7941 !! test
7942 Link with space in namespace
7943 !! wikitext
7944 [[User talk:Foo bar]]
7945 !! html
7946 <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>
7947 </p>
7948 !! end
7949
7950 !! article
7951 MemoryAlpha:AlphaTest
7952 !! text
7953 This is an article in the MemoryAlpha namespace
7954 (which shadows the memoryalpha interwiki link).
7955 !! endarticle
7956
7957 !! test
7958 Namespace takes precedence over interwiki link (T53680)
7959 !! wikitext
7960 [[MemoryAlpha:AlphaTest]]
7961 !! html
7962 <p><a href="/wiki/MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a>
7963 </p>
7964 !! end
7965
7966 # The previous test doesn't work correctly in html2*, due to not recognizing the
7967 # link as an internal one. This one checks for the correct behavior.
7968 !! test
7969 Link to namespace preferred over interwiki with correct rel attribute
7970 !! options
7971 parsoid=html2wt,html2html
7972 !! html/parsoid
7973 <p><a rel="mw:WikiLink" href="./MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a></p>
7974 !! wikitext
7975 [[MemoryAlpha:AlphaTest]]
7976 !! end
7977
7978 !! test
7979 Piped link to namespace
7980 !! wikitext
7981 [[Meta:Disclaimers|The disclaimers]]
7982 !! html
7983 <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>
7984 </p>
7985 !! end
7986
7987 !! test
7988 Link containing }
7989 !! wikitext
7990 [[Usually caused by a typo (oops}]]
7991 !! html
7992 <p>[[Usually caused by a typo (oops}]]
7993 </p>
7994 !! end
7995
7996 !! article
7997 7% Solution
7998 !! text
7999 Just a test of an article title containing a percent.
8000 !! endarticle
8001
8002 !! test
8003 Link containing % (not as a hex sequence)
8004 !! wikitext
8005 [[7% Solution]]
8006 [[7% Solution|7%25 Solution]]
8007 !! html/php
8008 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
8009 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
8010 </p>
8011 !! html/parsoid
8012 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
8013 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
8014 !! end
8015
8016 # note that the parsoid HTML is identical to the previous test output,
8017 # so the previous test ensures that the html2wt mode will generate the
8018 # "not as a hex sequence" wikitext.
8019 !! test
8020 Link containing % as a single hex sequence interpreted to char
8021 !! options
8022 parsoid=wt2wt,wt2html,html2html
8023 !! wikitext
8024 [[7%25 Solution]]
8025 [[7%25 Solution|7%25 Solution]]
8026 !! html/php
8027 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
8028 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
8029 </p>
8030 !! html/parsoid
8031 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
8032 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
8033 !!end
8034
8035 !! test
8036 Link containing % as a double hex sequence interpreted to hex sequence
8037 !! wikitext
8038 [[7%2525 Solution]]
8039 !! html
8040 <p>[[7%2525 Solution]]
8041 </p>
8042 !!end
8043
8044 ## Example for such a section: == < ==
8045 !! test
8046 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors
8047 !! options
8048 title=[[Main Page]]
8049 !! config
8050 wgFragmentMode=[ 'html5', 'legacy' ]
8051 !! wikitext
8052 [[%23%3c]][[%23%3e]]
8053 !! html/php
8054 <p><a href="#&lt;">#&lt;</a><a href="#&gt;">#&gt;</a>
8055 </p>
8056 !! html/parsoid
8057 <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>
8058 !! end
8059
8060 ## Example for such a section: == < ==
8061 !! test
8062 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors (legacy)
8063 !! config
8064 wgFragmentMode=[ 'legacy' ]
8065 !! wikitext
8066 [[%23%3c]][[%23%3e]]
8067 !! html/php
8068 <p><a href="#.3C">#&lt;</a><a href="#.3E">#&gt;</a>
8069 </p>
8070 !! end
8071
8072 !! test
8073 Link containing "<#" and ">#" as a hex sequences
8074 !! wikitext
8075 [[%3c%23]][[%3e%23]]
8076 !! html
8077 <p>[[%3c%23]][[%3e%23]]
8078 </p>
8079 !! end
8080
8081 !! test
8082 Link containing an equals sign
8083 !! wikitext
8084 [[Special:BookSources/isbn=4-00-026157-6]]
8085 !! html/php
8086 <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>
8087 </p>
8088 !! html/parsoid
8089 <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>
8090 !! end
8091
8092 !! article
8093 Foo & bar
8094 !! text
8095 Just a test of an article title containing an ampersand
8096 !! endarticle
8097
8098 !! test
8099 Link containing an ampersand
8100 !! wikitext
8101 [[Foo & bar]]
8102
8103 [[Foo &amp; bar]]
8104
8105 [[Foo &amp;amp; bar]]
8106 !! html/php+tidy
8107 <p><a href="/wiki/Foo_%26_bar" title="Foo &amp; bar">Foo &amp; bar</a>
8108 </p><p><a href="/wiki/Foo_%26_bar" title="Foo &amp; bar">Foo &amp; bar</a>
8109 </p><p>[[Foo &amp;amp; bar]]
8110 </p>
8111 !! html/parsoid
8112 <p><a rel="mw:WikiLink" href="./Foo_&amp;_bar" title="Foo &amp; bar">Foo &amp; bar</a></p>
8113 <p><a rel="mw:WikiLink" href="./Foo_&amp;_bar" title="Foo &amp; bar" data-parsoid='{"stx":"simple","a":{"href":"./Foo_&amp;_bar"},"sa":{"href":"Foo &amp;amp; bar"}}'>Foo &amp; bar</a></p>
8114 <p>[[Foo <span typeof="mw:Entity" data-parsoid='{"src":"&amp;amp;","srcContent":"&amp;"}'>&amp;</span>amp; bar]]</p>
8115 !! end
8116
8117 !! article
8118 Foo~bar
8119 !! text
8120 Just a test of an article title containing a tilde.
8121 !! endarticle
8122
8123 # note that links containing signatures, like [[Foo~~~~]], are
8124 # massaged by the pre-save transform (PST) and so the tildes are never
8125 # seen by the parser.
8126 !! test
8127 Link containing a tilde
8128 !! wikitext
8129 [[Foo~bar]]
8130 !! html/php
8131 <p><a href="/wiki/Foo~bar" title="Foo~bar">Foo~bar</a>
8132 </p>
8133 !! html/parsoid
8134 <p><a rel="mw:WikiLink" href="./Foo~bar" title="Foo~bar">Foo~bar</a></p>
8135 !! end
8136
8137 !! test
8138 Link containing double-single-quotes '' (T6598)
8139 !! wikitext
8140 [[Lista d''e paise d''o munno]]
8141 !! html/php
8142 <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>
8143 </p>
8144 !! html/parsoid
8145 <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>
8146 !! end
8147
8148 !! test
8149 Link containing double quotes and spaces
8150 !! wikitext
8151 [[Cool "Gator"]]
8152 !! html/php
8153 <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>
8154 </p>
8155 !! html/parsoid
8156 <p><a rel="mw:WikiLink" href='./Cool_"Gator"' title='Cool "Gator"'>Cool "Gator"</a></p>
8157 !! end
8158
8159 !! test
8160 File containing double quotes and spaces
8161 !! wikitext
8162 [[File:Cool "Gator".png]]
8163 !! html/parsoid
8164 <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>
8165 !! end
8166
8167 !! test
8168 Redirect containing double quotes and spaces
8169 !! wikitext
8170 #REDIRECT [[Cool "Gator"]]
8171 !! html/parsoid
8172 <link rel="mw:PageProp/redirect" href="./Cool_%22Gator%22" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Cool_%22Gator%22"},"sa":{"href":"Cool \"Gator\""}}'/>
8173 !! end
8174
8175 !! test
8176 Link containing double-single-quotes '' in text (T6598 sanity check)
8177 !! wikitext
8178 Some [[Link|pretty ''italics'' and stuff]]!
8179 !! html/php
8180 <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>!
8181 </p>
8182 !! html/parsoid
8183 <p>Some <a rel="mw:WikiLink" href="./Link" title="Link">pretty <i>italics</i> and stuff</a>!</p>
8184 !! end
8185
8186 !! test
8187 Link containing double-single-quotes '' in text embedded in italics (T6598 sanity check)
8188 !! wikitext
8189 ''Some [[Link|pretty ''italics'' and stuff]]!''
8190 !! html
8191 <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>
8192 </p>
8193 !! end
8194
8195 !! test
8196 Link with double quotes in title part (literal) and alternate part (interpreted)
8197 !! wikitext
8198 [[File:Denys_Savchenko_''Pentecoste''.jpg]]
8199
8200 [[''Pentecoste'']]
8201
8202 [[''Pentecoste''|Pentecoste]]
8203
8204 [[''Pentecoste''|''Pentecoste'']]
8205 !! html/php
8206 <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>
8207 </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>
8208 </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>
8209 </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>
8210 </p>
8211 !! html/parsoid
8212 <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>
8213 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">''Pentecoste''</a></p>
8214 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">Pentecoste</a></p>
8215 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''"><i>Pentecoste</i></a></p>
8216 !! end
8217
8218 !! test
8219 Broken image links with HTML captions (T41700)
8220 !! wikitext
8221 [[File:Nonexistent|<script></script>]]
8222 [[File:Nonexistent|100x100px|<script></script>]]
8223 [[File:Nonexistent|&lt;]]
8224 [[File:Nonexistent|a<i>b</i>c]]
8225 !! html/php
8226 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8227 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8228 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;</a>
8229 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">abc</a>
8230 </p>
8231 !! html/parsoid
8232 <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>
8233 <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>
8234 <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>
8235 <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>
8236 !! end
8237
8238 !! test
8239 Plain link to URL
8240 !! wikitext
8241 [[http://www.example.com]]
8242 !! html/php
8243 <p>[<a rel="nofollow" class="external autonumber" href="http://www.example.com">[1]</a>]
8244 </p>
8245 !! html/parsoid
8246 <p>[<a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com"></a>]</p>
8247 !! end
8248
8249 !! test
8250 Plain link to URL with link text
8251 !! wikitext
8252 [[http://www.example.com Link text]]
8253 !! html
8254 <p>[<a rel="nofollow" class="external text" href="http://www.example.com">Link text</a>]
8255 </p>
8256 !! end
8257
8258 !! test
8259 Plain link to protocol-relative URL
8260 !! wikitext
8261 [[//www.example.com]]
8262 !! html/php
8263 <p>[<a rel="nofollow" class="external autonumber" href="//www.example.com">[1]</a>]
8264 </p>
8265 !! html/parsoid
8266 <p>[<a rel="mw:ExtLink" class="external autonumber" href="//www.example.com"></a>]</p>
8267 !! end
8268
8269 !! test
8270 Plain link to protocol-relative URL with link text
8271 !! wikitext
8272 [[//www.example.com Link text]]
8273 !! html
8274 <p>[<a rel="nofollow" class="external text" href="//www.example.com">Link text</a>]
8275 </p>
8276 !! end
8277
8278 !! test
8279 Plain link to page with question mark in title
8280 !! wikitext
8281 [[A?b]]
8282
8283 [[A?b|Baz]]
8284 !! html
8285 <p><a href="/wiki/A%3Fb" title="A?b">A?b</a>
8286 </p><p><a href="/wiki/A%3Fb" title="A?b">Baz</a>
8287 </p>
8288 !! end
8289
8290 # I'm fairly sure the expected result here is wrong.
8291 # We want these to be URL links, not pseudo-pages with URLs for titles....
8292 # However the current output is also pretty screwy.
8293 #
8294 # ----
8295 # I'm changing it to match the current output--it arguably makes more
8296 # sense in the light of the test above. Old expected result was:
8297 #<p>Piped link to URL: <a href="/index.php?title=Http://www.example.com&amp;action=edit" class="new">an example URL</a>
8298 #</p>
8299 # But I think this test is bordering on "garbage in, garbage out" anyway.
8300 # -- wtm
8301 !! test
8302 Piped link to URL
8303 !! wikitext
8304 Piped link to URL: [[http://www.example.com|an example URL]]
8305 !! html/php
8306 <p>Piped link to URL: [<a rel="nofollow" class="external text" href="http://www.example.com%7Can">example URL</a>]
8307 </p>
8308 !! html/parsoid
8309 <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>
8310 !! end
8311
8312 !! test
8313 Plain link in template argument
8314 !! options
8315 parsoid=wt2html
8316 !! wikitext
8317 {{echo|[http://www.example.com |123]}}
8318
8319 {{echo|[[http://www.example.com |123]]}}
8320
8321 {{echo|[[http://www.example.com |123]}}
8322
8323 {{echo|[http://www.example.com |123]]}}
8324 !! html/php
8325 <p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8326 </p><p>[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>]
8327 </p><p>{{echo|[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>}}
8328 </p><p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8329 </p>
8330 !! html/parsoid
8331 <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>
8332
8333 <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>
8334
8335 <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>
8336
8337 <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>
8338 !! end
8339
8340 !! test
8341 T2002: [[page|http://url/]] should link to page, not http://url/
8342 !! wikitext
8343 [[Main Page|http://url/]]
8344 !! html/php
8345 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
8346 </p>
8347 !! html/parsoid
8348 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">http://url/</a></p>
8349 !! end
8350
8351 # Parsoid does not mark self-links, by design.
8352 !! test
8353 T2337: Escaped self-links should be bold
8354 !! options
8355 title=[[Bug462]]
8356 !! wikitext
8357 [[Bu&#103;462]] [[Bug462]]
8358 !! html/php+tidy
8359 <p><a class="mw-selflink selflink">Bu&#103;462</a> <a class="mw-selflink selflink">Bug462</a>
8360 </p>
8361 !! html/parsoid
8362 <p><a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a> <a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a></p>
8363 !! end
8364
8365 !! test
8366 Self-link to section should not be bold
8367 !! options
8368 title=[[Main Page]]
8369 !! wikitext
8370 [[Main Page#section]]
8371 !! html
8372 <p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
8373 </p>
8374 !! end
8375
8376 !! article
8377 00
8378 !! text
8379 This is 00.
8380 !! endarticle
8381
8382 !!test
8383 Self-link to numeric title
8384 !!options
8385 title=[[0]]
8386 !! wikitext
8387 [[0]]
8388 !! html
8389 <p><a class="mw-selflink selflink">0</a>
8390 </p>
8391 !!end
8392
8393 !!test
8394 Link to numeric-equivalent title
8395 !!options
8396 title=[[0]]
8397 !! wikitext
8398 [[00]]
8399 !! html
8400 <p><a href="/wiki/00" title="00">00</a>
8401 </p>
8402 !!end
8403
8404 !! test
8405 <nowiki> inside a link
8406 !! wikitext
8407 [[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
8408 !! html
8409 <p>[[Main Page]] <a href="/wiki/Main_Page" title="Main Page">the main page [it's not very good]</a>
8410 </p>
8411 !! end
8412
8413 !! test
8414 Non-breaking spaces in title
8415 !! wikitext
8416 [[&nbsp; Main &nbsp; Page &nbsp;]]
8417 !! html
8418 <p><a href="/wiki/Main_Page" title="Main Page">&#160; Main &#160; Page &#160;</a>
8419 </p>
8420 !!end
8421
8422 # Add new article for the test below so that it doesn't red-link
8423 !! article
8424 Foo bar baz
8425 !! text
8426 boo
8427 !! endarticle
8428
8429 !! test
8430 Multiple spaces in titles should normalize to a single underscore
8431 !! options
8432 parsoid=wt2html,wt2wt
8433 !! wikitext
8434 [[Foo bar baz|x]]
8435 [[Foo bar baz|x]]
8436 [[Foo bar baz|x]]
8437 !! html/php
8438 <p><a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8439 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8440 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8441 </p>
8442 !! html/parsoid
8443 <p><a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8444 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8445 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8446 </p>
8447 !! end
8448
8449 !! test
8450 Internal link with ca linktrail, surrounded by bold apostrophes (T29473 primary issue)
8451 !! options
8452 language=ca
8453 !! wikitext
8454 '''[[Main Page]]'''
8455 !! html
8456 <p><b><a href="/wiki/Main_Page" title="Main Page">Main Page</a></b>
8457 </p>
8458 !! end
8459
8460 !! test
8461 Internal link with ca linktrail, surrounded by italic apostrophes (T29473 primary issue)
8462 !! options
8463 language=ca
8464 !! wikitext
8465 ''[[Main Page]]''
8466 !! html
8467 <p><i><a href="/wiki/Main_Page" title="Main Page">Main Page</a></i>
8468 </p>
8469 !! end
8470
8471 !! test
8472 Internal link with en linktrail: no apostrophes (T29473)
8473 !! options
8474 language=en
8475 !! wikitext
8476 [[Something]]'nice
8477 !! html
8478 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (page does not exist)">Something</a>'nice
8479 </p>
8480 !! end
8481
8482 !! test
8483 Internal link with ca linktrail with apostrophes (T29473)
8484 !! options
8485 language=ca
8486 !! wikitext
8487 [[Something]]'nice
8488 !! html
8489 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (encara no existeix)">Something'nice</a>
8490 </p>
8491 !! end
8492
8493 !! test
8494 Internal link with kaa linktrail with apostrophes (T29473)
8495 !! options
8496 language=kaa
8497 !! wikitext
8498 [[Something]]'nice
8499 !! html
8500 <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>
8501 </p>
8502 !! end
8503
8504 !! test
8505 Link with multiple ":" in a subpage-supporting namespace (T65636)
8506 !! wikitext
8507 [[User:Foo/Test/63636:Bar|Test]]
8508 !! html/php
8509 <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>
8510 </p>
8511 !! html/parsoid
8512 <p><a rel="mw:WikiLink" href="./User:Foo/Test/63636:Bar" title="User:Foo/Test/63636:Bar">Test</a></p>
8513 !! end
8514
8515 ## Mainly a sanity check for Parsoid
8516 !! test
8517 Handle title parsing for subpages
8518 !! options
8519 title=[[/123123]]
8520 subpage
8521 !! wikitext
8522 123
8523 !! html/php
8524 <p>123
8525 </p>
8526 !! html/parsoid
8527 <p>123</p>
8528 !! end
8529
8530 !! article
8531 User:Test/123
8532 !! text
8533 test 123
8534 !! endarticle
8535
8536 !! test
8537 Link to a subpage from a namespace other than main
8538 !! options
8539 title=[[User:Test]]
8540 subpage
8541 !! wikitext
8542 [[/123]]
8543 !! html/php
8544 <p><a href="/wiki/User:Test/123" title="User:Test/123">/123</a>
8545 </p>
8546 !! html/parsoid
8547 <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>
8548 !! end
8549
8550 !! test
8551 Ensure that transclusion titles are not url-decoded
8552 !! options
8553 subpage title=[[Test]]
8554 parsoid=wt2html
8555 !! wikitext
8556 {{Bar%C3%A9}} {{/Bar%C3%A9}}
8557 !! html/php
8558 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}
8559 </p>
8560 !! html/parsoid
8561 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}</p>
8562 !! end
8563
8564 !! test
8565 Purely hash wikilink
8566 !! options
8567 title=[[User:Test/123]]
8568 subpage
8569 !! wikitext
8570 [[#a|b]]
8571 !! html/php
8572 <p><a href="#a">b</a>
8573 </p>
8574 !! html/parsoid
8575 <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>
8576 !! end
8577
8578 !! test
8579 Serialization of purely hash wikilink
8580 !! options
8581 title=[[User:Test/123]]
8582 subpage
8583 parsoid=html2wt
8584 !! html/parsoid
8585 <p><a href="#a">[[</a></p>
8586 !! wikitext
8587 [[#a|<nowiki>[[</nowiki>]]
8588 !! html/php
8589 <p><a href="#a">[[</a>
8590 </p>
8591 !! end
8592
8593 !! test
8594 1. Interaction of linktrail and template encapsulation
8595 !! wikitext
8596 {{echo|[[Foo]]}}l
8597 !! html/php+tidy
8598 <p><a href="/wiki/Foo" title="Foo">Fool</a>
8599 </p>
8600 !! html/parsoid
8601 <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>
8602 !! end
8603
8604 !! test
8605 2. Interaction of linktrail and template encapsulation
8606 !! wikitext
8607 {{echo|Some [[Fool]]}}s
8608 !! html/php+tidy
8609 <p>Some <a href="/index.php?title=Fool&amp;action=edit&amp;redlink=1" class="new" title="Fool (page does not exist)">Fools</a>
8610 </p>
8611 !! html/parsoid
8612 <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>
8613 !! end
8614
8615 !! test
8616 3. Interaction of linktrail and template encapsulation
8617 !! wikitext
8618 {{echo|Some [[Fool]]s are '''bold and foolish'''}}
8619 !! html/php+tidy
8620 <p>Some <a href="/index.php?title=Fool&amp;action=edit&amp;redlink=1" class="new" title="Fool (page does not exist)">Fools</a> are <b>bold and foolish</b>
8621 </p>
8622 !! html/parsoid
8623 <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>
8624 !! end
8625
8626 !! article
8627 Söfnuður
8628 !! text
8629 Test.
8630 !! endarticle
8631
8632 !! test
8633 Internal link with is link prefix
8634 !! options
8635 language=is
8636 !! wikitext
8637 Aðrir mótmælenda[[söfnuður|söfnuðir]] og
8638 !! html
8639 <p>Aðrir <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a> og
8640 </p>
8641 !! end
8642
8643 !! article
8644 Mótmælendatrú
8645 !! text
8646 Test.
8647 !! endarticle
8648
8649 !! test
8650 Internal link with is link trail and link prefix
8651 !! options
8652 language=is
8653 !! wikitext
8654 [[mótmælendatrú|xxx]]ar
8655 [[mótmælendatrú]]ar
8656 mótmælenda[[söfnuður]]
8657 mótmælenda[[söfnuður|söfnuðir]]
8658 mótmælenda[[söfnuður|söfnuðir]]xxx
8659 !! html
8660 <p><a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">xxxar</a>
8661 <a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">mótmælendatrúar</a>
8662 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuður</a>
8663 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a>
8664 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðirxxx</a>
8665 </p>
8666 !! end
8667
8668 !! test
8669 Parsoid link trail escaping
8670 !! options
8671 parsoid=html2wt,html2html
8672 !! html/parsoid
8673 <p><a rel="mw:WikiLink" href="./Apple" title="Apple">apple</a>s</p>
8674 !! wikitext
8675 [[apple]]<nowiki/>s
8676 !! end
8677
8678 !! test
8679 Parsoid link prefix escaping
8680 !! options
8681 language=is
8682 parsoid=html2wt,html2html
8683 !! html/parsoid
8684 <p>Aðrir mótmælenda<a rel="mw:WikiLink" href="./Söfnuður" title="Söfnuður">söfnuður</a></p>
8685 !! wikitext
8686 Aðrir mótmælenda<nowiki/>[[söfnuður]]
8687 !! end
8688
8689 !! test
8690 Parsoid link bracket escaping
8691 !! options
8692 parsoid=html2wt,html2html
8693 !! html/parsoid
8694 <p><a rel="mw:WikiLink" href="./Test" title="Test">Test</a></p>
8695 <p>[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]</p>
8696 <p>[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]</p>
8697 <p>[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]</p>
8698 <p>[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]</p>
8699 <p>[[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]]</p>
8700 !! wikitext
8701 [[Test]]
8702
8703 [<nowiki/>[[Test]]]
8704
8705 [[[[Test]]]]
8706
8707 [[[<nowiki/>[[Test]]]]]
8708
8709 [[[[[[Test]]]]]]
8710
8711 [[[[[<nowiki/>[[Test]]]]]]]
8712 !! end
8713
8714 !! test
8715 Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved
8716 !! wikitext
8717 [[Foo| bar]]
8718
8719 [[Foo| ''bar'']]
8720
8721 [http://wp.org foo]
8722
8723 [http://wp.org ''foo'']
8724 !! html
8725 <p><a href="/wiki/Foo" title="Foo"> bar</a>
8726 </p><p><a href="/wiki/Foo" title="Foo"> <i>bar</i></a>
8727 </p><p><a rel="nofollow" class="external text" href="http://wp.org">foo</a>
8728 </p><p><a rel="nofollow" class="external text" href="http://wp.org"><i>foo</i></a>
8729 </p>
8730 !! end
8731
8732 !! test
8733 Parsoid: Scoped parsing should handle mixed transclusions and plain text
8734 !! wikitext
8735 [[Foo|{{echo|a}} b {{echo|c}}]]
8736 !! html/parsoid
8737 <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>
8738 !! end
8739
8740 !! test
8741 Link with angle bracket after anchor
8742 !! config
8743 wgFragmentMode=[ 'html5', 'legacy' ]
8744 !! wikitext
8745 [[Foo#<bar>]]
8746 !! html/php
8747 <p><a href="/wiki/Foo#&lt;bar&gt;" title="Foo">Foo#&lt;bar&gt;</a>
8748 </p>
8749 !! html/parsoid
8750 <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>
8751 !! end
8752
8753 !! test
8754 Link with angle bracket after anchor (legacy)
8755 !! config
8756 wgFragmentMode=[ 'legacy' ]
8757 !! wikitext
8758 [[Foo#<bar>]]
8759 !! html/php
8760 <p><a href="/wiki/Foo#.3Cbar.3E" title="Foo">Foo#&lt;bar&gt;</a>
8761 </p>
8762 !! end
8763
8764 ###
8765 ### Interwiki links (see maintenance/interwiki.sql)
8766 ###
8767
8768 !! test
8769 Inline interwiki link
8770 !! options
8771 parsoid=wt2html,wt2wt,html2html
8772 !! wikitext
8773 [[MeatBall:SoftSecurity]]
8774 !! html/php
8775 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
8776 </p>
8777 !! html/parsoid
8778 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a></p>
8779 !! end
8780
8781 !! test
8782 Inline interwiki link with empty title (T4372)
8783 !! options
8784 parsoid=wt2html,wt2wt,html2html
8785 !! wikitext
8786 [[MeatBall:]]
8787 !! html/php
8788 <p><a href="http://www.usemod.com/cgi-bin/mb.pl" class="extiw" title="meatball:">MeatBall:</a>
8789 </p>
8790 !! html/parsoid
8791 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?" title="meatball:">MeatBall:</a></p>
8792 !! end
8793
8794 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
8795 !! test
8796 Interwiki link encoding conversion (T3636)
8797 !! options
8798 parsoid=wt2html,wt2wt
8799 !! wikitext
8800 *[[Wikipedia:ro:Olteni&#0355;a]]
8801 *[[Wikipedia:ro:Olteni&#355;a]]
8802 !! html/php
8803 <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>
8804 <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>
8805
8806 !! html/php+tidy
8807 <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>
8808 <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>
8809 !! html/parsoid
8810 <ul>
8811 <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>
8812 <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>
8813 </ul>
8814 !! end
8815
8816 !! test
8817 Interwiki link with fragment (T4130)
8818 !! wikitext
8819 [[MeatBall:SoftSecurity#foo]]
8820 !! html
8821 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity#foo</a>
8822 </p>
8823 !! end
8824
8825 !! test
8826 Link scenarios with escaped fragments
8827 !! options
8828 title=[[Main Page]]
8829 !! config
8830 wgFragmentMode=[ 'html5', 'legacy' ]
8831 !! wikitext
8832 [[#Is this great?]]
8833 [[Foo#Is this great?]]
8834 [[meatball:Foo#Is this great?]]
8835 !! html/php
8836 <p><a href="#Is_this_great?">#Is this great?</a>
8837 <a href="/wiki/Foo#Is_this_great?" title="Foo">Foo#Is this great?</a>
8838 <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>
8839 </p>
8840 !! html/parsoid
8841 <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>
8842 <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>
8843 <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>
8844 !! end
8845
8846 !! test
8847 Link scenarios with escaped fragments (legacy)
8848 !! config
8849 wgFragmentMode=[ 'legacy' ]
8850 !! wikitext
8851 [[#Is this great?]]
8852 [[Foo#Is this great?]]
8853 [[meatball:Foo#Is this great?]]
8854 !! html/php
8855 <p><a href="#Is_this_great.3F">#Is this great?</a>
8856 <a href="/wiki/Foo#Is_this_great.3F" title="Foo">Foo#Is this great?</a>
8857 <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>
8858 </p>
8859 !! end
8860
8861 # Ideally the wikipedia: prefix here should be proto-relative too
8862 # [CSA]: this is kind of a bogus test, as the PHP parser test doesn't
8863 # define the 'en' prefix, and originally the test used 'wikipedia',
8864 # which isn't a localinterwiki prefix hence the links to the 'en:Foo'
8865 # article.
8866 !! test
8867 Different interwiki prefixes mapping to the same URL
8868 !! wikitext
8869 [[:en:Foo]]
8870
8871 [[:en:Foo|Foo]]
8872
8873 [[wikipedia:Foo]]
8874
8875 [[:wikipedia:Foo|Foo]]
8876
8877 [[wikipedia:en:Foo]]
8878
8879 [[:wikipedia:en:Foo]]
8880
8881 [[ wikiPEdia :Foo]]
8882 !! html/parsoid
8883 <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>
8884
8885 <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>
8886
8887 <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>
8888
8889 <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>
8890
8891 <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>
8892
8893 <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>
8894
8895 <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>
8896 !! end
8897
8898 !! test
8899 Interwiki links that cannot be represented in wiki syntax
8900 !! wikitext
8901 [[meatball:ok]]
8902 [[meatball:ok#foo|ok with fragment]]
8903 [[meatball:ok_as_well?|ok ending with ? mark]]
8904 [http://de.wikipedia.org/wiki/Foo?action=history has query]
8905 [http://de.wikipedia.org/wiki/#foo is just fragment]
8906
8907 !! html/php
8908 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?ok" class="extiw" title="meatball:ok">meatball:ok</a>
8909 <a href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" class="extiw" title="meatball:ok">ok with fragment</a>
8910 <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>
8911 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8912 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a>
8913 </p>
8914 !! html/parsoid
8915 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok" title="meatball:ok">meatball:ok</a>
8916 <a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" title="meatball:ok">ok with fragment</a>
8917 <a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok_as_well%3F" title="meatball:ok as well?">ok ending with ? mark</a>
8918 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8919 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a></p>
8920 !! end
8921
8922 !! test
8923 Interwiki links: trail
8924 !! wikitext
8925 [[wikipedia:Foo|Ba]]r
8926 !! html/php
8927 <p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
8928 </p>
8929 !! html/parsoid
8930 <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>
8931 !! end
8932
8933 !! test
8934 Local interwiki link
8935 !! options
8936 parsoid=wt2html,wt2wt,html2html
8937 !! wikitext
8938 [[local:Template:Foo]]
8939 !! html/php
8940 <p><a href="/wiki/Template:Foo" title="Template:Foo">local:Template:Foo</a>
8941 </p>
8942 !! html/parsoid
8943 <p><a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">local:Template:Foo</a></p>
8944 !! end
8945
8946 # Parsoid does not mark self-links, by design.
8947 !! test
8948 Local interwiki link: self-link to current page
8949 !! options
8950 title=[[Main Page]]
8951 parsoid=wt2html,wt2wt,html2html
8952 !! wikitext
8953 [[local:Main Page]]
8954 !! html/php
8955 <p><a class="mw-selflink selflink">local:Main Page</a>
8956 </p>
8957 !! html/parsoid
8958 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:Main Page</a></p>
8959 !! end
8960
8961 !! test
8962 Local interwiki link: prefix only (T66167)
8963 !! options
8964 parsoid=wt2html,wt2wt,html2html
8965 !! wikitext
8966 [[local:]]
8967 !! html/php
8968 <p><a href="/wiki/Main_Page" title="Main Page">local:</a>
8969 </p>
8970 !! html/parsoid
8971 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:</a></p>
8972 !! end
8973
8974 !! test
8975 Local interwiki link: with additional interwiki prefix (T63357)
8976 !! options
8977 parsoid=wt2html,wt2wt,html2html
8978 !! wikitext
8979 [[local:meatball:Hello]]
8980 !! html/php
8981 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Hello" class="extiw" title="meatball:Hello">local:meatball:Hello</a>
8982 </p>
8983 !! html/parsoid
8984 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?Hello" title="meatball:Hello">local:meatball:Hello</a></p>
8985 !! end
8986
8987 !! test
8988 Multiple local interwiki link prefixes
8989 !! wikitext
8990 [[local:local:local:local:mi:local:Foo]]
8991 !! options
8992 parsoid=wt2html,wt2wt,html2html
8993 !! html/php
8994 <p><a href="/wiki/Foo" title="Foo">local:local:local:local:mi:local:Foo</a>
8995 </p>
8996 !! html/parsoid
8997 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">local:local:local:local:mi:local:Foo</a></p>
8998 !! end
8999
9000 !! test
9001 Interwiki link with percent encoded target
9002 !! wikitext
9003 [[:es:Nueva Guip%C3%BAzcoa|Nueva Guipúzcoa]]
9004 !! html/php
9005 <p><a href="http://es.wikipedia.org/wiki/Nueva_Guip%C3%BAzcoa" class="extiw" title="es:Nueva Guipúzcoa">Nueva Guipúzcoa</a>
9006 </p>
9007 !! html/parsoid
9008 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Nueva%20Guipúzcoa" title="es:Nueva Guipúzcoa" data-parsoid='{"stx":"piped","a":{"href":"http://es.wikipedia.org/wiki/Nueva%20Guipúzcoa"},"sa":{"href":":es:Nueva Guip%C3%BAzcoa"},"isIW":true}'>Nueva Guipúzcoa</a></p>
9009 !! end
9010
9011 ###
9012 ### Interlanguage links
9013 ### Language links (so that searching for '### language' matches..)
9014 ###
9015
9016 !! test
9017 Interlanguage link
9018 !! wikitext
9019 Blah blah blah
9020 [[zh:Chinese]]
9021 !! html/php
9022 <p>Blah blah blah
9023 </p>
9024 !! html/parsoid
9025 <p>Blah blah blah</p>
9026 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9027 !! end
9028
9029 ## parsoid html2wt will lose the space variations
9030 !! test
9031 Interlanguage link with spacing
9032 !! options
9033 parsoid=wt2html,wt2wt,html2html
9034 !! wikitext
9035 Blah blah blah
9036 [[ zh : Chinese ]]
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" href="http://zh.wikipedia.org/wiki/Chinese"/>
9043 !! end
9044
9045 !! test
9046 Double interlanguage link
9047 !! wikitext
9048 Blah blah blah
9049 [[es:Spanish]]
9050 [[zh:Chinese]]
9051 !! html/php
9052 <p>Blah blah blah
9053 </p>
9054 !! html/parsoid
9055 <p>Blah blah blah</p>
9056 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
9057 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9058 !! end
9059
9060 ## parsoid html2wt will lose the space variations
9061 !! test
9062 Interlanguage link variations
9063 !! options
9064 parsoid=wt2html,wt2wt,html2html
9065 !! wikitext
9066 Blah blah blah
9067 [[ es :Spanish]]
9068 [[ ZH :Chinese]]
9069 [[es:Foo_bar]]
9070 !! html/php
9071 <p>Blah blah blah
9072 </p>
9073 !! html/parsoid
9074 <p>Blah blah blah</p>
9075 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish" />
9076 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese" />
9077 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar" />
9078 !! end
9079
9080 !! test
9081 Escaping of interlanguage links (T129218, T156308)
9082 !! wikitext
9083 Blah blah blah
9084 [[:es:Spanish]]
9085 [[ : zh : Chinese ]]
9086 !! html/php
9087 <p>Blah blah blah
9088 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
9089 <a href="http://zh.wikipedia.org/wiki/Chinese" class="extiw" title="zh:Chinese"> zh : Chinese </a>
9090 </p>
9091 !! html/parsoid
9092 <p>Blah blah blah
9093 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
9094 <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh : Chinese </a></p>
9095 !! end
9096
9097 !! test
9098 Multiple colons escaping interlanguage links
9099 !! options
9100 parsoid=wt2html
9101 !! wikitext
9102 [[:es:Spanish]]
9103 [[::es:Spanish]]
9104 [[:::es:Spanish]]
9105 !! html/php
9106 <p><a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
9107 [[::es:Spanish]]
9108 [[:::es:Spanish]]
9109 </p>
9110 !! html/parsoid
9111 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
9112 [[::es:Spanish]]
9113 [[:::es:Spanish]]</p>
9114 !! end
9115
9116 ## parsoid html2wt will normalize the space to _
9117 !! test
9118 Space and question mark encoding in interlanguage links (T95473)
9119 !! options
9120 parsoid=wt2html,wt2wt,html2html
9121 !! wikitext
9122 Blah blah blah
9123 [[es:Foo bar?]]
9124 !! html/php
9125 <p>Blah blah blah
9126 </p>
9127 !! html/parsoid
9128 <p>Blah blah blah</p>
9129 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar%3F" />
9130 !! end
9131
9132 !! test
9133 Interlanguage link, with prefix links
9134 !! options
9135 language=ln
9136 !! wikitext
9137 Blah blah blah
9138 [[zh:Chinese]]
9139 !! html/php
9140 <p>Blah blah blah
9141 </p>
9142 !! html/parsoid
9143 <p>Blah blah blah</p>
9144 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9145 !! end
9146
9147 !! test
9148 Double interlanguage link, with prefix links (T10897)
9149 !! options
9150 language=ln
9151 !! wikitext
9152 Blah blah blah
9153 [[es:Spanish]]
9154 [[zh:Chinese]]
9155 !! html/php
9156 <p>Blah blah blah
9157 </p>
9158 !! html/parsoid
9159 <p>Blah blah blah</p>
9160 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
9161 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9162 !! end
9163
9164 !! test
9165 "Extra" interlanguage links (T34189 / gerrit 111390)
9166 !! wikitext
9167 Blah blah blah
9168 [[mul:Article]]
9169 !! html/php
9170 <p>Blah blah blah
9171 </p>
9172 !! html/parsoid
9173 <p>Blah blah blah</p>
9174 <link rel="mw:PageProp/Language" title="Multilingual" href="http://wikisource.org/wiki/Article"/>
9175 !! end
9176
9177 ## PHP parser tests script needs an update
9178 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
9179 !! test
9180 Language links render as inline links if $wgInterwikiMagic=false
9181 !! options
9182 wgInterwikiMagic=false
9183 parsoid=wt2html,wt2wt,html2html
9184 !! wikitext
9185 Blah blah blah
9186 [[zh:Chinese]]
9187 !! html/parsoid
9188 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
9189 !! end
9190
9191 ## PHP parser tests script needs an update
9192 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
9193 !! test
9194 Language links render as inline links in the Talk namespace
9195 !! options
9196 title=Talk:Foo
9197 parsoid=wt2html,wt2wt,html2html
9198 !! wikitext
9199 Blah blah blah
9200 [[zh:Chinese]]
9201 !! html/parsoid
9202 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
9203 !! end
9204
9205 !! test
9206 Parsoid-specific test: Wikilinks with &nbsp; should RT properly
9207 !! options
9208 language=ln
9209 !! wikitext
9210 [[WW&nbsp;II]]
9211 !! html
9212 <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>
9213 </p>
9214 !! end
9215
9216 !! test
9217 Parsoid T55221: Wikilinks should be properly entity-escaped
9218 !! options
9219 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
9220 !! html/parsoid
9221 <p>He&amp;nbsp;llo <a href="./Foo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9222 <p>He&amp;nbsp;llo <a href="./He&amp;nbsp;llo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9223 !! wikitext
9224 He&amp;nbsp;llo [[Foo|He&amp;nbsp;llo]]
9225
9226 He&amp;nbsp;llo He&amp;nbsp;llo
9227 !! html/php
9228 <p>He&amp;nbsp;llo <a href="/wiki/Foo" title="Foo">He&amp;nbsp;llo</a>
9229 </p><p>He&amp;nbsp;llo He&amp;nbsp;llo
9230 </p>
9231 !! end
9232
9233 # html2wt will fail because of title normalization without data-parsoid
9234 !! test
9235 Parsoid: handle constructor well
9236 !! options
9237 parsoid=wt2html,wt2wt
9238 !! wikitext
9239 [[constructor]]
9240
9241 [[constructor:foo]]
9242 !! html/php
9243 <p><a href="/index.php?title=Constructor&amp;action=edit&amp;redlink=1" class="new" title="Constructor (page does not exist)">constructor</a>
9244 </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>
9245 </p>
9246 !! html/parsoid
9247 <p><a rel="mw:WikiLink" href="./Constructor" title="Constructor" data-parsoid='{"stx":"simple","a":{"href":"./Constructor"},"sa":{"href":"constructor"}}'>constructor</a></p>
9248
9249 <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>
9250 !! end
9251
9252 !! test
9253 Template parameter named "constructor"
9254 !! wikitext
9255 {{echo| constructor = |hi}}
9256 !! html/parsoid
9257 <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>
9258 !! end
9259
9260 !! article
9261 ko:
9262 !! text
9263 Test.
9264 !! endarticle
9265
9266 # Note that `ko` isn't a known interlanguage prefix
9267 !! test
9268 Parsoid: recognize interlanguage links without a target page
9269 !! options
9270 ill
9271 !! wikitext
9272 [[es:]]
9273
9274 [[ko:]]
9275 !! html/php
9276 es:
9277 !! html/parsoid
9278 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/"/>
9279
9280 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9281 !! end
9282
9283 # Note that `ko` isn't a known interwiki prefix
9284 !! test
9285 Parsoid: recognize interwiki links without a target page
9286 !! options
9287 parsoid=wt2html,wt2wt,html2html
9288 !! wikitext
9289 [[:es:]]
9290
9291 [[:ko:]]
9292 !! html/php
9293 <p><a href="http://es.wikipedia.org/wiki/" class="extiw" title="es:">es:</a>
9294 </p><p><a href="/wiki/Ko:" title="Ko:">ko:</a>
9295 </p>
9296 !! html/parsoid
9297 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/" title="es:">es:</a></p>
9298 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9299 !! end
9300
9301 !! test
9302 Handle interwiki links pointing to the current wiki as plain wiki links (T47209)
9303 !! wikitext
9304 [[mi:Foo]]
9305 !! html/php
9306 <p><a href="/wiki/Foo" title="Foo">mi:Foo</a>
9307 </p>
9308 !! html/parsoid
9309 <p><a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo"},"sa":{"href":"mi:Foo"}}'>mi:Foo</a></p>
9310 !! end
9311
9312 !! test
9313 Interlanguage link with preceding local interwiki link (T70085)
9314 !! options
9315 parsoid=wt2html,wt2wt,html2html
9316 !! wikitext
9317 Blah blah blah
9318 [[local:es:Spanish]]
9319 !! html/php
9320 <p>Blah blah blah
9321 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">local:es:Spanish</a>
9322 </p>
9323 !! html/parsoid
9324 <p>Blah blah blah
9325 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">local:es:Spanish</a></p>
9326 !! end
9327
9328 !! test
9329 Looks like an interlanguage link, but is actually a local interwiki
9330 !! options
9331 parsoid=wt2html,wt2wt,html2html
9332 !! wikitext
9333 Blah blah blah
9334 [[mi:Template:Foo]]
9335 !! html/php
9336 <p>Blah blah blah
9337 <a href="/wiki/Template:Foo" title="Template:Foo">mi:Template:Foo</a>
9338 </p>
9339 !! html/parsoid
9340 <p>Blah blah blah
9341 <a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">mi:Template:Foo</a></p>
9342 !! end
9343
9344 ###
9345 ### Redirects, Parsoid-only
9346 ###
9347
9348 !! test
9349 1. Simple redirect to page
9350 !! wikitext
9351 #REDIRECT [[Main Page]]
9352 !! html/parsoid
9353 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9354 !! end
9355
9356 !! test
9357 2. Other redirect variants
9358 !! wikitext
9359 #REDIRECT [[Main_Page]]
9360 !! html/parsoid
9361 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Main_Page"},"sa":{"href":"Main_Page"}}'/>
9362 !! end
9363
9364 # Not a valid redirect in PHP (although perhaps it was, once upon a time)
9365 # This tests the Parsoid bail-out code.
9366 !! test
9367 3. Other redirect variants
9368 !! options
9369 parsoid=wt2html
9370 !! wikitext
9371 #REDIRECT [[<nowiki>[[Bar]]</nowiki>]]
9372 !! html/parsoid
9373 <ol><li>REDIRECT [[<span typeof="mw:Nowiki">[[Bar]]</span>]]</li></ol>
9374 !! end
9375
9376 !! test
9377 4. Redirect to a templated destination
9378 !! wikitext
9379 #REDIRECT [[{{echo|Foo}}bar]]
9380 !! html/parsoid
9381 <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"}]]}'/>
9382 !! end
9383
9384 !! test
9385 Empty redirect
9386 !! options
9387 parsoid=wt2html,wt2wt
9388 !! wikitext
9389 #REDIRECT [[]]
9390 !! html/parsoid
9391 <ol>
9392 <li>REDIRECT [[]]</li></ol>
9393 !! end
9394
9395 !! test
9396 Optional colon in #REDIRECT
9397 !! options
9398 # the colon is archaic syntax. we support it for wt2html, but we
9399 # don't care that it roundtrips back to the modern syntax.
9400 parsoid=wt2html,html2html
9401 !! wikitext
9402 #REDIRECT:[[Main Page]]
9403 !! html/parsoid
9404 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9405 !! end
9406
9407 !! test
9408 Whitespace in #REDIRECT with optional colon
9409 !! options
9410 # the colon and gratuitous whitespace is archaic syntax. we support
9411 # it for wt2html, but we don't care that it roundtrips back to the
9412 # modern syntax (without extra whitespace)
9413 parsoid=wt2html,html2html
9414 !! wikitext
9415
9416 #REDIRECT
9417 :
9418 [[Main Page]]
9419 !! html/parsoid
9420 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9421 !! end
9422
9423 !! test
9424 Piped link in #REDIRECT
9425 !! options
9426 # content after piped link is ignored. we support this syntax,
9427 # but don't care that the piped link is lost when we roundtrip this.
9428 parsoid=wt2html
9429 !! wikitext
9430 #REDIRECT [[Main Page|bar]]
9431 !! html/parsoid
9432 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9433 !! end
9434
9435 !! test
9436 Redirect to category (T104502)
9437 !! options
9438 parsoid=wt2html,wt2wt
9439 !! wikitext
9440 #REDIRECT [[Category:Foo]]
9441 !! html/parsoid
9442 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9443 !! end
9444
9445 !! test
9446 Redirect to category with URL encoding (T104502)
9447 !! options
9448 parsoid=wt2html
9449 !! wikitext
9450 #REDIRECT [[Category%3AFoo]]
9451 !! html/parsoid
9452 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9453 !! end
9454
9455 !! test
9456 Redirect to category page
9457 !! wikitext
9458 #REDIRECT [[:Category:Foo]]
9459 !! html/parsoid
9460 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9461 !! end
9462
9463 !! test
9464 Redirect to image page (1)
9465 !! wikitext
9466 #REDIRECT [[File:Wiki.png]]
9467 !! html/parsoid
9468 <link rel="mw:PageProp/redirect" href="./File:Wiki.png"/>
9469 !! end
9470
9471 !! test
9472 Redirect to image page (2)
9473 !! wikitext
9474 #REDIRECT [[Image:Wiki.png]]
9475 !! html/parsoid
9476 <link rel="mw:PageProp/redirect" href="./File:Wiki.png" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./File:Wiki.png"},"sa":{"href":"Image:Wiki.png"}}'/>
9477 !! end
9478
9479 # html2wt disabled because wts serializes as "#REDIRECT [[:en:File:Wiki.png]]"
9480 # Next test confirms this.
9481 !! test
9482 Redirect to language (1) (T104918)
9483 !! options
9484 parsoid=wt2html,wt2wt,html2html
9485 !! wikitext
9486 #REDIRECT [[en:File:Wiki.png]]
9487 !! html/parsoid
9488 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9489 !! end
9490
9491 !! test
9492 Redirect to language (2) (T104918)
9493 !! wikitext
9494 #REDIRECT [[:en:File:Wiki.png]]
9495 !! html/parsoid
9496 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9497 !! end
9498
9499 !! test
9500 Redirect to interwiki (T104918)
9501 !! wikitext
9502 #REDIRECT [[meatball:File:Wiki.png]]
9503 !! html/parsoid
9504 <link rel="mw:PageProp/redirect" href="http://www.usemod.com/cgi-bin/mb.pl?File:Wiki.png"/>
9505 !! end
9506
9507 !! test
9508 Non-English #REDIRECT
9509 !! options
9510 language=is
9511 !! wikitext
9512 #TILVÍSUN [[Main Page]]
9513 !! html/parsoid
9514 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#TILVÍSUN ","a":{"href":"./Main_Page"},"sa":{"href":"Main Page"}}'/>
9515 !! end
9516
9517 !! test
9518 Redirect syntax under text isn't considered a redirect
9519 !! wikitext
9520 some text
9521
9522 #redirect [[Main Page]]
9523 !! html/parsoid
9524 <p>some text</p>
9525 <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>
9526 !! end
9527
9528 !! test
9529 New redirect
9530 !! options
9531 parsoid=html2wt
9532 !! html/parsoid
9533 <p>Foo<link rel="mw:PageProp/redirect" href="./Foo"/></p>
9534 !! wikitext
9535 #REDIRECT [[Foo]]
9536 Foo
9537 !! end
9538
9539 !! test
9540 Redirect followed by block on the same line
9541 !! options
9542 parsoid=wt2html
9543 !! wikitext
9544 #REDIRECT [[Main Page]]<!-- haha -->==hi==
9545 !! html/parsoid
9546 <link rel="mw:PageProp/redirect" href="./Main_Page"/><!-- haha --><h2 id="hi">hi</h2>
9547 !! end
9548
9549 !! test
9550 Redirect followed by a newline
9551 !! wikitext
9552 #REDIRECT [[Main Page]]
9553 A newline
9554 !! html/parsoid
9555 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9556 <p>A newline</p>
9557 !! end
9558
9559 !! test
9560 Redirect followed by multiple newlines
9561 !! wikitext
9562 #REDIRECT [[Main Page]]
9563
9564
9565 A newline
9566 !! html/parsoid
9567 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9568
9569 <p><br/>
9570 A newline</p>
9571 !! end
9572
9573 !! test
9574 Drop duplicate redirects
9575 !! options
9576 parsoid=html2wt
9577 !! html/parsoid
9578 <link rel="mw:PageProp/redirect" href="./Foo"/>
9579 <link rel="mw:PageProp/redirect" href="./Bar"/>
9580 <link rel="mw:PageProp/redirect" href="./Baz"/>
9581 !! wikitext
9582 #REDIRECT [[Foo]]
9583 !! end
9584
9585 ##
9586 ## XHTML tidiness
9587 ###
9588
9589 !! test
9590 <br> to <br />
9591 !! wikitext
9592 1<br>2<br />3
9593 !! html
9594 <p>1<br />2<br />3
9595 </p>
9596 !! end
9597
9598 !! test
9599 Broken br tag sanitization
9600 !! wikitext
9601 </br>
9602 !! html/php
9603 <p>&lt;/br&gt;
9604 </p>
9605 !! end
9606
9607 # TODO: Fix html2html mode (T53055)!
9608 !! test
9609 Parsoid: Broken br tag recognition
9610 !! options
9611 parsoid=wt2html
9612 !! wikitext
9613 </br>
9614
9615 <br/ >
9616 !! html+tidy
9617 <p><br />
9618 </p><p><br />
9619 </p>
9620 !! end
9621
9622 !! test
9623 Incorrecly removing closing slashes from correctly formed XHTML
9624 !! wikitext
9625 <br style="clear:both;" />
9626 !! html
9627 <p><br style="clear:both;" />
9628 </p>
9629 !! end
9630
9631 !! test
9632 Failing to transform badly formed HTML into correct XHTML
9633 !! wikitext
9634 <br style="clear: left;">
9635 <br style="clear: right;">
9636 <br style="clear: both;">
9637 !! html
9638 <p><br style="clear: left;" />
9639 <br style="clear: right;" />
9640 <br style="clear: both;" />
9641 </p>
9642 !!end
9643
9644 ## FIXME: Is Parsoid's acceptance of self-closing html-tags
9645 ## a feature or a bug? See https://phabricator.wikimedia.org/T76962
9646 !! test
9647 Handling html with a div self-closing tag
9648 !! wikitext
9649 <div title />
9650 <div title/>
9651 <div title/ >
9652 <div title=bar />
9653 <div title=bar/>
9654 <div title=bar/ >
9655 !! html/php
9656 <p>&lt;div title /&gt;
9657 &lt;div title/&gt;
9658 </p>
9659 <div>
9660 <p>&lt;div title=bar /&gt;
9661 &lt;div title=bar/&gt;
9662 </p>
9663 <div title="bar/"></div>
9664 </div>
9665
9666 !! html/parsoid
9667 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9668 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9669 <div title="" data-parsoid='{"stx":"html","autoInsertedEnd":true}'>
9670 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9671 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9672 <div title="bar/" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></div></div>
9673 !! end
9674
9675 !! test
9676 Elements with solidus in various attribute positions
9677 !! options
9678 parsoid=wt2html,html2html
9679 !! wikitext
9680 <div cla/ss="123">ha</div>
9681
9682 <div / class="123">ha</div>
9683
9684 <div class= / "123">ha</div>
9685 !! html/php+tidy
9686 <div>ha</div>
9687 <div class="123">ha</div>
9688 <div class="/">ha</div>
9689 !! html/parsoid
9690 <div data-parsoid='{"stx":"html","a":{"cla":null,"ss":null},"sa":{"cla":"","ss":"123"}}'>ha</div>
9691
9692 <div class="123" data-parsoid='{"stx":"html"}'>ha</div>
9693
9694 <div class="/" data-parsoid='{"stx":"html","a":{"\"123\"":null},"sa":{"\"123\"":""}}'>ha</div>
9695 !! end
9696
9697 !! test
9698 Handling html with a br self-closing tag
9699 !! wikitext
9700 <br title />
9701 <br title/>
9702 <br title/ >
9703 <br title=bar />
9704 <br title=bar/>
9705 <br title=bar/ >
9706 !! html/php
9707 <p><br title="" />
9708 <br title="" />
9709 <br />
9710 <br title="bar" />
9711 <br title="bar" />
9712 <br title="bar/" />
9713 </p>
9714 !! html/parsoid
9715 <p><br title="" />
9716 <br title="" />
9717 <br title="" />
9718 <br title="bar" />
9719 <br title="bar" />
9720 <br title="bar/" />
9721 </p>
9722 !! end
9723
9724 !! test
9725 Horizontal ruler (should it add that extra space?)
9726 !! wikitext
9727 <hr>
9728 <hr >
9729 foo <hr
9730 > bar
9731 !! html+tidy
9732 <hr />
9733 <hr /><p>
9734 foo </p><hr /><p> bar
9735 </p>
9736 !! end
9737
9738 !! test
9739 Horizontal ruler -- 4+ dashes render hr
9740 !! wikitext
9741 ----
9742 !! html
9743 <hr />
9744
9745 !! end
9746
9747 !! test
9748 Horizontal ruler -- eats additional dashes on the same line
9749 !! wikitext
9750 ---------
9751 !! html
9752 <hr />
9753
9754 !! end
9755
9756 !! test
9757 Horizontal ruler -- does not collapse dashes on consecutive lines
9758 !! wikitext
9759 ----
9760 ----
9761 !! html
9762 <hr />
9763 <hr />
9764
9765 !! end
9766
9767 !! test
9768 Horizontal ruler -- <4 dashes render as plain text
9769 !! wikitext
9770 ---
9771 !! html
9772 <p>---
9773 </p>
9774 !! end
9775
9776 !! test
9777 Horizontal ruler -- Supports content following dashes on same line
9778 !! wikitext
9779 ---- Foo
9780 !! html
9781 <hr /> Foo
9782
9783 !! html+tidy
9784 <hr /><p> Foo
9785 </p>
9786 !! end
9787
9788 ###
9789 ### Block-level elements
9790 ###
9791 !! test
9792 Common list
9793 !! wikitext
9794 *Common list
9795 *item 2
9796 *item 3
9797 !! html
9798 <ul><li>Common list</li>
9799 <li>item 2</li>
9800 <li>item 3</li></ul>
9801
9802 !! end
9803
9804 !! test
9805 Numbered list
9806 !! wikitext
9807 #Numbered list
9808 #item 2
9809 #item 3
9810 !! html
9811 <ol><li>Numbered list</li>
9812 <li>item 2</li>
9813 <li>item 3</li></ol>
9814
9815 !! end
9816
9817 # the switch from level 3 to ordered should not introduce a newline between
9818 !! test
9819 Mixed list
9820 !! wikitext
9821 *Mixed list
9822 *#with numbers
9823 **and bullets
9824 *#and numbers
9825 *bullets again
9826 **bullet level 2
9827 ***bullet level 3
9828 ***#Number on level 4
9829 **bullet level 2
9830 **#Number on level 3
9831 **#Number on level 3
9832 *#number level 2
9833 *Level 1
9834 ***Level 3
9835 #**Level 3, but ordered
9836 !! html
9837 <ul><li>Mixed list
9838 <ol><li>with numbers</li></ol>
9839 <ul><li>and bullets</li></ul>
9840 <ol><li>and numbers</li></ol></li>
9841 <li>bullets again
9842 <ul><li>bullet level 2
9843 <ul><li>bullet level 3
9844 <ol><li>Number on level 4</li></ol></li></ul></li>
9845 <li>bullet level 2
9846 <ol><li>Number on level 3</li>
9847 <li>Number on level 3</li></ol></li></ul>
9848 <ol><li>number level 2</li></ol></li>
9849 <li>Level 1
9850 <ul><li><ul><li>Level 3</li></ul></li></ul></li></ul>
9851 <ol><li><ul><li><ul><li>Level 3, but ordered</li></ul></li></ul></li></ol>
9852
9853 !! end
9854
9855 !! test
9856 1. Nested mixed wikitext and html list
9857 !! wikitext
9858 *hi
9859 *<ul><li>ho</li></ul>
9860 *hi
9861 **ho
9862 !! html/php
9863 <ul><li>hi</li>
9864 <li><ul><li>ho</li></ul></li>
9865 <li>hi
9866 <ul><li>ho</li></ul></li></ul>
9867
9868 !! html/parsoid
9869 <ul><li>hi</li>
9870 <li><ul data-parsoid='{"stx":"html"}'><li data-parsoid='{"stx":"html"}'>ho</li></ul></li>
9871 <li>hi
9872 <ul><li>ho</li></ul></li></ul>
9873 !! end
9874
9875 !! test
9876 2. Nested mixed wikitext and html list (incompatible)
9877 !! wikitext
9878 ;hi
9879 :{{echo|<li>ho</li>}}
9880 !! html/php
9881 <dl><dt>hi</dt>
9882 <dd><li>ho</li></dd></dl>
9883
9884 !! html/parsoid
9885 <dl><dt>hi</dt>
9886 <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>
9887 !! end
9888
9889 !! test
9890 Nested lists 1
9891 !! wikitext
9892 *foo
9893 **bar
9894 !! html
9895 <ul><li>foo
9896 <ul><li>bar</li></ul></li></ul>
9897
9898 !! end
9899
9900 !! test
9901 Nested lists 2
9902 !! wikitext
9903 **foo
9904 *bar
9905 !! html
9906 <ul><li><ul><li>foo</li></ul></li>
9907 <li>bar</li></ul>
9908
9909 !! end
9910
9911 !! test
9912 Nested lists 3 (first element empty)
9913 !! wikitext
9914 *
9915 **bar
9916 !! html
9917 <ul><li>
9918 <ul><li>bar</li></ul></li></ul>
9919
9920 !! end
9921
9922 !! test
9923 Nested lists 4 (first element empty)
9924 !! wikitext
9925 **
9926 *bar
9927 !! html
9928 <ul><li><ul><li></li></ul></li>
9929 <li>bar</li></ul>
9930
9931 !! end
9932
9933 !! test
9934 Nested lists 5 (both elements empty)
9935 !! wikitext
9936 **
9937 *
9938 !! html
9939 <ul><li><ul><li></li></ul></li>
9940 <li></li></ul>
9941
9942 !! end
9943
9944 !! test
9945 Nested lists 6 (both elements empty)
9946 !! wikitext
9947 *
9948 **
9949 !! html
9950 <ul><li>
9951 <ul><li></li></ul></li></ul>
9952
9953 !! end
9954
9955 !! test
9956 Nested lists 7 (skip initial nesting levels)
9957 !! wikitext
9958 ***foo
9959 !! html
9960 <ul><li><ul><li><ul><li>foo</li></ul></li></ul></li></ul>
9961
9962 !! end
9963
9964 !! test
9965 Nested lists 8 (multiple nesting transitions)
9966 !! wikitext
9967 *foo
9968 ***bar
9969 **baz
9970 *boo
9971 !! html
9972 <ul><li>foo
9973 <ul><li><ul><li>bar</li></ul></li>
9974 <li>baz</li></ul></li>
9975 <li>boo</li></ul>
9976
9977 !! end
9978
9979 # XXX this test should be moved to citeParserTests, since it depends
9980 # on the Cite extension, which is "built in" to Parsoid.
9981 !! test
9982 Nested lists 9 (extension interaction)
9983 !! wikitext
9984 *<references />
9985 !! html/php+tidy-DISABLED
9986 <ul><li class="mw-empty-elt"></li></ul>
9987 !! html/parsoid
9988 <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>
9989 !! end
9990
9991 !! test
9992 1. Lists with start-of-line-transparent tokens before bullets: Comments
9993 !! wikitext
9994 *foo
9995 *<!--cmt-->bar
9996 <!--cmt-->*baz
9997 !! html
9998 <ul><li>foo</li>
9999 <li>bar</li>
10000 <li>baz</li></ul>
10001
10002 !! end
10003
10004 !! test
10005 Nested lists 10 (list and span siblings: wt2wt regression)
10006 !! wikitext
10007 *a <span>x</span>
10008 **b <span>y</span>
10009 !! html/parsoid
10010 <ul><li>a <span>x</span>
10011 <ul><li>b <span>y</span></li></ul></li></ul>
10012 !! end
10013
10014 !! test
10015 2. Lists with start-of-line-transparent tokens before bullets: Template close
10016 !! wikitext
10017 *foo {{echo|bar
10018 }}*baz
10019 !! html
10020 <ul><li>foo bar</li>
10021 <li>baz</li></ul>
10022
10023 !! end
10024
10025 !! test
10026 List items are not parsed correctly following a <pre> block (T2785)
10027 !! wikitext
10028 *<pre>foo</pre>
10029 *<pre>bar</pre>
10030 *zar
10031 !! html/php
10032 <ul><li><pre>foo</pre></li>
10033 <li><pre>bar</pre></li>
10034 <li>zar</li></ul>
10035
10036 !! html/parsoid
10037 <ul><li><pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre></li>
10038 <li><pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"bar"}}'>bar</pre></li>
10039 <li>zar</li></ul>
10040 !! end
10041
10042 # FIXME: Might benefit from a html/parsoid since this has a template
10043 !! test
10044 List items from template
10045 !! wikitext
10046
10047 {{inner list}}
10048 *item 2
10049
10050 *item 0
10051 {{inner list}}
10052 *item 2
10053
10054 *item 0
10055 *notSOL{{inner list}}
10056 *item 2
10057 !! html
10058 <ul><li>item 1</li>
10059 <li>item 2</li></ul>
10060 <ul><li>item 0</li>
10061 <li>item 1</li>
10062 <li>item 2</li></ul>
10063 <ul><li>item 0</li>
10064 <li>notSOL</li>
10065 <li>item 1</li>
10066 <li>item 2</li></ul>
10067
10068 !! end
10069
10070 !! test
10071 List interrupted by empty line or heading
10072 !! wikitext
10073 *foo
10074
10075 **bar
10076 ==A heading==
10077 *Another list item
10078 !! html
10079 <ul><li>foo</li></ul>
10080 <ul><li><ul><li>bar</li></ul></li></ul>
10081 <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>
10082 <ul><li>Another list item</li></ul>
10083
10084 !!end
10085
10086 !! test
10087 Multiple list tags generated by templates
10088 !! wikitext
10089 {{echo|<li>}}a
10090 {{echo|<li>}}b
10091 {{echo|<li>}}c
10092 !! html
10093 <li>a
10094 <li>b
10095 <li>c</li>
10096 </li>
10097 </li>
10098
10099
10100 !! html+tidy
10101 <li>a
10102 </li><li>b
10103 </li><li>c
10104 </li>
10105 !! html/parsoid
10106 <li about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","autoInsertedEnd":true,"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;li>"}},"i":0}},"a"]}'>a</li>
10107 <li about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"stx":"html","autoInsertedEnd":true,"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;li>"}},"i":0}},"b"]}'>b</li>
10108 <li about="#mwt3" typeof="mw:Transclusion" data-parsoid='{"stx":"html","autoInsertedEnd":true,"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;li>"}},"i":0}},"c"]}'>c</li>
10109 !! end
10110
10111 !! test
10112 Multiple newlines in between HTML list items don't induce paragraph wrapping
10113 !! wikitext
10114 <ul>
10115 <li>hi</li>
10116
10117
10118
10119
10120 <li>ho</li>
10121 </ul>
10122
10123 <dl>
10124 <dt>hi</dt>
10125 <dd>ho<div>123</div>
10126 </dd>
10127
10128
10129 </dl>
10130 !! html/php+tidy
10131 <ul>
10132 <li>hi</li>
10133
10134
10135
10136
10137 <li>ho</li>
10138 </ul>
10139 <dl>
10140 <dt>hi</dt>
10141 <dd>ho<div>123</div>
10142 </dd>
10143
10144
10145 </dl>
10146 !! end
10147
10148 !!test
10149 Single-comment whitespace lines dont break lists, and neither do multi-comment whitespace lines
10150 !! wikitext
10151 *a
10152 <!--This line will NOT split the list-->
10153 *b
10154 <!--This line will NOT split the list either-->
10155 *c
10156 <!--foo--> <!----> <!--This line NOT split the list either-->
10157 *d
10158 !! html
10159 <ul><li>a</li>
10160 <li>b</li>
10161 <li>c</li>
10162 <li>d</li></ul>
10163
10164 !!end
10165
10166 !!test
10167 Replacing whitespace with tabs still doesn't break the list (gerrit 78327)
10168 !! wikitext
10169 *a
10170 <!--This line will NOT split the list-->
10171 *b
10172 <!--This line will NOT split the list either-->
10173 *c
10174 <!--foo--> <!----> <!--This line NOT split the list
10175 either-->
10176 *d
10177 !! html
10178 <ul><li>a</li>
10179 <li>b</li>
10180 <li>c</li>
10181 <li>d</li></ul>
10182
10183 !!end
10184
10185 # FIXME: Parsoid has a dedicated DOM pass to mimic this Tidy-specific li-hack
10186 # That pass could possibly be removed.
10187 !!test
10188 Test the li-hack (a hack from Tidy days, but doesn't work as advertised with Remex)
10189 !!options
10190 parsoid=wt2html,wt2wt
10191 !! wikitext
10192 *foo
10193 *<li>li-hack
10194 *{{echo|<li>templated li-hack}}
10195 *<!--foo--><li> unsupported li-hack with preceding comments
10196
10197 <ul>
10198 <li><li>not a li-hack
10199 </li>
10200 </ul>
10201 !! html+tidy
10202 <ul><li>foo</li>
10203 <li class="mw-empty-elt"></li><li>li-hack</li>
10204 <li class="mw-empty-elt"></li><li>templated li-hack</li>
10205 <li class="mw-empty-elt"></li><li> unsupported li-hack with preceding comments</li></ul>
10206 <ul>
10207 <li class="mw-empty-elt"></li><li>not a li-hack
10208 </li>
10209 </ul>
10210 !! html/parsoid
10211 <ul><li> foo</li>
10212 <li data-parsoid='{"stx":"html","autoInsertedEnd":true,"liHackSrc":"*"}'>li-hack</li>
10213 <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>
10214 <li data-parsoid='{"autoInsertedEnd":true}'><!--foo--></li><li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>unsupported li-hack with preceding comments</li></ul>
10215
10216 <ul data-parsoid='{"stx":"html"}'>
10217 <li class="mw-empty-elt" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></li><li data-parsoid='{"stx":"html"}'>not a li-hack
10218 </li>
10219 </ul>
10220
10221 !!end
10222
10223 !! test
10224 Parsoid: Make sure nested lists are serialized on their own line even if HTML contains no newlines
10225 !! wikitext
10226 #foo
10227 ##bar
10228
10229 *foo
10230 **bar
10231
10232 :foo
10233 ::bar
10234 !! html/php+tidy
10235 <ol><li>foo
10236 <ol><li>bar</li></ol></li></ol>
10237 <ul><li>foo
10238 <ul><li>bar</li></ul></li></ul>
10239 <dl><dd>foo
10240 <dl><dd>bar</dd></dl></dd></dl>
10241 !! html/parsoid
10242 <ol>
10243 <li>foo<ol>
10244 <li>bar</li>
10245 </ol></li>
10246 </ol><ul>
10247 <li>foo<ul>
10248 <li>bar</li>
10249 </ul></li>
10250 </ul><dl>
10251 <dd>foo<dl>
10252 <dd>bar</dd>
10253 </dl></dd>
10254 </dl>
10255 !! end
10256
10257 !! test
10258 Parsoid: Test of whitespace serialization with Templated bullets
10259 !! options
10260 parsoid=wt2html
10261 !! wikitext
10262 * {{bullet}}
10263 !! html/parsoid
10264 <ul>
10265 <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>
10266 </ul>
10267 !! end
10268
10269 # ------------------------------------------------------------------------
10270 # The next set of tests are about Parsoid's ability to handle badly nested
10271 # tags (parse, minimize scope of fixup, and roundtrip back)
10272 # ------------------------------------------------------------------------
10273
10274 # Remex and Parsoid output stems from list handling diffs because Parsoid & PHP parser.
10275 # Parsoid's list handling is more aware of block structure.
10276 !! test
10277 Unbalanced closing block tags break a list
10278 !! wikitext
10279 <div>
10280 *a</div><div>
10281 *b</div>
10282 !! html+tidy
10283 <div>
10284 <ul><li>a</li></ul></div><div>
10285 <li>b</li></div>
10286 !! html/parsoid
10287 <div><ul>
10288 <li>a</li>
10289 </ul></div>
10290 <div><ul>
10291 <li>b</li>
10292 </ul></div>
10293 !! end
10294
10295 !! test
10296 Unbalanced closing non-block tags don't break a list
10297 !! options
10298 parsoid=wt2html,html2html
10299 !! wikitext
10300 <span>
10301 *a</span><span>
10302 *b</span>
10303 !! html/php+tidy
10304 <p><span>
10305 </span></p>
10306 <ul><li>a<span></span></li>
10307 <li>b</li></ul>
10308 !! html/parsoid
10309 <p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'></span></p>
10310 <ul><li>a<span data-parsoid='{"stx":"html","autoInsertedEnd":true}'></span></li>
10311 <li>b</li></ul>
10312 !! end
10313
10314 # Parsoid does some post-dom-building cleanup
10315 # which is why its output differs from Remex.
10316 !! test
10317 Unclosed formatting tags that straddle lists are closed and reopened
10318 !! options
10319 parsoid=wt2html,wt2wt,html2html
10320 !! wikitext
10321 #<s> a
10322 #b </s>
10323 !! html/php+tidy
10324 <ol><li><s> a</s></li><s>
10325 </s><li><s>b </s></li></ol>
10326 !! html/parsoid
10327 <ol><li><s> a</s></li>
10328 <li><s>b </s></li></ol>
10329 !! end
10330
10331 # Output is ugly because of all the misnested tag fixups.
10332 !! test
10333 1. List embedded in a formatting tag
10334 !! wikitext
10335 <small>
10336 *foo
10337 </small>
10338 !! html/php+tidy
10339 <p><small>
10340 </small></p><small><ul><li>foo</li></ul></small><small></small><p><small></small>
10341 </p>
10342 !! html/parsoid
10343 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p><small data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
10344 <ul><li data-parsoid='{}'>foo</li></ul></small>
10345 <p><small data-parsoid='{"stx":"html","autoInsertedStart":true}'></small></p>
10346 !! end
10347
10348 # Output is ugly because of all the misnested tag fixups.
10349 !! test
10350 2. List embedded in a formatting tag in a misnested way
10351 !! wikitext
10352 <small>
10353 *a
10354 *b</small>
10355 !! html/php+tidy
10356 <p><small>
10357 </small></p><small></small><ul><small><li>a</li>
10358 </small><li><small>b</small></li></ul>
10359 !! html/parsoid
10360 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p>
10361 <ul><small data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'><li>a</li></small>
10362 <li><small data-parsoid='{"stx":"html","autoInsertedStart":true}'>b</small></li></ul>
10363 !! end
10364
10365 # Output is ugly because of all the misnested tag fixups.
10366 !! test
10367 3. List embedded in a formatting tag in a misnested way
10368 !! wikitext
10369 <small>
10370
10371 ** 123</small>
10372 !! html/php+tidy
10373 <p><small>
10374 </small></p><small></small><ul><small></small><li><small></small><ul><small></small><li><small>123</small></li></ul></li></ul>
10375 !! html/parsoid
10376 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p>
10377
10378 <ul><li><ul><li data-parsoid='{}'><small data-parsoid='{"stx":"html","autoInsertedStart":true}'> 123</small></li></ul></li></ul>
10379 !! end
10380
10381 ###
10382 ### Magic Words
10383 ###
10384
10385 # Note that the current date is hard-coded as
10386 # 1970-01-01T00:02:03Z (a Thursday)
10387 # when running parser tests. The timezone is also fixed to GMT, so
10388 # local date will be identical to current date.
10389
10390 !! test
10391 Magic Word: {{CURRENTDAY}}
10392 !! wikitext
10393 {{CURRENTDAY}}
10394 !! html
10395 <p>1
10396 </p>
10397 !! end
10398
10399 !! test
10400 Magic Word: {{CURRENTDAY2}}
10401 !! wikitext
10402 {{CURRENTDAY2}}
10403 !! html
10404 <p>01
10405 </p>
10406 !! end
10407
10408 !! test
10409 Magic Word: {{CURRENTDAYNAME}}
10410 !! wikitext
10411 {{CURRENTDAYNAME}}
10412 !! html
10413 <p>Thursday
10414 </p>
10415 !! end
10416
10417 !! test
10418 Magic Word: {{CURRENTDOW}}
10419 !! wikitext
10420 {{CURRENTDOW}}
10421 !! html
10422 <p>4
10423 </p>
10424 !! end
10425
10426 !! test
10427 Magic Word: {{CURRENTMONTH}}
10428 !! wikitext
10429 {{CURRENTMONTH}}
10430 !! html
10431 <p>01
10432 </p>
10433 !! end
10434
10435 !! test
10436 Magic Word: {{CURRENTMONTH1}}
10437 !! wikitext
10438 {{CURRENTMONTH1}}
10439 !! html
10440 <p>1
10441 </p>
10442 !! end
10443
10444 !! test
10445 Magic Word: {{CURRENTMONTHABBREV}}
10446 !! wikitext
10447 {{CURRENTMONTHABBREV}}
10448 !! html
10449 <p>Jan
10450 </p>
10451 !! end
10452
10453 !! test
10454 Magic Word: {{CURRENTMONTHNAME}}
10455 !! wikitext
10456 {{CURRENTMONTHNAME}}
10457 !! html
10458 <p>January
10459 </p>
10460 !! end
10461
10462 !! test
10463 Magic Word: {{CURRENTMONTHNAMEGEN}}
10464 !! wikitext
10465 {{CURRENTMONTHNAMEGEN}}
10466 !! html
10467 <p>January
10468 </p>
10469 !! end
10470
10471 !! test
10472 Magic Word: {{CURRENTTIME}}
10473 !! wikitext
10474 {{CURRENTTIME}}
10475 !! html
10476 <p>00:02
10477 </p>
10478 !! end
10479
10480 !! test
10481 Magic Word: {{CURRENTHOUR}}
10482 !! wikitext
10483 {{CURRENTHOUR}}
10484 !! html
10485 <p>00
10486 </p>
10487 !! end
10488
10489 !! test
10490 Magic Word: {{CURRENTWEEK}} (T6594)
10491 !! wikitext
10492 {{CURRENTWEEK}}
10493 !! html
10494 <p>1
10495 </p>
10496 !! end
10497
10498 !! test
10499 Magic Word: {{CURRENTYEAR}}
10500 !! wikitext
10501 {{CURRENTYEAR}}
10502 !! html
10503 <p>1970
10504 </p>
10505 !! end
10506
10507 !! test
10508 Magic Word: {{CURRENTTIMESTAMP}}
10509 !! wikitext
10510 {{CURRENTTIMESTAMP}}
10511 !! html
10512 <p>19700101000203
10513 </p>
10514 !! end
10515
10516 !! test
10517 Magic Words LOCAL (UTC)
10518 !! wikitext
10519 *{{LOCALMONTH}}
10520 *{{LOCALMONTH1}}
10521 *{{LOCALMONTHNAME}}
10522 *{{LOCALMONTHNAMEGEN}}
10523 *{{LOCALMONTHABBREV}}
10524 *{{LOCALDAY}}
10525 *{{LOCALDAY2}}
10526 *{{LOCALDAYNAME}}
10527 *{{LOCALYEAR}}
10528 *{{LOCALTIME}}
10529 *{{LOCALHOUR}}
10530 *{{LOCALWEEK}}
10531 *{{LOCALDOW}}
10532 *{{LOCALTIMESTAMP}}
10533 !! html
10534 <ul><li>01</li>
10535 <li>1</li>
10536 <li>January</li>
10537 <li>January</li>
10538 <li>Jan</li>
10539 <li>1</li>
10540 <li>01</li>
10541 <li>Thursday</li>
10542 <li>1970</li>
10543 <li>00:02</li>
10544 <li>00</li>
10545 <li>1</li>
10546 <li>4</li>
10547 <li>19700101000203</li></ul>
10548
10549 !! end
10550
10551 !! test
10552 Magic Word: {{FULLPAGENAME}}
10553 !! options
10554 title=[[User:Ævar Arnfjörð Bjarmason]]
10555 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10556 !! wikitext
10557 {{FULLPAGENAME}}
10558 !! html/*
10559 <p>User:Ævar Arnfjörð Bjarmason
10560 </p>
10561 !! end
10562
10563 !! test
10564 Magic Word: {{FULLPAGENAMEE}}
10565 !! options
10566 title=[[User:Ævar Arnfjörð Bjarmason]]
10567 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10568 !! wikitext
10569 {{FULLPAGENAMEE}}
10570 !! html/*
10571 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10572 </p>
10573 !! end
10574
10575 !! test
10576 Magic Word: {{TALKSPACE}}
10577 !! options
10578 title=[[User:Ævar Arnfjörð Bjarmason]]
10579 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10580 !! wikitext
10581 {{TALKSPACE}}
10582 !! html/*
10583 <p>User talk
10584 </p>
10585 !! end
10586
10587 !! test
10588 Magic Word: {{TALKSPACE}}, same namespace
10589 !! options
10590 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10591 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10592 !! wikitext
10593 {{TALKSPACE}}
10594 !! html/*
10595 <p>User talk
10596 </p>
10597 !! end
10598
10599 !! test
10600 Magic Word: {{TALKSPACE}}, main namespace
10601 !! options
10602 title=[[Parser Test]]
10603 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10604 !! wikitext
10605 {{TALKSPACE}}
10606 !! html/*
10607 <p>Talk
10608 </p>
10609 !! end
10610
10611 !! test
10612 Magic Word: {{TALKSPACEE}}
10613 !! options
10614 title=[[User:Ævar Arnfjörð Bjarmason]]
10615 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10616 !! wikitext
10617 {{TALKSPACEE}}
10618 !! html/*
10619 <p>User_talk
10620 </p>
10621 !! end
10622
10623 !! test
10624 Magic Word: {{SUBJECTSPACE}}
10625 !! options
10626 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10627 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10628 !! wikitext
10629 {{SUBJECTSPACE}}
10630 !! html/*
10631 <p>User
10632 </p>
10633 !! end
10634
10635 !! test
10636 Magic Word: {{SUBJECTSPACE}}, same namespace
10637 !! options
10638 title=[[User:Ævar Arnfjörð Bjarmason]]
10639 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10640 !! wikitext
10641 {{SUBJECTSPACE}}
10642 !! html/*
10643 <p>User
10644 </p>
10645 !! end
10646
10647 !! test
10648 Magic Word: {{SUBJECTSPACE}}, main namespace
10649 !! options
10650 title=[[Parser Test]]
10651 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10652 !! wikitext
10653 {{SUBJECTSPACE}}
10654 !! html/*
10655
10656 !! end
10657
10658 !! test
10659 Magic Word: {{SUBJECTSPACEE}}
10660 !! options
10661 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10662 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10663 !! wikitext
10664 {{SUBJECTSPACEE}}
10665 !! html/*
10666 <p>User
10667 </p>
10668 !! end
10669
10670 !! test
10671 Magic Word: {{NAMESPACE}}
10672 !! options
10673 title=[[User:Ævar Arnfjörð Bjarmason]]
10674 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10675 !! wikitext
10676 {{NAMESPACE}}
10677 !! html/*
10678 <p>User
10679 </p>
10680 !! end
10681
10682 !! test
10683 Magic Word: {{NAMESPACEE}}
10684 !! options
10685 title=[[User:Ævar Arnfjörð Bjarmason]]
10686 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10687 !! wikitext
10688 {{NAMESPACEE}}
10689 !! html/*
10690 <p>User
10691 </p>
10692 !! end
10693
10694 !! test
10695 Magic Word: {{NAMESPACENUMBER}}
10696 !! options
10697 title=[[User:Ævar Arnfjörð Bjarmason]]
10698 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10699 !! wikitext
10700 {{NAMESPACENUMBER}}
10701 !! html/*
10702 <p>2
10703 </p>
10704 !! end
10705
10706 !! test
10707 Magic Word: {{SUBPAGENAME}}
10708 !! options
10709 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10710 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10711 !! wikitext
10712 {{SUBPAGENAME}}
10713 !! html/*
10714 <p>sub ö
10715 </p>
10716 !! end
10717
10718 !! test
10719 Magic Word: {{SUBPAGENAMEE}}
10720 !! options
10721 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10722 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10723 !! wikitext
10724 {{SUBPAGENAMEE}}
10725 !! html/*
10726 <p>sub_%C3%B6
10727 </p>
10728 !! end
10729
10730 !! test
10731 Magic Word: {{ROOTPAGENAME}}
10732 !! options
10733 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10734 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10735 !! wikitext
10736 {{ROOTPAGENAME}}
10737 !! html/*
10738 <p>Ævar Arnfjörð Bjarmason
10739 </p>
10740 !! end
10741
10742 !! test
10743 Magic Word: {{ROOTPAGENAMEE}}
10744 !! options
10745 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10746 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10747 !! wikitext
10748 {{ROOTPAGENAMEE}}
10749 !! html/*
10750 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10751 </p>
10752 !! end
10753
10754 !! test
10755 Magic Word: {{BASEPAGENAME}}
10756 !! options
10757 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10758 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10759 !! wikitext
10760 {{BASEPAGENAME}}
10761 !! html/*
10762 <p>Ævar Arnfjörð Bjarmason
10763 </p>
10764 !! end
10765
10766 !! test
10767 Magic Word: {{BASEPAGENAMEE}}
10768 !! options
10769 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10770 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10771 !! wikitext
10772 {{BASEPAGENAMEE}}
10773 !! html/*
10774 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10775 </p>
10776 !! end
10777
10778 !! test
10779 Magic Word: {{TALKPAGENAME}}
10780 !! options
10781 title=[[User:Ævar Arnfjörð Bjarmason]]
10782 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10783 !! wikitext
10784 {{TALKPAGENAME}}
10785 !! html/*
10786 <p>User talk:Ævar Arnfjörð Bjarmason
10787 </p>
10788 !! end
10789
10790 !! test
10791 Magic Word: {{TALKPAGENAMEE}}
10792 !! options
10793 title=[[User:Ævar Arnfjörð Bjarmason]]
10794 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10795 !! wikitext
10796 {{TALKPAGENAMEE}}
10797 !! html/*
10798 <p>User_talk:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10799 </p>
10800 !! end
10801
10802 !! test
10803 Magic Word: {{SUBJECTPAGENAME}}
10804 !! options
10805 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10806 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10807 !! wikitext
10808 {{SUBJECTPAGENAME}}
10809 !! html/*
10810 <p>User:Ævar Arnfjörð Bjarmason
10811 </p>
10812 !! end
10813
10814 !! test
10815 Magic Word: {{SUBJECTPAGENAMEE}}
10816 !! options
10817 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10818 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10819 !! wikitext
10820 {{SUBJECTPAGENAMEE}}
10821 !! html/*
10822 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10823 </p>
10824 !! end
10825
10826 !! test
10827 Magic Word: {{NUMBEROFFILES}}
10828 !! options
10829 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10830 !! wikitext
10831 {{NUMBEROFFILES}}
10832 !! html/*
10833 <p>7
10834 </p>
10835 !! end
10836
10837 !! test
10838 Magic Word: {{PAGENAME}}
10839 !! options
10840 title=[[User:Ævar Arnfjörð Bjarmason]]
10841 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10842 !! wikitext
10843 {{PAGENAME}}
10844 !! html/*
10845 <p>Ævar Arnfjörð Bjarmason
10846 </p>
10847 !! end
10848
10849 !! test
10850 Magic Word: {{PAGENAME}} with metacharacters
10851 !! options
10852 title=[['foo & bar = baz']]
10853 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10854 !! wikitext
10855 ''{{PAGENAME}}''
10856 !! html+tidy
10857 <p><i>&#39;foo &#38; bar &#61; baz&#39;</i>
10858 </p>
10859 !! end
10860
10861 !! test
10862 Magic Word: {{PAGENAME}} with metacharacters (T28781)
10863 !! options
10864 title=[[*RFC 1234 http://example.com/]]
10865 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10866 !! wikitext
10867 {{PAGENAME}}
10868 !! html+tidy
10869 <p>&#42;RFC&#32;1234 http&#58;//example.com/
10870 </p>
10871 !! end
10872
10873 !! test
10874 Magic Word: {{PAGENAMEE}}
10875 !! options
10876 title=[[User:Ævar Arnfjörð Bjarmason]]
10877 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10878 !! wikitext
10879 {{PAGENAMEE}}
10880 !! html/*
10881 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10882 </p>
10883 !! end
10884
10885 !! test
10886 Magic Word: {{PAGENAMEE}} with metacharacters (T28781)
10887 !! options
10888 title=[[*RFC 1234 http://example.com/]]
10889 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10890 !! wikitext
10891 {{PAGENAMEE}}
10892 !! html+tidy
10893 <p>&#42;RFC_1234_http&#58;//example.com/
10894 </p>
10895 !! end
10896
10897 !! test
10898 Magic Word: {{REVISIONID}}
10899 !! options
10900 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10901 showflags
10902 !! wikitext
10903 {{REVISIONID}}
10904 !! html/*
10905 <p>1337
10906 </p>
10907 flags=vary-revision-id
10908 !! end
10909
10910 !! test
10911 Magic Word: {{SCRIPTPATH}}
10912 !! options
10913 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10914 !! wikitext
10915 {{SCRIPTPATH}}
10916 !! html/*
10917
10918 !! end
10919
10920 !! test
10921 Magic Word: {{STYLEPATH}}
10922 !! options
10923 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10924 !! wikitext
10925 {{STYLEPATH}}
10926 !! html/*
10927 <p>/skins
10928 </p>
10929 !! end
10930
10931 !! test
10932 Magic Word: {{SERVER}}
10933 !! options
10934 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10935 !! wikitext
10936 {{SERVER}}
10937 !! html/*
10938 <p><a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10939 </p>
10940 !! end
10941
10942 !! test
10943 Magic Word: {{SERVERNAME}}
10944 !! options
10945 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10946 !! wikitext
10947 {{SERVERNAME}}
10948 !! html/*
10949 <p>example.org
10950 </p>
10951 !! end
10952
10953 !! test
10954 Magic Word: {{SITENAME}}
10955 !! options
10956 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10957 !! wikitext
10958 {{SITENAME}}
10959 !! html/*
10960 <p>MediaWiki
10961 </p>
10962 !! end
10963
10964 !! test
10965 Magic Word: {{PAGELANGUAGE}}
10966 !! options
10967 language=fr
10968 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10969 !! wikitext
10970 {{PAGELANGUAGE}}
10971 !! html/*
10972 <p>fr
10973 </p>
10974 !! end
10975
10976 !! test
10977 Magic Word: {{PAGELANGUAGE}} on a page with no explicitly set language
10978 !! options
10979 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10980 !! wikitext
10981 {{PAGELANGUAGE}}
10982 !! html/*
10983 <p>en
10984 </p>
10985 !! end
10986
10987 !! test
10988 Case-sensitive magic words, when cased differently, should just be template transclusions
10989 !! wikitext
10990 {{CurrentMonth}}
10991 {{currentday}}
10992 {{cURreNTweEK}}
10993 {{currentHour}}
10994 !! html
10995 <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>
10996 <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>
10997 <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>
10998 <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>
10999 </p>
11000 !! end
11001
11002 !! test
11003 Case-insensitive magic words should still work with weird casing.
11004 !! wikitext
11005 {{sErVeRNaMe}}
11006 {{LCFirst:AOEU}}
11007 {{ucFIRST:aoeu}}
11008 {{SERver}}
11009 !! html
11010 <p>example.org
11011 aOEU
11012 Aoeu
11013 <a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
11014 </p>
11015 !! end
11016
11017 # From plwiki:PLOS_ONE
11018 !! test
11019 Parsoid: Page property magic word with magic word contents
11020 !! options
11021 showtitle
11022 !! config
11023 wgAllowDisplayTitle=true
11024 wgRestrictDisplayTitle=false
11025 !! wikitext
11026 {{DISPLAYTITLE:''{{PAGENAME}}''}}
11027 !! html/php+tidy
11028 <i>Parser test</i>
11029
11030 !! html/parsoid
11031 <meta property="mw:PageProp/displaytitle" content="Parser test" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"src":"{{DISPLAYTITLE:&#39;&#39;{{PAGENAME}}&#39;&#39;}}"}' data-mw='{"attribs":[[{"txt":"content"},{"html":"DISPLAYTITLE:&lt;i data-parsoid=&#39;{\"dsr\":[15,31,2,2]}&#39;>&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[]],\"dsr\":[17,29,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"PAGENAME\",\"function\":\"pagename\"},\"params\":{},\"i\":0}}]}&#39;>Parser test&lt;/span>&lt;/i>"}]]}'/>
11032 !! end
11033
11034 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
11035 # But, this is a limitation of our representation and is documented in
11036 # TemplateHandler.js in processSpecialMagicWord
11037 !! test
11038 Parsoid: Template-generated DISPLAYTITLE
11039 !! wikitext
11040 {{{{echo|DISPLAYTITLE}}:Foo}}
11041 !! options
11042 showtitle
11043 !! config
11044 wgAllowDisplayTitle=true
11045 wgRestrictDisplayTitle=false
11046 !! html/php
11047 Foo
11048
11049 !! html/parsoid
11050 <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"}]]}'/>
11051 !! end
11052
11053 !! test
11054 Namespace 1 {{ns:1}}
11055 !! wikitext
11056 {{ns:1}}
11057 !! html
11058 <p>Talk
11059 </p>
11060 !! end
11061
11062 !! test
11063 Namespace 1 {{ns:01}}
11064 !! wikitext
11065 {{ns:01}}
11066 !! html
11067 <p>Talk
11068 </p>
11069 !! end
11070
11071 !! test
11072 Namespace 0 {{ns:0}} (T6783)
11073 !! wikitext
11074 {{ns:0}}
11075 !! html
11076
11077 !! end
11078
11079 !! test
11080 Namespace 0 {{ns:00}} (T6783)
11081 !! wikitext
11082 {{ns:00}}
11083 !! html
11084
11085 !! end
11086
11087 !! test
11088 Namespace -1 {{ns:-1}}
11089 !! wikitext
11090 {{ns:-1}}
11091 !! html
11092 <p>Special
11093 </p>
11094 !! end
11095
11096 !! test
11097 Namespace User {{ns:User}}
11098 !! wikitext
11099 {{ns:User}}
11100 !! html
11101 <p>User
11102 </p>
11103 !! end
11104
11105 !! test
11106 Namespace User talk {{ns:User_talk}}
11107 !! wikitext
11108 {{ns:User_talk}}
11109 !! html
11110 <p>User talk
11111 </p>
11112 !! end
11113
11114 !! test
11115 Namespace User talk {{ns:uSeR tAlK}}
11116 !! wikitext
11117 {{ns:uSeR tAlK}}
11118 !! html
11119 <p>User talk
11120 </p>
11121 !! end
11122
11123 !! test
11124 Namespace File {{ns:File}}
11125 !! wikitext
11126 {{ns:File}}
11127 !! html
11128 <p>File
11129 </p>
11130 !! end
11131
11132 !! test
11133 Namespace File {{ns:Image}}
11134 !! wikitext
11135 {{ns:Image}}
11136 !! html
11137 <p>File
11138 </p>
11139 !! end
11140
11141 !! test
11142 Namespace (lang=de) Benutzer {{ns:User}}
11143 !! options
11144 language=de
11145 !! wikitext
11146 {{ns:User}}
11147 !! html
11148 <p>Benutzer
11149 </p>
11150 !! end
11151
11152 !! test
11153 Namespace (lang=de) Benutzer Diskussion {{ns:3}}
11154 !! options
11155 language=de
11156 !! wikitext
11157 {{ns:3}}
11158 !! html
11159 <p>Benutzer Diskussion
11160 </p>
11161 !! end
11162
11163 !! test
11164 Urlencode
11165 !! wikitext
11166 {{urlencode:hi world?!}}
11167 {{urlencode:hi world?!|WIKI}}
11168 {{urlencode:hi world?!|PATH}}
11169 {{urlencode:hi world?!|QUERY}}
11170 !! html/php
11171 <p>hi+world%3F%21
11172 hi_world%3F!
11173 hi%20world%3F%21
11174 hi+world%3F%21
11175 </p>
11176 !! end
11177
11178 !! test
11179 Magic Word: prioritize type info over data-parsoid
11180 !! options
11181 parsoid=html2wt
11182 !! html/parsoid
11183 <meta property="mw:PageProp/forcetoc" data-parsoid='{"magicSrc":"__NOTOC__"}'/>
11184 !! wikitext
11185 __FORCETOC__
11186 !! end
11187
11188 !! test
11189 Magic Word: serialize on separate line (parsoid)
11190 !! options
11191 parsoid=wt2wt,html2wt
11192 !! wikitext
11193 foo
11194 __NOTOC__
11195 bar
11196 !! html/parsoid
11197 foo<meta property="mw:PageProp/notoc"/>bar
11198 !! end
11199
11200 !! test
11201 Magic Word: rt non-english wikis
11202 !! options
11203 parsoid=wt2wt
11204 language=de
11205 !! wikitext
11206 __NOEDITSECTION__
11207 !! html/parsoid
11208 <meta property="mw:PageProp/noeditsection" data-parsoid='{"magicSrc":"__NOEDITSECTION__"}'/>
11209 !! end
11210
11211 !!test
11212 __proto__ is treated as normal wikitext (T105997)
11213 !!wikitext
11214 __proto__
11215 !!html
11216 <p>__proto__
11217 </p>
11218 !!end
11219
11220 ###
11221 ### Magic links
11222 ###
11223 !! test
11224 Magic links: internal link to RFC (T2479)
11225 !! wikitext
11226 [[RFC 123]]
11227 !! html/php
11228 <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>
11229 </p>
11230 !! html/parsoid
11231 <p><a rel="mw:WikiLink" href="./RFC_123" title="RFC 123">RFC 123</a></p>
11232 !! end
11233
11234 !! test
11235 Magic links: RFC (T2479)
11236 !! wikitext
11237 RFC 822
11238 !! html/php
11239 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
11240 </p>
11241 !! html/parsoid
11242 <p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external mw-magiclink">RFC 822</a></p>
11243 !! end
11244
11245 !! test
11246 Magic links: RFC (T67278)
11247 !! wikitext
11248 This is RFC 822 but thisRFC 822 is not RFC 822linked.
11249 !! html/php
11250 <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.
11251 </p>
11252 !! html/parsoid
11253 <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>
11254 !! end
11255
11256 !! test
11257 Magic links: RFC (w/ non-newline whitespace, T30950/T31025)
11258 !! wikitext
11259 RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 822
11260 RFC
11261 822
11262 !! html/php
11263 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
11264 RFC
11265 822
11266 </p>
11267 !! html/parsoid
11268 <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>
11269 RFC
11270 822</p>
11271 !! end
11272
11273 !! test
11274 Magic links: ISBN (T3937)
11275 !! wikitext
11276 ISBN 0-306-40615-2
11277 !! html/php
11278 <p><a href="/wiki/Special:BookSources/0306406152" class="internal mw-magiclink-isbn">ISBN 0-306-40615-2</a>
11279 </p>
11280 !! html/parsoid
11281 <p><a href="./Special:BookSources/0306406152" rel="mw:WikiLink">ISBN 0-306-40615-2</a></p>
11282 !! end
11283
11284 !! test
11285 Magic links: ISBN (T67278)
11286 !! wikitext
11287 This is ISBN 978-0-316-09811-3 but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.
11288 !! html/php
11289 <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.
11290 </p>
11291 !! html/parsoid
11292 <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>
11293 !! end
11294
11295 !! test
11296 Magic links: ISBN (w/ non-newline whitespace, T30950/T31025)
11297 !! wikitext
11298 ISBN &nbsp;&#160;&#0160;&#xA0;&#Xa0; 978&nbsp;0&#160;316&#0160;09811&#xA0;3
11299 ISBN
11300 9780316098113
11301 ISBN 978
11302 0316098113
11303 !! html/php
11304 <p><a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978 0 316 09811 3</a>
11305 ISBN
11306 9780316098113
11307 ISBN 978
11308 0316098113
11309 </p>
11310 !! html/parsoid
11311 <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>
11312 ISBN
11313 9780316098113
11314 ISBN 978
11315 0316098113</p>
11316 !! end
11317
11318 !! test
11319 Magic links: PMID incorrectly converts space to underscore
11320 !! wikitext
11321 PMID 1234
11322 !! html/php
11323 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11324 </p>
11325 !! html/parsoid
11326 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external mw-magiclink">PMID 1234</a></p>
11327 !! end
11328
11329 !! test
11330 Magic links: PMID (T67278)
11331 !! wikitext
11332 This is PMID 1234 but thisPMID 1234 is not PMID 1234linked.
11333 !! html/php
11334 <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.
11335 </p>
11336 !! html/parsoid
11337 <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>
11338 !! end
11339
11340 !! test
11341 Magic links: PMID (w/ non-newline whitespace, T30950/T31025)
11342 !! wikitext
11343 PMID &nbsp;&#160;&#0160;&#xA0;&#Xa0; 1234
11344 PMID
11345 1234
11346 !! html/php
11347 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11348 PMID
11349 1234
11350 </p>
11351 !! html/parsoid
11352 <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>
11353 PMID
11354 1234</p>
11355 !! end
11356
11357 # <nowiki> nodes shouldn't be inserted during html2wt by Parsoid,
11358 # since these are ExtLinkText, not MagicLinkText
11359 !! test
11360 Magic links: use appropriate serialization for "almost" magic links.
11361 !! wikitext
11362 X[[Special:BookSources/0978739256|foo]]
11363
11364 X[https://tools.ietf.org/html/rfc1234 foo]
11365 !! html/php
11366 <p>X<a href="/wiki/Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a>
11367 </p><p>X<a rel="nofollow" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a>
11368 </p>
11369 !! html/parsoid
11370 <p>X<a rel="mw:WikiLink" href="./Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a></p>
11371 <p>X<a rel="mw:ExtLink" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a></p>
11372 !! end
11373
11374 !! test
11375 Magic links: All disabled (T47942)
11376 !! options
11377 wgEnableMagicLinks={"ISBN":false, "PMID":false, "RFC":false}
11378 !! wikitext
11379 ISBN 0-306-40615-2
11380 PMID 1234
11381 RFC 4321
11382 !! html/php
11383 <p>ISBN 0-306-40615-2
11384 PMID 1234
11385 RFC 4321
11386 </p>
11387 !! end
11388
11389 ###
11390 ### Templates
11391 ####
11392
11393 !! test
11394 Nonexistent template
11395 !! wikitext
11396 {{thistemplatedoesnotexist}}
11397 !! html
11398 <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>
11399 </p>
11400 !! end
11401
11402 !! test
11403 Template with invalid target containing tags
11404 !! wikitext
11405 {{a<b>b</b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11406 !! html
11407 <p>{{a<b>b</b>|foo|a=b|a = b}}
11408 </p>
11409 !! end
11410
11411 !! test
11412 Template with invalid target containing unclosed tag
11413 !! wikitext
11414 {{a<b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11415 !! html
11416 <p>{{a<b>|foo|a=b|a = b}}</b>
11417 </p>
11418 !! end
11419
11420 !! test
11421 Template with invalid target containing wikilink
11422 !! wikitext
11423 {{[[Main Page]]}}
11424 !! html/php
11425 <p>{{<a href="/wiki/Main_Page" title="Main Page">Main Page</a>}}
11426 </p>
11427 !! html/parsoid
11428 <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>
11429 !! end
11430
11431 !! test
11432 Template with just whitespace in it, T70421
11433 !! wikitext
11434 {{echo|{{ }}}}
11435 !! html/parsoid
11436 <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>
11437 !! end
11438
11439 !! article
11440 Template:test
11441 !! text
11442 This is a test template
11443 !! endarticle
11444
11445 !! test
11446 Simple template
11447 !! wikitext
11448 {{test}}
11449 !! html
11450 <p>This is a test template
11451 </p>
11452 !! end
11453
11454 !! test
11455 Template with explicit namespace
11456 !! wikitext
11457 {{Template:test}}
11458 !! html
11459 <p>This is a test template
11460 </p>
11461 !! end
11462
11463
11464 !! article
11465 Template:paramtest
11466 !! text
11467 This is a test template with parameter {{{param}}}
11468 !! endarticle
11469
11470 !! test
11471 Template parameter
11472 !! wikitext
11473 {{paramtest|param=foo}}
11474 !! html
11475 <p>This is a test template with parameter foo
11476 </p>
11477 !! end
11478
11479 !! article
11480 Template:paramtestnum
11481 !! text
11482 [[{{{1}}}|{{{2}}}]]
11483 !! endarticle
11484
11485 !! test
11486 Template unnamed parameter
11487 !! wikitext
11488 {{paramtestnum|Main Page|the main page}}
11489 !! html
11490 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
11491 </p>
11492 !! end
11493
11494 !! article
11495 Template:templatesimple
11496 !! text
11497 (test)
11498 !! endarticle
11499
11500 !! article
11501 Template:templateredirect
11502 !! text
11503 #redirect [[Template:templatesimple]]
11504 !! endarticle
11505
11506 !! article
11507 Template:templateasargtestnum
11508 !! text
11509 {{{{{1}}}}}
11510 !! endarticle
11511
11512 !! article
11513 Template:templateasargtest
11514 !! text
11515 {{template{{{templ}}}}}
11516 !! endarticle
11517
11518 !! article
11519 Template:templateasargtest2
11520 !! text
11521 {{{{{templ}}}}}
11522 !! endarticle
11523
11524 !! test
11525 Template with template name as unnamed argument
11526 !! wikitext
11527 {{templateasargtestnum|templatesimple}}
11528 !! html
11529 <p>(test)
11530 </p>
11531 !! end
11532
11533 !! test
11534 Template with template name as argument
11535 !! wikitext
11536 {{templateasargtest|templ=simple}}
11537 !! html
11538 <p>(test)
11539 </p>
11540 !! end
11541
11542 !! test
11543 Template with template name as argument (2)
11544 !! wikitext
11545 {{templateasargtest2|templ=templatesimple}}
11546 !! html
11547 <p>(test)
11548 </p>
11549 !! end
11550
11551 !! article
11552 Template:templateasargtestdefault
11553 !! text
11554 {{{{{templ|templatesimple}}}}}
11555 !! endarticle
11556
11557 !! article
11558 Template:templa
11559 !! text
11560 '''templ'''
11561 !! endarticle
11562
11563 !! test
11564 Template with default value
11565 !! wikitext
11566 {{templateasargtestdefault}}
11567 !! html
11568 <p>(test)
11569 </p>
11570 !! end
11571
11572 !! test
11573 Template with default value (value set)
11574 !! wikitext
11575 {{templateasargtestdefault|templ=templa}}
11576 !! html
11577 <p><b>templ</b>
11578 </p>
11579 !! end
11580
11581 !! test
11582 Template redirect
11583 !! wikitext
11584 {{templateredirect}}
11585 !! html/php
11586 <p>(test)
11587 </p>
11588 !! html/parsoid
11589 <link rel="mw:PageProp/redirect" href="./Template:Templatesimple" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"templateredirect","href":"./Template:Templateredirect"},"params":{},"i":0}}]}'/>
11590 !! end
11591
11592 !! test
11593 Template with argument in separate line
11594 !! wikitext
11595 {{ templateasargtest |
11596 templ = simple }}
11597 !! html
11598 <p>(test)
11599 </p>
11600 !! end
11601
11602 !! test
11603 Template with complex template as argument
11604 !! wikitext
11605 {{paramtest|
11606 param ={{ templateasargtest |
11607 templ = simple }}}}
11608 !! html
11609 <p>This is a test template with parameter (test)
11610 </p>
11611 !! end
11612
11613 !! test
11614 Templates with templated name
11615 !! wikitext
11616 {{{{echo|echo}}|foo}}
11617 {{{{echo|inner list}} }}
11618 !! html
11619 <p>foo
11620 </p>
11621 <ul><li>item 1</li></ul>
11622
11623 !! html/parsoid
11624 <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>
11625 <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>
11626 !! end
11627
11628 ## Regression test; the output here isn't really that interesting.
11629 !! test
11630 Templates with templated name and top level template args
11631 !! wikitext
11632 {{1{{2{{{3}}}|4=5}}}}
11633 !! html/parsoid
11634 <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>
11635 !! end
11636
11637 # Parsoid markup is deliberate "broken". This is an edge case.
11638 # See long comment in TemplateHandler.js:convertAttribsToString.
11639 !! test
11640 Templates with invalid templated targets
11641 !! wikitext
11642 {{echo
11643 {{echo|foo}}
11644 }}
11645 !! html/php
11646 <p>{{echo
11647 foo
11648 }}
11649 </p>
11650 !! html/parsoid
11651 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n{{echo|foo}}\n"},"params":{},"i":0}}]}'>{{echo
11652 foo }}</p>
11653 !! end
11654
11655 !! test
11656 Template with thumb image (with link in description)
11657 !! wikitext
11658 {{paramtest|param=[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
11659 !! html/php
11660 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>
11661
11662 !! html+tidy
11663 <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>
11664 !! html/parsoid
11665 <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>
11666 !! end
11667
11668 !! article
11669 Template:complextemplate
11670 !! text
11671 {{{1}}} {{paramtest|
11672 param ={{{param}}}}}
11673 !! endarticle
11674
11675 !! test
11676 Template with complex arguments
11677 !! wikitext
11678 {{complextemplate|
11679 param ={{ templateasargtest |
11680 templ = simple }}|[[Template:complextemplate|link]]}}
11681 !! html
11682 <p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test)
11683 </p>
11684 !! end
11685
11686 !! test
11687 T2553: link with two variables in a piped link
11688 !! wikitext
11689 {|
11690 |[[{{{1}}}|{{{2}}}]]
11691 |}
11692 !! html/php
11693 <table>
11694 <tr>
11695 <td>[[{{{1}}}|{{{2}}}]]
11696 </td></tr></table>
11697
11698 !! html/parsoid
11699 <table>
11700 <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>
11701 </tbody></table>
11702 !! end
11703
11704 # See: T2553
11705 !! test
11706 Abort table cell attribute parsing on wikilink
11707 !! wikitext
11708 {|
11709 |testing [[one|two]] |three||four
11710 |testing one two |three||four
11711 |testing="[[one|two]]" |three||four
11712 |}
11713 !! html/php
11714 <table>
11715 <tr>
11716 <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>
11717 <td>four
11718 </td>
11719 <td>three</td>
11720 <td>four
11721 </td>
11722 <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>
11723 <td>four
11724 </td></tr></table>
11725
11726 !! html/parsoid
11727 <table>
11728 <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>
11729 <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>
11730 <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>
11731 </tbody></table>
11732 !! end
11733
11734 !! test
11735 Don't abort table cell attribute parsing if wikilink is found in template arg
11736 !! wikitext
11737 {|
11738 |Test {{#tag:ref|One two "[[three]]" four}}
11739 |}
11740 !! html/parsoid
11741 <table>
11742 <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>
11743 </tbody></table>
11744 !! end
11745
11746 !! test
11747 Magic variable as template parameter
11748 !! wikitext
11749 {{paramtest|param={{SITENAME}}}}
11750 !! html
11751 <p>This is a test template with parameter MediaWiki
11752 </p>
11753 !! end
11754
11755 !! article
11756 Template:linktest
11757 !! text
11758 [[{{{param}}}|link]]
11759 !! endarticle
11760
11761 !! test
11762 Template parameter as link source
11763 !! wikitext
11764 {{linktest|param=Main Page}}
11765 !! html
11766 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
11767 </p>
11768 !! end
11769
11770 !!article
11771 Template:paramtest2
11772 !! text
11773 including another template, {{paramtest|param={{{arg}}}}}
11774 !! endarticle
11775
11776 !! test
11777 Template passing argument to another template
11778 !! wikitext
11779 {{paramtest2|arg='hmm'}}
11780 !! html
11781 <p>including another template, This is a test template with parameter 'hmm'
11782 </p>
11783 !! end
11784
11785 !! article
11786 Template:Linktest2
11787 !! text
11788 Main Page
11789 !! endarticle
11790
11791 !! test
11792 Template as link source
11793 !! wikitext
11794 [[{{linktest2}}]]
11795
11796 [[{{linktest2}}|Main Page]]
11797
11798 [[{{linktest2}}]]Page
11799 !! html
11800 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11801 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11802 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>Page
11803 </p>
11804 !! end
11805
11806
11807 !! article
11808 Template:loop1
11809 !! text
11810 {{loop2}}
11811 !! endarticle
11812
11813 !! article
11814 Template:loop2
11815 !! text
11816 {{loop1}}
11817 !! endarticle
11818
11819 !! test
11820 Template infinite loop
11821 !! wikitext
11822 {{loop1}}
11823 !! html
11824 <p><span class="error">Template loop detected: <a href="/wiki/Template:Loop1" title="Template:Loop1">Template:Loop1</a></span>
11825 </p>
11826 !! end
11827
11828 !! test
11829 Template from main namespace
11830 !! wikitext
11831 {{:Main Page}}
11832 !! html
11833 <p>blah blah
11834 </p>
11835 !! end
11836
11837 !! test
11838 Template from non-includable namespace
11839 !! options
11840 wgNonincludableNamespaces=10
11841 !! wikitext
11842 {{echo|uh oh!}}
11843 !! html
11844 <p><a href="/wiki/Template:Echo" title="Template:Echo">Template:Echo</a>
11845 </p>
11846 !! end
11847
11848 !! article
11849 Template:table
11850 !! text
11851 {|
11852 | 1 || 2
11853 |-
11854 | 3 || 4
11855 |}
11856 !! endarticle
11857
11858 !! test
11859 T2529: Template with table, not included at beginning of line
11860 !! wikitext
11861 foo {{table}}
11862 !! html
11863 <p>foo
11864 </p>
11865 <table>
11866 <tr>
11867 <td>1</td>
11868 <td>2
11869 </td></tr>
11870 <tr>
11871 <td>3</td>
11872 <td>4
11873 </td></tr></table>
11874
11875 !! end
11876
11877 !! test
11878 T2523: Template shouldn't eat newline (or add an extra one before table)
11879 !! wikitext
11880 foo
11881 {{table}}
11882 !! html
11883 <p>foo
11884 </p>
11885 <table>
11886 <tr>
11887 <td>1</td>
11888 <td>2
11889 </td></tr>
11890 <tr>
11891 <td>3</td>
11892 <td>4
11893 </td></tr></table>
11894
11895 !! end
11896
11897 !! test
11898 T2041: Template parameters shown as broken links
11899 !! wikitext
11900 {{{parameter}}}
11901 !! html
11902 <p>{{{parameter}}}
11903 </p>
11904 !! end
11905
11906 !! test
11907 Template with targets containing wikilinks
11908 !! options
11909 parsoid=wt2html
11910 !! wikitext
11911 {{[[foo]]}}
11912
11913 {{[[{{echo|foo}}]]}}
11914
11915 {{{{echo|[[foo}}]]}}
11916 !! html/php
11917 <p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11918 </p><p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11919 </p><p>{{[[foo}}]]
11920 </p>
11921 !! html/parsoid
11922 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">foo</a>}}</p>
11923 <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>
11924 <p>{{<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[foo}}]]"}},"i":0}}]}'>[[foo}}]]</span></p>
11925 !! end
11926
11927 !! article
11928 Template:''
11929 !! text
11930 bar
11931 !! endarticle
11932
11933 !! test
11934 Templates: Double quotes as template target
11935 !! wikitext
11936 foo {{''}} baz
11937 !! html/php
11938 <p>foo bar baz
11939 </p>
11940 !! html/parsoid
11941 <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
11942 </p>
11943 !! end
11944
11945 ## This test is about making sure Parsoid's data-mw is well formed in the
11946 ## face of multiple templates with intersecting and overlapping ranges. The
11947 ## wikitext itself is wretched.
11948 !! test
11949 Templates with intersecting and overlapping ranges
11950 !! wikitext
11951 {|{{echo|
11952 <p>ha</p>}}
11953 {|{{echo|
11954 <p>ho</p>}}
11955 {{echo|{{!}}hi}}
11956 |}
11957 !! html/php+tidy
11958 <p>ha</p><table>
11959
11960 </table><p>ho</p><table>
11961
11962 <tbody><tr>
11963 <td>hi
11964 </td></tr></tbody></table>
11965 !! html/parsoid
11966 <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":""}]]}'>
11967
11968 </table><p about="#mwt1">ho</p><table about="#mwt1" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"","html":""},{"html":""}]]}'>
11969
11970 <tbody><tr><td>hi</td></tr>
11971 </tbody></table>
11972 !! end
11973
11974 !! article
11975 Template:MSGNW test
11976 !! text
11977 ''None'' of '''this''' should be
11978 * interpreted
11979 but rather passed unmodified
11980 {{test}}
11981 <gallery>
11982 File:Foobar.jpg
11983 </gallery>
11984 <!-- comment -->
11985 !! endarticle
11986
11987 # hmm, fix this or just deprecate msgnw and document its behavior?
11988 !! test
11989 msgnw keyword
11990 !! wikitext
11991 {{msgnw:MSGNW test}}
11992 !! html/php
11993 <p>&#39;&#39;None&#39;&#39; of &#39;&#39;&#39;this&#39;&#39;&#39; should be
11994 &#42; interpreted
11995 &#32;but rather passed unmodified
11996 &#123;&#123;test&#125;&#125;
11997 &#60;gallery&#62;
11998 File:Foobar.jpg
11999 &#60;/gallery&#62;
12000 &#60;!-- comment --&#62;
12001 </p>
12002 !! end
12003
12004 !! test
12005 int keyword
12006 !! wikitext
12007 {{int:youhavenewmessages|lots of money|not!}}
12008 !! html
12009 <p>You have lots of money (not!).
12010 </p>
12011 !! end
12012
12013 !! test
12014 int keyword - non-existing message
12015 !! wikitext
12016 {{int:var}}
12017 !! html
12018 <p>⧼var⧽
12019 </p>
12020 !! end
12021
12022 !! article
12023 Template:Includes
12024 !! text
12025 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
12026 !! endarticle
12027
12028 !! test
12029 <includeonly> and <noinclude> being included
12030 !! wikitext
12031 {{Includes}}
12032 !! html
12033 <p>Foobar
12034 </p>
12035 !! end
12036
12037 !! article
12038 Template:Includes2
12039 !! text
12040 <onlyinclude>Foo</onlyinclude>bar
12041 !! endarticle
12042
12043 !! test
12044 <onlyinclude> being included
12045 !! wikitext
12046 {{Includes2}}
12047 !! html
12048 <p>Foo
12049 </p>
12050 !! end
12051
12052
12053 !! article
12054 Template:Includes3
12055 !! text
12056 <onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly>
12057 !! endarticle
12058
12059 !! test
12060 <onlyinclude> and <includeonly> being included
12061 !! wikitext
12062 {{Includes3}}
12063 !! html
12064 <p>Foo
12065 </p>
12066 !! end
12067
12068 !! test
12069 <includeonly> and <noinclude> on a page
12070 !! wikitext
12071 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
12072 !! html
12073 <p>Foozar
12074 </p>
12075 !! end
12076
12077 !! test
12078 Un-closed <noinclude>
12079 !! wikitext
12080 <noinclude>
12081 !! html
12082 !! end
12083
12084 !! test
12085 <onlyinclude> on a page
12086 !! wikitext
12087 <onlyinclude>Foo</onlyinclude>bar
12088 !! html
12089 <p>Foobar
12090 </p>
12091 !! end
12092
12093 !! test
12094 Un-closed <onlyinclude>
12095 !! wikitext
12096 <onlyinclude>
12097 !! html
12098 !! end
12099
12100 !!test
12101 Self-closed noinclude, includeonly, onlyinclude tags
12102 !! wikitext
12103 <noinclude />
12104 <includeonly />
12105 <onlyinclude />
12106 !! html
12107 <p><br />
12108 </p>
12109 !!end
12110
12111 !!test
12112 Unbalanced includeonly and noinclude tags
12113 !! wikitext
12114 {|
12115 |a</noinclude>
12116 |b</noinclude></noinclude>
12117 |c</noinclude></includeonly>
12118 |d</includeonly></includeonly>
12119 |}
12120 !! html
12121 <table>
12122 <tr>
12123 <td>a
12124 </td>
12125 <td>b
12126 </td>
12127 <td>c&lt;/includeonly&gt;
12128 </td>
12129 <td>d&lt;/includeonly&gt;&lt;/includeonly&gt;
12130 </td></tr></table>
12131
12132 !!end
12133
12134 !! article
12135 Template:Includeonly section
12136 !! text
12137 <includeonly>
12138 ==Includeonly section==
12139 </includeonly>
12140 ==Section T-1==
12141 !!endarticle
12142
12143 !! test
12144 T8563: Edit link generation for section shown by <includeonly>
12145 !! wikitext
12146 {{includeonly section}}
12147 !! html
12148 <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>
12149 <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>
12150
12151 !! end
12152
12153 # Uses same input as the contents of [[Template:Includeonly section]]
12154 !! test
12155 T8563: Section extraction for section shown by <includeonly>
12156 !! options
12157 section=T-2
12158 !! wikitext
12159 <includeonly>
12160 ==Includeonly section==
12161 </includeonly>
12162 ==Section T-2==
12163 !! html
12164 ==Section T-2==
12165 !! end
12166
12167 !! test
12168 T8563: Edit link generation for section suppressed by <includeonly>
12169 !! wikitext
12170 <includeonly>
12171 ==Includeonly section==
12172 </includeonly>
12173 ==Section 1==
12174 !! html
12175 <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>
12176
12177 !! end
12178
12179 !! test
12180 T8563: Section extraction for section suppressed by <includeonly>
12181 !! options
12182 section=1
12183 !! wikitext
12184 <includeonly>
12185 ==Includeonly section==
12186 </includeonly>
12187 ==Section 1==
12188 !! html
12189 ==Section 1==
12190 !! end
12191
12192 !! test
12193 Un-closed <includeonly>
12194 !! wikitext
12195 <includeonly>
12196 !! html/php
12197 !! html/parsoid
12198 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>"}' data-mw='{"src":"&lt;includeonly>"}'/>
12199 !! end
12200
12201 ## We used to, but no longer wt2wt this test since the default serializer
12202 ## will normalize the include directives to serialize on their own line.
12203 ## Selser will take care of preserving formatting in scenarios where they
12204 ## intermingled with other wikitext.
12205 !! test
12206 Includes and comments at SOL
12207 !! options
12208 parsoid=wt2html,html2html
12209 !! wikitext
12210 <!-- comment --><noinclude><!-- comment --></noinclude><!-- comment -->==hu==
12211
12212 <noinclude>
12213 some
12214 </noinclude>*stuff
12215 *here
12216
12217 <noinclude>
12218 some</noinclude>* stuff
12219 * here
12220
12221 <includeonly>can have stuff</includeonly>===here===
12222
12223 !! html/php
12224 <h2><span class="mw-headline" id="hu">hu</span></h2>
12225 <p>some
12226 </p>
12227 <ul><li>stuff</li>
12228 <li>here</li></ul>
12229 <p><br />
12230 some* stuff
12231 </p>
12232 <ul><li>here</li></ul>
12233 <h3><span class="mw-headline" id="here">here</span></h3>
12234
12235 !! html/parsoid
12236 <!-- 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>
12237
12238 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
12239 <p>some</p>
12240 <meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/><ul><li>stuff</li>
12241 <li>here</li></ul>
12242
12243 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
12244 <p>some<meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/>* stuff</p>
12245 <ul><li>here</li></ul>
12246
12247 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>can have stuff&lt;/includeonly>"}' data-mw='{"src":"&lt;includeonly>can have stuff&lt;/includeonly>"}'/><meta typeof="mw:Includes/IncludeOnly/End" data-parsoid='{"src":""}'/><h3 id="here">here</h3>
12248
12249 !! end
12250
12251 # TODO: test with DOM fragment reuse!
12252 !! test
12253 Parsoid: DOM fragment reuse
12254 !! options
12255 parsoid=wt2wt,wt2html
12256 !! wikitext
12257 a{{echo|b<table></table>c}}d
12258
12259 a{{echo|b
12260 <table></table>
12261 c}}d
12262
12263 {{echo|a
12264
12265 <table></table>
12266
12267 b}}
12268 !! html/php+tidy
12269 <p>ab</p><table></table><p>cd
12270 </p><p>ab
12271 </p>
12272 <table></table>
12273 <p>cd
12274 </p><p>a
12275 </p>
12276 <table></table>
12277 <p>b
12278 </p>
12279 !! html/parsoid
12280 <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>
12281
12282 <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">
12283 </span><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><span about="#mwt2">
12284 </span><p about="#mwt2">cd</p>
12285
12286 <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">
12287
12288 </span><table about="#mwt3" data-parsoid='{"stx":"html"}'></table><span about="#mwt3">
12289
12290 </span><p about="#mwt3">b</p>
12291 !! end
12292
12293 !! test
12294 Parsoid: Merge double tds (T52603)
12295 !! wikitext
12296 {|
12297 |{{echo|{{!}} foo}}
12298 |}
12299 !! html/php+tidy
12300 <table>
12301 <tbody><tr>
12302 <td>foo
12303 </td></tr></tbody></table>
12304 !! html/parsoid
12305 <table><tbody>
12306 <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>
12307 </tbody></table>
12308 !! end
12309
12310 !! test
12311 Parsoid: Merge double tds in nested transclusion content (T52603)
12312 !! wikitext
12313 {{echo|<div>}}
12314 {|
12315 |{{echo|{{!}} foo}}
12316 |}
12317 {{echo|</div>}}
12318 !! html/php+tidy
12319 <div>
12320 <table>
12321 <tbody><tr>
12322 <td>foo
12323 </td></tr></tbody></table>
12324 </div>
12325 !! html/parsoid
12326 <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}}]}'>
12327 <table><tbody>
12328 <tr><td data-mw='{"parts":["|"]}'> foo</td></tr>
12329 </tbody></table>
12330 </div>
12331 !! end
12332
12333 ###
12334 ### <includeonly> and <noinclude> in attributes
12335 ###
12336 !!test
12337 0. includeonly around the entire attribute
12338 !! wikitext
12339 <span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
12340 !! html
12341 <p><span id="v2">bar</span>
12342 </p>
12343 !!end
12344
12345 !!test
12346 1. includeonly in html attr key
12347 !! wikitext
12348 <span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
12349 !! html
12350 <p><span id="foo">bar</span>
12351 </p>
12352 !!end
12353
12354 !!test
12355 2. includeonly in html attr value
12356 !! wikitext
12357 <span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
12358 <span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
12359 !! html
12360 <p><span id="v1">bar</span>
12361 <span id="v1">bar</span>
12362 </p>
12363 !!end
12364
12365 !!test
12366 3. includeonly in part of an attr value
12367 !! wikitext
12368 <span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
12369 !! html
12370 <p><span style="color:red;">bar</span>
12371 </p>
12372 !!end
12373
12374 !!test
12375 4. includeonly in table attributes
12376 !! wikitext
12377 {|
12378 |- <noinclude>
12379 |-
12380 |a
12381 </noinclude>
12382 |- <includeonly>
12383 |-
12384 |b
12385 </includeonly>
12386 |}
12387 !! html
12388 <table>
12389
12390
12391 <tr>
12392 <td>a
12393 </td></tr>
12394 </table>
12395
12396 !!end
12397
12398 ###
12399 ### Preprocessor precedence tests
12400 ### See: https://www.mediawiki.org/wiki/Preprocessor_ABNF
12401 ###
12402 ##{{[[-{{{{{{[[Foo|bar}}]]}-}}}}}]]
12403 !! test
12404 Preprocessor precedence 1: link is rightmost opening
12405 !! options
12406 parsoid=wt2html
12407 !! wikitext
12408 {{[[Foo|bar}}]]
12409
12410 But close-brace is not a valid character in a link title:
12411 {{[[Foo}}|bar]]
12412
12413 However, we can still tell this was handled as a link in the preprocessor:
12414 {{echo|[[Foo}}|bar]]|bat}}
12415 !! html/php
12416 <p>{{<a href="/wiki/Foo" title="Foo">bar}}</a>
12417 </p><p>But close-brace is not a valid character in a link title:
12418 {{[[Foo}}|bar]]
12419 </p><p>However, we can still tell this was handled as a link in the preprocessor:
12420 [[Foo}}|bar]]
12421 </p>
12422 !! html/parsoid
12423 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">bar}}</a></p>
12424 <p>But close-brace is not a valid character in a link title: {{[[Foo}}|bar]]</p>
12425 <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>
12426 !! end
12427
12428 !! test
12429 Preprocessor precedence 2: template is rightmost opening
12430 !! options
12431 language=zh
12432 !! wikitext
12433 -{{echo|foo}-}}-
12434 !! html/php
12435 <p>-foo}--
12436 </p>
12437 !! html/parsoid
12438 <p>-<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}-"}},"i":0}}]}'>foo}-</span>-</p>
12439 !! end
12440
12441 !! test
12442 Preprocessor precedence 3: language converter is rightmost opening
12443 !! options
12444 language=zh
12445 parsoid=wt2html
12446 !! wikitext
12447 {{echo|hi}}
12448
12449 {{-{R|echo|hi}}}-
12450
12451 [[-{R|raw]]}-
12452 !! html/php
12453 <p>hi
12454 </p><p>{{echo|hi}}
12455 </p><p>[[raw]]
12456 </p>
12457 !! html/parsoid
12458 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"}},"i":0}}]}'>hi</p>
12459 <p>{{<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"echo|hi}}"}}'></span></p>
12460 <p>[[<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw]]"}}'></span></p>
12461 !! end
12462
12463 !! test
12464 Preprocessor precedence 4: left-most angle bracket
12465 !! options
12466 language=zh
12467 !! wikitext
12468 <!--{raw}-->
12469 !! html/php
12470 !! html/parsoid
12471 <!--{raw}-->
12472 !! end
12473
12474 !! article
12475 Template:Precedence5
12476 !! text
12477 {{{{{1}}}}}
12478 !! endarticle
12479
12480 !! test
12481 Preprocessor precedence 5: tplarg takes precedence over template
12482 !! wikitext
12483 {{Precedence5|Bullet}}
12484 !! html/php
12485 <ul><li>Bar</li></ul>
12486
12487 !! html/parsoid
12488 <ul typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Precedence5","href":"./Template:Precedence5"},"params":{"1":{"wt":"Bullet"}},"i":0}}]}'><li>Bar</li></ul>
12489 !! end
12490
12491 !! test
12492 Preprocessor precedence 6: broken link is rightmost opening
12493 !! options
12494 parsoid=wt2html
12495 !! wikitext
12496 {{echo|[[Foo}}
12497
12498 {{echo|[[Foo|bar|bat=baz}}
12499 !! html/php
12500 <p>{{echo|[[Foo}}
12501 </p><p>{{echo|[[Foo|bar|bat=baz}}
12502 </p>
12503 !! html/parsoid
12504 <p>{{echo|[[Foo}}</p>
12505 <p>{{echo|[[Foo|bar|bat=baz}}</p>
12506 !! end
12507
12508 # This next test exposes a difference between PHP and Parsoid:
12509 # Given [[Foo|{{echo|Bar]]x}}y]]z:
12510 # 1) Both PHP and Parsoid ignore the `]]` inside the `echo` in the
12511 # "preprocessor" stage. The `{{echo` extends until the `x}}`, and the
12512 # outer `[[Foo` extends until the `y]]`
12513 # 2a) But then the PHP preprocessor emits `[[Foo|Bar]]xy]]z` as an
12514 # intermediate result (after template expansion), and link processing
12515 # happens on this intermediate result, which moves the wikilink
12516 # boundary leftward to `[[Foo|Bar]]`
12517 # 2b) Parsoid works in a single step, so it's going to keep the
12518 # wikilink as extending to the `y]]`
12519 # 3a) Then PHP does linktrail processing which slurps up the trailing
12520 # `xy` inside the link.
12521 # 3b) Parsoid will do linktrail processing to slurp up the trailing
12522 # `z` inside the link.
12523 # This is "correct" behavior. Parsoid's basic worldview is that the
12524 # `]]` inside the template shouldn't be allowed to leak out to affect
12525 # the surrounding wikilink. PHP may match Parsoid (in the future)
12526 # if you use {{#balance}} (T114445).
12527
12528 !! test
12529 Preprocessor precedence 7: broken template is rightmost opening
12530 !! options
12531 parsoid=wt2html
12532 !! wikitext
12533 [[Foo|{{echo|Bar]]
12534
12535 [[Foo|{{echo|Bar]]-x}}-y]]-z
12536
12537 Careful: linktrails can move the end of the wikilink:
12538 [[Foo|{{echo|y']]a}}l]]l
12539 !! html/php
12540 <p><a href="/wiki/Foo" title="Foo">{{echo|Bar</a>
12541 </p><p><a href="/wiki/Foo" title="Foo">Bar</a>-x-y]]-z
12542 </p><p>Careful: linktrails can move the end of the wikilink:
12543 <a href="/wiki/Foo" title="Foo">y'al</a>]]l
12544 </p>
12545 !! html/parsoid
12546 <p>[[Foo|{{echo|Bar]]</p>
12547 <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>
12548 <p>Careful: linktrails can move the end of the wikilink:
12549 <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>
12550 !! end
12551
12552 !! test
12553 Preprocessor precedence 8: broken language converter is rightmost opening
12554 !! options
12555 language=zh
12556 !! wikitext
12557 [[Foo-{R|raw]]
12558 !! html
12559 <p>[[Foo-{R|raw]]
12560 </p>
12561 !! end
12562
12563 !! article
12564 Template:Preprocessor_precedence_9
12565 !! text
12566 ;4: {{{{1}}}}
12567 ;5: {{{{{2}}}}}
12568 ;6: {{{{{{3}}}}}}
12569 ;7: {{{{{{{4}}}}}}}
12570 !! endarticle
12571
12572 !! test
12573 Preprocessor precedence 9: groups of braces
12574 !! wikitext
12575 {{Preprocessor precedence 9|Four|Bullet|1|2}}
12576 !! html/php
12577 <dl><dt>4</dt>
12578 <dd>{Four}</dd>
12579 <dt>5</dt>
12580 <dd></dd></dl>
12581 <ul><li>Bar</li></ul>
12582 <dl><dt>6</dt>
12583 <dd>Four</dd>
12584 <dt>7</dt>
12585 <dd>{Bullet}</dd></dl>
12586
12587 !! html/parsoid
12588 <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}}]}'>
12589 <dt>4</dt>
12590 <dd>{Four}</dd>
12591 <dt>5</dt>
12592 <dd></dd>
12593 </dl><ul about="#mwt1">
12594 <li>Bar</li>
12595 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12596 <dt>6</dt>
12597 <dd>Four</dd>
12598 <dt>7</dt>
12599 <dd>{Bullet}</dd>
12600 </dl>
12601 !! end
12602
12603 !! article
12604 Template:Preprocessor_precedence_10
12605 !! text
12606 ;1: -{R|raw}-
12607 ;2: -{{Bullet}}-
12608 ;3: -{{{1}}}-
12609 ;4: -{{{{2}}}}-
12610 ;5: -{{{{{3}}}}}-
12611 ;6: -{{{{{{4}}}}}}-
12612 ;7: -{{{{{{{5}}}}}}}-
12613 !! endarticle
12614
12615 !! test
12616 Preprocessor precedence 10: groups of braces with leading dash
12617 !! options
12618 language=zh
12619 !! wikitext
12620 {{Preprocessor precedence 10|Three|raw2|Bullet|1|2}}
12621 !! html/php
12622 <dl><dt>1</dt>
12623 <dd>raw</dd>
12624 <dt>2</dt>
12625 <dd>-</dd></dl>
12626 <ul><li>Bar-</li></ul>
12627 <dl><dt>3</dt>
12628 <dd>-Three-</dd>
12629 <dt>4</dt>
12630 <dd>raw2</dd>
12631 <dt>5</dt>
12632 <dd>-</dd></dl>
12633 <ul><li>Bar-</li></ul>
12634 <dl><dt>6</dt>
12635 <dd>-Three-</dd>
12636 <dt>7</dt>
12637 <dd>raw2</dd></dl>
12638
12639 !! html/parsoid
12640 <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}}]}'>
12641 <dt>1</dt>
12642 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw"}}'></span></dd>
12643 <dt>2</dt>
12644 <dd>-</dd>
12645 </dl><ul about="#mwt1">
12646 <li>Bar-</li>
12647 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12648 <dt>3</dt>
12649 <dd>-Three-</dd>
12650 <dt>4</dt>
12651 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12652 <dt>5</dt>
12653 <dd>-</dd>
12654 </dl><ul about="#mwt1">
12655 <li>Bar-</li>
12656 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12657 <dt>6</dt>
12658 <dd>-Three-</dd>
12659 <dt>7</dt>
12660 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12661 </dl>
12662 !! end
12663
12664 !! test
12665 Preprocessor precedence 11: found during visual diff testing
12666 !! wikitext
12667 {{#tag:span|-{{#tag:span|-{{echo|x}}}}}}
12668
12669 {{echo|-{{echo|-{{echo|x}}}}}}
12670
12671 {{echo|-{{echo|x}}}}
12672 !! html/php
12673 <p><span>-<span>-x</span></span>
12674 </p><p>--x
12675 </p><p>-x
12676 </p>
12677 !! html/parsoid
12678 <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>
12679
12680 <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>
12681
12682 <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>
12683 !! end
12684
12685 !! test
12686 Preprocessor precedence 12: broken language converter closed by brace.
12687 !! options
12688 parsoid=wt2html
12689 !! wikitext
12690 This form breaks the template, which is unfortunate:
12691 *{{echo|foo-{bar}bat}}
12692
12693 But if the broken language converter markup is inside an extension
12694 tag, nothing bad happens:
12695 *<nowiki>foo-{bar}bat</nowiki>
12696 *{{echo|<nowiki>foo-{bar}bat</nowiki>}}
12697 *<pre>foo-{bar}bat</pre>
12698 *{{echo|<pre>foo-{bar}bat</pre>}}
12699
12700 <tag>foo-{bar}bat</tag>
12701 {{echo|<tag>foo-{bar}bat</tag>}}
12702
12703 !! html/php+tidy
12704 <p>This form breaks the template, which is unfortunate:
12705 </p>
12706 <ul><li>{{echo|foo-{bar}bat}}</li></ul>
12707 <p>But if the broken language converter markup is inside an extension
12708 tag, nothing bad happens:
12709 </p>
12710 <ul><li>foo-&#123;bar}bat</li>
12711 <li>foo-&#123;bar}bat</li>
12712 <li><pre>foo-{bar}bat</pre></li>
12713 <li><pre>foo-{bar}bat</pre></li></ul>
12714 <pre>'foo-{bar}bat'
12715 array (
12716 )
12717 </pre>
12718 <pre>'foo-{bar}bat'
12719 array (
12720 )
12721 </pre>
12722 !! html/parsoid
12723 <p>This form breaks the template, which is unfortunate:</p>
12724 <ul>
12725 <li>{{echo|foo-{bar}bat}}</li>
12726 </ul>
12727 <p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p>
12728 <ul>
12729 <li><span typeof="mw:Nowiki">foo-{bar}bat</span></li>
12730 <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>
12731 <li><pre typeof="mw:Extension/pre" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo-{bar}bat"}}'>foo-{bar}bat</pre></li>
12732 <li><pre typeof="mw:Extension/pre mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;pre>foo-{bar}bat&lt;/pre>"}},"i":0}}]}'>foo-{bar}bat</pre></li>
12733 </ul>
12734 <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>
12735 !! end
12736
12737 !! test
12738 Preprocessor precedence 13: broken language converter in external link
12739 !! options
12740 parsoid=wt2html
12741 !! wikitext
12742 *[http://example.com/-{foo Example in URL]
12743 *[http://example.com Example in -{link} description]
12744 *{{echo|[http://example.com/-{foo Breaks template, however]}}
12745 !! html/php+tidy
12746 <ul><li><a rel="nofollow" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12747 <li><a rel="nofollow" class="external text" href="http://example.com">Example in -{link} description</a></li>
12748 <li>{{echo|<a rel="nofollow" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li></ul>
12749 !! html/parsoid
12750 <ul>
12751 <li><a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12752 <li><a rel="mw:ExtLink" class="external text" href="http://example.com">Example in -{link} description</a></li>
12753 <li>{{echo|<a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
12754 </ul>
12755 !! end
12756
12757 !! test
12758 Preprocessor precedence 14: broken language converter in comment
12759 !! wikitext
12760 *<!--{{foo}}-->...should be ok
12761 *<!---{{foo}}-->...extra dashes
12762 *{{echo|foo<!-- -{bar} -->bat}}...should be ok
12763 !! html/php+tidy
12764 <ul><li>...should be ok</li>
12765 <li>...extra dashes</li>
12766 <li>foobat...should be ok</li></ul>
12767 !! html/parsoid
12768 <ul>
12769 <li><!--{{foo}}-->...should be ok</li>
12770 <li><!--&#x2D;{{foo}}-->...extra dashes</li>
12771 <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>
12772 </ul>
12773 !! end
12774
12775 !! test
12776 Preprocessor precedence 15: broken brace markup in headings
12777 !! config
12778 wgFragmentMode=[ 'html5', 'legacy' ]
12779 !! options
12780 parsoid=wt2html
12781 !! wikitext
12782 __NOTOC__ __NOEDITSECTION__
12783 ===1 foo[bar 1===
12784 1
12785 ===2 foo[[bar 2===
12786 2
12787 ===3 foo{bar 3===
12788 3
12789 ===4 foo{{bar 4===
12790 4
12791 ===5 foo{{{bar 5===
12792 5
12793 ===6 foo-{bar 6===
12794 6
12795 !! html/php+tidy
12796 <h3><span id="1_foo.5Bbar_1"></span><span class="mw-headline" id="1_foo[bar_1">1 foo[bar 1</span></h3>
12797 <p>1
12798 </p>
12799 <h3><span id="2_foo.5B.5Bbar_2"></span><span class="mw-headline" id="2_foo[[bar_2">2 foo[[bar 2</span></h3>
12800 <p>2
12801 </p>
12802 <h3><span id="3_foo.7Bbar_3"></span><span class="mw-headline" id="3_foo{bar_3">3 foo{bar 3</span></h3>
12803 <p>3
12804 </p>
12805 <h3><span id="4_foo.7B.7Bbar_4"></span><span class="mw-headline" id="4_foo{{bar_4">4 foo{{bar 4</span></h3>
12806 <p>4
12807 </p>
12808 <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>
12809 <p>5
12810 </p>
12811 <h3><span id="6_foo-.7Bbar_6"></span><span class="mw-headline" id="6_foo-{bar_6">6 foo-{bar 6</span></h3>
12812 <p>6
12813 </p>
12814 !! html/parsoid
12815 <meta property="mw:PageProp/notoc"/> <meta property="mw:PageProp/noeditsection"/>
12816 <h3 id="1_foo[bar_1"><span id="1_foo.5Bbar_1" typeof="mw:FallbackId"></span>1 foo[bar 1</h3>
12817 <p>1</p>
12818 <h3 id="2_foo[[bar_2"><span id="2_foo.5B.5Bbar_2" typeof="mw:FallbackId"></span>2 foo[[bar 2</h3>
12819 <p>2</p>
12820 <h3 id="3_foo{bar_3"><span id="3_foo.7Bbar_3" typeof="mw:FallbackId"></span>3 foo{bar 3</h3>
12821 <p>3</p>
12822 <h3 id="4_foo{{bar_4"><span id="4_foo.7B.7Bbar_4" typeof="mw:FallbackId"></span>4 foo{{bar 4</h3>
12823 <p>4</p>
12824 <h3 id="5_foo{{{bar_5"><span id="5_foo.7B.7B.7Bbar_5" typeof="mw:FallbackId"></span>5 foo{{{bar 5</h3>
12825 <p>5</p>
12826 <h3 id="6_foo-{bar_6"><span id="6_foo-.7Bbar_6" typeof="mw:FallbackId"></span>6 foo-{bar 6</h3>
12827 <p>6</p>
12828 !! end
12829
12830 !! test
12831 Preprocessor precedence 16: matching closing braces to opening braces
12832 !! options
12833 language=zh
12834 parsoid=wt2html
12835 !! wikitext
12836 -{{{echo|foo}}bar}-
12837 !! html/php
12838 <p>foobar
12839 </p>
12840 !! html/parsoid
12841 <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>
12842 !! end
12843
12844 !! test
12845 Preprocessor precedence 17: template w/o target shouldn't prevent closing
12846 !! options
12847 parsoid=wt2html
12848 !! wikitext
12849 {{echo|hi {{}}}}
12850 !! html/php
12851 <p>hi {{}}
12852 </p>
12853 !! html/parsoid
12854 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi {{}}"}},"i":0}}]}'>hi {{}}</p>
12855 !! end
12856
12857 # Ensure we're using a language without variants for this test; even
12858 # if $wgUsePigLatinVariant is true. We've picked `de` arbitrarily.
12859 !! test
12860 Preprocessor precedence 18: another rightmost wins scenario
12861 !! options
12862 parsoid=wt2html
12863 language=de
12864 !! wikitext
12865 {{ -{{{{1|tplarg}}} }} }-
12866 !! html/php
12867 <p>{{ -{tplarg }} }-
12868 </p>
12869 !! html/parsoid
12870 <p>{{ -{<span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"1"},"params":{"1":{"wt":"tplarg"}},"i":0}}]}'>tplarg</span> }} }-</p>
12871 !! end
12872
12873 !! test
12874 Preprocessor precedence 19: break syntax
12875 !! options
12876 parsoid=wt2html
12877 !! wikitext
12878 -{{
12879 !! html/php
12880 <p>-{{
12881 </p>
12882 !! html/parsoid
12883 <p>-{{</p>
12884 !! end
12885
12886 ###
12887 ### Token Stream Patcher tests
12888 ###
12889 ### These tests won't always pass wt2wt and other modes because
12890 ### on serialization, the table will be output on a new line.
12891 ### For now, we are blacklisting them, and using this to test selser.
12892 ###
12893
12894 !!test
12895 1. Table tag in SOL posn. should get reparsed correctly with valid TSR
12896 !!options
12897 parsoid=wt2html,wt2wt
12898 !!wikitext
12899 {{echo|}}{| width = '100%'
12900 |foo
12901 |}
12902 !!html/parsoid
12903 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":""}},"i":0}}]}'></span><table width="100%">
12904 <tbody><tr><td>foo</td></tr>
12905 </tbody></table>
12906 !!end
12907
12908 ## We used to, but no longer wt2wt this test since the default serializer
12909 ## will normalize the include directives to serialize on their own line.
12910 ## Selser will take care of preserving formatting in scenarios where they
12911 ## intermingled with other wikitext.
12912 !!test
12913 2. Table tag in SOL posn. should get reparsed correctly with valid TSR
12914 !!options
12915 parsoid=wt2html
12916 !!wikitext
12917 <includeonly>a</includeonly>{| {{{b}}}
12918 |c
12919 |}
12920 !!html/parsoid
12921 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>a&lt;/includeonly>"}' data-mw='{"src":"&lt;includeonly>a&lt;/includeonly>"}'/><meta typeof="mw:Includes/IncludeOnly/End" data-parsoid='{"src":""}'/><table about="#mwt2" typeof="mw:ExpandedAttrs" data-parsoid='{"a":{"{{{b}}}":null},"sa":{"{{{b}}}":""}}' data-mw='{"attribs":[[{"txt":"{{{b}}}","html":"&lt;span about=\"#mwt1\" typeof=\"mw:Param\" data-parsoid=&#39;{\"pi\":[[]],\"dsr\":[31,38,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"templatearg\":{\"target\":{\"wt\":\"b\"},\"params\":{},\"i\":0}}]}&#39;>{{{b}}}&lt;/span>"},{"html":""}]]}'>
12922 <tbody><tr><td>c</td></tr>
12923 </tbody></table>
12924 !!end
12925
12926 !! test
12927 Table wikitext syntax outside wiki-tables
12928 !! wikitext
12929 a
12930 |+ not a caption
12931 ! not a table heading
12932 |- not a table row
12933 | not a table cell
12934 | class="foo bar" | baz
12935 b
12936 |}
12937 |-
12938 c
12939 !! html
12940 <p>a
12941 |+ not a caption
12942 ! not a table heading
12943 |- not a table row
12944 | not a table cell
12945 | class="foo bar" | baz
12946 b
12947 |}
12948 |-
12949 c
12950 </p>
12951 !! end
12952
12953 ###
12954 ### Testing parsing of templates where a template arg
12955 ### has the same name as the template itself.
12956 ###
12957
12958 !! article
12959 Template:quote
12960 !! text
12961 {{{quote|{{{1}}}}}}
12962 !! endarticle
12963
12964 !!test
12965 Templates: Template Name/Arg clash: 1. Use of positional param
12966 !! wikitext
12967 {{quote|foo}}
12968 !! html
12969 <p>foo
12970 </p>
12971 !!end
12972
12973 !!test
12974 Templates: Template Name/Arg clash: 2. Use of named param
12975 !! wikitext
12976 {{quote|quote=foo}}
12977 !! html
12978 <p>foo
12979 </p>
12980 !!end
12981
12982 !!test
12983 Templates: Template Name/Arg clash: 3. Use of named param with empty input
12984 !! wikitext
12985 {{quote|quote}}
12986 !! html
12987 <p>quote
12988 </p>
12989 !!end
12990
12991 ###
12992 ### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
12993 ###
12994
12995 !!test
12996 Templates: 1. Simple use
12997 !! wikitext
12998 {{echo|Foo}}
12999 !! html
13000 <p>Foo
13001 </p>
13002 !!end
13003
13004 !!test
13005 Templates: 2. Inside a block tag
13006 !! wikitext
13007 <div>{{echo|Foo}}</div>
13008 <blockquote>{{echo|Foo}}</blockquote>
13009 !! html
13010 <div>Foo</div>
13011 <blockquote>Foo</blockquote>
13012
13013 !! html+tidy
13014 <div>Foo</div>
13015 <blockquote><p>Foo</p></blockquote>
13016 !!end
13017
13018 !!test
13019 Templates: P-wrapping: 1a. Templates on consecutive lines
13020 !! wikitext
13021 {{echo|Foo}}
13022 {{echo|bar}}
13023 !! html
13024 <p>Foo
13025 bar
13026 </p>
13027 !!end
13028
13029 !!test
13030 Templates: P-wrapping: 1b. Templates on consecutive lines
13031 !! wikitext
13032 Foo
13033
13034 {{echo|bar}}
13035 {{echo|baz}}
13036 !! html
13037 <p>Foo
13038 </p><p>bar
13039 baz
13040 </p>
13041 !!end
13042
13043 !!test
13044 Templates: P-wrapping: 1c. Templates on consecutive lines
13045 !! wikitext
13046 {{echo|Foo}}
13047 {{echo|bar}} <div>baz</div>
13048 !! html
13049 <p>Foo
13050 </p>
13051 bar <div>baz</div>
13052
13053 !! html+tidy
13054 <p>Foo
13055 </p><p>
13056 bar </p><div>baz</div>
13057 !! end
13058
13059 !! test
13060 Templates: P-wrapping: 1d. Template preceded by comment-only line
13061 !! wikitext
13062 <!-- foo -->
13063 {{echo|Bar}}
13064 !! html/php+tidy
13065 <p>Bar
13066 </p>
13067 !! html/parsoid
13068 <!-- foo -->
13069
13070 <p about="#mwt223" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar"}},"i":0}}]}'>Bar</p>
13071 !!end
13072
13073 !! test
13074 Templates: Scopes should not be expanded unnecessarily
13075 !! options
13076 parsoid=wt2html,wt2wt
13077 !! wikitext
13078 {{echo|<div>a</div>}}b{{echo|
13079 <div>c</div>}}
13080 !! html/php+tidy
13081 <div>a</div><p>b
13082 </p><div>c</div>
13083 !! html/parsoid
13084 <div about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;div>a&lt;/div>"}},"i":0}}]}'>a</div><p>b</p><span about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"\n&lt;div>c&lt;/div>"}},"i":0}}]}'>
13085 </span><div about="#mwt2">c</div>
13086 !! end
13087
13088 !!test
13089 Templates: Inline Text: 1. Multiple template uses
13090 !! wikitext
13091 {{echo|Foo}}bar{{echo|baz}}
13092 !! html
13093 <p>Foobarbaz
13094 </p>
13095 !!end
13096
13097 !!test
13098 Templates: Inline Text: 2. Back-to-back template uses
13099 !! wikitext
13100 {{echo|Foo}}{{echo|bar}}
13101 !! html
13102 <p>Foobar
13103 </p>
13104 !!end
13105
13106 !!test
13107 Templates: Block Tags: 1. Multiple template uses
13108 !! wikitext
13109 {{echo|<div>Foo</div>}}<div>bar</div>{{echo|<div>baz</div>}}
13110 !! html
13111 <div>Foo</div><div>bar</div><div>baz</div>
13112
13113 !!end
13114
13115 !!test
13116 Templates: Block Tags: 2. Back-to-back template uses
13117 !! wikitext
13118 {{echo|<div>Foo</div>}}{{echo|<div>bar</div>}}
13119 !! html
13120 <div>Foo</div><div>bar</div>
13121
13122 !!end
13123
13124 ## Parsoid drops empty elements in templates.
13125 !! test
13126 Templates: Correctly encapsulate templates producing </p> tag without a corresponding <p> tag
13127 !! wikitext
13128 {{echo|a
13129 b</p>}}
13130 !! html/php+tidy
13131 <p>a
13132 </p><p>
13133 b</p><p class="mw-empty-elt"></p>
13134 !! html/parsoid
13135 <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">
13136 </span><p about="#mwt1">b</p>
13137 !! end
13138
13139 !!test
13140 Templates: Links: 1. Simple example
13141 !! wikitext
13142 {{echo|[[Foo|bar]]}}
13143 !! html
13144 <p><a href="/wiki/Foo" title="Foo">bar</a>
13145 </p>
13146 !!end
13147
13148 !!test
13149 Templates: Links: 2. Generation of link href
13150 !! wikitext
13151 [[{{echo|Foo}}|bar]]
13152 !! html
13153 <p><a href="/wiki/Foo" title="Foo">bar</a>
13154 </p>
13155 !!end
13156
13157 !!test
13158 Templates: Links: 3. Generation of part of a link href
13159 !! wikitext
13160 [[Fo{{echo|o}}|bar]]
13161
13162 [[Foo{{echo|bar}}]]
13163
13164 [[Foo{{echo|bar}}baz]]
13165
13166 [[Foo{{echo|bar}}|bar]]
13167
13168 [[:Foo{{echo|bar}}]]
13169
13170 [[:Foo{{echo|bar}}|bar]]
13171 !! html
13172 <p><a href="/wiki/Foo" title="Foo">bar</a>
13173 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
13174 </p><p><a href="/index.php?title=Foobarbaz&amp;action=edit&amp;redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a>
13175 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
13176 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
13177 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
13178 </p>
13179 !!end
13180
13181 !!test
13182 Templates: Links: 4. Multiple templates generating link href
13183 !! wikitext
13184 [[{{echo|F}}{{echo|o}}ob{{echo|ar}}]]
13185 !! html
13186 <p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
13187 </p>
13188 !!end
13189
13190 !!test
13191 Templates: Links: 5. Generation of link text
13192 !! wikitext
13193 [[Foo|{{echo|bar}}]]
13194 !! html
13195 <p><a href="/wiki/Foo" title="Foo">bar</a>
13196 </p>
13197 !!end
13198
13199 !!test
13200 Templates: Links: 5. Nested templates (only outermost template should be marked)
13201 !! wikitext
13202 {{echo|[[{{echo|Foo}}|bar]]}}
13203 !! html
13204 <p><a href="/wiki/Foo" title="Foo">bar</a>
13205 </p>
13206 !!end
13207
13208 !!test
13209 Templates: HTML Tag: 1. Generation of HTML attr. key
13210 !! wikitext
13211 <div {{echo|style}}="color:red;">foo</div>
13212 !! html
13213 <div style="color:red;">foo</div>
13214
13215 !!end
13216
13217 !!test
13218 Templates: HTML Tag: 2. Generation of HTML attr. value
13219 !! wikitext
13220 <div style={{echo|'color:red;'}}>foo</div>
13221 !! html
13222 <div style="color:red;">foo</div>
13223
13224 !!end
13225
13226 !!test
13227 Templates: HTML Tag: 3. Generation of HTML attr key and value
13228 !! wikitext
13229 <div {{echo|style}}={{echo|'color:red;'}}>foo</div>
13230 !! html
13231 <div style="color:red;">foo</div>
13232
13233 !!end
13234
13235 !!test
13236 Templates: HTML Tag: 4. Generation of starting piece of HTML attr value
13237 !! wikitext
13238 <div title="{{echo|This is a long title}} with just one piece templated">foo</div>
13239 !! html
13240 <div title="This is a long title with just one piece templated">foo</div>
13241
13242 !!end
13243
13244 !!test
13245 Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
13246 !! wikitext
13247 <div title="This is a long title with just {{echo|one piece}} templated">foo</div>
13248 !! html
13249 <div title="This is a long title with just one piece templated">foo</div>
13250
13251 !!end
13252
13253 !!test
13254 Templates: HTML Tag: 6. Generation of end piece of HTML attr value
13255 !! wikitext
13256 <div title="This is a long title with just one piece {{echo|templated}}">foo</div>
13257 !! html
13258 <div title="This is a long title with just one piece templated">foo</div>
13259
13260 !!end
13261
13262 # SSS FIXME: While it is great we added support for all this,
13263 # do we want to make this part of the spec? Maybe we want to
13264 # deprecate this kind of usage in the future?
13265 !!test
13266 Templates: HTML Tag: 7. Generation of partial attribute key string
13267 !! wikitext
13268 <div st{{echo|yle}}="color:red;">foo</div>
13269 !! html
13270 <div style="color:red;">foo</div>
13271
13272 !!end
13273
13274 !! test
13275 Templates: HTML Tag: 8. Template-generated attribute (k=v)
13276 !! wikitext
13277 <div {{echo|1=id="v1"}}>bar</div>
13278 !! html
13279 <div id="v1">bar</div>
13280
13281 !!end
13282
13283 !! test
13284 Templates: HTML Tag: 9. Multiple template-generated attributes
13285 !! wikitext
13286 <div {{echo|1=id="v1" title="foo"}}>bar</div>
13287 !! html
13288 <div id="v1" title="foo">bar</div>
13289
13290 !!end
13291
13292 !! test
13293 Templates: Support for templates generating attributes and content
13294 !! wikitext
13295 {| {{mixed_attr_content_template}}
13296 |-
13297 |bar
13298 |}
13299 !! html/php
13300 <table style="color:red;" title="T48811">
13301
13302 <tr>
13303 <td>foo
13304 </td></tr>
13305 <tr>
13306 <td>bar
13307 </td></tr></table>
13308
13309 !! html/parsoid
13310 <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|}"]}'>
13311 <tbody><tr>
13312 <td>foo</td></tr>
13313 <tr>
13314 <td>bar</td></tr>
13315 </tbody></table>
13316 !!end
13317
13318 !! article
13319 Template:attribute_from_template
13320 !! text
13321 class="123"
13322 !! endarticle
13323
13324 !! test
13325 Table cell with attribute before expanded attribute
13326 !! wikitext
13327 {|
13328 | align="center" {{attribute_from_template}} |456
13329 |}
13330 !! html/parsoid
13331 <table>
13332 <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>
13333 </tbody></table>
13334 !! end
13335
13336 !! test
13337 1. Entities and nowikis inside templated attributes should be handled correctly
13338 !! wikitext
13339 <div {{echo|style{{=}}"background:&#35;f9f9f9;"}}>foo</div>
13340 !! html/php
13341 <div style="background:#f9f9f9;">foo</div>
13342
13343 !! html/parsoid
13344 <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>
13345 !! end
13346
13347 !! test
13348 2. Entities and nowikis inside templated attributes should be handled correctly
13349 !! wikitext
13350 {|
13351 |{{table_attribs_3}}
13352 |}
13353 !! html/php
13354 <table>
13355 <tr>
13356 <td style="background:#f9f9f9;">Foo
13357 </td></tr></table>
13358
13359 !! html/parsoid
13360 <table>
13361 <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>
13362 </tbody></table>
13363 !! end
13364
13365 !! test
13366 3. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13367 !! wikitext
13368 {{tbl-start}}
13369 |{{table_attribs_3}}
13370 {{tbl-end}}
13371 !! html/php
13372 <table>
13373 <tr>
13374 <td style="background:#f9f9f9;">Foo
13375 </td></tr></table>
13376
13377 !! html/parsoid
13378 <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}}]}'>
13379 <tbody><tr><td style="background:#f9f9f9;">Foo</td></tr>
13380 </tbody></table>
13381 !! end
13382
13383 # T107622
13384 !! test
13385 4. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13386 !! wikitext
13387 {|
13388 |{{table_attribs_6}} hi
13389 |}
13390 !! html/php
13391 <table>
13392 <tr>
13393 <td style="background: red;">hi
13394 </td></tr></table>
13395
13396 !! html/parsoid
13397 <table>
13398 <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>
13399 </tbody></table>
13400 !! end
13401
13402 !!test
13403 Templates: HTML Tables: 1. Generating start of a HTML table
13404 !! wikitext
13405 {{echo|<table><tr><td>foo</td>}}</tr></table>
13406 !! html
13407 <table><tr><td>foo</td></tr></table>
13408
13409 !!end
13410
13411 !!test
13412 Templates: HTML Tables: 2a. Generating middle of a HTML table
13413 !! wikitext
13414 <table><tr>{{echo|<td>foo</td>}}</tr></table>
13415 !! html
13416 <table><tr><td>foo</td></tr></table>
13417
13418 !!end
13419
13420 !!test
13421 Templates: HTML Tables: 2b. Generating middle of a HTML table
13422 !! wikitext
13423 <table>{{echo|<tr><td>foo</td></tr>}}</table>
13424 !! html
13425 <table><tr><td>foo</td></tr></table>
13426
13427 !!end
13428
13429 !!test
13430 Templates: HTML Tables: 3. Generating end of a HTML table
13431 !! wikitext
13432 <table><tr>{{echo|<td>foo</td></tr></table>}}
13433 !! html
13434 <table><tr><td>foo</td></tr></table>
13435
13436 !!end
13437
13438 !!test
13439 Templates: HTML Tables: 4a. Generating a single tag of a HTML table
13440 !! wikitext
13441 {{echo|<table>}}<tr><td>foo</td></tr></table>
13442 !! html
13443 <table><tr><td>foo</td></tr></table>
13444
13445 !!end
13446
13447 !!test
13448 Templates: HTML Tables: 4b. Generating a single tag of a HTML table
13449 !! wikitext
13450 <table>{{echo|<tr>}}<td>foo</td></tr></table>
13451 !! html
13452 <table><tr><td>foo</td></tr></table>
13453
13454 !!end
13455
13456 !!test
13457 Templates: HTML Tables: 4c. Generating a single tag of a HTML table
13458 !! wikitext
13459 <table><tr>{{echo|<td>}}foo</td></tr></table>
13460 !! html
13461 <table><tr><td>foo</td></tr></table>
13462
13463 !!end
13464
13465 !!test
13466 Templates: HTML Tables: 4d. Generating a single tag of a HTML table
13467 !! wikitext
13468 <table><tr><td>foo{{echo|</td>}}</tr></table>
13469 !! html
13470 <table><tr><td>foo</td></tr></table>
13471
13472 !!end
13473
13474 !!test
13475 Templates: HTML Tables: 4e. Generating a single tag of a HTML table
13476 !! wikitext
13477 <table><tr><td>foo</td>{{echo|</tr>}}</table>
13478 !! html
13479 <table><tr><td>foo</td></tr></table>
13480
13481 !!end
13482
13483 !!test
13484 Templates: HTML Tables: 4f. Generating a single tag of a HTML table
13485 !! wikitext
13486 <table><tr><td>foo</td></tr>{{echo|</table>}}
13487 !! html
13488 <table><tr><td>foo</td></tr></table>
13489
13490 !!end
13491
13492 !!test
13493 Templates: HTML Tables: 5. Proper fostering of categories from inside
13494 !!options
13495 parsoid=wt2html,wt2wt
13496 !! wikitext
13497 <table>[[Category:foo1]]<tr><td>foo</td></tr></table>
13498 <!--Two categories (T52330)-->
13499 <table>[[Category:bar1]][[Category:bar2]]<tr><td>foo</td></tr></table>
13500 !! html/php+tidy
13501 <table><tbody><tr><td>foo</td></tr></tbody></table>
13502 <table><tbody><tr><td>foo</td></tr></tbody></table>
13503 !! html/parsoid
13504 <link rel="mw:PageProp/Category" href="./Category:Foo1"><table><tbody><tr><td>foo</td></tr></tbody></table>
13505 <!--Two categories (T52330)-->
13506 <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>
13507 !!end
13508
13509 ## Remex doesn't account for fostered content.
13510 !! test
13511 Templates: Wiki Tables: 1a. Fostering of entire template content
13512 !! wikitext
13513 {|
13514 {{echo|a}}
13515 |}
13516 !! html/php
13517 <table>
13518 a
13519 <tr><td></td></tr></table>
13520
13521 !! html/php+tidy
13522
13523 a
13524 <table><tbody><tr><td></td></tr></tbody></table>
13525 !! html/parsoid
13526 <p about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE","pi":[[{"k":"1"}]]}' data-mw='{"parts":["{|\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a"}},"i":0}},"\n|}"]}'>a</p><table about="#mwt2">
13527
13528 </table>
13529 !! end
13530
13531 !!test
13532 Templates: Wiki Tables: 1b. Fostering of entire template content
13533 !! wikitext
13534 {|
13535 {{echo|<div>}}
13536 foo
13537 {{echo|</div>}}
13538 |}
13539 !! html
13540 <table>
13541 <div>
13542 <p>foo
13543 </p>
13544 </div>
13545 <tr><td></td></tr></table>
13546
13547 !! html/php+tidy
13548 <div>
13549 <p>foo
13550 </p>
13551 </div><table>
13552
13553 <tbody><tr><td></td></tr></tbody></table>
13554 !! html/parsoid
13555 <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|}"]}'>
13556 <p>foo</p>
13557 </div><table about="#mwt3">
13558
13559 </table>
13560 !! end
13561
13562 ## Remex doesn't account for fostered content.
13563 !! test
13564 Templates: Wiki Tables: 2. Fostering of partial template content
13565 !! wikitext
13566 {|
13567 {{echo|a
13568 <div>b</div>}}
13569 |}
13570 !! html/php
13571 <table>
13572 a
13573 <div>b</div>
13574 <tr><td></td></tr></table>
13575
13576 !! html/php+tidy
13577
13578 a
13579 <div>b</div><table>
13580 <tbody><tr><td></td></tr></tbody></table>
13581 !! html/parsoid
13582 <p about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE","pi":[[{"k":"1"}]]}' data-mw='{"parts":["{|\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n&lt;div>b&lt;/div>"}},"i":0}},"\n|}"]}'>a</p><div about="#mwt2">b</div><table about="#mwt2">
13583
13584
13585 </table>
13586 !! end
13587
13588 !!test
13589 Templates: Wiki Tables: 3. td-content via multiple templates
13590 !! wikitext
13591 {|
13592 {{echo|{{pipe}}a}}{{echo|b}}
13593 |}
13594 !! html
13595 <table>
13596 <tr>
13597 <td>ab
13598 </td></tr></table>
13599
13600 !!end
13601
13602 !!test
13603 Templates: Wiki Tables: 4. Templated tags, no content
13604 !! wikitext
13605 {{tbl-start}}
13606 {{tbl-end}}
13607 !! html
13608 <table>
13609 <tr><td></td></tr></table>
13610
13611 !!end
13612
13613 !!test
13614 Templates: Wiki Tables: 5. Templated tags, regular td-tags
13615 !! wikitext
13616 {{tbl-start}}
13617 |foo
13618 {{tbl-end}}
13619 !! html
13620 <table>
13621 <tr>
13622 <td>foo
13623 </td></tr></table>
13624
13625 !!end
13626
13627 !!test
13628 Templates: Wiki Tables: 6. Templated tags, templated td-tags
13629 !! wikitext
13630 {{tbl-start}}
13631 {{!}}foo
13632 {{tbl-end}}
13633 !! html
13634 <table>
13635 <tr>
13636 <td>foo
13637 </td></tr></table>
13638
13639 !!end
13640
13641 ## This test case is very specific to Parsoid's internals
13642 ## and is hence only tested for Parsoid's code. Parsoid uses
13643 ## a <meta> marker tag for <ref> tags and they are expanded
13644 ## much later. We are verifying that this <meta> tag usage
13645 ## doesn't prevent foster parenting.
13646 !! test
13647 Templates: Wiki Tables: 7. Fosterable <ref>s should get fostered
13648 !! wikitext
13649 {{PartialTable}}<ref>foo</ref>
13650 |}
13651
13652 <references />
13653 !! html/parsoid
13654 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"PartialTable","href":"./Template:PartialTable"},"params":{},"i":0}},"&lt;ref>foo&lt;/ref>\n|}"]}'><sup about="#mwt3" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{},"body":{"id":"mw-reference-text-cite_note-1"}}'><a href="./Parser_test#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup></p><table about="#mwt2">
13655 <tbody>
13656 </tbody></table>
13657
13658 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Parser_test#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">foo</span></li></ol>
13659 !! end
13660
13661 !! test
13662 Templates: Wiki Tables: 8. Fosterable meta-tags should get fostered
13663 !! wikitext
13664 {{echo|
13665 {{{!}}
13666 {{!}}-}}
13667 <onlyinclude>
13668 |foo
13669 </onlyinclude>
13670 {{!}}}
13671 !! html/parsoid
13672 <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{{!}}}"]}'>
13673 </span><meta typeof="mw:Includes/OnlyInclude" about="#mwt1"/><table about="#mwt1">
13674 <tbody><tr>
13675
13676 <td>foo
13677 <meta typeof="mw:Includes/OnlyInclude/End"/></td></tr>
13678 </tbody></table>
13679 !! end
13680
13681 !!test
13682 Templates: Lists: Multi-line list-items via templates
13683 !! wikitext
13684 *{{echo|a {{nonexistent|
13685 unused}}}}
13686 *{{echo|b {{nonexistent|
13687 unused}}}}
13688 !! html
13689 <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>
13690 <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>
13691
13692 !!end
13693
13694 !!test
13695 Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo)
13696 !! wikitext
13697 {{echo|''a}}{{echo|b''c''d}}{{echo|''e}}
13698 !! html
13699 <p><i>ab</i>c<i>d</i>e
13700 </p>
13701 !!end
13702
13703 !!test
13704 Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span)
13705 (PHP parser generates misnested html)
13706 !! wikitext
13707 {{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}}
13708 !! html/parsoid
13709 <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>
13710 !!end
13711
13712 !!test
13713 Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div)
13714 (PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s)
13715 !! options
13716 parsoid=wt2html,wt2wt
13717 !! wikitext
13718 {{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}}
13719 !! html/php+tidy
13720 <div><i>a</i></div><div><i>b</i>c<i>d</i></div><div>e</div>
13721 !! html/parsoid
13722 <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>
13723 <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>
13724 <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>
13725 !!end
13726
13727 !!test
13728 Templates: Ugly nesting: 4. Divs opened/closed across templates
13729 !! wikitext
13730 a<div>b{{echo|c</div>d}}e
13731 !! html
13732 a<div>bc</div>de
13733
13734 !! html+tidy
13735 <p>a</p><div>bc</div><p>de
13736 </p>
13737 !! end
13738
13739 !! test
13740 Templates: Ugly templates: 3. newline-only template parameter
13741 !! wikitext
13742 foo {{echo|
13743 }}
13744 !! html
13745 <p>foo
13746 </p>
13747 !! end
13748
13749 # This looks like a bug: a single newline triggers p/br for some reason.
13750 !! test
13751 Templates: Ugly templates: 4. newline-only template parameter inconsistency
13752 !! wikitext
13753 {{echo|
13754 }}
13755 !! html
13756 <p><br />
13757 </p>
13758 !! end
13759
13760 # T66017 -- ugly wikitext with fostered content generates two template ranges that
13761 # have a true overlap (T1-start - T2-start - T1-end - T2-end).
13762 !! test
13763 Templates: Ugly templates: 5. Template encapsulation test: Non-trivial overlap of template ranges is properly handled
13764 !! wikitext
13765 {{echo|<table>}}
13766 {{echo|<div>foo}}
13767 {{echo|</table>}}
13768 !! html/parsoid
13769 <div about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","autoInsertedEnd":true,"pi":[[{"k":"1"}],[{"k":"1"}],[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;table>"}},"i":0}},"\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;div>foo"}},"i":1}},"\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;/table>"}},"i":2}}]}'>foo</div><span about="#mwt1">
13770 </span><table about="#mwt1">
13771 </table>
13772 !! end
13773
13774 # T66017 -- ugly wikitext with fostered content generates two template ranges
13775 # that are "identical" and generate nesting cycles in the algorithm
13776 !! test
13777 Templates: Ugly templates: 6. Template encapsulation test: Cyclical nesting of template ranges is properly handled
13778 !! wikitext
13779 {{echo|<table><tr><td><table>}}
13780 {{echo|<div>}}
13781 {{echo|</div>}}
13782 !! html/parsoid
13783 <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"}'>
13784 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13785 </table></td></tr></tbody></table>
13786 !! end
13787
13788 !! test
13789 Templates: Parameters substituted at the top-level
13790 !! wikitext
13791 {{{foo|''who'' {{echo|me}}? '''never!'''}}}
13792
13793 {{{foo|bar|baz}}}
13794 !! html/php
13795 <p><i>who</i> me? <b>never!</b>
13796 </p><p>bar
13797 </p>
13798 !! html/parsoid
13799 <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>
13800
13801 <p about="#mwt3" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"foo"},"params":{"1":{"wt":"bar"},"2":{"wt":"baz"}},"i":0}}]}'>bar</p>
13802 !! end
13803
13804 !! test
13805 Templates: Param with empty arg in the final position
13806 !! wikitext
13807 {{{hi|}}}
13808 !! html/parsoid
13809 <span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"hi"},"params":{"1":{"wt":""}},"i":0}}]}'></span>
13810 !! end
13811
13812 !!test
13813 Parser Functions: 1. Simple example
13814 !! wikitext
13815 {{uc:foo}}
13816 !! html
13817 <p>FOO
13818 </p>
13819 !!end
13820
13821 !!test
13822 Parser Functions: 2. Nested use (only outermost should be marked up)
13823 !! wikitext
13824 {{uc:{{lc:FOO}}}}
13825 !! html
13826 <p>FOO
13827 </p>
13828 !!end
13829
13830 ## Note that the templates inside the references are not wrapped
13831 !! test
13832 Template nested in extension tag in template
13833 !! options
13834 title=[[Main Page]]
13835 language=zh
13836 !! wikitext
13837 {{echo|hi<ref>[[ho|{{echo|hi}}]]</ref>}}
13838 {{echo|hi<ref>[http://test.com?q={{echo|ho}}]</ref>}}
13839 {{echo|hi<ref>-{ho|{{echo|hi}}}-</ref>}}
13840 <references />
13841 !! html/parsoid
13842 <p><span about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi&lt;ref>[[ho|{{echo|hi}}]]&lt;/ref>"}},"i":0}}]}'>hi</span><sup about="#mwt2" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{},"body":{"id":"mw-reference-text-cite_note-1"}}'><a href="./Main_Page#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup>
13843 <span about="#mwt8" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi&lt;ref>[http://test.com?q={{echo|ho}}]&lt;/ref>"}},"i":0}}]}'>hi</span><sup about="#mwt8" class="mw-ref" id="cite_ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{},"body":{"id":"mw-reference-text-cite_note-2"}}'><a href="./Main_Page#cite_note-2" style="counter-reset: mw-Ref 2;"><span class="mw-reflink-text">[2]</span></a></sup>
13844 <span about="#mwt13" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi&lt;ref>-{ho|{{echo|hi}}}-&lt;/ref>"}},"i":0}}]}'>hi</span><sup about="#mwt13" class="mw-ref" id="cite_ref-3" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{},"body":{"id":"mw-reference-text-cite_note-3"}}'><a href="./Main_Page#cite_note-3" style="counter-reset: mw-Ref 3;"><span class="mw-reflink-text">[3]</span></a></sup></p>
13845 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt17" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text"><a rel="mw:WikiLink" href="./Ho" title="Ho">hi</a></span></li><li about="#cite_note-2" id="cite_note-2"><a href="./Main_Page#cite_ref-2" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-2" class="mw-reference-text"><a rel="mw:ExtLink" class="external autonumber" href="http://test.com?q=ho"></a></span></li><li about="#cite_note-3" id="cite_note-3"><a href="./Main_Page#cite_ref-3" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-3" class="mw-reference-text"><span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["ho"],"t":"hi"}}'></span></span></li></ol>
13846 !! end
13847
13848 ###
13849 ### Pre-save transform tests
13850 ###
13851
13852 !! test
13853 pre-save transform: subst:
13854 !! options
13855 pst
13856 !! wikitext
13857 {{subst:test}}
13858 !! html/php
13859 This is a test template
13860 !! end
13861
13862 !! test
13863 pre-save transform: normal template
13864 !! options
13865 pst
13866 !! wikitext
13867 {{test}}
13868 !! html/php
13869 {{test}}
13870 !! end
13871
13872 !! test
13873 pre-save transform: nonexistent template
13874 !! options
13875 pst
13876 !! wikitext
13877 {{thistemplatedoesnotexist}}
13878 !! html/php
13879 {{thistemplatedoesnotexist}}
13880 !! end
13881
13882 !! test
13883 pre-save transform: subst magic variables
13884 !! options
13885 pst
13886 !! wikitext
13887 {{subst:SITENAME}}
13888 !! html/php
13889 MediaWiki
13890 !! end
13891
13892 # This is T2089, which I fixed. -- wtm
13893 !! test
13894 pre-save transform: subst: templates with parameters
13895 !! options
13896 pst
13897 !! wikitext
13898 {{subst:paramtest|param="something else"}}
13899 !! html/php
13900 This is a test template with parameter "something else"
13901 !! end
13902
13903 !! article
13904 Template:nowikitest
13905 !! text
13906 <nowiki>'''not wiki'''</nowiki>
13907 !! endarticle
13908
13909 !! test
13910 pre-save transform: nowiki in subst (T3188)
13911 !! options
13912 pst
13913 !! wikitext
13914 {{subst:nowikitest}}
13915 !! html/php
13916 <nowiki>'''not wiki'''</nowiki>
13917 !! end
13918
13919 !! article
13920 Template:commenttest
13921 !! text
13922 This template has <!-- a comment --> in it.
13923 !! endarticle
13924
13925 !! test
13926 pre-save transform: comment in subst (T3936)
13927 !! options
13928 pst
13929 !! wikitext
13930 {{subst:commenttest}}
13931 !! html/php
13932 This template has <!-- a comment --> in it.
13933 !! end
13934
13935 !! test
13936 pre-save transform: unclosed tag
13937 !! options
13938 pst
13939 !! wikitext
13940 <nowiki>'''not wiki'''
13941 !! html/php
13942 <nowiki>'''not wiki'''
13943 !! end
13944
13945 !! test
13946 pre-save transform: mixed tag case
13947 !! options
13948 pst
13949 !! wikitext
13950 <NOwiki>'''not wiki'''</noWIKI>
13951 !! html/php
13952 <NOwiki>'''not wiki'''</noWIKI>
13953 !! end
13954
13955 !! test
13956 pre-save transform: unclosed comment in <nowiki>
13957 !! options
13958 pst
13959 !! wikitext
13960 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13961 !! html/php
13962 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13963 !!end
13964
13965 # Leading @ in this template definition works around a limitation
13966 # in parsoid's parserTests which otherwise strips the <span> from the
13967 # result (confusing it for a template wrapper)
13968 !! article
13969 Template:dangerous
13970 !!text
13971 @<span onmouseover="alert('crap')">Oh no</span>
13972 !!endarticle
13973
13974 !!test
13975 (confirming safety of fix for subst T3936)
13976 !! wikitext
13977 {{Template:dangerous}}
13978 !! html
13979 <p>@<span>Oh no</span>
13980 </p>
13981 !! end
13982
13983 !! test
13984 pre-save transform: comment containing gallery (T7024)
13985 !! options
13986 pst
13987 !! wikitext
13988 <!-- <gallery>data</gallery> -->
13989 !! html/php
13990 <!-- <gallery>data</gallery> -->
13991 !!end
13992
13993 !! test
13994 pre-save transform: comment containing extension
13995 !! options
13996 pst
13997 !! wikitext
13998 <!-- <tag>data</tag> -->
13999 !! html/php
14000 <!-- <tag>data</tag> -->
14001 !!end
14002
14003 !! test
14004 pre-save transform: comment containing nowiki
14005 !! options
14006 pst
14007 !! wikitext
14008 <!-- <nowiki>data</nowiki> -->
14009 !! html/php
14010 <!-- <nowiki>data</nowiki> -->
14011 !!end
14012
14013 !! test
14014 pre-save transform: <noinclude> in subst (T5298)
14015 !! options
14016 pst
14017 !! wikitext
14018 {{subst:Includes}}
14019 !! html/php
14020 Foobar
14021 !! end
14022
14023 !! test
14024 pre-save transform: <onlyinclude> in subst (T5298)
14025 !! options
14026 pst
14027 !! wikitext
14028 {{subst:Includes2}}
14029 !! html/php
14030 Foo
14031 !! end
14032
14033 !! article
14034 Template:SubstTest
14035 !!text
14036 {{<includeonly>subst:</includeonly>Includes}}
14037 !! endarticle
14038
14039 !! article
14040 Template:SafeSubstTest
14041 !! text
14042 {{<includeonly>safesubst:</includeonly>Includes}}
14043 !! endarticle
14044
14045 !! test
14046 T24297: safesubst: works during PST
14047 !! options
14048 pst
14049 !! wikitext
14050 {{subst:SafeSubstTest}}{{safesubst:SubstTest}}
14051 !! html/php
14052 FoobarFoobar
14053 !! end
14054
14055 !! test
14056 T24297: safesubst: works during normal parse
14057 !! wikitext
14058 {{SafeSubstTest}}
14059 !! html
14060 <p>Foobar
14061 </p>
14062 !! end
14063
14064 !! test
14065 subst: does not work during normal parse
14066 !! wikitext
14067 {{SubstTest}}
14068 !! html
14069 <p>{{subst:Includes}}
14070 </p>
14071 !! end
14072
14073 !! test
14074 pre-save transform: context links ("pipe trick")
14075 !! options
14076 pst
14077 !! wikitext
14078 [[Article (context)|]]
14079 [[Bar:Article|]]
14080 [[:Bar:Article|]]
14081 [[Bar:Article (context)|]]
14082 [[:Bar:Article (context)|]]
14083 [[|Article]]
14084 [[|Article (context)]]
14085 [[Bar:X (Y) Z|]]
14086 [[:Bar:X (Y) Z|]]
14087 !! html/php
14088 [[Article (context)|Article]]
14089 [[Bar:Article|Article]]
14090 [[:Bar:Article|Article]]
14091 [[Bar:Article (context)|Article]]
14092 [[:Bar:Article (context)|Article]]
14093 [[Article]]
14094 [[Article (context)]]
14095 [[Bar:X (Y) Z|X (Y) Z]]
14096 [[:Bar:X (Y) Z|X (Y) Z]]
14097 !! end
14098
14099 !! test
14100 pre-save transform: context links ("pipe trick") with interwiki prefix
14101 !! options
14102 pst
14103 !! wikitext
14104 [[interwiki:Article|]]
14105 [[:interwiki:Article|]]
14106 [[interwiki:Bar:Article|]]
14107 [[:interwiki:Bar:Article|]]
14108 !! html/php
14109 [[interwiki:Article|Article]]
14110 [[:interwiki:Article|Article]]
14111 [[interwiki:Bar:Article|Bar:Article]]
14112 [[:interwiki:Bar:Article|Bar:Article]]
14113 !! end
14114
14115 !! test
14116 pre-save transform: context links ("pipe trick") with parens in title
14117 !! options
14118 pst title=[[Somearticle (context)]]
14119 !! wikitext
14120 [[|Article]]
14121 !! html/php
14122 [[Article (context)|Article]]
14123 !! end
14124
14125 !! test
14126 pre-save transform: context links ("pipe trick") with comma in title
14127 !! options
14128 pst title=[[Someplace, Somewhere]]
14129 !! wikitext
14130 [[|Otherplace]]
14131 [[Otherplace, Elsewhere|]]
14132 [[Otherplace, Elsewhere, Anywhere|]]
14133 !! html/php
14134 [[Otherplace, Somewhere|Otherplace]]
14135 [[Otherplace, Elsewhere|Otherplace]]
14136 [[Otherplace, Elsewhere, Anywhere|Otherplace]]
14137 !! end
14138
14139 !! test
14140 pre-save transform: context links ("pipe trick") with parens and comma
14141 !! options
14142 pst title=[[Someplace (IGNORED), Somewhere]]
14143 !! wikitext
14144 [[|Otherplace]]
14145 [[Otherplace (place), Elsewhere|]]
14146 !! html/php
14147 [[Otherplace, Somewhere|Otherplace]]
14148 [[Otherplace (place), Elsewhere|Otherplace]]
14149 !! end
14150
14151 !! test
14152 pre-save transform: context links ("pipe trick") with comma and parens
14153 !! options
14154 pst title=[[Who, me? (context)]]
14155 !! wikitext
14156 [[|Yes, you.]]
14157 [[Me, Myself, and I (1937 song)|]]
14158 !! html/php
14159 [[Yes, you. (context)|Yes, you.]]
14160 [[Me, Myself, and I (1937 song)|Me, Myself, and I]]
14161 !! end
14162
14163 !! test
14164 pre-save transform: context links ("pipe trick") with namespace
14165 !! options
14166 pst title=[[Ns:Somearticle]]
14167 !! wikitext
14168 [[|Article]]
14169 !! html/php
14170 [[Ns:Article|Article]]
14171 !! end
14172
14173 !! test
14174 pre-save transform: context links ("pipe trick") with namespace and parens
14175 !! options
14176 pst title=[[Ns:Somearticle (context)]]
14177 !! wikitext
14178 [[|Article]]
14179 !! html/php
14180 [[Ns:Article (context)|Article]]
14181 !! end
14182
14183 !! test
14184 pre-save transform: context links ("pipe trick") with namespace and comma
14185 !! options
14186 pst title=[[Ns:Somearticle, Context, Whatever]]
14187 !! wikitext
14188 [[|Article]]
14189 !! html/php
14190 [[Ns:Article, Context, Whatever|Article]]
14191 !! end
14192
14193 !! test
14194 pre-save transform: context links ("pipe trick") with namespace, comma and parens
14195 !! options
14196 pst title=[[Ns:Somearticle, Context (context)]]
14197 !! wikitext
14198 [[|Article]]
14199 !! html/php
14200 [[Ns:Article (context)|Article]]
14201 !! end
14202
14203 !! test
14204 pre-save transform: context links ("pipe trick") with namespace, parens and comma
14205 !! options
14206 pst title=[[Ns:Somearticle (IGNORED), Context]]
14207 !! wikitext
14208 [[|Article]]
14209 !! html/php
14210 [[Ns:Article, Context|Article]]
14211 !! end
14212
14213 !! test
14214 pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, T32149)
14215 !! options
14216 pst
14217 !! wikitext
14218 [[Article(context)|]]
14219 [[Bar:Article(context)|]]
14220 [[:Bar:Article(context)|]]
14221 [[|Article(context)]]
14222 [[Bar:X(Y)Z|]]
14223 [[:Bar:X(Y)Z|]]
14224 !! html/php
14225 [[Article(context)|Article]]
14226 [[Bar:Article(context)|Article]]
14227 [[:Bar:Article(context)|Article]]
14228 [[Article(context)]]
14229 [[Bar:X(Y)Z|X(Y)Z]]
14230 [[:Bar:X(Y)Z|X(Y)Z]]
14231 !! end
14232
14233 !! test
14234 pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, T32149)
14235 !! options
14236 pst
14237 !! wikitext
14238 [[Article (context)|]]
14239 [[Bar:Article (context)|]]
14240 [[:Bar:Article (context)|]]
14241 [[|Article (context)]]
14242 [[Bar:X (Y) Z|]]
14243 [[:Bar:X (Y) Z|]]
14244 !! html/php
14245 [[Article (context)|Article]]
14246 [[Bar:Article (context)|Article]]
14247 [[:Bar:Article (context)|Article]]
14248 [[Article (context)]]
14249 [[Bar:X (Y) Z|X (Y) Z]]
14250 [[:Bar:X (Y) Z|X (Y) Z]]
14251 !! end
14252
14253 !! test
14254 pre-save transform: context links ("pipe trick") with parens and no space (Korean style, T32149)
14255 !! options
14256 pst
14257 !! wikitext
14258 [[Article(context)|]]
14259 [[Bar:Article(context)|]]
14260 [[:Bar:Article(context)|]]
14261 [[|Article(context)]]
14262 [[Bar:X(Y)Z|]]
14263 [[:Bar:X(Y)Z|]]
14264 !! html/php
14265 [[Article(context)|Article]]
14266 [[Bar:Article(context)|Article]]
14267 [[:Bar:Article(context)|Article]]
14268 [[Article(context)]]
14269 [[Bar:X(Y)Z|X(Y)Z]]
14270 [[:Bar:X(Y)Z|X(Y)Z]]
14271 !! end
14272
14273 !! test
14274 pre-save transform: context links ("pipe trick") with commas (T23660)
14275 !! options
14276 pst
14277 !! wikitext
14278 [[Article (context), context|]]
14279 [[Article (context),context|]]
14280 [[Bar:Article (context), context|]]
14281 [[Bar:Article (context),context|]]
14282 [[:Bar:Article (context), context|]]
14283 [[:Bar:Article (context),context|]]
14284 !! html/php
14285 [[Article (context), context|Article]]
14286 [[Article (context),context|Article]]
14287 [[Bar:Article (context), context|Article]]
14288 [[Bar:Article (context),context|Article]]
14289 [[:Bar:Article (context), context|Article]]
14290 [[:Bar:Article (context),context|Article]]
14291 !! end
14292
14293 !! test
14294 Parsoid: backwards pipe trick
14295 !! wikitext
14296 [[|'''bar''']]
14297 !! html/php
14298 <p>[[|<b>bar</b>]]
14299 </p>
14300 !! html/parsoid
14301 <p>[[|<b>bar</b>]]</p>
14302 !! end
14303
14304 !! test
14305 pre-save transform: trim trailing empty lines
14306 !! options
14307 pst
14308 !! wikitext
14309 Empty lines are trimmed
14310
14311
14312
14313
14314 !! html/php
14315 Empty lines are trimmed
14316 !! end
14317
14318 !! test
14319 pre-save transform: Signature expansion
14320 !! options
14321 pst
14322 !! wikitext
14323 * ~~~
14324 * ~~~~
14325 * ~~~~~
14326 * <noinclude>~~~</noinclude>
14327 * <includeonly>~~~</includeonly>
14328 * <onlyinclude>~~~</onlyinclude>
14329 !! html/php
14330 * [[Special:Contributions/127.0.0.1|127.0.0.1]]
14331 * [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
14332 * 00:02, 1 January 1970 (UTC)
14333 * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
14334 * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
14335 * <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>
14336 !! end
14337
14338
14339 !! test
14340 ParserOutput flags from signature expansion (T84843)
14341 !! options
14342 pst
14343 showflags
14344 !! wikitext
14345 ~~~~
14346 !! html/php
14347 [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
14348 flags=user-signature
14349 !! end
14350
14351
14352 !! test
14353 pre-save transform: Signature expansion in nowiki tags (T2093)
14354 !! options
14355 pst disabled
14356 !! wikitext
14357 Shall not expand:
14358
14359 <nowiki>~~~~</nowiki>
14360
14361 <includeonly><nowiki>~~~~</nowiki></includeonly>
14362
14363 <noinclude><nowiki>~~~~</nowiki></noinclude>
14364
14365 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14366
14367 {{subst:Foo}} shall be converted to FOO
14368
14369 As well as inside noinclude/onlyinclude
14370 <noinclude>{{subst:Foo}}</noinclude>
14371 <onlyinclude>{{subst:Foo}}</onlyinclude>
14372
14373 But not inside includeonly
14374 <includeonly>{{subst:Foo}}</includeonly>
14375 !! html/php
14376 Shall not expand:
14377
14378 <nowiki>~~~~</nowiki>
14379
14380 <includeonly><nowiki>~~~~</nowiki></includeonly>
14381
14382 <noinclude><nowiki>~~~~</nowiki></noinclude>
14383
14384 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14385
14386 FOO shall be converted to FOO
14387
14388 As well as inside noinclude/onlyinclude
14389 <noinclude>FOO</noinclude>
14390 <onlyinclude>FOO</onlyinclude>
14391
14392 But not inside includeonly
14393 <includeonly>{{subst:Foo}}</includeonly>
14394 !! end
14395
14396 !! test
14397 Parsoid: Recognize nowiki with trailing space in tags
14398 !! options
14399 parsoid=wt2html
14400 !! wikitext
14401 <nowiki ><div>[[foo]]</nowiki >
14402
14403 a<nowiki / >b
14404
14405 c<nowiki />d
14406
14407 e<nowiki/ >f
14408 !! html/php+tidy
14409 <p>&lt;div&gt;[[foo]]
14410 </p><p>a&lt;nowiki / &gt;b
14411 </p><p>cd
14412 </p><p>e&lt;nowiki/ &gt;f
14413 </p>
14414 !! html/parsoid
14415 <p><span typeof="mw:Nowiki">&lt;div>[[foo]]</span></p>
14416
14417 <p>a&lt;nowiki / >b</p>
14418
14419 <p>c<span typeof="mw:Nowiki"></span>d</p>
14420
14421 <p>e&lt;nowiki/ >f</p>
14422 !! end
14423
14424 !! test
14425 Parsoid: Recognize nowiki with odd capitalization
14426 !! options
14427 parsoid=wt2html
14428 !! wikitext
14429 <noWikI ><div>[[foo]]</Nowiki >
14430 !! html/php+tidy
14431 <p>&lt;div&gt;[[foo]]
14432 </p>
14433 !! html/parsoid
14434 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
14435 !! end
14436
14437
14438 !! test
14439 Parsoid: Escape nowiki with trailing space in tags
14440 !! options
14441 parsoid=html2wt
14442 !! html/parsoid
14443 <p>&lt;nowiki &gt; foo &lt/nowiki ></p>
14444 <p>a&lt;nowiki /&gt;b</p>
14445 <p>c&lt;nowiki/ &gt;d</p>
14446 !! wikitext
14447 &lt;nowiki &gt; foo &lt;/nowiki &gt;
14448
14449 a&lt;nowiki /&gt;b
14450
14451 c&lt;nowiki/ &gt;d
14452 !! end
14453
14454 !! test
14455 Parsoid: Escape weird noWikI capitalizations
14456 !! options
14457 parsoid=html2wt
14458 !! html/parsoid
14459 <p>&lt;noWikI &gt; foo &lt/NoWikI ></p>
14460 !! wikitext
14461 &lt;noWikI &gt; foo &lt;/NoWikI &gt;
14462 !! end
14463
14464 ###
14465 ### Message transform tests
14466 ###
14467 !! test
14468 message transform: magic variables
14469 !! options
14470 msg
14471 !! wikitext
14472 {{SITENAME}}
14473 !! html
14474 MediaWiki
14475 !! end
14476
14477 !! test
14478 message transform: should not transform wiki markup
14479 !! options
14480 msg
14481 !! wikitext
14482 ''test''
14483 !! html
14484 ''test''
14485 !! end
14486
14487 !! test
14488 message transform: <noinclude> in transcluded template (T6926)
14489 !! options
14490 msg
14491 !! wikitext
14492 {{Includes}}
14493 !! html
14494 Foobar
14495 !! end
14496
14497 !! test
14498 message transform: <onlyinclude> in transcluded template (T6926)
14499 !! options
14500 msg
14501 !! wikitext
14502 {{Includes2}}
14503 !! html
14504 Foo
14505 !! end
14506
14507 !! test
14508 {{#special:}} page name, known
14509 !! options
14510 msg
14511 !! wikitext
14512 {{#special:Recentchanges}}
14513 !! html
14514 Special:RecentChanges
14515 !! end
14516
14517 !! test
14518 {{#special:}} page name with subpage, known
14519 !! options
14520 msg
14521 !! wikitext
14522 {{#special:Recentchanges/param}}
14523 !! html
14524 Special:RecentChanges/param
14525 !! end
14526
14527 !! test
14528 {{#special:}} page name, unknown
14529 !! options
14530 msg
14531 !! wikitext
14532 {{#special:foobar nonexistent}}
14533 !! html
14534 Special:Foobar nonexistent
14535 !! end
14536
14537 !! test
14538 {{#speciale:}} page name, known
14539 !! options
14540 msg
14541 !! wikitext
14542 {{#speciale:Recentchanges}}
14543 !! html
14544 Special:RecentChanges
14545 !! end
14546
14547 !! test
14548 {{#speciale:}} page name with subpage, known
14549 !! options
14550 msg
14551 !! wikitext
14552 {{#speciale:Recentchanges/param}}
14553 !! html
14554 Special:RecentChanges/param
14555 !! end
14556
14557 !! test
14558 {{#speciale:}} page name, unknown
14559 !! options
14560 msg
14561 !! wikitext
14562 {{#speciale:foobar nonexistent}}
14563 !! html
14564 Special:Foobar_nonexistent
14565 !! end
14566
14567 ###
14568 ### Images
14569 ###
14570 ### For Parsoid-specific tests, see
14571 #### https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
14572
14573 !! test
14574 Simple image
14575 !! options
14576 parsoid=wt2html,wt2wt,html2html
14577 !! wikitext
14578 [[Image:foobar.jpg]]
14579 !! html/php
14580 <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>
14581 </p>
14582 !! html/parsoid
14583 <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>
14584 !! end
14585
14586 !! test
14587 Serialize simple image with span wrapper
14588 !! options
14589 parsoid=html2wt
14590 !! html/parsoid
14591 <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>
14592 !! wikitext
14593 [[File:Foobar.jpg]]
14594 !! end
14595
14596 !! test
14597 Simple image (using File: namespace, now canonical)
14598 !! wikitext
14599 [[File:Foobar.jpg]]
14600 !! html/php
14601 <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>
14602 </p>
14603 !! html/parsoid
14604 <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>
14605 !! end
14606
14607 !! test
14608 Right-aligned image
14609 !! wikitext
14610 [[File:Foobar.jpg|right]]
14611 !! html/php
14612 <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>
14613
14614 !! html/parsoid
14615 <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>
14616 !! end
14617
14618 !! test
14619 Image with caption
14620 !! wikitext
14621 [[File:Foobar.jpg|right|Caption text]]
14622 !! html/php
14623 <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>
14624
14625 !! html/parsoid
14626 <figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Caption text</figcaption></figure>
14627 !! end
14628
14629 !! test
14630 Image with caption, T55312 #1
14631 !! wikitext
14632 [[File:Foobar.jpg|right|Caption page stuff]]
14633 !! html/php
14634 <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>
14635
14636 !! html/parsoid
14637 <figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Caption page stuff</figcaption></figure>
14638 !! end
14639
14640 !! test
14641 Image with caption, T55312 #2
14642 !! wikitext
14643 [[File:Foobar.jpg|right|Caption page=]]
14644 !! html/php
14645 <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>
14646
14647 !! html/parsoid
14648 <figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Caption page=</figcaption></figure>
14649 !! end
14650
14651 !! test
14652 Image with caption, T55312 #3
14653 !! wikitext
14654 [[File:Foobar.jpg|right|Caption page=stuff]]
14655 !! html/php
14656 <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>
14657
14658 !! html/parsoid
14659 <figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Caption page=stuff</figcaption></figure>
14660 !! end
14661
14662 !! test
14663 Image caption with pipe entity
14664 !! wikitext
14665 [[File:Foobar.jpg|thumb|one &#x7C; two]]
14666 [[File:Foobar.jpg|thumb|one ''two'' &#x7C; three]]
14667 !! html/php
14668 <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>
14669 <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>
14670
14671 !! html/parsoid
14672 <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>
14673 <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>
14674 !! end
14675
14676 !! test
14677 Allow empty links in image captions (T62753)
14678 !! options
14679 thumbsize=220
14680 !! wikitext
14681 [[File:Foobar.jpg|thumb|Caption [[Link1]]
14682 [[]]
14683 [[Link2]]
14684 ]]
14685 !! html/php
14686 <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>
14687
14688 !! html/parsoid
14689 <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>
14690 [[]]
14691 <a rel="mw:WikiLink" href="./Link2" title="Link2" data-parsoid='{"stx":"simple","a":{"href":"./Link2"},"sa":{"href":"Link2"}}'>Link2</a>
14692 </figcaption></figure>
14693 !! end
14694
14695 !! test
14696 Titles in unlinked images (T23454)
14697 !! wikitext
14698 [[File:Foobar.jpg|link=|stuff]]
14699 !! html/php
14700 <p><img alt="stuff" src="http://example.com/images/3/3a/Foobar.jpg" title="stuff" width="1941" height="220" />
14701 </p>
14702 !! html/parsoid
14703 <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>
14704 !! end
14705
14706 !! test
14707 Link with empty target
14708 !! wikitext
14709 [[]]
14710 !! html
14711 <p>[[]]
14712 </p>
14713 !! end
14714
14715 !! test
14716 Image with link trail
14717 !! wikitext
14718 Linktrails should not work for images: [[File:Foobar.jpg]]s
14719 !! html/php
14720 <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
14721 </p>
14722 !! html/parsoid
14723 <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>
14724 !! end
14725
14726 !! test
14727 Image with empty attribute
14728 !! options
14729 parsoid=wt2html,wt2wt,html2html
14730 !! wikitext
14731 [[File:Foobar.jpg|right||Caption text]]
14732 !! html/php
14733 <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>
14734
14735 !! html/parsoid
14736 <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>
14737 !! end
14738
14739 !! test
14740 1. Block image with individual attributes from templates
14741 !! wikitext
14742 [[File:Foobar.jpg|thumb|{{echo|137px}}|This is a caption]]
14743 !! html/php
14744 <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>
14745
14746 !! html/parsoid
14747 <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>
14748 !! end
14749
14750 !! test
14751 2. Block Image with individual attributes from templates
14752 !! wikitext
14753 [[File:Foobar.jpg|{{echo|thumb}}|{{echo|137px}}|This is a caption]]
14754 !! html/php
14755 <div class="thumb tright"><div class="thumbinner" style="width:139px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/137px-Foobar.jpg" width="137" height="16" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/206px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/274px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This is a caption</div></div></div>
14756
14757 !! html/parsoid
14758 <figure typeof="mw:Image/Thumb mw:ExpandedAttrs" about="#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>
14759 !! end
14760
14761 !! test
14762 3. Inline image with individual attributes from templates
14763 !! wikitext
14764 [[File:Foobar.jpg|{{echo|50px}}]]
14765 !! html/php
14766 <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>
14767 </p>
14768 !! html/parsoid
14769 <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>
14770 !! end
14771
14772 ## Parsoid does not provide editing support for images where templates produce multiple image attributes.
14773 ## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
14774 !! test
14775 Image with multiple attributes from the same template
14776 !! wikitext
14777 [[File:Foobar.jpg|{{image_attribs}}]]
14778 !! html/php
14779 <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>
14780
14781 !! html/parsoid
14782 <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>
14783 !! end
14784
14785 !! test
14786 Image with link tails
14787 !! options
14788 thumbsize=220
14789 !! wikitext
14790 123[[File:Foobar.jpg]]456
14791 123[[File:Foobar.jpg|right]]456
14792 123[[File:Foobar.jpg|thumb]]456
14793 !! html/php
14794 <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
14795 </p>
14796 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
14797 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
14798
14799 !! html/php+tidy
14800 <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
14801 </p><p>
14802 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
14803 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
14804 </p>
14805 !! html/parsoid
14806 <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>
14807 <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
14808 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>
14809 !! end
14810
14811 !! test
14812 Image with multiple captions -- only last one is accepted
14813 !! wikitext
14814 [[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]]
14815 !! html/php
14816 <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>
14817
14818 !! html/parsoid
14819 <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>
14820 !! end
14821
14822 !! test
14823 Image with multiple widths -- use last
14824 !! wikitext
14825 [[File:Foobar.jpg|200px|300px|caption]]
14826 !! html/php
14827 <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>
14828 </p>
14829 !! html/parsoid
14830 <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>
14831 !! end
14832
14833 !! test
14834 Image with multiple alignments -- use first (T50664)
14835 !! options
14836 thumbsize=220
14837 !! wikitext
14838 [[File:Foobar.jpg|thumb|left|right|center|caption]]
14839
14840 [[File:Foobar.jpg|middle|text-top|caption]]
14841 !! html/php
14842 <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>
14843 <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>
14844 </p>
14845 !! html/parsoid
14846 <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>
14847 <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>
14848 !! end
14849
14850 !! test
14851 Image with width attribute at different positions
14852 !! wikitext
14853 [[File:Foobar.jpg|200px|right|Caption]]
14854 [[File:Foobar.jpg|right|200px|Caption]]
14855 [[File:Foobar.jpg|right|Caption|200px]]
14856 !! html/php
14857 <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>
14858 <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>
14859 <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>
14860
14861 !! html/parsoid
14862 <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>
14863 <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>
14864 <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>
14865 !! end
14866
14867 # a sad bit of backward-compatibility
14868 !! test
14869 Image with size specified with pxpx (T15500, T53628)
14870 !! options
14871 parsoid=wt2html,wt2wt,html2html
14872 !! wikitext
14873 [[File:Foobar.jpg|20pxpx]]
14874 [[File:Foobar.jpg|200x20pxpx]]
14875 !! html/php
14876 <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>
14877 <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>
14878 </p>
14879 !! html/parsoid
14880 <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>
14881 !! end
14882
14883 !! test
14884 Image with link parameter, wiki target
14885 !! wikitext
14886 [[File:Foobar.jpg|link=Main Page]]
14887 !! html/php
14888 <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>
14889 </p>
14890 !! html/parsoid
14891 <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>
14892 !! end
14893
14894 # parsoid T51293 (part 1)
14895 !! test
14896 Image with link parameter, URL target
14897 !! wikitext
14898 [[File:Foobar.jpg|link=http://example.com/]]
14899 !! html/php
14900 <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>
14901 </p>
14902 !! html/parsoid
14903 <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>
14904 !! end
14905
14906 # parsoid T51293 (part 2)
14907 !! test
14908 Image with link parameter, protocol-less URL target
14909 !! wikitext
14910 [[File:Foobar.jpg|link=//example.com/]]
14911 !! html/php
14912 <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>
14913 </p>
14914 !! html/parsoid
14915 <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>
14916 !! end
14917
14918 !! test
14919 Escaping non-block captions (T107435)
14920 !! options
14921 parsoid={
14922 "modes": ["wt2wt"],
14923 "changes": [
14924 ["[typeof~='mw:Image']", "attr", "data-mw", "{\"caption\": \"|\"}"]
14925 ]
14926 }
14927 !! wikitext
14928 [[Image:Foobar.jpg|caption]]
14929 !! wikitext/edited
14930 [[Image:Foobar.jpg|<nowiki>|</nowiki>]]
14931 !! end
14932
14933 # wgExternalLinkTarget not supported by Parsoid
14934 !! test
14935 Image with link parameter, wgExternalLinkTarget
14936 !! wikitext
14937 [[Image:foobar.jpg|link=http://example.com/]]
14938 !! config
14939 wgExternalLinkTarget='foobar'
14940 !! html/php
14941 <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>
14942 </p>
14943 !! end
14944
14945 !! test
14946 Image with link parameter, wgNoFollowLinks set to false
14947 !! wikitext
14948 [[Image:foobar.jpg|link=http://example.com/]]
14949 !! config
14950 wgNoFollowLinks=false
14951 !! html/php
14952 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14953 </p>
14954 !! end
14955
14956 !! test
14957 Image with link parameter, wgNoFollowDomainExceptions
14958 !! wikitext
14959 [[Image:foobar.jpg|link=http://example.com/]]
14960 !! config
14961 wgNoFollowDomainExceptions='example.com'
14962 !! html/php
14963 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14964 </p>
14965 !! end
14966
14967 # wgExternalLinkTarget not supported by Parsoid
14968 !! test
14969 Image with link parameter, wgExternalLinkTarget, unnamed parameter
14970 !! wikitext
14971 [[Image:foobar.jpg|link=http://example.com/|Title]]
14972 !! config
14973 wgExternalLinkTarget='foobar'
14974 !! html/php
14975 <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>
14976 </p>
14977 !! end
14978
14979 !! test
14980 Image with empty link parameter
14981 !! wikitext
14982 [[File:Foobar.jpg|link=]]
14983 !! html/php
14984 <p><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" />
14985 </p>
14986 !! html/parsoid
14987 <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>
14988 !! end
14989
14990 !! test
14991 Image with link parameter (wiki target) and unnamed parameter
14992 !! wikitext
14993 [[File:Foobar.jpg|link=Main_Page|Title]]
14994 !! html/php
14995 <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>
14996 </p>
14997 !! html/parsoid
14998 <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>
14999 !! end
15000
15001 !! test
15002 Image with link parameter (URL target) and unnamed parameter
15003 !! wikitext
15004 [[File:Foobar.jpg|link=http://example.com/|Title]]
15005 !! html/php
15006 <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>
15007 </p>
15008 !! html/parsoid
15009 <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>
15010 !! end
15011
15012 !! test
15013 Thumbnail image with link parameter
15014 !! options
15015 thumbsize=220
15016 parsoid=wt2html,wt2wt,html2html
15017 !! wikitext
15018 [[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
15019 !! html/php
15020 <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>
15021
15022 !! html/parsoid
15023 <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>
15024 !! end
15025
15026 !! test
15027 Manually-specified thumbnail image
15028 !! options
15029 thumbsize=220
15030 !! wikitext
15031 [[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
15032 !! html/php
15033 <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>
15034
15035 !! html/parsoid
15036 <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>
15037 !! end
15038
15039 !! test
15040 Manually-specified thumbnail image with explicit link to wiki page
15041 !! options
15042 thumbsize=220
15043 parsoid=wt2html,wt2wt,html2html
15044 !! wikitext
15045 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
15046 !! html/php
15047 <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>
15048
15049 !! html/parsoid
15050 <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>
15051 !! end
15052
15053 !! test
15054 Manually-specified thumbnail image with explicit link to url
15055 !! options
15056 thumbsize=220
15057 parsoid=wt2html,wt2wt,html2html
15058 !! wikitext
15059 [[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
15060 !! html/php
15061 <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>
15062
15063 !! html/parsoid
15064 <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>
15065 !! end
15066
15067 !! test
15068 Manually-specified thumbnail image with explicit no link
15069 !! options
15070 thumbsize=220
15071 parsoid=wt2html,wt2wt,html2html
15072 !! wikitext
15073 [[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
15074 !! html/php
15075 <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>
15076
15077 !! html/parsoid
15078 <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>
15079 !! end
15080
15081 !! test
15082 Manually-specified thumbnail image with explicit link and alt text
15083 !! options
15084 thumbsize=220
15085 parsoid=wt2html,wt2wt,html2html
15086 !! wikitext
15087 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
15088 !! html/php
15089 <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>
15090
15091 !! html/parsoid
15092 <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>
15093 !! end
15094
15095 !! test
15096 Image with frame and link
15097 !! options
15098 parsoid=wt2html,wt2wt,html2html
15099 !! wikitext
15100 [[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
15101 !! html/php
15102 <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>
15103
15104 !! html/parsoid
15105 <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>
15106 !! end
15107
15108 !! test
15109 Image with frame and link and explicit alt
15110 !! options
15111 parsoid=wt2html,wt2wt,html2html
15112 !! wikitext
15113 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]]
15114 !! html/php
15115 <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>
15116
15117 !! html/parsoid
15118 <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>
15119 !! end
15120
15121 !! test
15122 Image with wiki markup in implicit alt
15123 !! wikitext
15124 [[Image:Foobar.jpg|testing '''bold''' in alt]]
15125
15126 [[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
15127 !! html/php
15128 <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>
15129 </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>
15130 </p>
15131 !! html/parsoid
15132 <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>
15133
15134 <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>
15135 !! end
15136
15137 !! test
15138 Alt image option should handle most kinds of wikitext without barfing
15139 !! wikitext
15140 [[Image:Foobar.jpg|thumb|This is the image caption|alt=This is a [[link]] and a {{echo|''bold template''}}.]]
15141 !! html/php
15142 <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>
15143
15144 !! html/parsoid
15145 <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>
15146 !! end
15147
15148 !! test
15149 Ampersand in alt attribute (T206940)
15150 !! options
15151 parsoid = {
15152 "nativeGallery": true
15153 }
15154 !! wikitext
15155 [[File:Foobar.jpg|alt=&amp;amp;]]
15156
15157 <!-- consistency with gallery extension -->
15158 <gallery>
15159 File:Foobar.jpg|alt=&amp;amp;
15160 </gallery>
15161 !! html/php+tidy
15162 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="&amp;amp;" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15163 </p>
15164 <ul class="gallery mw-gallery-traditional">
15165 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15166 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="&amp;amp;" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
15167 <div class="gallerytext">
15168 </div>
15169 </div></li>
15170 </ul>
15171 !! html/parsoid
15172 <p><figure-inline class="mw-default-size" typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="&amp;amp;" resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p>
15173
15174 <!-- consistency with gallery extension -->
15175 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15176 <li class="gallerybox">
15177 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="&amp;amp;" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div>
15178 <div class="gallerytext"></div>
15179 </li>
15180 </ul>
15181 !! end
15182
15183 !! test
15184 Italics markup in alt attribute (T206940)
15185 !! wikitext
15186 [[File:Foobar.jpg|alt=''x''|caption]]
15187
15188 <!-- consistency with gallery extension -->
15189 <gallery>
15190 File:Foobar.jpg|alt=''x''|caption
15191 </gallery>
15192 !! html/php+tidy
15193 <p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="x" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15194 </p>
15195 <ul class="gallery mw-gallery-traditional">
15196 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15197 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="x" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
15198 <div class="gallerytext">
15199 <p>caption
15200 </p>
15201 </div>
15202 </div></li>
15203 </ul>
15204 !! html/parsoid
15205 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"alt","ak":"alt=&apos;&apos;x&apos;&apos;"},{"ck":"caption","ak":"caption"}]}' data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg"><img alt="x" resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"alt":"x","resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"alt":"alt=&apos;&apos;x&apos;&apos;","resource":"File:Foobar.jpg"}}'/></a></figure-inline></p>
15206
15207 <!-- consistency with gallery extension -->
15208 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{"extsrc":"\nFile:Foobar.jpg|alt=&apos;&apos;x&apos;&apos;|caption\n"}}'>
15209 <li class="gallerybox">
15210 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="x" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div>
15211 <div class="gallerytext">caption</div>
15212 </li>
15213 </ul>
15214 !! end
15215
15216 !! test
15217 Nowiki markup in alt attribute (T206940)
15218 !! wikitext
15219 [[File:Foobar.jpg|alt=<nowiki>''</nowiki>x<nowiki>''</nowiki>|caption]]
15220
15221 <!-- consistency with gallery extension -->
15222 <gallery>
15223 File:Foobar.jpg|alt=<nowiki>''</nowiki>x<nowiki>''</nowiki>|caption
15224 </gallery>
15225 !! html/php+tidy
15226 <p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="&#39;&#39;x&#39;&#39;" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15227 </p>
15228 <ul class="gallery mw-gallery-traditional">
15229 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15230 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="&#39;&#39;x&#39;&#39;" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
15231 <div class="gallerytext">
15232 <p>caption
15233 </p>
15234 </div>
15235 </div></li>
15236 </ul>
15237 !! html/parsoid
15238 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"alt","ak":"alt=&lt;nowiki>&apos;&apos;&lt;/nowiki>x&lt;nowiki>&apos;&apos;&lt;/nowiki>"},{"ck":"caption","ak":"caption"}],"dsr":[0,71,null,null]}' data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg"><img alt="''x''" resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"alt":"&apos;&apos;x&apos;&apos;","resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"alt":"alt=&lt;nowiki>&apos;&apos;&lt;/nowiki>x&lt;nowiki>&apos;&apos;&lt;/nowiki>","resource":"File:Foobar.jpg"}}'/></a></figure-inline></p>
15239
15240 <!-- consistency with gallery extension -->
15241 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{"extsrc":"\nFile:Foobar.jpg|alt=&lt;nowiki>&apos;&apos;&lt;/nowiki>x&lt;nowiki>&apos;&apos;&lt;/nowiki>|caption\n"}}'>
15242 <li class="gallerybox">
15243 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="''x''" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div>
15244 <div class="gallerytext">caption</div>
15245 </li>
15246 </ul>
15247 !! end
15248
15249 !! test
15250 Nowiki markup in alt attribute (edited html, no data-parsoid) (T206940)
15251 !! options
15252 parsoid = {
15253 "nativeGallery": true
15254 }
15255 !! wikitext
15256 [[File:Foobar.jpg|alt=<nowiki>''x''</nowiki>|caption]]
15257
15258 <!-- consistency with gallery extension -->
15259 <gallery>
15260 File:Foobar.jpg|alt=<nowiki>''x''</nowiki>|caption
15261 </gallery>
15262 !! html/php+tidy
15263 <p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="&#39;&#39;x&#39;&#39;" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15264 </p>
15265 <ul class="gallery mw-gallery-traditional">
15266 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15267 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="&#39;&#39;x&#39;&#39;" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
15268 <div class="gallerytext">
15269 <p>caption
15270 </p>
15271 </div>
15272 </div></li>
15273 </ul>
15274 !! html/parsoid
15275 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg"><img alt="''x''" resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p>
15276
15277 <!-- consistency with gallery extension -->
15278 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15279 <li class="gallerybox">
15280 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="''x''" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div>
15281 <div class="gallerytext">caption</div>
15282 </li>
15283 </ul>
15284 !! end
15285
15286 !! test
15287 Ampersand in link attribute (T206940)
15288 !! wikitext
15289 [[File:Foobar.jpg|link=Foo &amp; bar]]
15290
15291 <!-- consistency with gallery extension -->
15292 <gallery>
15293 File:Foobar.jpg|link=Foo &amp; bar
15294 </gallery>
15295 !! html/php+tidy
15296 <p><a href="/wiki/Foo_%26_bar" title="Foo &amp; bar"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15297 </p>
15298 <ul class="gallery mw-gallery-traditional">
15299 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15300 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Foo_%26_bar"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
15301 <div class="gallerytext">
15302 </div>
15303 </div></li>
15304 </ul>
15305 !! html/parsoid
15306 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"link","ak":"link=Foo &amp;amp; bar"}]}'><a href="./Foo_&amp;_bar" data-parsoid='{"a":{"href":"./Foo_&amp;_bar"},"sa":{"href":"link=Foo &amp;amp; bar"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p>
15307
15308 <!-- consistency with gallery extension -->
15309 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{"extsrc":"\nFile:Foobar.jpg|link=Foo &amp;amp; bar\n"}}'>
15310 <li class="gallerybox">
15311 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./Foo_&amp;_bar"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div>
15312 <div class="gallerytext"></div>
15313 </li>
15314 </ul>
15315 !! end
15316
15317 !! test
15318 Ampersand in link attribute (edited html, no data-parsoid) (T206940)
15319 !! options
15320 parsoid = {
15321 "nativeGallery": true
15322 }
15323 !! wikitext
15324 [[File:Foobar.jpg|link=Foo_&_bar]]
15325
15326 <!-- consistency with gallery extension -->
15327 <gallery>
15328 File:Foobar.jpg|link=Foo_&_bar
15329 </gallery>
15330 !! html/php+tidy
15331 <p><a href="/wiki/Foo_%26_bar" title="Foo &amp; bar"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15332 </p>
15333 <ul class="gallery mw-gallery-traditional">
15334 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15335 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Foo_%26_bar"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
15336 <div class="gallerytext">
15337 </div>
15338 </div></li>
15339 </ul>
15340 !! html/parsoid
15341 <p><figure-inline class="mw-default-size" typeof="mw:Image"><a href="./Foo_&amp;_bar"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p>
15342
15343 <!-- consistency with gallery extension -->
15344 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15345 <li class="gallerybox">
15346 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./Foo_&amp;_bar"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div>
15347 <div class="gallerytext"></div>
15348 </li>
15349 </ul>
15350 !! end
15351
15352 !! test
15353 Italics markup in link attribute (T206940)
15354 !! wikitext
15355 [[Foo''s bar''s]]
15356
15357 <!-- Note that "italics" are stripped, even though this is a valid page title -->
15358 [[File:Foobar.jpg|link=Foo''s bar''s|caption1]]
15359
15360 [[File:Foobar.jpg|link=''Main Page''|caption2]]
15361
15362 <!-- consistency with gallery extension -->
15363 <gallery>
15364 File:Foobar.jpg|link=Foo''s bar''s|caption1
15365 File:Foobar.jpg|link=''Main Page''|caption2
15366 </gallery>
15367 !! html/php+tidy
15368 <p><a href="/wiki/Foo%27%27s_bar%27%27s" title="Foo&#39;&#39;s bar&#39;&#39;s">Foo''s bar''s</a>
15369 </p><p><a href="/wiki/Foos_bars" title="caption1"><img alt="caption1" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15370 </p><p><a href="/wiki/Main_Page" title="caption2"><img alt="caption2" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15371 </p>
15372 <ul class="gallery mw-gallery-traditional">
15373 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15374 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Foos_bars"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
15375 <div class="gallerytext">
15376 <p>caption1
15377 </p>
15378 </div>
15379 </div></li>
15380 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15381 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Main_Page"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
15382 <div class="gallerytext">
15383 <p>caption2
15384 </p>
15385 </div>
15386 </div></li>
15387 </ul>
15388 !! html/parsoid
15389 <p><a rel="mw:WikiLink" href="./Foo''s_bar''s" title="Foo''s bar''s">Foo''s bar''s</a></p>
15390
15391 <!-- Note that "italics" are stripped, even though this is a valid page title -->
15392 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"link","ak":"link=Foo&apos;&apos;s bar&apos;&apos;s"},{"ck":"caption","ak":"caption1"}]}' data-mw='{"caption":"caption1"}'><a href="./Foos_bars" data-parsoid='{"a":{"href":"./Foos_bars"},"sa":{"href":"link=Foo&apos;&apos;s bar&apos;&apos;s"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p>
15393
15394 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"link","ak":"link=&apos;&apos;Main Page&apos;&apos;"},{"ck":"caption","ak":"caption2"}]}' data-mw='{"caption":"caption2"}'><a href="./Main_Page" data-parsoid='{"a":{"href":"./Main_Page"},"sa":{"href":"link=&apos;&apos;Main Page&apos;&apos;"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p>
15395
15396 <!-- consistency with gallery extension -->
15397 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{"extsrc":"\nFile:Foobar.jpg|link=Foo&apos;&apos;s bar&apos;&apos;s|caption1\nFile:Foobar.jpg|link=&apos;&apos;Main Page&apos;&apos;|caption2\n"}}'>
15398 <li class="gallerybox">
15399 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./Foos_bars"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div>
15400 <div class="gallerytext">caption1</div>
15401 </li>
15402 <li class="gallerybox">
15403 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./Main_Page"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div>
15404 <div class="gallerytext">caption2</div>
15405 </li>
15406 </ul>
15407 !! end
15408
15409 !! test
15410 Nowiki markup in link attribute (T206940)
15411 !! wikitext
15412 [[File:Foobar.jpg|link=Foo<nowiki>''</nowiki>s_bar<nowiki>''</nowiki>s|caption]]
15413
15414 <!-- consistency with gallery extension -->
15415 <gallery>
15416 File:Foobar.jpg|link=Foo<nowiki>''</nowiki>s_bar<nowiki>''</nowiki>s|caption
15417 </gallery>
15418 !! html/php+tidy
15419 <p><a href="/wiki/Foo%27%27s_bar%27%27s" title="caption"><img alt="caption" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15420 </p>
15421 <ul class="gallery mw-gallery-traditional">
15422 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15423 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Foo%27%27s_bar%27%27s"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
15424 <div class="gallerytext">
15425 <p>caption
15426 </p>
15427 </div>
15428 </div></li>
15429 </ul>
15430 !! html/parsoid
15431 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"link","ak":"link=Foo&lt;nowiki>&apos;&apos;&lt;/nowiki>s_bar&lt;nowiki>&apos;&apos;&lt;/nowiki>s"},{"ck":"caption","ak":"caption"}]}' data-mw='{"caption":"caption"}'><a href="./Foo''s_bar''s" data-parsoid='{"a":{"href":"./Foo&apos;&apos;s_bar&apos;&apos;s"},"sa":{"href":"link=Foo&lt;nowiki>&apos;&apos;&lt;/nowiki>s_bar&lt;nowiki>&apos;&apos;&lt;/nowiki>s"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p>
15432
15433 <!-- consistency with gallery extension -->
15434 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{"extsrc":"\nFile:Foobar.jpg|link=Foo&lt;nowiki>&apos;&apos;&lt;/nowiki>s_bar&lt;nowiki>&apos;&apos;&lt;/nowiki>s|caption\n"}}'>
15435 <li class="gallerybox">
15436 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./Foo''s_bar''s"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div>
15437 <div class="gallerytext">caption</div>
15438 </li>
15439 </ul>
15440 !! end
15441
15442 !! test
15443 Nowiki markup in link attribute (edited html, no data-parsoid) (T206940)
15444 !! options
15445 parsoid = {
15446 "nativeGallery": true
15447 }
15448 !! wikitext
15449 [[File:Foobar.jpg|link=Foo<nowiki>''s_bar''</nowiki>s|caption]]
15450
15451 <!-- consistency with gallery extension -->
15452 <gallery>
15453 File:Foobar.jpg|link=Foo<nowiki>''s_bar''</nowiki>s|caption
15454 </gallery>
15455 !! html/php+tidy
15456 <p><a href="/wiki/Foo%27%27s_bar%27%27s" title="caption"><img alt="caption" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15457 </p>
15458 <ul class="gallery mw-gallery-traditional">
15459 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15460 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Foo%27%27s_bar%27%27s"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
15461 <div class="gallerytext">
15462 <p>caption
15463 </p>
15464 </div>
15465 </div></li>
15466 </ul>
15467 !! html/parsoid
15468 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"caption"}'><a href="./Foo''s_bar''s"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p>
15469
15470 <!-- consistency with gallery extension -->
15471 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15472 <li class="gallerybox">
15473 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./Foo''s_bar''s"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div>
15474 <div class="gallerytext">caption</div>
15475 </li>
15476 </ul>
15477 !! end
15478
15479 !! test
15480 HTML entity prefix in link markup (T209236)
15481 !! wikitext
15482 [[File:Foobar.jpg|link=https://example.com?foo&params=bar]]
15483
15484 <!-- consistency with gallery extension -->
15485 <gallery>
15486 File:Foobar.jpg|link=https://example.com?foo&params=bar
15487 </gallery>
15488 !! html/php+tidy
15489 <p><a href="https://example.com?foo&amp;params=bar" rel="nofollow"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15490 </p>
15491 <ul class="gallery mw-gallery-traditional">
15492 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15493 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="https://example.com?foo&amp;params=bar"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" 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>
15494 <div class="gallerytext">
15495 </div>
15496 </div></li>
15497 </ul>
15498 !! html/parsoid
15499 <p><figure-inline class="mw-default-size" typeof="mw:Image"><a href="https://example.com?foo&amp;params=bar"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p>
15500
15501 <!-- consistency with gallery extension -->
15502 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{"extsrc":"\nFile:Foobar.jpg|link=https://example.com?foo&amp;params=bar\n"}}'>
15503 <li class="gallerybox">
15504 <div class="thumb"><figure-inline typeof="mw:Image"><a href="https://example.com?foo&amp;params=bar"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div>
15505 <div class="gallerytext"></div>
15506 </li>
15507 </ul>
15508 !! end
15509
15510 !! test
15511 Image with table with attributes in caption
15512 !! options
15513 parsoid=wt2html,html2html
15514 !! wikitext
15515 [[File:Foobar.jpg|thumb|
15516 {| class="123" |
15517 |- class="456" |
15518 | ha
15519 |}
15520 ]]
15521 !! html/parsoid
15522 <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>
15523 <table class="123">
15524 <tbody><tr class="456" data-parsoid='{"startTagSrc":"|-"}'>
15525 <td> ha</td></tr>
15526 </tbody></table>
15527 </figcaption></figure>
15528 !! end
15529
15530 !! test
15531 Image with table with rows from templates in caption
15532 !! wikitext
15533 [[File:Foobar.jpg|thumb|
15534 {|
15535 {{echo|{{!}} hi}}
15536 |}
15537 ]]
15538 !! html/parsoid
15539 <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>
15540 <table>
15541 <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>
15542 </tbody></table>
15543 </figcaption></figure>
15544 !! end
15545
15546 !! test
15547 Image with nested tables in caption
15548 !! wikitext
15549 [[File:Foobar.jpg|thumb|Foo<br />
15550 {|
15551 |
15552 {|
15553 |z
15554 |}
15555 |}
15556 ]]
15557 !! html/parsoid
15558 <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}'/>
15559 <table>
15560 <tbody><tr><td>
15561 <table>
15562 <tbody><tr><td>z</td></tr>
15563 </tbody></table></td></tr>
15564 </tbody></table>
15565 </figcaption></figure>
15566 !! end
15567
15568 !! test
15569 Image with heading and horizontal rule in caption
15570 !! wikitext
15571 [[File:Foobar.jpg|thumb|
15572 ===Testing===
15573 123
15574 --------------
15575 ]]
15576 !! html/php
15577 <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>
15578
15579 !! html/parsoid
15580 <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>
15581 <h3 id="Testing">Testing</h3>
15582 123
15583 <hr data-parsoid='{"extra_dashes":10}'/>
15584 </figcaption></figure>
15585 !! end
15586
15587 ###################
15588 # Conflicting image format options.
15589 # First option specified should 'win'.
15590 # All three cases in each test should be identical.
15591
15592 !! test
15593 Image with 'frameless' first.
15594 !! options
15595 parsoid=wt2html,wt2wt,html2html
15596 !! wikitext
15597 [[File:Foobar.jpg|frameless|caption]]
15598
15599 [[File:Foobar.jpg|frameless|frame|caption]]
15600
15601 [[File:Foobar.jpg|frameless|thumb|caption]]
15602 !! html/php
15603 <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>
15604 </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>
15605 </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>
15606 </p>
15607 !! html/parsoid
15608 <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>
15609 <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>
15610 <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>
15611 !! end
15612
15613 !! test
15614 Image with 'frame' first.
15615 !! options
15616 parsoid=wt2html,wt2wt,html2html
15617 !! wikitext
15618 [[File:Foobar.jpg|frame|caption]]
15619 [[File:Foobar.jpg|frame|frameless|caption]]
15620 [[File:Foobar.jpg|frame|thumb|caption]]
15621 !! html/php
15622 <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>
15623 <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>
15624 <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>
15625
15626 !! html/parsoid
15627 <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>
15628 <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>
15629 <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>
15630 !! end
15631
15632 !! test
15633 Image with 'thumb' first.
15634 !! options
15635 parsoid=wt2html,wt2wt,html2html
15636 !! wikitext
15637 [[File:Foobar.jpg|thumb|caption]]
15638 [[File:Foobar.jpg|thumb|frameless|caption]]
15639 [[File:Foobar.jpg|thumb|frame|caption]]
15640 !! html/php
15641 <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>
15642 <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>
15643 <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>
15644
15645 !! html/parsoid
15646 <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>
15647 <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>
15648 <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>
15649 !! end
15650
15651 ###################
15652 # Image sizing.
15653 # See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
15654 # and https://phabricator.wikimedia.org/T64258
15655 # Foobar has actual size of 1941x220
15656 # 1. Thumbs & frameless always reduce, can't be enlarged unless it's
15657 # a scalable format.
15658 # 2. Framed images always ignore size options; always render at default size.
15659 # 3. "Unspecified format" and border are the only types which can be
15660 # enlarged.
15661
15662 !! test
15663 Image: unspecified format and border enlarge
15664 !! options
15665 parsoid=wt2html,wt2wt,html2html
15666 !! wikitext
15667 [[File:Foobar.jpg|2000px]]
15668
15669 [[File:Foobar.jpg|border|2000px]]
15670 !! html/php
15671 <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>
15672 </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>
15673 </p>
15674 !! html/parsoid
15675 <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>
15676 <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>
15677 !! end
15678
15679 !! test
15680 Image: "unspecified format" and border reduce
15681 !! options
15682 parsoid=wt2html,wt2wt,html2html
15683 !! wikitext
15684 [[File:Foobar.jpg|1000px]]
15685
15686 [[File:Foobar.jpg|border|1000px]]
15687 !! html/php
15688 <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>
15689 </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>
15690 </p>
15691 !! html/parsoid
15692 <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>
15693 <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>
15694 !! end
15695
15696 !! test
15697 Image: thumbs reduce
15698 !! options
15699 parsoid=wt2html,wt2wt,html2html
15700 !! wikitext
15701 [[File:Foobar.jpg|thumb|50px]]
15702 !! html/php
15703 <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>
15704
15705 !! html/parsoid
15706 <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>
15707 !! end
15708
15709 !! test
15710 Image: bitmap thumbs can't be enlarged past original size, but vector can.
15711 !! options
15712 parsoid=wt2html,wt2wt,html2html
15713 !! wikitext
15714 [[File:Foobar.jpg|thumb|2000px]]
15715
15716 [[File:Foobar.svg|thumb|2000px]]
15717 !! html/php
15718 <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>
15719 <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>
15720
15721 !! html/parsoid
15722 <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>
15723 <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>
15724 !! end
15725
15726 !! test
15727 Image: frameless can reduce in size
15728 !! options
15729 parsoid=wt2html,wt2wt,html2html
15730 !! wikitext
15731 [[File:Foobar.jpg|frameless|50px]]
15732 !! html/php
15733 <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>
15734 </p>
15735 !! html/parsoid
15736 <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>
15737 !! end
15738
15739 !! test
15740 Image: bitmap frameless can't be enlarged past original size, but vector can
15741 !! options
15742 parsoid=wt2html,wt2wt,html2html
15743 !! wikitext
15744 [[File:Foobar.jpg|frameless|2000px]]
15745
15746 [[File:Foobar.svg|frameless|2000px]]
15747 !! html/php
15748 <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>
15749 </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>
15750 </p>
15751 !! html/parsoid
15752 <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>
15753 <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>
15754 !! end
15755
15756 !! test
15757 Image: framed images are always unscaled.
15758 !! options
15759 parsoid=wt2html,wt2wt,html2html
15760 !! wikitext
15761 [[File:Foobar.jpg|frame]]
15762
15763 [[File:Foobar.jpg|frame|50px]]
15764
15765 [[File:Foobar.jpg|frame|50x50px]]
15766
15767 [[File:Foobar.jpg|frame|2000px]]
15768 !! html/php
15769 <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>
15770 <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>
15771 <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>
15772 <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>
15773
15774 !! html/parsoid
15775 <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>
15776 <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>
15777 <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>
15778 <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>
15779 !! end
15780
15781 ###################
15782
15783 !! test
15784 Link to image page- image page normally doesn't exists, hence edit link
15785 Add test with existing image page
15786 #<p><a href="/wiki/File:Test" title="Image:Test">Image:test</a>
15787 !! wikitext
15788 [[:Image:test]]
15789 !! html
15790 <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>
15791 </p>
15792 !! end
15793
15794 !! test
15795 T20784 Link to non-existent image page with caption should use caption as link text
15796 !! wikitext
15797 [[:Image:test|caption]]
15798 !! html
15799 <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>
15800 </p>
15801 !! end
15802
15803 !! test
15804 Frameless image caption with a free URL
15805 !! wikitext
15806 [[File:Foobar.jpg|http://example.com]]
15807 !! html/php
15808 <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>
15809 </p>
15810 !! html/parsoid
15811 <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>
15812 !! end
15813
15814 !! test
15815 Thumbnail image caption with a free URL
15816 !! options
15817 thumbsize=220
15818 !! wikitext
15819 [[File:Foobar.jpg|thumb|http://example.com]]
15820 !! html/php
15821 <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>
15822
15823 !! html/parsoid
15824 <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>
15825 !! end
15826
15827 !! test
15828 Thumbnail image caption with a free URL and explicit alt
15829 !! options
15830 thumbsize=220
15831 parsoid=wt2html,wt2wt,html2html
15832 !! wikitext
15833 [[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]]
15834 !! html/php
15835 <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>
15836
15837 !! html/parsoid
15838 <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>
15839 !! end
15840
15841 !! test
15842 SVG thumbnails with no language set
15843 !! options
15844 !! wikitext
15845 [[File:Foobar.svg|thumb|caption]]
15846 !! html/php
15847 <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>
15848
15849 !! html/parsoid
15850 <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>
15851 !! end
15852
15853 !! test
15854 SVG thumbnails with language de
15855 !! options
15856 parsoid=wt2html,wt2wt,html2html
15857 !! wikitext
15858 [[File:Foobar.svg|thumb|caption|lang=de]]
15859 !! html/php
15860 <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>
15861
15862 !! html/parsoid
15863 <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>
15864 !! end
15865
15866 !! test
15867 SVG thumbnails with invalid language code
15868 !! options
15869 parsoid=wt2html,wt2wt,html2html
15870 !! wikitext
15871 [[File:Foobar.svg|thumb|caption|lang=invalid:language:code]]
15872 !! html/php
15873 <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>
15874
15875 !! html/parsoid
15876 <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>
15877 !! end
15878
15879 !! test
15880 SVG thumbnails in page language
15881 !! options
15882 language=ru
15883 wgMediaInTargetLanguage = true
15884 !! wikitext
15885 [[File:Foobar.svg]] [[File:Foobar.svg|lang=en]]
15886 !! html/php
15887 <p><a href="/wiki/%D0%A4%D0%B0%D0%B9%D0%BB:Foobar.svg" class="image"><img alt="Foobar.svg" src="http://example.com/images/thumb/f/ff/Foobar.svg/langru-240px-Foobar.svg.png" width="240" height="180" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/langru-360px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/langru-480px-Foobar.svg.png 2x" /></a> <a href="/index.php?title=%D0%A4%D0%B0%D0%B9%D0%BB:Foobar.svg&amp;lang=en" class="image"><img alt="Foobar.svg" src="http://example.com/images/thumb/f/ff/Foobar.svg/240px-Foobar.svg.png" width="240" height="180" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/360px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/480px-Foobar.svg.png 2x" /></a>
15888 </p>
15889 !! end
15890
15891 !! test
15892 SVG thumbnails in page language not present in the file
15893 !! options
15894 language=de
15895 wgMediaInTargetLanguage = true
15896 !! wikitext
15897 [[File:Foobar.svg]] [[File:Foobar.svg|lang=ru]]
15898 !! html/php
15899 <p><a href="/wiki/Datei:Foobar.svg" class="image"><img alt="Foobar.svg" src="http://example.com/images/thumb/f/ff/Foobar.svg/240px-Foobar.svg.png" width="240" height="180" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/360px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/480px-Foobar.svg.png 2x" /></a> <a href="/index.php?title=Datei:Foobar.svg&amp;lang=ru" class="image"><img alt="Foobar.svg" src="http://example.com/images/thumb/f/ff/Foobar.svg/langru-240px-Foobar.svg.png" width="240" height="180" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/langru-360px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/langru-480px-Foobar.svg.png 2x" /></a>
15900 </p>
15901 !! end
15902
15903 !! test
15904 T3887: A ISBN with a thumbnail
15905 !! wikitext
15906 [[File:Foobar.jpg|thumb|ISBN 1235467890]]
15907 !! html/php
15908 <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>
15909
15910 !! html/parsoid
15911 <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>
15912 !! end
15913
15914 !! test
15915 T3887: A RFC with a thumbnail
15916 !! wikitext
15917 [[File:Foobar.jpg|thumb|This is RFC 12354]]
15918 !! html/php
15919 <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>
15920
15921 !! html/parsoid
15922 <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>
15923 !! end
15924
15925 !! test
15926 T3887: A mailto link with a thumbnail
15927 !! wikitext
15928 [[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
15929 !! html/php
15930 <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>
15931
15932 !! html/parsoid
15933 <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>
15934 !! end
15935
15936 # Pending resolution to T2368
15937 !! test
15938 T2648: Frameless image caption with a link
15939 !! wikitext
15940 [[File:Foobar.jpg|text with a [[link]] in it]]
15941 !! html/php
15942 <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>
15943 </p>
15944 !! html/parsoid
15945 <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>
15946 !! end
15947
15948 !! test
15949 T2648: Frameless image caption with a link (suffix)
15950 !! wikitext
15951 [[File:Foobar.jpg|text with a [[link]]foo in it]]
15952 !! html/php
15953 <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>
15954 </p>
15955 !! html/parsoid
15956 <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>
15957 !! end
15958
15959 !! test
15960 T2648: Frameless image caption with an interwiki link
15961 !! wikitext
15962 [[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
15963 !! html/php
15964 <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>
15965 </p>
15966 !! html/parsoid
15967 <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>
15968 !! end
15969
15970 !! test
15971 T2648: Frameless image caption with a piped interwiki link
15972 !! wikitext
15973 [[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
15974 !! html/php
15975 <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>
15976 </p>
15977 !! html/parsoid
15978 <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>
15979 !! end
15980
15981 !! test
15982 T107474: Frameless image caption with <nowiki>
15983 !! wikitext
15984 [[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]]
15985 !! html/parsoid
15986 <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>
15987 !! end
15988
15989 !! test
15990 Escape HTML special chars in image alt text
15991 !! wikitext
15992 [[File:Foobar.jpg|& < > "]]
15993 !! html/php
15994 <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>
15995 </p>
15996 !! html/parsoid
15997 <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>
15998 !! end
15999
16000 !! test
16001 Escape HTML special chars in image alt text with LanguageConverter
16002 !! options
16003 language=zh
16004 !! wikitext
16005 [[File:Foobar.jpg|& < > "]]
16006 !! html/php
16007 <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>
16008 </p>
16009 !! html/parsoid
16010 <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>
16011 !! end
16012
16013 !! test
16014 Entities in file name and attributes
16015 !! wikitext
16016 [[File:7%25 solution.gif|manualthumb=7%25 solution.gif|link=7%25 solution|[[7%25 solution]]]]
16017 !! html/php
16018 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=7%25_solution.gif" class="new" title="File:7% solution.gif">7% solution</a>
16019 </p>
16020 !! html/parsoid
16021 <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>
16022 !! end
16023
16024 !! test
16025 T2499: Alt text should have &#1234;, not &amp;1234;
16026 !! wikitext
16027 [[File:Foobar.jpg|&#9792;]]
16028 !! html/php
16029 <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>
16030 </p>
16031 !! html/parsoid
16032 <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>
16033 !! end
16034
16035 !! test
16036 Broken image caption with link
16037 !! options
16038 parsoid=wt2html,wt2wt,html2html
16039 !! wikitext
16040 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
16041 !! html/php
16042 <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.
16043 </p>
16044 !! html/parsoid
16045 <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>
16046 !! end
16047
16048 !! test
16049 Image caption containing another image
16050 !! wikitext
16051 [[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
16052 !! html/php
16053 <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>
16054
16055 !! html/parsoid
16056 <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>
16057 !! end
16058
16059 !! test
16060 Image: caption containing a newline
16061 !! wikitext
16062 [[File:Foobar.jpg|This
16063 *is some text]]
16064 !! html/php
16065 <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>
16066 </p>
16067 !! html/parsoid
16068 <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>
16069 !!end
16070
16071 !!test
16072 Image: caption containing leading space
16073 (The leading space should not trigger nowiki escaping in wt2wt mode)
16074 !! wikitext
16075 [[File:Foobar.jpg|thumb| bar]]
16076 !! html/php
16077 <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>
16078
16079 !! html/parsoid
16080 <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>
16081 !!end
16082
16083 # html/php output not have newlines after table, td, th, etc. because
16084 # Linker::makeThumbLink2() replaces the newlines with spaces since
16085 # the table is inside a caption.
16086 # FIXME: Verify if that circa 2004 fix is still required.
16087 !! test
16088 Image: caption containing a table
16089 !! options
16090 parsoid=wt2html,wt2wt,html2html
16091 !! wikitext
16092 [[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
16093 {|
16094 !Foo!!Bar
16095 |-
16096 |Foo1||Bar1
16097 |}
16098 and some more text.]]
16099 !! html/php
16100 <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>
16101
16102 !! html/parsoid
16103 <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
16104 <table>
16105 <tbody>
16106 <tr><th>Foo</th><th>Bar</th></tr>
16107 <tr>
16108 <td>Foo1</td>
16109 <td>Bar1</td></tr></tbody></table>and some more text.</figcaption></figure>
16110 !! end
16111
16112 !! test
16113 T5090: External links other than http: in image captions
16114 !! wikitext
16115 [[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
16116 !! html/php
16117 <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>
16118
16119 !! html/parsoid
16120 <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>
16121 !! end
16122
16123 !! test
16124 Custom class
16125 !! options
16126 parsoid=wt2html,wt2wt,html2html
16127 !! wikitext
16128 [[Image:foobar.jpg|a|class=b]]
16129 !! html/php
16130 <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>
16131 </p>
16132 !! html/parsoid
16133 <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>
16134 !! end
16135
16136 !! test
16137 Localized image handling (1).
16138 !! options
16139 parsoid=wt2html,wt2wt,html2html
16140 language=es
16141 !! wikitext
16142 [[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]]
16143 !! html/php
16144 <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>
16145
16146 !! html/parsoid
16147 <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>
16148 !! end
16149
16150 !! test
16151 Localized image handling (2).
16152 !! options
16153 thumbsize=220
16154 parsoid=wt2html,wt2wt,html2html
16155 language=es
16156 !! wikitext
16157 [[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
16158 !! html/php
16159 <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>
16160
16161 !! html/parsoid
16162 <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>
16163 !! end
16164
16165 !! test
16166 Localized image handling (3).
16167 !! options
16168 language=fa
16169 parsoid=html2wt
16170 !! html/parsoid
16171 <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>
16172 !! wikitext
16173 [[File:Foobar.jpg|بندانگشتی]]
16174 !! end
16175
16176 !! test
16177 "border", "frameless" and "class" attributes on an image.
16178 !! options
16179 thumbsize=220
16180 parsoid=wt2html,wt2wt,html2html
16181 !! wikitext
16182 [[File:Foobar.jpg|frameless|border|class=extra|caption]]
16183 !! html/php
16184 <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>
16185 </p>
16186 !! html/parsoid
16187 <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>
16188 !! end
16189
16190 # Note that 'right' is the default alignment, despite the misspelled 'righ' below
16191 !! test
16192 Invalid image attributes (T64500)
16193 !! options
16194 thumbsize=220
16195 parsoid=wt2html,wt2wt,html2html
16196 !! wikitext
16197 [[File:Foobar.jpg|thumb|float|left|caption]]
16198
16199 [[File:Foobar.jpg|thumb|righ|caption]]
16200
16201 [[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]]
16202 !! html/php
16203 <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>
16204 <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>
16205 <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>
16206
16207 !! html/parsoid
16208 <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>
16209 <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>
16210 <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>
16211 !! end
16212
16213 !! article
16214 File:Barfoo.jpg
16215 !! text
16216 #REDIRECT [[File:Barfoo.jpg]]
16217 !! endarticle
16218
16219 # FIXME: Parsoid should run this test -- but we'd need to teach the
16220 # mockAPI about the redirected Barfoo.jpg image.
16221 !! test
16222 Redirected image
16223 !! wikitext
16224 [[Image:Barfoo.jpg]]
16225 !! html/php
16226 <p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
16227 </p>
16228 !! end
16229
16230 !! test
16231 Missing image with uploads disabled
16232 !! options
16233 wgEnableUploads=0
16234 !! wikitext
16235 [[File:Foobaz.jpg]]
16236 !! html/php
16237 <p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a>
16238 </p>
16239 !! html/parsoid
16240 <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>
16241 !! end
16242
16243 # Parsoid-specific testing for images
16244 # https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
16245 # Currently imperfect due to a flaw in the Parsoid testrunner
16246 # Work in progress
16247 # THESE TESTS SHOULD BE MOVED UP and merged with the php-specific
16248 # image tests.
16249
16250 !! test
16251 Parsoid-specific image handling - simple image with size and middle alignment
16252 !! wikitext
16253 [[File:Foobar.jpg|middle|50px]]
16254 !! html/parsoid
16255 <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>
16256 !! end
16257
16258 !! test
16259 Parsoid-specific image handling - simple image with size, middle alignment, non-standard namespace alias
16260 !! options
16261 parsoid=wt2wt,wt2html,html2html
16262 !! wikitext
16263 [[Image:Foobar.jpg|middle|50px]]
16264 !! html/parsoid
16265 <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>
16266 !! end
16267
16268 !! test
16269 Parsoid-specific image handling - simple image with size and middle alignment (existing content)
16270 !! wikitext
16271 [[File:Foobar.jpg|50px|middle]]
16272 !! html/parsoid
16273 <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>
16274 !! end
16275
16276 !! test
16277 Parsoid-specific image handling - simple image with size and middle alignment and non-standard namespace name
16278 !! options
16279 parsoid=wt2html,wt2wt,html2html
16280 !! wikitext
16281 [[Image:Foobar.jpg|50px|middle]]
16282 !! html/parsoid
16283 <p><figure-inline class="mw-valign-middle" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50"/></a></figure-inline></p>
16284 !! end
16285
16286 !! test
16287 Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
16288 !! wikitext
16289 [[File:Foobar.jpg|500x10px|baseline|caption]]
16290 !! html/parsoid
16291 <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>
16292 !! end
16293
16294 !! test
16295 Parsoid-specific image handling - simple image with border and size spec
16296 !! wikitext
16297 [[File:Foobar.jpg|50px|border|caption]]
16298 !! html/parsoid
16299 <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>
16300 !! end
16301
16302 !! test
16303 Parsoid-specific image handling - thumbnail with halign, valign, and caption
16304 !! options
16305 parsoid=wt2html,html2html
16306 !! wikitext
16307 [[File:Foobar.jpg|left|baseline|thumb|caption content]]
16308 !! html/parsoid
16309 <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>
16310 !! end
16311
16312 !! test
16313 Parsoid-specific image handling - thumbnail with halign, valign, and caption (existing content)
16314 !! options
16315 parsoid=wt2html,html2html
16316 !! wikitext
16317 [[File:Foobar.jpg|thumb|left|baseline|caption content]]
16318 !! html/parsoid
16319 <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>
16320 !! end
16321
16322 !! test
16323 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption
16324 !! options
16325 parsoid=wt2html,html2html
16326 !! wikitext
16327 [[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
16328 !! html/parsoid
16329 <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>
16330 !! end
16331
16332 !! test
16333 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption (existing content)
16334 !! options
16335 parsoid=wt2html,html2html
16336 !! wikitext
16337 [[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
16338 !! html/parsoid
16339 <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>
16340 !! end
16341
16342 !! test
16343 Parsoid-specific image handling - framed image with specific size and caption (size is ignored)
16344 !! options
16345 parsoid=wt2html,wt2wt,html2html
16346 !! wikitext
16347 [[File:Foobar.jpg|frame|500x50px|caption]]
16348 !! html/parsoid
16349 <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>
16350 !! end
16351
16352 !! test
16353 Parsoid-specific image handling - framed image with specific size, halign, valign, and caption (size is ignored)
16354 !! options
16355 parsoid=wt2html,html2html
16356 !! wikitext
16357 [[File:Foobar.jpg|left|baseline|frame|500x50px|caption]]
16358 !! html/parsoid
16359 <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>
16360 !! end
16361
16362 !! test
16363 Parsoid-specific image handling - frameless image with specific size, border, and caption
16364 !! wikitext
16365 [[File:Foobar.jpg|frameless|442x50px|border|caption]]
16366 !! html/parsoid
16367 <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>
16368 !! end
16369
16370 !! test
16371 Parsoid-specific image handling - simple image with a formatted caption
16372 !! wikitext
16373 [[File:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]]
16374 !! html/parsoid
16375 <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>
16376 !! end
16377
16378 !! test
16379 Parsoid-specific image handling - caption with a template in it
16380 !! wikitext
16381 [[File:Foobar.jpg|thumb|200x23px|This caption has a {{echo|transclusion}} in it.]]
16382 !! html/parsoid
16383 <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>
16384 !! end
16385
16386 !! test
16387 Parsoid-specific image handling - caption with unbalanced tags in it
16388 !! options
16389 parsoid=wt2html,wt2wt,html2html
16390 !! wikitext
16391 foo
16392 [[File:Foobar.jpg|thumb|200x200px|This caption has a <center>unbalanced tag in it.]]
16393 bar
16394 !! html/parsoid
16395 <p>foo</p>
16396 <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>
16397 <p>bar</p>
16398 !! end
16399
16400 !! test
16401 Parsoid-specific image handling - empty caption (1)
16402 !! options
16403 parsoid=wt2html,wt2wt
16404 !! wikitext
16405 [[File:Foobar.jpg|thumb|]]
16406 !! html/parsoid
16407 <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>
16408 !! end
16409
16410 # empty captions don't get serialized unless we're in the "round trip" case
16411 !! test
16412 Parsoid-specific image handling - empty caption (2)
16413 !! options
16414 parsoid=html2wt
16415 !! html/parsoid
16416 <figure class="mw-default-size" typeof="mw:Image/Thumb">
16417 <a href="./File:Foobar.jpg">
16418 <img resource="./File:Foobar.jpg"
16419 src="//example.com/images/3/3a/Foobar.jpg"
16420 data-file-width="1941" data-file-height="220" data-file-type="bitmap"
16421 height="25" width="220"/>
16422 </a>
16423 <figcaption></figcaption>
16424 </figure>
16425 !! wikitext
16426 [[File:Foobar.jpg|thumb]]
16427 !! end
16428
16429 !! test
16430 Parsoid-specific image handling - whitespace caption
16431 !! wikitext
16432 [[File:Foobar.jpg|thumb| ]]
16433 !! html/parsoid
16434 <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>
16435 !! end
16436
16437 !! test
16438 Parsoid-specific image handling - lang option
16439 !! wikitext
16440 foo
16441 [[File:Foobar.svg|lang=de|caption]]
16442 bar
16443 !! html/parsoid
16444 <p>foo
16445 <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>
16446 bar</p>
16447 !! end
16448
16449 ## Edge case bugs in Parsoid from T93580
16450 !! test
16451 T93580: 1. Templated <ref> inside block images
16452 !! wikitext
16453 [[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]]
16454
16455 <references />
16456 !! html/parsoid
16457 <figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"Caption with templated ref: {{echo|&lt;ref>foo&lt;/ref>}}"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>Caption with templated ref: <sup about="#mwt5" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Transclusion mw:Extension/ref" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;ref>foo&lt;/ref>"}},"i":0}}]}'><a href="./Parser_test#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup></figcaption></figure>
16458
16459 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Parser_test#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
16460 !! end
16461
16462 !! test
16463 T93580: 2. <ref> inside inline images
16464 !! wikitext
16465 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: <ref>foo</ref>]]
16466
16467 <references />
16468 !! html/parsoid
16469 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"Undisplayed caption in inline image with ref: &lt;ref>foo&lt;/ref>"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: &lt;sup about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-parsoid=&#39;{\"dsr\":[64,78,5,6]}&#39; data-mw=&#39;{\"name\":\"ref\",\"attrs\":{},\"body\":{\"id\":\"mw-reference-text-cite_note-1\"}}&#39;>&lt;a href=\"./Parser_test#cite_note-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]&lt;/span>&lt;/a>&lt;/sup>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{"href":"File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p>
16470
16471 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Parser_test#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">foo</span></li></ol>
16472 !! end
16473
16474 !! test
16475 T93580: 3. Templated <ref> inside inline images
16476 !! wikitext
16477 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}]]
16478
16479 <references />
16480 !! html/parsoid
16481 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"Undisplayed caption in inline image with ref: {{echo|&lt;ref>{{echo|foo}}&lt;/ref>}}"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: &lt;sup about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Transclusion mw:Extension/ref\" data-parsoid=&#39;{\"dsr\":[64,96,null,null],\"pi\":[[{\"k\":\"1\"}]]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&amp;lt;ref>{{echo|foo}}&amp;lt;/ref>\"}},\"i\":0}}]}&#39;>&lt;a href=\"./Parser_test#cite_note-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]&lt;/span>&lt;/a>&lt;/sup>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{"href":"File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p>
16482
16483 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Parser_test#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">foo</span></li></ol>
16484 !! end
16485
16486 ###
16487 ### Subpages
16488 ###
16489 !! article
16490 Subpage test/subpage
16491 !! text
16492 foo
16493 !! endarticle
16494
16495 !! test
16496 Subpage link
16497 !! options
16498 subpage title=[[Subpage test]]
16499 !! wikitext
16500 [[/subpage]]
16501 !! html
16502 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
16503 </p>
16504 !! end
16505
16506 !! test
16507 Subpage noslash link
16508 !! options
16509 subpage title=[[Subpage test]]
16510 !! wikitext
16511 [[/subpage/]]
16512 !! html
16513 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
16514 </p>
16515 !! end
16516
16517 !! article
16518 Subpage test/1/2/subpage
16519 !! text
16520 blah
16521 !! endarticle
16522
16523 !! test
16524 Relative subpage noslash link
16525 !! options
16526 parsoid=wt2wt,wt2html,html2html
16527 subpage title=[[Subpage test/1/2/3/4]]
16528 !! wikitext
16529 [[../../subpage/]]
16530
16531 [[../../subpage]]
16532 !! html/php
16533 <p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a>
16534 </p><p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage test/1/2/subpage</a>
16535 </p>
16536 !! html/parsoid
16537 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a></p>
16538 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage_test/1/2/subpage</a></p>
16539 !! end
16540
16541 !! test
16542 Parsoid: dot-slash prefixed wikilinks
16543 !! wikitext
16544 [[./foo]]
16545
16546 [[././bar]]
16547
16548 [[././baz/]]
16549 !! html/php
16550 <p>[[./foo]]
16551 </p><p>[[././bar]]
16552 </p><p>[[././baz/]]
16553 </p>
16554 !! html/parsoid
16555 <p>[[./foo]]
16556 </p><p>[[././bar]]
16557 </p><p>[[././baz/]]
16558 </p>
16559 !! end
16560
16561 !! test
16562 Render invalid page names as plain text (T53090)
16563 !! wikitext
16564 [[./../foo|bar]]
16565 [[foo�|bar]]
16566 [[foo/.|bar]]
16567 [[foo/..|bar]]
16568 [[foo~~~bar]]
16569 [[foo>bar]]
16570 [[foo[bar]]
16571 [[.]]
16572 [[..]]
16573 [[foo././bar]]
16574 [[foo[http://example.com]xyz]]
16575
16576 [[{{echo|./../foo}}|bar]]
16577 [[{{echo|foo/.}}|bar]]
16578 [[{{echo|foo/..}}|bar]]
16579 [[{{echo|foo~~~~bar}}]]
16580 [[{{echo|foo>bar}}]]
16581 [[{{echo|foo././bar}}]]
16582 [[{{echo|foo{bar}}]]
16583 [[{{echo|foo}bar}}]]
16584 [[{{echo|foo[bar}}]]
16585 [[{{echo|foo]bar}}]]
16586 [[{{echo|foo<bar}}]]
16587 !!html/php
16588 <p>[[./../foo|bar]]
16589 [[foo�|bar]]
16590 [[foo/.|bar]]
16591 [[foo/..|bar]]
16592 [[foo~~~bar]]
16593 [[foo&gt;bar]]
16594 [[foo[bar]]
16595 [[.]]
16596 [[..]]
16597 [[foo././bar]]
16598 [[foo<a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>xyz]]
16599 </p><p>[[./../foo|bar]]
16600 [[foo/.|bar]]
16601 [[foo/..|bar]]
16602 [[foo~~~~bar]]
16603 [[foo&gt;bar]]
16604 [[foo././bar]]
16605 [[foo{bar]]
16606 [[foo}bar]]
16607 [[foo[bar]]
16608 [[foo]bar]]
16609 [[foo&lt;bar]]
16610 </p>
16611 !!html/parsoid
16612 <p>[[./../foo|bar]]
16613 [[foo�|bar]]
16614 [[foo/.|bar]]
16615 [[foo/..|bar]]
16616 [[foo~~~bar]]
16617 [[foo>bar]]
16618 [[foo[bar]]
16619 [[.]]
16620 [[..]]
16621 [[foo././bar]]
16622 [[foo<a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>xyz]]</p>
16623
16624 <p>[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"./../foo"}},"i":0}}]}'>./../foo</span>|bar]]
16625 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/."}},"i":0}}]}'>foo/.</span>|bar]]
16626 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/.."}},"i":0}}]}'>foo/..</span>|bar]]
16627 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo~~~~bar"}},"i":0}}]}'>foo~~~~bar</span>]]
16628 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo>bar"}},"i":0}}]}'>foo>bar</span>]]
16629 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo././bar"}},"i":0}}]}'>foo././bar</span>]]
16630 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo{bar"}},"i":0}}]}'>foo{bar</span>]]
16631 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}bar"}},"i":0}}]}'>foo}bar</span>]]
16632 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo[bar"}},"i":0}}]}'>foo[bar</span>]]
16633 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo]bar"}},"i":0}}]}'>foo]bar</span>]]
16634 [[<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>
16635 !!end
16636
16637 !! test
16638 Disabled subpages
16639 !! wikitext
16640 [[/subpage]]
16641 !! html
16642 <p><a href="/index.php?title=/subpage&amp;action=edit&amp;redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a>
16643 </p>
16644 !! end
16645
16646 !! test
16647 T2561: {{/Subpage}}
16648 !! options
16649 subpage title=[[Page]]
16650 !! wikitext
16651 {{/Subpage}}
16652 !! html
16653 <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>
16654 </p>
16655 !! end
16656
16657 ###
16658 ### Categories
16659 ###
16660 !! article
16661 Category:MediaWiki User's Guide
16662 !! text
16663 blah
16664 !! endarticle
16665
16666 !! test
16667 Link to category
16668 !! wikitext
16669 [[:Category:MediaWiki User's Guide]]
16670 !! html
16671 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User&#39;s Guide">Category:MediaWiki User's Guide</a>
16672 </p>
16673 !! end
16674
16675 !! test
16676 Simple category
16677 !! options
16678 cat
16679 !! wikitext
16680 [[Category:MediaWiki User's Guide]]
16681 !! html/php
16682 cat=MediaWiki_User's_Guide sort=
16683 !! html/parsoid
16684 <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"}}'/>
16685 !! end
16686
16687 !! test
16688 PAGESINCATEGORY invalid title fatal (r33546 fix)
16689 !! wikitext
16690 {{PAGESINCATEGORY:<bogus>}}
16691 !! html
16692 <p>0
16693 </p>
16694 !! end
16695
16696 !! test
16697 Category with different sort key
16698 !! options
16699 cat
16700 !! wikitext
16701 [[Category:MediaWiki User's Guide|Foo]]
16702 !! html/php
16703 cat=MediaWiki_User's_Guide sort=Foo
16704 !! html/parsoid
16705 <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"}}'/>
16706 !! end
16707
16708 !! test
16709 Category with identical sort key
16710 !! options
16711 cat
16712 !! wikitext
16713 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
16714 !! html/php
16715 cat=MediaWiki_User's_Guide sort=MediaWiki User's Guide
16716 !! html/parsoid
16717 <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"}}'/>
16718 !! end
16719
16720 !! test
16721 Category with empty sort key
16722 !! options
16723 cat
16724 pst
16725 !! wikitext
16726 [[Category:MediaWiki User's Guide|]]
16727 !! html/php
16728 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
16729 !! end
16730
16731 !! test
16732 Category with empty sort key and parentheses
16733 !! options
16734 cat
16735 pst
16736 !! wikitext
16737 [[Category:Foo (bar)|]]
16738 !! html/php
16739 [[Category:Foo (bar)|Foo]]
16740 !! end
16741
16742 !! test
16743 Category with link tail
16744 !! options
16745 cat
16746 pst
16747 !! wikitext
16748 123[[Category:Foo]]456
16749 !! html/php
16750 123[[Category:Foo]]456
16751 !! end
16752
16753 !! test
16754 Category with template
16755 !! options
16756 cat
16757 pst
16758 !! wikitext
16759 [[Category:{{echo|Foo}}]]
16760 !! html/php
16761 [[Category:{{echo|Foo}}]]
16762 !! end
16763
16764 !! test
16765 Category with template in sort key
16766 !! options
16767 cat
16768 pst
16769 !! wikitext
16770 [[Category:Foo|{{echo|Bar}}]]
16771 !! html/php
16772 [[Category:Foo|{{echo|Bar}}]]
16773 !! end
16774
16775 !! test
16776 Category with template in sort key and title
16777 !! options
16778 cat
16779 pst
16780 !! wikitext
16781 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16782 !! html/php
16783 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16784 !! end
16785
16786 ## We used to, but no longer wt2wt this test since the default serializer
16787 ## will normalize all categories to serialize on their own line.
16788 ## This wikitext usage is going to be fairly uncommon in production and
16789 ## selser will take care of preserving formatting in those scenarios.
16790 !! test
16791 Category / paragraph interactions
16792 !! options
16793 parsoid=wt2html
16794 !! wikitext
16795 Foo [[Category:Baz]] Bar
16796
16797 Foo [[Category:Baz]]
16798 Bar
16799
16800 Foo
16801 [[Category:Baz]]
16802 Bar
16803
16804 Foo
16805 [[Category:Baz]] Bar
16806
16807 Foo
16808 [[Category:Baz]]
16809 [[Category:Baz]]
16810 [[Category:Baz]]
16811 Bar
16812
16813 [[Category:Baz]]
16814 [[Category:Baz]]
16815 [[Category:Baz]]
16816
16817 [[Category:Baz]]
16818 {{echo|[[Category:Baz]]}}
16819 [[Category:Baz]]
16820 !! html/php
16821 <p>Foo Bar
16822 </p><p>Foo
16823 Bar
16824 </p><p>Foo
16825 Bar
16826 </p><p>Foo Bar
16827 </p><p>Foo
16828 Bar
16829 </p>
16830 !! html/parsoid
16831 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16832 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16833 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16834 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16835 <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>
16836 <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}}]}'/>
16837 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
16838 !! end
16839
16840 ## We used to, but no longer wt2wt this test since the default serializer
16841 ## will normalize all categories to serialize on their own line.
16842 ## This wikitext usage is going to be fairly uncommon in production and
16843 ## selser will take care of preserving formatting in those scenarios.
16844 ##
16845 ## The whitespace on the empty line is part of the test. Please do not delete
16846 !! test
16847 1. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16848 !! options
16849 parsoid=wt2html
16850 !! wikitext
16851 This
16852
16853 [[Category:Foo]] and this should be part of same paragraph (not an indent-pre)
16854
16855 {{echo|[[Category:Foo]] and so should this!}}
16856 !! html/php
16857 <p>This and this should be part of same paragraph (not an indent-pre) and so should this!
16858 </p>
16859 !! html/parsoid
16860 <p>This
16861
16862 <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of same paragraph (not an indent-pre)
16863
16864 <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>
16865 !! end
16866
16867 ## Parsoid will not try to wt2wt this while preserving newlines because
16868 ## it suppresses excess newlines within list items -- and we don't want to
16869 ## introduce a special case just for categories, which is, in reality somewhat
16870 ## odd behavior -- categories are unlikely to be used in list items like this
16871 ## in top-level pages and are only likely to show up in template-generated
16872 ## list items where this RT-ing is a non-issue.
16873 ##
16874 ## The whitespace on the empty line is part of the test. Please do not delete
16875 !! test
16876 2. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16877 !! options
16878 parsoid=wt2html
16879 !! wikitext
16880 * This
16881
16882 [[Category:Foo]] and this should be part of the same list item
16883 * So should this
16884
16885 {{echo|[[Category:Foo]] and this should be part of the same list item}}
16886 !! html/php+tidy
16887 <ul><li>This and this should be part of the same list item</li>
16888 <li>So should this and this should be part of the same list item</li></ul>
16889 !! html/parsoid
16890 <ul>
16891 <li>This <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of the same list item</li>
16892 <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>
16893 </ul>
16894 !! end
16895
16896 ## Newlines and categories that follow the last item of a list
16897 ## are treated differently because this (list followed by categories)
16898 ## is an extremely common pattern on wikis.
16899 !! test
16900 3. Categories and newlines: newline suppression for last list item should RT properly
16901 !! wikitext
16902 *a
16903 *b
16904
16905 [[Category:Foo]]
16906
16907 [[Category:Bar]]
16908 [[Category:Baz]]
16909
16910 :c
16911
16912 [[Category:C]]
16913
16914 ;d
16915
16916 [[Category:D]]
16917 !! html/parsoid
16918 <ul><li>a</li>
16919 <li>b</li></ul>
16920
16921 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
16922
16923 <link rel="mw:PageProp/Category" href="./Category:Bar"/>
16924 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
16925
16926 <dl><dd>c</dd></dl>
16927
16928 <link rel="mw:PageProp/Category" href="./Category:C"/>
16929
16930 <dl><dt>d</dt></dl>
16931
16932 <link rel="mw:PageProp/Category" href="./Category:D"/>
16933 !! end
16934
16935 !! test
16936 4. Categories and newlines: newline suppression for last list item should RT properly
16937 !! wikitext
16938 *a
16939 ****b
16940
16941 [[Category:Foo]]
16942 !! html/parsoid
16943 <ul><li>a
16944 <ul><li><ul><li><ul><li>b</li></ul></li></ul></li></ul></li></ul>
16945
16946 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16947 !! end
16948
16949 ## only wt2html for this to make sure the algo only applies to the rightmost path
16950 !! test
16951 5. Categories and newlines: migrateTrailingCategories dom pass should only run on the rightmost path of nested lists
16952 !! options
16953 parsoid=wt2html
16954 !! wikitext
16955 *a
16956 **b
16957 [[Category:Foo]]
16958 *c
16959 **d
16960 [[Category:Foo]]
16961 !! html/parsoid
16962 <ul><li>a
16963 <ul><li>b
16964 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul></li>
16965 <li>c
16966 <ul><li>d</li></ul></li></ul>
16967 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16968 !! end
16969
16970 ## We used to, but no longer wt2wt this test since the default serializer
16971 ## will normalize all categories to serialize on their own line.
16972 ## This wikitext usage is going to be fairly uncommon in production and
16973 ## selser will take care of preserving formatting in those scenarios.
16974 !! test
16975 6. Categories and newlines: migrateTrailingCategories dom pass should not migrate categories not preceded by newlines
16976 !! options
16977 parsoid=wt2html
16978 !! wikitext
16979 *a [[Category:Foo]]
16980 !! html/parsoid
16981 <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>
16982 !! end
16983
16984 # This test also demonstrates because of newline+category tunneling
16985 # through the list hander, template wrapping doesn't expand to the
16986 # containing list when the list item swallows the category.
16987 !! test
16988 7. Categories and newlines: migrateTrailingCategories dom pass should leave template content alone
16989 !! wikitext
16990 *{{echo|a
16991 [[Category:Foo]]}}
16992 !! html/parsoid
16993 <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
16994 </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>
16995 !! end
16996
16997 !! test
16998 8. Categories and newlines: migrateTrailingCategories dom pass should not get tripped by intervening templates
16999 !! wikitext
17000 *a
17001
17002 {{echo|[[Category:Foo]]
17003 [[Category:Bar]]}}
17004 [[Category:Baz]]
17005 !! html/parsoid
17006 <ul><li>a</li></ul>
17007
17008 <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">
17009 </span><link rel="mw:PageProp/Category" href="./Category:Bar" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
17010 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
17011 !! end
17012
17013 !! test
17014 Categories and newlines: migrateTrailingCategories dom pass should not get tripped by comments and whitespace
17015 !! wikitext
17016 *a
17017
17018 [[Category:Bar]]<!--boo1--> <!--boo2-->
17019 [[Category:Baz]]<!--boo3--> <!--boo4-->
17020 !! html/parsoid
17021 <ul><li>a</li></ul>
17022
17023 <link rel="mw:PageProp/Category" href="./Category:Bar"/><!--boo1--> <!--boo2-->
17024 <link rel="mw:PageProp/Category" href="./Category:Baz"/><!--boo3--> <!--boo4-->
17025 !! end
17026
17027 !! test
17028 Categories and newlines: should behave properly with linkprefix (T87753)
17029 !! options
17030 language=ar
17031 !! wikitext
17032 foo bar
17033 foo bar
17034 [[تصنيف:Foo]]
17035 [[تصنيف:Bar]]
17036 !! html/php
17037 <p>foo bar
17038 foo bar
17039 </p>
17040 !! html/parsoid
17041 <p>foo bar
17042 foo bar</p>
17043 <link rel="mw:PageProp/Category" href="./تصنيف:Foo"/>
17044 <link rel="mw:PageProp/Category" href="./تصنيف:Bar"/>
17045 !! end
17046
17047 !! test
17048 No regressions on internal links following category (T174639)
17049 !! options
17050 parsoid=wt2html,html2html
17051 !! wikitext
17052 [[Category:Foo]]<div>a
17053
17054 [[Foo]]</div>
17055 !! html/php
17056 <div>a
17057 <a href="/wiki/Foo" title="Foo">Foo</a></div>
17058
17059 !! html/parsoid
17060 <link rel="mw:PageProp/Category" href="./Category:Foo"/><div>a
17061
17062 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></div>
17063 !! end
17064
17065 # Note that Parsoid differs slightly from PHP due to T175421
17066 !! test
17067 11. Special case where only newlines separate links (T175416)
17068 !! options
17069 parsoid=wt2html,html2html
17070 !! wikitext
17071 [[Category:Foo]]
17072
17073 [[Foo]][[es:Alimento]]
17074
17075 [[Foo]]
17076 !! html/php
17077 <p><br />
17078 <a href="/wiki/Foo" title="Foo">Foo</a>
17079 </p><p><a href="/wiki/Foo" title="Foo">Foo</a>
17080 </p>
17081 !! html/parsoid
17082 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
17083
17084 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p><link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
17085
17086 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p>
17087 !! end
17088
17089 !! test
17090 Category links with multiple namespaces
17091 !! wikitext
17092 [[Category:Project:Foo]]
17093 !! html/parsoid
17094 <link rel="mw:PageProp/Category" href="./Category:Project:Foo" />
17095 !! end
17096
17097 !! test
17098 Parsoid: Serialize link to category page with colon escape
17099 !! wikitext
17100
17101 [[:Category:Foo]]
17102 [[:Category:Foo|Bar]]
17103 !! html/php+tidy
17104 <p><a href="/index.php?title=Category:Foo&amp;action=edit&amp;redlink=1" class="new" title="Category:Foo (page does not exist)">Category:Foo</a>
17105 <a href="/index.php?title=Category:Foo&amp;action=edit&amp;redlink=1" class="new" title="Category:Foo (page does not exist)">Bar</a>
17106 </p>
17107 !! html/parsoid
17108 <p>
17109 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Category:Foo</a>
17110 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Bar</a>
17111 </p>
17112 !! end
17113
17114 # We used to, but no longer wt2wt this test since the default serializer
17115 # will normalize all categories to serialize on their own line.
17116 # This wikitext usage is going to be fairly uncommon in production and
17117 # selser will take care of preventing whitespace insertion if this
17118 # occurs in an article.
17119 #
17120 # html2html disabled for the same reason (whitespace insertion between
17121 # x and y).
17122 #
17123 # html2wt disabled because it localizes the "Category" namespace.
17124 !! test
17125 Link prefix/suffixes aren't applied to category links
17126 !! options
17127 parsoid=wt2html
17128 language=is
17129 !! wikitext
17130 x[[Category:Foo]]y
17131 !! html/php
17132 <p>xy
17133 </p>
17134 !! html/parsoid
17135 <p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p>
17136 !! end
17137
17138 !! test
17139 Link prefix/suffixes aren't applied to language links
17140 !! options
17141 parsoid=wt2html
17142 language=is
17143 !! wikitext
17144 x[[es:Foo]]y
17145 !! html/php
17146 <p>xy
17147 </p>
17148 !! html/parsoid
17149 <p>x<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo" data-parsoid=""/>y</p>
17150 !! end
17151
17152 !! test
17153 Parsoid: Serialize link to file page with colon escape
17154 !! wikitext
17155
17156 [[:File:Foo.png]]
17157 [[:File:Foo.png|Bar]]
17158 !! html/php+tidy
17159 <p><a href="/index.php?title=File:Foo.png&amp;action=edit&amp;redlink=1" class="new" title="File:Foo.png (page does not exist)">File:Foo.png</a>
17160 <a href="/index.php?title=File:Foo.png&amp;action=edit&amp;redlink=1" class="new" title="File:Foo.png (page does not exist)">Bar</a>
17161 </p>
17162 !! html/parsoid
17163 <p>
17164 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">File:Foo.png</a>
17165 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">Bar</a>
17166 </p>
17167 !! end
17168
17169 !! test
17170 Parsoid: Serialize a genuine category link without colon escape
17171 !! wikitext
17172 [[Category:Foo]]
17173 [[Category:Foo|Bar]]
17174 !! html/php+tidy
17175 !! html/parsoid
17176 <link rel="mw:PageProp/Category" href="./Category:Foo">
17177 <link rel="mw:PageProp/Category" href="./Category:Foo#Bar">
17178 !! end
17179
17180 !! test
17181 Normalize hrefs properly before testing for invalid link targets (T72894)
17182 !! options
17183 parsoid=html2wt
17184 !! html/parsoid
17185 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/>
17186 !! wikitext
17187 [[Category:Toxine bactérienne]]
17188 !! end
17189
17190 !! test
17191 Parsoid: Defaultsort
17192 !! wikitext
17193 {{DEFAULTSORT:Foo}}
17194 !! html/parsoid
17195 <meta property="mw:PageProp/categorydefaultsort" content="Foo"/>
17196 !! end
17197
17198 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
17199 # But, this is a limitation of our representation and is documented in
17200 # TemplateHandler.js in processSpecialMagicWord
17201 !! test
17202 Parsoid: Defaultsort (template-generated)
17203 !! wikitext
17204 {{{{echo|DEFAULTSORT}}:Foo}}
17205 !! html/parsoid
17206 <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"}]]}'/>
17207 !! end
17208
17209 ###
17210 ### Inter-language links
17211 ###
17212 !! test
17213 Interlanguage links
17214 !! options
17215 ill
17216 !! wikitext
17217 [[es:Alimento]]
17218 [[fr:Nourriture]]
17219 [[zh:食品]]
17220 !! html/php
17221 es:Alimento fr:Nourriture zh:食品
17222 !! html/parsoid
17223 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
17224 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Nourriture"/>
17225 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/食品"/>
17226 !! end
17227
17228 !! test
17229 Duplicate interlanguage links (T26502)
17230 !! options
17231 ill
17232 !! wikitext
17233 [[es:1]]
17234 [[es:2]]
17235 [[fr:1]]
17236 [[fr:2]]
17237 !! html/php
17238 es:1 fr:1
17239 !! html/parsoid
17240 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/1"/>
17241 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/2"/>
17242 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/1"/>
17243 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/2"/>
17244 !! end
17245
17246 ###
17247 ### Sections
17248 ###
17249 !! test
17250 Basic section headings
17251 !! wikitext
17252 ==Headline 1==
17253 Some text
17254
17255 ==Headline 2==
17256 More
17257 ===Smaller headline===
17258 Blah blah
17259 !! html
17260 <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>
17261 <p>Some text
17262 </p>
17263 <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>
17264 <p>More
17265 </p>
17266 <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>
17267 <p>Blah blah
17268 </p>
17269 !! end
17270
17271 !! test
17272 Section headings with TOC
17273 !! wikitext
17274 ==Headline 1==
17275 ===Subheadline 1===
17276 =====Skipping a level=====
17277 ======Skipping a level======
17278
17279 ==Headline 2==
17280 Some text
17281 ===Another headline===
17282 !! html
17283 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17284 <ul>
17285 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
17286 <ul>
17287 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
17288 <ul>
17289 <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>
17290 <ul>
17291 <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>
17292 </ul>
17293 </li>
17294 </ul>
17295 </li>
17296 </ul>
17297 </li>
17298 <li class="toclevel-1 tocsection-5"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
17299 <ul>
17300 <li class="toclevel-2 tocsection-6"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
17301 </ul>
17302 </li>
17303 </ul>
17304 </div>
17305
17306 <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>
17307 <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>
17308 <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>
17309 <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>
17310 <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>
17311 <p>Some text
17312 </p>
17313 <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>
17314
17315 !! end
17316
17317 !! test
17318 TOC anchors don't collide
17319 !! wikitext
17320 __FORCETOC__
17321 ==Headline 2==
17322 ==Headline==
17323 ==Headline 2==
17324 ==Headline==
17325 !! html/php
17326 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17327 <ul>
17328 <li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
17329 <li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
17330 <li class="toclevel-1 tocsection-3"><a href="#Headline_2_2"><span class="tocnumber">3</span> <span class="toctext">Headline 2</span></a></li>
17331 <li class="toclevel-1 tocsection-4"><a href="#Headline_3"><span class="tocnumber">4</span> <span class="toctext">Headline</span></a></li>
17332 </ul>
17333 </div>
17334
17335 <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>
17336 <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>
17337 <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>
17338 <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>
17339
17340 !! end
17341
17342 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
17343 # Parsoid html2wt direction adds <nowiki> for level 7 and up.
17344 !! test
17345 Handling of sections up to level 6 and beyond
17346 !! options
17347 parsoid=wt2html
17348 !! wikitext
17349 =Level 1 Heading=
17350 ==Level 2 Heading==
17351 ===Level 3 Heading===
17352 ====Level 4 Heading====
17353 =====Level 5 Heading=====
17354 ======Level 6 Heading======
17355 =======Level 7 Heading=======
17356 ========Level 8 Heading========
17357 =========Level 9 Heading=========
17358 ==========Level 10 Heading==========
17359 !! html/php
17360 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17361 <ul>
17362 <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
17363 <ul>
17364 <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>
17365 <ul>
17366 <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>
17367 <ul>
17368 <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>
17369 <ul>
17370 <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>
17371 <ul>
17372 <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>
17373 <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>
17374 <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>
17375 <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>
17376 <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>
17377 </ul>
17378 </li>
17379 </ul>
17380 </li>
17381 </ul>
17382 </li>
17383 </ul>
17384 </li>
17385 </ul>
17386 </li>
17387 </ul>
17388 </div>
17389
17390 <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>
17391 <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>
17392 <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>
17393 <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>
17394 <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>
17395 <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>
17396 <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>
17397 <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>
17398 <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>
17399 <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>
17400
17401 !! html/parsoid
17402 <h1 id="Level_1_Heading" data-parsoid='{}'>Level 1 Heading</h1>
17403 <h2 id="Level_2_Heading" data-parsoid='{}'>Level 2 Heading</h2>
17404 <h3 id="Level_3_Heading" data-parsoid='{}'>Level 3 Heading</h3>
17405 <h4 id="Level_4_Heading" data-parsoid='{}'>Level 4 Heading</h4>
17406 <h5 id="Level_5_Heading" data-parsoid='{}'>Level 5 Heading</h5>
17407 <h6 id="Level_6_Heading" data-parsoid='{}'>Level 6 Heading</h6>
17408 <h6 id="=Level_7_Heading=" data-parsoid='{}'><span id=".3DLevel_7_Heading.3D" typeof="mw:FallbackId"></span>=Level 7 Heading=</h6>
17409 <h6 id="==Level_8_Heading==" data-parsoid='{}'><span id=".3D.3DLevel_8_Heading.3D.3D" typeof="mw:FallbackId"></span>==Level 8 Heading==</h6>
17410 <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>
17411 <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>
17412 !! end
17413
17414 !! test
17415 TOC regression (T11764)
17416 !! wikitext
17417 ==title 1==
17418 ===title 1.1===
17419 ====title 1.1.1====
17420 ===title 1.2===
17421 ==title 2==
17422 ===title 2.1===
17423 !! html
17424 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17425 <ul>
17426 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
17427 <ul>
17428 <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>
17429 <ul>
17430 <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>
17431 </ul>
17432 </li>
17433 <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>
17434 </ul>
17435 </li>
17436 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
17437 <ul>
17438 <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>
17439 </ul>
17440 </li>
17441 </ul>
17442 </div>
17443
17444 <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>
17445 <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>
17446 <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>
17447 <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>
17448 <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>
17449 <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>
17450
17451 !! end
17452
17453 !! test
17454 TOC for heading containing <span id="..."></span> (T96153)
17455 !! wikitext
17456 __FORCETOC__
17457 ==<span id="old-anchor"></span>New title==
17458 !! html/php
17459 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17460 <ul>
17461 <li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
17462 </ul>
17463 </div>
17464
17465 <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>
17466
17467 !! end
17468
17469 !! test
17470 TOC with wgMaxTocLevel=3 (T8204)
17471 !! options
17472 wgMaxTocLevel=3
17473 !! wikitext
17474 ==title 1==
17475 ===title 1.1===
17476 ====title 1.1.1====
17477 ===title 1.2===
17478 ==title 2==
17479 ===title 2.1===
17480 !! html
17481 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17482 <ul>
17483 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
17484 <ul>
17485 <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>
17486 <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>
17487 </ul>
17488 </li>
17489 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
17490 <ul>
17491 <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>
17492 </ul>
17493 </li>
17494 </ul>
17495 </div>
17496
17497 <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>
17498 <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>
17499 <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>
17500 <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>
17501 <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>
17502 <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>
17503
17504 !! end
17505
17506 !! test
17507 TOC with wgMaxTocLevel=3 and two level four headings (T8204)
17508 !! options
17509 wgMaxTocLevel=3
17510 !! wikitext
17511 ==Section 1==
17512 ===Section 1.1===
17513 ====Section 1.1.1====
17514 ====Section 1.1.1.1====
17515 ==Section 2==
17516 !! html
17517 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17518 <ul>
17519 <li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
17520 <ul>
17521 <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>
17522 </ul>
17523 </li>
17524 <li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li>
17525 </ul>
17526 </div>
17527
17528 <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>
17529 <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>
17530 <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>
17531 <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>
17532 <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>
17533
17534 !! end
17535
17536
17537 !! test
17538 Resolving duplicate section names
17539 !! wikitext
17540 ==Foo bar==
17541 ==Foo bar==
17542 !! html
17543 <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>
17544 <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>
17545
17546 !! end
17547
17548 !! test
17549 Resolving duplicate section names with differing case (T12721)
17550 !! wikitext
17551 ==Foo bar==
17552 ==Foo Bar==
17553 !! html
17554 <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>
17555 <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>
17556
17557 !! end
17558
17559 !! article
17560 Template:sections
17561 !! text
17562 ===Section 1===
17563 ==Section 2==
17564 !! endarticle
17565
17566 !! test
17567 Template with sections, __NOTOC__
17568 !! wikitext
17569 __NOTOC__
17570 ==Section 0==
17571 {{sections}}
17572 ==Section 4==
17573 !! html
17574 <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>
17575 <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>
17576 <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>
17577 <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>
17578
17579 !! end
17580
17581 !! test
17582 __NOEDITSECTION__ keyword
17583 !! wikitext
17584 __NOEDITSECTION__
17585 ==Section 1==
17586 ==Section 2==
17587 !! html
17588 <h2><span class="mw-headline" id="Section_1">Section 1</span></h2>
17589 <h2><span class="mw-headline" id="Section_2">Section 2</span></h2>
17590
17591 !! end
17592
17593 !! test
17594 Link inside a section heading
17595 !! wikitext
17596 ==Section with a [[Main Page|link]] in it==
17597 !! html
17598 <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>
17599
17600 !! end
17601
17602 !! test
17603 TOC regression (T14077)
17604 !! wikitext
17605 __TOC__
17606 ==title 1==
17607 ===title 1.1===
17608 ==title 2==
17609 !! html
17610 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17611 <ul>
17612 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
17613 <ul>
17614 <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>
17615 </ul>
17616 </li>
17617 <li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li>
17618 </ul>
17619 </div>
17620
17621 <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>
17622 <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>
17623 <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>
17624
17625 !! end
17626
17627 !! test
17628 T3219 URL next to image (good)
17629 !! wikitext
17630 http://example.com [[File:Foobar.jpg]]
17631 !! html/php
17632 <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>
17633 </p>
17634 !! html/parsoid
17635 <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>
17636 !!end
17637
17638 # Parsoid doesn't wt2wt this cleanly because it adds <nowiki>s.
17639 !! test
17640 Short headings with trailing space should match behavior of Parser::doHeadings (T21910)
17641 !! options
17642 parsoid=wt2html,html2html
17643 !! wikitext
17644 ===
17645 The line above must have a trailing space!
17646 === <!--
17647 --> <!-- -->
17648 But just in case it doesn't...
17649 !! html/php
17650 <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>
17651 <p>The line above must have a trailing space!
17652 </p>
17653 <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>
17654 <p>But just in case it doesn't...
17655 </p>
17656 !! html/parsoid
17657 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
17658 <p>The line above must have a trailing space!</p>
17659 <h1 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h1> <!--
17660 --> <!-- -->
17661 <p>But just in case it doesn't...</p>
17662 !! end
17663
17664 !! test
17665 Header with special characters (T27462)
17666 !! wikitext
17667 The tooltips shall not show entities to the user (ie. be double escaped)
17668
17669 ==text > text==
17670 section 1
17671
17672 ==text < text==
17673 section 2
17674
17675 ==text & text==
17676 section 3
17677
17678 ==text ' text==
17679 section 4
17680
17681 ==text " text==
17682 section 5
17683 !! html/php
17684 <p>The tooltips shall not show entities to the user (ie. be double escaped)
17685 </p>
17686 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17687 <ul>
17688 <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>
17689 <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>
17690 <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>
17691 <li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li>
17692 <li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li>
17693 </ul>
17694 </div>
17695
17696 <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>
17697 <p>section 1
17698 </p>
17699 <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>
17700 <p>section 2
17701 </p>
17702 <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>
17703 <p>section 3
17704 </p>
17705 <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>
17706 <p>section 4
17707 </p>
17708 <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>
17709 <p>section 5
17710 </p>
17711 !! html/parsoid
17712 <p>The tooltips shall not show entities to the user (ie. be double escaped)</p>
17713
17714 <h2 id="text_>_text"><span id="text_.3E_text" typeof="mw:FallbackId"></span>text > text</h2>
17715 <p>section 1</p>
17716
17717 <h2 id="text_&lt;_text"><span id="text_.3C_text" typeof="mw:FallbackId"></span>text &lt; text</h2>
17718 <p>section 2</p>
17719
17720 <h2 id="text_&amp;_text"><span id="text_.26_text" typeof="mw:FallbackId"></span>text &amp; text</h2>
17721 <p>section 3</p>
17722
17723 <h2 id="text_'_text"><span id="text_.27_text" typeof="mw:FallbackId"></span>text ' text</h2>
17724 <p>section 4</p>
17725
17726 <h2 id='text_"_text'><span id="text_.22_text" typeof="mw:FallbackId"></span>text " text</h2>
17727 <p>section 5</p>
17728 !! end
17729
17730 !! test
17731 Header with space, plus and underscore as entity
17732 !! wikitext
17733 Id should not contain + for spaces
17734
17735 ==Space between Text==
17736 section 1
17737
17738 ==Space-Entity&#32;between&#32;Text==
17739 section 2
17740
17741 ==Plus+between+Text==
17742 section 3
17743
17744 ==Plus-Entity&#43;between&#43;Text==
17745 section 4
17746
17747 ==Underscore_between_Text==
17748 section 5
17749
17750 ==Underscore-Entity&#95;between&#95;Text==
17751 section 6
17752
17753 [[#Space between Text]]
17754 [[#Space-Entity&#32;between&#32;Text]]
17755 [[#Plus+between+Text]]
17756 [[#Plus-Entity&#43;between&#43;Text]]
17757 [[#Underscore_between_Text]]
17758 [[#Underscore-Entity&#95;between&#95;Text]]
17759 !! html/php
17760 <p>Id should not contain + for spaces
17761 </p>
17762 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17763 <ul>
17764 <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>
17765 <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>
17766 <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>
17767 <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>
17768 <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>
17769 <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>
17770 </ul>
17771 </div>
17772
17773 <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>
17774 <p>section 1
17775 </p>
17776 <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>
17777 <p>section 2
17778 </p>
17779 <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>
17780 <p>section 3
17781 </p>
17782 <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>
17783 <p>section 4
17784 </p>
17785 <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>
17786 <p>section 5
17787 </p>
17788 <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>
17789 <p>section 6
17790 </p><p><a href="#Space_between_Text">#Space between Text</a>
17791 <a href="#Space-Entity_between_Text">#Space-Entity&#32;between&#32;Text</a>
17792 <a href="#Plus.2Bbetween.2BText">#Plus+between+Text</a>
17793 <a href="#Plus-Entity.2Bbetween.2BText">#Plus-Entity&#43;between&#43;Text</a>
17794 <a href="#Underscore_between_Text">#Underscore_between_Text</a>
17795 <a href="#Underscore-Entity_between_Text">#Underscore-Entity&#95;between&#95;Text</a>
17796 </p>
17797 !! html/parsoid
17798 <p>Id should not contain + for spaces</p>
17799
17800 <h2 id="Space_between_Text">Space between Text</h2>
17801 <p>section 1</p>
17802
17803 <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>
17804 <p>section 2</p>
17805
17806 <h2 id="Plus+between+Text"><span id="Plus.2Bbetween.2BText" typeof="mw:FallbackId"></span>Plus+between+Text</h2>
17807 <p>section 3</p>
17808
17809 <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>
17810 <p>section 4</p>
17811
17812 <h2 id="Underscore_between_Text">Underscore_between_Text</h2>
17813 <p>section 5</p>
17814
17815 <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>
17816 <p>section 6</p>
17817
17818 <p><a rel="mw:WikiLink" href="./Parser_test#Space_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Space_between_Text"},"sa":{"href":"#Space between Text"}}'>#Space between Text</a>
17819 <a rel="mw:WikiLink" href="./Parser_test#Space-Entity_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Space-Entity_between_Text"},"sa":{"href":"#Space-Entity&amp;#32;between&amp;#32;Text"}}'>#Space-Entity between Text</a>
17820 <a rel="mw:WikiLink" href="./Parser_test#Plus+between+Text" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Plus+between+Text"},"sa":{"href":"#Plus+between+Text"}}'>#Plus+between+Text</a>
17821 <a rel="mw:WikiLink" href="./Parser_test#Plus-Entity+between+Text" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Plus-Entity+between+Text"},"sa":{"href":"#Plus-Entity&amp;#43;between&amp;#43;Text"}}'>#Plus-Entity+between+Text</a>
17822 <a rel="mw:WikiLink" href="./Parser_test#Underscore_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Underscore_between_Text"},"sa":{"href":"#Underscore_between_Text"}}'>#Underscore_between_Text</a>
17823 <a rel="mw:WikiLink" href="./Parser_test#Underscore-Entity_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Underscore-Entity_between_Text"},"sa":{"href":"#Underscore-Entity&amp;#95;between&amp;#95;Text"}}'>#Underscore-Entity_between_Text</a></p>
17824 !! end
17825
17826 # Parsoid html2wt disabled because it adds padding spaces around =
17827 !! test
17828 Headers with excess '=' characters
17829 (Are similar tests necessary beyond the 1st level?)
17830 !! options
17831 parsoid=wt2html,wt2wt,html2html
17832 !! wikitext
17833 =foo==
17834 ==foo=
17835 =''italic'' heading==
17836 ==''italic'' heading=
17837 !! html/php
17838 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17839 <ul>
17840 <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
17841 <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
17842 <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>
17843 <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>
17844 </ul>
17845 </div>
17846
17847 <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>
17848 <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>
17849 <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>
17850 <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>
17851
17852 !! html/parsoid
17853 <h1 id="foo="><span id="foo.3D" typeof="mw:FallbackId"></span>foo=</h1>
17854 <h1 id="=foo"><span id=".3Dfoo" typeof="mw:FallbackId"></span>=foo</h1>
17855 <h1 id="italic_heading="><span id="italic_heading.3D" typeof="mw:FallbackId"></span><i>italic</i> heading=</h1>
17856 <h1 id="=italic_heading"><span id=".3Ditalic_heading" typeof="mw:FallbackId"></span>=<i>italic</i> heading</h1>
17857 !! end
17858
17859 !! test
17860 HTML headers vs TOC (T25393)
17861 (__NOEDITSECTION__ for clearer output, doesn't matter here)
17862 !! wikitext
17863 <h1>Header 1</h1>
17864 ==Header 1.1==
17865 ==Header 1.2==
17866
17867 <h1>Header 2
17868 </h1>
17869 ==Header 2.1==
17870 ==Header 2.2==
17871 __NOEDITSECTION__
17872 !! html/php
17873 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17874 <ul>
17875 <li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
17876 <ul>
17877 <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>
17878 <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>
17879 </ul>
17880 </li>
17881 <li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a>
17882 <ul>
17883 <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>
17884 <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>
17885 </ul>
17886 </li>
17887 </ul>
17888 </div>
17889
17890 <h1><span class="mw-headline" id="Header_1">Header 1</span></h1>
17891 <h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2>
17892 <h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2>
17893 <h1><span class="mw-headline" id="Header_2">Header 2
17894 </span></h1>
17895 <h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2>
17896 <h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2>
17897
17898 !! html/parsoid
17899 <h1 id="Header_1" data-parsoid='{"stx":"html"}'>Header 1</h1>
17900 <h2 id="Header_1.1" data-parsoid='{}'>Header 1.1</h2>
17901 <h2 id="Header_1.2" data-parsoid='{}'>Header 1.2</h2>
17902
17903 <h1 id="Header_2" data-parsoid='{"stx":"html"}'>Header 2
17904 </h1>
17905 <h2 id="Header_2.1" data-parsoid='{}'>Header 2.1</h2>
17906 <h2 id="Header_2.2" data-parsoid='{}'>Header 2.2</h2>
17907 <meta property="mw:PageProp/noeditsection"/>
17908 !! end
17909
17910 !! test
17911 Single-line or multiline-comments can follow headings
17912 !! options
17913 parsoid=wt2html,wt2wt
17914 !! wikitext
17915 ==foo==<!---->
17916 ==bar==<!--c1-->
17917 ==baz==<!--
17918 c2
17919 c3-->
17920 !! html/php
17921 <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>
17922 <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>
17923 <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>
17924
17925 !! html/parsoid
17926 <h2 id="foo">foo</h2><!---->
17927 <h2 id="bar">bar</h2><!--c1-->
17928 <h2 id="baz">baz</h2><!--
17929 c2
17930 c3-->
17931 !! end
17932
17933 !! test
17934 T3219 URL next to image (broken)
17935 !! wikitext
17936 http://example.com[[File:Foobar.jpg]]
17937 !! html/php
17938 <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>
17939 </p>
17940 !! html/parsoid
17941 <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>
17942 !!end
17943
17944 !! test
17945 T3186 news: in the middle of text
17946 !! wikitext
17947 http://en.wikinews.org/wiki/Wikinews:Workplace
17948 !! html
17949 <p><a rel="nofollow" class="external free" href="http://en.wikinews.org/wiki/Wikinews:Workplace">http://en.wikinews.org/wiki/Wikinews:Workplace</a>
17950 </p>
17951 !!end
17952
17953
17954 !! test
17955 Namespaced link must have a title
17956 !! wikitext
17957 [[Project:]]
17958 !! html
17959 <p>[[Project:]]
17960 </p>
17961 !!end
17962
17963 !! test
17964 Namespaced link must have a title (bad fragment version)
17965 !! wikitext
17966 [[Project:#fragment]]
17967 !! html
17968 <p>[[Project:#fragment]]
17969 </p>
17970 !!end
17971
17972
17973 ###
17974 ### HTML tags and HTML attributes
17975 ###
17976
17977 !! test
17978 div with no attributes
17979 !! wikitext
17980 <div>HTML rocks</div>
17981 !! html
17982 <div>HTML rocks</div>
17983
17984 !! end
17985
17986 !! test
17987 div with double-quoted attribute
17988 !! wikitext
17989 <div id="rock">HTML rocks</div>
17990 !! html
17991 <div id="rock">HTML rocks</div>
17992
17993 !! end
17994
17995 !! test
17996 div with single-quoted attribute
17997 !! wikitext
17998 <div id='rock'>HTML rocks</div>
17999 !! html
18000 <div id="rock">HTML rocks</div>
18001
18002 !! end
18003
18004 !! test
18005 div with unquoted attribute
18006 !! wikitext
18007 <div id=rock>HTML rocks</div>
18008 !! html
18009 <div id="rock">HTML rocks</div>
18010
18011 !! end
18012
18013 !! test
18014 div with illegal double attributes
18015 !! wikitext
18016 <div id="a" id="b">HTML rocks</div>
18017 !! html
18018 <div id="b">HTML rocks</div>
18019
18020 !!end
18021
18022 !! test
18023 div with empty attribute value, space before equals
18024 !! options
18025 parsoid=wt2html,html2html
18026 !! wikitext
18027 <div class =>HTML rocks</div>
18028 !! html/php
18029 <div class="">HTML rocks</div>
18030
18031 !! html/parsoid
18032 <div class="" data-parsoid='{"stx":"html"}'>HTML rocks</div>
18033 !! end
18034
18035 !! test
18036 div with multiple empty attribute values
18037 !! config
18038 wgFragmentMode=[ 'html5', 'legacy' ]
18039 !! options
18040 parsoid=wt2html,html2html
18041 !! wikitext
18042 <div id= title=>HTML rocks</div>
18043 !! html/php
18044 <div id="title=">HTML rocks</div>
18045
18046 !! html/parsoid
18047 <div id="title=" data-parsoid='{"stx":"html"}'>HTML rocks</div>
18048 !! end
18049
18050 # FIXME Parsoid doesn't actually match PHP here.
18051 # Probably we should use the synthetic <foo /> or <indicator>
18052 # extensions for this test, which are enabled when running parser tests.
18053 !! test
18054 Extension tag in attribute value
18055 !! wikitext
18056 <span title="<translate>123</translate>">ok</span>
18057 !! html/php+disabled
18058 <p>&lt;span title="&lt;translate&gt;123&lt;/translate&gt;"&gt;ok&lt;/span&gt;
18059 </p>
18060 !! html/parsoid
18061 <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>
18062 !! end
18063
18064 !! test
18065 table with multiple empty attribute values
18066 !! options
18067 parsoid=wt2html,html2html
18068 !! wikitext
18069 {| title= id=
18070 |hi
18071 |}
18072 !! html/php
18073 <table title="id=">
18074 <tr>
18075 <td>hi
18076 </td></tr></table>
18077
18078 !! html/parsoid
18079 <table title="id=">
18080 <tbody><tr><td>hi</td></tr>
18081 </tbody></table>
18082 !! end
18083
18084 !! test
18085 div with braces in attribute value
18086 !! wikitext
18087 <div title="{}">Foo</div>
18088 !! html/php
18089 <div title="&#123;&#125;">Foo</div>
18090
18091 !! html/parsoid
18092 <div title="{}">Foo</div>
18093 !! end
18094
18095 !! test
18096 div with empty attribute value, no space before equals
18097 !! options
18098 parsoid=wt2html,html2html
18099 !! wikitext
18100 <div class=>HTML rocks</div>
18101 !! html/php
18102 <div class="">HTML rocks</div>
18103
18104 !! html/parsoid
18105 <div class="">HTML rocks</div>
18106 !! end
18107
18108 !! test
18109 HTML multiple attributes correction
18110 !! wikitext
18111 <p class="error" class="awesome">Awesome!</p>
18112 !! html
18113 <p class="awesome">Awesome!</p>
18114
18115 !!end
18116
18117 !! test
18118 Table multiple attributes correction
18119 !! wikitext
18120 {|
18121 !+ class="error" class="awesome"|status
18122 |}
18123 !! html
18124 <table>
18125 <tr>
18126 <th class="awesome">status
18127 </th></tr></table>
18128
18129 !!end
18130
18131 !! test
18132 DIV IN UPPERCASE
18133 !! wikitext
18134 <DIV ID="x">HTML ROCKS</DIV>
18135 !! html
18136 <div id="x">HTML ROCKS</div>
18137
18138 !!end
18139
18140 !! test
18141 Non-ASCII pseudo-tags are rendered as text
18142 !! wikitext
18143 <khyô>
18144 !! html
18145 <p>&lt;khyô&gt;
18146 </p>
18147 !! end
18148
18149 !! test
18150 Pseudo-tag with URL 'name' renders as url link
18151 !! wikitext
18152 <http://example.com/>
18153 !! html
18154 <p>&lt;<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&gt;
18155 </p>
18156 !! end
18157
18158 !! test
18159 text with amp in the middle of nowhere
18160 !! wikitext
18161 Remember AT&T?
18162 !! html
18163 <p>Remember AT&amp;T?
18164 </p>
18165 !! end
18166
18167 !! test
18168 text with character entity: eacute
18169 !! wikitext
18170 I always thought &eacute; was a cute letter.
18171 !! html+tidy
18172 <p>I always thought &#233; was a cute letter.
18173 </p>
18174 !! end
18175
18176 !! test
18177 text with entity-escaped character entity-like string: eacute
18178 !! wikitext
18179 I always thought &amp;eacute; was a cute letter.
18180 !! html
18181 <p>I always thought &amp;eacute; was a cute letter.
18182 </p>
18183 !! end
18184
18185 !! test
18186 text with undefined character entity: xacute
18187 !! wikitext
18188 I always thought &xacute; was a cute letter.
18189 !! html
18190 <p>I always thought &amp;xacute; was a cute letter.
18191 </p>
18192 !! end
18193
18194 !! test
18195 HTML5 tags
18196 !! wikitext
18197 <data value="5">five</data>
18198 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
18199 <mark>This highlighted text</mark>
18200 !! html
18201 <p><data value="5">five</data>
18202 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
18203 <mark>This highlighted text</mark>
18204 </p>
18205 !! end
18206
18207 !! test
18208 HTML tag with leading space is parsed as text
18209 !! wikitext
18210 < div>foo< /div>
18211 !! html
18212 <p>&lt; div&gt;foo&lt; /div&gt;
18213 </p>
18214 !! end
18215
18216 ## Don't expect Parsoid and PHP to match, since PHP isn't exactly following
18217 ## the HTML5 parsing spec.
18218 !! test
18219 Element with broken attribute syntax
18220 !! options
18221 parsoid=wt2html
18222 !! wikitext
18223 <div style=" style="123">hi</div>
18224 <div =>ho</div>
18225 !! html/php
18226 <div style="123">hi</div>
18227 <div>ho</div>
18228
18229 !! html/parsoid
18230 <div style=" style=" data-parsoid='{"stx":"html","a":{"123\"":null},"sa":{"123\"":""}}'>hi</div>
18231 <div data-parsoid='{"stx":"html","a":{"=":null},"sa":{"=":""}}'>ho</div>
18232 !! end
18233
18234 ###
18235 ### Nesting tests (see T43545, T52604, T53081)
18236 ###
18237
18238 # This test case is fixed in Parsoid by domino 1.0.12. (T52604)
18239 # Note that html2wt is considerably more difficult if we use <b> in
18240 # the test case, instead of <small>
18241 !! test
18242 Ensure that HTML adoption agency algorithm is properly implemented.
18243 !! wikitext
18244 <small>X<small>Y</small>Z</small>
18245 !! html
18246 <p><small>X<small>Y</small>Z</small>
18247 </p>
18248 !! end
18249
18250 # This was T43545 in the PHP parser.
18251 !! test
18252 Nesting of <kbd>
18253 !! wikitext
18254 <kbd>X<kbd>Y</kbd>Z</kbd>
18255 !! html+tidy
18256 <p><kbd>X<kbd>Y</kbd>Z</kbd>
18257 </p>
18258 !! end
18259
18260 # The following cases were T53081 in the PHP parser.
18261 # Note that there are some other nestable tags (b, i, etc) which are
18262 # not covered; see T53081 for discussion.
18263
18264 !! test
18265 Nesting of <em>
18266 !! wikitext
18267 <em>X<em>Y</em>Z</em>
18268 !! html+tidy
18269 <p><em>X<em>Y</em>Z</em>
18270 </p>
18271 !! end
18272
18273 !! test
18274 Nesting of <strong>
18275 !! wikitext
18276 <strong>X<strong>Y</strong>Z</strong>
18277 !! html+tidy
18278 <p><strong>X<strong>Y</strong>Z</strong>
18279 </p>
18280 !! end
18281
18282 !! test
18283 Nesting of <q>
18284 !! wikitext
18285 <q>X<q>Y</q>Z</q>
18286 !! html+tidy
18287 <p><q>X<q>Y</q>Z</q>
18288 </p>
18289 !! end
18290
18291 !! test
18292 Nesting of <ruby>
18293 !! wikitext
18294 <ruby>X<ruby>Y</ruby>Z</ruby>
18295 !! html
18296 <p><ruby>X<ruby>Y</ruby>Z</ruby>
18297 </p>
18298 !! end
18299
18300 !! test
18301 Nesting of <bdo>
18302 !! wikitext
18303 <bdo>X<bdo>Y</bdo>Z</bdo>
18304 !! html
18305 <p><bdo>X<bdo>Y</bdo>Z</bdo>
18306 </p>
18307 !! end
18308
18309
18310 ###
18311 ### Media links
18312 ###
18313
18314 !! test
18315 Media link
18316 !! wikitext
18317 [[Media:Foobar.jpg]]
18318 [[Media:Video.ogv]]
18319 [[:Media:Video.ogv]]
18320 !! html/php
18321 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a>
18322 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
18323 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
18324 </p>
18325 !! html/parsoid
18326 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Media:Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a>
18327 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" resource="./Media:Video.ogv" title="Video.ogv">Media:Video.ogv</a>
18328 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" resource="./Media:Video.ogv" title="Video.ogv" data-parsoid='{"a":{"resource":"./Media:Video.ogv"},"sa":{"resource":":Media:Video.ogv"}}'>Media:Video.ogv</a></p>
18329 !! end
18330
18331 !! test
18332 Media link with text
18333 !! wikitext
18334 [[Media:Foobar.jpg|A neat file to look at]]
18335 !! html/php
18336 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">A neat file to look at</a>
18337 </p>
18338 !! html/parsoid
18339 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Media:Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
18340 !! end
18341
18342 !! test
18343 Localized media link
18344 !! options
18345 language=is
18346 !! wikitext
18347 [[Miðill:Foobar.jpg]]
18348
18349 [[Miðill:Foobar.jpg|Icelandic]]
18350 !! html/php
18351 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Miðill:Foobar.jpg</a>
18352 </p><p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Icelandic</a>
18353 </p>
18354 !! html/parsoid
18355 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Miðill:Foobar.jpg" title="Foobar.jpg">Miðill:Foobar.jpg</a></p>
18356 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Miðill:Foobar.jpg" title="Foobar.jpg">Icelandic</a></p>
18357 !! end
18358
18359 # FIXME: this is still bad HTML tag nesting
18360 # FIXME: doBlockLevels won't wrap this in a paragraph because it contains a div
18361 # Parsoid & Remex fix the p-wrapping since they operate on the DOM.
18362 !! test
18363 Media link with nasty text
18364 !! options
18365 parsoid=wt2html,html2html
18366 !! wikitext
18367 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
18368 !! html/php
18369 <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>
18370
18371 !! html/php+tidy
18372 <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>
18373 !! html/parsoid
18374 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Media:Foobar.jpg" title="Foobar.jpg">Safe Link</a></p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Media:Foobar.jpg" title="Foobar.jpg"><div style="display:none" data-parsoid='{"stx":"html"}'>" onmouseover="alert(document.cookie)" onfoo="</div></a>
18375 !! end
18376
18377 !! test
18378 Media link from missing resource (parsoid-only)
18379 !! options
18380 parsoid=html2wt
18381 !! html/parsoid
18382 <a rel="mw:MediaLink" href="http://example.com/images/3/3a/Foobar.jpg">Bat!</a>
18383 !! wikitext
18384 [[Media:Foobar.jpg|Bat!]]
18385 !! end
18386
18387 !! test
18388 Media link from missing resource, localized (parsoid-only)
18389 !! options
18390 parsoid=html2wt
18391 language=is
18392 !! html/parsoid
18393 <a rel="mw:MediaLink" href="http://example.com/images/3/3a/Foobar.jpg">Bat!</a>
18394 !! wikitext
18395 [[Miðill:Foobar.jpg|Bat!]]
18396 !! end
18397
18398 # This is a sanity test to ensure we don't crash or choke when given
18399 # old cached 1.7.0 HTML for media links; we don't require that the
18400 # result be "valid" because wt2wt was completely broken in 1.7.0
18401 !! test
18402 Media link from old 1.7.0 DOM spec (crash test, parsoid-only) T198511
18403 !! options
18404 parsoid=html2wt
18405 !! html/parsoid
18406 <p>This is what Parsoid would emit (and we still handle this HTML fine):</p>
18407 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
18408 <p>But VisualEditor would mangle the rel attribute, and give us back this:</p>
18409 <p><a rel="mw:ExtLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
18410 <p>But at least we don't crash when trying to handle the mangled HTML!</p>
18411 !! wikitext
18412 This is what Parsoid would emit (and we still handle this HTML fine):
18413
18414 [[Media:Foobar.jpg|A neat file to look at]]
18415
18416 But VisualEditor would mangle the rel attribute, and give us back this:
18417
18418 [//example.com/images/3/3a/Foobar.jpg A neat file to look at]
18419
18420 But at least we don't crash when trying to handle the mangled HTML!
18421 !! end
18422
18423 !! test
18424 Media link to nonexistent file (T3702)
18425 !! wikitext
18426 [[Media:No such.jpg]]
18427 [[Media:No_such file.jpg]]
18428 !! html/php
18429 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a>
18430 <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>
18431 </p>
18432 !! html/parsoid
18433 <p><a rel="mw:MediaLink" href="./Special:FilePath/No_such.jpg" resource="./Media:No_such.jpg" title="No such.jpg" typeof="mw:Error" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}' data-parsoid='{"a":{"resource":"./Media:No_such.jpg"},"sa":{"resource":"Media:No such.jpg"}}'>Media:No such.jpg</a>
18434 <a rel="mw:MediaLink" href="./Special:FilePath/No_such_file.jpg" resource="./Media:No_such_file.jpg" title="No such file.jpg" typeof="mw:Error" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}' data-parsoid='{"a":{"resource":"./Media:No_such_file.jpg"},"sa":{"resource":"Media:No_such file.jpg"}}'>Media:No_such file.jpg</a></p>
18435 !! end
18436
18437 !! test
18438 Image link to nonexistent file (T3850 - good)
18439 !! wikitext
18440 [[File:No_such.jpg]]
18441 !! html/php
18442 <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>
18443 </p>
18444 !! html/parsoid
18445 <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>
18446 !! end
18447
18448 !! test
18449 :Image link to nonexistent file (T3850 - bad)
18450 !! wikitext
18451 [[:Image:No such.jpg]]
18452 !! html/php
18453 <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>
18454 </p>
18455 !! html/parsoid
18456 <p><a rel="mw:WikiLink" href="./File:No_such.jpg" title="File:No such.jpg">Image:No such.jpg</a></p>
18457 !! end
18458
18459 !! test
18460 Character reference normalization in link text (T3938)
18461 !! wikitext
18462 [[Main Page|this&that]]
18463 !! html
18464 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
18465 </p>
18466 !!end
18467
18468 !! article
18469 אַ
18470 !! text
18471 Test for unicode normalization
18472
18473 The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
18474 !! endarticle
18475
18476 !! test
18477 (T21451) Links should refer to the normalized form.
18478 !! wikitext
18479 [[&#xFB2E;]]
18480 [[&#x5d0;&#x5b7;]]
18481 [[&#x5d0;ַ]]
18482 [[א&#x5b7;]]
18483 [[אַ]]
18484 !! html
18485 <p><a href="/wiki/%D7%90%D6%B7" title="אַ">&#xfb2e;</a>
18486 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;&#x5b7;</a>
18487 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;ַ</a>
18488 <a href="/wiki/%D7%90%D6%B7" title="אַ">א&#x5b7;</a>
18489 <a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a>
18490 </p>
18491 !! end
18492
18493 !! test
18494 Empty attribute crash test (T4067)
18495 !! wikitext
18496 <font color="">foo</font>
18497 !! html
18498 <p><font color="">foo</font>
18499 </p>
18500 !! end
18501
18502 !! test
18503 Empty attribute crash test single-quotes (T4067)
18504 !! wikitext
18505 <font color=''>foo</font>
18506 !! html
18507 <p><font color="">foo</font>
18508 </p>
18509 !! end
18510
18511 !! test
18512 Attribute test: equals, then nothing
18513 !! options
18514 parsoid=wt2html,html2html
18515 !! wikitext
18516 <font color=>foo</font>
18517 !! html/php
18518 <p><font color="">foo</font>
18519 </p>
18520 !! html/parsoid
18521 <p><font color="" data-parsoid='{"stx":"html"}'>foo</font></p>
18522 !! end
18523
18524 !! test
18525 Attribute test: unquoted value
18526 !! options
18527 parsoid=wt2html,html2html
18528 !! wikitext
18529 <font color=x>foo</font>
18530 !! html/php
18531 <p><font color="x">foo</font>
18532 </p>
18533 !! html/parsoid
18534 <p><font color="x" data-parsoid='{"stx":"html"}'>foo</font></p>
18535 !! end
18536
18537 !! test
18538 Attribute test: unquoted but illegal value (hash)
18539 !! wikitext
18540 <font color=#x>foo</font>
18541 !! html
18542 <p><font color="#x">foo</font>
18543 </p>
18544 !! end
18545
18546 # Parsoid does not serialize to empty attribute syntax,
18547 # so wt2wt and html2wt cases are skipped
18548 !! test
18549 Attribute test: no value (T54330)
18550 !! options
18551 parsoid=wt2html,html2html
18552 !! wikitext
18553 <font color>foo</font>
18554 !! html/php
18555 <p><font color="">foo</font>
18556 </p>
18557 !! html/parsoid
18558 <p><font color="">foo</font></p>
18559 !! end
18560
18561 !! test
18562 T4095: link with three closing brackets
18563 !! wikitext
18564 [[Main Page]]]
18565 !! html/php
18566 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
18567 </p>
18568 !! html/parsoid
18569 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>]</p>
18570 !! end
18571
18572 !! test
18573 T4095: link with pipe and three closing brackets
18574 !! wikitext
18575 [[Main Page|link]]]
18576 !! html/php
18577 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
18578 </p>
18579 !! html/parsoid
18580 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">link</a>]</p>
18581 !! end
18582
18583 !! test
18584 T4095: link with pipe and three closing brackets, version 2
18585 !! wikitext
18586 [[Main Page|[http://example.com/]]]
18587 !! html/php
18588 <p><a href="/wiki/Main_Page" title="Main Page">[http://example.com/]</a>
18589 </p>
18590 !! html/parsoid
18591 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">[http://example.com/]</a></p>
18592 !! end
18593
18594
18595 ###
18596 ### Safety
18597 ###
18598
18599 !! article
18600 Template:Dangerous attribute
18601 !! text
18602 " onmouseover="alert(document.cookie)
18603 !! endarticle
18604
18605 !! article
18606 Template:Dangerous style attribute
18607 !! text
18608 border-size: expression(alert(document.cookie))
18609 !! endarticle
18610
18611 !! article
18612 Template:Div style
18613 !! text
18614 <div style="float: right; {{{1}}}">Magic div</div>
18615 !! endarticle
18616
18617 !! test
18618 T4304: HTML attribute safety (safe template; regression T4309)
18619 !! wikitext
18620 <div title="{{test}}"></div>
18621 !! html/php
18622 <div title="This is a test template"></div>
18623
18624 !! html/parsoid
18625 <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>
18626 !! end
18627
18628 # Parsoid has enough context to handle this case
18629 !! test
18630 T4304: HTML attribute safety (dangerous template; 2309)
18631 !! wikitext
18632 <div title="{{dangerous attribute}}"></div>
18633 !! html/php
18634 <div title=""></div>
18635
18636 !! html/parsoid
18637 <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>
18638 !! end
18639
18640 !! test
18641 T4304: HTML attribute safety (dangerous style template; 2309)
18642 !! wikitext
18643 <div style="{{dangerous style attribute}}"></div>
18644 !! html/php
18645 <div style="/* insecure input */"></div>
18646
18647 !! html/parsoid
18648 <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>
18649 !! end
18650
18651 !! test
18652 T4304: HTML attribute safety (safe parameter; 2309)
18653 !! wikitext
18654 {{div style|width: 200px}}
18655 !! html/php
18656 <div style="float: right; width: 200px">Magic div</div>
18657
18658 !! html/parsoid
18659 <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>
18660 !! end
18661
18662 !! test
18663 T4304: HTML attribute safety (unsafe parameter; 2309)
18664 !! wikitext
18665 {{div style|width: expression(alert(document.cookie))}}
18666 !! html/php
18667 <div style="/* insecure input */">Magic div</div>
18668
18669 !! html/parsoid
18670 <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>
18671 !! end
18672
18673 ## Parsoid output here differs; needs investigation.
18674 !! test
18675 T4304: HTML attribute safety (unsafe breakout parameter; 2309)
18676 !! wikitext
18677 {{div style|"><script>alert(document.cookie)</script>}}
18678 !! html
18679 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
18680
18681 !! end
18682
18683 ## Parsoid output here differs; needs investigation.
18684 !! test
18685 T4304: HTML attribute safety (unsafe breakout parameter 2; 2309)
18686 !! wikitext
18687 {{div style|" ><script>alert(document.cookie)</script>}}
18688 !! html
18689 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
18690
18691 !! end
18692
18693 !! test
18694 T4304: HTML attribute safety (link)
18695 !! wikitext
18696 <div title="[[Main Page]]"></div>
18697 !! html/php
18698 <div title="&#91;&#91;Main Page&#93;&#93;"></div>
18699
18700 !! html/parsoid
18701 <div title="[[Main Page]]"></div>
18702 !! end
18703
18704 !! test
18705 T4304: HTML attribute safety (italics)
18706 !! wikitext
18707 <div title="''foobar''"></div>
18708 !! html
18709 <div title="&#39;&#39;foobar&#39;&#39;"></div>
18710
18711 !! end
18712
18713 !! test
18714 T4304: HTML attribute safety (bold)
18715 !! wikitext
18716 <div title="'''foobar'''"></div>
18717 !! html
18718 <div title="&#39;&#39;&#39;foobar&#39;&#39;&#39;"></div>
18719
18720 !! end
18721
18722 !! test
18723 T4304: HTML attribute safety (ISBN)
18724 !! wikitext
18725 <div title="ISBN 1234567890"></div>
18726 !! html
18727 <div title="&#73;SBN 1234567890"></div>
18728
18729 !! end
18730
18731 !! test
18732 T4304: HTML attribute safety (RFC)
18733 !! wikitext
18734 <div title="RFC 1234"></div>
18735 !! html
18736 <div title="&#82;FC 1234"></div>
18737
18738 !! end
18739
18740 !! test
18741 T4304: HTML attribute safety (PMID)
18742 !! wikitext
18743 <div title="PMID 1234567890"></div>
18744 !! html
18745 <div title="&#80;MID 1234567890"></div>
18746
18747 !! end
18748
18749 !! test
18750 T4304: HTML attribute safety (web link)
18751 !! wikitext
18752 <div title="http://example.com/"></div>
18753 !! html
18754 <div title="http&#58;//example.com/"></div>
18755
18756 !! end
18757
18758 !! test
18759 T4304: HTML attribute safety (named web link)
18760 !! wikitext
18761 <div title="[http://example.com/ link]"></div>
18762 !! html/php
18763 <div title="&#91;http&#58;//example.com/ link&#93;"></div>
18764
18765 !! html/parsoid
18766 <div title="[http://example.com/ link]"></div>
18767 !! end
18768
18769 !! test
18770 T5244: HTML attribute safety (extension; safe)
18771 !! wikitext
18772 <div style="<nowiki>background:blue</nowiki>"></div>
18773 !! html/php
18774 <div style="background:blue"></div>
18775
18776 !! html/parsoid
18777 <div style="background:blue" data-parsoid='{"stx":"html","a":{"style":"background:blue"},"sa":{"style":"&lt;nowiki>background:blue&lt;/nowiki>"}}'></div>
18778 !! end
18779
18780 !! test
18781 T5244: HTML attribute safety (extension; unsafe)
18782 !! wikitext
18783 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
18784 !! html/php
18785 <div style="/* insecure input */"></div>
18786
18787 !! html/parsoid
18788 <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>
18789 !! end
18790
18791 # More MSIE fun discovered by Tom Gilder
18792
18793 !! test
18794 MSIE CSS safety test: spurious slash
18795 !! wikitext
18796 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
18797 !! html/php
18798 <div style="/* insecure input */">evil</div>
18799
18800 !! html/parsoid
18801 <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>
18802 !! end
18803
18804 !! test
18805 MSIE CSS safety test: hex code
18806 !! wikitext
18807 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
18808 !! html/php
18809 <div style="/* insecure input */">evil</div>
18810
18811 !! html/parsoid
18812 <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>
18813 !! end
18814
18815 !! test
18816 MSIE CSS safety test: comment in url
18817 !! wikitext
18818 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
18819 !! html/php
18820 <div style="background-image:u rl(javascript:alert(&#39;boo&#39;))">evil</div>
18821
18822 !! html/parsoid
18823 <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>
18824 !! end
18825
18826 !! test
18827 MSIE CSS safety test: comment in expression
18828 !! wikitext
18829 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
18830 !! html/php
18831 <div style="background-image:expres sion(alert(&#39;boo4&#39;))">evil4</div>
18832
18833 !! html/parsoid
18834 <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>
18835 !! end
18836
18837 !! test
18838 CSS safety test (all browsers): vertical tab (T57332 / CVE-2013-4567)
18839 !! wikitext
18840 <p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p>
18841 !! html/php
18842 <p style="/* invalid control char */">A</p>
18843
18844 !! html/parsoid
18845 <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>
18846 !! end
18847
18848 !! test
18849 MSIE 6 CSS safety test: Fullwidth (T57332)
18850 !! wikitext
18851 <p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p>
18852 <div style="top:EXPRESSION(alert())">B</div>
18853 !! html/php
18854 <p style="/* insecure input */">A</p>
18855 <div style="/* insecure input */">B</div>
18856
18857 !! html/parsoid
18858 <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>
18859 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"top:EXPRESSION(alert())"}}'>B</div>
18860 !! end
18861
18862 !! test
18863 MSIE 6 CSS safety test: IPA extensions (T57332)
18864 !! wikitext
18865 <div style="background-image:uʀʟ(javascript:alert())">A</div>
18866 <p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p>
18867 !! html/php
18868 <div style="/* insecure input */">A</div>
18869 <p style="/* insecure input */">B</p>
18870
18871 !! html/parsoid
18872 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:uʀʟ(javascript:alert())"}}'>A</div>
18873 <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>
18874 !! end
18875
18876 !! test
18877 MSIE 6 CSS safety test: sup/sub script (T57332)
18878 !! wikitext
18879 <div style="background-image:url⁽javascript:alert())">A</div>
18880 <div style="background-image:url₍javascript:alert())">B</div>
18881 <p style="font-size: 100px; color: expressioⁿ((title='XSSed'),'red')">C</p>
18882 !! html/php
18883 <div style="/* insecure input */">A</div>
18884 <div style="/* insecure input */">B</div>
18885 <p style="/* insecure input */">C</p>
18886
18887 !! html/parsoid
18888 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url⁽javascript:alert())"}}'>A</div>
18889 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url₍javascript:alert())"}}'>B</div>
18890 <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>
18891 !! end
18892
18893 !! test
18894 Opera -o-link CSS
18895 !! options
18896 parsoid=wt2html,html2html
18897 !! wikitext
18898 <div
18899 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;"
18900 style="-o-link:attr(title);-o-link-source:current">X</div>
18901 !! html/php
18902 <div title="data:text/html,&lt;img src=1 onerror=alert(1)&gt;" style="/* insecure input */">X</div>
18903
18904 !! html/parsoid
18905 <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>
18906 !! end
18907
18908 !! test
18909 MSIE 6 CSS safety test: Repetition markers (T57332)
18910 !! wikitext
18911 <p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p>
18912 <p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p>
18913 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">C</p>
18914 <p style="font-size: 100px; color: expresヽion((title='XSSed'),'red')">D</p>
18915 <p style="font-size: 100px; color: expresﹽion((title='XSSed'),'red')">E</p>
18916 <p style="font-size: 100px; color: expresﹼion((title='XSSed'),'red')">F</p>
18917 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">G</p>
18918 !! html/php
18919 <p style="/* insecure input */">A</p>
18920 <p style="/* insecure input */">B</p>
18921 <p style="/* insecure input */">C</p>
18922 <p style="/* insecure input */">D</p>
18923 <p style="/* insecure input */">E</p>
18924 <p style="/* insecure input */">F</p>
18925 <p style="/* insecure input */">G</p>
18926
18927 !! html/parsoid
18928 <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>
18929 <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>
18930 <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>
18931 <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>
18932 <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>
18933 <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>
18934 <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>
18935 !! end
18936
18937 !! test
18938 Table attribute legitimate extension
18939 !! wikitext
18940 {|
18941 !+ style="<nowiki>color:blue</nowiki>"|status
18942 |}
18943 !! html
18944 <table>
18945 <tr>
18946 <th style="color:blue">status
18947 </th></tr></table>
18948
18949 !!end
18950
18951 !! test
18952 Table attribute safety
18953 !! wikitext
18954 {|
18955 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"|status
18956 |}
18957 !! html
18958 <table>
18959 <tr>
18960 <th style="/* insecure input */">status
18961 </th></tr></table>
18962
18963 !! end
18964
18965 !! test
18966 CSS line continuation 1
18967 !! wikitext
18968 <div style="background-image: u\&#10;rl(test.jpg);"></div>
18969 !! html
18970 <div style="/* insecure input */"></div>
18971
18972 !! end
18973
18974 !! test
18975 CSS line continuation 2
18976 !! wikitext
18977 <div style="background-image: u\&#13;rl(test.jpg); "></div>
18978 !! html
18979 <div style="/* invalid control char */"></div>
18980
18981 !! end
18982
18983 !! article
18984 Template:Identity
18985 !! text
18986 {{{1}}}
18987 !! endarticle
18988
18989 !! test
18990 Expansion of multi-line templates in attribute values (T8255)
18991 !! wikitext
18992 <div style="background: {{identity|#00FF00}}">-</div>
18993 !! html
18994 <div style="background: #00FF00">-</div>
18995
18996 !! end
18997
18998 !! test
18999 Expansion of multi-line templates in attribute values (T8255 sanity check)
19000 !! wikitext
19001 <div style="background:
19002 #00FF00">-</div>
19003 !! html/php
19004 <div style="background: #00FF00">-</div>
19005
19006 !! html/parsoid
19007 <div style="background:
19008 #00FF00">-</div>
19009 !! end
19010
19011 !! test
19012 Expansion of multi-line templates in attribute values (T8255 sanity check 2)
19013 !! wikitext
19014 <div style="background: &#10;#00FF00">-</div>
19015 !! html
19016 <div style="background: &#10;#00FF00">-</div>
19017
19018 !! end
19019
19020 !! test
19021 Tags which are hidden from tidiers cannot pass through the Sanitizer
19022 !! wikitext
19023 <mw:toc><script>alert();</script></mw:toc>
19024 !! html+tidy
19025 <p>&lt;mw:toc&gt;&lt;script&gt;alert();&lt;/script&gt;&lt;/mw:toc&gt;
19026 </p>
19027 !! end
19028
19029 ###
19030 ### Parser hooks (see tests/parser/ParserTestParserHook.php for the <tag> extension)
19031 ###
19032
19033 !! test
19034 Parser hook: empty input
19035 !! wikitext
19036 <tag></tag>
19037 !! html/php
19038 <pre>
19039 ''
19040 array (
19041 )
19042 </pre>
19043
19044 !! html/parsoid
19045 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19046 !! end
19047
19048 ## Don't expect parsoid to rt this form.
19049 !! test
19050 Parser hook: empty input using terminated empty elements
19051 !! options
19052 parsoid=wt2html,html2html
19053 !! wikitext
19054 <tag/>
19055 !! html/php
19056 <pre>
19057 NULL
19058 array (
19059 )
19060 </pre>
19061
19062 !! html/parsoid
19063 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{}}' data-parsoid='{}' about="#mwt2"></pre>
19064 !! end
19065
19066 !! test
19067 Parser hook: empty input using terminated empty elements (space before)
19068 !! wikitext
19069 <tag />
19070 !! html/php
19071 <pre>
19072 NULL
19073 array (
19074 )
19075 </pre>
19076
19077 !! html/parsoid
19078 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{}}' data-parsoid='{}' about="#mwt2"></pre>
19079 !! end
19080
19081 !! test
19082 Parser hook: basic input
19083 !! wikitext
19084 <tag>input</tag>
19085 !! html/php
19086 <pre>
19087 'input'
19088 array (
19089 )
19090 </pre>
19091
19092 !! html/parsoid
19093 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
19094 !! end
19095
19096 ## Don't expect parsoid to rt this form.
19097 !! test
19098 Parser hook: case insensitive
19099 !! options
19100 parsoid=wt2html,html2html
19101 !! wikitext
19102 <TAG>input</TAG>
19103 !! html/php
19104 <pre>
19105 'input'
19106 array (
19107 )
19108 </pre>
19109
19110 !! html/parsoid
19111 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
19112 !! end
19113
19114 ## Don't expect parsoid to rt this form.
19115 !! test
19116 Parser hook: case insensitive, redux
19117 !! options
19118 parsoid=wt2html,html2html
19119 !! wikitext
19120 <TaG>input</TAg>
19121 !! html/php
19122 <pre>
19123 'input'
19124 array (
19125 )
19126 </pre>
19127
19128 !! html/parsoid
19129 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
19130 !! end
19131
19132 !! test
19133 Parser hook: nested tags
19134 !! options
19135 parsoid=wt2html
19136 !! wikitext
19137 <tag><tag></tag></tag>
19138 !! html/php
19139 <pre>
19140 '<tag>'
19141 array (
19142 )
19143 </pre>&lt;/tag&gt;
19144
19145 !! html/php+tidy
19146 <pre>'<tag>'
19147 array (
19148 )
19149 </tag></pre><p>&lt;/tag&gt;
19150 </p>
19151 !! html/parsoid
19152 <pre typeof="mw:Extension/tag" about="#mwt2" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"&lt;tag>"}}'></pre><p>&lt;/tag></p>
19153 !! end
19154
19155 !! test
19156 Parser hook: basic arguments
19157 !! wikitext
19158 <tag width="200" height="100" depth="50" square=""></tag>
19159 !! html/php
19160 <pre>
19161 ''
19162 array (
19163 'width' => '200',
19164 'height' => '100',
19165 'depth' => '50',
19166 'square' => '',
19167 )
19168 </pre>
19169
19170 !! html/parsoid
19171 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19172 !! end
19173
19174 ## Don't expect parsoid to rt this form.
19175 !! test
19176 Parser hook: basic arguments, variations
19177 !! options
19178 parsoid=wt2html,html2html
19179 !! wikitext
19180 <tag width=200 height = "100" depth = '50' square></tag>
19181 !! html/php
19182 <pre>
19183 ''
19184 array (
19185 'width' => '200',
19186 'height' => '100',
19187 'depth' => '50',
19188 'square' => '',
19189 )
19190 </pre>
19191
19192 !! html/parsoid
19193 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19194 !! end
19195
19196 !! test
19197 Parser hook: argument containing a forward slash (T7344)
19198 !! wikitext
19199 <tag filename="/tmp/bla"></tag>
19200 !! html/php
19201 <pre>
19202 ''
19203 array (
19204 'filename' => '/tmp/bla',
19205 )
19206 </pre>
19207
19208 !! html/parsoid
19209 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"filename":"/tmp/bla"},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19210 !! end
19211
19212 ## Don't expect parsoid to rt this form.
19213 !! test
19214 Parser hook: empty input using terminated empty elements (T4374)
19215 !! options
19216 parsoid=wt2html,html2html
19217 !! wikitext
19218 <tag foo=bar/>text
19219 !! html/php
19220 <pre>
19221 NULL
19222 array (
19223 'foo' => 'bar',
19224 )
19225 </pre>text
19226
19227 !! html/parsoid
19228 <pre typeof="mw:Extension/tag" about="#mwt2" data-mw='{"name":"tag","attrs":{"foo":"bar"}}'></pre><p>text</p>
19229 !! end
19230
19231 ## </tag> should be output literally since there is no matching tag that begins it
19232 ## Don't expect parsoid to rt this form.
19233 !! test
19234 Parser hook: basic arguments using terminated empty elements (T4374)
19235 !! options
19236 parsoid=wt2html
19237 !! wikitext
19238 <tag width=200 height = "100" depth = '50' square/>
19239 other stuff
19240 </tag>
19241 !! html/php
19242 <pre>
19243 NULL
19244 array (
19245 'width' => '200',
19246 'height' => '100',
19247 'depth' => '50',
19248 'square' => '',
19249 )
19250 </pre>
19251 <p>other stuff
19252 &lt;/tag&gt;
19253 </p>
19254 !! html/parsoid
19255 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""}}' about="#mwt2"></pre><p>other stuff
19256 &lt;/tag></p>
19257 !! end
19258
19259 ## Don't expect parsoid to rt this form.
19260 !! test
19261 Parser hook: Don't allow unclosed extension tags
19262 !! options
19263 parsoid=wt2html
19264 !! wikitext
19265 test <tag>123
19266
19267 this is a '''test'''
19268 !! html/php
19269 <p>test &lt;tag&gt;123
19270 </p><p>this is a <b>test</b>
19271 </p>
19272 !! html/parsoid
19273 <p>test &lt;tag>123</p>
19274
19275 <p>this is a <b>test</b></p>
19276 !! end
19277
19278 !! test
19279 Parser hook: horizontal rule inside extension tag that outputs <pre>
19280 !! wikitext
19281 <tag>
19282 Hello
19283 <hr/>
19284 Goodbye
19285 </tag>
19286 !! html/php
19287 <pre>
19288 '
19289 Hello
19290 <hr/>
19291 Goodbye
19292 '
19293 array (
19294 )
19295 </pre>
19296
19297 !! end
19298
19299 ###
19300 ### (see tests/parser/ParserTestParserHook.php for the <statictag> extension)
19301 ###
19302
19303 !! test
19304 Parser hook: static parser hook not inside a comment
19305 !! wikitext
19306 <statictag>hello, world</statictag>
19307
19308 <statictag action="flush" />
19309 !! html/php
19310 <p><br />
19311 hello, world
19312 </p>
19313 !! html/parsoid
19314 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{},"body":{"extsrc":"hello, world"}}' about="#mwt2"></span></p>
19315 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"}}' about="#mwt4">hello, world</span></p>
19316 !! end
19317
19318 !! test
19319 Parser hook: static parser hook inside a comment
19320 !! wikitext
19321 <!-- <statictag>hello, world</statictag> -->
19322 <statictag action="flush" />
19323 !! html/php
19324 <p><br />
19325 </p>
19326 !! html/parsoid
19327 <!-- <statictag&#x3E;hello, world</statictag&#x3E; -->
19328 <p><span typeof='mw:Extension/statictag' data-mw='{"name":"statictag","attrs":{"action":"flush"}}' data-parsoid='{}' about='#mwt2'></span></p>
19329 !! end
19330
19331 # Nested template calls; this case was broken by Parser.php rev 1.506,
19332 # since reverted.
19333
19334 !! article
19335 Template:One-parameter
19336 !! text
19337 (My parameter is: {{{1}}})
19338 !! endarticle
19339
19340 !! article
19341 Template:Map-one-parameter
19342 !! text
19343 {{{{{1}}}|{{{2}}}}}
19344 !! endarticle
19345
19346 !! test
19347 Nested template calls
19348 !! wikitext
19349 {{Map-one-parameter|One-parameter|param}}
19350 !! html
19351 <p>(My parameter is: param)
19352 </p>
19353 !! end
19354
19355
19356 ###
19357 ### Sanitizer
19358 ###
19359
19360 !! test
19361 Sanitizer: Closing of open tags
19362 !! wikitext
19363 <s></s><table></table>
19364 !! html/php+tidy
19365 <p><s></s></p><table></table>
19366 !! html/parsoid
19367 <p><s data-parsoid='{"stx":"html"}'></s></p><table data-parsoid='{"stx":"html"}'></table>
19368 !! end
19369
19370 !! test
19371 Sanitizer: Closing of open but not closed tags
19372 !! wikitext
19373 <s>foo
19374 !! html
19375 <p><s>foo</s>
19376 </p>
19377 !! end
19378
19379 !! test
19380 Sanitizer: Closing of closed but not open tags
19381 !! options
19382 parsoid=wt2html
19383 !! wikitext
19384 </s>
19385 !! html+tidy
19386 <p class="mw-empty-elt">
19387 </p>
19388 !! end
19389
19390 !! test
19391 Sanitizer: Closing of closed but not open table tags
19392 !! options
19393 parsoid=wt2html
19394 !! wikitext
19395 Table not started</td></tr></table>
19396 !! html+tidy
19397 <p>Table not started
19398 </p>
19399 !! end
19400
19401 !! test
19402 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
19403 !! options
19404 title=[[Main Page]]
19405 !! config
19406 wgFragmentMode=[ 'html5', 'legacy' ]
19407 !! wikitext
19408 <span id="æ: v">byte</span>[[#æ: v|backlink]]
19409 !! html/php
19410 <p><span id="æ:_v">byte</span><a href="#æ:_v">backlink</a>
19411 </p>
19412 !! html/parsoid
19413 <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>
19414 !! end
19415
19416 !! test
19417 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id="" (legacy)
19418 !! config
19419 wgFragmentMode=[ 'legacy' ]
19420 !! wikitext
19421 <span id="æ: v">byte</span>[[#æ: v|backlink]]
19422 !! html/php
19423 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v">backlink</a>
19424 </p>
19425 !! end
19426
19427 # In HTML5, the restrictions are that id must contain at least one character,
19428 # and must not contain any space characters.
19429 !! test
19430 Sanitizer: Validating the contents of the id attribute (T6515)
19431 !! options
19432 disabled
19433 !! wikitext
19434 <br id="" /><br id="a space" />
19435 !! html
19436 Something ...
19437 !! end
19438
19439 # In HTML5, id must be unique amongst all the ids in the element's home subtree.
19440 !! test
19441 Sanitizer: Validating id attribute uniqueness (T6515, T8301)
19442 !! options
19443 disabled
19444 !! wikitext
19445 <br id="foo" /><br id="foo" />
19446 !! html
19447 Something need to be done. foo-2 ?
19448 !! end
19449
19450 !! test
19451 Sanitizer: Validating that <meta> and <link> work, but only for Microdata
19452 !! wikitext
19453 <div itemscope>
19454 <meta itemprop="hello" content="world">
19455 <meta http-equiv="refresh" content="5">
19456 <meta itemprop="hello" http-equiv="refresh" content="5">
19457 <link itemprop="hello" href="{{SERVER}}">
19458 <link rel="stylesheet" href="{{SERVER}}">
19459 <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
19460 </div>
19461 !! html
19462 <div itemscope="">
19463 <p> <meta itemprop="hello" content="world" />
19464 &lt;meta http-equiv="refresh" content="5"&gt;
19465 <meta itemprop="hello" content="5" />
19466 <link itemprop="hello" href="http&#58;//example.org" />
19467 &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"&gt;
19468 <link itemprop="hello" href="http&#58;//example.org" />
19469 </p>
19470 </div>
19471
19472 !! end
19473
19474 !! test
19475 Sanitizer: Strip comments from CSS attributes
19476 !! options
19477 parsoid=wt2html,wt2wt
19478 !! wikitext
19479 <span style="margin:/*negate mbox-text padding */-0.125em -0.45em; /*rainbow*/rgba(255, 0, 0, 0.3)">2013</span>
19480 !! html/php
19481 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span>
19482 </p>
19483 !! html/parsoid
19484 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span></p>
19485 !! end
19486
19487 !! test
19488 Sanitizer: Avoid unnecessary percent encoded characters in interwiki links
19489 !! wikitext
19490 [[meatball:Soft"Security]]
19491 !! html/php
19492 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Soft%22Security" class="extiw" title="meatball:Soft&quot;Security">meatball:Soft"Security</a>
19493 </p>
19494 !! html/parsoid
19495 <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>
19496 !! end
19497
19498 !! test
19499 Sanitizer: angle brackets are invalid, even in interwiki links (T182338)
19500 !! wikitext
19501 [[meatball:Foo<Bar]]
19502 [[meatball:Foo>Bar]]
19503 [[meatball:Foo&lt;bar]]
19504 [[meatball:Foo&gt;bar]]
19505 !! html/php
19506 <p>[[meatball:Foo&lt;Bar]]
19507 [[meatball:Foo&gt;Bar]]
19508 [[meatball:Foo&lt;bar]]
19509 [[meatball:Foo&gt;bar]]
19510 </p>
19511 !! html/parsoid
19512 <p>[[meatball:Foo&lt;Bar]]
19513 [[meatball:Foo>Bar]]
19514 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span>bar]]
19515 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;gt;","srcContent":">"}'>></span>bar]]</p>
19516 !! end
19517
19518 !! test
19519 Language converter: output gets cut off unexpectedly (T7757)
19520 !! options
19521 language=zh
19522 !! wikitext
19523 this bit is safe: }-
19524
19525 but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}-
19526
19527 then we get cut off here: }-
19528
19529 all additional text is vanished
19530 !! html/php
19531 <p>this bit is safe: }-
19532 </p><p>but if we add a conversion instance: xxx
19533 </p><p>then we get cut off here: }-
19534 </p><p>all additional text is vanished
19535 </p>
19536 !! html/parsoid
19537 <p>this bit is safe: }-</p>
19538 <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>
19539 <p>then we get cut off here: }-</p>
19540 <p>all additional text is vanished</p>
19541 !! end
19542
19543 !! test
19544 Language converter glossary rules inside attributes (T119158)
19545 !! options
19546 language=sr variant=sr-el
19547 !! wikitext
19548 -{H|foAjrjvi=>sr-el:" onload="alert(1)" data-foo="}-
19549
19550 [[File:Foobar.jpg|alt=-{}-foAjrjvi-{}-]]
19551 !! html/php
19552 <p>
19553 </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>
19554 </p>
19555 !! html/parsoid
19556 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"foAjrjvi","l":"sr-el","t":"\" onload=\"alert(1)\" data-foo=\""}]}'/></p>
19557
19558 <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>
19559 !! end
19560
19561 !! test
19562 Self closed html pairs (T7487)
19563 !! wikitext
19564 <center><font id="bug" />Centered text</center>
19565 <div><font id="bug2" />In div text</div>
19566 !! html+tidy
19567 <center><font id="bug"></font>Centered text</center>
19568 <div><font id="bug2"></font>In div text</div>
19569 !! end
19570
19571 !! test
19572 Punctuation: nbsp before exclamation
19573 !! wikitext
19574 C'est grave !
19575 !! html
19576 <p>C'est grave&#160;!
19577 </p>
19578 !! end
19579
19580 !! test
19581 Punctuation: CSS !important (T13874)
19582 !! wikitext
19583 <div style="width:50% !important">important</div>
19584 !! html
19585 <div style="width:50% !important">important</div>
19586
19587 !!end
19588
19589 !! test
19590 Punctuation: CSS ! important (T13874; with space after)
19591 !! wikitext
19592 <div style="width:50% ! important">important</div>
19593 !! html
19594 <div style="width:50%&#32;! important">important</div>
19595
19596 !!end
19597
19598 !! test
19599 HTML bullet list, closed tags (T7497)
19600 !! wikitext
19601 <ul>
19602 <li>One</li>
19603 <li>Two</li>
19604 </ul>
19605 !! html/php
19606 <ul>
19607 <li>One</li>
19608 <li>Two</li>
19609 </ul>
19610
19611 !! html/parsoid
19612 <ul data-parsoid='{"stx":"html"}'>
19613 <li data-parsoid='{"stx":"html"}'>One</li>
19614 <li data-parsoid='{"stx":"html"}'>Two</li>
19615 </ul>
19616
19617 !! end
19618
19619 !! test
19620 HTML bullet list, unclosed tags (T7497)
19621 !! wikitext
19622 <ul>
19623 <li>One
19624 <li>Two
19625 </ul>
19626 !! html/php+tidy
19627 <ul>
19628 <li>One
19629 </li><li>Two
19630 </li></ul>
19631 !! html/parsoid
19632 <ul data-parsoid='{"stx":"html"}'>
19633 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
19634 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
19635 </ul>
19636
19637 !! end
19638
19639 !! test
19640 HTML ordered list, closed tags (T7497)
19641 !! wikitext
19642 <ol>
19643 <li>One</li>
19644 <li>Two</li>
19645 </ol>
19646 !! html/php
19647 <ol>
19648 <li>One</li>
19649 <li>Two</li>
19650 </ol>
19651
19652 !! html/parsoid
19653 <ol data-parsoid='{"stx":"html"}'>
19654 <li data-parsoid='{"stx":"html"}'>One</li>
19655 <li data-parsoid='{"stx":"html"}'>Two</li>
19656 </ol>
19657
19658 !! end
19659
19660 !! test
19661 HTML ordered list, unclosed tags (T7497)
19662 !! options
19663 !! wikitext
19664 <ol>
19665 <li>One
19666 <li>Two
19667 </ol>
19668 !! html/php+tidy
19669 <ol>
19670 <li>One
19671 </li><li>Two
19672 </li></ol>
19673 !! html/parsoid
19674 <ol data-parsoid='{"stx":"html"}'>
19675 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
19676 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
19677 </ol>
19678
19679 !! end
19680
19681 !! test
19682 HTML nested bullet list, closed tags (T7497)
19683 !! wikitext
19684 <ul>
19685 <li>One</li>
19686 <li>Two:
19687 <ul>
19688 <li>Sub-one</li>
19689 <li>Sub-two</li>
19690 </ul>
19691 </li>
19692 </ul>
19693 !! html/php
19694 <ul>
19695 <li>One</li>
19696 <li>Two:
19697 <ul>
19698 <li>Sub-one</li>
19699 <li>Sub-two</li>
19700 </ul>
19701 </li>
19702 </ul>
19703
19704 !! html/parsoid
19705 <ul data-parsoid='{"stx":"html"}'>
19706 <li data-parsoid='{"stx":"html"}'>One</li>
19707 <li data-parsoid='{"stx":"html"}'>Two:
19708 <ul data-parsoid='{"stx":"html"}'>
19709 <li data-parsoid='{"stx":"html"}'>Sub-one</li>
19710 <li data-parsoid='{"stx":"html"}'>Sub-two</li>
19711 </ul>
19712 </li>
19713 </ul>
19714 !! end
19715
19716 !! test
19717 HTML nested bullet list, open tags (T7497)
19718 !! wikitext
19719 <ul>
19720 <li>One
19721 <li>Two:
19722 <ul>
19723 <li>Sub-one
19724 <li>Sub-two
19725 </ul>
19726 </ul>
19727 !! html+tidy
19728 <ul>
19729 <li>One
19730 </li><li>Two:
19731 <ul>
19732 <li>Sub-one
19733 </li><li>Sub-two
19734 </li></ul>
19735 </li></ul>
19736 !! end
19737
19738 !! test
19739 HTML nested ordered list, closed tags (T7497)
19740 !! wikitext
19741 <ol>
19742 <li>One</li>
19743 <li>Two:
19744 <ol>
19745 <li>Sub-one</li>
19746 <li>Sub-two</li>
19747 </ol>
19748 </li>
19749 </ol>
19750 !! html
19751 <ol>
19752 <li>One</li>
19753 <li>Two:
19754 <ol>
19755 <li>Sub-one</li>
19756 <li>Sub-two</li>
19757 </ol>
19758 </li>
19759 </ol>
19760
19761 !! end
19762
19763 !! test
19764 HTML nested ordered list, open tags (T7497)
19765 !! wikitext
19766 <ol>
19767 <li>One
19768 <li>Two:
19769 <ol>
19770 <li>Sub-one
19771 <li>Sub-two
19772 </ol>
19773 </ol>
19774 !! html/php
19775 <ol>
19776 <li>One
19777 <li>Two:
19778 <ol>
19779 <li>Sub-one
19780 <li>Sub-two
19781 </ol>
19782 </ol>
19783
19784 !! html/parsoid
19785 <ol>
19786 <li>One
19787 </li>
19788 <li>Two:
19789 <ol>
19790 <li>Sub-one
19791 </li>
19792 <li>Sub-two
19793 </li>
19794 </ol>
19795 </li>
19796 </ol>
19797
19798 !! end
19799
19800 !! test
19801 HTML ordered list item with parameters oddity
19802 !! wikitext
19803 <ol><li id="fragment">One</li>
19804 </ol>
19805 !! html
19806 <ol><li id="fragment">One</li>
19807 </ol>
19808
19809 !! end
19810
19811 # parsoid doesn't explicitly mark autonumbered links, see T55505
19812 !!test
19813 T7918: autonumbering
19814 !! wikitext
19815 [http://first/] [http://second] [ftp://ftp]
19816
19817 ftp://inlineftp
19818
19819 [mailto:enclosed@mail.tld With target]
19820
19821 [mailto:enclosed@mail.tld]
19822
19823 mailto:inline@mail.tld
19824 !! html/php
19825 <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>
19826 </p><p><a rel="nofollow" class="external free" href="ftp://inlineftp">ftp://inlineftp</a>
19827 </p><p><a rel="nofollow" class="external text" href="mailto:enclosed@mail.tld">With target</a>
19828 </p><p><a rel="nofollow" class="external autonumber" href="mailto:enclosed@mail.tld">[4]</a>
19829 </p><p><a rel="nofollow" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a>
19830 </p>
19831 !! html/parsoid
19832 <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>
19833 <p><a rel="mw:ExtLink" class="external free" href="ftp://inlineftp">ftp://inlineftp</a></p>
19834 <p><a rel="mw:ExtLink" class="external text" href="mailto:enclosed@mail.tld">With target</a></p>
19835 <p><a rel="mw:ExtLink" class="external autonumber" href="mailto:enclosed@mail.tld"></a></p>
19836 <p><a rel="mw:ExtLink" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a></p>
19837 !! end
19838
19839
19840 #
19841 # Security and HTML correctness
19842 # From Nick Jenkins' fuzz testing
19843 #
19844
19845 !! test
19846 Fuzz testing: Parser13
19847 !! wikitext
19848 {|
19849 | http://a|
19850 !! html
19851 <table>
19852 <tr>
19853 <td>
19854 </td>
19855 </tr>
19856 </table>
19857
19858 !! end
19859
19860 # Note that Parsoid output differs from the PHP parser here: the PHP
19861 # parser breaks the URL for the magic word, while in Parsoid the URL
19862 # production takes precedence.
19863 !! test
19864 Fuzz testing: Parser14
19865 !! wikitext
19866 ==onmouseover===
19867 http://__TOC__
19868 !! html/php
19869 <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>
19870 http://<div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
19871 <ul>
19872 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
19873 </ul>
19874 </div>
19875
19876
19877 !! html/php+tidy
19878 <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>
19879 http://</p><div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
19880 <ul>
19881 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
19882 </ul>
19883 </div>
19884 !! html/parsoid
19885 <h2 id="onmouseover="><span id="onmouseover.3D" typeof="mw:FallbackId"></span>onmouseover=</h2>
19886 <p><a rel="mw:ExtLink" class="external free" href="http://__TOC__" data-parsoid='{"stx":"url"}'>http://__TOC__</a></p>
19887 !! end
19888
19889 !! test
19890 Fuzz testing: Parser14-table
19891 !! options
19892 parsoid=wt2html,html2html
19893 !! wikitext
19894 ==a==
19895 {| STYLE=__TOC__
19896 !! html/php
19897 <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>
19898 <table style="&#95;_TOC&#95;_">
19899 <tr><td></td></tr>
19900 </table>
19901
19902 !! html/php+tidy
19903 <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>
19904 <table style="&#95;_TOC&#95;_">
19905 <tbody><tr><td></td></tr>
19906 </tbody></table>
19907 !! html/parsoid
19908 <h2 id="a">a</h2>
19909 <table style="__TOC__"></table>
19910 !! end
19911
19912 # Known to produce bogus xml (extra </td>)
19913 # Don't add the html/php section since it generates broken HTML
19914 !! test
19915 Fuzz testing: Parser16
19916 !! wikitext
19917 {|
19918 !https://||||||
19919 !! html+tidy
19920 <table>
19921 <tbody><tr>
19922 <th>https://</th>
19923 <th></th>
19924 <th></th>
19925 <th>
19926
19927 </th></tr>
19928 </tbody></table>
19929 !! end
19930
19931 !! test
19932 Fuzz testing: Parser21
19933 !! wikitext
19934 {|
19935 !irc://{{ftp://a" onmouseover="alert('hello world');"
19936 |
19937 !! html
19938 <table>
19939 <tr>
19940 <th><a rel="nofollow" class="external free" href="irc://{{ftp://a">irc://{{ftp://a</a>" onmouseover="alert('hello world');"
19941 </th>
19942 <td>
19943 </td>
19944 </tr>
19945 </table>
19946
19947 !! end
19948
19949 !! test
19950 Fuzz testing: Parser22
19951 !! wikitext
19952 http://===r:::https://b
19953
19954 {|
19955 !! html
19956 <p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a>
19957 </p>
19958 <table>
19959 <tr><td></td></tr>
19960 </table>
19961
19962 !! end
19963
19964 ## Remex doesn't account for fostered content.
19965 ## Known to produce bad XML for now
19966 !! test
19967 Fuzz testing: Parser24
19968 !! options
19969 parsoid=wt2html
19970 !! wikitext
19971 {|
19972 {{{|
19973 <u CLASS=
19974 | {{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}} >
19975 <br style="onmouseover='alert(document.cookie);' " />
19976
19977 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19978 |
19979 !! html/php
19980 <table>
19981 {{{|
19982 <u class="&#124;">}}}} &gt;
19983 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
19984
19985 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19986 <tr>
19987 <td></u>
19988 </td>
19989 </tr>
19990 </table>
19991
19992 !! html/php+tidy
19993
19994 {{{|
19995 <u class="&#124;">}}}} &gt;
19996 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
19997
19998 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19999 </u><table><tbody><tr>
20000 <td>
20001 </td>
20002 </tr>
20003 </tbody></table><p><u class="&#124;">
20004 </u></p>
20005 !! html/parsoid
20006 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>
20007 {{{|
20008 <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>"}'/>}}}} >
20009 <br style="onmouseover='alert(document.cookie);' " data-parsoid='{"stx":"html","selfClose":true}'/>
20010
20011 MOVE YOUR MOUSE CURSOR OVER THIS TEXT</u></p>
20012 <table data-parsoid='{"autoInsertedEnd":true}'><tbody><tr data-parsoid='{"autoInsertedStart":true}'><td></td></tr></tbody></table>
20013 !! end
20014
20015 # Note: the current result listed for this is not what the original one was,
20016 # but the original bug was JavaScript injection, which is fixed in any case.
20017 # It's not clear that the original result listed was any more correct than the
20018 # current one. Original result:
20019 # <p>{{{|
20020 # </p>
20021 # <li class="&#124;&#124;">
20022 # }}}blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
20023 !!test
20024 Fuzz testing: Parser25 (T8055)
20025 !! wikitext
20026 {{{
20027 |
20028 <LI CLASS=||
20029 >
20030 }}}blah" onmouseover="alert('hello world');" align="left"'''MOVE MOUSE CURSOR OVER HERE
20031 !! html/php
20032 <p>&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
20033 </p>
20034 !! html/parsoid
20035 <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"]}'>
20036 </span><p about="#mwt1">&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b></p>
20037 !! end
20038
20039 !!test
20040 Fuzz testing: URL adjacent extension (with space, clean)
20041 !! wikitext
20042 http://example.com <nowiki>junk</nowiki>
20043 !! html/php
20044 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> junk
20045 </p>
20046 !! html/parsoid
20047 <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>
20048 !! end
20049
20050 !!test
20051 Fuzz testing: URL adjacent extension (no space, dirty; nowiki)
20052 !! wikitext
20053 http://example.com<nowiki>junk</nowiki>
20054 !! html/php
20055 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>junk
20056 </p>
20057 !! html/parsoid
20058 <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>
20059 !! end
20060
20061 !! test
20062 Fuzz testing: URL adjacent extension (no space, dirty; pre)
20063 !! wikitext
20064 http://example.com<pre>junk</pre>
20065 !! html/php
20066 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre>
20067
20068 !! html/php+tidy
20069 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p><pre>junk</pre>
20070 !! html/parsoid
20071 <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>
20072 !! end
20073
20074 !! test
20075 Fuzz testing: image with bogus manual thumbnail
20076 !! wikitext
20077 [[Image:foobar.jpg|thumbnail= ]]
20078 !! html/php
20079 <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div>
20080
20081 !! html/parsoid
20082 <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>
20083 !! end
20084
20085 # Parsoid will emit the newline literally in wt2wt; see next test case.
20086 !! test
20087 Fuzz testing: encoded newline in generated HTML replacements (T8577)
20088 !! options
20089 parsoid=wt2html
20090 !! wikitext
20091 <pre dir="&#10;"></pre>
20092 !! html/php
20093 <pre dir="&#10;"></pre>
20094
20095 !! html/parsoid
20096 <pre dir="
20097 " typeof="mw:Extension/pre" about="#mwt2"data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
20098 !! end
20099
20100 !! test
20101 Fuzz testing: encoded newline in generated HTML replacements, html2wt (T8577)
20102 !! options
20103 parsoid=html2wt
20104 !! html/parsoid
20105 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
20106 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
20107 !! wikitext
20108 <pre dir="
20109 "></pre>
20110 !! html/php
20111 <pre dir=""></pre>
20112
20113 !! end
20114
20115 !! test
20116 Templates in extension attributes are not expanded
20117 !! wikitext
20118 <pre dir="{{echo|ltr}}"></pre>
20119 !! html/php
20120 <pre dir="{{echo|ltr}}"></pre>
20121
20122 !! html/parsoid
20123 <pre dir="{{echo|ltr}}" typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"dir":"{{echo|ltr}}"},"body":{"extsrc":""}}'></pre>
20124 !! end
20125
20126 !! test
20127 Parsing optional HTML elements (T8171)
20128 !! options
20129 !! wikitext
20130 <table>
20131 <tr>
20132 <td> Some tabular data</td>
20133 <td> More tabular data ...
20134 <td> And yet som tabular data</td>
20135 </tr>
20136 </table>
20137 !! html
20138 <table>
20139 <tr>
20140 <td> Some tabular data</td>
20141 <td> More tabular data ...
20142 </td><td> And yet som tabular data</td>
20143 </tr>
20144 </table>
20145
20146 !! end
20147
20148 !! test
20149 Correct handling of <td>, <tr> (T8171)
20150 !! options
20151 !! wikitext
20152 <table>
20153 <tr>
20154 <td> Some tabular data</td>
20155 <td> More tabular data ...</td>
20156 <td> And yet som tabular data</td>
20157 </tr>
20158 </table>
20159 !! html
20160 <table>
20161 <tr>
20162 <td> Some tabular data</td>
20163 <td> More tabular data ...</td>
20164 <td> And yet som tabular data</td>
20165 </tr>
20166 </table>
20167
20168 !! end
20169
20170
20171 !! test
20172 Parsing crashing regression (fr:JavaScript)
20173 !! wikitext
20174 </body></x>
20175 !! html
20176 <p>&lt;/body&gt;&lt;/x&gt;
20177 </p>
20178 !! end
20179
20180 !! test
20181 Inline wiki vs wiki block nesting
20182 !! wikitext
20183 '''Bold paragraph
20184
20185 New wiki paragraph
20186 !! html
20187 <p><b>Bold paragraph</b>
20188 </p><p>New wiki paragraph
20189 </p>
20190 !! end
20191
20192 # FIXME: The current php output is documented
20193 # and desired output is the parsoid target.
20194 !! test
20195 Inline HTML vs wiki block nesting
20196 !! wikitext
20197 <b>Bold paragraph
20198
20199 New wiki paragraph
20200 !! html/php
20201 <p><b>Bold paragraph
20202 </p><p>New wiki paragraph</b>
20203 </p>
20204 !! html/php+tidy
20205 <p><b>Bold paragraph
20206 </b></p><p><b>New wiki paragraph
20207 </b></p>
20208 !! html/parsoid
20209 <p><b>Bold paragraph</b>
20210 </p><p>New wiki paragraph
20211 </p>
20212 !! end
20213
20214 # Original result was this:
20215 # <p><b>bold</b><b>bold<i>bolditalics</i></b>
20216 # </p>
20217 # While that might be marginally more intuitive, maybe, the six-apostrophe
20218 # construct is clearly pathological and the result stated here (which is what
20219 # the parser actually does) is about as reasonable as anything.
20220 !!test
20221 Mixing markup for italics and bold
20222 !! options
20223 !! wikitext
20224 '''bold''''''bold''bolditalics'''''
20225 !! html
20226 <p>'<i>bold'</i><b>bold<i>bolditalics</i></b>
20227 </p>
20228 !! end
20229
20230
20231 !! article
20232 Xyzzyx
20233 !! text
20234 Article for special page transclusion test
20235 !! endarticle
20236
20237 !! test
20238 Special page transclusion
20239 !! options
20240 !! wikitext
20241 {{Special:Prefixindex/Xyzzyx}}
20242 !! html
20243 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
20244 </ul>
20245
20246 !! end
20247
20248 !! test
20249 Special page transclusion twice (T7021)
20250 !! options
20251 !! wikitext
20252 {{Special:Prefixindex/Xyzzyx}}
20253 {{Special:Prefixindex/Xyzzyx}}
20254 !! html
20255 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
20256 </ul>
20257 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
20258 </ul>
20259
20260 !! end
20261
20262 !! test
20263 Transclusion of default MediaWiki message
20264 !! wikitext
20265 {{MediaWiki:Mainpage}}
20266 !! html
20267 <p>Main Page
20268 </p>
20269 !! end
20270
20271 !! test
20272 Transclusion of nonexistent MediaWiki message
20273 !! wikitext
20274 {{MediaWiki:Mainpagexxx}}
20275 !! html
20276 <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>
20277 </p>
20278 !! end
20279
20280 !! test
20281 Transclusion of MediaWiki message with underscore
20282 !! wikitext
20283 {{MediaWiki:history_short}}
20284 !! html
20285 <p>History
20286 </p>
20287 !! end
20288
20289 !! test
20290 Transclusion of MediaWiki message with space
20291 !! wikitext
20292 {{MediaWiki:history short}}
20293 !! html
20294 <p>History
20295 </p>
20296 !! end
20297
20298 !! test
20299 Invalid header with following text
20300 !! wikitext
20301 = x = y
20302 !! html
20303 <p>= x = y
20304 </p>
20305 !! end
20306
20307
20308 !! test
20309 Section extraction test (section 0)
20310 !! options
20311 section=0
20312 !! wikitext
20313 start
20314 ==a==
20315 ===aa===
20316 ====aaa====
20317 ==b==
20318 ===ba===
20319 ===bb===
20320 ====bba====
20321 ===bc===
20322 ==c==
20323 ===ca===
20324 !! html/php
20325 start
20326 !! end
20327
20328 !! test
20329 Section extraction test (section 1)
20330 !! options
20331 section=1
20332 !! wikitext
20333 start
20334 ==a==
20335 ===aa===
20336 ====aaa====
20337 ==b==
20338 ===ba===
20339 ===bb===
20340 ====bba====
20341 ===bc===
20342 ==c==
20343 ===ca===
20344 !! html/php
20345 ==a==
20346 ===aa===
20347 ====aaa====
20348 !! end
20349
20350 !! test
20351 Section extraction test (section 2)
20352 !! options
20353 section=2
20354 !! wikitext
20355 start
20356 ==a==
20357 ===aa===
20358 ====aaa====
20359 ==b==
20360 ===ba===
20361 ===bb===
20362 ====bba====
20363 ===bc===
20364 ==c==
20365 ===ca===
20366 !! html/php
20367 ===aa===
20368 ====aaa====
20369 !! end
20370
20371 !! test
20372 Section extraction test (section 3)
20373 !! options
20374 section=3
20375 !! wikitext
20376 start
20377 ==a==
20378 ===aa===
20379 ====aaa====
20380 ==b==
20381 ===ba===
20382 ===bb===
20383 ====bba====
20384 ===bc===
20385 ==c==
20386 ===ca===
20387 !! html/php
20388 ====aaa====
20389 !! end
20390
20391 !! test
20392 Section extraction test (section 4)
20393 !! options
20394 section=4
20395 !! wikitext
20396 start
20397 ==a==
20398 ===aa===
20399 ====aaa====
20400 ==b==
20401 ===ba===
20402 ===bb===
20403 ====bba====
20404 ===bc===
20405 ==c==
20406 ===ca===
20407 !! html/php
20408 ==b==
20409 ===ba===
20410 ===bb===
20411 ====bba====
20412 ===bc===
20413 !! end
20414
20415 !! test
20416 Section extraction test (section 5)
20417 !! options
20418 section=5
20419 !! wikitext
20420 start
20421 ==a==
20422 ===aa===
20423 ====aaa====
20424 ==b==
20425 ===ba===
20426 ===bb===
20427 ====bba====
20428 ===bc===
20429 ==c==
20430 ===ca===
20431 !! html/php
20432 ===ba===
20433 !! end
20434
20435 !! test
20436 Section extraction test (section 6)
20437 !! options
20438 section=6
20439 !! wikitext
20440 start
20441 ==a==
20442 ===aa===
20443 ====aaa====
20444 ==b==
20445 ===ba===
20446 ===bb===
20447 ====bba====
20448 ===bc===
20449 ==c==
20450 ===ca===
20451 !! html/php
20452 ===bb===
20453 ====bba====
20454 !! end
20455
20456 !! test
20457 Section extraction test (section 7)
20458 !! options
20459 section=7
20460 !! wikitext
20461 start
20462 ==a==
20463 ===aa===
20464 ====aaa====
20465 ==b==
20466 ===ba===
20467 ===bb===
20468 ====bba====
20469 ===bc===
20470 ==c==
20471 ===ca===
20472 !! html/php
20473 ====bba====
20474 !! end
20475
20476 !! test
20477 Section extraction test (section 8)
20478 !! options
20479 section=8
20480 !! wikitext
20481 start
20482 ==a==
20483 ===aa===
20484 ====aaa====
20485 ==b==
20486 ===ba===
20487 ===bb===
20488 ====bba====
20489 ===bc===
20490 ==c==
20491 ===ca===
20492 !! html/php
20493 ===bc===
20494 !! end
20495
20496 !! test
20497 Section extraction test (section 9)
20498 !! options
20499 section=9
20500 !! wikitext
20501 start
20502 ==a==
20503 ===aa===
20504 ====aaa====
20505 ==b==
20506 ===ba===
20507 ===bb===
20508 ====bba====
20509 ===bc===
20510 ==c==
20511 ===ca===
20512 !! html/php
20513 ==c==
20514 ===ca===
20515 !! end
20516
20517 !! test
20518 Section extraction test (section 10)
20519 !! options
20520 section=10
20521 !! wikitext
20522 start
20523 ==a==
20524 ===aa===
20525 ====aaa====
20526 ==b==
20527 ===ba===
20528 ===bb===
20529 ====bba====
20530 ===bc===
20531 ==c==
20532 ===ca===
20533 !! html/php
20534 ===ca===
20535 !! end
20536
20537 !! test
20538 Section extraction test (nonexistent section 11)
20539 !! options
20540 section=11
20541 !! wikitext
20542 start
20543 ==a==
20544 ===aa===
20545 ====aaa====
20546 ==b==
20547 ===ba===
20548 ===bb===
20549 ====bba====
20550 ===bc===
20551 ==c==
20552 ===ca===
20553 !! html/php
20554 !! end
20555
20556 !! test
20557 Section extraction test with bogus heading (section 1)
20558 !! options
20559 section=1
20560 !! wikitext
20561 ==a==
20562 ==bogus== not a legal section
20563 ==b==
20564 !! html/php
20565 ==a==
20566 ==bogus== not a legal section
20567 !! end
20568
20569 !! test
20570 Section extraction test with bogus heading (section 2)
20571 !! options
20572 section=2
20573 !! wikitext
20574 ==a==
20575 ==bogus== not a legal section
20576 ==b==
20577 !! html/php
20578 ==b==
20579 !! end
20580
20581 !! test
20582 Section extraction test with comment after heading (section 1)
20583 !! options
20584 section=1
20585 !! wikitext
20586 ==a==
20587 ==b== <!-- -->
20588 ==c==
20589 !! html/php
20590 ==a==
20591 !! end
20592
20593 !! test
20594 Section extraction test with comment after heading (section 2)
20595 !! options
20596 section=2
20597 !! wikitext
20598 ==a==
20599 ==b== <!-- -->
20600 ==c==
20601 !! html/php
20602 ==b== <!-- -->
20603 !! end
20604
20605 !! test
20606 Section extraction test with bogus <nowiki> heading (section 1)
20607 !! options
20608 section=1
20609 !! wikitext
20610 ==a==
20611 ==bogus== <nowiki>not a legal section</nowiki>
20612 ==b==
20613 !! html/php
20614 ==a==
20615 ==bogus== <nowiki>not a legal section</nowiki>
20616 !! end
20617
20618 !! test
20619 Section extraction test with bogus <nowiki> heading (section 2)
20620 !! options
20621 section=2
20622 !! wikitext
20623 ==a==
20624 ==bogus== <nowiki>not a legal section</nowiki>
20625 ==b==
20626 !! html/php
20627 ==b==
20628 !! end
20629
20630 # Formerly testing for T4587, now resolved by the use of unmarked sections
20631 # instead of respecting commented sections
20632 !! test
20633 Section extraction prefixed by comment (section 1)
20634 !! options
20635 section=1
20636 !! wikitext
20637 <!-- -->==sec1==
20638 ==sec2==
20639 !! html/php
20640 ==sec2==
20641 !!end
20642
20643 !! test
20644 Section extraction prefixed by comment (section 2)
20645 !! options
20646 section=2
20647 !! wikitext
20648 <!-- -->==sec1==
20649 ==sec2==
20650 !! html/php
20651
20652 !!end
20653
20654 # Formerly testing for T4607, now resolved by the use of unmarked sections
20655 # instead of respecting HTML-style headings
20656 !! test
20657 Section extraction, mixed wiki and html (section 1)
20658 !! options
20659 section=1
20660 !! wikitext
20661 <h2>unmarked</h2>
20662 unmarked
20663 ==1==
20664 one
20665 ==2==
20666 two
20667 !! html/php
20668 ==1==
20669 one
20670 !! end
20671
20672 !! test
20673 Section extraction, mixed wiki and html (section 2)
20674 !! options
20675 section=2
20676 !! wikitext
20677 <h2>unmarked</h2>
20678 unmarked
20679 ==1==
20680 one
20681 ==2==
20682 two
20683 !! html/php
20684 ==2==
20685 two
20686 !! end
20687
20688
20689 # Formerly testing for T5342
20690 !! test
20691 Section extraction, heading surrounded by <noinclude>
20692 !! options
20693 section=1
20694 !! wikitext
20695 <noinclude>==unmarked==</noinclude>
20696 ==marked==
20697 !! html/php
20698 ==marked==
20699 !!end
20700
20701 # Test behavior of T21910
20702 !! test
20703 Sectiion with all-equals
20704 !! options
20705 section=2
20706 !! wikitext
20707 ===
20708 The line above must have a trailing space
20709 === <!--
20710 --> <!-- -->
20711 But just in case it doesn't...
20712 !! html/php
20713 === <!--
20714 --> <!-- -->
20715 But just in case it doesn't...
20716 !! end
20717
20718 !! test
20719 Section replacement test (section 0)
20720 !! options
20721 replace=0,"xxx"
20722 !! wikitext
20723 start
20724 ==a==
20725 ===aa===
20726 ====aaa====
20727 ==b==
20728 ===ba===
20729 ===bb===
20730 ====bba====
20731 ===bc===
20732 ==c==
20733 ===ca===
20734 !! html/php
20735 xxx
20736
20737 ==a==
20738 ===aa===
20739 ====aaa====
20740 ==b==
20741 ===ba===
20742 ===bb===
20743 ====bba====
20744 ===bc===
20745 ==c==
20746 ===ca===
20747 !! end
20748
20749 !! test
20750 Section replacement test (section 1)
20751 !! options
20752 replace=1,"xxx"
20753 !! wikitext
20754 start
20755 ==a==
20756 ===aa===
20757 ====aaa====
20758 ==b==
20759 ===ba===
20760 ===bb===
20761 ====bba====
20762 ===bc===
20763 ==c==
20764 ===ca===
20765 !! html/php
20766 start
20767 xxx
20768
20769 ==b==
20770 ===ba===
20771 ===bb===
20772 ====bba====
20773 ===bc===
20774 ==c==
20775 ===ca===
20776 !! end
20777
20778 !! test
20779 Section replacement test (section 2)
20780 !! options
20781 replace=2,"xxx"
20782 !! wikitext
20783 start
20784 ==a==
20785 ===aa===
20786 ====aaa====
20787 ==b==
20788 ===ba===
20789 ===bb===
20790 ====bba====
20791 ===bc===
20792 ==c==
20793 ===ca===
20794 !! html/php
20795 start
20796 ==a==
20797 xxx
20798
20799 ==b==
20800 ===ba===
20801 ===bb===
20802 ====bba====
20803 ===bc===
20804 ==c==
20805 ===ca===
20806 !! end
20807
20808 !! test
20809 Section replacement test (section 3)
20810 !! options
20811 replace=3,"xxx"
20812 !! wikitext
20813 start
20814 ==a==
20815 ===aa===
20816 ====aaa====
20817 ==b==
20818 ===ba===
20819 ===bb===
20820 ====bba====
20821 ===bc===
20822 ==c==
20823 ===ca===
20824 !! html/php
20825 start
20826 ==a==
20827 ===aa===
20828 xxx
20829
20830 ==b==
20831 ===ba===
20832 ===bb===
20833 ====bba====
20834 ===bc===
20835 ==c==
20836 ===ca===
20837 !! end
20838
20839 !! test
20840 Section replacement test (section 4)
20841 !! options
20842 replace=4,"xxx"
20843 !! wikitext
20844 start
20845 ==a==
20846 ===aa===
20847 ====aaa====
20848 ==b==
20849 ===ba===
20850 ===bb===
20851 ====bba====
20852 ===bc===
20853 ==c==
20854 ===ca===
20855 !! html/php
20856 start
20857 ==a==
20858 ===aa===
20859 ====aaa====
20860 xxx
20861
20862 ==c==
20863 ===ca===
20864 !! end
20865
20866 !! test
20867 Section replacement test (section 5)
20868 !! options
20869 replace=5,"xxx"
20870 !! wikitext
20871 start
20872 ==a==
20873 ===aa===
20874 ====aaa====
20875 ==b==
20876 ===ba===
20877 ===bb===
20878 ====bba====
20879 ===bc===
20880 ==c==
20881 ===ca===
20882 !! html/php
20883 start
20884 ==a==
20885 ===aa===
20886 ====aaa====
20887 ==b==
20888 xxx
20889
20890 ===bb===
20891 ====bba====
20892 ===bc===
20893 ==c==
20894 ===ca===
20895 !! end
20896
20897 !! test
20898 Section replacement test (section 6)
20899 !! options
20900 replace=6,"xxx"
20901 !! wikitext
20902 start
20903 ==a==
20904 ===aa===
20905 ====aaa====
20906 ==b==
20907 ===ba===
20908 ===bb===
20909 ====bba====
20910 ===bc===
20911 ==c==
20912 ===ca===
20913 !! html/php
20914 start
20915 ==a==
20916 ===aa===
20917 ====aaa====
20918 ==b==
20919 ===ba===
20920 xxx
20921
20922 ===bc===
20923 ==c==
20924 ===ca===
20925 !! end
20926
20927 !! test
20928 Section replacement test (section 7)
20929 !! options
20930 replace=7,"xxx"
20931 !! wikitext
20932 start
20933 ==a==
20934 ===aa===
20935 ====aaa====
20936 ==b==
20937 ===ba===
20938 ===bb===
20939 ====bba====
20940 ===bc===
20941 ==c==
20942 ===ca===
20943 !! html/php
20944 start
20945 ==a==
20946 ===aa===
20947 ====aaa====
20948 ==b==
20949 ===ba===
20950 ===bb===
20951 xxx
20952
20953 ===bc===
20954 ==c==
20955 ===ca===
20956 !! end
20957
20958 !! test
20959 Section replacement test (section 8)
20960 !! options
20961 replace=8,"xxx"
20962 !! wikitext
20963 start
20964 ==a==
20965 ===aa===
20966 ====aaa====
20967 ==b==
20968 ===ba===
20969 ===bb===
20970 ====bba====
20971 ===bc===
20972 ==c==
20973 ===ca===
20974 !! html/php
20975 start
20976 ==a==
20977 ===aa===
20978 ====aaa====
20979 ==b==
20980 ===ba===
20981 ===bb===
20982 ====bba====
20983 xxx
20984
20985 ==c==
20986 ===ca===
20987 !!end
20988
20989 !! test
20990 Section replacement test (section 9)
20991 !! options
20992 replace=9,"xxx"
20993 !! wikitext
20994 start
20995 ==a==
20996 ===aa===
20997 ====aaa====
20998 ==b==
20999 ===ba===
21000 ===bb===
21001 ====bba====
21002 ===bc===
21003 ==c==
21004 ===ca===
21005 !! html/php
21006 start
21007 ==a==
21008 ===aa===
21009 ====aaa====
21010 ==b==
21011 ===ba===
21012 ===bb===
21013 ====bba====
21014 ===bc===
21015 xxx
21016 !! end
21017
21018 !! test
21019 Section replacement test (section 10)
21020 !! options
21021 replace=10,"xxx"
21022 !! wikitext
21023 start
21024 ==a==
21025 ===aa===
21026 ====aaa====
21027 ==b==
21028 ===ba===
21029 ===bb===
21030 ====bba====
21031 ===bc===
21032 ==c==
21033 ===ca===
21034 !! html/php
21035 start
21036 ==a==
21037 ===aa===
21038 ====aaa====
21039 ==b==
21040 ===ba===
21041 ===bb===
21042 ====bba====
21043 ===bc===
21044 ==c==
21045 xxx
21046 !! end
21047
21048 !! test
21049 Section replacement test with initial whitespace (T15728)
21050 !! options
21051 replace=2,"xxx"
21052 !! wikitext
21053 Preformatted initial line
21054 ==a==
21055 ===a===
21056 !! html/php
21057 Preformatted initial line
21058 ==a==
21059 xxx
21060 !! end
21061
21062
21063 !! test
21064 Section extraction, heading followed by pre with 20 spaces (T8398)
21065 !! options
21066 section=1
21067 !! wikitext
21068 ==a==
21069 a
21070 !! html/php
21071 ==a==
21072 a
21073 !! end
21074
21075 !! test
21076 Section extraction, heading followed by pre with 19 spaces (T8398 sanity check)
21077 !! options
21078 section=1
21079 !! wikitext
21080 ==a==
21081 a
21082 !! html/php
21083 ==a==
21084 a
21085 !! end
21086
21087
21088 !! test
21089 Section extraction, <pre> around bogus header (T12309)
21090 !! options
21091 section=2
21092 !! wikitext
21093 == Section One ==
21094 <pre>
21095 =======
21096 </pre>
21097
21098 == Section Two ==
21099 stuff
21100 !! html/php
21101 == Section Two ==
21102 stuff
21103 !! end
21104
21105 !! test
21106 Section replacement, <pre> around bogus header (T12309)
21107 !! options
21108 replace=2,"xxx"
21109 !! wikitext
21110 == Section One ==
21111 <pre>
21112 =======
21113 </pre>
21114
21115 == Section Two ==
21116 stuff
21117 !! html/php
21118 == Section One ==
21119 <pre>
21120 =======
21121 </pre>
21122
21123 xxx
21124 !! end
21125
21126 !! test
21127 Handling of &#x0A; in URLs
21128 !! wikitext
21129 *irc://&#x0A;a
21130 !! html/php
21131 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
21132
21133 !! html/parsoid
21134 <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>
21135 !! end
21136
21137 !! test
21138 Handling of %0A in URLs
21139 !! wikitext
21140 *irc://%0Aa
21141 !! html/php
21142 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
21143
21144 !! html/parsoid
21145 <ul><li><a rel="mw:ExtLink" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
21146 !! end
21147
21148 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
21149 !! test
21150 5 quotes, code coverage +1 line
21151 !! options
21152 parsoid=wt2html
21153 !! wikitext
21154 '''''
21155 !! html/php
21156 !! html/parsoid
21157 <p><b><i></i></b></p>
21158 !! end
21159
21160 # same html as previous, but wikitext adjusted to match parsoid html2wt
21161 # note that wt2html and html2html will put the <i> before the <b>
21162 !! test
21163 5 quotes, code coverage +1 line w/ nowiki (1)
21164 !! options
21165 parsoid=wt2wt,html2wt
21166 !! wikitext
21167 '''''<nowiki/>'''''
21168 !! html/php
21169 <p><i></i>
21170 </p>
21171 !! html/parsoid
21172 <p><b><i></i></b></p>
21173 !! end
21174
21175 # same as previous, just swapping the <i> and <b>
21176 !! test
21177 5 quotes, code coverage +1 line w/ nowiki (2)
21178 !! wikitext
21179 '''''<nowiki/>'''''
21180 !! html/php
21181 <p><i></i>
21182 </p>
21183 !! html/parsoid
21184 <p><i><b></b></i></p>
21185 !! end
21186
21187 !! test
21188 Special:Search page linking.
21189 !! wikitext
21190 {{Special:search}}
21191 !! html
21192 <p><a href="/wiki/Special:Search" title="Special:Search">Special:Search</a>
21193 </p>
21194 !! end
21195
21196 !! test
21197 {{!}} is a magic word
21198 !! wikitext
21199 {{!}} is a magic word there and {{!}} is still a magic word here
21200 | is not a magic word here but {{!}} is still a magic word here
21201 !! html/php
21202 <p>| is a magic word there and | is still a magic word here
21203 | is not a magic word here but | is still a magic word here
21204 </p>
21205 !! html/parsoid
21206 <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
21207 | 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>
21208 !! end
21209
21210 !! test
21211 Say the magic word
21212 !! options
21213 title=[[Parser test]]
21214 !! wikitext
21215 *{{PAGENAME}}
21216 *{{PAGENAMEE}}
21217 *{{FULLPAGENAME}}
21218 *{{FULLPAGENAMEE}}
21219 *{{BASEPAGENAME}}
21220 *{{BASEPAGENAMEE}}
21221 *{{SUBPAGENAME}}
21222 *{{SUBPAGENAMEE}}
21223 *{{ROOTPAGENAME}}
21224 *{{ROOTPAGENAMEE}}
21225 *{{TALKPAGENAME}}
21226 *{{TALKPAGENAMEE}}
21227 *{{SUBJECTPAGENAME}}
21228 *{{SUBJECTPAGENAMEE}}
21229 *{{NAMESPACEE}}
21230 *{{NAMESPACE}}
21231 *{{NAMESPACENUMBER}}
21232 *{{TALKSPACE}}
21233 *{{TALKSPACEE}}
21234 *{{SUBJECTSPACE}}
21235 *{{SUBJECTSPACEE}}
21236 *{{Dynamic|{{NUMBEROFUSERS}}|{{NUMBEROFPAGES}}|{{CURRENTVERSION}}|{{CONTENTLANGUAGE}}|{{DIRECTIONMARK}}|{{CURRENTTIMESTAMP}}|{{NUMBEROFARTICLES}}}}
21237 !! html
21238 <ul><li>Parser test</li>
21239 <li>Parser_test</li>
21240 <li>Parser test</li>
21241 <li>Parser_test</li>
21242 <li>Parser test</li>
21243 <li>Parser_test</li>
21244 <li>Parser test</li>
21245 <li>Parser_test</li>
21246 <li>Parser test</li>
21247 <li>Parser_test</li>
21248 <li>Talk:Parser test</li>
21249 <li>Talk:Parser_test</li>
21250 <li>Parser test</li>
21251 <li>Parser_test</li>
21252 <li></li>
21253 <li></li>
21254 <li>0</li>
21255 <li>Talk</li>
21256 <li>Talk</li>
21257 <li></li>
21258 <li></li>
21259 <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>
21260
21261 !! end
21262 ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included.
21263
21264 !! test
21265 Gallery with valid attributes
21266 !! wikitext
21267 <gallery type="123" summary="345">
21268 File:File:Foobar.jpg
21269 </gallery>
21270 !! html/php
21271 <ul class="gallery mw-gallery-traditional" type="123">
21272 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21273 <div class="thumb" style="height: 150px;">File:Foobar.jpg</div>
21274 <div class="gallerytext">
21275 </div>
21276 </div></li>
21277 </ul>
21278
21279 !! html/parsoid
21280 <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"}}'>
21281 <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>
21282 </ul>
21283 !! end
21284
21285 ## Parsoid thinks the "centre" here is a property, not a caption.
21286 !! test
21287 Gallery
21288 !! options
21289 parsoid={
21290 "modes": ["wt2html"],
21291 "nativeGallery": true
21292 }
21293 !! wikitext
21294 <gallery>
21295 image1.png |
21296 image2.gif|||||
21297
21298 image3|
21299 image4 |300px| centre
21300 image5.svg| http://///////
21301 [[x|xx]]]]
21302 * image6
21303 </gallery>
21304 !! html/php
21305 <ul class="gallery mw-gallery-traditional">
21306 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21307 <div class="thumb" style="height: 150px;">Image1.png</div>
21308 <div class="gallerytext">
21309 </div>
21310 </div></li>
21311 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21312 <div class="thumb" style="height: 150px;">Image2.gif</div>
21313 <div class="gallerytext">
21314 </div>
21315 </div></li>
21316 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21317 <div class="thumb" style="height: 150px;">Image3</div>
21318 <div class="gallerytext">
21319 </div>
21320 </div></li>
21321 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21322 <div class="thumb" style="height: 150px;">Image4</div>
21323 <div class="gallerytext">
21324 <pre>centre
21325 </pre>
21326 </div>
21327 </div></li>
21328 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21329 <div class="thumb" style="height: 150px;">Image5.svg</div>
21330 <div class="gallerytext">
21331 <p><a rel="nofollow" class="external free" href="http://///////">http://///////</a>
21332 </p>
21333 </div>
21334 </div></li>
21335 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21336 <div class="thumb" style="height: 150px;">* image6</div>
21337 <div class="gallerytext">
21338 </div>
21339 </div></li>
21340 </ul>
21341
21342 !! html/parsoid
21343 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21344 <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>
21345 <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>
21346 <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>
21347 <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>
21348 <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>
21349 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Error mw:Image"><a href="./File:*_image6"><img resource="./File:*_image6" src="./Special:FilePath/*_image6" height="120" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li>
21350 </ul>
21351 !! end
21352
21353 !! test
21354 Gallery (with options, html)
21355 !! options
21356 parsoid={
21357 "modes": ["wt2html", "html2html"],
21358 "nativeGallery": true
21359 }
21360 !! wikitext
21361 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
21362 File:Nonexistent.jpg|caption
21363 File:Nonexistent.jpg
21364 image:foobar.jpg|some '''caption''' [[Main Page]]
21365 image:foobar.jpg
21366 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
21367 </gallery>
21368 !! html/php
21369 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
21370 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
21371 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21372 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21373 <div class="gallerytext">
21374 <p>caption
21375 </p>
21376 </div>
21377 </div></li>
21378 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21379 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21380 <div class="gallerytext">
21381 </div>
21382 </div></li>
21383 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21384 <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>
21385 <div class="gallerytext">
21386 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21387 </p>
21388 </div>
21389 </div></li>
21390 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21391 <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>
21392 <div class="gallerytext">
21393 </div>
21394 </div></li>
21395 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21396 <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="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>
21397 <div class="gallerytext">
21398 <p>blabla.
21399 </p>
21400 </div>
21401 </div></li>
21402 </ul>
21403
21404 !! html/parsoid
21405 <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":{}}'>
21406 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
21407 <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>
21408 <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>
21409 <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>
21410 <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>
21411 <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>
21412 </ul>
21413 !! end
21414
21415 !! test
21416 Gallery (with options, extsrc)
21417 !! options
21418 parsoid={
21419 "nativeGallery": false
21420 }
21421 !! wikitext
21422 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
21423 File:Nonexistent.jpg|caption
21424 File:Nonexistent.jpg
21425 image:foobar.jpg|some '''caption''' [[Main Page]]
21426 image:foobar.jpg
21427 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
21428 </gallery>
21429 !! html/php
21430 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
21431 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
21432 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21433 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21434 <div class="gallerytext">
21435 <p>caption
21436 </p>
21437 </div>
21438 </div></li>
21439 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21440 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21441 <div class="gallerytext">
21442 </div>
21443 </div></li>
21444 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21445 <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>
21446 <div class="gallerytext">
21447 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21448 </p>
21449 </div>
21450 </div></li>
21451 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21452 <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>
21453 <div class="gallerytext">
21454 </div>
21455 </div></li>
21456 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21457 <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="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>
21458 <div class="gallerytext">
21459 <p>blabla.
21460 </p>
21461 </div>
21462 </div></li>
21463 </ul>
21464
21465 !! html/parsoid
21466 <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"}}'>
21467 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
21468 <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>
21469 <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>
21470 <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>
21471 <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>
21472 <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>
21473 </ul>
21474 !! end
21475
21476 !! test
21477 Gallery (without px units)
21478 !! wikitext
21479 <gallery widths="70" heights="40">
21480 File:Foobar.jpg
21481 </gallery>
21482 !! html/php
21483 <ul class="gallery mw-gallery-traditional">
21484 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21485 <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>
21486 <div class="gallerytext">
21487 </div>
21488 </div></li>
21489 </ul>
21490
21491 !! html/parsoid
21492 <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"}}'>
21493 <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>
21494 </ul>
21495 !! end
21496
21497 !! test
21498 Gallery (with invalid units)
21499 !! wikitext
21500 <gallery widths="70em" heights="40em">
21501 File:Foobar.jpg
21502 </gallery>
21503 !! html/php
21504 <ul class="gallery mw-gallery-traditional">
21505 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21506 <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>
21507 <div class="gallerytext">
21508 </div>
21509 </div></li>
21510 </ul>
21511
21512 !! html/parsoid
21513 <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"}}'>
21514 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li>
21515 </ul>
21516 !! end
21517
21518 !! test
21519 Gallery with link that has fragment
21520 !! options
21521 parsoid={
21522 "modes": ["wt2html", "html2html"],
21523 "nativeGallery": true
21524 }
21525 !! wikitext
21526 <gallery>
21527 image:foobar.jpg|link=Main_Page
21528 image:foobar.jpg|link=Main_Page#section
21529 image:foobar.jpg|link=Main Page#section|caption
21530 </gallery>
21531 !! html/php
21532 <ul class="gallery mw-gallery-traditional">
21533 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21534 <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>
21535 <div class="gallerytext">
21536 </div>
21537 </div></li>
21538 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21539 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Main_Page#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>
21540 <div class="gallerytext">
21541 </div>
21542 </div></li>
21543 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21544 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Main_Page#section"><img alt="" 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>
21545 <div class="gallerytext">
21546 <p>caption
21547 </p>
21548 </div>
21549 </div></li>
21550 </ul>
21551
21552 !! html/parsoid
21553 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21554 <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>
21555 <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>
21556 <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>
21557 </ul>
21558 !! end
21559
21560 ## Whoops, Parsoid shouldn't be parsing templates in the attribute caption!
21561 !! test
21562 Gallery with template inside caption
21563 !! options
21564 parsoid={
21565 "nativeGallery": true
21566 }
21567 !! wikitext
21568 <gallery caption="{{echo|hi}}">
21569 File:Foobar.jpg|{{echo|ho}}
21570 </gallery>
21571 !! html/php
21572 <ul class="gallery mw-gallery-traditional">
21573 <li class='gallerycaption'>{{echo|hi}}</li>
21574 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21575 <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>
21576 <div class="gallerytext">
21577 <p>ho
21578 </p>
21579 </div>
21580 </div></li>
21581 </ul>
21582
21583 !! html/parsoid
21584 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21585 <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>
21586 <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>
21587 </ul>
21588 !! end
21589
21590 !! test
21591 Gallery with wikitext inside caption
21592 !! options
21593 parsoid={
21594 "nativeGallery": true
21595 }
21596 !! wikitext
21597 <gallery>
21598 File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]]
21599 File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}}
21600 </gallery>
21601 !! html/php
21602 <ul class="gallery mw-gallery-traditional">
21603 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21604 <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>
21605 <div class="gallerytext">
21606 <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>
21607 </p>
21608 </div>
21609 </div></li>
21610 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21611 <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>
21612 <div class="gallerytext">
21613 <p>This is a test template
21614 </p>
21615 </div>
21616 </div></li>
21617 </ul>
21618
21619 !! html/parsoid
21620 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21621 <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>
21622 <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>
21623 </ul>
21624 !! end
21625
21626 !! test
21627 Gallery (with showfilename option)
21628 !! options
21629 parsoid={
21630 "nativeGallery": true
21631 }
21632 !! wikitext
21633 <gallery showfilename="">
21634 File:Nonexistent.jpg|caption
21635 File:Nonexistent.jpg
21636 File:Foobar.jpg|some '''caption''' [[Main Page]]
21637 File:Foobar.jpg
21638 </gallery>
21639 !! html/php
21640 <ul class="gallery mw-gallery-traditional">
21641 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21642 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21643 <div class="gallerytext">
21644 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
21645 caption
21646 </p>
21647 </div>
21648 </div></li>
21649 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21650 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21651 <div class="gallerytext">
21652 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
21653 </p>
21654 </div>
21655 </div></li>
21656 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21657 <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>
21658 <div class="gallerytext">
21659 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
21660 some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21661 </p>
21662 </div>
21663 </div></li>
21664 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21665 <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>
21666 <div class="gallerytext">
21667 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
21668 </p>
21669 </div>
21670 </div></li>
21671 </ul>
21672
21673 !! html/parsoid
21674 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
21675 <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>
21676 <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>
21677 <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>
21678 <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>
21679 </ul>
21680 !! end
21681
21682 ## Should Parsoid be preserving these variations? See T151367
21683 !! test
21684 Gallery (with namespace-less filenames)
21685 !! options
21686 parsoid={
21687 "modes": ["wt2html", "html2html"],
21688 "nativeGallery": true
21689 }
21690 !! wikitext
21691 <gallery>
21692 File:Nonexistent.jpg
21693 Nonexistent.jpg
21694 image:foobar.jpg
21695 foobar.jpg
21696 </gallery>
21697 !! html/php
21698 <ul class="gallery mw-gallery-traditional">
21699 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21700 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21701 <div class="gallerytext">
21702 </div>
21703 </div></li>
21704 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21705 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21706 <div class="gallerytext">
21707 </div>
21708 </div></li>
21709 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21710 <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>
21711 <div class="gallerytext">
21712 </div>
21713 </div></li>
21714 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21715 <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>
21716 <div class="gallerytext">
21717 </div>
21718 </div></li>
21719 </ul>
21720
21721 !! html/parsoid
21722 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21723 <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>
21724 <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>
21725 <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>
21726 <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>
21727 </ul>
21728 !! end
21729
21730 !! test
21731 Gallery override link with wikilink (T36852)
21732 !! options
21733 parsoid={
21734 "nativeGallery": true
21735 }
21736 !! wikitext
21737 <gallery>
21738 File:Foobar.jpg|alt=galleryalt|link=Wikilink
21739 </gallery>
21740 !! html/php
21741 <ul class="gallery mw-gallery-traditional">
21742 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21743 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/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>
21744 <div class="gallerytext">
21745 </div>
21746 </div></li>
21747 </ul>
21748
21749 !! html/parsoid
21750 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21751 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw: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>
21752 </ul>
21753 !! end
21754
21755 !! test
21756 Gallery override link with absolute external link (T36852)
21757 !! options
21758 parsoid={
21759 "nativeGallery": true
21760 }
21761 !! wikitext
21762 <gallery>
21763 File:Foobar.jpg|alt=galleryalt|link=http://www.example.org
21764 </gallery>
21765 !! html/php
21766 <ul class="gallery mw-gallery-traditional">
21767 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21768 <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>
21769 <div class="gallerytext">
21770 </div>
21771 </div></li>
21772 </ul>
21773
21774 !! html/parsoid
21775 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21776 <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>
21777 </ul>
21778 !! end
21779
21780 !! test
21781 Gallery override link with absolute external link with LanguageConverter
21782 !! options
21783 language=zh
21784 !! wikitext
21785 <gallery>
21786 File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org
21787 </gallery>
21788 !! html/php
21789 <ul class="gallery mw-gallery-traditional">
21790 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21791 <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>
21792 <div class="gallerytext">
21793 <p>caption
21794 </p>
21795 </div>
21796 </div></li>
21797 </ul>
21798
21799 !! html/parsoid
21800 <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"}}'>
21801 <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>
21802 </ul>
21803 !! end
21804
21805 !! test
21806 Gallery override link with malicious javascript (T36852)
21807 !! options
21808 parsoid={
21809 "modes": ["wt2html", "html2html"],
21810 "nativeGallery": true
21811 }
21812 !! wikitext
21813 <gallery>
21814 File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!');
21815 </gallery>
21816 !! html/php
21817 <ul class="gallery mw-gallery-traditional">
21818 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21819 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/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>
21820 <div class="gallerytext">
21821 </div>
21822 </div></li>
21823 </ul>
21824
21825 !! html/parsoid
21826 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21827 <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>
21828 </ul>
21829 !! end
21830
21831 # Note that parsoid uses the invalid link as a caption, PHP does not.
21832 !! test
21833 Gallery with invalid title as link (T45964)
21834 !! options
21835 parsoid={
21836 "modes": ["wt2html", "html2html"],
21837 "nativeGallery": true
21838 }
21839 !! wikitext
21840 <gallery>
21841 File:Foobar.jpg|link=<
21842 </gallery>
21843 !! html/php
21844 <ul class="gallery mw-gallery-traditional">
21845 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21846 <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>
21847 <div class="gallerytext">
21848 </div>
21849 </div></li>
21850 </ul>
21851
21852 !! html/parsoid
21853 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21854 <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>
21855 </ul>
21856 !! end
21857
21858 !! test
21859 Serialize gallery without attrs in data-mw
21860 !! options
21861 parsoid={
21862 "modes": ["html2wt"],
21863 "nativeGallery": true
21864 }
21865 !! html/parsoid
21866 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'>
21867 <li class="gallerycaption">123</li>
21868 <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>
21869 </ul>
21870 !! wikitext
21871 <gallery caption="123">
21872 File:Test.png
21873 </gallery>
21874 !! end
21875
21876 !! test
21877 Gallery with class and style attributes
21878 !! options
21879 parsoid={
21880 "nativeGallery": true
21881 }
21882 !! wikitext
21883 <gallery class="center" style="text-align: center;">
21884 File:Foobar.jpg
21885 </gallery>
21886 !! html/php
21887 <ul class="gallery mw-gallery-traditional center" style="text-align: center;">
21888 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21889 <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>
21890 <div class="gallerytext">
21891 </div>
21892 </div></li>
21893 </ul>
21894
21895 !! html/parsoid
21896 <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":{}}'>
21897 <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>
21898 </ul>
21899 !! end
21900
21901 !! test
21902 Gallery in slideshow mode
21903 !! options
21904 parsoid={
21905 "nativeGallery": true
21906 }
21907 !! wikitext
21908 <gallery mode="slideshow" showthumbnails="">
21909 File:Foobar.jpg
21910 </gallery>
21911 !! html/php
21912 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1">
21913 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21914 <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>
21915 <div class="gallerytext">
21916 </div>
21917 </div></li>
21918 </ul>
21919
21920 !! html/parsoid
21921 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'>
21922 <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>
21923 </ul>
21924 !! end
21925
21926 !! test
21927 Serialize gallery image captions on a line
21928 !! options
21929 parsoid={
21930 "modes": ["html2wt"],
21931 "nativeGallery": true
21932 }
21933 !! html/parsoid
21934 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21935 <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>
21936 <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>
21937 </ul>
21938 !! wikitext
21939 <gallery>
21940 File:Foobar.jpg| hi ho
21941 File:Foobar.jpg|hi<br />ho
21942 </gallery>
21943 !! end
21944
21945 !! test
21946 HTML Hex character encoding (spells the word "JavaScript")
21947 !! options
21948 parsoid=wt2html,wt2wt,html2html
21949 !! wikitext
21950 &#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
21951 !! html/php
21952 <p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
21953 </p>
21954 !! html/parsoid
21955 <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>
21956 !! end
21957
21958 !! test
21959 HTML Hex character encoding bogus encoding (T28437 regression check)
21960 !! wikitext
21961 &#xsee;&#XSEE;
21962 !! html
21963 <p>&amp;#xsee;&amp;#XSEE;
21964 </p>
21965 !! end
21966
21967 !! test
21968 HTML Hex character encoding mixed case
21969 !! options
21970 parsoid=wt2html,wt2wt,html2html
21971 !! wikitext
21972 &#xEE;&#Xee;
21973 !! html/php
21974 <p>&#xee;&#xee;
21975 </p>
21976 !! html/parsoid
21977 <p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
21978 !! end
21979
21980 # See: https://www.w3.org/TR/html5/syntax.html#character-references
21981 # Note that U+000C (form feed) is not a valid XML character, so
21982 # it is banned even though allowed in HTML5.
21983 !! test
21984 Illegal character references (T106578)
21985 !! wikitext
21986 ; Null: &#00;
21987 ; FF: &#xC;
21988 ; CR: &#xD;
21989 ; Control (low): &#8;
21990 ; Control (high): &#x7F; &#x9F;
21991 ; Surrogate: &#xD83D;&#xDCA9;
21992 ; This is an okay astral character: &#x1F4A9;
21993 !! html+tidy
21994 <dl><dt>Null</dt>
21995 <dd>&amp;#00;</dd>
21996 <dt>FF</dt>
21997 <dd>&amp;#xC;</dd>
21998 <dt>CR</dt>
21999 <dd>&amp;#xD;</dd>
22000 <dt>Control (low)</dt>
22001 <dd>&amp;#8;</dd>
22002 <dt>Control (high)</dt>
22003 <dd>&amp;#x7F; &amp;#x9F;</dd>
22004 <dt>Surrogate</dt>
22005 <dd>&amp;#xD83D;&amp;#xDCA9;</dd>
22006 <dt>This is an okay astral character</dt>
22007 <dd>&#x1f4a9;</dd></dl>
22008 !! end
22009
22010 !! test
22011 __FORCETOC__ override
22012 !! wikitext
22013 __NEWSECTIONLINK__
22014 __FORCETOC__
22015 !! html/php
22016 <p><br />
22017 </p>
22018 !! end
22019
22020 !! test
22021 ISBN code coverage
22022 !! wikitext
22023 ISBN 978-0-1234-56&#x20;789
22024 !! html/php
22025 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a>&#x20;789
22026 </p>
22027 !! html/parsoid
22028 <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>
22029 !! end
22030
22031 !! test
22032 ISBN followed by 5 spaces
22033 !! wikitext
22034 ISBN
22035 !! html
22036 <p>ISBN
22037 </p>
22038 !! end
22039
22040 !! test
22041 Double ISBN
22042 !! wikitext
22043 ISBN ISBN 1234567890
22044 !! html/php
22045 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
22046 </p>
22047 !! html/parsoid
22048 <p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
22049 !! end
22050
22051 # Uppercase X and lowercase x as well
22052 !! test
22053 ISBN with an X
22054 !! wikitext
22055 ISBN 3-462-04561-X
22056 ISBN 3-462-04561-x
22057 ISBN 080442957X
22058 ISBN 080442957x
22059 ISBN 978080442957X
22060 ISBN 978080442957x
22061 !! html/php
22062 <p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a>
22063 <a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a>
22064 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a>
22065 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a>
22066 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a>
22067 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
22068 </p>
22069 !! html/parsoid
22070 <p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
22071 <a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
22072 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
22073 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
22074 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
22075 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
22076 !! end
22077
22078 !! test
22079 ISBN with empty prefix (parsoid test)
22080 !! wikitext
22081 ISBN 1234567890
22082 !! html/php
22083 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
22084 </p>
22085 !! html/parsoid
22086 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p>
22087 !! end
22088
22089 !! test
22090 T24905: <abbr> followed by ISBN followed by </a>
22091 !! wikitext
22092 <abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
22093 !! html/php
22094 <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>
22095 </p>
22096 !! html/parsoid
22097 <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>
22098 !! end
22099
22100 !! test
22101 Double RFC
22102 !! wikitext
22103 RFC RFC 1234
22104 !! html/php
22105 <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a>
22106 </p>
22107 !! html/parsoid
22108 <p>RFC <a href="https://tools.ietf.org/html/rfc1234" rel="mw:ExtLink" class="external mw-magiclink">RFC 1234</a></p>
22109 !! end
22110
22111 !! test
22112 Double RFC with a wiki link
22113 !! wikitext
22114 RFC [[RFC 1234]]
22115 !! html/php
22116 <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>
22117 </p>
22118 !! html/parsoid
22119 <p>RFC <a rel="mw:WikiLink" href="./RFC_1234" title="RFC 1234">RFC 1234</a></p>
22120 !! end
22121
22122 !! test
22123 RFC code coverage
22124 !! wikitext
22125 RFC 983&#x20;987
22126 !! html/php
22127 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
22128 </p>
22129 !! html/parsoid
22130 <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>
22131 !! end
22132
22133 !! test
22134 Centre-aligned image
22135 !! wikitext
22136 [[Image:foobar.jpg|centre]]
22137 !! html/php
22138 <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>
22139
22140 !! html/parsoid
22141 <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>
22142 !! end
22143
22144 !! test
22145 None-aligned image
22146 !! wikitext
22147 [[Image:foobar.jpg|none]]
22148 !! html/php
22149 <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>
22150
22151 !! html/parsoid
22152 <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>
22153 !! end
22154
22155 !! test
22156 Width + Height sized image (using px) (height is ignored)
22157 !! wikitext
22158 [[Image:foobar.jpg|640x480px]]
22159 !! html/php
22160 <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>
22161 </p>
22162 !! html/parsoid
22163 <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>
22164 !! end
22165
22166 !! test
22167 Width-sized image (using px, no following whitespace)
22168 !! wikitext
22169 [[Image:foobar.jpg|640px]]
22170 !! html/php
22171 <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>
22172 </p>
22173 !! html/parsoid
22174 <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>
22175 !! end
22176
22177 !! test
22178 Width-sized image (using px, with following whitespace - test regression from r39467)
22179 !! wikitext
22180 [[Image:foobar.jpg|640px ]]
22181 !! html/php
22182 <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>
22183 </p>
22184 !! html/parsoid
22185 <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>
22186 !!end
22187
22188 !! test
22189 Width-sized image (using px, with preceding whitespace - test regression from r39467)
22190 !! wikitext
22191 [[Image:foobar.jpg| 640px]]
22192 !! html/php
22193 <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>
22194 </p>
22195 !! html/parsoid
22196 <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>
22197 !! end
22198
22199 !! test
22200 Image with page parameter
22201 !! options
22202 djvu
22203 !! wikitext
22204 [[File:LoremIpsum.djvu|page=2]]
22205 !! html/php
22206 <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>
22207 </p>
22208 !! html/parsoid
22209 <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>
22210 !! end
22211
22212 !! test
22213 Another italics / bold test
22214 !! wikitext
22215 ''' ''x'
22216 !! html
22217 <pre>'<i> </i>x'
22218 </pre>
22219 !!end
22220
22221 # FIXME: The php output seems broken. It's interleaving some open/close tags.
22222 !! test
22223 dt/dd/dl test
22224 !! wikitext
22225 :;;;::
22226 !! html/php
22227 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dt></dl></dd></dl></dd></dl></dd></dl></dd></dl></dd></dl>
22228
22229 !! html/parsoid
22230 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dd></dl></dd></dl></dt></dl></dt></dl></dt></dl></dd></dl>
22231
22232 !!end
22233
22234 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
22235 !! test
22236 Images with the "|" character in the comment
22237 !! wikitext
22238 [[File:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
22239 !! html/php
22240 <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>
22241
22242 !! html/parsoid
22243 <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>
22244 !! end
22245
22246 !! test
22247 [Before] HTML without raw HTML enabled ($wgRawHtml==false)
22248 !! wikitext
22249 <html><script>alert(1);</script></html>
22250 !! html
22251 <p>&lt;html&gt;&lt;script&gt;alert(1);&lt;/script&gt;&lt;/html&gt;
22252 </p>
22253 !! end
22254
22255 !! test
22256 HTML with raw HTML ($wgRawHtml==true)
22257 !! options
22258 wgRawHtml=1
22259 !! wikitext
22260 <html><script>alert(1);</script></html>
22261 !! html/php
22262 <p><script>alert(1);</script>
22263 </p>
22264 !! html/parsoid
22265 <p><script typeof="mw:Extension/html" about="#mwt3" data-mw='{"name":"html","attrs":{},"body":{"extsrc":"&lt;script>alert(1);&lt;/script>"}}'>alert(1);</script></p>
22266 !! end
22267
22268 !! test
22269 Parents of subpages, one level up
22270 !! options
22271 subpage title=[[Subpage test/L1/L2/L3]]
22272 !! wikitext
22273 [[../|L2]]
22274 !! html
22275 <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>
22276 </p>
22277 !! end
22278
22279
22280 !! test
22281 Parents of subpages, one level up, not named
22282 !! options
22283 subpage title=[[Subpage test/L1/L2/L3]]
22284 !! wikitext
22285 [[../]]
22286 !! html
22287 <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>
22288 </p>
22289 !! end
22290
22291
22292
22293 !! test
22294 Parents of subpages, two levels up
22295 !! options
22296 subpage title=[[Subpage test/L1/L2/L3]]
22297 !! wikitext
22298 [[../../|L1]]2
22299
22300 [[../../|L1]]l
22301 !! html
22302 <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
22303 </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>
22304 </p>
22305 !! end
22306
22307 !! test
22308 Parents of subpages, two levels up, without trailing slash or name.
22309 !! options
22310 subpage title=[[Subpage test/L1/L2/L3]]
22311 !! wikitext
22312 [[../..]]
22313 !! html
22314 <p>[[../..]]
22315 </p>
22316 !! end
22317
22318 !! test
22319 Parents of subpages, two levels up, with lots of extra trailing slashes.
22320 !! options
22321 subpage title=[[Subpage test/L1/L2/L3]]
22322 !! wikitext
22323 [[../../////]]
22324 !! html
22325 <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>
22326 </p>
22327 !! end
22328
22329 !! article
22330 Subpage test/L1/L2/L3Sibling
22331 !! text
22332 Sibling article
22333 !! endarticle
22334
22335 !! test
22336 Transclusion of a sibling page (one level up)
22337 !! options
22338 subpage title=[[Subpage test/L1/L2/L3]]
22339 !! wikitext
22340 {{../L3Sibling}}
22341 !! html
22342 <p>Sibling article
22343 </p>
22344 !! end
22345
22346 !! test
22347 Transclusion of a child page
22348 !! options
22349 subpage title=[[Subpage test/L1/L2]]
22350 !! wikitext
22351 {{/L3Sibling}}
22352 !! html
22353 <p>Sibling article
22354 </p>
22355 !! end
22356
22357 # This is wt2html only in Parsoid because we add <nowiki>
22358 # because of {{..}} and we don't expect to fix that to
22359 # eliminate the nowikis selective for {{..}} markup.
22360 !! test
22361 Non-transclusion because of too many up levels
22362 !! options
22363 subpage title=[[Subpage test/L1/L2/L3]]
22364 parsoid=wt2html
22365 !! wikitext
22366 {{../../../../More than parent}}
22367 !! html/php
22368 <p>{{../../../../More than parent}}
22369 </p>
22370 !! html/parsoid
22371 <p>{{../../../../More than parent}}</p>
22372 !! end
22373
22374 !! test
22375 Definition list code coverage
22376 !! wikitext
22377 ;title :def
22378 ;title :def
22379 ;title:def
22380 !! html/php
22381 <dl><dt>title</dt>
22382 <dd>def</dd>
22383 <dt>title</dt>
22384 <dd>def</dd>
22385 <dt>title</dt>
22386 <dd>def</dd></dl>
22387
22388 !! html/parsoid
22389 <dl><dt>title </dt><dd>def</dd>
22390 <dt>title </dt><dd>def</dd>
22391 <dt>title</dt><dd>def</dd></dl>
22392 !! end
22393
22394 !! test
22395 Don't fall for the self-closing div
22396 !! wikitext
22397 <div>hello world</div/>
22398 !! html
22399 <div>hello world</div>
22400
22401 !! end
22402
22403 !! test
22404 MSGNW magic word
22405 !! wikitext
22406 {{MSGNW:msg}}
22407 !! html/php
22408 <p>&#91;&#91;:Template:Msg&#93;&#93;
22409 </p>
22410 !! end
22411
22412 !! test
22413 RAW magic word
22414 !! wikitext
22415 {{RAW:QUERTY}}
22416 !! html
22417 <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>
22418 </p>
22419 !! end
22420
22421 # This isn't needed for XHTML conformance, but would be handy as a fallback security measure
22422 !! test
22423 Always escape literal '>' in output, not just after '<'
22424 !! wikitext
22425 ><>
22426 !! html
22427 <p>&gt;&lt;&gt;
22428 </p>
22429 !! end
22430
22431 !! test
22432 Template caching
22433 !! wikitext
22434 {{Test}}
22435 {{Test}}
22436 !! html
22437 <p>This is a test template
22438 This is a test template
22439 </p>
22440 !! end
22441
22442
22443 !! article
22444 MediaWiki:Fake
22445 !! text
22446 ==header==
22447 !! endarticle
22448
22449 !! test
22450 Inclusion of !userCanEdit() content
22451 !! wikitext
22452 {{MediaWiki:Fake}}
22453 !! html
22454 <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>
22455
22456 !! end
22457
22458
22459 !! test
22460 Out-of-order TOC heading levels
22461 !! wikitext
22462 ==2==
22463 ======6======
22464 ===3===
22465 =1=
22466 =====5=====
22467 ==2==
22468 !! html
22469 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
22470 <ul>
22471 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
22472 <ul>
22473 <li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
22474 <li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
22475 </ul>
22476 </li>
22477 <li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
22478 <ul>
22479 <li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
22480 <li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
22481 </ul>
22482 </li>
22483 </ul>
22484 </div>
22485
22486 <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>
22487 <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>
22488 <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>
22489 <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>
22490 <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>
22491 <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>
22492
22493 !! end
22494
22495
22496 !! test
22497 ISBN with a dummy number
22498 !! wikitext
22499 ISBN ---
22500 !! html
22501 <p>ISBN ---
22502 </p>
22503 !! end
22504
22505
22506 !! test
22507 ISBN with space-delimited number
22508 !! wikitext
22509 ISBN 92 9017 032 8
22510 !! html/php
22511 <p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a>
22512 </p>
22513 !! html/parsoid
22514 <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>
22515 !! end
22516
22517
22518 !! test
22519 ISBN with multiple spaces, no number
22520 !! wikitext
22521 ISBN foo
22522 !! html
22523 <p>ISBN foo
22524 </p>
22525 !! end
22526
22527
22528 !! test
22529 ISBN length
22530 !! wikitext
22531 ISBN 123456789
22532
22533 ISBN 1234567890
22534
22535 ISBN 12345678901
22536 !! html/php
22537 <p>ISBN 123456789
22538 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
22539 </p><p>ISBN 12345678901
22540 </p>
22541 !! html/parsoid
22542 <p>ISBN 123456789</p>
22543
22544 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
22545
22546 <p>ISBN 12345678901</p>
22547 !! end
22548
22549
22550 !! test
22551 ISBN with trailing year (T9110)
22552 !! wikitext
22553 ISBN 1-234-56789-0 - 2006
22554
22555 ISBN 1 234 56789 0 - 2006
22556 !! html/php
22557 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006
22558 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006
22559 </p>
22560 !! html/parsoid
22561 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p>
22562
22563 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p>
22564 !! end
22565
22566
22567 !! test
22568 anchorencode
22569 !! config
22570 wgFragmentMode=[ 'html5', 'legacy' ]
22571 !! wikitext
22572 {{anchorencode:foo bar©#%n}}
22573 !! html/php
22574 <p>foo_bar©#%n
22575 </p>
22576 !! html/parsoid
22577 <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>
22578 !! end
22579
22580 !! test
22581 anchorencode (legacy)
22582 !! config
22583 wgFragmentMode=[ 'legacy' ]
22584 !! wikitext
22585 {{anchorencode:foo bar©#%n}}
22586 !! html/php
22587 <p>foo_bar.C2.A9.23.25n
22588 </p>
22589 !! end
22590
22591 !! test
22592 anchorencode trims spaces
22593 !! config
22594 wgFragmentMode=[ 'html5', 'legacy' ]
22595 !! wikitext
22596 {{anchorencode: __pretty__please__}}
22597 !! html/php
22598 <p>pretty_please
22599 </p>
22600 !! html/parsoid
22601 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: __pretty__please__","function":"anchorencode"},"params":{},"i":0}}]}'>pretty_please</p>
22602 !! end
22603
22604 !! test
22605 anchorencode deals with links
22606 !! config
22607 wgFragmentMode=[ 'html5', 'legacy' ]
22608 !! wikitext
22609 {{anchorencode: [[hello|world]] [[hi]]}}
22610 !! html/php
22611 <p>world_hi
22612 </p>
22613 !! html/parsoid
22614 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: [[hello|world]] [[hi]]","function":"anchorencode"},"params":{},"i":0}}]}'>world_hi</p>
22615 !! end
22616
22617 !! test
22618 anchorencode deals with templates
22619 !! config
22620 wgFragmentMode=[ 'html5', 'legacy' ]
22621 !! wikitext
22622 {{anchorencode: {{Foo}} x}}
22623 !! html/php
22624 <p>FOO_x
22625 </p>
22626 !! html/parsoid
22627 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: {{Foo}} x","function":"anchorencode"},"params":{},"i":0}}]}'>FOO_x</p>
22628 !! end
22629
22630 !! test
22631 anchorencode encodes like the TOC generator: (T20431)
22632 !! config
22633 wgFragmentMode=[ 'html5', 'legacy' ]
22634 !! wikitext
22635 ===_ +:.3A%3A _ &&amp;]] x===
22636 {{anchorencode: _ +:.3A%3A _ &&amp;]] x}}
22637 __NOEDITSECTION__
22638 !! html/php
22639 <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>
22640 <p>+:.3A%3A_&amp;&amp;&#93;&#93;_x
22641 </p>
22642 !! html/parsoid
22643 <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>
22644 <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>
22645 <meta property="mw:PageProp/noeditsection"/>
22646 !! end
22647
22648 !! test
22649 anchorencode encodes like the TOC generator: (T20431) (legacy)
22650 !! config
22651 wgFragmentMode=[ 'legacy' ]
22652 !! wikitext
22653 ===_ +:.3A%3A&&amp;]]===
22654 {{anchorencode: _ +:.3A%3A&&amp;]] }}
22655 __NOEDITSECTION__
22656 !! html/php
22657 <h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&amp;&amp;]]</span></h3>
22658 <p>.2B:.3A.253A.26.26.5D.5D
22659 </p>
22660 !! end
22661
22662 !! test
22663 T8200: blockquotes and paragraph formatting
22664 !! wikitext
22665 <blockquote>
22666 foo
22667 </blockquote>
22668
22669 bar
22670
22671 baz
22672 !! html
22673 <blockquote>
22674 <p>foo
22675 </p>
22676 </blockquote>
22677 <p>bar
22678 </p>
22679 <pre>baz
22680 </pre>
22681 !! end
22682
22683 !! test
22684 T10293: Use of center tag ruins paragraph formatting
22685 !! wikitext
22686 <center>
22687 foo
22688 </center>
22689
22690 bar
22691
22692 baz
22693 !! html
22694 <center>
22695 <p>foo
22696 </p>
22697 </center>
22698 <p>bar
22699 </p>
22700 <pre>baz
22701 </pre>
22702 !! end
22703
22704 !!test
22705 Parsing of overlapping (improperly nested) inline html tags
22706 !! wikitext
22707 <span><s>x</span></s>
22708 !! html/php
22709 <p><span><s>x&lt;/span&gt;</s></span>
22710 </p>
22711 !! html/parsoid
22712 <p><span><s>x</s></span>
22713 </p>
22714 !!end
22715
22716 ###
22717 ### Language variants related tests
22718 ###
22719
22720 # Parsoid does not mark self-links.
22721 # Parsoid does not convert links; PHP will do any necessary redirects.
22722
22723 !! test
22724 Self-link in language variants
22725 !! options
22726 title=[[Dunav]] language=sr
22727 !! wikitext
22728 Both [[Dunav]] and [[Дунав]] are names for this river.
22729 !! html/php
22730 <p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
22731 </p>
22732 !! html/parsoid
22733 <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>
22734 !! end
22735
22736 !! article
22737 Дуна
22738 !! text
22739 content
22740 !! endarticle
22741
22742 !! test
22743 Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
22744 !! options
22745 title=[[Duna]] language=sr
22746 !! wikitext
22747 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
22748 !! html/php
22749 <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.
22750 </p>
22751 !! html/parsoid
22752 <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>
22753 !! end
22754
22755 !! test
22756 Link to a section of a variant of this title shouldn't be parsed as self-link
22757 !! options
22758 title=[[Duna]] language=sr
22759 !! wikitext
22760 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
22761 !! html/php
22762 <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.
22763 </p>
22764 !! html/parsoid
22765 <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>
22766 !! end
22767
22768 !! test
22769 Link to pages in language variants
22770 !! options
22771 language=sr
22772 !! wikitext
22773 Main Page can be written as [[Маин Паге]]
22774 !! html/php
22775 <p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>
22776 </p>
22777 !! html/parsoid
22778 <p>Main Page can be written as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a></p>
22779 !! end
22780
22781
22782 !! test
22783 Multiple links to pages in language variants
22784 !! options
22785 language=sr
22786 !! wikitext
22787 [[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
22788 !! html/php
22789 <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>.
22790 </p>
22791 !! html/parsoid
22792 <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>
22793 !! end
22794
22795
22796 !! test
22797 Simple template in language variants
22798 !! options
22799 language=sr
22800 !! wikitext
22801 {{тест}}
22802 !! html/php
22803 <p>This is a test template
22804 </p>
22805 !! end
22806
22807
22808 !! test
22809 Template with explicit namespace in language variants
22810 !! options
22811 language=sr
22812 !! wikitext
22813 {{Template:тест}}
22814 !! html/php
22815 <p>This is a test template
22816 </p>
22817 !! end
22818
22819
22820 !! test
22821 Basic test for template parameter in language variants
22822 !! options
22823 language=sr
22824 !! wikitext
22825 {{парамтест|param=foo}}
22826 !! html/php
22827 <p>This is a test template with parameter foo
22828 </p>
22829 !! end
22830
22831 !! test
22832 Simple category in language variants
22833 !! options
22834 language=sr cat
22835 !! wikitext
22836 [[Category:МедиаWики Усер'с Гуиде]]
22837 !! html/php
22838 cat=МедиаWики_Усер'с_Гуиде sort=
22839 !! html/parsoid
22840 <link rel="mw:PageProp/Category" href="./Категорија:МедиаWики_Усер'с_Гуиде" data-parsoid='{"stx":"simple","a":{"href":"./Категорија:МедиаWики_Усер&#39;с_Гуиде"},"sa":{"href":"Category:МедиаWики Усер&#39;с Гуиде"}}'/>
22841 !! end
22842
22843 !! article
22844 Category:分类
22845 !! text
22846 blah
22847 !! endarticle
22848
22849 !! article
22850 Category:分類
22851 !! text
22852 blah
22853 !! endarticle
22854
22855 ## We used to, but no longer wt2wt this test since the default serializer
22856 ## will normalize all categories to serialize on their own line.
22857 ## This wikitext usage is going to be fairly uncommon in production and
22858 ## selser will take care of preserving formatting in those scenarios.
22859 !! test
22860 Don't convert blue categorylinks to another variant (T35210)
22861 !! options
22862 cat
22863 language=zh
22864 parsoid=wt2html
22865 !! wikitext
22866 [[A]][[Category:分类]]
22867 !! html/php
22868 cat=分类 sort=
22869 !! html/parsoid
22870 <p><a rel="mw:WikiLink" href="./A" title="A">A</a></p>
22871 <link rel="mw:PageProp/Category" href="./Category:分类"/>
22872 !! end
22873
22874 !! test
22875 Stripping -{}- tags (language variants)
22876 !! options
22877 language=sr
22878 !! wikitext
22879 Latin proverb: -{Ne nuntium necare}-
22880 !! html/php
22881 <p>Latin proverb: Ne nuntium necare
22882 </p>
22883 !! html/parsoid
22884 <p>Latin proverb: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22885 !! end
22886
22887
22888 !! test
22889 Prevent conversion with -{}- tags (language variants)
22890 !! options
22891 language=sr variant=sr-ec
22892 !! wikitext
22893 Latinski: -{Ne nuntium necare}-
22894 !! html/php
22895 <p>Латински: Ne nuntium necare
22896 </p>
22897 !! html/parsoid
22898 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22899 !! end
22900
22901
22902 !! test
22903 Prevent conversion of text with -{}- tags (language variants)
22904 !! options
22905 language=sr variant=sr-ec
22906 !! wikitext
22907 Latinski: -{Ne nuntium necare}-
22908 !! html/php
22909 <p>Латински: Ne nuntium necare
22910 </p>
22911 !! html/parsoid
22912 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22913 !! end
22914
22915
22916 !! test
22917 Prevent conversion of links with -{}- tags (language variants)
22918 !! options
22919 language=sr variant=sr-ec
22920 !! wikitext
22921 -{[[Main Page]]}-
22922 !! html/php
22923 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
22924 </p>
22925 !! html/parsoid
22926 <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>
22927 !! end
22928
22929
22930 !! test
22931 -{}- tags within headlines (within html for parserConvert())
22932 !! config
22933 wgFragmentMode=[ 'html5', 'legacy' ]
22934 !! options
22935 language=sr variant=sr-ec
22936 !! wikitext
22937 ==-{Naslov}-==
22938
22939 Note that even an unprotected headline ID is not affected by language
22940 conversion:
22941
22942 ==Latinski==
22943 !! html/php
22944 <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>
22945 <p>Ноте тхат евен ан унпротецтед хеадлине ИД ис нот аффецтед бy лангуаге
22946 цонверсион:
22947 </p>
22948 <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>
22949
22950 !! html/parsoid
22951 <h2 id="-{Naslov}-"><span id="-.7BNaslov.7D-" typeof="mw:FallbackId"></span><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Naslov"}}'></span></h2>
22952
22953 <p>Note that even an unprotected headline ID is not affected by language
22954 conversion:</p>
22955
22956 <h2 id="Latinski">Latinski</h2>
22957 !! end
22958
22959 !! test
22960 Explicit definition of language variant alternatives
22961 !! options
22962 language=zh variant=zh-tw
22963 !! wikitext
22964 -{zh:China;zh-tw:Taiwan}-, not China
22965 !! html/php
22966 <p>Taiwan, not China
22967 </p>
22968 !! html/parsoid
22969 <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>
22970 !! end
22971
22972 !! test
22973 Filter syntax for language variants
22974 !! options
22975 language=zh variant=zh-tw
22976 !! wikitext
22977 foo-{zh;zh-hans;zh-hant|blog, WEBJOURNAL, WEBLOG}-quux
22978 !! html/php
22979 <p>fooblog, WEBJOURNAL, WEBLOGquux
22980 </p>
22981 !! html/parsoid
22982 <p>foo<span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"blog, WEBJOURNAL, WEBLOG"}}'></span>quux</p>
22983 !! end
22984
22985 # Note that Parsoid post-processing for language variants needs to
22986 # update the `title` attribute here, based on the mw:ExpandedAttrs property
22987 !! test
22988 Conversion around HTML tags
22989 !! options
22990 language=sr variant=sr-ec
22991 !! wikitext
22992 -{H|span=>sr-ec:script;title=>sr-ec:src}-
22993 <span title="La-{sr-el:L;sr-ec:C}-tin">ski</span>
22994 !! html/php
22995 <p>
22996 <span title="ЛаCтин">ски</span>
22997 </p>
22998 !! html/parsoid
22999 <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"}]}'/>
23000 <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>
23001 !! end
23002
23003 !! test
23004 Explicit session-wise two-way language variant mapping (A flag and - flag)
23005 !! options
23006 language=zh variant=zh-tw
23007 !! wikitext
23008 This is -{zh:China; zh-tw:Taiwan}-, but we'll forget that now.
23009
23010 Taiwan is not China.
23011
23012 But -{A|zh:China; zh-tw:Taiwan}- is China,
23013
23014 (This-{-|zh:China; zh-tw:Taiwan}- should be stripped!)
23015
23016 and -{China}- is China.
23017 !! html/php
23018 <p>This is Taiwan, but we'll forget that now.
23019 </p><p>Taiwan is not China.
23020 </p><p>But Taiwan is Taiwan,
23021 </p><p>(This should be stripped!)
23022 </p><p>and China is China.
23023 </p>
23024 !! html/parsoid
23025 <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>
23026 <p>Taiwan is not China.</p>
23027 <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>
23028 <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>
23029 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"China"}}'></span> is China.</p>
23030 !! end
23031
23032 !! test
23033 Explicit session-wise one-way language variant mapping (A flag and - flag)
23034 !! options
23035 language=zh variant=zh-tw
23036 !! wikitext
23037 This is -{COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}-, but we'll forget that now.
23038
23039 COUNTRY is China or Taiwan.
23040
23041 But -{A|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- is COUNTRY,
23042
23043 (This-{-|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
23044
23045 and -{COUNTRY}- is COUNTRY.
23046 !! html/php
23047 <p>This is Taiwan, but we'll forget that now.
23048 </p><p>COUNTRY is China or Taiwan.
23049 </p><p>But Taiwan is Taiwan,
23050 </p><p>(This should be stripped!)
23051 </p><p>and COUNTRY is COUNTRY.
23052 </p>
23053 !! html/parsoid
23054 <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>
23055 <p>COUNTRY is China or Taiwan.</p>
23056 <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>
23057 <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>
23058 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"COUNTRY"}}'></span> is COUNTRY.</p>
23059 !! end
23060
23061 !! test
23062 Explicit session-wise two-way language variant mapping (H flag for hide)
23063 !! options
23064 language=zh variant=zh-tw
23065 !! wikitext
23066 (This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
23067
23068 Taiwan is China.
23069 !! html/php
23070 <p>(This should be stripped!)
23071 </p><p>Taiwan is Taiwan.
23072 </p>
23073 !! html/parsoid
23074 <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>
23075 <p>Taiwan is China.</p>
23076 !! end
23077
23078 !! test
23079 Explicit session-wise one-way language variant mapping (H flag for hide)
23080 !! options
23081 language=zh variant=zh-tw
23082 !! wikitext
23083 (This-{H|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
23084
23085 COUNTRY is Taiwan or China.
23086 !! html/php
23087 <p>(This should be stripped!)
23088 </p><p>Taiwan is Taiwan or China.
23089 </p>
23090 !! html/parsoid
23091 <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>
23092 <p>COUNTRY is Taiwan or China.</p>
23093 !! end
23094
23095 ## Note that parsoid test runner does not support 'showtitle' option.
23096 !! test
23097 Adding explicit conversion rule for title (T flag)
23098 !! options
23099 language=zh variant=zh-tw showtitle
23100 !! wikitext
23101 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
23102
23103 Taiwan is China.
23104 !! html/php
23105 Taiwan
23106 <p>Should be stripped!
23107 </p><p>Taiwan is China.
23108 </p>
23109 !! html/parsoid
23110 <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>
23111 <p>Taiwan is China.</p>
23112 !! end
23113
23114 !! test
23115 Code coverage: T combined with H flag
23116 !! options
23117 language=zh variant=zh-tw showtitle
23118 !! wikitext
23119 Should be stripped-{T;H|zh:China; zh-tw:Taiwan}-!
23120
23121 Taiwan is China.
23122 !! html/php
23123 Taiwan
23124 <p>Should be stripped!
23125 </p><p>Taiwan is Taiwan.
23126 </p>
23127 !! html/parsoid
23128 <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>
23129 <p>Taiwan is China.</p>
23130 !! end
23131
23132 !! test
23133 Code coverage: T with no variants
23134 !! options
23135 language=zh variant=zh-tw showtitle
23136 !! wikitext
23137 -{H|zh:China; zh-tw:Taiwan}-
23138 Taiwan is China.-{T|Taiwan is China}-
23139 !! html/php
23140 Taiwan is China
23141 <p>
23142 Taiwan is Taiwan.
23143 </p>
23144 !! html/parsoid
23145 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
23146 Taiwan is China.<meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Taiwan is China"},"title":true}'/></p>
23147 !! end
23148
23149 !! test
23150 Code coverage: rules with no variants
23151 !! options
23152 language=zh variant=zh-tw
23153 !! wikitext
23154 -{H|zh:China; zh-tw:Taiwan}-
23155 Taiwan is China.
23156 -{H|China}-
23157 Taiwan is China.
23158 !! html/php
23159 <p>
23160 Taiwan is Taiwan.
23161
23162 Taiwan is China.
23163 </p>
23164 !! html/parsoid
23165 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
23166 Taiwan is China.
23167 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":"China"}]}'/>
23168 Taiwan is China.</p>
23169 !! end
23170
23171
23172 !! test
23173 Code coverage: D flag for conversion rule
23174 !! options
23175 language=zh variant=zh-tw
23176 !! wikitext
23177 -{D|zh-cn:XA; zh-tw:YA}-
23178 -{A;D|zh-cn:XB; zh-tw:YB}-
23179 -{D;H|zh-cn:XC; zh-tw:YC}-
23180
23181 -{D;H|FOO=>zh-tw:BAR;FOO=>zh-cn:BAT}-
23182
23183 -{D|0=>zh-tw:1}-
23184 -{A;D|2=>zh-tw:3}-
23185 -{D;H|4=>zh-tw:5}-
23186
23187 XA XB XC YA YB YC FOO BAR BAT 012345
23188 !! html/php
23189 <p>大陆:XA;台灣:YA;
23190
23191 大陆:XC;台灣:YC;
23192 </p><p>FOO⇒台灣:BAR;FOO⇒大陆:BAT;
23193 </p><p>0⇒台灣:1;
23194
23195 4⇒台灣:5;
23196 </p><p>XA YB YC YA YB YC BAR BAR BAT 013355
23197 </p>
23198 !! html/parsoid
23199 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"twoway":[{"l":"zh-cn","t":"XA"},{"l":"zh-tw","t":"YA"}]}'></span>
23200 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XB"},{"l":"zh-tw","t":"YB"}]}'/>
23201 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XC"},{"l":"zh-tw","t":"YC"}]}'></span></p>
23202 <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>
23203 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"oneway":[{"f":"0","l":"zh-tw","t":"1"}]}'></span>
23204 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"2","l":"zh-tw","t":"3"}]}'/>
23205 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"4","l":"zh-tw","t":"5"}]}'></span></p>
23206 <p>XA XB XC YA YB YC FOO BAR BAT 012345</p>
23207 !! end
23208
23209 !! test
23210 Code coverage: N flag for conversion rule
23211 !! options
23212 language=zh variant=zh-cn
23213 !! wikitext
23214 -{N|zh-cn}-
23215
23216 -{N|zh-tw}-
23217
23218 -{N|sr-ec}-
23219 !! html/php
23220 <p>大陆
23221 </p><p>台灣
23222 </p><p>српски (ћирилица)‎
23223 </p>
23224 !! html/parsoid
23225 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-cn"}}'></span></p>
23226 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-tw"}}'></span></p>
23227 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"sr-ec"}}'></span></p>
23228 !! end
23229
23230 # html2wt suppresses the bogus 'D' flag, so this is wt2html only
23231 !! test
23232 Code coverage: N flag for conversion rule (wt2html only)
23233 !! options
23234 language=zh variant=zh-cn
23235 parsoid=wt2html,html2html
23236 !! wikitext
23237 -{D;N|en}-
23238 !! html/php
23239 <p>English
23240 </p>
23241 !! html/parsoid
23242 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"en"}}' data-parsoid='{"fl":["D","N"]}'></span></p>
23243 !! end
23244
23245 !! test
23246 Testing that changing the language variant here in the tests actually works
23247 !! options
23248 language=zh variant=zh showtitle
23249 !! wikitext
23250 Should be stripped-{T|zh:China; zh-tw:Taiwan}-!
23251 !! html/php
23252 China
23253 <p>Should be stripped!
23254 </p>
23255 !! html/parsoid
23256 <p>Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
23257 !! end
23258
23259 !! test
23260 Recursive conversion of alt and title attrs shouldn't clear converter state
23261 !! options
23262 language=zh variant=zh-cn
23263 showtitle
23264 !! wikitext
23265 -{H|zh-cn:Exclamation; zh-tw:exclamation}-
23266 Should be stripped-{T|zh-cn:China; zh-tw:Taiwan}-<span title="exclamation">!</span>
23267 !! html/php
23268 China
23269 <p>
23270 Should be stripped<span title="Exclamation">!</span>
23271 </p>
23272 !! html/parsoid
23273 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh-cn","t":"Exclamation"},{"l":"zh-tw","t":"exclamation"}]}'/>
23274 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>
23275 !! end
23276
23277 !! test
23278 T26072: more test on conversion rule for title
23279 !! options
23280 language=zh variant=zh-tw showtitle
23281 !! wikitext
23282 This should be stripped-{T|zh:China; zh-tw:Taiwan}-!
23283
23284 This won't take interferes with the title rule-{H|zh:Beijing; zh-tw:Taipei}-.
23285 !! html/php
23286 Taiwan
23287 <p>This should be stripped!
23288 </p><p>This won't take interferes with the title rule.
23289 </p>
23290 !! html/parsoid
23291 <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>
23292 <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>
23293 !! end
23294
23295 !! test
23296 Partly disable title conversion if variant == main language code
23297 !! options
23298 language=zh variant=zh title=[[ZH]] showtitle
23299 !! wikitext
23300 -{T|zh-cn:CN;zh-tw:TW}-
23301 !! html/php
23302 ZH
23303 <p>
23304 </p>
23305 !! html/parsoid
23306 <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>
23307 !! end
23308
23309 !! test
23310 Partly disable title conversion if variant == main language code, more
23311 !! options
23312 language=zh variant=zh title=[[ZH]] showtitle
23313 !! wikitext
23314 -{T|TW}-
23315 !! html/php
23316 ZH
23317 <p>
23318 </p>
23319 !! html/parsoid
23320 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"TW"},"title":true}'/></p>
23321 !! end
23322
23323 !! test
23324 Raw output of variant escape tags (R flag)
23325 !! options
23326 language=zh variant=zh-tw
23327 !! wikitext
23328 Raw: -{R|zh:China;zh-tw:Taiwan}-
23329 !! html/php
23330 <p>Raw: zh:China;zh-tw:Taiwan
23331 </p>
23332 !! html/parsoid
23333 <p>Raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"zh:China;zh-tw:Taiwan"}}'></span></p>
23334 !! end
23335
23336 # html2wt suppresses the bogus 'D' flags, so this is wt2html only
23337 !! test
23338 Raw output of variant escape tags (R flag) (wt2html only)
23339 !! options
23340 language=zh variant=zh-tw
23341 parsoid=wt2html,html2html
23342 !! wikitext
23343 -{Variant}- -{D|syntax}- -{D;R|options}-
23344 !! html/php
23345 <p>Variant syntax options
23346 </p>
23347 !! html/parsoid
23348 <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>
23349 !! end
23350
23351 !! test
23352 Nested markup inside raw output of variant escape tags (R flag)
23353 !! options
23354 language=zh variant=zh-tw
23355 !! wikitext
23356 Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
23357 !! html/php
23358 <p>Nested raw: nested Taiwan nested
23359 </p>
23360 !! html/parsoid
23361 <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>
23362 !! end
23363
23364 !! test
23365 Nested markup and spaces inside raw output of variant escape tags (R flag)
23366 !! options
23367 language=zh variant=zh-tw
23368 !! wikitext
23369 X-{ outer -{ inner }- outer }-X
23370 !! html/php
23371 <p>X outer inner outer X
23372 </p>
23373 !! html/parsoid
23374 <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>
23375 !! end
23376
23377 !! test
23378 Templates inside raw output of variant escape tags (R flag)
23379 !! options
23380 language=zh variant=zh-tw
23381 !! wikitext
23382 Nested raw: -{R|nested {{echo|hi}} templates}-
23383 !! html/php
23384 <p>Nested raw: nested hi templates
23385 </p>
23386 !! html/parsoid
23387 <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>
23388 !! end
23389
23390 !! test
23391 Strings evaluating false shouldn't be ignored by Language converter (T51072)
23392 !! options
23393 language=zh variant=zh-cn
23394 !! wikitext
23395 -{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
23396 !! html/php
23397 <p>0
23398 </p>
23399 !! html/parsoid
23400 <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>
23401 !! end
23402
23403 !! test
23404 Conversion rules from [numeric-only string] to [something else] (T48634)
23405 !! options
23406 language=zh variant=zh-cn
23407 !! wikitext
23408 -{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
23409 !! html/php
23410 <p>D12345EE12345
23411 </p>
23412 !! html/parsoid
23413 <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>
23414 !! end
23415
23416 !! test
23417 Two-way converter rule entries with an empty value should be ignored (T53551)
23418 !! options
23419 language=zh variant=zh-cn
23420 !! wikitext
23421 -{H|zh-cn:foo;zh-tw:;}-foobar
23422 !! html/php
23423 <p>foobar
23424 </p>
23425 !! html/parsoid
23426 <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>
23427 !! end
23428
23429 !! test
23430 One-way converter rule entries with an empty "from" string should be ignored (T53551)
23431 !! options
23432 language=zh variant=zh-cn
23433 !! wikitext
23434 -{H|=>zh-cn:foo;}-foobar
23435 !! html/php
23436 <p>foobar
23437 </p>
23438 !! html/parsoid
23439 <p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[5]}' data-mw-variant='{"add":true,"oneway":[{"f":"","l":"zh-cn","t":"foo"}]}'/>foobar</p>
23440 !! end
23441
23442 !! test
23443 Empty converter rule entries shouldn't be inserted into the conversion table (T53551)
23444 !! options
23445 language=zh variant=zh-cn
23446 !! wikitext
23447 -{H|}-foobar
23448 !! html/php
23449 <p>foobar
23450 </p>
23451 !! html/parsoid
23452 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":""}]}'/>foobar</p>
23453 !! end
23454
23455 !! test
23456 Nested using of manual convert syntax
23457 !! options
23458 language=zh variant=zh-hk
23459 !! wikitext
23460 Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
23461 !! html/php
23462 <p>Nested: Hello Hong Kong!
23463 </p>
23464 !! html/parsoid
23465 <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>
23466 !! end
23467
23468 !! test
23469 HTML markups with conversion syntax in attribs, nested in other conversion blocks
23470 !! options
23471 language=zh variant=zh-cn
23472 !! wikitext
23473 -{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}-
23474 !! html/php
23475 <p><span title="X">A</span>
23476 </p>
23477 !! html/parsoid
23478 <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>
23479 !! end
23480
23481 !! test
23482 HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet in PHP parser)
23483 !! options
23484 language=zh variant=zh-cn
23485 !! wikitext
23486 -{<span title="-{X}-">A</span>}-
23487 !! html/php+disabled
23488 <p><span title="X">A</span>
23489 </p>
23490 !! html/parsoid
23491 <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>
23492 !! end
23493
23494 # Parsoid and PHP disagree on how to parse this example: Parsoid
23495 # insists that the content of a language converter element be a valid
23496 # DOM fragment or attribute string
23497 !! test
23498 Language converter markup with block content
23499 !! options
23500 language=zh variant=zh-cn
23501 !! wikitext
23502 <span>a-{b<div>c}-d
23503
23504 <span>a-{zh;zh-hans;zh-hant|b<div>c}-d
23505
23506 <span>a-{H|0=>zh-cn:x<span>y;0=>zh-tw:b<div>c}-d
23507 !! html/php+tidy
23508 <span>ab<div>cd
23509 <span>ab<div>cd
23510 <span>ad
23511 </span></div></span></div></span>
23512 !! html/parsoid
23513 <span data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a<div typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"b&lt;div data-parsoid=&apos;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[10,16,5,0]}&apos;>c&lt;/div>"}}'></div>d
23514
23515 <span data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a<div typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"b&lt;div data-parsoid=&apos;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[50,56,5,0]}&apos;>c&lt;/div>"}}'></div>d
23516
23517 <p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a<meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"0","l":"zh-cn","t":"x&lt;span data-parsoid=&apos;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[82,89,6,0]}&apos;>y&lt;/span>"},{"f":"0","l":"zh-tw","t":"b&lt;div data-parsoid=&apos;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[100,106,5,0]}&apos;>c&lt;/div>"}]}'/>d</span></p></span></span>
23518 !! end
23519
23520 !! test
23521 LanguageConverter selser (1)
23522 !! options
23523 language=zh variant=zh-cn
23524 parsoid={
23525 "modes": ["wt2wt", "selser"],
23526 "changes": [
23527 ["span[typeof]", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
23528 ]
23529 }
23530 !! wikitext
23531 -{raw}-
23532 !! wikitext/edited
23533 -{edited}-
23534 !! end
23535
23536 !! test
23537 LanguageConverter selser (2)
23538 !! options
23539 language=zh variant=zh-cn
23540 parsoid={
23541 "modes": ["wt2wt", "selser"],
23542 "changes": [
23543 ["span[class='x']", "contents", "text", "-{foo}-"],
23544 ["a", "contents", "text", "-{"],
23545 ["span[typeof]", "attr", "data-mw", "{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"-{\"}},\"i\":0}}]}"]
23546 ]
23547 }
23548 !! wikitext
23549 <span class="x">TEXT1</span>
23550 [http://example.com TEXT2]
23551 [[Foo|TEXT3]]
23552 {{echo|TEXT4}}
23553 !! wikitext/edited
23554 <span class="x"><nowiki>-{foo}-</nowiki></span>
23555 [http://example.com -{]
23556 [[Foo|<nowiki>-{</nowiki>]]
23557 {{1x|<nowiki>-{</nowiki>}}
23558 !! end
23559
23560 # Tests LanguageVariantText in ConstrainedText
23561 !! test
23562 LanguageConverter selser (3)
23563 !! options
23564 language=zh variant=zh-cn
23565 parsoid={
23566 "modes": ["wt2wt", "selser"],
23567 "changes": [
23568 ["td > span", "attr", "typeof", "mw:LanguageVariant"],
23569 ["td > span", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
23570 ]
23571 }
23572 !! wikitext
23573 {|
23574 |-
23575 |<span>Foo</span>
23576 |}
23577 !! wikitext/edited
23578 {|
23579 |-
23580 |<nowiki/>-{edited}-
23581 |}
23582 !! end
23583
23584 # Tests LanguageVariantText._fromSelSer
23585 !! test
23586 LanguageConverter selser (4)
23587 !! options
23588 language=zh variant=zh-cn
23589 parsoid={
23590 "modes": ["wt2wt", "selser"],
23591 "changes": [
23592 ["td > span.x", "remove"]
23593 ]
23594 }
23595 !! wikitext
23596 {|
23597 |-
23598 |<span class="x">Foo</span>-{Bar}-
23599 ||<span class="x">Foo</span>-{Bar}-
23600 |}
23601 !! wikitext/edited
23602 {|
23603 |-
23604 |<nowiki/>-{Bar}-
23605 ||-{Bar}-
23606 |}
23607 !! end
23608
23609 # Since Parsoid is starting to emit canonical wikitext for links,
23610 # [http://example.com http://example.com] will not RT back to that
23611 # form anymore.
23612 # Parsoid does not language-convert links (it is done in a
23613 # post-processing step)
23614 !! test
23615 Proper conversion of text in external links
23616 !! options
23617 language=sr variant=sr-ec
23618 parsoid=wt2html
23619 !! wikitext
23620 http://www.google.com
23621 gopher://www.google.com
23622 [http://www.google.com http://www.google.com]
23623 [gopher://www.google.com gopher://www.google.com]
23624 [https://www.google.com irc://www.google.com]
23625 [ftp://www.google.com www.google.com/ftp://dir]
23626 [//www.google.com www.google.com]
23627 !! html/php
23628 <p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
23629 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
23630 <a rel="nofollow" class="external text" href="http://www.google.com">http://www.google.com</a>
23631 <a rel="nofollow" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
23632 <a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
23633 <a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
23634 <a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
23635 </p>
23636 !! html/parsoid
23637 <p><a rel="mw:ExtLink" class="external free" href="http://www.google.com">http://www.google.com</a>
23638 <a rel="mw:ExtLink" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
23639 <a rel="mw:ExtLink" class="external text" href="http://www.google.com">http://www.google.com</a>
23640 <a rel="mw:ExtLink" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
23641 <a rel="mw:ExtLink" class="external text" href="https://www.google.com">irc://www.google.com</a>
23642 <a rel="mw:ExtLink" class="external text" href="ftp://www.google.com">www.google.com/ftp://dir</a>
23643 <a rel="mw:ExtLink" class="external text" href="//www.google.com">www.google.com</a></p>
23644 !! end
23645
23646 !! test
23647 Do not convert roman numbers to language variants
23648 !! options
23649 language=sr variant=sr-ec
23650 !! wikitext
23651 Fridrih IV je car.
23652 !! html/php
23653 <p>Фридрих IV је цар.
23654 </p>
23655 !! html/parsoid
23656 <p>Fridrih IV je car.</p>
23657 !! end
23658
23659 !! test
23660 Unclosed language converter markup "-{"
23661 !! options
23662 language=sr
23663 !! wikitext
23664 -{T|hello
23665 !! html
23666 <p>-{T|hello
23667 </p>
23668 !! end
23669
23670 !! test
23671 Don't convert raw rule "-{R|=&gt;}-" to "=>"
23672 !! options
23673 language=sr
23674 !! wikitext
23675 -{R|=&gt;}-
23676 !! html/php
23677 <p>=&gt;
23678 </p>
23679 !! html/parsoid
23680 <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>
23681 !!end
23682
23683 !! test
23684 Don't break link parsing if language converter markup is in the caption.
23685 !! options
23686 language=sr variant=sr-ec
23687 !! wikitext
23688 [[Main Page|-{R|main page}-]]
23689 !! html/php
23690 <p><a href="/wiki/Main_Page" title="Маин Паге">main page</a>
23691 </p>
23692 !! html/parsoid
23693 <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>
23694 !! end
23695
23696 !! test
23697 T146304: Don't break template parsing if language converter markup is in the parameter.
23698 !! options
23699 language=sr variant=sr-ec
23700 !! wikitext
23701 {{echo|-{R|foo}-}}
23702 !! html/php
23703 <p>foo
23704 </p>
23705 !! html/parsoid
23706 <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>
23707 !! end
23708
23709 !! test
23710 T146305: Don't break image parsing if language converter markup is in the caption.
23711 !! options
23712 language=sr
23713 !! wikitext
23714 [[Датотека:Foobar.jpg|thumb|-{R|caption:}-]]
23715 !! html/php
23716 <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>
23717
23718 !! html/parsoid
23719 <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>
23720 !! end
23721
23722 !! test
23723 T146305: Don't break image parsing if nested language converter markup is in the caption.
23724 !! options
23725 language=zh variant=zh-cn
23726 !! wikitext
23727 [[File:Foobar.jpg|thumb|-{|zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
23728 !! html/php
23729 <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>
23730
23731 !! html/parsoid
23732 <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>
23733 !! end
23734
23735 # XXX html2wt disabled because rich markup in alt is not preserved.
23736 !! test
23737 Don't break gallery if language converter markup is inside.
23738 !! options
23739 language=zh
23740 !! wikitext
23741 <gallery>
23742 File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-
23743 File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt
23744 </gallery>
23745 !! html/php
23746 <ul class="gallery mw-gallery-traditional">
23747 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
23748 <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>
23749 <div class="gallerytext">
23750 <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>
23751 </p>
23752 </div>
23753 </div></li>
23754 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
23755 <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>
23756 <div class="gallerytext">
23757 <p>This is a test template
23758 </p>
23759 </div>
23760 </div></li>
23761 </ul>
23762
23763 !! html/parsoid
23764 <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"}}'>
23765 <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>
23766 <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>
23767 </ul>
23768 !! end
23769
23770 !! test
23771 T153135: Don't break list handling if language converter markup is in the item.
23772 !! options
23773 language=zh variant=zh-cn
23774 !! wikitext
23775 ;-{zh-cn:AAA;zh-tw:BBB}-
23776 ;-{R|foo:bar}-
23777 !! html/php
23778 <dl><dt>AAA</dt>
23779 <dt>foo:bar</dt></dl>
23780
23781 !! html/parsoid
23782 <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>
23783 <dt data-parsoid='{"dsr":[25,39,1,0]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"foo:bar"}}'></span></dt>
23784 </dl>
23785 !! end
23786
23787 // Note that parsoid does not protect colons unless language converter
23788 // markup is properly nested, because it is a backtracking parser.
23789 !! test
23790 T153135: Unclosed markup in definition list (code coverage)
23791 !! options
23792 language=zh variant=zh-cn
23793 !! wikitext
23794 ;<b>foo:bar
23795 ;-{zh-cn:AAA
23796 !! html/php+tidy
23797 <dl><dt><b>foo:bar</b></dt><b>
23798 <dt>-{zh-cn:AAA</dt></b></dl><p><b>
23799 </b></p>
23800 !! html/parsoid
23801 <dl><dt data-parsoid='{}'><b data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo:bar</b></dt><b data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
23802 <dt data-parsoid='{}'>-{zh-cn</dt><dd data-parsoid='{"stx":"row"}'>AAA</dd></b></dl>
23803 !! end
23804
23805 !! test
23806 T153135: Nested language converter markup in definition list (code coverage)
23807 !! options
23808 language=zh variant=zh-cn
23809 !! wikitext
23810 ;-{|zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
23811 !! html/php
23812 <dl><dt>AAA foo:bar bat:baz</dt>
23813 <dd>def</dd></dl>
23814
23815 !! html/parsoid
23816 <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>
23817 <dd data-parsoid='{"stx":"row","dsr":[49,53,1,0]}'>def</dd>
23818 </dl>
23819 !! end
23820
23821 # html2wt mode disabled due to <nowiki> insertion.
23822 !! test
23823 T153140: Don't break table handling if language converter markup is in the cell.
23824 !! options
23825 language=sr variant=sr-ec
23826 parsoid=wt2html,wt2wt,html2html
23827 !! wikitext
23828 {|
23829 |-
23830 | -{R|B}-
23831 |}
23832 !! html/php
23833 <table>
23834
23835 <tr>
23836 <td>B
23837 </td></tr></table>
23838
23839 !! html/parsoid
23840 <table>
23841 <tbody>
23842 <tr>
23843 <td><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"B"}}'></span></td>
23844 </tr>
23845 </tbody>
23846 </table>
23847 !! end
23848
23849 !! test
23850 Language converter tricky html2wt cases (1)
23851 !! options
23852 language=sr
23853 parsoid=html2wt,wt2wt
23854 !! html/parsoid
23855 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"}-"}}'></span></p>
23856 !! wikitext
23857 -{<nowiki>}-</nowiki>}-
23858 !! html/php
23859 <p>&#125;-
23860 </p>
23861 !! end
23862
23863 !! test
23864 Language converter tricky html2wt cases (2)
23865 !! options
23866 language=sr
23867 parsoid=html2wt,wt2wt
23868 !! html/parsoid
23869 <p>-{foo}-</p>
23870 !! wikitext
23871 <nowiki>-{foo}-</nowiki>
23872 !! html/php
23873 <p>-&#123;foo&#125;-
23874 </p>
23875 !! end
23876
23877 !! test
23878 Language converter tricky html2wt cases (3)
23879 !! options
23880 language=sr
23881 parsoid=html2wt,wt2wt
23882 !! html/parsoid
23883 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"|"}}'></span></p>
23884 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"R|raw"}}'></span></p>
23885 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"-{foo}-"}}'></span></p>
23886 !! wikitext
23887 -{R||}-
23888
23889 -{R|R|raw}-
23890
23891 -{<nowiki>-{foo}-</nowiki>}-
23892 !! html/php
23893 <p>|
23894 </p><p>R|raw
23895 </p><p>-&#123;foo&#125;-
23896 </p>
23897 !! end
23898
23899 !! test
23900 Language converter tricky html2wt cases (4)
23901 !! options
23902 language=sr
23903 parsoid=html2wt,wt2wt
23904 !! html/parsoid
23905 <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>
23906 !! wikitext
23907 -{R|{{echo|hey}}}-
23908 !! html/php
23909 <p>hey
23910 </p>
23911 !! end
23912
23913 # Note that the <nowiki> escaping added by parsoid for source text,
23914 # destination text, and language names only works on the PHP side
23915 # for *destination text*. (HTML entity escaping wouldn't work
23916 # any better.) This is probably a bug, at least for source texts.
23917 # (For language names PHP uses a precise regexp based on the languages
23918 # it currently knows have variants, which is fragile since this set
23919 # can grow/shrink over time.)
23920 !! test
23921 Language converter tricky html2wt cases (5)
23922 !! options
23923 language=zh variant=zh-cn
23924 !! html/parsoid
23925 <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>
23926 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"A","l":"bo:g;us","t":"B"}]}'/></p>
23927 <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>
23928 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"bo:g;us","t":"xyz"},{"l":"zh-cn","t":"abc"}]}'></span></p>
23929 <p>a:b=>c xyz</p>
23930 !! wikitext
23931 -{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
23932
23933 -{H|A=><nowiki>bo:g;us</nowiki>:B}-
23934
23935 -{A|zh-tw:xyz; zh-cn:<nowiki>0;zh-tw:bar</nowiki>}-
23936
23937 -{<nowiki>bo:g;us</nowiki>:xyz; zh-cn:abc}-
23938
23939 a:b=>c xyz
23940 !! html/php+disabled
23941 <p>foobat;xyz=&gt;zh-cn:abc
23942 </p><p>A
23943 </p><p>0;zh-tw:bar
23944 </p><p>abc
23945 </p><p>a:b=&gt;c 0;zh-tw:bar
23946 </p>
23947 !! end
23948
23949 !! test
23950 T179579: Nowiki and lc interaction
23951 !! options
23952 parsoid=wt2html
23953 language=sr
23954 !! wikitext
23955 -{</nowiki>123}-
23956
23957 -{123<nowiki>|</nowiki>456}-
23958 !! html/parsoid
23959 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&amp;lt;/nowiki>123"}}' data-parsoid='{"fl":[],"src":"-{&lt;/nowiki>123}-"}'></span></p>
23960
23961 <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>
23962 !! end
23963
23964 !! test
23965 T2529: Uncovered bullet
23966 !! wikitext
23967 *Foo {{bullet}}
23968 !! html
23969 <ul><li>Foo</li>
23970 <li>Bar</li></ul>
23971
23972 !! end
23973
23974 !! test
23975 T2529: Uncovered bullet in a deeply nested list
23976 !! wikitext
23977 *******Foo {{bullet}}
23978 !! html
23979 <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>
23980 <li>Bar</li></ul>
23981
23982 !! end
23983
23984 !! test
23985 T2529: Uncovered table already at line-start
23986 !! wikitext
23987 x
23988
23989 {{table}}
23990 y
23991 !! html
23992 <p>x
23993 </p>
23994 <table>
23995 <tr>
23996 <td>1</td>
23997 <td>2
23998 </td></tr>
23999 <tr>
24000 <td>3</td>
24001 <td>4
24002 </td></tr></table>
24003 <p>y
24004 </p>
24005 !! end
24006
24007 !! test
24008 T2529: Uncovered bullet in parser function result
24009 !! wikitext
24010 *Foo {{lc:{{bullet}} }}
24011 !! html
24012 <ul><li>Foo</li>
24013 <li>bar</li></ul>
24014
24015 !! end
24016
24017 !! test
24018 T7678: Double-parsed template argument
24019 !! wikitext
24020 {{lc:{{{1}}}|hello}}
24021 !! html
24022 <p>{{{1}}}
24023 </p>
24024 !! end
24025
24026 !! test
24027 T7678: Double-parsed template invocation
24028 !! wikitext
24029 {{lc:{{paramtest {{!}} param = hello }} }}
24030 !! html
24031 <p>{{paramtest | param = hello }}
24032 </p>
24033 !! end
24034
24035 !! test
24036 Case insensitivity of parser functions for non-ASCII characters (T10143)
24037 !! options
24038 language=cs
24039 title=[[Main Page]]
24040 !! wikitext
24041 {{PRVNÍVELKÉ:ěščř}}
24042 {{prvnívelké:ěščř}}
24043 {{PRVNÍMALÉ:ěščř}}
24044 {{prvnímalé:ěščř}}
24045 {{MALÁ:ěščř}}
24046 {{malá:ěščř}}
24047 {{VELKÁ:ěščř}}
24048 {{velká:ěščř}}
24049 !! html
24050 <p>Ěščř
24051 Ěščř
24052 ěščř
24053 ěščř
24054 ěščř
24055 ěščř
24056 ĚŠČŘ
24057 ĚŠČŘ
24058 </p>
24059 !! end
24060
24061 !! test
24062 Morwen/13: Unclosed link followed by heading
24063 !! wikitext
24064 [[link
24065 ==heading==
24066 !! html
24067 <p>[[link
24068 </p>
24069 <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>
24070
24071 !! end
24072
24073 !! test
24074 HHP2.1: Heuristics for headings in preprocessor parenthetical structures
24075 !! wikitext
24076 {{foo|
24077 =heading=
24078 !! html
24079 <p>{{foo|
24080 </p>
24081 <h1><span class="mw-headline" id="heading">heading</span></h1>
24082
24083 !! end
24084
24085 !! test
24086 HHP2.2: Heuristics for headings in preprocessor parenthetical structures
24087 !! wikitext
24088 {{foo|
24089 ==heading==
24090 !! html
24091 <p>{{foo|
24092 </p>
24093 <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>
24094
24095 !! end
24096
24097 !! test
24098 Tildes in comments
24099 !! options
24100 pst
24101 !! wikitext
24102 <!-- ~~~~ -->
24103 !! html/php
24104 <!-- ~~~~ -->
24105 !! end
24106
24107 !! test
24108 Paragraphs inside divs (no extra line breaks)
24109 !! wikitext
24110 <div>Line one
24111
24112 Line two</div>
24113 !! html
24114 <div>Line one
24115 Line two</div>
24116
24117 !! end
24118
24119 !! test
24120 Paragraphs inside divs (extra line break on open)
24121 !! wikitext
24122 <div>
24123 Line one
24124
24125 Line two</div>
24126 !! html
24127 <div>
24128 <p>Line one
24129 </p>
24130 Line two</div>
24131
24132 !! end
24133
24134 !! test
24135 Paragraphs inside divs (extra line break on close)
24136 !! wikitext
24137 <div>Line one
24138
24139 Line two
24140 </div>
24141 !! html
24142 <div>Line one
24143 <p>Line two
24144 </p>
24145 </div>
24146
24147 !! end
24148
24149 !! test
24150 Paragraphs inside divs (extra line break on open and close)
24151 !! wikitext
24152 <div>
24153 Line one
24154
24155 Line two
24156 </div>
24157 !! html
24158 <div>
24159 <p>Line one
24160 </p><p>Line two
24161 </p>
24162 </div>
24163
24164 !! end
24165
24166 # doBlockLevels screws up this output and Remex cleans up as much as it can.
24167 !! test
24168 Nesting tags, paragraphs on lines which begin with <div>
24169 !! wikitext
24170 <div></div><strong>A
24171 B</strong>
24172 !! html/php+tidy
24173 <div></div><p><strong>A
24174 </strong></p><strong></strong><p><strong>B</strong>
24175 </p>
24176 !! html/parsoid
24177 <div data-parsoid='{"stx":"html"}'></div><p><strong data-parsoid='{"stx":"html","autoInsertedEnd":true}'>A</strong></p>
24178 <p><strong data-parsoid='{"stx":"html","autoInsertedStart":true}'>B</strong></p>
24179 !! end
24180
24181 # T8200: <blockquote> should behave like <div> with respect to line breaks
24182 !! test
24183 T8200: paragraphs inside blockquotes (no extra line breaks)
24184 !! wikitext
24185 <blockquote>Line one
24186
24187 Line two</blockquote>
24188 !! html
24189 <blockquote>Line one
24190 Line two</blockquote>
24191
24192 !! html+tidy
24193 <blockquote><p>Line one
24194 Line two</p></blockquote>
24195 !! end
24196
24197 !! test
24198 T8200: paragraphs inside blockquotes (extra line break on open)
24199 !! wikitext
24200 <blockquote>
24201 Line one
24202
24203 Line two</blockquote>
24204 !! html
24205 <blockquote>
24206 <p>Line one
24207 </p>
24208 Line two</blockquote>
24209
24210 !! html+tidy
24211 <blockquote>
24212 <p>Line one
24213 </p><p>
24214 Line two</p></blockquote>
24215 !! end
24216
24217 !! test
24218 T8200: paragraphs inside blockquotes (extra line break on close)
24219 !! wikitext
24220 <blockquote>Line one
24221
24222 Line two
24223 </blockquote>
24224 !! html
24225 <blockquote>Line one
24226 <p>Line two
24227 </p>
24228 </blockquote>
24229
24230 !! html+tidy
24231 <blockquote><p>Line one
24232 </p><p>Line two
24233 </p>
24234 </blockquote>
24235 !! end
24236
24237 !! test
24238 T8200: paragraphs inside blockquotes (extra line break on open and close)
24239 !! wikitext
24240 <blockquote>
24241 Line one
24242
24243 Line two
24244 </blockquote>
24245 !! html
24246 <blockquote>
24247 <p>Line one
24248 </p><p>Line two
24249 </p>
24250 </blockquote>
24251
24252 !! end
24253
24254 ## This is a corner case interaction between the paragraph wrapping in the
24255 ## php parser's BlockLevelPass and Remex. `doBlockLevels` has a notion of
24256 ## some tags which close paragraphs (and thus prevent wrapping on their line),
24257 ## of which "div" is one, but do p-wrapping inside them. These are referred
24258 ## to as "never suppressing". Remex, for its part, doesn't traverse into
24259 ## "div"s to p-wrap. Hence, we only get this partial wrapping.
24260 !! test
24261 Paragraphs inside blockquotes/divs (no extra line breaks)
24262 !! wikitext
24263 <blockquote><div>Line one
24264
24265 Line two</div></blockquote>
24266 !! html
24267 <blockquote><div>Line one
24268 Line two</div></blockquote>
24269
24270 !! end
24271
24272 !! test
24273 Paragraphs inside blockquotes/divs (extra line break on open)
24274 !! wikitext
24275 <blockquote><div>
24276 Line one
24277
24278 Line two</div></blockquote>
24279 !! html
24280 <blockquote><div>
24281 <p>Line one
24282 </p>
24283 Line two</div></blockquote>
24284
24285 !! end
24286
24287 !! test
24288 Paragraphs inside blockquotes/divs (extra line break on close)
24289 !! wikitext
24290 <blockquote><div>Line one
24291
24292 Line two
24293 </div></blockquote>
24294 !! html
24295 <blockquote><div>Line one
24296 <p>Line two
24297 </p>
24298 </div></blockquote>
24299
24300 !! end
24301
24302 !! test
24303 Paragraphs inside blockquotes/divs (extra line break on open and close)
24304 !! wikitext
24305 <blockquote><div>
24306 Line one
24307
24308 Line two
24309 </div></blockquote>
24310 !! html
24311 <blockquote><div>
24312 <p>Line one
24313 </p><p>Line two
24314 </p>
24315 </div></blockquote>
24316
24317 !! end
24318
24319 !! test
24320 Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion
24321 !! options
24322 wgLinkHolderBatchSize=0
24323 !! wikitext
24324 [[meatball:1]]
24325 [[meatball:2]]
24326 [[meatball:3]]
24327 !! html
24328 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?1" class="extiw" title="meatball:1">meatball:1</a>
24329 <a href="http://www.usemod.com/cgi-bin/mb.pl?2" class="extiw" title="meatball:2">meatball:2</a>
24330 <a href="http://www.usemod.com/cgi-bin/mb.pl?3" class="extiw" title="meatball:3">meatball:3</a>
24331 </p>
24332 !! end
24333
24334 !! test
24335 Free external link invading image caption
24336 !! wikitext
24337 [[Image:Foobar.jpg|thumb|http://x|hello]]
24338 !! html/php
24339 <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>
24340
24341 !! html/parsoid
24342 <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>
24343 !! end
24344
24345 !! test
24346 T17196: localised external link numbers
24347 !! options
24348 language=fa
24349 !! wikitext
24350 [http://en.wikipedia.org/]
24351 !! html/php
24352 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/">[۱]</a>
24353 </p>
24354 !! html/parsoid
24355 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/"></a></p>
24356 !! end
24357
24358 !! test
24359 Multibyte character in padleft
24360 !! wikitext
24361 {{padleft:-Hello|7|Æ}}
24362 !! html/php
24363 <p>Æ-Hello
24364 </p>
24365 !! html/parsoid
24366 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:-Hello","function":"padleft"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Æ-Hello</p>
24367 !! end
24368
24369 !! test
24370 Multibyte character in padright
24371 !! wikitext
24372 {{padright:Hello-|7|Æ}}
24373 !! html/php
24374 <p>Hello-Æ
24375 </p>
24376 !! html/parsoid
24377 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:Hello-","function":"padright"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Hello-Æ</p>
24378 !! end
24379
24380 !!test
24381 formatdate parser function
24382 !! wikitext
24383 {{#formatdate:2009-03-24}}
24384 !! html
24385 <p><span class="mw-formatted-date" title="2009-03-24">2009-03-24</span>
24386 </p>
24387 !! end
24388
24389 !!test
24390 formatdate parser function, with default format
24391 !! wikitext
24392 {{#formatdate:2009-03-24|mdy}}
24393 !! html
24394 <p><span class="mw-formatted-date" title="2009-03-24">March 24, 2009</span>
24395 </p>
24396 !! end
24397
24398 !! test
24399 Spacing of numbers in formatted dates
24400 !! wikitext
24401 {{#formatdate:January 15}}
24402 !! html
24403 <p><span class="mw-formatted-date" title="01-15">January 15</span>
24404 </p>
24405 !! end
24406
24407 !! test
24408 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
24409 !! options
24410 language=nl title=[[MediaWiki:Common.css]]
24411 !! wikitext
24412 {{#formatdate:2009-03-24|dmy}}
24413 !! html
24414 <p><span class="mw-formatted-date" title="2009-03-24">24 March 2009</span>
24415 </p>
24416 !! end
24417
24418 #
24419 #
24420 #
24421
24422 #
24423 # Edit comments
24424 #
24425
24426 !! test
24427 Edit comment with link
24428 !! options
24429 comment
24430 !! wikitext
24431 I like the [[Main Page]] a lot
24432 !! html/php
24433 I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot
24434 !!end
24435
24436 !! test
24437 Edit comment with link and link text
24438 !! options
24439 comment
24440 !! wikitext
24441 I like the [[Main Page|best pages]] a lot
24442 !! html/php
24443 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
24444 !!end
24445
24446 !! test
24447 Edit comment with link and link text with suffix
24448 !! options
24449 comment
24450 !! wikitext
24451 I like the [[Main Page|best page]]s a lot
24452 !! html/php
24453 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
24454 !!end
24455
24456 !! test
24457 Edit comment with section link (non-local, eg in history list)
24458 !! options
24459 comment title=[[Main Page]]
24460 !! wikitext
24461 /* External links */ removed bogus entries
24462 !! html/php
24463 <a href="/wiki/Main_Page#External_links" title="Main Page">→External links</a>‎<span dir="auto"><span class="autocomment">: </span> removed bogus entries</span>
24464 !!end
24465
24466 !! test
24467 Edit comment with section link and text before it (non-local, eg in history list)
24468 !! options
24469 comment title=[[Main Page]]
24470 !! wikitext
24471 pre-comment text /* External links */ removed bogus entries
24472 !! html/php
24473 pre-comment text <a href="/wiki/Main_Page#External_links" title="Main Page">→External links</a>‎<span dir="auto"><span class="autocomment">: </span> removed bogus entries</span>
24474 !!end
24475
24476 !! test
24477 Edit comment with section link (local, eg in diff view)
24478 !! options
24479 comment local title=[[Main Page]]
24480 !! wikitext
24481 /* External links */ removed bogus entries
24482 !! html/php
24483 <a href="#External_links">→External links</a>‎<span dir="auto"><span class="autocomment">: </span> removed bogus entries</span>
24484 !!end
24485
24486 !! test
24487 Edit comment with subpage link (T16080)
24488 !! options
24489 comment
24490 subpage
24491 title=[[Subpage test]]
24492 !! wikitext
24493 Poked at a [[/subpage]] here...
24494 !! html/php
24495 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> here...
24496 !!end
24497
24498 !! test
24499 Edit comment with subpage link and link text (T16080)
24500 !! options
24501 comment
24502 subpage
24503 title=[[Subpage test]]
24504 !! wikitext
24505 Poked at a [[/subpage|neat little page]] here...
24506 !! html/php
24507 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">neat little page</a> here...
24508 !!end
24509
24510 !! test
24511 Edit comment with bogus subpage link in non-subpage NS (T16080)
24512 !! options
24513 comment
24514 title=[[Subpage test]]
24515 !! wikitext
24516 Poked at a [[/subpage]] here...
24517 !! html/php
24518 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...
24519 !!end
24520
24521 !! test
24522 Edit comment with bare anchor link (local, as on diff)
24523 !! options
24524 comment
24525 local
24526 title=[[Main Page]]
24527 !! wikitext
24528 [[#section]]
24529 !! html/php
24530 <a href="#section">#section</a>
24531 !! end
24532
24533 !! test
24534 Edit comment with bare anchor link (non-local, as on history)
24535 !! options
24536 comment
24537 title=[[Main Page]]
24538 !! wikitext
24539 [[#section]]
24540 !! html/php
24541 <a href="/wiki/Main_Page#section" title="Main Page">#section</a>
24542 !! end
24543
24544 !! test
24545 Anchor starting with underscore
24546 !! options
24547 title=[[Foo]]
24548 !! wikitext
24549 [[#_ref|One]]
24550 !! html/php
24551 <p><a href="#_ref">One</a>
24552 </p>
24553 !! html/parsoid
24554 <p><a rel="mw:WikiLink" href="./Foo#_ref" data-parsoid='{"stx":"piped","a":{"href":"./Foo#_ref"},"sa":{"href":"#_ref"}}'>One</a></p>
24555 !! end
24556
24557 !! test
24558 Id starting with underscore
24559 !! wikitext
24560 <div id="_ref"></div>
24561 !! html/*
24562 <div id="_ref"></div>
24563
24564 !! end
24565
24566 !! test
24567 Edit comment with link with more than one pipe (T99346)
24568 !! options
24569 comment
24570 !! wikitext
24571 [[Main Page|Many|pipes]]
24572 !! html/php
24573 <a href="/wiki/Main_Page" title="Main Page">Many|pipes</a>
24574 !! end
24575
24576 !! test
24577 Complex edit comment with link with more than one pipe (T99346)
24578 !! options
24579 comment
24580 !! wikitext
24581 Created page with "<noinclude>[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]]</noinclude> === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..."
24582 !! html/php
24583 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;
24584 !! end
24585
24586 !! test
24587 Space normalisation on autocomment (T24784)
24588 !! options
24589 comment
24590 title=[[Main Page]]
24591 !! wikitext
24592 /* __hello__world__ */
24593 !! html/php
24594 <a href="/wiki/Main_Page#hello_world" title="Main Page">→__hello__world__</a>‎
24595 !! end
24596
24597 !! test
24598 percent-encoding and + signs in comments (T28410)
24599 !! options
24600 comment
24601 !! wikitext
24602 [[ABC%33D% ++]] [[ABC%33D% ++|+%20]]
24603 !! html/php
24604 <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>
24605 !! end
24606
24607 # Parsoid doesn't support this yet: see T75581
24608 # but it *should* omit the 'src' attribute if the image is bad.
24609 # PHP side of tests was disabled in
24610 # mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
24611 # because of issues in the PHP parserTests infrastructure
24612 # (but the output below is indeed what the PHP side emits)
24613 !! test
24614 Bad images - basic functionality
24615 !! wikitext
24616 [[File:Bad.jpg]]
24617 !! html/php+disabled
24618 !! html/parsoid
24619 <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>
24620 !! end
24621
24622 !! test
24623 Bad images - T18039: text after bad image disappears
24624 !! wikitext
24625 Foo bar
24626 [[File:Bad.jpg]]
24627 Bar foo
24628 !! html/php+disabled
24629 <p>Foo bar
24630 </p><p>Bar foo
24631 </p>
24632 !! html/parsoid
24633 <p>Foo bar
24634 <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>
24635 Bar foo</p>
24636 !! end
24637
24638 !! test
24639 Verify that displaytitle works (T24501) no displaytitle
24640 !! options
24641 showtitle
24642 !! config
24643 wgAllowDisplayTitle=true
24644 wgRestrictDisplayTitle=false
24645 !! wikitext
24646 this is not the the title
24647 !! html/php
24648 Parser test
24649 <p>this is not the the title
24650 </p>
24651 !! end
24652
24653 !! test
24654 Verify that displaytitle works (T24501) RestrictDisplayTitle=false
24655 !! options
24656 showtitle
24657 title=[[Screen]]
24658 !! config
24659 wgAllowDisplayTitle=true
24660 wgRestrictDisplayTitle=false
24661 !! wikitext
24662 this is not the the title
24663 {{DISPLAYTITLE:whatever}}
24664 !! html/php
24665 whatever
24666 <p>this is not the the title
24667 </p>
24668 !! end
24669
24670 !! test
24671 Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch
24672 !! options
24673 showtitle
24674 title=[[Screen]]
24675 !! config
24676 wgAllowDisplayTitle=true
24677 wgRestrictDisplayTitle=true
24678 !! wikitext
24679 this is not the the title
24680 {{DISPLAYTITLE:whatever}}
24681 !! html/php
24682 Screen
24683 <p>this is not the the title
24684 </p>
24685 !! end
24686
24687 !! test
24688 Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching
24689 !! options
24690 showtitle
24691 title=[[Screen]]
24692 !! config
24693 wgAllowDisplayTitle=true
24694 wgRestrictDisplayTitle=true
24695 !! wikitext
24696 this is not the the title
24697 {{DISPLAYTITLE:screen}}
24698 !! html/php
24699 screen
24700 <p>this is not the the title
24701 </p>
24702 !! end
24703
24704 !! test
24705 Verify that displaytitle works (T24501) AllowDisplayTitle=false
24706 !! options
24707 showtitle
24708 title=[[Screen]]
24709 !! config
24710 wgAllowDisplayTitle=false
24711 !! wikitext
24712 this is not the the title
24713 {{DISPLAYTITLE:screen}}
24714 !! html/php
24715 Screen
24716 <p>this is not the the title
24717 <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>
24718 </p>
24719 !! end
24720
24721 !! test
24722 Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE
24723 !! options
24724 showtitle
24725 title=[[Screen]]
24726 !! config
24727 wgAllowDisplayTitle=false
24728 !! wikitext
24729 this is not the the title
24730 !! html/php
24731 Screen
24732 <p>this is not the the title
24733 </p>
24734 !! end
24735
24736 !! test
24737 Verify that displaytitle handles inline CSS styles (T28547) - rejected value
24738 !! options
24739 showtitle
24740 title=[[Screen]]
24741 !! config
24742 wgAllowDisplayTitle=true
24743 wgRestrictDisplayTitle=true
24744 !! wikitext
24745 this is not the the title
24746 {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
24747 !! html/php
24748 <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
24749 <p>this is not the the title
24750 </p>
24751 !! end
24752
24753 !! test
24754 Verify that displaytitle handles inline CSS styles (T28547) - accepted value
24755 !! options
24756 showtitle
24757 title=[[Screen]]
24758 !! config
24759 wgAllowDisplayTitle=true
24760 wgRestrictDisplayTitle=true
24761 !! wikitext
24762 this is not the the title
24763 {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
24764 !! html/php
24765 <span style="color: red;">s</span>creen
24766 <p>this is not the the title
24767 </p>
24768 !! end
24769
24770 !! test
24771 Page status indicators: Empty name is invalid
24772 !! options
24773 showindicators
24774 !! wikitext
24775 <indicator name=" "></indicator>
24776 <indicator></indicator>
24777 !! html/php
24778 <p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
24779 <span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
24780 </p>
24781 !! end
24782
24783 !! test
24784 Page status indicators: Weird syntaxes that are okay
24785 !! options
24786 showindicators
24787 !! wikitext
24788 <indicator name="empty" />
24789 <indicator name="name"></indicator>
24790 !! html/php
24791 empty=
24792 name=
24793 <p><br />
24794 </p>
24795 !! end
24796
24797 !! test
24798 Page status indicators: Torture test
24799 !! options
24800 showindicators
24801 !! wikitext
24802 <indicator name="01">hello world</indicator>
24803 <indicator name="02">[[Main Page]]</indicator>
24804 <indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator>
24805 <indicator name="04">[[File:Foobar.jpg|25px]]</indicator>
24806 <indicator name="05">*foo
24807 *bar</indicator>
24808 <indicator name="06"><nowiki>foo</nowiki></indicator>
24809 <indicator name="07"> Preformatted</indicator>
24810 <indicator name="08"><div>Broken tag</indicator>
24811 <indicator name="09">{| class=wikitable
24812 |cell
24813 |}</indicator>
24814 <indicator name="10">Two
24815
24816 paragraphs</indicator>
24817 !! html/php
24818 01=hello world
24819 02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
24820 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" />
24821 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>
24822 05=<ul><li>foo</li>
24823 <li>bar</li></ul>
24824
24825 06=foo
24826 07=<pre>Preformatted
24827 </pre>
24828 08=<div>Broken tag</div>
24829
24830 09=<table class="wikitable">
24831 <tr>
24832 <td>cell
24833 </td></tr></table>
24834
24835 10=<p>Two
24836 </p><p>paragraphs
24837 </p>
24838 <p><br />
24839 </p><p><br />
24840 </p><p><br />
24841 </p><p><br />
24842 </p><p><br />
24843 </p>
24844 !! end
24845
24846 !! test
24847 preload: check <noinclude> and <includeonly>
24848 !! options
24849 preload
24850 !! wikitext
24851 Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
24852 !! html/php
24853 Hello kind world.
24854 !! end
24855
24856 !! test
24857 preload: check <onlyinclude>
24858 !! options
24859 preload
24860 !! wikitext
24861 Goodbye <onlyinclude>Hello world</onlyinclude>
24862 !! html/php
24863 Hello world
24864 !! end
24865
24866 !! test
24867 preload: can pass tags through if we want to
24868 !! options
24869 preload
24870 !! wikitext
24871 <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
24872 !! html/php
24873 <includeonly>Hello world</includeonly>
24874 !! end
24875
24876 !! test
24877 preload: check that it doesn't try to do tricks
24878 !! options
24879 preload
24880 !! wikitext
24881 * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
24882 !! html/php
24883 * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
24884 !! end
24885
24886 !! test
24887 Play a bit with r67090 and T5158
24888 !! wikitext
24889 <div style="width:50% !important">&nbsp;</div>
24890 <div style="width:50%&nbsp;!important">&nbsp;</div>
24891 <div style="width:50%&#160;!important">&nbsp;</div>
24892 <div style="border : solid;">&nbsp;</div>
24893 !! html/php
24894 <div style="width:50% !important">&#160;</div>
24895 <div style="width:50% !important">&#160;</div>
24896 <div style="width:50% !important">&#160;</div>
24897 <div style="border&#32;: solid;">&#160;</div>
24898
24899 !! html/parsoid
24900 <div style="width:50% !important" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
24901 <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>
24902 <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>
24903 <div style="border : solid;" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
24904
24905 !! end
24906
24907 !! test
24908 French spaces in wikitext
24909 !! wikitext
24910 foo ! bar ? bat 50 % is less than 75 %.
24911
24912 Hello : this ; is « something ‹ else › again »
24913 !! html
24914 <p>foo&#160;! bar&#160;? bat 50&#160;% is less than 75&#160;%.
24915 </p><p>Hello&#160;: this&#160;; is «&#160;something ‹&#160;else&#160;› again&#160;»
24916 </p>
24917 !! end
24918
24919 # It would be reasonable for Parsoid and PHP to differ here.
24920 # The PHP behavior is arguably a bug.
24921 !! test
24922 Corner case: french spaces in definition list
24923 !! wikitext
24924 ;foo : bar
24925 !! html+tidy
24926 <dl><dt>foo&#160;</dt>
24927 <dd>bar</dd></dl>
24928 !! end
24929
24930 !! test
24931 T5158: Test for French spaces in attributes
24932 !! wikitext
24933 <br style=" clear : both ; " />
24934 !! html/php
24935 <p><br style="clear&#32;: both&#32;;" />
24936 </p>
24937 !! end
24938
24939 !! test
24940 HTML5 data attributes
24941 !! wikitext
24942 <span data-foo="bar">Baz</span>
24943 <p data-abc-def_hij="">Quuz</p>
24944 !! html/php
24945 <p><span data-foo="bar">Baz</span>
24946 </p>
24947 <p data-abc-def_hij="">Quuz</p>
24948
24949 !! html/parsoid
24950 <p><span data-foo="bar" data-parsoid='{"stx":"html"}'>Baz</span></p>
24951 <p data-abc-def_hij="" data-parsoid='{"stx":"html"}'>Quuz</p>
24952 !! end
24953
24954 !! test
24955 Strip reserved data attributes
24956 !! wikitext
24957 <div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
24958 !! html/php
24959 <div data-ok="fred">d</div>
24960
24961 !! html/parsoid
24962 <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>
24963 !! end
24964
24965 !! test
24966 percent-encoding and + signs in internal links (T28410)
24967 !! wikitext
24968 [[User:+%]] [[Page+title%]]
24969 [[%+]] [[%+|%20]] [[%+ ]] [[%+r]]
24970 [[%]] [[+]] [[File:%+abc%39|foo|[[bar]]]]
24971 [[%33%45]] [[%33%45+]]
24972 !! html/php
24973 <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>
24974 <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>
24975 <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>
24976 <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>
24977 </p>
24978 !! html/parsoid
24979 <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>
24980 <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>
24981 <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>
24982 <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>
24983 !! end
24984
24985 !! test
24986 Special characters in embedded file links (T29679)
24987 !! wikitext
24988 [[File:Contains & ampersand.jpg]]
24989 [[File:Does not exist.jpg|Title with & ampersand]]
24990 !! html/php
24991 <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>
24992 <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>
24993 </p>
24994 !! html/parsoid
24995 <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>
24996 <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>
24997 !! end
24998
24999 !! test
25000 Confirm that 'apos' named character reference doesn't make it to output (not legal in HTML 4)
25001 !! wikitext
25002 Text&apos;s been normalized?
25003 !! html
25004 <p>Text&#39;s been normalized?
25005 </p>
25006 !! end
25007
25008 !! test
25009 T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
25010 !! wikitext
25011 http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
25012 !! html
25013 <p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> &lt;-- U+3000 (vim: ^Vu3000)
25014 </p>
25015 !! end
25016
25017 !! test
25018 T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
25019 !! wikitext
25020 [http://www.example.org/ ideograms]
25021 !! html
25022 <p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a>
25023 </p>
25024 !! end
25025
25026 !! test
25027 T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
25028 !! wikitext
25029 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
25030 !! html
25031 <p><img src="http://www.example.org/pic.png" alt="pic.png"/> &lt;-- U+3000 (vim: ^Vu3000)
25032 </p>
25033 !! end
25034
25035 !! article
25036 Mediawiki:loop1
25037 !! text
25038 {{Identical|A}}
25039 !! endarticle
25040
25041 !! article
25042 Mediawiki:loop2
25043 !! text
25044 {{Identical|B}}
25045 !! endarticle
25046
25047 !! article
25048 Template:Identical
25049 !! text
25050 {{int:loop1}}
25051 {{int:loop2}}
25052 !! endarticle
25053
25054 !! test
25055 T33098 Template which includes system messages which includes the template
25056 !! wikitext
25057 {{Identical}}
25058 !! html
25059 <p><span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
25060 <span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
25061 </p>
25062 !! end
25063
25064 !! test
25065 T33490 Turkish: ucfirst 'blah'
25066 !! options
25067 language=tr
25068 !! wikitext
25069 {{ucfirst:blah}}
25070 !! html
25071 <p>Blah
25072 </p>
25073 !! end
25074
25075 !! test
25076 T33490 Turkish: ucfirst 'ix'
25077 !! options
25078 language=tr
25079 !! wikitext
25080 {{ucfirst:ix}}
25081 !! html
25082 <p>İx
25083 </p>
25084 !! end
25085
25086 !! test
25087 T33490 Turkish: lcfirst 'BLAH'
25088 !! options
25089 language=tr
25090 !! wikitext
25091 {{lcfirst:BLAH}}
25092 !! html
25093 <p>bLAH
25094 </p>
25095 !! end
25096
25097 !! test
25098 T33490 Turkish: ucfırst (with a dotless i)
25099 !! options
25100 language=tr
25101 !! wikitext
25102 {{ucfırst:blah}}
25103 !! html
25104 <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>
25105 </p>
25106 !! end
25107
25108 !! test
25109 T33490 ucfırst (with a dotless i) with English language
25110 !! options
25111 language=en
25112 !! wikitext
25113 {{ucfırst:blah}}
25114 !! html
25115 <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>
25116 </p>
25117 !! end
25118
25119 # Note that Parsoid doesn't emit an explicit TOC.
25120 # Note also that the html2wt direction tends to emit an extra newline
25121 # between the __TOC__ magicword and the first heading unless *both*
25122 # the <meta> and the <h2> have a data-parsoid attribute set (even if
25123 # it's "{}").
25124
25125 !! test
25126 T28375: TOC with italics
25127 !! options
25128 title=[[Main Page]]
25129 !! wikitext
25130 __TOC__
25131 ==''Lost'' episodes==
25132 !! html/php
25133 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25134 <ul>
25135 <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>
25136 </ul>
25137 </div>
25138
25139 <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>
25140
25141 !! html/parsoid
25142 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25143 <h2 id="Lost_episodes" data-parsoid='{}'><i>Lost</i> episodes</h2>
25144 !! end
25145
25146 !! test
25147 T28375: TOC with bold
25148 !! options
25149 title=[[Main Page]]
25150 !! wikitext
25151 __TOC__
25152 =='''should be bold''' then normal text==
25153 !! html/php
25154 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25155 <ul>
25156 <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>
25157 </ul>
25158 </div>
25159
25160 <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>
25161
25162 !! html/parsoid
25163 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25164 <h2 id="should_be_bold_then_normal_text" data-parsoid='{}'><b>should be bold</b> then normal text</h2>
25165 !! end
25166
25167 !! test
25168 T35845: Headings become cursive in TOC when they contain an image
25169 !! options
25170 title=[[Main Page]]
25171 !! wikitext
25172 __TOC__
25173 ==Image [[Image:foobar.jpg]]==
25174 !! html/php
25175 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25176 <ul>
25177 <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
25178 </ul>
25179 </div>
25180
25181 <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>
25182
25183 !! html/parsoid
25184 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25185 <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>
25186 !! end
25187
25188 !! test
25189 T35845 (2): Headings become bold in TOC when they contain a blockquote
25190 !! options
25191 title=[[Main Page]]
25192 !! wikitext
25193 __TOC__
25194 ==<blockquote>Quote</blockquote>==
25195 !! html/php
25196 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25197 <ul>
25198 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
25199 </ul>
25200 </div>
25201
25202 <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>
25203
25204 !! html/php+tidy
25205 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25206 <ul>
25207 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
25208 </ul>
25209 </div>
25210
25211 <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>
25212 !! html/parsoid
25213 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25214 <h2 id="Quote" data-parsoid='{}'><blockquote><p>Quote</p></blockquote></h2>
25215 !! end
25216
25217 !! test
25218 Unclosed tags in TOC
25219 !! config
25220 wgFragmentMode=[ 'html5', 'legacy' ]
25221 !! options
25222 title=[[Main Page]]
25223 !! wikitext
25224 __TOC__
25225 ==Proof: 2 < 3==
25226 <small>Hanc marginis exiguitas non caperet.</small>
25227 QED
25228 !! html/php
25229 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25230 <ul>
25231 <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>
25232 </ul>
25233 </div>
25234
25235 <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>
25236 <p><small>Hanc marginis exiguitas non caperet.</small>
25237 QED
25238 </p>
25239 !! html/parsoid
25240 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25241 <h2 id="Proof:_2_&lt;_3" data-parsoid='{}'><span id="Proof:_2_.3C_3" typeof="mw:FallbackId"></span>Proof: 2 &lt; 3</h2>
25242 <p><small>Hanc marginis exiguitas non caperet.</small>
25243 QED</p>
25244 !! end
25245
25246 !! test
25247 Multiple tags in TOC
25248 !! wikitext
25249 __TOC__
25250 ==<i>Foo</i> <b>Bar</b>==
25251
25252 ==<i>Foo</i> <blockquote>Bar</blockquote>==
25253 !! html/php
25254 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25255 <ul>
25256 <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>
25257 <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>
25258 </ul>
25259 </div>
25260
25261 <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>
25262 <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>
25263
25264 !! html/php+tidy
25265 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25266 <ul>
25267 <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>
25268 <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>
25269 </ul>
25270 </div>
25271
25272 <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>
25273 <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>
25274 !! html/parsoid
25275 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25276 <h2 id="Foo_Bar" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b></h2>
25277
25278 <h2 id="Foo_Bar_2" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote><p>Bar</p></blockquote></h2>
25279 !! end
25280
25281 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
25282 # html5 tag parsing.
25283 !! test
25284 Tags with parameters in TOC
25285 !! options
25286 parsoid=wt2html
25287 !! wikitext
25288 __TOC__
25289 ==<sup class="in-h2">Hello</sup>==
25290
25291 ==<sup class="a > b">Evilbye</sup>==
25292 !! html/php
25293 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25294 <ul>
25295 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
25296 <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>
25297 </ul>
25298 </div>
25299
25300 <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>
25301 <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>
25302
25303 !! html/parsoid
25304 <meta property="mw:PageProp/toc" />
25305 <h2 id="Hello"><sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup></h2>
25306
25307 <h2 id='b">Evilbye'><span id="b.22.3EEvilbye" typeof="mw:FallbackId"></span><sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup></h2>
25308 !! end
25309
25310 !! test
25311 span tags with directionality in TOC
25312 !! wikitext
25313 __TOC__
25314 ==<span dir="ltr">C++</span>==
25315
25316 ==<span dir="rtl">זבנג!</span>==
25317
25318 ==<span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span>==
25319
25320 ==<span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span>==
25321
25322 ==<span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span>==
25323 !! html/php
25324 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25325 <ul>
25326 <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>
25327 <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>
25328 <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>
25329 <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>
25330 <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>
25331 </ul>
25332 </div>
25333
25334 <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>
25335 <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>
25336 <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>
25337 <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>
25338 <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>
25339
25340 !! html/parsoid
25341 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25342 <h2 id="C++" data-parsoid='{}'><span id="C.2B.2B" typeof="mw:FallbackId"></span><span dir="ltr">C++</span></h2>
25343 <h2 id="זבנג!"><span id=".D7.96.D7.91.D7.A0.D7.92.21" typeof="mw:FallbackId"></span><span dir="rtl">זבנג!</span></h2>
25344 <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>
25345 <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>
25346 <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>
25347 !! end
25348
25349 !! test
25350 T74884: bdi element in ToC
25351 !! wikitext
25352 __TOC__
25353 ==<bdi>test</bdi>==
25354 !! html/php
25355 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25356 <ul>
25357 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
25358 </ul>
25359 </div>
25360
25361 <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>
25362
25363 !! html/parsoid
25364 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25365 <h2 id="test" data-parsoid='{}'><bdi>test</bdi></h2>
25366 !! end
25367
25368 !! test
25369 T35715: s/strike element in ToC
25370 !! wikitext
25371 __TOC__
25372 ==<s>test</s> test <strike>test</strike>==
25373 !! html/php
25374 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25375 <ul>
25376 <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>
25377 </ul>
25378 </div>
25379
25380 <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>
25381
25382 !! html/parsoid
25383 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25384 <h2 id="test_test_test" data-parsoid='{}'><s>test</s> test <strike>test</strike></h2>
25385 !! end
25386
25387 !! test
25388 T198618: style element in ToC
25389 !! options
25390 styletag=1
25391 !! wikitext
25392 __TOC__
25393 ==<style>.foo {}</style>Style<style>.bar {}</style>==
25394 !! html/php
25395 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25396 <ul>
25397 <li class="toclevel-1 tocsection-1"><a href="#Style"><span class="tocnumber">1</span> <span class="toctext">Style</span></a></li>
25398 </ul>
25399 </div>
25400
25401 <h2><span class="mw-headline" id="Style"><style>.foo {}</style>Style<style>.bar {}</style></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Style">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
25402
25403 !! html/parsoid
25404 <meta property="mw:PageProp/toc" data-parsoid="{}"/>
25405 <h2 id="Style" data-parsoid="{}"><style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo {}"}}'>.foo {}</style>Style<style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".bar {}"}}'>.bar {}</style></h2>
25406 !! end
25407
25408 !! test
25409 T198618: script element in ToC
25410 !! options
25411 wgRawHtml=1
25412 !! wikitext
25413 __TOC__
25414 ==<html><script>alert(1);</script></html>Script<html><script>alert(1);</script></html>==
25415 !! html/php
25416 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25417 <ul>
25418 <li class="toclevel-1 tocsection-1"><a href="#Script"><span class="tocnumber">1</span> <span class="toctext">Script</span></a></li>
25419 </ul>
25420 </div>
25421
25422 <h2><span class="mw-headline" id="Script"><script>alert(1);</script>Script<script>alert(1);</script></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Script">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
25423
25424 !! html/parsoid
25425 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25426 <h2 id="Script" data-parsoid='{}'><script typeof="mw:Extension/html" about="#mwt4" data-mw='{"name":"html","attrs":{},"body":{"extsrc":"&lt;script>alert(1);&lt;/script>"}}'>alert(1);</script>Script<script typeof="mw:Extension/html" about="#mwt6" data-mw='{"name":"html","attrs":{},"body":{"extsrc":"&lt;script>alert(1);&lt;/script>"}}'>alert(1);</script></h2>
25427 !! end
25428
25429 !! test
25430 Empty <p> tag in TOC, removed by Sanitizer (T92892)
25431 !! wikitext
25432 __TOC__
25433 ==x==
25434 !! html/php
25435 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25436 <ul>
25437 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
25438 </ul>
25439 </div>
25440
25441 <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>
25442
25443 !! html/parsoid
25444 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25445 <h2 id="x" data-parsoid='{}'>x</h2>
25446 !! end
25447
25448 !! article
25449 MediaWiki:T34057
25450 !! text
25451 == {{int:headline_sample}} ==
25452 !! endarticle
25453
25454 !! test
25455 T34057: Title needed when expanding <h> nodes.
25456 !! options
25457 title=[[Main Page]]
25458 !! wikitext
25459 {{int:T34057}}
25460 !! html
25461 <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>
25462
25463 !! end
25464
25465 !! test
25466 Strip marker in urlencode
25467 !! wikitext
25468 {{urlencode:x<nowiki/>y}}
25469 {{urlencode:x<nowiki/>y|wiki}}
25470 {{urlencode:x<nowiki/>y|path}}
25471 {{urlencode:x<pre id="one">two</pre>y}}
25472 !! html/php
25473 <p>xy
25474 xy
25475 xy
25476 xy
25477 </p>
25478 !! end
25479
25480 !! test
25481 Strip marker in lc
25482 !! wikitext
25483 {{lc:x<nowiki/>y}}
25484 !! html
25485 <p>xy
25486 </p>
25487 !! end
25488
25489 !! test
25490 Strip marker in uc
25491 !! wikitext
25492 {{uc:x<nowiki/>y}}
25493 !! html
25494 <p>XY
25495 </p>
25496 !! end
25497
25498 !! test
25499 Strip marker in formatNum
25500 !! wikitext
25501 {{formatnum:1<nowiki/>2}}
25502 {{formatnum:1<nowiki/>2|R}}
25503 !! html
25504 <p>12
25505 12
25506 </p>
25507 !! end
25508
25509 !! test
25510 Check noCommafy in formatNum
25511 !! options
25512 language=be-tarask
25513 !! wikitext
25514 {{formatnum:123456.78}}
25515 {{formatnum:123456.78|NOSEP}}
25516 !! html
25517 <p>123 456,78
25518 123456.78
25519 </p>
25520 !! end
25521
25522 !! test
25523 Wrong option for formatNum (T58199)
25524 !! wikitext
25525 {{formatnum:1,234.56|Random}}
25526 {{formatnum:1,234.56|EVERYTHING}}
25527 {{formatnum:1234.56|any argument that has the string 'NOSEP'}}
25528 !! html
25529 <p>1,234.56
25530 1,234.56
25531 1,234.56
25532 </p>
25533 !! end
25534
25535 !! test
25536 Strip marker in grammar
25537 !! options
25538 language=fi
25539 !! wikitext
25540 {{grammar:elative|foo<nowiki/>bar}}
25541 !! html
25542 <p>foobarista
25543 </p>
25544 !! end
25545
25546 !! test
25547 Strip marker in padleft
25548 !! wikitext
25549 {{padleft:|2|x<nowiki/>y}}
25550 !! html
25551 <p>xy
25552 </p>
25553 !! end
25554
25555 !! test
25556 Strip marker in padright
25557 !! wikitext
25558 {{padright:|2|x<nowiki/>y}}
25559 !! html
25560 <p>xy
25561 </p>
25562 !! end
25563
25564 !! test
25565 Strip marker in anchorencode
25566 !! wikitext
25567 {{anchorencode:x<nowiki/>y}}
25568 !! html/php
25569 <p>xy
25570 </p>
25571 !! html/parsoid
25572 <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>
25573 !! end
25574
25575 !! test
25576 nowiki inside link inside heading (T20295)
25577 !! wikitext
25578 ==[[foo|x<nowiki>y</nowiki>z]]==
25579 !! html
25580 <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>
25581
25582 !! end
25583
25584 !! test
25585 new support for bdi element (T33817)
25586 !! wikitext
25587 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
25588 !! html
25589 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
25590
25591 !!end
25592
25593 !! test
25594 Ignore pipe between table row attributes
25595 !! wikitext
25596 {|
25597 |quux
25598 |- id=foo | style='color: red'
25599 |bar
25600 |}
25601 !! html
25602 <table>
25603 <tr>
25604 <td>quux
25605 </td></tr>
25606 <tr id="foo" style="color: red">
25607 <td>bar
25608 </td></tr></table>
25609
25610 !! end
25611
25612 !!test
25613 Language parser function
25614 !! wikitext
25615 {{#language:ar}}
25616 !! html
25617 <p>العربية
25618 </p>
25619 !! end
25620
25621 !!test
25622 Padleft and padright (default 0-padding)
25623 !! wikitext
25624 {{padleft:xyz|5}}
25625 {{padright:xyz|5}}
25626 !! html/php
25627 <p>00xyz
25628 xyz00
25629 </p>
25630 !! html/parsoid
25631 <p><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:xyz","function":"padleft"},"params":{"1":{"wt":"5"}},"i":0}}]}'>00xyz</span>
25632 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:xyz","function":"padright"},"params":{"1":{"wt":"5"}},"i":0}}]}'>xyz00</span></p>
25633 !! end
25634
25635 !!test
25636 Padleft and padright (partial fill)
25637 !! wikitext
25638 {{padleft:xyz|6|ab}}
25639 {{padright:xyz|6|ab}}
25640 !! html/php
25641 <p>abaxyz
25642 xyzaba
25643 </p>
25644 !! html/parsoid
25645 <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>
25646 <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>
25647 !! end
25648
25649 !!test
25650 Padleft and padright as substr
25651 !! wikitext
25652 {{padleft:|3|abcde}}
25653 {{padright:|3|abcde}}
25654 !! html/php
25655 <p>abc
25656 abc
25657 </p>
25658 !! html/parsoid
25659 <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>
25660 <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>
25661 !! end
25662
25663 !! test
25664 Padleft and padright with non-numerical length (T180403)
25665 !! wikitext
25666 {{padleft:abcdef|junk}}
25667 {{padright:abcdef|junk}}
25668 !! html/php
25669 <p>abcdef
25670 abcdef
25671 </p>
25672 !! end
25673
25674 !!test
25675 Special parser function
25676 !! wikitext
25677 {{#special:RandomPage}}
25678 {{#special:BaDtItLe}}
25679 {{#special:Foobar}}
25680 !! html
25681 <p>Special:Random
25682 Special:Badtitle
25683 Special:Foobar
25684 </p>
25685 !! end
25686
25687 !!test
25688 T36939 - Case insensitive link parsing ([HttP://])
25689 !! wikitext
25690 [HttP://MediaWiki.Org/]
25691 !! html/php
25692 <p><a rel="nofollow" class="external autonumber" href="HttP://MediaWiki.Org/">[1]</a>
25693 </p>
25694 !! html/parsoid
25695 <p><a rel="mw:ExtLink" class="external autonumber" href="HttP://MediaWiki.Org/"></a></p>
25696 !! end
25697
25698 !!test
25699 T36939 - Case insensitive link parsing ([HttP:// title])
25700 !! wikitext
25701 [HttP://MediaWiki.Org/ MediaWiki]
25702 !! html
25703 <p><a rel="nofollow" class="external text" href="HttP://MediaWiki.Org/">MediaWiki</a>
25704 </p>
25705 !! end
25706
25707 !!test
25708 T36939 - Case insensitive link parsing (HttP://)
25709 !! wikitext
25710 HttP://MediaWiki.Org/
25711 !! html/php
25712 <p><a rel="nofollow" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a>
25713 </p>
25714 !! html/parsoid
25715 <p><a rel="mw:ExtLink" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a></p>
25716 !! end
25717
25718 !!test
25719 Disable TOC
25720 !! options
25721 notoc
25722 !! wikitext
25723 Lead
25724 ==Section 1==
25725 ==Section 2==
25726 ==Section 3==
25727 ==Section 4==
25728 ==Section 5==
25729 !! html
25730 <p>Lead
25731 </p>
25732
25733 <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>
25734 <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>
25735 <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>
25736 <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>
25737 <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>
25738
25739 !! end
25740
25741
25742 ###
25743 ### Parsoid-specific tests
25744 ### Parsoid-PHP parser incompatibilities
25745 ###
25746 !!test
25747 1. SOL-sensitive wikitext tokens as template-args
25748 !! options
25749 parsoid=wt2html,wt2wt
25750 !! wikitext
25751 {{echo|*a}}
25752 {{echo|#a}}
25753 {{echo|:a}}
25754 !! html/php+tidy
25755 <ul><li>a</li></ul>
25756 <ol><li>a</li></ol>
25757 <dl><dd>a</dd></dl>
25758 !! html/parsoid
25759 <span about="#mwt1" typeof="mw:Transclusion">
25760 </span><ul about="#mwt1"><li>a</li>
25761 </ul>
25762 <span about="#mwt2" typeof="mw:Transclusion">
25763 </span><ol about="#mwt2"><li>a</li>
25764 </ol>
25765 <span about="#mwt3" typeof="mw:Transclusion">
25766 </span><dl about="#mwt3"><dd>a</dd>
25767 </dl>
25768 !!end
25769
25770 #### -----------------------------------------------------------------
25771 #### Parsoid-specific functionality tests
25772 #### -----------------------------------------------------------------
25773
25774 # T65642/T68749: Formatting elt fixup around images.
25775 # We know wt2wt will fail, but we expect selser to pass.
25776 # Due to the nature of our testing, wt2wt and selser tests will enter the
25777 # blacklist and we'll catch selser regressions based on changes to the
25778 # blacklist entries for selser tests.
25779 !! test
25780 1. Treebuilder fixup of formatting elt
25781 !! options
25782 parsoid=wt2html,wt2wt
25783 !! wikitext
25784 {|
25785 |
25786 <small>
25787 [[Image:Foobar.jpg|right|Test]]
25788 </small>
25789 |}
25790 !! html/php+tidy
25791 <table>
25792 <tbody><tr>
25793 <td>
25794 <p><small>
25795 </small></p><small>
25796 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Test"><img alt="Test" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
25797 </small><p><small></small>
25798 </p>
25799 </td></tr></tbody></table>
25800 !! html/parsoid
25801 <table>
25802 <tbody><tr><td>
25803 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p><small data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
25804 <figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Test</figcaption></figure></small>
25805 <p><small data-parsoid='{"stx":"html","autoInsertedStart":true}'></small></p></td></tr>
25806 </tbody></table>
25807 !! end
25808
25809 !! test
25810 2. Treebuilder fixup of formatting elt
25811 !! options
25812 parsoid=wt2html,wt2wt
25813 !! wikitext
25814 '''foo[[File:Foobar.jpg|thumb|caption]]bar'''
25815
25816 <small>[[Image:Foobar.jpg|right|300px]]</small>
25817 !! html/php+tidy
25818 <p><b>foo</b></p><b><div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div></b><p><b>bar</b>
25819 </p><small><div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" width="300" height="34" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/450px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/600px-Foobar.jpg 2x" /></a></div></small>
25820 !! html/parsoid
25821 <p><b>foo</b></p><b><figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption</figcaption></figure></b><p><b>bar</b></p>
25822
25823 <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>
25824 !! end
25825
25826 !! test
25827 3. Treebuilder fixup of formatting elt
25828 !! options
25829 parsoid=wt2html,wt2wt
25830 !! wikitext
25831 <small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
25832 !! html/php+tidy
25833 <p><small><b>foo</b></small></p><small><b><div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div></b></small><p><small><b>bar</b></small>
25834 </p>
25835 !! html/parsoid
25836 <p><small><b>foo</b></small></p><small><b><figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption</figcaption></figure></b></small><p><small><b>bar</b></small></p>
25837 !! end
25838
25839 !! test
25840 4. Treebuilder fixup of formatting elt: formatting tags around captionless images
25841 !! options
25842 parsoid=wt2html,wt2wt
25843 !! wikitext
25844 '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
25845 !! html/php+tidy
25846 <b><small><div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" width="300" height="34" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/450px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/600px-Foobar.jpg 2x" /></a></div></small></b>
25847 !! html/parsoid
25848 <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>
25849 !! end
25850
25851 #### ----------------------------------------------------------------
25852 #### Parsoid-only testing of Parsoid's impl of LST
25853 #### Not implemented yet, see
25854 #### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
25855 #### ----------------------------------------------------------------
25856
25857 ## We still need to support serializing the older format while content is stored.
25858 !! test
25859 LST Sections: Backwards compatibility
25860 !! options
25861 parsoid={
25862 "suppressErrors": true,
25863 "modes": ["html2wt"]
25864 }
25865 !! wikitext
25866 <section begin="2011-05-16" />
25867 <section end="2014-04-10 (MW 1.23wmf22)" />
25868 !! html/parsoid
25869 <p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/>
25870 <meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p>
25871 !! end
25872
25873 !! test
25874 LST Sections: Newfangled approach
25875 !! wikitext
25876 <section begin="2011-05-16" />
25877 <section end="2014-04-10 (MW 1.23wmf22)" />
25878 !! html/parsoid
25879 <p><span typeof="mw:Extension/section" about="#mwt4" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"}}'>
25880 </span>
25881 <span typeof="mw:Extension/section" about="#mwt6" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"}}'>
25882 </span></p>
25883 !! end
25884
25885 #--------- Test stripping of empty nodes in template content ----------
25886
25887 !! test
25888 Empty LI and TR nodes should be stripped from template content
25889 !! wikitext
25890 {{EmptyLITest}}
25891 {{EmptyTRTest}}
25892 !! html/parsoid
25893 <ul about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyLITest","href":"./Template:EmptyLITest"},"params":{},"i":0}}]}'>
25894 <li>a</li>
25895 <li>b</li>
25896 </ul>
25897 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRTest","href":"./Template:EmptyTRTest"},"params":{},"i":0}}]}'>
25898 <tbody>
25899 <tr>
25900 <td>foo</td>
25901 </tr>
25902 <tr>
25903 <td>bar</td>
25904 </tr>
25905 </tbody>
25906 </table>
25907 !! end
25908
25909 !! test
25910 Empty LI and TR nodes should not be stripped from top-level content
25911 !! wikitext
25912 *a
25913 *
25914 *b
25915
25916 {|
25917 |-
25918 |-
25919 |foo
25920 |}
25921 !! html/parsoid
25922 <ul>
25923 <li>a</li>
25924 <li class='mw-empty-elt'></li>
25925 <li>b</li>
25926 </ul>
25927 <table>
25928 <tbody>
25929 <tr class='mw-empty-elt'></tr>
25930 <tr>
25931 <td>foo</td>
25932 </tr>
25933 </tbody>
25934 </table>
25935 !! end
25936
25937 !! test
25938 Empty TR nodes should not be stripped if they have any attributes set
25939 !! wikitext
25940 {{EmptyTRWithHTMLAttrTest}}
25941 !! html/parsoid
25942 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'>
25943 <tr align='center'></tr>
25944 <tr><td>foo</td></tr>
25945 <tr align='center'></tr>
25946 <tr><td>bar</td></tr>
25947 </table>
25948 !! end
25949
25950 #### ----------------------------------------------------------------
25951 #### The following section of tests are primarily to test
25952 #### wikitext escaping capabilities of Parsoid. Given that
25953 #### escaping can be done any number of ways, the wikitext (input)
25954 #### is always adjusted to reflect how Parsoid adds nowiki
25955 #### escape tags.
25956 ####
25957 #### We are marking several tests as parsoid-only since the
25958 #### HTML in the result section is different from what the
25959 #### PHP parser generates for it.
25960 #### ----------------------------------------------------------------
25961
25962
25963 #### --------------- Headings ---------------
25964 #### 0. Unnested
25965 #### 1. Nested inside html <h1>=foo=</h1>
25966 #### 2. Outside heading nest on a single line <h1>foo</h1>*bar
25967 #### 3. Nested inside html with wikitext split by html tags
25968 #### 4. No escape needed
25969 #### 5. Empty headings <h1></h1>
25970 #### 6. Heading chars in SOL context
25971 #### ----------------------------------------
25972 !! test
25973 Headings: 0. Unnested
25974 !! options
25975 parsoid=html2wt
25976 !! html/parsoid
25977 <p>=foo=</p>
25978
25979 <p> =foo=
25980 <!--cmt-->
25981 =foo=</p>
25982
25983 <p>=foo<i>a</i>=</p>
25984 !! wikitext
25985 <nowiki>=foo=</nowiki>
25986
25987 <nowiki> </nowiki>=foo=
25988 <!--cmt-->
25989 <nowiki>=foo=</nowiki>
25990
25991 =foo''a''<nowiki>=</nowiki>
25992 !!end
25993
25994 # New headings and existing headings are handled differently
25995 !! test
25996 Headings: 1. Nested inside html
25997 !! options
25998 parsoid=html2wt
25999 !! html/parsoid
26000 <h1>=foo=</h1>
26001 <h2>=foo=</h2>
26002 <h3>=foo=</h3>
26003
26004 <h1 data-parsoid=''>=foo=</h1>
26005 <h2 data-parsoid=''>=foo=</h2>
26006 <h3 data-parsoid=''>=foo=</h3>
26007 <h4 data-parsoid=''>=foo=</h4>
26008 <h5 data-parsoid=''>=foo=</h5>
26009 <h6 data-parsoid=''>=foo=</h6>
26010 !! wikitext
26011 = =foo= =
26012
26013 == =foo= ==
26014
26015 === =foo= ===
26016
26017 =<nowiki>=foo=</nowiki>=
26018 ==<nowiki>=foo=</nowiki>==
26019 ===<nowiki>=foo=</nowiki>===
26020 ====<nowiki>=foo=</nowiki>====
26021 =====<nowiki>=foo=</nowiki>=====
26022 ======<nowiki>=foo=</nowiki>======
26023
26024 !!end
26025
26026 !! test
26027 Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
26028 !! options
26029 parsoid=html2wt
26030 !! html/parsoid
26031 <h1>foo</h1>*bar
26032 <h1>foo</h1>=bar
26033 <h1>foo</h1>=bar=
26034 !! wikitext
26035 = foo =
26036 <nowiki>*</nowiki>bar
26037
26038 = foo =
26039 =bar
26040
26041 = foo =
26042 <nowiki>=bar=</nowiki>
26043 !!end
26044
26045 !! test
26046 Headings: 3. Nested inside html with wikitext split by html tags
26047 !! options
26048 parsoid=html2wt
26049 !! html/parsoid
26050 <h1>=<b>bold</b>foo=</h1>
26051 !! wikitext
26052 = ='''bold'''foo= =
26053 !!end
26054
26055 !! test
26056 Headings: 4a. No escaping needed (testing just h1 and h2)
26057 !! options
26058 parsoid=html2wt
26059 !! html/parsoid
26060 <h1>=foo</h1>
26061 <h1>foo=</h1>
26062 <h1> =foo= </h1>
26063 <h1>=foo= bar</h1>
26064 <h2>=foo</h2>
26065 <h2>foo=</h2>
26066 <h1>=</h1>
26067 <h1><i>=</i>foo=</h1>
26068 !! wikitext
26069 = =foo =
26070
26071 = foo= =
26072
26073 = =foo= =
26074
26075 = =foo= bar =
26076
26077 == =foo ==
26078
26079 == foo= ==
26080
26081 = = =
26082
26083 = ''=''foo= =
26084 !!end
26085
26086 !! test
26087 Headings: 4b. No escaping needed (inside p-tags)
26088 !! options
26089 parsoid=html2wt
26090 !! html/parsoid
26091 <p>=foo= x
26092 =foo= <s></s>
26093 </p>
26094 !! wikitext
26095 =foo= x
26096 =foo= <s></s>
26097 !! html/php
26098 <p>=foo= x
26099 =foo= <s></s>
26100 </p>
26101 !!end
26102
26103 !! test
26104 Headings: 4c. Short headings (1)
26105 !! options
26106 parsoid=html2wt
26107 !! html/parsoid
26108 <p>===
26109 </p>
26110 !! wikitext
26111 <nowiki>===</nowiki>
26112 !! html/php
26113 <p>===
26114 </p>
26115 !! end
26116
26117 # in the html2wt direction we emit '= = =' or '=<nowiki>=</nowiki>='
26118 !! test
26119 Headings: 4d. Short headings (2)
26120 !! options
26121 parsoid=wt2html,html2html
26122 !! wikitext
26123 =
26124 ==
26125 ===
26126 ====
26127 =====
26128 !! html/php
26129 <p>=
26130 ==
26131 </p>
26132 <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>
26133 <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>
26134 <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>
26135
26136 !! html/parsoid
26137 <p>=
26138 ==</p>
26139 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
26140 <h1 id="=="><span id=".3D.3D" typeof="mw:FallbackId"></span>==</h1>
26141 <h2 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h2>
26142 !! end
26143
26144 !! test
26145 Headings: 5. Empty headings
26146 !! options
26147 parsoid=html2wt
26148 !! html/parsoid
26149 <h1 data-parsoid='{}'></h1>
26150
26151 <h2 data-parsoid='{}'></h2>
26152
26153 <h3 data-parsoid='{}'></h3>
26154
26155 <h4 data-parsoid='{}'></h4>
26156
26157 <h5 data-parsoid='{}'></h5>
26158
26159 <h6 data-parsoid='{}'></h6>
26160 !! wikitext
26161 =<nowiki/>=
26162
26163 ==<nowiki/>==
26164
26165 ===<nowiki/>===
26166
26167 ====<nowiki/>====
26168
26169 =====<nowiki/>=====
26170
26171 ======<nowiki/>======
26172 !!end
26173
26174 !! test
26175 Headings: 6a. Heading chars in SOL context (with trailing spaces)
26176 !! options
26177 parsoid=html2wt
26178 !! html/parsoid
26179 <p>=a=</p>
26180
26181 <p>=a=</p>
26182
26183 <p>=a=</p>
26184 !! wikitext
26185 <nowiki>=a=</nowiki>
26186
26187 <nowiki>=a=</nowiki>
26188
26189 <nowiki>=a=</nowiki>
26190 !!end
26191
26192 !! test
26193 Headings: 6b. Heading chars in SOL context (with trailing newlines)
26194 !! options
26195 parsoid=html2wt
26196 !! html/parsoid
26197 <p>=a=
26198 b</p>
26199
26200 <p>=a=
26201 b</p>
26202
26203 <p>=a=
26204 b</p>
26205 !! wikitext
26206 <nowiki>=a=</nowiki>
26207 b
26208
26209 <nowiki>=a=</nowiki>
26210 b
26211
26212 <nowiki>=a=</nowiki>
26213 b
26214 !!end
26215
26216 !! test
26217 Headings: 6c. Heading chars in SOL context (leading newline break)
26218 !! options
26219 parsoid=html2wt
26220 !! html/parsoid
26221 <p>a
26222 =b=</p>
26223 !! wikitext
26224 a
26225 <nowiki>=b=</nowiki>
26226 !!end
26227
26228 !! test
26229 Headings: 6d. Heading chars in SOL context (with interspersed comments)
26230 !! options
26231 parsoid=html2wt
26232 !! html/parsoid
26233 <!--c0--><p>=a=</p>
26234
26235 <!--c1--><p>=a=</p> <!--c2--> <!--c3-->
26236 !! wikitext
26237 <!--c0--><nowiki>=a=</nowiki>
26238
26239 <!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3-->
26240 !!end
26241
26242 !! test
26243 Headings: 6d. Heading chars in SOL context (No escaping needed)
26244 !! options
26245 parsoid=html2wt
26246 !! html/parsoid
26247 =a=<div>b</div>
26248 !! wikitext
26249 =a=<div>b</div>
26250 !!end
26251
26252 !! test
26253 Headings: 7. Insert a newline between new content and headings
26254 !! options
26255 parsoid=html2wt
26256 !! html/parsoid
26257 <h2>NEW</h2>
26258 <p>new</p>
26259 <h2 data-parsoid='{}'>A</h2>
26260 <p data-parsoid='{}'>a</p>
26261 !! wikitext
26262 == NEW ==
26263 new
26264
26265 ==A==
26266 a
26267
26268 !! end
26269
26270 !! test
26271 Headings: Used as horizontal rule
26272 !! config
26273 wgFragmentMode=[ 'html5', 'legacy' ]
26274 !! options
26275 parsoid=wt2html
26276 !! wikitext
26277 ===============
26278 !! html/php
26279 <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>
26280
26281 !! html/parsoid
26282 <h6 id="==="><span id=".3D.3D.3D" typeof="mw:FallbackId"></span>===</h6>
26283 !! end
26284
26285 #### --------------- Lists ---------------
26286 #### 0. Outside nests (*foo, etc.)
26287 #### 1. Nested inside html <ul><li>*foo</li></ul>
26288 #### 2. Inside definition lists
26289 #### 3. Only bullets at start should be escaped
26290 #### 4. No escapes needed
26291 #### 5. No unnecessary escapes
26292 #### 6. Escape bullets in SOL position
26293 #### 7. Escape bullets in a multi-line context
26294 #### ----------------------------------------
26295
26296 !! test
26297 Lists: 0. Outside nests
26298 !! options
26299 parsoid=html2wt
26300 !! html/parsoid
26301 <p>*foo</p>
26302
26303 <p>#foo</p>
26304
26305 <p>;Foo:bar</p>
26306 !! wikitext
26307 <nowiki>*</nowiki>foo
26308
26309 <nowiki>#</nowiki>foo
26310
26311 <nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar
26312 !!end
26313
26314 ## Making these next 3 tests Parsoid-only since they are html2wt tests
26315 ## to test wikitext escaping, and insignificant whitespace diffs
26316 ## cause PHP parser tests to barf
26317 !! test
26318 Lists: 1. Nested inside html (No unnecessary escapes)
26319 !! options
26320 parsoid=html2wt
26321 !! html/parsoid
26322 <ul>
26323 <li>*foo</li>
26324 <li>#foo</li>
26325 <li>:foo</li>
26326 <li>;foo</li>
26327 <li data-parsoid='{}'>*foo</li>
26328 <li data-parsoid='{}'>#foo</li>
26329 <li data-parsoid='{}'>:foo</li>
26330 <li data-parsoid='{}'>;foo</li>
26331 </ul>
26332
26333 <ol>
26334 <li>*foo</li>
26335 <li>#foo</li>
26336 <li>:foo</li>
26337 <li>;foo</li>
26338 <li data-parsoid='{}'>*foo</li>
26339 <li data-parsoid='{}'>#foo</li>
26340 <li data-parsoid='{}'>:foo</li>
26341 <li data-parsoid='{}'>;foo</li>
26342 </ol>
26343 !! wikitext
26344 * *foo
26345 * #foo
26346 * :foo
26347 * ;foo
26348 *<nowiki>*foo</nowiki>
26349 *<nowiki>#foo</nowiki>
26350 *<nowiki>:foo</nowiki>
26351 *<nowiki>;foo</nowiki>
26352
26353 # *foo
26354 # #foo
26355 # :foo
26356 # ;foo
26357 #<nowiki>*foo</nowiki>
26358 #<nowiki>#foo</nowiki>
26359 #<nowiki>:foo</nowiki>
26360 #<nowiki>;foo</nowiki>
26361 !!end
26362
26363 !! test
26364 Lists: 2. Inside definition lists
26365 !! options
26366 parsoid=html2wt
26367 !! html/parsoid
26368 <dl><dt>;foo</dt></dl>
26369 <dl><dt>:foo</dt></dl>
26370 <dl><dt>:foo</dt>
26371 <dd>bar</dd></dl>
26372 <dl><dd>:foo</dd></dl>
26373 !! wikitext
26374 ; ;foo
26375
26376 ; <nowiki>:foo</nowiki>
26377
26378 ; <nowiki>:foo</nowiki>
26379 : bar
26380
26381 : :foo
26382 !!end
26383
26384 !! test
26385 Lists: 3. Only bullets at start of text in wikitext-generated HTML should be escaped
26386 !! options
26387 parsoid=html2wt
26388 !! html/parsoid
26389 <ul>
26390 <li>*foo*bar</li>
26391 <li data-parsoid='{}'>*foo<i>it</i>*bar</li>
26392 </ul>
26393 !! wikitext
26394 * *foo*bar
26395 *<nowiki>*foo</nowiki>''it''*bar
26396 !!end
26397
26398 !! test
26399 Lists: 4. No escapes needed
26400 !! options
26401 parsoid=html2wt
26402 !! html/parsoid
26403 <ul>
26404 <li>foo*bar
26405 </li>
26406 </ul>
26407 <ul>
26408 <li><i>foo</i>*bar
26409 </li>
26410 </ul>
26411 <ul>
26412 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>: bar
26413 </li>
26414 </ul>
26415 <ul>
26416 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar
26417 </li>
26418 </ul>
26419 !! wikitext
26420 *foo*bar
26421
26422 *''foo''*bar
26423
26424 *[[Foo]]: bar
26425
26426 *[[Foo]]*bar
26427 !!end
26428
26429 !! test
26430 Lists: 5. No unnecessary escapes
26431 !! options
26432 parsoid=html2wt
26433 !! html/parsoid
26434 <ul><li> bar <span>[[foo]]</span></li></ul>
26435 <ul><li> =bar <span>[[foo]]</span></li></ul>
26436 <ul><li> [[bar <span>[[foo]]</span></li></ul>
26437 <ul><li> ]]bar <span>[[foo]]</span></li></ul>
26438 <ul><li> =bar <span>foo]]</span>=</li></ul>
26439 <ul><li> <s></s>: a</li></ul>
26440 <ul><li> <i>* foo</i></li></ul>
26441
26442 !! wikitext
26443 * bar <span><nowiki>[[foo]]</nowiki></span>
26444
26445 * =bar <span><nowiki>[[foo]]</nowiki></span>
26446
26447 * [[bar <span><nowiki>[[foo]]</nowiki></span>
26448
26449 * ]]bar <span><nowiki>[[foo]]</nowiki></span>
26450
26451 * =bar <span>foo]]</span>=
26452
26453 * <s></s>: a
26454
26455 * ''* foo''
26456 !!end
26457
26458 !! test
26459 Lists: 6. Escape bullets in SOL position
26460 !! options
26461 parsoid=html2wt
26462 !! html/parsoid
26463 <p><!--cmt-->*foo</p>
26464 !! wikitext
26465 <!--cmt--><nowiki>*</nowiki>foo
26466 !!end
26467
26468 !! test
26469 Lists: 7. Escape bullets in a multi-line context
26470 !! options
26471 parsoid=html2wt
26472 !! html/parsoid
26473 <p>a
26474 *b
26475 </p>
26476 !! wikitext
26477 a
26478 <nowiki>*</nowiki>b
26479 !!end
26480
26481 !! test
26482 Lists: 8. Escape colons only if not present in tags
26483 !! options
26484 parsoid=html2wt
26485 !! html/parsoid
26486 <dl><dt>a:b<i>c:d</i></dt></dl>
26487 !! wikitext
26488 ; <nowiki>a:b</nowiki>''c:d''
26489 !! end
26490
26491 #### --------------- HRs ---------------
26492 #### 1. Single line
26493 #### -----------------------------------
26494
26495 !! test
26496 HRs: 1. Single line
26497 !! options
26498 parsoid=html2wt
26499 !! html/parsoid
26500 <hr />----
26501 <hr />=foo=
26502 <hr />*foo
26503 !! wikitext
26504 ----<nowiki>----</nowiki>
26505 ----=foo=
26506 ----*foo
26507 !! end
26508
26509 #### --------------- Tables ---------------
26510 #### 1a. Simple example
26511 #### 1b. No escaping needed (!foo)
26512 #### 1c. No escaping needed (|foo)
26513 #### 1d. No escaping needed (|}foo)
26514 ####
26515 #### 2a. Nested in td (<td>foo|bar</td>)
26516 #### 2b. Nested in td (<td>foo||bar</td>)
26517 #### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
26518 ####
26519 #### 3a. Nested in th (<th>foo!bar</th>)
26520 #### 3b. Nested in th (<th>foo!!bar</th>)
26521 #### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
26522 ####
26523 #### 4a. Escape -
26524 #### 4b. Escape +
26525 #### 4c. No escaping needed
26526 #### --------------------------------------
26527
26528 !! test
26529 Tables: 1a. Simple example
26530 !! options
26531 parsoid=html2wt
26532 !! html/parsoid
26533 <p>{|
26534 |}
26535 </p>
26536 !! wikitext
26537 <nowiki>{|</nowiki>
26538 |}
26539 !! end
26540
26541 !! test
26542 Tables: 1b. No escaping needed
26543 !! options
26544 parsoid=html2wt
26545 !! html/parsoid
26546 <p>!foo
26547 </p>
26548 !! wikitext
26549 !foo
26550 !! end
26551
26552 !! test
26553 Tables: 1c. No escaping needed
26554 !! options
26555 parsoid=html2wt
26556 !! html/parsoid
26557 <p>|foo
26558 </p>
26559 !! wikitext
26560 |foo
26561 !! end
26562
26563 !! test
26564 Tables: 1d. No escaping needed
26565 !! options
26566 parsoid=html2wt
26567 !! html/parsoid
26568 <p>|}foo
26569 </p>
26570 !! wikitext
26571 |}foo
26572 !! end
26573
26574 !! test
26575 Tables: 2a. Nested in td
26576 !! options
26577 parsoid=html2wt
26578 !! html/parsoid
26579 <table><tbody><tr>
26580 <td>foo|bar</td></tr>
26581 <tr><td>x<div>a|b</div></td>
26582 </tbody></table>
26583 !! wikitext
26584 {|
26585 |<nowiki>foo|bar</nowiki>
26586 |-
26587 |x<div><nowiki>a|b</nowiki></div>
26588 |}
26589 !! html/php+tidy
26590 <table>
26591 <tbody><tr>
26592 <td>foo|bar
26593 </td></tr>
26594 <tr>
26595 <td>x<div>a|b</div>
26596 </td></tr></tbody></table>
26597 !! end
26598
26599 !! test
26600 Tables: 2b. Nested in td
26601 !! options
26602 parsoid=html2wt
26603 !! html/parsoid
26604 <table><tbody><tr>
26605 <td>foo||bar</td>
26606 <td>a<i>b||c</i></td>
26607 <td>a<i><div>b||c</div></i></td>
26608 </tr></tbody></table>
26609 !! wikitext
26610 {|
26611 |<nowiki>foo||bar</nowiki>
26612 |a''<nowiki>b||c</nowiki>''
26613 |a''<div><nowiki>b||c</nowiki></div>''
26614 |}
26615 !! html/php
26616 <table>
26617 <tr>
26618 <td>foo||bar
26619 </td>
26620 <td>a<i>b||c</i>
26621 </td>
26622 <td>a<i><div>b||c</div></i>
26623 </td></tr></table>
26624
26625 !! end
26626
26627 !! test
26628 Tables: 2c. Nested in td -- no escaping needed
26629 !! options
26630 parsoid=html2wt
26631 !! html/*
26632 <table>
26633 <tr>
26634 <td>foo!!bar
26635 </td></tr></table>
26636
26637 !! wikitext
26638 {|
26639 |foo!!bar
26640 |}
26641 !! end
26642
26643 !! test
26644 Tables: 3a. Nested in th
26645 !! options
26646 parsoid=html2wt
26647 !! html/*
26648 <table>
26649 <tr>
26650 <th>foo!bar
26651 </th></tr></table>
26652
26653 !! wikitext
26654 {|
26655 !foo!bar
26656 |}
26657 !! end
26658
26659 !! test
26660 Tables: 3b. Nested in th
26661 !! options
26662 parsoid=html2wt
26663 !! html/parsoid
26664 <table><tbody>
26665 <tr><th>foo!!bar</th>
26666 <th><i>foo|bar</i></th>
26667 <th><i>foo!!bar</i></th>
26668 <th><i><span>foo!!bar</span></i></th>
26669 </tr></tbody></table>
26670 !! wikitext
26671 {|
26672 !<nowiki>foo!!bar</nowiki>
26673 !''<nowiki>foo|bar</nowiki>''
26674 !''<nowiki>foo!!bar</nowiki>''
26675 !''<span><nowiki>foo!!bar</nowiki></span>''
26676 |}
26677 !! html/php
26678 <table>
26679 <tr>
26680 <th>foo!!bar
26681 </th>
26682 <th><i>foo|bar</i>
26683 </th>
26684 <th><i>foo!!bar</i>
26685 </th>
26686 <th><i><span>foo!!bar</span></i>
26687 </th></tr></table>
26688
26689 !! end
26690
26691 !! test
26692 Tables: 3c. Nested in th
26693 !! options
26694 parsoid=html2wt
26695 !! html/parsoid
26696 <table><tbody>
26697 <tr><th>foo||bar</th>
26698 <th><span typeof="mw:Nowiki">foo||bar</span></th>
26699 </tr></tbody></table>
26700 !! wikitext
26701 {|
26702 !<nowiki>foo||bar</nowiki>
26703 !<nowiki>foo||bar</nowiki>
26704 |}
26705 !! html/php
26706 <table>
26707 <tr>
26708 <th>foo||bar
26709 </th>
26710 <th>foo||bar
26711 </th></tr></table>
26712
26713 !! end
26714
26715 !! test
26716 Tables: 4a. Escape -
26717 !! options
26718 parsoid=html2wt
26719 !! html/*
26720 <table>
26721 <tr>
26722 <th>-bar
26723 </th></tr>
26724 <tr>
26725 <td>-bar
26726 </td></tr></table>
26727
26728 !! wikitext
26729 {|
26730 !-bar
26731 |-
26732 |<nowiki>-bar</nowiki>
26733 |}
26734 !! end
26735
26736 !! test
26737 Tables: 4b. Escape +
26738 !! options
26739 parsoid=html2wt
26740 !! html/*
26741 <table>
26742 <tr>
26743 <th>+bar
26744 </th></tr>
26745 <tr>
26746 <td>+bar
26747 </td></tr></table>
26748
26749 !! wikitext
26750 {|
26751 !+bar
26752 |-
26753 |<nowiki>+bar</nowiki>
26754 |}
26755 !! end
26756
26757 !! test
26758 Tables: 4c. No escaping needed
26759 !! options
26760 parsoid=html2wt
26761 !! html/parsoid
26762 <table><tbody>
26763 <tr><td>foo-bar</td><td>foo+bar</td></tr>
26764 <tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
26765 <tr><td>foo
26766 <p>bar|baz
26767 +bar
26768 -bar</p></td></tr>
26769 <tr><td>x
26770 <div>a|b</div></td>
26771 </tbody></table>
26772 !! wikitext
26773 {|
26774 |foo-bar
26775 |foo+bar
26776 |-
26777 |''foo''-bar
26778 |''foo''+bar
26779 |-
26780 |foo
26781 bar|baz
26782 +bar
26783 -bar
26784 |-
26785 |x
26786 <div>a|b</div>
26787 |}
26788 !! html/php
26789 <table>
26790 <tr>
26791 <td>foo-bar
26792 </td>
26793 <td>foo+bar
26794 </td></tr>
26795 <tr>
26796 <td><i>foo</i>-bar
26797 </td>
26798 <td><i>foo</i>+bar
26799 </td></tr>
26800 <tr>
26801 <td>foo
26802 <p>bar|baz
26803 +bar
26804 -bar
26805 </p>
26806 </td></tr>
26807 <tr>
26808 <td>x
26809 <div>a|b</div>
26810 </td></tr></table>
26811
26812 !! end
26813
26814 !! test
26815 Tables: 4d. No escaping needed
26816 !! options
26817 parsoid=html2wt
26818 !! html/parsoid
26819 <table>
26820 <tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
26821 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
26822 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
26823 </tbody></table>
26824 !! wikitext
26825 {|
26826 |[[Foo]]-bar
26827 ||+1
26828 ||-2
26829 |}
26830 !! html/php
26831 <table>
26832 <tr>
26833 <td><a href="/wiki/Foo" title="Foo">Foo</a>-bar
26834 </td>
26835 <td>+1
26836 </td>
26837 <td>-2
26838 </td></tr></table>
26839
26840 !! end
26841
26842 !! test
26843 Tables: 4e. Escape }
26844 !! options
26845 parsoid=html2wt
26846 !! html/parsoid
26847 <table>
26848 <tr><td>}</td></tr>
26849 <tr><td>x</td><td data-parsoid='{"stx":"row"}'>}</td></tr></table>
26850 </table>
26851 !! wikitext
26852 {|
26853 |<nowiki>}</nowiki>
26854 |-
26855 |x||}
26856 |}
26857 !! html/php
26858 <table>
26859 <tr>
26860 <td>}
26861 </td></tr>
26862 <tr>
26863 <td>x</td>
26864 <td>}
26865 </td></tr></table>
26866
26867 !! end
26868
26869 !! test
26870 Tables: 5. Empty table cells should get whitespace to avoid need for nowikis
26871 !! options
26872 parsoid=html2wt
26873 !! html/parsoid
26874 <table><tr><td></td><td align="center" data-parsoid='{"stx":"row"}'></td><td data-parsoid='{"stx":"row"}'></td></tr></table>
26875
26876 <table><tr><td></td><td align="center"></td><td></td></tr></table>
26877
26878 <table><tr><td></td><td align="center" data-parsoid='{"stx":"row", "startTagSrc":"{{!}}{{!}}"}'></td><td data-parsoid='{"stx":"row"}'></td></tr></table>
26879
26880 <table><tr><th></th><th align="center" data-parsoid='{"stx":"row"}'></th><th data-parsoid='{"stx":"row"}'></th></tr></table>
26881 !! wikitext
26882 {|
26883 | || align="center" | ||
26884 |}
26885
26886 {|
26887 |
26888 | align="center" |
26889 |
26890 |}
26891
26892 {|
26893 | {{!}}{{!}} align="center" | ||
26894 |}
26895
26896 {|
26897 ! !! align="center" | !!
26898 |}
26899 !! html/php+tidy
26900 <table>
26901 <tbody><tr>
26902 <td></td>
26903 <td align="center"></td>
26904 <td>
26905 </td></tr></tbody></table>
26906 <table>
26907 <tbody><tr>
26908 <td>
26909 </td>
26910 <td align="center">
26911 </td>
26912 <td>
26913 </td></tr></tbody></table>
26914 <table>
26915 <tbody><tr>
26916 <td></td>
26917 <td align="center"></td>
26918 <td>
26919 </td></tr></tbody></table>
26920 <table>
26921 <tbody><tr>
26922 <th></th>
26923 <th align="center"></th>
26924 <th>
26925 </th></tr></tbody></table>
26926 !! end
26927
26928 !! test
26929 T97430: Don't emit empty nowiki pairs around marker meta tags
26930 !! options
26931 parsoid=html2wt
26932 !! html/parsoid
26933 <p>*This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
26934 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
26935 !! wikitext
26936 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
26937 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
26938 !! end
26939
26940 !! test
26941 Unclosed xmlish element in table line shouldn't eat end delimiters
26942 !! options
26943 parsoid=html2wt
26944 !! html/parsoid
26945 <table>
26946 <tbody><tr><td> &lt;foo</td>
26947 <td> bar></td></tr>
26948 </tbody></table>
26949 !! wikitext
26950 {|
26951 | <foo
26952 | bar>
26953 |}
26954 !! html/php
26955 <table>
26956 <tr>
26957 <td>&lt;foo
26958 </td>
26959 <td>bar&gt;
26960 </td></tr></table>
26961
26962 !! end
26963
26964 #### --------------- Links ----------------
26965 #### 1. Quote marks in link text
26966 #### 2. Wikilinks: Escapes needed
26967 #### 3. Wikilinks: No escapes needed
26968 #### 4. Extlinks: Escapes needed
26969 #### 5. Extlinks: No escapes needed
26970 #### --------------------------------------
26971 !! test
26972 Links 1. WikiLinks: No escapes needed
26973 !! options
26974 parsoid=html2wt
26975 !! html/parsoid
26976 <p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
26977 <a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
26978 <a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
26979 !! wikitext
26980 [[Foo|Foo''boo'']]
26981 [[Foo|[Foobar]]]
26982 [[Foo|x [Foobar] x]]
26983 !! html/php
26984 <p><a href="/wiki/Foo" title="Foo">Foo<i>boo</i></a>
26985 <a href="/wiki/Foo" title="Foo">[Foobar]</a>
26986 <a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
26987 </p>
26988 !! end
26989
26990 !! test
26991 Links 2. WikiLinks: Escapes needed
26992 !! options
26993 parsoid=html2wt
26994 !! html/parsoid
26995 <a href="Foo" rel="mw:WikiLink">Foobar]</a>
26996 <a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
26997 <a href="Foo" rel="mw:WikiLink">[[Bar]]</a>
26998 <a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a>
26999 <a href="Foo" rel="mw:WikiLink">|Bar</a>
27000 <a href="Foo" rel="mw:WikiLink">]]bar</a>
27001 <a href="Foo" rel="mw:WikiLink">[[bar</a>
27002 <a href="Foo" rel="mw:WikiLink">x [[ y</a>
27003 <a href="Foo" rel="mw:WikiLink">x ]] y</a>
27004 <a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a>
27005 !! wikitext
27006 [[Foo|<nowiki>Foobar]</nowiki>]]
27007 [[Foo|x <nowiki>[http://google.com g]</nowiki> x]]
27008 [[Foo|<nowiki>[[Bar]]</nowiki>]]
27009 [[Foo|<nowiki>x [[Bar]] x</nowiki>]]
27010 [[Foo|<nowiki>|Bar</nowiki>]]
27011 [[Foo|<nowiki>]]bar</nowiki>]]
27012 [[Foo|<nowiki>[[bar</nowiki>]]
27013 [[Foo|<nowiki>x [[ y</nowiki>]]
27014 [[Foo|<nowiki>x ]] y</nowiki>]]
27015 [[Foo|<nowiki>x ]] y [[ z</nowiki>]]
27016 !! html/php
27017 <p><a href="/wiki/Foo" title="Foo">Foobar]</a>
27018 <a href="/wiki/Foo" title="Foo">x [http://google.com g] x</a>
27019 <a href="/wiki/Foo" title="Foo">[[Bar]]</a>
27020 <a href="/wiki/Foo" title="Foo">x [[Bar]] x</a>
27021 <a href="/wiki/Foo" title="Foo">|Bar</a>
27022 <a href="/wiki/Foo" title="Foo">]]bar</a>
27023 <a href="/wiki/Foo" title="Foo">[[bar</a>
27024 <a href="/wiki/Foo" title="Foo">x [[ y</a>
27025 <a href="/wiki/Foo" title="Foo">x ]] y</a>
27026 <a href="/wiki/Foo" title="Foo">x ]] y [[ z</a>
27027 </p>
27028 !! end
27029
27030 !! test
27031 Links 3. WikiLinks: No escapes needed
27032 !! options
27033 parsoid=html2wt
27034 !! html/parsoid
27035 <p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
27036 <a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
27037 !! wikitext
27038 [[Foo|[Foobar]]
27039 [[Foo|foo|bar]]
27040 !! html/php
27041 <p><a href="/wiki/Foo" title="Foo">[Foobar</a>
27042 <a href="/wiki/Foo" title="Foo">foo|bar</a>
27043 </p>
27044 !! end
27045
27046 !! test
27047 Links 4. ExtLinks: Escapes needed
27048 !! options
27049 parsoid=html2wt
27050 !! html/parsoid
27051 <p><a rel="mw:ExtLink" href="http://google.com">[google]</a>
27052 <a rel="mw:ExtLink" href="http://google.com">google]</a>
27053 <a rel="mw:ExtLink" href="http://google.com">goog] le</a></p>
27054 <p>[http://google.com]</p>
27055 <p>[http://google.com google]</p>
27056 <p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p>
27057 <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>
27058 !! wikitext
27059 [http://google.com <nowiki>[google]</nowiki>]
27060 [http://google.com <nowiki>google]</nowiki>]
27061 [http://google.com <nowiki>goog] le</nowiki>]
27062
27063 <nowiki>[http://google.com]</nowiki>
27064
27065 <nowiki>[http://google.com google]</nowiki>
27066
27067 [http://google.com<nowiki>]</nowiki>
27068
27069 [{{echo|http://google.com}}<nowiki>]</nowiki>
27070 !! html/php
27071 <p><a rel="nofollow" class="external text" href="http://google.com">[google]</a>
27072 <a rel="nofollow" class="external text" href="http://google.com">google]</a>
27073 <a rel="nofollow" class="external text" href="http://google.com">goog] le</a>
27074 </p><p>[http://google.com]
27075 </p><p>[http://google.com google]
27076 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
27077 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
27078 </p>
27079 !! end
27080
27081 !! test
27082 Links 5. ExtLinks: No escapes needed
27083 !! options
27084 parsoid=html2wt
27085 !! html/parsoid
27086 <p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
27087 <p>[<a ref="mw:ExtLink" href="http://google.com"></a>]</p>
27088 !! wikitext
27089 [http://google.com [google]
27090
27091 [[http://google.com]]
27092 !! html/php
27093 <p><a rel="nofollow" class="external text" href="http://google.com">[google</a>
27094 </p><p>[<a rel="nofollow" class="external autonumber" href="http://google.com">[1]</a>]
27095 </p>
27096 !! end
27097
27098 !! test
27099 Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300)
27100 !! options
27101 parsoid=html2wt
27102 !! html/parsoid
27103 <p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y
27104 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>?x
27105 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>&amp;x
27106 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>'x
27107 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,x
27108 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.x
27109 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
27110 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>:x
27111 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
27112 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>!x
27113 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>=x
27114 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>(x)
27115 <a rel="mw:ExtLink" href="http://example.com(x" data-parsoid='{"stx":"url"}'>http://example.com(x</a>)
27116 </p>
27117 !! wikitext
27118 x<nowiki/>http://example.com<nowiki/>y
27119 http://example.com<nowiki/>?x
27120 http://example.com<nowiki/>&x
27121 http://example.com<nowiki/>'x
27122 http://example.com<nowiki/>,x
27123 http://example.com<nowiki/>.x
27124 http://example.com<nowiki/>;x
27125 http://example.com<nowiki/>:x
27126 http://example.com<nowiki/>;x
27127 http://example.com<nowiki/>!x
27128 http://example.com<nowiki/>=x
27129 http://example.com<nowiki/>(x)
27130 http://example.com(x<nowiki/>)
27131 !! end
27132
27133 !! test
27134 Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
27135 !! options
27136 parsoid=html2wt
27137 !! html/parsoid
27138 <p>x
27139 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>
27140 y
27141 "<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>"
27142 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>)
27143 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>) foo
27144 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,
27145 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, foo
27146 </p>
27147 !! wikitext
27148 x
27149 http://example.com
27150 y
27151 "http://example.com"
27152 (http://example.com)
27153 (http://example.com) foo
27154 http://example.com,
27155 http://example.com, foo
27156 !! html/php
27157 <p>x
27158 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
27159 y
27160 "<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>"
27161 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
27162 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) foo
27163 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
27164 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, foo
27165 </p>
27166 !! end
27167
27168 !! test
27169 Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
27170 !! options
27171 parsoid=html2wt
27172 !! html/parsoid
27173 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\
27174 -<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p>
27175 !! wikitext
27176 http://example.com.,;:!?\
27177 -http://example.com:
27178 !! html/php
27179 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.,;:!?\
27180 -<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
27181 </p>
27182 !! end
27183
27184 !! test
27185 Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
27186 !! options
27187 parsoid=html2wt
27188 !! html/parsoid
27189 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
27190 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
27191 X<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
27192 !! wikitext
27193 RFC 123<nowiki/>4
27194 RFC 123<nowiki/>y
27195 X<nowiki/>RFC 123<nowiki/>y
27196 !! end
27197
27198 !! test
27199 Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
27200 !! options
27201 parsoid=html2wt
27202 !! html/parsoid
27203 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
27204 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
27205 -<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
27206 </p>
27207 !! wikitext
27208 RFC 123?foo
27209 RFC 123&foo
27210 -RFC 123-
27211 !! html/php
27212 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>?foo
27213 <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
27214 -<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>-
27215 </p>
27216 !! end
27217
27218 !! test
27219 Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300)
27220 !! options
27221 parsoid=html2wt
27222 !! html/parsoid
27223 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4
27224 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
27225 X<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
27226 !! wikitext
27227 PMID 123<nowiki/>4
27228 PMID 123<nowiki/>y
27229 X<nowiki/>PMID 123<nowiki/>y
27230 !! end
27231
27232 !! test
27233 Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300)
27234 !! options
27235 parsoid=html2wt
27236 !! html/parsoid
27237 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo
27238 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo
27239 -<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>-
27240 </p>
27241 !! wikitext
27242 PMID 123?foo
27243 PMID 123&foo
27244 -PMID 123-
27245 !! html/php
27246 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>?foo
27247 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>&amp;foo
27248 -<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>-
27249 </p>
27250 !! end
27251
27252 !! test
27253 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300)
27254 !! options
27255 parsoid=html2wt
27256 !! html/parsoid
27257 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
27258 <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
27259 a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
27260 </p>
27261 !! wikitext
27262 ISBN 1234567890<nowiki/>1
27263 ISBN 1234567890<nowiki/>x
27264 a<nowiki/>ISBN 1234567890<nowiki/>b
27265 !! end
27266
27267 !! test
27268 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (T66300)
27269 !! options
27270 parsoid=html2wt
27271 !! html/parsoid
27272 <p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
27273 !! wikitext
27274 -ISBN 1234567890's
27275 !! html/php
27276 <p>-<a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>'s
27277 </p>
27278 !! end
27279
27280 !! test
27281 Links 14. Protect link-like plain text. (Parsoid bug T78425)
27282 !! options
27283 parsoid=html2wt
27284 !! html/*
27285 <p>this is not a link: http://example.com
27286 </p>
27287 !! wikitext
27288 this is not a link: <nowiki>http://example.com</nowiki>
27289 !! end
27290
27291 !! test
27292 Links 15. Link trails can't become link prefixes.
27293 !! options
27294 language=is
27295 parsoid=html2wt
27296 !! html/parsoid
27297 <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>
27298 !! wikitext
27299 [[Söfnuður]]-[[00]]
27300 !! html/php
27301 <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>
27302 </p>
27303 !! end
27304
27305 #### --------------- Quotes ---------------
27306 #### 1. Quotes inside <b> and <i>
27307 #### 2. Link fragments separated by <i> and <b> tags
27308 #### 3. Link fragments inside <i> and <b>
27309 #### 4. No escaping needed
27310 #### --------------------------------------
27311 !! test
27312 1a. Quotes inside <b> and <i>
27313 !! options
27314 parsoid=html2wt
27315 !! html/*
27316 <p><i>'foo'</i>
27317 <i>''foo''</i>
27318 <i>'''foo'''</i>
27319 <i>foo</i>'s
27320 <b>'foo'</b>
27321 <b>''foo''</b>
27322 <b>'''foo'''</b>
27323 <b>foo'<i>bar'</i>baz</b>
27324 <b>foo</b>'s
27325 '<i>foo</i>
27326 <i>foo</i>'
27327 <i>foo'</i>'
27328 '<i>foo</i>'
27329 '<b>foo</b>
27330 <b>foo</b>'
27331 '<b>foo</b>'
27332 <i>fools'<span> errand</span></i>
27333 <i><span>fool</span>'s errand</i>
27334 '<i>foo</i> bar '<i>baz</i>
27335 a|!*#-:;+-~[]{}b'<i>x</i>
27336 </p>
27337 !! wikitext
27338 ''<nowiki/>'foo'''
27339 ''<nowiki>''foo''</nowiki>''
27340 ''<nowiki>'''foo'''</nowiki>''
27341 ''foo''<nowiki/>'s
27342 '''<nowiki/>'foo''''
27343 '''<nowiki>''foo''</nowiki>'''
27344 '''<nowiki>'''foo'''</nowiki>'''
27345 '''foo'<nowiki/>''bar'<nowiki/>''baz'''
27346 '''foo'''<nowiki/>'s
27347 '''foo''
27348 ''foo''<nowiki/>'
27349 ''foo'''<nowiki/>'
27350 '''foo''<nowiki/>'
27351 ''''foo'''
27352 '''foo'''<nowiki/>'
27353 ''''foo'''<nowiki/>'
27354 ''fools'<span> errand</span>''
27355 ''<span>fool</span>'s errand''
27356 '<nowiki/>''foo'' bar '''baz''
27357 a|!*#-:;+-~[]{}b'''x''
27358 !! end
27359
27360 !! test
27361 1b. Quotes inside <b> and <i> with other tags on same line
27362 !! options
27363 parsoid=html2wt
27364 !! html/parsoid
27365 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
27366 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
27367 <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>
27368 <a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" rel="mw:WikiLink" title="Bar">bar</a></i>
27369 '<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>
27370 '<i>foo</i> <div title="name">test</div>
27371 '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
27372 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
27373 <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>
27374 </ol>
27375 !! wikitext
27376 '''a'' foo ''[[bar]]''
27377 ''a''' foo ''[[bar]]''
27378 ''a''' foo '''{{echo|[[bar]]}}'''
27379 [[foo]] x'''[[bar]]''
27380 '''foo'' <ref>test</ref>
27381 '''foo'' <div title="name">test</div>
27382 '''foo'' and <br> bar
27383 <references />
27384 !! end
27385
27386 !! test
27387 2. Link fragments separated by <i> and <b> tags
27388 !! options
27389 parsoid=html2wt
27390 !! html/parsoid
27391 <p>[[<i>foo</i>hello]]</p>
27392 <p>[[<b>foo</b>hello]]</p>
27393 !! wikitext
27394 [[''foo''<nowiki>hello]]</nowiki>
27395
27396 [['''foo'''<nowiki>hello]]</nowiki>
27397 !! end
27398
27399 # FIXME: Escaping one or both of [[ and ]] is also acceptable --
27400 # this is one of the shortcomings of this format
27401 !! test
27402 3. Link fragments inside <i> and <b>
27403 !! options
27404 parsoid=html2wt
27405 !! html/parsoid
27406 <p><i>[[foo</i>]]</p>
27407 <p><b>[[foo</b>]]</p>
27408 !! wikitext
27409 ''[[foo''<nowiki>]]</nowiki>
27410
27411 '''[[foo'''<nowiki>]]</nowiki>
27412 !! end
27413
27414 !! test
27415 4. No escaping needed
27416 !! options
27417 parsoid=html2wt
27418 !! html/parsoid
27419 <p>'<span><i>bar</i></span>'
27420 '<span><b>bar</b></span>'
27421 'a:b'foo
27422 </p>
27423 !! wikitext
27424 '<span>''bar''</span>'
27425 '<span>'''bar'''</span>'
27426 'a:b'foo
27427 !! end
27428
27429 #### ----------- Paragraphs ---------------
27430 #### 1. No unnecessary escapes
27431 #### --------------------------------------
27432
27433 !! test
27434 1. No unnecessary escapes
27435 !! options
27436 parsoid=html2wt
27437 !! html/parsoid
27438 <p>bar <span>[[foo]]</span>
27439 </p><p>=bar <span>[[foo]]</span>
27440 </p><p>[[bar <span>[[foo]]</span>
27441 </p><p>]]bar <span>[[foo]]</span>
27442 </p><p>=bar <span>foo]]</span>=
27443 </p>
27444 !! wikitext
27445 bar <span><nowiki>[[foo]]</nowiki></span>
27446
27447 =bar <span><nowiki>[[foo]]</nowiki></span>
27448
27449 [[bar <span><nowiki>[[foo]]</nowiki></span>
27450
27451 ]]bar <span><nowiki>[[foo]]</nowiki></span>
27452
27453 =bar <span>foo]]</span><nowiki>=</nowiki>
27454 !!end
27455
27456 #### ----------------------- PRE --------------------------
27457 !! test
27458 1. Leading whitespace in SOL context should be escaped
27459 !! options
27460 parsoid=html2wt
27461 !! html/parsoid
27462 <p> a</p>
27463
27464 <p> a</p>
27465
27466 <p> a(tab)</p>
27467
27468 <p> a
27469 <!--cmt-->
27470 a</p>
27471
27472 <p>a
27473 b</p>
27474
27475 <p>a
27476 b</p>
27477
27478 <p>a
27479 b</p>
27480 !! wikitext
27481 <nowiki> </nowiki>a
27482
27483 <nowiki> </nowiki> a
27484
27485 a(tab)
27486
27487 <nowiki> </nowiki> a
27488 <!--cmt-->
27489 <nowiki> </nowiki>a
27490
27491 a
27492 <nowiki> </nowiki>b
27493
27494 a
27495 b
27496
27497 a
27498 b
27499 !! html/php
27500 <p> a
27501 </p><p> a
27502 </p><p> a(tab)
27503 </p><p> a
27504 a
27505 </p><p>a
27506 b
27507 </p><p>a
27508 b
27509 </p><p>a
27510 b
27511 </p>
27512 !! end
27513
27514 !! test
27515 2. Leading whitespace in non-indent-pre contexts should not be escaped
27516 !! options
27517 parsoid=html2wt
27518 !! html/parsoid
27519 <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>
27520 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
27521 <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>
27522 b</span></li>
27523 </ol>
27524 !! wikitext
27525 foo <ref>''a''
27526 b</ref>
27527 <references />
27528 !! end
27529
27530 !! test
27531 3. Leading whitespace in indent-pre suppressing contexts should not be escaped
27532 !! options
27533 parsoid=html2wt
27534 !! html/parsoid
27535 <blockquote>
27536 <p>
27537 a
27538 <span>b</span>
27539 c</p>
27540 </blockquote>
27541 !! wikitext
27542 <blockquote>
27543 a
27544 <span>b</span>
27545 c
27546 </blockquote>
27547 !! end
27548
27549 !! test
27550 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
27551 !! options
27552 parsoid=html2wt
27553 !! html/parsoid
27554 <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>
27555 !! wikitext
27556 [[File:Foobar.jpg|thumb|caption]]
27557 !! end
27558
27559 !! test
27560 5. Nowiki escaping should account for indent-pres
27561 !! options
27562 parsoid=html2wt
27563 !! html/parsoid
27564 <pre>==foo==</pre>
27565 !! wikitext
27566 ==foo==
27567 !! end
27568
27569 !! test
27570 T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
27571 !! options
27572 parsoid=html2wt
27573 !! html/parsoid
27574 <pre>
27575 * foo
27576 * bar
27577 </pre>
27578 !! wikitext
27579 * foo
27580 * bar
27581 !! end
27582
27583 !! test
27584 Whitespace scrubbing in SOL position should account for SOL-sensitive wikitext markup
27585 !! options
27586 parsoid = {
27587 "modes": ["html2wt"],
27588 "scrubWikitext": true
27589 }
27590 !! html/parsoid
27591 <p> foo</p>
27592 <p> %foo</p>
27593 <p> *foo</p>
27594 <p> #foo</p>
27595 <p> =foo=</p>
27596 <p><link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid="{}"> *foo</p>
27597 <p> <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid="{}">*foo</p>
27598 <p> <!--boo-->*foo</p>
27599 <p><!--boo--> *foo</p>
27600 <p><!--a--> <!--b--> <!--c--> <!--d--> <!--e--> foo</p>
27601 <p><!--a--> <!--b--> <!--c--> <!--d--> <!--e--> *foo</p>
27602 !! wikitext
27603 foo
27604
27605 %foo
27606
27607 <nowiki/>*foo
27608
27609 <nowiki/>#foo
27610
27611 <nowiki/>=foo=
27612
27613 [[Category:Foo]]
27614 <nowiki/>*foo
27615
27616 [[Category:Foo]]
27617 <nowiki>*</nowiki>foo
27618
27619 <nowiki/><!--boo-->*foo
27620
27621 <!--boo--><nowiki/>*foo
27622
27623 <!--a--><!--b--><!--c--><!--d--><!--e-->foo
27624
27625 <!--a--><nowiki/><!--b--><!--c--><!--d--><!--e-->*foo
27626 !! end
27627
27628 #### --------------- Behavior Switches --------------------
27629
27630 !! test
27631 1. Valid behavior switches should be escaped
27632 !! options
27633 parsoid=html2wt
27634 !! html/parsoid
27635 __TOC__
27636 <i>__TOC__</i>
27637 !! wikitext
27638 <nowiki>__TOC__</nowiki>
27639 ''<nowiki>__TOC__</nowiki>''
27640 !! end
27641
27642 !! test
27643 2. Invalid behavior switches should not be escaped
27644 !! options
27645 parsoid=html2wt
27646 !! html/parsoid
27647 __TOO__
27648 __|__
27649 !! wikitext
27650 __TOO__
27651 __|__
27652 !! end
27653
27654 # We use indent-pre as an indirect way to test for sol-transparent behavior.
27655 !! test
27656 Behavior switches should be SOL-transparent
27657 !! options
27658 parsoid=html2wt
27659 !! html/parsoid
27660 <meta property="mw:PageProp/toc" />
27661
27662 <!-- this one's bogus -->
27663 <pre>__TOO__</pre>
27664
27665 <pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre>
27666
27667 <meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre>
27668 !! wikitext
27669 __TOC__
27670
27671 <!-- this one's bogus -->
27672 __TOO__
27673
27674 __TOC__ foo
27675
27676 __TOC__
27677 bar
27678 !! end
27679
27680 #### --------------- HTML tags ---------------
27681 #### 1. a tags
27682 #### 2. other tags
27683 #### 3. multi-line html tag
27684 #### 4. extension tags
27685 #### -----------------------------------------
27686 !! test
27687 1. a tags
27688 !! options
27689 parsoid=html2wt
27690 !! html/parsoid
27691 &lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
27692 !! wikitext
27693 <a href="http://google.com">google</a>
27694 !! end
27695
27696 !! test
27697 2. other tags
27698 !! options
27699 parsoid=html2wt
27700 !! html/parsoid
27701 <ul><li> &lt;div&gt;foo&lt;/div&gt;</li>
27702 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
27703 <li> &lt;td&gt;</li></ul>
27704
27705 !! wikitext
27706 * <nowiki><div>foo</div></nowiki>
27707 * <nowiki><div style="color:red">foo</div></nowiki>
27708 * <nowiki><td></nowiki>
27709 !! end
27710
27711 !! test
27712 3. multi-line html tag
27713 !! options
27714 parsoid=html2wt
27715 !! html/parsoid
27716 <p>&lt;div
27717 &gt;foo&lt;/div
27718 &gt;
27719 </p>
27720 !! wikitext
27721 <nowiki><div
27722 >foo</div
27723 ></nowiki>
27724 !! end
27725
27726 !! test
27727 4. extension tags
27728 !! options
27729 parsoid=html2wt
27730 !! html/parsoid
27731 <p>&lt;ref&gt;foo&lt;/ref&gt;
27732 </p><p>&lt;ref&gt;bar
27733 </p><p>baz&lt;/ref&gt;
27734 </p>
27735 !! wikitext
27736 <nowiki><ref>foo</ref></nowiki>
27737
27738 <nowiki><ref>bar</nowiki>
27739
27740 baz<nowiki></ref></nowiki>
27741 !! end
27742
27743 !! test
27744 Parsoid: newline inducing block nodes don't suppress <nowiki>
27745 !! options
27746 parsoid=html2wt
27747 !! html/parsoid
27748 a<h1>foo</h1>
27749 !! wikitext
27750 <nowiki> </nowiki>a
27751
27752 = foo =
27753 !! end
27754
27755 #### --------------- Others ---------------
27756 !! test
27757 Escaping nowikis
27758 !! options
27759 parsoid=html2wt
27760 !! html/parsoid
27761 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
27762 </p>
27763 !! wikitext
27764 &lt;nowiki&gt;foo&lt;/nowiki&gt;
27765 !! end
27766
27767 ## The quote-char in the input is necessary for triggering the bug
27768 !! test
27769 (T54035) Nowiki-escaping should not get tripped by " :" in text
27770 !! options
27771 parsoid=html2wt
27772 !! html/parsoid
27773 <p>foo's bar :</p>
27774 !! wikitext
27775 foo's bar :
27776 !! end
27777
27778 #----------- End of wikitext escaping tests --------------
27779
27780 !! test
27781
27782 Tag-like HTML structures are passed through as text
27783 !! wikitext
27784 <x y>
27785
27786 <x.y>
27787
27788 <x-y>
27789
27790 1>2
27791
27792 x<y
27793
27794 a>b
27795
27796 1<d e>f
27797 !! html
27798 <p>&lt;x y&gt;
27799 </p><p>&lt;x.y&gt;
27800 </p><p>&lt;x-y&gt;
27801 </p><p>1&gt;2
27802 </p><p>x&lt;y
27803 </p><p>a&gt;b
27804 </p><p>1&lt;d e&gt;f
27805 </p>
27806 !! end
27807
27808 !! test
27809 HTML tag with necessary entities in attributes
27810 !! wikitext
27811 <span title="&amp;amp;">foo</span>
27812 !! html
27813 <p><span title="&amp;amp;">foo</span>
27814 </p>
27815 !! end
27816
27817 !! test
27818 HTML tag with 'unnecessary' entity encoding in attributes
27819 !! wikitext
27820 <span title="&amp;">foo</span>
27821 !! html
27822 <p><span title="&amp;">foo</span>
27823 </p>
27824 !! end
27825
27826 !! test
27827 HTML tag with broken attribute value quoting
27828 !! options
27829 parsoid=wt2html,html2html
27830 !! wikitext
27831 <span title="Hello world>Foo</span>
27832 !! html/php
27833 <p><span title="Hello world">Foo</span>
27834 </p>
27835 !! html/parsoid
27836 <p><span title="Hello world">Foo</span></p>
27837 !! end
27838
27839 !! test
27840 Self-closed tag with broken attribute value quoting
27841 !! options
27842 parsoid=wt2html,html2html
27843 !! wikitext
27844 <div title="Hello world />Foo
27845 !! html/php+tidy
27846 <div title="Hello world"></div><p>Foo
27847 </p>
27848 !! html/parsoid
27849 <div title="Hello world " data-parsoid='{"stx":"html","selfClose":true}'></div><p>Foo</p>
27850 !! end
27851
27852 !! test
27853 Table with broken attribute value quoting
27854 !! options
27855 parsoid=wt2html,html2html
27856 !! wikitext
27857 {|
27858 | title="Hello world|Foo
27859 |}
27860 !! html/php
27861 <table>
27862 <tr>
27863 <td title="Hello world">Foo
27864 </td></tr></table>
27865
27866 !! html/parsoid
27867 <table>
27868 <tr>
27869 <td title="Hello world">Foo
27870 </td></tr></table>
27871
27872 !! end
27873
27874 !! test
27875 Table with broken attribute value quoting on consecutive lines
27876 !! options
27877 parsoid=wt2html,html2html
27878 !! wikitext
27879 {|
27880 | title="Hello world|Foo
27881 | style="color:red|Bar
27882 |}
27883 !! html/php
27884 <table>
27885 <tr>
27886 <td title="Hello world">Foo
27887 </td>
27888 <td style="color:red">Bar
27889 </td></tr></table>
27890
27891 !! html/parsoid
27892 <table><tbody>
27893 <tr>
27894 <td title="Hello world">Foo
27895 </td><td style="color: red">Bar
27896 </td></tr></tbody></table>
27897
27898 !! end
27899
27900 !!test
27901 Accept empty td cell attribute
27902 !! wikitext
27903 {|
27904 | align="center" |foo|| |
27905 |}
27906 !! html
27907 <table>
27908 <tr>
27909 <td align="center">foo</td>
27910 <td>
27911 </td></tr></table>
27912
27913 !!end
27914
27915 !!test
27916 Non-empty attributes in th-cells
27917 !! wikitext
27918 {|
27919 !Foo!! style="color: red" |Bar
27920 |}
27921 !! html
27922 <table>
27923 <tr>
27924 <th>Foo</th>
27925 <th style="color: red">Bar
27926 </th></tr></table>
27927
27928 !!end
27929
27930 !!test
27931 Accept empty attributes in th-cells
27932 !! wikitext
27933 {|
27934 !|foo!!|bar
27935 |}
27936 !! html
27937 <table>
27938 <tr>
27939 <th>foo</th>
27940 <th>bar
27941 </th></tr></table>
27942
27943 !!end
27944
27945 !!test
27946 Empty table rows go away
27947 !! wikitext
27948 {|
27949 |Hello
27950 |there
27951 |- class="foo"
27952 |-
27953 |}
27954 !! html
27955 <table>
27956 <tr>
27957 <td>Hello
27958 </td>
27959 <td>there
27960 </td></tr>
27961
27962 </table>
27963
27964 !! end
27965
27966 ###
27967 ### Parsoid-centric tests for testing RTing of inter-element separators
27968 ### Edge cases not tested by existing parser tests and specific to
27969 ### Parsoid-specific serialization strategies.
27970 ###
27971
27972 !!test
27973 RT-ed inter-element separators should be valid separators
27974 !! wikitext
27975 {|
27976 |- [[foo]]
27977 |}
27978 !! html/php
27979 <table>
27980
27981 </table>
27982
27983 !! html/parsoid
27984 <table>
27985 <tbody><tr class='mw-empty-elt' data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
27986 </tbody></table>
27987 !!end
27988
27989 # Parsoid-only test of a DOM pass
27990 !!test
27991 Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out
27992 !! wikitext
27993 {|
27994 |<small>foo
27995 bar
27996 |}
27997
27998 {|
27999 |<small>foo<small>
28000 |}
28001 !! html/parsoid
28002 <table>
28003 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo
28004 <p>bar</p></small></td></tr>
28005 </tbody></table>
28006
28007 <table>
28008 <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>
28009 </tbody></table>
28010 !!end
28011
28012 # Note that the "style" attribute is really a template parameter here.
28013 # The = would have to be {{=}} if you wanted the literal.
28014 !!test
28015 Empty TD followed by TD with tpl-generated attribute
28016 !! wikitext
28017 {|
28018 |-
28019 |
28020 |{{echo|style='color:red'}}|foo
28021 |}
28022 !! html
28023 <table>
28024
28025 <tr>
28026 <td>
28027 </td>
28028 <td>foo
28029 </td></tr></table>
28030
28031 !!end
28032
28033 !!test
28034 Indented table with an empty td
28035 !! wikitext
28036 {|
28037 |-
28038 |
28039 |foo
28040 |}
28041 !! html
28042 <table>
28043
28044 <tr>
28045 <td>
28046 </td>
28047 <td>foo
28048 </td></tr></table>
28049
28050 !!end
28051
28052 !! test
28053 Indented table with blank lines in between (T85627)
28054 !! wikitext
28055 {|
28056 |foo
28057
28058
28059 |}
28060 !! html/php
28061 <table>
28062 <tr>
28063 <td>foo
28064 <p><br />
28065 </p>
28066 </td></tr></table>
28067
28068 !! html/parsoid
28069 <table>
28070 <tbody><tr><td>foo
28071 <p>
28072 <br /></p></td></tr>
28073 </tbody></table>
28074 !! end
28075
28076 !!test
28077 Indented block & table
28078 !! wikitext
28079 <div>foo</div>
28080 {|
28081 |foo
28082 |}
28083 !! html/php
28084 <div>foo</div>
28085 <table>
28086 <tr>
28087 <td>foo
28088 </td></tr></table>
28089
28090 !! html/parsoid
28091 <div data-parsoid='{"stx":"html"}'>foo</div>
28092 <table><tbody>
28093 <tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>foo</td></tr>
28094 </tbody></table>
28095 !!end
28096
28097 !! test
28098 Indent and comment before table row
28099 !! wikitext
28100 {|
28101 <!--hi-->|-
28102 |there
28103 |}
28104 !! html/php
28105 <table>
28106
28107 <tr>
28108 <td>there
28109 </td></tr></table>
28110
28111 !! html/parsoid
28112 <table>
28113 <!--hi--><tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
28114 <td data-parsoid='{"autoInsertedEnd":true}'> there</td></tr>
28115 </tbody></table>
28116 !! end
28117
28118 # PHP parser omits empty TR
28119 !!test
28120 Empty TR followed by a template-generated TR
28121 !! wikitext
28122 {|
28123 |-
28124 {{echo|<tr><td>foo</td></tr>}}
28125 |}
28126 !! html/php+tidy
28127 <table>
28128
28129 <tbody><tr><td>foo</td></tr>
28130 </tbody></table>
28131 !! html/parsoid
28132 <table>
28133 <tbody>
28134 <tr class='mw-empty-elt'></tr>
28135 <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}}]}'>
28136 <td>foo</td></tr>
28137 </tbody></table>
28138 !!end
28139
28140 ## PHP and parsoid output differ for this; as usual PHP omits empty
28141 ## elements, and since it strips the comments the TR is empty.
28142 !!test
28143 Empty TR followed by mixed-ws-comment line should RT correctly
28144 !! wikitext
28145 {|
28146 |-
28147 <!--c-->
28148 |-
28149 <!--c--> <!--d-->
28150 |}
28151 !! html/php+tidy
28152 <table>
28153
28154
28155 </table>
28156 !! html/parsoid
28157 <table>
28158 <tbody>
28159 <tr class='mw-empty-elt'></tr>
28160 <!--c-->
28161 <tr>
28162 <!--c--> </tr><!--d-->
28163 </tbody></table>
28164
28165 !!end
28166
28167 !!test
28168 Multi-line image caption generated by templates with/without trailing newlines
28169 !! wikitext
28170 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]]
28171 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]]
28172 !! html/parsoid
28173 <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>
28174 <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>
28175 !!end
28176
28177 !! test
28178 New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly
28179 !! options
28180 parsoid=html2wt
28181 !! html/parsoid
28182 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>foo&lt;/includeonly>"}' data-mw='{"src":"&lt;includeonly>foo&lt;/includeonly>"}'/><meta typeof="mw:Includes/IncludeOnly/End" data-parsoid='{"src":""}'/><p>new para</p>
28183
28184 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{}'/><h1>new heading</h1>
28185 !! wikitext
28186 <includeonly>foo</includeonly>
28187 new para
28188
28189 [[Category:Foo]]
28190
28191 = new heading =
28192 !! end
28193
28194 ## PHP emits broken html for this, and since this is primarily
28195 ## a Parsoid serializer test, marking this Parsoid only
28196 !!test
28197 Improperly nested inline or quotes tags with whitespace in between
28198 !! wikitext
28199 <span> <s>x</span> </s>
28200 ''' ''x''' ''
28201 !! html/parsoid
28202 <p><span> <s>x</s></span><s> </s>
28203 <b> <i>x</i></b><i> </i>
28204 </p>
28205 !!end
28206
28207 !!test
28208 Encapsulate protected attributes from wt
28209 !! wikitext
28210 <div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
28211
28212 {| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true"
28213 |ok
28214 |}
28215 !! html/parsoid
28216 <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>
28217
28218 <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">
28219 <tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'>ok</td></tr>
28220 </tbody></table>
28221 !!end
28222
28223 ## Currently the p-wrapper is fragile in how it adds / removes transformations.
28224 ## Having nested or stray pre tags results in the attempt to add duplicates,
28225 ## causing an assertion fail. This test tries to prevent that situation.
28226 !! test
28227 Ensure ParagraphWrapper can deal with stray closing pre tags
28228 !! options
28229 parsoid=wt2html
28230 !! wikitext
28231 plain text</pre>
28232 !! html/parsoid
28233 <p>plain text</p>
28234 !! end
28235
28236 ## Remex doesn't account for fostered content.
28237 !! test
28238 1. Ensure fostered text content is wrapped in element nodes
28239 !! options
28240 parsoid=wt2html
28241 !! wikitext
28242 <table>hi</table><table>ho</table>
28243 !! html/php+tidy
28244 hi<table></table>ho<table></table>
28245 !! html/parsoid
28246 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>hi</p><table data-parsoid='{"stx":"html"}'></table><p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>ho</p><table data-parsoid='{"stx":"html"}'></table>
28247 !! end
28248
28249 ## Remex doesn't account for fostered content.
28250 !! test
28251 2. Ensure fostered text content is wrapped in element nodes (traps regressions around fostered marker on the element getting lost)
28252 !! options
28253 parsoid=wt2html,wt2wt
28254 !! wikitext
28255 <table>
28256 <tr> || ||
28257 <td> a
28258 </table>
28259 !! html/php+tidy
28260 || ||
28261 <table>
28262 <tbody><tr><td> a
28263 </td></tr></tbody></table>
28264 !! html/parsoid
28265 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'> || ||</p>
28266 <table data-parsoid='{"stx":"html"}'>
28267 <tbody><tr data-parsoid='{"stx":"html","autoInsertedEnd":true}'><td data-parsoid='{"stx":"html","autoInsertedEnd":true}'> a
28268 </td></tr></tbody></table>
28269 !! end
28270
28271 ## Remex doesn't account for fostered content.
28272 !! test
28273 Encapsulation properly handles null DSR information from foster box
28274 !! options
28275 parsoid=wt2html,wt2wt
28276 !! wikitext
28277 {{echo|<table>foo<tr><td>bar</td></tr></table>}}
28278 !! html/parsoid
28279 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;table>foo&lt;tr>&lt;td>bar&lt;/td>&lt;/tr>&lt;/table>"}},"i":0}}]}'>foo</p><table about="#mwt1" data-parsoid='{"stx":"html"}'><tbody><tr><td>bar</td></tr></tbody></table>
28280 !! end
28281
28282 ## Remex doesn't account for fostered content.
28283 !! test
28284 1. Encapsulate foster-parented transclusion content
28285 !! options
28286 parsoid=wt2wt,wt2html
28287 !! wikitext
28288 <table>{{echo|foo<tr><td>bar</td></tr>}}</table>
28289 !! html/php+tidy
28290 foo<table><tbody><tr><td>bar</td></tr></tbody></table>
28291 !! html/parsoid
28292 <p about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE_html","pi":[[{"k":"1"}]]}' data-mw='{"parts":["&lt;table>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo&lt;tr>&lt;td>bar&lt;/td>&lt;/tr>"}},"i":0}},"&lt;/table>"]}'>foo</p><table about="#mwt2" data-parsoid='{"stx":"html"}'><tbody><tr><td>bar</td></tr></tbody></table>
28293 !! end
28294
28295 !! test
28296 2. Encapsulate foster-parented transclusion content
28297 !! options
28298 parsoid=wt2wt,wt2html
28299 !! wikitext
28300 <table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table>
28301 !! html/parsoid
28302 <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>
28303 <table>
28304 <tbody>
28305 <tr>
28306 <td>bar</td>
28307 </tr>
28308 </tbody>
28309 </table>
28310 !! end
28311
28312 !! test
28313 3. Encapsulate foster-parented transclusion content
28314 !! options
28315 parsoid=wt2wt,wt2html
28316 !! wikitext
28317 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
28318 !! html/parsoid
28319 <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;]}">
28320 <p>foo</p>
28321 </div>
28322 <table>
28323 <tbody>
28324 <tr>
28325 <td>bar</td>
28326 </tr>
28327 </tbody>
28328 </table>
28329 !! end
28330
28331 !! test
28332 4. Encapsulate foster-parented transclusion content
28333 !! options
28334 parsoid=wt2wt,wt2html
28335 !! wikitext
28336 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
28337 !! html/parsoid
28338 <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;]}">
28339 <p>foo</p>
28340 </div>
28341 <table>
28342 <tbody>
28343 <tr>
28344 <td>bar</td>
28345 </tr>
28346 </tbody>
28347 </table>
28348 !! end
28349
28350 ## Remex doesn't account for fostered content.
28351 !! test
28352 5. Encapsulate foster-parented transclusion content
28353 !!options
28354 parsoid=wt2wt,wt2html
28355 !! wikitext
28356 <table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table>
28357 !! html/php+tidy
28358 foo<table><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table>
28359 !! html/parsoid
28360 <p about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE_html","pi":[[{"k":"1"}]]}' data-mw='{"parts":["&lt;table>&lt;tr>&lt;td>&lt;div>&lt;p>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo&lt;/p>&lt;/div>&lt;/td>foo"}},"i":0}},"&lt;/tr>&lt;/table>"]}'>foo</p><table about="#mwt2" data-parsoid='{"stx":"html"}'><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table>
28361 !! end
28362
28363 ## Remex doesn't account for fostered content.
28364 !! test
28365 6. Encapsulate foster-parented transclusion content
28366 !! options
28367 parsoid=wt2wt,wt2html
28368 !! wikitext
28369 <table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p>
28370 !! html/php+tidy
28371 foo<table><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table><p>ok</p>
28372 !! html/parsoid
28373 <p about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE_html","pi":[[{"k":"1"}]]}' data-mw='{"parts":["&lt;table>&lt;tr>&lt;td>&lt;div>&lt;p>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo&lt;/p>&lt;/div>&lt;/td>foo&lt;/tr>&lt;/table>"}},"i":0}}]}'>foo</p><table about="#mwt2" data-parsoid='{"stx":"html"}'><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table><p data-parsoid='{"stx":"html"}'>ok</p>
28374 !! end
28375
28376 !! test
28377 7. Encapsulate foster-parented transclusion content
28378 !!options
28379 parsoid=wt2wt,wt2html
28380 !! wikitext
28381 <table>{{echo|<p>foo</p>}}<td>bar</td></table>
28382 !! html/parsoid
28383 <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>
28384 <table>
28385 <tbody>
28386 <tr>
28387 <td>bar</td>
28388 </tr>
28389 </tbody>
28390 </table>
28391 !! end
28392
28393 ## Remex doesn't account for fostered content.
28394 # Note that the wt is broken on purpose: the = should be {{=}} if you
28395 # don't want it to be a template parameter key.
28396 !! test
28397 8. Encapsulate foster-parented transclusion content
28398 !! options
28399 parsoid=wt2wt,wt2html
28400 !! wikitext
28401 {{echo|a
28402 }}{|{{echo|style='color:red'}}
28403 |-
28404 |b
28405 |}
28406 !! html/php+tidy
28407 <p>a
28408 </p>
28409 <table>
28410
28411 <tbody><tr>
28412 <td>b
28413 </td></tr></tbody></table>
28414 !! html/parsoid
28415 <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">
28416 </span><p about="#mwt3" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE","pi":[[{"k":"style","named":true}]]}' data-mw='{"parts":["{|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"style":{"wt":"&apos;color:red&apos;"}},"i":0}},"\n|-\n|b\n|}"]}'>{{{1}}}</p><table about="#mwt3">
28417 <tbody><tr>
28418 <td>b
28419 </td></tr></tbody></table>
28420 !! end
28421
28422 ## Remex doesn't account for fostered content.
28423 !! test
28424 9. Encapsulate foster-parented transclusion content
28425 !!options
28426 parsoid=wt2wt,wt2html
28427 !! wikitext
28428 <table>{{echo|hi</table>hello}}
28429 !! html/php+tidy
28430 hi<table></table><p>hello
28431 </p>
28432 !! html/parsoid
28433 <p about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE_html","pi":[[{"k":"1"}]]}' data-mw='{"parts":["&lt;table>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi&lt;/table>hello"}},"i":0}}]}'>hi</p><table about="#mwt2"></table><p about="#mwt2">hello</p>
28434 !! end
28435
28436 !! test
28437 Table in fosterable position
28438 !!options
28439 parsoid=wt2html
28440 !! wikitext
28441 {{OpenTable}}
28442 <div>
28443 {|
28444 |}
28445 </div>
28446 |}
28447 !! html/parsoid
28448 <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">
28449 </span>
28450 <table about="#mwt1" data-parsoid='{"autoInsertedEnd":true}'></table>
28451
28452 <table>
28453 </table>
28454 !! end
28455
28456 # Parsoid only for T66747
28457 !! test
28458 Properly encapsulate empty-content transclusions in fosterable positions
28459 !! wikitext
28460 <table>
28461 {{#if:|
28462 <td>foo</td>
28463 }}
28464 </table>
28465 !! html/parsoid
28466 <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"}]]}'>
28467
28468 </table>
28469 !! end
28470
28471 ## No longer captures its original intention
28472 !! test
28473 Always encapsulate foster box when template range is expanded to table
28474 !! options
28475 disabled
28476 parsoid=wt2wt
28477 !! wikitext
28478 {|
28479 hello
28480 {{OpenTable}}
28481 |}
28482 !! html/parsoid
28483
28484 !! end
28485
28486 !! test
28487 T115289: Unclosed table
28488 !! wikitext
28489 {{echo|<table>}}<!--c-->[[Category:Two]]
28490 !! html/parsoid
28491 <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>
28492 !! end
28493
28494 !! test
28495 T115289: Don't migrate newlines out of tables with fostered content
28496 !! wikitext
28497 <table><td></td>{{echo|<tr>[[Category:One]]}}<!--c-->[[Category:Two]]
28498 !! html/parsoid
28499 <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>
28500 !! end
28501
28502 !! test
28503 T73074: More fostering fun
28504 !! wikitext
28505 <table><td></td>{{echo|<tr>}}<!--c-->[[Category:Two]]
28506 !! html/parsoid
28507 <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>
28508 !! end
28509
28510 !!test
28511 Support <object> element with .data attribute
28512 !!options
28513 parsoid=html2wt
28514 !! html/parsoid
28515 <object data="test.swf"></object>
28516 !! wikitext
28517 <object data="test.swf"></object>
28518 !!end
28519
28520 !! test
28521 Don't block XML namespace declaration
28522 !! wikitext
28523 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span>
28524 !! html/php
28525 <p><span xmlns:dct="http&#58;//purl.org/dc/terms/" property="dct:title">MediaWiki</span>
28526 </p>
28527 !! html/parsoid
28528 <p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p>
28529 !! end
28530
28531 # -----------------------------------------------------------------
28532 # The following section of tests are primarily to spec requirements
28533 # around Parsoid's serialization (old, new, edited content)
28534 #
28535 # All these tests are marked Parsoid html2wt and html2html only
28536 # ----------------------------------------------------------------
28537
28538 !! test
28539 Ignore rel attribute in a-tags during serialization to url-links
28540 !! options
28541 parsoid=html2wt
28542 !! html/parsoid
28543 <a href='http://en.wikipedia.org/wiki/Foobar'>http://en.wikipedia.org/wiki/Foobar</a>
28544 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:ExtLink'>http://en.wikipedia.org/wiki/Foobar</a>
28545 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:WikiLink'>http://en.wikipedia.org/wiki/Foobar</a>
28546 !! wikitext
28547 http://en.wikipedia.org/wiki/Foobar
28548 http://en.wikipedia.org/wiki/Foobar
28549 http://en.wikipedia.org/wiki/Foobar
28550 !! end
28551
28552 # 'mi' is a localinterwiki prefix as well as a language
28553 !! test
28554 Serialize interwiki links pointing to the current wiki as plain wiki links (T67869)
28555 !! options
28556 parsoid=html2wt
28557 !! html/parsoid
28558 <p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p>
28559 !! wikitext
28560 [[Foo]]
28561 !! end
28562
28563 !! test
28564 Parsoid should accept interwiki shortcuts
28565 !! options
28566 parsoid=html2wt
28567 !! html/parsoid
28568 <p><a rel='mw:WikiLink' href='./fr:Foo'>Foo</a>
28569 <a rel='mw:ExtLink' href='./fr:Foo'>Foo</a>
28570 <a href='./fr:Foo'>Foo</a></p>
28571 <p><a rel='mw:WikiLink' href='fr%3AFoo'>Foo</a>
28572 <a rel='mw:ExtLink' href='fr%3AFoo'>Foo</a>
28573 <a href='fr%3AFoo'>Foo</a></p>
28574 <p><a href='FR%3AFoo'>Foo</a>
28575 <a href='./FR:Foo'>Foo</a></p>
28576 !! wikitext
28577 [[:fr:Foo|Foo]]
28578 [[:fr:Foo|Foo]]
28579 [[:fr:Foo|Foo]]
28580
28581 [[:fr:Foo|Foo]]
28582 [[:fr:Foo|Foo]]
28583 [[:fr:Foo|Foo]]
28584
28585 [[:fr:Foo|Foo]]
28586 [[:fr:Foo|Foo]]
28587 !! end
28588
28589 !! test
28590 Parsoid should not accept invalid interwiki shortcuts
28591 !! options
28592 parsoid=html2wt
28593 !! html/parsoid
28594 <p><a rel='mw:WikiLink' href='news:Foo'>Foo</a>
28595 <a rel='mw:ExtLink' href='news:Foo'>Foo</a>
28596 <a href='news:Foo'>Foo</a></p>
28597 !! wikitext
28598 [news:Foo Foo]
28599 [news:Foo Foo]
28600 [news:Foo Foo]
28601 !! end
28602
28603 # See T93839
28604 !! test
28605 New wikilinks should be serialized properly
28606 !! options
28607 parsoid=html2wt
28608 !! html/parsoid
28609 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
28610 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
28611 <a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a>
28612 <a href="http://en.wikipedia.org/wiki/Foo">http://en.wikipedia.org/wiki/Foo</a>
28613 <a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a>
28614 !! wikitext
28615 [[Foo]]
28616 [[Foo]]
28617 [[:en:Foo|//en.wikipedia.org/wiki/Foo]]
28618 http://en.wikipedia.org/wiki/Foo
28619 [[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]]
28620 !! end
28621
28622 !! test
28623 New wiki links (href variations)
28624 !! options
28625 parsoid=html2wt
28626 !! html/parsoid
28627 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
28628 <a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a>
28629 <a rel="mw:WikiLink" href="Foo bar">Foo_bar</a>
28630 <a rel="mw:WikiLink" href="./Toxine_bact%C3%A9rienne">Toxine bactérienne</a>
28631 !! wikitext
28632 [[Foo_bar]]
28633 [[Foo_bar]]
28634 [[Foo_bar]]
28635 [[Toxine bactérienne]]
28636 !! end
28637
28638 !! test
28639 New wiki links (content string variations)
28640 !! options
28641 parsoid=html2wt
28642 !! html/parsoid
28643 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
28644 <a rel="mw:WikiLink" href="./Foo_bar">Foo bar</a>
28645 <a rel="mw:WikiLink" href="./Foo_bar">./Foo_bar</a>
28646 !! wikitext
28647 [[Foo_bar]]
28648 [[Foo bar]]
28649 [[Foo_bar|./Foo_bar]]
28650 !! end
28651
28652 !! test
28653 New category links (href variations)
28654 !! options
28655 parsoid=html2wt
28656 !! html/parsoid
28657 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" />
28658 <link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" />
28659 <link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" />
28660 !! wikitext
28661 [[Category:Toxine bactérienne]]
28662 [[Category:Toxine bactérienne]]
28663 [[Category:Toxine bactérienne]]
28664 !! end
28665
28666 !! test
28667 New sol transparent links don't need indent-pre nowiki protection
28668 !! options
28669 parsoid=html2wt
28670 language=de
28671 !! html/parsoid
28672 <link rel="mw:PageProp/redirect" href="./Main_Page">
28673 <!-- this is good --> <link rel="mw:PageProp/Category" href="./Category:Good" />
28674 <!-- this is great --> <link rel="mw:PageProp/Category" href="./Kategorie:Great" />
28675 !! wikitext
28676 #WEITERLEITUNG [[Main Page]]
28677 <!-- this is good --> [[Category:Good]]
28678 <!-- this is great --> [[Kategorie:Great]]
28679 !! end
28680
28681 !! test
28682 New interlanguage links (href variations)
28683 !! options
28684 parsoid=html2wt
28685 !! html/parsoid
28686 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" />
28687 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" />
28688 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" />
28689 !! wikitext
28690 [[es:Toxine bactérienne]]
28691 [[es:Toxine_bactérienne]]
28692 [[es:Toxine_bactérienne]]
28693 !! end
28694
28695 !! test
28696 Image: Modifying size of an image (1)
28697 !! options
28698 parsoid={
28699 "modes": ["wt2wt"],
28700 "changes": [
28701 ["img[height]", "attr", "height", "22"],
28702 ["img[width]", "attr", "width", "200"]
28703 ]
28704 }
28705 !! wikitext
28706 [[Image:Foobar.jpg|230x230px]]
28707 !! wikitext/edited
28708 [[Image:Foobar.jpg|200x200px]]
28709 !!end
28710
28711 !! test
28712 Image: Modifying size of an image (2)
28713 !! options
28714 parsoid={
28715 "modes": ["wt2wt"],
28716 "changes": [
28717 ["img[height]", "attr", "height", "100"],
28718 ["img[width]", "attr", "width", "500"]
28719 ]
28720 }
28721 !! wikitext
28722 [[Image:Foobar.jpg|230x230px]]
28723 !! wikitext/edited
28724 [[Image:Foobar.jpg|500x500px]]
28725 !!end
28726
28727 # Change in size is ignored so long as class='mw-default-size'
28728 !! test
28729 Image: Modifying size of an image (3)
28730 !! options
28731 parsoid={
28732 "modes": ["wt2wt"],
28733 "changes": [
28734 ["figure[class]", "removeClass", "mw-default-size"],
28735 ["figure img", "attr", "height", "19"],
28736 ["figure img", "attr", "width", "170"]
28737 ]
28738 }
28739 !! wikitext
28740 [[Image:Foobar.jpg|thumb]]
28741 !! wikitext/edited
28742 [[Image:Foobar.jpg|thumb|170x170px]]
28743 !!end
28744
28745 !! test
28746 Image: Modifying alignment of an image (T50665)
28747 !! options
28748 parsoid={
28749 "modes": ["wt2wt"],
28750 "changes": [
28751 ["figure[class]", "removeClass", "mw-halign-right"],
28752 ["figure[class]", "addClass", "mw-halign-left"]
28753 ]
28754 }
28755 !! wikitext
28756 [[Image:Foobar.jpg|thumb|caption|right]]
28757 !! wikitext/edited
28758 [[Image:Foobar.jpg|thumb|caption|left]]
28759 !! end
28760
28761 !! test
28762 Image: Modifying mw-default-size of an frameless image (T64805)
28763 !! options
28764 parsoid={
28765 "modes": ["wt2wt"],
28766 "changes": [
28767 ["figure.mw-default-size", "removeClass", "mw-default-size"]
28768 ]
28769 }
28770 !! wikitext
28771 [[Image:Foobar.jpg|frameless|right]]
28772 !! wikitext/edited
28773 [[Image:Foobar.jpg|frameless|right|220x220px]]
28774 !! end
28775
28776 !! test
28777 Image: Modifying valign of an image (T51221)
28778 !! options
28779 parsoid={
28780 "modes": ["wt2wt"],
28781 "changes": [
28782 ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
28783 ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
28784 ]
28785 }
28786 !! wikitext
28787 [[File:Foobar.jpg|20px|middle]]
28788 !! wikitext/edited
28789 [[File:Foobar.jpg|20px|text-top]]
28790 !! end
28791
28792 !! test
28793 Image: Modifying alt attribute of an image (T58400)
28794 !! options
28795 parsoid={
28796 "modes": ["wt2wt"],
28797 "changes": [
28798 ["img[alt]", "attr", "alt", "some alternate edited text"]
28799 ]
28800 }
28801 !! wikitext
28802 [[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
28803 !! wikitext/edited
28804 [[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
28805 !!end
28806
28807 !! test
28808 Image: Modifying caption of an image
28809 !! options
28810 parsoid={
28811 "modes": ["wt2wt"],
28812 "changes": [
28813 ["figcaption", "text", "new caption"]
28814 ]
28815 }
28816 !! wikitext
28817 [[Image:Foobar.jpg|thumb|original caption]]
28818 !! wikitext/edited
28819 [[Image:Foobar.jpg|thumb|new caption]]
28820 !!end
28821
28822 !! test
28823 Image: empty alt attribute (T50924)
28824 !! wikitext
28825 [[File:Foobar.jpg|thumb|alt=|bar]]
28826 !! html/php+tidy
28827 <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>
28828 !! html/parsoid
28829 <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>
28830 !! end
28831
28832 !! test
28833 Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
28834 !! options
28835 parsoid=html2wt
28836 language=ar
28837 disabled
28838 !! html/parsoid
28839 <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>
28840 !! wikitext
28841 [[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
28842 !! end
28843
28844 !! test
28845 Image: Block level image should have \n before and after
28846 !! wikitext
28847 123
28848 [[File:Foobar.jpg|right|thumb|150x150px]]
28849 456
28850 !! html/parsoid
28851 <p>123</p>
28852 <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>
28853 <p>456</p>
28854 !! end
28855
28856 !! test
28857 Image: New block level image should have \n before and after (existing content)
28858 !! wikitext
28859 123
28860 [[File:Foobar.jpg|right|thumb|150x150px]]
28861 456
28862 !! html/parsoid
28863 <p>123</p>
28864 <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>
28865 <p>456</p>
28866 !! end
28867
28868 !! test
28869 Image: upright option (parsoid)
28870 !! wikitext
28871 [[File:Foobar.jpg|thumb|upright|caption]]
28872 [[File:Foobar.jpg|thumb|upright=0.5|caption]]
28873 [[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]]
28874 !! html/parsoid
28875 <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>
28876 <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>
28877 <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>
28878 !! end
28879
28880 !! test
28881 Image: upright option is ignored on inline and frame images (parsoid)
28882 !! wikitext
28883 [[File:Foobar.jpg|500x500px|upright=0.5|caption]]
28884 !! html/parsoid
28885 <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>
28886 !! end
28887
28888 !! test
28889 Image: in template parameter with empty parameter
28890 !! wikitext
28891 {{echo|[[File:Foobar.jpg|link=]]}}
28892 !! html/parsoid
28893 <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>
28894 !! end
28895
28896 !! test
28897 Image: from basic HTML (1)
28898 !! options
28899 parsoid=html2wt
28900 !! html/parsoid
28901 <span typeof="mw:Image">
28902 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
28903 </span>
28904 !! wikitext
28905 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
28906 !! end
28907
28908 !! test
28909 Image: from basic HTML (2)
28910 !! options
28911 parsoid=html2wt
28912 !! html/parsoid
28913 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
28914 !! wikitext
28915 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
28916 !! end
28917
28918 !! test
28919 Image: from basic HTML (3)
28920 !! options
28921 parsoid=html2wt
28922 !! html/parsoid
28923 <a href="Main"><img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"></a>
28924 !! wikitext
28925 [[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
28926 !! end
28927
28928 !! test
28929 Image: from basic HTML (4)
28930 !! options
28931 parsoid=html2wt
28932 !! html/parsoid
28933 <img src="./File:Foobar.jpg">
28934 !! wikitext
28935 [[File:Foobar.jpg|link=]]
28936 !! end
28937
28938 !! test
28939 Image: Invalid title as link
28940 !! wikitext
28941 [[File:Foobar.jpg|link=<]]
28942 !! html/php
28943 <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>
28944 </p>
28945 !! html/parsoid
28946 <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>
28947 !! end
28948
28949 !! test
28950 Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
28951 !! options
28952 parsoid=html2wt
28953 !! html/parsoid
28954 <ul>
28955 <li><p>foo</p></li>
28956 </ul>
28957 !! wikitext
28958 * foo
28959 !! end
28960
28961 !! test
28962 Lists: Serialize correctly even when list tags has unneeded whitespace between tags
28963 !! options
28964 parsoid=html2wt
28965 !! html/parsoid
28966 <ul> <li>foo</li></ul>
28967 !! wikitext
28968 * foo
28969 !! end
28970
28971 !! test
28972 Don't strip leading whitespace when handling indent-pre suppressing tags
28973 !! options
28974 parsoid=html2wt
28975 !! html/parsoid
28976 <table>
28977 <tr><td> indented row</td></tr>
28978 </table>
28979 <blockquote><p>
28980 <b>This is very bold of you!</b>
28981 </p>
28982 <table><tr><td>
28983 indented cell (no pre-wrapping!)
28984 </td></tr></table>
28985 </blockquote>
28986 <p>foo</p>
28987 <div>bar</div>
28988 !! wikitext
28989 {|
28990 | indented row
28991 |}
28992 <blockquote>
28993 '''This is very bold of you!'''
28994
28995 {|
28996 |
28997 indented cell (no pre-wrapping!)
28998 |}
28999 </blockquote>
29000 foo
29001 <div>bar</div>
29002 !! end
29003
29004 !! test
29005 Nowiki-wrap leading whitespace when handling indent-pre inducing tags
29006 !! options
29007 parsoid=html2wt
29008 !! html/parsoid
29009 <p>foo</p>
29010 <span>bar</span>
29011
29012 <span>foo2
29013 </span>bar2
29014
29015 <div>foo</div>
29016 <span>bar</span>
29017
29018 <div>
29019 <span>foo</span>
29020 </div>
29021 !! wikitext
29022 foo
29023
29024 <span>bar</span>
29025
29026 <span>foo2
29027 <nowiki> </nowiki></span>bar2
29028
29029 <div>foo</div>
29030 <nowiki> </nowiki><span>bar</span>
29031
29032 <div>
29033 <nowiki> </nowiki><span>foo</span>
29034 </div>
29035 !! end
29036
29037 !! test
29038 Lists: Dont insert newlines in a serialized list item.
29039 !! options
29040 parsoid=html2wt
29041 !! html/parsoid
29042 <ul><li>a<br>b</li><li>c</li></ul>
29043 !! wikitext
29044 * a<br />b
29045 * c
29046 !! end
29047
29048 !! test
29049 1. Headings: Force sol-transparent links and behavior switches to serialize before/after
29050 !! options
29051 parsoid={
29052 "modes": ["html2wt"],
29053 "scrubWikitext": false
29054 }
29055 !! html/parsoid
29056 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
29057 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
29058
29059 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
29060 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
29061
29062 <h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2>
29063
29064 <h2><meta property="mw:PageProp/toc" /> ok</h2>
29065 !! wikitext
29066 == hello there [[Category:A1]] ==
29067
29068 == [[Category:A2]] hi pal ==
29069
29070 == <!--foo--> [[Category:A3]] how goes it ==
29071
29072 == it goes well [[Category:A4]] <!--bar--> ==
29073
29074 ==howdy [[Category:A5]]==
29075
29076 == __TOC__ ok ==
29077 !! end
29078
29079 !! test
29080 2. Headings: Force sol-transparent links and behavior switches to serialize before/after
29081 !! options
29082 parsoid={
29083 "modes": ["html2wt"],
29084 "scrubWikitext": true
29085 }
29086 !! html/parsoid
29087 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
29088 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
29089
29090 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
29091 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
29092
29093 <h2><meta property="mw:PageProp/toc" /> ok</h2>
29094 !! wikitext
29095 == hello there ==
29096 [[Category:A1]]
29097 [[Category:A2]]
29098
29099 == hi pal ==
29100
29101 <!--foo-->[[Category:A3]]
29102
29103 == how goes it ==
29104
29105 == it goes well ==
29106 [[Category:A4]] <!--bar-->
29107
29108 __TOC__
29109
29110 == ok ==
29111 !! end
29112
29113 !! test
29114 Headings: Don't hoist metas that come from templates
29115 !! options
29116 parsoid={
29117 "modes": ["html2wt"],
29118 "scrubWikitext": true
29119 }
29120 !! html/parsoid
29121 <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>
29122 !! wikitext
29123 == {{echo|foo [[Category:Foo]]}} ==
29124 !! end
29125
29126 !! test
29127 Headings: Category in ref isn't hoisted
29128 !! options
29129 parsoid={
29130 "modes": ["html2wt"],
29131 "scrubWikitext": true
29132 }
29133 !! html/parsoid
29134 <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>
29135
29136 <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>
29137 !! wikitext
29138 == foo <ref>bar
29139 [[Category:Baz]] </ref> ==
29140
29141 <references />
29142 !! end
29143
29144 !! test
29145 Parsoid: Serialize positional parameters with = in them as named parameter
29146 !! options
29147 parsoid=html2wt
29148 !! html/parsoid
29149 <p about="#mwt1" typeof="mw:Transclusion"
29150 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p>
29151
29152 <p about="#mwt1" typeof="mw:Transclusion"
29153 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p>
29154
29155 <!--Orig params with data-parsoid has heuristics for handling = chars-->
29156 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
29157 <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>
29158 !! wikitext
29159 {{echo|1=f=oo}}
29160
29161 {{echo|1=f=oo|2=bar}}
29162
29163 <!--Orig params with data-parsoid has heuristics for handling = chars-->
29164 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
29165 {{echo|<nowiki>f=oo</nowiki>|bar}}
29166 !! end
29167
29168 !! test
29169 Parsoid: Serialize positional parameters with = in extlink as named parameter
29170 !! options
29171 parsoid=html2wt
29172 !! html/parsoid
29173 <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>
29174 !! wikitext
29175 {{echo|1=http://stuff?is=ok}}
29176 !! end
29177
29178 !! test
29179 Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes
29180 !! options
29181 parsoid=html2wt
29182 !! html/parsoid
29183 <div>a<p>b</p></div>
29184 <div>a
29185 <p>b</p></div>
29186 <div>
29187 a
29188 <p>b</p></div>
29189 !! wikitext
29190 <div>a
29191 b
29192 </div>
29193 <div>a
29194 b
29195 </div>
29196 <div>
29197 a
29198
29199 b
29200 </div>
29201 !! end
29202
29203 !! test
29204 Substrings resembling wikitext in hrefs should not get nowiki escapes
29205 !! options
29206 parsoid=html2wt
29207 !! html/parsoid
29208 <a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a>
29209 !! wikitext
29210 [[Foo''bar''baz]]
29211 !! end
29212
29213 !! test
29214 Enforce single-line context in the serializer
29215 !! options
29216 parsoid=html2wt
29217 !! html/parsoid
29218 <h2>testing
29219 123</h2>
29220
29221 <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">
29222 </span><span about="#mwt1">you</span> </h2>
29223
29224 <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>
29225
29226 <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
29227 there</span></li></ol>
29228
29229 <ul><li>asd
29230 sdf</li></ul>
29231
29232 <ul><li>foo
29233 bar
29234 baz</li>
29235 <li>foo <b>bar</b>
29236 baz</li></ul>
29237
29238 <dl><dt>hi
29239 ho </dt><dd data-parsoid='{"stx":"row"}'> hi
29240 ho</dd></dl>
29241
29242 <dl><dd> <table>
29243 <tbody><tr><td> ha
29244 ha
29245 ha</td></tr>
29246 </tbody></table></dd></dl>
29247 !! wikitext
29248 == testing 123 ==
29249
29250 == hi {{bogus|there
29251 you}} ==
29252
29253 == foo <ref>hello
29254 there</ref> ==
29255
29256 <references />
29257
29258 * asd sdf
29259
29260 * foo bar baz
29261 * foo '''bar''' baz
29262
29263 ; hi ho : hi ho
29264
29265 : {|
29266 | ha
29267 ha
29268 ha
29269 |}
29270 !! end
29271
29272 !! test
29273 Serialize new placeholder space without spans
29274 !! options
29275 parsoid=html2wt
29276 !! html/parsoid
29277 <p>foo<span typeof="mw:Placeholder"> </span>: bar</p>
29278
29279 <p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p>
29280
29281 <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>
29282 !! wikitext
29283 foo : bar
29284
29285 foo : bar
29286
29287 <ref>foo : bar</ref>ok
29288 !! end
29289
29290
29291 #-----------------------
29292 # Tag minimization tests
29293 #-----------------------
29294
29295 !! test
29296 1. I/B quote minimization: wikitext-only tags should be combined
29297 !! options
29298 parsoid=html2wt
29299 !! html/parsoid
29300 <p><i>A</i><i>B</i></p>
29301 <p><b>A</b><b>B</b></p>
29302 <p><i>A</i><b><i>B</i></b></p>
29303 <p><b>A</b><i><b>B</b></i></p>
29304 <p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p>
29305 <p><i><b>A</b></i><i><b>B</b></i></p>
29306 <p><i><b>A</b></i><b><i>B</i></b></p>
29307 <p><b><i>A</i></b><i><b>B</b></i></p>
29308 !! wikitext
29309 ''AB''
29310
29311 '''AB'''
29312
29313 ''A'''B'''''
29314
29315 '''A''B'''''
29316
29317 '''A''BC''D'''
29318
29319 '''''AB'''''
29320
29321 '''''AB'''''
29322
29323 '''''AB'''''
29324 !! end
29325
29326 !! test
29327 2. I/B quote minimization: wikitext and html tags should not be combined
29328 !! options
29329 parsoid=html2wt
29330 !! html/parsoid
29331 <p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
29332 <p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
29333 !! wikitext
29334 ''A''<i>B</i>
29335
29336 ''A''<nowiki/>'''<i>B</i>'''
29337 !! end
29338
29339 !! test
29340 3. I/B quote minimization: templated content stops minimization
29341 !! options
29342 parsoid=html2wt
29343 !! html/parsoid
29344 <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>
29345 <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>
29346 !! wikitext
29347 ''A''{{echo|''B''}}
29348
29349 ''A''{{echo|'''''B'''''}}
29350 !! end
29351
29352 !! test
29353 4. I/B quote minimization: new content should be mimimized with adjacent old content
29354 !! options
29355 parsoid=html2wt
29356 !! html/parsoid
29357 <p><i>A</i><i>B</i></p>
29358 <p><b>A</b><b>B</b></p>
29359 <p><i>A</i><b><i>B</i></b></p>
29360 !! wikitext
29361 ''AB''
29362
29363 '''AB'''
29364
29365 ''A'''B'''''
29366 !! end
29367
29368 !! test
29369 5a. Merge adjacent quote nodes if they've been edited
29370 !! options
29371 parsoid={
29372 "modes": ["wt2wt", "selser"],
29373 "changes": [
29374 ["p", "contents", "remove", ":contains('b')"]
29375 ]
29376 }
29377 !! wikitext
29378 ''a''b''c''
29379 !! wikitext/edited
29380 ''ac''
29381 !! end
29382
29383 !! test
29384 5b. Merge adjacent quote nodes if they've been edited
29385 !! options
29386 parsoid={
29387 "modes": ["wt2wt", "selser"],
29388 "changes": [
29389 ["#x", "remove"]
29390 ]
29391 }
29392 !! wikitext
29393 ''a''<span id="x">b</span>''c''
29394 !! wikitext/edited
29395 ''ac''
29396 !! end
29397
29398 !! test
29399 1. Merge adjacent link nodes as long as at least one element is new
29400 !! options
29401 parsoid={
29402 "modes": ["html2wt"],
29403 "scrubWikitext": true
29404 }
29405 !! html/parsoid
29406 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29407 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29408 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a>
29409 !! wikitext
29410 [[Football]]
29411 [[Football]]
29412 [[Football|Foot]][[Football|ball]]
29413 !! end
29414
29415 !! test
29416 2. Merge adjacent link nodes and enable additional normalizations
29417 !! options
29418 parsoid={
29419 "modes": ["html2wt"],
29420 "scrubWikitext": true
29421 }
29422 !! html/parsoid
29423 <a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a>
29424 !! wikitext
29425 ''[[Football]]''
29426 !! end
29427
29428 !! test
29429 3. Don't merge adjacent link nodes if scrubWikitext is false
29430 !! options
29431 parsoid={
29432 "modes": ["html2wt"],
29433 "scrubWikitext": false
29434 }
29435 !! html/parsoid
29436 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29437 !! wikitext
29438 [[Football|Foot]][[Football|ball]]
29439 !! end
29440
29441 !! test
29442 1. Move format tags outside of WikiLink
29443 !! options
29444 parsoid={
29445 "modes": ["html2wt"],
29446 "scrubWikitext": true
29447 }
29448 !! html/parsoid
29449 <a rel="mw:WikiLink" href="./Football"><i>Football</i></a>
29450 <a rel="mw:WikiLink" href="./Football"><i><b>Football</b></i></a>
29451 <a rel="mw:WikiLink" href="./Football"><u><i><b>Football</b></i></u></a>
29452 !! wikitext
29453 ''[[Football]]''
29454 '''''[[Football]]'''''
29455 <u>'''''[[Football]]'''''</u>
29456 !! end
29457
29458 !! test
29459 2. Move format tags outside of WikiLink with mergable A tags
29460 !! options
29461 parsoid={
29462 "modes": ["html2wt"],
29463 "scrubWikitext": true
29464 }
29465 !! html/parsoid
29466 <a rel="mw:WikiLink" href="./Football"><i><b>Foot</b></i></a><a rel="mw:WikiLink" href="./Football"><i><b>ball</b></i></a>
29467 !! wikitext
29468 '''''[[Football]]'''''
29469 !! end
29470
29471 !! test
29472 3. Move format tags outside of WikiLink while preserving formats already outside WikiLink
29473 !! options
29474 parsoid={
29475 "modes": ["html2wt"],
29476 "scrubWikitext": true
29477 }
29478 !! html/parsoid
29479 <font color="red"><a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><u><b>Foo</b></u></a></font>
29480 !! wikitext
29481 <font color="red"><u>'''[[Foo]]'''</u></font>
29482 !! end
29483
29484 !! test
29485 4. Do not move format tags outside of WikiLink which includes attributes color, style and class
29486 !! options
29487 parsoid={
29488 "modes": ["html2wt"],
29489 "scrubWikitext": true
29490 }
29491 !! html/parsoid
29492 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><font color="red">Foo</font></a>
29493 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><span style="color: blue; font-size: 46px;">Foo></span></a>
29494 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><span class="Bar">Foo</span></a>
29495 !! wikitext
29496 [[Foo|<font color="red">Foo</font>]]
29497 [[Foo|<span style="color: blue; font-size: 46px;">Foo></span>]]
29498 [[Foo|<span class="Bar">Foo</span>]]
29499 !! end
29500
29501 !! test
29502 5. T194083 Regression test: Manual edit test that also enables scrubWikitext to move format tags outside wikilinks
29503 !! options
29504 parsoid={
29505 "modes": ["selser"],
29506 "scrubWikitext": true,
29507 "changes": [
29508 ["a", "html", "<i>Foo</i>"]
29509 ]
29510 }
29511 !! wikitext
29512 [[Foo]]
29513 !! wikitext/edited
29514 ''[[Foo]]''
29515 !! end
29516
29517 !! test
29518 6. Regression test: Manual edit test to ensure diff markers are not lost
29519 !! options
29520 parsoid={
29521 "modes": ["selser"],
29522 "scrubWikitext": true,
29523 "changes": [
29524 ["i", "wrap", "<a href='./Foo' rel='mw:WikiLink'></a>"]
29525 ]
29526 }
29527 !! wikitext
29528 ''Foo''
29529 !! wikitext/edited
29530 ''[[Foo]]''
29531 !! end
29532
29533 !! test
29534 7. T194083 Regression test: Manual edit test to ensure nested diff markers aren't inserted
29535 !! options
29536 parsoid={
29537 "modes": ["selser"],
29538 "scrubWikitext": true,
29539 "changes": [
29540 ["div", "after", "\n<p><a href='./Foo' rel='mw:WikiLink'>Foo </a>, placeholder</p>"]
29541 ]
29542 }
29543 !! wikitext
29544 <div>placeholder</div>
29545 !! wikitext/edited
29546 <div>placeholder</div>
29547 [[Foo]] , placeholder
29548 !! end
29549
29550 #------------------------------
29551 # End of tag minimization tests
29552 #------------------------------
29553
29554 !!test
29555 T56262: New entities
29556 !! options
29557 parsoid=html2wt
29558 !! html/parsoid
29559 <span typeof="mw:Entity">&nbsp;</span>
29560 !! wikitext
29561 &nbsp;
29562 !! end
29563
29564 ## Note that there is no wikitext output for 'unknownproperty' ##
29565 ## Unknown magic words are silently dropped ##
29566
29567 !! test
29568 Magic words
29569 !! options
29570 parsoid=html2wt
29571 !! html/parsoid
29572 <meta property='mw:PageProp/toc' />
29573 <meta property='mw:PageProp/notoc' />
29574 <meta property='mw:PageProp/forcetoc' />
29575 <meta property='mw:PageProp/index' />
29576 <meta property='mw:PageProp/noindex' />
29577 <meta property='mw:PageProp/nogallery' />
29578 <meta property='mw:PageProp/noeditsection' />
29579 <meta property='mw:PageProp/notitleconvert' />
29580 <meta property='mw:PageProp/nocontentconvert' />
29581 <meta property='mw:PageProp/unknownproperty' />
29582 !! wikitext
29583 __TOC__
29584 __NOTOC__
29585 __FORCETOC__
29586 __INDEX__
29587 __NOINDEX__
29588 __NOGALLERY__
29589 __NOEDITSECTION__
29590 __NOTITLECONVERT__
29591 __NOCONTENTCONVERT__
29592 !! end
29593
29594 !! test
29595 Consecutive <pre>s should not get merged
29596 !! options
29597 parsoid=html2wt,html2html
29598 !! html/parsoid
29599 <pre>a</pre><pre>b</pre>
29600
29601 <pre>c
29602 </pre><pre>
29603 d</pre>
29604
29605 <pre>e
29606
29607 </pre><pre>
29608
29609 f</pre>
29610 !! wikitext
29611 a
29612
29613 b
29614
29615 c
29616
29617 d
29618
29619 e
29620
29621
29622
29623 f
29624 !! end
29625
29626 !! test
29627 Edited ISBN links not serializable as ISBN links should serialize as wikilinks
29628 !! options
29629 parsoid=html2wt
29630 !! html/parsoid
29631 <a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a>
29632 !! wikitext
29633 [[Special:BookSources/1234567890|ISBN 1234567895]]
29634 !! end
29635
29636 !! test
29637 Edited RFC links not serializable as RFC links should serialize as extlinks
29638 !! options
29639 parsoid=html2wt
29640 !! html/parsoid
29641 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
29642 !! wikitext
29643 [https://tools.ietf.org/html/rfc123 New RFC]
29644 !! end
29645
29646 !! test
29647 Edited PMID links not serializable as PMID links should serialize as extlinks
29648 !! options
29649 parsoid=html2wt
29650 !! html/parsoid
29651 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a>
29652 !! wikitext
29653 [//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID]
29654 !! end
29655
29656 !! test
29657 WTS of autolinks with trailing/surrounding context
29658 !! options
29659 parsoid=html2wt
29660 !! html/parsoid
29661 <p><a href="http://cscott.net">http://cscott.net</a><b>foo</b></p>
29662 <p><a href="http://cscott.net">http://cscott.net</a><b data-parsoid='{"stx":"html"}'>foo</b></p>
29663 <p><b><a href="http://cscott.net">http://cscott.net</a></b></p>
29664 <p><b><a href="http://cscott.net">http://cscott.net</a> </b></p>
29665 <p><b><a href="http://cscott.net">http://cscott.net</a>x</b></p>
29666 <p><a href="http://cscott.net">http://cscott.net</a>x</p>
29667 !! wikitext
29668 http://cscott.net'''foo'''
29669
29670 http://cscott.net<b>foo</b>
29671
29672 '''http://cscott.net'''
29673
29674 '''http://cscott.net '''
29675
29676 '''http://cscott.net<nowiki/>x'''
29677
29678 http://cscott.net<nowiki/>x
29679 !! end
29680
29681 !! test
29682 WTS of autolinks with nowikis (round-trip)
29683 !! wikitext
29684 x<nowiki/>http://cscott.net<nowiki/>x
29685 !! html/parsoid
29686 <p>x<a rel="mw:ExtLink" class="external free" href="http://cscott.net">http://cscott.net</a>x</p>
29687 !! end
29688
29689 # this is the "easy" test because it leaves in place all the
29690 # data-parsoid information indicating this is an autolink
29691 !! test
29692 WTS of autolinks with escapes (editing)
29693 !! options
29694 parsoid={
29695 "modes": ["wt2wt"],
29696 "changes": [
29697 [ "span", "remove" ]
29698 ]
29699 }
29700 !! wikitext
29701 x<nowiki/>http://cscott.net<nowiki/>x
29702 !! wikitext/edited
29703 x<nowiki/>http://cscott.net<nowiki/>x
29704 !! end
29705
29706 !! test
29707 WTS of edited autolink-like text (T103364)
29708 !! options
29709 parsoid={
29710 "modes": ["wt2wt"],
29711 "changes": [
29712 [ "span[typeof]", "removeAttr", "typeof" ]
29713 ]
29714 }
29715 !! wikitext
29716 Not a link: <nowiki>http://example.com</nowiki>.
29717 !! wikitext/edited
29718 Not a link: <span><nowiki>http://example.com</nowiki></span>.
29719 !! end
29720
29721 !! test
29722 WTS of newly-authored autolink-like text (T103364)
29723 !! options
29724 parsoid=html2wt
29725 !! html/parsoid
29726 <p>http://example.com is not a link.</p>
29727 !! wikitext
29728 <nowiki>http://example.com</nowiki> is not a link.
29729 !! end
29730
29731 !! test
29732 WTS of autolink-like text after an autolink (T108563)
29733 !! options
29734 parsoid=html2wt
29735 !! html/parsoid
29736 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p>
29737 !! wikitext
29738 http://example.com <nowiki>http://example.com</nowiki> is not a link.
29739 !! end
29740
29741 !! test
29742 Magic links inside links (not autolinked)
29743 !! wikitext
29744 [[Foo|http://example.com]]
29745 [[Foo|RFC 1234]]
29746 [[Foo|PMID 1234]]
29747 [[Foo|ISBN 123456789x]]
29748
29749 [http://foo.com http://example.com]
29750 [http://foo.com RFC 1234]
29751 [http://foo.com PMID 1234]
29752 [http://foo.com ISBN 123456789x]
29753 !! html+tidy
29754 <p><a href="/wiki/Foo" title="Foo">http://example.com</a>
29755 <a href="/wiki/Foo" title="Foo">RFC 1234</a>
29756 <a href="/wiki/Foo" title="Foo">PMID 1234</a>
29757 <a href="/wiki/Foo" title="Foo">ISBN 123456789x</a>
29758 </p><p><a rel="nofollow" class="external text" href="http://foo.com">http://example.com</a>
29759 <a rel="nofollow" class="external text" href="http://foo.com">RFC 1234</a>
29760 <a rel="nofollow" class="external text" href="http://foo.com">PMID 1234</a>
29761 <a rel="nofollow" class="external text" href="http://foo.com">ISBN 123456789x</a>
29762 </p>
29763 !! html/parsoid
29764 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a>
29765 <a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a>
29766 <a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a>
29767 <a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p>
29768
29769 <p><a rel="mw:ExtLink" class="external text" href="http://foo.com">http://example.com</a>
29770 <a rel="mw:ExtLink" class="external text" href="http://foo.com">RFC 1234</a>
29771 <a rel="mw:ExtLink" class="external text" href="http://foo.com">PMID 1234</a>
29772 <a rel="mw:ExtLink" class="external text" href="http://foo.com">ISBN 123456789x</a></p>
29773 !! end
29774
29775 !! test
29776 Magic links inside image captions (autolinked)
29777 !! wikitext
29778 [[File:Foobar.jpg|thumb|http://example.com]]
29779 [[File:Foobar.jpg|thumb|RFC 1234]]
29780 [[File:Foobar.jpg|thumb|PMID 1234]]
29781 [[File:Foobar.jpg|thumb|ISBN 123456789x]]
29782 !! html+tidy
29783 <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>
29784 <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>
29785 <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>
29786 <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>
29787 !! html/parsoid
29788 <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>
29789 <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>
29790 <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>
29791 <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>
29792 !! end
29793
29794 !! test
29795 WTS of magic word text (T109371)
29796 !! options
29797 parsoid=html2wt
29798 !! html/parsoid
29799 <p>RFC 1234</p>
29800 <p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p>
29801 <p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p>
29802 !! wikitext
29803 <nowiki>RFC 1234</nowiki>
29804
29805 [http://foo.com RFC 1234]
29806
29807 [[Foo|RFC 1234]]
29808 !! end
29809
29810 !! test
29811 Edited Redirect link should emit a non-piped wikitext link
29812 !! options
29813 parsoid=html2wt
29814 !! html/parsoid
29815 <link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>
29816 !! wikitext
29817 #REDIRECT [[Bar]]
29818 !! end
29819
29820 !! test
29821 T75121: Infer extension name from typeOf if data-mw is not present
29822 !! options
29823 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
29824 !! html/parsoid
29825 <div typeOf="mw:Extension/foo"></div>
29826 !! wikitext
29827 <foo />
29828 !! end
29829
29830 # Note that the <p> wrapping isn't present in PHP parser output
29831 # The important thing for this test is that P-wrapping doesn't
29832 # interfere with the <nowiki> protection for leading - in <td>
29833 # (which isn't necessary for <th>).
29834 !! test
29835 T88318: p-wrapped dash in table.
29836 !! options
29837 parsoid=html2wt,wt2wt
29838 !! html/parsoid
29839 <table><tbody>
29840 <tr><th><p>-</p></th><th><p>- </p></th></tr>
29841 <tr><td><p>-</p></td><td><p>- </p></td></tr>
29842 <tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr>
29843 </tbody></table>
29844 !! wikitext
29845 {|
29846 !-
29847 !-
29848 |-
29849 |<nowiki>-</nowiki>
29850 |<nowiki>- </nowiki>
29851 |-
29852 |<small>-</small>
29853 |<br />
29854 -
29855 |<br />-
29856 |}
29857 !! html/php+tidy
29858 <table>
29859 <tbody><tr>
29860 <th>-
29861 </th>
29862 <th>-
29863 </th></tr>
29864 <tr>
29865 <td>-
29866 </td>
29867 <td>-
29868 </td></tr>
29869 <tr>
29870 <td><small>-</small>
29871 </td>
29872 <td><br />
29873 <p>-
29874 </p>
29875 </td>
29876 <td><br />-
29877 </td></tr></tbody></table>
29878 !! end
29879
29880 !! test
29881 T149209: WTS: Handle newlines in table cells properly
29882 !! options
29883 parsoid=html2wt
29884 !! html/parsoid
29885 <table>
29886 <tbody>
29887 <tr><td>a
29888 b
29889 </td><td data-parsoid='{"stx":"row"}'>c</td></tr>
29890 <tr><td><p>x</p>
29891 </td><td data-parsoid='{"stx":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr>
29892 </tbody></table>
29893 <table>
29894 <tbody>
29895 <tr><th>a
29896 b
29897 </th><th data-parsoid='{"stx":"row"}'>c</th></tr>
29898 <tr><th><p>x</h>
29899 </th><th data-parsoid='{"stx":"row"}'>y</th></tr>
29900 </tbody></table>
29901 !! wikitext
29902 {|
29903 |a
29904 b
29905 |c
29906 |-
29907 |x
29908 {{!}}y
29909 |}
29910 {|
29911 !a
29912 b
29913 !c
29914 |-
29915 !x
29916 !y
29917 |}
29918 !! end
29919
29920 !! test
29921 T149209: Selser: Handle newlines in table cells properly
29922 !! options
29923 parsoid={
29924 "modes": ["selser"],
29925 "changes": [
29926 [ "#h1", "html", "a\nb\n" ],
29927 [ "#h2", "html", "a\nb\n" ],
29928 [ "#c1", "html", "a\nb\n" ],
29929 [ "#c2", "html", "<p>a</p>" ],
29930 [ "#c3", "html", "<p>a</p>" ],
29931 [ "#c4", "html", "edit-me<p>a</p>" ]
29932 ]
29933 }
29934 !! wikitext
29935 {|
29936 ! id="h1" |edit-me!!1
29937 |-
29938 ! id="h2" |edit-me||2
29939 |-
29940 | id="c1" |edit-me||3
29941 |-
29942 | id="c2" |edit-me||4
29943 |-
29944 | id="c3" |edit-me||p||q||r
29945 |-
29946 | id="c4" |edit-me||p||q||r
29947 |}
29948 !! wikitext/edited
29949 {|
29950 ! id="h1" |a
29951 b
29952 !1
29953 |-
29954 ! id="h2" |a
29955 b
29956 !2
29957 |-
29958 | id="c1" |a
29959 b
29960 |3
29961 |-
29962 | id="c2" |a
29963 |4
29964 |-
29965 | id="c3" |a
29966 |p||q||r
29967 |-
29968 | id="c4" |edit-me
29969 a
29970 |p||q||r
29971 |}
29972 !! end
29973
29974 !! test
29975 HTML id attribute with Parsoid-like element ids should not be serialized to wikitext
29976 !! options
29977 parsoid=html2wt
29978 !! html/parsoid
29979 <table id='mwAb'>
29980 <td id='mwAc'>foo</td>
29981 <td id='serialize-this'>bar</td>
29982 </table>
29983 !! wikitext
29984 {|
29985 |foo
29986 | id="serialize-this" |bar
29987 |}
29988 !! end
29989
29990 !! test
29991 Parsoid-like element ids should not be serialized to wikitext unless shadowed
29992 !! options
29993 parsoid=html2wt
29994 !! html/parsoid
29995 <div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div>
29996 !! wikitext
29997 <div id="hello">ok</div>
29998 !! end
29999
30000 !! test
30001 Testing serialization after deletion in references
30002 !! options
30003 parsoid={
30004 "modes": ["wt2wt"],
30005 "changes": [
30006 ["#x", "remove"]
30007 ]
30008 }
30009 !! wikitext
30010 hi <ref><div id="x">ho</div></ref>
30011
30012 <references />
30013 !! wikitext/edited
30014 hi <ref></ref>
30015
30016 <references />
30017 !! end
30018
30019 !!test
30020 Testing serialization after deletion of table cells
30021 !!options
30022 parsoid={
30023 "modes": ["wt2wt", "selser"],
30024 "changes": [
30025 ["#x", "remove"]
30026 ]
30027 }
30028 !!wikitext
30029 {|
30030 !h1 !!h2 !!h3
30031 | id="x" |c1 {{!}}{{!}}{{!}}c2 |||c3
30032 |}
30033 !! wikitext/edited
30034 {|
30035 !h1!!h2!!h3
30036 |c2|||c3
30037 |}
30038 !!end
30039
30040 !! test
30041 Testing selser after addition of new row before first row (T125419)
30042 !! options
30043 parsoid={
30044 "modes": ["wt2wt", "selser"],
30045 "changes": [
30046 [ "tr", "before", "<tr><td>X</td></tr>" ]
30047 ]
30048 }
30049 !! wikitext
30050 {|
30051 |a
30052 |}
30053 !! wikitext/edited
30054 {|
30055 |X
30056 |-
30057 |a
30058 |}
30059 !! end
30060
30061 !! test
30062 Serialize new table rows in a HTML table using HTML tags
30063 !! options
30064 parsoid={
30065 "modes": ["wt2wt", "selser"],
30066 "changes": [
30067 [ "tr", "before", "<tr><td>X</td></tr>" ]
30068 ]
30069 }
30070 !! wikitext
30071 <table><tr><td>a</td></tr></table>
30072 !! wikitext/edited
30073 <table><tr><td>X</td></tr><tr><td>a</td></tr></table>
30074 !! end
30075
30076 !! test
30077 Serialize new table cells in a HTML row using HTML tags
30078 !! options
30079 parsoid={
30080 "modes": ["wt2wt", "selser"],
30081 "changes": [
30082 [ "td", "before", "<td>X</td>" ]
30083 ]
30084 }
30085 !! wikitext
30086 <table><tr><td>a</td></tr></table>
30087 !! wikitext/edited
30088 <table><tr><td>X</td><td>a</td></tr></table>
30089 !! end
30090
30091 !! test
30092 Serialize wikitext list items as HTML list items when embedded in a HTML list
30093 !! options
30094 parsoid=html2wt
30095 !! html/parsoid
30096 <ul data-parsoid='{"stx": "html"}'>
30097 <li data-parsoid='{}'>a</li>
30098 <li>b</li>
30099 </ul>
30100 !! wikitext
30101 <ul>
30102 <li>a</li>
30103 <li>b</li>
30104 </ul>
30105 !! html/php+tidy
30106 <ul>
30107 <li>a</li>
30108 <li>b</li>
30109 </ul>
30110 !! end
30111
30112 # Nested list should be inside <li>, that is
30113 # <ul><li>foo<ul>..</ul></li></ul> instead of
30114 # <ul><li>foo</li><ul>..</ul></ul>
30115 # See https://stackoverflow.com/questions/5899337/proper-way-to-make-html-nested-list
30116 !! test
30117 Wikitext lists can be nested inside HTML lists
30118 !! options
30119 parsoid=html2wt
30120 !! html/parsoid
30121 <ul data-parsoid='{"stx": "html"}'>
30122 <li data-parsoid='{"stx": "html"}'>a
30123 <ul><li>b</li></ul>
30124 </li>
30125 </ul>
30126
30127 <ul data-parsoid='{"stx": "html"}'>
30128 <li>x
30129 <ul><li>y</li></ul>
30130 </li>
30131 </ul>
30132 !! wikitext
30133 <ul>
30134 <li>a
30135 * b
30136 </li>
30137 </ul>
30138
30139 <ul>
30140 <li>x
30141 * y
30142 </li>
30143 </ul>
30144 !! html/php+tidy
30145 <ul>
30146 <li>a
30147 <ul><li>b</li></ul>
30148 </li>
30149 </ul>
30150 <ul>
30151 <li>x
30152 <ul><li>y</li></ul>
30153 </li>
30154 </ul>
30155 !! end
30156
30157 !! test
30158 WTS change modes
30159 !! options
30160 parsoid={
30161 "modes": ["wt2wt"],
30162 "changes": [
30163 [ "#xyz", "before", "<b>before</b> stuff " ],
30164 [ "#xyz", "after", " stuff <i>after</i>" ],
30165 [ "#xyz", "html", "x <b>y</b> z" ]
30166 ]
30167 }
30168 !! wikitext
30169 <span id="xyz">hello</span>
30170 !! wikitext/edited
30171 '''before''' stuff <span id="xyz">x '''y''' z</span> stuff ''after''
30172 !! end
30173
30174 !! test
30175 Never serialize a-tag as html, regardless of what data-parsoid has to say
30176 !! options
30177 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
30178 !! html/parsoid
30179 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a>
30180 !! wikitext
30181 [[Foo]]
30182 !! end
30183
30184 ## SSS FIXME: This is broken output nevertheless.
30185 ## What might be a reasonable non-broken output for this?
30186 ## This is an edge case unlikely to be seen in production
30187 ## that I am not wasting more time on this right now.
30188 !! test
30189 Never serialize a-tag as html, no matter what attributes it has
30190 !! options
30191 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
30192 !! html/parsoid
30193 <a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a>
30194 !! wikitext
30195 [http://boo.org http://boohoo.org]
30196 !! end
30197
30198 # Misnested is an indication that selser can reuse the source but these have
30199 # shown to sneak through on occasion. See T101768.
30200 # The original wikitext here is: [http://test.com [[one]] two three]
30201 !! test
30202 Strip span tags added to mark misnested links
30203 !! options
30204 parsoid=html2wt
30205 !! html/parsoid
30206 <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>
30207 !! wikitext
30208 [http://test.com][[one]] two three
30209 !! end
30210
30211 !! test
30212 Catch regression when unpacking misnested links
30213 !! options
30214 parsoid=wt2html
30215 !! wikitext
30216 {{echo|hi}}[http://example.com [[ho]]]
30217 !! html/parsoid
30218 <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>
30219 !! end
30220
30221 !! test
30222 Catch regression when unpacking with trailing content
30223 !! wikitext
30224 {{echo|Foo <references/> bar}}
30225 !! html/parsoid
30226 <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>
30227 !! end
30228
30229 !! test
30230 Use data-parsoid.firstWikitextNode to compute newline constraints for template content
30231 !! options
30232 parsoid=html2wt
30233 !! html/parsoid
30234 <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|}"]}'>
30235 <tbody><tr><td>d
30236 </td></tr>
30237 </tbody></table>
30238 !! wikitext
30239 {{echo|a}}
30240 {|{{echo|c
30241 {{!}}d
30242 }}
30243 |}
30244 !! end
30245
30246 ## This test verifies the presence and computation of this attribute indirectly
30247 ## by making an edit and ensuring that the serialization is correct (which it would be
30248 ## only if firstWikitextNode is properly set).
30249 !! test
30250 data-parsoid.firstWikitextNode should be computed properly in the presence of fostered content
30251 !! options
30252 parsoid= {
30253 "modes": ["wt2wt"],
30254 "changes": [
30255 [ "div#x", "remove" ],
30256 [ "div", "before", "<div>new</div>" ]
30257 ]
30258 }
30259 !! wikitext
30260 <div id="x">foo</div>
30261 {|
30262 {{echo|<div>boo</div>
30263 {{!}}b}}
30264 |c
30265 |}
30266 !! wikitext/edited
30267
30268 <div>new</div>
30269 {|
30270 {{echo|<div>boo</div>
30271 {{!}}b}}
30272 |c
30273 |}
30274 !! end
30275
30276 # --------------------------------------------
30277 # Tests spec'ing wikitext serialization norms |
30278 # --------------------------------------------
30279
30280 !! test
30281 Serialize multi-line indent-pre starting with wikitext syntax
30282 !! options
30283 parsoid=html2wt
30284 !! html/parsoid
30285 <pre>* 1
30286 ** 2
30287 * 3</pre>
30288 !! wikitext
30289 * 1
30290 ** 2
30291 * 3
30292 !! end
30293
30294 !! test
30295 1. Categories should always be serialized on their own line
30296 !! options
30297 parsoid=html2wt
30298 !! html/parsoid
30299 foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar
30300 !! wikitext
30301 foo
30302 [[Category:Foo]]
30303 bar
30304 !! end
30305
30306 !! test
30307 2. Categories that are part of templates should not introduce a line break
30308 !! wikitext
30309 foo {{echo|<span>bar</span> [[Category:baz]]}} bar
30310 !! html/parsoid
30311 <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>
30312 !! end
30313
30314 # Careful while editing these next 2 tests. There are \u200f characters
30315 # before and after the <link> tags in the HTML and following some
30316 # of the categories in wikitext
30317 # Do not remove these characters in edits.
30318 #
30319 # As part of the serialization, these bidi characters will get stripped.
30320 !! test
30321 RTL (\u200f) and LTR (\u200e) markers around category tags should be stripped
30322 !! options
30323 parsoid={
30324 "modes": ["html2wt"],
30325 "scrubWikitext": true
30326 }
30327 !! html/parsoid
30328 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏
30329 ‏<link rel="mw:PageProp/Category" href="./קטגוריה:_שיטות_משפט" />‏</p>
30330 !! wikitext
30331 [[קטגוריה:טקסים]]
30332 [[קטגוריה: שיטות משפט]]
30333 !! end
30334
30335 !! test
30336 RTL (\u200f) and LTR (\u200e) markers should not be stripped if followed by a text node
30337 !! options
30338 parsoid={
30339 "modes": ["html2wt"],
30340 "scrubWikitext": true
30341 }
30342 !! html/parsoid
30343 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏y</p>
30344 !! wikitext
30345 [[קטגוריה:טקסים]]
30346 ‏y
30347 !! end
30348
30349 !! test
30350 Lists: Add space after bullets
30351 !! options
30352 parsoid=html2wt
30353 !! html/parsoid
30354 <ul>
30355 <li>foo</li>
30356 <li> bar</li>
30357 <li><span> baz</span></li>
30358 </ul>
30359 !! wikitext
30360 * foo
30361 * bar
30362 * <span> baz</span>
30363 !! end
30364
30365 !! test
30366 1. Headings: Add space before/after == (T53744)
30367 !! options
30368 parsoid=html2wt
30369 !! html/parsoid
30370 <h2>foo</h2>
30371 <h2> bar</h2>
30372 <h2>baz </h2>
30373 <h2><span> baz</span></h2>
30374 !! wikitext
30375 == foo ==
30376
30377 == bar ==
30378
30379 == baz ==
30380
30381 == <span> baz</span> ==
30382 !! end
30383
30384 !! test
30385 2. Headings: Add space before/after == even after hoisted content
30386 !! options
30387 parsoid={
30388 "modes": ["html2wt"],
30389 "scrubWikitext": true
30390 }
30391 !! html/parsoid
30392 <h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2>
30393 !! wikitext
30394 [[Category:A2]]
30395
30396 == ok ==
30397 !! end
30398
30399 !! test
30400 1. Headings: suppress newly created empty headings
30401 !! options
30402 parsoid={
30403 "modes": ["html2wt"],
30404 "scrubWikitext": true
30405 }
30406 !! html/parsoid
30407 <h2></h2>
30408 !! wikitext
30409 !! end
30410
30411 !! test
30412 2. Headings: don't suppress empty headings if scrubWikitext is false
30413 !! options
30414 parsoid=html2wt
30415 !! html/parsoid
30416 <h2></h2>
30417 !! wikitext
30418 ==<nowiki/>==
30419 !! end
30420
30421 !! test
30422 3. Headings: suppress empty headings on edits
30423 !! options
30424 parsoid={
30425 "modes": ["selser"],
30426 "scrubWikitext": true,
30427 "changes": [
30428 [ "#x", "remove"]
30429 ]
30430 }
30431 !! wikitext
30432 ==<span id="x">foo</span>==
30433 !! wikitext/edited
30434 !! end
30435
30436 !! test
30437 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = true)
30438 !! options
30439 parsoid={
30440 "modes": ["html2wt"],
30441 "scrubWikitext": true
30442 }
30443 !! html/parsoid
30444 <h2>foo<br/>bar</h2>
30445 <h2>foo <span><br/>bar</span> baz</h2>
30446 !! wikitext
30447 == foo bar ==
30448
30449 == foo <span> bar</span> baz ==
30450 !! end
30451
30452 !! test
30453 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = false)
30454 !! options
30455 parsoid={
30456 "modes": ["html2wt"],
30457 "scrubWikitext": false
30458 }
30459 !! html/parsoid
30460 <h2>foo<br/>bar</h2>
30461 !! wikitext
30462 == foo<br />bar ==
30463 !! end
30464
30465 !! test
30466 1. WT Quote Tags: suppress newly created empty style tags
30467 !! options
30468 parsoid={
30469 "modes": ["html2wt"],
30470 "scrubWikitext": true
30471 }
30472 !! html/parsoid
30473 <i></i><b></b>
30474 !! wikitext
30475 !! end
30476
30477 !! test
30478 2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false
30479 !! options
30480 parsoid=html2wt
30481 !! html/parsoid
30482 <i></i><b></b>
30483 !! wikitext
30484 ''<nowiki/>'''''<nowiki/>'''
30485 !! end
30486
30487 !! test
30488 3. WT Quote Tags: suppress empty style tags on edits
30489 !! options
30490 parsoid={
30491 "modes": ["selser"],
30492 "scrubWikitext": true,
30493 "changes": [
30494 [ "#x", "remove"]
30495 ]
30496 }
30497 !! wikitext
30498 '''<span id="x">foo</span>'''
30499 !! wikitext/edited
30500 !! end
30501
30502 !! test
30503 1. Anchors: suppress newly created empty anchors
30504 !! options
30505 parsoid={
30506 "modes": ["html2wt"],
30507 "scrubWikitext": true
30508 }
30509 !! html/parsoid
30510 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
30511 !! wikitext
30512 !! end
30513
30514 !! test
30515 2. Anchors: don't suppress empty anchors if scrubWikitext is false
30516 !! options
30517 parsoid={
30518 "modes": ["html2wt"],
30519 "scrubWikitext": false
30520 }
30521 !! html/parsoid
30522 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
30523 !! wikitext
30524 [[Test|<nowiki/>]]
30525 !! end
30526
30527 !! test
30528 3. Anchors: suppress empty anchors on edits
30529 !! options
30530 parsoid={
30531 "modes": ["selser"],
30532 "scrubWikitext": true,
30533 "changes": [
30534 [ "#x", "remove"]
30535 ]
30536 }
30537 !! wikitext
30538 [[Test|<span id="x">foo</span>]]
30539 !! wikitext/edited
30540 !! end
30541
30542 !! test
30543 3a. Anchors: do not suppress numbered extlinks
30544 !! options
30545 parsoid={
30546 "modes": ["wt2wt"],
30547 "scrubWikitext": true
30548 }
30549 !! wikitext
30550 [http://foo.com]
30551 !! html/parsoid
30552 <a rel="mw:ExtLink" href="http://foo.com"></a>
30553 !! end
30554
30555 !! test
30556 3b. Anchors: do not suppress numbered extlinks
30557 !! options
30558 parsoid={
30559 "modes": ["wt2wt"],
30560 "scrubWikitext": true,
30561 "changes": [
30562 [ "#x", "remove"]
30563 ]
30564 }
30565 !! wikitext
30566 [http://foo.com <span id="x">foo</span>]
30567 !! wikitext/edited
30568 [http://foo.com]
30569 !! end
30570
30571 !!test
30572 Normalizations should be restricted to edited content
30573 !!options
30574 parsoid={
30575 "modes": ["selser"],
30576 "scrubWikitext": true,
30577 "changes": [
30578 [ "h1", "before", "<i></i>"]
30579 ]
30580 }
30581 !!wikitext
30582 a
30583 = =
30584 b
30585 !!wikitext/edited
30586 a
30587 = =
30588 b
30589 !!end
30590
30591 !! test
30592 1. Multiple normalizations (html2wt)
30593 !! options
30594 parsoid={
30595 "modes": ["html2wt"],
30596 "scrubWikitext": true
30597 }
30598 !! html/parsoid
30599 <h2><i></i></h2>
30600 <p><a href='Foo' rel='mw:WikiLink'>foo<i></i>
30601 </a><b><i></i></b>x</p>
30602 !! wikitext
30603
30604 [[foo]]
30605 x
30606
30607 !! end
30608
30609 !! test
30610 2. Multiple normalizations (selser)
30611 !! options
30612 parsoid={
30613 "modes": ["selser"],
30614 "scrubWikitext": true,
30615 "changes": [
30616 [ "#x", "after", "<h1><i></i></h1>\n<p> bar<b></b></p>"]
30617 ]
30618 }
30619 !! wikitext
30620 <div id="x">foo</div>
30621 !! wikitext/edited
30622 <div id="x">foo</div>
30623 bar
30624 !! end
30625
30626 !! test
30627 1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
30628 !! options
30629 parsoid={
30630 "modes": ["html2wt"],
30631 "scrubWikitext": true
30632 }
30633 !! html/parsoid
30634 <p> hi</p>
30635 <p> hello</p>
30636 !! wikitext
30637 hi
30638
30639 hello
30640 !! end
30641
30642 !! test
30643 2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false
30644 !! options
30645 parsoid=html2wt
30646 !! html/parsoid
30647 <p> hi</p>
30648 <p> hello</p>
30649 !! wikitext
30650 <nowiki> </nowiki>hi
30651
30652 <nowiki> </nowiki> hello
30653 !! end
30654
30655 !! test
30656 3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
30657 !! options
30658 parsoid={
30659 "modes": ["html2wt"],
30660 "scrubWikitext": true
30661 }
30662 !! html/parsoid
30663 <p>Foo
30664 bar
30665 baz</p>
30666
30667 <table><tr><td>Foo
30668 bar
30669 baz bang</td></tr></table>
30670
30671 <p><!--boo--> foo
30672 bar</p>
30673
30674 <p> foo
30675 bar<span>boo</span></p>
30676 !! wikitext
30677 Foo
30678 bar
30679 baz
30680
30681 {|
30682 |Foo
30683 bar
30684 baz bang
30685 |}
30686
30687 <!--boo-->foo
30688 bar
30689
30690 foo
30691 bar<span>boo</span>
30692 !! end
30693
30694 !! test
30695 4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs
30696 !! options
30697 parsoid={
30698 "modes": ["selser"],
30699 "scrubWikitext": true,
30700 "changes": [
30701 [ "p", "html", " a\n b" ]
30702 ]
30703 }
30704 !! wikitext
30705 xyz
30706 !! wikitext/edited
30707 a
30708 b
30709 !! end
30710
30711 !! test
30712 1. New links that end in spaces
30713 !! options
30714 parsoid={
30715 "modes": ["html2wt"],
30716 "scrubWikitext": false
30717 }
30718 !! html/parsoid
30719 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
30720 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
30721 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
30722 !! wikitext
30723 [[Berlin ]]<nowiki/>is the capital of Germany.
30724
30725 [[Foo ]]'''bar'''
30726
30727 [[Boston ]] is a city.
30728 !! end
30729
30730 !! test
30731 2. New links that end in spaces
30732 !! options
30733 parsoid={
30734 "modes": ["html2wt"],
30735 "scrubWikitext": true
30736 }
30737 !! html/parsoid
30738 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
30739 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
30740 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
30741 !! wikitext
30742 [[Berlin]] is the capital of Germany.
30743
30744 [[Foo]] '''bar'''
30745
30746 [[Boston]] is a city.
30747 !! end
30748
30749 !! test
30750 1. Table cells with escapable prefixes
30751 !! options
30752 parsoid={
30753 "modes": ["html2wt"],
30754 "scrubWikitext": false
30755 }
30756 !! html/parsoid
30757 <table>
30758 <tr><td>a</td></tr>
30759 <tr><td>-</td></tr>
30760 <tr><td>+</td></tr>
30761 <tr><td>}</td></tr>
30762 </table>
30763 !! wikitext
30764 {|
30765 |a
30766 |-
30767 |<nowiki>-</nowiki>
30768 |-
30769 |<nowiki>+</nowiki>
30770 |-
30771 |<nowiki>}</nowiki>
30772 |}
30773 !! end
30774
30775 !! test
30776 2. Table cells with escapable prefixes
30777 !! options
30778 parsoid={
30779 "modes": ["html2wt"],
30780 "scrubWikitext": true
30781 }
30782 !! html/parsoid
30783 <table>
30784 <tr><td>a</td></tr>
30785 <tr><td>-</td></tr>
30786 <tr><td>+</td></tr>
30787 <tr><td>}</td></tr>
30788 </table>
30789 !! wikitext
30790 {|
30791 |a
30792 |-
30793 | -
30794 |-
30795 | +
30796 |-
30797 | }
30798 |}
30799 !! end
30800
30801 !! test
30802 3a. Table cells with escapable prefixes after edits
30803 !! options
30804 parsoid={
30805 "modes": ["selser"],
30806 "scrubWikitext": true,
30807 "changes": [
30808 [ "table tbody tr:first-child td:first-child", "remove"]
30809 ]
30810 }
30811 !! wikitext
30812 {|
30813 |a||-
30814 |}
30815 !! wikitext/edited
30816 {|
30817 | -
30818 |}
30819 !! end
30820
30821 !! test
30822 3b. Table cells with escapable prefixes after edits
30823 !! options
30824 parsoid={
30825 "modes": ["selser"],
30826 "scrubWikitext": true,
30827 "changes": [
30828 [ "table tbody tr:first-child td:first-child", "html", "-" ],
30829 [ "#x", "remove" ]
30830 ]
30831 }
30832 !! wikitext
30833 {|
30834 |pqr
30835 |<span id="x">foo</span>+
30836 |}
30837 !! wikitext/edited
30838 {|
30839 | -
30840 | +
30841 |}
30842 !! end
30843
30844 # FIXME: This test will fail because
30845 # normalization doesn't realize that the id attribute
30846 # will eliminate the escapable scenario
30847 !! test
30848 4a. Table cells without escapable prefixes after edits
30849 !! options
30850 parsoid={
30851 "modes": ["selser"],
30852 "scrubWikitext": true,
30853 "changes": [
30854 [ "#x", "html", "-" ]
30855 ]
30856 }
30857 !! wikitext
30858 {|
30859 | id="x" |abcd
30860 |}
30861 !! wikitext/edited
30862 {|
30863 | id="x" |-
30864 |}
30865 !! end
30866
30867 ## This tests normalizer's ability to discriminate between
30868 ## cells having identical content.
30869 !! test
30870 4b. Table cells without escapable prefixes after edits
30871 !! options
30872 parsoid={
30873 "modes": ["selser"],
30874 "scrubWikitext": true,
30875 "changes": [
30876 [ "td", "html", "-" ]
30877 ]
30878 }
30879 !! wikitext
30880 {|
30881 |a||b
30882 |}
30883 !! wikitext/edited
30884 {|
30885 | -||-
30886 |}
30887 !! end
30888
30889 ## This tests normalizer's ability to not be tripped by
30890 ## comments (and whitespace)
30891 !! test
30892 4c. Table cells without escapable prefixes after edits
30893 !! options
30894 parsoid={
30895 "modes": ["selser"],
30896 "scrubWikitext": true,
30897 "changes": [
30898 [ "table tbody tr td:first-child", "remove" ]
30899 ]
30900 }
30901 !! wikitext
30902 {|
30903 |-
30904 <!--foo--> |a||-
30905 |}
30906 !! wikitext/edited
30907 {|
30908 |-
30909 <!--foo--> | -
30910 |}
30911 !! end
30912
30913 ## This tests normalizer's ability to handle HTML cells
30914 !! test
30915 4d. Table cells without escapable prefixes after edits
30916 !! options
30917 parsoid={
30918 "modes": ["selser"],
30919 "scrubWikitext": true,
30920 "changes": [
30921 [ "td", "html", "-" ]
30922 ]
30923 }
30924 !! wikitext
30925 <table>
30926 <tr><td>a</td></tr>
30927 </table>
30928 !! wikitext/edited
30929 <table>
30930 <tr><td>-</td></tr>
30931 </table>
30932 !! end
30933
30934 ## T111151 Remove font elements without attributes
30935 !! test
30936 5a. font tags without attributes should be dropped in scrubWikitext mode
30937 !! options
30938 parsoid={
30939 "modes": ["html2wt"],
30940 "scrubWikitext": true
30941 }
30942 !! html/parsoid
30943 <font>foo</font>
30944 <font><font>bar</font></font>
30945 <font class="x">boo</font>
30946 !! wikitext
30947 foo
30948 bar
30949 <font class="x">boo</font>
30950 !! end
30951
30952 !! test
30953 5b. font tags should not be dropped without scrubWikitext being enabled
30954 !! options
30955 parsoid={
30956 "modes": ["html2wt"],
30957 "scrubWikitext": false
30958 }
30959 !! html/parsoid
30960 <font>foo</font>
30961 !! wikitext
30962 <font>foo</font>
30963 !! end
30964
30965 !! test
30966 Escape nowiki DOM elements
30967 !! options
30968 parsoid=html2wt
30969 !! html/parsoid
30970 <nowiki><i>foo</i></nowiki>
30971 !! wikitext
30972 &lt;nowiki&gt;''foo''&lt;/nowiki&gt;
30973 !! end
30974
30975 # This is meant to be an interim fix while we go about figuring out
30976 # how to not introduce these trailing <nowiki/>s in the first place.
30977 !! test
30978 T115717: Strip trailing <nowiki/>s (without affecting valid uses)
30979 !! options
30980 parsoid=html2wt
30981 !! html/parsoid
30982 <p>x<meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/>
30983 y</p>
30984 <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>
30985 <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>
30986 !! wikitext
30987 x
30988 y
30989
30990 {{echo|
30991 1 = <nowiki/>}}
30992
30993 {{echo|
30994 1 = <nowiki/>
30995 }}
30996 !! end
30997
30998 !! test
30999 New list is serialized on newlines
31000 !! options
31001 parsoid=html2wt
31002 !! html/parsoid
31003 <p>The quick brown fox jumps over the lazy dog.</p><ul>
31004 <li>Yesterday</li>
31005 <li>Today</li>
31006 <li>Tomorrow</li>
31007 </ul><p>The quick onyx goblin jumps over the lazy dwarf.</p>
31008 !! wikitext
31009 The quick brown fox jumps over the lazy dog.
31010
31011 * Yesterday
31012 * Today
31013 * Tomorrow
31014
31015 The quick onyx goblin jumps over the lazy dwarf.
31016 !! end
31017
31018 !! test
31019 New lists in formatting elements serialized w/o newlines
31020 !! options
31021 parsoid=html2wt
31022 !! html/parsoid
31023 <small>
31024
31025 <ul>
31026 <li>123</li>
31027 </ul>
31028
31029 </small>
31030
31031 <small><ul><li>hi</li></ul></small>
31032 !! wikitext
31033 <small>
31034 * 123
31035 </small>
31036
31037 <small>
31038 * hi
31039 </small>
31040 !! end
31041
31042 !! test
31043 New list in table doesn't need newlines
31044 !! options
31045 parsoid=html2wt
31046 !! html/parsoid
31047 <table><tr><td><ul><li>test</li><li>123</li></td></tr></table>
31048 !! wikitext
31049 {|
31050 |
31051 * test
31052 * 123
31053 |}
31054 !! end
31055
31056 # ---------------------------------------------------
31057 # End of tests spec'ing wikitext serialization norms |
31058 # ---------------------------------------------------
31059
31060 # T104032
31061 !! test
31062 Bare inline nodes not wrapped inside p-tags should be treated as p-wrapped
31063 !! options
31064 parsoid=html2wt
31065 !! html/parsoid
31066 a<p>b</p>
31067 <b>c</b><p>d</p>
31068 <table><tr>
31069 <td>a<p>b</p></td>
31070 <td><b>c</b><p>d</p></td>
31071 </tr></table>
31072 !! wikitext
31073 a
31074
31075 b
31076
31077 '''c'''
31078
31079 d
31080 {|
31081 |a
31082 b
31083 |'''c'''
31084 d
31085 |}
31086 !! end
31087
31088 !! test
31089 Anchor without href scenarios
31090 !! options
31091 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
31092 !! html/parsoid
31093 <a class="bc"></a>
31094 <a class="no">dice</a>
31095 <a name="foo"></a>
31096 !! wikitext
31097
31098 dice
31099 <span name="foo"></span>
31100 !! end
31101
31102 !! test
31103 New transclusion added after a list should be serialized after the list
31104 !! options
31105 parsoid=html2wt
31106 !! html/parsoid
31107 <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>
31108 !! wikitext
31109 * a
31110 {{echo|foo}}
31111 !! end
31112
31113 # -----------------------------------------------------------------
31114 # End of section for Parsoid-only html2wt tests for serialization
31115 # of new content
31116 # -----------------------------------------------------------------
31117
31118 # -----------------------------------------------------------------
31119 # The following section of tests are primarily to spec behavior of
31120 # the selective serializer. All these tests have manual selser
31121 # changes. The automated selser changes for all tests handle the
31122 # wide variation of changes, but these tests here capture specs
31123 # deterministically.
31124 # ----------------------------------------------------------------
31125
31126 ## T90517
31127 !! test
31128 Selser: New comments should not be lost
31129 !! options
31130 parsoid={
31131 "modes": ["selser"],
31132 "changes": [
31133 [ "#a", "after", "<!--c1-->" ],
31134 [ "#b", "before", "<!--c2-->" ]
31135 ]
31136 }
31137 !! wikitext
31138 <span id="a">a</span>
31139
31140 <span id="b">b</span>
31141 !! wikitext/edited
31142 <span id="a">a</span><!--c1-->
31143
31144 <!--c2--><span id="b">b</span>
31145 !! end
31146
31147 ## T89383
31148 !! test
31149 Selser: Check for validity of DSR before using it
31150 !! options
31151 parsoid={
31152 "modes": ["selser"],
31153 "changes": [
31154 [ "#a", "before", "<meta property='mw:PageProp/displaytitle' content='foo'>" ]
31155 ]
31156 }
31157 !! wikitext
31158 <span id="a">a</span>
31159 !! wikitext/edited
31160 {{DISPLAYTITLE:foo}}
31161 <span id="a">a</span>
31162 !! end
31163
31164 !! test
31165 1. DOMDiff: Changes to <ref> content should be looked up using id
31166 !! options
31167 parsoid={
31168 "modes": ["selser"],
31169 "changes": [
31170 ["#X", "after", "bar"],
31171 ["#Y", "after", "baz"]
31172 ]
31173 }
31174 !! wikitext
31175 X <ref><span id="X">foo</span></ref>
31176 Y <ref name="a" />
31177 <references>
31178 <ref name="a"><span id="Y">foo</span></ref>
31179 </references>
31180 !! wikitext/edited
31181 X <ref><span id="X">foo</span>bar</ref>
31182 Y <ref name="a" />
31183 <references>
31184 <ref name="a"><span id="Y">foo</span>baz</ref>
31185 </references>
31186 !! end
31187
31188 !! test
31189 2. DOMDiff: Changes to <ref> content should be looked up using id
31190 !! options
31191 parsoid={
31192 "modes": ["selser"],
31193 "changes": [
31194 ["#Z", "after", "bar"]
31195 ]
31196 }
31197 !! wikitext
31198 A <ref>foo bar for a</ref>
31199 B <ref group="X" name="b" />
31200
31201 <references />
31202
31203 <references group="X">
31204 <ref name="b"><span id="Z">foo</span></ref>
31205 </references>
31206 !! wikitext/edited
31207 A <ref>foo bar for a</ref>
31208 B <ref group="X" name="b" />
31209
31210 <references />
31211
31212 <references group="X">
31213 <ref name="b"><span id="Z">foo</span>bar</ref>
31214 </references>
31215 !! end
31216
31217 !! test
31218 DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388)
31219 !! options
31220 parsoid={
31221 "modes": ["selser"],
31222 "changes": [
31223 [ "div:first-child", "text", "bar" ]
31224 ]
31225 }
31226 !! wikitext
31227 <div style="{{1x|color:red;}}%">foo</div>
31228 !! wikitext/edited
31229 <div style="{{1x|color:red;}}%">bar</div>
31230 !! end
31231
31232 !! test
31233 Empty LI (T49673)
31234 !! wikitext
31235 *a
31236 *
31237 *
31238 *b
31239 !! html+tidy
31240 <ul><li>a</li>
31241 <li class="mw-empty-elt"></li>
31242 <li class="mw-empty-elt"></li>
31243 <li>b</li></ul>
31244 !! end
31245
31246 !! test
31247 Thumbnail output
31248 !! wikitext
31249 [[File:Thumb.png|thumb]]
31250 !! html/php+tidy
31251 <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>
31252 !! html/parsoid
31253 <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>
31254 !! end
31255
31256 !! test
31257 unclosed internal link XSS (T137264)
31258 !! wikitext
31259 [[#%3Cscript%3Ealert(1)%3C/script%3E|
31260 !! html/php
31261 <p>[[#&lt;script&gt;alert(1)&lt;/script&gt;|
31262 </p>
31263 !! html/parsoid
31264 <p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p>
31265 !! end
31266
31267 !! test
31268 Validating that <style> isn't eaten by tidy (T167349)
31269 !! options
31270 styletag=1
31271 !! wikitext
31272 <div class="foo">
31273 <style>.foo::before { content: "<foo>"; }</style>
31274 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
31275 </div>
31276 !! html/php+tidy
31277 <div class="foo">
31278 <style>.foo::before { content: "<foo>"; }</style>
31279 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
31280 </div>
31281 !! html/parsoid
31282 <div class="foo">
31283 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31284 <style data-x-data-mw-foobar="baz" typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{"data-x-data-mw-foobar":"baz"},"body":{"extsrc":".foo::after { content: \"&lt;bar>\"; }"}}'>.foo::after { content: "<bar>"; }</style>
31285 </div>
31286 !! end
31287
31288 ## Right now, Parsoid doesn't de-duplicate style tags.
31289 ## So, we shouldn't see link tags that need to bypass the sanitizer.
31290 ## In a followup patch, when we de-duplicate style tags and
31291 ## introduce link tags, we'll add a hook for link tags in
31292 ## the parser test runner script.
31293 !! test
31294 Validating that <style> isn't wrapped in a paragraph (T186965)
31295 !! options
31296 styletag=1
31297 !! wikitext
31298 A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31299
31300 <style>.foo::before { content: "<foo>"; }</style>
31301
31302 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
31303
31304 But if it's on a line with other content, let it be wrapped.
31305
31306 <style>.foo::before { content: "<foo>"; }</style> bar
31307
31308 foo <style>.foo::before { content: "<foo>"; }</style>
31309
31310 foo <style>.foo::before { content: "<foo>"; }</style> bar
31311
31312 And the same if we have non-paragraph-breaking whitespace
31313
31314 foo
31315 <style>.foo::before { content: "<foo>"; }</style>
31316 bar
31317 !! html/php
31318 <p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31319 </p>
31320 <style>.foo::before { content: "<foo>"; }</style>
31321 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
31322 <p>But if it's on a line with other content, let it be wrapped.
31323 </p><p><style>.foo::before { content: "<foo>"; }</style> bar
31324 </p><p>foo <style>.foo::before { content: "<foo>"; }</style>
31325 </p><p>foo <style>.foo::before { content: "<foo>"; }</style> bar
31326 </p><p>And the same if we have non-paragraph-breaking whitespace
31327 </p><p>foo
31328 <style>.foo::before { content: "<foo>"; }</style>
31329 bar
31330 </p>
31331 !! html/parsoid
31332 <p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph</p>
31333
31334 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31335
31336 <p><style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style> &lt;link rel="foo" href="bar"/><style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style></p>
31337
31338 <p>But if it's on a line with other content, let it be wrapped.</p>
31339
31340 <p><style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style> bar</p>
31341
31342 <p>foo <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style></p>
31343
31344 <p>foo <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style> bar</p>
31345
31346 <p>And the same if we have non-paragraph-breaking whitespace</p>
31347
31348 <p>foo
31349 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31350 bar</p>
31351 !! end
31352
31353 !! test
31354 Validating that <link> isn't wrapped in a paragraph (T186965)
31355 !! options
31356 styletag=1
31357 !! wikitext
31358 A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31359
31360 <link rel="foo" href="bar"/>
31361
31362 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
31363
31364 But if it's on a line with other content, let it be wrapped.
31365
31366 <link rel="foo" href="bar"/> bar
31367
31368 foo <link rel="foo" href="bar"/>
31369
31370 foo <link rel="foo" href="bar"/> bar
31371
31372 And the same if we have non-paragraph-breaking whitespace
31373
31374 foo
31375 <link rel="foo" href="bar"/>
31376 bar
31377 !! html/php
31378 <p>A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31379 </p>
31380 <link rel="foo" href="bar"/>
31381 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
31382 <p>But if it's on a line with other content, let it be wrapped.
31383 </p><p><link rel="foo" href="bar"/> bar
31384 </p><p>foo <link rel="foo" href="bar"/>
31385 </p><p>foo <link rel="foo" href="bar"/> bar
31386 </p><p>And the same if we have non-paragraph-breaking whitespace
31387 </p><p>foo
31388 <link rel="foo" href="bar"/>
31389 bar
31390 </p>
31391 !! end
31392
31393 !! test
31394 Extension returning multiple nodes starting with a style tag roundtrips
31395 !! options
31396 wgRawHtml=1
31397 !! wikitext
31398 <table>
31399 {{echo|<html><style>.hi { color: red; }</style>
31400 </html>}}
31401 <tr><td class="hi">ho</td></tr>
31402 </table>
31403 !! html/parsoid
31404 <p about="#mwt5" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE_html","pi":[[{"k":"1"}]]}' data-mw='{"parts":["&lt;table>\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;html>&lt;style>.hi { color: red; }&lt;/style>\n&lt;/html>"}},"i":0}},"\n&lt;tr>&lt;td class=\"hi\">ho&lt;/td>&lt;/tr>\n&lt;/table>"]}'><style typeof="mw:Extension/html" about="#mwt4" data-mw='{"name":"html","attrs":{},"body":{"extsrc":"&lt;style>.hi { color: red; }&lt;/style>\n"}}'>.hi { color: red; }</style><span about="#mwt4">
31405 </span></p><table about="#mwt5" data-parsoid='{"stx":"html"}'>
31406
31407 <tbody><tr><td class="hi">ho</td></tr>
31408 </tbody></table>
31409 !! end
31410
31411 !! test
31412 Decoding of HTML entities in headings and links for IDs and link fragments (T103714)
31413 !! config
31414 wgFragmentMode=[ 'html5', 'legacy' ]
31415 !! wikitext
31416 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
31417 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
31418 !! html/php
31419 <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>
31420 <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>
31421 </p>
31422 !! html/parsoid
31423 <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>
31424 <p><a rel="mw:WikiLink" href="./Parser_test#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E"},"sa":{"href":"#A&amp;B&amp;amp;C&amp;amp;amp;D&amp;amp;amp;amp;E"}}'>#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a></p>
31425 !! end
31426
31427 !! test
31428 Decoding of HTML entities in headings and links for IDs and link fragments (T103714) (legacy)
31429 !! config
31430 wgFragmentMode=[ 'legacy' ]
31431 !! wikitext
31432 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
31433 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
31434 !! html/php
31435 <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>
31436 <p><a href="#A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a>
31437 </p>
31438 !! end
31439
31440 !! test
31441 Decoding of HTML entities in embedded HTML tags
31442 !! wikitext
31443 <table class="1&2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
31444 !! html/php
31445 <table class="1&amp;2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
31446
31447 !! html/parsoid
31448 <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>
31449 !! end
31450
31451 !! test
31452 Decoding of HTML entities in indicator names for IDs (T104196)
31453 !! options
31454 parsoid=wt2html,html2html
31455 showindicators
31456 !! wikitext
31457 <indicator name="1&2&amp;3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
31458 !! html/php
31459 1&2&3&amp;4&amp;amp;5=Indicator
31460
31461 !! html/parsoid
31462 <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>
31463 !! end
31464
31465 # this version of the test strips out the ambiguity so Parsoid rts cleanly
31466 !! test
31467 Decoding of HTML entities in indicator names for IDs (unambiguous) (T104196)
31468 !! options
31469 showindicators
31470 !! wikitext
31471 <indicator name="1&2&3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
31472 !! html/php
31473 1&2&3&amp;4&amp;amp;5=Indicator
31474
31475 !! html/parsoid
31476 <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>
31477 !! end
31478
31479 # This fragment mode is what Parsoid supports.
31480 !! test
31481 HTML5 ids: fallback to legacy
31482 !! config
31483 wgFragmentMode=[ 'html5', 'legacy' ]
31484 !! wikitext
31485 ==Foo bar==
31486
31487 ==foo Bar==
31488
31489 ==Тест==
31490
31491 ==Тест==
31492
31493 ==тест==
31494
31495 ==Hey < # " > % : '==
31496 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31497
31498 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31499
31500 <!-- These two links should produce identical HTML -->
31501 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31502
31503 !! html/php
31504 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
31505 <ul>
31506 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31507 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31508 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
31509 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
31510 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
31511 <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>
31512 </ul>
31513 </div>
31514
31515 <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>
31516 <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>
31517 <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>
31518 <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>
31519 <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>
31520 <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>
31521 <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>
31522 </p><p>💩 <span id="💩"></span>
31523 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
31524 </p>
31525 !! html/parsoid
31526 <h2 id="Foo_bar">Foo bar</h2>
31527
31528 <h2 id="foo_Bar_2">foo Bar</h2>
31529
31530 <h2 id="Тест"><span id=".D0.A2.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>Тест</h2>
31531
31532 <h2 id="Тест_2"><span id=".D0.A2.D0.B5.D1.81.D1.82_2" typeof="mw:FallbackId"></span>Тест</h2>
31533
31534 <h2 id="тест"><span id=".D1.82.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>тест</h2>
31535
31536 <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>
31537 <p><a rel="mw:WikiLink" href="./Parser_test#Foo_bar">#Foo bar</a> <a rel="mw:WikiLink" href="./Parser_test#foo_Bar">#foo Bar</a> <a rel="mw:WikiLink" href="./Parser_test#Тест">#Тест</a> <a rel="mw:WikiLink" href="./Parser_test#тест">#тест</a> <a rel="mw:WikiLink" href="./Parser_test#Hey_&lt;_#_&quot;_>_%_:_'" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Hey_&lt;_#_\"_>_%_:_&#39;"},"sa":{"href":"#Hey &lt; # \" > % : &#39;"}}'>#Hey &lt; # " > % : '</a></p>
31538
31539 <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>
31540
31541 <!-- These two links should produce identical HTML -->
31542 <p><a rel="mw:WikiLink" href="./Parser_test#啤酒">#啤酒</a> <a rel="mw:WikiLink" href="./Parser_test#啤酒" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#啤酒"},"sa":{"href":"#%E5%95%A4%E9%85%92"}}'>#啤酒</a></p>
31543 !! end
31544
31545 # Parsoid doesn't support this mode
31546 !! test
31547 HTML5 ids: legacy with a fallback to modern
31548 !! config
31549 wgFragmentMode=[ 'legacy', 'html5' ]
31550 !! wikitext
31551 ==Foo bar==
31552
31553 ==foo Bar==
31554
31555 ==Тест==
31556
31557 ==Тест==
31558
31559 ==тест==
31560
31561 ==Hey < # " > % : '==
31562 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31563
31564 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31565
31566 <!-- These two links should produce identical HTML -->
31567 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31568
31569 !! html/php
31570 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
31571 <ul>
31572 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31573 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31574 <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>
31575 <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>
31576 <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>
31577 <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>
31578 </ul>
31579 </div>
31580
31581 <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>
31582 <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>
31583 <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>
31584 <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>
31585 <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>
31586 <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>
31587 <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>
31588 </p><p>.F0.9F.92.A9 <span id=".F0.9F.92.A9"></span>
31589 </p><p><a href="#.E5.95.A4.E9.85.92">#啤酒</a> <a href="#.E5.95.A4.E9.85.92">#啤酒</a>
31590 </p>
31591 !! end
31592
31593 # Parsoid doesn't support this mode.
31594 !! test
31595 HTML5 ids: no legacy
31596 !! config
31597 wgFragmentMode=[ 'html5' ]
31598 !! wikitext
31599 ==Foo bar==
31600
31601 ==foo Bar==
31602
31603 ==Тест==
31604
31605 ==Тест==
31606
31607 ==тест==
31608
31609 ==Hey < # " > % : '==
31610 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31611
31612 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31613
31614 <!-- These two links should produce identical HTML -->
31615 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31616
31617 !! html/php
31618 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
31619 <ul>
31620 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31621 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31622 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
31623 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
31624 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
31625 <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>
31626 </ul>
31627 </div>
31628
31629 <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>
31630 <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>
31631 <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>
31632 <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>
31633 <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>
31634 <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>
31635 <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>
31636 </p><p>💩 <span id="💩"></span>
31637 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
31638 </p>
31639 !! end
31640
31641 !! test
31642 T90902: Normalize weird characters in section IDs
31643 !! config
31644 wgFragmentMode=[ 'html5', 'legacy' ]
31645 !! wikitext
31646 ==Foo&nbsp;bar==
31647 [[#Foo&nbsp;bar]]
31648
31649 !! html/php
31650 <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>
31651 <p><a href="#Foo_bar">#Foo&#160;bar</a>
31652 </p>
31653 !! html/parsoid
31654 <h2 id="Foo_bar"> Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span>bar </h2>
31655 <p><a rel="mw:WikiLink" href="./Parser_test#Foo_bar" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Foo_bar"},"sa":{"href":"#Foo&amp;nbsp;bar"}}'>#Foo bar</a></p>
31656 !! end
31657
31658 !! test
31659 T51672: Test for brackets in attributes of elements in external link texts
31660 !! wikitext
31661 [http://example.com/ link <span title="title with [brackets]">span</span>]
31662 [http://example.com/ link <span title="title with &#91;brackets&#93;">span</span>]
31663
31664 !! html/php
31665 <p><a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
31666 <a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
31667 </p>
31668 !! html/parsoid
31669 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/">link <span title="title with [brackets]">span</span></a>
31670 <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>
31671 !! end
31672
31673 !! test
31674 T72875: Test for brackets in attributes of elements in internal link texts
31675 !! wikitext
31676 [[Foo|link <span title="title with [[double brackets]]">span</span>]]
31677 [[Foo|link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span>]]
31678
31679 !! html/php
31680 <p><a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
31681 <a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
31682 </p>
31683 !! html/parsoid
31684 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">link <span title="title with [[double brackets]]">span</span></a>
31685 <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>
31686 !! end
31687
31688 !! test
31689 T199926: html arrow wt: Parsoid sometimes trips up on verticalbar chars in hrefs
31690 !! options
31691 parsoid={
31692 "modes": ["html2wt"]
31693 }
31694 !! html/parsoid
31695 <a href="https://stats.wikimedia.org/v2/#/fr.wikipedia.org/reading/page-views-by-country/normal|map|2-Year~2016060100~2018071100|~total">9</a>
31696 <a href="https://stats.wikimedia.org/v2/#/fr.wikipedia.org/reading/page-views-by-country/normal%7Cmap%7C2-Year~2016060100~2018071100%7C~total">10</a>
31697 !! wikitext
31698 [https://stats.wikimedia.org/v2/#/fr.wikipedia.org/reading/page-views-by-country/normal|map|2-Year~2016060100~2018071100|~total 9]
31699 [[stats:v2/#/fr.wikipedia.org/reading/page-views-by-country/normal%7Cmap%7C2-Year~2016060100~2018071100%7C~total|10]]
31700 !! end
31701
31702 !! test
31703 T179544: {{anchorencode:}} output should be always usable in links
31704 !! config
31705 wgFragmentMode=[ 'html5' ]
31706 !! wikitext
31707 <span id="{{anchorencode:[foo]}}"></span>[[#{{anchorencode:[foo]}}]]
31708 !! html/php
31709 <p><span id="&#91;foo&#93;"></span><a href="#[foo]">#&#91;foo&#93;</a>
31710 </p>
31711 !! html/parsoid
31712 <p><span id="[foo]" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html","a":{"id":"[foo]"},"sa":{"id":"{{anchorencode:[foo]}}"}}' data-mw='{"attribs":[[{"txt":"id"},{"html":"&lt;span typeof=\"mw:Transclusion mw:Entity\" about=\"#mwt1\" data-parsoid=&apos;{\"srcContent\":\"[\",\"dsr\":[10,32,null,null],\"pi\":[[]]}&apos; data-mw=&apos;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"anchorencode:[foo]\",\"function\":\"anchorencode\"},\"params\":{},\"i\":0}}]}&apos;>[&lt;/span>&lt;span about=\"#mwt1\" data-parsoid=\"{}\">foo&lt;/span>&lt;span typeof=\"mw:Entity\" about=\"#mwt1\" data-parsoid=&apos;{\"src\":\"&amp;amp;#x5D;\",\"srcContent\":\"]\"}&apos;>]&lt;/span>"}]]}'></span><a typeof="mw:ExpandedAttrs" about="#mwt4" rel="mw:WikiLink" href="./Parser_test#[foo]" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#[foo]"},"sa":{"href":"#{{anchorencode:[foo]}}"}}' data-mw='{"attribs":[[{"txt":"href"},{"html":"#&lt;span typeof=\"mw:Transclusion mw:Entity\" about=\"#mwt2\" data-parsoid=&apos;{\"srcContent\":\"[\",\"dsr\":[44,66,null,null],\"pi\":[[]]}&apos; data-mw=&apos;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"anchorencode:[foo]\",\"function\":\"anchorencode\"},\"params\":{},\"i\":0}}]}&apos;>[&lt;/span>&lt;span about=\"#mwt2\" data-parsoid=\"{}\">foo&lt;/span>&lt;span typeof=\"mw:Entity\" about=\"#mwt2\" data-parsoid=&apos;{\"src\":\"&amp;amp;#x5D;\",\"srcContent\":\"]\"}&apos;>]&lt;/span>"}]]}'>#[foo]</a></p>
31713 !! end
31714
31715 ## ------------------------------
31716 ## Parsoid section-wrapping tests
31717 ## ------------------------------
31718 !! test
31719 Section wrapping for well-nested sections (no leading content)
31720 !! options
31721 parsoid={
31722 "wrapSections": true
31723 }
31724 !! wikitext
31725 =1=
31726 a
31727
31728 =2=
31729 b
31730
31731 ==2.1==
31732 c
31733
31734 ==2.2==
31735 d
31736
31737 ===2.2.1===
31738 e
31739
31740 =3=
31741 f
31742 !! html/parsoid
31743 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
31744 <p>a</p>
31745
31746 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
31747 <p>b</p>
31748
31749 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
31750 <p>c</p>
31751
31752 </section><section data-mw-section-id="4"><h2 id="2.2">2.2</h2>
31753 <p>d</p>
31754
31755 <section data-mw-section-id="5"><h3 id="2.2.1">2.2.1</h3>
31756 <p>e</p>
31757
31758 </section></section></section><section data-mw-section-id="6"><h1 id="3">3</h1>
31759 <p>f</p>
31760
31761 </section>
31762 !! end
31763
31764 !! test
31765 Section wrapping for well-nested sections (with leading content)
31766 !! options
31767 parsoid={
31768 "wrapSections": true
31769 }
31770 !! wikitext
31771 Para 1.
31772
31773 Para 2 with a <div>nested in it</div>
31774
31775 Para 3.
31776
31777 =1=
31778 a
31779
31780 =2=
31781 b
31782
31783 ==2.1==
31784 c
31785 !! html/parsoid
31786 <section data-mw-section-id="0"><p>Para 1.</p>
31787
31788 <p>Para 2 with a </p><div>nested in it</div>
31789
31790 <p>Para 3.</p>
31791
31792 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
31793 <p>a</p>
31794
31795 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
31796 <p>b</p>
31797
31798 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
31799 <p>c</p>
31800
31801 </section></section>
31802 !! end
31803
31804 !! test
31805 Section wrapping with template-generated sections (good nesting 1)
31806 !! options
31807 parsoid={
31808 "wrapSections": true
31809 }
31810 !! wikitext
31811 =1=
31812 a
31813
31814 {{echo|1=
31815 ==1.1==
31816 b
31817 }}
31818
31819 ==1.2==
31820 c
31821
31822 =2=
31823 d
31824 !! html/parsoid
31825 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
31826 <p>a</p>
31827
31828 <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">
31829 </span><p about="#mwt1">b</p>
31830 </section><section data-mw-section-id="3"><h2 id="1.2">1.2</h2>
31831 <p>c</p>
31832
31833 </section></section><section data-mw-section-id="4"><h1 id="2">2</h1>
31834 <p>d</p></section>
31835 !! end
31836
31837 # In this example, the template scope is mildly expanded to incorporate the
31838 # trailing newline after the transclusion since that is part of section 1.1.1
31839 !! test
31840 Section wrapping with template-generated sections (good nesting 2)
31841 !! options
31842 parsoid={
31843 "wrapSections": true,
31844 "modes": ["wt2html", "wt2wt"]
31845 }
31846 !! wikitext
31847 =1=
31848 a
31849
31850 {{echo|1=
31851 ==1.1==
31852 b
31853 ===1.1.1===
31854 d
31855 }}
31856 =2=
31857 e
31858 !! html/parsoid
31859 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
31860 <p>a</p>
31861
31862 <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">
31863 </span><p about="#mwt1">b</p><span about="#mwt1">
31864 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.1.1">1.1.1</h3><span about="#mwt1">
31865 </span><p about="#mwt1">d</p><span about="#mwt1">
31866 </span></section></section></section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="2">2</h1>
31867 <p>e</p></section>
31868 !! end
31869
31870 # In this example, the template scope is mildly expanded to incorporate the
31871 # trailing newline after the transclusion since that is part of section 1.2.1
31872 !! test
31873 Section wrapping with template-generated sections (good nesting 3)
31874 !! options
31875 parsoid={
31876 "wrapSections": true,
31877 "modes": ["wt2html", "wt2wt"]
31878 }
31879 !! wikitext
31880 =1=
31881 a
31882
31883 {{echo|1=
31884 x
31885 ==1.1==
31886 b
31887 ==1.2==
31888 c
31889 ===1.2.1===
31890 d
31891 }}
31892 =2=
31893 e
31894 !! html/parsoid
31895 <section data-mw-section-id="0"></section><section data-mw-section-id="1" data-parsoid="{}"><h1 id="1"> 1 </h1>
31896 <p>a</p>
31897
31898 <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">
31899 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.1">1.1</h2><span about="#mwt1">
31900 </span><p about="#mwt1">b</p><span about="#mwt1">
31901 </span></section><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.2">1.2</h2><span about="#mwt1">
31902 </span><p about="#mwt1">c</p><span about="#mwt1">
31903 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.2.1">1.2.1</h3><span about="#mwt1">
31904 </span><p about="#mwt1">d</p><span about="#mwt1">
31905 </span></section></section></section><section data-mw-section-id="5"><h1 id="2">2</h1>
31906 <p>e</p></section>
31907 !! end
31908
31909 # Because of section-wrapping and template-wrapping interactions,
31910 # the scope of the template is expanded so that the template markup
31911 # is valid in the presence of <section> tags.
31912 # This exercises the s1 is null scenario in the wrapSections code
31913 !! test
31914 Section wrapping with template-generated sections (bad nesting 1)
31915 !! options
31916 parsoid={
31917 "wrapSections": true
31918 }
31919 !! wikitext
31920 <div>
31921 a
31922
31923 {{echo|
31924 =1=
31925 b
31926 }}
31927
31928 c
31929 </div>
31930 !! html/parsoid
31931 <section data-mw-section-id="-1"></section><section data-mw-section-id="-2"><div data-parsoid='{"stx":"html"}'>
31932 <p>a</p>
31933
31934 <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"]}'>
31935 </span><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="1">1</h1><span about="#mwt1">
31936 </span><p about="#mwt1">b
31937 </p><span about="#mwt1">
31938
31939 </span><p about="#mwt1">c</p><span about="#mwt1">
31940 </span></section></div></section>
31941 !! end
31942
31943 # Because of section-wrapping and template-wrapping interactions,
31944 # the scope of the template is expanded so that the template markup
31945 # is valid in the presence of <section> tags.
31946 # This exercises the s1 is ancestor of s2 scenario in the wrapSections code
31947 !! test
31948 Section wrapping with template-generated sections (bad nesting 2)
31949 !! options
31950 parsoid={
31951 "wrapSections": true
31952 }
31953 !! wikitext
31954 =1=
31955 a
31956
31957 {{echo|1=
31958 =2=
31959 b
31960 ==2.1==
31961 c
31962 }}
31963
31964 d
31965
31966 =3=
31967 e
31968 !! html/parsoid
31969 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
31970 <p>a</p>
31971
31972 </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">
31973 </span><p about="#mwt1">b</p><span about="#mwt1">
31974 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="2.1">2.1</h2><span about="#mwt1">
31975 </span><p about="#mwt1">c</p><span about="#mwt1">
31976
31977 </span><p about="#mwt1">d</p><span about="#mwt1">
31978
31979 </span></section></section><section data-mw-section-id="4"><h1 id="3">3</h1>
31980 <p>e</p></section>
31981 !! end
31982
31983 # Because of section-wrapping and template-wrapping interactions,
31984 # additional template wrappers are added to <section> tags
31985 # so that template wrapping semantics are valid whether section
31986 # tags are retained or stripped. But, the template scope can expand
31987 # greatly when accounting for section tags.
31988 # This exercises the s1 and s2 are in different subtrees scenario
31989 !! test
31990 Section wrapping with template-generated sections (bad nesting 3)
31991 !! options
31992 parsoid={
31993 "wrapSections": true,
31994 "modes": ["wt2html", "wt2wt"]
31995 }
31996 !! wikitext
31997 =1=
31998 a
31999
32000 {{echo|1=
32001 ==1.2==
32002 b
32003 =2=
32004 c
32005 }}
32006
32007 d
32008
32009 =3=
32010 e
32011 !! html/parsoid
32012 <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>
32013 <p>a</p>
32014
32015 <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">
32016 </span><p about="#mwt1">b</p><span about="#mwt1">
32017 </span></section></section><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="2">2</h1><span about="#mwt1">
32018 </span><p about="#mwt1">c</p>
32019
32020 <p>d</p>
32021 </section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="3">3</h1>
32022 <p>e</p></section>
32023 !! end
32024
32025 !! test
32026 Section wrapping with uneditable lead section + div wrapping multiple sections
32027 !! options
32028 parsoid={
32029 "wrapSections": true
32030 }
32031 !! wikitext
32032 foo
32033
32034 <div style="border:1px solid red;">
32035 =1=
32036 a
32037
32038 ==1.1==
32039 b
32040
32041 =2=
32042 c
32043 </div>
32044
32045 =3=
32046 d
32047
32048 ==3.1==
32049 e
32050 !! html/parsoid
32051 <section data-mw-section-id="-1"><p>foo</p>
32052
32053 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
32054 <section data-mw-section-id="1"><h1 id="1">1</h1>
32055 <p>a</p>
32056
32057 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
32058 <p>b</p>
32059
32060 </section></section><section data-mw-section-id="-1"><h1 id="2">2</h1>
32061 <p>c</p>
32062 </section></div>
32063
32064 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
32065 <p>d</p>
32066
32067 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
32068 <p>e</p>
32069 </section></section>
32070 !! end
32071
32072 !! test
32073 Section wrapping with editable lead section + div overlapping multiple sections
32074 !! options
32075 parsoid={
32076 "wrapSections": true
32077 }
32078 !! wikitext
32079 foo
32080
32081 =1=
32082 a
32083 <div style="border:1px solid red;">
32084 b
32085
32086 ==1.1==
32087 c
32088
32089 =2=
32090 d
32091 </div>
32092 e
32093
32094 =3=
32095 f
32096
32097 ==3.1==
32098 g
32099 !! html/parsoid
32100 <section data-mw-section-id="0"><p>foo</p>
32101
32102 </section><section data-mw-section-id="-1"><h1 id="1">1</h1>
32103 <p>a</p>
32104 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
32105 <p>b</p>
32106
32107 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
32108 <p>c</p>
32109
32110 </section><section data-mw-section-id="-1"><h1 id="2">2</h1>
32111 <p>d</p>
32112 </section></div>
32113 <p>e</p>
32114
32115 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
32116 <p>f</p>
32117
32118 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
32119 <p>g</p>
32120 </section></section>
32121 !! end
32122
32123 !! test
32124 HTML header tags should not be wrapped in section tags
32125 !! options
32126 parsoid={
32127 "wrapSections": true
32128 }
32129 !! wikitext
32130 foo
32131
32132 <h1>a</h1>
32133
32134 =b=
32135
32136 <h1>c</h1>
32137
32138 =d=
32139 !! html/parsoid
32140 <section data-mw-section-id="0"><p>foo</p>
32141
32142 <h1 id="a" data-parsoid='{"stx":"html"}'>a</h1>
32143
32144 </section><section data-mw-section-id="1"><h1 id="b">b</h1>
32145
32146 <h1 id="c" data-parsoid='{"stx":"html"}'>c</h1>
32147
32148 </section><section data-mw-section-id="2"><h1 id="d">d</h1></section>
32149 !! end
32150
32151 !! test
32152 Lead section containing only whitespace and comments.
32153 !! options
32154 parsoid={
32155 "wrapSections": true
32156 }
32157 !! wikitext
32158
32159 <!-- this is a comment, presumably significant to editors -->
32160 =1=
32161 a
32162
32163 =2=
32164 b
32165 !! html/parsoid
32166 <section data-mw-section-id="0" data-parsoid="{}">
32167 <!-- this is a comment, presumably significant to editors -->
32168 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
32169 <p>a</p>
32170
32171 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
32172 <p>b</p></section>
32173 !! end
32174
32175 !! test
32176 Pseudo-sections emitted by templates should have id -2
32177 !! options
32178 parsoid={
32179 "wrapSections": true
32180 }
32181 !! wikitext
32182 foo
32183 {{echo|<div>
32184 ==a==
32185 ==b==
32186 </div>
32187 }}
32188 !! html/parsoid
32189 <section data-mw-section-id="-1"><p>foo</p>
32190 </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}}]}'>
32191 <section data-mw-section-id="-1"><h2 id="a">a</h2>
32192 </section><section data-mw-section-id="-1"><h2 id="b">b</h2>
32193 </section></div><span about="#mwt1">
32194 </span></section>
32195 !! end
32196
32197 ##########################################################################
32198 Tests demonstrating white-space insensitivity in input wikitext
32199 for wikitext headings, wikitext list items, and wikitext table captions,
32200 headings, and cells. HTML versions of the same should preserve whitespace.
32201 ##########################################################################
32202 !! test
32203 Trim whitespace in wikitext headings, list items, table captions, headings, and cells
32204 !! options
32205 parsoid={
32206 "modes": ["wt2html"],
32207 "preserveIEW": true
32208 }
32209 !! wikitext
32210 __NOTOC__
32211 == <!--c1--> <!--c2--> Spaces <!--c3--> <!--c4--> ==
32212 == <!--c1--> <!--c2--> Tabs <!--c3--><!--c4--> ==
32213 == <!--Headings with fallback ids--> Личная жизнь ==
32214 * <!--c1--> <!--c2--> List item <!--c3--> <!--c4-->
32215 ; <!--term to define--> term : <!--term's definition--> definition
32216 {|
32217 |+ <!--c1--> <!--c2--> Table Caption <!--c3--> <!--c4-->
32218 |-
32219 ! <!--c1--> <!--c2--> Table Heading 1 <!--c3--> <!--c4--> !! Table Heading 2 <!--c5-->
32220 |-
32221 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
32222 |-
32223 | class="foo" || <!--c1--> <!--c2--> Table Cell 3 <!--c3--> <!--c4-->
32224 |-
32225 | <!--c1--> testing [[one|two]] <!--c2--> | <!--c3--> some content
32226 |}
32227 : {|
32228 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
32229 |} foo <!--c1-->
32230 !! html/php+tidy
32231 <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>
32232 <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>
32233 <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>
32234 <ul><li>List item</li></ul>
32235 <dl><dt>term&#160;</dt>
32236 <dd>definition</dd></dl>
32237 <table>
32238 <caption>Table Caption
32239 </caption>
32240 <tbody><tr>
32241 <th>Table Heading 1</th>
32242 <th>Table Heading 2
32243 </th></tr>
32244 <tr>
32245 <td>Table Cell 1</td>
32246 <td>Table Cell 2
32247 </td></tr>
32248 <tr>
32249 <td>class="foo"</td>
32250 <td>Table Cell 3
32251 </td></tr>
32252 <tr>
32253 <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
32254 </td></tr></tbody></table>
32255 <dl><dd><table>
32256 <tbody><tr>
32257 <td>Table Cell 1</td>
32258 <td>Table Cell 2
32259 </td></tr></tbody></table> foo</dd></dl>
32260 !! html/parsoid
32261 <meta property="mw:PageProp/notoc">
32262 <h2 id="Spaces"><!--c1--><!--c2-->Spaces<!--c3--><!--c4--></h2>
32263 <h2 id="Tabs"><!--c1--><!--c2-->Tabs<!--c3--><!--c4--></h2>
32264 <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>
32265 <ul><li><!--c1--><!--c2-->List item<!--c3--><!--c4--></li></ul>
32266 <dl><dt><!--term to define-->term&nbsp;</dt><dd><!--term's definition-->definition</dd></dl>
32267 <table>
32268 <caption><!--c1--><!--c2-->Table Caption<!--c3--><!--c4--></caption>
32269 <tbody><tr>
32270 <th><!--c1--><!--c2-->Table Heading 1<!--c3--><!--c4--></th><th>Table Heading 2<!--c5--></th></tr>
32271 <tr>
32272 <td><!--c1--><!--c2-->Table Cell 1<!--c3--><!--c4--></td><td>Table Cell 2<!--c5--></td></tr>
32273 <tr>
32274 <td>class="foo"</td><td><!--c1--><!--c2-->Table Cell 3<!--c3--><!--c4--></td></tr>
32275 <tr>
32276 <td><!--c1-->testing <a rel="mw:WikiLink" href="./One" title="One">two</a> <!--c2--> | <!--c3--> some content</td></tr>
32277 </tbody></table>
32278 <dl><dd><table>
32279 <tbody><tr><td><!--c1--><!--c2-->Table Cell 1<!--c3--><!--c4--></td><td>Table Cell 2<!--c5--></td></tr>
32280 </tbody></table> foo<!--c1--></dd></dl>
32281 !! end
32282
32283 # Looks like <caption> is not accepted in HTML
32284 !! test
32285 Do not trim whitespace in HTML headings, list items, table captions, headings, and cells
32286 !! options
32287 parsoid={
32288 "modes": ["wt2html"],
32289 "preserveIEW": true
32290 }
32291 !! wikitext
32292 __NOTOC__
32293 <h2> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
32294 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
32295 <table>
32296 <tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> <th></tr>
32297 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> <th></tr>
32298 </table>
32299 !! html/php+tidy
32300 <h2><span class="mw-headline" id="Heading"> Heading </span></h2>
32301 <ul><li> List item </li></ul>
32302 <table>
32303 <tbody><tr><th> Table Heading </th><th></th></tr>
32304 <tr><td> Table Cell </td><th></th></tr>
32305 </tbody></table>
32306 !! html/parsoid
32307 <meta property="mw:PageProp/notoc"/>
32308 <h2 id="Heading"> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
32309 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
32310 <table>
32311 <tbody><tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> </th><th></th></tr>
32312 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> </td><th></th></tr>
32313 </tbody></table>
32314 !! end
32315
32316 !! test
32317 Do not trim whitespace in links and quotes
32318 !! options
32319 parsoid={
32320 "modes": ["wt2html"],
32321 "preserveIEW": true
32322 }
32323 !! wikitext
32324 foo '' <!--c1--> italic <!--c2--> '' and ''' <!--c3--> bold <!--c4--> '''
32325 [[Foo| some text ]]
32326 !! html/php+tidy
32327 <p>foo <i> italic </i> and <b> bold </b>
32328 <a href="/wiki/Foo" title="Foo"> some text </a>
32329 </p>
32330 !! html/parsoid
32331 <p>foo <i> <!--c1--> italic <!--c2--> </i> and <b> <!--c3--> bold <!--c4--> </b>
32332 <a rel="mw:WikiLink" href="./Foo" title="Foo"> some text </a></p>
32333 !! end
32334
32335 !! test
32336 Remove p tags surrounding a single element in a figcaption
32337 !! options
32338 parsoid=html2wt
32339 !! wikitext
32340 [[File:Foobar.jpg|right|200x200px|Caption]]
32341 !! html/parsoid
32342 <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>
32343 !! end
32344
32345 !! test
32346 Selser preserves lack of newline before list and allows newline after the list
32347 !! options
32348 parsoid={
32349 "modes": ["selser"],
32350 "scrubWikitext": true,
32351 "changes": [
32352 [ "ul", "after", "<p>footer</p>" ]
32353 ]
32354 }
32355 !! wikitext
32356 header
32357 *foo
32358 *bar
32359 !! wikitext/edited
32360 header
32361 *foo
32362 *bar
32363
32364 footer
32365 !! end
32366
32367
32368 !! test
32369 Selser does not introduce newlines between unedited paragraph preceding the list
32370 !! options
32371 parsoid={
32372 "modes": ["selser"],
32373 "changes": [
32374 [ "table tbody tr td p:last-child", "empty" ]
32375 ]
32376 }
32377 !! wikitext
32378 {|
32379 |
32380 header
32381 *foo
32382 *bar
32383 footer
32384 |}
32385 !! wikitext/edited
32386 {|
32387 |
32388 header
32389 *foo
32390 *bar
32391
32392 |}
32393 !! end
32394
32395 !! test
32396 Selser does not introduce newlines between unedited paragraph following the list
32397 !! options
32398 parsoid={
32399 "modes": ["selser"],
32400 "changes": [
32401 [ "table tbody tr td p:first-child", "empty" ]
32402 ]
32403 }
32404 !! wikitext
32405 {|
32406 |
32407 header
32408 *foo
32409 *bar
32410 footer
32411 |}
32412 !! wikitext/edited
32413 {|
32414 |
32415
32416 *foo
32417 *bar
32418 footer
32419 |}
32420 !! end
32421
32422 !! test
32423 Remove a list item but do not insert newline above list
32424 !! options
32425 parsoid={
32426 "modes": ["selser"],
32427 "changes": [
32428 [ "ul li:last-child", "remove" ]
32429 ]
32430 }
32431 !! wikitext
32432 header
32433 *foo
32434 *bar
32435 footer
32436 !! wikitext/edited
32437 header
32438 *foo
32439 footer
32440 !! end