Merge "Parse wikitext in gallery caption"
[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 !! test
21561 Gallery with template inside caption
21562 !! options
21563 parsoid={
21564 "nativeGallery": true
21565 }
21566 !! wikitext
21567 <gallery caption="{{echo|hi}}">
21568 File:Foobar.jpg|{{echo|ho}}
21569 </gallery>
21570 !! html/php
21571 <ul class="gallery mw-gallery-traditional">
21572 <li class='gallerycaption'>hi</li>
21573 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21574 <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>
21575 <div class="gallerytext">
21576 <p>ho
21577 </p>
21578 </div>
21579 </div></li>
21580 </ul>
21581
21582 !! html/parsoid
21583 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21584 <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>
21585 <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>
21586 </ul>
21587 !! end
21588
21589 !! test
21590 Gallery with wikitext inside gallery caption
21591 !! wikitext
21592 <gallery caption="# List item
21593
21594 Text '''bold''' [[link]] {{ns:-1}}
21595
21596 [[File:Foobar.jpg|thumb|File in gallery caption]]">
21597 File:Foobar.jpg|Image caption
21598 </gallery>
21599 !! html/php
21600 <ul class="gallery mw-gallery-traditional">
21601 <li class='gallerycaption'># List item Text <b>bold</b> <a href="/index.php?title=Link&amp;action=edit&amp;redlink=1" class="new" title="Link (page does not exist)">link</a> Special <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>File in gallery caption</div></div></div></li>
21602 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21603 <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>
21604 <div class="gallerytext">
21605 <p>Image caption
21606 </p>
21607 </div>
21608 </div></li>
21609 </ul>
21610
21611 !! end
21612
21613 !! test
21614 Gallery with wikitext inside caption
21615 !! options
21616 parsoid={
21617 "nativeGallery": true
21618 }
21619 !! wikitext
21620 <gallery>
21621 File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]]
21622 File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}}
21623 </gallery>
21624 !! html/php
21625 <ul class="gallery mw-gallery-traditional">
21626 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21627 <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>
21628 <div class="gallerytext">
21629 <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>
21630 </p>
21631 </div>
21632 </div></li>
21633 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21634 <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>
21635 <div class="gallerytext">
21636 <p>This is a test template
21637 </p>
21638 </div>
21639 </div></li>
21640 </ul>
21641
21642 !! html/parsoid
21643 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21644 <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>
21645 <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>
21646 </ul>
21647 !! end
21648
21649 !! test
21650 Gallery (with showfilename option)
21651 !! options
21652 parsoid={
21653 "nativeGallery": true
21654 }
21655 !! wikitext
21656 <gallery showfilename="">
21657 File:Nonexistent.jpg|caption
21658 File:Nonexistent.jpg
21659 File:Foobar.jpg|some '''caption''' [[Main Page]]
21660 File:Foobar.jpg
21661 </gallery>
21662 !! html/php
21663 <ul class="gallery mw-gallery-traditional">
21664 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21665 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21666 <div class="gallerytext">
21667 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
21668 caption
21669 </p>
21670 </div>
21671 </div></li>
21672 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21673 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21674 <div class="gallerytext">
21675 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
21676 </p>
21677 </div>
21678 </div></li>
21679 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21680 <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>
21681 <div class="gallerytext">
21682 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
21683 some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21684 </p>
21685 </div>
21686 </div></li>
21687 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21688 <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>
21689 <div class="gallerytext">
21690 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
21691 </p>
21692 </div>
21693 </div></li>
21694 </ul>
21695
21696 !! html/parsoid
21697 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
21698 <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>
21699 <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>
21700 <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>
21701 <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>
21702 </ul>
21703 !! end
21704
21705 ## Should Parsoid be preserving these variations? See T151367
21706 !! test
21707 Gallery (with namespace-less filenames)
21708 !! options
21709 parsoid={
21710 "modes": ["wt2html", "html2html"],
21711 "nativeGallery": true
21712 }
21713 !! wikitext
21714 <gallery>
21715 File:Nonexistent.jpg
21716 Nonexistent.jpg
21717 image:foobar.jpg
21718 foobar.jpg
21719 </gallery>
21720 !! html/php
21721 <ul class="gallery mw-gallery-traditional">
21722 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21723 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21724 <div class="gallerytext">
21725 </div>
21726 </div></li>
21727 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21728 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21729 <div class="gallerytext">
21730 </div>
21731 </div></li>
21732 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21733 <div class="thumb" style="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>
21734 <div class="gallerytext">
21735 </div>
21736 </div></li>
21737 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21738 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
21739 <div class="gallerytext">
21740 </div>
21741 </div></li>
21742 </ul>
21743
21744 !! html/parsoid
21745 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21746 <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>
21747 <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>
21748 <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>
21749 <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>
21750 </ul>
21751 !! end
21752
21753 !! test
21754 Gallery override link with wikilink (T36852)
21755 !! options
21756 parsoid={
21757 "nativeGallery": true
21758 }
21759 !! wikitext
21760 <gallery>
21761 File:Foobar.jpg|alt=galleryalt|link=Wikilink
21762 </gallery>
21763 !! html/php
21764 <ul class="gallery mw-gallery-traditional">
21765 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21766 <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>
21767 <div class="gallerytext">
21768 </div>
21769 </div></li>
21770 </ul>
21771
21772 !! html/parsoid
21773 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21774 <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>
21775 </ul>
21776 !! end
21777
21778 !! test
21779 Gallery override link with absolute external link (T36852)
21780 !! options
21781 parsoid={
21782 "nativeGallery": true
21783 }
21784 !! wikitext
21785 <gallery>
21786 File:Foobar.jpg|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 </div>
21794 </div></li>
21795 </ul>
21796
21797 !! html/parsoid
21798 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21799 <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>
21800 </ul>
21801 !! end
21802
21803 !! test
21804 Gallery override link with absolute external link with LanguageConverter
21805 !! options
21806 language=zh
21807 !! wikitext
21808 <gallery>
21809 File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org
21810 </gallery>
21811 !! html/php
21812 <ul class="gallery mw-gallery-traditional">
21813 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21814 <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>
21815 <div class="gallerytext">
21816 <p>caption
21817 </p>
21818 </div>
21819 </div></li>
21820 </ul>
21821
21822 !! html/parsoid
21823 <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"}}'>
21824 <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>
21825 </ul>
21826 !! end
21827
21828 !! test
21829 Gallery override link with malicious javascript (T36852)
21830 !! options
21831 parsoid={
21832 "modes": ["wt2html", "html2html"],
21833 "nativeGallery": true
21834 }
21835 !! wikitext
21836 <gallery>
21837 File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!');
21838 </gallery>
21839 !! html/php
21840 <ul class="gallery mw-gallery-traditional">
21841 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21842 <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>
21843 <div class="gallerytext">
21844 </div>
21845 </div></li>
21846 </ul>
21847
21848 !! html/parsoid
21849 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21850 <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>
21851 </ul>
21852 !! end
21853
21854 # Note that parsoid uses the invalid link as a caption, PHP does not.
21855 !! test
21856 Gallery with invalid title as link (T45964)
21857 !! options
21858 parsoid={
21859 "modes": ["wt2html", "html2html"],
21860 "nativeGallery": true
21861 }
21862 !! wikitext
21863 <gallery>
21864 File:Foobar.jpg|link=<
21865 </gallery>
21866 !! html/php
21867 <ul class="gallery mw-gallery-traditional">
21868 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21869 <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>
21870 <div class="gallerytext">
21871 </div>
21872 </div></li>
21873 </ul>
21874
21875 !! html/parsoid
21876 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21877 <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>
21878 </ul>
21879 !! end
21880
21881 !! test
21882 Serialize gallery without attrs in data-mw
21883 !! options
21884 parsoid={
21885 "modes": ["html2wt"],
21886 "nativeGallery": true
21887 }
21888 !! html/parsoid
21889 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'>
21890 <li class="gallerycaption">123</li>
21891 <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>
21892 </ul>
21893 !! wikitext
21894 <gallery caption="123">
21895 File:Test.png
21896 </gallery>
21897 !! end
21898
21899 !! test
21900 Gallery with class and style attributes
21901 !! options
21902 parsoid={
21903 "nativeGallery": true
21904 }
21905 !! wikitext
21906 <gallery class="center" style="text-align: center;">
21907 File:Foobar.jpg
21908 </gallery>
21909 !! html/php
21910 <ul class="gallery mw-gallery-traditional center" style="text-align: center;">
21911 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21912 <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>
21913 <div class="gallerytext">
21914 </div>
21915 </div></li>
21916 </ul>
21917
21918 !! html/parsoid
21919 <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":{}}'>
21920 <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>
21921 </ul>
21922 !! end
21923
21924 !! test
21925 Gallery in slideshow mode
21926 !! options
21927 parsoid={
21928 "nativeGallery": true
21929 }
21930 !! wikitext
21931 <gallery mode="slideshow" showthumbnails="">
21932 File:Foobar.jpg
21933 </gallery>
21934 !! html/php
21935 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1">
21936 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21937 <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>
21938 <div class="gallerytext">
21939 </div>
21940 </div></li>
21941 </ul>
21942
21943 !! html/parsoid
21944 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'>
21945 <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>
21946 </ul>
21947 !! end
21948
21949 !! test
21950 Serialize gallery image captions on a line
21951 !! options
21952 parsoid={
21953 "modes": ["html2wt"],
21954 "nativeGallery": true
21955 }
21956 !! html/parsoid
21957 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21958 <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>
21959 <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>
21960 </ul>
21961 !! wikitext
21962 <gallery>
21963 File:Foobar.jpg| hi ho
21964 File:Foobar.jpg|hi<br />ho
21965 </gallery>
21966 !! end
21967
21968 !! test
21969 HTML Hex character encoding (spells the word "JavaScript")
21970 !! options
21971 parsoid=wt2html,wt2wt,html2html
21972 !! wikitext
21973 &#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
21974 !! html/php
21975 <p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
21976 </p>
21977 !! html/parsoid
21978 <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>
21979 !! end
21980
21981 !! test
21982 HTML Hex character encoding bogus encoding (T28437 regression check)
21983 !! wikitext
21984 &#xsee;&#XSEE;
21985 !! html
21986 <p>&amp;#xsee;&amp;#XSEE;
21987 </p>
21988 !! end
21989
21990 !! test
21991 HTML Hex character encoding mixed case
21992 !! options
21993 parsoid=wt2html,wt2wt,html2html
21994 !! wikitext
21995 &#xEE;&#Xee;
21996 !! html/php
21997 <p>&#xee;&#xee;
21998 </p>
21999 !! html/parsoid
22000 <p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
22001 !! end
22002
22003 # See: https://www.w3.org/TR/html5/syntax.html#character-references
22004 # Note that U+000C (form feed) is not a valid XML character, so
22005 # it is banned even though allowed in HTML5.
22006 !! test
22007 Illegal character references (T106578)
22008 !! wikitext
22009 ; Null: &#00;
22010 ; FF: &#xC;
22011 ; CR: &#xD;
22012 ; Control (low): &#8;
22013 ; Control (high): &#x7F; &#x9F;
22014 ; Surrogate: &#xD83D;&#xDCA9;
22015 ; This is an okay astral character: &#x1F4A9;
22016 !! html+tidy
22017 <dl><dt>Null</dt>
22018 <dd>&amp;#00;</dd>
22019 <dt>FF</dt>
22020 <dd>&amp;#xC;</dd>
22021 <dt>CR</dt>
22022 <dd>&amp;#xD;</dd>
22023 <dt>Control (low)</dt>
22024 <dd>&amp;#8;</dd>
22025 <dt>Control (high)</dt>
22026 <dd>&amp;#x7F; &amp;#x9F;</dd>
22027 <dt>Surrogate</dt>
22028 <dd>&amp;#xD83D;&amp;#xDCA9;</dd>
22029 <dt>This is an okay astral character</dt>
22030 <dd>&#x1f4a9;</dd></dl>
22031 !! end
22032
22033 !! test
22034 __FORCETOC__ override
22035 !! wikitext
22036 __NEWSECTIONLINK__
22037 __FORCETOC__
22038 !! html/php
22039 <p><br />
22040 </p>
22041 !! end
22042
22043 !! test
22044 ISBN code coverage
22045 !! wikitext
22046 ISBN 978-0-1234-56&#x20;789
22047 !! html/php
22048 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a>&#x20;789
22049 </p>
22050 !! html/parsoid
22051 <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>
22052 !! end
22053
22054 !! test
22055 ISBN followed by 5 spaces
22056 !! wikitext
22057 ISBN
22058 !! html
22059 <p>ISBN
22060 </p>
22061 !! end
22062
22063 !! test
22064 Double ISBN
22065 !! wikitext
22066 ISBN ISBN 1234567890
22067 !! html/php
22068 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
22069 </p>
22070 !! html/parsoid
22071 <p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
22072 !! end
22073
22074 # Uppercase X and lowercase x as well
22075 !! test
22076 ISBN with an X
22077 !! wikitext
22078 ISBN 3-462-04561-X
22079 ISBN 3-462-04561-x
22080 ISBN 080442957X
22081 ISBN 080442957x
22082 ISBN 978080442957X
22083 ISBN 978080442957x
22084 !! html/php
22085 <p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a>
22086 <a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a>
22087 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a>
22088 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a>
22089 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a>
22090 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
22091 </p>
22092 !! html/parsoid
22093 <p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
22094 <a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
22095 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
22096 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
22097 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
22098 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
22099 !! end
22100
22101 !! test
22102 ISBN with empty prefix (parsoid test)
22103 !! wikitext
22104 ISBN 1234567890
22105 !! html/php
22106 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
22107 </p>
22108 !! html/parsoid
22109 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p>
22110 !! end
22111
22112 !! test
22113 T24905: <abbr> followed by ISBN followed by </a>
22114 !! wikitext
22115 <abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
22116 !! html/php
22117 <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>
22118 </p>
22119 !! html/parsoid
22120 <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>
22121 !! end
22122
22123 !! test
22124 Double RFC
22125 !! wikitext
22126 RFC RFC 1234
22127 !! html/php
22128 <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a>
22129 </p>
22130 !! html/parsoid
22131 <p>RFC <a href="https://tools.ietf.org/html/rfc1234" rel="mw:ExtLink" class="external mw-magiclink">RFC 1234</a></p>
22132 !! end
22133
22134 !! test
22135 Double RFC with a wiki link
22136 !! wikitext
22137 RFC [[RFC 1234]]
22138 !! html/php
22139 <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>
22140 </p>
22141 !! html/parsoid
22142 <p>RFC <a rel="mw:WikiLink" href="./RFC_1234" title="RFC 1234">RFC 1234</a></p>
22143 !! end
22144
22145 !! test
22146 RFC code coverage
22147 !! wikitext
22148 RFC 983&#x20;987
22149 !! html/php
22150 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
22151 </p>
22152 !! html/parsoid
22153 <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>
22154 !! end
22155
22156 !! test
22157 Centre-aligned image
22158 !! wikitext
22159 [[Image:foobar.jpg|centre]]
22160 !! html/php
22161 <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>
22162
22163 !! html/parsoid
22164 <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>
22165 !! end
22166
22167 !! test
22168 None-aligned image
22169 !! wikitext
22170 [[Image:foobar.jpg|none]]
22171 !! html/php
22172 <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>
22173
22174 !! html/parsoid
22175 <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>
22176 !! end
22177
22178 !! test
22179 Width + Height sized image (using px) (height is ignored)
22180 !! wikitext
22181 [[Image:foobar.jpg|640x480px]]
22182 !! html/php
22183 <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>
22184 </p>
22185 !! html/parsoid
22186 <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>
22187 !! end
22188
22189 !! test
22190 Width-sized image (using px, no following whitespace)
22191 !! wikitext
22192 [[Image:foobar.jpg|640px]]
22193 !! html/php
22194 <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>
22195 </p>
22196 !! html/parsoid
22197 <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>
22198 !! end
22199
22200 !! test
22201 Width-sized image (using px, with following whitespace - test regression from r39467)
22202 !! wikitext
22203 [[Image:foobar.jpg|640px ]]
22204 !! html/php
22205 <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>
22206 </p>
22207 !! html/parsoid
22208 <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>
22209 !!end
22210
22211 !! test
22212 Width-sized image (using px, with preceding whitespace - test regression from r39467)
22213 !! wikitext
22214 [[Image:foobar.jpg| 640px]]
22215 !! html/php
22216 <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>
22217 </p>
22218 !! html/parsoid
22219 <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>
22220 !! end
22221
22222 !! test
22223 Image with page parameter
22224 !! options
22225 djvu
22226 !! wikitext
22227 [[File:LoremIpsum.djvu|page=2]]
22228 !! html/php
22229 <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>
22230 </p>
22231 !! html/parsoid
22232 <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>
22233 !! end
22234
22235 !! test
22236 Another italics / bold test
22237 !! wikitext
22238 ''' ''x'
22239 !! html
22240 <pre>'<i> </i>x'
22241 </pre>
22242 !!end
22243
22244 # FIXME: The php output seems broken. It's interleaving some open/close tags.
22245 !! test
22246 dt/dd/dl test
22247 !! wikitext
22248 :;;;::
22249 !! html/php
22250 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dt></dl></dd></dl></dd></dl></dd></dl></dd></dl></dd></dl>
22251
22252 !! html/parsoid
22253 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dd></dl></dd></dl></dt></dl></dt></dl></dt></dl></dd></dl>
22254
22255 !!end
22256
22257 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
22258 !! test
22259 Images with the "|" character in the comment
22260 !! wikitext
22261 [[File:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
22262 !! html/php
22263 <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>
22264
22265 !! html/parsoid
22266 <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>
22267 !! end
22268
22269 !! test
22270 [Before] HTML without raw HTML enabled ($wgRawHtml==false)
22271 !! wikitext
22272 <html><script>alert(1);</script></html>
22273 !! html
22274 <p>&lt;html&gt;&lt;script&gt;alert(1);&lt;/script&gt;&lt;/html&gt;
22275 </p>
22276 !! end
22277
22278 !! test
22279 HTML with raw HTML ($wgRawHtml==true)
22280 !! options
22281 wgRawHtml=1
22282 !! wikitext
22283 <html><script>alert(1);</script></html>
22284 !! html/php
22285 <p><script>alert(1);</script>
22286 </p>
22287 !! html/parsoid
22288 <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>
22289 !! end
22290
22291 !! test
22292 Parents of subpages, one level up
22293 !! options
22294 subpage title=[[Subpage test/L1/L2/L3]]
22295 !! wikitext
22296 [[../|L2]]
22297 !! html
22298 <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>
22299 </p>
22300 !! end
22301
22302
22303 !! test
22304 Parents of subpages, one level up, not named
22305 !! options
22306 subpage title=[[Subpage test/L1/L2/L3]]
22307 !! wikitext
22308 [[../]]
22309 !! html
22310 <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>
22311 </p>
22312 !! end
22313
22314
22315
22316 !! test
22317 Parents of subpages, two levels up
22318 !! options
22319 subpage title=[[Subpage test/L1/L2/L3]]
22320 !! wikitext
22321 [[../../|L1]]2
22322
22323 [[../../|L1]]l
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)">L1</a>2
22326 </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>
22327 </p>
22328 !! end
22329
22330 !! test
22331 Parents of subpages, two levels up, without trailing slash or name.
22332 !! options
22333 subpage title=[[Subpage test/L1/L2/L3]]
22334 !! wikitext
22335 [[../..]]
22336 !! html
22337 <p>[[../..]]
22338 </p>
22339 !! end
22340
22341 !! test
22342 Parents of subpages, two levels up, with lots of extra trailing slashes.
22343 !! options
22344 subpage title=[[Subpage test/L1/L2/L3]]
22345 !! wikitext
22346 [[../../////]]
22347 !! html
22348 <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>
22349 </p>
22350 !! end
22351
22352 !! article
22353 Subpage test/L1/L2/L3Sibling
22354 !! text
22355 Sibling article
22356 !! endarticle
22357
22358 !! test
22359 Transclusion of a sibling page (one level up)
22360 !! options
22361 subpage title=[[Subpage test/L1/L2/L3]]
22362 !! wikitext
22363 {{../L3Sibling}}
22364 !! html
22365 <p>Sibling article
22366 </p>
22367 !! end
22368
22369 !! test
22370 Transclusion of a child page
22371 !! options
22372 subpage title=[[Subpage test/L1/L2]]
22373 !! wikitext
22374 {{/L3Sibling}}
22375 !! html
22376 <p>Sibling article
22377 </p>
22378 !! end
22379
22380 # This is wt2html only in Parsoid because we add <nowiki>
22381 # because of {{..}} and we don't expect to fix that to
22382 # eliminate the nowikis selective for {{..}} markup.
22383 !! test
22384 Non-transclusion because of too many up levels
22385 !! options
22386 subpage title=[[Subpage test/L1/L2/L3]]
22387 parsoid=wt2html
22388 !! wikitext
22389 {{../../../../More than parent}}
22390 !! html/php
22391 <p>{{../../../../More than parent}}
22392 </p>
22393 !! html/parsoid
22394 <p>{{../../../../More than parent}}</p>
22395 !! end
22396
22397 !! test
22398 Definition list code coverage
22399 !! wikitext
22400 ;title :def
22401 ;title :def
22402 ;title:def
22403 !! html/php
22404 <dl><dt>title</dt>
22405 <dd>def</dd>
22406 <dt>title</dt>
22407 <dd>def</dd>
22408 <dt>title</dt>
22409 <dd>def</dd></dl>
22410
22411 !! html/parsoid
22412 <dl><dt>title </dt><dd>def</dd>
22413 <dt>title </dt><dd>def</dd>
22414 <dt>title</dt><dd>def</dd></dl>
22415 !! end
22416
22417 !! test
22418 Don't fall for the self-closing div
22419 !! wikitext
22420 <div>hello world</div/>
22421 !! html
22422 <div>hello world</div>
22423
22424 !! end
22425
22426 !! test
22427 MSGNW magic word
22428 !! wikitext
22429 {{MSGNW:msg}}
22430 !! html/php
22431 <p>&#91;&#91;:Template:Msg&#93;&#93;
22432 </p>
22433 !! end
22434
22435 !! test
22436 RAW magic word
22437 !! wikitext
22438 {{RAW:QUERTY}}
22439 !! html
22440 <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>
22441 </p>
22442 !! end
22443
22444 # This isn't needed for XHTML conformance, but would be handy as a fallback security measure
22445 !! test
22446 Always escape literal '>' in output, not just after '<'
22447 !! wikitext
22448 ><>
22449 !! html
22450 <p>&gt;&lt;&gt;
22451 </p>
22452 !! end
22453
22454 !! test
22455 Template caching
22456 !! wikitext
22457 {{Test}}
22458 {{Test}}
22459 !! html
22460 <p>This is a test template
22461 This is a test template
22462 </p>
22463 !! end
22464
22465
22466 !! article
22467 MediaWiki:Fake
22468 !! text
22469 ==header==
22470 !! endarticle
22471
22472 !! test
22473 Inclusion of !userCanEdit() content
22474 !! wikitext
22475 {{MediaWiki:Fake}}
22476 !! html
22477 <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>
22478
22479 !! end
22480
22481
22482 !! test
22483 Out-of-order TOC heading levels
22484 !! wikitext
22485 ==2==
22486 ======6======
22487 ===3===
22488 =1=
22489 =====5=====
22490 ==2==
22491 !! html
22492 <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>
22493 <ul>
22494 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
22495 <ul>
22496 <li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
22497 <li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
22498 </ul>
22499 </li>
22500 <li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
22501 <ul>
22502 <li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
22503 <li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
22504 </ul>
22505 </li>
22506 </ul>
22507 </div>
22508
22509 <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>
22510 <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>
22511 <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>
22512 <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>
22513 <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>
22514 <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>
22515
22516 !! end
22517
22518
22519 !! test
22520 ISBN with a dummy number
22521 !! wikitext
22522 ISBN ---
22523 !! html
22524 <p>ISBN ---
22525 </p>
22526 !! end
22527
22528
22529 !! test
22530 ISBN with space-delimited number
22531 !! wikitext
22532 ISBN 92 9017 032 8
22533 !! html/php
22534 <p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a>
22535 </p>
22536 !! html/parsoid
22537 <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>
22538 !! end
22539
22540
22541 !! test
22542 ISBN with multiple spaces, no number
22543 !! wikitext
22544 ISBN foo
22545 !! html
22546 <p>ISBN foo
22547 </p>
22548 !! end
22549
22550
22551 !! test
22552 ISBN length
22553 !! wikitext
22554 ISBN 123456789
22555
22556 ISBN 1234567890
22557
22558 ISBN 12345678901
22559 !! html/php
22560 <p>ISBN 123456789
22561 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
22562 </p><p>ISBN 12345678901
22563 </p>
22564 !! html/parsoid
22565 <p>ISBN 123456789</p>
22566
22567 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
22568
22569 <p>ISBN 12345678901</p>
22570 !! end
22571
22572
22573 !! test
22574 ISBN with trailing year (T9110)
22575 !! wikitext
22576 ISBN 1-234-56789-0 - 2006
22577
22578 ISBN 1 234 56789 0 - 2006
22579 !! html/php
22580 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006
22581 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006
22582 </p>
22583 !! html/parsoid
22584 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p>
22585
22586 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p>
22587 !! end
22588
22589
22590 !! test
22591 anchorencode
22592 !! config
22593 wgFragmentMode=[ 'html5', 'legacy' ]
22594 !! wikitext
22595 {{anchorencode:foo bar©#%n}}
22596 !! html/php
22597 <p>foo_bar©#%n
22598 </p>
22599 !! html/parsoid
22600 <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>
22601 !! end
22602
22603 !! test
22604 anchorencode (legacy)
22605 !! config
22606 wgFragmentMode=[ 'legacy' ]
22607 !! wikitext
22608 {{anchorencode:foo bar©#%n}}
22609 !! html/php
22610 <p>foo_bar.C2.A9.23.25n
22611 </p>
22612 !! end
22613
22614 !! test
22615 anchorencode trims spaces
22616 !! config
22617 wgFragmentMode=[ 'html5', 'legacy' ]
22618 !! wikitext
22619 {{anchorencode: __pretty__please__}}
22620 !! html/php
22621 <p>pretty_please
22622 </p>
22623 !! html/parsoid
22624 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: __pretty__please__","function":"anchorencode"},"params":{},"i":0}}]}'>pretty_please</p>
22625 !! end
22626
22627 !! test
22628 anchorencode deals with links
22629 !! config
22630 wgFragmentMode=[ 'html5', 'legacy' ]
22631 !! wikitext
22632 {{anchorencode: [[hello|world]] [[hi]]}}
22633 !! html/php
22634 <p>world_hi
22635 </p>
22636 !! html/parsoid
22637 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: [[hello|world]] [[hi]]","function":"anchorencode"},"params":{},"i":0}}]}'>world_hi</p>
22638 !! end
22639
22640 !! test
22641 anchorencode deals with templates
22642 !! config
22643 wgFragmentMode=[ 'html5', 'legacy' ]
22644 !! wikitext
22645 {{anchorencode: {{Foo}} x}}
22646 !! html/php
22647 <p>FOO_x
22648 </p>
22649 !! html/parsoid
22650 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: {{Foo}} x","function":"anchorencode"},"params":{},"i":0}}]}'>FOO_x</p>
22651 !! end
22652
22653 !! test
22654 anchorencode encodes like the TOC generator: (T20431)
22655 !! config
22656 wgFragmentMode=[ 'html5', 'legacy' ]
22657 !! wikitext
22658 ===_ +:.3A%3A _ &&amp;]] x===
22659 {{anchorencode: _ +:.3A%3A _ &&amp;]] x}}
22660 __NOEDITSECTION__
22661 !! html/php
22662 <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>
22663 <p>+:.3A%3A_&amp;&amp;&#93;&#93;_x
22664 </p>
22665 !! html/parsoid
22666 <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>
22667 <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>
22668 <meta property="mw:PageProp/noeditsection"/>
22669 !! end
22670
22671 !! test
22672 anchorencode encodes like the TOC generator: (T20431) (legacy)
22673 !! config
22674 wgFragmentMode=[ 'legacy' ]
22675 !! wikitext
22676 ===_ +:.3A%3A&&amp;]]===
22677 {{anchorencode: _ +:.3A%3A&&amp;]] }}
22678 __NOEDITSECTION__
22679 !! html/php
22680 <h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&amp;&amp;]]</span></h3>
22681 <p>.2B:.3A.253A.26.26.5D.5D
22682 </p>
22683 !! end
22684
22685 !! test
22686 T8200: blockquotes and paragraph formatting
22687 !! wikitext
22688 <blockquote>
22689 foo
22690 </blockquote>
22691
22692 bar
22693
22694 baz
22695 !! html
22696 <blockquote>
22697 <p>foo
22698 </p>
22699 </blockquote>
22700 <p>bar
22701 </p>
22702 <pre>baz
22703 </pre>
22704 !! end
22705
22706 !! test
22707 T10293: Use of center tag ruins paragraph formatting
22708 !! wikitext
22709 <center>
22710 foo
22711 </center>
22712
22713 bar
22714
22715 baz
22716 !! html
22717 <center>
22718 <p>foo
22719 </p>
22720 </center>
22721 <p>bar
22722 </p>
22723 <pre>baz
22724 </pre>
22725 !! end
22726
22727 !!test
22728 Parsing of overlapping (improperly nested) inline html tags
22729 !! wikitext
22730 <span><s>x</span></s>
22731 !! html/php
22732 <p><span><s>x&lt;/span&gt;</s></span>
22733 </p>
22734 !! html/parsoid
22735 <p><span><s>x</s></span>
22736 </p>
22737 !!end
22738
22739 ###
22740 ### Language variants related tests
22741 ###
22742
22743 # Parsoid does not mark self-links.
22744 # Parsoid does not convert links; PHP will do any necessary redirects.
22745
22746 !! test
22747 Self-link in language variants
22748 !! options
22749 title=[[Dunav]] language=sr
22750 !! wikitext
22751 Both [[Dunav]] and [[Дунав]] are names for this river.
22752 !! html/php
22753 <p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
22754 </p>
22755 !! html/parsoid
22756 <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>
22757 !! end
22758
22759 !! article
22760 Дуна
22761 !! text
22762 content
22763 !! endarticle
22764
22765 !! test
22766 Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
22767 !! options
22768 title=[[Duna]] language=sr
22769 !! wikitext
22770 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
22771 !! html/php
22772 <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.
22773 </p>
22774 !! html/parsoid
22775 <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>
22776 !! end
22777
22778 !! test
22779 Link to a section of a variant of this title shouldn't be parsed as self-link
22780 !! options
22781 title=[[Duna]] language=sr
22782 !! wikitext
22783 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
22784 !! html/php
22785 <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.
22786 </p>
22787 !! html/parsoid
22788 <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>
22789 !! end
22790
22791 !! test
22792 Link to pages in language variants
22793 !! options
22794 language=sr
22795 !! wikitext
22796 Main Page can be written as [[Маин Паге]]
22797 !! html/php
22798 <p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>
22799 </p>
22800 !! html/parsoid
22801 <p>Main Page can be written as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a></p>
22802 !! end
22803
22804
22805 !! test
22806 Multiple links to pages in language variants
22807 !! options
22808 language=sr
22809 !! wikitext
22810 [[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
22811 !! html/php
22812 <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>.
22813 </p>
22814 !! html/parsoid
22815 <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>
22816 !! end
22817
22818
22819 !! test
22820 Simple template in language variants
22821 !! options
22822 language=sr
22823 !! wikitext
22824 {{тест}}
22825 !! html/php
22826 <p>This is a test template
22827 </p>
22828 !! end
22829
22830
22831 !! test
22832 Template with explicit namespace in language variants
22833 !! options
22834 language=sr
22835 !! wikitext
22836 {{Template:тест}}
22837 !! html/php
22838 <p>This is a test template
22839 </p>
22840 !! end
22841
22842
22843 !! test
22844 Basic test for template parameter in language variants
22845 !! options
22846 language=sr
22847 !! wikitext
22848 {{парамтест|param=foo}}
22849 !! html/php
22850 <p>This is a test template with parameter foo
22851 </p>
22852 !! end
22853
22854 !! test
22855 Simple category in language variants
22856 !! options
22857 language=sr cat
22858 !! wikitext
22859 [[Category:МедиаWики Усер'с Гуиде]]
22860 !! html/php
22861 cat=МедиаWики_Усер'с_Гуиде sort=
22862 !! html/parsoid
22863 <link rel="mw:PageProp/Category" href="./Категорија:МедиаWики_Усер'с_Гуиде" data-parsoid='{"stx":"simple","a":{"href":"./Категорија:МедиаWики_Усер&#39;с_Гуиде"},"sa":{"href":"Category:МедиаWики Усер&#39;с Гуиде"}}'/>
22864 !! end
22865
22866 !! article
22867 Category:分类
22868 !! text
22869 blah
22870 !! endarticle
22871
22872 !! article
22873 Category:分類
22874 !! text
22875 blah
22876 !! endarticle
22877
22878 ## We used to, but no longer wt2wt this test since the default serializer
22879 ## will normalize all categories to serialize on their own line.
22880 ## This wikitext usage is going to be fairly uncommon in production and
22881 ## selser will take care of preserving formatting in those scenarios.
22882 !! test
22883 Don't convert blue categorylinks to another variant (T35210)
22884 !! options
22885 cat
22886 language=zh
22887 parsoid=wt2html
22888 !! wikitext
22889 [[A]][[Category:分类]]
22890 !! html/php
22891 cat=分类 sort=
22892 !! html/parsoid
22893 <p><a rel="mw:WikiLink" href="./A" title="A">A</a></p>
22894 <link rel="mw:PageProp/Category" href="./Category:分类"/>
22895 !! end
22896
22897 !! test
22898 Stripping -{}- tags (language variants)
22899 !! options
22900 language=sr
22901 !! wikitext
22902 Latin proverb: -{Ne nuntium necare}-
22903 !! html/php
22904 <p>Latin proverb: Ne nuntium necare
22905 </p>
22906 !! html/parsoid
22907 <p>Latin proverb: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22908 !! end
22909
22910
22911 !! test
22912 Prevent conversion with -{}- tags (language variants)
22913 !! options
22914 language=sr variant=sr-ec
22915 !! wikitext
22916 Latinski: -{Ne nuntium necare}-
22917 !! html/php
22918 <p>Латински: Ne nuntium necare
22919 </p>
22920 !! html/parsoid
22921 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22922 !! end
22923
22924
22925 !! test
22926 Prevent conversion of text with -{}- tags (language variants)
22927 !! options
22928 language=sr variant=sr-ec
22929 !! wikitext
22930 Latinski: -{Ne nuntium necare}-
22931 !! html/php
22932 <p>Латински: Ne nuntium necare
22933 </p>
22934 !! html/parsoid
22935 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22936 !! end
22937
22938
22939 !! test
22940 Prevent conversion of links with -{}- tags (language variants)
22941 !! options
22942 language=sr variant=sr-ec
22943 !! wikitext
22944 -{[[Main Page]]}-
22945 !! html/php
22946 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
22947 </p>
22948 !! html/parsoid
22949 <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>
22950 !! end
22951
22952
22953 !! test
22954 -{}- tags within headlines (within html for parserConvert())
22955 !! config
22956 wgFragmentMode=[ 'html5', 'legacy' ]
22957 !! options
22958 language=sr variant=sr-ec
22959 !! wikitext
22960 ==-{Naslov}-==
22961
22962 Note that even an unprotected headline ID is not affected by language
22963 conversion:
22964
22965 ==Latinski==
22966 !! html/php
22967 <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>
22968 <p>Ноте тхат евен ан унпротецтед хеадлине ИД ис нот аффецтед бy лангуаге
22969 цонверсион:
22970 </p>
22971 <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>
22972
22973 !! html/parsoid
22974 <h2 id="-{Naslov}-"><span id="-.7BNaslov.7D-" typeof="mw:FallbackId"></span><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Naslov"}}'></span></h2>
22975
22976 <p>Note that even an unprotected headline ID is not affected by language
22977 conversion:</p>
22978
22979 <h2 id="Latinski">Latinski</h2>
22980 !! end
22981
22982 !! test
22983 Explicit definition of language variant alternatives
22984 !! options
22985 language=zh variant=zh-tw
22986 !! wikitext
22987 -{zh:China;zh-tw:Taiwan}-, not China
22988 !! html/php
22989 <p>Taiwan, not China
22990 </p>
22991 !! html/parsoid
22992 <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>
22993 !! end
22994
22995 !! test
22996 Filter syntax for language variants
22997 !! options
22998 language=zh variant=zh-tw
22999 !! wikitext
23000 foo-{zh;zh-hans;zh-hant|blog, WEBJOURNAL, WEBLOG}-quux
23001 !! html/php
23002 <p>fooblog, WEBJOURNAL, WEBLOGquux
23003 </p>
23004 !! html/parsoid
23005 <p>foo<span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"blog, WEBJOURNAL, WEBLOG"}}'></span>quux</p>
23006 !! end
23007
23008 # Note that Parsoid post-processing for language variants needs to
23009 # update the `title` attribute here, based on the mw:ExpandedAttrs property
23010 !! test
23011 Conversion around HTML tags
23012 !! options
23013 language=sr variant=sr-ec
23014 !! wikitext
23015 -{H|span=>sr-ec:script;title=>sr-ec:src}-
23016 <span title="La-{sr-el:L;sr-ec:C}-tin">ski</span>
23017 !! html/php
23018 <p>
23019 <span title="ЛаCтин">ски</span>
23020 </p>
23021 !! html/parsoid
23022 <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"}]}'/>
23023 <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>
23024 !! end
23025
23026 !! test
23027 Explicit session-wise two-way language variant mapping (A flag and - flag)
23028 !! options
23029 language=zh variant=zh-tw
23030 !! wikitext
23031 This is -{zh:China; zh-tw:Taiwan}-, but we'll forget that now.
23032
23033 Taiwan is not China.
23034
23035 But -{A|zh:China; zh-tw:Taiwan}- is China,
23036
23037 (This-{-|zh:China; zh-tw:Taiwan}- should be stripped!)
23038
23039 and -{China}- is China.
23040 !! html/php
23041 <p>This is Taiwan, but we'll forget that now.
23042 </p><p>Taiwan is not China.
23043 </p><p>But Taiwan is Taiwan,
23044 </p><p>(This should be stripped!)
23045 </p><p>and China is China.
23046 </p>
23047 !! html/parsoid
23048 <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>
23049 <p>Taiwan is not China.</p>
23050 <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>
23051 <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>
23052 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"China"}}'></span> is China.</p>
23053 !! end
23054
23055 !! test
23056 Explicit session-wise one-way language variant mapping (A flag and - flag)
23057 !! options
23058 language=zh variant=zh-tw
23059 !! wikitext
23060 This is -{COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}-, but we'll forget that now.
23061
23062 COUNTRY is China or Taiwan.
23063
23064 But -{A|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- is COUNTRY,
23065
23066 (This-{-|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
23067
23068 and -{COUNTRY}- is COUNTRY.
23069 !! html/php
23070 <p>This is Taiwan, but we'll forget that now.
23071 </p><p>COUNTRY is China or Taiwan.
23072 </p><p>But Taiwan is Taiwan,
23073 </p><p>(This should be stripped!)
23074 </p><p>and COUNTRY is COUNTRY.
23075 </p>
23076 !! html/parsoid
23077 <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>
23078 <p>COUNTRY is China or Taiwan.</p>
23079 <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>
23080 <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>
23081 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"COUNTRY"}}'></span> is COUNTRY.</p>
23082 !! end
23083
23084 !! test
23085 Explicit session-wise two-way language variant mapping (H flag for hide)
23086 !! options
23087 language=zh variant=zh-tw
23088 !! wikitext
23089 (This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
23090
23091 Taiwan is China.
23092 !! html/php
23093 <p>(This should be stripped!)
23094 </p><p>Taiwan is Taiwan.
23095 </p>
23096 !! html/parsoid
23097 <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>
23098 <p>Taiwan is China.</p>
23099 !! end
23100
23101 !! test
23102 Explicit session-wise one-way language variant mapping (H flag for hide)
23103 !! options
23104 language=zh variant=zh-tw
23105 !! wikitext
23106 (This-{H|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
23107
23108 COUNTRY is Taiwan or China.
23109 !! html/php
23110 <p>(This should be stripped!)
23111 </p><p>Taiwan is Taiwan or China.
23112 </p>
23113 !! html/parsoid
23114 <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>
23115 <p>COUNTRY is Taiwan or China.</p>
23116 !! end
23117
23118 ## Note that parsoid test runner does not support 'showtitle' option.
23119 !! test
23120 Adding explicit conversion rule for title (T flag)
23121 !! options
23122 language=zh variant=zh-tw showtitle
23123 !! wikitext
23124 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
23125
23126 Taiwan is China.
23127 !! html/php
23128 Taiwan
23129 <p>Should be stripped!
23130 </p><p>Taiwan is China.
23131 </p>
23132 !! html/parsoid
23133 <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>
23134 <p>Taiwan is China.</p>
23135 !! end
23136
23137 !! test
23138 Code coverage: T combined with H flag
23139 !! options
23140 language=zh variant=zh-tw showtitle
23141 !! wikitext
23142 Should be stripped-{T;H|zh:China; zh-tw:Taiwan}-!
23143
23144 Taiwan is China.
23145 !! html/php
23146 Taiwan
23147 <p>Should be stripped!
23148 </p><p>Taiwan is Taiwan.
23149 </p>
23150 !! html/parsoid
23151 <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>
23152 <p>Taiwan is China.</p>
23153 !! end
23154
23155 !! test
23156 Code coverage: T with no variants
23157 !! options
23158 language=zh variant=zh-tw showtitle
23159 !! wikitext
23160 -{H|zh:China; zh-tw:Taiwan}-
23161 Taiwan is China.-{T|Taiwan is China}-
23162 !! html/php
23163 Taiwan is China
23164 <p>
23165 Taiwan is Taiwan.
23166 </p>
23167 !! html/parsoid
23168 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
23169 Taiwan is China.<meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Taiwan is China"},"title":true}'/></p>
23170 !! end
23171
23172 !! test
23173 Code coverage: rules with no variants
23174 !! options
23175 language=zh variant=zh-tw
23176 !! wikitext
23177 -{H|zh:China; zh-tw:Taiwan}-
23178 Taiwan is China.
23179 -{H|China}-
23180 Taiwan is China.
23181 !! html/php
23182 <p>
23183 Taiwan is Taiwan.
23184
23185 Taiwan is China.
23186 </p>
23187 !! html/parsoid
23188 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
23189 Taiwan is China.
23190 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":"China"}]}'/>
23191 Taiwan is China.</p>
23192 !! end
23193
23194
23195 !! test
23196 Code coverage: D flag for conversion rule
23197 !! options
23198 language=zh variant=zh-tw
23199 !! wikitext
23200 -{D|zh-cn:XA; zh-tw:YA}-
23201 -{A;D|zh-cn:XB; zh-tw:YB}-
23202 -{D;H|zh-cn:XC; zh-tw:YC}-
23203
23204 -{D;H|FOO=>zh-tw:BAR;FOO=>zh-cn:BAT}-
23205
23206 -{D|0=>zh-tw:1}-
23207 -{A;D|2=>zh-tw:3}-
23208 -{D;H|4=>zh-tw:5}-
23209
23210 XA XB XC YA YB YC FOO BAR BAT 012345
23211 !! html/php
23212 <p>大陆:XA;台灣:YA;
23213
23214 大陆:XC;台灣:YC;
23215 </p><p>FOO⇒台灣:BAR;FOO⇒大陆:BAT;
23216 </p><p>0⇒台灣:1;
23217
23218 4⇒台灣:5;
23219 </p><p>XA YB YC YA YB YC BAR BAR BAT 013355
23220 </p>
23221 !! html/parsoid
23222 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"twoway":[{"l":"zh-cn","t":"XA"},{"l":"zh-tw","t":"YA"}]}'></span>
23223 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XB"},{"l":"zh-tw","t":"YB"}]}'/>
23224 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XC"},{"l":"zh-tw","t":"YC"}]}'></span></p>
23225 <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>
23226 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"oneway":[{"f":"0","l":"zh-tw","t":"1"}]}'></span>
23227 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"2","l":"zh-tw","t":"3"}]}'/>
23228 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"4","l":"zh-tw","t":"5"}]}'></span></p>
23229 <p>XA XB XC YA YB YC FOO BAR BAT 012345</p>
23230 !! end
23231
23232 !! test
23233 Code coverage: N flag for conversion rule
23234 !! options
23235 language=zh variant=zh-cn
23236 !! wikitext
23237 -{N|zh-cn}-
23238
23239 -{N|zh-tw}-
23240
23241 -{N|sr-ec}-
23242 !! html/php
23243 <p>大陆
23244 </p><p>台灣
23245 </p><p>српски (ћирилица)‎
23246 </p>
23247 !! html/parsoid
23248 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-cn"}}'></span></p>
23249 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-tw"}}'></span></p>
23250 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"sr-ec"}}'></span></p>
23251 !! end
23252
23253 # html2wt suppresses the bogus 'D' flag, so this is wt2html only
23254 !! test
23255 Code coverage: N flag for conversion rule (wt2html only)
23256 !! options
23257 language=zh variant=zh-cn
23258 parsoid=wt2html,html2html
23259 !! wikitext
23260 -{D;N|en}-
23261 !! html/php
23262 <p>English
23263 </p>
23264 !! html/parsoid
23265 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"en"}}' data-parsoid='{"fl":["D","N"]}'></span></p>
23266 !! end
23267
23268 !! test
23269 Testing that changing the language variant here in the tests actually works
23270 !! options
23271 language=zh variant=zh showtitle
23272 !! wikitext
23273 Should be stripped-{T|zh:China; zh-tw:Taiwan}-!
23274 !! html/php
23275 China
23276 <p>Should be stripped!
23277 </p>
23278 !! html/parsoid
23279 <p>Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
23280 !! end
23281
23282 !! test
23283 Recursive conversion of alt and title attrs shouldn't clear converter state
23284 !! options
23285 language=zh variant=zh-cn
23286 showtitle
23287 !! wikitext
23288 -{H|zh-cn:Exclamation; zh-tw:exclamation}-
23289 Should be stripped-{T|zh-cn:China; zh-tw:Taiwan}-<span title="exclamation">!</span>
23290 !! html/php
23291 China
23292 <p>
23293 Should be stripped<span title="Exclamation">!</span>
23294 </p>
23295 !! html/parsoid
23296 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh-cn","t":"Exclamation"},{"l":"zh-tw","t":"exclamation"}]}'/>
23297 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>
23298 !! end
23299
23300 !! test
23301 T26072: more test on conversion rule for title
23302 !! options
23303 language=zh variant=zh-tw showtitle
23304 !! wikitext
23305 This should be stripped-{T|zh:China; zh-tw:Taiwan}-!
23306
23307 This won't take interferes with the title rule-{H|zh:Beijing; zh-tw:Taipei}-.
23308 !! html/php
23309 Taiwan
23310 <p>This should be stripped!
23311 </p><p>This won't take interferes with the title rule.
23312 </p>
23313 !! html/parsoid
23314 <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>
23315 <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>
23316 !! end
23317
23318 !! test
23319 Partly disable title conversion if variant == main language code
23320 !! options
23321 language=zh variant=zh title=[[ZH]] showtitle
23322 !! wikitext
23323 -{T|zh-cn:CN;zh-tw:TW}-
23324 !! html/php
23325 ZH
23326 <p>
23327 </p>
23328 !! html/parsoid
23329 <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>
23330 !! end
23331
23332 !! test
23333 Partly disable title conversion if variant == main language code, more
23334 !! options
23335 language=zh variant=zh title=[[ZH]] showtitle
23336 !! wikitext
23337 -{T|TW}-
23338 !! html/php
23339 ZH
23340 <p>
23341 </p>
23342 !! html/parsoid
23343 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"TW"},"title":true}'/></p>
23344 !! end
23345
23346 !! test
23347 Raw output of variant escape tags (R flag)
23348 !! options
23349 language=zh variant=zh-tw
23350 !! wikitext
23351 Raw: -{R|zh:China;zh-tw:Taiwan}-
23352 !! html/php
23353 <p>Raw: zh:China;zh-tw:Taiwan
23354 </p>
23355 !! html/parsoid
23356 <p>Raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"zh:China;zh-tw:Taiwan"}}'></span></p>
23357 !! end
23358
23359 # html2wt suppresses the bogus 'D' flags, so this is wt2html only
23360 !! test
23361 Raw output of variant escape tags (R flag) (wt2html only)
23362 !! options
23363 language=zh variant=zh-tw
23364 parsoid=wt2html,html2html
23365 !! wikitext
23366 -{Variant}- -{D|syntax}- -{D;R|options}-
23367 !! html/php
23368 <p>Variant syntax options
23369 </p>
23370 !! html/parsoid
23371 <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>
23372 !! end
23373
23374 !! test
23375 Nested markup inside raw output of variant escape tags (R flag)
23376 !! options
23377 language=zh variant=zh-tw
23378 !! wikitext
23379 Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
23380 !! html/php
23381 <p>Nested raw: nested Taiwan nested
23382 </p>
23383 !! html/parsoid
23384 <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>
23385 !! end
23386
23387 !! test
23388 Nested markup and spaces inside raw output of variant escape tags (R flag)
23389 !! options
23390 language=zh variant=zh-tw
23391 !! wikitext
23392 X-{ outer -{ inner }- outer }-X
23393 !! html/php
23394 <p>X outer inner outer X
23395 </p>
23396 !! html/parsoid
23397 <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>
23398 !! end
23399
23400 !! test
23401 Templates inside raw output of variant escape tags (R flag)
23402 !! options
23403 language=zh variant=zh-tw
23404 !! wikitext
23405 Nested raw: -{R|nested {{echo|hi}} templates}-
23406 !! html/php
23407 <p>Nested raw: nested hi templates
23408 </p>
23409 !! html/parsoid
23410 <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>
23411 !! end
23412
23413 !! test
23414 Strings evaluating false shouldn't be ignored by Language converter (T51072)
23415 !! options
23416 language=zh variant=zh-cn
23417 !! wikitext
23418 -{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
23419 !! html/php
23420 <p>0
23421 </p>
23422 !! html/parsoid
23423 <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>
23424 !! end
23425
23426 !! test
23427 Conversion rules from [numeric-only string] to [something else] (T48634)
23428 !! options
23429 language=zh variant=zh-cn
23430 !! wikitext
23431 -{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
23432 !! html/php
23433 <p>D12345EE12345
23434 </p>
23435 !! html/parsoid
23436 <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>
23437 !! end
23438
23439 !! test
23440 Two-way converter rule entries with an empty value should be ignored (T53551)
23441 !! options
23442 language=zh variant=zh-cn
23443 !! wikitext
23444 -{H|zh-cn:foo;zh-tw:;}-foobar
23445 !! html/php
23446 <p>foobar
23447 </p>
23448 !! html/parsoid
23449 <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>
23450 !! end
23451
23452 !! test
23453 One-way converter rule entries with an empty "from" string should be ignored (T53551)
23454 !! options
23455 language=zh variant=zh-cn
23456 !! wikitext
23457 -{H|=>zh-cn:foo;}-foobar
23458 !! html/php
23459 <p>foobar
23460 </p>
23461 !! html/parsoid
23462 <p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[5]}' data-mw-variant='{"add":true,"oneway":[{"f":"","l":"zh-cn","t":"foo"}]}'/>foobar</p>
23463 !! end
23464
23465 !! test
23466 Empty converter rule entries shouldn't be inserted into the conversion table (T53551)
23467 !! options
23468 language=zh variant=zh-cn
23469 !! wikitext
23470 -{H|}-foobar
23471 !! html/php
23472 <p>foobar
23473 </p>
23474 !! html/parsoid
23475 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":""}]}'/>foobar</p>
23476 !! end
23477
23478 !! test
23479 Nested using of manual convert syntax
23480 !! options
23481 language=zh variant=zh-hk
23482 !! wikitext
23483 Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
23484 !! html/php
23485 <p>Nested: Hello Hong Kong!
23486 </p>
23487 !! html/parsoid
23488 <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>
23489 !! end
23490
23491 !! test
23492 HTML markups with conversion syntax in attribs, nested in other conversion blocks
23493 !! options
23494 language=zh variant=zh-cn
23495 !! wikitext
23496 -{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}-
23497 !! html/php
23498 <p><span title="X">A</span>
23499 </p>
23500 !! html/parsoid
23501 <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>
23502 !! end
23503
23504 !! test
23505 HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet in PHP parser)
23506 !! options
23507 language=zh variant=zh-cn
23508 !! wikitext
23509 -{<span title="-{X}-">A</span>}-
23510 !! html/php+disabled
23511 <p><span title="X">A</span>
23512 </p>
23513 !! html/parsoid
23514 <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>
23515 !! end
23516
23517 # Parsoid and PHP disagree on how to parse this example: Parsoid
23518 # insists that the content of a language converter element be a valid
23519 # DOM fragment or attribute string
23520 !! test
23521 Language converter markup with block content
23522 !! options
23523 language=zh variant=zh-cn
23524 !! wikitext
23525 <span>a-{b<div>c}-d
23526
23527 <span>a-{zh;zh-hans;zh-hant|b<div>c}-d
23528
23529 <span>a-{H|0=>zh-cn:x<span>y;0=>zh-tw:b<div>c}-d
23530 !! html/php+tidy
23531 <span>ab<div>cd
23532 <span>ab<div>cd
23533 <span>ad
23534 </span></div></span></div></span>
23535 !! html/parsoid
23536 <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
23537
23538 <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
23539
23540 <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>
23541 !! end
23542
23543 !! test
23544 LanguageConverter selser (1)
23545 !! options
23546 language=zh variant=zh-cn
23547 parsoid={
23548 "modes": ["wt2wt", "selser"],
23549 "changes": [
23550 ["span[typeof]", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
23551 ]
23552 }
23553 !! wikitext
23554 -{raw}-
23555 !! wikitext/edited
23556 -{edited}-
23557 !! end
23558
23559 !! test
23560 LanguageConverter selser (2)
23561 !! options
23562 language=zh variant=zh-cn
23563 parsoid={
23564 "modes": ["wt2wt", "selser"],
23565 "changes": [
23566 ["span[class='x']", "contents", "text", "-{foo}-"],
23567 ["a", "contents", "text", "-{"],
23568 ["span[typeof]", "attr", "data-mw", "{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"-{\"}},\"i\":0}}]}"]
23569 ]
23570 }
23571 !! wikitext
23572 <span class="x">TEXT1</span>
23573 [http://example.com TEXT2]
23574 [[Foo|TEXT3]]
23575 {{echo|TEXT4}}
23576 !! wikitext/edited
23577 <span class="x"><nowiki>-{foo}-</nowiki></span>
23578 [http://example.com -{]
23579 [[Foo|<nowiki>-{</nowiki>]]
23580 {{1x|<nowiki>-{</nowiki>}}
23581 !! end
23582
23583 # Tests LanguageVariantText in ConstrainedText
23584 !! test
23585 LanguageConverter selser (3)
23586 !! options
23587 language=zh variant=zh-cn
23588 parsoid={
23589 "modes": ["wt2wt", "selser"],
23590 "changes": [
23591 ["td > span", "attr", "typeof", "mw:LanguageVariant"],
23592 ["td > span", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
23593 ]
23594 }
23595 !! wikitext
23596 {|
23597 |-
23598 |<span>Foo</span>
23599 |}
23600 !! wikitext/edited
23601 {|
23602 |-
23603 |<nowiki/>-{edited}-
23604 |}
23605 !! end
23606
23607 # Tests LanguageVariantText._fromSelSer
23608 !! test
23609 LanguageConverter selser (4)
23610 !! options
23611 language=zh variant=zh-cn
23612 parsoid={
23613 "modes": ["wt2wt", "selser"],
23614 "changes": [
23615 ["td > span.x", "remove"]
23616 ]
23617 }
23618 !! wikitext
23619 {|
23620 |-
23621 |<span class="x">Foo</span>-{Bar}-
23622 ||<span class="x">Foo</span>-{Bar}-
23623 |}
23624 !! wikitext/edited
23625 {|
23626 |-
23627 |<nowiki/>-{Bar}-
23628 ||-{Bar}-
23629 |}
23630 !! end
23631
23632 # Since Parsoid is starting to emit canonical wikitext for links,
23633 # [http://example.com http://example.com] will not RT back to that
23634 # form anymore.
23635 # Parsoid does not language-convert links (it is done in a
23636 # post-processing step)
23637 !! test
23638 Proper conversion of text in external links
23639 !! options
23640 language=sr variant=sr-ec
23641 parsoid=wt2html
23642 !! wikitext
23643 http://www.google.com
23644 gopher://www.google.com
23645 [http://www.google.com http://www.google.com]
23646 [gopher://www.google.com gopher://www.google.com]
23647 [https://www.google.com irc://www.google.com]
23648 [ftp://www.google.com www.google.com/ftp://dir]
23649 [//www.google.com www.google.com]
23650 !! html/php
23651 <p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
23652 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
23653 <a rel="nofollow" class="external text" href="http://www.google.com">http://www.google.com</a>
23654 <a rel="nofollow" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
23655 <a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
23656 <a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
23657 <a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
23658 </p>
23659 !! html/parsoid
23660 <p><a rel="mw:ExtLink" class="external free" href="http://www.google.com">http://www.google.com</a>
23661 <a rel="mw:ExtLink" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
23662 <a rel="mw:ExtLink" class="external text" href="http://www.google.com">http://www.google.com</a>
23663 <a rel="mw:ExtLink" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
23664 <a rel="mw:ExtLink" class="external text" href="https://www.google.com">irc://www.google.com</a>
23665 <a rel="mw:ExtLink" class="external text" href="ftp://www.google.com">www.google.com/ftp://dir</a>
23666 <a rel="mw:ExtLink" class="external text" href="//www.google.com">www.google.com</a></p>
23667 !! end
23668
23669 !! test
23670 Do not convert roman numbers to language variants
23671 !! options
23672 language=sr variant=sr-ec
23673 !! wikitext
23674 Fridrih IV je car.
23675 !! html/php
23676 <p>Фридрих IV је цар.
23677 </p>
23678 !! html/parsoid
23679 <p>Fridrih IV je car.</p>
23680 !! end
23681
23682 !! test
23683 Unclosed language converter markup "-{"
23684 !! options
23685 language=sr
23686 !! wikitext
23687 -{T|hello
23688 !! html
23689 <p>-{T|hello
23690 </p>
23691 !! end
23692
23693 !! test
23694 Don't convert raw rule "-{R|=&gt;}-" to "=>"
23695 !! options
23696 language=sr
23697 !! wikitext
23698 -{R|=&gt;}-
23699 !! html/php
23700 <p>=&gt;
23701 </p>
23702 !! html/parsoid
23703 <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>
23704 !!end
23705
23706 !! test
23707 Don't break link parsing if language converter markup is in the caption.
23708 !! options
23709 language=sr variant=sr-ec
23710 !! wikitext
23711 [[Main Page|-{R|main page}-]]
23712 !! html/php
23713 <p><a href="/wiki/Main_Page" title="Маин Паге">main page</a>
23714 </p>
23715 !! html/parsoid
23716 <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>
23717 !! end
23718
23719 !! test
23720 T146304: Don't break template parsing if language converter markup is in the parameter.
23721 !! options
23722 language=sr variant=sr-ec
23723 !! wikitext
23724 {{echo|-{R|foo}-}}
23725 !! html/php
23726 <p>foo
23727 </p>
23728 !! html/parsoid
23729 <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>
23730 !! end
23731
23732 !! test
23733 T146305: Don't break image parsing if language converter markup is in the caption.
23734 !! options
23735 language=sr
23736 !! wikitext
23737 [[Датотека:Foobar.jpg|thumb|-{R|caption:}-]]
23738 !! html/php
23739 <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>
23740
23741 !! html/parsoid
23742 <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>
23743 !! end
23744
23745 !! test
23746 T146305: Don't break image parsing if nested language converter markup is in the caption.
23747 !! options
23748 language=zh variant=zh-cn
23749 !! wikitext
23750 [[File:Foobar.jpg|thumb|-{|zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
23751 !! html/php
23752 <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>
23753
23754 !! html/parsoid
23755 <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>
23756 !! end
23757
23758 # XXX html2wt disabled because rich markup in alt is not preserved.
23759 !! test
23760 Don't break gallery if language converter markup is inside.
23761 !! options
23762 language=zh
23763 !! wikitext
23764 <gallery>
23765 File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-
23766 File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt
23767 </gallery>
23768 !! html/php
23769 <ul class="gallery mw-gallery-traditional">
23770 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
23771 <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>
23772 <div class="gallerytext">
23773 <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>
23774 </p>
23775 </div>
23776 </div></li>
23777 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
23778 <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>
23779 <div class="gallerytext">
23780 <p>This is a test template
23781 </p>
23782 </div>
23783 </div></li>
23784 </ul>
23785
23786 !! html/parsoid
23787 <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"}}'>
23788 <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>
23789 <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>
23790 </ul>
23791 !! end
23792
23793 !! test
23794 T153135: Don't break list handling if language converter markup is in the item.
23795 !! options
23796 language=zh variant=zh-cn
23797 !! wikitext
23798 ;-{zh-cn:AAA;zh-tw:BBB}-
23799 ;-{R|foo:bar}-
23800 !! html/php
23801 <dl><dt>AAA</dt>
23802 <dt>foo:bar</dt></dl>
23803
23804 !! html/parsoid
23805 <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>
23806 <dt data-parsoid='{"dsr":[25,39,1,0]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"foo:bar"}}'></span></dt>
23807 </dl>
23808 !! end
23809
23810 // Note that parsoid does not protect colons unless language converter
23811 // markup is properly nested, because it is a backtracking parser.
23812 !! test
23813 T153135: Unclosed markup in definition list (code coverage)
23814 !! options
23815 language=zh variant=zh-cn
23816 !! wikitext
23817 ;<b>foo:bar
23818 ;-{zh-cn:AAA
23819 !! html/php+tidy
23820 <dl><dt><b>foo:bar</b></dt><b>
23821 <dt>-{zh-cn:AAA</dt></b></dl><p><b>
23822 </b></p>
23823 !! html/parsoid
23824 <dl><dt data-parsoid='{}'><b data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo:bar</b></dt><b data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
23825 <dt data-parsoid='{}'>-{zh-cn</dt><dd data-parsoid='{"stx":"row"}'>AAA</dd></b></dl>
23826 !! end
23827
23828 !! test
23829 T153135: Nested language converter markup in definition list (code coverage)
23830 !! options
23831 language=zh variant=zh-cn
23832 !! wikitext
23833 ;-{|zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
23834 !! html/php
23835 <dl><dt>AAA foo:bar bat:baz</dt>
23836 <dd>def</dd></dl>
23837
23838 !! html/parsoid
23839 <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>
23840 <dd data-parsoid='{"stx":"row","dsr":[49,53,1,0]}'>def</dd>
23841 </dl>
23842 !! end
23843
23844 # html2wt mode disabled due to <nowiki> insertion.
23845 !! test
23846 T153140: Don't break table handling if language converter markup is in the cell.
23847 !! options
23848 language=sr variant=sr-ec
23849 parsoid=wt2html,wt2wt,html2html
23850 !! wikitext
23851 {|
23852 |-
23853 | -{R|B}-
23854 |}
23855 !! html/php
23856 <table>
23857
23858 <tr>
23859 <td>B
23860 </td></tr></table>
23861
23862 !! html/parsoid
23863 <table>
23864 <tbody>
23865 <tr>
23866 <td><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"B"}}'></span></td>
23867 </tr>
23868 </tbody>
23869 </table>
23870 !! end
23871
23872 !! test
23873 Language converter tricky html2wt cases (1)
23874 !! options
23875 language=sr
23876 parsoid=html2wt,wt2wt
23877 !! html/parsoid
23878 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"}-"}}'></span></p>
23879 !! wikitext
23880 -{<nowiki>}-</nowiki>}-
23881 !! html/php
23882 <p>&#125;-
23883 </p>
23884 !! end
23885
23886 !! test
23887 Language converter tricky html2wt cases (2)
23888 !! options
23889 language=sr
23890 parsoid=html2wt,wt2wt
23891 !! html/parsoid
23892 <p>-{foo}-</p>
23893 !! wikitext
23894 <nowiki>-{foo}-</nowiki>
23895 !! html/php
23896 <p>-&#123;foo&#125;-
23897 </p>
23898 !! end
23899
23900 !! test
23901 Language converter tricky html2wt cases (3)
23902 !! options
23903 language=sr
23904 parsoid=html2wt,wt2wt
23905 !! html/parsoid
23906 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"|"}}'></span></p>
23907 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"R|raw"}}'></span></p>
23908 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"-{foo}-"}}'></span></p>
23909 !! wikitext
23910 -{R||}-
23911
23912 -{R|R|raw}-
23913
23914 -{<nowiki>-{foo}-</nowiki>}-
23915 !! html/php
23916 <p>|
23917 </p><p>R|raw
23918 </p><p>-&#123;foo&#125;-
23919 </p>
23920 !! end
23921
23922 !! test
23923 Language converter tricky html2wt cases (4)
23924 !! options
23925 language=sr
23926 parsoid=html2wt,wt2wt
23927 !! html/parsoid
23928 <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>
23929 !! wikitext
23930 -{R|{{echo|hey}}}-
23931 !! html/php
23932 <p>hey
23933 </p>
23934 !! end
23935
23936 # Note that the <nowiki> escaping added by parsoid for source text,
23937 # destination text, and language names only works on the PHP side
23938 # for *destination text*. (HTML entity escaping wouldn't work
23939 # any better.) This is probably a bug, at least for source texts.
23940 # (For language names PHP uses a precise regexp based on the languages
23941 # it currently knows have variants, which is fragile since this set
23942 # can grow/shrink over time.)
23943 !! test
23944 Language converter tricky html2wt cases (5)
23945 !! options
23946 language=zh variant=zh-cn
23947 !! html/parsoid
23948 <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>
23949 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"A","l":"bo:g;us","t":"B"}]}'/></p>
23950 <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>
23951 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"bo:g;us","t":"xyz"},{"l":"zh-cn","t":"abc"}]}'></span></p>
23952 <p>a:b=>c xyz</p>
23953 !! wikitext
23954 -{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
23955
23956 -{H|A=><nowiki>bo:g;us</nowiki>:B}-
23957
23958 -{A|zh-tw:xyz; zh-cn:<nowiki>0;zh-tw:bar</nowiki>}-
23959
23960 -{<nowiki>bo:g;us</nowiki>:xyz; zh-cn:abc}-
23961
23962 a:b=>c xyz
23963 !! html/php+disabled
23964 <p>foobat;xyz=&gt;zh-cn:abc
23965 </p><p>A
23966 </p><p>0;zh-tw:bar
23967 </p><p>abc
23968 </p><p>a:b=&gt;c 0;zh-tw:bar
23969 </p>
23970 !! end
23971
23972 !! test
23973 T179579: Nowiki and lc interaction
23974 !! options
23975 parsoid=wt2html
23976 language=sr
23977 !! wikitext
23978 -{</nowiki>123}-
23979
23980 -{123<nowiki>|</nowiki>456}-
23981 !! html/parsoid
23982 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&amp;lt;/nowiki>123"}}' data-parsoid='{"fl":[],"src":"-{&lt;/nowiki>123}-"}'></span></p>
23983
23984 <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>
23985 !! end
23986
23987 !! test
23988 T2529: Uncovered bullet
23989 !! wikitext
23990 *Foo {{bullet}}
23991 !! html
23992 <ul><li>Foo</li>
23993 <li>Bar</li></ul>
23994
23995 !! end
23996
23997 !! test
23998 T2529: Uncovered bullet in a deeply nested list
23999 !! wikitext
24000 *******Foo {{bullet}}
24001 !! html
24002 <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>
24003 <li>Bar</li></ul>
24004
24005 !! end
24006
24007 !! test
24008 T2529: Uncovered table already at line-start
24009 !! wikitext
24010 x
24011
24012 {{table}}
24013 y
24014 !! html
24015 <p>x
24016 </p>
24017 <table>
24018 <tr>
24019 <td>1</td>
24020 <td>2
24021 </td></tr>
24022 <tr>
24023 <td>3</td>
24024 <td>4
24025 </td></tr></table>
24026 <p>y
24027 </p>
24028 !! end
24029
24030 !! test
24031 T2529: Uncovered bullet in parser function result
24032 !! wikitext
24033 *Foo {{lc:{{bullet}} }}
24034 !! html
24035 <ul><li>Foo</li>
24036 <li>bar</li></ul>
24037
24038 !! end
24039
24040 !! test
24041 T7678: Double-parsed template argument
24042 !! wikitext
24043 {{lc:{{{1}}}|hello}}
24044 !! html
24045 <p>{{{1}}}
24046 </p>
24047 !! end
24048
24049 !! test
24050 T7678: Double-parsed template invocation
24051 !! wikitext
24052 {{lc:{{paramtest {{!}} param = hello }} }}
24053 !! html
24054 <p>{{paramtest | param = hello }}
24055 </p>
24056 !! end
24057
24058 !! test
24059 Case insensitivity of parser functions for non-ASCII characters (T10143)
24060 !! options
24061 language=cs
24062 title=[[Main Page]]
24063 !! wikitext
24064 {{PRVNÍVELKÉ:ěščř}}
24065 {{prvnívelké:ěščř}}
24066 {{PRVNÍMALÉ:ěščř}}
24067 {{prvnímalé:ěščř}}
24068 {{MALÁ:ěščř}}
24069 {{malá:ěščř}}
24070 {{VELKÁ:ěščř}}
24071 {{velká:ěščř}}
24072 !! html
24073 <p>Ěščř
24074 Ěščř
24075 ěščř
24076 ěščř
24077 ěščř
24078 ěščř
24079 ĚŠČŘ
24080 ĚŠČŘ
24081 </p>
24082 !! end
24083
24084 !! test
24085 Morwen/13: Unclosed link followed by heading
24086 !! wikitext
24087 [[link
24088 ==heading==
24089 !! html
24090 <p>[[link
24091 </p>
24092 <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>
24093
24094 !! end
24095
24096 !! test
24097 HHP2.1: Heuristics for headings in preprocessor parenthetical structures
24098 !! wikitext
24099 {{foo|
24100 =heading=
24101 !! html
24102 <p>{{foo|
24103 </p>
24104 <h1><span class="mw-headline" id="heading">heading</span></h1>
24105
24106 !! end
24107
24108 !! test
24109 HHP2.2: Heuristics for headings in preprocessor parenthetical structures
24110 !! wikitext
24111 {{foo|
24112 ==heading==
24113 !! html
24114 <p>{{foo|
24115 </p>
24116 <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>
24117
24118 !! end
24119
24120 !! test
24121 Tildes in comments
24122 !! options
24123 pst
24124 !! wikitext
24125 <!-- ~~~~ -->
24126 !! html/php
24127 <!-- ~~~~ -->
24128 !! end
24129
24130 !! test
24131 Paragraphs inside divs (no extra line breaks)
24132 !! wikitext
24133 <div>Line one
24134
24135 Line two</div>
24136 !! html
24137 <div>Line one
24138 Line two</div>
24139
24140 !! end
24141
24142 !! test
24143 Paragraphs inside divs (extra line break on open)
24144 !! wikitext
24145 <div>
24146 Line one
24147
24148 Line two</div>
24149 !! html
24150 <div>
24151 <p>Line one
24152 </p>
24153 Line two</div>
24154
24155 !! end
24156
24157 !! test
24158 Paragraphs inside divs (extra line break on close)
24159 !! wikitext
24160 <div>Line one
24161
24162 Line two
24163 </div>
24164 !! html
24165 <div>Line one
24166 <p>Line two
24167 </p>
24168 </div>
24169
24170 !! end
24171
24172 !! test
24173 Paragraphs inside divs (extra line break on open and close)
24174 !! wikitext
24175 <div>
24176 Line one
24177
24178 Line two
24179 </div>
24180 !! html
24181 <div>
24182 <p>Line one
24183 </p><p>Line two
24184 </p>
24185 </div>
24186
24187 !! end
24188
24189 # doBlockLevels screws up this output and Remex cleans up as much as it can.
24190 !! test
24191 Nesting tags, paragraphs on lines which begin with <div>
24192 !! wikitext
24193 <div></div><strong>A
24194 B</strong>
24195 !! html/php+tidy
24196 <div></div><p><strong>A
24197 </strong></p><strong></strong><p><strong>B</strong>
24198 </p>
24199 !! html/parsoid
24200 <div data-parsoid='{"stx":"html"}'></div><p><strong data-parsoid='{"stx":"html","autoInsertedEnd":true}'>A</strong></p>
24201 <p><strong data-parsoid='{"stx":"html","autoInsertedStart":true}'>B</strong></p>
24202 !! end
24203
24204 # T8200: <blockquote> should behave like <div> with respect to line breaks
24205 !! test
24206 T8200: paragraphs inside blockquotes (no extra line breaks)
24207 !! wikitext
24208 <blockquote>Line one
24209
24210 Line two</blockquote>
24211 !! html
24212 <blockquote>Line one
24213 Line two</blockquote>
24214
24215 !! html+tidy
24216 <blockquote><p>Line one
24217 Line two</p></blockquote>
24218 !! end
24219
24220 !! test
24221 T8200: paragraphs inside blockquotes (extra line break on open)
24222 !! wikitext
24223 <blockquote>
24224 Line one
24225
24226 Line two</blockquote>
24227 !! html
24228 <blockquote>
24229 <p>Line one
24230 </p>
24231 Line two</blockquote>
24232
24233 !! html+tidy
24234 <blockquote>
24235 <p>Line one
24236 </p><p>
24237 Line two</p></blockquote>
24238 !! end
24239
24240 !! test
24241 T8200: paragraphs inside blockquotes (extra line break on close)
24242 !! wikitext
24243 <blockquote>Line one
24244
24245 Line two
24246 </blockquote>
24247 !! html
24248 <blockquote>Line one
24249 <p>Line two
24250 </p>
24251 </blockquote>
24252
24253 !! html+tidy
24254 <blockquote><p>Line one
24255 </p><p>Line two
24256 </p>
24257 </blockquote>
24258 !! end
24259
24260 !! test
24261 T8200: paragraphs inside blockquotes (extra line break on open and close)
24262 !! wikitext
24263 <blockquote>
24264 Line one
24265
24266 Line two
24267 </blockquote>
24268 !! html
24269 <blockquote>
24270 <p>Line one
24271 </p><p>Line two
24272 </p>
24273 </blockquote>
24274
24275 !! end
24276
24277 ## This is a corner case interaction between the paragraph wrapping in the
24278 ## php parser's BlockLevelPass and Remex. `doBlockLevels` has a notion of
24279 ## some tags which close paragraphs (and thus prevent wrapping on their line),
24280 ## of which "div" is one, but do p-wrapping inside them. These are referred
24281 ## to as "never suppressing". Remex, for its part, doesn't traverse into
24282 ## "div"s to p-wrap. Hence, we only get this partial wrapping.
24283 !! test
24284 Paragraphs inside blockquotes/divs (no extra line breaks)
24285 !! wikitext
24286 <blockquote><div>Line one
24287
24288 Line two</div></blockquote>
24289 !! html
24290 <blockquote><div>Line one
24291 Line two</div></blockquote>
24292
24293 !! end
24294
24295 !! test
24296 Paragraphs inside blockquotes/divs (extra line break on open)
24297 !! wikitext
24298 <blockquote><div>
24299 Line one
24300
24301 Line two</div></blockquote>
24302 !! html
24303 <blockquote><div>
24304 <p>Line one
24305 </p>
24306 Line two</div></blockquote>
24307
24308 !! end
24309
24310 !! test
24311 Paragraphs inside blockquotes/divs (extra line break on close)
24312 !! wikitext
24313 <blockquote><div>Line one
24314
24315 Line two
24316 </div></blockquote>
24317 !! html
24318 <blockquote><div>Line one
24319 <p>Line two
24320 </p>
24321 </div></blockquote>
24322
24323 !! end
24324
24325 !! test
24326 Paragraphs inside blockquotes/divs (extra line break on open and close)
24327 !! wikitext
24328 <blockquote><div>
24329 Line one
24330
24331 Line two
24332 </div></blockquote>
24333 !! html
24334 <blockquote><div>
24335 <p>Line one
24336 </p><p>Line two
24337 </p>
24338 </div></blockquote>
24339
24340 !! end
24341
24342 !! test
24343 Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion
24344 !! options
24345 wgLinkHolderBatchSize=0
24346 !! wikitext
24347 [[meatball:1]]
24348 [[meatball:2]]
24349 [[meatball:3]]
24350 !! html
24351 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?1" class="extiw" title="meatball:1">meatball:1</a>
24352 <a href="http://www.usemod.com/cgi-bin/mb.pl?2" class="extiw" title="meatball:2">meatball:2</a>
24353 <a href="http://www.usemod.com/cgi-bin/mb.pl?3" class="extiw" title="meatball:3">meatball:3</a>
24354 </p>
24355 !! end
24356
24357 !! test
24358 Free external link invading image caption
24359 !! wikitext
24360 [[Image:Foobar.jpg|thumb|http://x|hello]]
24361 !! html/php
24362 <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>
24363
24364 !! html/parsoid
24365 <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>
24366 !! end
24367
24368 !! test
24369 T17196: localised external link numbers
24370 !! options
24371 language=fa
24372 !! wikitext
24373 [http://en.wikipedia.org/]
24374 !! html/php
24375 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/">[۱]</a>
24376 </p>
24377 !! html/parsoid
24378 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/"></a></p>
24379 !! end
24380
24381 !! test
24382 Multibyte character in padleft
24383 !! wikitext
24384 {{padleft:-Hello|7|Æ}}
24385 !! html/php
24386 <p>Æ-Hello
24387 </p>
24388 !! html/parsoid
24389 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:-Hello","function":"padleft"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Æ-Hello</p>
24390 !! end
24391
24392 !! test
24393 Multibyte character in padright
24394 !! wikitext
24395 {{padright:Hello-|7|Æ}}
24396 !! html/php
24397 <p>Hello-Æ
24398 </p>
24399 !! html/parsoid
24400 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:Hello-","function":"padright"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Hello-Æ</p>
24401 !! end
24402
24403 !!test
24404 formatdate parser function
24405 !! wikitext
24406 {{#formatdate:2009-03-24}}
24407 !! html
24408 <p><span class="mw-formatted-date" title="2009-03-24">2009-03-24</span>
24409 </p>
24410 !! end
24411
24412 !!test
24413 formatdate parser function, with default format
24414 !! wikitext
24415 {{#formatdate:2009-03-24|mdy}}
24416 !! html
24417 <p><span class="mw-formatted-date" title="2009-03-24">March 24, 2009</span>
24418 </p>
24419 !! end
24420
24421 !! test
24422 Spacing of numbers in formatted dates
24423 !! wikitext
24424 {{#formatdate:January 15}}
24425 !! html
24426 <p><span class="mw-formatted-date" title="01-15">January 15</span>
24427 </p>
24428 !! end
24429
24430 !! test
24431 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
24432 !! options
24433 language=nl title=[[MediaWiki:Common.css]]
24434 !! wikitext
24435 {{#formatdate:2009-03-24|dmy}}
24436 !! html
24437 <p><span class="mw-formatted-date" title="2009-03-24">24 March 2009</span>
24438 </p>
24439 !! end
24440
24441 #
24442 #
24443 #
24444
24445 #
24446 # Edit comments
24447 #
24448
24449 !! test
24450 Edit comment with link
24451 !! options
24452 comment
24453 !! wikitext
24454 I like the [[Main Page]] a lot
24455 !! html/php
24456 I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot
24457 !!end
24458
24459 !! test
24460 Edit comment with link and link text
24461 !! options
24462 comment
24463 !! wikitext
24464 I like the [[Main Page|best pages]] a lot
24465 !! html/php
24466 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
24467 !!end
24468
24469 !! test
24470 Edit comment with link and link text with suffix
24471 !! options
24472 comment
24473 !! wikitext
24474 I like the [[Main Page|best page]]s a lot
24475 !! html/php
24476 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
24477 !!end
24478
24479 !! test
24480 Edit comment with section link (non-local, eg in history list)
24481 !! options
24482 comment title=[[Main Page]]
24483 !! wikitext
24484 /* External links */ removed bogus entries
24485 !! html/php
24486 <a href="/wiki/Main_Page#External_links" title="Main Page">→External links</a>‎<span dir="auto"><span class="autocomment">: </span> removed bogus entries</span>
24487 !!end
24488
24489 !! test
24490 Edit comment with section link and text before it (non-local, eg in history list)
24491 !! options
24492 comment title=[[Main Page]]
24493 !! wikitext
24494 pre-comment text /* External links */ removed bogus entries
24495 !! html/php
24496 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>
24497 !!end
24498
24499 !! test
24500 Edit comment with section link (local, eg in diff view)
24501 !! options
24502 comment local title=[[Main Page]]
24503 !! wikitext
24504 /* External links */ removed bogus entries
24505 !! html/php
24506 <a href="#External_links">→External links</a>‎<span dir="auto"><span class="autocomment">: </span> removed bogus entries</span>
24507 !!end
24508
24509 !! test
24510 Edit comment with subpage link (T16080)
24511 !! options
24512 comment
24513 subpage
24514 title=[[Subpage test]]
24515 !! wikitext
24516 Poked at a [[/subpage]] here...
24517 !! html/php
24518 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> here...
24519 !!end
24520
24521 !! test
24522 Edit comment with subpage link and link text (T16080)
24523 !! options
24524 comment
24525 subpage
24526 title=[[Subpage test]]
24527 !! wikitext
24528 Poked at a [[/subpage|neat little page]] here...
24529 !! html/php
24530 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">neat little page</a> here...
24531 !!end
24532
24533 !! test
24534 Edit comment with bogus subpage link in non-subpage NS (T16080)
24535 !! options
24536 comment
24537 title=[[Subpage test]]
24538 !! wikitext
24539 Poked at a [[/subpage]] here...
24540 !! html/php
24541 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...
24542 !!end
24543
24544 !! test
24545 Edit comment with bare anchor link (local, as on diff)
24546 !! options
24547 comment
24548 local
24549 title=[[Main Page]]
24550 !! wikitext
24551 [[#section]]
24552 !! html/php
24553 <a href="#section">#section</a>
24554 !! end
24555
24556 !! test
24557 Edit comment with bare anchor link (non-local, as on history)
24558 !! options
24559 comment
24560 title=[[Main Page]]
24561 !! wikitext
24562 [[#section]]
24563 !! html/php
24564 <a href="/wiki/Main_Page#section" title="Main Page">#section</a>
24565 !! end
24566
24567 !! test
24568 Anchor starting with underscore
24569 !! options
24570 title=[[Foo]]
24571 !! wikitext
24572 [[#_ref|One]]
24573 !! html/php
24574 <p><a href="#_ref">One</a>
24575 </p>
24576 !! html/parsoid
24577 <p><a rel="mw:WikiLink" href="./Foo#_ref" data-parsoid='{"stx":"piped","a":{"href":"./Foo#_ref"},"sa":{"href":"#_ref"}}'>One</a></p>
24578 !! end
24579
24580 !! test
24581 Id starting with underscore
24582 !! wikitext
24583 <div id="_ref"></div>
24584 !! html/*
24585 <div id="_ref"></div>
24586
24587 !! end
24588
24589 !! test
24590 Edit comment with link with more than one pipe (T99346)
24591 !! options
24592 comment
24593 !! wikitext
24594 [[Main Page|Many|pipes]]
24595 !! html/php
24596 <a href="/wiki/Main_Page" title="Main Page">Many|pipes</a>
24597 !! end
24598
24599 !! test
24600 Complex edit comment with link with more than one pipe (T99346)
24601 !! options
24602 comment
24603 !! wikitext
24604 Created page with "<noinclude>[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]]</noinclude> === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..."
24605 !! html/php
24606 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;
24607 !! end
24608
24609 !! test
24610 Space normalisation on autocomment (T24784)
24611 !! options
24612 comment
24613 title=[[Main Page]]
24614 !! wikitext
24615 /* __hello__world__ */
24616 !! html/php
24617 <a href="/wiki/Main_Page#hello_world" title="Main Page">→__hello__world__</a>‎
24618 !! end
24619
24620 !! test
24621 percent-encoding and + signs in comments (T28410)
24622 !! options
24623 comment
24624 !! wikitext
24625 [[ABC%33D% ++]] [[ABC%33D% ++|+%20]]
24626 !! html/php
24627 <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>
24628 !! end
24629
24630 # Parsoid doesn't support this yet: see T75581
24631 # but it *should* omit the 'src' attribute if the image is bad.
24632 # PHP side of tests was disabled in
24633 # mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
24634 # because of issues in the PHP parserTests infrastructure
24635 # (but the output below is indeed what the PHP side emits)
24636 !! test
24637 Bad images - basic functionality
24638 !! wikitext
24639 [[File:Bad.jpg]]
24640 !! html/php+disabled
24641 !! html/parsoid
24642 <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>
24643 !! end
24644
24645 !! test
24646 Bad images - T18039: text after bad image disappears
24647 !! wikitext
24648 Foo bar
24649 [[File:Bad.jpg]]
24650 Bar foo
24651 !! html/php+disabled
24652 <p>Foo bar
24653 </p><p>Bar foo
24654 </p>
24655 !! html/parsoid
24656 <p>Foo bar
24657 <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>
24658 Bar foo</p>
24659 !! end
24660
24661 !! test
24662 Verify that displaytitle works (T24501) no displaytitle
24663 !! options
24664 showtitle
24665 !! config
24666 wgAllowDisplayTitle=true
24667 wgRestrictDisplayTitle=false
24668 !! wikitext
24669 this is not the the title
24670 !! html/php
24671 Parser test
24672 <p>this is not the the title
24673 </p>
24674 !! end
24675
24676 !! test
24677 Verify that displaytitle works (T24501) RestrictDisplayTitle=false
24678 !! options
24679 showtitle
24680 title=[[Screen]]
24681 !! config
24682 wgAllowDisplayTitle=true
24683 wgRestrictDisplayTitle=false
24684 !! wikitext
24685 this is not the the title
24686 {{DISPLAYTITLE:whatever}}
24687 !! html/php
24688 whatever
24689 <p>this is not the the title
24690 </p>
24691 !! end
24692
24693 !! test
24694 Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch
24695 !! options
24696 showtitle
24697 title=[[Screen]]
24698 !! config
24699 wgAllowDisplayTitle=true
24700 wgRestrictDisplayTitle=true
24701 !! wikitext
24702 this is not the the title
24703 {{DISPLAYTITLE:whatever}}
24704 !! html/php
24705 Screen
24706 <p>this is not the the title
24707 </p>
24708 !! end
24709
24710 !! test
24711 Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching
24712 !! options
24713 showtitle
24714 title=[[Screen]]
24715 !! config
24716 wgAllowDisplayTitle=true
24717 wgRestrictDisplayTitle=true
24718 !! wikitext
24719 this is not the the title
24720 {{DISPLAYTITLE:screen}}
24721 !! html/php
24722 screen
24723 <p>this is not the the title
24724 </p>
24725 !! end
24726
24727 !! test
24728 Verify that displaytitle works (T24501) AllowDisplayTitle=false
24729 !! options
24730 showtitle
24731 title=[[Screen]]
24732 !! config
24733 wgAllowDisplayTitle=false
24734 !! wikitext
24735 this is not the the title
24736 {{DISPLAYTITLE:screen}}
24737 !! html/php
24738 Screen
24739 <p>this is not the the title
24740 <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>
24741 </p>
24742 !! end
24743
24744 !! test
24745 Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE
24746 !! options
24747 showtitle
24748 title=[[Screen]]
24749 !! config
24750 wgAllowDisplayTitle=false
24751 !! wikitext
24752 this is not the the title
24753 !! html/php
24754 Screen
24755 <p>this is not the the title
24756 </p>
24757 !! end
24758
24759 !! test
24760 Verify that displaytitle handles inline CSS styles (T28547) - rejected value
24761 !! options
24762 showtitle
24763 title=[[Screen]]
24764 !! config
24765 wgAllowDisplayTitle=true
24766 wgRestrictDisplayTitle=true
24767 !! wikitext
24768 this is not the the title
24769 {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
24770 !! html/php
24771 <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
24772 <p>this is not the the title
24773 </p>
24774 !! end
24775
24776 !! test
24777 Verify that displaytitle handles inline CSS styles (T28547) - accepted value
24778 !! options
24779 showtitle
24780 title=[[Screen]]
24781 !! config
24782 wgAllowDisplayTitle=true
24783 wgRestrictDisplayTitle=true
24784 !! wikitext
24785 this is not the the title
24786 {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
24787 !! html/php
24788 <span style="color: red;">s</span>creen
24789 <p>this is not the the title
24790 </p>
24791 !! end
24792
24793 !! test
24794 Page status indicators: Empty name is invalid
24795 !! options
24796 showindicators
24797 !! wikitext
24798 <indicator name=" "></indicator>
24799 <indicator></indicator>
24800 !! html/php
24801 <p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
24802 <span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
24803 </p>
24804 !! end
24805
24806 !! test
24807 Page status indicators: Weird syntaxes that are okay
24808 !! options
24809 showindicators
24810 !! wikitext
24811 <indicator name="empty" />
24812 <indicator name="name"></indicator>
24813 !! html/php
24814 empty=
24815 name=
24816 <p><br />
24817 </p>
24818 !! end
24819
24820 !! test
24821 Page status indicators: Torture test
24822 !! options
24823 showindicators
24824 !! wikitext
24825 <indicator name="01">hello world</indicator>
24826 <indicator name="02">[[Main Page]]</indicator>
24827 <indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator>
24828 <indicator name="04">[[File:Foobar.jpg|25px]]</indicator>
24829 <indicator name="05">*foo
24830 *bar</indicator>
24831 <indicator name="06"><nowiki>foo</nowiki></indicator>
24832 <indicator name="07"> Preformatted</indicator>
24833 <indicator name="08"><div>Broken tag</indicator>
24834 <indicator name="09">{| class=wikitable
24835 |cell
24836 |}</indicator>
24837 <indicator name="10">Two
24838
24839 paragraphs</indicator>
24840 !! html/php
24841 01=hello world
24842 02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
24843 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" />
24844 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>
24845 05=<ul><li>foo</li>
24846 <li>bar</li></ul>
24847
24848 06=foo
24849 07=<pre>Preformatted
24850 </pre>
24851 08=<div>Broken tag</div>
24852
24853 09=<table class="wikitable">
24854 <tr>
24855 <td>cell
24856 </td></tr></table>
24857
24858 10=<p>Two
24859 </p><p>paragraphs
24860 </p>
24861 <p><br />
24862 </p><p><br />
24863 </p><p><br />
24864 </p><p><br />
24865 </p><p><br />
24866 </p>
24867 !! end
24868
24869 !! test
24870 preload: check <noinclude> and <includeonly>
24871 !! options
24872 preload
24873 !! wikitext
24874 Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
24875 !! html/php
24876 Hello kind world.
24877 !! end
24878
24879 !! test
24880 preload: check <onlyinclude>
24881 !! options
24882 preload
24883 !! wikitext
24884 Goodbye <onlyinclude>Hello world</onlyinclude>
24885 !! html/php
24886 Hello world
24887 !! end
24888
24889 !! test
24890 preload: can pass tags through if we want to
24891 !! options
24892 preload
24893 !! wikitext
24894 <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
24895 !! html/php
24896 <includeonly>Hello world</includeonly>
24897 !! end
24898
24899 !! test
24900 preload: check that it doesn't try to do tricks
24901 !! options
24902 preload
24903 !! wikitext
24904 * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
24905 !! html/php
24906 * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
24907 !! end
24908
24909 !! test
24910 Play a bit with r67090 and T5158
24911 !! wikitext
24912 <div style="width:50% !important">&nbsp;</div>
24913 <div style="width:50%&nbsp;!important">&nbsp;</div>
24914 <div style="width:50%&#160;!important">&nbsp;</div>
24915 <div style="border : solid;">&nbsp;</div>
24916 !! html/php
24917 <div style="width:50% !important">&#160;</div>
24918 <div style="width:50% !important">&#160;</div>
24919 <div style="width:50% !important">&#160;</div>
24920 <div style="border&#32;: solid;">&#160;</div>
24921
24922 !! html/parsoid
24923 <div style="width:50% !important" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
24924 <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>
24925 <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>
24926 <div style="border : solid;" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
24927
24928 !! end
24929
24930 !! test
24931 French spaces in wikitext
24932 !! wikitext
24933 foo ! bar ? bat 50 % is less than 75 %.
24934
24935 Hello : this ; is « something ‹ else › again »
24936 !! html
24937 <p>foo&#160;! bar&#160;? bat 50&#160;% is less than 75&#160;%.
24938 </p><p>Hello&#160;: this&#160;; is «&#160;something ‹&#160;else&#160;› again&#160;»
24939 </p>
24940 !! end
24941
24942 # It would be reasonable for Parsoid and PHP to differ here.
24943 # The PHP behavior is arguably a bug.
24944 !! test
24945 Corner case: french spaces in definition list
24946 !! wikitext
24947 ;foo : bar
24948 !! html+tidy
24949 <dl><dt>foo&#160;</dt>
24950 <dd>bar</dd></dl>
24951 !! end
24952
24953 !! test
24954 T5158: Test for French spaces in attributes
24955 !! wikitext
24956 <br style=" clear : both ; " />
24957 !! html/php
24958 <p><br style="clear&#32;: both&#32;;" />
24959 </p>
24960 !! end
24961
24962 !! test
24963 HTML5 data attributes
24964 !! wikitext
24965 <span data-foo="bar">Baz</span>
24966 <p data-abc-def_hij="">Quuz</p>
24967 !! html/php
24968 <p><span data-foo="bar">Baz</span>
24969 </p>
24970 <p data-abc-def_hij="">Quuz</p>
24971
24972 !! html/parsoid
24973 <p><span data-foo="bar" data-parsoid='{"stx":"html"}'>Baz</span></p>
24974 <p data-abc-def_hij="" data-parsoid='{"stx":"html"}'>Quuz</p>
24975 !! end
24976
24977 !! test
24978 Strip reserved data attributes
24979 !! wikitext
24980 <div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
24981 !! html/php
24982 <div data-ok="fred">d</div>
24983
24984 !! html/parsoid
24985 <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>
24986 !! end
24987
24988 !! test
24989 percent-encoding and + signs in internal links (T28410)
24990 !! wikitext
24991 [[User:+%]] [[Page+title%]]
24992 [[%+]] [[%+|%20]] [[%+ ]] [[%+r]]
24993 [[%]] [[+]] [[File:%+abc%39|foo|[[bar]]]]
24994 [[%33%45]] [[%33%45+]]
24995 !! html/php
24996 <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>
24997 <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>
24998 <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>
24999 <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>
25000 </p>
25001 !! html/parsoid
25002 <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>
25003 <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>
25004 <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>
25005 <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>
25006 !! end
25007
25008 !! test
25009 Special characters in embedded file links (T29679)
25010 !! wikitext
25011 [[File:Contains & ampersand.jpg]]
25012 [[File:Does not exist.jpg|Title with & ampersand]]
25013 !! html/php
25014 <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>
25015 <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>
25016 </p>
25017 !! html/parsoid
25018 <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>
25019 <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>
25020 !! end
25021
25022 !! test
25023 Confirm that 'apos' named character reference doesn't make it to output (not legal in HTML 4)
25024 !! wikitext
25025 Text&apos;s been normalized?
25026 !! html
25027 <p>Text&#39;s been normalized?
25028 </p>
25029 !! end
25030
25031 !! test
25032 T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
25033 !! wikitext
25034 http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
25035 !! html
25036 <p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> &lt;-- U+3000 (vim: ^Vu3000)
25037 </p>
25038 !! end
25039
25040 !! test
25041 T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
25042 !! wikitext
25043 [http://www.example.org/ ideograms]
25044 !! html
25045 <p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a>
25046 </p>
25047 !! end
25048
25049 !! test
25050 T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
25051 !! wikitext
25052 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
25053 !! html
25054 <p><img src="http://www.example.org/pic.png" alt="pic.png"/> &lt;-- U+3000 (vim: ^Vu3000)
25055 </p>
25056 !! end
25057
25058 !! article
25059 Mediawiki:loop1
25060 !! text
25061 {{Identical|A}}
25062 !! endarticle
25063
25064 !! article
25065 Mediawiki:loop2
25066 !! text
25067 {{Identical|B}}
25068 !! endarticle
25069
25070 !! article
25071 Template:Identical
25072 !! text
25073 {{int:loop1}}
25074 {{int:loop2}}
25075 !! endarticle
25076
25077 !! test
25078 T33098 Template which includes system messages which includes the template
25079 !! wikitext
25080 {{Identical}}
25081 !! html
25082 <p><span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
25083 <span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
25084 </p>
25085 !! end
25086
25087 !! test
25088 T33490 Turkish: ucfirst 'blah'
25089 !! options
25090 language=tr
25091 !! wikitext
25092 {{ucfirst:blah}}
25093 !! html
25094 <p>Blah
25095 </p>
25096 !! end
25097
25098 !! test
25099 T33490 Turkish: ucfirst 'ix'
25100 !! options
25101 language=tr
25102 !! wikitext
25103 {{ucfirst:ix}}
25104 !! html
25105 <p>İx
25106 </p>
25107 !! end
25108
25109 !! test
25110 T33490 Turkish: lcfirst 'BLAH'
25111 !! options
25112 language=tr
25113 !! wikitext
25114 {{lcfirst:BLAH}}
25115 !! html
25116 <p>bLAH
25117 </p>
25118 !! end
25119
25120 !! test
25121 T33490 Turkish: ucfırst (with a dotless i)
25122 !! options
25123 language=tr
25124 !! wikitext
25125 {{ucfırst:blah}}
25126 !! html
25127 <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>
25128 </p>
25129 !! end
25130
25131 !! test
25132 T33490 ucfırst (with a dotless i) with English language
25133 !! options
25134 language=en
25135 !! wikitext
25136 {{ucfırst:blah}}
25137 !! html
25138 <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>
25139 </p>
25140 !! end
25141
25142 # Note that Parsoid doesn't emit an explicit TOC.
25143 # Note also that the html2wt direction tends to emit an extra newline
25144 # between the __TOC__ magicword and the first heading unless *both*
25145 # the <meta> and the <h2> have a data-parsoid attribute set (even if
25146 # it's "{}").
25147
25148 !! test
25149 T28375: TOC with italics
25150 !! options
25151 title=[[Main Page]]
25152 !! wikitext
25153 __TOC__
25154 ==''Lost'' episodes==
25155 !! html/php
25156 <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>
25157 <ul>
25158 <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>
25159 </ul>
25160 </div>
25161
25162 <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>
25163
25164 !! html/parsoid
25165 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25166 <h2 id="Lost_episodes" data-parsoid='{}'><i>Lost</i> episodes</h2>
25167 !! end
25168
25169 !! test
25170 T28375: TOC with bold
25171 !! options
25172 title=[[Main Page]]
25173 !! wikitext
25174 __TOC__
25175 =='''should be bold''' then normal text==
25176 !! html/php
25177 <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>
25178 <ul>
25179 <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>
25180 </ul>
25181 </div>
25182
25183 <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>
25184
25185 !! html/parsoid
25186 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25187 <h2 id="should_be_bold_then_normal_text" data-parsoid='{}'><b>should be bold</b> then normal text</h2>
25188 !! end
25189
25190 !! test
25191 T35845: Headings become cursive in TOC when they contain an image
25192 !! options
25193 title=[[Main Page]]
25194 !! wikitext
25195 __TOC__
25196 ==Image [[Image:foobar.jpg]]==
25197 !! html/php
25198 <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>
25199 <ul>
25200 <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
25201 </ul>
25202 </div>
25203
25204 <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>
25205
25206 !! html/parsoid
25207 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25208 <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>
25209 !! end
25210
25211 !! test
25212 T35845 (2): Headings become bold in TOC when they contain a blockquote
25213 !! options
25214 title=[[Main Page]]
25215 !! wikitext
25216 __TOC__
25217 ==<blockquote>Quote</blockquote>==
25218 !! html/php
25219 <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>
25220 <ul>
25221 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
25222 </ul>
25223 </div>
25224
25225 <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>
25226
25227 !! html/php+tidy
25228 <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>
25229 <ul>
25230 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
25231 </ul>
25232 </div>
25233
25234 <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>
25235 !! html/parsoid
25236 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25237 <h2 id="Quote" data-parsoid='{}'><blockquote><p>Quote</p></blockquote></h2>
25238 !! end
25239
25240 !! test
25241 Unclosed tags in TOC
25242 !! config
25243 wgFragmentMode=[ 'html5', 'legacy' ]
25244 !! options
25245 title=[[Main Page]]
25246 !! wikitext
25247 __TOC__
25248 ==Proof: 2 < 3==
25249 <small>Hanc marginis exiguitas non caperet.</small>
25250 QED
25251 !! html/php
25252 <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>
25253 <ul>
25254 <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>
25255 </ul>
25256 </div>
25257
25258 <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>
25259 <p><small>Hanc marginis exiguitas non caperet.</small>
25260 QED
25261 </p>
25262 !! html/parsoid
25263 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25264 <h2 id="Proof:_2_&lt;_3" data-parsoid='{}'><span id="Proof:_2_.3C_3" typeof="mw:FallbackId"></span>Proof: 2 &lt; 3</h2>
25265 <p><small>Hanc marginis exiguitas non caperet.</small>
25266 QED</p>
25267 !! end
25268
25269 !! test
25270 Multiple tags in TOC
25271 !! wikitext
25272 __TOC__
25273 ==<i>Foo</i> <b>Bar</b>==
25274
25275 ==<i>Foo</i> <blockquote>Bar</blockquote>==
25276 !! html/php
25277 <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>
25278 <ul>
25279 <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>
25280 <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>
25281 </ul>
25282 </div>
25283
25284 <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>
25285 <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>
25286
25287 !! html/php+tidy
25288 <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>
25289 <ul>
25290 <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>
25291 <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>
25292 </ul>
25293 </div>
25294
25295 <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>
25296 <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>
25297 !! html/parsoid
25298 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25299 <h2 id="Foo_Bar" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b></h2>
25300
25301 <h2 id="Foo_Bar_2" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote><p>Bar</p></blockquote></h2>
25302 !! end
25303
25304 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
25305 # html5 tag parsing.
25306 !! test
25307 Tags with parameters in TOC
25308 !! options
25309 parsoid=wt2html
25310 !! wikitext
25311 __TOC__
25312 ==<sup class="in-h2">Hello</sup>==
25313
25314 ==<sup class="a > b">Evilbye</sup>==
25315 !! html/php
25316 <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>
25317 <ul>
25318 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
25319 <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>
25320 </ul>
25321 </div>
25322
25323 <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>
25324 <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>
25325
25326 !! html/parsoid
25327 <meta property="mw:PageProp/toc" />
25328 <h2 id="Hello"><sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup></h2>
25329
25330 <h2 id='b">Evilbye'><span id="b.22.3EEvilbye" typeof="mw:FallbackId"></span><sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup></h2>
25331 !! end
25332
25333 !! test
25334 span tags with directionality in TOC
25335 !! wikitext
25336 __TOC__
25337 ==<span dir="ltr">C++</span>==
25338
25339 ==<span dir="rtl">זבנג!</span>==
25340
25341 ==<span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span>==
25342
25343 ==<span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span>==
25344
25345 ==<span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span>==
25346 !! html/php
25347 <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>
25348 <ul>
25349 <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>
25350 <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>
25351 <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>
25352 <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>
25353 <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>
25354 </ul>
25355 </div>
25356
25357 <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>
25358 <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>
25359 <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>
25360 <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>
25361 <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>
25362
25363 !! html/parsoid
25364 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25365 <h2 id="C++" data-parsoid='{}'><span id="C.2B.2B" typeof="mw:FallbackId"></span><span dir="ltr">C++</span></h2>
25366 <h2 id="זבנג!"><span id=".D7.96.D7.91.D7.A0.D7.92.21" typeof="mw:FallbackId"></span><span dir="rtl">זבנג!</span></h2>
25367 <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>
25368 <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>
25369 <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>
25370 !! end
25371
25372 !! test
25373 T74884: bdi element in ToC
25374 !! wikitext
25375 __TOC__
25376 ==<bdi>test</bdi>==
25377 !! html/php
25378 <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>
25379 <ul>
25380 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
25381 </ul>
25382 </div>
25383
25384 <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>
25385
25386 !! html/parsoid
25387 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25388 <h2 id="test" data-parsoid='{}'><bdi>test</bdi></h2>
25389 !! end
25390
25391 !! test
25392 T35715: s/strike element in ToC
25393 !! wikitext
25394 __TOC__
25395 ==<s>test</s> test <strike>test</strike>==
25396 !! html/php
25397 <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>
25398 <ul>
25399 <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>
25400 </ul>
25401 </div>
25402
25403 <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>
25404
25405 !! html/parsoid
25406 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25407 <h2 id="test_test_test" data-parsoid='{}'><s>test</s> test <strike>test</strike></h2>
25408 !! end
25409
25410 !! test
25411 T198618: style element in ToC
25412 !! options
25413 styletag=1
25414 !! wikitext
25415 __TOC__
25416 ==<style>.foo {}</style>Style<style>.bar {}</style>==
25417 !! html/php
25418 <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>
25419 <ul>
25420 <li class="toclevel-1 tocsection-1"><a href="#Style"><span class="tocnumber">1</span> <span class="toctext">Style</span></a></li>
25421 </ul>
25422 </div>
25423
25424 <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>
25425
25426 !! html/parsoid
25427 <meta property="mw:PageProp/toc" data-parsoid="{}"/>
25428 <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>
25429 !! end
25430
25431 !! test
25432 T198618: script element in ToC
25433 !! options
25434 wgRawHtml=1
25435 !! wikitext
25436 __TOC__
25437 ==<html><script>alert(1);</script></html>Script<html><script>alert(1);</script></html>==
25438 !! html/php
25439 <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>
25440 <ul>
25441 <li class="toclevel-1 tocsection-1"><a href="#Script"><span class="tocnumber">1</span> <span class="toctext">Script</span></a></li>
25442 </ul>
25443 </div>
25444
25445 <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>
25446
25447 !! html/parsoid
25448 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25449 <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>
25450 !! end
25451
25452 !! test
25453 Empty <p> tag in TOC, removed by Sanitizer (T92892)
25454 !! wikitext
25455 __TOC__
25456 ==x==
25457 !! html/php
25458 <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>
25459 <ul>
25460 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
25461 </ul>
25462 </div>
25463
25464 <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>
25465
25466 !! html/parsoid
25467 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25468 <h2 id="x" data-parsoid='{}'>x</h2>
25469 !! end
25470
25471 !! article
25472 MediaWiki:T34057
25473 !! text
25474 == {{int:headline_sample}} ==
25475 !! endarticle
25476
25477 !! test
25478 T34057: Title needed when expanding <h> nodes.
25479 !! options
25480 title=[[Main Page]]
25481 !! wikitext
25482 {{int:T34057}}
25483 !! html
25484 <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>
25485
25486 !! end
25487
25488 !! test
25489 Strip marker in urlencode
25490 !! wikitext
25491 {{urlencode:x<nowiki/>y}}
25492 {{urlencode:x<nowiki/>y|wiki}}
25493 {{urlencode:x<nowiki/>y|path}}
25494 {{urlencode:x<pre id="one">two</pre>y}}
25495 !! html/php
25496 <p>xy
25497 xy
25498 xy
25499 xy
25500 </p>
25501 !! end
25502
25503 !! test
25504 Strip marker in lc
25505 !! wikitext
25506 {{lc:x<nowiki/>y}}
25507 !! html
25508 <p>xy
25509 </p>
25510 !! end
25511
25512 !! test
25513 Strip marker in uc
25514 !! wikitext
25515 {{uc:x<nowiki/>y}}
25516 !! html
25517 <p>XY
25518 </p>
25519 !! end
25520
25521 !! test
25522 Strip marker in formatNum
25523 !! wikitext
25524 {{formatnum:1<nowiki/>2}}
25525 {{formatnum:1<nowiki/>2|R}}
25526 !! html
25527 <p>12
25528 12
25529 </p>
25530 !! end
25531
25532 !! test
25533 Check noCommafy in formatNum
25534 !! options
25535 language=be-tarask
25536 !! wikitext
25537 {{formatnum:123456.78}}
25538 {{formatnum:123456.78|NOSEP}}
25539 !! html
25540 <p>123 456,78
25541 123456.78
25542 </p>
25543 !! end
25544
25545 !! test
25546 Wrong option for formatNum (T58199)
25547 !! wikitext
25548 {{formatnum:1,234.56|Random}}
25549 {{formatnum:1,234.56|EVERYTHING}}
25550 {{formatnum:1234.56|any argument that has the string 'NOSEP'}}
25551 !! html
25552 <p>1,234.56
25553 1,234.56
25554 1,234.56
25555 </p>
25556 !! end
25557
25558 !! test
25559 Strip marker in grammar
25560 !! options
25561 language=fi
25562 !! wikitext
25563 {{grammar:elative|foo<nowiki/>bar}}
25564 !! html
25565 <p>foobarista
25566 </p>
25567 !! end
25568
25569 !! test
25570 Strip marker in padleft
25571 !! wikitext
25572 {{padleft:|2|x<nowiki/>y}}
25573 !! html
25574 <p>xy
25575 </p>
25576 !! end
25577
25578 !! test
25579 Strip marker in padright
25580 !! wikitext
25581 {{padright:|2|x<nowiki/>y}}
25582 !! html
25583 <p>xy
25584 </p>
25585 !! end
25586
25587 !! test
25588 Strip marker in anchorencode
25589 !! wikitext
25590 {{anchorencode:x<nowiki/>y}}
25591 !! html/php
25592 <p>xy
25593 </p>
25594 !! html/parsoid
25595 <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>
25596 !! end
25597
25598 !! test
25599 nowiki inside link inside heading (T20295)
25600 !! wikitext
25601 ==[[foo|x<nowiki>y</nowiki>z]]==
25602 !! html
25603 <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>
25604
25605 !! end
25606
25607 !! test
25608 new support for bdi element (T33817)
25609 !! wikitext
25610 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
25611 !! html
25612 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
25613
25614 !!end
25615
25616 !! test
25617 Ignore pipe between table row attributes
25618 !! wikitext
25619 {|
25620 |quux
25621 |- id=foo | style='color: red'
25622 |bar
25623 |}
25624 !! html
25625 <table>
25626 <tr>
25627 <td>quux
25628 </td></tr>
25629 <tr id="foo" style="color: red">
25630 <td>bar
25631 </td></tr></table>
25632
25633 !! end
25634
25635 !!test
25636 Language parser function
25637 !! wikitext
25638 {{#language:ar}}
25639 !! html
25640 <p>العربية
25641 </p>
25642 !! end
25643
25644 !!test
25645 Padleft and padright (default 0-padding)
25646 !! wikitext
25647 {{padleft:xyz|5}}
25648 {{padright:xyz|5}}
25649 !! html/php
25650 <p>00xyz
25651 xyz00
25652 </p>
25653 !! html/parsoid
25654 <p><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:xyz","function":"padleft"},"params":{"1":{"wt":"5"}},"i":0}}]}'>00xyz</span>
25655 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:xyz","function":"padright"},"params":{"1":{"wt":"5"}},"i":0}}]}'>xyz00</span></p>
25656 !! end
25657
25658 !!test
25659 Padleft and padright (partial fill)
25660 !! wikitext
25661 {{padleft:xyz|6|ab}}
25662 {{padright:xyz|6|ab}}
25663 !! html/php
25664 <p>abaxyz
25665 xyzaba
25666 </p>
25667 !! html/parsoid
25668 <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>
25669 <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>
25670 !! end
25671
25672 !!test
25673 Padleft and padright as substr
25674 !! wikitext
25675 {{padleft:|3|abcde}}
25676 {{padright:|3|abcde}}
25677 !! html/php
25678 <p>abc
25679 abc
25680 </p>
25681 !! html/parsoid
25682 <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>
25683 <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>
25684 !! end
25685
25686 !! test
25687 Padleft and padright with non-numerical length (T180403)
25688 !! wikitext
25689 {{padleft:abcdef|junk}}
25690 {{padright:abcdef|junk}}
25691 !! html/php
25692 <p>abcdef
25693 abcdef
25694 </p>
25695 !! end
25696
25697 !!test
25698 Special parser function
25699 !! wikitext
25700 {{#special:RandomPage}}
25701 {{#special:BaDtItLe}}
25702 {{#special:Foobar}}
25703 !! html
25704 <p>Special:Random
25705 Special:Badtitle
25706 Special:Foobar
25707 </p>
25708 !! end
25709
25710 !!test
25711 T36939 - Case insensitive link parsing ([HttP://])
25712 !! wikitext
25713 [HttP://MediaWiki.Org/]
25714 !! html/php
25715 <p><a rel="nofollow" class="external autonumber" href="HttP://MediaWiki.Org/">[1]</a>
25716 </p>
25717 !! html/parsoid
25718 <p><a rel="mw:ExtLink" class="external autonumber" href="HttP://MediaWiki.Org/"></a></p>
25719 !! end
25720
25721 !!test
25722 T36939 - Case insensitive link parsing ([HttP:// title])
25723 !! wikitext
25724 [HttP://MediaWiki.Org/ MediaWiki]
25725 !! html
25726 <p><a rel="nofollow" class="external text" href="HttP://MediaWiki.Org/">MediaWiki</a>
25727 </p>
25728 !! end
25729
25730 !!test
25731 T36939 - Case insensitive link parsing (HttP://)
25732 !! wikitext
25733 HttP://MediaWiki.Org/
25734 !! html/php
25735 <p><a rel="nofollow" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a>
25736 </p>
25737 !! html/parsoid
25738 <p><a rel="mw:ExtLink" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a></p>
25739 !! end
25740
25741 !!test
25742 Disable TOC
25743 !! options
25744 notoc
25745 !! wikitext
25746 Lead
25747 ==Section 1==
25748 ==Section 2==
25749 ==Section 3==
25750 ==Section 4==
25751 ==Section 5==
25752 !! html
25753 <p>Lead
25754 </p>
25755
25756 <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>
25757 <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>
25758 <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>
25759 <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>
25760 <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>
25761
25762 !! end
25763
25764
25765 ###
25766 ### Parsoid-specific tests
25767 ### Parsoid-PHP parser incompatibilities
25768 ###
25769 !!test
25770 1. SOL-sensitive wikitext tokens as template-args
25771 !! options
25772 parsoid=wt2html,wt2wt
25773 !! wikitext
25774 {{echo|*a}}
25775 {{echo|#a}}
25776 {{echo|:a}}
25777 !! html/php+tidy
25778 <ul><li>a</li></ul>
25779 <ol><li>a</li></ol>
25780 <dl><dd>a</dd></dl>
25781 !! html/parsoid
25782 <span about="#mwt1" typeof="mw:Transclusion">
25783 </span><ul about="#mwt1"><li>a</li>
25784 </ul>
25785 <span about="#mwt2" typeof="mw:Transclusion">
25786 </span><ol about="#mwt2"><li>a</li>
25787 </ol>
25788 <span about="#mwt3" typeof="mw:Transclusion">
25789 </span><dl about="#mwt3"><dd>a</dd>
25790 </dl>
25791 !!end
25792
25793 #### -----------------------------------------------------------------
25794 #### Parsoid-specific functionality tests
25795 #### -----------------------------------------------------------------
25796
25797 # T65642/T68749: Formatting elt fixup around images.
25798 # We know wt2wt will fail, but we expect selser to pass.
25799 # Due to the nature of our testing, wt2wt and selser tests will enter the
25800 # blacklist and we'll catch selser regressions based on changes to the
25801 # blacklist entries for selser tests.
25802 !! test
25803 1. Treebuilder fixup of formatting elt
25804 !! options
25805 parsoid=wt2html,wt2wt
25806 !! wikitext
25807 {|
25808 |
25809 <small>
25810 [[Image:Foobar.jpg|right|Test]]
25811 </small>
25812 |}
25813 !! html/php+tidy
25814 <table>
25815 <tbody><tr>
25816 <td>
25817 <p><small>
25818 </small></p><small>
25819 <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>
25820 </small><p><small></small>
25821 </p>
25822 </td></tr></tbody></table>
25823 !! html/parsoid
25824 <table>
25825 <tbody><tr><td>
25826 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p><small data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
25827 <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>
25828 <p><small data-parsoid='{"stx":"html","autoInsertedStart":true}'></small></p></td></tr>
25829 </tbody></table>
25830 !! end
25831
25832 !! test
25833 2. Treebuilder fixup of formatting elt
25834 !! options
25835 parsoid=wt2html,wt2wt
25836 !! wikitext
25837 '''foo[[File:Foobar.jpg|thumb|caption]]bar'''
25838
25839 <small>[[Image:Foobar.jpg|right|300px]]</small>
25840 !! html/php+tidy
25841 <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>
25842 </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>
25843 !! html/parsoid
25844 <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>
25845
25846 <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>
25847 !! end
25848
25849 !! test
25850 3. Treebuilder fixup of formatting elt
25851 !! options
25852 parsoid=wt2html,wt2wt
25853 !! wikitext
25854 <small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
25855 !! html/php+tidy
25856 <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>
25857 </p>
25858 !! html/parsoid
25859 <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>
25860 !! end
25861
25862 !! test
25863 4. Treebuilder fixup of formatting elt: formatting tags around captionless images
25864 !! options
25865 parsoid=wt2html,wt2wt
25866 !! wikitext
25867 '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
25868 !! html/php+tidy
25869 <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>
25870 !! html/parsoid
25871 <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>
25872 !! end
25873
25874 #### ----------------------------------------------------------------
25875 #### Parsoid-only testing of Parsoid's impl of LST
25876 #### Not implemented yet, see
25877 #### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
25878 #### ----------------------------------------------------------------
25879
25880 ## We still need to support serializing the older format while content is stored.
25881 !! test
25882 LST Sections: Backwards compatibility
25883 !! options
25884 parsoid={
25885 "suppressErrors": true,
25886 "modes": ["html2wt"]
25887 }
25888 !! wikitext
25889 <section begin="2011-05-16" />
25890 <section end="2014-04-10 (MW 1.23wmf22)" />
25891 !! html/parsoid
25892 <p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/>
25893 <meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p>
25894 !! end
25895
25896 !! test
25897 LST Sections: Newfangled approach
25898 !! wikitext
25899 <section begin="2011-05-16" />
25900 <section end="2014-04-10 (MW 1.23wmf22)" />
25901 !! html/parsoid
25902 <p><span typeof="mw:Extension/section" about="#mwt4" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"}}'>
25903 </span>
25904 <span typeof="mw:Extension/section" about="#mwt6" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"}}'>
25905 </span></p>
25906 !! end
25907
25908 #--------- Test stripping of empty nodes in template content ----------
25909
25910 !! test
25911 Empty LI and TR nodes should be stripped from template content
25912 !! wikitext
25913 {{EmptyLITest}}
25914 {{EmptyTRTest}}
25915 !! html/parsoid
25916 <ul about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyLITest","href":"./Template:EmptyLITest"},"params":{},"i":0}}]}'>
25917 <li>a</li>
25918 <li>b</li>
25919 </ul>
25920 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRTest","href":"./Template:EmptyTRTest"},"params":{},"i":0}}]}'>
25921 <tbody>
25922 <tr>
25923 <td>foo</td>
25924 </tr>
25925 <tr>
25926 <td>bar</td>
25927 </tr>
25928 </tbody>
25929 </table>
25930 !! end
25931
25932 !! test
25933 Empty LI and TR nodes should not be stripped from top-level content
25934 !! wikitext
25935 *a
25936 *
25937 *b
25938
25939 {|
25940 |-
25941 |-
25942 |foo
25943 |}
25944 !! html/parsoid
25945 <ul>
25946 <li>a</li>
25947 <li class='mw-empty-elt'></li>
25948 <li>b</li>
25949 </ul>
25950 <table>
25951 <tbody>
25952 <tr class='mw-empty-elt'></tr>
25953 <tr>
25954 <td>foo</td>
25955 </tr>
25956 </tbody>
25957 </table>
25958 !! end
25959
25960 !! test
25961 Empty TR nodes should not be stripped if they have any attributes set
25962 !! wikitext
25963 {{EmptyTRWithHTMLAttrTest}}
25964 !! html/parsoid
25965 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'>
25966 <tr align='center'></tr>
25967 <tr><td>foo</td></tr>
25968 <tr align='center'></tr>
25969 <tr><td>bar</td></tr>
25970 </table>
25971 !! end
25972
25973 #### ----------------------------------------------------------------
25974 #### The following section of tests are primarily to test
25975 #### wikitext escaping capabilities of Parsoid. Given that
25976 #### escaping can be done any number of ways, the wikitext (input)
25977 #### is always adjusted to reflect how Parsoid adds nowiki
25978 #### escape tags.
25979 ####
25980 #### We are marking several tests as parsoid-only since the
25981 #### HTML in the result section is different from what the
25982 #### PHP parser generates for it.
25983 #### ----------------------------------------------------------------
25984
25985
25986 #### --------------- Headings ---------------
25987 #### 0. Unnested
25988 #### 1. Nested inside html <h1>=foo=</h1>
25989 #### 2. Outside heading nest on a single line <h1>foo</h1>*bar
25990 #### 3. Nested inside html with wikitext split by html tags
25991 #### 4. No escape needed
25992 #### 5. Empty headings <h1></h1>
25993 #### 6. Heading chars in SOL context
25994 #### ----------------------------------------
25995 !! test
25996 Headings: 0. Unnested
25997 !! options
25998 parsoid=html2wt
25999 !! html/parsoid
26000 <p>=foo=</p>
26001
26002 <p> =foo=
26003 <!--cmt-->
26004 =foo=</p>
26005
26006 <p>=foo<i>a</i>=</p>
26007 !! wikitext
26008 <nowiki>=foo=</nowiki>
26009
26010 <nowiki> </nowiki>=foo=
26011 <!--cmt-->
26012 <nowiki>=foo=</nowiki>
26013
26014 =foo''a''<nowiki>=</nowiki>
26015 !!end
26016
26017 # New headings and existing headings are handled differently
26018 !! test
26019 Headings: 1. Nested inside html
26020 !! options
26021 parsoid=html2wt
26022 !! html/parsoid
26023 <h1>=foo=</h1>
26024 <h2>=foo=</h2>
26025 <h3>=foo=</h3>
26026
26027 <h1 data-parsoid=''>=foo=</h1>
26028 <h2 data-parsoid=''>=foo=</h2>
26029 <h3 data-parsoid=''>=foo=</h3>
26030 <h4 data-parsoid=''>=foo=</h4>
26031 <h5 data-parsoid=''>=foo=</h5>
26032 <h6 data-parsoid=''>=foo=</h6>
26033 !! wikitext
26034 = =foo= =
26035
26036 == =foo= ==
26037
26038 === =foo= ===
26039
26040 =<nowiki>=foo=</nowiki>=
26041 ==<nowiki>=foo=</nowiki>==
26042 ===<nowiki>=foo=</nowiki>===
26043 ====<nowiki>=foo=</nowiki>====
26044 =====<nowiki>=foo=</nowiki>=====
26045 ======<nowiki>=foo=</nowiki>======
26046
26047 !!end
26048
26049 !! test
26050 Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
26051 !! options
26052 parsoid=html2wt
26053 !! html/parsoid
26054 <h1>foo</h1>*bar
26055 <h1>foo</h1>=bar
26056 <h1>foo</h1>=bar=
26057 !! wikitext
26058 = foo =
26059 <nowiki>*</nowiki>bar
26060
26061 = foo =
26062 =bar
26063
26064 = foo =
26065 <nowiki>=bar=</nowiki>
26066 !!end
26067
26068 !! test
26069 Headings: 3. Nested inside html with wikitext split by html tags
26070 !! options
26071 parsoid=html2wt
26072 !! html/parsoid
26073 <h1>=<b>bold</b>foo=</h1>
26074 !! wikitext
26075 = ='''bold'''foo= =
26076 !!end
26077
26078 !! test
26079 Headings: 4a. No escaping needed (testing just h1 and h2)
26080 !! options
26081 parsoid=html2wt
26082 !! html/parsoid
26083 <h1>=foo</h1>
26084 <h1>foo=</h1>
26085 <h1> =foo= </h1>
26086 <h1>=foo= bar</h1>
26087 <h2>=foo</h2>
26088 <h2>foo=</h2>
26089 <h1>=</h1>
26090 <h1><i>=</i>foo=</h1>
26091 !! wikitext
26092 = =foo =
26093
26094 = foo= =
26095
26096 = =foo= =
26097
26098 = =foo= bar =
26099
26100 == =foo ==
26101
26102 == foo= ==
26103
26104 = = =
26105
26106 = ''=''foo= =
26107 !!end
26108
26109 !! test
26110 Headings: 4b. No escaping needed (inside p-tags)
26111 !! options
26112 parsoid=html2wt
26113 !! html/parsoid
26114 <p>=foo= x
26115 =foo= <s></s>
26116 </p>
26117 !! wikitext
26118 =foo= x
26119 =foo= <s></s>
26120 !! html/php
26121 <p>=foo= x
26122 =foo= <s></s>
26123 </p>
26124 !!end
26125
26126 !! test
26127 Headings: 4c. Short headings (1)
26128 !! options
26129 parsoid=html2wt
26130 !! html/parsoid
26131 <p>===
26132 </p>
26133 !! wikitext
26134 <nowiki>===</nowiki>
26135 !! html/php
26136 <p>===
26137 </p>
26138 !! end
26139
26140 # in the html2wt direction we emit '= = =' or '=<nowiki>=</nowiki>='
26141 !! test
26142 Headings: 4d. Short headings (2)
26143 !! options
26144 parsoid=wt2html,html2html
26145 !! wikitext
26146 =
26147 ==
26148 ===
26149 ====
26150 =====
26151 !! html/php
26152 <p>=
26153 ==
26154 </p>
26155 <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>
26156 <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>
26157 <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>
26158
26159 !! html/parsoid
26160 <p>=
26161 ==</p>
26162 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
26163 <h1 id="=="><span id=".3D.3D" typeof="mw:FallbackId"></span>==</h1>
26164 <h2 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h2>
26165 !! end
26166
26167 !! test
26168 Headings: 5. Empty headings
26169 !! options
26170 parsoid=html2wt
26171 !! html/parsoid
26172 <h1 data-parsoid='{}'></h1>
26173
26174 <h2 data-parsoid='{}'></h2>
26175
26176 <h3 data-parsoid='{}'></h3>
26177
26178 <h4 data-parsoid='{}'></h4>
26179
26180 <h5 data-parsoid='{}'></h5>
26181
26182 <h6 data-parsoid='{}'></h6>
26183 !! wikitext
26184 =<nowiki/>=
26185
26186 ==<nowiki/>==
26187
26188 ===<nowiki/>===
26189
26190 ====<nowiki/>====
26191
26192 =====<nowiki/>=====
26193
26194 ======<nowiki/>======
26195 !!end
26196
26197 !! test
26198 Headings: 6a. Heading chars in SOL context (with trailing spaces)
26199 !! options
26200 parsoid=html2wt
26201 !! html/parsoid
26202 <p>=a=</p>
26203
26204 <p>=a=</p>
26205
26206 <p>=a=</p>
26207 !! wikitext
26208 <nowiki>=a=</nowiki>
26209
26210 <nowiki>=a=</nowiki>
26211
26212 <nowiki>=a=</nowiki>
26213 !!end
26214
26215 !! test
26216 Headings: 6b. Heading chars in SOL context (with trailing newlines)
26217 !! options
26218 parsoid=html2wt
26219 !! html/parsoid
26220 <p>=a=
26221 b</p>
26222
26223 <p>=a=
26224 b</p>
26225
26226 <p>=a=
26227 b</p>
26228 !! wikitext
26229 <nowiki>=a=</nowiki>
26230 b
26231
26232 <nowiki>=a=</nowiki>
26233 b
26234
26235 <nowiki>=a=</nowiki>
26236 b
26237 !!end
26238
26239 !! test
26240 Headings: 6c. Heading chars in SOL context (leading newline break)
26241 !! options
26242 parsoid=html2wt
26243 !! html/parsoid
26244 <p>a
26245 =b=</p>
26246 !! wikitext
26247 a
26248 <nowiki>=b=</nowiki>
26249 !!end
26250
26251 !! test
26252 Headings: 6d. Heading chars in SOL context (with interspersed comments)
26253 !! options
26254 parsoid=html2wt
26255 !! html/parsoid
26256 <!--c0--><p>=a=</p>
26257
26258 <!--c1--><p>=a=</p> <!--c2--> <!--c3-->
26259 !! wikitext
26260 <!--c0--><nowiki>=a=</nowiki>
26261
26262 <!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3-->
26263 !!end
26264
26265 !! test
26266 Headings: 6d. Heading chars in SOL context (No escaping needed)
26267 !! options
26268 parsoid=html2wt
26269 !! html/parsoid
26270 =a=<div>b</div>
26271 !! wikitext
26272 =a=<div>b</div>
26273 !!end
26274
26275 !! test
26276 Headings: 7. Insert a newline between new content and headings
26277 !! options
26278 parsoid=html2wt
26279 !! html/parsoid
26280 <h2>NEW</h2>
26281 <p>new</p>
26282 <h2 data-parsoid='{}'>A</h2>
26283 <p data-parsoid='{}'>a</p>
26284 !! wikitext
26285 == NEW ==
26286 new
26287
26288 ==A==
26289 a
26290
26291 !! end
26292
26293 !! test
26294 Headings: Used as horizontal rule
26295 !! config
26296 wgFragmentMode=[ 'html5', 'legacy' ]
26297 !! options
26298 parsoid=wt2html
26299 !! wikitext
26300 ===============
26301 !! html/php
26302 <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>
26303
26304 !! html/parsoid
26305 <h6 id="==="><span id=".3D.3D.3D" typeof="mw:FallbackId"></span>===</h6>
26306 !! end
26307
26308 #### --------------- Lists ---------------
26309 #### 0. Outside nests (*foo, etc.)
26310 #### 1. Nested inside html <ul><li>*foo</li></ul>
26311 #### 2. Inside definition lists
26312 #### 3. Only bullets at start should be escaped
26313 #### 4. No escapes needed
26314 #### 5. No unnecessary escapes
26315 #### 6. Escape bullets in SOL position
26316 #### 7. Escape bullets in a multi-line context
26317 #### ----------------------------------------
26318
26319 !! test
26320 Lists: 0. Outside nests
26321 !! options
26322 parsoid=html2wt
26323 !! html/parsoid
26324 <p>*foo</p>
26325
26326 <p>#foo</p>
26327
26328 <p>;Foo:bar</p>
26329 !! wikitext
26330 <nowiki>*</nowiki>foo
26331
26332 <nowiki>#</nowiki>foo
26333
26334 <nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar
26335 !!end
26336
26337 ## Making these next 3 tests Parsoid-only since they are html2wt tests
26338 ## to test wikitext escaping, and insignificant whitespace diffs
26339 ## cause PHP parser tests to barf
26340 !! test
26341 Lists: 1. Nested inside html (No unnecessary escapes)
26342 !! options
26343 parsoid=html2wt
26344 !! html/parsoid
26345 <ul>
26346 <li>*foo</li>
26347 <li>#foo</li>
26348 <li>:foo</li>
26349 <li>;foo</li>
26350 <li data-parsoid='{}'>*foo</li>
26351 <li data-parsoid='{}'>#foo</li>
26352 <li data-parsoid='{}'>:foo</li>
26353 <li data-parsoid='{}'>;foo</li>
26354 </ul>
26355
26356 <ol>
26357 <li>*foo</li>
26358 <li>#foo</li>
26359 <li>:foo</li>
26360 <li>;foo</li>
26361 <li data-parsoid='{}'>*foo</li>
26362 <li data-parsoid='{}'>#foo</li>
26363 <li data-parsoid='{}'>:foo</li>
26364 <li data-parsoid='{}'>;foo</li>
26365 </ol>
26366 !! wikitext
26367 * *foo
26368 * #foo
26369 * :foo
26370 * ;foo
26371 *<nowiki>*foo</nowiki>
26372 *<nowiki>#foo</nowiki>
26373 *<nowiki>:foo</nowiki>
26374 *<nowiki>;foo</nowiki>
26375
26376 # *foo
26377 # #foo
26378 # :foo
26379 # ;foo
26380 #<nowiki>*foo</nowiki>
26381 #<nowiki>#foo</nowiki>
26382 #<nowiki>:foo</nowiki>
26383 #<nowiki>;foo</nowiki>
26384 !!end
26385
26386 !! test
26387 Lists: 2. Inside definition lists
26388 !! options
26389 parsoid=html2wt
26390 !! html/parsoid
26391 <dl><dt>;foo</dt></dl>
26392 <dl><dt>:foo</dt></dl>
26393 <dl><dt>:foo</dt>
26394 <dd>bar</dd></dl>
26395 <dl><dd>:foo</dd></dl>
26396 !! wikitext
26397 ; ;foo
26398
26399 ; <nowiki>:foo</nowiki>
26400
26401 ; <nowiki>:foo</nowiki>
26402 : bar
26403
26404 : :foo
26405 !!end
26406
26407 !! test
26408 Lists: 3. Only bullets at start of text in wikitext-generated HTML should be escaped
26409 !! options
26410 parsoid=html2wt
26411 !! html/parsoid
26412 <ul>
26413 <li>*foo*bar</li>
26414 <li data-parsoid='{}'>*foo<i>it</i>*bar</li>
26415 </ul>
26416 !! wikitext
26417 * *foo*bar
26418 *<nowiki>*foo</nowiki>''it''*bar
26419 !!end
26420
26421 !! test
26422 Lists: 4. No escapes needed
26423 !! options
26424 parsoid=html2wt
26425 !! html/parsoid
26426 <ul>
26427 <li>foo*bar
26428 </li>
26429 </ul>
26430 <ul>
26431 <li><i>foo</i>*bar
26432 </li>
26433 </ul>
26434 <ul>
26435 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>: bar
26436 </li>
26437 </ul>
26438 <ul>
26439 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar
26440 </li>
26441 </ul>
26442 !! wikitext
26443 *foo*bar
26444
26445 *''foo''*bar
26446
26447 *[[Foo]]: bar
26448
26449 *[[Foo]]*bar
26450 !!end
26451
26452 !! test
26453 Lists: 5. No unnecessary escapes
26454 !! options
26455 parsoid=html2wt
26456 !! html/parsoid
26457 <ul><li> bar <span>[[foo]]</span></li></ul>
26458 <ul><li> =bar <span>[[foo]]</span></li></ul>
26459 <ul><li> [[bar <span>[[foo]]</span></li></ul>
26460 <ul><li> ]]bar <span>[[foo]]</span></li></ul>
26461 <ul><li> =bar <span>foo]]</span>=</li></ul>
26462 <ul><li> <s></s>: a</li></ul>
26463 <ul><li> <i>* foo</i></li></ul>
26464
26465 !! wikitext
26466 * bar <span><nowiki>[[foo]]</nowiki></span>
26467
26468 * =bar <span><nowiki>[[foo]]</nowiki></span>
26469
26470 * [[bar <span><nowiki>[[foo]]</nowiki></span>
26471
26472 * ]]bar <span><nowiki>[[foo]]</nowiki></span>
26473
26474 * =bar <span>foo]]</span>=
26475
26476 * <s></s>: a
26477
26478 * ''* foo''
26479 !!end
26480
26481 !! test
26482 Lists: 6. Escape bullets in SOL position
26483 !! options
26484 parsoid=html2wt
26485 !! html/parsoid
26486 <p><!--cmt-->*foo</p>
26487 !! wikitext
26488 <!--cmt--><nowiki>*</nowiki>foo
26489 !!end
26490
26491 !! test
26492 Lists: 7. Escape bullets in a multi-line context
26493 !! options
26494 parsoid=html2wt
26495 !! html/parsoid
26496 <p>a
26497 *b
26498 </p>
26499 !! wikitext
26500 a
26501 <nowiki>*</nowiki>b
26502 !!end
26503
26504 !! test
26505 Lists: 8. Escape colons only if not present in tags
26506 !! options
26507 parsoid=html2wt
26508 !! html/parsoid
26509 <dl><dt>a:b<i>c:d</i></dt></dl>
26510 !! wikitext
26511 ; <nowiki>a:b</nowiki>''c:d''
26512 !! end
26513
26514 #### --------------- HRs ---------------
26515 #### 1. Single line
26516 #### -----------------------------------
26517
26518 !! test
26519 HRs: 1. Single line
26520 !! options
26521 parsoid=html2wt
26522 !! html/parsoid
26523 <hr />----
26524 <hr />=foo=
26525 <hr />*foo
26526 !! wikitext
26527 ----<nowiki>----</nowiki>
26528 ----=foo=
26529 ----*foo
26530 !! end
26531
26532 #### --------------- Tables ---------------
26533 #### 1a. Simple example
26534 #### 1b. No escaping needed (!foo)
26535 #### 1c. No escaping needed (|foo)
26536 #### 1d. No escaping needed (|}foo)
26537 ####
26538 #### 2a. Nested in td (<td>foo|bar</td>)
26539 #### 2b. Nested in td (<td>foo||bar</td>)
26540 #### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
26541 ####
26542 #### 3a. Nested in th (<th>foo!bar</th>)
26543 #### 3b. Nested in th (<th>foo!!bar</th>)
26544 #### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
26545 ####
26546 #### 4a. Escape -
26547 #### 4b. Escape +
26548 #### 4c. No escaping needed
26549 #### --------------------------------------
26550
26551 !! test
26552 Tables: 1a. Simple example
26553 !! options
26554 parsoid=html2wt
26555 !! html/parsoid
26556 <p>{|
26557 |}
26558 </p>
26559 !! wikitext
26560 <nowiki>{|</nowiki>
26561 |}
26562 !! end
26563
26564 !! test
26565 Tables: 1b. No escaping needed
26566 !! options
26567 parsoid=html2wt
26568 !! html/parsoid
26569 <p>!foo
26570 </p>
26571 !! wikitext
26572 !foo
26573 !! end
26574
26575 !! test
26576 Tables: 1c. No escaping needed
26577 !! options
26578 parsoid=html2wt
26579 !! html/parsoid
26580 <p>|foo
26581 </p>
26582 !! wikitext
26583 |foo
26584 !! end
26585
26586 !! test
26587 Tables: 1d. No escaping needed
26588 !! options
26589 parsoid=html2wt
26590 !! html/parsoid
26591 <p>|}foo
26592 </p>
26593 !! wikitext
26594 |}foo
26595 !! end
26596
26597 !! test
26598 Tables: 2a. Nested in td
26599 !! options
26600 parsoid=html2wt
26601 !! html/parsoid
26602 <table><tbody><tr>
26603 <td>foo|bar</td></tr>
26604 <tr><td>x<div>a|b</div></td>
26605 </tbody></table>
26606 !! wikitext
26607 {|
26608 |<nowiki>foo|bar</nowiki>
26609 |-
26610 |x<div><nowiki>a|b</nowiki></div>
26611 |}
26612 !! html/php+tidy
26613 <table>
26614 <tbody><tr>
26615 <td>foo|bar
26616 </td></tr>
26617 <tr>
26618 <td>x<div>a|b</div>
26619 </td></tr></tbody></table>
26620 !! end
26621
26622 !! test
26623 Tables: 2b. Nested in td
26624 !! options
26625 parsoid=html2wt
26626 !! html/parsoid
26627 <table><tbody><tr>
26628 <td>foo||bar</td>
26629 <td>a<i>b||c</i></td>
26630 <td>a<i><div>b||c</div></i></td>
26631 </tr></tbody></table>
26632 !! wikitext
26633 {|
26634 |<nowiki>foo||bar</nowiki>
26635 |a''<nowiki>b||c</nowiki>''
26636 |a''<div><nowiki>b||c</nowiki></div>''
26637 |}
26638 !! html/php
26639 <table>
26640 <tr>
26641 <td>foo||bar
26642 </td>
26643 <td>a<i>b||c</i>
26644 </td>
26645 <td>a<i><div>b||c</div></i>
26646 </td></tr></table>
26647
26648 !! end
26649
26650 !! test
26651 Tables: 2c. Nested in td -- no escaping needed
26652 !! options
26653 parsoid=html2wt
26654 !! html/*
26655 <table>
26656 <tr>
26657 <td>foo!!bar
26658 </td></tr></table>
26659
26660 !! wikitext
26661 {|
26662 |foo!!bar
26663 |}
26664 !! end
26665
26666 !! test
26667 Tables: 3a. Nested in th
26668 !! options
26669 parsoid=html2wt
26670 !! html/*
26671 <table>
26672 <tr>
26673 <th>foo!bar
26674 </th></tr></table>
26675
26676 !! wikitext
26677 {|
26678 !foo!bar
26679 |}
26680 !! end
26681
26682 !! test
26683 Tables: 3b. Nested in th
26684 !! options
26685 parsoid=html2wt
26686 !! html/parsoid
26687 <table><tbody>
26688 <tr><th>foo!!bar</th>
26689 <th><i>foo|bar</i></th>
26690 <th><i>foo!!bar</i></th>
26691 <th><i><span>foo!!bar</span></i></th>
26692 </tr></tbody></table>
26693 !! wikitext
26694 {|
26695 !<nowiki>foo!!bar</nowiki>
26696 !''<nowiki>foo|bar</nowiki>''
26697 !''<nowiki>foo!!bar</nowiki>''
26698 !''<span><nowiki>foo!!bar</nowiki></span>''
26699 |}
26700 !! html/php
26701 <table>
26702 <tr>
26703 <th>foo!!bar
26704 </th>
26705 <th><i>foo|bar</i>
26706 </th>
26707 <th><i>foo!!bar</i>
26708 </th>
26709 <th><i><span>foo!!bar</span></i>
26710 </th></tr></table>
26711
26712 !! end
26713
26714 !! test
26715 Tables: 3c. Nested in th
26716 !! options
26717 parsoid=html2wt
26718 !! html/parsoid
26719 <table><tbody>
26720 <tr><th>foo||bar</th>
26721 <th><span typeof="mw:Nowiki">foo||bar</span></th>
26722 </tr></tbody></table>
26723 !! wikitext
26724 {|
26725 !<nowiki>foo||bar</nowiki>
26726 !<nowiki>foo||bar</nowiki>
26727 |}
26728 !! html/php
26729 <table>
26730 <tr>
26731 <th>foo||bar
26732 </th>
26733 <th>foo||bar
26734 </th></tr></table>
26735
26736 !! end
26737
26738 !! test
26739 Tables: 4a. Escape -
26740 !! options
26741 parsoid=html2wt
26742 !! html/*
26743 <table>
26744 <tr>
26745 <th>-bar
26746 </th></tr>
26747 <tr>
26748 <td>-bar
26749 </td></tr></table>
26750
26751 !! wikitext
26752 {|
26753 !-bar
26754 |-
26755 |<nowiki>-bar</nowiki>
26756 |}
26757 !! end
26758
26759 !! test
26760 Tables: 4b. Escape +
26761 !! options
26762 parsoid=html2wt
26763 !! html/*
26764 <table>
26765 <tr>
26766 <th>+bar
26767 </th></tr>
26768 <tr>
26769 <td>+bar
26770 </td></tr></table>
26771
26772 !! wikitext
26773 {|
26774 !+bar
26775 |-
26776 |<nowiki>+bar</nowiki>
26777 |}
26778 !! end
26779
26780 !! test
26781 Tables: 4c. No escaping needed
26782 !! options
26783 parsoid=html2wt
26784 !! html/parsoid
26785 <table><tbody>
26786 <tr><td>foo-bar</td><td>foo+bar</td></tr>
26787 <tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
26788 <tr><td>foo
26789 <p>bar|baz
26790 +bar
26791 -bar</p></td></tr>
26792 <tr><td>x
26793 <div>a|b</div></td>
26794 </tbody></table>
26795 !! wikitext
26796 {|
26797 |foo-bar
26798 |foo+bar
26799 |-
26800 |''foo''-bar
26801 |''foo''+bar
26802 |-
26803 |foo
26804 bar|baz
26805 +bar
26806 -bar
26807 |-
26808 |x
26809 <div>a|b</div>
26810 |}
26811 !! html/php
26812 <table>
26813 <tr>
26814 <td>foo-bar
26815 </td>
26816 <td>foo+bar
26817 </td></tr>
26818 <tr>
26819 <td><i>foo</i>-bar
26820 </td>
26821 <td><i>foo</i>+bar
26822 </td></tr>
26823 <tr>
26824 <td>foo
26825 <p>bar|baz
26826 +bar
26827 -bar
26828 </p>
26829 </td></tr>
26830 <tr>
26831 <td>x
26832 <div>a|b</div>
26833 </td></tr></table>
26834
26835 !! end
26836
26837 !! test
26838 Tables: 4d. No escaping needed
26839 !! options
26840 parsoid=html2wt
26841 !! html/parsoid
26842 <table>
26843 <tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
26844 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
26845 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
26846 </tbody></table>
26847 !! wikitext
26848 {|
26849 |[[Foo]]-bar
26850 ||+1
26851 ||-2
26852 |}
26853 !! html/php
26854 <table>
26855 <tr>
26856 <td><a href="/wiki/Foo" title="Foo">Foo</a>-bar
26857 </td>
26858 <td>+1
26859 </td>
26860 <td>-2
26861 </td></tr></table>
26862
26863 !! end
26864
26865 !! test
26866 Tables: 4e. Escape }
26867 !! options
26868 parsoid=html2wt
26869 !! html/parsoid
26870 <table>
26871 <tr><td>}</td></tr>
26872 <tr><td>x</td><td data-parsoid='{"stx":"row"}'>}</td></tr></table>
26873 </table>
26874 !! wikitext
26875 {|
26876 |<nowiki>}</nowiki>
26877 |-
26878 |x||}
26879 |}
26880 !! html/php
26881 <table>
26882 <tr>
26883 <td>}
26884 </td></tr>
26885 <tr>
26886 <td>x</td>
26887 <td>}
26888 </td></tr></table>
26889
26890 !! end
26891
26892 !! test
26893 Tables: 5. Empty table cells should get whitespace to avoid need for nowikis
26894 !! options
26895 parsoid=html2wt
26896 !! html/parsoid
26897 <table><tr><td></td><td align="center" data-parsoid='{"stx":"row"}'></td><td data-parsoid='{"stx":"row"}'></td></tr></table>
26898
26899 <table><tr><td></td><td align="center"></td><td></td></tr></table>
26900
26901 <table><tr><td></td><td align="center" data-parsoid='{"stx":"row", "startTagSrc":"{{!}}{{!}}"}'></td><td data-parsoid='{"stx":"row"}'></td></tr></table>
26902
26903 <table><tr><th></th><th align="center" data-parsoid='{"stx":"row"}'></th><th data-parsoid='{"stx":"row"}'></th></tr></table>
26904 !! wikitext
26905 {|
26906 | || align="center" | ||
26907 |}
26908
26909 {|
26910 |
26911 | align="center" |
26912 |
26913 |}
26914
26915 {|
26916 | {{!}}{{!}} align="center" | ||
26917 |}
26918
26919 {|
26920 ! !! align="center" | !!
26921 |}
26922 !! html/php+tidy
26923 <table>
26924 <tbody><tr>
26925 <td></td>
26926 <td align="center"></td>
26927 <td>
26928 </td></tr></tbody></table>
26929 <table>
26930 <tbody><tr>
26931 <td>
26932 </td>
26933 <td align="center">
26934 </td>
26935 <td>
26936 </td></tr></tbody></table>
26937 <table>
26938 <tbody><tr>
26939 <td></td>
26940 <td align="center"></td>
26941 <td>
26942 </td></tr></tbody></table>
26943 <table>
26944 <tbody><tr>
26945 <th></th>
26946 <th align="center"></th>
26947 <th>
26948 </th></tr></tbody></table>
26949 !! end
26950
26951 !! test
26952 T97430: Don't emit empty nowiki pairs around marker meta tags
26953 !! options
26954 parsoid=html2wt
26955 !! html/parsoid
26956 <p>*This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
26957 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
26958 !! wikitext
26959 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
26960 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
26961 !! end
26962
26963 !! test
26964 Unclosed xmlish element in table line shouldn't eat end delimiters
26965 !! options
26966 parsoid=html2wt
26967 !! html/parsoid
26968 <table>
26969 <tbody><tr><td> &lt;foo</td>
26970 <td> bar></td></tr>
26971 </tbody></table>
26972 !! wikitext
26973 {|
26974 | <foo
26975 | bar>
26976 |}
26977 !! html/php
26978 <table>
26979 <tr>
26980 <td>&lt;foo
26981 </td>
26982 <td>bar&gt;
26983 </td></tr></table>
26984
26985 !! end
26986
26987 #### --------------- Links ----------------
26988 #### 1. Quote marks in link text
26989 #### 2. Wikilinks: Escapes needed
26990 #### 3. Wikilinks: No escapes needed
26991 #### 4. Extlinks: Escapes needed
26992 #### 5. Extlinks: No escapes needed
26993 #### --------------------------------------
26994 !! test
26995 Links 1. WikiLinks: No escapes needed
26996 !! options
26997 parsoid=html2wt
26998 !! html/parsoid
26999 <p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
27000 <a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
27001 <a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
27002 !! wikitext
27003 [[Foo|Foo''boo'']]
27004 [[Foo|[Foobar]]]
27005 [[Foo|x [Foobar] x]]
27006 !! html/php
27007 <p><a href="/wiki/Foo" title="Foo">Foo<i>boo</i></a>
27008 <a href="/wiki/Foo" title="Foo">[Foobar]</a>
27009 <a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
27010 </p>
27011 !! end
27012
27013 !! test
27014 Links 2. WikiLinks: Escapes needed
27015 !! options
27016 parsoid=html2wt
27017 !! html/parsoid
27018 <a href="Foo" rel="mw:WikiLink">Foobar]</a>
27019 <a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
27020 <a href="Foo" rel="mw:WikiLink">[[Bar]]</a>
27021 <a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a>
27022 <a href="Foo" rel="mw:WikiLink">|Bar</a>
27023 <a href="Foo" rel="mw:WikiLink">]]bar</a>
27024 <a href="Foo" rel="mw:WikiLink">[[bar</a>
27025 <a href="Foo" rel="mw:WikiLink">x [[ y</a>
27026 <a href="Foo" rel="mw:WikiLink">x ]] y</a>
27027 <a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a>
27028 !! wikitext
27029 [[Foo|<nowiki>Foobar]</nowiki>]]
27030 [[Foo|x <nowiki>[http://google.com g]</nowiki> x]]
27031 [[Foo|<nowiki>[[Bar]]</nowiki>]]
27032 [[Foo|<nowiki>x [[Bar]] x</nowiki>]]
27033 [[Foo|<nowiki>|Bar</nowiki>]]
27034 [[Foo|<nowiki>]]bar</nowiki>]]
27035 [[Foo|<nowiki>[[bar</nowiki>]]
27036 [[Foo|<nowiki>x [[ y</nowiki>]]
27037 [[Foo|<nowiki>x ]] y</nowiki>]]
27038 [[Foo|<nowiki>x ]] y [[ z</nowiki>]]
27039 !! html/php
27040 <p><a href="/wiki/Foo" title="Foo">Foobar]</a>
27041 <a href="/wiki/Foo" title="Foo">x [http://google.com g] x</a>
27042 <a href="/wiki/Foo" title="Foo">[[Bar]]</a>
27043 <a href="/wiki/Foo" title="Foo">x [[Bar]] x</a>
27044 <a href="/wiki/Foo" title="Foo">|Bar</a>
27045 <a href="/wiki/Foo" title="Foo">]]bar</a>
27046 <a href="/wiki/Foo" title="Foo">[[bar</a>
27047 <a href="/wiki/Foo" title="Foo">x [[ y</a>
27048 <a href="/wiki/Foo" title="Foo">x ]] y</a>
27049 <a href="/wiki/Foo" title="Foo">x ]] y [[ z</a>
27050 </p>
27051 !! end
27052
27053 !! test
27054 Links 3. WikiLinks: No escapes needed
27055 !! options
27056 parsoid=html2wt
27057 !! html/parsoid
27058 <p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
27059 <a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
27060 !! wikitext
27061 [[Foo|[Foobar]]
27062 [[Foo|foo|bar]]
27063 !! html/php
27064 <p><a href="/wiki/Foo" title="Foo">[Foobar</a>
27065 <a href="/wiki/Foo" title="Foo">foo|bar</a>
27066 </p>
27067 !! end
27068
27069 !! test
27070 Links 4. ExtLinks: Escapes needed
27071 !! options
27072 parsoid=html2wt
27073 !! html/parsoid
27074 <p><a rel="mw:ExtLink" href="http://google.com">[google]</a>
27075 <a rel="mw:ExtLink" href="http://google.com">google]</a>
27076 <a rel="mw:ExtLink" href="http://google.com">goog] le</a></p>
27077 <p>[http://google.com]</p>
27078 <p>[http://google.com google]</p>
27079 <p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p>
27080 <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>
27081 !! wikitext
27082 [http://google.com <nowiki>[google]</nowiki>]
27083 [http://google.com <nowiki>google]</nowiki>]
27084 [http://google.com <nowiki>goog] le</nowiki>]
27085
27086 <nowiki>[http://google.com]</nowiki>
27087
27088 <nowiki>[http://google.com google]</nowiki>
27089
27090 [http://google.com<nowiki>]</nowiki>
27091
27092 [{{echo|http://google.com}}<nowiki>]</nowiki>
27093 !! html/php
27094 <p><a rel="nofollow" class="external text" href="http://google.com">[google]</a>
27095 <a rel="nofollow" class="external text" href="http://google.com">google]</a>
27096 <a rel="nofollow" class="external text" href="http://google.com">goog] le</a>
27097 </p><p>[http://google.com]
27098 </p><p>[http://google.com google]
27099 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
27100 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
27101 </p>
27102 !! end
27103
27104 !! test
27105 Links 5. ExtLinks: No escapes needed
27106 !! options
27107 parsoid=html2wt
27108 !! html/parsoid
27109 <p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
27110 <p>[<a ref="mw:ExtLink" href="http://google.com"></a>]</p>
27111 !! wikitext
27112 [http://google.com [google]
27113
27114 [[http://google.com]]
27115 !! html/php
27116 <p><a rel="nofollow" class="external text" href="http://google.com">[google</a>
27117 </p><p>[<a rel="nofollow" class="external autonumber" href="http://google.com">[1]</a>]
27118 </p>
27119 !! end
27120
27121 !! test
27122 Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300)
27123 !! options
27124 parsoid=html2wt
27125 !! html/parsoid
27126 <p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y
27127 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>?x
27128 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>&amp;x
27129 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>'x
27130 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,x
27131 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.x
27132 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
27133 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>:x
27134 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
27135 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>!x
27136 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>=x
27137 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>(x)
27138 <a rel="mw:ExtLink" href="http://example.com(x" data-parsoid='{"stx":"url"}'>http://example.com(x</a>)
27139 </p>
27140 !! wikitext
27141 x<nowiki/>http://example.com<nowiki/>y
27142 http://example.com<nowiki/>?x
27143 http://example.com<nowiki/>&x
27144 http://example.com<nowiki/>'x
27145 http://example.com<nowiki/>,x
27146 http://example.com<nowiki/>.x
27147 http://example.com<nowiki/>;x
27148 http://example.com<nowiki/>:x
27149 http://example.com<nowiki/>;x
27150 http://example.com<nowiki/>!x
27151 http://example.com<nowiki/>=x
27152 http://example.com<nowiki/>(x)
27153 http://example.com(x<nowiki/>)
27154 !! end
27155
27156 !! test
27157 Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
27158 !! options
27159 parsoid=html2wt
27160 !! html/parsoid
27161 <p>x
27162 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>
27163 y
27164 "<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>"
27165 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>)
27166 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>) foo
27167 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,
27168 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, foo
27169 </p>
27170 !! wikitext
27171 x
27172 http://example.com
27173 y
27174 "http://example.com"
27175 (http://example.com)
27176 (http://example.com) foo
27177 http://example.com,
27178 http://example.com, foo
27179 !! html/php
27180 <p>x
27181 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
27182 y
27183 "<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>"
27184 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
27185 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) foo
27186 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
27187 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, foo
27188 </p>
27189 !! end
27190
27191 !! test
27192 Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
27193 !! options
27194 parsoid=html2wt
27195 !! html/parsoid
27196 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\
27197 -<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p>
27198 !! wikitext
27199 http://example.com.,;:!?\
27200 -http://example.com:
27201 !! html/php
27202 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.,;:!?\
27203 -<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
27204 </p>
27205 !! end
27206
27207 !! test
27208 Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
27209 !! options
27210 parsoid=html2wt
27211 !! html/parsoid
27212 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
27213 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
27214 X<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
27215 !! wikitext
27216 RFC 123<nowiki/>4
27217 RFC 123<nowiki/>y
27218 X<nowiki/>RFC 123<nowiki/>y
27219 !! end
27220
27221 !! test
27222 Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
27223 !! options
27224 parsoid=html2wt
27225 !! html/parsoid
27226 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
27227 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
27228 -<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
27229 </p>
27230 !! wikitext
27231 RFC 123?foo
27232 RFC 123&foo
27233 -RFC 123-
27234 !! html/php
27235 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>?foo
27236 <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
27237 -<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>-
27238 </p>
27239 !! end
27240
27241 !! test
27242 Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300)
27243 !! options
27244 parsoid=html2wt
27245 !! html/parsoid
27246 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4
27247 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
27248 X<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
27249 !! wikitext
27250 PMID 123<nowiki/>4
27251 PMID 123<nowiki/>y
27252 X<nowiki/>PMID 123<nowiki/>y
27253 !! end
27254
27255 !! test
27256 Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300)
27257 !! options
27258 parsoid=html2wt
27259 !! html/parsoid
27260 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo
27261 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo
27262 -<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>-
27263 </p>
27264 !! wikitext
27265 PMID 123?foo
27266 PMID 123&foo
27267 -PMID 123-
27268 !! html/php
27269 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>?foo
27270 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>&amp;foo
27271 -<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>-
27272 </p>
27273 !! end
27274
27275 !! test
27276 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300)
27277 !! options
27278 parsoid=html2wt
27279 !! html/parsoid
27280 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
27281 <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
27282 a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
27283 </p>
27284 !! wikitext
27285 ISBN 1234567890<nowiki/>1
27286 ISBN 1234567890<nowiki/>x
27287 a<nowiki/>ISBN 1234567890<nowiki/>b
27288 !! end
27289
27290 !! test
27291 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (T66300)
27292 !! options
27293 parsoid=html2wt
27294 !! html/parsoid
27295 <p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
27296 !! wikitext
27297 -ISBN 1234567890's
27298 !! html/php
27299 <p>-<a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>'s
27300 </p>
27301 !! end
27302
27303 !! test
27304 Links 14. Protect link-like plain text. (Parsoid bug T78425)
27305 !! options
27306 parsoid=html2wt
27307 !! html/*
27308 <p>this is not a link: http://example.com
27309 </p>
27310 !! wikitext
27311 this is not a link: <nowiki>http://example.com</nowiki>
27312 !! end
27313
27314 !! test
27315 Links 15. Link trails can't become link prefixes.
27316 !! options
27317 language=is
27318 parsoid=html2wt
27319 !! html/parsoid
27320 <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>
27321 !! wikitext
27322 [[Söfnuður]]-[[00]]
27323 !! html/php
27324 <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>
27325 </p>
27326 !! end
27327
27328 #### --------------- Quotes ---------------
27329 #### 1. Quotes inside <b> and <i>
27330 #### 2. Link fragments separated by <i> and <b> tags
27331 #### 3. Link fragments inside <i> and <b>
27332 #### 4. No escaping needed
27333 #### --------------------------------------
27334 !! test
27335 1a. Quotes inside <b> and <i>
27336 !! options
27337 parsoid=html2wt
27338 !! html/*
27339 <p><i>'foo'</i>
27340 <i>''foo''</i>
27341 <i>'''foo'''</i>
27342 <i>foo</i>'s
27343 <b>'foo'</b>
27344 <b>''foo''</b>
27345 <b>'''foo'''</b>
27346 <b>foo'<i>bar'</i>baz</b>
27347 <b>foo</b>'s
27348 '<i>foo</i>
27349 <i>foo</i>'
27350 <i>foo'</i>'
27351 '<i>foo</i>'
27352 '<b>foo</b>
27353 <b>foo</b>'
27354 '<b>foo</b>'
27355 <i>fools'<span> errand</span></i>
27356 <i><span>fool</span>'s errand</i>
27357 '<i>foo</i> bar '<i>baz</i>
27358 a|!*#-:;+-~[]{}b'<i>x</i>
27359 </p>
27360 !! wikitext
27361 ''<nowiki/>'foo'''
27362 ''<nowiki>''foo''</nowiki>''
27363 ''<nowiki>'''foo'''</nowiki>''
27364 ''foo''<nowiki/>'s
27365 '''<nowiki/>'foo''''
27366 '''<nowiki>''foo''</nowiki>'''
27367 '''<nowiki>'''foo'''</nowiki>'''
27368 '''foo'<nowiki/>''bar'<nowiki/>''baz'''
27369 '''foo'''<nowiki/>'s
27370 '''foo''
27371 ''foo''<nowiki/>'
27372 ''foo'''<nowiki/>'
27373 '''foo''<nowiki/>'
27374 ''''foo'''
27375 '''foo'''<nowiki/>'
27376 ''''foo'''<nowiki/>'
27377 ''fools'<span> errand</span>''
27378 ''<span>fool</span>'s errand''
27379 '<nowiki/>''foo'' bar '''baz''
27380 a|!*#-:;+-~[]{}b'''x''
27381 !! end
27382
27383 !! test
27384 1b. Quotes inside <b> and <i> with other tags on same line
27385 !! options
27386 parsoid=html2wt
27387 !! html/parsoid
27388 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
27389 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
27390 <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>
27391 <a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" rel="mw:WikiLink" title="Bar">bar</a></i>
27392 '<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>
27393 '<i>foo</i> <div title="name">test</div>
27394 '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
27395 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
27396 <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>
27397 </ol>
27398 !! wikitext
27399 '''a'' foo ''[[bar]]''
27400 ''a''' foo ''[[bar]]''
27401 ''a''' foo '''{{echo|[[bar]]}}'''
27402 [[foo]] x'''[[bar]]''
27403 '''foo'' <ref>test</ref>
27404 '''foo'' <div title="name">test</div>
27405 '''foo'' and <br> bar
27406 <references />
27407 !! end
27408
27409 !! test
27410 2. Link fragments separated by <i> and <b> tags
27411 !! options
27412 parsoid=html2wt
27413 !! html/parsoid
27414 <p>[[<i>foo</i>hello]]</p>
27415 <p>[[<b>foo</b>hello]]</p>
27416 !! wikitext
27417 [[''foo''<nowiki>hello]]</nowiki>
27418
27419 [['''foo'''<nowiki>hello]]</nowiki>
27420 !! end
27421
27422 # FIXME: Escaping one or both of [[ and ]] is also acceptable --
27423 # this is one of the shortcomings of this format
27424 !! test
27425 3. Link fragments inside <i> and <b>
27426 !! options
27427 parsoid=html2wt
27428 !! html/parsoid
27429 <p><i>[[foo</i>]]</p>
27430 <p><b>[[foo</b>]]</p>
27431 !! wikitext
27432 ''[[foo''<nowiki>]]</nowiki>
27433
27434 '''[[foo'''<nowiki>]]</nowiki>
27435 !! end
27436
27437 !! test
27438 4. No escaping needed
27439 !! options
27440 parsoid=html2wt
27441 !! html/parsoid
27442 <p>'<span><i>bar</i></span>'
27443 '<span><b>bar</b></span>'
27444 'a:b'foo
27445 </p>
27446 !! wikitext
27447 '<span>''bar''</span>'
27448 '<span>'''bar'''</span>'
27449 'a:b'foo
27450 !! end
27451
27452 #### ----------- Paragraphs ---------------
27453 #### 1. No unnecessary escapes
27454 #### --------------------------------------
27455
27456 !! test
27457 1. No unnecessary escapes
27458 !! options
27459 parsoid=html2wt
27460 !! html/parsoid
27461 <p>bar <span>[[foo]]</span>
27462 </p><p>=bar <span>[[foo]]</span>
27463 </p><p>[[bar <span>[[foo]]</span>
27464 </p><p>]]bar <span>[[foo]]</span>
27465 </p><p>=bar <span>foo]]</span>=
27466 </p>
27467 !! wikitext
27468 bar <span><nowiki>[[foo]]</nowiki></span>
27469
27470 =bar <span><nowiki>[[foo]]</nowiki></span>
27471
27472 [[bar <span><nowiki>[[foo]]</nowiki></span>
27473
27474 ]]bar <span><nowiki>[[foo]]</nowiki></span>
27475
27476 =bar <span>foo]]</span><nowiki>=</nowiki>
27477 !!end
27478
27479 #### ----------------------- PRE --------------------------
27480 !! test
27481 1. Leading whitespace in SOL context should be escaped
27482 !! options
27483 parsoid=html2wt
27484 !! html/parsoid
27485 <p> a</p>
27486
27487 <p> a</p>
27488
27489 <p> a(tab)</p>
27490
27491 <p> a
27492 <!--cmt-->
27493 a</p>
27494
27495 <p>a
27496 b</p>
27497
27498 <p>a
27499 b</p>
27500
27501 <p>a
27502 b</p>
27503 !! wikitext
27504 <nowiki> </nowiki>a
27505
27506 <nowiki> </nowiki> a
27507
27508 a(tab)
27509
27510 <nowiki> </nowiki> a
27511 <!--cmt-->
27512 <nowiki> </nowiki>a
27513
27514 a
27515 <nowiki> </nowiki>b
27516
27517 a
27518 b
27519
27520 a
27521 b
27522 !! html/php
27523 <p> a
27524 </p><p> a
27525 </p><p> a(tab)
27526 </p><p> a
27527 a
27528 </p><p>a
27529 b
27530 </p><p>a
27531 b
27532 </p><p>a
27533 b
27534 </p>
27535 !! end
27536
27537 !! test
27538 2. Leading whitespace in non-indent-pre contexts should not be escaped
27539 !! options
27540 parsoid=html2wt
27541 !! html/parsoid
27542 <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>
27543 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
27544 <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>
27545 b</span></li>
27546 </ol>
27547 !! wikitext
27548 foo <ref>''a''
27549 b</ref>
27550 <references />
27551 !! end
27552
27553 !! test
27554 3. Leading whitespace in indent-pre suppressing contexts should not be escaped
27555 !! options
27556 parsoid=html2wt
27557 !! html/parsoid
27558 <blockquote>
27559 <p>
27560 a
27561 <span>b</span>
27562 c</p>
27563 </blockquote>
27564 !! wikitext
27565 <blockquote>
27566 a
27567 <span>b</span>
27568 c
27569 </blockquote>
27570 !! end
27571
27572 !! test
27573 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
27574 !! options
27575 parsoid=html2wt
27576 !! html/parsoid
27577 <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>
27578 !! wikitext
27579 [[File:Foobar.jpg|thumb|caption]]
27580 !! end
27581
27582 !! test
27583 5. Nowiki escaping should account for indent-pres
27584 !! options
27585 parsoid=html2wt
27586 !! html/parsoid
27587 <pre>==foo==</pre>
27588 !! wikitext
27589 ==foo==
27590 !! end
27591
27592 !! test
27593 T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
27594 !! options
27595 parsoid=html2wt
27596 !! html/parsoid
27597 <pre>
27598 * foo
27599 * bar
27600 </pre>
27601 !! wikitext
27602 * foo
27603 * bar
27604 !! end
27605
27606 !! test
27607 Whitespace scrubbing in SOL position should account for SOL-sensitive wikitext markup
27608 !! options
27609 parsoid = {
27610 "modes": ["html2wt"],
27611 "scrubWikitext": true
27612 }
27613 !! html/parsoid
27614 <p> foo</p>
27615 <p> %foo</p>
27616 <p> *foo</p>
27617 <p> #foo</p>
27618 <p> =foo=</p>
27619 <p><link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid="{}"> *foo</p>
27620 <p> <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid="{}">*foo</p>
27621 <p> <!--boo-->*foo</p>
27622 <p><!--boo--> *foo</p>
27623 <p><!--a--> <!--b--> <!--c--> <!--d--> <!--e--> foo</p>
27624 <p><!--a--> <!--b--> <!--c--> <!--d--> <!--e--> *foo</p>
27625 !! wikitext
27626 foo
27627
27628 %foo
27629
27630 <nowiki/>*foo
27631
27632 <nowiki/>#foo
27633
27634 <nowiki/>=foo=
27635
27636 [[Category:Foo]]
27637 <nowiki/>*foo
27638
27639 [[Category:Foo]]
27640 <nowiki>*</nowiki>foo
27641
27642 <nowiki/><!--boo-->*foo
27643
27644 <!--boo--><nowiki/>*foo
27645
27646 <!--a--><!--b--><!--c--><!--d--><!--e-->foo
27647
27648 <!--a--><nowiki/><!--b--><!--c--><!--d--><!--e-->*foo
27649 !! end
27650
27651 #### --------------- Behavior Switches --------------------
27652
27653 !! test
27654 1. Valid behavior switches should be escaped
27655 !! options
27656 parsoid=html2wt
27657 !! html/parsoid
27658 __TOC__
27659 <i>__TOC__</i>
27660 !! wikitext
27661 <nowiki>__TOC__</nowiki>
27662 ''<nowiki>__TOC__</nowiki>''
27663 !! end
27664
27665 !! test
27666 2. Invalid behavior switches should not be escaped
27667 !! options
27668 parsoid=html2wt
27669 !! html/parsoid
27670 __TOO__
27671 __|__
27672 !! wikitext
27673 __TOO__
27674 __|__
27675 !! end
27676
27677 # We use indent-pre as an indirect way to test for sol-transparent behavior.
27678 !! test
27679 Behavior switches should be SOL-transparent
27680 !! options
27681 parsoid=html2wt
27682 !! html/parsoid
27683 <meta property="mw:PageProp/toc" />
27684
27685 <!-- this one's bogus -->
27686 <pre>__TOO__</pre>
27687
27688 <pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre>
27689
27690 <meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre>
27691 !! wikitext
27692 __TOC__
27693
27694 <!-- this one's bogus -->
27695 __TOO__
27696
27697 __TOC__ foo
27698
27699 __TOC__
27700 bar
27701 !! end
27702
27703 #### --------------- HTML tags ---------------
27704 #### 1. a tags
27705 #### 2. other tags
27706 #### 3. multi-line html tag
27707 #### 4. extension tags
27708 #### -----------------------------------------
27709 !! test
27710 1. a tags
27711 !! options
27712 parsoid=html2wt
27713 !! html/parsoid
27714 &lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
27715 !! wikitext
27716 <a href="http://google.com">google</a>
27717 !! end
27718
27719 !! test
27720 2. other tags
27721 !! options
27722 parsoid=html2wt
27723 !! html/parsoid
27724 <ul><li> &lt;div&gt;foo&lt;/div&gt;</li>
27725 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
27726 <li> &lt;td&gt;</li></ul>
27727
27728 !! wikitext
27729 * <nowiki><div>foo</div></nowiki>
27730 * <nowiki><div style="color:red">foo</div></nowiki>
27731 * <nowiki><td></nowiki>
27732 !! end
27733
27734 !! test
27735 3. multi-line html tag
27736 !! options
27737 parsoid=html2wt
27738 !! html/parsoid
27739 <p>&lt;div
27740 &gt;foo&lt;/div
27741 &gt;
27742 </p>
27743 !! wikitext
27744 <nowiki><div
27745 >foo</div
27746 ></nowiki>
27747 !! end
27748
27749 !! test
27750 4. extension tags
27751 !! options
27752 parsoid=html2wt
27753 !! html/parsoid
27754 <p>&lt;ref&gt;foo&lt;/ref&gt;
27755 </p><p>&lt;ref&gt;bar
27756 </p><p>baz&lt;/ref&gt;
27757 </p>
27758 !! wikitext
27759 <nowiki><ref>foo</ref></nowiki>
27760
27761 <nowiki><ref>bar</nowiki>
27762
27763 baz<nowiki></ref></nowiki>
27764 !! end
27765
27766 !! test
27767 Parsoid: newline inducing block nodes don't suppress <nowiki>
27768 !! options
27769 parsoid=html2wt
27770 !! html/parsoid
27771 a<h1>foo</h1>
27772 !! wikitext
27773 <nowiki> </nowiki>a
27774
27775 = foo =
27776 !! end
27777
27778 #### --------------- Others ---------------
27779 !! test
27780 Escaping nowikis
27781 !! options
27782 parsoid=html2wt
27783 !! html/parsoid
27784 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
27785 </p>
27786 !! wikitext
27787 &lt;nowiki&gt;foo&lt;/nowiki&gt;
27788 !! end
27789
27790 ## The quote-char in the input is necessary for triggering the bug
27791 !! test
27792 (T54035) Nowiki-escaping should not get tripped by " :" in text
27793 !! options
27794 parsoid=html2wt
27795 !! html/parsoid
27796 <p>foo's bar :</p>
27797 !! wikitext
27798 foo's bar :
27799 !! end
27800
27801 #----------- End of wikitext escaping tests --------------
27802
27803 !! test
27804
27805 Tag-like HTML structures are passed through as text
27806 !! wikitext
27807 <x y>
27808
27809 <x.y>
27810
27811 <x-y>
27812
27813 1>2
27814
27815 x<y
27816
27817 a>b
27818
27819 1<d e>f
27820 !! html
27821 <p>&lt;x y&gt;
27822 </p><p>&lt;x.y&gt;
27823 </p><p>&lt;x-y&gt;
27824 </p><p>1&gt;2
27825 </p><p>x&lt;y
27826 </p><p>a&gt;b
27827 </p><p>1&lt;d e&gt;f
27828 </p>
27829 !! end
27830
27831 !! test
27832 HTML tag with necessary entities in attributes
27833 !! wikitext
27834 <span title="&amp;amp;">foo</span>
27835 !! html
27836 <p><span title="&amp;amp;">foo</span>
27837 </p>
27838 !! end
27839
27840 !! test
27841 HTML tag with 'unnecessary' entity encoding in attributes
27842 !! wikitext
27843 <span title="&amp;">foo</span>
27844 !! html
27845 <p><span title="&amp;">foo</span>
27846 </p>
27847 !! end
27848
27849 !! test
27850 HTML tag with broken attribute value quoting
27851 !! options
27852 parsoid=wt2html,html2html
27853 !! wikitext
27854 <span title="Hello world>Foo</span>
27855 !! html/php
27856 <p><span title="Hello world">Foo</span>
27857 </p>
27858 !! html/parsoid
27859 <p><span title="Hello world">Foo</span></p>
27860 !! end
27861
27862 !! test
27863 Self-closed tag with broken attribute value quoting
27864 !! options
27865 parsoid=wt2html,html2html
27866 !! wikitext
27867 <div title="Hello world />Foo
27868 !! html/php+tidy
27869 <div title="Hello world"></div><p>Foo
27870 </p>
27871 !! html/parsoid
27872 <div title="Hello world " data-parsoid='{"stx":"html","selfClose":true}'></div><p>Foo</p>
27873 !! end
27874
27875 !! test
27876 Table with broken attribute value quoting
27877 !! options
27878 parsoid=wt2html,html2html
27879 !! wikitext
27880 {|
27881 | title="Hello world|Foo
27882 |}
27883 !! html/php
27884 <table>
27885 <tr>
27886 <td title="Hello world">Foo
27887 </td></tr></table>
27888
27889 !! html/parsoid
27890 <table>
27891 <tr>
27892 <td title="Hello world">Foo
27893 </td></tr></table>
27894
27895 !! end
27896
27897 !! test
27898 Table with broken attribute value quoting on consecutive lines
27899 !! options
27900 parsoid=wt2html,html2html
27901 !! wikitext
27902 {|
27903 | title="Hello world|Foo
27904 | style="color:red|Bar
27905 |}
27906 !! html/php
27907 <table>
27908 <tr>
27909 <td title="Hello world">Foo
27910 </td>
27911 <td style="color:red">Bar
27912 </td></tr></table>
27913
27914 !! html/parsoid
27915 <table><tbody>
27916 <tr>
27917 <td title="Hello world">Foo
27918 </td><td style="color: red">Bar
27919 </td></tr></tbody></table>
27920
27921 !! end
27922
27923 !!test
27924 Accept empty td cell attribute
27925 !! wikitext
27926 {|
27927 | align="center" |foo|| |
27928 |}
27929 !! html
27930 <table>
27931 <tr>
27932 <td align="center">foo</td>
27933 <td>
27934 </td></tr></table>
27935
27936 !!end
27937
27938 !!test
27939 Non-empty attributes in th-cells
27940 !! wikitext
27941 {|
27942 !Foo!! style="color: red" |Bar
27943 |}
27944 !! html
27945 <table>
27946 <tr>
27947 <th>Foo</th>
27948 <th style="color: red">Bar
27949 </th></tr></table>
27950
27951 !!end
27952
27953 !!test
27954 Accept empty attributes in th-cells
27955 !! wikitext
27956 {|
27957 !|foo!!|bar
27958 |}
27959 !! html
27960 <table>
27961 <tr>
27962 <th>foo</th>
27963 <th>bar
27964 </th></tr></table>
27965
27966 !!end
27967
27968 !!test
27969 Empty table rows go away
27970 !! wikitext
27971 {|
27972 |Hello
27973 |there
27974 |- class="foo"
27975 |-
27976 |}
27977 !! html
27978 <table>
27979 <tr>
27980 <td>Hello
27981 </td>
27982 <td>there
27983 </td></tr>
27984
27985 </table>
27986
27987 !! end
27988
27989 ###
27990 ### Parsoid-centric tests for testing RTing of inter-element separators
27991 ### Edge cases not tested by existing parser tests and specific to
27992 ### Parsoid-specific serialization strategies.
27993 ###
27994
27995 !!test
27996 RT-ed inter-element separators should be valid separators
27997 !! wikitext
27998 {|
27999 |- [[foo]]
28000 |}
28001 !! html/php
28002 <table>
28003
28004 </table>
28005
28006 !! html/parsoid
28007 <table>
28008 <tbody><tr class='mw-empty-elt' data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
28009 </tbody></table>
28010 !!end
28011
28012 # Parsoid-only test of a DOM pass
28013 !!test
28014 Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out
28015 !! wikitext
28016 {|
28017 |<small>foo
28018 bar
28019 |}
28020
28021 {|
28022 |<small>foo<small>
28023 |}
28024 !! html/parsoid
28025 <table>
28026 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo
28027 <p>bar</p></small></td></tr>
28028 </tbody></table>
28029
28030 <table>
28031 <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>
28032 </tbody></table>
28033 !!end
28034
28035 # Note that the "style" attribute is really a template parameter here.
28036 # The = would have to be {{=}} if you wanted the literal.
28037 !!test
28038 Empty TD followed by TD with tpl-generated attribute
28039 !! wikitext
28040 {|
28041 |-
28042 |
28043 |{{echo|style='color:red'}}|foo
28044 |}
28045 !! html
28046 <table>
28047
28048 <tr>
28049 <td>
28050 </td>
28051 <td>foo
28052 </td></tr></table>
28053
28054 !!end
28055
28056 !!test
28057 Indented table with an empty td
28058 !! wikitext
28059 {|
28060 |-
28061 |
28062 |foo
28063 |}
28064 !! html
28065 <table>
28066
28067 <tr>
28068 <td>
28069 </td>
28070 <td>foo
28071 </td></tr></table>
28072
28073 !!end
28074
28075 !! test
28076 Indented table with blank lines in between (T85627)
28077 !! wikitext
28078 {|
28079 |foo
28080
28081
28082 |}
28083 !! html/php
28084 <table>
28085 <tr>
28086 <td>foo
28087 <p><br />
28088 </p>
28089 </td></tr></table>
28090
28091 !! html/parsoid
28092 <table>
28093 <tbody><tr><td>foo
28094 <p>
28095 <br /></p></td></tr>
28096 </tbody></table>
28097 !! end
28098
28099 !!test
28100 Indented block & table
28101 !! wikitext
28102 <div>foo</div>
28103 {|
28104 |foo
28105 |}
28106 !! html/php
28107 <div>foo</div>
28108 <table>
28109 <tr>
28110 <td>foo
28111 </td></tr></table>
28112
28113 !! html/parsoid
28114 <div data-parsoid='{"stx":"html"}'>foo</div>
28115 <table><tbody>
28116 <tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>foo</td></tr>
28117 </tbody></table>
28118 !!end
28119
28120 !! test
28121 Indent and comment before table row
28122 !! wikitext
28123 {|
28124 <!--hi-->|-
28125 |there
28126 |}
28127 !! html/php
28128 <table>
28129
28130 <tr>
28131 <td>there
28132 </td></tr></table>
28133
28134 !! html/parsoid
28135 <table>
28136 <!--hi--><tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
28137 <td data-parsoid='{"autoInsertedEnd":true}'> there</td></tr>
28138 </tbody></table>
28139 !! end
28140
28141 # PHP parser omits empty TR
28142 !!test
28143 Empty TR followed by a template-generated TR
28144 !! wikitext
28145 {|
28146 |-
28147 {{echo|<tr><td>foo</td></tr>}}
28148 |}
28149 !! html/php+tidy
28150 <table>
28151
28152 <tbody><tr><td>foo</td></tr>
28153 </tbody></table>
28154 !! html/parsoid
28155 <table>
28156 <tbody>
28157 <tr class='mw-empty-elt'></tr>
28158 <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}}]}'>
28159 <td>foo</td></tr>
28160 </tbody></table>
28161 !!end
28162
28163 ## PHP and parsoid output differ for this; as usual PHP omits empty
28164 ## elements, and since it strips the comments the TR is empty.
28165 !!test
28166 Empty TR followed by mixed-ws-comment line should RT correctly
28167 !! wikitext
28168 {|
28169 |-
28170 <!--c-->
28171 |-
28172 <!--c--> <!--d-->
28173 |}
28174 !! html/php+tidy
28175 <table>
28176
28177
28178 </table>
28179 !! html/parsoid
28180 <table>
28181 <tbody>
28182 <tr class='mw-empty-elt'></tr>
28183 <!--c-->
28184 <tr>
28185 <!--c--> </tr><!--d-->
28186 </tbody></table>
28187
28188 !!end
28189
28190 !!test
28191 Multi-line image caption generated by templates with/without trailing newlines
28192 !! wikitext
28193 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]]
28194 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]]
28195 !! html/parsoid
28196 <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>
28197 <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>
28198 !!end
28199
28200 !! test
28201 New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly
28202 !! options
28203 parsoid=html2wt
28204 !! html/parsoid
28205 <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>
28206
28207 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{}'/><h1>new heading</h1>
28208 !! wikitext
28209 <includeonly>foo</includeonly>
28210 new para
28211
28212 [[Category:Foo]]
28213
28214 = new heading =
28215 !! end
28216
28217 ## PHP emits broken html for this, and since this is primarily
28218 ## a Parsoid serializer test, marking this Parsoid only
28219 !!test
28220 Improperly nested inline or quotes tags with whitespace in between
28221 !! wikitext
28222 <span> <s>x</span> </s>
28223 ''' ''x''' ''
28224 !! html/parsoid
28225 <p><span> <s>x</s></span><s> </s>
28226 <b> <i>x</i></b><i> </i>
28227 </p>
28228 !!end
28229
28230 !!test
28231 Encapsulate protected attributes from wt
28232 !! wikitext
28233 <div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
28234
28235 {| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true"
28236 |ok
28237 |}
28238 !! html/parsoid
28239 <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>
28240
28241 <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">
28242 <tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'>ok</td></tr>
28243 </tbody></table>
28244 !!end
28245
28246 ## Currently the p-wrapper is fragile in how it adds / removes transformations.
28247 ## Having nested or stray pre tags results in the attempt to add duplicates,
28248 ## causing an assertion fail. This test tries to prevent that situation.
28249 !! test
28250 Ensure ParagraphWrapper can deal with stray closing pre tags
28251 !! options
28252 parsoid=wt2html
28253 !! wikitext
28254 plain text</pre>
28255 !! html/parsoid
28256 <p>plain text</p>
28257 !! end
28258
28259 ## Remex doesn't account for fostered content.
28260 !! test
28261 1. Ensure fostered text content is wrapped in element nodes
28262 !! options
28263 parsoid=wt2html
28264 !! wikitext
28265 <table>hi</table><table>ho</table>
28266 !! html/php+tidy
28267 hi<table></table>ho<table></table>
28268 !! html/parsoid
28269 <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>
28270 !! end
28271
28272 ## Remex doesn't account for fostered content.
28273 !! test
28274 2. Ensure fostered text content is wrapped in element nodes (traps regressions around fostered marker on the element getting lost)
28275 !! options
28276 parsoid=wt2html,wt2wt
28277 !! wikitext
28278 <table>
28279 <tr> || ||
28280 <td> a
28281 </table>
28282 !! html/php+tidy
28283 || ||
28284 <table>
28285 <tbody><tr><td> a
28286 </td></tr></tbody></table>
28287 !! html/parsoid
28288 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'> || ||</p>
28289 <table data-parsoid='{"stx":"html"}'>
28290 <tbody><tr data-parsoid='{"stx":"html","autoInsertedEnd":true}'><td data-parsoid='{"stx":"html","autoInsertedEnd":true}'> a
28291 </td></tr></tbody></table>
28292 !! end
28293
28294 ## Remex doesn't account for fostered content.
28295 !! test
28296 Encapsulation properly handles null DSR information from foster box
28297 !! options
28298 parsoid=wt2html,wt2wt
28299 !! wikitext
28300 {{echo|<table>foo<tr><td>bar</td></tr></table>}}
28301 !! html/parsoid
28302 <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>
28303 !! end
28304
28305 ## Remex doesn't account for fostered content.
28306 !! test
28307 1. Encapsulate foster-parented transclusion content
28308 !! options
28309 parsoid=wt2wt,wt2html
28310 !! wikitext
28311 <table>{{echo|foo<tr><td>bar</td></tr>}}</table>
28312 !! html/php+tidy
28313 foo<table><tbody><tr><td>bar</td></tr></tbody></table>
28314 !! html/parsoid
28315 <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>
28316 !! end
28317
28318 !! test
28319 2. Encapsulate foster-parented transclusion content
28320 !! options
28321 parsoid=wt2wt,wt2html
28322 !! wikitext
28323 <table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table>
28324 !! html/parsoid
28325 <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>
28326 <table>
28327 <tbody>
28328 <tr>
28329 <td>bar</td>
28330 </tr>
28331 </tbody>
28332 </table>
28333 !! end
28334
28335 !! test
28336 3. Encapsulate foster-parented transclusion content
28337 !! options
28338 parsoid=wt2wt,wt2html
28339 !! wikitext
28340 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
28341 !! html/parsoid
28342 <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;]}">
28343 <p>foo</p>
28344 </div>
28345 <table>
28346 <tbody>
28347 <tr>
28348 <td>bar</td>
28349 </tr>
28350 </tbody>
28351 </table>
28352 !! end
28353
28354 !! test
28355 4. Encapsulate foster-parented transclusion content
28356 !! options
28357 parsoid=wt2wt,wt2html
28358 !! wikitext
28359 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
28360 !! html/parsoid
28361 <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;]}">
28362 <p>foo</p>
28363 </div>
28364 <table>
28365 <tbody>
28366 <tr>
28367 <td>bar</td>
28368 </tr>
28369 </tbody>
28370 </table>
28371 !! end
28372
28373 ## Remex doesn't account for fostered content.
28374 !! test
28375 5. Encapsulate foster-parented transclusion content
28376 !!options
28377 parsoid=wt2wt,wt2html
28378 !! wikitext
28379 <table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table>
28380 !! html/php+tidy
28381 foo<table><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table>
28382 !! html/parsoid
28383 <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>
28384 !! end
28385
28386 ## Remex doesn't account for fostered content.
28387 !! test
28388 6. Encapsulate foster-parented transclusion content
28389 !! options
28390 parsoid=wt2wt,wt2html
28391 !! wikitext
28392 <table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p>
28393 !! html/php+tidy
28394 foo<table><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table><p>ok</p>
28395 !! html/parsoid
28396 <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>
28397 !! end
28398
28399 !! test
28400 7. Encapsulate foster-parented transclusion content
28401 !!options
28402 parsoid=wt2wt,wt2html
28403 !! wikitext
28404 <table>{{echo|<p>foo</p>}}<td>bar</td></table>
28405 !! html/parsoid
28406 <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>
28407 <table>
28408 <tbody>
28409 <tr>
28410 <td>bar</td>
28411 </tr>
28412 </tbody>
28413 </table>
28414 !! end
28415
28416 ## Remex doesn't account for fostered content.
28417 # Note that the wt is broken on purpose: the = should be {{=}} if you
28418 # don't want it to be a template parameter key.
28419 !! test
28420 8. Encapsulate foster-parented transclusion content
28421 !! options
28422 parsoid=wt2wt,wt2html
28423 !! wikitext
28424 {{echo|a
28425 }}{|{{echo|style='color:red'}}
28426 |-
28427 |b
28428 |}
28429 !! html/php+tidy
28430 <p>a
28431 </p>
28432 <table>
28433
28434 <tbody><tr>
28435 <td>b
28436 </td></tr></tbody></table>
28437 !! html/parsoid
28438 <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">
28439 </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">
28440 <tbody><tr>
28441 <td>b
28442 </td></tr></tbody></table>
28443 !! end
28444
28445 ## Remex doesn't account for fostered content.
28446 !! test
28447 9. Encapsulate foster-parented transclusion content
28448 !!options
28449 parsoid=wt2wt,wt2html
28450 !! wikitext
28451 <table>{{echo|hi</table>hello}}
28452 !! html/php+tidy
28453 hi<table></table><p>hello
28454 </p>
28455 !! html/parsoid
28456 <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>
28457 !! end
28458
28459 !! test
28460 Table in fosterable position
28461 !!options
28462 parsoid=wt2html
28463 !! wikitext
28464 {{OpenTable}}
28465 <div>
28466 {|
28467 |}
28468 </div>
28469 |}
28470 !! html/parsoid
28471 <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">
28472 </span>
28473 <table about="#mwt1" data-parsoid='{"autoInsertedEnd":true}'></table>
28474
28475 <table>
28476 </table>
28477 !! end
28478
28479 # Parsoid only for T66747
28480 !! test
28481 Properly encapsulate empty-content transclusions in fosterable positions
28482 !! wikitext
28483 <table>
28484 {{#if:|
28485 <td>foo</td>
28486 }}
28487 </table>
28488 !! html/parsoid
28489 <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"}]]}'>
28490
28491 </table>
28492 !! end
28493
28494 ## No longer captures its original intention
28495 !! test
28496 Always encapsulate foster box when template range is expanded to table
28497 !! options
28498 disabled
28499 parsoid=wt2wt
28500 !! wikitext
28501 {|
28502 hello
28503 {{OpenTable}}
28504 |}
28505 !! html/parsoid
28506
28507 !! end
28508
28509 !! test
28510 T115289: Unclosed table
28511 !! wikitext
28512 {{echo|<table>}}<!--c-->[[Category:Two]]
28513 !! html/parsoid
28514 <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>
28515 !! end
28516
28517 !! test
28518 T115289: Don't migrate newlines out of tables with fostered content
28519 !! wikitext
28520 <table><td></td>{{echo|<tr>[[Category:One]]}}<!--c-->[[Category:Two]]
28521 !! html/parsoid
28522 <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>
28523 !! end
28524
28525 !! test
28526 T73074: More fostering fun
28527 !! wikitext
28528 <table><td></td>{{echo|<tr>}}<!--c-->[[Category:Two]]
28529 !! html/parsoid
28530 <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>
28531 !! end
28532
28533 !!test
28534 Support <object> element with .data attribute
28535 !!options
28536 parsoid=html2wt
28537 !! html/parsoid
28538 <object data="test.swf"></object>
28539 !! wikitext
28540 <object data="test.swf"></object>
28541 !!end
28542
28543 !! test
28544 Don't block XML namespace declaration
28545 !! wikitext
28546 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span>
28547 !! html/php
28548 <p><span xmlns:dct="http&#58;//purl.org/dc/terms/" property="dct:title">MediaWiki</span>
28549 </p>
28550 !! html/parsoid
28551 <p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p>
28552 !! end
28553
28554 # -----------------------------------------------------------------
28555 # The following section of tests are primarily to spec requirements
28556 # around Parsoid's serialization (old, new, edited content)
28557 #
28558 # All these tests are marked Parsoid html2wt and html2html only
28559 # ----------------------------------------------------------------
28560
28561 !! test
28562 Ignore rel attribute in a-tags during serialization to url-links
28563 !! options
28564 parsoid=html2wt
28565 !! html/parsoid
28566 <a href='http://en.wikipedia.org/wiki/Foobar'>http://en.wikipedia.org/wiki/Foobar</a>
28567 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:ExtLink'>http://en.wikipedia.org/wiki/Foobar</a>
28568 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:WikiLink'>http://en.wikipedia.org/wiki/Foobar</a>
28569 !! wikitext
28570 http://en.wikipedia.org/wiki/Foobar
28571 http://en.wikipedia.org/wiki/Foobar
28572 http://en.wikipedia.org/wiki/Foobar
28573 !! end
28574
28575 # 'mi' is a localinterwiki prefix as well as a language
28576 !! test
28577 Serialize interwiki links pointing to the current wiki as plain wiki links (T67869)
28578 !! options
28579 parsoid=html2wt
28580 !! html/parsoid
28581 <p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p>
28582 !! wikitext
28583 [[Foo]]
28584 !! end
28585
28586 !! test
28587 Parsoid should accept interwiki shortcuts
28588 !! options
28589 parsoid=html2wt
28590 !! html/parsoid
28591 <p><a rel='mw:WikiLink' href='./fr:Foo'>Foo</a>
28592 <a rel='mw:ExtLink' href='./fr:Foo'>Foo</a>
28593 <a href='./fr:Foo'>Foo</a></p>
28594 <p><a rel='mw:WikiLink' href='fr%3AFoo'>Foo</a>
28595 <a rel='mw:ExtLink' href='fr%3AFoo'>Foo</a>
28596 <a href='fr%3AFoo'>Foo</a></p>
28597 <p><a href='FR%3AFoo'>Foo</a>
28598 <a href='./FR:Foo'>Foo</a></p>
28599 !! wikitext
28600 [[:fr:Foo|Foo]]
28601 [[:fr:Foo|Foo]]
28602 [[:fr:Foo|Foo]]
28603
28604 [[:fr:Foo|Foo]]
28605 [[:fr:Foo|Foo]]
28606 [[:fr:Foo|Foo]]
28607
28608 [[:fr:Foo|Foo]]
28609 [[:fr:Foo|Foo]]
28610 !! end
28611
28612 !! test
28613 Parsoid should not accept invalid interwiki shortcuts
28614 !! options
28615 parsoid=html2wt
28616 !! html/parsoid
28617 <p><a rel='mw:WikiLink' href='news:Foo'>Foo</a>
28618 <a rel='mw:ExtLink' href='news:Foo'>Foo</a>
28619 <a href='news:Foo'>Foo</a></p>
28620 !! wikitext
28621 [news:Foo Foo]
28622 [news:Foo Foo]
28623 [news:Foo Foo]
28624 !! end
28625
28626 # See T93839
28627 !! test
28628 New wikilinks should be serialized properly
28629 !! options
28630 parsoid=html2wt
28631 !! html/parsoid
28632 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
28633 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
28634 <a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a>
28635 <a href="http://en.wikipedia.org/wiki/Foo">http://en.wikipedia.org/wiki/Foo</a>
28636 <a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a>
28637 !! wikitext
28638 [[Foo]]
28639 [[Foo]]
28640 [[:en:Foo|//en.wikipedia.org/wiki/Foo]]
28641 http://en.wikipedia.org/wiki/Foo
28642 [[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]]
28643 !! end
28644
28645 !! test
28646 New wiki links (href variations)
28647 !! options
28648 parsoid=html2wt
28649 !! html/parsoid
28650 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
28651 <a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a>
28652 <a rel="mw:WikiLink" href="Foo bar">Foo_bar</a>
28653 <a rel="mw:WikiLink" href="./Toxine_bact%C3%A9rienne">Toxine bactérienne</a>
28654 !! wikitext
28655 [[Foo_bar]]
28656 [[Foo_bar]]
28657 [[Foo_bar]]
28658 [[Toxine bactérienne]]
28659 !! end
28660
28661 !! test
28662 New wiki links (content string variations)
28663 !! options
28664 parsoid=html2wt
28665 !! html/parsoid
28666 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
28667 <a rel="mw:WikiLink" href="./Foo_bar">Foo bar</a>
28668 <a rel="mw:WikiLink" href="./Foo_bar">./Foo_bar</a>
28669 !! wikitext
28670 [[Foo_bar]]
28671 [[Foo bar]]
28672 [[Foo_bar|./Foo_bar]]
28673 !! end
28674
28675 !! test
28676 New category links (href variations)
28677 !! options
28678 parsoid=html2wt
28679 !! html/parsoid
28680 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" />
28681 <link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" />
28682 <link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" />
28683 !! wikitext
28684 [[Category:Toxine bactérienne]]
28685 [[Category:Toxine bactérienne]]
28686 [[Category:Toxine bactérienne]]
28687 !! end
28688
28689 !! test
28690 New sol transparent links don't need indent-pre nowiki protection
28691 !! options
28692 parsoid=html2wt
28693 language=de
28694 !! html/parsoid
28695 <link rel="mw:PageProp/redirect" href="./Main_Page">
28696 <!-- this is good --> <link rel="mw:PageProp/Category" href="./Category:Good" />
28697 <!-- this is great --> <link rel="mw:PageProp/Category" href="./Kategorie:Great" />
28698 !! wikitext
28699 #WEITERLEITUNG [[Main Page]]
28700 <!-- this is good --> [[Category:Good]]
28701 <!-- this is great --> [[Kategorie:Great]]
28702 !! end
28703
28704 !! test
28705 New interlanguage links (href variations)
28706 !! options
28707 parsoid=html2wt
28708 !! html/parsoid
28709 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" />
28710 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" />
28711 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" />
28712 !! wikitext
28713 [[es:Toxine bactérienne]]
28714 [[es:Toxine_bactérienne]]
28715 [[es:Toxine_bactérienne]]
28716 !! end
28717
28718 !! test
28719 Image: Modifying size of an image (1)
28720 !! options
28721 parsoid={
28722 "modes": ["wt2wt"],
28723 "changes": [
28724 ["img[height]", "attr", "height", "22"],
28725 ["img[width]", "attr", "width", "200"]
28726 ]
28727 }
28728 !! wikitext
28729 [[Image:Foobar.jpg|230x230px]]
28730 !! wikitext/edited
28731 [[Image:Foobar.jpg|200x200px]]
28732 !!end
28733
28734 !! test
28735 Image: Modifying size of an image (2)
28736 !! options
28737 parsoid={
28738 "modes": ["wt2wt"],
28739 "changes": [
28740 ["img[height]", "attr", "height", "100"],
28741 ["img[width]", "attr", "width", "500"]
28742 ]
28743 }
28744 !! wikitext
28745 [[Image:Foobar.jpg|230x230px]]
28746 !! wikitext/edited
28747 [[Image:Foobar.jpg|500x500px]]
28748 !!end
28749
28750 # Change in size is ignored so long as class='mw-default-size'
28751 !! test
28752 Image: Modifying size of an image (3)
28753 !! options
28754 parsoid={
28755 "modes": ["wt2wt"],
28756 "changes": [
28757 ["figure[class]", "removeClass", "mw-default-size"],
28758 ["figure img", "attr", "height", "19"],
28759 ["figure img", "attr", "width", "170"]
28760 ]
28761 }
28762 !! wikitext
28763 [[Image:Foobar.jpg|thumb]]
28764 !! wikitext/edited
28765 [[Image:Foobar.jpg|thumb|170x170px]]
28766 !!end
28767
28768 !! test
28769 Image: Modifying alignment of an image (T50665)
28770 !! options
28771 parsoid={
28772 "modes": ["wt2wt"],
28773 "changes": [
28774 ["figure[class]", "removeClass", "mw-halign-right"],
28775 ["figure[class]", "addClass", "mw-halign-left"]
28776 ]
28777 }
28778 !! wikitext
28779 [[Image:Foobar.jpg|thumb|caption|right]]
28780 !! wikitext/edited
28781 [[Image:Foobar.jpg|thumb|caption|left]]
28782 !! end
28783
28784 !! test
28785 Image: Modifying mw-default-size of an frameless image (T64805)
28786 !! options
28787 parsoid={
28788 "modes": ["wt2wt"],
28789 "changes": [
28790 ["figure.mw-default-size", "removeClass", "mw-default-size"]
28791 ]
28792 }
28793 !! wikitext
28794 [[Image:Foobar.jpg|frameless|right]]
28795 !! wikitext/edited
28796 [[Image:Foobar.jpg|frameless|right|220x220px]]
28797 !! end
28798
28799 !! test
28800 Image: Modifying valign of an image (T51221)
28801 !! options
28802 parsoid={
28803 "modes": ["wt2wt"],
28804 "changes": [
28805 ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
28806 ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
28807 ]
28808 }
28809 !! wikitext
28810 [[File:Foobar.jpg|20px|middle]]
28811 !! wikitext/edited
28812 [[File:Foobar.jpg|20px|text-top]]
28813 !! end
28814
28815 !! test
28816 Image: Modifying alt attribute of an image (T58400)
28817 !! options
28818 parsoid={
28819 "modes": ["wt2wt"],
28820 "changes": [
28821 ["img[alt]", "attr", "alt", "some alternate edited text"]
28822 ]
28823 }
28824 !! wikitext
28825 [[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
28826 !! wikitext/edited
28827 [[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
28828 !!end
28829
28830 !! test
28831 Image: Modifying caption of an image
28832 !! options
28833 parsoid={
28834 "modes": ["wt2wt"],
28835 "changes": [
28836 ["figcaption", "text", "new caption"]
28837 ]
28838 }
28839 !! wikitext
28840 [[Image:Foobar.jpg|thumb|original caption]]
28841 !! wikitext/edited
28842 [[Image:Foobar.jpg|thumb|new caption]]
28843 !!end
28844
28845 !! test
28846 Image: empty alt attribute (T50924)
28847 !! wikitext
28848 [[File:Foobar.jpg|thumb|alt=|bar]]
28849 !! html/php+tidy
28850 <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>
28851 !! html/parsoid
28852 <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>
28853 !! end
28854
28855 !! test
28856 Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
28857 !! options
28858 parsoid=html2wt
28859 language=ar
28860 disabled
28861 !! html/parsoid
28862 <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>
28863 !! wikitext
28864 [[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
28865 !! end
28866
28867 !! test
28868 Image: Block level image should have \n before and after
28869 !! wikitext
28870 123
28871 [[File:Foobar.jpg|right|thumb|150x150px]]
28872 456
28873 !! html/parsoid
28874 <p>123</p>
28875 <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>
28876 <p>456</p>
28877 !! end
28878
28879 !! test
28880 Image: New block level image should have \n before and after (existing content)
28881 !! wikitext
28882 123
28883 [[File:Foobar.jpg|right|thumb|150x150px]]
28884 456
28885 !! html/parsoid
28886 <p>123</p>
28887 <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>
28888 <p>456</p>
28889 !! end
28890
28891 !! test
28892 Image: upright option (parsoid)
28893 !! wikitext
28894 [[File:Foobar.jpg|thumb|upright|caption]]
28895 [[File:Foobar.jpg|thumb|upright=0.5|caption]]
28896 [[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]]
28897 !! html/parsoid
28898 <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>
28899 <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>
28900 <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>
28901 !! end
28902
28903 !! test
28904 Image: upright option is ignored on inline and frame images (parsoid)
28905 !! wikitext
28906 [[File:Foobar.jpg|500x500px|upright=0.5|caption]]
28907 !! html/parsoid
28908 <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>
28909 !! end
28910
28911 !! test
28912 Image: in template parameter with empty parameter
28913 !! wikitext
28914 {{echo|[[File:Foobar.jpg|link=]]}}
28915 !! html/parsoid
28916 <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>
28917 !! end
28918
28919 !! test
28920 Image: from basic HTML (1)
28921 !! options
28922 parsoid=html2wt
28923 !! html/parsoid
28924 <span typeof="mw:Image">
28925 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
28926 </span>
28927 !! wikitext
28928 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
28929 !! end
28930
28931 !! test
28932 Image: from basic HTML (2)
28933 !! options
28934 parsoid=html2wt
28935 !! html/parsoid
28936 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
28937 !! wikitext
28938 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
28939 !! end
28940
28941 !! test
28942 Image: from basic HTML (3)
28943 !! options
28944 parsoid=html2wt
28945 !! html/parsoid
28946 <a href="Main"><img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"></a>
28947 !! wikitext
28948 [[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
28949 !! end
28950
28951 !! test
28952 Image: from basic HTML (4)
28953 !! options
28954 parsoid=html2wt
28955 !! html/parsoid
28956 <img src="./File:Foobar.jpg">
28957 !! wikitext
28958 [[File:Foobar.jpg|link=]]
28959 !! end
28960
28961 !! test
28962 Image: Invalid title as link
28963 !! wikitext
28964 [[File:Foobar.jpg|link=<]]
28965 !! html/php
28966 <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>
28967 </p>
28968 !! html/parsoid
28969 <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>
28970 !! end
28971
28972 !! test
28973 Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
28974 !! options
28975 parsoid=html2wt
28976 !! html/parsoid
28977 <ul>
28978 <li><p>foo</p></li>
28979 </ul>
28980 !! wikitext
28981 * foo
28982 !! end
28983
28984 !! test
28985 Lists: Serialize correctly even when list tags has unneeded whitespace between tags
28986 !! options
28987 parsoid=html2wt
28988 !! html/parsoid
28989 <ul> <li>foo</li></ul>
28990 !! wikitext
28991 * foo
28992 !! end
28993
28994 !! test
28995 Don't strip leading whitespace when handling indent-pre suppressing tags
28996 !! options
28997 parsoid=html2wt
28998 !! html/parsoid
28999 <table>
29000 <tr><td> indented row</td></tr>
29001 </table>
29002 <blockquote><p>
29003 <b>This is very bold of you!</b>
29004 </p>
29005 <table><tr><td>
29006 indented cell (no pre-wrapping!)
29007 </td></tr></table>
29008 </blockquote>
29009 <p>foo</p>
29010 <div>bar</div>
29011 !! wikitext
29012 {|
29013 | indented row
29014 |}
29015 <blockquote>
29016 '''This is very bold of you!'''
29017
29018 {|
29019 |
29020 indented cell (no pre-wrapping!)
29021 |}
29022 </blockquote>
29023 foo
29024 <div>bar</div>
29025 !! end
29026
29027 !! test
29028 Nowiki-wrap leading whitespace when handling indent-pre inducing tags
29029 !! options
29030 parsoid=html2wt
29031 !! html/parsoid
29032 <p>foo</p>
29033 <span>bar</span>
29034
29035 <span>foo2
29036 </span>bar2
29037
29038 <div>foo</div>
29039 <span>bar</span>
29040
29041 <div>
29042 <span>foo</span>
29043 </div>
29044 !! wikitext
29045 foo
29046
29047 <span>bar</span>
29048
29049 <span>foo2
29050 <nowiki> </nowiki></span>bar2
29051
29052 <div>foo</div>
29053 <nowiki> </nowiki><span>bar</span>
29054
29055 <div>
29056 <nowiki> </nowiki><span>foo</span>
29057 </div>
29058 !! end
29059
29060 !! test
29061 Lists: Dont insert newlines in a serialized list item.
29062 !! options
29063 parsoid=html2wt
29064 !! html/parsoid
29065 <ul><li>a<br>b</li><li>c</li></ul>
29066 !! wikitext
29067 * a<br />b
29068 * c
29069 !! end
29070
29071 !! test
29072 1. Headings: Force sol-transparent links and behavior switches to serialize before/after
29073 !! options
29074 parsoid={
29075 "modes": ["html2wt"],
29076 "scrubWikitext": false
29077 }
29078 !! html/parsoid
29079 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
29080 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
29081
29082 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
29083 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
29084
29085 <h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2>
29086
29087 <h2><meta property="mw:PageProp/toc" /> ok</h2>
29088 !! wikitext
29089 == hello there [[Category:A1]] ==
29090
29091 == [[Category:A2]] hi pal ==
29092
29093 == <!--foo--> [[Category:A3]] how goes it ==
29094
29095 == it goes well [[Category:A4]] <!--bar--> ==
29096
29097 ==howdy [[Category:A5]]==
29098
29099 == __TOC__ ok ==
29100 !! end
29101
29102 !! test
29103 2. Headings: Force sol-transparent links and behavior switches to serialize before/after
29104 !! options
29105 parsoid={
29106 "modes": ["html2wt"],
29107 "scrubWikitext": true
29108 }
29109 !! html/parsoid
29110 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
29111 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
29112
29113 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
29114 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
29115
29116 <h2><meta property="mw:PageProp/toc" /> ok</h2>
29117 !! wikitext
29118 == hello there ==
29119 [[Category:A1]]
29120 [[Category:A2]]
29121
29122 == hi pal ==
29123
29124 <!--foo-->[[Category:A3]]
29125
29126 == how goes it ==
29127
29128 == it goes well ==
29129 [[Category:A4]] <!--bar-->
29130
29131 __TOC__
29132
29133 == ok ==
29134 !! end
29135
29136 !! test
29137 Headings: Don't hoist metas that come from templates
29138 !! options
29139 parsoid={
29140 "modes": ["html2wt"],
29141 "scrubWikitext": true
29142 }
29143 !! html/parsoid
29144 <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>
29145 !! wikitext
29146 == {{echo|foo [[Category:Foo]]}} ==
29147 !! end
29148
29149 !! test
29150 Headings: Category in ref isn't hoisted
29151 !! options
29152 parsoid={
29153 "modes": ["html2wt"],
29154 "scrubWikitext": true
29155 }
29156 !! html/parsoid
29157 <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>
29158
29159 <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>
29160 !! wikitext
29161 == foo <ref>bar
29162 [[Category:Baz]] </ref> ==
29163
29164 <references />
29165 !! end
29166
29167 !! test
29168 Parsoid: Serialize positional parameters with = in them as named parameter
29169 !! options
29170 parsoid=html2wt
29171 !! html/parsoid
29172 <p about="#mwt1" typeof="mw:Transclusion"
29173 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p>
29174
29175 <p about="#mwt1" typeof="mw:Transclusion"
29176 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p>
29177
29178 <!--Orig params with data-parsoid has heuristics for handling = chars-->
29179 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
29180 <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>
29181 !! wikitext
29182 {{echo|1=f=oo}}
29183
29184 {{echo|1=f=oo|2=bar}}
29185
29186 <!--Orig params with data-parsoid has heuristics for handling = chars-->
29187 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
29188 {{echo|<nowiki>f=oo</nowiki>|bar}}
29189 !! end
29190
29191 !! test
29192 Parsoid: Serialize positional parameters with = in extlink as named parameter
29193 !! options
29194 parsoid=html2wt
29195 !! html/parsoid
29196 <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>
29197 !! wikitext
29198 {{echo|1=http://stuff?is=ok}}
29199 !! end
29200
29201 !! test
29202 Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes
29203 !! options
29204 parsoid=html2wt
29205 !! html/parsoid
29206 <div>a<p>b</p></div>
29207 <div>a
29208 <p>b</p></div>
29209 <div>
29210 a
29211 <p>b</p></div>
29212 !! wikitext
29213 <div>a
29214 b
29215 </div>
29216 <div>a
29217 b
29218 </div>
29219 <div>
29220 a
29221
29222 b
29223 </div>
29224 !! end
29225
29226 !! test
29227 Substrings resembling wikitext in hrefs should not get nowiki escapes
29228 !! options
29229 parsoid=html2wt
29230 !! html/parsoid
29231 <a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a>
29232 !! wikitext
29233 [[Foo''bar''baz]]
29234 !! end
29235
29236 !! test
29237 Enforce single-line context in the serializer
29238 !! options
29239 parsoid=html2wt
29240 !! html/parsoid
29241 <h2>testing
29242 123</h2>
29243
29244 <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">
29245 </span><span about="#mwt1">you</span> </h2>
29246
29247 <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>
29248
29249 <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
29250 there</span></li></ol>
29251
29252 <ul><li>asd
29253 sdf</li></ul>
29254
29255 <ul><li>foo
29256 bar
29257 baz</li>
29258 <li>foo <b>bar</b>
29259 baz</li></ul>
29260
29261 <dl><dt>hi
29262 ho </dt><dd data-parsoid='{"stx":"row"}'> hi
29263 ho</dd></dl>
29264
29265 <dl><dd> <table>
29266 <tbody><tr><td> ha
29267 ha
29268 ha</td></tr>
29269 </tbody></table></dd></dl>
29270 !! wikitext
29271 == testing 123 ==
29272
29273 == hi {{bogus|there
29274 you}} ==
29275
29276 == foo <ref>hello
29277 there</ref> ==
29278
29279 <references />
29280
29281 * asd sdf
29282
29283 * foo bar baz
29284 * foo '''bar''' baz
29285
29286 ; hi ho : hi ho
29287
29288 : {|
29289 | ha
29290 ha
29291 ha
29292 |}
29293 !! end
29294
29295 !! test
29296 Serialize new placeholder space without spans
29297 !! options
29298 parsoid=html2wt
29299 !! html/parsoid
29300 <p>foo<span typeof="mw:Placeholder"> </span>: bar</p>
29301
29302 <p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p>
29303
29304 <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>
29305 !! wikitext
29306 foo : bar
29307
29308 foo : bar
29309
29310 <ref>foo : bar</ref>ok
29311 !! end
29312
29313
29314 #-----------------------
29315 # Tag minimization tests
29316 #-----------------------
29317
29318 !! test
29319 1. I/B quote minimization: wikitext-only tags should be combined
29320 !! options
29321 parsoid=html2wt
29322 !! html/parsoid
29323 <p><i>A</i><i>B</i></p>
29324 <p><b>A</b><b>B</b></p>
29325 <p><i>A</i><b><i>B</i></b></p>
29326 <p><b>A</b><i><b>B</b></i></p>
29327 <p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p>
29328 <p><i><b>A</b></i><i><b>B</b></i></p>
29329 <p><i><b>A</b></i><b><i>B</i></b></p>
29330 <p><b><i>A</i></b><i><b>B</b></i></p>
29331 !! wikitext
29332 ''AB''
29333
29334 '''AB'''
29335
29336 ''A'''B'''''
29337
29338 '''A''B'''''
29339
29340 '''A''BC''D'''
29341
29342 '''''AB'''''
29343
29344 '''''AB'''''
29345
29346 '''''AB'''''
29347 !! end
29348
29349 !! test
29350 2. I/B quote minimization: wikitext and html tags should not be combined
29351 !! options
29352 parsoid=html2wt
29353 !! html/parsoid
29354 <p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
29355 <p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
29356 !! wikitext
29357 ''A''<i>B</i>
29358
29359 ''A''<nowiki/>'''<i>B</i>'''
29360 !! end
29361
29362 !! test
29363 3. I/B quote minimization: templated content stops minimization
29364 !! options
29365 parsoid=html2wt
29366 !! html/parsoid
29367 <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>
29368 <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>
29369 !! wikitext
29370 ''A''{{echo|''B''}}
29371
29372 ''A''{{echo|'''''B'''''}}
29373 !! end
29374
29375 !! test
29376 4. I/B quote minimization: new content should be mimimized with adjacent old content
29377 !! options
29378 parsoid=html2wt
29379 !! html/parsoid
29380 <p><i>A</i><i>B</i></p>
29381 <p><b>A</b><b>B</b></p>
29382 <p><i>A</i><b><i>B</i></b></p>
29383 !! wikitext
29384 ''AB''
29385
29386 '''AB'''
29387
29388 ''A'''B'''''
29389 !! end
29390
29391 !! test
29392 5a. Merge adjacent quote nodes if they've been edited
29393 !! options
29394 parsoid={
29395 "modes": ["wt2wt", "selser"],
29396 "changes": [
29397 ["p", "contents", "remove", ":contains('b')"]
29398 ]
29399 }
29400 !! wikitext
29401 ''a''b''c''
29402 !! wikitext/edited
29403 ''ac''
29404 !! end
29405
29406 !! test
29407 5b. Merge adjacent quote nodes if they've been edited
29408 !! options
29409 parsoid={
29410 "modes": ["wt2wt", "selser"],
29411 "changes": [
29412 ["#x", "remove"]
29413 ]
29414 }
29415 !! wikitext
29416 ''a''<span id="x">b</span>''c''
29417 !! wikitext/edited
29418 ''ac''
29419 !! end
29420
29421 !! test
29422 1. Merge adjacent link nodes as long as at least one element is new
29423 !! options
29424 parsoid={
29425 "modes": ["html2wt"],
29426 "scrubWikitext": true
29427 }
29428 !! html/parsoid
29429 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29430 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29431 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a>
29432 !! wikitext
29433 [[Football]]
29434 [[Football]]
29435 [[Football|Foot]][[Football|ball]]
29436 !! end
29437
29438 !! test
29439 2. Merge adjacent link nodes and enable additional normalizations
29440 !! options
29441 parsoid={
29442 "modes": ["html2wt"],
29443 "scrubWikitext": true
29444 }
29445 !! html/parsoid
29446 <a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a>
29447 !! wikitext
29448 ''[[Football]]''
29449 !! end
29450
29451 !! test
29452 3. Don't merge adjacent link nodes if scrubWikitext is false
29453 !! options
29454 parsoid={
29455 "modes": ["html2wt"],
29456 "scrubWikitext": false
29457 }
29458 !! html/parsoid
29459 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29460 !! wikitext
29461 [[Football|Foot]][[Football|ball]]
29462 !! end
29463
29464 !! test
29465 1. Move format tags outside of WikiLink
29466 !! options
29467 parsoid={
29468 "modes": ["html2wt"],
29469 "scrubWikitext": true
29470 }
29471 !! html/parsoid
29472 <a rel="mw:WikiLink" href="./Football"><i>Football</i></a>
29473 <a rel="mw:WikiLink" href="./Football"><i><b>Football</b></i></a>
29474 <a rel="mw:WikiLink" href="./Football"><u><i><b>Football</b></i></u></a>
29475 !! wikitext
29476 ''[[Football]]''
29477 '''''[[Football]]'''''
29478 <u>'''''[[Football]]'''''</u>
29479 !! end
29480
29481 !! test
29482 2. Move format tags outside of WikiLink with mergable A tags
29483 !! options
29484 parsoid={
29485 "modes": ["html2wt"],
29486 "scrubWikitext": true
29487 }
29488 !! html/parsoid
29489 <a rel="mw:WikiLink" href="./Football"><i><b>Foot</b></i></a><a rel="mw:WikiLink" href="./Football"><i><b>ball</b></i></a>
29490 !! wikitext
29491 '''''[[Football]]'''''
29492 !! end
29493
29494 !! test
29495 3. Move format tags outside of WikiLink while preserving formats already outside WikiLink
29496 !! options
29497 parsoid={
29498 "modes": ["html2wt"],
29499 "scrubWikitext": true
29500 }
29501 !! html/parsoid
29502 <font color="red"><a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><u><b>Foo</b></u></a></font>
29503 !! wikitext
29504 <font color="red"><u>'''[[Foo]]'''</u></font>
29505 !! end
29506
29507 !! test
29508 4. Do not move format tags outside of WikiLink which includes attributes color, style and class
29509 !! options
29510 parsoid={
29511 "modes": ["html2wt"],
29512 "scrubWikitext": true
29513 }
29514 !! html/parsoid
29515 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><font color="red">Foo</font></a>
29516 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><span style="color: blue; font-size: 46px;">Foo></span></a>
29517 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><span class="Bar">Foo</span></a>
29518 !! wikitext
29519 [[Foo|<font color="red">Foo</font>]]
29520 [[Foo|<span style="color: blue; font-size: 46px;">Foo></span>]]
29521 [[Foo|<span class="Bar">Foo</span>]]
29522 !! end
29523
29524 !! test
29525 5. T194083 Regression test: Manual edit test that also enables scrubWikitext to move format tags outside wikilinks
29526 !! options
29527 parsoid={
29528 "modes": ["selser"],
29529 "scrubWikitext": true,
29530 "changes": [
29531 ["a", "html", "<i>Foo</i>"]
29532 ]
29533 }
29534 !! wikitext
29535 [[Foo]]
29536 !! wikitext/edited
29537 ''[[Foo]]''
29538 !! end
29539
29540 !! test
29541 6. Regression test: Manual edit test to ensure diff markers are not lost
29542 !! options
29543 parsoid={
29544 "modes": ["selser"],
29545 "scrubWikitext": true,
29546 "changes": [
29547 ["i", "wrap", "<a href='./Foo' rel='mw:WikiLink'></a>"]
29548 ]
29549 }
29550 !! wikitext
29551 ''Foo''
29552 !! wikitext/edited
29553 ''[[Foo]]''
29554 !! end
29555
29556 !! test
29557 7. T194083 Regression test: Manual edit test to ensure nested diff markers aren't inserted
29558 !! options
29559 parsoid={
29560 "modes": ["selser"],
29561 "scrubWikitext": true,
29562 "changes": [
29563 ["div", "after", "\n<p><a href='./Foo' rel='mw:WikiLink'>Foo </a>, placeholder</p>"]
29564 ]
29565 }
29566 !! wikitext
29567 <div>placeholder</div>
29568 !! wikitext/edited
29569 <div>placeholder</div>
29570 [[Foo]] , placeholder
29571 !! end
29572
29573 #------------------------------
29574 # End of tag minimization tests
29575 #------------------------------
29576
29577 !!test
29578 T56262: New entities
29579 !! options
29580 parsoid=html2wt
29581 !! html/parsoid
29582 <span typeof="mw:Entity">&nbsp;</span>
29583 !! wikitext
29584 &nbsp;
29585 !! end
29586
29587 ## Note that there is no wikitext output for 'unknownproperty' ##
29588 ## Unknown magic words are silently dropped ##
29589
29590 !! test
29591 Magic words
29592 !! options
29593 parsoid=html2wt
29594 !! html/parsoid
29595 <meta property='mw:PageProp/toc' />
29596 <meta property='mw:PageProp/notoc' />
29597 <meta property='mw:PageProp/forcetoc' />
29598 <meta property='mw:PageProp/index' />
29599 <meta property='mw:PageProp/noindex' />
29600 <meta property='mw:PageProp/nogallery' />
29601 <meta property='mw:PageProp/noeditsection' />
29602 <meta property='mw:PageProp/notitleconvert' />
29603 <meta property='mw:PageProp/nocontentconvert' />
29604 <meta property='mw:PageProp/unknownproperty' />
29605 !! wikitext
29606 __TOC__
29607 __NOTOC__
29608 __FORCETOC__
29609 __INDEX__
29610 __NOINDEX__
29611 __NOGALLERY__
29612 __NOEDITSECTION__
29613 __NOTITLECONVERT__
29614 __NOCONTENTCONVERT__
29615 !! end
29616
29617 !! test
29618 Consecutive <pre>s should not get merged
29619 !! options
29620 parsoid=html2wt,html2html
29621 !! html/parsoid
29622 <pre>a</pre><pre>b</pre>
29623
29624 <pre>c
29625 </pre><pre>
29626 d</pre>
29627
29628 <pre>e
29629
29630 </pre><pre>
29631
29632 f</pre>
29633 !! wikitext
29634 a
29635
29636 b
29637
29638 c
29639
29640 d
29641
29642 e
29643
29644
29645
29646 f
29647 !! end
29648
29649 !! test
29650 Edited ISBN links not serializable as ISBN links should serialize as wikilinks
29651 !! options
29652 parsoid=html2wt
29653 !! html/parsoid
29654 <a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a>
29655 !! wikitext
29656 [[Special:BookSources/1234567890|ISBN 1234567895]]
29657 !! end
29658
29659 !! test
29660 Edited RFC links not serializable as RFC links should serialize as extlinks
29661 !! options
29662 parsoid=html2wt
29663 !! html/parsoid
29664 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
29665 !! wikitext
29666 [https://tools.ietf.org/html/rfc123 New RFC]
29667 !! end
29668
29669 !! test
29670 Edited PMID links not serializable as PMID links should serialize as extlinks
29671 !! options
29672 parsoid=html2wt
29673 !! html/parsoid
29674 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a>
29675 !! wikitext
29676 [//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID]
29677 !! end
29678
29679 !! test
29680 WTS of autolinks with trailing/surrounding context
29681 !! options
29682 parsoid=html2wt
29683 !! html/parsoid
29684 <p><a href="http://cscott.net">http://cscott.net</a><b>foo</b></p>
29685 <p><a href="http://cscott.net">http://cscott.net</a><b data-parsoid='{"stx":"html"}'>foo</b></p>
29686 <p><b><a href="http://cscott.net">http://cscott.net</a></b></p>
29687 <p><b><a href="http://cscott.net">http://cscott.net</a> </b></p>
29688 <p><b><a href="http://cscott.net">http://cscott.net</a>x</b></p>
29689 <p><a href="http://cscott.net">http://cscott.net</a>x</p>
29690 !! wikitext
29691 http://cscott.net'''foo'''
29692
29693 http://cscott.net<b>foo</b>
29694
29695 '''http://cscott.net'''
29696
29697 '''http://cscott.net '''
29698
29699 '''http://cscott.net<nowiki/>x'''
29700
29701 http://cscott.net<nowiki/>x
29702 !! end
29703
29704 !! test
29705 WTS of autolinks with nowikis (round-trip)
29706 !! wikitext
29707 x<nowiki/>http://cscott.net<nowiki/>x
29708 !! html/parsoid
29709 <p>x<a rel="mw:ExtLink" class="external free" href="http://cscott.net">http://cscott.net</a>x</p>
29710 !! end
29711
29712 # this is the "easy" test because it leaves in place all the
29713 # data-parsoid information indicating this is an autolink
29714 !! test
29715 WTS of autolinks with escapes (editing)
29716 !! options
29717 parsoid={
29718 "modes": ["wt2wt"],
29719 "changes": [
29720 [ "span", "remove" ]
29721 ]
29722 }
29723 !! wikitext
29724 x<nowiki/>http://cscott.net<nowiki/>x
29725 !! wikitext/edited
29726 x<nowiki/>http://cscott.net<nowiki/>x
29727 !! end
29728
29729 !! test
29730 WTS of edited autolink-like text (T103364)
29731 !! options
29732 parsoid={
29733 "modes": ["wt2wt"],
29734 "changes": [
29735 [ "span[typeof]", "removeAttr", "typeof" ]
29736 ]
29737 }
29738 !! wikitext
29739 Not a link: <nowiki>http://example.com</nowiki>.
29740 !! wikitext/edited
29741 Not a link: <span><nowiki>http://example.com</nowiki></span>.
29742 !! end
29743
29744 !! test
29745 WTS of newly-authored autolink-like text (T103364)
29746 !! options
29747 parsoid=html2wt
29748 !! html/parsoid
29749 <p>http://example.com is not a link.</p>
29750 !! wikitext
29751 <nowiki>http://example.com</nowiki> is not a link.
29752 !! end
29753
29754 !! test
29755 WTS of autolink-like text after an autolink (T108563)
29756 !! options
29757 parsoid=html2wt
29758 !! html/parsoid
29759 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p>
29760 !! wikitext
29761 http://example.com <nowiki>http://example.com</nowiki> is not a link.
29762 !! end
29763
29764 !! test
29765 Magic links inside links (not autolinked)
29766 !! wikitext
29767 [[Foo|http://example.com]]
29768 [[Foo|RFC 1234]]
29769 [[Foo|PMID 1234]]
29770 [[Foo|ISBN 123456789x]]
29771
29772 [http://foo.com http://example.com]
29773 [http://foo.com RFC 1234]
29774 [http://foo.com PMID 1234]
29775 [http://foo.com ISBN 123456789x]
29776 !! html+tidy
29777 <p><a href="/wiki/Foo" title="Foo">http://example.com</a>
29778 <a href="/wiki/Foo" title="Foo">RFC 1234</a>
29779 <a href="/wiki/Foo" title="Foo">PMID 1234</a>
29780 <a href="/wiki/Foo" title="Foo">ISBN 123456789x</a>
29781 </p><p><a rel="nofollow" class="external text" href="http://foo.com">http://example.com</a>
29782 <a rel="nofollow" class="external text" href="http://foo.com">RFC 1234</a>
29783 <a rel="nofollow" class="external text" href="http://foo.com">PMID 1234</a>
29784 <a rel="nofollow" class="external text" href="http://foo.com">ISBN 123456789x</a>
29785 </p>
29786 !! html/parsoid
29787 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a>
29788 <a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a>
29789 <a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a>
29790 <a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p>
29791
29792 <p><a rel="mw:ExtLink" class="external text" href="http://foo.com">http://example.com</a>
29793 <a rel="mw:ExtLink" class="external text" href="http://foo.com">RFC 1234</a>
29794 <a rel="mw:ExtLink" class="external text" href="http://foo.com">PMID 1234</a>
29795 <a rel="mw:ExtLink" class="external text" href="http://foo.com">ISBN 123456789x</a></p>
29796 !! end
29797
29798 !! test
29799 Magic links inside image captions (autolinked)
29800 !! wikitext
29801 [[File:Foobar.jpg|thumb|http://example.com]]
29802 [[File:Foobar.jpg|thumb|RFC 1234]]
29803 [[File:Foobar.jpg|thumb|PMID 1234]]
29804 [[File:Foobar.jpg|thumb|ISBN 123456789x]]
29805 !! html+tidy
29806 <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>
29807 <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>
29808 <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>
29809 <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>
29810 !! html/parsoid
29811 <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>
29812 <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>
29813 <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>
29814 <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>
29815 !! end
29816
29817 !! test
29818 WTS of magic word text (T109371)
29819 !! options
29820 parsoid=html2wt
29821 !! html/parsoid
29822 <p>RFC 1234</p>
29823 <p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p>
29824 <p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p>
29825 !! wikitext
29826 <nowiki>RFC 1234</nowiki>
29827
29828 [http://foo.com RFC 1234]
29829
29830 [[Foo|RFC 1234]]
29831 !! end
29832
29833 !! test
29834 Edited Redirect link should emit a non-piped wikitext link
29835 !! options
29836 parsoid=html2wt
29837 !! html/parsoid
29838 <link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>
29839 !! wikitext
29840 #REDIRECT [[Bar]]
29841 !! end
29842
29843 !! test
29844 T75121: Infer extension name from typeOf if data-mw is not present
29845 !! options
29846 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
29847 !! html/parsoid
29848 <div typeOf="mw:Extension/foo"></div>
29849 !! wikitext
29850 <foo />
29851 !! end
29852
29853 # Note that the <p> wrapping isn't present in PHP parser output
29854 # The important thing for this test is that P-wrapping doesn't
29855 # interfere with the <nowiki> protection for leading - in <td>
29856 # (which isn't necessary for <th>).
29857 !! test
29858 T88318: p-wrapped dash in table.
29859 !! options
29860 parsoid=html2wt,wt2wt
29861 !! html/parsoid
29862 <table><tbody>
29863 <tr><th><p>-</p></th><th><p>- </p></th></tr>
29864 <tr><td><p>-</p></td><td><p>- </p></td></tr>
29865 <tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr>
29866 </tbody></table>
29867 !! wikitext
29868 {|
29869 !-
29870 !-
29871 |-
29872 |<nowiki>-</nowiki>
29873 |<nowiki>- </nowiki>
29874 |-
29875 |<small>-</small>
29876 |<br />
29877 -
29878 |<br />-
29879 |}
29880 !! html/php+tidy
29881 <table>
29882 <tbody><tr>
29883 <th>-
29884 </th>
29885 <th>-
29886 </th></tr>
29887 <tr>
29888 <td>-
29889 </td>
29890 <td>-
29891 </td></tr>
29892 <tr>
29893 <td><small>-</small>
29894 </td>
29895 <td><br />
29896 <p>-
29897 </p>
29898 </td>
29899 <td><br />-
29900 </td></tr></tbody></table>
29901 !! end
29902
29903 !! test
29904 T149209: WTS: Handle newlines in table cells properly
29905 !! options
29906 parsoid=html2wt
29907 !! html/parsoid
29908 <table>
29909 <tbody>
29910 <tr><td>a
29911 b
29912 </td><td data-parsoid='{"stx":"row"}'>c</td></tr>
29913 <tr><td><p>x</p>
29914 </td><td data-parsoid='{"stx":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr>
29915 </tbody></table>
29916 <table>
29917 <tbody>
29918 <tr><th>a
29919 b
29920 </th><th data-parsoid='{"stx":"row"}'>c</th></tr>
29921 <tr><th><p>x</h>
29922 </th><th data-parsoid='{"stx":"row"}'>y</th></tr>
29923 </tbody></table>
29924 !! wikitext
29925 {|
29926 |a
29927 b
29928 |c
29929 |-
29930 |x
29931 {{!}}y
29932 |}
29933 {|
29934 !a
29935 b
29936 !c
29937 |-
29938 !x
29939 !y
29940 |}
29941 !! end
29942
29943 !! test
29944 T149209: Selser: Handle newlines in table cells properly
29945 !! options
29946 parsoid={
29947 "modes": ["selser"],
29948 "changes": [
29949 [ "#h1", "html", "a\nb\n" ],
29950 [ "#h2", "html", "a\nb\n" ],
29951 [ "#c1", "html", "a\nb\n" ],
29952 [ "#c2", "html", "<p>a</p>" ],
29953 [ "#c3", "html", "<p>a</p>" ],
29954 [ "#c4", "html", "edit-me<p>a</p>" ]
29955 ]
29956 }
29957 !! wikitext
29958 {|
29959 ! id="h1" |edit-me!!1
29960 |-
29961 ! id="h2" |edit-me||2
29962 |-
29963 | id="c1" |edit-me||3
29964 |-
29965 | id="c2" |edit-me||4
29966 |-
29967 | id="c3" |edit-me||p||q||r
29968 |-
29969 | id="c4" |edit-me||p||q||r
29970 |}
29971 !! wikitext/edited
29972 {|
29973 ! id="h1" |a
29974 b
29975 !1
29976 |-
29977 ! id="h2" |a
29978 b
29979 !2
29980 |-
29981 | id="c1" |a
29982 b
29983 |3
29984 |-
29985 | id="c2" |a
29986 |4
29987 |-
29988 | id="c3" |a
29989 |p||q||r
29990 |-
29991 | id="c4" |edit-me
29992 a
29993 |p||q||r
29994 |}
29995 !! end
29996
29997 !! test
29998 HTML id attribute with Parsoid-like element ids should not be serialized to wikitext
29999 !! options
30000 parsoid=html2wt
30001 !! html/parsoid
30002 <table id='mwAb'>
30003 <td id='mwAc'>foo</td>
30004 <td id='serialize-this'>bar</td>
30005 </table>
30006 !! wikitext
30007 {|
30008 |foo
30009 | id="serialize-this" |bar
30010 |}
30011 !! end
30012
30013 !! test
30014 Parsoid-like element ids should not be serialized to wikitext unless shadowed
30015 !! options
30016 parsoid=html2wt
30017 !! html/parsoid
30018 <div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div>
30019 !! wikitext
30020 <div id="hello">ok</div>
30021 !! end
30022
30023 !! test
30024 Testing serialization after deletion in references
30025 !! options
30026 parsoid={
30027 "modes": ["wt2wt"],
30028 "changes": [
30029 ["#x", "remove"]
30030 ]
30031 }
30032 !! wikitext
30033 hi <ref><div id="x">ho</div></ref>
30034
30035 <references />
30036 !! wikitext/edited
30037 hi <ref></ref>
30038
30039 <references />
30040 !! end
30041
30042 !!test
30043 Testing serialization after deletion of table cells
30044 !!options
30045 parsoid={
30046 "modes": ["wt2wt", "selser"],
30047 "changes": [
30048 ["#x", "remove"]
30049 ]
30050 }
30051 !!wikitext
30052 {|
30053 !h1 !!h2 !!h3
30054 | id="x" |c1 {{!}}{{!}}{{!}}c2 |||c3
30055 |}
30056 !! wikitext/edited
30057 {|
30058 !h1!!h2!!h3
30059 |c2|||c3
30060 |}
30061 !!end
30062
30063 !! test
30064 Testing selser after addition of new row before first row (T125419)
30065 !! options
30066 parsoid={
30067 "modes": ["wt2wt", "selser"],
30068 "changes": [
30069 [ "tr", "before", "<tr><td>X</td></tr>" ]
30070 ]
30071 }
30072 !! wikitext
30073 {|
30074 |a
30075 |}
30076 !! wikitext/edited
30077 {|
30078 |X
30079 |-
30080 |a
30081 |}
30082 !! end
30083
30084 !! test
30085 Serialize new table rows in a HTML table using HTML tags
30086 !! options
30087 parsoid={
30088 "modes": ["wt2wt", "selser"],
30089 "changes": [
30090 [ "tr", "before", "<tr><td>X</td></tr>" ]
30091 ]
30092 }
30093 !! wikitext
30094 <table><tr><td>a</td></tr></table>
30095 !! wikitext/edited
30096 <table><tr><td>X</td></tr><tr><td>a</td></tr></table>
30097 !! end
30098
30099 !! test
30100 Serialize new table cells in a HTML row using HTML tags
30101 !! options
30102 parsoid={
30103 "modes": ["wt2wt", "selser"],
30104 "changes": [
30105 [ "td", "before", "<td>X</td>" ]
30106 ]
30107 }
30108 !! wikitext
30109 <table><tr><td>a</td></tr></table>
30110 !! wikitext/edited
30111 <table><tr><td>X</td><td>a</td></tr></table>
30112 !! end
30113
30114 !! test
30115 Serialize wikitext list items as HTML list items when embedded in a HTML list
30116 !! options
30117 parsoid=html2wt
30118 !! html/parsoid
30119 <ul data-parsoid='{"stx": "html"}'>
30120 <li data-parsoid='{}'>a</li>
30121 <li>b</li>
30122 </ul>
30123 !! wikitext
30124 <ul>
30125 <li>a</li>
30126 <li>b</li>
30127 </ul>
30128 !! html/php+tidy
30129 <ul>
30130 <li>a</li>
30131 <li>b</li>
30132 </ul>
30133 !! end
30134
30135 # Nested list should be inside <li>, that is
30136 # <ul><li>foo<ul>..</ul></li></ul> instead of
30137 # <ul><li>foo</li><ul>..</ul></ul>
30138 # See https://stackoverflow.com/questions/5899337/proper-way-to-make-html-nested-list
30139 !! test
30140 Wikitext lists can be nested inside HTML lists
30141 !! options
30142 parsoid=html2wt
30143 !! html/parsoid
30144 <ul data-parsoid='{"stx": "html"}'>
30145 <li data-parsoid='{"stx": "html"}'>a
30146 <ul><li>b</li></ul>
30147 </li>
30148 </ul>
30149
30150 <ul data-parsoid='{"stx": "html"}'>
30151 <li>x
30152 <ul><li>y</li></ul>
30153 </li>
30154 </ul>
30155 !! wikitext
30156 <ul>
30157 <li>a
30158 * b
30159 </li>
30160 </ul>
30161
30162 <ul>
30163 <li>x
30164 * y
30165 </li>
30166 </ul>
30167 !! html/php+tidy
30168 <ul>
30169 <li>a
30170 <ul><li>b</li></ul>
30171 </li>
30172 </ul>
30173 <ul>
30174 <li>x
30175 <ul><li>y</li></ul>
30176 </li>
30177 </ul>
30178 !! end
30179
30180 !! test
30181 WTS change modes
30182 !! options
30183 parsoid={
30184 "modes": ["wt2wt"],
30185 "changes": [
30186 [ "#xyz", "before", "<b>before</b> stuff " ],
30187 [ "#xyz", "after", " stuff <i>after</i>" ],
30188 [ "#xyz", "html", "x <b>y</b> z" ]
30189 ]
30190 }
30191 !! wikitext
30192 <span id="xyz">hello</span>
30193 !! wikitext/edited
30194 '''before''' stuff <span id="xyz">x '''y''' z</span> stuff ''after''
30195 !! end
30196
30197 !! test
30198 Never serialize a-tag as html, regardless of what data-parsoid has to say
30199 !! options
30200 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
30201 !! html/parsoid
30202 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a>
30203 !! wikitext
30204 [[Foo]]
30205 !! end
30206
30207 ## SSS FIXME: This is broken output nevertheless.
30208 ## What might be a reasonable non-broken output for this?
30209 ## This is an edge case unlikely to be seen in production
30210 ## that I am not wasting more time on this right now.
30211 !! test
30212 Never serialize a-tag as html, no matter what attributes it has
30213 !! options
30214 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
30215 !! html/parsoid
30216 <a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a>
30217 !! wikitext
30218 [http://boo.org http://boohoo.org]
30219 !! end
30220
30221 # Misnested is an indication that selser can reuse the source but these have
30222 # shown to sneak through on occasion. See T101768.
30223 # The original wikitext here is: [http://test.com [[one]] two three]
30224 !! test
30225 Strip span tags added to mark misnested links
30226 !! options
30227 parsoid=html2wt
30228 !! html/parsoid
30229 <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>
30230 !! wikitext
30231 [http://test.com][[one]] two three
30232 !! end
30233
30234 !! test
30235 Catch regression when unpacking misnested links
30236 !! options
30237 parsoid=wt2html
30238 !! wikitext
30239 {{echo|hi}}[http://example.com [[ho]]]
30240 !! html/parsoid
30241 <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>
30242 !! end
30243
30244 !! test
30245 Catch regression when unpacking with trailing content
30246 !! wikitext
30247 {{echo|Foo <references/> bar}}
30248 !! html/parsoid
30249 <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>
30250 !! end
30251
30252 !! test
30253 Use data-parsoid.firstWikitextNode to compute newline constraints for template content
30254 !! options
30255 parsoid=html2wt
30256 !! html/parsoid
30257 <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|}"]}'>
30258 <tbody><tr><td>d
30259 </td></tr>
30260 </tbody></table>
30261 !! wikitext
30262 {{echo|a}}
30263 {|{{echo|c
30264 {{!}}d
30265 }}
30266 |}
30267 !! end
30268
30269 ## This test verifies the presence and computation of this attribute indirectly
30270 ## by making an edit and ensuring that the serialization is correct (which it would be
30271 ## only if firstWikitextNode is properly set).
30272 !! test
30273 data-parsoid.firstWikitextNode should be computed properly in the presence of fostered content
30274 !! options
30275 parsoid= {
30276 "modes": ["wt2wt"],
30277 "changes": [
30278 [ "div#x", "remove" ],
30279 [ "div", "before", "<div>new</div>" ]
30280 ]
30281 }
30282 !! wikitext
30283 <div id="x">foo</div>
30284 {|
30285 {{echo|<div>boo</div>
30286 {{!}}b}}
30287 |c
30288 |}
30289 !! wikitext/edited
30290
30291 <div>new</div>
30292 {|
30293 {{echo|<div>boo</div>
30294 {{!}}b}}
30295 |c
30296 |}
30297 !! end
30298
30299 # --------------------------------------------
30300 # Tests spec'ing wikitext serialization norms |
30301 # --------------------------------------------
30302
30303 !! test
30304 Serialize multi-line indent-pre starting with wikitext syntax
30305 !! options
30306 parsoid=html2wt
30307 !! html/parsoid
30308 <pre>* 1
30309 ** 2
30310 * 3</pre>
30311 !! wikitext
30312 * 1
30313 ** 2
30314 * 3
30315 !! end
30316
30317 !! test
30318 1. Categories should always be serialized on their own line
30319 !! options
30320 parsoid=html2wt
30321 !! html/parsoid
30322 foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar
30323 !! wikitext
30324 foo
30325 [[Category:Foo]]
30326 bar
30327 !! end
30328
30329 !! test
30330 2. Categories that are part of templates should not introduce a line break
30331 !! wikitext
30332 foo {{echo|<span>bar</span> [[Category:baz]]}} bar
30333 !! html/parsoid
30334 <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>
30335 !! end
30336
30337 # Careful while editing these next 2 tests. There are \u200f characters
30338 # before and after the <link> tags in the HTML and following some
30339 # of the categories in wikitext
30340 # Do not remove these characters in edits.
30341 #
30342 # As part of the serialization, these bidi characters will get stripped.
30343 !! test
30344 RTL (\u200f) and LTR (\u200e) markers around category tags should be stripped
30345 !! options
30346 parsoid={
30347 "modes": ["html2wt"],
30348 "scrubWikitext": true
30349 }
30350 !! html/parsoid
30351 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏
30352 ‏<link rel="mw:PageProp/Category" href="./קטגוריה:_שיטות_משפט" />‏</p>
30353 !! wikitext
30354 [[קטגוריה:טקסים]]
30355 [[קטגוריה: שיטות משפט]]
30356 !! end
30357
30358 !! test
30359 RTL (\u200f) and LTR (\u200e) markers should not be stripped if followed by a text node
30360 !! options
30361 parsoid={
30362 "modes": ["html2wt"],
30363 "scrubWikitext": true
30364 }
30365 !! html/parsoid
30366 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏y</p>
30367 !! wikitext
30368 [[קטגוריה:טקסים]]
30369 ‏y
30370 !! end
30371
30372 !! test
30373 Lists: Add space after bullets
30374 !! options
30375 parsoid=html2wt
30376 !! html/parsoid
30377 <ul>
30378 <li>foo</li>
30379 <li> bar</li>
30380 <li><span> baz</span></li>
30381 </ul>
30382 !! wikitext
30383 * foo
30384 * bar
30385 * <span> baz</span>
30386 !! end
30387
30388 !! test
30389 1. Headings: Add space before/after == (T53744)
30390 !! options
30391 parsoid=html2wt
30392 !! html/parsoid
30393 <h2>foo</h2>
30394 <h2> bar</h2>
30395 <h2>baz </h2>
30396 <h2><span> baz</span></h2>
30397 !! wikitext
30398 == foo ==
30399
30400 == bar ==
30401
30402 == baz ==
30403
30404 == <span> baz</span> ==
30405 !! end
30406
30407 !! test
30408 2. Headings: Add space before/after == even after hoisted content
30409 !! options
30410 parsoid={
30411 "modes": ["html2wt"],
30412 "scrubWikitext": true
30413 }
30414 !! html/parsoid
30415 <h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2>
30416 !! wikitext
30417 [[Category:A2]]
30418
30419 == ok ==
30420 !! end
30421
30422 !! test
30423 1. Headings: suppress newly created empty headings
30424 !! options
30425 parsoid={
30426 "modes": ["html2wt"],
30427 "scrubWikitext": true
30428 }
30429 !! html/parsoid
30430 <h2></h2>
30431 !! wikitext
30432 !! end
30433
30434 !! test
30435 2. Headings: don't suppress empty headings if scrubWikitext is false
30436 !! options
30437 parsoid=html2wt
30438 !! html/parsoid
30439 <h2></h2>
30440 !! wikitext
30441 ==<nowiki/>==
30442 !! end
30443
30444 !! test
30445 3. Headings: suppress empty headings on edits
30446 !! options
30447 parsoid={
30448 "modes": ["selser"],
30449 "scrubWikitext": true,
30450 "changes": [
30451 [ "#x", "remove"]
30452 ]
30453 }
30454 !! wikitext
30455 ==<span id="x">foo</span>==
30456 !! wikitext/edited
30457 !! end
30458
30459 !! test
30460 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = true)
30461 !! options
30462 parsoid={
30463 "modes": ["html2wt"],
30464 "scrubWikitext": true
30465 }
30466 !! html/parsoid
30467 <h2>foo<br/>bar</h2>
30468 <h2>foo <span><br/>bar</span> baz</h2>
30469 !! wikitext
30470 == foo bar ==
30471
30472 == foo <span> bar</span> baz ==
30473 !! end
30474
30475 !! test
30476 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = false)
30477 !! options
30478 parsoid={
30479 "modes": ["html2wt"],
30480 "scrubWikitext": false
30481 }
30482 !! html/parsoid
30483 <h2>foo<br/>bar</h2>
30484 !! wikitext
30485 == foo<br />bar ==
30486 !! end
30487
30488 !! test
30489 1. WT Quote Tags: suppress newly created empty style tags
30490 !! options
30491 parsoid={
30492 "modes": ["html2wt"],
30493 "scrubWikitext": true
30494 }
30495 !! html/parsoid
30496 <i></i><b></b>
30497 !! wikitext
30498 !! end
30499
30500 !! test
30501 2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false
30502 !! options
30503 parsoid=html2wt
30504 !! html/parsoid
30505 <i></i><b></b>
30506 !! wikitext
30507 ''<nowiki/>'''''<nowiki/>'''
30508 !! end
30509
30510 !! test
30511 3. WT Quote Tags: suppress empty style tags on edits
30512 !! options
30513 parsoid={
30514 "modes": ["selser"],
30515 "scrubWikitext": true,
30516 "changes": [
30517 [ "#x", "remove"]
30518 ]
30519 }
30520 !! wikitext
30521 '''<span id="x">foo</span>'''
30522 !! wikitext/edited
30523 !! end
30524
30525 !! test
30526 1. Anchors: suppress newly created empty anchors
30527 !! options
30528 parsoid={
30529 "modes": ["html2wt"],
30530 "scrubWikitext": true
30531 }
30532 !! html/parsoid
30533 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
30534 !! wikitext
30535 !! end
30536
30537 !! test
30538 2. Anchors: don't suppress empty anchors if scrubWikitext is false
30539 !! options
30540 parsoid={
30541 "modes": ["html2wt"],
30542 "scrubWikitext": false
30543 }
30544 !! html/parsoid
30545 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
30546 !! wikitext
30547 [[Test|<nowiki/>]]
30548 !! end
30549
30550 !! test
30551 3. Anchors: suppress empty anchors on edits
30552 !! options
30553 parsoid={
30554 "modes": ["selser"],
30555 "scrubWikitext": true,
30556 "changes": [
30557 [ "#x", "remove"]
30558 ]
30559 }
30560 !! wikitext
30561 [[Test|<span id="x">foo</span>]]
30562 !! wikitext/edited
30563 !! end
30564
30565 !! test
30566 3a. Anchors: do not suppress numbered extlinks
30567 !! options
30568 parsoid={
30569 "modes": ["wt2wt"],
30570 "scrubWikitext": true
30571 }
30572 !! wikitext
30573 [http://foo.com]
30574 !! html/parsoid
30575 <a rel="mw:ExtLink" href="http://foo.com"></a>
30576 !! end
30577
30578 !! test
30579 3b. Anchors: do not suppress numbered extlinks
30580 !! options
30581 parsoid={
30582 "modes": ["wt2wt"],
30583 "scrubWikitext": true,
30584 "changes": [
30585 [ "#x", "remove"]
30586 ]
30587 }
30588 !! wikitext
30589 [http://foo.com <span id="x">foo</span>]
30590 !! wikitext/edited
30591 [http://foo.com]
30592 !! end
30593
30594 !!test
30595 Normalizations should be restricted to edited content
30596 !!options
30597 parsoid={
30598 "modes": ["selser"],
30599 "scrubWikitext": true,
30600 "changes": [
30601 [ "h1", "before", "<i></i>"]
30602 ]
30603 }
30604 !!wikitext
30605 a
30606 = =
30607 b
30608 !!wikitext/edited
30609 a
30610 = =
30611 b
30612 !!end
30613
30614 !! test
30615 1. Multiple normalizations (html2wt)
30616 !! options
30617 parsoid={
30618 "modes": ["html2wt"],
30619 "scrubWikitext": true
30620 }
30621 !! html/parsoid
30622 <h2><i></i></h2>
30623 <p><a href='Foo' rel='mw:WikiLink'>foo<i></i>
30624 </a><b><i></i></b>x</p>
30625 !! wikitext
30626
30627 [[foo]]
30628 x
30629
30630 !! end
30631
30632 !! test
30633 2. Multiple normalizations (selser)
30634 !! options
30635 parsoid={
30636 "modes": ["selser"],
30637 "scrubWikitext": true,
30638 "changes": [
30639 [ "#x", "after", "<h1><i></i></h1>\n<p> bar<b></b></p>"]
30640 ]
30641 }
30642 !! wikitext
30643 <div id="x">foo</div>
30644 !! wikitext/edited
30645 <div id="x">foo</div>
30646 bar
30647 !! end
30648
30649 !! test
30650 1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
30651 !! options
30652 parsoid={
30653 "modes": ["html2wt"],
30654 "scrubWikitext": true
30655 }
30656 !! html/parsoid
30657 <p> hi</p>
30658 <p> hello</p>
30659 !! wikitext
30660 hi
30661
30662 hello
30663 !! end
30664
30665 !! test
30666 2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false
30667 !! options
30668 parsoid=html2wt
30669 !! html/parsoid
30670 <p> hi</p>
30671 <p> hello</p>
30672 !! wikitext
30673 <nowiki> </nowiki>hi
30674
30675 <nowiki> </nowiki> hello
30676 !! end
30677
30678 !! test
30679 3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
30680 !! options
30681 parsoid={
30682 "modes": ["html2wt"],
30683 "scrubWikitext": true
30684 }
30685 !! html/parsoid
30686 <p>Foo
30687 bar
30688 baz</p>
30689
30690 <table><tr><td>Foo
30691 bar
30692 baz bang</td></tr></table>
30693
30694 <p><!--boo--> foo
30695 bar</p>
30696
30697 <p> foo
30698 bar<span>boo</span></p>
30699 !! wikitext
30700 Foo
30701 bar
30702 baz
30703
30704 {|
30705 |Foo
30706 bar
30707 baz bang
30708 |}
30709
30710 <!--boo-->foo
30711 bar
30712
30713 foo
30714 bar<span>boo</span>
30715 !! end
30716
30717 !! test
30718 4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs
30719 !! options
30720 parsoid={
30721 "modes": ["selser"],
30722 "scrubWikitext": true,
30723 "changes": [
30724 [ "p", "html", " a\n b" ]
30725 ]
30726 }
30727 !! wikitext
30728 xyz
30729 !! wikitext/edited
30730 a
30731 b
30732 !! end
30733
30734 !! test
30735 1. New links that end in spaces
30736 !! options
30737 parsoid={
30738 "modes": ["html2wt"],
30739 "scrubWikitext": false
30740 }
30741 !! html/parsoid
30742 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
30743 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
30744 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
30745 !! wikitext
30746 [[Berlin ]]<nowiki/>is the capital of Germany.
30747
30748 [[Foo ]]'''bar'''
30749
30750 [[Boston ]] is a city.
30751 !! end
30752
30753 !! test
30754 2. New links that end in spaces
30755 !! options
30756 parsoid={
30757 "modes": ["html2wt"],
30758 "scrubWikitext": true
30759 }
30760 !! html/parsoid
30761 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
30762 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
30763 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
30764 !! wikitext
30765 [[Berlin]] is the capital of Germany.
30766
30767 [[Foo]] '''bar'''
30768
30769 [[Boston]] is a city.
30770 !! end
30771
30772 !! test
30773 1. Table cells with escapable prefixes
30774 !! options
30775 parsoid={
30776 "modes": ["html2wt"],
30777 "scrubWikitext": false
30778 }
30779 !! html/parsoid
30780 <table>
30781 <tr><td>a</td></tr>
30782 <tr><td>-</td></tr>
30783 <tr><td>+</td></tr>
30784 <tr><td>}</td></tr>
30785 </table>
30786 !! wikitext
30787 {|
30788 |a
30789 |-
30790 |<nowiki>-</nowiki>
30791 |-
30792 |<nowiki>+</nowiki>
30793 |-
30794 |<nowiki>}</nowiki>
30795 |}
30796 !! end
30797
30798 !! test
30799 2. Table cells with escapable prefixes
30800 !! options
30801 parsoid={
30802 "modes": ["html2wt"],
30803 "scrubWikitext": true
30804 }
30805 !! html/parsoid
30806 <table>
30807 <tr><td>a</td></tr>
30808 <tr><td>-</td></tr>
30809 <tr><td>+</td></tr>
30810 <tr><td>}</td></tr>
30811 </table>
30812 !! wikitext
30813 {|
30814 |a
30815 |-
30816 | -
30817 |-
30818 | +
30819 |-
30820 | }
30821 |}
30822 !! end
30823
30824 !! test
30825 3a. Table cells with escapable prefixes after edits
30826 !! options
30827 parsoid={
30828 "modes": ["selser"],
30829 "scrubWikitext": true,
30830 "changes": [
30831 [ "table tbody tr:first-child td:first-child", "remove"]
30832 ]
30833 }
30834 !! wikitext
30835 {|
30836 |a||-
30837 |}
30838 !! wikitext/edited
30839 {|
30840 | -
30841 |}
30842 !! end
30843
30844 !! test
30845 3b. Table cells with escapable prefixes after edits
30846 !! options
30847 parsoid={
30848 "modes": ["selser"],
30849 "scrubWikitext": true,
30850 "changes": [
30851 [ "table tbody tr:first-child td:first-child", "html", "-" ],
30852 [ "#x", "remove" ]
30853 ]
30854 }
30855 !! wikitext
30856 {|
30857 |pqr
30858 |<span id="x">foo</span>+
30859 |}
30860 !! wikitext/edited
30861 {|
30862 | -
30863 | +
30864 |}
30865 !! end
30866
30867 # FIXME: This test will fail because
30868 # normalization doesn't realize that the id attribute
30869 # will eliminate the escapable scenario
30870 !! test
30871 4a. Table cells without escapable prefixes after edits
30872 !! options
30873 parsoid={
30874 "modes": ["selser"],
30875 "scrubWikitext": true,
30876 "changes": [
30877 [ "#x", "html", "-" ]
30878 ]
30879 }
30880 !! wikitext
30881 {|
30882 | id="x" |abcd
30883 |}
30884 !! wikitext/edited
30885 {|
30886 | id="x" |-
30887 |}
30888 !! end
30889
30890 ## This tests normalizer's ability to discriminate between
30891 ## cells having identical content.
30892 !! test
30893 4b. Table cells without escapable prefixes after edits
30894 !! options
30895 parsoid={
30896 "modes": ["selser"],
30897 "scrubWikitext": true,
30898 "changes": [
30899 [ "td", "html", "-" ]
30900 ]
30901 }
30902 !! wikitext
30903 {|
30904 |a||b
30905 |}
30906 !! wikitext/edited
30907 {|
30908 | -||-
30909 |}
30910 !! end
30911
30912 ## This tests normalizer's ability to not be tripped by
30913 ## comments (and whitespace)
30914 !! test
30915 4c. Table cells without escapable prefixes after edits
30916 !! options
30917 parsoid={
30918 "modes": ["selser"],
30919 "scrubWikitext": true,
30920 "changes": [
30921 [ "table tbody tr td:first-child", "remove" ]
30922 ]
30923 }
30924 !! wikitext
30925 {|
30926 |-
30927 <!--foo--> |a||-
30928 |}
30929 !! wikitext/edited
30930 {|
30931 |-
30932 <!--foo--> | -
30933 |}
30934 !! end
30935
30936 ## This tests normalizer's ability to handle HTML cells
30937 !! test
30938 4d. Table cells without escapable prefixes after edits
30939 !! options
30940 parsoid={
30941 "modes": ["selser"],
30942 "scrubWikitext": true,
30943 "changes": [
30944 [ "td", "html", "-" ]
30945 ]
30946 }
30947 !! wikitext
30948 <table>
30949 <tr><td>a</td></tr>
30950 </table>
30951 !! wikitext/edited
30952 <table>
30953 <tr><td>-</td></tr>
30954 </table>
30955 !! end
30956
30957 ## T111151 Remove font elements without attributes
30958 !! test
30959 5a. font tags without attributes should be dropped in scrubWikitext mode
30960 !! options
30961 parsoid={
30962 "modes": ["html2wt"],
30963 "scrubWikitext": true
30964 }
30965 !! html/parsoid
30966 <font>foo</font>
30967 <font><font>bar</font></font>
30968 <font class="x">boo</font>
30969 !! wikitext
30970 foo
30971 bar
30972 <font class="x">boo</font>
30973 !! end
30974
30975 !! test
30976 5b. font tags should not be dropped without scrubWikitext being enabled
30977 !! options
30978 parsoid={
30979 "modes": ["html2wt"],
30980 "scrubWikitext": false
30981 }
30982 !! html/parsoid
30983 <font>foo</font>
30984 !! wikitext
30985 <font>foo</font>
30986 !! end
30987
30988 !! test
30989 Escape nowiki DOM elements
30990 !! options
30991 parsoid=html2wt
30992 !! html/parsoid
30993 <nowiki><i>foo</i></nowiki>
30994 !! wikitext
30995 &lt;nowiki&gt;''foo''&lt;/nowiki&gt;
30996 !! end
30997
30998 # This is meant to be an interim fix while we go about figuring out
30999 # how to not introduce these trailing <nowiki/>s in the first place.
31000 !! test
31001 T115717: Strip trailing <nowiki/>s (without affecting valid uses)
31002 !! options
31003 parsoid=html2wt
31004 !! html/parsoid
31005 <p>x<meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/>
31006 y</p>
31007 <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>
31008 <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>
31009 !! wikitext
31010 x
31011 y
31012
31013 {{echo|
31014 1 = <nowiki/>}}
31015
31016 {{echo|
31017 1 = <nowiki/>
31018 }}
31019 !! end
31020
31021 !! test
31022 New list is serialized on newlines
31023 !! options
31024 parsoid=html2wt
31025 !! html/parsoid
31026 <p>The quick brown fox jumps over the lazy dog.</p><ul>
31027 <li>Yesterday</li>
31028 <li>Today</li>
31029 <li>Tomorrow</li>
31030 </ul><p>The quick onyx goblin jumps over the lazy dwarf.</p>
31031 !! wikitext
31032 The quick brown fox jumps over the lazy dog.
31033
31034 * Yesterday
31035 * Today
31036 * Tomorrow
31037
31038 The quick onyx goblin jumps over the lazy dwarf.
31039 !! end
31040
31041 !! test
31042 New lists in formatting elements serialized w/o newlines
31043 !! options
31044 parsoid=html2wt
31045 !! html/parsoid
31046 <small>
31047
31048 <ul>
31049 <li>123</li>
31050 </ul>
31051
31052 </small>
31053
31054 <small><ul><li>hi</li></ul></small>
31055 !! wikitext
31056 <small>
31057 * 123
31058 </small>
31059
31060 <small>
31061 * hi
31062 </small>
31063 !! end
31064
31065 !! test
31066 New list in table doesn't need newlines
31067 !! options
31068 parsoid=html2wt
31069 !! html/parsoid
31070 <table><tr><td><ul><li>test</li><li>123</li></td></tr></table>
31071 !! wikitext
31072 {|
31073 |
31074 * test
31075 * 123
31076 |}
31077 !! end
31078
31079 # ---------------------------------------------------
31080 # End of tests spec'ing wikitext serialization norms |
31081 # ---------------------------------------------------
31082
31083 # T104032
31084 !! test
31085 Bare inline nodes not wrapped inside p-tags should be treated as p-wrapped
31086 !! options
31087 parsoid=html2wt
31088 !! html/parsoid
31089 a<p>b</p>
31090 <b>c</b><p>d</p>
31091 <table><tr>
31092 <td>a<p>b</p></td>
31093 <td><b>c</b><p>d</p></td>
31094 </tr></table>
31095 !! wikitext
31096 a
31097
31098 b
31099
31100 '''c'''
31101
31102 d
31103 {|
31104 |a
31105 b
31106 |'''c'''
31107 d
31108 |}
31109 !! end
31110
31111 !! test
31112 Anchor without href scenarios
31113 !! options
31114 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
31115 !! html/parsoid
31116 <a class="bc"></a>
31117 <a class="no">dice</a>
31118 <a name="foo"></a>
31119 !! wikitext
31120
31121 dice
31122 <span name="foo"></span>
31123 !! end
31124
31125 !! test
31126 New transclusion added after a list should be serialized after the list
31127 !! options
31128 parsoid=html2wt
31129 !! html/parsoid
31130 <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>
31131 !! wikitext
31132 * a
31133 {{echo|foo}}
31134 !! end
31135
31136 # -----------------------------------------------------------------
31137 # End of section for Parsoid-only html2wt tests for serialization
31138 # of new content
31139 # -----------------------------------------------------------------
31140
31141 # -----------------------------------------------------------------
31142 # The following section of tests are primarily to spec behavior of
31143 # the selective serializer. All these tests have manual selser
31144 # changes. The automated selser changes for all tests handle the
31145 # wide variation of changes, but these tests here capture specs
31146 # deterministically.
31147 # ----------------------------------------------------------------
31148
31149 ## T90517
31150 !! test
31151 Selser: New comments should not be lost
31152 !! options
31153 parsoid={
31154 "modes": ["selser"],
31155 "changes": [
31156 [ "#a", "after", "<!--c1-->" ],
31157 [ "#b", "before", "<!--c2-->" ]
31158 ]
31159 }
31160 !! wikitext
31161 <span id="a">a</span>
31162
31163 <span id="b">b</span>
31164 !! wikitext/edited
31165 <span id="a">a</span><!--c1-->
31166
31167 <!--c2--><span id="b">b</span>
31168 !! end
31169
31170 ## T89383
31171 !! test
31172 Selser: Check for validity of DSR before using it
31173 !! options
31174 parsoid={
31175 "modes": ["selser"],
31176 "changes": [
31177 [ "#a", "before", "<meta property='mw:PageProp/displaytitle' content='foo'>" ]
31178 ]
31179 }
31180 !! wikitext
31181 <span id="a">a</span>
31182 !! wikitext/edited
31183 {{DISPLAYTITLE:foo}}
31184 <span id="a">a</span>
31185 !! end
31186
31187 !! test
31188 1. DOMDiff: Changes to <ref> content should be looked up using id
31189 !! options
31190 parsoid={
31191 "modes": ["selser"],
31192 "changes": [
31193 ["#X", "after", "bar"],
31194 ["#Y", "after", "baz"]
31195 ]
31196 }
31197 !! wikitext
31198 X <ref><span id="X">foo</span></ref>
31199 Y <ref name="a" />
31200 <references>
31201 <ref name="a"><span id="Y">foo</span></ref>
31202 </references>
31203 !! wikitext/edited
31204 X <ref><span id="X">foo</span>bar</ref>
31205 Y <ref name="a" />
31206 <references>
31207 <ref name="a"><span id="Y">foo</span>baz</ref>
31208 </references>
31209 !! end
31210
31211 !! test
31212 2. DOMDiff: Changes to <ref> content should be looked up using id
31213 !! options
31214 parsoid={
31215 "modes": ["selser"],
31216 "changes": [
31217 ["#Z", "after", "bar"]
31218 ]
31219 }
31220 !! wikitext
31221 A <ref>foo bar for a</ref>
31222 B <ref group="X" name="b" />
31223
31224 <references />
31225
31226 <references group="X">
31227 <ref name="b"><span id="Z">foo</span></ref>
31228 </references>
31229 !! wikitext/edited
31230 A <ref>foo bar for a</ref>
31231 B <ref group="X" name="b" />
31232
31233 <references />
31234
31235 <references group="X">
31236 <ref name="b"><span id="Z">foo</span>bar</ref>
31237 </references>
31238 !! end
31239
31240 !! test
31241 DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388)
31242 !! options
31243 parsoid={
31244 "modes": ["selser"],
31245 "changes": [
31246 [ "div:first-child", "text", "bar" ]
31247 ]
31248 }
31249 !! wikitext
31250 <div style="{{1x|color:red;}}%">foo</div>
31251 !! wikitext/edited
31252 <div style="{{1x|color:red;}}%">bar</div>
31253 !! end
31254
31255 !! test
31256 Empty LI (T49673)
31257 !! wikitext
31258 *a
31259 *
31260 *
31261 *b
31262 !! html+tidy
31263 <ul><li>a</li>
31264 <li class="mw-empty-elt"></li>
31265 <li class="mw-empty-elt"></li>
31266 <li>b</li></ul>
31267 !! end
31268
31269 !! test
31270 Thumbnail output
31271 !! wikitext
31272 [[File:Thumb.png|thumb]]
31273 !! html/php+tidy
31274 <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>
31275 !! html/parsoid
31276 <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>
31277 !! end
31278
31279 !! test
31280 unclosed internal link XSS (T137264)
31281 !! wikitext
31282 [[#%3Cscript%3Ealert(1)%3C/script%3E|
31283 !! html/php
31284 <p>[[#&lt;script&gt;alert(1)&lt;/script&gt;|
31285 </p>
31286 !! html/parsoid
31287 <p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p>
31288 !! end
31289
31290 !! test
31291 Validating that <style> isn't eaten by tidy (T167349)
31292 !! options
31293 styletag=1
31294 !! wikitext
31295 <div class="foo">
31296 <style>.foo::before { content: "<foo>"; }</style>
31297 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
31298 </div>
31299 !! html/php+tidy
31300 <div class="foo">
31301 <style>.foo::before { content: "<foo>"; }</style>
31302 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
31303 </div>
31304 !! html/parsoid
31305 <div class="foo">
31306 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31307 <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>
31308 </div>
31309 !! end
31310
31311 ## Right now, Parsoid doesn't de-duplicate style tags.
31312 ## So, we shouldn't see link tags that need to bypass the sanitizer.
31313 ## In a followup patch, when we de-duplicate style tags and
31314 ## introduce link tags, we'll add a hook for link tags in
31315 ## the parser test runner script.
31316 !! test
31317 Validating that <style> isn't wrapped in a paragraph (T186965)
31318 !! options
31319 styletag=1
31320 !! wikitext
31321 A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31322
31323 <style>.foo::before { content: "<foo>"; }</style>
31324
31325 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
31326
31327 But if it's on a line with other content, let it be wrapped.
31328
31329 <style>.foo::before { content: "<foo>"; }</style> bar
31330
31331 foo <style>.foo::before { content: "<foo>"; }</style>
31332
31333 foo <style>.foo::before { content: "<foo>"; }</style> bar
31334
31335 And the same if we have non-paragraph-breaking whitespace
31336
31337 foo
31338 <style>.foo::before { content: "<foo>"; }</style>
31339 bar
31340 !! html/php
31341 <p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31342 </p>
31343 <style>.foo::before { content: "<foo>"; }</style>
31344 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
31345 <p>But if it's on a line with other content, let it be wrapped.
31346 </p><p><style>.foo::before { content: "<foo>"; }</style> bar
31347 </p><p>foo <style>.foo::before { content: "<foo>"; }</style>
31348 </p><p>foo <style>.foo::before { content: "<foo>"; }</style> bar
31349 </p><p>And the same if we have non-paragraph-breaking whitespace
31350 </p><p>foo
31351 <style>.foo::before { content: "<foo>"; }</style>
31352 bar
31353 </p>
31354 !! html/parsoid
31355 <p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph</p>
31356
31357 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31358
31359 <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>
31360
31361 <p>But if it's on a line with other content, let it be wrapped.</p>
31362
31363 <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>
31364
31365 <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>
31366
31367 <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>
31368
31369 <p>And the same if we have non-paragraph-breaking whitespace</p>
31370
31371 <p>foo
31372 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31373 bar</p>
31374 !! end
31375
31376 !! test
31377 Validating that <link> isn't wrapped in a paragraph (T186965)
31378 !! options
31379 styletag=1
31380 !! wikitext
31381 A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31382
31383 <link rel="foo" href="bar"/>
31384
31385 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
31386
31387 But if it's on a line with other content, let it be wrapped.
31388
31389 <link rel="foo" href="bar"/> bar
31390
31391 foo <link rel="foo" href="bar"/>
31392
31393 foo <link rel="foo" href="bar"/> bar
31394
31395 And the same if we have non-paragraph-breaking whitespace
31396
31397 foo
31398 <link rel="foo" href="bar"/>
31399 bar
31400 !! html/php
31401 <p>A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31402 </p>
31403 <link rel="foo" href="bar"/>
31404 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
31405 <p>But if it's on a line with other content, let it be wrapped.
31406 </p><p><link rel="foo" href="bar"/> bar
31407 </p><p>foo <link rel="foo" href="bar"/>
31408 </p><p>foo <link rel="foo" href="bar"/> bar
31409 </p><p>And the same if we have non-paragraph-breaking whitespace
31410 </p><p>foo
31411 <link rel="foo" href="bar"/>
31412 bar
31413 </p>
31414 !! end
31415
31416 !! test
31417 Extension returning multiple nodes starting with a style tag roundtrips
31418 !! options
31419 wgRawHtml=1
31420 !! wikitext
31421 <table>
31422 {{echo|<html><style>.hi { color: red; }</style>
31423 </html>}}
31424 <tr><td class="hi">ho</td></tr>
31425 </table>
31426 !! html/parsoid
31427 <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">
31428 </span></p><table about="#mwt5" data-parsoid='{"stx":"html"}'>
31429
31430 <tbody><tr><td class="hi">ho</td></tr>
31431 </tbody></table>
31432 !! end
31433
31434 !! test
31435 Decoding of HTML entities in headings and links for IDs and link fragments (T103714)
31436 !! config
31437 wgFragmentMode=[ 'html5', 'legacy' ]
31438 !! wikitext
31439 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
31440 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
31441 !! html/php
31442 <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>
31443 <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>
31444 </p>
31445 !! html/parsoid
31446 <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>
31447 <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>
31448 !! end
31449
31450 !! test
31451 Decoding of HTML entities in headings and links for IDs and link fragments (T103714) (legacy)
31452 !! config
31453 wgFragmentMode=[ 'legacy' ]
31454 !! wikitext
31455 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
31456 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
31457 !! html/php
31458 <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>
31459 <p><a href="#A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a>
31460 </p>
31461 !! end
31462
31463 !! test
31464 Decoding of HTML entities in embedded HTML tags
31465 !! wikitext
31466 <table class="1&2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
31467 !! html/php
31468 <table class="1&amp;2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
31469
31470 !! html/parsoid
31471 <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>
31472 !! end
31473
31474 !! test
31475 Decoding of HTML entities in indicator names for IDs (T104196)
31476 !! options
31477 parsoid=wt2html,html2html
31478 showindicators
31479 !! wikitext
31480 <indicator name="1&2&amp;3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
31481 !! html/php
31482 1&2&3&amp;4&amp;amp;5=Indicator
31483
31484 !! html/parsoid
31485 <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>
31486 !! end
31487
31488 # this version of the test strips out the ambiguity so Parsoid rts cleanly
31489 !! test
31490 Decoding of HTML entities in indicator names for IDs (unambiguous) (T104196)
31491 !! options
31492 showindicators
31493 !! wikitext
31494 <indicator name="1&2&3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
31495 !! html/php
31496 1&2&3&amp;4&amp;amp;5=Indicator
31497
31498 !! html/parsoid
31499 <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>
31500 !! end
31501
31502 # This fragment mode is what Parsoid supports.
31503 !! test
31504 HTML5 ids: fallback to legacy
31505 !! config
31506 wgFragmentMode=[ 'html5', 'legacy' ]
31507 !! wikitext
31508 ==Foo bar==
31509
31510 ==foo Bar==
31511
31512 ==Тест==
31513
31514 ==Тест==
31515
31516 ==тест==
31517
31518 ==Hey < # " > % : '==
31519 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31520
31521 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31522
31523 <!-- These two links should produce identical HTML -->
31524 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31525
31526 !! html/php
31527 <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>
31528 <ul>
31529 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31530 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31531 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
31532 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
31533 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
31534 <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>
31535 </ul>
31536 </div>
31537
31538 <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>
31539 <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>
31540 <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>
31541 <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>
31542 <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>
31543 <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>
31544 <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>
31545 </p><p>💩 <span id="💩"></span>
31546 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
31547 </p>
31548 !! html/parsoid
31549 <h2 id="Foo_bar">Foo bar</h2>
31550
31551 <h2 id="foo_Bar_2">foo Bar</h2>
31552
31553 <h2 id="Тест"><span id=".D0.A2.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>Тест</h2>
31554
31555 <h2 id="Тест_2"><span id=".D0.A2.D0.B5.D1.81.D1.82_2" typeof="mw:FallbackId"></span>Тест</h2>
31556
31557 <h2 id="тест"><span id=".D1.82.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>тест</h2>
31558
31559 <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>
31560 <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>
31561
31562 <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>
31563
31564 <!-- These two links should produce identical HTML -->
31565 <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>
31566 !! end
31567
31568 # Parsoid doesn't support this mode
31569 !! test
31570 HTML5 ids: legacy with a fallback to modern
31571 !! config
31572 wgFragmentMode=[ 'legacy', 'html5' ]
31573 !! wikitext
31574 ==Foo bar==
31575
31576 ==foo Bar==
31577
31578 ==Тест==
31579
31580 ==Тест==
31581
31582 ==тест==
31583
31584 ==Hey < # " > % : '==
31585 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31586
31587 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31588
31589 <!-- These two links should produce identical HTML -->
31590 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31591
31592 !! html/php
31593 <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>
31594 <ul>
31595 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31596 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31597 <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>
31598 <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>
31599 <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>
31600 <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>
31601 </ul>
31602 </div>
31603
31604 <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>
31605 <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>
31606 <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>
31607 <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>
31608 <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>
31609 <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>
31610 <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>
31611 </p><p>.F0.9F.92.A9 <span id=".F0.9F.92.A9"></span>
31612 </p><p><a href="#.E5.95.A4.E9.85.92">#啤酒</a> <a href="#.E5.95.A4.E9.85.92">#啤酒</a>
31613 </p>
31614 !! end
31615
31616 # Parsoid doesn't support this mode.
31617 !! test
31618 HTML5 ids: no legacy
31619 !! config
31620 wgFragmentMode=[ 'html5' ]
31621 !! wikitext
31622 ==Foo bar==
31623
31624 ==foo Bar==
31625
31626 ==Тест==
31627
31628 ==Тест==
31629
31630 ==тест==
31631
31632 ==Hey < # " > % : '==
31633 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31634
31635 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31636
31637 <!-- These two links should produce identical HTML -->
31638 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31639
31640 !! html/php
31641 <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>
31642 <ul>
31643 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31644 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31645 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
31646 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
31647 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
31648 <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>
31649 </ul>
31650 </div>
31651
31652 <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>
31653 <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>
31654 <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>
31655 <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>
31656 <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>
31657 <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>
31658 <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>
31659 </p><p>💩 <span id="💩"></span>
31660 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
31661 </p>
31662 !! end
31663
31664 !! test
31665 T90902: Normalize weird characters in section IDs
31666 !! config
31667 wgFragmentMode=[ 'html5', 'legacy' ]
31668 !! wikitext
31669 ==Foo&nbsp;bar==
31670 [[#Foo&nbsp;bar]]
31671
31672 !! html/php
31673 <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>
31674 <p><a href="#Foo_bar">#Foo&#160;bar</a>
31675 </p>
31676 !! html/parsoid
31677 <h2 id="Foo_bar"> Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span>bar </h2>
31678 <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>
31679 !! end
31680
31681 !! test
31682 T51672: Test for brackets in attributes of elements in external link texts
31683 !! wikitext
31684 [http://example.com/ link <span title="title with [brackets]">span</span>]
31685 [http://example.com/ link <span title="title with &#91;brackets&#93;">span</span>]
31686
31687 !! html/php
31688 <p><a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
31689 <a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
31690 </p>
31691 !! html/parsoid
31692 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/">link <span title="title with [brackets]">span</span></a>
31693 <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>
31694 !! end
31695
31696 !! test
31697 T72875: Test for brackets in attributes of elements in internal link texts
31698 !! wikitext
31699 [[Foo|link <span title="title with [[double brackets]]">span</span>]]
31700 [[Foo|link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span>]]
31701
31702 !! html/php
31703 <p><a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
31704 <a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
31705 </p>
31706 !! html/parsoid
31707 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">link <span title="title with [[double brackets]]">span</span></a>
31708 <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>
31709 !! end
31710
31711 !! test
31712 T199926: html arrow wt: Parsoid sometimes trips up on verticalbar chars in hrefs
31713 !! options
31714 parsoid={
31715 "modes": ["html2wt"]
31716 }
31717 !! html/parsoid
31718 <a href="https://stats.wikimedia.org/v2/#/fr.wikipedia.org/reading/page-views-by-country/normal|map|2-Year~2016060100~2018071100|~total">9</a>
31719 <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>
31720 !! wikitext
31721 [https://stats.wikimedia.org/v2/#/fr.wikipedia.org/reading/page-views-by-country/normal|map|2-Year~2016060100~2018071100|~total 9]
31722 [[stats:v2/#/fr.wikipedia.org/reading/page-views-by-country/normal%7Cmap%7C2-Year~2016060100~2018071100%7C~total|10]]
31723 !! end
31724
31725 !! test
31726 T179544: {{anchorencode:}} output should be always usable in links
31727 !! config
31728 wgFragmentMode=[ 'html5' ]
31729 !! wikitext
31730 <span id="{{anchorencode:[foo]}}"></span>[[#{{anchorencode:[foo]}}]]
31731 !! html/php
31732 <p><span id="&#91;foo&#93;"></span><a href="#[foo]">#&#91;foo&#93;</a>
31733 </p>
31734 !! html/parsoid
31735 <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>
31736 !! end
31737
31738 ## ------------------------------
31739 ## Parsoid section-wrapping tests
31740 ## ------------------------------
31741 !! test
31742 Section wrapping for well-nested sections (no leading content)
31743 !! options
31744 parsoid={
31745 "wrapSections": true
31746 }
31747 !! wikitext
31748 =1=
31749 a
31750
31751 =2=
31752 b
31753
31754 ==2.1==
31755 c
31756
31757 ==2.2==
31758 d
31759
31760 ===2.2.1===
31761 e
31762
31763 =3=
31764 f
31765 !! html/parsoid
31766 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
31767 <p>a</p>
31768
31769 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
31770 <p>b</p>
31771
31772 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
31773 <p>c</p>
31774
31775 </section><section data-mw-section-id="4"><h2 id="2.2">2.2</h2>
31776 <p>d</p>
31777
31778 <section data-mw-section-id="5"><h3 id="2.2.1">2.2.1</h3>
31779 <p>e</p>
31780
31781 </section></section></section><section data-mw-section-id="6"><h1 id="3">3</h1>
31782 <p>f</p>
31783
31784 </section>
31785 !! end
31786
31787 !! test
31788 Section wrapping for well-nested sections (with leading content)
31789 !! options
31790 parsoid={
31791 "wrapSections": true
31792 }
31793 !! wikitext
31794 Para 1.
31795
31796 Para 2 with a <div>nested in it</div>
31797
31798 Para 3.
31799
31800 =1=
31801 a
31802
31803 =2=
31804 b
31805
31806 ==2.1==
31807 c
31808 !! html/parsoid
31809 <section data-mw-section-id="0"><p>Para 1.</p>
31810
31811 <p>Para 2 with a </p><div>nested in it</div>
31812
31813 <p>Para 3.</p>
31814
31815 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
31816 <p>a</p>
31817
31818 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
31819 <p>b</p>
31820
31821 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
31822 <p>c</p>
31823
31824 </section></section>
31825 !! end
31826
31827 !! test
31828 Section wrapping with template-generated sections (good nesting 1)
31829 !! options
31830 parsoid={
31831 "wrapSections": true
31832 }
31833 !! wikitext
31834 =1=
31835 a
31836
31837 {{echo|1=
31838 ==1.1==
31839 b
31840 }}
31841
31842 ==1.2==
31843 c
31844
31845 =2=
31846 d
31847 !! html/parsoid
31848 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
31849 <p>a</p>
31850
31851 <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">
31852 </span><p about="#mwt1">b</p>
31853 </section><section data-mw-section-id="3"><h2 id="1.2">1.2</h2>
31854 <p>c</p>
31855
31856 </section></section><section data-mw-section-id="4"><h1 id="2">2</h1>
31857 <p>d</p></section>
31858 !! end
31859
31860 # In this example, the template scope is mildly expanded to incorporate the
31861 # trailing newline after the transclusion since that is part of section 1.1.1
31862 !! test
31863 Section wrapping with template-generated sections (good nesting 2)
31864 !! options
31865 parsoid={
31866 "wrapSections": true,
31867 "modes": ["wt2html", "wt2wt"]
31868 }
31869 !! wikitext
31870 =1=
31871 a
31872
31873 {{echo|1=
31874 ==1.1==
31875 b
31876 ===1.1.1===
31877 d
31878 }}
31879 =2=
31880 e
31881 !! html/parsoid
31882 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
31883 <p>a</p>
31884
31885 <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">
31886 </span><p about="#mwt1">b</p><span about="#mwt1">
31887 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.1.1">1.1.1</h3><span about="#mwt1">
31888 </span><p about="#mwt1">d</p><span about="#mwt1">
31889 </span></section></section></section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="2">2</h1>
31890 <p>e</p></section>
31891 !! end
31892
31893 # In this example, the template scope is mildly expanded to incorporate the
31894 # trailing newline after the transclusion since that is part of section 1.2.1
31895 !! test
31896 Section wrapping with template-generated sections (good nesting 3)
31897 !! options
31898 parsoid={
31899 "wrapSections": true,
31900 "modes": ["wt2html", "wt2wt"]
31901 }
31902 !! wikitext
31903 =1=
31904 a
31905
31906 {{echo|1=
31907 x
31908 ==1.1==
31909 b
31910 ==1.2==
31911 c
31912 ===1.2.1===
31913 d
31914 }}
31915 =2=
31916 e
31917 !! html/parsoid
31918 <section data-mw-section-id="0"></section><section data-mw-section-id="1" data-parsoid="{}"><h1 id="1"> 1 </h1>
31919 <p>a</p>
31920
31921 <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">
31922 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.1">1.1</h2><span about="#mwt1">
31923 </span><p about="#mwt1">b</p><span about="#mwt1">
31924 </span></section><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.2">1.2</h2><span about="#mwt1">
31925 </span><p about="#mwt1">c</p><span about="#mwt1">
31926 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.2.1">1.2.1</h3><span about="#mwt1">
31927 </span><p about="#mwt1">d</p><span about="#mwt1">
31928 </span></section></section></section><section data-mw-section-id="5"><h1 id="2">2</h1>
31929 <p>e</p></section>
31930 !! end
31931
31932 # Because of section-wrapping and template-wrapping interactions,
31933 # the scope of the template is expanded so that the template markup
31934 # is valid in the presence of <section> tags.
31935 # This exercises the s1 is null scenario in the wrapSections code
31936 !! test
31937 Section wrapping with template-generated sections (bad nesting 1)
31938 !! options
31939 parsoid={
31940 "wrapSections": true
31941 }
31942 !! wikitext
31943 <div>
31944 a
31945
31946 {{echo|
31947 =1=
31948 b
31949 }}
31950
31951 c
31952 </div>
31953 !! html/parsoid
31954 <section data-mw-section-id="-1"></section><section data-mw-section-id="-2"><div data-parsoid='{"stx":"html"}'>
31955 <p>a</p>
31956
31957 <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"]}'>
31958 </span><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="1">1</h1><span about="#mwt1">
31959 </span><p about="#mwt1">b
31960 </p><span about="#mwt1">
31961
31962 </span><p about="#mwt1">c</p><span about="#mwt1">
31963 </span></section></div></section>
31964 !! end
31965
31966 # Because of section-wrapping and template-wrapping interactions,
31967 # the scope of the template is expanded so that the template markup
31968 # is valid in the presence of <section> tags.
31969 # This exercises the s1 is ancestor of s2 scenario in the wrapSections code
31970 !! test
31971 Section wrapping with template-generated sections (bad nesting 2)
31972 !! options
31973 parsoid={
31974 "wrapSections": true
31975 }
31976 !! wikitext
31977 =1=
31978 a
31979
31980 {{echo|1=
31981 =2=
31982 b
31983 ==2.1==
31984 c
31985 }}
31986
31987 d
31988
31989 =3=
31990 e
31991 !! html/parsoid
31992 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
31993 <p>a</p>
31994
31995 </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">
31996 </span><p about="#mwt1">b</p><span about="#mwt1">
31997 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="2.1">2.1</h2><span about="#mwt1">
31998 </span><p about="#mwt1">c</p><span about="#mwt1">
31999
32000 </span><p about="#mwt1">d</p><span about="#mwt1">
32001
32002 </span></section></section><section data-mw-section-id="4"><h1 id="3">3</h1>
32003 <p>e</p></section>
32004 !! end
32005
32006 # Because of section-wrapping and template-wrapping interactions,
32007 # additional template wrappers are added to <section> tags
32008 # so that template wrapping semantics are valid whether section
32009 # tags are retained or stripped. But, the template scope can expand
32010 # greatly when accounting for section tags.
32011 # This exercises the s1 and s2 are in different subtrees scenario
32012 !! test
32013 Section wrapping with template-generated sections (bad nesting 3)
32014 !! options
32015 parsoid={
32016 "wrapSections": true,
32017 "modes": ["wt2html", "wt2wt"]
32018 }
32019 !! wikitext
32020 =1=
32021 a
32022
32023 {{echo|1=
32024 ==1.2==
32025 b
32026 =2=
32027 c
32028 }}
32029
32030 d
32031
32032 =3=
32033 e
32034 !! html/parsoid
32035 <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>
32036 <p>a</p>
32037
32038 <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">
32039 </span><p about="#mwt1">b</p><span about="#mwt1">
32040 </span></section></section><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="2">2</h1><span about="#mwt1">
32041 </span><p about="#mwt1">c</p>
32042
32043 <p>d</p>
32044 </section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="3">3</h1>
32045 <p>e</p></section>
32046 !! end
32047
32048 !! test
32049 Section wrapping with uneditable lead section + div wrapping multiple sections
32050 !! options
32051 parsoid={
32052 "wrapSections": true
32053 }
32054 !! wikitext
32055 foo
32056
32057 <div style="border:1px solid red;">
32058 =1=
32059 a
32060
32061 ==1.1==
32062 b
32063
32064 =2=
32065 c
32066 </div>
32067
32068 =3=
32069 d
32070
32071 ==3.1==
32072 e
32073 !! html/parsoid
32074 <section data-mw-section-id="-1"><p>foo</p>
32075
32076 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
32077 <section data-mw-section-id="1"><h1 id="1">1</h1>
32078 <p>a</p>
32079
32080 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
32081 <p>b</p>
32082
32083 </section></section><section data-mw-section-id="-1"><h1 id="2">2</h1>
32084 <p>c</p>
32085 </section></div>
32086
32087 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
32088 <p>d</p>
32089
32090 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
32091 <p>e</p>
32092 </section></section>
32093 !! end
32094
32095 !! test
32096 Section wrapping with editable lead section + div overlapping multiple sections
32097 !! options
32098 parsoid={
32099 "wrapSections": true
32100 }
32101 !! wikitext
32102 foo
32103
32104 =1=
32105 a
32106 <div style="border:1px solid red;">
32107 b
32108
32109 ==1.1==
32110 c
32111
32112 =2=
32113 d
32114 </div>
32115 e
32116
32117 =3=
32118 f
32119
32120 ==3.1==
32121 g
32122 !! html/parsoid
32123 <section data-mw-section-id="0"><p>foo</p>
32124
32125 </section><section data-mw-section-id="-1"><h1 id="1">1</h1>
32126 <p>a</p>
32127 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
32128 <p>b</p>
32129
32130 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
32131 <p>c</p>
32132
32133 </section><section data-mw-section-id="-1"><h1 id="2">2</h1>
32134 <p>d</p>
32135 </section></div>
32136 <p>e</p>
32137
32138 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
32139 <p>f</p>
32140
32141 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
32142 <p>g</p>
32143 </section></section>
32144 !! end
32145
32146 !! test
32147 HTML header tags should not be wrapped in section tags
32148 !! options
32149 parsoid={
32150 "wrapSections": true
32151 }
32152 !! wikitext
32153 foo
32154
32155 <h1>a</h1>
32156
32157 =b=
32158
32159 <h1>c</h1>
32160
32161 =d=
32162 !! html/parsoid
32163 <section data-mw-section-id="0"><p>foo</p>
32164
32165 <h1 id="a" data-parsoid='{"stx":"html"}'>a</h1>
32166
32167 </section><section data-mw-section-id="1"><h1 id="b">b</h1>
32168
32169 <h1 id="c" data-parsoid='{"stx":"html"}'>c</h1>
32170
32171 </section><section data-mw-section-id="2"><h1 id="d">d</h1></section>
32172 !! end
32173
32174 !! test
32175 Lead section containing only whitespace and comments.
32176 !! options
32177 parsoid={
32178 "wrapSections": true
32179 }
32180 !! wikitext
32181
32182 <!-- this is a comment, presumably significant to editors -->
32183 =1=
32184 a
32185
32186 =2=
32187 b
32188 !! html/parsoid
32189 <section data-mw-section-id="0" data-parsoid="{}">
32190 <!-- this is a comment, presumably significant to editors -->
32191 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
32192 <p>a</p>
32193
32194 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
32195 <p>b</p></section>
32196 !! end
32197
32198 !! test
32199 Pseudo-sections emitted by templates should have id -2
32200 !! options
32201 parsoid={
32202 "wrapSections": true
32203 }
32204 !! wikitext
32205 foo
32206 {{echo|<div>
32207 ==a==
32208 ==b==
32209 </div>
32210 }}
32211 !! html/parsoid
32212 <section data-mw-section-id="-1"><p>foo</p>
32213 </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}}]}'>
32214 <section data-mw-section-id="-1"><h2 id="a">a</h2>
32215 </section><section data-mw-section-id="-1"><h2 id="b">b</h2>
32216 </section></div><span about="#mwt1">
32217 </span></section>
32218 !! end
32219
32220 ##########################################################################
32221 Tests demonstrating white-space insensitivity in input wikitext
32222 for wikitext headings, wikitext list items, and wikitext table captions,
32223 headings, and cells. HTML versions of the same should preserve whitespace.
32224 ##########################################################################
32225 !! test
32226 Trim whitespace in wikitext headings, list items, table captions, headings, and cells
32227 !! options
32228 parsoid={
32229 "modes": ["wt2html"],
32230 "preserveIEW": true
32231 }
32232 !! wikitext
32233 __NOTOC__
32234 == <!--c1--> <!--c2--> Spaces <!--c3--> <!--c4--> ==
32235 == <!--c1--> <!--c2--> Tabs <!--c3--><!--c4--> ==
32236 == <!--Headings with fallback ids--> Личная жизнь ==
32237 * <!--c1--> <!--c2--> List item <!--c3--> <!--c4-->
32238 ; <!--term to define--> term : <!--term's definition--> definition
32239 {|
32240 |+ <!--c1--> <!--c2--> Table Caption <!--c3--> <!--c4-->
32241 |-
32242 ! <!--c1--> <!--c2--> Table Heading 1 <!--c3--> <!--c4--> !! Table Heading 2 <!--c5-->
32243 |-
32244 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
32245 |-
32246 | class="foo" || <!--c1--> <!--c2--> Table Cell 3 <!--c3--> <!--c4-->
32247 |-
32248 | <!--c1--> testing [[one|two]] <!--c2--> | <!--c3--> some content
32249 |}
32250 : {|
32251 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
32252 |} foo <!--c1-->
32253 !! html/php+tidy
32254 <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>
32255 <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>
32256 <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>
32257 <ul><li>List item</li></ul>
32258 <dl><dt>term&#160;</dt>
32259 <dd>definition</dd></dl>
32260 <table>
32261 <caption>Table Caption
32262 </caption>
32263 <tbody><tr>
32264 <th>Table Heading 1</th>
32265 <th>Table Heading 2
32266 </th></tr>
32267 <tr>
32268 <td>Table Cell 1</td>
32269 <td>Table Cell 2
32270 </td></tr>
32271 <tr>
32272 <td>class="foo"</td>
32273 <td>Table Cell 3
32274 </td></tr>
32275 <tr>
32276 <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
32277 </td></tr></tbody></table>
32278 <dl><dd><table>
32279 <tbody><tr>
32280 <td>Table Cell 1</td>
32281 <td>Table Cell 2
32282 </td></tr></tbody></table> foo</dd></dl>
32283 !! html/parsoid
32284 <meta property="mw:PageProp/notoc">
32285 <h2 id="Spaces"><!--c1--><!--c2-->Spaces<!--c3--><!--c4--></h2>
32286 <h2 id="Tabs"><!--c1--><!--c2-->Tabs<!--c3--><!--c4--></h2>
32287 <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>
32288 <ul><li><!--c1--><!--c2-->List item<!--c3--><!--c4--></li></ul>
32289 <dl><dt><!--term to define-->term&nbsp;</dt><dd><!--term's definition-->definition</dd></dl>
32290 <table>
32291 <caption><!--c1--><!--c2-->Table Caption<!--c3--><!--c4--></caption>
32292 <tbody><tr>
32293 <th><!--c1--><!--c2-->Table Heading 1<!--c3--><!--c4--></th><th>Table Heading 2<!--c5--></th></tr>
32294 <tr>
32295 <td><!--c1--><!--c2-->Table Cell 1<!--c3--><!--c4--></td><td>Table Cell 2<!--c5--></td></tr>
32296 <tr>
32297 <td>class="foo"</td><td><!--c1--><!--c2-->Table Cell 3<!--c3--><!--c4--></td></tr>
32298 <tr>
32299 <td><!--c1-->testing <a rel="mw:WikiLink" href="./One" title="One">two</a> <!--c2--> | <!--c3--> some content</td></tr>
32300 </tbody></table>
32301 <dl><dd><table>
32302 <tbody><tr><td><!--c1--><!--c2-->Table Cell 1<!--c3--><!--c4--></td><td>Table Cell 2<!--c5--></td></tr>
32303 </tbody></table> foo<!--c1--></dd></dl>
32304 !! end
32305
32306 # Looks like <caption> is not accepted in HTML
32307 !! test
32308 Do not trim whitespace in HTML headings, list items, table captions, headings, and cells
32309 !! options
32310 parsoid={
32311 "modes": ["wt2html"],
32312 "preserveIEW": true
32313 }
32314 !! wikitext
32315 __NOTOC__
32316 <h2> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
32317 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
32318 <table>
32319 <tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> <th></tr>
32320 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> <th></tr>
32321 </table>
32322 !! html/php+tidy
32323 <h2><span class="mw-headline" id="Heading"> Heading </span></h2>
32324 <ul><li> List item </li></ul>
32325 <table>
32326 <tbody><tr><th> Table Heading </th><th></th></tr>
32327 <tr><td> Table Cell </td><th></th></tr>
32328 </tbody></table>
32329 !! html/parsoid
32330 <meta property="mw:PageProp/notoc"/>
32331 <h2 id="Heading"> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
32332 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
32333 <table>
32334 <tbody><tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> </th><th></th></tr>
32335 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> </td><th></th></tr>
32336 </tbody></table>
32337 !! end
32338
32339 !! test
32340 Do not trim whitespace in links and quotes
32341 !! options
32342 parsoid={
32343 "modes": ["wt2html"],
32344 "preserveIEW": true
32345 }
32346 !! wikitext
32347 foo '' <!--c1--> italic <!--c2--> '' and ''' <!--c3--> bold <!--c4--> '''
32348 [[Foo| some text ]]
32349 !! html/php+tidy
32350 <p>foo <i> italic </i> and <b> bold </b>
32351 <a href="/wiki/Foo" title="Foo"> some text </a>
32352 </p>
32353 !! html/parsoid
32354 <p>foo <i> <!--c1--> italic <!--c2--> </i> and <b> <!--c3--> bold <!--c4--> </b>
32355 <a rel="mw:WikiLink" href="./Foo" title="Foo"> some text </a></p>
32356 !! end
32357
32358 !! test
32359 Remove p tags surrounding a single element in a figcaption
32360 !! options
32361 parsoid=html2wt
32362 !! wikitext
32363 [[File:Foobar.jpg|right|200x200px|Caption]]
32364 !! html/parsoid
32365 <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>
32366 !! end
32367
32368 !! test
32369 Selser preserves lack of newline before list and allows newline after the list
32370 !! options
32371 parsoid={
32372 "modes": ["selser"],
32373 "scrubWikitext": true,
32374 "changes": [
32375 [ "ul", "after", "<p>footer</p>" ]
32376 ]
32377 }
32378 !! wikitext
32379 header
32380 *foo
32381 *bar
32382 !! wikitext/edited
32383 header
32384 *foo
32385 *bar
32386
32387 footer
32388 !! end
32389
32390
32391 !! test
32392 Selser does not introduce newlines between unedited paragraph preceding the list
32393 !! options
32394 parsoid={
32395 "modes": ["selser"],
32396 "changes": [
32397 [ "table tbody tr td p:last-child", "empty" ]
32398 ]
32399 }
32400 !! wikitext
32401 {|
32402 |
32403 header
32404 *foo
32405 *bar
32406 footer
32407 |}
32408 !! wikitext/edited
32409 {|
32410 |
32411 header
32412 *foo
32413 *bar
32414
32415 |}
32416 !! end
32417
32418 !! test
32419 Selser does not introduce newlines between unedited paragraph following the list
32420 !! options
32421 parsoid={
32422 "modes": ["selser"],
32423 "changes": [
32424 [ "table tbody tr td p:first-child", "empty" ]
32425 ]
32426 }
32427 !! wikitext
32428 {|
32429 |
32430 header
32431 *foo
32432 *bar
32433 footer
32434 |}
32435 !! wikitext/edited
32436 {|
32437 |
32438
32439 *foo
32440 *bar
32441 footer
32442 |}
32443 !! end
32444
32445 !! test
32446 Remove a list item but do not insert newline above list
32447 !! options
32448 parsoid={
32449 "modes": ["selser"],
32450 "changes": [
32451 [ "ul li:last-child", "remove" ]
32452 ]
32453 }
32454 !! wikitext
32455 header
32456 *foo
32457 *bar
32458 footer
32459 !! wikitext/edited
32460 header
32461 *foo
32462 footer
32463 !! end