Make "→" link to page section on History page larger by adding section name to it
[lhc/web/wiklou.git] / tests / parser / parserTests.txt
1 # MediaWiki Parser test cases
2 # Some taken from https://meta.wikimedia.org/wiki/Parser_testing
3 # All (C) their respective authors and released under the GPL
4 #
5 # The syntax should be fairly self-explanatory.
6 #
7 # Currently supported test options:
8 # One of the following three:
9 #
10 # (default) generate HTML output
11 # pst apply pre-save transform
12 # msg apply message transform
13 #
14 # Plus any combination of these:
15 #
16 # cat add category links
17 # (ignored by Parsoid, since it emits <link>s)
18 # ill add inter-language links
19 # (ignored by Parsoid, since it emits <link>s)
20 # subpage enable subpages (disabled by default)
21 # title=[[XXX]] run test using article title XXX
22 # language=XXX set content language to XXX for this test
23 # variant=XXX set the variant of language for this test (eg zh-tw)
24 # disabled do not run test
25 # parsoid parsoid-specific options (not run by PHP parser unless
26 # the test includes an html/php section)
27 # php php-only test (not run by the parsoid parser unless
28 # the test includes an html/parsoid section)
29 # showtitle make the first line the title
30 # showindicators make the first lines the page status indicators
31 # comment run through Linker::formatComment() instead of main parser
32 # local format section links in edit comment text as local links
33 # notoc disable table of contents
34 # thumbsize=NNN set the default thumb size to NNNpx for this test
35 # wrap include the normal wrapper <div class="mw-parser-output"> (since 1.30)
36 #
37 # You can also set the following parser properties via test options:
38 # wgEnableUploads, wgAllowExternalImages, wgMaxTocLevel,
39 # wgLinkHolderBatchSize, wgRawHtml, wgInterwikiMagic,
40 # wgEnableMagicLinks, wgMediaInTargetLanguage
41 #
42 # For testing purposes, temporary articles can created:
43 # !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
44 # where '/' denotes a newline.
45
46 # This is the standard article assumed to exist.
47 !! article
48 Main Page
49 !! text
50 blah blah
51 !! endarticle
52
53 !!article
54 Foo
55 !!text
56 FOO
57 !!endarticle
58
59 !!article
60 Foo''s bar''s
61 !!text
62 Article titles can contain single quotes!
63 !!endarticle
64
65 !!article
66 Template:Foo
67 !!text
68 FOO
69 !!endarticle
70
71 !! article
72 Template:redirect to foo
73 !! text
74 #REDIRECT [[Template:Foo]]
75 !! endarticle
76
77 !! article
78 Template:Blank
79 !! text
80 !! endarticle
81
82 !! article
83 Template:pipe
84 !! text
85 |
86 !! endarticle
87
88 !! article
89 Template:=
90 !! text
91 <nowiki>=</nowiki>
92 !! endarticle
93
94 !!article
95 MediaWiki:bad image list
96 !!text
97 * [[File:Bad.jpg]] except [[Nasty page]]
98 !!endarticle
99
100 !! article
101 Template:inner list
102 !! text
103 * item 1
104 !! endarticle
105
106 !! article
107 Template:tbl-start
108 !! text
109 {|
110 !! endarticle
111
112 !! article
113 Template:tbl-end
114 !! text
115 |}
116 !! endarticle
117
118 !! article
119 Template:echo
120 !! text
121 {{{1}}}
122 !! endarticle
123
124 !! article
125 Template:echo3
126 !! text
127 {{{1}}}
128 {{{1}}}
129 {{{1}}}
130 !! endarticle
131
132 // For Serbian; localize Template namespace
133 !! article
134 Шаблон:Echo
135 !! text
136 {{{1}}}
137 !! endarticle
138
139 !! article
140 Template:echo_with_span
141 !! text
142 <span>{{{1}}}</span>
143 !! endarticle
144
145 !! article
146 Template:echo_with_div
147 !! text
148 <div>{{{1}}}</div>
149 !! endarticle
150
151 !! article
152 Template:echo with depth
153 !! text
154 {{echo|{{{1}}}}}
155 !! endarticle
156
157 !! article
158 Template:blank_param
159 !! text
160 {{{1}}}
161 {{{}}}
162 !! endarticle
163
164 !! article
165 Template:table_attribs
166 !! text
167 <noinclude>
168 |</noinclude>style="color:red;"|Foo
169 !! endarticle
170
171 !! article
172 Template:table_attribs_2
173 !! text
174 <noinclude>
175 |</noinclude>style="color:red;"|Foo
176 |Bar||Baz
177 !! endarticle
178
179 !! article
180 Template:table_attribs_3
181 !! text
182 <noinclude>
183 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo
184 !! endarticle
185
186 !! article
187 Template:table_attribs_4
188 !! text
189 | style="background-color:#DC241f;" width="10px" |
190 !! endarticle
191
192 !! article
193 Template:table_attribs_5
194 !! text
195 <noinclude>
196 |</noinclude>style="color:red;"||Bar
197 !! endarticle
198
199 !! article
200 Template:table_attribs_6
201 !! text
202 style="background: <nowiki>
203
204
205 red;</nowiki>" |
206 !! endarticle
207
208 !! article
209 Template:table_attribs_7
210 !! text
211 <noinclude>
212 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo<ref>foo</ref>
213 !! endarticle
214
215 !! article
216 Template:table_header_cells
217 !! text
218 {{table_attribs}}!!style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
219 !! endarticle
220
221 !! article
222 Template:table_cells
223 !! text
224 {{table_attribs}}||style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
225 !! endarticle
226
227 !! article
228 Template:PartialTable
229 !! text
230 {|
231 |-
232 !! endarticle
233
234 !! article
235 Template:image_attribs
236 !! text
237 <noinclude>
238 [[File:foobar.jpg|</noinclude>right|Caption text<noinclude>]]</noinclude>
239 !! endarticle
240
241 ## See T48811 for details
242 !! article
243 Template:mixed_attr_content_template
244 !! text
245 style="color:red;" title="T48811"
246 |-
247 |foo
248 !! endarticle
249
250 !! article
251 Template:definition_list
252 !! text
253 one
254 ::two
255 !! endarticle
256
257 !! article
258 A?b
259 !! text
260 Weirdo titles!
261 !! endarticle
262
263 !!article
264 Template:Bullet
265 !!text
266 *Bar
267 !!endarticle
268
269 !!article
270 Template:OpenTable
271 !!text
272 {|
273 !!endarticle
274
275 !!article
276 Template:EmptyLITest
277 !!text
278 *a
279 *
280 *
281 *b
282 !!endarticle
283
284 !!article
285 Template:EmptyTRTest
286 !!text
287 {|
288 |-
289 |-
290 |foo
291 |-
292 |-
293 |bar
294 |}
295 !!endarticle
296
297 !!article
298 Template:EmptyTRWithHTMLAttrTest
299 !!text
300 <table>
301 <tr align="center"></tr>
302 <tr><td>foo</td></tr>
303 <tr align="center"></tr>
304 <tr><td>bar</td></tr>
305 </table>
306 !!endarticle
307
308 !! article
309 Template:With: Colon
310 !! text
311 Template with colon
312 !! endarticle
313
314 ###
315 ### Basic tests
316 ###
317
318 !! test
319 Blank input
320 !! wikitext
321 !! html
322 !! end
323
324 !! test
325 Simple paragraph
326 !! wikitext
327 This is a simple paragraph.
328 !! html
329 <p>This is a simple paragraph.
330 </p>
331 !! end
332
333 !! test
334 Paragraphs with extra newline spacing
335 !! wikitext
336 a
337
338 b (+2 nls)
339
340
341 c (+3 nls)
342
343
344
345 d (+4 nls)
346
347
348
349
350 e (+5 nls)
351 !! html
352 <p>a
353 </p><p>b (+2 nls)
354 </p><p><br />
355 c (+3 nls)
356 </p><p><br />
357 </p><p>d (+4 nls)
358 </p><p><br />
359 </p><p><br />
360 e (+5 nls)
361 </p>
362 !! end
363
364 !! test
365 Paragraphs with newline spacing with comment lines in between
366 !! wikitext
367 ----
368 a
369 <!--foo-->
370 b
371 ----
372 a
373 <!--foo--><!--More than 1 comment, still stripped-->
374 b
375 ----
376 a
377 <!--foo--> <!----> <!-- bar -->
378 b
379 ----
380 a
381 <!--foo-->
382
383 b
384 ----
385 a
386
387 <!--foo-->
388 b
389 ----
390 a
391 <!--foo-->
392
393
394 b
395 ----
396 a
397
398
399 <!--foo-->
400 b
401 ----
402 !! html
403 <hr />
404 <p>a
405 b
406 </p>
407 <hr />
408 <p>a
409 b
410 </p>
411 <hr />
412 <p>a
413 b
414 </p>
415 <hr />
416 <p>a
417 </p><p>b
418 </p>
419 <hr />
420 <p>a
421 </p><p>b
422 </p>
423 <hr />
424 <p>a
425 </p><p><br />
426 b
427 </p>
428 <hr />
429 <p>a
430 </p><p><br />
431 b
432 </p>
433 <hr />
434
435 !! end
436
437 !! test
438 Paragraphs with newline spacing with non-empty white-space lines in between
439 !! wikitext
440 ----
441 a
442
443 b
444 ----
445 a
446
447
448 b
449 ----
450 !! html
451 <hr />
452 <p>a
453 </p><p>b
454 </p>
455 <hr />
456 <p>a
457 </p><p><br />
458 b
459 </p>
460 <hr />
461
462 !! end
463
464 !! test
465 Paragraphs with newline spacing with non-empty mixed comment and white-space lines in between
466 !! wikitext
467 ----
468 a
469 <!--foo-->
470 b
471 ----
472 a
473 <!--foo--><!--More than 1 comment doesn't disable stripping of this line!-->
474 b
475 ----
476 a
477
478 <!--foo-->
479 <!--bar-->
480 b
481 ----
482 a
483
484 <!--foo-->
485 <!--bar-->
486
487 b
488 ----
489 !! html
490 <hr />
491 <p>a
492 b
493 </p>
494 <hr />
495 <p>a
496 b
497 </p>
498 <hr />
499 <p>a
500 </p><p>b
501 </p>
502 <hr />
503 <p>a
504 </p><p><br />
505 b
506 </p>
507 <hr />
508
509 !! end
510
511 !! test
512 Extra newlines: More paragraphs with indented comment
513 !! wikitext
514 a
515
516 <!--boo-->
517
518 b
519 !! html
520 <p>a
521 </p><p><br />
522 b
523 </p>
524 !!end
525
526 !! test
527 Extra newlines followed by heading
528 !! wikitext
529 a
530
531
532 =b=
533 [[a]]
534
535
536 =b=
537 !! html
538 <p>a
539 </p><p><br />
540 </p>
541 <h1><span class="mw-headline" id="b">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
542 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
543 </p><p><br />
544 </p>
545 <h1><span class="mw-headline" id="b_2">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
546
547 !! end
548
549 !! test
550 Extra newlines between heading and content are swallowed (Parsoid does not)
551 !! wikitext
552 =b=
553
554
555
556 [[a]]
557 !! html/php+tidy
558 <h1><span class="mw-headline" id="b">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
559 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
560 </p>
561 !! html/parsoid
562 <h1 id="b">b</h1>
563 <p>
564 <br></p>
565
566 <p><a rel="mw:WikiLink" href="./A" title="A">a</a></p>
567 !! end
568
569 !! test
570 Extra new lines before and after lists are preserved
571 !! wikitext
572 a
573
574
575 *b
576
577
578 c
579 !! html/php+tidy
580 <p>a
581 </p><p><br />
582 </p>
583 <ul><li>b</li></ul>
584 <p><br />
585 c
586 </p>
587 !! html/parsoid
588 <p>a</p>
589 <p>
590 <br></p>
591 <ul><li>b</li></ul>
592 <p>
593 <br>
594 c</p>
595 !! end
596
597 # Parsoid regression test
598 !!test
599 Multiple newlines after tables are converted to p-br-p tags
600 !!options
601 parsoid=wt2html,wt2wt
602 !!wikitext
603 {|
604 |x
605 |}
606
607
608
609
610 =b=
611 !!html/php+tidy
612 <table>
613 <tbody><tr>
614 <td>x
615 </td></tr></tbody></table>
616 <p><br />
617 </p><p><br />
618 </p>
619 <h1><span class="mw-headline" id="b">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
620 !!html/parsoid
621 <table>
622 <tbody>
623 <tr>
624 <td>x</td>
625 </tr>
626 </tbody>
627 </table>
628 <p><br/></p>
629 <p><br/></p>
630 <h1 id="b">b</h1>
631 !!end
632
633 !! test
634 Heading with line break in nowiki
635 !! options
636 parsoid=wt2html
637 !! config
638 wgFragmentMode=[ 'html5', 'legacy' ]
639 !! wikitext
640 ==A <nowiki>B
641 C</nowiki>==
642 !! html/php
643 <h2><span id="A_B.0AC"></span><span class="mw-headline" id="A_B
644 C">A B
645 C</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: A B&#10;C">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
646
647 !! html/parsoid
648 <h2 id="A_B
649 C"><span id="A_B.0AC" typeof="mw:FallbackId"></span>A <span typeof="mw:Nowiki">B
650 C</span></h2>
651 !! end
652
653 !! test
654 Parsing an URL
655 !! wikitext
656 http://fr.wikipedia.org/wiki/🍺
657 <!-- EasterEgg we love beer, better be able be able to link to it -->
658 !! html
659 <p><a rel="nofollow" class="external free" href="http://fr.wikipedia.org/wiki/🍺">http://fr.wikipedia.org/wiki/🍺</a>
660 </p>
661 !! end
662
663 !! test
664 Simple list
665 !! wikitext
666 *Item 1
667 *Item 2
668 !! html
669 <ul><li>Item 1</li>
670 <li>Item 2</li></ul>
671
672 !! end
673
674 !! test
675 Italics and bold
676 !! wikitext
677 *plain
678 *plain''italic''plain
679 *plain''italic''plain''italic''plain
680 *plain'''bold'''plain
681 *plain'''bold'''plain'''bold'''plain
682 *plain''italic''plain'''bold'''plain
683 *plain'''bold'''plain''italic''plain
684 *plain''italic'''bold-italic'''italic''plain
685 *plain'''bold''bold-italic''bold'''plain
686 *plain'''''bold-italic'''italic''plain
687 *plain'''''bold-italic''bold'''plain
688 *plain''italic'''bold-italic'''''plain
689 *plain'''bold''bold-italic'''''plain
690 *plain l'''italic''plain
691 *plain l''''bold''' plain
692 !! html
693 <ul><li>plain</li>
694 <li>plain<i>italic</i>plain</li>
695 <li>plain<i>italic</i>plain<i>italic</i>plain</li>
696 <li>plain<b>bold</b>plain</li>
697 <li>plain<b>bold</b>plain<b>bold</b>plain</li>
698 <li>plain<i>italic</i>plain<b>bold</b>plain</li>
699 <li>plain<b>bold</b>plain<i>italic</i>plain</li>
700 <li>plain<i>italic<b>bold-italic</b>italic</i>plain</li>
701 <li>plain<b>bold<i>bold-italic</i>bold</b>plain</li>
702 <li>plain<i><b>bold-italic</b>italic</i>plain</li>
703 <li>plain<b><i>bold-italic</i>bold</b>plain</li>
704 <li>plain<i>italic<b>bold-italic</b></i>plain</li>
705 <li>plain<b>bold<i>bold-italic</i></b>plain</li>
706 <li>plain l'<i>italic</i>plain</li>
707 <li>plain l'<b>bold</b> plain</li></ul>
708
709 !! end
710
711 # this example taken from the [[simple:Moon]] article (T49326)
712 !! test
713 Italics and possessives (1)
714 !! wikitext
715 obtained by ''[[Lunar Prospector]]'''s gamma-ray spectrometer
716 !! html
717 <p>obtained by <i><a href="/index.php?title=Lunar_Prospector&amp;action=edit&amp;redlink=1" class="new" title="Lunar Prospector (page does not exist)">Lunar Prospector</a>'</i>s gamma-ray spectrometer
718 </p>
719 !! end
720
721 # this example taken from [[en:Flaming Pie]] (T51926)
722 !! test
723 Italics and possessives (2)
724 !! wikitext
725 '''''Flaming Pie''''' is ... released in 1997. In ''Flaming Pie'''s liner notes
726 !! html
727 <p><i><b>Flaming Pie</b></i> is ... released in 1997. In <i>Flaming Pie'</i>s liner notes
728 </p>
729 !! end
730
731 # this example taken from [[en:Dictionary]] (T51926)
732 !! test
733 Italics and possessives (3)
734 !! wikitext
735 The first monolingual dictionary written in a Romance language was ''Sebastián Covarrubias''' ''Tesoro de la lengua castellana o española'', published in 1611 in Madrid. In 1612 the first edition of the ''Vocabolario dell'[[Accademia della Crusca]]'', for Italian, was published. In 1690 in Rotterdam was published, posthumously, the ''Dictionnaire Universel''.
736 !! html
737 <p>The first monolingual dictionary written in a Romance language was <i>Sebastián Covarrubias'</i> <i>Tesoro de la lengua castellana o española</i>, published in 1611 in Madrid. In 1612 the first edition of the <i>Vocabolario dell'<a href="/index.php?title=Accademia_della_Crusca&amp;action=edit&amp;redlink=1" class="new" title="Accademia della Crusca (page does not exist)">Accademia della Crusca</a></i>, for Italian, was published. In 1690 in Rotterdam was published, posthumously, the <i>Dictionnaire Universel</i>.
738 </p>
739 !! end
740
741
742 ###
743 ### 2-quote opening sequence tests
744 ###
745 !! test
746 Italics and bold: 2-quote opening sequence: (2,2)
747 !! wikitext
748 ''foo''
749 !! html
750 <p><i>foo</i>
751 </p>
752 !!end
753
754 !! test
755 Italics and bold: 2-quote opening sequence: (2,3)
756 !! wikitext
757 ''foo'''
758 !! html/*
759 <p><i>foo'</i>
760 </p>
761 !!end
762
763 !! test
764 Italics and bold: 2-quote opening sequence: (2,4)
765 !! options
766 parsoid=wt2html
767 !! wikitext
768 ''foo''''
769 !! html/*
770 <p><i>foo''</i>
771 </p>
772 !!end
773
774 # same html as previous, but wikitext adjusted to match parsoid html2wt
775 !! test
776 Italics and bold: 2-quote opening sequence: (2,4) w/ nowiki
777 !! wikitext
778 ''foo<nowiki>''</nowiki>''
779 !! html
780 <p><i>foo''</i>
781 </p>
782 !! end
783
784 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
785 !! test
786 Italics and bold: 2-quote opening sequence: (2,5)
787 !! options
788 parsoid=wt2html
789 !! wikitext
790 ''foo'''''
791 !! html/php
792 <p><i>foo</i>
793 </p>
794 !! html/parsoid
795 <p><i>foo</i><b></b>
796 </p>
797 !!end
798
799 # same html as previous, but wikitext adjusted to match parsoid html2wt
800 !! test
801 Italics and bold: 2-quote opening sequence: (2,5+3) w/ nowiki
802 !! wikitext
803 ''foo'''''<nowiki/>'''
804 !! html/php
805 <p><i>foo</i>
806 </p>
807 !! html/parsoid
808 <p><i>foo</i><b></b>
809 </p>
810 !! end
811
812
813 ###
814 ### 3-quote opening sequence tests
815 ###
816
817 !! test
818 Italics and bold: 3-quote opening sequence: (3,2)
819 !! wikitext
820 '''foo''
821 !! html/*
822 <p>'<i>foo</i>
823 </p>
824 !!end
825
826 !! test
827 Italics and bold: 3-quote opening sequence: (3,3)
828 !! wikitext
829 '''foo'''
830 !! html
831 <p><b>foo</b>
832 </p>
833 !!end
834
835 !! test
836 Italics and bold: 3-quote opening sequence: (3,4)
837 !! wikitext
838 '''foo''''
839 !! html/*
840 <p><b>foo'</b>
841 </p>
842 !!end
843
844 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
845 !! test
846 Italics and bold: 3-quote opening sequence: (3,5)
847 !! options
848 parsoid=wt2html
849 !! wikitext
850 '''foo'''''
851 !! html/php
852 <p><b>foo</b>
853 </p>
854 !! html/parsoid
855 <p><b>foo</b><i></i>
856 </p>
857 !!end
858
859 # same html as previous, but wikitext adjusted to match parsoid html2wt
860 !! test
861 Italics and bold: 3-quote opening sequence: (3,5+2) w/ nowiki
862 !! wikitext
863 '''foo'''''<nowiki/>''
864 !! html/php
865 <p><b>foo</b>
866 </p>
867 !! html/parsoid
868 <p><b>foo</b><i></i>
869 </p>
870 !! end
871
872
873 ###
874 ### 4-quote opening sequence tests
875 ###
876
877 !! test
878 Italics and bold: 4-quote opening sequence: (4,2)
879 !! options
880 parsoid=wt2html
881 !! wikitext
882 ''''foo''
883 !! html/*
884 <p>''<i>foo</i>
885 </p>
886 !!end
887
888 # same html as previous, but wikitext adjusted to match parsoid html2wt
889 !! test
890 Italics and bold: 4-quote opening sequence: (4,2) w/ nowiki
891 !! wikitext
892 <nowiki>''</nowiki>''foo''
893 !! html
894 <p>''<i>foo</i>
895 </p>
896 !! end
897
898 !! test
899 Italics and bold: 4-quote opening sequence: (4,3)
900 !! wikitext
901 ''''foo'''
902 !! html/*
903 <p>'<b>foo</b>
904 </p>
905 !!end
906
907 !! test
908 Italics and bold: 4-quote opening sequence: (4,4)
909 !! options
910 parsoid=wt2html
911 !! wikitext
912 ''''foo''''
913 !! html/*
914 <p>'<b>foo'</b>
915 </p>
916 !!end
917
918 # same html as previous, but wikitext adjusted to match parsoid html2wt
919 !! test
920 Italics and bold: 4-quote opening sequence: (4,4) w/ nowiki
921 !! wikitext
922 '<nowiki/>'''foo''''
923 !! html
924 <p>'<b>foo'</b>
925 </p>
926 !! end
927
928 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
929 !! test
930 Italics and bold: 4-quote opening sequence: (4,5)
931 !! options
932 parsoid=wt2html
933 !! wikitext
934 ''''foo'''''
935 !! html/php
936 <p>'<b>foo</b>
937 </p>
938 !! html/parsoid
939 <p>'<b>foo</b><i></i>
940 </p>
941 !!end
942
943 # same html as previous, but wikitext adjusted to match parsoid html2wt
944 !! test
945 Italics and bold: 4-quote opening sequence: (4,5+2) w/ nowiki
946 !! wikitext
947 '<nowiki/>'''foo'''''<nowiki/>''
948 !! html/php
949 <p>'<b>foo</b>
950 </p>
951 !! html/parsoid
952 <p>'<b>foo</b><i></i>
953 </p>
954 !! end
955
956
957 ###
958 ### 5-quote opening sequence tests
959 ###
960
961 !! test
962 Italics and bold: 5-quote opening sequence: (5,2)
963 !! options
964 parsoid=wt2html
965 !! wikitext
966 '''''foo''
967 !! html/*
968 <p><b><i>foo</i></b>
969 </p>
970 !!end
971
972 # same html as previous, but wikitext adjusted to match parsoid html2wt
973 !! test
974 Italics and bold: 5-quote opening sequence: (5,2+3)
975 !! wikitext
976 '''''foo'''''
977 !! html/*
978 <p><i><b>foo</b></i>
979 </p>
980 !! end
981
982 !! test
983 Italics and bold: 5-quote opening sequence: (5,3)
984 !! options
985 parsoid=wt2html
986 !! wikitext
987 '''''foo'''
988 !! html/*
989 <p><i><b>foo</b></i>
990 </p>
991 !!end
992
993 # same html as previous, but wikitext adjusted to match parsoid html2wt
994 !! test
995 Italics and bold: 5-quote opening sequence: (5,3+2)
996 !! wikitext
997 '''''foo'''''
998 !! html
999 <p><i><b>foo</b></i>
1000 </p>
1001 !! end
1002
1003 !! test
1004 Italics and bold: 5-quote opening sequence: (5,4)
1005 !! options
1006 parsoid=wt2html
1007 !! wikitext
1008 '''''foo''''
1009 !! html/*
1010 <p><i><b>foo'</b></i>
1011 </p>
1012 !!end
1013
1014 !! test
1015 Italics and bold: 5-quote opening sequence: (5,5)
1016 !! wikitext
1017 '''''foo'''''
1018 !! html
1019 <p><i><b>foo</b></i>
1020 </p>
1021 !!end
1022
1023 !! test
1024 Italics and bold: 5-quote opening sequence: (5,6)
1025 !! wikitext
1026 '''''foo''''''
1027 !! html/*
1028 <p><i><b>foo'</b></i>
1029 </p>
1030 !! end
1031
1032 ###
1033 ### multiple quote sequences in a line
1034 ###
1035
1036 !! test
1037 Italics and bold: multiple quote sequences: (2,4,2)
1038 !! options
1039 parsoid=wt2html
1040 !! wikitext
1041 ''foo''''bar''
1042 !! html/*
1043 <p><i>foo'<b>bar</b></i>
1044 </p>
1045 !! end
1046
1047 # same html as previous, but wikitext adjusted to match parsoid html2wt
1048 !! test
1049 Italics and bold: multiple quote sequences: (2,4,2+3) w/ nowiki
1050 !! wikitext
1051 ''foo'<nowiki/>'''bar'''''
1052 !! html
1053 <p><i>foo'<b>bar</b></i>
1054 </p>
1055 !! end
1056
1057 !! test
1058 Italics and bold: multiple quote sequences: (2,4,3)
1059 !! options
1060 parsoid=wt2html
1061 !! wikitext
1062 ''foo''''bar'''
1063 !! html/*
1064 <p><i>foo'<b>bar</b></i>
1065 </p>
1066 !! end
1067
1068 # same html as previous, but wikitext adjusted to match parsoid html2wt
1069 !! test
1070 Italics and bold: multiple quote sequences: (2,4,3+2) w/ nowiki
1071 !! wikitext
1072 ''foo'<nowiki/>'''bar'''''
1073 !! html
1074 <p><i>foo'<b>bar</b></i>
1075 </p>
1076 !! end
1077
1078 !! test
1079 Italics and bold: multiple quote sequences: (2,4,4)
1080 !! options
1081 parsoid=wt2html
1082 !! wikitext
1083 ''foo''''bar''''
1084 !! html/*
1085 <p><i>foo'<b>bar'</b></i>
1086 </p>
1087 !! end
1088
1089 # same html as previous, but wikitext adjusted to match parsoid html2wt
1090 !! test
1091 Italics and bold: multiple quote sequences: (2,4,4+2) w/ nowiki
1092 !! wikitext
1093 ''foo'<nowiki/>'''bar'<nowiki/>'''''
1094 !! html
1095 <p><i>foo'<b>bar'</b></i>
1096 </p>
1097 !! end
1098
1099 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1100 !! test
1101 Italics and bold: multiple quote sequences: (3,4,2)
1102 !! options
1103 parsoid=wt2html
1104 !! wikitext
1105 '''foo''''bar''
1106 !! html/php
1107 <p><b>foo'</b>bar
1108 </p>
1109 !! html/parsoid
1110 <p><b>foo'</b>bar<i></i>
1111 </p>
1112 !! end
1113
1114 # same html as previous, but wikitext adjusted to match parsoid html2wt
1115 !! test
1116 Italics and bold: multiple quote sequences: (3,4,2+2) w/ nowiki
1117 !! wikitext
1118 '''foo''''bar''<nowiki/>''
1119 !! html/php
1120 <p><b>foo'</b>bar
1121 </p>
1122 !! html/parsoid
1123 <p><b>foo'</b>bar<i></i>
1124 </p>
1125 !! end
1126
1127 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1128 !! test
1129 Italics and bold: multiple quote sequences: (3,4,3)
1130 !! options
1131 parsoid=wt2html
1132 !! wikitext
1133 '''foo''''bar'''
1134 !! html/php
1135 <p><b>foo'</b>bar
1136 </p>
1137 !! html/parsoid
1138 <p><b>foo'</b>bar<b></b>
1139 </p>
1140 !! end
1141
1142 # same html as previous, but wikitext adjusted to match parsoid html2wt
1143 !! test
1144 Italics and bold: multiple quote sequences: (3,4,3+3) w/ nowiki
1145 !! wikitext
1146 '''foo''''bar'''<nowiki/>'''
1147 !! html/php
1148 <p><b>foo'</b>bar
1149 </p>
1150 !! html/parsoid
1151 <p><b>foo'</b>bar<b></b>
1152 </p>
1153 !! end
1154
1155 ###
1156 ### other quote tests
1157 ###
1158 !! test
1159 Italics and bold: other quote tests: (2,3,5)
1160 !! wikitext
1161 ''this is about '''foo's family'''''
1162 !! html
1163 <p><i>this is about <b>foo's family</b></i>
1164 </p>
1165 !!end
1166
1167
1168 !! test
1169 Italics and bold: other quote tests: (2,(3,3),2)
1170 !! wikitext
1171 ''this is about '''foo's''' family''
1172 !! html
1173 <p><i>this is about <b>foo's</b> family</i>
1174 </p>
1175 !!end
1176
1177
1178 !! test
1179 Italics and bold: other quote tests: (3,2,3,2)
1180 !! options
1181 parsoid=wt2html
1182 !! wikitext
1183 '''this is about ''foo'''s family''
1184 !! html/*
1185 <p><b>this is about <i>foo</i></b><i>s family</i>
1186 </p>
1187 !!end
1188
1189
1190 # same html as previous, but wikitext adjusted to match parsoid html2wt
1191 !! test
1192 Italics and bold: other quote tests: (3,2,3+2+2,2)
1193 !! wikitext
1194 '''this is about ''foo'''''<nowiki/>''s family''
1195 !! html
1196 <p><b>this is about <i>foo</i></b><i>s family</i>
1197 </p>
1198 !! end
1199
1200
1201 !! test
1202 Italics and bold: other quote tests: (3,2,3,3)
1203 !! wikitext
1204 '''this is about ''foo'''s family'''
1205 !! html/*
1206 <p>'<i>this is about </i>foo<b>s family</b>
1207 </p>
1208 !!end
1209
1210
1211 !! test
1212 Italics and bold: other quote tests: (3,(2,2),3)
1213 !! wikitext
1214 '''this is about ''foo's'' family'''
1215 !! html
1216 <p><b>this is about <i>foo's</i> family</b>
1217 </p>
1218 !!end
1219
1220
1221 !! test
1222 Italicized possessive
1223 !! wikitext
1224 The ''[[Main Page]]'''s talk page.
1225 !! html/php
1226 <p>The <i><a href="/wiki/Main_Page" title="Main Page">Main Page</a>'</i>s talk page.
1227 </p>
1228 !! html/parsoid
1229 <p>The <i><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>'</i>s talk page.</p>
1230 !! end
1231
1232 !! test
1233 Quote balancing context should be restricted to td/th cells on the same wikitext line
1234 !! options
1235 parsoid=wt2html,wt2wt
1236 !! wikitext
1237 {|
1238 !''a!!''b
1239 |''a||''b
1240 |}
1241 !! html+tidy
1242 <table>
1243 <tbody><tr>
1244 <th><i>a</i></th>
1245 <th><i>b</i>
1246 </th>
1247 <td><i>a</i></td>
1248 <td><i>b</i>
1249 </td></tr></tbody></table>
1250 !! end
1251
1252 ###
1253 ### Non-html5 tags
1254 ###
1255
1256 !! test
1257 Non-html5 tags should be accepted
1258 !! wikitext
1259 <center>''foo''</center>
1260 <big>''foo''</big>
1261 <font>''foo''</font>
1262 <strike>''foo''</strike>
1263 <tt>''foo''</tt>
1264 !! html
1265 <center><i>foo</i></center>
1266 <p><big><i>foo</i></big>
1267 <font><i>foo</i></font>
1268 <strike><i>foo</i></strike>
1269 <tt><i>foo</i></tt>
1270 </p>
1271 !! end
1272
1273 !! test
1274 <wbr> is valid wikitext (T54468)
1275 !! wikitext
1276 <wbr>
1277 !! html
1278 <p><wbr />
1279 </p>
1280 !! end
1281
1282 # <strike> is HTML4, <s> is HTML4/5.
1283 !! test
1284 <s> or <strike> for strikethrough
1285 !! wikitext
1286 <strike>strike</strike>
1287
1288 <s>s</s>
1289 !! html
1290 <p><strike>strike</strike>
1291 </p><p><s>s</s>
1292 </p>
1293 !! end
1294
1295 ## a not permitted
1296 ## i,b,br omitted
1297 !! test
1298 Text-level semantic html elements in wikitext
1299 !! wikitext
1300 <em>text</em>
1301 <strong>text</strong>
1302 <small>text</small>
1303 <s>text</s>
1304 <cite>text</cite>
1305 <q>text</q>
1306 <dfn>text</dfn>
1307 <abbr>text</abbr>
1308 <data>text</data>
1309 <time>text</time>
1310 <code>text</code>
1311 <var>text</var>
1312 <samp>text</samp>
1313 <kbd>text</kbd>
1314 <sub>text</sub>
1315 <u>text</u>
1316 <mark>text</mark>
1317 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1318 <bdi>text</bdi>
1319 <bdo>text</bdo>
1320 <span>text</span>
1321 <wbr />
1322 !! html
1323 <p><em>text</em>
1324 <strong>text</strong>
1325 <small>text</small>
1326 <s>text</s>
1327 <cite>text</cite>
1328 <q>text</q>
1329 <dfn>text</dfn>
1330 <abbr>text</abbr>
1331 <data>text</data>
1332 <time>text</time>
1333 <code>text</code>
1334 <var>text</var>
1335 <samp>text</samp>
1336 <kbd>text</kbd>
1337 <sub>text</sub>
1338 <u>text</u>
1339 <mark>text</mark>
1340 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1341 <bdi>text</bdi>
1342 <bdo>text</bdo>
1343 <span>text</span>
1344 <wbr />
1345 </p>
1346 !! end
1347
1348 # test cases taken from
1349 # https://www.w3.org/TR/html5/text-level-semantics.html#the-ruby-element
1350 !! test
1351 Ruby markup (W3C-style)
1352 !! wikitext
1353 ;Mono-ruby for individual base characters
1354 :<ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby>
1355 ;Group ruby
1356 :<ruby>今日<rt>きょう</rt></ruby>
1357 ;Jukugo ruby
1358 :<ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby>
1359 ;Inline ruby
1360 :<ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby>
1361 ;Double-sided ruby
1362 :<ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby>
1363
1364 <ruby>
1365 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1366 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1367 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1368 </ruby>
1369 !! html
1370 <dl><dt>Mono-ruby for individual base characters</dt>
1371 <dd><ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby></dd>
1372 <dt>Group ruby</dt>
1373 <dd><ruby>今日<rt>きょう</rt></ruby></dd>
1374 <dt>Jukugo ruby</dt>
1375 <dd><ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby></dd>
1376 <dt>Inline ruby</dt>
1377 <dd><ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby></dd>
1378 <dt>Double-sided ruby</dt>
1379 <dd><ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby></dd></dl>
1380 <p><ruby>
1381 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1382 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1383 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1384 </ruby>
1385 </p>
1386 !! end
1387
1388 # The next two test different paths in the sanitizer.
1389 !! test
1390 Non-word characters don't terminate tag names (T19663, T42670, T54022)
1391 !! wikitext
1392 <blockquote|>a</blockquote>
1393
1394 <b→> doesn't terminate </b→>
1395
1396 <bä> doesn't terminate </bä>
1397
1398 <boo> doesn't terminate </boo>
1399
1400 <s.foo> doesn't terminate </s.foo>
1401
1402 <sub-ID#1>
1403 !! html/php
1404 <p>&lt;blockquote|&gt;a&lt;/blockquote&gt;
1405 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1406 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1407 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1408 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1409 </p><p>&lt;sub-ID#1&gt;
1410 </p>
1411 !! end
1412
1413 !! test
1414 Non-word characters don't terminate tag names
1415 !! wikitext
1416 <blockquote|>a</blockquote>
1417
1418 <b→> doesn't terminate </b→>
1419
1420 <bä> doesn't terminate </bä>
1421
1422 <boo> doesn't terminate </boo>
1423
1424 <s.foo> doesn't terminate </s.foo>
1425
1426 <sub-ID#1>
1427 !! html+tidy
1428 <p>&lt;blockquote|&gt;a
1429 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1430 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1431 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1432 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1433 </p><p>&lt;sub-ID#1&gt;
1434 </p>
1435 !! end
1436
1437 ###
1438 ### See tests/parser/parserTestsParserHook.php for the <tåg> extension)
1439 ### This checks that HTML5 tags (with non-word characters in the tag
1440 ### name) make it safely through the parser -- the Sanitizer will
1441 ### munge them later, as it should.
1442 ###
1443 !! test
1444 Non-word characters are valid in extension tags (T19663)
1445 !! wikitext
1446 <tåg>tåg</tåg>
1447 !! html/php
1448 <pre>
1449 'tåg'
1450 array (
1451 )
1452 </pre>
1453
1454 !! html/parsoid
1455 <pre typeof="mw:Extension/tåg" data-mw='{"name":"tåg","attrs":{},"body":{"extsrc":"tåg"}}' data-parsoid='{}' about="#mwt2"></pre>
1456 !! end
1457
1458 !! test
1459 Isolated close tags should be treated as literal text (T54760)
1460 !! options
1461 parsoid=wt2html
1462 !! wikitext
1463 </b>
1464
1465 <s.foo>s</s>
1466 !! html+tidy
1467 <p class="mw-empty-elt">
1468 </p><p>&lt;s.foo&gt;s
1469 </p>
1470 !! end
1471
1472 ###
1473 ### Special characters
1474 ###
1475
1476 !! test
1477 Bare pipe character (T54363)
1478 !! wikitext
1479 |
1480 !! html
1481 <p>|
1482 </p>
1483 !! end
1484
1485 !! test
1486 Bare pipe character from a template (T54363)
1487 !! wikitext
1488 {{pipe}}
1489 !! html
1490 <p>|
1491 </p>
1492 !! end
1493
1494 ###
1495 ### <nowiki> test cases
1496 ###
1497
1498 !! test
1499 <nowiki> unordered list
1500 !! wikitext
1501 <nowiki>* This is not an unordered list item.</nowiki>
1502 !! html/php
1503 <p>* This is not an unordered list item.
1504 </p>
1505 !! html/parsoid
1506 <p><span typeof="mw:Nowiki">* This is not an unordered list item.</span></p>
1507 !! end
1508
1509 !! test
1510 <nowiki> spacing
1511 !! wikitext
1512 <nowiki>Lorem ipsum dolor
1513
1514 sed abit.
1515 sed nullum.
1516
1517 :and a colon
1518 </nowiki>
1519 !! html/php
1520 <p>Lorem ipsum dolor
1521
1522 sed abit.
1523 sed nullum.
1524
1525 :and a colon
1526
1527 </p>
1528 !! html/parsoid
1529 <p><span typeof="mw:Nowiki">Lorem ipsum dolor
1530
1531 sed abit.
1532 sed nullum.
1533
1534 :and a colon
1535 </span></p>
1536 !! end
1537
1538 !! test
1539 Don't parse <nowiki><span class="error"></nowiki> (T149622)
1540 !! wikitext
1541 <nowiki><span class="error"></nowiki>
1542 !! html/php
1543 <p>&lt;span class="error"&gt;
1544 </p>
1545 !! html/parsoid
1546 <p><span typeof="mw:Nowiki">&lt;span class="error"></span></p>
1547 !! end
1548
1549 !! test
1550 nowiki 3
1551 !! wikitext
1552 :There is not nowiki.
1553 :There is <nowiki>nowiki</nowiki>.
1554
1555 #There is not nowiki.
1556 #There is <nowiki>nowiki</nowiki>.
1557
1558 *There is not nowiki.
1559 *There is <nowiki>nowiki</nowiki>.
1560 !! html/php
1561 <dl><dd>There is not nowiki.</dd>
1562 <dd>There is nowiki.</dd></dl>
1563 <ol><li>There is not nowiki.</li>
1564 <li>There is nowiki.</li></ol>
1565 <ul><li>There is not nowiki.</li>
1566 <li>There is nowiki.</li></ul>
1567
1568 !! html/parsoid
1569 <dl><dd data-parsoid='{}'>There is not nowiki.</dd>
1570 <dd data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</dd></dl>
1571
1572 <ol><li data-parsoid='{}'>There is not nowiki.</li>
1573 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ol>
1574
1575 <ul><li data-parsoid='{}'>There is not nowiki.</li>
1576 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ul>
1577 !! end
1578
1579 !! test
1580 Entities inside <nowiki>
1581 !! wikitext
1582 <nowiki>&lt;</nowiki>
1583 !! html/php
1584 <p>&lt;
1585 </p>
1586 !! html/parsoid
1587 <p><span typeof="mw:Nowiki"><span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span></span></p>
1588 !! end
1589
1590 !! test
1591 Entities inside template parameters
1592 !! wikitext
1593 {{echo|&ndash;}}
1594 !! html/php+tidy
1595 <p>&#8211;
1596 </p>
1597 !! html/parsoid
1598 <p><span typeof="mw:Transclusion mw:Entity" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&amp;ndash;"}},"i":0}}]}'>&ndash;</span></p>
1599 !! end
1600
1601 !! test
1602 Properly escape nowiki when combined with other wiki markup
1603 !! options
1604 parsoid=html2wt
1605 !! html/parsoid
1606 <p>* &lt;/nowiki&gt; tag</p>
1607 !! wikitext
1608 <nowiki>*</nowiki> <nowiki>&lt;/nowiki&gt;</nowiki> tag
1609 !! end
1610
1611 !! test
1612 T93824: Put escaped HTML tags inside nowiki
1613 !! options
1614 parsoid=html2wt
1615 !! html/parsoid
1616 <p>&lt;h2&gt;foo&lt;/h2&gt;</p>
1617 !! wikitext
1618 <nowiki><h2>foo</h2></nowiki>
1619 !! end
1620
1621 !! test
1622 T71950: 1. Put nowiki as close to cause as possible, even with non-quote escapable chars
1623 !! options
1624 parsoid=html2wt
1625 !! html/parsoid
1626 <p>This text: L'<a rel="mw:WikiLink" href="./Foo">Foo</a>
1627 This text: L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1628 This text: L'''<a rel="mw:WikiLink" href="./Foo">Foo</a>''</p>
1629 !! wikitext
1630 This text: L'[[Foo]]
1631 This text: L<nowiki>''</nowiki>[[Foo]]
1632 This text: L<nowiki>'''</nowiki>[[Foo]]<nowiki>''</nowiki>
1633 !! end
1634
1635 # This test fails because wikitext whitespace is not normalized before comparing.
1636 !! test
1637 T71950: 2. Put nowiki as close to cause as possible, after ' :'
1638 !! options
1639 parsoid=html2wt
1640 !! html/parsoid
1641 <p>This text : L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1642 </p>
1643 !! wikitext
1644 This text : L<nowiki>''</nowiki>[[Foo]]
1645 !! end
1646
1647 # This test and the next one are html2wt only as they test that incorrect wikitext
1648 # passed in template arguments gets escaped or wrapped in nowikis where required.
1649 !! test
1650 T71482: Use {{!}} instead of nowiki for single pipe in template argument
1651 !! options
1652 parsoid=html2wt
1653 !! html/parsoid
1654 <p><span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo|bar&quot;}},&quot;i&quot;:0}}]}" about="#mwt1"></span>
1655 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo|bar |[[&quot;}},&quot;i&quot;:0}}]}" about="#mwt2"></p>
1656 !! wikitext
1657 {{echo|foo{{!}}bar}}
1658 {{echo|<nowiki>foo|bar |[[</nowiki>}}
1659 !! end
1660
1661 !! test
1662 T53961: Output correct nowikis in template arguments
1663 !! options
1664 parsoid=html2wt
1665 !! html/parsoid
1666 <p><span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a [ b&quot;}},&quot;i&quot;:0}}]}" about="#mwt1"></span>
1667 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a }} b&quot;}},&quot;i&quot;:0}}]}" about="#mwt2"></span>
1668 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a [[ b&quot;}},&quot;i&quot;:0}}]}" about="#mwt3"></span>
1669 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a | {{ ]]&quot;}},&quot;i&quot;:0}}]}" about="#mwt4"></span>
1670 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a }&quot;}},&quot;i&quot;:0}}]}" about="#mwt5"></span></p>
1671 !! wikitext
1672 {{echo|a [ b}}
1673 {{echo|<nowiki>a }} b</nowiki>}}
1674 {{echo|<nowiki>a [[ b</nowiki>}}
1675 {{echo|<nowiki>a | {{ ]]</nowiki>}}
1676 {{echo|a <nowiki>}</nowiki>}}
1677 !! end
1678
1679 !! test
1680 Cases where "!!" needs nowiki protection
1681 !! options
1682 parsoid=html2wt
1683 !! html/parsoid
1684 <table>
1685 <tr><th>this needs protection !! here</th></tr>
1686 </table>
1687
1688 <table>
1689 <tr><th>this does not need
1690 protection !! here</th></tr>
1691 </table>
1692 !! wikitext
1693 {|
1694 !<nowiki>this needs protection !! here</nowiki>
1695 |}
1696
1697 {|
1698 !this does not need
1699 protection !! here
1700 |}
1701 !! end
1702
1703 ###
1704 ### Comments
1705 ###
1706 !! test
1707 Comments and Indent-Pre
1708 !! wikitext
1709 <!-- comment 1 --> asdf
1710
1711 <!-- comment 1 --> asdf
1712 <!-- comment 2 -->
1713
1714 <!-- comment 1 --> asdf
1715 <!-- comment 2 -->xyz
1716
1717 <!-- comment 1 --> asdf
1718 <!-- comment 2 --> xyz
1719 !! html
1720 <pre>asdf
1721 </pre>
1722 <pre>asdf
1723 </pre>
1724 <pre>asdf
1725 </pre>
1726 <p>xyz
1727 </p>
1728 <pre>asdf
1729 xyz
1730 </pre>
1731 !! end
1732
1733 !! test
1734 Comment test 2a
1735 !! wikitext
1736 asdf
1737 <!-- comment 1 -->
1738 jkl
1739 !! html
1740 <p>asdf
1741 jkl
1742 </p>
1743 !! end
1744
1745 !! test
1746 Comment test 2b
1747 !! wikitext
1748 asdf
1749 <!-- comment 1 -->
1750
1751 jkl
1752 !! html
1753 <p>asdf
1754 </p><p>jkl
1755 </p>
1756 !! end
1757
1758 !! test
1759 Comment test 3
1760 !! wikitext
1761 asdf
1762 <!-- comment 1 -->
1763 <!-- comment 2 -->
1764 jkl
1765 !! html
1766 <p>asdf
1767 jkl
1768 </p>
1769 !! end
1770
1771 !! test
1772 Comment test 4
1773 !! wikitext
1774 asdf<!-- comment 1 -->jkl
1775 !! html
1776 <p>asdfjkl
1777 </p>
1778 !! end
1779
1780 !! test
1781 Comment spacing
1782 !! wikitext
1783 a
1784 <!-- foo --> b <!-- bar -->
1785 c
1786 !! html
1787 <p>a
1788 </p>
1789 <pre> b
1790 </pre>
1791 <p>c
1792 </p>
1793 !! end
1794
1795 !! test
1796 Comment whitespace
1797 !! wikitext
1798 <!-- returns a single newline, not nothing, since the newline after > is not stripped -->
1799 !! html
1800
1801 !! end
1802
1803 !! test
1804 Comment semantics and delimiters
1805 !! wikitext
1806 <!-- --><!----><!-----><!------>
1807 !! html/php
1808
1809 !! html/parsoid
1810 <!-- --><!----><!--&#x2D;--><!--&#x2D;&#x2D;-->
1811 !! end
1812
1813 !! test
1814 Comment semantics and delimiters, redux
1815 !! wikitext
1816 <!-- In SGML every "foo" here would actually show up in the text -- foo -- bar
1817 -- foo -- funky huh? ... -->
1818 !! html/php
1819
1820 !! html/parsoid
1821 <!-- In SGML every "foo" here would actually show up in the text &#x2D;&#x2D; foo &#x2D;&#x2D; bar
1822 &#x2D;&#x2D; foo &#x2D;&#x2D; funky huh? ... -->
1823 !! end
1824
1825 !! test
1826 Comment semantics and delimiters: directors cut
1827 !! wikitext
1828 <!-- ... However we like to keep things simple and somewhat XML-ish so we eat
1829 everything starting with < followed by !-- until the first -- and > we see,
1830 that wouldn't be valid XML however, since in XML -- has to terminate a comment
1831 -->-->
1832 !! html/php
1833 <p>--&gt;
1834 </p>
1835 !! html/parsoid
1836 <!-- ... However we like to keep things simple and somewhat XML&#x2D;ish so we eat
1837 everything starting with < followed by !&#x2D;&#x2D; until the first &#x2D;&#x2D; and &#x3E; we see,
1838 that wouldn't be valid XML however, since in XML &#x2D;&#x2D; has to terminate a comment
1839 --><p>--></p>
1840 !! end
1841
1842 !! test
1843 Comment semantics: nesting
1844 !! wikitext
1845 <!--<!-- no, we're not going to do anything fancy here -->-->
1846 !! html/php
1847 <p>--&gt;
1848 </p>
1849 !! html/parsoid
1850 <!--<!&#x2D;&#x2D; no, we're not going to do anything fancy here --><p>--></p>
1851 !! end
1852
1853 # Parsoid closes the unclosed comment, even if it means a slight
1854 # round-trip diff.
1855 !! test
1856 Comment semantics: unclosed comment at end
1857 !! options
1858 parsoid=wt2html,html2html
1859 !! wikitext
1860 <!--This comment will run out to the end of the document
1861 !! html/php
1862
1863 !! html/parsoid
1864 <!--This comment will run out to the end of the document-->
1865 !! end
1866
1867 !! test
1868 Comment semantics: normalize comments to play nice with XML and browsers
1869 !! wikitext
1870 <!-- Browsers --!> think this is closed -->
1871 <!--> This would normally be text -->
1872 <!---> As would this -->
1873 <!-- XML doesn't like trailing dashes -------->
1874 <!-- Nor doubled hyphens -- anywhere in the data -->
1875 But this is not a comment.
1876 !! html/php
1877 <p>But this is not a comment.
1878 </p>
1879 !! html/parsoid
1880 <!-- Browsers &#x2D;&#x2D;!&#x3E; think this is closed -->
1881 <!--&#x3E; This would normally be text -->
1882 <!--&#x2D;&#x3E; As would this -->
1883 <!-- XML doesn't like trailing dashes &#x2D;&#x2D;&#x2D;&#x2D;&#x2D;&#x2D;-->
1884 <!-- Nor doubled hyphens &#x2D;&#x2D; anywhere in the data -->
1885 <p>But this is not a comment.</p>
1886 !! end
1887
1888 !! test
1889 Comment semantics: round-trip even text which contains encoded -->
1890 !! wikitext
1891 <!-- hello & goodbye - > --&gt; --&amp;gt; --&xx -->
1892 !! html/parsoid
1893 <!-- hello &#x26; goodbye &#x2D; &#x3E; &#x2D;&#x2D;&#x3E; &#x2D;&#x2D;&#x26;gt; &#x2D;&#x2D;&#x26;xx -->
1894 !! end
1895
1896 !! test
1897 Comment in template title
1898 !! wikitext
1899 {{f<!---->oo}}
1900 !! html
1901 <p>FOO
1902 </p>
1903 !! end
1904
1905 !! test
1906 Comment on its own line post-expand
1907 !! wikitext
1908 a
1909 {{blank}}<!---->
1910 b
1911 !! html
1912 <p>a
1913 </p><p>b
1914 </p>
1915 !! end
1916
1917 !! test
1918 Comment on its own line post-expand with non-significant whitespace
1919 !! wikitext
1920 a
1921 {{blank}} <!---->
1922 b
1923 !! html
1924 <p>a
1925 </p><p>b
1926 </p>
1927 !! end
1928
1929 !! test
1930 post-expand include size being exceeded
1931 !! options
1932 maxincludesize=20
1933 !! wikitext
1934 {{echo3|1234567890}}
1935 !! html
1936 <p><a href="/wiki/Template:Echo3" title="Template:Echo3">Template:Echo3</a><!-- WARNING: template omitted, post-expand include size too large -->
1937 </p>
1938 !! end
1939
1940 !! test
1941 max template depth being reached
1942 !! options
1943 maxtemplatedepth=1
1944 !! wikitext
1945 {{echo with depth|too deep!}}
1946 !! html
1947 <p><span class="error">Template recursion depth limit exceeded (1)</span>
1948 </p>
1949 !! end
1950
1951 !! test
1952 multiple templates that are redirects
1953 !! wikitext
1954 {{redirect to foo}}
1955 {{redirect to foo}}
1956 !! html
1957 <p>FOO
1958 FOO
1959 </p>
1960 !! end
1961
1962 !! test
1963 Multiple comments should still parse as SOL-transparent
1964 !! options
1965 parsoid=wt2html,wt2wt
1966 !! wikitext
1967 <!--c1-->*a
1968 <!--c2--><!--c3--><!--c4-->*b
1969 !! html/php
1970 <ul><li>a</li>
1971 <li>b</li></ul>
1972
1973 !! html/parsoid
1974 <!--c1--><ul>
1975 <li>a
1976 </li>
1977 <!--c2--><!--c3--><!--c4-->
1978 <li>b
1979 </li>
1980 </ul>
1981 !! end
1982
1983 ## Make sure ">" gets escaped in comments to avoid XSS
1984 !! test
1985 IE conditional comments
1986 !! wikitext
1987 <!--[if lt IE 9]>
1988 <script>alert('hi');</script>
1989 <![endif]-->
1990 !! html/parsoid
1991 <!--[if lt IE 9]&#x3E;
1992 <script&#x3E;alert('hi');</script&#x3E;
1993 <![endif]-->
1994 !! end
1995
1996 ###
1997 ### paragraph wrapping tests
1998 ###
1999
2000 !! test
2001 No block tags
2002 !! wikitext
2003 a
2004
2005 b
2006 !! html
2007 <p>a
2008 </p><p>b
2009 </p>
2010 !! end
2011
2012 !! test
2013 Block tag on one line (<div>)
2014 !! wikitext
2015 a <div>foo</div>
2016
2017 b
2018 !! html
2019 a <div>foo</div>
2020 <p>b
2021 </p>
2022 !! html+tidy
2023 <p>a </p><div>foo</div>
2024 <p>b
2025 </p>
2026 !! end
2027
2028 !! test
2029 No p-wrappable content
2030 !! options
2031 parsoid=wt2html,html2html
2032 !! wikitext
2033 <span><div>x</div></span>
2034 <span><s><div>x</div></s></span>
2035 <small><em></em></small><span><s><div>x</div></s></span>
2036 !! html+tidy
2037 <span><div>x</div></span>
2038 <span><s><div>x</div></s></span>
2039 <p><small><em></em></small></p><span><s><div>x</div></s></span>
2040 !! end
2041
2042 # T177612: Parsoid-only test
2043 !! test
2044 Transclusion meta tags shouldn't trip Parsoid's useless p-wrapper stripping code
2045 !! wikitext
2046 {{echo|<span><div>x</div></span>}}
2047 x
2048 !! html/parsoid
2049 <span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;span>&lt;div>x&lt;/div>&lt;/span>"}},"i":0}}]}'><div>x</div></span>
2050 <p>x</p>
2051 !! end
2052
2053 !! test
2054 Block tag on one line (<blockquote>)
2055 !! wikitext
2056 a <blockquote>foo</blockquote>
2057
2058 b
2059 !! html
2060 a <blockquote>foo</blockquote>
2061 <p>b
2062 </p>
2063 !! html+tidy
2064 <p>a </p><blockquote><p>foo</p></blockquote>
2065 <p>b
2066 </p>
2067 !! end
2068
2069 !! test
2070 Block tag on both lines (<div>)
2071 !! wikitext
2072 a <div>foo</div>
2073
2074 b <div>foo</div>
2075 !! html
2076 a <div>foo</div>
2077 b <div>foo</div>
2078
2079 !! html+tidy
2080 <p>a </p><div>foo</div><p>
2081 b </p><div>foo</div>
2082 !! end
2083
2084 !! test
2085 Block tag on both lines (<blockquote>)
2086 !! wikitext
2087 a <blockquote>foo</blockquote>
2088
2089 b <blockquote>foo</blockquote>
2090 !! html
2091 a <blockquote>foo</blockquote>
2092 b <blockquote>foo</blockquote>
2093
2094 !! html+tidy
2095 <p>a </p><blockquote><p>foo</p></blockquote><p>
2096 b </p><blockquote><p>foo</p></blockquote>
2097 !! end
2098
2099 !! test
2100 Multiple lines without block tags
2101 !! wikitext
2102 <div>foo</div> a
2103 b
2104 c
2105 d<!--foo--> e
2106 x <div>foo</div> z
2107 !! html
2108 <div>foo</div> a
2109 <p>b
2110 c
2111 d e
2112 </p>
2113 x <div>foo</div> z
2114
2115 !! html+tidy
2116 <div>foo</div><p> a
2117 </p><p>b
2118 c
2119 d e
2120 </p><p>
2121 x </p><div>foo</div><p> z
2122 </p>
2123 !! end
2124
2125 !! test
2126 Empty lines between lines with block tags
2127 !! wikitext
2128 <div></div>
2129
2130
2131 <div></div>a
2132
2133 b
2134 <div>a</div>b
2135
2136 <div>b</div>d
2137
2138
2139 <div>e</div>
2140 !! html
2141 <div></div>
2142 <p><br />
2143 </p>
2144 <div></div>a
2145 <p>b
2146 </p>
2147 <div>a</div>b
2148 <div>b</div>d
2149 <p><br />
2150 </p>
2151 <div>e</div>
2152
2153 !! html+tidy
2154 <div></div>
2155 <p><br />
2156 </p>
2157 <div></div><p>a
2158 </p><p>b
2159 </p>
2160 <div>a</div><p>b
2161 </p><div>b</div><p>d
2162 </p><p><br />
2163 </p>
2164 <div>e</div>
2165 !! html/parsoid
2166 <div data-parsoid='{"stx":"html"}'></div>
2167
2168 <p><br /></p>
2169 <div data-parsoid='{"stx":"html"}'></div><p>a</p>
2170
2171 <p>b</p>
2172 <div data-parsoid='{"stx":"html"}'>a</div><p>b</p>
2173
2174 <div data-parsoid='{"stx":"html"}'>b</div><p>d</p>
2175
2176 <p><br /></p>
2177 <div data-parsoid='{"stx":"html"}'>e</div>
2178 !! end
2179
2180 !! test
2181 Unclosed HTML p-tags should be handled properly
2182 !! wikitext
2183 <div><p>foo</div>
2184 a
2185
2186 b
2187 !! html/php+tidy
2188 <div><p>foo</p></div>
2189 <p>a
2190 </p><p>b
2191 </p>
2192 !! html/parsoid
2193 <div data-parsoid='{"stx":"html"}'><p data-parsoid='{"stx":"html", "autoInsertedEnd":true}'>foo</p></div>
2194 <p>a</p>
2195 <p>b</p>
2196 !! end
2197
2198 ## SSS FIXME: I can come up with other scenarios where this doesn't work because
2199 ## of eager output of buffered tokens in the p-wrapper. But, I'm going to ignore
2200 ## them for now.
2201 !! test
2202 1. P-wrapping should leave sol-transparent tags outside p-tags where possible
2203 !! options
2204 parsoid=wt2html
2205 !! wikitext
2206 a [[Category:A1]] [[Category:A2]]
2207 [[Category:A3]]
2208 [[Category:A4]]
2209 !! html/parsoid
2210 <p>a</p>
2211 <link rel="mw:PageProp/Category" href="./Category:A1"/> <link rel="mw:PageProp/Category" href="./Category:A2"/> <link rel="mw:PageProp/Category" href="./Category:A3"/> <link rel="mw:PageProp/Category" href="./Category:A4"/>
2212 !! end
2213
2214 !! test
2215 2. P-wrapping should leave sol-transparent tags outside p-tags where possible
2216 !! options
2217 parsoid=wt2html
2218 !! wikitext
2219 [[Category:A1]]a
2220 !! html/parsoid
2221 <link rel="mw:PageProp/Category" href="./Category:A1"/><p>a</p>
2222 !! end
2223
2224 !! test
2225 No paragraph necessary for SOL transparent template
2226 !! wikitext
2227 <span><div>foo</div></span>
2228 [[Category:Foo]]
2229
2230 <span><div>foo</div></span>
2231 {{echo|[[Category:Foo]]}}
2232 !! html/php
2233 <span><div>foo</div></span>
2234 <span><div>foo</div></span>
2235
2236 !! html/parsoid
2237 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2238 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
2239
2240 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2241 <link rel="mw:PageProp/Category" href="./Category:Foo" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Category:Foo]]"}},"i":0}}]}'/>
2242 !! end
2243
2244 !! test
2245 Avoid expanding multiline sol transparent template ranges unnecessarily
2246 !! wikitext
2247 hi
2248
2249
2250 {{echo|<br/>
2251 }}
2252
2253 [[Category:Ho]]
2254 !! html/php
2255 <p>hi
2256 </p><p><br />
2257 <br />
2258 </p>
2259 !! html/parsoid
2260 <p>hi</p>
2261
2262 <p><br />
2263 <br about="#mwt1" typeof="mw:Transclusion" data-parsoid='{}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;br/>\n"}},"i":0}}]}'/><span about="#mwt1">
2264 </span></p>
2265
2266 <link rel="mw:PageProp/Category" href="./Category:Ho" />
2267 !! end
2268
2269 !! test
2270 Paragraph wrapping following unclosed table
2271 !! options
2272 parsoid=wt2html,html2html
2273 !! wikitext
2274 {|
2275 |-
2276
2277 {|
2278 | x
2279 |}
2280
2281 a
2282
2283 b
2284
2285 c
2286 !! html/php+tidy
2287 <table>
2288
2289
2290 </table><table>
2291 <tbody><tr>
2292 <td>x
2293 </td></tr></tbody></table>
2294 <p>a
2295 </p><p>b
2296 </p><p>c
2297 </p>
2298 !! html/parsoid
2299 <table data-parsoid='{"autoInsertedEnd":true}'>
2300 <tbody><tr class="mw-empty-elt" data-parsoid='{"startTagSrc":"|-"}'></tr>
2301
2302 </tbody></table><table>
2303 <tbody><tr data-parsoid='{"autoInsertedStart":true}'><td>x</td></tr>
2304 </tbody></table>
2305
2306 <p>a</p>
2307
2308 <p>b</p>
2309
2310 <p>c</p>
2311 !! end
2312
2313 !! test
2314 Paragraph wrapping suppressed in html p
2315 !! options
2316 parsoid=wt2html,html2html
2317 !! wikitext
2318 <p>
2319
2320
2321 hi
2322
2323
2324
2325 </p>
2326 !! html/php+tidy
2327 <p>
2328
2329
2330 hi
2331
2332
2333
2334 </p>
2335 !! html/parsoid
2336 <p data-parsoid='{"stx":"html"}'>
2337
2338
2339 hi
2340
2341
2342
2343 </p>
2344 !! end
2345
2346 !! test
2347 Dangling table row doesn't prevent p-wrapping
2348 !! options
2349 parsoid=wt2html,html2html
2350 !! wikitext
2351 {|
2352 | hi
2353 |-
2354 |} ho
2355 !! html/parsoid
2356 <table>
2357 <tbody><tr><td>hi</td></tr>
2358 <tr class="mw-empty-elt"></tr>
2359 </tbody></table><p> ho</p>
2360 !! end
2361
2362 ###
2363 ### Preformatted text
2364 ###
2365
2366 !! test
2367 Preformatted text
2368 !! wikitext
2369 This is some
2370 Preformatted text
2371 With ''italic''
2372 And '''bold'''
2373 And a [[Main Page|link]]
2374 !! html
2375 <pre>This is some
2376 Preformatted text
2377 With <i>italic</i>
2378 And <b>bold</b>
2379 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
2380 </pre>
2381 !! end
2382
2383 !! test
2384 Tabs don't trigger preformatted text
2385 !! wikitext
2386 This is not
2387 preformatted text.
2388 This is preformatted text.
2389 So is this.
2390 !! html/php
2391 <p> This is not
2392 preformatted text.
2393 </p>
2394 <pre>This is preformatted text.
2395 So is this.
2396 </pre>
2397 !! html/parsoid
2398 <p> This is not
2399 preformatted text.</p>
2400 <pre>This is preformatted text.
2401 So is this.</pre>
2402 !! end
2403
2404 !! test
2405 Space before tab needs nowiki pre protection
2406 !! options
2407 parsoid=html2wt
2408 !! html/parsoid
2409 <p> a</p>
2410 !! wikitext
2411 <nowiki> </nowiki> a
2412 !! end
2413
2414 !! test
2415 Ident preformatting with inline content
2416 !! wikitext
2417 a
2418 ''b''
2419 !! html
2420 <pre>a
2421 <i>b</i>
2422 </pre>
2423 !! end
2424
2425 !! test
2426 <pre> with <nowiki> inside (compatibility with 1.6 and earlier)
2427 !! wikitext
2428 <pre><nowiki>
2429 <b>
2430 <cite>
2431 <em>
2432 </nowiki></pre>
2433 !! html
2434 <pre>
2435 &lt;b&gt;
2436 &lt;cite&gt;
2437 &lt;em&gt;
2438 </pre>
2439
2440 !! end
2441
2442 !! test
2443 Regression with preformatted in <center>
2444 !! wikitext
2445 <center>
2446 Blah
2447 </center>
2448 !! html
2449 <center>
2450 <pre>Blah
2451 </pre>
2452 </center>
2453
2454 !! end
2455
2456 !! test
2457 T54763: Preformatted in <blockquote>
2458 !! wikitext
2459 <blockquote>
2460 Blah
2461 {|
2462 |
2463 indented cell (no pre-wrapping!)
2464 |}
2465 </blockquote>
2466 !! html
2467 <blockquote>
2468 <p> Blah
2469 </p>
2470 <table>
2471 <tr>
2472 <td>
2473 <p> indented cell (no pre-wrapping!)
2474 </p>
2475 </td></tr></table>
2476 </blockquote>
2477
2478 !! end
2479
2480 !! test
2481 T53086: Double newlines in blockquotes should be turned into paragraphs
2482 !! wikitext
2483 <blockquote>
2484 Foo
2485
2486 Bar
2487 </blockquote>
2488 !! html
2489 <blockquote>
2490 <p>Foo
2491 </p><p>Bar
2492 </p>
2493 </blockquote>
2494
2495 !! end
2496
2497 !! test
2498 T17491: <ins>/<del> in blockquote
2499 !! wikitext
2500 <blockquote>
2501 Foo <del>bar</del> <ins>baz</ins> quux
2502 </blockquote>
2503 !! html
2504 <blockquote>
2505 <p>Foo <del>bar</del> <ins>baz</ins> quux
2506 </p>
2507 </blockquote>
2508
2509 !! html+tidy
2510 <blockquote>
2511 <p>Foo <del>bar</del> <ins>baz</ins> quux
2512 </p>
2513 </blockquote>
2514 !! end
2515
2516 !! test
2517 T17491: <ins>/<del> in blockquote (2)
2518 !! wikitext
2519 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2520 </blockquote>
2521 !! html
2522 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2523 </blockquote>
2524
2525 !! html+tidy
2526 <blockquote><p>Foo <del>bar</del> <ins>baz</ins> quux
2527 </p></blockquote>
2528 !! end
2529
2530 !! test
2531 <pre> with attributes (T5202)
2532 !! wikitext
2533 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2534 !! html
2535 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2536
2537 !! end
2538
2539 !! test
2540 <pre> with width attribute (T5202)
2541 !! wikitext
2542 <pre width="8">Narrow screen goodies</pre>
2543 !! html
2544 <pre width="8">Narrow screen goodies</pre>
2545
2546 !! end
2547
2548 !! test
2549 <pre> with forbidden attribute (T5202)
2550 !! wikitext
2551 <pre width="8" onmouseover="alert(document.cookie)">Narrow screen goodies</pre>
2552 !! html
2553 <pre width="8">Narrow screen goodies</pre>
2554
2555 !! end
2556
2557 !! test
2558 Entities inside <pre>
2559 !! wikitext
2560 <pre>&lt;</pre>
2561 !! html
2562 <pre>&lt;</pre>
2563
2564 !! end
2565
2566 !! test
2567 <pre> with forbidden attribute values (T5202)
2568 !! wikitext
2569 <pre width="8" style="border-width: expression(alert(document.cookie))">Narrow screen goodies</pre>
2570 !! html
2571 <pre width="8" style="/* insecure input */">Narrow screen goodies</pre>
2572
2573 !! end
2574
2575 !! test
2576 <nowiki> inside <pre> (T15238)
2577 !! wikitext
2578 <pre>
2579 <nowiki>
2580 </pre>
2581 <pre>
2582 <nowiki></nowiki>
2583 </pre>
2584 <pre><nowiki><nowiki></nowiki>Foo<nowiki></nowiki></nowiki></pre>
2585 !! html
2586 <pre>
2587 &lt;nowiki&gt;
2588 </pre>
2589 <pre>
2590
2591 </pre>
2592 <pre>&lt;nowiki&gt;Foo&lt;/nowiki&gt;</pre>
2593
2594 !! end
2595
2596 !! test
2597 <nowiki> inside of #tag:pre
2598 !! wikitext
2599 {{#tag:pre|Foo <nowiki>&rarr;bar</nowiki>}}
2600 !! html/php
2601 <pre>Foo &#8594;bar</pre>
2602
2603 !! html/parsoid
2604 <pre about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"#tag:pre","function":"tag"},"params":{"1":{"wt":"Foo &lt;nowiki>&amp;rarr;bar&lt;/nowiki>"}},"i":0}}]}'>Foo <span typeof="mw:Entity">→</span>bar</pre>
2605 !! end
2606
2607 ## Don't expect this to rt, Parsoid drops the unmatched closing pre tags that
2608 ## aren't enclosed in nowikis.
2609 !! test
2610 <nowiki> and <pre> preference (first one wins)
2611 !! options
2612 parsoid=wt2html
2613 !! wikitext
2614 <pre>
2615 <nowiki>
2616 </pre>
2617 </nowiki>
2618 </pre>
2619
2620 <nowiki>
2621 <pre>
2622 <nowiki>
2623 </pre>
2624 </nowiki>
2625 </pre>
2626
2627 !! html/php
2628 <pre>
2629 &lt;nowiki&gt;
2630 </pre>
2631 <p>&lt;/nowiki&gt;
2632 &lt;/pre&gt;
2633 </p><p>
2634 &lt;pre&gt;
2635 &lt;nowiki&gt;
2636 &lt;/pre&gt;
2637
2638 &lt;/pre&gt;
2639 </p>
2640 !! html/parsoid
2641 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n&lt;nowiki>\n"}}'>&lt;nowiki>
2642 </pre>
2643 <p>&lt;/nowiki></p>
2644
2645
2646 <p><span typeof="mw:Nowiki">
2647 &lt;pre>
2648 &lt;nowiki>
2649 &lt;/pre>
2650 </span></p>
2651 !! end
2652
2653 !! test
2654 </pre> inside nowiki
2655 !! wikitext
2656 <nowiki></pre></nowiki>
2657 !! html
2658 <p>&lt;/pre&gt;
2659 </p>
2660 !! end
2661
2662 !! test
2663 Empty pre; pre inside other HTML tags (T56946)
2664 !! wikitext
2665 a
2666
2667 <div><pre>
2668 foo
2669 </pre></div>
2670 <pre></pre>
2671 !! html/php+tidy
2672 <p>a
2673 </p>
2674 <div><pre>foo
2675 </pre></div>
2676 <pre></pre>
2677 !! html/parsoid
2678 <p>a</p>
2679
2680 <div data-parsoid='{"stx":"html"}'><pre typeof="mw:Extension/pre" about="#mwt2" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
2681 </pre></div>
2682 <pre typeof="mw:Extension/pre" about="#mwt4" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":""}}'></pre>
2683 !! end
2684
2685 !! test
2686 HTML pre followed by indent-pre
2687 !! wikitext
2688 <pre>foo</pre>
2689 bar
2690 !! html
2691 <pre>foo</pre>
2692 <pre>bar
2693 </pre>
2694 !! end
2695
2696 !! test
2697 Block tag pre
2698 !! wikitext
2699 <p><pre>foo</pre></p>
2700 !! html/php+tidy
2701 <p class="mw-empty-elt"></p><pre>foo</pre><p class="mw-empty-elt"></p>
2702 !! html/parsoid
2703 <p class='mw-empty-elt' data-parsoid='{"stx":"html","autoInsertedEnd":true}'></p><pre typeof="mw:Extension/pre" about="#mwt2" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre><p class='mw-empty-elt' data-parsoid='{"autoInsertedStart":true,"stx":"html"}'></p>
2704 !! end
2705
2706 !!test
2707 Templates: Indent-Pre: 1a. Templates that break a line should suppress <pre>
2708 !! wikitext
2709 {{echo|}}
2710 !! html
2711
2712 !!end
2713
2714 !!test
2715 Templates: Indent-Pre: 1b. Templates that break a line should suppress <pre>
2716 !! wikitext
2717 {{echo|
2718 foo}}
2719 !! html
2720 <p>foo
2721 </p>
2722 !!end
2723
2724 !! test
2725 Templates: Indent-Pre: 1c: Wrapping should be based on expanded content
2726 !! wikitext
2727 {{echo|a
2728 b}}
2729 !! html
2730 <pre>a
2731 </pre>
2732 <p>b
2733 </p>
2734 !!end
2735
2736 !! test
2737 Templates: Indent-Pre: 1d: Wrapping should be based on expanded content
2738 !! wikitext
2739 {{echo|a
2740 b
2741 c
2742 d
2743 e
2744 }}
2745 !! html
2746 <pre>a
2747 </pre>
2748 <p>b
2749 c
2750 </p>
2751 <pre>d
2752 </pre>
2753 <p>e
2754 </p>
2755 !!end
2756
2757 !!test
2758 Templates: Indent-Pre: 1e. Wrapping should be based on expanded content
2759 !! wikitext
2760 {{echo| foo}}
2761
2762 {{echo| foo}}{{echo| bar}}
2763
2764 {{echo| foo}}
2765 {{echo| bar}}
2766
2767 {{echo|<!--cmt--> foo}}
2768
2769 <!--cmt-->{{echo| foo}}
2770
2771 {{echo|{{echo| }}bar}}
2772 !! html
2773 <pre>foo
2774 </pre>
2775 <pre>foo bar
2776 </pre>
2777 <pre>foo
2778 bar
2779 </pre>
2780 <pre>foo
2781 </pre>
2782 <pre>foo
2783 </pre>
2784 <pre>bar
2785 </pre>
2786 !!end
2787
2788 !! test
2789 Templates: Indent-Pre: 1f: Wrapping should be based on expanded content
2790 !! wikitext
2791 {{echo| }}a
2792
2793 {{echo|
2794 }}a
2795
2796 {{echo|
2797 b}}
2798
2799 {{echo|a
2800 }}b
2801
2802 {{echo|a
2803 }} b
2804 !! html
2805 <pre>a
2806 </pre>
2807 <p><br />
2808 </p>
2809 <pre>a
2810 </pre>
2811 <p><br />
2812 </p>
2813 <pre>b
2814 </pre>
2815 <p>a
2816 </p>
2817 <pre>b
2818 </pre>
2819 <p>a
2820 </p>
2821 <pre>b
2822 </pre>
2823 !!end
2824
2825 ## Hmm, should Parsoid rt this?
2826 !! test
2827 Pres with newline attributes
2828 !! options
2829 parsoid=wt2html,html2html
2830 !! wikitext
2831 <pre class="one
2832 two">hi</pre>
2833 !! html/php
2834 <pre class="one two">hi</pre>
2835
2836 !! html/parsoid
2837 <pre typeof="mw:Extension/pre" about="#mwt2" class="one two" data-mw='{"name":"pre","attrs":{"class":"one two"},"body":{"extsrc":"hi"}}'>hi</pre>
2838 !! end
2839
2840 !! test
2841 Things that look like <pre> tags aren't treated as such
2842 !! wikitext
2843 Barack Obama <President> of the United States
2844 <President></President>
2845 !! html
2846 <p>Barack Obama &lt;President&gt; of the United States
2847 &lt;President&gt;&lt;/President&gt;
2848 </p>
2849 !! end
2850
2851 ## Remex doesn't account for fostered content.
2852 ## The difference between Parsoid and the PHP parser can be attributed to core
2853 ## commit 674e8388cba and 710618f89af in Parsoid's repo. Parsoid doesn't
2854 ## tokenize unmatched extension tags that shadow html tags as strings to ease
2855 ## an escaping mechanism. See the comment in `maybeExtensionTag`.
2856 !! test
2857 Handle broken pre-like tags (T66025)
2858 !! options
2859 parsoid=wt2html
2860 !! wikitext
2861 {{echo|<pre <pre>x</pre>}}
2862
2863 <table><pre </table>
2864 !! html/php
2865 <pre>x</pre>
2866 <table>&lt;pre </table>
2867
2868 !! html/php+tidy
2869 <pre>x</pre>
2870 &lt;pre <table></table>
2871 !! html/parsoid
2872 <pre typeof="mw:Transclusion mw:Extension/pre" about="#mwt2" data-parsoid='{"stx":"html","a":{"&lt;pre":null},"sa":{"&lt;pre":""},"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;pre &lt;pre>x&lt;/pre>"}},"i":0}}]}'>x</pre>
2873
2874 <pre data-parsoid='{"stx":"html","src":"&lt;pre &lt;/table>","tagWidths":[13,0],"a":{"&lt;":null,"table":null},"sa":{"&lt;":"","table":""},"fostered":true,"autoInsertedEnd":true}'></pre><table data-parsoid='{"stx":"html","autoInsertedEnd":true}'></table>
2875 !! end
2876
2877 ## Similar to the above, but shows the difference between extension and html tags
2878 !! test
2879 Less than in attribute position
2880 !! wikitext
2881 <pre <pre>123</pre>
2882
2883 <div <div>123</div>
2884 !! html/php+tidy
2885 <pre>123</pre><p>
2886 &lt;div </p><div>123</div>
2887 !! html/parsoid
2888 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"&lt;pre":""},"body":{"extsrc":"123"}}'>123</pre><p>
2889
2890 &lt;div </p><div>123</div>
2891 !! end
2892
2893 !! test
2894 Parsoid: handle pre with space after attribute
2895 !! options
2896 parsoid=wt2html
2897 !! wikitext
2898 <pre style="width:50%;" >{{echo|foo}}</pre>
2899 !! html/php
2900 <pre style="width:50%;">{{echo|foo}}</pre>
2901
2902 !! html/parsoid
2903 <pre typeof="mw:Extension/pre" about="#mwt2" style="width:50%;" data-mw='{"name":"pre","attrs":{"style":"width:50%;"},"body":{"extsrc":"{{echo|foo}}"}}'>{{echo|foo}}</pre>
2904 !! end
2905
2906 !! test
2907 Self-closed pre
2908 !! wikitext
2909 <pre />
2910 !! html/php
2911 <pre></pre>
2912
2913 !! html/parsoid
2914 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{}}'></pre>
2915 !! end
2916
2917 !! test
2918 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 typeof="mw:Extension/pre" about="#mwt2" class="123" 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="./Main_Page#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="./Main_Page#cite_ref-hi|ho_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-hi|ho-1" class="mw-reference-text">ha</span></li></ol>
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="./Main_Page#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="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
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 !! config
8048 wgFragmentMode=[ 'html5', 'legacy' ]
8049 !! wikitext
8050 [[%23%3c]][[%23%3e]]
8051 !! html/php
8052 <p><a href="#&lt;">#&lt;</a><a href="#&gt;">#&gt;</a>
8053 </p>
8054 !! html/parsoid
8055 <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>
8056 !! end
8057
8058 ## Example for such a section: == < ==
8059 !! test
8060 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors (legacy)
8061 !! config
8062 wgFragmentMode=[ 'legacy' ]
8063 !! wikitext
8064 [[%23%3c]][[%23%3e]]
8065 !! html/php
8066 <p><a href="#.3C">#&lt;</a><a href="#.3E">#&gt;</a>
8067 </p>
8068 !! end
8069
8070 !! test
8071 Link containing "<#" and ">#" as a hex sequences
8072 !! wikitext
8073 [[%3c%23]][[%3e%23]]
8074 !! html
8075 <p>[[%3c%23]][[%3e%23]]
8076 </p>
8077 !! end
8078
8079 !! test
8080 Link containing an equals sign
8081 !! wikitext
8082 [[Special:BookSources/isbn=4-00-026157-6]]
8083 !! html/php
8084 <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>
8085 </p>
8086 !! html/parsoid
8087 <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>
8088 !! end
8089
8090 !! article
8091 Foo & bar
8092 !! text
8093 Just a test of an article title containing an ampersand
8094 !! endarticle
8095
8096 !! test
8097 Link containing an ampersand
8098 !! wikitext
8099 [[Foo & bar]]
8100
8101 [[Foo &amp; bar]]
8102
8103 [[Foo &amp;amp; bar]]
8104 !! html/php+tidy
8105 <p><a href="/wiki/Foo_%26_bar" title="Foo &amp; bar">Foo &amp; bar</a>
8106 </p><p><a href="/wiki/Foo_%26_bar" title="Foo &amp; bar">Foo &amp; bar</a>
8107 </p><p>[[Foo &amp;amp; bar]]
8108 </p>
8109 !! html/parsoid
8110 <p><a rel="mw:WikiLink" href="./Foo_&amp;_bar" title="Foo &amp; bar">Foo &amp; bar</a></p>
8111 <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>
8112 <p>[[Foo <span typeof="mw:Entity" data-parsoid='{"src":"&amp;amp;","srcContent":"&amp;"}'>&amp;</span>amp; bar]]</p>
8113 !! end
8114
8115 !! article
8116 Foo~bar
8117 !! text
8118 Just a test of an article title containing a tilde.
8119 !! endarticle
8120
8121 # note that links containing signatures, like [[Foo~~~~]], are
8122 # massaged by the pre-save transform (PST) and so the tildes are never
8123 # seen by the parser.
8124 !! test
8125 Link containing a tilde
8126 !! wikitext
8127 [[Foo~bar]]
8128 !! html/php
8129 <p><a href="/wiki/Foo~bar" title="Foo~bar">Foo~bar</a>
8130 </p>
8131 !! html/parsoid
8132 <p><a rel="mw:WikiLink" href="./Foo~bar" title="Foo~bar">Foo~bar</a></p>
8133 !! end
8134
8135 !! test
8136 Link containing double-single-quotes '' (T6598)
8137 !! wikitext
8138 [[Lista d''e paise d''o munno]]
8139 !! html/php
8140 <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>
8141 </p>
8142 !! html/parsoid
8143 <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>
8144 !! end
8145
8146 !! test
8147 Link containing double quotes and spaces
8148 !! wikitext
8149 [[Cool "Gator"]]
8150 !! html/php
8151 <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>
8152 </p>
8153 !! html/parsoid
8154 <p><a rel="mw:WikiLink" href='./Cool_"Gator"' title='Cool "Gator"'>Cool "Gator"</a></p>
8155 !! end
8156
8157 !! test
8158 File containing double quotes and spaces
8159 !! wikitext
8160 [[File:Cool "Gator".png]]
8161 !! html/parsoid
8162 <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>
8163 !! end
8164
8165 !! test
8166 Redirect containing double quotes and spaces
8167 !! wikitext
8168 #REDIRECT [[Cool "Gator"]]
8169 !! html/parsoid
8170 <link rel="mw:PageProp/redirect" href="./Cool_%22Gator%22" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Cool_%22Gator%22"},"sa":{"href":"Cool \"Gator\""}}'/>
8171 !! end
8172
8173 !! test
8174 Link containing double-single-quotes '' in text (T6598 sanity check)
8175 !! wikitext
8176 Some [[Link|pretty ''italics'' and stuff]]!
8177 !! html/php
8178 <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>!
8179 </p>
8180 !! html/parsoid
8181 <p>Some <a rel="mw:WikiLink" href="./Link" title="Link">pretty <i>italics</i> and stuff</a>!</p>
8182 !! end
8183
8184 !! test
8185 Link containing double-single-quotes '' in text embedded in italics (T6598 sanity check)
8186 !! wikitext
8187 ''Some [[Link|pretty ''italics'' and stuff]]!''
8188 !! html
8189 <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>
8190 </p>
8191 !! end
8192
8193 !! test
8194 Link with double quotes in title part (literal) and alternate part (interpreted)
8195 !! wikitext
8196 [[File:Denys_Savchenko_''Pentecoste''.jpg]]
8197
8198 [[''Pentecoste'']]
8199
8200 [[''Pentecoste''|Pentecoste]]
8201
8202 [[''Pentecoste''|''Pentecoste'']]
8203 !! html/php
8204 <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>
8205 </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>
8206 </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>
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)"><i>Pentecoste</i></a>
8208 </p>
8209 !! html/parsoid
8210 <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>
8211 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">''Pentecoste''</a></p>
8212 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">Pentecoste</a></p>
8213 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''"><i>Pentecoste</i></a></p>
8214 !! end
8215
8216 !! test
8217 Broken image links with HTML captions (T41700)
8218 !! wikitext
8219 [[File:Nonexistent|<script></script>]]
8220 [[File:Nonexistent|100x100px|<script></script>]]
8221 [[File:Nonexistent|&lt;]]
8222 [[File:Nonexistent|a<i>b</i>c]]
8223 !! html/php
8224 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8225 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8226 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;</a>
8227 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">abc</a>
8228 </p>
8229 !! html/parsoid
8230 <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>
8231 <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>
8232 <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>
8233 <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>
8234 !! end
8235
8236 !! test
8237 Plain link to URL
8238 !! wikitext
8239 [[http://www.example.com]]
8240 !! html/php
8241 <p>[<a rel="nofollow" class="external autonumber" href="http://www.example.com">[1]</a>]
8242 </p>
8243 !! html/parsoid
8244 <p>[<a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com"></a>]</p>
8245 !! end
8246
8247 !! test
8248 Plain link to URL with link text
8249 !! wikitext
8250 [[http://www.example.com Link text]]
8251 !! html
8252 <p>[<a rel="nofollow" class="external text" href="http://www.example.com">Link text</a>]
8253 </p>
8254 !! end
8255
8256 !! test
8257 Plain link to protocol-relative URL
8258 !! wikitext
8259 [[//www.example.com]]
8260 !! html/php
8261 <p>[<a rel="nofollow" class="external autonumber" href="//www.example.com">[1]</a>]
8262 </p>
8263 !! html/parsoid
8264 <p>[<a rel="mw:ExtLink" class="external autonumber" href="//www.example.com"></a>]</p>
8265 !! end
8266
8267 !! test
8268 Plain link to protocol-relative URL with link text
8269 !! wikitext
8270 [[//www.example.com Link text]]
8271 !! html
8272 <p>[<a rel="nofollow" class="external text" href="//www.example.com">Link text</a>]
8273 </p>
8274 !! end
8275
8276 !! test
8277 Plain link to page with question mark in title
8278 !! wikitext
8279 [[A?b]]
8280
8281 [[A?b|Baz]]
8282 !! html
8283 <p><a href="/wiki/A%3Fb" title="A?b">A?b</a>
8284 </p><p><a href="/wiki/A%3Fb" title="A?b">Baz</a>
8285 </p>
8286 !! end
8287
8288 # I'm fairly sure the expected result here is wrong.
8289 # We want these to be URL links, not pseudo-pages with URLs for titles....
8290 # However the current output is also pretty screwy.
8291 #
8292 # ----
8293 # I'm changing it to match the current output--it arguably makes more
8294 # sense in the light of the test above. Old expected result was:
8295 #<p>Piped link to URL: <a href="/index.php?title=Http://www.example.com&amp;action=edit" class="new">an example URL</a>
8296 #</p>
8297 # But I think this test is bordering on "garbage in, garbage out" anyway.
8298 # -- wtm
8299 !! test
8300 Piped link to URL
8301 !! wikitext
8302 Piped link to URL: [[http://www.example.com|an example URL]]
8303 !! html/php
8304 <p>Piped link to URL: [<a rel="nofollow" class="external text" href="http://www.example.com%7Can">example URL</a>]
8305 </p>
8306 !! html/parsoid
8307 <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>
8308 !! end
8309
8310 !! test
8311 Plain link in template argument
8312 !! options
8313 parsoid=wt2html
8314 !! wikitext
8315 {{echo|[http://www.example.com |123]}}
8316
8317 {{echo|[[http://www.example.com |123]]}}
8318
8319 {{echo|[[http://www.example.com |123]}}
8320
8321 {{echo|[http://www.example.com |123]]}}
8322 !! html/php
8323 <p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8324 </p><p>[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>]
8325 </p><p>{{echo|[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>}}
8326 </p><p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8327 </p>
8328 !! html/parsoid
8329 <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>
8330
8331 <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>
8332
8333 <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>
8334
8335 <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>
8336 !! end
8337
8338 !! test
8339 T2002: [[page|http://url/]] should link to page, not http://url/
8340 !! wikitext
8341 [[Main Page|http://url/]]
8342 !! html/php
8343 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
8344 </p>
8345 !! html/parsoid
8346 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">http://url/</a></p>
8347 !! end
8348
8349 # Parsoid does not mark self-links, by design.
8350 !! test
8351 T2337: Escaped self-links should be bold
8352 !! options
8353 title=[[Bug462]]
8354 !! wikitext
8355 [[Bu&#103;462]] [[Bug462]]
8356 !! html/php+tidy
8357 <p><a class="mw-selflink selflink">Bu&#103;462</a> <a class="mw-selflink selflink">Bug462</a>
8358 </p>
8359 !! html/parsoid
8360 <p><a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a> <a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a></p>
8361 !! end
8362
8363 !! test
8364 Self-link to section should not be bold
8365 !! options
8366 title=[[Main Page]]
8367 !! wikitext
8368 [[Main Page#section]]
8369 !! html
8370 <p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
8371 </p>
8372 !! end
8373
8374 !! article
8375 00
8376 !! text
8377 This is 00.
8378 !! endarticle
8379
8380 !!test
8381 Self-link to numeric title
8382 !!options
8383 title=[[0]]
8384 !! wikitext
8385 [[0]]
8386 !! html
8387 <p><a class="mw-selflink selflink">0</a>
8388 </p>
8389 !!end
8390
8391 !!test
8392 Link to numeric-equivalent title
8393 !!options
8394 title=[[0]]
8395 !! wikitext
8396 [[00]]
8397 !! html
8398 <p><a href="/wiki/00" title="00">00</a>
8399 </p>
8400 !!end
8401
8402 !! test
8403 <nowiki> inside a link
8404 !! wikitext
8405 [[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
8406 !! html
8407 <p>[[Main Page]] <a href="/wiki/Main_Page" title="Main Page">the main page [it's not very good]</a>
8408 </p>
8409 !! end
8410
8411 !! test
8412 Non-breaking spaces in title
8413 !! wikitext
8414 [[&nbsp; Main &nbsp; Page &nbsp;]]
8415 !! html
8416 <p><a href="/wiki/Main_Page" title="Main Page">&#160; Main &#160; Page &#160;</a>
8417 </p>
8418 !!end
8419
8420 # Add new article for the test below so that it doesn't red-link
8421 !! article
8422 Foo bar baz
8423 !! text
8424 boo
8425 !! endarticle
8426
8427 !! test
8428 Multiple spaces in titles should normalize to a single underscore
8429 !! options
8430 parsoid=wt2html,wt2wt
8431 !! wikitext
8432 [[Foo bar baz|x]]
8433 [[Foo bar baz|x]]
8434 [[Foo bar baz|x]]
8435 !! html/php
8436 <p><a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8437 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8438 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8439 </p>
8440 !! html/parsoid
8441 <p><a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8442 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8443 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8444 </p>
8445 !! end
8446
8447 !! test
8448 Internal link with ca linktrail, surrounded by bold apostrophes (T29473 primary issue)
8449 !! options
8450 language=ca
8451 !! wikitext
8452 '''[[Main Page]]'''
8453 !! html
8454 <p><b><a href="/wiki/Main_Page" title="Main Page">Main Page</a></b>
8455 </p>
8456 !! end
8457
8458 !! test
8459 Internal link with ca linktrail, surrounded by italic apostrophes (T29473 primary issue)
8460 !! options
8461 language=ca
8462 !! wikitext
8463 ''[[Main Page]]''
8464 !! html
8465 <p><i><a href="/wiki/Main_Page" title="Main Page">Main Page</a></i>
8466 </p>
8467 !! end
8468
8469 !! test
8470 Internal link with en linktrail: no apostrophes (T29473)
8471 !! options
8472 language=en
8473 !! wikitext
8474 [[Something]]'nice
8475 !! html
8476 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (page does not exist)">Something</a>'nice
8477 </p>
8478 !! end
8479
8480 !! test
8481 Internal link with ca linktrail with apostrophes (T29473)
8482 !! options
8483 language=ca
8484 !! wikitext
8485 [[Something]]'nice
8486 !! html
8487 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (encara no existeix)">Something'nice</a>
8488 </p>
8489 !! end
8490
8491 !! test
8492 Internal link with kaa linktrail with apostrophes (T29473)
8493 !! options
8494 language=kaa
8495 !! wikitext
8496 [[Something]]'nice
8497 !! html
8498 <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>
8499 </p>
8500 !! end
8501
8502 !! test
8503 Link with multiple ":" in a subpage-supporting namespace (T65636)
8504 !! wikitext
8505 [[User:Foo/Test/63636:Bar|Test]]
8506 !! html/php
8507 <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>
8508 </p>
8509 !! html/parsoid
8510 <p><a rel="mw:WikiLink" href="./User:Foo/Test/63636:Bar" title="User:Foo/Test/63636:Bar">Test</a></p>
8511 !! end
8512
8513 ## Mainly a sanity check for Parsoid
8514 !! test
8515 Handle title parsing for subpages
8516 !! options
8517 title=[[/123123]]
8518 subpage
8519 !! wikitext
8520 123
8521 !! html/php
8522 <p>123
8523 </p>
8524 !! html/parsoid
8525 <p>123</p>
8526 !! end
8527
8528 !! article
8529 User:Test/123
8530 !! text
8531 test 123
8532 !! endarticle
8533
8534 !! test
8535 Link to a subpage from a namespace other than main
8536 !! options
8537 title=[[User:Test]]
8538 subpage
8539 !! wikitext
8540 [[/123]]
8541 !! html/php
8542 <p><a href="/wiki/User:Test/123" title="User:Test/123">/123</a>
8543 </p>
8544 !! html/parsoid
8545 <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>
8546 !! end
8547
8548 !! test
8549 Ensure that transclusion titles are not url-decoded
8550 !! options
8551 subpage title=[[Test]]
8552 parsoid=wt2html
8553 !! wikitext
8554 {{Bar%C3%A9}} {{/Bar%C3%A9}}
8555 !! html/php
8556 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}
8557 </p>
8558 !! html/parsoid
8559 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}</p>
8560 !! end
8561
8562 !! test
8563 Purely hash wikilink
8564 !! options
8565 title=[[User:Test/123]]
8566 subpage
8567 !! wikitext
8568 [[#a|b]]
8569 !! html/php
8570 <p><a href="#a">b</a>
8571 </p>
8572 !! html/parsoid
8573 <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>
8574 !! end
8575
8576 !! test
8577 Serialization of purely hash wikilink
8578 !! options
8579 title=[[User:Test/123]]
8580 subpage
8581 parsoid=html2wt
8582 !! html/parsoid
8583 <p><a href="#a">[[</a></p>
8584 !! wikitext
8585 [[#a|<nowiki>[[</nowiki>]]
8586 !! html/php
8587 <p><a href="#a">[[</a>
8588 </p>
8589 !! end
8590
8591 !! test
8592 1. Interaction of linktrail and template encapsulation
8593 !! wikitext
8594 {{echo|[[Foo]]}}l
8595 !! html/php+tidy
8596 <p><a href="/wiki/Foo" title="Foo">Fool</a>
8597 </p>
8598 !! html/parsoid
8599 <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>
8600 !! end
8601
8602 !! test
8603 2. Interaction of linktrail and template encapsulation
8604 !! wikitext
8605 {{echo|Some [[Fool]]}}s
8606 !! html/php+tidy
8607 <p>Some <a href="/index.php?title=Fool&amp;action=edit&amp;redlink=1" class="new" title="Fool (page does not exist)">Fools</a>
8608 </p>
8609 !! html/parsoid
8610 <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>
8611 !! end
8612
8613 !! test
8614 3. Interaction of linktrail and template encapsulation
8615 !! wikitext
8616 {{echo|Some [[Fool]]s are '''bold and foolish'''}}
8617 !! html/php+tidy
8618 <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>
8619 </p>
8620 !! html/parsoid
8621 <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>
8622 !! end
8623
8624 !! article
8625 Söfnuður
8626 !! text
8627 Test.
8628 !! endarticle
8629
8630 !! test
8631 Internal link with is link prefix
8632 !! options
8633 language=is
8634 !! wikitext
8635 Aðrir mótmælenda[[söfnuður|söfnuðir]] og
8636 !! html
8637 <p>Aðrir <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a> og
8638 </p>
8639 !! end
8640
8641 !! article
8642 Mótmælendatrú
8643 !! text
8644 Test.
8645 !! endarticle
8646
8647 !! test
8648 Internal link with is link trail and link prefix
8649 !! options
8650 language=is
8651 !! wikitext
8652 [[mótmælendatrú|xxx]]ar
8653 [[mótmælendatrú]]ar
8654 mótmælenda[[söfnuður]]
8655 mótmælenda[[söfnuður|söfnuðir]]
8656 mótmælenda[[söfnuður|söfnuðir]]xxx
8657 !! html
8658 <p><a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">xxxar</a>
8659 <a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">mótmælendatrúar</a>
8660 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuður</a>
8661 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a>
8662 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðirxxx</a>
8663 </p>
8664 !! end
8665
8666 !! test
8667 Parsoid link trail escaping
8668 !! options
8669 parsoid=html2wt,html2html
8670 !! html/parsoid
8671 <p><a rel="mw:WikiLink" href="./Apple" title="Apple">apple</a>s</p>
8672 !! wikitext
8673 [[apple]]<nowiki/>s
8674 !! end
8675
8676 !! test
8677 Parsoid link prefix escaping
8678 !! options
8679 language=is
8680 parsoid=html2wt,html2html
8681 !! html/parsoid
8682 <p>Aðrir mótmælenda<a rel="mw:WikiLink" href="./Söfnuður" title="Söfnuður">söfnuður</a></p>
8683 !! wikitext
8684 Aðrir mótmælenda<nowiki/>[[söfnuður]]
8685 !! end
8686
8687 !! test
8688 Parsoid link bracket escaping
8689 !! options
8690 parsoid=html2wt,html2html
8691 !! html/parsoid
8692 <p><a rel="mw:WikiLink" href="./Test" title="Test">Test</a></p>
8693 <p>[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]</p>
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 !! wikitext
8699 [[Test]]
8700
8701 [<nowiki/>[[Test]]]
8702
8703 [[[[Test]]]]
8704
8705 [[[<nowiki/>[[Test]]]]]
8706
8707 [[[[[[Test]]]]]]
8708
8709 [[[[[<nowiki/>[[Test]]]]]]]
8710 !! end
8711
8712 !! test
8713 Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved
8714 !! wikitext
8715 [[Foo| bar]]
8716
8717 [[Foo| ''bar'']]
8718
8719 [http://wp.org foo]
8720
8721 [http://wp.org ''foo'']
8722 !! html
8723 <p><a href="/wiki/Foo" title="Foo"> bar</a>
8724 </p><p><a href="/wiki/Foo" title="Foo"> <i>bar</i></a>
8725 </p><p><a rel="nofollow" class="external text" href="http://wp.org">foo</a>
8726 </p><p><a rel="nofollow" class="external text" href="http://wp.org"><i>foo</i></a>
8727 </p>
8728 !! end
8729
8730 !! test
8731 Parsoid: Scoped parsing should handle mixed transclusions and plain text
8732 !! wikitext
8733 [[Foo|{{echo|a}} b {{echo|c}}]]
8734 !! html/parsoid
8735 <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>
8736 !! end
8737
8738 !! test
8739 Link with angle bracket after anchor
8740 !! config
8741 wgFragmentMode=[ 'html5', 'legacy' ]
8742 !! wikitext
8743 [[Foo#<bar>]]
8744 !! html/php
8745 <p><a href="/wiki/Foo#&lt;bar&gt;" title="Foo">Foo#&lt;bar&gt;</a>
8746 </p>
8747 !! html/parsoid
8748 <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>
8749 !! end
8750
8751 !! test
8752 Link with angle bracket after anchor (legacy)
8753 !! config
8754 wgFragmentMode=[ 'legacy' ]
8755 !! wikitext
8756 [[Foo#<bar>]]
8757 !! html/php
8758 <p><a href="/wiki/Foo#.3Cbar.3E" title="Foo">Foo#&lt;bar&gt;</a>
8759 </p>
8760 !! end
8761
8762 ###
8763 ### Interwiki links (see maintenance/interwiki.sql)
8764 ###
8765
8766 !! test
8767 Inline interwiki link
8768 !! options
8769 parsoid=wt2html,wt2wt,html2html
8770 !! wikitext
8771 [[MeatBall:SoftSecurity]]
8772 !! html/php
8773 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
8774 </p>
8775 !! html/parsoid
8776 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a></p>
8777 !! end
8778
8779 !! test
8780 Inline interwiki link with empty title (T4372)
8781 !! options
8782 parsoid=wt2html,wt2wt,html2html
8783 !! wikitext
8784 [[MeatBall:]]
8785 !! html/php
8786 <p><a href="http://www.usemod.com/cgi-bin/mb.pl" class="extiw" title="meatball:">MeatBall:</a>
8787 </p>
8788 !! html/parsoid
8789 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?" title="meatball:">MeatBall:</a></p>
8790 !! end
8791
8792 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
8793 !! test
8794 Interwiki link encoding conversion (T3636)
8795 !! options
8796 parsoid=wt2html,wt2wt
8797 !! wikitext
8798 *[[Wikipedia:ro:Olteni&#0355;a]]
8799 *[[Wikipedia:ro:Olteni&#355;a]]
8800 !! html/php
8801 <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>
8802 <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>
8803
8804 !! html/php+tidy
8805 <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>
8806 <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>
8807 !! html/parsoid
8808 <ul>
8809 <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>
8810 <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>
8811 </ul>
8812 !! end
8813
8814 !! test
8815 Interwiki link with fragment (T4130)
8816 !! wikitext
8817 [[MeatBall:SoftSecurity#foo]]
8818 !! html
8819 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity#foo</a>
8820 </p>
8821 !! end
8822
8823 !! test
8824 Link scenarios with escaped fragments
8825 !! config
8826 wgFragmentMode=[ 'html5', 'legacy' ]
8827 !! wikitext
8828 [[#Is this great?]]
8829 [[Foo#Is this great?]]
8830 [[meatball:Foo#Is this great?]]
8831 !! html/php
8832 <p><a href="#Is_this_great?">#Is this great?</a>
8833 <a href="/wiki/Foo#Is_this_great?" title="Foo">Foo#Is this great?</a>
8834 <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>
8835 </p>
8836 !! html/parsoid
8837 <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>
8838 <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>
8839 <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>
8840 !! end
8841
8842 !! test
8843 Link scenarios with escaped fragments (legacy)
8844 !! config
8845 wgFragmentMode=[ 'legacy' ]
8846 !! wikitext
8847 [[#Is this great?]]
8848 [[Foo#Is this great?]]
8849 [[meatball:Foo#Is this great?]]
8850 !! html/php
8851 <p><a href="#Is_this_great.3F">#Is this great?</a>
8852 <a href="/wiki/Foo#Is_this_great.3F" title="Foo">Foo#Is this great?</a>
8853 <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>
8854 </p>
8855 !! end
8856
8857 # Ideally the wikipedia: prefix here should be proto-relative too
8858 # [CSA]: this is kind of a bogus test, as the PHP parser test doesn't
8859 # define the 'en' prefix, and originally the test used 'wikipedia',
8860 # which isn't a localinterwiki prefix hence the links to the 'en:Foo'
8861 # article.
8862 !! test
8863 Different interwiki prefixes mapping to the same URL
8864 !! wikitext
8865 [[:en:Foo]]
8866
8867 [[:en:Foo|Foo]]
8868
8869 [[wikipedia:Foo]]
8870
8871 [[:wikipedia:Foo|Foo]]
8872
8873 [[wikipedia:en:Foo]]
8874
8875 [[:wikipedia:en:Foo]]
8876
8877 [[ wikiPEdia :Foo]]
8878 !! html/parsoid
8879 <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>
8880
8881 <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>
8882
8883 <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>
8884
8885 <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>
8886
8887 <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>
8888
8889 <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>
8890
8891 <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>
8892 !! end
8893
8894 !! test
8895 Interwiki links that cannot be represented in wiki syntax
8896 !! wikitext
8897 [[meatball:ok]]
8898 [[meatball:ok#foo|ok with fragment]]
8899 [[meatball:ok_as_well?|ok ending with ? mark]]
8900 [http://de.wikipedia.org/wiki/Foo?action=history has query]
8901 [http://de.wikipedia.org/wiki/#foo is just fragment]
8902
8903 !! html/php
8904 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?ok" class="extiw" title="meatball:ok">meatball:ok</a>
8905 <a href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" class="extiw" title="meatball:ok">ok with fragment</a>
8906 <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>
8907 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8908 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a>
8909 </p>
8910 !! html/parsoid
8911 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok" title="meatball:ok">meatball:ok</a>
8912 <a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" title="meatball:ok">ok with fragment</a>
8913 <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>
8914 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8915 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a></p>
8916 !! end
8917
8918 !! test
8919 Interwiki links: trail
8920 !! wikitext
8921 [[wikipedia:Foo|Ba]]r
8922 !! html/php
8923 <p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
8924 </p>
8925 !! html/parsoid
8926 <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>
8927 !! end
8928
8929 !! test
8930 Local interwiki link
8931 !! options
8932 parsoid=wt2html,wt2wt,html2html
8933 !! wikitext
8934 [[local:Template:Foo]]
8935 !! html/php
8936 <p><a href="/wiki/Template:Foo" title="Template:Foo">local:Template:Foo</a>
8937 </p>
8938 !! html/parsoid
8939 <p><a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">local:Template:Foo</a></p>
8940 !! end
8941
8942 # Parsoid does not mark self-links, by design.
8943 !! test
8944 Local interwiki link: self-link to current page
8945 !! options
8946 title=[[Main Page]]
8947 parsoid=wt2html,wt2wt,html2html
8948 !! wikitext
8949 [[local:Main Page]]
8950 !! html/php
8951 <p><a class="mw-selflink selflink">local:Main Page</a>
8952 </p>
8953 !! html/parsoid
8954 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:Main Page</a></p>
8955 !! end
8956
8957 !! test
8958 Local interwiki link: prefix only (T66167)
8959 !! options
8960 parsoid=wt2html,wt2wt,html2html
8961 !! wikitext
8962 [[local:]]
8963 !! html/php
8964 <p><a href="/wiki/Main_Page" title="Main Page">local:</a>
8965 </p>
8966 !! html/parsoid
8967 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:</a></p>
8968 !! end
8969
8970 !! test
8971 Local interwiki link: with additional interwiki prefix (T63357)
8972 !! options
8973 parsoid=wt2html,wt2wt,html2html
8974 !! wikitext
8975 [[local:meatball:Hello]]
8976 !! html/php
8977 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Hello" class="extiw" title="meatball:Hello">local:meatball:Hello</a>
8978 </p>
8979 !! html/parsoid
8980 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?Hello" title="meatball:Hello">local:meatball:Hello</a></p>
8981 !! end
8982
8983 !! test
8984 Multiple local interwiki link prefixes
8985 !! wikitext
8986 [[local:local:local:local:mi:local:Foo]]
8987 !! options
8988 parsoid=wt2html,wt2wt,html2html
8989 !! html/php
8990 <p><a href="/wiki/Foo" title="Foo">local:local:local:local:mi:local:Foo</a>
8991 </p>
8992 !! html/parsoid
8993 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">local:local:local:local:mi:local:Foo</a></p>
8994 !! end
8995
8996 !! test
8997 Interwiki link with percent encoded target
8998 !! wikitext
8999 [[:es:Nueva Guip%C3%BAzcoa|Nueva Guipúzcoa]]
9000 !! html/php
9001 <p><a href="http://es.wikipedia.org/wiki/Nueva_Guip%C3%BAzcoa" class="extiw" title="es:Nueva Guipúzcoa">Nueva Guipúzcoa</a>
9002 </p>
9003 !! html/parsoid
9004 <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>
9005 !! end
9006
9007 ###
9008 ### Interlanguage links
9009 ### Language links (so that searching for '### language' matches..)
9010 ###
9011
9012 !! test
9013 Interlanguage link
9014 !! wikitext
9015 Blah blah blah
9016 [[zh:Chinese]]
9017 !! html/php
9018 <p>Blah blah blah
9019 </p>
9020 !! html/parsoid
9021 <p>Blah blah blah</p>
9022 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9023 !! end
9024
9025 ## parsoid html2wt will lose the space variations
9026 !! test
9027 Interlanguage link with spacing
9028 !! options
9029 parsoid=wt2html,wt2wt,html2html
9030 !! wikitext
9031 Blah blah blah
9032 [[ zh : Chinese ]]
9033 !! html/php
9034 <p>Blah blah blah
9035 </p>
9036 !! html/parsoid
9037 <p>Blah blah blah</p>
9038 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9039 !! end
9040
9041 !! test
9042 Double interlanguage link
9043 !! wikitext
9044 Blah blah blah
9045 [[es:Spanish]]
9046 [[zh:Chinese]]
9047 !! html/php
9048 <p>Blah blah blah
9049 </p>
9050 !! html/parsoid
9051 <p>Blah blah blah</p>
9052 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
9053 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9054 !! end
9055
9056 ## parsoid html2wt will lose the space variations
9057 !! test
9058 Interlanguage link variations
9059 !! options
9060 parsoid=wt2html,wt2wt,html2html
9061 !! wikitext
9062 Blah blah blah
9063 [[ es :Spanish]]
9064 [[ ZH :Chinese]]
9065 [[es:Foo_bar]]
9066 !! html/php
9067 <p>Blah blah blah
9068 </p>
9069 !! html/parsoid
9070 <p>Blah blah blah</p>
9071 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish" />
9072 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese" />
9073 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar" />
9074 !! end
9075
9076 !! test
9077 Escaping of interlanguage links (T129218, T156308)
9078 !! wikitext
9079 Blah blah blah
9080 [[:es:Spanish]]
9081 [[ : zh : Chinese ]]
9082 !! html/php
9083 <p>Blah blah blah
9084 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
9085 <a href="http://zh.wikipedia.org/wiki/Chinese" class="extiw" title="zh:Chinese"> zh : Chinese </a>
9086 </p>
9087 !! html/parsoid
9088 <p>Blah blah blah
9089 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
9090 <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh : Chinese </a></p>
9091 !! end
9092
9093 !! test
9094 Multiple colons escaping interlanguage links
9095 !! options
9096 parsoid=wt2html
9097 !! wikitext
9098 [[:es:Spanish]]
9099 [[::es:Spanish]]
9100 [[:::es:Spanish]]
9101 !! html/php
9102 <p><a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
9103 [[::es:Spanish]]
9104 [[:::es:Spanish]]
9105 </p>
9106 !! html/parsoid
9107 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
9108 [[::es:Spanish]]
9109 [[:::es:Spanish]]</p>
9110 !! end
9111
9112 ## parsoid html2wt will normalize the space to _
9113 !! test
9114 Space and question mark encoding in interlanguage links (T95473)
9115 !! options
9116 parsoid=wt2html,wt2wt,html2html
9117 !! wikitext
9118 Blah blah blah
9119 [[es:Foo bar?]]
9120 !! html/php
9121 <p>Blah blah blah
9122 </p>
9123 !! html/parsoid
9124 <p>Blah blah blah</p>
9125 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar%3F" />
9126 !! end
9127
9128 !! test
9129 Interlanguage link, with prefix links
9130 !! options
9131 language=ln
9132 !! wikitext
9133 Blah blah blah
9134 [[zh:Chinese]]
9135 !! html/php
9136 <p>Blah blah blah
9137 </p>
9138 !! html/parsoid
9139 <p>Blah blah blah</p>
9140 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9141 !! end
9142
9143 !! test
9144 Double interlanguage link, with prefix links (T10897)
9145 !! options
9146 language=ln
9147 !! wikitext
9148 Blah blah blah
9149 [[es:Spanish]]
9150 [[zh:Chinese]]
9151 !! html/php
9152 <p>Blah blah blah
9153 </p>
9154 !! html/parsoid
9155 <p>Blah blah blah</p>
9156 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
9157 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9158 !! end
9159
9160 !! test
9161 "Extra" interlanguage links (T34189 / gerrit 111390)
9162 !! wikitext
9163 Blah blah blah
9164 [[mul:Article]]
9165 !! html/php
9166 <p>Blah blah blah
9167 </p>
9168 !! html/parsoid
9169 <p>Blah blah blah</p>
9170 <link rel="mw:PageProp/Language" title="Multilingual" href="http://wikisource.org/wiki/Article"/>
9171 !! end
9172
9173 ## PHP parser tests script needs an update
9174 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
9175 !! test
9176 Language links render as inline links if $wgInterwikiMagic=false
9177 !! options
9178 wgInterwikiMagic=false
9179 parsoid=wt2html,wt2wt,html2html
9180 !! wikitext
9181 Blah blah blah
9182 [[zh:Chinese]]
9183 !! html/parsoid
9184 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
9185 !! end
9186
9187 ## PHP parser tests script needs an update
9188 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
9189 !! test
9190 Language links render as inline links in the Talk namespace
9191 !! options
9192 title=Talk:Foo
9193 parsoid=wt2html,wt2wt,html2html
9194 !! wikitext
9195 Blah blah blah
9196 [[zh:Chinese]]
9197 !! html/parsoid
9198 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
9199 !! end
9200
9201 !! test
9202 Parsoid-specific test: Wikilinks with &nbsp; should RT properly
9203 !! options
9204 language=ln
9205 !! wikitext
9206 [[WW&nbsp;II]]
9207 !! html
9208 <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>
9209 </p>
9210 !! end
9211
9212 !! test
9213 Parsoid T55221: Wikilinks should be properly entity-escaped
9214 !! options
9215 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
9216 !! html/parsoid
9217 <p>He&amp;nbsp;llo <a href="./Foo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9218 <p>He&amp;nbsp;llo <a href="./He&amp;nbsp;llo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9219 !! wikitext
9220 He&amp;nbsp;llo [[Foo|He&amp;nbsp;llo]]
9221
9222 He&amp;nbsp;llo He&amp;nbsp;llo
9223 !! html/php
9224 <p>He&amp;nbsp;llo <a href="/wiki/Foo" title="Foo">He&amp;nbsp;llo</a>
9225 </p><p>He&amp;nbsp;llo He&amp;nbsp;llo
9226 </p>
9227 !! end
9228
9229 # html2wt will fail because of title normalization without data-parsoid
9230 !! test
9231 Parsoid: handle constructor well
9232 !! options
9233 parsoid=wt2html,wt2wt
9234 !! wikitext
9235 [[constructor]]
9236
9237 [[constructor:foo]]
9238 !! html/php
9239 <p><a href="/index.php?title=Constructor&amp;action=edit&amp;redlink=1" class="new" title="Constructor (page does not exist)">constructor</a>
9240 </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>
9241 </p>
9242 !! html/parsoid
9243 <p><a rel="mw:WikiLink" href="./Constructor" title="Constructor" data-parsoid='{"stx":"simple","a":{"href":"./Constructor"},"sa":{"href":"constructor"}}'>constructor</a></p>
9244
9245 <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>
9246 !! end
9247
9248 !! test
9249 Template parameter named "constructor"
9250 !! wikitext
9251 {{echo| constructor = |hi}}
9252 !! html/parsoid
9253 <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>
9254 !! end
9255
9256 !! article
9257 ko:
9258 !! text
9259 Test.
9260 !! endarticle
9261
9262 # Note that `ko` isn't a known interlanguage prefix
9263 !! test
9264 Parsoid: recognize interlanguage links without a target page
9265 !! options
9266 ill
9267 !! wikitext
9268 [[es:]]
9269
9270 [[ko:]]
9271 !! html/php
9272 es:
9273 !! html/parsoid
9274 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/"/>
9275
9276 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9277 !! end
9278
9279 # Note that `ko` isn't a known interwiki prefix
9280 !! test
9281 Parsoid: recognize interwiki links without a target page
9282 !! options
9283 parsoid=wt2html,wt2wt,html2html
9284 !! wikitext
9285 [[:es:]]
9286
9287 [[:ko:]]
9288 !! html/php
9289 <p><a href="http://es.wikipedia.org/wiki/" class="extiw" title="es:">es:</a>
9290 </p><p><a href="/wiki/Ko:" title="Ko:">ko:</a>
9291 </p>
9292 !! html/parsoid
9293 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/" title="es:">es:</a></p>
9294 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9295 !! end
9296
9297 !! test
9298 Handle interwiki links pointing to the current wiki as plain wiki links (T47209)
9299 !! wikitext
9300 [[mi:Foo]]
9301 !! html/php
9302 <p><a href="/wiki/Foo" title="Foo">mi:Foo</a>
9303 </p>
9304 !! html/parsoid
9305 <p><a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo"},"sa":{"href":"mi:Foo"}}'>mi:Foo</a></p>
9306 !! end
9307
9308 !! test
9309 Interlanguage link with preceding local interwiki link (T70085)
9310 !! options
9311 parsoid=wt2html,wt2wt,html2html
9312 !! wikitext
9313 Blah blah blah
9314 [[local:es:Spanish]]
9315 !! html/php
9316 <p>Blah blah blah
9317 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">local:es:Spanish</a>
9318 </p>
9319 !! html/parsoid
9320 <p>Blah blah blah
9321 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">local:es:Spanish</a></p>
9322 !! end
9323
9324 !! test
9325 Looks like an interlanguage link, but is actually a local interwiki
9326 !! options
9327 parsoid=wt2html,wt2wt,html2html
9328 !! wikitext
9329 Blah blah blah
9330 [[mi:Template:Foo]]
9331 !! html/php
9332 <p>Blah blah blah
9333 <a href="/wiki/Template:Foo" title="Template:Foo">mi:Template:Foo</a>
9334 </p>
9335 !! html/parsoid
9336 <p>Blah blah blah
9337 <a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">mi:Template:Foo</a></p>
9338 !! end
9339
9340 ###
9341 ### Redirects, Parsoid-only
9342 ###
9343
9344 !! test
9345 1. Simple redirect to page
9346 !! wikitext
9347 #REDIRECT [[Main Page]]
9348 !! html/parsoid
9349 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9350 !! end
9351
9352 !! test
9353 2. Other redirect variants
9354 !! wikitext
9355 #REDIRECT [[Main_Page]]
9356 !! html/parsoid
9357 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Main_Page"},"sa":{"href":"Main_Page"}}'/>
9358 !! end
9359
9360 # Not a valid redirect in PHP (although perhaps it was, once upon a time)
9361 # This tests the Parsoid bail-out code.
9362 !! test
9363 3. Other redirect variants
9364 !! options
9365 parsoid=wt2html
9366 !! wikitext
9367 #REDIRECT [[<nowiki>[[Bar]]</nowiki>]]
9368 !! html/parsoid
9369 <ol><li>REDIRECT [[<span typeof="mw:Nowiki">[[Bar]]</span>]]</li></ol>
9370 !! end
9371
9372 !! test
9373 4. Redirect to a templated destination
9374 !! wikitext
9375 #REDIRECT [[{{echo|Foo}}bar]]
9376 !! html/parsoid
9377 <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"}]]}'/>
9378 !! end
9379
9380 !! test
9381 Empty redirect
9382 !! options
9383 parsoid=wt2html,wt2wt
9384 !! wikitext
9385 #REDIRECT [[]]
9386 !! html/parsoid
9387 <ol>
9388 <li>REDIRECT [[]]</li></ol>
9389 !! end
9390
9391 !! test
9392 Optional colon in #REDIRECT
9393 !! options
9394 # the colon is archaic syntax. we support it for wt2html, but we
9395 # don't care that it roundtrips back to the modern syntax.
9396 parsoid=wt2html,html2html
9397 !! wikitext
9398 #REDIRECT:[[Main Page]]
9399 !! html/parsoid
9400 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9401 !! end
9402
9403 !! test
9404 Whitespace in #REDIRECT with optional colon
9405 !! options
9406 # the colon and gratuitous whitespace is archaic syntax. we support
9407 # it for wt2html, but we don't care that it roundtrips back to the
9408 # modern syntax (without extra whitespace)
9409 parsoid=wt2html,html2html
9410 !! wikitext
9411
9412 #REDIRECT
9413 :
9414 [[Main Page]]
9415 !! html/parsoid
9416 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9417 !! end
9418
9419 !! test
9420 Piped link in #REDIRECT
9421 !! options
9422 # content after piped link is ignored. we support this syntax,
9423 # but don't care that the piped link is lost when we roundtrip this.
9424 parsoid=wt2html
9425 !! wikitext
9426 #REDIRECT [[Main Page|bar]]
9427 !! html/parsoid
9428 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9429 !! end
9430
9431 !! test
9432 Redirect to category (T104502)
9433 !! options
9434 parsoid=wt2html,wt2wt
9435 !! wikitext
9436 #REDIRECT [[Category:Foo]]
9437 !! html/parsoid
9438 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9439 !! end
9440
9441 !! test
9442 Redirect to category with URL encoding (T104502)
9443 !! options
9444 parsoid=wt2html
9445 !! wikitext
9446 #REDIRECT [[Category%3AFoo]]
9447 !! html/parsoid
9448 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9449 !! end
9450
9451 !! test
9452 Redirect to category page
9453 !! wikitext
9454 #REDIRECT [[:Category:Foo]]
9455 !! html/parsoid
9456 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9457 !! end
9458
9459 !! test
9460 Redirect to image page (1)
9461 !! wikitext
9462 #REDIRECT [[File:Wiki.png]]
9463 !! html/parsoid
9464 <link rel="mw:PageProp/redirect" href="./File:Wiki.png"/>
9465 !! end
9466
9467 !! test
9468 Redirect to image page (2)
9469 !! wikitext
9470 #REDIRECT [[Image:Wiki.png]]
9471 !! html/parsoid
9472 <link rel="mw:PageProp/redirect" href="./File:Wiki.png" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./File:Wiki.png"},"sa":{"href":"Image:Wiki.png"}}'/>
9473 !! end
9474
9475 # html2wt disabled because wts serializes as "#REDIRECT [[:en:File:Wiki.png]]"
9476 # Next test confirms this.
9477 !! test
9478 Redirect to language (1) (T104918)
9479 !! options
9480 parsoid=wt2html,wt2wt,html2html
9481 !! wikitext
9482 #REDIRECT [[en:File:Wiki.png]]
9483 !! html/parsoid
9484 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9485 !! end
9486
9487 !! test
9488 Redirect to language (2) (T104918)
9489 !! wikitext
9490 #REDIRECT [[:en:File:Wiki.png]]
9491 !! html/parsoid
9492 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9493 !! end
9494
9495 !! test
9496 Redirect to interwiki (T104918)
9497 !! wikitext
9498 #REDIRECT [[meatball:File:Wiki.png]]
9499 !! html/parsoid
9500 <link rel="mw:PageProp/redirect" href="http://www.usemod.com/cgi-bin/mb.pl?File:Wiki.png"/>
9501 !! end
9502
9503 !! test
9504 Non-English #REDIRECT
9505 !! options
9506 language=is
9507 !! wikitext
9508 #TILVÍSUN [[Main Page]]
9509 !! html/parsoid
9510 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#TILVÍSUN ","a":{"href":"./Main_Page"},"sa":{"href":"Main Page"}}'/>
9511 !! end
9512
9513 !! test
9514 Redirect syntax under text isn't considered a redirect
9515 !! wikitext
9516 some text
9517
9518 #redirect [[Main Page]]
9519 !! html/parsoid
9520 <p>some text</p>
9521 <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>
9522 !! end
9523
9524 !! test
9525 New redirect
9526 !! options
9527 parsoid=html2wt
9528 !! html/parsoid
9529 <p>Foo<link rel="mw:PageProp/redirect" href="./Foo"/></p>
9530 !! wikitext
9531 #REDIRECT [[Foo]]
9532 Foo
9533 !! end
9534
9535 !! test
9536 Redirect followed by block on the same line
9537 !! options
9538 parsoid=wt2html
9539 !! wikitext
9540 #REDIRECT [[Main Page]]<!-- haha -->==hi==
9541 !! html/parsoid
9542 <link rel="mw:PageProp/redirect" href="./Main_Page"/><!-- haha --><h2 id="hi">hi</h2>
9543 !! end
9544
9545 !! test
9546 Redirect followed by a newline
9547 !! wikitext
9548 #REDIRECT [[Main Page]]
9549 A newline
9550 !! html/parsoid
9551 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9552 <p>A newline</p>
9553 !! end
9554
9555 !! test
9556 Redirect followed by multiple newlines
9557 !! wikitext
9558 #REDIRECT [[Main Page]]
9559
9560
9561 A newline
9562 !! html/parsoid
9563 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9564
9565 <p><br/>
9566 A newline</p>
9567 !! end
9568
9569 !! test
9570 Drop duplicate redirects
9571 !! options
9572 parsoid=html2wt
9573 !! html/parsoid
9574 <link rel="mw:PageProp/redirect" href="./Foo"/>
9575 <link rel="mw:PageProp/redirect" href="./Bar"/>
9576 <link rel="mw:PageProp/redirect" href="./Baz"/>
9577 !! wikitext
9578 #REDIRECT [[Foo]]
9579 !! end
9580
9581 ##
9582 ## XHTML tidiness
9583 ###
9584
9585 !! test
9586 <br> to <br />
9587 !! wikitext
9588 1<br>2<br />3
9589 !! html
9590 <p>1<br />2<br />3
9591 </p>
9592 !! end
9593
9594 !! test
9595 Broken br tag sanitization
9596 !! wikitext
9597 </br>
9598 !! html/php
9599 <p>&lt;/br&gt;
9600 </p>
9601 !! end
9602
9603 # TODO: Fix html2html mode (T53055)!
9604 !! test
9605 Parsoid: Broken br tag recognition
9606 !! options
9607 parsoid=wt2html
9608 !! wikitext
9609 </br>
9610
9611 <br/ >
9612 !! html+tidy
9613 <p><br />
9614 </p><p><br />
9615 </p>
9616 !! end
9617
9618 !! test
9619 Incorrecly removing closing slashes from correctly formed XHTML
9620 !! wikitext
9621 <br style="clear:both;" />
9622 !! html
9623 <p><br style="clear:both;" />
9624 </p>
9625 !! end
9626
9627 !! test
9628 Failing to transform badly formed HTML into correct XHTML
9629 !! wikitext
9630 <br style="clear: left;">
9631 <br style="clear: right;">
9632 <br style="clear: both;">
9633 !! html
9634 <p><br style="clear: left;" />
9635 <br style="clear: right;" />
9636 <br style="clear: both;" />
9637 </p>
9638 !!end
9639
9640 ## FIXME: Is Parsoid's acceptance of self-closing html-tags
9641 ## a feature or a bug? See https://phabricator.wikimedia.org/T76962
9642 !! test
9643 Handling html with a div self-closing tag
9644 !! wikitext
9645 <div title />
9646 <div title/>
9647 <div title/ >
9648 <div title=bar />
9649 <div title=bar/>
9650 <div title=bar/ >
9651 !! html/php
9652 <p>&lt;div title /&gt;
9653 &lt;div title/&gt;
9654 </p>
9655 <div>
9656 <p>&lt;div title=bar /&gt;
9657 &lt;div title=bar/&gt;
9658 </p>
9659 <div title="bar/"></div>
9660 </div>
9661
9662 !! html/parsoid
9663 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9664 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9665 <div title="" data-parsoid='{"stx":"html","autoInsertedEnd":true}'>
9666 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9667 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9668 <div title="bar/" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></div></div>
9669 !! end
9670
9671 !! test
9672 Elements with solidus in various attribute positions
9673 !! options
9674 parsoid=wt2html,html2html
9675 !! wikitext
9676 <div cla/ss="123">ha</div>
9677
9678 <div / class="123">ha</div>
9679
9680 <div class= / "123">ha</div>
9681 !! html/php+tidy
9682 <div>ha</div>
9683 <div class="123">ha</div>
9684 <div class="/">ha</div>
9685 !! html/parsoid
9686 <div data-parsoid='{"stx":"html","a":{"cla":null,"ss":null},"sa":{"cla":"","ss":"123"}}'>ha</div>
9687
9688 <div class="123" data-parsoid='{"stx":"html"}'>ha</div>
9689
9690 <div class="/" data-parsoid='{"stx":"html","a":{"\"123\"":null},"sa":{"\"123\"":""}}'>ha</div>
9691 !! end
9692
9693 !! test
9694 Handling html with a br self-closing tag
9695 !! wikitext
9696 <br title />
9697 <br title/>
9698 <br title/ >
9699 <br title=bar />
9700 <br title=bar/>
9701 <br title=bar/ >
9702 !! html/php
9703 <p><br title="" />
9704 <br title="" />
9705 <br />
9706 <br title="bar" />
9707 <br title="bar" />
9708 <br title="bar/" />
9709 </p>
9710 !! html/parsoid
9711 <p><br title="" />
9712 <br title="" />
9713 <br title="" />
9714 <br title="bar" />
9715 <br title="bar" />
9716 <br title="bar/" />
9717 </p>
9718 !! end
9719
9720 !! test
9721 Horizontal ruler (should it add that extra space?)
9722 !! wikitext
9723 <hr>
9724 <hr >
9725 foo <hr
9726 > bar
9727 !! html+tidy
9728 <hr />
9729 <hr /><p>
9730 foo </p><hr /><p> bar
9731 </p>
9732 !! end
9733
9734 !! test
9735 Horizontal ruler -- 4+ dashes render hr
9736 !! wikitext
9737 ----
9738 !! html
9739 <hr />
9740
9741 !! end
9742
9743 !! test
9744 Horizontal ruler -- eats additional dashes on the same line
9745 !! wikitext
9746 ---------
9747 !! html
9748 <hr />
9749
9750 !! end
9751
9752 !! test
9753 Horizontal ruler -- does not collapse dashes on consecutive lines
9754 !! wikitext
9755 ----
9756 ----
9757 !! html
9758 <hr />
9759 <hr />
9760
9761 !! end
9762
9763 !! test
9764 Horizontal ruler -- <4 dashes render as plain text
9765 !! wikitext
9766 ---
9767 !! html
9768 <p>---
9769 </p>
9770 !! end
9771
9772 !! test
9773 Horizontal ruler -- Supports content following dashes on same line
9774 !! wikitext
9775 ---- Foo
9776 !! html
9777 <hr /> Foo
9778
9779 !! html+tidy
9780 <hr /><p> Foo
9781 </p>
9782 !! end
9783
9784 ###
9785 ### Block-level elements
9786 ###
9787 !! test
9788 Common list
9789 !! wikitext
9790 *Common list
9791 *item 2
9792 *item 3
9793 !! html
9794 <ul><li>Common list</li>
9795 <li>item 2</li>
9796 <li>item 3</li></ul>
9797
9798 !! end
9799
9800 !! test
9801 Numbered list
9802 !! wikitext
9803 #Numbered list
9804 #item 2
9805 #item 3
9806 !! html
9807 <ol><li>Numbered list</li>
9808 <li>item 2</li>
9809 <li>item 3</li></ol>
9810
9811 !! end
9812
9813 # the switch from level 3 to ordered should not introduce a newline between
9814 !! test
9815 Mixed list
9816 !! wikitext
9817 *Mixed list
9818 *#with numbers
9819 **and bullets
9820 *#and numbers
9821 *bullets again
9822 **bullet level 2
9823 ***bullet level 3
9824 ***#Number on level 4
9825 **bullet level 2
9826 **#Number on level 3
9827 **#Number on level 3
9828 *#number level 2
9829 *Level 1
9830 ***Level 3
9831 #**Level 3, but ordered
9832 !! html
9833 <ul><li>Mixed list
9834 <ol><li>with numbers</li></ol>
9835 <ul><li>and bullets</li></ul>
9836 <ol><li>and numbers</li></ol></li>
9837 <li>bullets again
9838 <ul><li>bullet level 2
9839 <ul><li>bullet level 3
9840 <ol><li>Number on level 4</li></ol></li></ul></li>
9841 <li>bullet level 2
9842 <ol><li>Number on level 3</li>
9843 <li>Number on level 3</li></ol></li></ul>
9844 <ol><li>number level 2</li></ol></li>
9845 <li>Level 1
9846 <ul><li><ul><li>Level 3</li></ul></li></ul></li></ul>
9847 <ol><li><ul><li><ul><li>Level 3, but ordered</li></ul></li></ul></li></ol>
9848
9849 !! end
9850
9851 !! test
9852 1. Nested mixed wikitext and html list
9853 !! wikitext
9854 *hi
9855 *<ul><li>ho</li></ul>
9856 *hi
9857 **ho
9858 !! html/php
9859 <ul><li>hi</li>
9860 <li><ul><li>ho</li></ul></li>
9861 <li>hi
9862 <ul><li>ho</li></ul></li></ul>
9863
9864 !! html/parsoid
9865 <ul><li>hi</li>
9866 <li><ul data-parsoid='{"stx":"html"}'><li data-parsoid='{"stx":"html"}'>ho</li></ul></li>
9867 <li>hi
9868 <ul><li>ho</li></ul></li></ul>
9869 !! end
9870
9871 !! test
9872 2. Nested mixed wikitext and html list (incompatible)
9873 !! wikitext
9874 ;hi
9875 :{{echo|<li>ho</li>}}
9876 !! html/php
9877 <dl><dt>hi</dt>
9878 <dd><li>ho</li></dd></dl>
9879
9880 !! html/parsoid
9881 <dl><dt>hi</dt>
9882 <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>
9883 !! end
9884
9885 !! test
9886 Nested lists 1
9887 !! wikitext
9888 *foo
9889 **bar
9890 !! html
9891 <ul><li>foo
9892 <ul><li>bar</li></ul></li></ul>
9893
9894 !! end
9895
9896 !! test
9897 Nested lists 2
9898 !! wikitext
9899 **foo
9900 *bar
9901 !! html
9902 <ul><li><ul><li>foo</li></ul></li>
9903 <li>bar</li></ul>
9904
9905 !! end
9906
9907 !! test
9908 Nested lists 3 (first element empty)
9909 !! wikitext
9910 *
9911 **bar
9912 !! html
9913 <ul><li>
9914 <ul><li>bar</li></ul></li></ul>
9915
9916 !! end
9917
9918 !! test
9919 Nested lists 4 (first element empty)
9920 !! wikitext
9921 **
9922 *bar
9923 !! html
9924 <ul><li><ul><li></li></ul></li>
9925 <li>bar</li></ul>
9926
9927 !! end
9928
9929 !! test
9930 Nested lists 5 (both elements empty)
9931 !! wikitext
9932 **
9933 *
9934 !! html
9935 <ul><li><ul><li></li></ul></li>
9936 <li></li></ul>
9937
9938 !! end
9939
9940 !! test
9941 Nested lists 6 (both elements empty)
9942 !! wikitext
9943 *
9944 **
9945 !! html
9946 <ul><li>
9947 <ul><li></li></ul></li></ul>
9948
9949 !! end
9950
9951 !! test
9952 Nested lists 7 (skip initial nesting levels)
9953 !! wikitext
9954 ***foo
9955 !! html
9956 <ul><li><ul><li><ul><li>foo</li></ul></li></ul></li></ul>
9957
9958 !! end
9959
9960 !! test
9961 Nested lists 8 (multiple nesting transitions)
9962 !! wikitext
9963 *foo
9964 ***bar
9965 **baz
9966 *boo
9967 !! html
9968 <ul><li>foo
9969 <ul><li><ul><li>bar</li></ul></li>
9970 <li>baz</li></ul></li>
9971 <li>boo</li></ul>
9972
9973 !! end
9974
9975 # XXX this test should be moved to citeParserTests, since it depends
9976 # on the Cite extension, which is "built in" to Parsoid.
9977 !! test
9978 Nested lists 9 (extension interaction)
9979 !! wikitext
9980 *<references />
9981 !! html/php+tidy-DISABLED
9982 <ul><li class="mw-empty-elt"></li></ul>
9983 !! html/parsoid
9984 <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>
9985 !! end
9986
9987 !! test
9988 1. Lists with start-of-line-transparent tokens before bullets: Comments
9989 !! wikitext
9990 *foo
9991 *<!--cmt-->bar
9992 <!--cmt-->*baz
9993 !! html
9994 <ul><li>foo</li>
9995 <li>bar</li>
9996 <li>baz</li></ul>
9997
9998 !! end
9999
10000 !! test
10001 Nested lists 10 (list and span siblings: wt2wt regression)
10002 !! wikitext
10003 *a <span>x</span>
10004 **b <span>y</span>
10005 !! html/parsoid
10006 <ul><li>a <span>x</span>
10007 <ul><li>b <span>y</span></li></ul></li></ul>
10008 !! end
10009
10010 !! test
10011 2. Lists with start-of-line-transparent tokens before bullets: Template close
10012 !! wikitext
10013 *foo {{echo|bar
10014 }}*baz
10015 !! html
10016 <ul><li>foo bar</li>
10017 <li>baz</li></ul>
10018
10019 !! end
10020
10021 !! test
10022 List items are not parsed correctly following a <pre> block (T2785)
10023 !! wikitext
10024 *<pre>foo</pre>
10025 *<pre>bar</pre>
10026 *zar
10027 !! html/php
10028 <ul><li><pre>foo</pre></li>
10029 <li><pre>bar</pre></li>
10030 <li>zar</li></ul>
10031
10032 !! html/parsoid
10033 <ul><li><pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre></li>
10034 <li><pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"bar"}}'>bar</pre></li>
10035 <li>zar</li></ul>
10036 !! end
10037
10038 # FIXME: Might benefit from a html/parsoid since this has a template
10039 !! test
10040 List items from template
10041 !! wikitext
10042
10043 {{inner list}}
10044 *item 2
10045
10046 *item 0
10047 {{inner list}}
10048 *item 2
10049
10050 *item 0
10051 *notSOL{{inner list}}
10052 *item 2
10053 !! html
10054 <ul><li>item 1</li>
10055 <li>item 2</li></ul>
10056 <ul><li>item 0</li>
10057 <li>item 1</li>
10058 <li>item 2</li></ul>
10059 <ul><li>item 0</li>
10060 <li>notSOL</li>
10061 <li>item 1</li>
10062 <li>item 2</li></ul>
10063
10064 !! end
10065
10066 !! test
10067 List interrupted by empty line or heading
10068 !! wikitext
10069 *foo
10070
10071 **bar
10072 ==A heading==
10073 *Another list item
10074 !! html
10075 <ul><li>foo</li></ul>
10076 <ul><li><ul><li>bar</li></ul></li></ul>
10077 <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>
10078 <ul><li>Another list item</li></ul>
10079
10080 !!end
10081
10082 !! test
10083 Multiple list tags generated by templates
10084 !! wikitext
10085 {{echo|<li>}}a
10086 {{echo|<li>}}b
10087 {{echo|<li>}}c
10088 !! html
10089 <li>a
10090 <li>b
10091 <li>c</li>
10092 </li>
10093 </li>
10094
10095
10096 !! html+tidy
10097 <li>a
10098 </li><li>b
10099 </li><li>c
10100 </li>
10101 !! html/parsoid
10102 <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>
10103 <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>
10104 <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>
10105 !! end
10106
10107 !! test
10108 Multiple newlines in between HTML list items don't induce paragraph wrapping
10109 !! wikitext
10110 <ul>
10111 <li>hi</li>
10112
10113
10114
10115
10116 <li>ho</li>
10117 </ul>
10118
10119 <dl>
10120 <dt>hi</dt>
10121 <dd>ho<div>123</div>
10122 </dd>
10123
10124
10125 </dl>
10126 !! html/php+tidy
10127 <ul>
10128 <li>hi</li>
10129
10130
10131
10132
10133 <li>ho</li>
10134 </ul>
10135 <dl>
10136 <dt>hi</dt>
10137 <dd>ho<div>123</div>
10138 </dd>
10139
10140
10141 </dl>
10142 !! end
10143
10144 !!test
10145 Single-comment whitespace lines dont break lists, and neither do multi-comment whitespace lines
10146 !! wikitext
10147 *a
10148 <!--This line will NOT split the list-->
10149 *b
10150 <!--This line will NOT split the list either-->
10151 *c
10152 <!--foo--> <!----> <!--This line NOT split the list either-->
10153 *d
10154 !! html
10155 <ul><li>a</li>
10156 <li>b</li>
10157 <li>c</li>
10158 <li>d</li></ul>
10159
10160 !!end
10161
10162 !!test
10163 Replacing whitespace with tabs still doesn't break the list (gerrit 78327)
10164 !! wikitext
10165 *a
10166 <!--This line will NOT split the list-->
10167 *b
10168 <!--This line will NOT split the list either-->
10169 *c
10170 <!--foo--> <!----> <!--This line NOT split the list
10171 either-->
10172 *d
10173 !! html
10174 <ul><li>a</li>
10175 <li>b</li>
10176 <li>c</li>
10177 <li>d</li></ul>
10178
10179 !!end
10180
10181 # FIXME: Parsoid has a dedicated DOM pass to mimic this Tidy-specific li-hack
10182 # That pass could possibly be removed.
10183 !!test
10184 Test the li-hack (a hack from Tidy days, but doesn't work as advertised with Remex)
10185 !!options
10186 parsoid=wt2html,wt2wt
10187 !! wikitext
10188 *foo
10189 *<li>li-hack
10190 *{{echo|<li>templated li-hack}}
10191 *<!--foo--><li> unsupported li-hack with preceding comments
10192
10193 <ul>
10194 <li><li>not a li-hack
10195 </li>
10196 </ul>
10197 !! html+tidy
10198 <ul><li>foo</li>
10199 <li class="mw-empty-elt"></li><li>li-hack</li>
10200 <li class="mw-empty-elt"></li><li>templated li-hack</li>
10201 <li class="mw-empty-elt"></li><li> unsupported li-hack with preceding comments</li></ul>
10202 <ul>
10203 <li class="mw-empty-elt"></li><li>not a li-hack
10204 </li>
10205 </ul>
10206 !! html/parsoid
10207 <ul><li> foo</li>
10208 <li data-parsoid='{"stx":"html","autoInsertedEnd":true,"liHackSrc":"*"}'>li-hack</li>
10209 <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>
10210 <li data-parsoid='{"autoInsertedEnd":true}'><!--foo--></li><li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>unsupported li-hack with preceding comments</li></ul>
10211
10212 <ul data-parsoid='{"stx":"html"}'>
10213 <li class="mw-empty-elt" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></li><li data-parsoid='{"stx":"html"}'>not a li-hack
10214 </li>
10215 </ul>
10216
10217 !!end
10218
10219 !! test
10220 Parsoid: Make sure nested lists are serialized on their own line even if HTML contains no newlines
10221 !! wikitext
10222 #foo
10223 ##bar
10224
10225 *foo
10226 **bar
10227
10228 :foo
10229 ::bar
10230 !! html/php+tidy
10231 <ol><li>foo
10232 <ol><li>bar</li></ol></li></ol>
10233 <ul><li>foo
10234 <ul><li>bar</li></ul></li></ul>
10235 <dl><dd>foo
10236 <dl><dd>bar</dd></dl></dd></dl>
10237 !! html/parsoid
10238 <ol>
10239 <li>foo<ol>
10240 <li>bar</li>
10241 </ol></li>
10242 </ol><ul>
10243 <li>foo<ul>
10244 <li>bar</li>
10245 </ul></li>
10246 </ul><dl>
10247 <dd>foo<dl>
10248 <dd>bar</dd>
10249 </dl></dd>
10250 </dl>
10251 !! end
10252
10253 !! test
10254 Parsoid: Test of whitespace serialization with Templated bullets
10255 !! options
10256 parsoid=wt2html
10257 !! wikitext
10258 * {{bullet}}
10259 !! html/parsoid
10260 <ul>
10261 <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>
10262 </ul>
10263 !! end
10264
10265 # ------------------------------------------------------------------------
10266 # The next set of tests are about Parsoid's ability to handle badly nested
10267 # tags (parse, minimize scope of fixup, and roundtrip back)
10268 # ------------------------------------------------------------------------
10269
10270 # Remex and Parsoid output stems from list handling diffs because Parsoid & PHP parser.
10271 # Parsoid's list handling is more aware of block structure.
10272 !! test
10273 Unbalanced closing block tags break a list
10274 !! wikitext
10275 <div>
10276 *a</div><div>
10277 *b</div>
10278 !! html+tidy
10279 <div>
10280 <ul><li>a</li></ul></div><div>
10281 <li>b</li></div>
10282 !! html/parsoid
10283 <div><ul>
10284 <li>a</li>
10285 </ul></div>
10286 <div><ul>
10287 <li>b</li>
10288 </ul></div>
10289 !! end
10290
10291 !! test
10292 Unbalanced closing non-block tags don't break a list
10293 !! options
10294 parsoid=wt2html,html2html
10295 !! wikitext
10296 <span>
10297 *a</span><span>
10298 *b</span>
10299 !! html/php+tidy
10300 <p><span>
10301 </span></p>
10302 <ul><li>a<span></span></li>
10303 <li>b</li></ul>
10304 !! html/parsoid
10305 <p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'></span></p>
10306 <ul><li>a<span data-parsoid='{"stx":"html","autoInsertedEnd":true}'></span></li>
10307 <li>b</li></ul>
10308 !! end
10309
10310 # Parsoid does some post-dom-building cleanup
10311 # which is why its output differs from Remex.
10312 !! test
10313 Unclosed formatting tags that straddle lists are closed and reopened
10314 !! options
10315 parsoid=wt2html,wt2wt,html2html
10316 !! wikitext
10317 #<s> a
10318 #b </s>
10319 !! html/php+tidy
10320 <ol><li><s> a</s></li><s>
10321 </s><li><s>b </s></li></ol>
10322 !! html/parsoid
10323 <ol><li><s> a</s></li>
10324 <li><s>b </s></li></ol>
10325 !! end
10326
10327 # Output is ugly because of all the misnested tag fixups.
10328 !! test
10329 1. List embedded in a formatting tag
10330 !! wikitext
10331 <small>
10332 *foo
10333 </small>
10334 !! html/php+tidy
10335 <p><small>
10336 </small></p><small><ul><li>foo</li></ul></small><small></small><p><small></small>
10337 </p>
10338 !! html/parsoid
10339 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p><small data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
10340 <ul><li data-parsoid='{}'>foo</li></ul></small>
10341 <p><small data-parsoid='{"stx":"html","autoInsertedStart":true}'></small></p>
10342 !! end
10343
10344 # Output is ugly because of all the misnested tag fixups.
10345 !! test
10346 2. List embedded in a formatting tag in a misnested way
10347 !! wikitext
10348 <small>
10349 *a
10350 *b</small>
10351 !! html/php+tidy
10352 <p><small>
10353 </small></p><small></small><ul><small><li>a</li>
10354 </small><li><small>b</small></li></ul>
10355 !! html/parsoid
10356 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p>
10357 <ul><small data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'><li>a</li></small>
10358 <li><small data-parsoid='{"stx":"html","autoInsertedStart":true}'>b</small></li></ul>
10359 !! end
10360
10361 # Output is ugly because of all the misnested tag fixups.
10362 !! test
10363 3. List embedded in a formatting tag in a misnested way
10364 !! wikitext
10365 <small>
10366
10367 ** 123</small>
10368 !! html/php+tidy
10369 <p><small>
10370 </small></p><small></small><ul><small></small><li><small></small><ul><small></small><li><small>123</small></li></ul></li></ul>
10371 !! html/parsoid
10372 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p>
10373
10374 <ul><li><ul><li data-parsoid='{}'><small data-parsoid='{"stx":"html","autoInsertedStart":true}'> 123</small></li></ul></li></ul>
10375 !! end
10376
10377 ###
10378 ### Magic Words
10379 ###
10380
10381 # Note that the current date is hard-coded as
10382 # 1970-01-01T00:02:03Z (a Thursday)
10383 # when running parser tests. The timezone is also fixed to GMT, so
10384 # local date will be identical to current date.
10385
10386 !! test
10387 Magic Word: {{CURRENTDAY}}
10388 !! wikitext
10389 {{CURRENTDAY}}
10390 !! html
10391 <p>1
10392 </p>
10393 !! end
10394
10395 !! test
10396 Magic Word: {{CURRENTDAY2}}
10397 !! wikitext
10398 {{CURRENTDAY2}}
10399 !! html
10400 <p>01
10401 </p>
10402 !! end
10403
10404 !! test
10405 Magic Word: {{CURRENTDAYNAME}}
10406 !! wikitext
10407 {{CURRENTDAYNAME}}
10408 !! html
10409 <p>Thursday
10410 </p>
10411 !! end
10412
10413 !! test
10414 Magic Word: {{CURRENTDOW}}
10415 !! wikitext
10416 {{CURRENTDOW}}
10417 !! html
10418 <p>4
10419 </p>
10420 !! end
10421
10422 !! test
10423 Magic Word: {{CURRENTMONTH}}
10424 !! wikitext
10425 {{CURRENTMONTH}}
10426 !! html
10427 <p>01
10428 </p>
10429 !! end
10430
10431 !! test
10432 Magic Word: {{CURRENTMONTH1}}
10433 !! wikitext
10434 {{CURRENTMONTH1}}
10435 !! html
10436 <p>1
10437 </p>
10438 !! end
10439
10440 !! test
10441 Magic Word: {{CURRENTMONTHABBREV}}
10442 !! wikitext
10443 {{CURRENTMONTHABBREV}}
10444 !! html
10445 <p>Jan
10446 </p>
10447 !! end
10448
10449 !! test
10450 Magic Word: {{CURRENTMONTHNAME}}
10451 !! wikitext
10452 {{CURRENTMONTHNAME}}
10453 !! html
10454 <p>January
10455 </p>
10456 !! end
10457
10458 !! test
10459 Magic Word: {{CURRENTMONTHNAMEGEN}}
10460 !! wikitext
10461 {{CURRENTMONTHNAMEGEN}}
10462 !! html
10463 <p>January
10464 </p>
10465 !! end
10466
10467 !! test
10468 Magic Word: {{CURRENTTIME}}
10469 !! wikitext
10470 {{CURRENTTIME}}
10471 !! html
10472 <p>00:02
10473 </p>
10474 !! end
10475
10476 !! test
10477 Magic Word: {{CURRENTHOUR}}
10478 !! wikitext
10479 {{CURRENTHOUR}}
10480 !! html
10481 <p>00
10482 </p>
10483 !! end
10484
10485 !! test
10486 Magic Word: {{CURRENTWEEK}} (T6594)
10487 !! wikitext
10488 {{CURRENTWEEK}}
10489 !! html
10490 <p>1
10491 </p>
10492 !! end
10493
10494 !! test
10495 Magic Word: {{CURRENTYEAR}}
10496 !! wikitext
10497 {{CURRENTYEAR}}
10498 !! html
10499 <p>1970
10500 </p>
10501 !! end
10502
10503 !! test
10504 Magic Word: {{CURRENTTIMESTAMP}}
10505 !! wikitext
10506 {{CURRENTTIMESTAMP}}
10507 !! html
10508 <p>19700101000203
10509 </p>
10510 !! end
10511
10512 !! test
10513 Magic Words LOCAL (UTC)
10514 !! wikitext
10515 *{{LOCALMONTH}}
10516 *{{LOCALMONTH1}}
10517 *{{LOCALMONTHNAME}}
10518 *{{LOCALMONTHNAMEGEN}}
10519 *{{LOCALMONTHABBREV}}
10520 *{{LOCALDAY}}
10521 *{{LOCALDAY2}}
10522 *{{LOCALDAYNAME}}
10523 *{{LOCALYEAR}}
10524 *{{LOCALTIME}}
10525 *{{LOCALHOUR}}
10526 *{{LOCALWEEK}}
10527 *{{LOCALDOW}}
10528 *{{LOCALTIMESTAMP}}
10529 !! html
10530 <ul><li>01</li>
10531 <li>1</li>
10532 <li>January</li>
10533 <li>January</li>
10534 <li>Jan</li>
10535 <li>1</li>
10536 <li>01</li>
10537 <li>Thursday</li>
10538 <li>1970</li>
10539 <li>00:02</li>
10540 <li>00</li>
10541 <li>1</li>
10542 <li>4</li>
10543 <li>19700101000203</li></ul>
10544
10545 !! end
10546
10547 !! test
10548 Magic Word: {{FULLPAGENAME}}
10549 !! options
10550 title=[[User:Ævar Arnfjörð Bjarmason]]
10551 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10552 !! wikitext
10553 {{FULLPAGENAME}}
10554 !! html/*
10555 <p>User:Ævar Arnfjörð Bjarmason
10556 </p>
10557 !! end
10558
10559 !! test
10560 Magic Word: {{FULLPAGENAMEE}}
10561 !! options
10562 title=[[User:Ævar Arnfjörð Bjarmason]]
10563 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10564 !! wikitext
10565 {{FULLPAGENAMEE}}
10566 !! html/*
10567 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10568 </p>
10569 !! end
10570
10571 !! test
10572 Magic Word: {{TALKSPACE}}
10573 !! options
10574 title=[[User:Ævar Arnfjörð Bjarmason]]
10575 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10576 !! wikitext
10577 {{TALKSPACE}}
10578 !! html/*
10579 <p>User talk
10580 </p>
10581 !! end
10582
10583 !! test
10584 Magic Word: {{TALKSPACE}}, same namespace
10585 !! options
10586 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10587 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10588 !! wikitext
10589 {{TALKSPACE}}
10590 !! html/*
10591 <p>User talk
10592 </p>
10593 !! end
10594
10595 !! test
10596 Magic Word: {{TALKSPACE}}, main namespace
10597 !! options
10598 title=[[Parser Test]]
10599 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10600 !! wikitext
10601 {{TALKSPACE}}
10602 !! html/*
10603 <p>Talk
10604 </p>
10605 !! end
10606
10607 !! test
10608 Magic Word: {{TALKSPACEE}}
10609 !! options
10610 title=[[User:Ævar Arnfjörð Bjarmason]]
10611 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10612 !! wikitext
10613 {{TALKSPACEE}}
10614 !! html/*
10615 <p>User_talk
10616 </p>
10617 !! end
10618
10619 !! test
10620 Magic Word: {{SUBJECTSPACE}}
10621 !! options
10622 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10623 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10624 !! wikitext
10625 {{SUBJECTSPACE}}
10626 !! html/*
10627 <p>User
10628 </p>
10629 !! end
10630
10631 !! test
10632 Magic Word: {{SUBJECTSPACE}}, same namespace
10633 !! options
10634 title=[[User:Ævar Arnfjörð Bjarmason]]
10635 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10636 !! wikitext
10637 {{SUBJECTSPACE}}
10638 !! html/*
10639 <p>User
10640 </p>
10641 !! end
10642
10643 !! test
10644 Magic Word: {{SUBJECTSPACE}}, main namespace
10645 !! options
10646 title=[[Parser Test]]
10647 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10648 !! wikitext
10649 {{SUBJECTSPACE}}
10650 !! html/*
10651
10652 !! end
10653
10654 !! test
10655 Magic Word: {{SUBJECTSPACEE}}
10656 !! options
10657 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10658 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10659 !! wikitext
10660 {{SUBJECTSPACEE}}
10661 !! html/*
10662 <p>User
10663 </p>
10664 !! end
10665
10666 !! test
10667 Magic Word: {{NAMESPACE}}
10668 !! options
10669 title=[[User:Ævar Arnfjörð Bjarmason]]
10670 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10671 !! wikitext
10672 {{NAMESPACE}}
10673 !! html/*
10674 <p>User
10675 </p>
10676 !! end
10677
10678 !! test
10679 Magic Word: {{NAMESPACEE}}
10680 !! options
10681 title=[[User:Ævar Arnfjörð Bjarmason]]
10682 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10683 !! wikitext
10684 {{NAMESPACEE}}
10685 !! html/*
10686 <p>User
10687 </p>
10688 !! end
10689
10690 !! test
10691 Magic Word: {{NAMESPACENUMBER}}
10692 !! options
10693 title=[[User:Ævar Arnfjörð Bjarmason]]
10694 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10695 !! wikitext
10696 {{NAMESPACENUMBER}}
10697 !! html/*
10698 <p>2
10699 </p>
10700 !! end
10701
10702 !! test
10703 Magic Word: {{SUBPAGENAME}}
10704 !! options
10705 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10706 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10707 !! wikitext
10708 {{SUBPAGENAME}}
10709 !! html/*
10710 <p>sub ö
10711 </p>
10712 !! end
10713
10714 !! test
10715 Magic Word: {{SUBPAGENAMEE}}
10716 !! options
10717 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10718 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10719 !! wikitext
10720 {{SUBPAGENAMEE}}
10721 !! html/*
10722 <p>sub_%C3%B6
10723 </p>
10724 !! end
10725
10726 !! test
10727 Magic Word: {{ROOTPAGENAME}}
10728 !! options
10729 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10730 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10731 !! wikitext
10732 {{ROOTPAGENAME}}
10733 !! html/*
10734 <p>Ævar Arnfjörð Bjarmason
10735 </p>
10736 !! end
10737
10738 !! test
10739 Magic Word: {{ROOTPAGENAMEE}}
10740 !! options
10741 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10742 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10743 !! wikitext
10744 {{ROOTPAGENAMEE}}
10745 !! html/*
10746 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10747 </p>
10748 !! end
10749
10750 !! test
10751 Magic Word: {{BASEPAGENAME}}
10752 !! options
10753 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10754 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10755 !! wikitext
10756 {{BASEPAGENAME}}
10757 !! html/*
10758 <p>Ævar Arnfjörð Bjarmason
10759 </p>
10760 !! end
10761
10762 !! test
10763 Magic Word: {{BASEPAGENAMEE}}
10764 !! options
10765 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10766 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10767 !! wikitext
10768 {{BASEPAGENAMEE}}
10769 !! html/*
10770 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10771 </p>
10772 !! end
10773
10774 !! test
10775 Magic Word: {{TALKPAGENAME}}
10776 !! options
10777 title=[[User:Ævar Arnfjörð Bjarmason]]
10778 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10779 !! wikitext
10780 {{TALKPAGENAME}}
10781 !! html/*
10782 <p>User talk:Ævar Arnfjörð Bjarmason
10783 </p>
10784 !! end
10785
10786 !! test
10787 Magic Word: {{TALKPAGENAMEE}}
10788 !! options
10789 title=[[User:Ævar Arnfjörð Bjarmason]]
10790 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10791 !! wikitext
10792 {{TALKPAGENAMEE}}
10793 !! html/*
10794 <p>User_talk:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10795 </p>
10796 !! end
10797
10798 !! test
10799 Magic Word: {{SUBJECTPAGENAME}}
10800 !! options
10801 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10802 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10803 !! wikitext
10804 {{SUBJECTPAGENAME}}
10805 !! html/*
10806 <p>User:Ævar Arnfjörð Bjarmason
10807 </p>
10808 !! end
10809
10810 !! test
10811 Magic Word: {{SUBJECTPAGENAMEE}}
10812 !! options
10813 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10814 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10815 !! wikitext
10816 {{SUBJECTPAGENAMEE}}
10817 !! html/*
10818 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10819 </p>
10820 !! end
10821
10822 !! test
10823 Magic Word: {{NUMBEROFFILES}}
10824 !! options
10825 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10826 !! wikitext
10827 {{NUMBEROFFILES}}
10828 !! html/*
10829 <p>7
10830 </p>
10831 !! end
10832
10833 !! test
10834 Magic Word: {{PAGENAME}}
10835 !! options
10836 title=[[User:Ævar Arnfjörð Bjarmason]]
10837 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10838 !! wikitext
10839 {{PAGENAME}}
10840 !! html/*
10841 <p>Ævar Arnfjörð Bjarmason
10842 </p>
10843 !! end
10844
10845 !! test
10846 Magic Word: {{PAGENAME}} with metacharacters
10847 !! options
10848 title=[['foo & bar = baz']]
10849 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10850 !! wikitext
10851 ''{{PAGENAME}}''
10852 !! html+tidy
10853 <p><i>&#39;foo &#38; bar &#61; baz&#39;</i>
10854 </p>
10855 !! end
10856
10857 !! test
10858 Magic Word: {{PAGENAME}} with metacharacters (T28781)
10859 !! options
10860 title=[[*RFC 1234 http://example.com/]]
10861 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10862 !! wikitext
10863 {{PAGENAME}}
10864 !! html+tidy
10865 <p>&#42;RFC&#32;1234 http&#58;//example.com/
10866 </p>
10867 !! end
10868
10869 !! test
10870 Magic Word: {{PAGENAMEE}}
10871 !! options
10872 title=[[User:Ævar Arnfjörð Bjarmason]]
10873 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10874 !! wikitext
10875 {{PAGENAMEE}}
10876 !! html/*
10877 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10878 </p>
10879 !! end
10880
10881 !! test
10882 Magic Word: {{PAGENAMEE}} with metacharacters (T28781)
10883 !! options
10884 title=[[*RFC 1234 http://example.com/]]
10885 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10886 !! wikitext
10887 {{PAGENAMEE}}
10888 !! html+tidy
10889 <p>&#42;RFC_1234_http&#58;//example.com/
10890 </p>
10891 !! end
10892
10893 !! test
10894 Magic Word: {{REVISIONID}}
10895 !! options
10896 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10897 showflags
10898 !! wikitext
10899 {{REVISIONID}}
10900 !! html/*
10901 <p>1337
10902 </p>
10903 flags=vary-revision-id
10904 !! end
10905
10906 !! test
10907 Magic Word: {{SCRIPTPATH}}
10908 !! options
10909 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10910 !! wikitext
10911 {{SCRIPTPATH}}
10912 !! html/*
10913
10914 !! end
10915
10916 !! test
10917 Magic Word: {{STYLEPATH}}
10918 !! options
10919 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10920 !! wikitext
10921 {{STYLEPATH}}
10922 !! html/*
10923 <p>/skins
10924 </p>
10925 !! end
10926
10927 !! test
10928 Magic Word: {{SERVER}}
10929 !! options
10930 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10931 !! wikitext
10932 {{SERVER}}
10933 !! html/*
10934 <p><a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10935 </p>
10936 !! end
10937
10938 !! test
10939 Magic Word: {{SERVERNAME}}
10940 !! options
10941 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10942 !! wikitext
10943 {{SERVERNAME}}
10944 !! html/*
10945 <p>example.org
10946 </p>
10947 !! end
10948
10949 !! test
10950 Magic Word: {{SITENAME}}
10951 !! options
10952 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10953 !! wikitext
10954 {{SITENAME}}
10955 !! html/*
10956 <p>MediaWiki
10957 </p>
10958 !! end
10959
10960 !! test
10961 Magic Word: {{PAGELANGUAGE}}
10962 !! options
10963 language=fr
10964 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10965 !! wikitext
10966 {{PAGELANGUAGE}}
10967 !! html/*
10968 <p>fr
10969 </p>
10970 !! end
10971
10972 !! test
10973 Magic Word: {{PAGELANGUAGE}} on a page with no explicitly set language
10974 !! options
10975 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10976 !! wikitext
10977 {{PAGELANGUAGE}}
10978 !! html/*
10979 <p>en
10980 </p>
10981 !! end
10982
10983 !! test
10984 Case-sensitive magic words, when cased differently, should just be template transclusions
10985 !! wikitext
10986 {{CurrentMonth}}
10987 {{currentday}}
10988 {{cURreNTweEK}}
10989 {{currentHour}}
10990 !! html
10991 <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>
10992 <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>
10993 <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>
10994 <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>
10995 </p>
10996 !! end
10997
10998 !! test
10999 Case-insensitive magic words should still work with weird casing.
11000 !! wikitext
11001 {{sErVeRNaMe}}
11002 {{LCFirst:AOEU}}
11003 {{ucFIRST:aoeu}}
11004 {{SERver}}
11005 !! html
11006 <p>example.org
11007 aOEU
11008 Aoeu
11009 <a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
11010 </p>
11011 !! end
11012
11013 # From plwiki:PLOS_ONE
11014 !! test
11015 Parsoid: Page property magic word with magic word contents
11016 !! options
11017 showtitle
11018 !! config
11019 wgAllowDisplayTitle=true
11020 wgRestrictDisplayTitle=false
11021 !! wikitext
11022 {{DISPLAYTITLE:''{{PAGENAME}}''}}
11023 !! html/php+tidy
11024 <i>Parser test</i>
11025
11026 !! html/parsoid
11027 <meta property="mw:PageProp/displaytitle" content="Main Page" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"src":"{{DISPLAYTITLE:&#39;&#39;{{PAGENAME}}&#39;&#39;}}"}' data-mw='{"attribs":[[{"txt":"content"},{"html":"DISPLAYTITLE:&lt;i data-parsoid=&#39;{\"dsr\":[15,31,2,2]}&#39;>&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[]],\"dsr\":[17,29,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"PAGENAME\",\"function\":\"pagename\"},\"params\":{},\"i\":0}}]}&#39;>Main Page&lt;/span>&lt;/i>"}]]}'/>
11028 !! end
11029
11030 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
11031 # But, this is a limitation of our representation and is documented in
11032 # TemplateHandler.js in processSpecialMagicWord
11033 !! test
11034 Parsoid: Template-generated DISPLAYTITLE
11035 !! wikitext
11036 {{{{echo|DISPLAYTITLE}}:Foo}}
11037 !! options
11038 showtitle
11039 !! config
11040 wgAllowDisplayTitle=true
11041 wgRestrictDisplayTitle=false
11042 !! html/php
11043 Foo
11044
11045 !! html/parsoid
11046 <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"}]]}'/>
11047 !! end
11048
11049 !! test
11050 Namespace 1 {{ns:1}}
11051 !! wikitext
11052 {{ns:1}}
11053 !! html
11054 <p>Talk
11055 </p>
11056 !! end
11057
11058 !! test
11059 Namespace 1 {{ns:01}}
11060 !! wikitext
11061 {{ns:01}}
11062 !! html
11063 <p>Talk
11064 </p>
11065 !! end
11066
11067 !! test
11068 Namespace 0 {{ns:0}} (T6783)
11069 !! wikitext
11070 {{ns:0}}
11071 !! html
11072
11073 !! end
11074
11075 !! test
11076 Namespace 0 {{ns:00}} (T6783)
11077 !! wikitext
11078 {{ns:00}}
11079 !! html
11080
11081 !! end
11082
11083 !! test
11084 Namespace -1 {{ns:-1}}
11085 !! wikitext
11086 {{ns:-1}}
11087 !! html
11088 <p>Special
11089 </p>
11090 !! end
11091
11092 !! test
11093 Namespace User {{ns:User}}
11094 !! wikitext
11095 {{ns:User}}
11096 !! html
11097 <p>User
11098 </p>
11099 !! end
11100
11101 !! test
11102 Namespace User talk {{ns:User_talk}}
11103 !! wikitext
11104 {{ns:User_talk}}
11105 !! html
11106 <p>User talk
11107 </p>
11108 !! end
11109
11110 !! test
11111 Namespace User talk {{ns:uSeR tAlK}}
11112 !! wikitext
11113 {{ns:uSeR tAlK}}
11114 !! html
11115 <p>User talk
11116 </p>
11117 !! end
11118
11119 !! test
11120 Namespace File {{ns:File}}
11121 !! wikitext
11122 {{ns:File}}
11123 !! html
11124 <p>File
11125 </p>
11126 !! end
11127
11128 !! test
11129 Namespace File {{ns:Image}}
11130 !! wikitext
11131 {{ns:Image}}
11132 !! html
11133 <p>File
11134 </p>
11135 !! end
11136
11137 !! test
11138 Namespace (lang=de) Benutzer {{ns:User}}
11139 !! options
11140 language=de
11141 !! wikitext
11142 {{ns:User}}
11143 !! html
11144 <p>Benutzer
11145 </p>
11146 !! end
11147
11148 !! test
11149 Namespace (lang=de) Benutzer Diskussion {{ns:3}}
11150 !! options
11151 language=de
11152 !! wikitext
11153 {{ns:3}}
11154 !! html
11155 <p>Benutzer Diskussion
11156 </p>
11157 !! end
11158
11159 !! test
11160 Urlencode
11161 !! wikitext
11162 {{urlencode:hi world?!}}
11163 {{urlencode:hi world?!|WIKI}}
11164 {{urlencode:hi world?!|PATH}}
11165 {{urlencode:hi world?!|QUERY}}
11166 !! html/php
11167 <p>hi+world%3F%21
11168 hi_world%3F!
11169 hi%20world%3F%21
11170 hi+world%3F%21
11171 </p>
11172 !! end
11173
11174 !! test
11175 Magic Word: prioritize type info over data-parsoid
11176 !! options
11177 parsoid=html2wt
11178 !! html/parsoid
11179 <meta property="mw:PageProp/forcetoc" data-parsoid='{"magicSrc":"__NOTOC__"}'/>
11180 !! wikitext
11181 __FORCETOC__
11182 !! end
11183
11184 !! test
11185 Magic Word: serialize on separate line (parsoid)
11186 !! options
11187 parsoid=wt2wt,html2wt
11188 !! wikitext
11189 foo
11190 __NOTOC__
11191 bar
11192 !! html/parsoid
11193 foo<meta property="mw:PageProp/notoc"/>bar
11194 !! end
11195
11196 !! test
11197 Magic Word: rt non-english wikis
11198 !! options
11199 parsoid=wt2wt
11200 language=de
11201 !! wikitext
11202 __NOEDITSECTION__
11203 !! html/parsoid
11204 <meta property="mw:PageProp/noeditsection" data-parsoid='{"magicSrc":"__NOEDITSECTION__"}'/>
11205 !! end
11206
11207 !!test
11208 __proto__ is treated as normal wikitext (T105997)
11209 !!wikitext
11210 __proto__
11211 !!html
11212 <p>__proto__
11213 </p>
11214 !!end
11215
11216 ###
11217 ### Magic links
11218 ###
11219 !! test
11220 Magic links: internal link to RFC (T2479)
11221 !! wikitext
11222 [[RFC 123]]
11223 !! html/php
11224 <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>
11225 </p>
11226 !! html/parsoid
11227 <p><a rel="mw:WikiLink" href="./RFC_123" title="RFC 123">RFC 123</a></p>
11228 !! end
11229
11230 !! test
11231 Magic links: RFC (T2479)
11232 !! wikitext
11233 RFC 822
11234 !! html/php
11235 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
11236 </p>
11237 !! html/parsoid
11238 <p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external mw-magiclink">RFC 822</a></p>
11239 !! end
11240
11241 !! test
11242 Magic links: RFC (T67278)
11243 !! wikitext
11244 This is RFC 822 but thisRFC 822 is not RFC 822linked.
11245 !! html/php
11246 <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.
11247 </p>
11248 !! html/parsoid
11249 <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>
11250 !! end
11251
11252 !! test
11253 Magic links: RFC (w/ non-newline whitespace, T30950/T31025)
11254 !! wikitext
11255 RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 822
11256 RFC
11257 822
11258 !! html/php
11259 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
11260 RFC
11261 822
11262 </p>
11263 !! html/parsoid
11264 <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>
11265 RFC
11266 822</p>
11267 !! end
11268
11269 !! test
11270 Magic links: ISBN (T3937)
11271 !! wikitext
11272 ISBN 0-306-40615-2
11273 !! html/php
11274 <p><a href="/wiki/Special:BookSources/0306406152" class="internal mw-magiclink-isbn">ISBN 0-306-40615-2</a>
11275 </p>
11276 !! html/parsoid
11277 <p><a href="./Special:BookSources/0306406152" rel="mw:WikiLink">ISBN 0-306-40615-2</a></p>
11278 !! end
11279
11280 !! test
11281 Magic links: ISBN (T67278)
11282 !! wikitext
11283 This is ISBN 978-0-316-09811-3 but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.
11284 !! html/php
11285 <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.
11286 </p>
11287 !! html/parsoid
11288 <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>
11289 !! end
11290
11291 !! test
11292 Magic links: ISBN (w/ non-newline whitespace, T30950/T31025)
11293 !! wikitext
11294 ISBN &nbsp;&#160;&#0160;&#xA0;&#Xa0; 978&nbsp;0&#160;316&#0160;09811&#xA0;3
11295 ISBN
11296 9780316098113
11297 ISBN 978
11298 0316098113
11299 !! html/php
11300 <p><a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978 0 316 09811 3</a>
11301 ISBN
11302 9780316098113
11303 ISBN 978
11304 0316098113
11305 </p>
11306 !! html/parsoid
11307 <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>
11308 ISBN
11309 9780316098113
11310 ISBN 978
11311 0316098113</p>
11312 !! end
11313
11314 !! test
11315 Magic links: PMID incorrectly converts space to underscore
11316 !! wikitext
11317 PMID 1234
11318 !! html/php
11319 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11320 </p>
11321 !! html/parsoid
11322 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external mw-magiclink">PMID 1234</a></p>
11323 !! end
11324
11325 !! test
11326 Magic links: PMID (T67278)
11327 !! wikitext
11328 This is PMID 1234 but thisPMID 1234 is not PMID 1234linked.
11329 !! html/php
11330 <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.
11331 </p>
11332 !! html/parsoid
11333 <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>
11334 !! end
11335
11336 !! test
11337 Magic links: PMID (w/ non-newline whitespace, T30950/T31025)
11338 !! wikitext
11339 PMID &nbsp;&#160;&#0160;&#xA0;&#Xa0; 1234
11340 PMID
11341 1234
11342 !! html/php
11343 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11344 PMID
11345 1234
11346 </p>
11347 !! html/parsoid
11348 <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>
11349 PMID
11350 1234</p>
11351 !! end
11352
11353 # <nowiki> nodes shouldn't be inserted during html2wt by Parsoid,
11354 # since these are ExtLinkText, not MagicLinkText
11355 !! test
11356 Magic links: use appropriate serialization for "almost" magic links.
11357 !! wikitext
11358 X[[Special:BookSources/0978739256|foo]]
11359
11360 X[https://tools.ietf.org/html/rfc1234 foo]
11361 !! html/php
11362 <p>X<a href="/wiki/Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a>
11363 </p><p>X<a rel="nofollow" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a>
11364 </p>
11365 !! html/parsoid
11366 <p>X<a rel="mw:WikiLink" href="./Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a></p>
11367 <p>X<a rel="mw:ExtLink" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a></p>
11368 !! end
11369
11370 !! test
11371 Magic links: All disabled (T47942)
11372 !! options
11373 wgEnableMagicLinks={"ISBN":false, "PMID":false, "RFC":false}
11374 !! wikitext
11375 ISBN 0-306-40615-2
11376 PMID 1234
11377 RFC 4321
11378 !! html/php
11379 <p>ISBN 0-306-40615-2
11380 PMID 1234
11381 RFC 4321
11382 </p>
11383 !! end
11384
11385 ###
11386 ### Templates
11387 ####
11388
11389 !! test
11390 Nonexistent template
11391 !! wikitext
11392 {{thistemplatedoesnotexist}}
11393 !! html
11394 <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>
11395 </p>
11396 !! end
11397
11398 !! test
11399 Template with invalid target containing tags
11400 !! wikitext
11401 {{a<b>b</b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11402 !! html
11403 <p>{{a<b>b</b>|foo|a=b|a = b}}
11404 </p>
11405 !! end
11406
11407 !! test
11408 Template with invalid target containing unclosed tag
11409 !! wikitext
11410 {{a<b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11411 !! html
11412 <p>{{a<b>|foo|a=b|a = b}}</b>
11413 </p>
11414 !! end
11415
11416 !! test
11417 Template with invalid target containing wikilink
11418 !! wikitext
11419 {{[[Main Page]]}}
11420 !! html/php
11421 <p>{{<a href="/wiki/Main_Page" title="Main Page">Main Page</a>}}
11422 </p>
11423 !! html/parsoid
11424 <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>
11425 !! end
11426
11427 !! test
11428 Template with just whitespace in it, T70421
11429 !! wikitext
11430 {{echo|{{ }}}}
11431 !! html/parsoid
11432 <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>
11433 !! end
11434
11435 !! article
11436 Template:test
11437 !! text
11438 This is a test template
11439 !! endarticle
11440
11441 !! test
11442 Simple template
11443 !! wikitext
11444 {{test}}
11445 !! html
11446 <p>This is a test template
11447 </p>
11448 !! end
11449
11450 !! test
11451 Template with explicit namespace
11452 !! wikitext
11453 {{Template:test}}
11454 !! html
11455 <p>This is a test template
11456 </p>
11457 !! end
11458
11459
11460 !! article
11461 Template:paramtest
11462 !! text
11463 This is a test template with parameter {{{param}}}
11464 !! endarticle
11465
11466 !! test
11467 Template parameter
11468 !! wikitext
11469 {{paramtest|param=foo}}
11470 !! html
11471 <p>This is a test template with parameter foo
11472 </p>
11473 !! end
11474
11475 !! article
11476 Template:paramtestnum
11477 !! text
11478 [[{{{1}}}|{{{2}}}]]
11479 !! endarticle
11480
11481 !! test
11482 Template unnamed parameter
11483 !! wikitext
11484 {{paramtestnum|Main Page|the main page}}
11485 !! html
11486 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
11487 </p>
11488 !! end
11489
11490 !! article
11491 Template:templatesimple
11492 !! text
11493 (test)
11494 !! endarticle
11495
11496 !! article
11497 Template:templateredirect
11498 !! text
11499 #redirect [[Template:templatesimple]]
11500 !! endarticle
11501
11502 !! article
11503 Template:templateasargtestnum
11504 !! text
11505 {{{{{1}}}}}
11506 !! endarticle
11507
11508 !! article
11509 Template:templateasargtest
11510 !! text
11511 {{template{{{templ}}}}}
11512 !! endarticle
11513
11514 !! article
11515 Template:templateasargtest2
11516 !! text
11517 {{{{{templ}}}}}
11518 !! endarticle
11519
11520 !! test
11521 Template with template name as unnamed argument
11522 !! wikitext
11523 {{templateasargtestnum|templatesimple}}
11524 !! html
11525 <p>(test)
11526 </p>
11527 !! end
11528
11529 !! test
11530 Template with template name as argument
11531 !! wikitext
11532 {{templateasargtest|templ=simple}}
11533 !! html
11534 <p>(test)
11535 </p>
11536 !! end
11537
11538 !! test
11539 Template with template name as argument (2)
11540 !! wikitext
11541 {{templateasargtest2|templ=templatesimple}}
11542 !! html
11543 <p>(test)
11544 </p>
11545 !! end
11546
11547 !! article
11548 Template:templateasargtestdefault
11549 !! text
11550 {{{{{templ|templatesimple}}}}}
11551 !! endarticle
11552
11553 !! article
11554 Template:templa
11555 !! text
11556 '''templ'''
11557 !! endarticle
11558
11559 !! test
11560 Template with default value
11561 !! wikitext
11562 {{templateasargtestdefault}}
11563 !! html
11564 <p>(test)
11565 </p>
11566 !! end
11567
11568 !! test
11569 Template with default value (value set)
11570 !! wikitext
11571 {{templateasargtestdefault|templ=templa}}
11572 !! html
11573 <p><b>templ</b>
11574 </p>
11575 !! end
11576
11577 !! test
11578 Template redirect
11579 !! wikitext
11580 {{templateredirect}}
11581 !! html/php
11582 <p>(test)
11583 </p>
11584 !! html/parsoid
11585 <link rel="mw:PageProp/redirect" href="./Template:Templatesimple" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"templateredirect","href":"./Template:Templateredirect"},"params":{},"i":0}}]}'/>
11586 !! end
11587
11588 !! test
11589 Template with argument in separate line
11590 !! wikitext
11591 {{ templateasargtest |
11592 templ = simple }}
11593 !! html
11594 <p>(test)
11595 </p>
11596 !! end
11597
11598 !! test
11599 Template with complex template as argument
11600 !! wikitext
11601 {{paramtest|
11602 param ={{ templateasargtest |
11603 templ = simple }}}}
11604 !! html
11605 <p>This is a test template with parameter (test)
11606 </p>
11607 !! end
11608
11609 !! test
11610 Templates with templated name
11611 !! wikitext
11612 {{{{echo|echo}}|foo}}
11613 {{{{echo|inner list}} }}
11614 !! html
11615 <p>foo
11616 </p>
11617 <ul><li>item 1</li></ul>
11618
11619 !! html/parsoid
11620 <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>
11621 <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>
11622 !! end
11623
11624 ## Regression test; the output here isn't really that interesting.
11625 !! test
11626 Templates with templated name and top level template args
11627 !! wikitext
11628 {{1{{2{{{3}}}|4=5}}}}
11629 !! html/parsoid
11630 <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>
11631 !! end
11632
11633 # Parsoid markup is deliberate "broken". This is an edge case.
11634 # See long comment in TemplateHandler.js:convertAttribsToString.
11635 !! test
11636 Templates with invalid templated targets
11637 !! wikitext
11638 {{echo
11639 {{echo|foo}}
11640 }}
11641 !! html/php
11642 <p>{{echo
11643 foo
11644 }}
11645 </p>
11646 !! html/parsoid
11647 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n{{echo|foo}}\n"},"params":{},"i":0}}]}'>{{echo
11648 foo }}</p>
11649 !! end
11650
11651 !! test
11652 Template with thumb image (with link in description)
11653 !! wikitext
11654 {{paramtest|param=[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
11655 !! html/php
11656 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>
11657
11658 !! html+tidy
11659 <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>
11660 !! html/parsoid
11661 <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>
11662 !! end
11663
11664 !! article
11665 Template:complextemplate
11666 !! text
11667 {{{1}}} {{paramtest|
11668 param ={{{param}}}}}
11669 !! endarticle
11670
11671 !! test
11672 Template with complex arguments
11673 !! wikitext
11674 {{complextemplate|
11675 param ={{ templateasargtest |
11676 templ = simple }}|[[Template:complextemplate|link]]}}
11677 !! html
11678 <p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test)
11679 </p>
11680 !! end
11681
11682 !! test
11683 T2553: link with two variables in a piped link
11684 !! wikitext
11685 {|
11686 |[[{{{1}}}|{{{2}}}]]
11687 |}
11688 !! html/php
11689 <table>
11690 <tr>
11691 <td>[[{{{1}}}|{{{2}}}]]
11692 </td></tr></table>
11693
11694 !! html/parsoid
11695 <table>
11696 <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>
11697 </tbody></table>
11698 !! end
11699
11700 # See: T2553
11701 !! test
11702 Abort table cell attribute parsing on wikilink
11703 !! wikitext
11704 {|
11705 |testing [[one|two]] |three||four
11706 |testing one two |three||four
11707 |testing="[[one|two]]" |three||four
11708 |}
11709 !! html/php
11710 <table>
11711 <tr>
11712 <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>
11713 <td>four
11714 </td>
11715 <td>three</td>
11716 <td>four
11717 </td>
11718 <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>
11719 <td>four
11720 </td></tr></table>
11721
11722 !! html/parsoid
11723 <table>
11724 <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>
11725 <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>
11726 <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>
11727 </tbody></table>
11728 !! end
11729
11730 !! test
11731 Don't abort table cell attribute parsing if wikilink is found in template arg
11732 !! wikitext
11733 {|
11734 |Test {{#tag:ref|One two "[[three]]" four}}
11735 |}
11736 !! html/parsoid
11737 <table>
11738 <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>
11739 </tbody></table>
11740 !! end
11741
11742 !! test
11743 Magic variable as template parameter
11744 !! wikitext
11745 {{paramtest|param={{SITENAME}}}}
11746 !! html
11747 <p>This is a test template with parameter MediaWiki
11748 </p>
11749 !! end
11750
11751 !! article
11752 Template:linktest
11753 !! text
11754 [[{{{param}}}|link]]
11755 !! endarticle
11756
11757 !! test
11758 Template parameter as link source
11759 !! wikitext
11760 {{linktest|param=Main Page}}
11761 !! html
11762 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
11763 </p>
11764 !! end
11765
11766 !!article
11767 Template:paramtest2
11768 !! text
11769 including another template, {{paramtest|param={{{arg}}}}}
11770 !! endarticle
11771
11772 !! test
11773 Template passing argument to another template
11774 !! wikitext
11775 {{paramtest2|arg='hmm'}}
11776 !! html
11777 <p>including another template, This is a test template with parameter 'hmm'
11778 </p>
11779 !! end
11780
11781 !! article
11782 Template:Linktest2
11783 !! text
11784 Main Page
11785 !! endarticle
11786
11787 !! test
11788 Template as link source
11789 !! wikitext
11790 [[{{linktest2}}]]
11791
11792 [[{{linktest2}}|Main Page]]
11793
11794 [[{{linktest2}}]]Page
11795 !! html
11796 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11797 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11798 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>Page
11799 </p>
11800 !! end
11801
11802
11803 !! article
11804 Template:loop1
11805 !! text
11806 {{loop2}}
11807 !! endarticle
11808
11809 !! article
11810 Template:loop2
11811 !! text
11812 {{loop1}}
11813 !! endarticle
11814
11815 !! test
11816 Template infinite loop
11817 !! wikitext
11818 {{loop1}}
11819 !! html
11820 <p><span class="error">Template loop detected: <a href="/wiki/Template:Loop1" title="Template:Loop1">Template:Loop1</a></span>
11821 </p>
11822 !! end
11823
11824 !! test
11825 Template from main namespace
11826 !! wikitext
11827 {{:Main Page}}
11828 !! html
11829 <p>blah blah
11830 </p>
11831 !! end
11832
11833 !! test
11834 Template from non-includable namespace
11835 !! options
11836 wgNonincludableNamespaces=10
11837 !! wikitext
11838 {{echo|uh oh!}}
11839 !! html
11840 <p><a href="/wiki/Template:Echo" title="Template:Echo">Template:Echo</a>
11841 </p>
11842 !! end
11843
11844 !! article
11845 Template:table
11846 !! text
11847 {|
11848 | 1 || 2
11849 |-
11850 | 3 || 4
11851 |}
11852 !! endarticle
11853
11854 !! test
11855 T2529: Template with table, not included at beginning of line
11856 !! wikitext
11857 foo {{table}}
11858 !! html
11859 <p>foo
11860 </p>
11861 <table>
11862 <tr>
11863 <td>1</td>
11864 <td>2
11865 </td></tr>
11866 <tr>
11867 <td>3</td>
11868 <td>4
11869 </td></tr></table>
11870
11871 !! end
11872
11873 !! test
11874 T2523: Template shouldn't eat newline (or add an extra one before table)
11875 !! wikitext
11876 foo
11877 {{table}}
11878 !! html
11879 <p>foo
11880 </p>
11881 <table>
11882 <tr>
11883 <td>1</td>
11884 <td>2
11885 </td></tr>
11886 <tr>
11887 <td>3</td>
11888 <td>4
11889 </td></tr></table>
11890
11891 !! end
11892
11893 !! test
11894 T2041: Template parameters shown as broken links
11895 !! wikitext
11896 {{{parameter}}}
11897 !! html
11898 <p>{{{parameter}}}
11899 </p>
11900 !! end
11901
11902 !! test
11903 Template with targets containing wikilinks
11904 !! options
11905 parsoid=wt2html
11906 !! wikitext
11907 {{[[foo]]}}
11908
11909 {{[[{{echo|foo}}]]}}
11910
11911 {{{{echo|[[foo}}]]}}
11912 !! html/php
11913 <p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11914 </p><p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11915 </p><p>{{[[foo}}]]
11916 </p>
11917 !! html/parsoid
11918 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">foo</a>}}</p>
11919 <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>
11920 <p>{{<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[foo}}]]"}},"i":0}}]}'>[[foo}}]]</span></p>
11921 !! end
11922
11923 !! article
11924 Template:''
11925 !! text
11926 bar
11927 !! endarticle
11928
11929 !! test
11930 Templates: Double quotes as template target
11931 !! wikitext
11932 foo {{''}} baz
11933 !! html/php
11934 <p>foo bar baz
11935 </p>
11936 !! html/parsoid
11937 <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
11938 </p>
11939 !! end
11940
11941 ## This test is about making sure Parsoid's data-mw is well formed in the
11942 ## face of multiple templates with intersecting and overlapping ranges. The
11943 ## wikitext itself is wretched.
11944 !! test
11945 Templates with intersecting and overlapping ranges
11946 !! wikitext
11947 {|{{echo|
11948 <p>ha</p>}}
11949 {|{{echo|
11950 <p>ho</p>}}
11951 {{echo|{{!}}hi}}
11952 |}
11953 !! html/php+tidy
11954 <p>ha</p><table>
11955
11956 </table><p>ho</p><table>
11957
11958 <tbody><tr>
11959 <td>hi
11960 </td></tr></tbody></table>
11961 !! html/parsoid
11962 <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":""}]]}'>
11963
11964 </table><p about="#mwt1">ho</p><table about="#mwt1" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"","html":""},{"html":""}]]}'>
11965
11966 <tbody><tr><td>hi</td></tr>
11967 </tbody></table>
11968 !! end
11969
11970 !! article
11971 Template:MSGNW test
11972 !! text
11973 ''None'' of '''this''' should be
11974 * interpreted
11975 but rather passed unmodified
11976 {{test}}
11977 <gallery>
11978 File:Foobar.jpg
11979 </gallery>
11980 <!-- comment -->
11981 !! endarticle
11982
11983 # hmm, fix this or just deprecate msgnw and document its behavior?
11984 !! test
11985 msgnw keyword
11986 !! wikitext
11987 {{msgnw:MSGNW test}}
11988 !! html/php
11989 <p>&#39;&#39;None&#39;&#39; of &#39;&#39;&#39;this&#39;&#39;&#39; should be
11990 &#42; interpreted
11991 &#32;but rather passed unmodified
11992 &#123;&#123;test&#125;&#125;
11993 &#60;gallery&#62;
11994 File:Foobar.jpg
11995 &#60;/gallery&#62;
11996 &#60;!-- comment --&#62;
11997 </p>
11998 !! end
11999
12000 !! test
12001 int keyword
12002 !! wikitext
12003 {{int:youhavenewmessages|lots of money|not!}}
12004 !! html
12005 <p>You have lots of money (not!).
12006 </p>
12007 !! end
12008
12009 !! test
12010 int keyword - non-existing message
12011 !! wikitext
12012 {{int:var}}
12013 !! html
12014 <p>⧼var⧽
12015 </p>
12016 !! end
12017
12018 !! article
12019 Template:Includes
12020 !! text
12021 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
12022 !! endarticle
12023
12024 !! test
12025 <includeonly> and <noinclude> being included
12026 !! wikitext
12027 {{Includes}}
12028 !! html
12029 <p>Foobar
12030 </p>
12031 !! end
12032
12033 !! article
12034 Template:Includes2
12035 !! text
12036 <onlyinclude>Foo</onlyinclude>bar
12037 !! endarticle
12038
12039 !! test
12040 <onlyinclude> being included
12041 !! wikitext
12042 {{Includes2}}
12043 !! html
12044 <p>Foo
12045 </p>
12046 !! end
12047
12048
12049 !! article
12050 Template:Includes3
12051 !! text
12052 <onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly>
12053 !! endarticle
12054
12055 !! test
12056 <onlyinclude> and <includeonly> being included
12057 !! wikitext
12058 {{Includes3}}
12059 !! html
12060 <p>Foo
12061 </p>
12062 !! end
12063
12064 !! test
12065 <includeonly> and <noinclude> on a page
12066 !! wikitext
12067 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
12068 !! html
12069 <p>Foozar
12070 </p>
12071 !! end
12072
12073 !! test
12074 Un-closed <noinclude>
12075 !! wikitext
12076 <noinclude>
12077 !! html
12078 !! end
12079
12080 !! test
12081 <onlyinclude> on a page
12082 !! wikitext
12083 <onlyinclude>Foo</onlyinclude>bar
12084 !! html
12085 <p>Foobar
12086 </p>
12087 !! end
12088
12089 !! test
12090 Un-closed <onlyinclude>
12091 !! wikitext
12092 <onlyinclude>
12093 !! html
12094 !! end
12095
12096 !!test
12097 Self-closed noinclude, includeonly, onlyinclude tags
12098 !! wikitext
12099 <noinclude />
12100 <includeonly />
12101 <onlyinclude />
12102 !! html
12103 <p><br />
12104 </p>
12105 !!end
12106
12107 !!test
12108 Unbalanced includeonly and noinclude tags
12109 !! wikitext
12110 {|
12111 |a</noinclude>
12112 |b</noinclude></noinclude>
12113 |c</noinclude></includeonly>
12114 |d</includeonly></includeonly>
12115 |}
12116 !! html
12117 <table>
12118 <tr>
12119 <td>a
12120 </td>
12121 <td>b
12122 </td>
12123 <td>c&lt;/includeonly&gt;
12124 </td>
12125 <td>d&lt;/includeonly&gt;&lt;/includeonly&gt;
12126 </td></tr></table>
12127
12128 !!end
12129
12130 !! article
12131 Template:Includeonly section
12132 !! text
12133 <includeonly>
12134 ==Includeonly section==
12135 </includeonly>
12136 ==Section T-1==
12137 !!endarticle
12138
12139 !! test
12140 T8563: Edit link generation for section shown by <includeonly>
12141 !! wikitext
12142 {{includeonly section}}
12143 !! html
12144 <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>
12145 <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>
12146
12147 !! end
12148
12149 # Uses same input as the contents of [[Template:Includeonly section]]
12150 !! test
12151 T8563: Section extraction for section shown by <includeonly>
12152 !! options
12153 section=T-2
12154 !! wikitext
12155 <includeonly>
12156 ==Includeonly section==
12157 </includeonly>
12158 ==Section T-2==
12159 !! html
12160 ==Section T-2==
12161 !! end
12162
12163 !! test
12164 T8563: Edit link generation for section suppressed by <includeonly>
12165 !! wikitext
12166 <includeonly>
12167 ==Includeonly section==
12168 </includeonly>
12169 ==Section 1==
12170 !! html
12171 <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>
12172
12173 !! end
12174
12175 !! test
12176 T8563: Section extraction for section suppressed by <includeonly>
12177 !! options
12178 section=1
12179 !! wikitext
12180 <includeonly>
12181 ==Includeonly section==
12182 </includeonly>
12183 ==Section 1==
12184 !! html
12185 ==Section 1==
12186 !! end
12187
12188 !! test
12189 Un-closed <includeonly>
12190 !! wikitext
12191 <includeonly>
12192 !! html/php
12193 !! html/parsoid
12194 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>"}' data-mw='{"src":"&lt;includeonly>"}'/>
12195 !! end
12196
12197 ## We used to, but no longer wt2wt this test since the default serializer
12198 ## will normalize the include directives to serialize on their own line.
12199 ## Selser will take care of preserving formatting in scenarios where they
12200 ## intermingled with other wikitext.
12201 !! test
12202 Includes and comments at SOL
12203 !! options
12204 parsoid=wt2html,html2html
12205 !! wikitext
12206 <!-- comment --><noinclude><!-- comment --></noinclude><!-- comment -->==hu==
12207
12208 <noinclude>
12209 some
12210 </noinclude>*stuff
12211 *here
12212
12213 <noinclude>
12214 some</noinclude>* stuff
12215 * here
12216
12217 <includeonly>can have stuff</includeonly>===here===
12218
12219 !! html/php
12220 <h2><span class="mw-headline" id="hu">hu</span></h2>
12221 <p>some
12222 </p>
12223 <ul><li>stuff</li>
12224 <li>here</li></ul>
12225 <p><br />
12226 some* stuff
12227 </p>
12228 <ul><li>here</li></ul>
12229 <h3><span class="mw-headline" id="here">here</span></h3>
12230
12231 !! html/parsoid
12232 <!-- 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>
12233
12234 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
12235 <p>some</p>
12236 <meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/><ul><li>stuff</li>
12237 <li>here</li></ul>
12238
12239 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
12240 <p>some<meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/>* stuff</p>
12241 <ul><li>here</li></ul>
12242
12243 <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>
12244
12245 !! end
12246
12247 # TODO: test with DOM fragment reuse!
12248 !! test
12249 Parsoid: DOM fragment reuse
12250 !! options
12251 parsoid=wt2wt,wt2html
12252 !! wikitext
12253 a{{echo|b<table></table>c}}d
12254
12255 a{{echo|b
12256 <table></table>
12257 c}}d
12258
12259 {{echo|a
12260
12261 <table></table>
12262
12263 b}}
12264 !! html/php+tidy
12265 <p>ab</p><table></table><p>cd
12266 </p><p>ab
12267 </p>
12268 <table></table>
12269 <p>cd
12270 </p><p>a
12271 </p>
12272 <table></table>
12273 <p>b
12274 </p>
12275 !! html/parsoid
12276 <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>
12277
12278 <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">
12279 </span><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><span about="#mwt2">
12280 </span><p about="#mwt2">cd</p>
12281
12282 <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">
12283
12284 </span><table about="#mwt3" data-parsoid='{"stx":"html"}'></table><span about="#mwt3">
12285
12286 </span><p about="#mwt3">b</p>
12287 !! end
12288
12289 !! test
12290 Parsoid: Merge double tds (T52603)
12291 !! wikitext
12292 {|
12293 |{{echo|{{!}} foo}}
12294 |}
12295 !! html/php+tidy
12296 <table>
12297 <tbody><tr>
12298 <td>foo
12299 </td></tr></tbody></table>
12300 !! html/parsoid
12301 <table><tbody>
12302 <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>
12303 </tbody></table>
12304 !! end
12305
12306 !! test
12307 Parsoid: Merge double tds in nested transclusion content (T52603)
12308 !! wikitext
12309 {{echo|<div>}}
12310 {|
12311 |{{echo|{{!}} foo}}
12312 |}
12313 {{echo|</div>}}
12314 !! html/php+tidy
12315 <div>
12316 <table>
12317 <tbody><tr>
12318 <td>foo
12319 </td></tr></tbody></table>
12320 </div>
12321 !! html/parsoid
12322 <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}}]}'>
12323 <table><tbody>
12324 <tr><td data-mw='{"parts":["|"]}'> foo</td></tr>
12325 </tbody></table>
12326 </div>
12327 !! end
12328
12329 ###
12330 ### <includeonly> and <noinclude> in attributes
12331 ###
12332 !!test
12333 0. includeonly around the entire attribute
12334 !! wikitext
12335 <span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
12336 !! html
12337 <p><span id="v2">bar</span>
12338 </p>
12339 !!end
12340
12341 !!test
12342 1. includeonly in html attr key
12343 !! wikitext
12344 <span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
12345 !! html
12346 <p><span id="foo">bar</span>
12347 </p>
12348 !!end
12349
12350 !!test
12351 2. includeonly in html attr value
12352 !! wikitext
12353 <span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
12354 <span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
12355 !! html
12356 <p><span id="v1">bar</span>
12357 <span id="v1">bar</span>
12358 </p>
12359 !!end
12360
12361 !!test
12362 3. includeonly in part of an attr value
12363 !! wikitext
12364 <span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
12365 !! html
12366 <p><span style="color:red;">bar</span>
12367 </p>
12368 !!end
12369
12370 !!test
12371 4. includeonly in table attributes
12372 !! wikitext
12373 {|
12374 |- <noinclude>
12375 |-
12376 |a
12377 </noinclude>
12378 |- <includeonly>
12379 |-
12380 |b
12381 </includeonly>
12382 |}
12383 !! html
12384 <table>
12385
12386
12387 <tr>
12388 <td>a
12389 </td></tr>
12390 </table>
12391
12392 !!end
12393
12394 ###
12395 ### Preprocessor precedence tests
12396 ### See: https://www.mediawiki.org/wiki/Preprocessor_ABNF
12397 ###
12398 ##{{[[-{{{{{{[[Foo|bar}}]]}-}}}}}]]
12399 !! test
12400 Preprocessor precedence 1: link is rightmost opening
12401 !! options
12402 parsoid=wt2html
12403 !! wikitext
12404 {{[[Foo|bar}}]]
12405
12406 But close-brace is not a valid character in a link title:
12407 {{[[Foo}}|bar]]
12408
12409 However, we can still tell this was handled as a link in the preprocessor:
12410 {{echo|[[Foo}}|bar]]|bat}}
12411 !! html/php
12412 <p>{{<a href="/wiki/Foo" title="Foo">bar}}</a>
12413 </p><p>But close-brace is not a valid character in a link title:
12414 {{[[Foo}}|bar]]
12415 </p><p>However, we can still tell this was handled as a link in the preprocessor:
12416 [[Foo}}|bar]]
12417 </p>
12418 !! html/parsoid
12419 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">bar}}</a></p>
12420 <p>But close-brace is not a valid character in a link title: {{[[Foo}}|bar]]</p>
12421 <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>
12422 !! end
12423
12424 !! test
12425 Preprocessor precedence 2: template is rightmost opening
12426 !! options
12427 language=zh
12428 !! wikitext
12429 -{{echo|foo}-}}-
12430 !! html/php
12431 <p>-foo}--
12432 </p>
12433 !! html/parsoid
12434 <p>-<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}-"}},"i":0}}]}'>foo}-</span>-</p>
12435 !! end
12436
12437 !! test
12438 Preprocessor precedence 3: language converter is rightmost opening
12439 !! options
12440 language=zh
12441 parsoid=wt2html
12442 !! wikitext
12443 {{echo|hi}}
12444
12445 {{-{R|echo|hi}}}-
12446
12447 [[-{R|raw]]}-
12448 !! html/php
12449 <p>hi
12450 </p><p>{{echo|hi}}
12451 </p><p>[[raw]]
12452 </p>
12453 !! html/parsoid
12454 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"}},"i":0}}]}'>hi</p>
12455 <p>{{<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"echo|hi}}"}}'></span></p>
12456 <p>[[<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw]]"}}'></span></p>
12457 !! end
12458
12459 !! test
12460 Preprocessor precedence 4: left-most angle bracket
12461 !! options
12462 language=zh
12463 !! wikitext
12464 <!--{raw}-->
12465 !! html/php
12466 !! html/parsoid
12467 <!--{raw}-->
12468 !! end
12469
12470 !! article
12471 Template:Precedence5
12472 !! text
12473 {{{{{1}}}}}
12474 !! endarticle
12475
12476 !! test
12477 Preprocessor precedence 5: tplarg takes precedence over template
12478 !! wikitext
12479 {{Precedence5|Bullet}}
12480 !! html/php
12481 <ul><li>Bar</li></ul>
12482
12483 !! html/parsoid
12484 <ul typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Precedence5","href":"./Template:Precedence5"},"params":{"1":{"wt":"Bullet"}},"i":0}}]}'><li>Bar</li></ul>
12485 !! end
12486
12487 !! test
12488 Preprocessor precedence 6: broken link is rightmost opening
12489 !! options
12490 parsoid=wt2html
12491 !! wikitext
12492 {{echo|[[Foo}}
12493
12494 {{echo|[[Foo|bar|bat=baz}}
12495 !! html/php
12496 <p>{{echo|[[Foo}}
12497 </p><p>{{echo|[[Foo|bar|bat=baz}}
12498 </p>
12499 !! html/parsoid
12500 <p>{{echo|[[Foo}}</p>
12501 <p>{{echo|[[Foo|bar|bat=baz}}</p>
12502 !! end
12503
12504 # This next test exposes a difference between PHP and Parsoid:
12505 # Given [[Foo|{{echo|Bar]]x}}y]]z:
12506 # 1) Both PHP and Parsoid ignore the `]]` inside the `echo` in the
12507 # "preprocessor" stage. The `{{echo` extends until the `x}}`, and the
12508 # outer `[[Foo` extends until the `y]]`
12509 # 2a) But then the PHP preprocessor emits `[[Foo|Bar]]xy]]z` as an
12510 # intermediate result (after template expansion), and link processing
12511 # happens on this intermediate result, which moves the wikilink
12512 # boundary leftward to `[[Foo|Bar]]`
12513 # 2b) Parsoid works in a single step, so it's going to keep the
12514 # wikilink as extending to the `y]]`
12515 # 3a) Then PHP does linktrail processing which slurps up the trailing
12516 # `xy` inside the link.
12517 # 3b) Parsoid will do linktrail processing to slurp up the trailing
12518 # `z` inside the link.
12519 # This is "correct" behavior. Parsoid's basic worldview is that the
12520 # `]]` inside the template shouldn't be allowed to leak out to affect
12521 # the surrounding wikilink. PHP may match Parsoid (in the future)
12522 # if you use {{#balance}} (T114445).
12523
12524 !! test
12525 Preprocessor precedence 7: broken template is rightmost opening
12526 !! options
12527 parsoid=wt2html
12528 !! wikitext
12529 [[Foo|{{echo|Bar]]
12530
12531 [[Foo|{{echo|Bar]]-x}}-y]]-z
12532
12533 Careful: linktrails can move the end of the wikilink:
12534 [[Foo|{{echo|y']]a}}l]]l
12535 !! html/php
12536 <p><a href="/wiki/Foo" title="Foo">{{echo|Bar</a>
12537 </p><p><a href="/wiki/Foo" title="Foo">Bar</a>-x-y]]-z
12538 </p><p>Careful: linktrails can move the end of the wikilink:
12539 <a href="/wiki/Foo" title="Foo">y'al</a>]]l
12540 </p>
12541 !! html/parsoid
12542 <p>[[Foo|{{echo|Bar]]</p>
12543 <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>
12544 <p>Careful: linktrails can move the end of the wikilink:
12545 <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>
12546 !! end
12547
12548 !! test
12549 Preprocessor precedence 8: broken language converter is rightmost opening
12550 !! options
12551 language=zh
12552 !! wikitext
12553 [[Foo-{R|raw]]
12554 !! html
12555 <p>[[Foo-{R|raw]]
12556 </p>
12557 !! end
12558
12559 !! article
12560 Template:Preprocessor_precedence_9
12561 !! text
12562 ;4: {{{{1}}}}
12563 ;5: {{{{{2}}}}}
12564 ;6: {{{{{{3}}}}}}
12565 ;7: {{{{{{{4}}}}}}}
12566 !! endarticle
12567
12568 !! test
12569 Preprocessor precedence 9: groups of braces
12570 !! wikitext
12571 {{Preprocessor precedence 9|Four|Bullet|1|2}}
12572 !! html/php
12573 <dl><dt>4</dt>
12574 <dd>{Four}</dd>
12575 <dt>5</dt>
12576 <dd></dd></dl>
12577 <ul><li>Bar</li></ul>
12578 <dl><dt>6</dt>
12579 <dd>Four</dd>
12580 <dt>7</dt>
12581 <dd>{Bullet}</dd></dl>
12582
12583 !! html/parsoid
12584 <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}}]}'>
12585 <dt>4</dt>
12586 <dd>{Four}</dd>
12587 <dt>5</dt>
12588 <dd></dd>
12589 </dl><ul about="#mwt1">
12590 <li>Bar</li>
12591 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12592 <dt>6</dt>
12593 <dd>Four</dd>
12594 <dt>7</dt>
12595 <dd>{Bullet}</dd>
12596 </dl>
12597 !! end
12598
12599 !! article
12600 Template:Preprocessor_precedence_10
12601 !! text
12602 ;1: -{R|raw}-
12603 ;2: -{{Bullet}}-
12604 ;3: -{{{1}}}-
12605 ;4: -{{{{2}}}}-
12606 ;5: -{{{{{3}}}}}-
12607 ;6: -{{{{{{4}}}}}}-
12608 ;7: -{{{{{{{5}}}}}}}-
12609 !! endarticle
12610
12611 !! test
12612 Preprocessor precedence 10: groups of braces with leading dash
12613 !! options
12614 language=zh
12615 !! wikitext
12616 {{Preprocessor precedence 10|Three|raw2|Bullet|1|2}}
12617 !! html/php
12618 <dl><dt>1</dt>
12619 <dd>raw</dd>
12620 <dt>2</dt>
12621 <dd>-</dd></dl>
12622 <ul><li>Bar-</li></ul>
12623 <dl><dt>3</dt>
12624 <dd>-Three-</dd>
12625 <dt>4</dt>
12626 <dd>raw2</dd>
12627 <dt>5</dt>
12628 <dd>-</dd></dl>
12629 <ul><li>Bar-</li></ul>
12630 <dl><dt>6</dt>
12631 <dd>-Three-</dd>
12632 <dt>7</dt>
12633 <dd>raw2</dd></dl>
12634
12635 !! html/parsoid
12636 <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}}]}'>
12637 <dt>1</dt>
12638 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw"}}'></span></dd>
12639 <dt>2</dt>
12640 <dd>-</dd>
12641 </dl><ul about="#mwt1">
12642 <li>Bar-</li>
12643 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12644 <dt>3</dt>
12645 <dd>-Three-</dd>
12646 <dt>4</dt>
12647 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12648 <dt>5</dt>
12649 <dd>-</dd>
12650 </dl><ul about="#mwt1">
12651 <li>Bar-</li>
12652 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12653 <dt>6</dt>
12654 <dd>-Three-</dd>
12655 <dt>7</dt>
12656 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12657 </dl>
12658 !! end
12659
12660 !! test
12661 Preprocessor precedence 11: found during visual diff testing
12662 !! wikitext
12663 {{#tag:span|-{{#tag:span|-{{echo|x}}}}}}
12664
12665 {{echo|-{{echo|-{{echo|x}}}}}}
12666
12667 {{echo|-{{echo|x}}}}
12668 !! html/php
12669 <p><span>-<span>-x</span></span>
12670 </p><p>--x
12671 </p><p>-x
12672 </p>
12673 !! html/parsoid
12674 <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>
12675
12676 <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>
12677
12678 <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>
12679 !! end
12680
12681 !! test
12682 Preprocessor precedence 12: broken language converter closed by brace.
12683 !! options
12684 parsoid=wt2html
12685 !! wikitext
12686 This form breaks the template, which is unfortunate:
12687 *{{echo|foo-{bar}bat}}
12688
12689 But if the broken language converter markup is inside an extension
12690 tag, nothing bad happens:
12691 *<nowiki>foo-{bar}bat</nowiki>
12692 *{{echo|<nowiki>foo-{bar}bat</nowiki>}}
12693 *<pre>foo-{bar}bat</pre>
12694 *{{echo|<pre>foo-{bar}bat</pre>}}
12695
12696 <tag>foo-{bar}bat</tag>
12697 {{echo|<tag>foo-{bar}bat</tag>}}
12698
12699 !! html/php+tidy
12700 <p>This form breaks the template, which is unfortunate:
12701 </p>
12702 <ul><li>{{echo|foo-{bar}bat}}</li></ul>
12703 <p>But if the broken language converter markup is inside an extension
12704 tag, nothing bad happens:
12705 </p>
12706 <ul><li>foo-&#123;bar}bat</li>
12707 <li>foo-&#123;bar}bat</li>
12708 <li><pre>foo-{bar}bat</pre></li>
12709 <li><pre>foo-{bar}bat</pre></li></ul>
12710 <pre>'foo-{bar}bat'
12711 array (
12712 )
12713 </pre>
12714 <pre>'foo-{bar}bat'
12715 array (
12716 )
12717 </pre>
12718 !! html/parsoid
12719 <p>This form breaks the template, which is unfortunate:</p>
12720 <ul>
12721 <li>{{echo|foo-{bar}bat}}</li>
12722 </ul>
12723 <p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p>
12724 <ul>
12725 <li><span typeof="mw:Nowiki">foo-{bar}bat</span></li>
12726 <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>
12727 <li><pre typeof="mw:Extension/pre" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo-{bar}bat"}}'>foo-{bar}bat</pre></li>
12728 <li><pre typeof="mw:Transclusion mw:Extension/pre" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;pre>foo-{bar}bat&lt;/pre>"}},"i":0}}]}'>foo-{bar}bat</pre></li>
12729 </ul>
12730 <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>
12731 !! end
12732
12733 !! test
12734 Preprocessor precedence 13: broken language converter in external link
12735 !! options
12736 parsoid=wt2html
12737 !! wikitext
12738 *[http://example.com/-{foo Example in URL]
12739 *[http://example.com Example in -{link} description]
12740 *{{echo|[http://example.com/-{foo Breaks template, however]}}
12741 !! html/php+tidy
12742 <ul><li><a rel="nofollow" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12743 <li><a rel="nofollow" class="external text" href="http://example.com">Example in -{link} description</a></li>
12744 <li>{{echo|<a rel="nofollow" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li></ul>
12745 !! html/parsoid
12746 <ul>
12747 <li><a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12748 <li><a rel="mw:ExtLink" class="external text" href="http://example.com">Example in -{link} description</a></li>
12749 <li>{{echo|<a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
12750 </ul>
12751 !! end
12752
12753 !! test
12754 Preprocessor precedence 14: broken language converter in comment
12755 !! wikitext
12756 *<!--{{foo}}-->...should be ok
12757 *<!---{{foo}}-->...extra dashes
12758 *{{echo|foo<!-- -{bar} -->bat}}...should be ok
12759 !! html/php+tidy
12760 <ul><li>...should be ok</li>
12761 <li>...extra dashes</li>
12762 <li>foobat...should be ok</li></ul>
12763 !! html/parsoid
12764 <ul>
12765 <li><!--{{foo}}-->...should be ok</li>
12766 <li><!--&#x2D;{{foo}}-->...extra dashes</li>
12767 <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>
12768 </ul>
12769 !! end
12770
12771 !! test
12772 Preprocessor precedence 15: broken brace markup in headings
12773 !! config
12774 wgFragmentMode=[ 'html5', 'legacy' ]
12775 !! options
12776 parsoid=wt2html
12777 !! wikitext
12778 __NOTOC__ __NOEDITSECTION__
12779 ===1 foo[bar 1===
12780 1
12781 ===2 foo[[bar 2===
12782 2
12783 ===3 foo{bar 3===
12784 3
12785 ===4 foo{{bar 4===
12786 4
12787 ===5 foo{{{bar 5===
12788 5
12789 ===6 foo-{bar 6===
12790 6
12791 !! html/php+tidy
12792 <h3><span id="1_foo.5Bbar_1"></span><span class="mw-headline" id="1_foo[bar_1">1 foo[bar 1</span></h3>
12793 <p>1
12794 </p>
12795 <h3><span id="2_foo.5B.5Bbar_2"></span><span class="mw-headline" id="2_foo[[bar_2">2 foo[[bar 2</span></h3>
12796 <p>2
12797 </p>
12798 <h3><span id="3_foo.7Bbar_3"></span><span class="mw-headline" id="3_foo{bar_3">3 foo{bar 3</span></h3>
12799 <p>3
12800 </p>
12801 <h3><span id="4_foo.7B.7Bbar_4"></span><span class="mw-headline" id="4_foo{{bar_4">4 foo{{bar 4</span></h3>
12802 <p>4
12803 </p>
12804 <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>
12805 <p>5
12806 </p>
12807 <h3><span id="6_foo-.7Bbar_6"></span><span class="mw-headline" id="6_foo-{bar_6">6 foo-{bar 6</span></h3>
12808 <p>6
12809 </p>
12810 !! html/parsoid
12811 <meta property="mw:PageProp/notoc"/> <meta property="mw:PageProp/noeditsection"/>
12812 <h3 id="1_foo[bar_1"><span id="1_foo.5Bbar_1" typeof="mw:FallbackId"></span>1 foo[bar 1</h3>
12813 <p>1</p>
12814 <h3 id="2_foo[[bar_2"><span id="2_foo.5B.5Bbar_2" typeof="mw:FallbackId"></span>2 foo[[bar 2</h3>
12815 <p>2</p>
12816 <h3 id="3_foo{bar_3"><span id="3_foo.7Bbar_3" typeof="mw:FallbackId"></span>3 foo{bar 3</h3>
12817 <p>3</p>
12818 <h3 id="4_foo{{bar_4"><span id="4_foo.7B.7Bbar_4" typeof="mw:FallbackId"></span>4 foo{{bar 4</h3>
12819 <p>4</p>
12820 <h3 id="5_foo{{{bar_5"><span id="5_foo.7B.7B.7Bbar_5" typeof="mw:FallbackId"></span>5 foo{{{bar 5</h3>
12821 <p>5</p>
12822 <h3 id="6_foo-{bar_6"><span id="6_foo-.7Bbar_6" typeof="mw:FallbackId"></span>6 foo-{bar 6</h3>
12823 <p>6</p>
12824 !! end
12825
12826 !! test
12827 Preprocessor precedence 16: matching closing braces to opening braces
12828 !! options
12829 language=zh
12830 parsoid=wt2html
12831 !! wikitext
12832 -{{{echo|foo}}bar}-
12833 !! html/php
12834 <p>foobar
12835 </p>
12836 !! html/parsoid
12837 <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>
12838 !! end
12839
12840 !! test
12841 Preprocessor precedence 17: template w/o target shouldn't prevent closing
12842 !! options
12843 parsoid=wt2html
12844 !! wikitext
12845 {{echo|hi {{}}}}
12846 !! html/php
12847 <p>hi {{}}
12848 </p>
12849 !! html/parsoid
12850 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi {{}}"}},"i":0}}]}'>hi {{}}</p>
12851 !! end
12852
12853 # Ensure we're using a language without variants for this test; even
12854 # if $wgUsePigLatinVariant is true. We've picked `de` arbitrarily.
12855 !! test
12856 Preprocessor precedence 18: another rightmost wins scenario
12857 !! options
12858 parsoid=wt2html
12859 language=de
12860 !! wikitext
12861 {{ -{{{{1|tplarg}}} }} }-
12862 !! html/php
12863 <p>{{ -{tplarg }} }-
12864 </p>
12865 !! html/parsoid
12866 <p>{{ -{<span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"1"},"params":{"1":{"wt":"tplarg"}},"i":0}}]}'>tplarg</span> }} }-</p>
12867 !! end
12868
12869 !! test
12870 Preprocessor precedence 19: break syntax
12871 !! options
12872 parsoid=wt2html
12873 !! wikitext
12874 -{{
12875 !! html/php
12876 <p>-{{
12877 </p>
12878 !! html/parsoid
12879 <p>-{{</p>
12880 !! end
12881
12882 ###
12883 ### Token Stream Patcher tests
12884 ###
12885 ### These tests won't always pass wt2wt and other modes because
12886 ### on serialization, the table will be output on a new line.
12887 ### For now, we are blacklisting them, and using this to test selser.
12888 ###
12889
12890 !!test
12891 1. Table tag in SOL posn. should get reparsed correctly with valid TSR
12892 !!options
12893 parsoid=wt2html,wt2wt
12894 !!wikitext
12895 {{echo|}}{| width = '100%'
12896 |foo
12897 |}
12898 !!html/parsoid
12899 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":""}},"i":0}}]}'></span><table width="100%">
12900 <tbody><tr><td>foo</td></tr>
12901 </tbody></table>
12902 !!end
12903
12904 ## We used to, but no longer wt2wt this test since the default serializer
12905 ## will normalize the include directives to serialize on their own line.
12906 ## Selser will take care of preserving formatting in scenarios where they
12907 ## intermingled with other wikitext.
12908 !!test
12909 2. Table tag in SOL posn. should get reparsed correctly with valid TSR
12910 !!options
12911 parsoid=wt2html
12912 !!wikitext
12913 <includeonly>a</includeonly>{| {{{b}}}
12914 |c
12915 |}
12916 !!html/parsoid
12917 <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":""}]]}'>
12918 <tbody><tr><td>c</td></tr>
12919 </tbody></table>
12920 !!end
12921
12922 !! test
12923 Table wikitext syntax outside wiki-tables
12924 !! wikitext
12925 a
12926 |+ not a caption
12927 ! not a table heading
12928 |- not a table row
12929 | not a table cell
12930 | class="foo bar" | baz
12931 b
12932 |}
12933 |-
12934 c
12935 !! html
12936 <p>a
12937 |+ not a caption
12938 ! not a table heading
12939 |- not a table row
12940 | not a table cell
12941 | class="foo bar" | baz
12942 b
12943 |}
12944 |-
12945 c
12946 </p>
12947 !! end
12948
12949 ###
12950 ### Testing parsing of templates where a template arg
12951 ### has the same name as the template itself.
12952 ###
12953
12954 !! article
12955 Template:quote
12956 !! text
12957 {{{quote|{{{1}}}}}}
12958 !! endarticle
12959
12960 !!test
12961 Templates: Template Name/Arg clash: 1. Use of positional param
12962 !! wikitext
12963 {{quote|foo}}
12964 !! html
12965 <p>foo
12966 </p>
12967 !!end
12968
12969 !!test
12970 Templates: Template Name/Arg clash: 2. Use of named param
12971 !! wikitext
12972 {{quote|quote=foo}}
12973 !! html
12974 <p>foo
12975 </p>
12976 !!end
12977
12978 !!test
12979 Templates: Template Name/Arg clash: 3. Use of named param with empty input
12980 !! wikitext
12981 {{quote|quote}}
12982 !! html
12983 <p>quote
12984 </p>
12985 !!end
12986
12987 ###
12988 ### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
12989 ###
12990
12991 !!test
12992 Templates: 1. Simple use
12993 !! wikitext
12994 {{echo|Foo}}
12995 !! html
12996 <p>Foo
12997 </p>
12998 !!end
12999
13000 !!test
13001 Templates: 2. Inside a block tag
13002 !! wikitext
13003 <div>{{echo|Foo}}</div>
13004 <blockquote>{{echo|Foo}}</blockquote>
13005 !! html
13006 <div>Foo</div>
13007 <blockquote>Foo</blockquote>
13008
13009 !! html+tidy
13010 <div>Foo</div>
13011 <blockquote><p>Foo</p></blockquote>
13012 !!end
13013
13014 !!test
13015 Templates: P-wrapping: 1a. Templates on consecutive lines
13016 !! wikitext
13017 {{echo|Foo}}
13018 {{echo|bar}}
13019 !! html
13020 <p>Foo
13021 bar
13022 </p>
13023 !!end
13024
13025 !!test
13026 Templates: P-wrapping: 1b. Templates on consecutive lines
13027 !! wikitext
13028 Foo
13029
13030 {{echo|bar}}
13031 {{echo|baz}}
13032 !! html
13033 <p>Foo
13034 </p><p>bar
13035 baz
13036 </p>
13037 !!end
13038
13039 !!test
13040 Templates: P-wrapping: 1c. Templates on consecutive lines
13041 !! wikitext
13042 {{echo|Foo}}
13043 {{echo|bar}} <div>baz</div>
13044 !! html
13045 <p>Foo
13046 </p>
13047 bar <div>baz</div>
13048
13049 !! html+tidy
13050 <p>Foo
13051 </p><p>
13052 bar </p><div>baz</div>
13053 !! end
13054
13055 !! test
13056 Templates: P-wrapping: 1d. Template preceded by comment-only line
13057 !! wikitext
13058 <!-- foo -->
13059 {{echo|Bar}}
13060 !! html/php+tidy
13061 <p>Bar
13062 </p>
13063 !! html/parsoid
13064 <!-- foo -->
13065
13066 <p about="#mwt223" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar"}},"i":0}}]}'>Bar</p>
13067 !!end
13068
13069 !! test
13070 Templates: Scopes should not be expanded unnecessarily
13071 !! options
13072 parsoid=wt2html,wt2wt
13073 !! wikitext
13074 {{echo|<div>a</div>}}b{{echo|
13075 <div>c</div>}}
13076 !! html/php+tidy
13077 <div>a</div><p>b
13078 </p><div>c</div>
13079 !! html/parsoid
13080 <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}}]}'>
13081 </span><div about="#mwt2">c</div>
13082 !! end
13083
13084 !!test
13085 Templates: Inline Text: 1. Multiple template uses
13086 !! wikitext
13087 {{echo|Foo}}bar{{echo|baz}}
13088 !! html
13089 <p>Foobarbaz
13090 </p>
13091 !!end
13092
13093 !!test
13094 Templates: Inline Text: 2. Back-to-back template uses
13095 !! wikitext
13096 {{echo|Foo}}{{echo|bar}}
13097 !! html
13098 <p>Foobar
13099 </p>
13100 !!end
13101
13102 !!test
13103 Templates: Block Tags: 1. Multiple template uses
13104 !! wikitext
13105 {{echo|<div>Foo</div>}}<div>bar</div>{{echo|<div>baz</div>}}
13106 !! html
13107 <div>Foo</div><div>bar</div><div>baz</div>
13108
13109 !!end
13110
13111 !!test
13112 Templates: Block Tags: 2. Back-to-back template uses
13113 !! wikitext
13114 {{echo|<div>Foo</div>}}{{echo|<div>bar</div>}}
13115 !! html
13116 <div>Foo</div><div>bar</div>
13117
13118 !!end
13119
13120 ## Parsoid drops empty elements in templates.
13121 !! test
13122 Templates: Correctly encapsulate templates producing </p> tag without a corresponding <p> tag
13123 !! wikitext
13124 {{echo|a
13125 b</p>}}
13126 !! html/php+tidy
13127 <p>a
13128 </p><p>
13129 b</p><p class="mw-empty-elt"></p>
13130 !! html/parsoid
13131 <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">
13132 </span><p about="#mwt1">b</p>
13133 !! end
13134
13135 !!test
13136 Templates: Links: 1. Simple example
13137 !! wikitext
13138 {{echo|[[Foo|bar]]}}
13139 !! html
13140 <p><a href="/wiki/Foo" title="Foo">bar</a>
13141 </p>
13142 !!end
13143
13144 !!test
13145 Templates: Links: 2. Generation of link href
13146 !! wikitext
13147 [[{{echo|Foo}}|bar]]
13148 !! html
13149 <p><a href="/wiki/Foo" title="Foo">bar</a>
13150 </p>
13151 !!end
13152
13153 !!test
13154 Templates: Links: 3. Generation of part of a link href
13155 !! wikitext
13156 [[Fo{{echo|o}}|bar]]
13157
13158 [[Foo{{echo|bar}}]]
13159
13160 [[Foo{{echo|bar}}baz]]
13161
13162 [[Foo{{echo|bar}}|bar]]
13163
13164 [[:Foo{{echo|bar}}]]
13165
13166 [[:Foo{{echo|bar}}|bar]]
13167 !! html
13168 <p><a href="/wiki/Foo" title="Foo">bar</a>
13169 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
13170 </p><p><a href="/index.php?title=Foobarbaz&amp;action=edit&amp;redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a>
13171 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
13172 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
13173 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
13174 </p>
13175 !!end
13176
13177 !!test
13178 Templates: Links: 4. Multiple templates generating link href
13179 !! wikitext
13180 [[{{echo|F}}{{echo|o}}ob{{echo|ar}}]]
13181 !! html
13182 <p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
13183 </p>
13184 !!end
13185
13186 !!test
13187 Templates: Links: 5. Generation of link text
13188 !! wikitext
13189 [[Foo|{{echo|bar}}]]
13190 !! html
13191 <p><a href="/wiki/Foo" title="Foo">bar</a>
13192 </p>
13193 !!end
13194
13195 !!test
13196 Templates: Links: 5. Nested templates (only outermost template should be marked)
13197 !! wikitext
13198 {{echo|[[{{echo|Foo}}|bar]]}}
13199 !! html
13200 <p><a href="/wiki/Foo" title="Foo">bar</a>
13201 </p>
13202 !!end
13203
13204 !!test
13205 Templates: HTML Tag: 1. Generation of HTML attr. key
13206 !! wikitext
13207 <div {{echo|style}}="color:red;">foo</div>
13208 !! html
13209 <div style="color:red;">foo</div>
13210
13211 !!end
13212
13213 !!test
13214 Templates: HTML Tag: 2. Generation of HTML attr. value
13215 !! wikitext
13216 <div style={{echo|'color:red;'}}>foo</div>
13217 !! html
13218 <div style="color:red;">foo</div>
13219
13220 !!end
13221
13222 !!test
13223 Templates: HTML Tag: 3. Generation of HTML attr key and value
13224 !! wikitext
13225 <div {{echo|style}}={{echo|'color:red;'}}>foo</div>
13226 !! html
13227 <div style="color:red;">foo</div>
13228
13229 !!end
13230
13231 !!test
13232 Templates: HTML Tag: 4. Generation of starting piece of HTML attr value
13233 !! wikitext
13234 <div title="{{echo|This is a long title}} with just one piece templated">foo</div>
13235 !! html
13236 <div title="This is a long title with just one piece templated">foo</div>
13237
13238 !!end
13239
13240 !!test
13241 Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
13242 !! wikitext
13243 <div title="This is a long title with just {{echo|one piece}} templated">foo</div>
13244 !! html
13245 <div title="This is a long title with just one piece templated">foo</div>
13246
13247 !!end
13248
13249 !!test
13250 Templates: HTML Tag: 6. Generation of end piece of HTML attr value
13251 !! wikitext
13252 <div title="This is a long title with just one piece {{echo|templated}}">foo</div>
13253 !! html
13254 <div title="This is a long title with just one piece templated">foo</div>
13255
13256 !!end
13257
13258 # SSS FIXME: While it is great we added support for all this,
13259 # do we want to make this part of the spec? Maybe we want to
13260 # deprecate this kind of usage in the future?
13261 !!test
13262 Templates: HTML Tag: 7. Generation of partial attribute key string
13263 !! wikitext
13264 <div st{{echo|yle}}="color:red;">foo</div>
13265 !! html
13266 <div style="color:red;">foo</div>
13267
13268 !!end
13269
13270 !! test
13271 Templates: HTML Tag: 8. Template-generated attribute (k=v)
13272 !! wikitext
13273 <div {{echo|1=id="v1"}}>bar</div>
13274 !! html
13275 <div id="v1">bar</div>
13276
13277 !!end
13278
13279 !! test
13280 Templates: HTML Tag: 9. Multiple template-generated attributes
13281 !! wikitext
13282 <div {{echo|1=id="v1" title="foo"}}>bar</div>
13283 !! html
13284 <div id="v1" title="foo">bar</div>
13285
13286 !!end
13287
13288 !! test
13289 Templates: Support for templates generating attributes and content
13290 !! wikitext
13291 {| {{mixed_attr_content_template}}
13292 |-
13293 |bar
13294 |}
13295 !! html/php
13296 <table style="color:red;" title="T48811">
13297
13298 <tr>
13299 <td>foo
13300 </td></tr>
13301 <tr>
13302 <td>bar
13303 </td></tr></table>
13304
13305 !! html/parsoid
13306 <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|}"]}'>
13307 <tbody><tr>
13308 <td>foo</td></tr>
13309 <tr>
13310 <td>bar</td></tr>
13311 </tbody></table>
13312 !!end
13313
13314 !! article
13315 Template:attribute_from_template
13316 !! text
13317 class="123"
13318 !! endarticle
13319
13320 !! test
13321 Table cell with attribute before expanded attribute
13322 !! wikitext
13323 {|
13324 | align="center" {{attribute_from_template}} |456
13325 |}
13326 !! html/parsoid
13327 <table>
13328 <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>
13329 </tbody></table>
13330 !! end
13331
13332 !! test
13333 1. Entities and nowikis inside templated attributes should be handled correctly
13334 !! wikitext
13335 <div {{echo|style{{=}}"background:&#35;f9f9f9;"}}>foo</div>
13336 !! html/php
13337 <div style="background:#f9f9f9;">foo</div>
13338
13339 !! html/parsoid
13340 <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>
13341 !! end
13342
13343 !! test
13344 2. Entities and nowikis inside templated attributes should be handled correctly
13345 !! wikitext
13346 {|
13347 |{{table_attribs_3}}
13348 |}
13349 !! html/php
13350 <table>
13351 <tr>
13352 <td style="background:#f9f9f9;">Foo
13353 </td></tr></table>
13354
13355 !! html/parsoid
13356 <table>
13357 <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>
13358 </tbody></table>
13359 !! end
13360
13361 !! test
13362 3. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13363 !! wikitext
13364 {{tbl-start}}
13365 |{{table_attribs_3}}
13366 {{tbl-end}}
13367 !! html/php
13368 <table>
13369 <tr>
13370 <td style="background:#f9f9f9;">Foo
13371 </td></tr></table>
13372
13373 !! html/parsoid
13374 <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}}]}'>
13375 <tbody><tr><td style="background:#f9f9f9;">Foo</td></tr>
13376 </tbody></table>
13377 !! end
13378
13379 # T107622
13380 !! test
13381 4. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13382 !! wikitext
13383 {|
13384 |{{table_attribs_6}} hi
13385 |}
13386 !! html/php
13387 <table>
13388 <tr>
13389 <td style="background: red;">hi
13390 </td></tr></table>
13391
13392 !! html/parsoid
13393 <table>
13394 <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>
13395 </tbody></table>
13396 !! end
13397
13398 !!test
13399 Templates: HTML Tables: 1. Generating start of a HTML table
13400 !! wikitext
13401 {{echo|<table><tr><td>foo</td>}}</tr></table>
13402 !! html
13403 <table><tr><td>foo</td></tr></table>
13404
13405 !!end
13406
13407 !!test
13408 Templates: HTML Tables: 2a. Generating middle of a HTML table
13409 !! wikitext
13410 <table><tr>{{echo|<td>foo</td>}}</tr></table>
13411 !! html
13412 <table><tr><td>foo</td></tr></table>
13413
13414 !!end
13415
13416 !!test
13417 Templates: HTML Tables: 2b. Generating middle of a HTML table
13418 !! wikitext
13419 <table>{{echo|<tr><td>foo</td></tr>}}</table>
13420 !! html
13421 <table><tr><td>foo</td></tr></table>
13422
13423 !!end
13424
13425 !!test
13426 Templates: HTML Tables: 3. Generating end of a HTML table
13427 !! wikitext
13428 <table><tr>{{echo|<td>foo</td></tr></table>}}
13429 !! html
13430 <table><tr><td>foo</td></tr></table>
13431
13432 !!end
13433
13434 !!test
13435 Templates: HTML Tables: 4a. Generating a single tag of a HTML table
13436 !! wikitext
13437 {{echo|<table>}}<tr><td>foo</td></tr></table>
13438 !! html
13439 <table><tr><td>foo</td></tr></table>
13440
13441 !!end
13442
13443 !!test
13444 Templates: HTML Tables: 4b. Generating a single tag of a HTML table
13445 !! wikitext
13446 <table>{{echo|<tr>}}<td>foo</td></tr></table>
13447 !! html
13448 <table><tr><td>foo</td></tr></table>
13449
13450 !!end
13451
13452 !!test
13453 Templates: HTML Tables: 4c. Generating a single tag of a HTML table
13454 !! wikitext
13455 <table><tr>{{echo|<td>}}foo</td></tr></table>
13456 !! html
13457 <table><tr><td>foo</td></tr></table>
13458
13459 !!end
13460
13461 !!test
13462 Templates: HTML Tables: 4d. Generating a single tag of a HTML table
13463 !! wikitext
13464 <table><tr><td>foo{{echo|</td>}}</tr></table>
13465 !! html
13466 <table><tr><td>foo</td></tr></table>
13467
13468 !!end
13469
13470 !!test
13471 Templates: HTML Tables: 4e. Generating a single tag of a HTML table
13472 !! wikitext
13473 <table><tr><td>foo</td>{{echo|</tr>}}</table>
13474 !! html
13475 <table><tr><td>foo</td></tr></table>
13476
13477 !!end
13478
13479 !!test
13480 Templates: HTML Tables: 4f. Generating a single tag of a HTML table
13481 !! wikitext
13482 <table><tr><td>foo</td></tr>{{echo|</table>}}
13483 !! html
13484 <table><tr><td>foo</td></tr></table>
13485
13486 !!end
13487
13488 !!test
13489 Templates: HTML Tables: 5. Proper fostering of categories from inside
13490 !!options
13491 parsoid=wt2html,wt2wt
13492 !! wikitext
13493 <table>[[Category:foo1]]<tr><td>foo</td></tr></table>
13494 <!--Two categories (T52330)-->
13495 <table>[[Category:bar1]][[Category:bar2]]<tr><td>foo</td></tr></table>
13496 !! html/php+tidy
13497 <table><tbody><tr><td>foo</td></tr></tbody></table>
13498 <table><tbody><tr><td>foo</td></tr></tbody></table>
13499 !! html/parsoid
13500 <link rel="mw:PageProp/Category" href="./Category:Foo1"><table><tbody><tr><td>foo</td></tr></tbody></table>
13501 <!--Two categories (T52330)-->
13502 <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>
13503 !!end
13504
13505 ## Remex doesn't account for fostered content.
13506 !! test
13507 Templates: Wiki Tables: 1a. Fostering of entire template content
13508 !! wikitext
13509 {|
13510 {{echo|a}}
13511 |}
13512 !! html/php
13513 <table>
13514 a
13515 <tr><td></td></tr></table>
13516
13517 !! html/php+tidy
13518
13519 a
13520 <table><tbody><tr><td></td></tr></tbody></table>
13521 !! html/parsoid
13522 <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">
13523
13524 </table>
13525 !! end
13526
13527 !!test
13528 Templates: Wiki Tables: 1b. Fostering of entire template content
13529 !! wikitext
13530 {|
13531 {{echo|<div>}}
13532 foo
13533 {{echo|</div>}}
13534 |}
13535 !! html
13536 <table>
13537 <div>
13538 <p>foo
13539 </p>
13540 </div>
13541 <tr><td></td></tr></table>
13542
13543 !! html/php+tidy
13544 <div>
13545 <p>foo
13546 </p>
13547 </div><table>
13548
13549 <tbody><tr><td></td></tr></tbody></table>
13550 !! html/parsoid
13551 <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|}"]}'>
13552 <p>foo</p>
13553 </div><table about="#mwt3">
13554
13555 </table>
13556 !! end
13557
13558 ## Remex doesn't account for fostered content.
13559 !! test
13560 Templates: Wiki Tables: 2. Fostering of partial template content
13561 !! wikitext
13562 {|
13563 {{echo|a
13564 <div>b</div>}}
13565 |}
13566 !! html/php
13567 <table>
13568 a
13569 <div>b</div>
13570 <tr><td></td></tr></table>
13571
13572 !! html/php+tidy
13573
13574 a
13575 <div>b</div><table>
13576 <tbody><tr><td></td></tr></tbody></table>
13577 !! html/parsoid
13578 <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">
13579
13580
13581 </table>
13582 !! end
13583
13584 !!test
13585 Templates: Wiki Tables: 3. td-content via multiple templates
13586 !! wikitext
13587 {|
13588 {{echo|{{pipe}}a}}{{echo|b}}
13589 |}
13590 !! html
13591 <table>
13592 <tr>
13593 <td>ab
13594 </td></tr></table>
13595
13596 !!end
13597
13598 !!test
13599 Templates: Wiki Tables: 4. Templated tags, no content
13600 !! wikitext
13601 {{tbl-start}}
13602 {{tbl-end}}
13603 !! html
13604 <table>
13605 <tr><td></td></tr></table>
13606
13607 !!end
13608
13609 !!test
13610 Templates: Wiki Tables: 5. Templated tags, regular td-tags
13611 !! wikitext
13612 {{tbl-start}}
13613 |foo
13614 {{tbl-end}}
13615 !! html
13616 <table>
13617 <tr>
13618 <td>foo
13619 </td></tr></table>
13620
13621 !!end
13622
13623 !!test
13624 Templates: Wiki Tables: 6. Templated tags, templated td-tags
13625 !! wikitext
13626 {{tbl-start}}
13627 {{!}}foo
13628 {{tbl-end}}
13629 !! html
13630 <table>
13631 <tr>
13632 <td>foo
13633 </td></tr></table>
13634
13635 !!end
13636
13637 ## This test case is very specific to Parsoid's internals
13638 ## and is hence only tested for Parsoid's code. Parsoid uses
13639 ## a <meta> marker tag for <ref> tags and they are expanded
13640 ## much later. We are verifying that this <meta> tag usage
13641 ## doesn't prevent foster parenting.
13642 !! test
13643 Templates: Wiki Tables: 7. Fosterable <ref>s should get fostered
13644 !! wikitext
13645 {{PartialTable}}<ref>foo</ref>
13646 |}
13647
13648 <references />
13649 !! html/parsoid
13650 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"PartialTable","href":"./Template:PartialTable"},"params":{},"i":0}},"&lt;ref>foo&lt;/ref>\n|}"]}'><sup about="#mwt3" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{},"body":{"id":"mw-reference-text-cite_note-1"}}'><a href="./Main_Page#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup></p><table about="#mwt2">
13651 <tbody>
13652 </tbody></table>
13653
13654 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">foo</span></li></ol>
13655 !! end
13656
13657 !! test
13658 Templates: Wiki Tables: 8. Fosterable meta-tags should get fostered
13659 !! wikitext
13660 {{echo|
13661 {{{!}}
13662 {{!}}-}}
13663 <onlyinclude>
13664 |foo
13665 </onlyinclude>
13666 {{!}}}
13667 !! html/parsoid
13668 <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{{!}}}"]}'>
13669 </span><meta typeof="mw:Includes/OnlyInclude" about="#mwt1"/><table about="#mwt1">
13670 <tbody><tr>
13671
13672 <td>foo
13673 <meta typeof="mw:Includes/OnlyInclude/End"/></td></tr>
13674 </tbody></table>
13675 !! end
13676
13677 !!test
13678 Templates: Lists: Multi-line list-items via templates
13679 !! wikitext
13680 *{{echo|a {{nonexistent|
13681 unused}}}}
13682 *{{echo|b {{nonexistent|
13683 unused}}}}
13684 !! html
13685 <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>
13686 <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>
13687
13688 !!end
13689
13690 !!test
13691 Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo)
13692 !! wikitext
13693 {{echo|''a}}{{echo|b''c''d}}{{echo|''e}}
13694 !! html
13695 <p><i>ab</i>c<i>d</i>e
13696 </p>
13697 !!end
13698
13699 !!test
13700 Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span)
13701 (PHP parser generates misnested html)
13702 !! wikitext
13703 {{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}}
13704 !! html/parsoid
13705 <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>
13706 !!end
13707
13708 !!test
13709 Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div)
13710 (PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s)
13711 !! options
13712 parsoid=wt2html,wt2wt
13713 !! wikitext
13714 {{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}}
13715 !! html/php+tidy
13716 <div><i>a</i></div><div><i>b</i>c<i>d</i></div><div>e</div>
13717 !! html/parsoid
13718 <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>
13719 <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>
13720 <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>
13721 !!end
13722
13723 !!test
13724 Templates: Ugly nesting: 4. Divs opened/closed across templates
13725 !! wikitext
13726 a<div>b{{echo|c</div>d}}e
13727 !! html
13728 a<div>bc</div>de
13729
13730 !! html+tidy
13731 <p>a</p><div>bc</div><p>de
13732 </p>
13733 !! end
13734
13735 !! test
13736 Templates: Ugly templates: 3. newline-only template parameter
13737 !! wikitext
13738 foo {{echo|
13739 }}
13740 !! html
13741 <p>foo
13742 </p>
13743 !! end
13744
13745 # This looks like a bug: a single newline triggers p/br for some reason.
13746 !! test
13747 Templates: Ugly templates: 4. newline-only template parameter inconsistency
13748 !! wikitext
13749 {{echo|
13750 }}
13751 !! html
13752 <p><br />
13753 </p>
13754 !! end
13755
13756 # T66017 -- ugly wikitext with fostered content generates two template ranges that
13757 # have a true overlap (T1-start - T2-start - T1-end - T2-end).
13758 !! test
13759 Templates: Ugly templates: 5. Template encapsulation test: Non-trivial overlap of template ranges is properly handled
13760 !! wikitext
13761 {{echo|<table>}}
13762 {{echo|<div>foo}}
13763 {{echo|</table>}}
13764 !! html/parsoid
13765 <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">
13766 </span><table about="#mwt1">
13767 </table>
13768 !! end
13769
13770 # T66017 -- ugly wikitext with fostered content generates two template ranges
13771 # that are "identical" and generate nesting cycles in the algorithm
13772 !! test
13773 Templates: Ugly templates: 6. Template encapsulation test: Cyclical nesting of template ranges is properly handled
13774 !! wikitext
13775 {{echo|<table><tr><td><table>}}
13776 {{echo|<div>}}
13777 {{echo|</div>}}
13778 !! html/parsoid
13779 <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"}'>
13780 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13781 </table></td></tr></tbody></table>
13782 !! end
13783
13784 !! test
13785 Templates: Parameters substituted at the top-level
13786 !! wikitext
13787 {{{foo|''who'' {{echo|me}}? '''never!'''}}}
13788
13789 {{{foo|bar|baz}}}
13790 !! html/php
13791 <p><i>who</i> me? <b>never!</b>
13792 </p><p>bar
13793 </p>
13794 !! html/parsoid
13795 <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>
13796
13797 <p about="#mwt3" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"foo"},"params":{"1":{"wt":"bar"},"2":{"wt":"baz"}},"i":0}}]}'>bar</p>
13798 !! end
13799
13800 !! test
13801 Templates: Param with empty arg in the final position
13802 !! wikitext
13803 {{{hi|}}}
13804 !! html/parsoid
13805 <span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"hi"},"params":{"1":{"wt":""}},"i":0}}]}'></span>
13806 !! end
13807
13808 !!test
13809 Parser Functions: 1. Simple example
13810 !! wikitext
13811 {{uc:foo}}
13812 !! html
13813 <p>FOO
13814 </p>
13815 !!end
13816
13817 !!test
13818 Parser Functions: 2. Nested use (only outermost should be marked up)
13819 !! wikitext
13820 {{uc:{{lc:FOO}}}}
13821 !! html
13822 <p>FOO
13823 </p>
13824 !!end
13825
13826 ## Note that the templates inside the references are not wrapped
13827 !! test
13828 Template nested in extension tag in template
13829 !! options
13830 language=zh
13831 !! wikitext
13832 {{echo|hi<ref>[[ho|{{echo|hi}}]]</ref>}}
13833 {{echo|hi<ref>[http://test.com?q={{echo|ho}}]</ref>}}
13834 {{echo|hi<ref>-{ho|{{echo|hi}}}-</ref>}}
13835 <references />
13836 !! html/parsoid
13837 <p><span about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi&lt;ref>[[ho|{{echo|hi}}]]&lt;/ref>"}},"i":0}}]}'>hi</span><sup about="#mwt2" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{},"body":{"id":"mw-reference-text-cite_note-1"}}'><a href="./Wikipedia:首页#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup>
13838 <span about="#mwt8" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi&lt;ref>[http://test.com?q={{echo|ho}}]&lt;/ref>"}},"i":0}}]}'>hi</span><sup about="#mwt8" class="mw-ref" id="cite_ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{},"body":{"id":"mw-reference-text-cite_note-2"}}'><a href="./Wikipedia:首页#cite_note-2" style="counter-reset: mw-Ref 2;"><span class="mw-reflink-text">[2]</span></a></sup>
13839 <span about="#mwt13" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi&lt;ref>-{ho|{{echo|hi}}}-&lt;/ref>"}},"i":0}}]}'>hi</span><sup about="#mwt13" class="mw-ref" id="cite_ref-3" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{},"body":{"id":"mw-reference-text-cite_note-3"}}'><a href="./Wikipedia:首页#cite_note-3" style="counter-reset: mw-Ref 3;"><span class="mw-reflink-text">[3]</span></a></sup></p>
13840 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt17" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Wikipedia:首页#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text"><a rel="mw:WikiLink" href="./Ho" title="Ho">hi</a></span></li><li about="#cite_note-2" id="cite_note-2"><a href="./Wikipedia:首页#cite_ref-2" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-2" class="mw-reference-text"><a rel="mw:ExtLink" class="external autonumber" href="http://test.com?q=ho"></a></span></li><li about="#cite_note-3" id="cite_note-3"><a href="./Wikipedia:首页#cite_ref-3" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-3" class="mw-reference-text"><span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["ho"],"t":"hi"}}'></span></span></li></ol>
13841 !! end
13842
13843 ###
13844 ### Pre-save transform tests
13845 ###
13846
13847 !! test
13848 pre-save transform: subst:
13849 !! options
13850 pst
13851 !! wikitext
13852 {{subst:test}}
13853 !! html/php
13854 This is a test template
13855 !! end
13856
13857 !! test
13858 pre-save transform: normal template
13859 !! options
13860 pst
13861 !! wikitext
13862 {{test}}
13863 !! html/php
13864 {{test}}
13865 !! end
13866
13867 !! test
13868 pre-save transform: nonexistent template
13869 !! options
13870 pst
13871 !! wikitext
13872 {{thistemplatedoesnotexist}}
13873 !! html/php
13874 {{thistemplatedoesnotexist}}
13875 !! end
13876
13877 !! test
13878 pre-save transform: subst magic variables
13879 !! options
13880 pst
13881 !! wikitext
13882 {{subst:SITENAME}}
13883 !! html/php
13884 MediaWiki
13885 !! end
13886
13887 # This is T2089, which I fixed. -- wtm
13888 !! test
13889 pre-save transform: subst: templates with parameters
13890 !! options
13891 pst
13892 !! wikitext
13893 {{subst:paramtest|param="something else"}}
13894 !! html/php
13895 This is a test template with parameter "something else"
13896 !! end
13897
13898 !! article
13899 Template:nowikitest
13900 !! text
13901 <nowiki>'''not wiki'''</nowiki>
13902 !! endarticle
13903
13904 !! test
13905 pre-save transform: nowiki in subst (T3188)
13906 !! options
13907 pst
13908 !! wikitext
13909 {{subst:nowikitest}}
13910 !! html/php
13911 <nowiki>'''not wiki'''</nowiki>
13912 !! end
13913
13914 !! article
13915 Template:commenttest
13916 !! text
13917 This template has <!-- a comment --> in it.
13918 !! endarticle
13919
13920 !! test
13921 pre-save transform: comment in subst (T3936)
13922 !! options
13923 pst
13924 !! wikitext
13925 {{subst:commenttest}}
13926 !! html/php
13927 This template has <!-- a comment --> in it.
13928 !! end
13929
13930 !! test
13931 pre-save transform: unclosed tag
13932 !! options
13933 pst
13934 !! wikitext
13935 <nowiki>'''not wiki'''
13936 !! html/php
13937 <nowiki>'''not wiki'''
13938 !! end
13939
13940 !! test
13941 pre-save transform: mixed tag case
13942 !! options
13943 pst
13944 !! wikitext
13945 <NOwiki>'''not wiki'''</noWIKI>
13946 !! html/php
13947 <NOwiki>'''not wiki'''</noWIKI>
13948 !! end
13949
13950 !! test
13951 pre-save transform: unclosed comment in <nowiki>
13952 !! options
13953 pst
13954 !! wikitext
13955 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13956 !! html/php
13957 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13958 !!end
13959
13960 # Leading @ in this template definition works around a limitation
13961 # in parsoid's parserTests which otherwise strips the <span> from the
13962 # result (confusing it for a template wrapper)
13963 !! article
13964 Template:dangerous
13965 !!text
13966 @<span onmouseover="alert('crap')">Oh no</span>
13967 !!endarticle
13968
13969 !!test
13970 (confirming safety of fix for subst T3936)
13971 !! wikitext
13972 {{Template:dangerous}}
13973 !! html
13974 <p>@<span>Oh no</span>
13975 </p>
13976 !! end
13977
13978 !! test
13979 pre-save transform: comment containing gallery (T7024)
13980 !! options
13981 pst
13982 !! wikitext
13983 <!-- <gallery>data</gallery> -->
13984 !! html/php
13985 <!-- <gallery>data</gallery> -->
13986 !!end
13987
13988 !! test
13989 pre-save transform: comment containing extension
13990 !! options
13991 pst
13992 !! wikitext
13993 <!-- <tag>data</tag> -->
13994 !! html/php
13995 <!-- <tag>data</tag> -->
13996 !!end
13997
13998 !! test
13999 pre-save transform: comment containing nowiki
14000 !! options
14001 pst
14002 !! wikitext
14003 <!-- <nowiki>data</nowiki> -->
14004 !! html/php
14005 <!-- <nowiki>data</nowiki> -->
14006 !!end
14007
14008 !! test
14009 pre-save transform: <noinclude> in subst (T5298)
14010 !! options
14011 pst
14012 !! wikitext
14013 {{subst:Includes}}
14014 !! html/php
14015 Foobar
14016 !! end
14017
14018 !! test
14019 pre-save transform: <onlyinclude> in subst (T5298)
14020 !! options
14021 pst
14022 !! wikitext
14023 {{subst:Includes2}}
14024 !! html/php
14025 Foo
14026 !! end
14027
14028 !! article
14029 Template:SubstTest
14030 !!text
14031 {{<includeonly>subst:</includeonly>Includes}}
14032 !! endarticle
14033
14034 !! article
14035 Template:SafeSubstTest
14036 !! text
14037 {{<includeonly>safesubst:</includeonly>Includes}}
14038 !! endarticle
14039
14040 !! test
14041 T24297: safesubst: works during PST
14042 !! options
14043 pst
14044 !! wikitext
14045 {{subst:SafeSubstTest}}{{safesubst:SubstTest}}
14046 !! html/php
14047 FoobarFoobar
14048 !! end
14049
14050 !! test
14051 T24297: safesubst: works during normal parse
14052 !! wikitext
14053 {{SafeSubstTest}}
14054 !! html
14055 <p>Foobar
14056 </p>
14057 !! end
14058
14059 !! test
14060 subst: does not work during normal parse
14061 !! wikitext
14062 {{SubstTest}}
14063 !! html
14064 <p>{{subst:Includes}}
14065 </p>
14066 !! end
14067
14068 !! test
14069 pre-save transform: context links ("pipe trick")
14070 !! options
14071 pst
14072 !! wikitext
14073 [[Article (context)|]]
14074 [[Bar:Article|]]
14075 [[:Bar:Article|]]
14076 [[Bar:Article (context)|]]
14077 [[:Bar:Article (context)|]]
14078 [[|Article]]
14079 [[|Article (context)]]
14080 [[Bar:X (Y) Z|]]
14081 [[:Bar:X (Y) Z|]]
14082 !! html/php
14083 [[Article (context)|Article]]
14084 [[Bar:Article|Article]]
14085 [[:Bar:Article|Article]]
14086 [[Bar:Article (context)|Article]]
14087 [[:Bar:Article (context)|Article]]
14088 [[Article]]
14089 [[Article (context)]]
14090 [[Bar:X (Y) Z|X (Y) Z]]
14091 [[:Bar:X (Y) Z|X (Y) Z]]
14092 !! end
14093
14094 !! test
14095 pre-save transform: context links ("pipe trick") with interwiki prefix
14096 !! options
14097 pst
14098 !! wikitext
14099 [[interwiki:Article|]]
14100 [[:interwiki:Article|]]
14101 [[interwiki:Bar:Article|]]
14102 [[:interwiki:Bar:Article|]]
14103 !! html/php
14104 [[interwiki:Article|Article]]
14105 [[:interwiki:Article|Article]]
14106 [[interwiki:Bar:Article|Bar:Article]]
14107 [[:interwiki:Bar:Article|Bar:Article]]
14108 !! end
14109
14110 !! test
14111 pre-save transform: context links ("pipe trick") with parens in title
14112 !! options
14113 pst title=[[Somearticle (context)]]
14114 !! wikitext
14115 [[|Article]]
14116 !! html/php
14117 [[Article (context)|Article]]
14118 !! end
14119
14120 !! test
14121 pre-save transform: context links ("pipe trick") with comma in title
14122 !! options
14123 pst title=[[Someplace, Somewhere]]
14124 !! wikitext
14125 [[|Otherplace]]
14126 [[Otherplace, Elsewhere|]]
14127 [[Otherplace, Elsewhere, Anywhere|]]
14128 !! html/php
14129 [[Otherplace, Somewhere|Otherplace]]
14130 [[Otherplace, Elsewhere|Otherplace]]
14131 [[Otherplace, Elsewhere, Anywhere|Otherplace]]
14132 !! end
14133
14134 !! test
14135 pre-save transform: context links ("pipe trick") with parens and comma
14136 !! options
14137 pst title=[[Someplace (IGNORED), Somewhere]]
14138 !! wikitext
14139 [[|Otherplace]]
14140 [[Otherplace (place), Elsewhere|]]
14141 !! html/php
14142 [[Otherplace, Somewhere|Otherplace]]
14143 [[Otherplace (place), Elsewhere|Otherplace]]
14144 !! end
14145
14146 !! test
14147 pre-save transform: context links ("pipe trick") with comma and parens
14148 !! options
14149 pst title=[[Who, me? (context)]]
14150 !! wikitext
14151 [[|Yes, you.]]
14152 [[Me, Myself, and I (1937 song)|]]
14153 !! html/php
14154 [[Yes, you. (context)|Yes, you.]]
14155 [[Me, Myself, and I (1937 song)|Me, Myself, and I]]
14156 !! end
14157
14158 !! test
14159 pre-save transform: context links ("pipe trick") with namespace
14160 !! options
14161 pst title=[[Ns:Somearticle]]
14162 !! wikitext
14163 [[|Article]]
14164 !! html/php
14165 [[Ns:Article|Article]]
14166 !! end
14167
14168 !! test
14169 pre-save transform: context links ("pipe trick") with namespace and parens
14170 !! options
14171 pst title=[[Ns:Somearticle (context)]]
14172 !! wikitext
14173 [[|Article]]
14174 !! html/php
14175 [[Ns:Article (context)|Article]]
14176 !! end
14177
14178 !! test
14179 pre-save transform: context links ("pipe trick") with namespace and comma
14180 !! options
14181 pst title=[[Ns:Somearticle, Context, Whatever]]
14182 !! wikitext
14183 [[|Article]]
14184 !! html/php
14185 [[Ns:Article, Context, Whatever|Article]]
14186 !! end
14187
14188 !! test
14189 pre-save transform: context links ("pipe trick") with namespace, comma and parens
14190 !! options
14191 pst title=[[Ns:Somearticle, Context (context)]]
14192 !! wikitext
14193 [[|Article]]
14194 !! html/php
14195 [[Ns:Article (context)|Article]]
14196 !! end
14197
14198 !! test
14199 pre-save transform: context links ("pipe trick") with namespace, parens and comma
14200 !! options
14201 pst title=[[Ns:Somearticle (IGNORED), Context]]
14202 !! wikitext
14203 [[|Article]]
14204 !! html/php
14205 [[Ns:Article, Context|Article]]
14206 !! end
14207
14208 !! test
14209 pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, T32149)
14210 !! options
14211 pst
14212 !! wikitext
14213 [[Article(context)|]]
14214 [[Bar:Article(context)|]]
14215 [[:Bar:Article(context)|]]
14216 [[|Article(context)]]
14217 [[Bar:X(Y)Z|]]
14218 [[:Bar:X(Y)Z|]]
14219 !! html/php
14220 [[Article(context)|Article]]
14221 [[Bar:Article(context)|Article]]
14222 [[:Bar:Article(context)|Article]]
14223 [[Article(context)]]
14224 [[Bar:X(Y)Z|X(Y)Z]]
14225 [[:Bar:X(Y)Z|X(Y)Z]]
14226 !! end
14227
14228 !! test
14229 pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, T32149)
14230 !! options
14231 pst
14232 !! wikitext
14233 [[Article (context)|]]
14234 [[Bar:Article (context)|]]
14235 [[:Bar:Article (context)|]]
14236 [[|Article (context)]]
14237 [[Bar:X (Y) Z|]]
14238 [[:Bar:X (Y) Z|]]
14239 !! html/php
14240 [[Article (context)|Article]]
14241 [[Bar:Article (context)|Article]]
14242 [[:Bar:Article (context)|Article]]
14243 [[Article (context)]]
14244 [[Bar:X (Y) Z|X (Y) Z]]
14245 [[:Bar:X (Y) Z|X (Y) Z]]
14246 !! end
14247
14248 !! test
14249 pre-save transform: context links ("pipe trick") with parens and no space (Korean style, T32149)
14250 !! options
14251 pst
14252 !! wikitext
14253 [[Article(context)|]]
14254 [[Bar:Article(context)|]]
14255 [[:Bar:Article(context)|]]
14256 [[|Article(context)]]
14257 [[Bar:X(Y)Z|]]
14258 [[:Bar:X(Y)Z|]]
14259 !! html/php
14260 [[Article(context)|Article]]
14261 [[Bar:Article(context)|Article]]
14262 [[:Bar:Article(context)|Article]]
14263 [[Article(context)]]
14264 [[Bar:X(Y)Z|X(Y)Z]]
14265 [[:Bar:X(Y)Z|X(Y)Z]]
14266 !! end
14267
14268 !! test
14269 pre-save transform: context links ("pipe trick") with commas (T23660)
14270 !! options
14271 pst
14272 !! wikitext
14273 [[Article (context), context|]]
14274 [[Article (context),context|]]
14275 [[Bar:Article (context), context|]]
14276 [[Bar:Article (context),context|]]
14277 [[:Bar:Article (context), context|]]
14278 [[:Bar:Article (context),context|]]
14279 !! html/php
14280 [[Article (context), context|Article]]
14281 [[Article (context),context|Article]]
14282 [[Bar:Article (context), context|Article]]
14283 [[Bar:Article (context),context|Article]]
14284 [[:Bar:Article (context), context|Article]]
14285 [[:Bar:Article (context),context|Article]]
14286 !! end
14287
14288 !! test
14289 Parsoid: backwards pipe trick
14290 !! wikitext
14291 [[|'''bar''']]
14292 !! html/php
14293 <p>[[|<b>bar</b>]]
14294 </p>
14295 !! html/parsoid
14296 <p>[[|<b>bar</b>]]</p>
14297 !! end
14298
14299 !! test
14300 pre-save transform: trim trailing empty lines
14301 !! options
14302 pst
14303 !! wikitext
14304 Empty lines are trimmed
14305
14306
14307
14308
14309 !! html/php
14310 Empty lines are trimmed
14311 !! end
14312
14313 !! test
14314 pre-save transform: Signature expansion
14315 !! options
14316 pst
14317 !! wikitext
14318 * ~~~
14319 * ~~~~
14320 * ~~~~~
14321 * <noinclude>~~~</noinclude>
14322 * <includeonly>~~~</includeonly>
14323 * <onlyinclude>~~~</onlyinclude>
14324 !! html/php
14325 * [[Special:Contributions/127.0.0.1|127.0.0.1]]
14326 * [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
14327 * 00:02, 1 January 1970 (UTC)
14328 * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
14329 * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
14330 * <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>
14331 !! end
14332
14333
14334 !! test
14335 ParserOutput flags from signature expansion (T84843)
14336 !! options
14337 pst
14338 showflags
14339 !! wikitext
14340 ~~~~
14341 !! html/php
14342 [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
14343 flags=user-signature
14344 !! end
14345
14346
14347 !! test
14348 pre-save transform: Signature expansion in nowiki tags (T2093)
14349 !! options
14350 pst disabled
14351 !! wikitext
14352 Shall not expand:
14353
14354 <nowiki>~~~~</nowiki>
14355
14356 <includeonly><nowiki>~~~~</nowiki></includeonly>
14357
14358 <noinclude><nowiki>~~~~</nowiki></noinclude>
14359
14360 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14361
14362 {{subst:Foo}} shall be converted to FOO
14363
14364 As well as inside noinclude/onlyinclude
14365 <noinclude>{{subst:Foo}}</noinclude>
14366 <onlyinclude>{{subst:Foo}}</onlyinclude>
14367
14368 But not inside includeonly
14369 <includeonly>{{subst:Foo}}</includeonly>
14370 !! html/php
14371 Shall not expand:
14372
14373 <nowiki>~~~~</nowiki>
14374
14375 <includeonly><nowiki>~~~~</nowiki></includeonly>
14376
14377 <noinclude><nowiki>~~~~</nowiki></noinclude>
14378
14379 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14380
14381 FOO shall be converted to FOO
14382
14383 As well as inside noinclude/onlyinclude
14384 <noinclude>FOO</noinclude>
14385 <onlyinclude>FOO</onlyinclude>
14386
14387 But not inside includeonly
14388 <includeonly>{{subst:Foo}}</includeonly>
14389 !! end
14390
14391 !! test
14392 Parsoid: Recognize nowiki with trailing space in tags
14393 !! options
14394 parsoid=wt2html
14395 !! wikitext
14396 <nowiki ><div>[[foo]]</nowiki >
14397
14398 a<nowiki / >b
14399
14400 c<nowiki />d
14401
14402 e<nowiki/ >f
14403 !! html/php+tidy
14404 <p>&lt;div&gt;[[foo]]
14405 </p><p>a&lt;nowiki / &gt;b
14406 </p><p>cd
14407 </p><p>e&lt;nowiki/ &gt;f
14408 </p>
14409 !! html/parsoid
14410 <p><span typeof="mw:Nowiki">&lt;div>[[foo]]</span></p>
14411
14412 <p>a&lt;nowiki / >b</p>
14413
14414 <p>c<span typeof="mw:Nowiki"></span>d</p>
14415
14416 <p>e&lt;nowiki/ >f</p>
14417 !! end
14418
14419 !! test
14420 Parsoid: Recognize nowiki with odd capitalization
14421 !! options
14422 parsoid=wt2html
14423 !! wikitext
14424 <noWikI ><div>[[foo]]</Nowiki >
14425 !! html/php+tidy
14426 <p>&lt;div&gt;[[foo]]
14427 </p>
14428 !! html/parsoid
14429 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
14430 !! end
14431
14432
14433 !! test
14434 Parsoid: Escape nowiki with trailing space in tags
14435 !! options
14436 parsoid=html2wt
14437 !! html/parsoid
14438 <p>&lt;nowiki &gt; foo &lt/nowiki ></p>
14439 <p>a&lt;nowiki /&gt;b</p>
14440 <p>c&lt;nowiki/ &gt;d</p>
14441 !! wikitext
14442 &lt;nowiki &gt; foo &lt;/nowiki &gt;
14443
14444 a&lt;nowiki /&gt;b
14445
14446 c&lt;nowiki/ &gt;d
14447 !! end
14448
14449 !! test
14450 Parsoid: Escape weird noWikI capitalizations
14451 !! options
14452 parsoid=html2wt
14453 !! html/parsoid
14454 <p>&lt;noWikI &gt; foo &lt/NoWikI ></p>
14455 !! wikitext
14456 &lt;noWikI &gt; foo &lt;/NoWikI &gt;
14457 !! end
14458
14459 ###
14460 ### Message transform tests
14461 ###
14462 !! test
14463 message transform: magic variables
14464 !! options
14465 msg
14466 !! wikitext
14467 {{SITENAME}}
14468 !! html
14469 MediaWiki
14470 !! end
14471
14472 !! test
14473 message transform: should not transform wiki markup
14474 !! options
14475 msg
14476 !! wikitext
14477 ''test''
14478 !! html
14479 ''test''
14480 !! end
14481
14482 !! test
14483 message transform: <noinclude> in transcluded template (T6926)
14484 !! options
14485 msg
14486 !! wikitext
14487 {{Includes}}
14488 !! html
14489 Foobar
14490 !! end
14491
14492 !! test
14493 message transform: <onlyinclude> in transcluded template (T6926)
14494 !! options
14495 msg
14496 !! wikitext
14497 {{Includes2}}
14498 !! html
14499 Foo
14500 !! end
14501
14502 !! test
14503 {{#special:}} page name, known
14504 !! options
14505 msg
14506 !! wikitext
14507 {{#special:Recentchanges}}
14508 !! html
14509 Special:RecentChanges
14510 !! end
14511
14512 !! test
14513 {{#special:}} page name with subpage, known
14514 !! options
14515 msg
14516 !! wikitext
14517 {{#special:Recentchanges/param}}
14518 !! html
14519 Special:RecentChanges/param
14520 !! end
14521
14522 !! test
14523 {{#special:}} page name, unknown
14524 !! options
14525 msg
14526 !! wikitext
14527 {{#special:foobar nonexistent}}
14528 !! html
14529 Special:Foobar nonexistent
14530 !! end
14531
14532 !! test
14533 {{#speciale:}} page name, known
14534 !! options
14535 msg
14536 !! wikitext
14537 {{#speciale:Recentchanges}}
14538 !! html
14539 Special:RecentChanges
14540 !! end
14541
14542 !! test
14543 {{#speciale:}} page name with subpage, known
14544 !! options
14545 msg
14546 !! wikitext
14547 {{#speciale:Recentchanges/param}}
14548 !! html
14549 Special:RecentChanges/param
14550 !! end
14551
14552 !! test
14553 {{#speciale:}} page name, unknown
14554 !! options
14555 msg
14556 !! wikitext
14557 {{#speciale:foobar nonexistent}}
14558 !! html
14559 Special:Foobar_nonexistent
14560 !! end
14561
14562 ###
14563 ### Images
14564 ###
14565 ### For Parsoid-specific tests, see
14566 #### https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
14567
14568 !! test
14569 Simple image
14570 !! options
14571 parsoid=wt2html,wt2wt,html2html
14572 !! wikitext
14573 [[Image:foobar.jpg]]
14574 !! html/php
14575 <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>
14576 </p>
14577 !! html/parsoid
14578 <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>
14579 !! end
14580
14581 !! test
14582 Serialize simple image with span wrapper
14583 !! options
14584 parsoid=html2wt
14585 !! html/parsoid
14586 <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>
14587 !! wikitext
14588 [[File:Foobar.jpg]]
14589 !! end
14590
14591 !! test
14592 Simple image (using File: namespace, now canonical)
14593 !! wikitext
14594 [[File:Foobar.jpg]]
14595 !! html/php
14596 <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>
14597 </p>
14598 !! html/parsoid
14599 <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>
14600 !! end
14601
14602 !! test
14603 Right-aligned image
14604 !! wikitext
14605 [[File:Foobar.jpg|right]]
14606 !! html/php
14607 <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>
14608
14609 !! html/parsoid
14610 <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>
14611 !! end
14612
14613 !! test
14614 Image with caption
14615 !! wikitext
14616 [[File:Foobar.jpg|right|Caption text]]
14617 !! html/php
14618 <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>
14619
14620 !! html/parsoid
14621 <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>
14622 !! end
14623
14624 !! test
14625 Image with caption, T55312 #1
14626 !! wikitext
14627 [[File:Foobar.jpg|right|Caption page stuff]]
14628 !! html/php
14629 <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>
14630
14631 !! html/parsoid
14632 <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>
14633 !! end
14634
14635 !! test
14636 Image with caption, T55312 #2
14637 !! wikitext
14638 [[File:Foobar.jpg|right|Caption page=]]
14639 !! html/php
14640 <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>
14641
14642 !! html/parsoid
14643 <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>
14644 !! end
14645
14646 !! test
14647 Image with caption, T55312 #3
14648 !! wikitext
14649 [[File:Foobar.jpg|right|Caption page=stuff]]
14650 !! html/php
14651 <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>
14652
14653 !! html/parsoid
14654 <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>
14655 !! end
14656
14657 !! test
14658 Image caption with pipe entity
14659 !! wikitext
14660 [[File:Foobar.jpg|thumb|one &#x7C; two]]
14661 [[File:Foobar.jpg|thumb|one ''two'' &#x7C; three]]
14662 !! html/php
14663 <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>
14664 <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>
14665
14666 !! html/parsoid
14667 <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>
14668 <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>
14669 !! end
14670
14671 !! test
14672 Allow empty links in image captions (T62753)
14673 !! options
14674 thumbsize=220
14675 !! wikitext
14676 [[File:Foobar.jpg|thumb|Caption [[Link1]]
14677 [[]]
14678 [[Link2]]
14679 ]]
14680 !! html/php
14681 <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>
14682
14683 !! html/parsoid
14684 <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>
14685 [[]]
14686 <a rel="mw:WikiLink" href="./Link2" title="Link2" data-parsoid='{"stx":"simple","a":{"href":"./Link2"},"sa":{"href":"Link2"}}'>Link2</a>
14687 </figcaption></figure>
14688 !! end
14689
14690 !! test
14691 Titles in unlinked images (T23454)
14692 !! wikitext
14693 [[File:Foobar.jpg|link=|stuff]]
14694 !! html/php
14695 <p><img alt="stuff" src="http://example.com/images/3/3a/Foobar.jpg" title="stuff" width="1941" height="220" />
14696 </p>
14697 !! html/parsoid
14698 <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>
14699 !! end
14700
14701 !! test
14702 Link with empty target
14703 !! wikitext
14704 [[]]
14705 !! html
14706 <p>[[]]
14707 </p>
14708 !! end
14709
14710 !! test
14711 Image with link trail
14712 !! wikitext
14713 Linktrails should not work for images: [[File:Foobar.jpg]]s
14714 !! html/php
14715 <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
14716 </p>
14717 !! html/parsoid
14718 <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>
14719 !! end
14720
14721 !! test
14722 Image with empty attribute
14723 !! options
14724 parsoid=wt2html,wt2wt,html2html
14725 !! wikitext
14726 [[File:Foobar.jpg|right||Caption text]]
14727 !! html/php
14728 <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>
14729
14730 !! html/parsoid
14731 <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>
14732 !! end
14733
14734 !! test
14735 1. Block image with individual attributes from templates
14736 !! wikitext
14737 [[File:Foobar.jpg|thumb|{{echo|137px}}|This is a caption]]
14738 !! html/php
14739 <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>
14740
14741 !! html/parsoid
14742 <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>
14743 !! end
14744
14745 !! test
14746 2. Block Image with individual attributes from templates
14747 !! wikitext
14748 [[File:Foobar.jpg|{{echo|thumb}}|{{echo|137px}}|This is a caption]]
14749 !! html/php
14750 <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>
14751
14752 !! html/parsoid
14753 <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>
14754 !! end
14755
14756 !! test
14757 3. Inline image with individual attributes from templates
14758 !! wikitext
14759 [[File:Foobar.jpg|{{echo|50px}}]]
14760 !! html/php
14761 <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>
14762 </p>
14763 !! html/parsoid
14764 <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>
14765 !! end
14766
14767 ## Parsoid does not provide editing support for images where templates produce multiple image attributes.
14768 ## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
14769 !! test
14770 Image with multiple attributes from the same template
14771 !! wikitext
14772 [[File:Foobar.jpg|{{image_attribs}}]]
14773 !! html/php
14774 <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>
14775
14776 !! html/parsoid
14777 <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>
14778 !! end
14779
14780 !! test
14781 Image with link tails
14782 !! options
14783 thumbsize=220
14784 !! wikitext
14785 123[[File:Foobar.jpg]]456
14786 123[[File:Foobar.jpg|right]]456
14787 123[[File:Foobar.jpg|thumb]]456
14788 !! html/php
14789 <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
14790 </p>
14791 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
14792 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
14793
14794 !! html/php+tidy
14795 <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
14796 </p><p>
14797 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
14798 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
14799 </p>
14800 !! html/parsoid
14801 <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>
14802 <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
14803 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>
14804 !! end
14805
14806 !! test
14807 Image with multiple captions -- only last one is accepted
14808 !! wikitext
14809 [[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]]
14810 !! html/php
14811 <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>
14812
14813 !! html/parsoid
14814 <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>
14815 !! end
14816
14817 !! test
14818 Image with multiple widths -- use last
14819 !! wikitext
14820 [[File:Foobar.jpg|200px|300px|caption]]
14821 !! html/php
14822 <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>
14823 </p>
14824 !! html/parsoid
14825 <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>
14826 !! end
14827
14828 !! test
14829 Image with multiple alignments -- use first (T50664)
14830 !! options
14831 thumbsize=220
14832 !! wikitext
14833 [[File:Foobar.jpg|thumb|left|right|center|caption]]
14834
14835 [[File:Foobar.jpg|middle|text-top|caption]]
14836 !! html/php
14837 <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>
14838 <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>
14839 </p>
14840 !! html/parsoid
14841 <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>
14842 <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>
14843 !! end
14844
14845 !! test
14846 Image with width attribute at different positions
14847 !! wikitext
14848 [[File:Foobar.jpg|200px|right|Caption]]
14849 [[File:Foobar.jpg|right|200px|Caption]]
14850 [[File:Foobar.jpg|right|Caption|200px]]
14851 !! html/php
14852 <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>
14853 <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>
14854 <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>
14855
14856 !! html/parsoid
14857 <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>
14858 <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>
14859 <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>
14860 !! end
14861
14862 # a sad bit of backward-compatibility
14863 !! test
14864 Image with size specified with pxpx (T15500, T53628)
14865 !! options
14866 parsoid=wt2html,wt2wt,html2html
14867 !! wikitext
14868 [[File:Foobar.jpg|20pxpx]]
14869 [[File:Foobar.jpg|200x20pxpx]]
14870 !! html/php
14871 <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>
14872 <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>
14873 </p>
14874 !! html/parsoid
14875 <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>
14876 !! end
14877
14878 !! test
14879 Image with link parameter, wiki target
14880 !! wikitext
14881 [[File:Foobar.jpg|link=Main Page]]
14882 !! html/php
14883 <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>
14884 </p>
14885 !! html/parsoid
14886 <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>
14887 !! end
14888
14889 # parsoid T51293 (part 1)
14890 !! test
14891 Image with link parameter, URL target
14892 !! wikitext
14893 [[File:Foobar.jpg|link=http://example.com/]]
14894 !! html/php
14895 <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>
14896 </p>
14897 !! html/parsoid
14898 <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>
14899 !! end
14900
14901 # parsoid T51293 (part 2)
14902 !! test
14903 Image with link parameter, protocol-less URL target
14904 !! wikitext
14905 [[File:Foobar.jpg|link=//example.com/]]
14906 !! html/php
14907 <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>
14908 </p>
14909 !! html/parsoid
14910 <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>
14911 !! end
14912
14913 !! test
14914 Escaping non-block captions (T107435)
14915 !! options
14916 parsoid={
14917 "modes": ["wt2wt"],
14918 "changes": [
14919 ["[typeof~='mw:Image']", "attr", "data-mw", "{\"caption\": \"|\"}"]
14920 ]
14921 }
14922 !! wikitext
14923 [[Image:Foobar.jpg|caption]]
14924 !! wikitext/edited
14925 [[Image:Foobar.jpg|<nowiki>|</nowiki>]]
14926 !! end
14927
14928 # wgExternalLinkTarget not supported by Parsoid
14929 !! test
14930 Image with link parameter, wgExternalLinkTarget
14931 !! wikitext
14932 [[Image:foobar.jpg|link=http://example.com/]]
14933 !! config
14934 wgExternalLinkTarget='foobar'
14935 !! html/php
14936 <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>
14937 </p>
14938 !! end
14939
14940 !! test
14941 Image with link parameter, wgNoFollowLinks set to false
14942 !! wikitext
14943 [[Image:foobar.jpg|link=http://example.com/]]
14944 !! config
14945 wgNoFollowLinks=false
14946 !! html/php
14947 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14948 </p>
14949 !! end
14950
14951 !! test
14952 Image with link parameter, wgNoFollowDomainExceptions
14953 !! wikitext
14954 [[Image:foobar.jpg|link=http://example.com/]]
14955 !! config
14956 wgNoFollowDomainExceptions='example.com'
14957 !! html/php
14958 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14959 </p>
14960 !! end
14961
14962 # wgExternalLinkTarget not supported by Parsoid
14963 !! test
14964 Image with link parameter, wgExternalLinkTarget, unnamed parameter
14965 !! wikitext
14966 [[Image:foobar.jpg|link=http://example.com/|Title]]
14967 !! config
14968 wgExternalLinkTarget='foobar'
14969 !! html/php
14970 <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>
14971 </p>
14972 !! end
14973
14974 !! test
14975 Image with empty link parameter
14976 !! wikitext
14977 [[File:Foobar.jpg|link=]]
14978 !! html/php
14979 <p><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" />
14980 </p>
14981 !! html/parsoid
14982 <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>
14983 !! end
14984
14985 !! test
14986 Image with link parameter (wiki target) and unnamed parameter
14987 !! wikitext
14988 [[File:Foobar.jpg|link=Main_Page|Title]]
14989 !! html/php
14990 <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>
14991 </p>
14992 !! html/parsoid
14993 <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>
14994 !! end
14995
14996 !! test
14997 Image with link parameter (URL target) and unnamed parameter
14998 !! wikitext
14999 [[File:Foobar.jpg|link=http://example.com/|Title]]
15000 !! html/php
15001 <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>
15002 </p>
15003 !! html/parsoid
15004 <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>
15005 !! end
15006
15007 !! test
15008 Thumbnail image with link parameter
15009 !! options
15010 thumbsize=220
15011 parsoid=wt2html,wt2wt,html2html
15012 !! wikitext
15013 [[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
15014 !! html/php
15015 <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>
15016
15017 !! html/parsoid
15018 <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>
15019 !! end
15020
15021 !! test
15022 Manually-specified thumbnail image
15023 !! options
15024 thumbsize=220
15025 !! wikitext
15026 [[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
15027 !! html/php
15028 <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>
15029
15030 !! html/parsoid
15031 <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>
15032 !! end
15033
15034 !! test
15035 Manually-specified thumbnail image with explicit link to wiki page
15036 !! options
15037 thumbsize=220
15038 parsoid=wt2html,wt2wt,html2html
15039 !! wikitext
15040 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
15041 !! html/php
15042 <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>
15043
15044 !! html/parsoid
15045 <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>
15046 !! end
15047
15048 !! test
15049 Manually-specified thumbnail image with explicit link to url
15050 !! options
15051 thumbsize=220
15052 parsoid=wt2html,wt2wt,html2html
15053 !! wikitext
15054 [[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
15055 !! html/php
15056 <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>
15057
15058 !! html/parsoid
15059 <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>
15060 !! end
15061
15062 !! test
15063 Manually-specified thumbnail image with explicit no link
15064 !! options
15065 thumbsize=220
15066 parsoid=wt2html,wt2wt,html2html
15067 !! wikitext
15068 [[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
15069 !! html/php
15070 <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>
15071
15072 !! html/parsoid
15073 <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>
15074 !! end
15075
15076 !! test
15077 Manually-specified thumbnail image with explicit link and alt text
15078 !! options
15079 thumbsize=220
15080 parsoid=wt2html,wt2wt,html2html
15081 !! wikitext
15082 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
15083 !! html/php
15084 <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>
15085
15086 !! html/parsoid
15087 <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>
15088 !! end
15089
15090 !! test
15091 Image with frame and link
15092 !! options
15093 parsoid=wt2html,wt2wt,html2html
15094 !! wikitext
15095 [[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
15096 !! html/php
15097 <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>
15098
15099 !! html/parsoid
15100 <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>
15101 !! end
15102
15103 !! test
15104 Image with frame and link and explicit alt
15105 !! options
15106 parsoid=wt2html,wt2wt,html2html
15107 !! wikitext
15108 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]]
15109 !! html/php
15110 <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>
15111
15112 !! html/parsoid
15113 <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>
15114 !! end
15115
15116 !! test
15117 Image with wiki markup in implicit alt
15118 !! wikitext
15119 [[Image:Foobar.jpg|testing '''bold''' in alt]]
15120
15121 [[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
15122 !! html/php
15123 <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>
15124 </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>
15125 </p>
15126 !! html/parsoid
15127 <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>
15128
15129 <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>
15130 !! end
15131
15132 !! test
15133 Alt image option should handle most kinds of wikitext without barfing
15134 !! wikitext
15135 [[Image:Foobar.jpg|thumb|This is the image caption|alt=This is a [[link]] and a {{echo|''bold template''}}.]]
15136 !! html/php
15137 <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>
15138
15139 !! html/parsoid
15140 <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>
15141 !! end
15142
15143 !! test
15144 Ampersand in alt attribute (T206940)
15145 !! options
15146 parsoid = {
15147 "nativeGallery": true
15148 }
15149 !! wikitext
15150 [[File:Foobar.jpg|alt=&amp;amp;]]
15151
15152 <!-- consistency with gallery extension -->
15153 <gallery>
15154 File:Foobar.jpg|alt=&amp;amp;
15155 </gallery>
15156 !! html/php+tidy
15157 <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>
15158 </p>
15159 <ul class="gallery mw-gallery-traditional">
15160 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15161 <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>
15162 <div class="gallerytext">
15163 </div>
15164 </div></li>
15165 </ul>
15166 !! html/parsoid
15167 <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>
15168
15169 <!-- consistency with gallery extension -->
15170 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15171 <li class="gallerybox">
15172 <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>
15173 <div class="gallerytext"></div>
15174 </li>
15175 </ul>
15176 !! end
15177
15178 !! test
15179 Italics markup in alt attribute (T206940)
15180 !! wikitext
15181 [[File:Foobar.jpg|alt=''x''|caption]]
15182
15183 <!-- consistency with gallery extension -->
15184 <gallery>
15185 File:Foobar.jpg|alt=''x''|caption
15186 </gallery>
15187 !! html/php+tidy
15188 <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>
15189 </p>
15190 <ul class="gallery mw-gallery-traditional">
15191 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15192 <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>
15193 <div class="gallerytext">
15194 <p>caption
15195 </p>
15196 </div>
15197 </div></li>
15198 </ul>
15199 !! html/parsoid
15200 <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>
15201
15202 <!-- consistency with gallery extension -->
15203 <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"}}'>
15204 <li class="gallerybox">
15205 <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>
15206 <div class="gallerytext">caption</div>
15207 </li>
15208 </ul>
15209 !! end
15210
15211 !! test
15212 Nowiki markup in alt attribute (T206940)
15213 !! wikitext
15214 [[File:Foobar.jpg|alt=<nowiki>''</nowiki>x<nowiki>''</nowiki>|caption]]
15215
15216 <!-- consistency with gallery extension -->
15217 <gallery>
15218 File:Foobar.jpg|alt=<nowiki>''</nowiki>x<nowiki>''</nowiki>|caption
15219 </gallery>
15220 !! html/php+tidy
15221 <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>
15222 </p>
15223 <ul class="gallery mw-gallery-traditional">
15224 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15225 <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>
15226 <div class="gallerytext">
15227 <p>caption
15228 </p>
15229 </div>
15230 </div></li>
15231 </ul>
15232 !! html/parsoid
15233 <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>
15234
15235 <!-- consistency with gallery extension -->
15236 <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"}}'>
15237 <li class="gallerybox">
15238 <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>
15239 <div class="gallerytext">caption</div>
15240 </li>
15241 </ul>
15242 !! end
15243
15244 !! test
15245 Nowiki markup in alt attribute (edited html, no data-parsoid) (T206940)
15246 !! options
15247 parsoid = {
15248 "nativeGallery": true
15249 }
15250 !! wikitext
15251 [[File:Foobar.jpg|alt=<nowiki>''x''</nowiki>|caption]]
15252
15253 <!-- consistency with gallery extension -->
15254 <gallery>
15255 File:Foobar.jpg|alt=<nowiki>''x''</nowiki>|caption
15256 </gallery>
15257 !! html/php+tidy
15258 <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>
15259 </p>
15260 <ul class="gallery mw-gallery-traditional">
15261 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15262 <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>
15263 <div class="gallerytext">
15264 <p>caption
15265 </p>
15266 </div>
15267 </div></li>
15268 </ul>
15269 !! html/parsoid
15270 <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>
15271
15272 <!-- consistency with gallery extension -->
15273 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15274 <li class="gallerybox">
15275 <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>
15276 <div class="gallerytext">caption</div>
15277 </li>
15278 </ul>
15279 !! end
15280
15281 !! test
15282 Ampersand in link attribute (T206940)
15283 !! wikitext
15284 [[File:Foobar.jpg|link=Foo &amp; bar]]
15285
15286 <!-- consistency with gallery extension -->
15287 <gallery>
15288 File:Foobar.jpg|link=Foo &amp; bar
15289 </gallery>
15290 !! html/php+tidy
15291 <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>
15292 </p>
15293 <ul class="gallery mw-gallery-traditional">
15294 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15295 <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>
15296 <div class="gallerytext">
15297 </div>
15298 </div></li>
15299 </ul>
15300 !! html/parsoid
15301 <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>
15302
15303 <!-- consistency with gallery extension -->
15304 <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"}}'>
15305 <li class="gallerybox">
15306 <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>
15307 <div class="gallerytext"></div>
15308 </li>
15309 </ul>
15310 !! end
15311
15312 !! test
15313 Ampersand in link attribute (edited html, no data-parsoid) (T206940)
15314 !! options
15315 parsoid = {
15316 "nativeGallery": true
15317 }
15318 !! wikitext
15319 [[File:Foobar.jpg|link=Foo_&_bar]]
15320
15321 <!-- consistency with gallery extension -->
15322 <gallery>
15323 File:Foobar.jpg|link=Foo_&_bar
15324 </gallery>
15325 !! html/php+tidy
15326 <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>
15327 </p>
15328 <ul class="gallery mw-gallery-traditional">
15329 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15330 <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>
15331 <div class="gallerytext">
15332 </div>
15333 </div></li>
15334 </ul>
15335 !! html/parsoid
15336 <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>
15337
15338 <!-- consistency with gallery extension -->
15339 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15340 <li class="gallerybox">
15341 <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>
15342 <div class="gallerytext"></div>
15343 </li>
15344 </ul>
15345 !! end
15346
15347 !! test
15348 Italics markup in link attribute (T206940)
15349 !! wikitext
15350 [[Foo''s bar''s]]
15351
15352 <!-- Note that "italics" are stripped, even though this is a valid page title -->
15353 [[File:Foobar.jpg|link=Foo''s bar''s|caption1]]
15354
15355 [[File:Foobar.jpg|link=''Main Page''|caption2]]
15356
15357 <!-- consistency with gallery extension -->
15358 <gallery>
15359 File:Foobar.jpg|link=Foo''s bar''s|caption1
15360 File:Foobar.jpg|link=''Main Page''|caption2
15361 </gallery>
15362 !! html/php+tidy
15363 <p><a href="/wiki/Foo%27%27s_bar%27%27s" title="Foo&#39;&#39;s bar&#39;&#39;s">Foo''s bar''s</a>
15364 </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>
15365 </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>
15366 </p>
15367 <ul class="gallery mw-gallery-traditional">
15368 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15369 <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>
15370 <div class="gallerytext">
15371 <p>caption1
15372 </p>
15373 </div>
15374 </div></li>
15375 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15376 <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>
15377 <div class="gallerytext">
15378 <p>caption2
15379 </p>
15380 </div>
15381 </div></li>
15382 </ul>
15383 !! html/parsoid
15384 <p><a rel="mw:WikiLink" href="./Foo''s_bar''s" title="Foo''s bar''s">Foo''s bar''s</a></p>
15385
15386 <!-- Note that "italics" are stripped, even though this is a valid page title -->
15387 <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>
15388
15389 <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>
15390
15391 <!-- consistency with gallery extension -->
15392 <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"}}'>
15393 <li class="gallerybox">
15394 <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>
15395 <div class="gallerytext">caption1</div>
15396 </li>
15397 <li class="gallerybox">
15398 <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>
15399 <div class="gallerytext">caption2</div>
15400 </li>
15401 </ul>
15402 !! end
15403
15404 !! test
15405 Nowiki markup in link attribute (T206940)
15406 !! wikitext
15407 [[File:Foobar.jpg|link=Foo<nowiki>''</nowiki>s_bar<nowiki>''</nowiki>s|caption]]
15408
15409 <!-- consistency with gallery extension -->
15410 <gallery>
15411 File:Foobar.jpg|link=Foo<nowiki>''</nowiki>s_bar<nowiki>''</nowiki>s|caption
15412 </gallery>
15413 !! html/php+tidy
15414 <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>
15415 </p>
15416 <ul class="gallery mw-gallery-traditional">
15417 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15418 <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>
15419 <div class="gallerytext">
15420 <p>caption
15421 </p>
15422 </div>
15423 </div></li>
15424 </ul>
15425 !! html/parsoid
15426 <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>
15427
15428 <!-- consistency with gallery extension -->
15429 <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"}}'>
15430 <li class="gallerybox">
15431 <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>
15432 <div class="gallerytext">caption</div>
15433 </li>
15434 </ul>
15435 !! end
15436
15437 !! test
15438 Nowiki markup in link attribute (edited html, no data-parsoid) (T206940)
15439 !! options
15440 parsoid = {
15441 "nativeGallery": true
15442 }
15443 !! wikitext
15444 [[File:Foobar.jpg|link=Foo<nowiki>''s_bar''</nowiki>s|caption]]
15445
15446 <!-- consistency with gallery extension -->
15447 <gallery>
15448 File:Foobar.jpg|link=Foo<nowiki>''s_bar''</nowiki>s|caption
15449 </gallery>
15450 !! html/php+tidy
15451 <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>
15452 </p>
15453 <ul class="gallery mw-gallery-traditional">
15454 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15455 <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>
15456 <div class="gallerytext">
15457 <p>caption
15458 </p>
15459 </div>
15460 </div></li>
15461 </ul>
15462 !! html/parsoid
15463 <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>
15464
15465 <!-- consistency with gallery extension -->
15466 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15467 <li class="gallerybox">
15468 <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>
15469 <div class="gallerytext">caption</div>
15470 </li>
15471 </ul>
15472 !! end
15473
15474 !! test
15475 Image with table with attributes in caption
15476 !! options
15477 parsoid=wt2html,html2html
15478 !! wikitext
15479 [[File:Foobar.jpg|thumb|
15480 {| class="123" |
15481 |- class="456" |
15482 | ha
15483 |}
15484 ]]
15485 !! html/parsoid
15486 <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>
15487 <table class="123">
15488 <tbody><tr class="456" data-parsoid='{"startTagSrc":"|-"}'>
15489 <td> ha</td></tr>
15490 </tbody></table>
15491 </figcaption></figure>
15492 !! end
15493
15494 !! test
15495 Image with table with rows from templates in caption
15496 !! wikitext
15497 [[File:Foobar.jpg|thumb|
15498 {|
15499 {{echo|{{!}} hi}}
15500 |}
15501 ]]
15502 !! html/parsoid
15503 <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>
15504 <table>
15505 <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>
15506 </tbody></table>
15507 </figcaption></figure>
15508 !! end
15509
15510 !! test
15511 Image with nested tables in caption
15512 !! wikitext
15513 [[File:Foobar.jpg|thumb|Foo<br />
15514 {|
15515 |
15516 {|
15517 |z
15518 |}
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":"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}'/>
15523 <table>
15524 <tbody><tr><td>
15525 <table>
15526 <tbody><tr><td>z</td></tr>
15527 </tbody></table></td></tr>
15528 </tbody></table>
15529 </figcaption></figure>
15530 !! end
15531
15532 !! test
15533 Image with heading and horizontal rule in caption
15534 !! wikitext
15535 [[File:Foobar.jpg|thumb|
15536 ===Testing===
15537 123
15538 --------------
15539 ]]
15540 !! html/php
15541 <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>
15542
15543 !! html/parsoid
15544 <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>
15545 <h3 id="Testing">Testing</h3>
15546 123
15547 <hr data-parsoid='{"extra_dashes":10}'/>
15548 </figcaption></figure>
15549 !! end
15550
15551 ###################
15552 # Conflicting image format options.
15553 # First option specified should 'win'.
15554 # All three cases in each test should be identical.
15555
15556 !! test
15557 Image with 'frameless' first.
15558 !! options
15559 parsoid=wt2html,wt2wt,html2html
15560 !! wikitext
15561 [[File:Foobar.jpg|frameless|caption]]
15562
15563 [[File:Foobar.jpg|frameless|frame|caption]]
15564
15565 [[File:Foobar.jpg|frameless|thumb|caption]]
15566 !! html/php
15567 <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>
15568 </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>
15569 </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>
15570 </p>
15571 !! html/parsoid
15572 <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>
15573 <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>
15574 <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>
15575 !! end
15576
15577 !! test
15578 Image with 'frame' first.
15579 !! options
15580 parsoid=wt2html,wt2wt,html2html
15581 !! wikitext
15582 [[File:Foobar.jpg|frame|caption]]
15583 [[File:Foobar.jpg|frame|frameless|caption]]
15584 [[File:Foobar.jpg|frame|thumb|caption]]
15585 !! html/php
15586 <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>
15587 <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>
15588 <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>
15589
15590 !! html/parsoid
15591 <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>
15592 <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>
15593 <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>
15594 !! end
15595
15596 !! test
15597 Image with 'thumb' first.
15598 !! options
15599 parsoid=wt2html,wt2wt,html2html
15600 !! wikitext
15601 [[File:Foobar.jpg|thumb|caption]]
15602 [[File:Foobar.jpg|thumb|frameless|caption]]
15603 [[File:Foobar.jpg|thumb|frame|caption]]
15604 !! html/php
15605 <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>
15606 <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>
15607 <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>
15608
15609 !! html/parsoid
15610 <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>
15611 <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>
15612 <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>
15613 !! end
15614
15615 ###################
15616 # Image sizing.
15617 # See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
15618 # and https://phabricator.wikimedia.org/T64258
15619 # Foobar has actual size of 1941x220
15620 # 1. Thumbs & frameless always reduce, can't be enlarged unless it's
15621 # a scalable format.
15622 # 2. Framed images always ignore size options; always render at default size.
15623 # 3. "Unspecified format" and border are the only types which can be
15624 # enlarged.
15625
15626 !! test
15627 Image: unspecified format and border enlarge
15628 !! options
15629 parsoid=wt2html,wt2wt,html2html
15630 !! wikitext
15631 [[File:Foobar.jpg|2000px]]
15632
15633 [[File:Foobar.jpg|border|2000px]]
15634 !! html/php
15635 <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>
15636 </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>
15637 </p>
15638 !! html/parsoid
15639 <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>
15640 <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>
15641 !! end
15642
15643 !! test
15644 Image: "unspecified format" and border reduce
15645 !! options
15646 parsoid=wt2html,wt2wt,html2html
15647 !! wikitext
15648 [[File:Foobar.jpg|1000px]]
15649
15650 [[File:Foobar.jpg|border|1000px]]
15651 !! html/php
15652 <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>
15653 </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>
15654 </p>
15655 !! html/parsoid
15656 <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>
15657 <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>
15658 !! end
15659
15660 !! test
15661 Image: thumbs reduce
15662 !! options
15663 parsoid=wt2html,wt2wt,html2html
15664 !! wikitext
15665 [[File:Foobar.jpg|thumb|50px]]
15666 !! html/php
15667 <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>
15668
15669 !! html/parsoid
15670 <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>
15671 !! end
15672
15673 !! test
15674 Image: bitmap thumbs can't be enlarged past original size, but vector can.
15675 !! options
15676 parsoid=wt2html,wt2wt,html2html
15677 !! wikitext
15678 [[File:Foobar.jpg|thumb|2000px]]
15679
15680 [[File:Foobar.svg|thumb|2000px]]
15681 !! html/php
15682 <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>
15683 <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>
15684
15685 !! html/parsoid
15686 <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>
15687 <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>
15688 !! end
15689
15690 !! test
15691 Image: frameless can reduce in size
15692 !! options
15693 parsoid=wt2html,wt2wt,html2html
15694 !! wikitext
15695 [[File:Foobar.jpg|frameless|50px]]
15696 !! html/php
15697 <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>
15698 </p>
15699 !! html/parsoid
15700 <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>
15701 !! end
15702
15703 !! test
15704 Image: bitmap frameless can't be enlarged past original size, but vector can
15705 !! options
15706 parsoid=wt2html,wt2wt,html2html
15707 !! wikitext
15708 [[File:Foobar.jpg|frameless|2000px]]
15709
15710 [[File:Foobar.svg|frameless|2000px]]
15711 !! html/php
15712 <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>
15713 </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>
15714 </p>
15715 !! html/parsoid
15716 <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>
15717 <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>
15718 !! end
15719
15720 !! test
15721 Image: framed images are always unscaled.
15722 !! options
15723 parsoid=wt2html,wt2wt,html2html
15724 !! wikitext
15725 [[File:Foobar.jpg|frame]]
15726
15727 [[File:Foobar.jpg|frame|50px]]
15728
15729 [[File:Foobar.jpg|frame|50x50px]]
15730
15731 [[File:Foobar.jpg|frame|2000px]]
15732 !! html/php
15733 <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>
15734 <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>
15735 <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>
15736 <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>
15737
15738 !! html/parsoid
15739 <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>
15740 <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>
15741 <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>
15742 <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>
15743 !! end
15744
15745 ###################
15746
15747 !! test
15748 Link to image page- image page normally doesn't exists, hence edit link
15749 Add test with existing image page
15750 #<p><a href="/wiki/File:Test" title="Image:Test">Image:test</a>
15751 !! wikitext
15752 [[:Image:test]]
15753 !! html
15754 <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>
15755 </p>
15756 !! end
15757
15758 !! test
15759 T20784 Link to non-existent image page with caption should use caption as link text
15760 !! wikitext
15761 [[:Image:test|caption]]
15762 !! html
15763 <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>
15764 </p>
15765 !! end
15766
15767 !! test
15768 Frameless image caption with a free URL
15769 !! wikitext
15770 [[File:Foobar.jpg|http://example.com]]
15771 !! html/php
15772 <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>
15773 </p>
15774 !! html/parsoid
15775 <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>
15776 !! end
15777
15778 !! test
15779 Thumbnail image caption with a free URL
15780 !! options
15781 thumbsize=220
15782 !! wikitext
15783 [[File:Foobar.jpg|thumb|http://example.com]]
15784 !! html/php
15785 <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>
15786
15787 !! html/parsoid
15788 <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>
15789 !! end
15790
15791 !! test
15792 Thumbnail image caption with a free URL and explicit alt
15793 !! options
15794 thumbsize=220
15795 parsoid=wt2html,wt2wt,html2html
15796 !! wikitext
15797 [[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]]
15798 !! html/php
15799 <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>
15800
15801 !! html/parsoid
15802 <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>
15803 !! end
15804
15805 !! test
15806 SVG thumbnails with no language set
15807 !! options
15808 !! wikitext
15809 [[File:Foobar.svg|thumb|caption]]
15810 !! html/php
15811 <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>
15812
15813 !! html/parsoid
15814 <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>
15815 !! end
15816
15817 !! test
15818 SVG thumbnails with language de
15819 !! options
15820 parsoid=wt2html,wt2wt,html2html
15821 !! wikitext
15822 [[File:Foobar.svg|thumb|caption|lang=de]]
15823 !! html/php
15824 <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>
15825
15826 !! html/parsoid
15827 <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>
15828 !! end
15829
15830 !! test
15831 SVG thumbnails with invalid language code
15832 !! options
15833 parsoid=wt2html,wt2wt,html2html
15834 !! wikitext
15835 [[File:Foobar.svg|thumb|caption|lang=invalid:language:code]]
15836 !! html/php
15837 <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>
15838
15839 !! html/parsoid
15840 <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>
15841 !! end
15842
15843 !! test
15844 SVG thumbnails in page language
15845 !! options
15846 language=ru
15847 wgMediaInTargetLanguage = true
15848 !! wikitext
15849 [[File:Foobar.svg]] [[File:Foobar.svg|lang=en]]
15850 !! html/php
15851 <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>
15852 </p>
15853 !! end
15854
15855 !! test
15856 SVG thumbnails in page language not present in the file
15857 !! options
15858 language=de
15859 wgMediaInTargetLanguage = true
15860 !! wikitext
15861 [[File:Foobar.svg]] [[File:Foobar.svg|lang=ru]]
15862 !! html/php
15863 <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>
15864 </p>
15865 !! end
15866
15867 !! test
15868 T3887: A ISBN with a thumbnail
15869 !! wikitext
15870 [[File:Foobar.jpg|thumb|ISBN 1235467890]]
15871 !! html/php
15872 <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>
15873
15874 !! html/parsoid
15875 <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>
15876 !! end
15877
15878 !! test
15879 T3887: A RFC with a thumbnail
15880 !! wikitext
15881 [[File:Foobar.jpg|thumb|This is RFC 12354]]
15882 !! html/php
15883 <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>
15884
15885 !! html/parsoid
15886 <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>
15887 !! end
15888
15889 !! test
15890 T3887: A mailto link with a thumbnail
15891 !! wikitext
15892 [[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
15893 !! html/php
15894 <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>
15895
15896 !! html/parsoid
15897 <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>
15898 !! end
15899
15900 # Pending resolution to T2368
15901 !! test
15902 T2648: Frameless image caption with a link
15903 !! wikitext
15904 [[File:Foobar.jpg|text with a [[link]] in it]]
15905 !! html/php
15906 <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>
15907 </p>
15908 !! html/parsoid
15909 <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>
15910 !! end
15911
15912 !! test
15913 T2648: Frameless image caption with a link (suffix)
15914 !! wikitext
15915 [[File:Foobar.jpg|text with a [[link]]foo in it]]
15916 !! html/php
15917 <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>
15918 </p>
15919 !! html/parsoid
15920 <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>
15921 !! end
15922
15923 !! test
15924 T2648: Frameless image caption with an interwiki link
15925 !! wikitext
15926 [[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
15927 !! html/php
15928 <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>
15929 </p>
15930 !! html/parsoid
15931 <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>
15932 !! end
15933
15934 !! test
15935 T2648: Frameless image caption with a piped interwiki link
15936 !! wikitext
15937 [[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
15938 !! html/php
15939 <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>
15940 </p>
15941 !! html/parsoid
15942 <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>
15943 !! end
15944
15945 !! test
15946 T107474: Frameless image caption with <nowiki>
15947 !! wikitext
15948 [[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]]
15949 !! html/parsoid
15950 <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>
15951 !! end
15952
15953 !! test
15954 Escape HTML special chars in image alt text
15955 !! wikitext
15956 [[File:Foobar.jpg|& < > "]]
15957 !! html/php
15958 <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>
15959 </p>
15960 !! html/parsoid
15961 <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>
15962 !! end
15963
15964 !! test
15965 Escape HTML special chars in image alt text with LanguageConverter
15966 !! options
15967 language=zh
15968 !! wikitext
15969 [[File:Foobar.jpg|& < > "]]
15970 !! html/php
15971 <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>
15972 </p>
15973 !! html/parsoid
15974 <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>
15975 !! end
15976
15977 !! test
15978 Entities in file name and attributes
15979 !! wikitext
15980 [[File:7%25 solution.gif|manualthumb=7%25 solution.gif|link=7%25 solution|[[7%25 solution]]]]
15981 !! html/php
15982 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=7%25_solution.gif" class="new" title="File:7% solution.gif">7% solution</a>
15983 </p>
15984 !! html/parsoid
15985 <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>
15986 !! end
15987
15988 !! test
15989 T2499: Alt text should have &#1234;, not &amp;1234;
15990 !! wikitext
15991 [[File:Foobar.jpg|&#9792;]]
15992 !! html/php
15993 <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>
15994 </p>
15995 !! html/parsoid
15996 <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>
15997 !! end
15998
15999 !! test
16000 Broken image caption with link
16001 !! options
16002 parsoid=wt2html,wt2wt,html2html
16003 !! wikitext
16004 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
16005 !! html/php
16006 <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.
16007 </p>
16008 !! html/parsoid
16009 <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>
16010 !! end
16011
16012 !! test
16013 Image caption containing another image
16014 !! wikitext
16015 [[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
16016 !! html/php
16017 <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>
16018
16019 !! html/parsoid
16020 <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>
16021 !! end
16022
16023 !! test
16024 Image: caption containing a newline
16025 !! wikitext
16026 [[File:Foobar.jpg|This
16027 *is some text]]
16028 !! html/php
16029 <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>
16030 </p>
16031 !! html/parsoid
16032 <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>
16033 !!end
16034
16035 !!test
16036 Image: caption containing leading space
16037 (The leading space should not trigger nowiki escaping in wt2wt mode)
16038 !! wikitext
16039 [[File:Foobar.jpg|thumb| bar]]
16040 !! html/php
16041 <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>
16042
16043 !! html/parsoid
16044 <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>
16045 !!end
16046
16047 # html/php output not have newlines after table, td, th, etc. because
16048 # Linker::makeThumbLink2() replaces the newlines with spaces since
16049 # the table is inside a caption.
16050 # FIXME: Verify if that circa 2004 fix is still required.
16051 !! test
16052 Image: caption containing a table
16053 !! options
16054 parsoid=wt2html,wt2wt,html2html
16055 !! wikitext
16056 [[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
16057 {|
16058 !Foo!!Bar
16059 |-
16060 |Foo1||Bar1
16061 |}
16062 and some more text.]]
16063 !! html/php
16064 <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>
16065
16066 !! html/parsoid
16067 <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
16068 <table>
16069 <tbody>
16070 <tr><th>Foo</th><th>Bar</th></tr>
16071 <tr>
16072 <td>Foo1</td>
16073 <td>Bar1</td></tr></tbody></table>and some more text.</figcaption></figure>
16074 !! end
16075
16076 !! test
16077 T5090: External links other than http: in image captions
16078 !! wikitext
16079 [[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
16080 !! html/php
16081 <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>
16082
16083 !! html/parsoid
16084 <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>
16085 !! end
16086
16087 !! test
16088 Custom class
16089 !! options
16090 parsoid=wt2html,wt2wt,html2html
16091 !! wikitext
16092 [[Image:foobar.jpg|a|class=b]]
16093 !! html/php
16094 <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>
16095 </p>
16096 !! html/parsoid
16097 <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>
16098 !! end
16099
16100 !! test
16101 Localized image handling (1).
16102 !! options
16103 parsoid=wt2html,wt2wt,html2html
16104 language=es
16105 !! wikitext
16106 [[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]]
16107 !! html/php
16108 <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>
16109
16110 !! html/parsoid
16111 <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>
16112 !! end
16113
16114 !! test
16115 Localized image handling (2).
16116 !! options
16117 thumbsize=220
16118 parsoid=wt2html,wt2wt,html2html
16119 language=es
16120 !! wikitext
16121 [[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
16122 !! html/php
16123 <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>
16124
16125 !! html/parsoid
16126 <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>
16127 !! end
16128
16129 !! test
16130 Localized image handling (3).
16131 !! options
16132 language=fa
16133 parsoid=html2wt
16134 !! html/parsoid
16135 <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>
16136 !! wikitext
16137 [[File:Foobar.jpg|بندانگشتی]]
16138 !! end
16139
16140 !! test
16141 "border", "frameless" and "class" attributes on an image.
16142 !! options
16143 thumbsize=220
16144 parsoid=wt2html,wt2wt,html2html
16145 !! wikitext
16146 [[File:Foobar.jpg|frameless|border|class=extra|caption]]
16147 !! html/php
16148 <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>
16149 </p>
16150 !! html/parsoid
16151 <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>
16152 !! end
16153
16154 # Note that 'right' is the default alignment, despite the misspelled 'righ' below
16155 !! test
16156 Invalid image attributes (T64500)
16157 !! options
16158 thumbsize=220
16159 parsoid=wt2html,wt2wt,html2html
16160 !! wikitext
16161 [[File:Foobar.jpg|thumb|float|left|caption]]
16162
16163 [[File:Foobar.jpg|thumb|righ|caption]]
16164
16165 [[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]]
16166 !! html/php
16167 <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>
16168 <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>
16169 <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>
16170
16171 !! html/parsoid
16172 <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>
16173 <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>
16174 <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>
16175 !! end
16176
16177 !! article
16178 File:Barfoo.jpg
16179 !! text
16180 #REDIRECT [[File:Barfoo.jpg]]
16181 !! endarticle
16182
16183 # FIXME: Parsoid should run this test -- but we'd need to teach the
16184 # mockAPI about the redirected Barfoo.jpg image.
16185 !! test
16186 Redirected image
16187 !! wikitext
16188 [[Image:Barfoo.jpg]]
16189 !! html/php
16190 <p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
16191 </p>
16192 !! end
16193
16194 !! test
16195 Missing image with uploads disabled
16196 !! options
16197 wgEnableUploads=0
16198 !! wikitext
16199 [[File:Foobaz.jpg]]
16200 !! html/php
16201 <p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a>
16202 </p>
16203 !! html/parsoid
16204 <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>
16205 !! end
16206
16207 # Parsoid-specific testing for images
16208 # https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
16209 # Currently imperfect due to a flaw in the Parsoid testrunner
16210 # Work in progress
16211 # THESE TESTS SHOULD BE MOVED UP and merged with the php-specific
16212 # image tests.
16213
16214 !! test
16215 Parsoid-specific image handling - simple image with size and middle alignment
16216 !! wikitext
16217 [[File:Foobar.jpg|middle|50px]]
16218 !! html/parsoid
16219 <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>
16220 !! end
16221
16222 !! test
16223 Parsoid-specific image handling - simple image with size, middle alignment, non-standard namespace alias
16224 !! options
16225 parsoid=wt2wt,wt2html,html2html
16226 !! wikitext
16227 [[Image:Foobar.jpg|middle|50px]]
16228 !! html/parsoid
16229 <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>
16230 !! end
16231
16232 !! test
16233 Parsoid-specific image handling - simple image with size and middle alignment (existing content)
16234 !! wikitext
16235 [[File:Foobar.jpg|50px|middle]]
16236 !! html/parsoid
16237 <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>
16238 !! end
16239
16240 !! test
16241 Parsoid-specific image handling - simple image with size and middle alignment and non-standard namespace name
16242 !! options
16243 parsoid=wt2html,wt2wt,html2html
16244 !! wikitext
16245 [[Image:Foobar.jpg|50px|middle]]
16246 !! html/parsoid
16247 <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>
16248 !! end
16249
16250 !! test
16251 Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
16252 !! wikitext
16253 [[File:Foobar.jpg|500x10px|baseline|caption]]
16254 !! html/parsoid
16255 <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>
16256 !! end
16257
16258 !! test
16259 Parsoid-specific image handling - simple image with border and size spec
16260 !! wikitext
16261 [[File:Foobar.jpg|50px|border|caption]]
16262 !! html/parsoid
16263 <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>
16264 !! end
16265
16266 !! test
16267 Parsoid-specific image handling - thumbnail with halign, valign, and caption
16268 !! options
16269 parsoid=wt2html,html2html
16270 !! wikitext
16271 [[File:Foobar.jpg|left|baseline|thumb|caption content]]
16272 !! html/parsoid
16273 <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>
16274 !! end
16275
16276 !! test
16277 Parsoid-specific image handling - thumbnail with halign, valign, and caption (existing content)
16278 !! options
16279 parsoid=wt2html,html2html
16280 !! wikitext
16281 [[File:Foobar.jpg|thumb|left|baseline|caption content]]
16282 !! html/parsoid
16283 <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>
16284 !! end
16285
16286 !! test
16287 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption
16288 !! options
16289 parsoid=wt2html,html2html
16290 !! wikitext
16291 [[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
16292 !! html/parsoid
16293 <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>
16294 !! end
16295
16296 !! test
16297 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption (existing content)
16298 !! options
16299 parsoid=wt2html,html2html
16300 !! wikitext
16301 [[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
16302 !! html/parsoid
16303 <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>
16304 !! end
16305
16306 !! test
16307 Parsoid-specific image handling - framed image with specific size and caption (size is ignored)
16308 !! options
16309 parsoid=wt2html,wt2wt,html2html
16310 !! wikitext
16311 [[File:Foobar.jpg|frame|500x50px|caption]]
16312 !! html/parsoid
16313 <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>
16314 !! end
16315
16316 !! test
16317 Parsoid-specific image handling - framed image with specific size, halign, valign, and caption (size is ignored)
16318 !! options
16319 parsoid=wt2html,html2html
16320 !! wikitext
16321 [[File:Foobar.jpg|left|baseline|frame|500x50px|caption]]
16322 !! html/parsoid
16323 <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>
16324 !! end
16325
16326 !! test
16327 Parsoid-specific image handling - frameless image with specific size, border, and caption
16328 !! wikitext
16329 [[File:Foobar.jpg|frameless|442x50px|border|caption]]
16330 !! html/parsoid
16331 <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>
16332 !! end
16333
16334 !! test
16335 Parsoid-specific image handling - simple image with a formatted caption
16336 !! wikitext
16337 [[File:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]]
16338 !! html/parsoid
16339 <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>
16340 !! end
16341
16342 !! test
16343 Parsoid-specific image handling - caption with a template in it
16344 !! wikitext
16345 [[File:Foobar.jpg|thumb|200x23px|This caption has a {{echo|transclusion}} in it.]]
16346 !! html/parsoid
16347 <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>
16348 !! end
16349
16350 !! test
16351 Parsoid-specific image handling - caption with unbalanced tags in it
16352 !! options
16353 parsoid=wt2html,wt2wt,html2html
16354 !! wikitext
16355 foo
16356 [[File:Foobar.jpg|thumb|200x200px|This caption has a <center>unbalanced tag in it.]]
16357 bar
16358 !! html/parsoid
16359 <p>foo</p>
16360 <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>
16361 <p>bar</p>
16362 !! end
16363
16364 !! test
16365 Parsoid-specific image handling - empty caption (1)
16366 !! options
16367 parsoid=wt2html,wt2wt
16368 !! wikitext
16369 [[File:Foobar.jpg|thumb|]]
16370 !! html/parsoid
16371 <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>
16372 !! end
16373
16374 # empty captions don't get serialized unless we're in the "round trip" case
16375 !! test
16376 Parsoid-specific image handling - empty caption (2)
16377 !! options
16378 parsoid=html2wt
16379 !! html/parsoid
16380 <figure class="mw-default-size" typeof="mw:Image/Thumb">
16381 <a href="./File:Foobar.jpg">
16382 <img resource="./File:Foobar.jpg"
16383 src="//example.com/images/3/3a/Foobar.jpg"
16384 data-file-width="1941" data-file-height="220" data-file-type="bitmap"
16385 height="25" width="220"/>
16386 </a>
16387 <figcaption></figcaption>
16388 </figure>
16389 !! wikitext
16390 [[File:Foobar.jpg|thumb]]
16391 !! end
16392
16393 !! test
16394 Parsoid-specific image handling - whitespace caption
16395 !! wikitext
16396 [[File:Foobar.jpg|thumb| ]]
16397 !! html/parsoid
16398 <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>
16399 !! end
16400
16401 !! test
16402 Parsoid-specific image handling - lang option
16403 !! wikitext
16404 foo
16405 [[File:Foobar.svg|lang=de|caption]]
16406 bar
16407 !! html/parsoid
16408 <p>foo
16409 <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>
16410 bar</p>
16411 !! end
16412
16413 ## Edge case bugs in Parsoid from T93580
16414 !! test
16415 T93580: 1. Templated <ref> inside block images
16416 !! wikitext
16417 [[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]]
16418
16419 <references />
16420 !! html/parsoid
16421 <figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"Caption with templated ref: {{echo|&lt;ref>foo&lt;/ref>}}"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>Caption with templated ref: <sup about="#mwt5" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Transclusion mw:Extension/ref" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;ref>foo&lt;/ref>"}},"i":0}}]}'><a href="./Main_Page#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup></figcaption></figure>
16422
16423 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
16424 !! end
16425
16426 !! test
16427 T93580: 2. <ref> inside inline images
16428 !! wikitext
16429 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: <ref>foo</ref>]]
16430
16431 <references />
16432 !! html/parsoid
16433 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"Undisplayed caption in inline image with ref: &lt;ref>foo&lt;/ref>"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: &lt;sup about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-parsoid=&#39;{\"dsr\":[64,78,5,6]}&#39; data-mw=&#39;{\"name\":\"ref\",\"attrs\":{},\"body\":{\"id\":\"mw-reference-text-cite_note-1\"}}&#39;>&lt;a href=\"./Main_Page#cite_note-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]&lt;/span>&lt;/a>&lt;/sup>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{"href":"File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p>
16434
16435 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">foo</span></li></ol>
16436 !! end
16437
16438 !! test
16439 T93580: 3. Templated <ref> inside inline images
16440 !! wikitext
16441 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}]]
16442
16443 <references />
16444 !! html/parsoid
16445 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"Undisplayed caption in inline image with ref: {{echo|&lt;ref>{{echo|foo}}&lt;/ref>}}"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: &lt;sup about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Transclusion mw:Extension/ref\" data-parsoid=&#39;{\"dsr\":[64,96,null,null],\"pi\":[[{\"k\":\"1\"}]]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&amp;lt;ref>{{echo|foo}}&amp;lt;/ref>\"}},\"i\":0}}]}&#39;>&lt;a href=\"./Main_Page#cite_note-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]&lt;/span>&lt;/a>&lt;/sup>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{"href":"File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p>
16446
16447 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">foo</span></li></ol>
16448 !! end
16449
16450 ###
16451 ### Subpages
16452 ###
16453 !! article
16454 Subpage test/subpage
16455 !! text
16456 foo
16457 !! endarticle
16458
16459 !! test
16460 Subpage link
16461 !! options
16462 subpage title=[[Subpage test]]
16463 !! wikitext
16464 [[/subpage]]
16465 !! html
16466 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
16467 </p>
16468 !! end
16469
16470 !! test
16471 Subpage noslash link
16472 !! options
16473 subpage title=[[Subpage test]]
16474 !! wikitext
16475 [[/subpage/]]
16476 !! html
16477 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
16478 </p>
16479 !! end
16480
16481 !! article
16482 Subpage test/1/2/subpage
16483 !! text
16484 blah
16485 !! endarticle
16486
16487 !! test
16488 Relative subpage noslash link
16489 !! options
16490 parsoid=wt2wt,wt2html,html2html
16491 subpage title=[[Subpage test/1/2/3/4]]
16492 !! wikitext
16493 [[../../subpage/]]
16494
16495 [[../../subpage]]
16496 !! html/php
16497 <p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a>
16498 </p><p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage test/1/2/subpage</a>
16499 </p>
16500 !! html/parsoid
16501 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a></p>
16502 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage_test/1/2/subpage</a></p>
16503 !! end
16504
16505 !! test
16506 Parsoid: dot-slash prefixed wikilinks
16507 !! wikitext
16508 [[./foo]]
16509
16510 [[././bar]]
16511
16512 [[././baz/]]
16513 !! html/php
16514 <p>[[./foo]]
16515 </p><p>[[././bar]]
16516 </p><p>[[././baz/]]
16517 </p>
16518 !! html/parsoid
16519 <p>[[./foo]]
16520 </p><p>[[././bar]]
16521 </p><p>[[././baz/]]
16522 </p>
16523 !! end
16524
16525 !! test
16526 Render invalid page names as plain text (T53090)
16527 !! wikitext
16528 [[./../foo|bar]]
16529 [[foo�|bar]]
16530 [[foo/.|bar]]
16531 [[foo/..|bar]]
16532 [[foo~~~bar]]
16533 [[foo>bar]]
16534 [[foo[bar]]
16535 [[.]]
16536 [[..]]
16537 [[foo././bar]]
16538 [[foo[http://example.com]xyz]]
16539
16540 [[{{echo|./../foo}}|bar]]
16541 [[{{echo|foo/.}}|bar]]
16542 [[{{echo|foo/..}}|bar]]
16543 [[{{echo|foo~~~~bar}}]]
16544 [[{{echo|foo>bar}}]]
16545 [[{{echo|foo././bar}}]]
16546 [[{{echo|foo{bar}}]]
16547 [[{{echo|foo}bar}}]]
16548 [[{{echo|foo[bar}}]]
16549 [[{{echo|foo]bar}}]]
16550 [[{{echo|foo<bar}}]]
16551 !!html/php
16552 <p>[[./../foo|bar]]
16553 [[foo�|bar]]
16554 [[foo/.|bar]]
16555 [[foo/..|bar]]
16556 [[foo~~~bar]]
16557 [[foo&gt;bar]]
16558 [[foo[bar]]
16559 [[.]]
16560 [[..]]
16561 [[foo././bar]]
16562 [[foo<a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>xyz]]
16563 </p><p>[[./../foo|bar]]
16564 [[foo/.|bar]]
16565 [[foo/..|bar]]
16566 [[foo~~~~bar]]
16567 [[foo&gt;bar]]
16568 [[foo././bar]]
16569 [[foo{bar]]
16570 [[foo}bar]]
16571 [[foo[bar]]
16572 [[foo]bar]]
16573 [[foo&lt;bar]]
16574 </p>
16575 !!html/parsoid
16576 <p>[[./../foo|bar]]
16577 [[foo�|bar]]
16578 [[foo/.|bar]]
16579 [[foo/..|bar]]
16580 [[foo~~~bar]]
16581 [[foo>bar]]
16582 [[foo[bar]]
16583 [[.]]
16584 [[..]]
16585 [[foo././bar]]
16586 [[foo<a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>xyz]]</p>
16587
16588 <p>[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"./../foo"}},"i":0}}]}'>./../foo</span>|bar]]
16589 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/."}},"i":0}}]}'>foo/.</span>|bar]]
16590 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/.."}},"i":0}}]}'>foo/..</span>|bar]]
16591 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo~~~~bar"}},"i":0}}]}'>foo~~~~bar</span>]]
16592 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo>bar"}},"i":0}}]}'>foo>bar</span>]]
16593 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo././bar"}},"i":0}}]}'>foo././bar</span>]]
16594 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo{bar"}},"i":0}}]}'>foo{bar</span>]]
16595 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}bar"}},"i":0}}]}'>foo}bar</span>]]
16596 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo[bar"}},"i":0}}]}'>foo[bar</span>]]
16597 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo]bar"}},"i":0}}]}'>foo]bar</span>]]
16598 [[<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>
16599 !!end
16600
16601 !! test
16602 Disabled subpages
16603 !! wikitext
16604 [[/subpage]]
16605 !! html
16606 <p><a href="/index.php?title=/subpage&amp;action=edit&amp;redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a>
16607 </p>
16608 !! end
16609
16610 !! test
16611 T2561: {{/Subpage}}
16612 !! options
16613 subpage title=[[Page]]
16614 !! wikitext
16615 {{/Subpage}}
16616 !! html
16617 <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>
16618 </p>
16619 !! end
16620
16621 ###
16622 ### Categories
16623 ###
16624 !! article
16625 Category:MediaWiki User's Guide
16626 !! text
16627 blah
16628 !! endarticle
16629
16630 !! test
16631 Link to category
16632 !! wikitext
16633 [[:Category:MediaWiki User's Guide]]
16634 !! html
16635 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User&#39;s Guide">Category:MediaWiki User's Guide</a>
16636 </p>
16637 !! end
16638
16639 !! test
16640 Simple category
16641 !! options
16642 cat
16643 !! wikitext
16644 [[Category:MediaWiki User's Guide]]
16645 !! html/php
16646 cat=MediaWiki_User's_Guide sort=
16647 !! html/parsoid
16648 <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"}}'/>
16649 !! end
16650
16651 !! test
16652 PAGESINCATEGORY invalid title fatal (r33546 fix)
16653 !! wikitext
16654 {{PAGESINCATEGORY:<bogus>}}
16655 !! html
16656 <p>0
16657 </p>
16658 !! end
16659
16660 !! test
16661 Category with different sort key
16662 !! options
16663 cat
16664 !! wikitext
16665 [[Category:MediaWiki User's Guide|Foo]]
16666 !! html/php
16667 cat=MediaWiki_User's_Guide sort=Foo
16668 !! html/parsoid
16669 <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"}}'/>
16670 !! end
16671
16672 !! test
16673 Category with identical sort key
16674 !! options
16675 cat
16676 !! wikitext
16677 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
16678 !! html/php
16679 cat=MediaWiki_User's_Guide sort=MediaWiki User's Guide
16680 !! html/parsoid
16681 <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"}}'/>
16682 !! end
16683
16684 !! test
16685 Category with empty sort key
16686 !! options
16687 cat
16688 pst
16689 !! wikitext
16690 [[Category:MediaWiki User's Guide|]]
16691 !! html/php
16692 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
16693 !! end
16694
16695 !! test
16696 Category with empty sort key and parentheses
16697 !! options
16698 cat
16699 pst
16700 !! wikitext
16701 [[Category:Foo (bar)|]]
16702 !! html/php
16703 [[Category:Foo (bar)|Foo]]
16704 !! end
16705
16706 !! test
16707 Category with link tail
16708 !! options
16709 cat
16710 pst
16711 !! wikitext
16712 123[[Category:Foo]]456
16713 !! html/php
16714 123[[Category:Foo]]456
16715 !! end
16716
16717 !! test
16718 Category with template
16719 !! options
16720 cat
16721 pst
16722 !! wikitext
16723 [[Category:{{echo|Foo}}]]
16724 !! html/php
16725 [[Category:{{echo|Foo}}]]
16726 !! end
16727
16728 !! test
16729 Category with template in sort key
16730 !! options
16731 cat
16732 pst
16733 !! wikitext
16734 [[Category:Foo|{{echo|Bar}}]]
16735 !! html/php
16736 [[Category:Foo|{{echo|Bar}}]]
16737 !! end
16738
16739 !! test
16740 Category with template in sort key and title
16741 !! options
16742 cat
16743 pst
16744 !! wikitext
16745 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16746 !! html/php
16747 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16748 !! end
16749
16750 ## We used to, but no longer wt2wt this test since the default serializer
16751 ## will normalize all categories to serialize on their own line.
16752 ## This wikitext usage is going to be fairly uncommon in production and
16753 ## selser will take care of preserving formatting in those scenarios.
16754 !! test
16755 Category / paragraph interactions
16756 !! options
16757 parsoid=wt2html
16758 !! wikitext
16759 Foo [[Category:Baz]] Bar
16760
16761 Foo [[Category:Baz]]
16762 Bar
16763
16764 Foo
16765 [[Category:Baz]]
16766 Bar
16767
16768 Foo
16769 [[Category:Baz]] Bar
16770
16771 Foo
16772 [[Category:Baz]]
16773 [[Category:Baz]]
16774 [[Category:Baz]]
16775 Bar
16776
16777 [[Category:Baz]]
16778 [[Category:Baz]]
16779 [[Category:Baz]]
16780
16781 [[Category:Baz]]
16782 {{echo|[[Category:Baz]]}}
16783 [[Category:Baz]]
16784 !! html/php
16785 <p>Foo Bar
16786 </p><p>Foo
16787 Bar
16788 </p><p>Foo
16789 Bar
16790 </p><p>Foo Bar
16791 </p><p>Foo
16792 Bar
16793 </p>
16794 !! html/parsoid
16795 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16796 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16797 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16798 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16799 <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>
16800 <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}}]}'/>
16801 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
16802 !! end
16803
16804 ## We used to, but no longer wt2wt this test since the default serializer
16805 ## will normalize all categories to serialize on their own line.
16806 ## This wikitext usage is going to be fairly uncommon in production and
16807 ## selser will take care of preserving formatting in those scenarios.
16808 ##
16809 ## The whitespace on the empty line is part of the test. Please do not delete
16810 !! test
16811 1. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16812 !! options
16813 parsoid=wt2html
16814 !! wikitext
16815 This
16816
16817 [[Category:Foo]] and this should be part of same paragraph (not an indent-pre)
16818
16819 {{echo|[[Category:Foo]] and so should this!}}
16820 !! html/php
16821 <p>This and this should be part of same paragraph (not an indent-pre) and so should this!
16822 </p>
16823 !! html/parsoid
16824 <p>This
16825
16826 <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of same paragraph (not an indent-pre)
16827
16828 <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>
16829 !! end
16830
16831 ## Parsoid will not try to wt2wt this while preserving newlines because
16832 ## it suppresses excess newlines within list items -- and we don't want to
16833 ## introduce a special case just for categories, which is, in reality somewhat
16834 ## odd behavior -- categories are unlikely to be used in list items like this
16835 ## in top-level pages and are only likely to show up in template-generated
16836 ## list items where this RT-ing is a non-issue.
16837 ##
16838 ## The whitespace on the empty line is part of the test. Please do not delete
16839 !! test
16840 2. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16841 !! options
16842 parsoid=wt2html
16843 !! wikitext
16844 * This
16845
16846 [[Category:Foo]] and this should be part of the same list item
16847 * So should this
16848
16849 {{echo|[[Category:Foo]] and this should be part of the same list item}}
16850 !! html/php+tidy
16851 <ul><li>This and this should be part of the same list item</li>
16852 <li>So should this and this should be part of the same list item</li></ul>
16853 !! html/parsoid
16854 <ul>
16855 <li>This <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of the same list item</li>
16856 <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>
16857 </ul>
16858 !! end
16859
16860 ## Newlines and categories that follow the last item of a list
16861 ## are treated differently because this (list followed by categories)
16862 ## is an extremely common pattern on wikis.
16863 !! test
16864 3. Categories and newlines: newline suppression for last list item should RT properly
16865 !! wikitext
16866 *a
16867 *b
16868
16869 [[Category:Foo]]
16870
16871 [[Category:Bar]]
16872 [[Category:Baz]]
16873
16874 :c
16875
16876 [[Category:C]]
16877
16878 ;d
16879
16880 [[Category:D]]
16881 !! html/parsoid
16882 <ul><li>a</li>
16883 <li>b</li></ul>
16884
16885 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
16886
16887 <link rel="mw:PageProp/Category" href="./Category:Bar"/>
16888 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
16889
16890 <dl><dd>c</dd></dl>
16891
16892 <link rel="mw:PageProp/Category" href="./Category:C"/>
16893
16894 <dl><dt>d</dt></dl>
16895
16896 <link rel="mw:PageProp/Category" href="./Category:D"/>
16897 !! end
16898
16899 !! test
16900 4. Categories and newlines: newline suppression for last list item should RT properly
16901 !! wikitext
16902 *a
16903 ****b
16904
16905 [[Category:Foo]]
16906 !! html/parsoid
16907 <ul><li>a
16908 <ul><li><ul><li><ul><li>b</li></ul></li></ul></li></ul></li></ul>
16909
16910 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16911 !! end
16912
16913 ## only wt2html for this to make sure the algo only applies to the rightmost path
16914 !! test
16915 5. Categories and newlines: migrateTrailingCategories dom pass should only run on the rightmost path of nested lists
16916 !! options
16917 parsoid=wt2html
16918 !! wikitext
16919 *a
16920 **b
16921 [[Category:Foo]]
16922 *c
16923 **d
16924 [[Category:Foo]]
16925 !! html/parsoid
16926 <ul><li>a
16927 <ul><li>b
16928 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul></li>
16929 <li>c
16930 <ul><li>d</li></ul></li></ul>
16931 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16932 !! end
16933
16934 ## We used to, but no longer wt2wt this test since the default serializer
16935 ## will normalize all categories to serialize on their own line.
16936 ## This wikitext usage is going to be fairly uncommon in production and
16937 ## selser will take care of preserving formatting in those scenarios.
16938 !! test
16939 6. Categories and newlines: migrateTrailingCategories dom pass should not migrate categories not preceded by newlines
16940 !! options
16941 parsoid=wt2html
16942 !! wikitext
16943 *a [[Category:Foo]]
16944 !! html/parsoid
16945 <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>
16946 !! end
16947
16948 # This test also demonstrates because of newline+category tunneling
16949 # through the list hander, template wrapping doesn't expand to the
16950 # containing list when the list item swallows the category.
16951 !! test
16952 7. Categories and newlines: migrateTrailingCategories dom pass should leave template content alone
16953 !! wikitext
16954 *{{echo|a
16955 [[Category:Foo]]}}
16956 !! html/parsoid
16957 <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
16958 </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>
16959 !! end
16960
16961 !! test
16962 8. Categories and newlines: migrateTrailingCategories dom pass should not get tripped by intervening templates
16963 !! wikitext
16964 *a
16965
16966 {{echo|[[Category:Foo]]
16967 [[Category:Bar]]}}
16968 [[Category:Baz]]
16969 !! html/parsoid
16970 <ul><li>a</li></ul>
16971
16972 <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">
16973 </span><link rel="mw:PageProp/Category" href="./Category:Bar" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
16974 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
16975 !! end
16976
16977 !! test
16978 Categories and newlines: migrateTrailingCategories dom pass should not get tripped by comments and whitespace
16979 !! wikitext
16980 *a
16981
16982 [[Category:Bar]]<!--boo1--> <!--boo2-->
16983 [[Category:Baz]]<!--boo3--> <!--boo4-->
16984 !! html/parsoid
16985 <ul><li>a</li></ul>
16986
16987 <link rel="mw:PageProp/Category" href="./Category:Bar"/><!--boo1--> <!--boo2-->
16988 <link rel="mw:PageProp/Category" href="./Category:Baz"/><!--boo3--> <!--boo4-->
16989 !! end
16990
16991 !! test
16992 Categories and newlines: should behave properly with linkprefix (T87753)
16993 !! options
16994 language=ar
16995 !! wikitext
16996 foo bar
16997 foo bar
16998 [[تصنيف:Foo]]
16999 [[تصنيف:Bar]]
17000 !! html/php
17001 <p>foo bar
17002 foo bar
17003 </p>
17004 !! html/parsoid
17005 <p>foo bar
17006 foo bar</p>
17007 <link rel="mw:PageProp/Category" href="./تصنيف:Foo"/>
17008 <link rel="mw:PageProp/Category" href="./تصنيف:Bar"/>
17009 !! end
17010
17011 !! test
17012 No regressions on internal links following category (T174639)
17013 !! options
17014 parsoid=wt2html,html2html
17015 !! wikitext
17016 [[Category:Foo]]<div>a
17017
17018 [[Foo]]</div>
17019 !! html/php
17020 <div>a
17021 <a href="/wiki/Foo" title="Foo">Foo</a></div>
17022
17023 !! html/parsoid
17024 <link rel="mw:PageProp/Category" href="./Category:Foo"/><div>a
17025
17026 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></div>
17027 !! end
17028
17029 # Note that Parsoid differs slightly from PHP due to T175421
17030 !! test
17031 11. Special case where only newlines separate links (T175416)
17032 !! options
17033 parsoid=wt2html,html2html
17034 !! wikitext
17035 [[Category:Foo]]
17036
17037 [[Foo]][[es:Alimento]]
17038
17039 [[Foo]]
17040 !! html/php
17041 <p><br />
17042 <a href="/wiki/Foo" title="Foo">Foo</a>
17043 </p><p><a href="/wiki/Foo" title="Foo">Foo</a>
17044 </p>
17045 !! html/parsoid
17046 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
17047
17048 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p><link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
17049
17050 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p>
17051 !! end
17052
17053 !! test
17054 Category links with multiple namespaces
17055 !! wikitext
17056 [[Category:Project:Foo]]
17057 !! html/parsoid
17058 <link rel="mw:PageProp/Category" href="./Category:Project:Foo" />
17059 !! end
17060
17061 !! test
17062 Parsoid: Serialize link to category page with colon escape
17063 !! wikitext
17064
17065 [[:Category:Foo]]
17066 [[:Category:Foo|Bar]]
17067 !! html/php+tidy
17068 <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>
17069 <a href="/index.php?title=Category:Foo&amp;action=edit&amp;redlink=1" class="new" title="Category:Foo (page does not exist)">Bar</a>
17070 </p>
17071 !! html/parsoid
17072 <p>
17073 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Category:Foo</a>
17074 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Bar</a>
17075 </p>
17076 !! end
17077
17078 # We used to, but no longer wt2wt this test since the default serializer
17079 # will normalize all categories to serialize on their own line.
17080 # This wikitext usage is going to be fairly uncommon in production and
17081 # selser will take care of preventing whitespace insertion if this
17082 # occurs in an article.
17083 #
17084 # html2html disabled for the same reason (whitespace insertion between
17085 # x and y).
17086 #
17087 # html2wt disabled because it localizes the "Category" namespace.
17088 !! test
17089 Link prefix/suffixes aren't applied to category links
17090 !! options
17091 parsoid=wt2html
17092 language=is
17093 !! wikitext
17094 x[[Category:Foo]]y
17095 !! html/php
17096 <p>xy
17097 </p>
17098 !! html/parsoid
17099 <p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p>
17100 !! end
17101
17102 !! test
17103 Link prefix/suffixes aren't applied to language links
17104 !! options
17105 parsoid=wt2html
17106 language=is
17107 !! wikitext
17108 x[[es:Foo]]y
17109 !! html/php
17110 <p>xy
17111 </p>
17112 !! html/parsoid
17113 <p>x<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo" data-parsoid=""/>y</p>
17114 !! end
17115
17116 !! test
17117 Parsoid: Serialize link to file page with colon escape
17118 !! wikitext
17119
17120 [[:File:Foo.png]]
17121 [[:File:Foo.png|Bar]]
17122 !! html/php+tidy
17123 <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>
17124 <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>
17125 </p>
17126 !! html/parsoid
17127 <p>
17128 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">File:Foo.png</a>
17129 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">Bar</a>
17130 </p>
17131 !! end
17132
17133 !! test
17134 Parsoid: Serialize a genuine category link without colon escape
17135 !! wikitext
17136 [[Category:Foo]]
17137 [[Category:Foo|Bar]]
17138 !! html/php+tidy
17139 !! html/parsoid
17140 <link rel="mw:PageProp/Category" href="./Category:Foo">
17141 <link rel="mw:PageProp/Category" href="./Category:Foo#Bar">
17142 !! end
17143
17144 !! test
17145 Normalize hrefs properly before testing for invalid link targets (T72894)
17146 !! options
17147 parsoid=html2wt
17148 !! html/parsoid
17149 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/>
17150 !! wikitext
17151 [[Category:Toxine bactérienne]]
17152 !! end
17153
17154 !! test
17155 Parsoid: Defaultsort
17156 !! wikitext
17157 {{DEFAULTSORT:Foo}}
17158 !! html/parsoid
17159 <meta property="mw:PageProp/categorydefaultsort" content="Foo"/>
17160 !! end
17161
17162 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
17163 # But, this is a limitation of our representation and is documented in
17164 # TemplateHandler.js in processSpecialMagicWord
17165 !! test
17166 Parsoid: Defaultsort (template-generated)
17167 !! wikitext
17168 {{{{echo|DEFAULTSORT}}:Foo}}
17169 !! html/parsoid
17170 <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"}]]}'/>
17171 !! end
17172
17173 ###
17174 ### Inter-language links
17175 ###
17176 !! test
17177 Interlanguage links
17178 !! options
17179 ill
17180 !! wikitext
17181 [[es:Alimento]]
17182 [[fr:Nourriture]]
17183 [[zh:食品]]
17184 !! html/php
17185 es:Alimento fr:Nourriture zh:食品
17186 !! html/parsoid
17187 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
17188 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Nourriture"/>
17189 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/食品"/>
17190 !! end
17191
17192 !! test
17193 Duplicate interlanguage links (T26502)
17194 !! options
17195 ill
17196 !! wikitext
17197 [[es:1]]
17198 [[es:2]]
17199 [[fr:1]]
17200 [[fr:2]]
17201 !! html/php
17202 es:1 fr:1
17203 !! html/parsoid
17204 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/1"/>
17205 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/2"/>
17206 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/1"/>
17207 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/2"/>
17208 !! end
17209
17210 ###
17211 ### Sections
17212 ###
17213 !! test
17214 Basic section headings
17215 !! wikitext
17216 ==Headline 1==
17217 Some text
17218
17219 ==Headline 2==
17220 More
17221 ===Smaller headline===
17222 Blah blah
17223 !! html
17224 <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>
17225 <p>Some text
17226 </p>
17227 <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>
17228 <p>More
17229 </p>
17230 <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>
17231 <p>Blah blah
17232 </p>
17233 !! end
17234
17235 !! test
17236 Section headings with TOC
17237 !! wikitext
17238 ==Headline 1==
17239 ===Subheadline 1===
17240 =====Skipping a level=====
17241 ======Skipping a level======
17242
17243 ==Headline 2==
17244 Some text
17245 ===Another headline===
17246 !! html
17247 <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>
17248 <ul>
17249 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
17250 <ul>
17251 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
17252 <ul>
17253 <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>
17254 <ul>
17255 <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>
17256 </ul>
17257 </li>
17258 </ul>
17259 </li>
17260 </ul>
17261 </li>
17262 <li class="toclevel-1 tocsection-5"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
17263 <ul>
17264 <li class="toclevel-2 tocsection-6"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
17265 </ul>
17266 </li>
17267 </ul>
17268 </div>
17269
17270 <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>
17271 <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>
17272 <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>
17273 <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>
17274 <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>
17275 <p>Some text
17276 </p>
17277 <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>
17278
17279 !! end
17280
17281 !! test
17282 TOC anchors don't collide
17283 !! wikitext
17284 __FORCETOC__
17285 ==Headline 2==
17286 ==Headline==
17287 ==Headline 2==
17288 ==Headline==
17289 !! html/php
17290 <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>
17291 <ul>
17292 <li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
17293 <li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
17294 <li class="toclevel-1 tocsection-3"><a href="#Headline_2_2"><span class="tocnumber">3</span> <span class="toctext">Headline 2</span></a></li>
17295 <li class="toclevel-1 tocsection-4"><a href="#Headline_3"><span class="tocnumber">4</span> <span class="toctext">Headline</span></a></li>
17296 </ul>
17297 </div>
17298
17299 <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>
17300 <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>
17301 <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>
17302 <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>
17303
17304 !! end
17305
17306 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
17307 # Parsoid html2wt direction adds <nowiki> for level 7 and up.
17308 !! test
17309 Handling of sections up to level 6 and beyond
17310 !! options
17311 parsoid=wt2html
17312 !! wikitext
17313 =Level 1 Heading=
17314 ==Level 2 Heading==
17315 ===Level 3 Heading===
17316 ====Level 4 Heading====
17317 =====Level 5 Heading=====
17318 ======Level 6 Heading======
17319 =======Level 7 Heading=======
17320 ========Level 8 Heading========
17321 =========Level 9 Heading=========
17322 ==========Level 10 Heading==========
17323 !! html/php
17324 <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>
17325 <ul>
17326 <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
17327 <ul>
17328 <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>
17329 <ul>
17330 <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>
17331 <ul>
17332 <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>
17333 <ul>
17334 <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>
17335 <ul>
17336 <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>
17337 <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>
17338 <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>
17339 <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>
17340 <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>
17341 </ul>
17342 </li>
17343 </ul>
17344 </li>
17345 </ul>
17346 </li>
17347 </ul>
17348 </li>
17349 </ul>
17350 </li>
17351 </ul>
17352 </div>
17353
17354 <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>
17355 <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>
17356 <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>
17357 <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>
17358 <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>
17359 <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>
17360 <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>
17361 <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>
17362 <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>
17363 <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>
17364
17365 !! html/parsoid
17366 <h1 id="Level_1_Heading" data-parsoid='{}'>Level 1 Heading</h1>
17367 <h2 id="Level_2_Heading" data-parsoid='{}'>Level 2 Heading</h2>
17368 <h3 id="Level_3_Heading" data-parsoid='{}'>Level 3 Heading</h3>
17369 <h4 id="Level_4_Heading" data-parsoid='{}'>Level 4 Heading</h4>
17370 <h5 id="Level_5_Heading" data-parsoid='{}'>Level 5 Heading</h5>
17371 <h6 id="Level_6_Heading" data-parsoid='{}'>Level 6 Heading</h6>
17372 <h6 id="=Level_7_Heading=" data-parsoid='{}'><span id=".3DLevel_7_Heading.3D" typeof="mw:FallbackId"></span>=Level 7 Heading=</h6>
17373 <h6 id="==Level_8_Heading==" data-parsoid='{}'><span id=".3D.3DLevel_8_Heading.3D.3D" typeof="mw:FallbackId"></span>==Level 8 Heading==</h6>
17374 <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>
17375 <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>
17376 !! end
17377
17378 !! test
17379 TOC regression (T11764)
17380 !! wikitext
17381 ==title 1==
17382 ===title 1.1===
17383 ====title 1.1.1====
17384 ===title 1.2===
17385 ==title 2==
17386 ===title 2.1===
17387 !! html
17388 <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>
17389 <ul>
17390 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
17391 <ul>
17392 <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>
17393 <ul>
17394 <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>
17395 </ul>
17396 </li>
17397 <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>
17398 </ul>
17399 </li>
17400 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
17401 <ul>
17402 <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>
17403 </ul>
17404 </li>
17405 </ul>
17406 </div>
17407
17408 <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>
17409 <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>
17410 <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>
17411 <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>
17412 <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>
17413 <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>
17414
17415 !! end
17416
17417 !! test
17418 TOC for heading containing <span id="..."></span> (T96153)
17419 !! wikitext
17420 __FORCETOC__
17421 ==<span id="old-anchor"></span>New title==
17422 !! html/php
17423 <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>
17424 <ul>
17425 <li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
17426 </ul>
17427 </div>
17428
17429 <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>
17430
17431 !! end
17432
17433 !! test
17434 TOC with wgMaxTocLevel=3 (T8204)
17435 !! options
17436 wgMaxTocLevel=3
17437 !! wikitext
17438 ==title 1==
17439 ===title 1.1===
17440 ====title 1.1.1====
17441 ===title 1.2===
17442 ==title 2==
17443 ===title 2.1===
17444 !! html
17445 <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>
17446 <ul>
17447 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
17448 <ul>
17449 <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>
17450 <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>
17451 </ul>
17452 </li>
17453 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
17454 <ul>
17455 <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>
17456 </ul>
17457 </li>
17458 </ul>
17459 </div>
17460
17461 <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>
17462 <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>
17463 <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>
17464 <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>
17465 <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>
17466 <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>
17467
17468 !! end
17469
17470 !! test
17471 TOC with wgMaxTocLevel=3 and two level four headings (T8204)
17472 !! options
17473 wgMaxTocLevel=3
17474 !! wikitext
17475 ==Section 1==
17476 ===Section 1.1===
17477 ====Section 1.1.1====
17478 ====Section 1.1.1.1====
17479 ==Section 2==
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="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
17484 <ul>
17485 <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>
17486 </ul>
17487 </li>
17488 <li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li>
17489 </ul>
17490 </div>
17491
17492 <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>
17493 <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>
17494 <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>
17495 <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>
17496 <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>
17497
17498 !! end
17499
17500
17501 !! test
17502 Resolving duplicate section names
17503 !! wikitext
17504 ==Foo bar==
17505 ==Foo bar==
17506 !! html
17507 <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>
17508 <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>
17509
17510 !! end
17511
17512 !! test
17513 Resolving duplicate section names with differing case (T12721)
17514 !! wikitext
17515 ==Foo bar==
17516 ==Foo Bar==
17517 !! html
17518 <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>
17519 <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>
17520
17521 !! end
17522
17523 !! article
17524 Template:sections
17525 !! text
17526 ===Section 1===
17527 ==Section 2==
17528 !! endarticle
17529
17530 !! test
17531 Template with sections, __NOTOC__
17532 !! wikitext
17533 __NOTOC__
17534 ==Section 0==
17535 {{sections}}
17536 ==Section 4==
17537 !! html
17538 <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>
17539 <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>
17540 <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>
17541 <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>
17542
17543 !! end
17544
17545 !! test
17546 __NOEDITSECTION__ keyword
17547 !! wikitext
17548 __NOEDITSECTION__
17549 ==Section 1==
17550 ==Section 2==
17551 !! html
17552 <h2><span class="mw-headline" id="Section_1">Section 1</span></h2>
17553 <h2><span class="mw-headline" id="Section_2">Section 2</span></h2>
17554
17555 !! end
17556
17557 !! test
17558 Link inside a section heading
17559 !! wikitext
17560 ==Section with a [[Main Page|link]] in it==
17561 !! html
17562 <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>
17563
17564 !! end
17565
17566 !! test
17567 TOC regression (T14077)
17568 !! wikitext
17569 __TOC__
17570 ==title 1==
17571 ===title 1.1===
17572 ==title 2==
17573 !! html
17574 <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>
17575 <ul>
17576 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
17577 <ul>
17578 <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>
17579 </ul>
17580 </li>
17581 <li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li>
17582 </ul>
17583 </div>
17584
17585 <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>
17586 <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>
17587 <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>
17588
17589 !! end
17590
17591 !! test
17592 T3219 URL next to image (good)
17593 !! wikitext
17594 http://example.com [[File:Foobar.jpg]]
17595 !! html/php
17596 <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>
17597 </p>
17598 !! html/parsoid
17599 <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>
17600 !!end
17601
17602 # Parsoid doesn't wt2wt this cleanly because it adds <nowiki>s.
17603 !! test
17604 Short headings with trailing space should match behavior of Parser::doHeadings (T21910)
17605 !! options
17606 parsoid=wt2html,html2html
17607 !! wikitext
17608 ===
17609 The line above must have a trailing space!
17610 === <!--
17611 --> <!-- -->
17612 But just in case it doesn't...
17613 !! html/php
17614 <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>
17615 <p>The line above must have a trailing space!
17616 </p>
17617 <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>
17618 <p>But just in case it doesn't...
17619 </p>
17620 !! html/parsoid
17621 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
17622 <p>The line above must have a trailing space!</p>
17623 <h1 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h1> <!--
17624 --> <!-- -->
17625 <p>But just in case it doesn't...</p>
17626 !! end
17627
17628 !! test
17629 Header with special characters (T27462)
17630 !! wikitext
17631 The tooltips shall not show entities to the user (ie. be double escaped)
17632
17633 ==text > text==
17634 section 1
17635
17636 ==text < text==
17637 section 2
17638
17639 ==text & text==
17640 section 3
17641
17642 ==text ' text==
17643 section 4
17644
17645 ==text " text==
17646 section 5
17647 !! html/php
17648 <p>The tooltips shall not show entities to the user (ie. be double escaped)
17649 </p>
17650 <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>
17651 <ul>
17652 <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>
17653 <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>
17654 <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>
17655 <li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li>
17656 <li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li>
17657 </ul>
17658 </div>
17659
17660 <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>
17661 <p>section 1
17662 </p>
17663 <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>
17664 <p>section 2
17665 </p>
17666 <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>
17667 <p>section 3
17668 </p>
17669 <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>
17670 <p>section 4
17671 </p>
17672 <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>
17673 <p>section 5
17674 </p>
17675 !! html/parsoid
17676 <p>The tooltips shall not show entities to the user (ie. be double escaped)</p>
17677
17678 <h2 id="text_>_text"><span id="text_.3E_text" typeof="mw:FallbackId"></span>text > text</h2>
17679 <p>section 1</p>
17680
17681 <h2 id="text_&lt;_text"><span id="text_.3C_text" typeof="mw:FallbackId"></span>text &lt; text</h2>
17682 <p>section 2</p>
17683
17684 <h2 id="text_&amp;_text"><span id="text_.26_text" typeof="mw:FallbackId"></span>text &amp; text</h2>
17685 <p>section 3</p>
17686
17687 <h2 id="text_'_text"><span id="text_.27_text" typeof="mw:FallbackId"></span>text ' text</h2>
17688 <p>section 4</p>
17689
17690 <h2 id='text_"_text'><span id="text_.22_text" typeof="mw:FallbackId"></span>text " text</h2>
17691 <p>section 5</p>
17692 !! end
17693
17694 !! test
17695 Header with space, plus and underscore as entity
17696 !! wikitext
17697 Id should not contain + for spaces
17698
17699 ==Space between Text==
17700 section 1
17701
17702 ==Space-Entity&#32;between&#32;Text==
17703 section 2
17704
17705 ==Plus+between+Text==
17706 section 3
17707
17708 ==Plus-Entity&#43;between&#43;Text==
17709 section 4
17710
17711 ==Underscore_between_Text==
17712 section 5
17713
17714 ==Underscore-Entity&#95;between&#95;Text==
17715 section 6
17716
17717 [[#Space between Text]]
17718 [[#Space-Entity&#32;between&#32;Text]]
17719 [[#Plus+between+Text]]
17720 [[#Plus-Entity&#43;between&#43;Text]]
17721 [[#Underscore_between_Text]]
17722 [[#Underscore-Entity&#95;between&#95;Text]]
17723 !! html/php
17724 <p>Id should not contain + for spaces
17725 </p>
17726 <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>
17727 <ul>
17728 <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>
17729 <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>
17730 <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>
17731 <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>
17732 <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>
17733 <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>
17734 </ul>
17735 </div>
17736
17737 <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>
17738 <p>section 1
17739 </p>
17740 <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>
17741 <p>section 2
17742 </p>
17743 <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>
17744 <p>section 3
17745 </p>
17746 <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>
17747 <p>section 4
17748 </p>
17749 <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>
17750 <p>section 5
17751 </p>
17752 <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>
17753 <p>section 6
17754 </p><p><a href="#Space_between_Text">#Space between Text</a>
17755 <a href="#Space-Entity_between_Text">#Space-Entity&#32;between&#32;Text</a>
17756 <a href="#Plus.2Bbetween.2BText">#Plus+between+Text</a>
17757 <a href="#Plus-Entity.2Bbetween.2BText">#Plus-Entity&#43;between&#43;Text</a>
17758 <a href="#Underscore_between_Text">#Underscore_between_Text</a>
17759 <a href="#Underscore-Entity_between_Text">#Underscore-Entity&#95;between&#95;Text</a>
17760 </p>
17761 !! html/parsoid
17762 <p>Id should not contain + for spaces</p>
17763
17764 <h2 id="Space_between_Text">Space between Text</h2>
17765 <p>section 1</p>
17766
17767 <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>
17768 <p>section 2</p>
17769
17770 <h2 id="Plus+between+Text"><span id="Plus.2Bbetween.2BText" typeof="mw:FallbackId"></span>Plus+between+Text</h2>
17771 <p>section 3</p>
17772
17773 <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>
17774 <p>section 4</p>
17775
17776 <h2 id="Underscore_between_Text">Underscore_between_Text</h2>
17777 <p>section 5</p>
17778
17779 <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>
17780 <p>section 6</p>
17781
17782 <p><a rel="mw:WikiLink" href="./Main_Page#Space_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Space_between_Text"},"sa":{"href":"#Space between Text"}}'>#Space between Text</a>
17783 <a rel="mw:WikiLink" href="./Main_Page#Space-Entity_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Space-Entity_between_Text"},"sa":{"href":"#Space-Entity&amp;#32;between&amp;#32;Text"}}'>#Space-Entity between Text</a>
17784 <a rel="mw:WikiLink" href="./Main_Page#Plus+between+Text" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Plus+between+Text"},"sa":{"href":"#Plus+between+Text"}}'>#Plus+between+Text</a>
17785 <a rel="mw:WikiLink" href="./Main_Page#Plus-Entity+between+Text" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Plus-Entity+between+Text"},"sa":{"href":"#Plus-Entity&amp;#43;between&amp;#43;Text"}}'>#Plus-Entity+between+Text</a>
17786 <a rel="mw:WikiLink" href="./Main_Page#Underscore_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Underscore_between_Text"},"sa":{"href":"#Underscore_between_Text"}}'>#Underscore_between_Text</a>
17787 <a rel="mw:WikiLink" href="./Main_Page#Underscore-Entity_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Underscore-Entity_between_Text"},"sa":{"href":"#Underscore-Entity&amp;#95;between&amp;#95;Text"}}'>#Underscore-Entity_between_Text</a></p>
17788 !! end
17789
17790 # Parsoid html2wt disabled because it adds padding spaces around =
17791 !! test
17792 Headers with excess '=' characters
17793 (Are similar tests necessary beyond the 1st level?)
17794 !! options
17795 parsoid=wt2html,wt2wt,html2html
17796 !! wikitext
17797 =foo==
17798 ==foo=
17799 =''italic'' heading==
17800 ==''italic'' heading=
17801 !! html/php
17802 <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>
17803 <ul>
17804 <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
17805 <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
17806 <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>
17807 <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>
17808 </ul>
17809 </div>
17810
17811 <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>
17812 <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>
17813 <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>
17814 <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>
17815
17816 !! html/parsoid
17817 <h1 id="foo="><span id="foo.3D" typeof="mw:FallbackId"></span>foo=</h1>
17818 <h1 id="=foo"><span id=".3Dfoo" typeof="mw:FallbackId"></span>=foo</h1>
17819 <h1 id="italic_heading="><span id="italic_heading.3D" typeof="mw:FallbackId"></span><i>italic</i> heading=</h1>
17820 <h1 id="=italic_heading"><span id=".3Ditalic_heading" typeof="mw:FallbackId"></span>=<i>italic</i> heading</h1>
17821 !! end
17822
17823 !! test
17824 HTML headers vs TOC (T25393)
17825 (__NOEDITSECTION__ for clearer output, doesn't matter here)
17826 !! wikitext
17827 <h1>Header 1</h1>
17828 ==Header 1.1==
17829 ==Header 1.2==
17830
17831 <h1>Header 2
17832 </h1>
17833 ==Header 2.1==
17834 ==Header 2.2==
17835 __NOEDITSECTION__
17836 !! html/php
17837 <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>
17838 <ul>
17839 <li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
17840 <ul>
17841 <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>
17842 <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>
17843 </ul>
17844 </li>
17845 <li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a>
17846 <ul>
17847 <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>
17848 <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>
17849 </ul>
17850 </li>
17851 </ul>
17852 </div>
17853
17854 <h1><span class="mw-headline" id="Header_1">Header 1</span></h1>
17855 <h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2>
17856 <h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2>
17857 <h1><span class="mw-headline" id="Header_2">Header 2
17858 </span></h1>
17859 <h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2>
17860 <h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2>
17861
17862 !! html/parsoid
17863 <h1 id="Header_1" data-parsoid='{"stx":"html"}'>Header 1</h1>
17864 <h2 id="Header_1.1" data-parsoid='{}'>Header 1.1</h2>
17865 <h2 id="Header_1.2" data-parsoid='{}'>Header 1.2</h2>
17866
17867 <h1 id="Header_2" data-parsoid='{"stx":"html"}'>Header 2
17868 </h1>
17869 <h2 id="Header_2.1" data-parsoid='{}'>Header 2.1</h2>
17870 <h2 id="Header_2.2" data-parsoid='{}'>Header 2.2</h2>
17871 <meta property="mw:PageProp/noeditsection"/>
17872 !! end
17873
17874 !! test
17875 Single-line or multiline-comments can follow headings
17876 !! options
17877 parsoid=wt2html,wt2wt
17878 !! wikitext
17879 ==foo==<!---->
17880 ==bar==<!--c1-->
17881 ==baz==<!--
17882 c2
17883 c3-->
17884 !! html/php
17885 <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>
17886 <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>
17887 <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>
17888
17889 !! html/parsoid
17890 <h2 id="foo">foo</h2><!---->
17891 <h2 id="bar">bar</h2><!--c1-->
17892 <h2 id="baz">baz</h2><!--
17893 c2
17894 c3-->
17895 !! end
17896
17897 !! test
17898 T3219 URL next to image (broken)
17899 !! wikitext
17900 http://example.com[[File:Foobar.jpg]]
17901 !! html/php
17902 <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>
17903 </p>
17904 !! html/parsoid
17905 <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>
17906 !!end
17907
17908 !! test
17909 T3186 news: in the middle of text
17910 !! wikitext
17911 http://en.wikinews.org/wiki/Wikinews:Workplace
17912 !! html
17913 <p><a rel="nofollow" class="external free" href="http://en.wikinews.org/wiki/Wikinews:Workplace">http://en.wikinews.org/wiki/Wikinews:Workplace</a>
17914 </p>
17915 !!end
17916
17917
17918 !! test
17919 Namespaced link must have a title
17920 !! wikitext
17921 [[Project:]]
17922 !! html
17923 <p>[[Project:]]
17924 </p>
17925 !!end
17926
17927 !! test
17928 Namespaced link must have a title (bad fragment version)
17929 !! wikitext
17930 [[Project:#fragment]]
17931 !! html
17932 <p>[[Project:#fragment]]
17933 </p>
17934 !!end
17935
17936
17937 ###
17938 ### HTML tags and HTML attributes
17939 ###
17940
17941 !! test
17942 div with no attributes
17943 !! wikitext
17944 <div>HTML rocks</div>
17945 !! html
17946 <div>HTML rocks</div>
17947
17948 !! end
17949
17950 !! test
17951 div with double-quoted attribute
17952 !! wikitext
17953 <div id="rock">HTML rocks</div>
17954 !! html
17955 <div id="rock">HTML rocks</div>
17956
17957 !! end
17958
17959 !! test
17960 div with single-quoted attribute
17961 !! wikitext
17962 <div id='rock'>HTML rocks</div>
17963 !! html
17964 <div id="rock">HTML rocks</div>
17965
17966 !! end
17967
17968 !! test
17969 div with unquoted attribute
17970 !! wikitext
17971 <div id=rock>HTML rocks</div>
17972 !! html
17973 <div id="rock">HTML rocks</div>
17974
17975 !! end
17976
17977 !! test
17978 div with illegal double attributes
17979 !! wikitext
17980 <div id="a" id="b">HTML rocks</div>
17981 !! html
17982 <div id="b">HTML rocks</div>
17983
17984 !!end
17985
17986 !! test
17987 div with empty attribute value, space before equals
17988 !! options
17989 parsoid=wt2html,html2html
17990 !! wikitext
17991 <div class =>HTML rocks</div>
17992 !! html/php
17993 <div class="">HTML rocks</div>
17994
17995 !! html/parsoid
17996 <div class="" data-parsoid='{"stx":"html"}'>HTML rocks</div>
17997 !! end
17998
17999 !! test
18000 div with multiple empty attribute values
18001 !! config
18002 wgFragmentMode=[ 'html5', 'legacy' ]
18003 !! options
18004 parsoid=wt2html,html2html
18005 !! wikitext
18006 <div id= title=>HTML rocks</div>
18007 !! html/php
18008 <div id="title=">HTML rocks</div>
18009
18010 !! html/parsoid
18011 <div id="title=" data-parsoid='{"stx":"html"}'>HTML rocks</div>
18012 !! end
18013
18014 # FIXME Parsoid doesn't actually match PHP here.
18015 # Probably we should use the synthetic <foo /> or <indicator>
18016 # extensions for this test, which are enabled when running parser tests.
18017 !! test
18018 Extension tag in attribute value
18019 !! wikitext
18020 <span title="<translate>123</translate>">ok</span>
18021 !! html/php+disabled
18022 <p>&lt;span title="&lt;translate&gt;123&lt;/translate&gt;"&gt;ok&lt;/span&gt;
18023 </p>
18024 !! html/parsoid
18025 <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>
18026 !! end
18027
18028 !! test
18029 table with multiple empty attribute values
18030 !! options
18031 parsoid=wt2html,html2html
18032 !! wikitext
18033 {| title= id=
18034 |hi
18035 |}
18036 !! html/php
18037 <table title="id=">
18038 <tr>
18039 <td>hi
18040 </td></tr></table>
18041
18042 !! html/parsoid
18043 <table title="id=">
18044 <tbody><tr><td>hi</td></tr>
18045 </tbody></table>
18046 !! end
18047
18048 !! test
18049 div with braces in attribute value
18050 !! wikitext
18051 <div title="{}">Foo</div>
18052 !! html/php
18053 <div title="&#123;&#125;">Foo</div>
18054
18055 !! html/parsoid
18056 <div title="{}">Foo</div>
18057 !! end
18058
18059 !! test
18060 div with empty attribute value, no space before equals
18061 !! options
18062 parsoid=wt2html,html2html
18063 !! wikitext
18064 <div class=>HTML rocks</div>
18065 !! html/php
18066 <div class="">HTML rocks</div>
18067
18068 !! html/parsoid
18069 <div class="">HTML rocks</div>
18070 !! end
18071
18072 !! test
18073 HTML multiple attributes correction
18074 !! wikitext
18075 <p class="error" class="awesome">Awesome!</p>
18076 !! html
18077 <p class="awesome">Awesome!</p>
18078
18079 !!end
18080
18081 !! test
18082 Table multiple attributes correction
18083 !! wikitext
18084 {|
18085 !+ class="error" class="awesome"|status
18086 |}
18087 !! html
18088 <table>
18089 <tr>
18090 <th class="awesome">status
18091 </th></tr></table>
18092
18093 !!end
18094
18095 !! test
18096 DIV IN UPPERCASE
18097 !! wikitext
18098 <DIV ID="x">HTML ROCKS</DIV>
18099 !! html
18100 <div id="x">HTML ROCKS</div>
18101
18102 !!end
18103
18104 !! test
18105 Non-ASCII pseudo-tags are rendered as text
18106 !! wikitext
18107 <khyô>
18108 !! html
18109 <p>&lt;khyô&gt;
18110 </p>
18111 !! end
18112
18113 !! test
18114 Pseudo-tag with URL 'name' renders as url link
18115 !! wikitext
18116 <http://example.com/>
18117 !! html
18118 <p>&lt;<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&gt;
18119 </p>
18120 !! end
18121
18122 !! test
18123 text with amp in the middle of nowhere
18124 !! wikitext
18125 Remember AT&T?
18126 !! html
18127 <p>Remember AT&amp;T?
18128 </p>
18129 !! end
18130
18131 !! test
18132 text with character entity: eacute
18133 !! wikitext
18134 I always thought &eacute; was a cute letter.
18135 !! html+tidy
18136 <p>I always thought &#233; was a cute letter.
18137 </p>
18138 !! end
18139
18140 !! test
18141 text with entity-escaped character entity-like string: eacute
18142 !! wikitext
18143 I always thought &amp;eacute; was a cute letter.
18144 !! html
18145 <p>I always thought &amp;eacute; was a cute letter.
18146 </p>
18147 !! end
18148
18149 !! test
18150 text with undefined character entity: xacute
18151 !! wikitext
18152 I always thought &xacute; was a cute letter.
18153 !! html
18154 <p>I always thought &amp;xacute; was a cute letter.
18155 </p>
18156 !! end
18157
18158 !! test
18159 HTML5 tags
18160 !! wikitext
18161 <data value="5">five</data>
18162 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
18163 <mark>This highlighted text</mark>
18164 !! html
18165 <p><data value="5">five</data>
18166 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
18167 <mark>This highlighted text</mark>
18168 </p>
18169 !! end
18170
18171 !! test
18172 HTML tag with leading space is parsed as text
18173 !! wikitext
18174 < div>foo< /div>
18175 !! html
18176 <p>&lt; div&gt;foo&lt; /div&gt;
18177 </p>
18178 !! end
18179
18180 ## Don't expect Parsoid and PHP to match, since PHP isn't exactly following
18181 ## the HTML5 parsing spec.
18182 !! test
18183 Element with broken attribute syntax
18184 !! options
18185 parsoid=wt2html
18186 !! wikitext
18187 <div style=" style="123">hi</div>
18188 <div =>ho</div>
18189 !! html/php
18190 <div style="123">hi</div>
18191 <div>ho</div>
18192
18193 !! html/parsoid
18194 <div style=" style=" data-parsoid='{"stx":"html","a":{"123\"":null},"sa":{"123\"":""}}'>hi</div>
18195 <div data-parsoid='{"stx":"html","a":{"=":null},"sa":{"=":""}}'>ho</div>
18196 !! end
18197
18198 ###
18199 ### Nesting tests (see T43545, T52604, T53081)
18200 ###
18201
18202 # This test case is fixed in Parsoid by domino 1.0.12. (T52604)
18203 # Note that html2wt is considerably more difficult if we use <b> in
18204 # the test case, instead of <small>
18205 !! test
18206 Ensure that HTML adoption agency algorithm is properly implemented.
18207 !! wikitext
18208 <small>X<small>Y</small>Z</small>
18209 !! html
18210 <p><small>X<small>Y</small>Z</small>
18211 </p>
18212 !! end
18213
18214 # This was T43545 in the PHP parser.
18215 !! test
18216 Nesting of <kbd>
18217 !! wikitext
18218 <kbd>X<kbd>Y</kbd>Z</kbd>
18219 !! html+tidy
18220 <p><kbd>X<kbd>Y</kbd>Z</kbd>
18221 </p>
18222 !! end
18223
18224 # The following cases were T53081 in the PHP parser.
18225 # Note that there are some other nestable tags (b, i, etc) which are
18226 # not covered; see T53081 for discussion.
18227
18228 !! test
18229 Nesting of <em>
18230 !! wikitext
18231 <em>X<em>Y</em>Z</em>
18232 !! html+tidy
18233 <p><em>X<em>Y</em>Z</em>
18234 </p>
18235 !! end
18236
18237 !! test
18238 Nesting of <strong>
18239 !! wikitext
18240 <strong>X<strong>Y</strong>Z</strong>
18241 !! html+tidy
18242 <p><strong>X<strong>Y</strong>Z</strong>
18243 </p>
18244 !! end
18245
18246 !! test
18247 Nesting of <q>
18248 !! wikitext
18249 <q>X<q>Y</q>Z</q>
18250 !! html+tidy
18251 <p><q>X<q>Y</q>Z</q>
18252 </p>
18253 !! end
18254
18255 !! test
18256 Nesting of <ruby>
18257 !! wikitext
18258 <ruby>X<ruby>Y</ruby>Z</ruby>
18259 !! html
18260 <p><ruby>X<ruby>Y</ruby>Z</ruby>
18261 </p>
18262 !! end
18263
18264 !! test
18265 Nesting of <bdo>
18266 !! wikitext
18267 <bdo>X<bdo>Y</bdo>Z</bdo>
18268 !! html
18269 <p><bdo>X<bdo>Y</bdo>Z</bdo>
18270 </p>
18271 !! end
18272
18273
18274 ###
18275 ### Media links
18276 ###
18277
18278 !! test
18279 Media link
18280 !! wikitext
18281 [[Media:Foobar.jpg]]
18282 [[Media:Video.ogv]]
18283 [[:Media:Video.ogv]]
18284 !! html/php
18285 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a>
18286 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
18287 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
18288 </p>
18289 !! html/parsoid
18290 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Media:Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a>
18291 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" resource="./Media:Video.ogv" title="Video.ogv">Media:Video.ogv</a>
18292 <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>
18293 !! end
18294
18295 !! test
18296 Media link with text
18297 !! wikitext
18298 [[Media:Foobar.jpg|A neat file to look at]]
18299 !! html/php
18300 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">A neat file to look at</a>
18301 </p>
18302 !! html/parsoid
18303 <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>
18304 !! end
18305
18306 !! test
18307 Localized media link
18308 !! options
18309 language=is
18310 !! wikitext
18311 [[Miðill:Foobar.jpg]]
18312
18313 [[Miðill:Foobar.jpg|Icelandic]]
18314 !! html/php
18315 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Miðill:Foobar.jpg</a>
18316 </p><p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Icelandic</a>
18317 </p>
18318 !! html/parsoid
18319 <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>
18320 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Miðill:Foobar.jpg" title="Foobar.jpg">Icelandic</a></p>
18321 !! end
18322
18323 # FIXME: this is still bad HTML tag nesting
18324 # FIXME: doBlockLevels won't wrap this in a paragraph because it contains a div
18325 # Parsoid & Remex fix the p-wrapping since they operate on the DOM.
18326 !! test
18327 Media link with nasty text
18328 !! options
18329 parsoid=wt2html,html2html
18330 !! wikitext
18331 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
18332 !! html/php
18333 <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>
18334
18335 !! html/php+tidy
18336 <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>
18337 !! html/parsoid
18338 <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>
18339 !! end
18340
18341 !! test
18342 Media link from missing resource (parsoid-only)
18343 !! options
18344 parsoid=html2wt
18345 !! html/parsoid
18346 <a rel="mw:MediaLink" href="http://example.com/images/3/3a/Foobar.jpg">Bat!</a>
18347 !! wikitext
18348 [[Media:Foobar.jpg|Bat!]]
18349 !! end
18350
18351 !! test
18352 Media link from missing resource, localized (parsoid-only)
18353 !! options
18354 parsoid=html2wt
18355 language=is
18356 !! html/parsoid
18357 <a rel="mw:MediaLink" href="http://example.com/images/3/3a/Foobar.jpg">Bat!</a>
18358 !! wikitext
18359 [[Miðill:Foobar.jpg|Bat!]]
18360 !! end
18361
18362 # This is a sanity test to ensure we don't crash or choke when given
18363 # old cached 1.7.0 HTML for media links; we don't require that the
18364 # result be "valid" because wt2wt was completely broken in 1.7.0
18365 !! test
18366 Media link from old 1.7.0 DOM spec (crash test, parsoid-only) T198511
18367 !! options
18368 parsoid=html2wt
18369 !! html/parsoid
18370 <p>This is what Parsoid would emit (and we still handle this HTML fine):</p>
18371 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
18372 <p>But VisualEditor would mangle the rel attribute, and give us back this:</p>
18373 <p><a rel="mw:ExtLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
18374 <p>But at least we don't crash when trying to handle the mangled HTML!</p>
18375 !! wikitext
18376 This is what Parsoid would emit (and we still handle this HTML fine):
18377
18378 [[Media:Foobar.jpg|A neat file to look at]]
18379
18380 But VisualEditor would mangle the rel attribute, and give us back this:
18381
18382 [//example.com/images/3/3a/Foobar.jpg A neat file to look at]
18383
18384 But at least we don't crash when trying to handle the mangled HTML!
18385 !! end
18386
18387 !! test
18388 Media link to nonexistent file (T3702)
18389 !! wikitext
18390 [[Media:No such.jpg]]
18391 [[Media:No_such file.jpg]]
18392 !! html/php
18393 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a>
18394 <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>
18395 </p>
18396 !! html/parsoid
18397 <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>
18398 <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>
18399 !! end
18400
18401 !! test
18402 Image link to nonexistent file (T3850 - good)
18403 !! wikitext
18404 [[File:No_such.jpg]]
18405 !! html/php
18406 <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>
18407 </p>
18408 !! html/parsoid
18409 <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>
18410 !! end
18411
18412 !! test
18413 :Image link to nonexistent file (T3850 - bad)
18414 !! wikitext
18415 [[:Image:No such.jpg]]
18416 !! html/php
18417 <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>
18418 </p>
18419 !! html/parsoid
18420 <p><a rel="mw:WikiLink" href="./File:No_such.jpg" title="File:No such.jpg">Image:No such.jpg</a></p>
18421 !! end
18422
18423 !! test
18424 Character reference normalization in link text (T3938)
18425 !! wikitext
18426 [[Main Page|this&that]]
18427 !! html
18428 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
18429 </p>
18430 !!end
18431
18432 !! article
18433 אַ
18434 !! text
18435 Test for unicode normalization
18436
18437 The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
18438 !! endarticle
18439
18440 !! test
18441 (T21451) Links should refer to the normalized form.
18442 !! wikitext
18443 [[&#xFB2E;]]
18444 [[&#x5d0;&#x5b7;]]
18445 [[&#x5d0;ַ]]
18446 [[א&#x5b7;]]
18447 [[אַ]]
18448 !! html
18449 <p><a href="/wiki/%D7%90%D6%B7" title="אַ">&#xfb2e;</a>
18450 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;&#x5b7;</a>
18451 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;ַ</a>
18452 <a href="/wiki/%D7%90%D6%B7" title="אַ">א&#x5b7;</a>
18453 <a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a>
18454 </p>
18455 !! end
18456
18457 !! test
18458 Empty attribute crash test (T4067)
18459 !! wikitext
18460 <font color="">foo</font>
18461 !! html
18462 <p><font color="">foo</font>
18463 </p>
18464 !! end
18465
18466 !! test
18467 Empty attribute crash test single-quotes (T4067)
18468 !! wikitext
18469 <font color=''>foo</font>
18470 !! html
18471 <p><font color="">foo</font>
18472 </p>
18473 !! end
18474
18475 !! test
18476 Attribute test: equals, then nothing
18477 !! options
18478 parsoid=wt2html,html2html
18479 !! wikitext
18480 <font color=>foo</font>
18481 !! html/php
18482 <p><font color="">foo</font>
18483 </p>
18484 !! html/parsoid
18485 <p><font color="" data-parsoid='{"stx":"html"}'>foo</font></p>
18486 !! end
18487
18488 !! test
18489 Attribute test: unquoted value
18490 !! options
18491 parsoid=wt2html,html2html
18492 !! wikitext
18493 <font color=x>foo</font>
18494 !! html/php
18495 <p><font color="x">foo</font>
18496 </p>
18497 !! html/parsoid
18498 <p><font color="x" data-parsoid='{"stx":"html"}'>foo</font></p>
18499 !! end
18500
18501 !! test
18502 Attribute test: unquoted but illegal value (hash)
18503 !! wikitext
18504 <font color=#x>foo</font>
18505 !! html
18506 <p><font color="#x">foo</font>
18507 </p>
18508 !! end
18509
18510 # Parsoid does not serialize to empty attribute syntax,
18511 # so wt2wt and html2wt cases are skipped
18512 !! test
18513 Attribute test: no value (T54330)
18514 !! options
18515 parsoid=wt2html,html2html
18516 !! wikitext
18517 <font color>foo</font>
18518 !! html/php
18519 <p><font color="">foo</font>
18520 </p>
18521 !! html/parsoid
18522 <p><font color="">foo</font></p>
18523 !! end
18524
18525 !! test
18526 T4095: link with three closing brackets
18527 !! wikitext
18528 [[Main Page]]]
18529 !! html/php
18530 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
18531 </p>
18532 !! html/parsoid
18533 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>]</p>
18534 !! end
18535
18536 !! test
18537 T4095: link with pipe and three closing brackets
18538 !! wikitext
18539 [[Main Page|link]]]
18540 !! html/php
18541 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
18542 </p>
18543 !! html/parsoid
18544 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">link</a>]</p>
18545 !! end
18546
18547 !! test
18548 T4095: link with pipe and three closing brackets, version 2
18549 !! wikitext
18550 [[Main Page|[http://example.com/]]]
18551 !! html/php
18552 <p><a href="/wiki/Main_Page" title="Main Page">[http://example.com/]</a>
18553 </p>
18554 !! html/parsoid
18555 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">[http://example.com/]</a></p>
18556 !! end
18557
18558
18559 ###
18560 ### Safety
18561 ###
18562
18563 !! article
18564 Template:Dangerous attribute
18565 !! text
18566 " onmouseover="alert(document.cookie)
18567 !! endarticle
18568
18569 !! article
18570 Template:Dangerous style attribute
18571 !! text
18572 border-size: expression(alert(document.cookie))
18573 !! endarticle
18574
18575 !! article
18576 Template:Div style
18577 !! text
18578 <div style="float: right; {{{1}}}">Magic div</div>
18579 !! endarticle
18580
18581 !! test
18582 T4304: HTML attribute safety (safe template; regression T4309)
18583 !! wikitext
18584 <div title="{{test}}"></div>
18585 !! html/php
18586 <div title="This is a test template"></div>
18587
18588 !! html/parsoid
18589 <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>
18590 !! end
18591
18592 # Parsoid has enough context to handle this case
18593 !! test
18594 T4304: HTML attribute safety (dangerous template; 2309)
18595 !! wikitext
18596 <div title="{{dangerous attribute}}"></div>
18597 !! html/php
18598 <div title=""></div>
18599
18600 !! html/parsoid
18601 <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>
18602 !! end
18603
18604 !! test
18605 T4304: HTML attribute safety (dangerous style template; 2309)
18606 !! wikitext
18607 <div style="{{dangerous style attribute}}"></div>
18608 !! html/php
18609 <div style="/* insecure input */"></div>
18610
18611 !! html/parsoid
18612 <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>
18613 !! end
18614
18615 !! test
18616 T4304: HTML attribute safety (safe parameter; 2309)
18617 !! wikitext
18618 {{div style|width: 200px}}
18619 !! html/php
18620 <div style="float: right; width: 200px">Magic div</div>
18621
18622 !! html/parsoid
18623 <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>
18624 !! end
18625
18626 !! test
18627 T4304: HTML attribute safety (unsafe parameter; 2309)
18628 !! wikitext
18629 {{div style|width: expression(alert(document.cookie))}}
18630 !! html/php
18631 <div style="/* insecure input */">Magic div</div>
18632
18633 !! html/parsoid
18634 <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>
18635 !! end
18636
18637 ## Parsoid output here differs; needs investigation.
18638 !! test
18639 T4304: HTML attribute safety (unsafe breakout parameter; 2309)
18640 !! wikitext
18641 {{div style|"><script>alert(document.cookie)</script>}}
18642 !! html
18643 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
18644
18645 !! end
18646
18647 ## Parsoid output here differs; needs investigation.
18648 !! test
18649 T4304: HTML attribute safety (unsafe breakout parameter 2; 2309)
18650 !! wikitext
18651 {{div style|" ><script>alert(document.cookie)</script>}}
18652 !! html
18653 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
18654
18655 !! end
18656
18657 !! test
18658 T4304: HTML attribute safety (link)
18659 !! wikitext
18660 <div title="[[Main Page]]"></div>
18661 !! html/php
18662 <div title="&#91;&#91;Main Page&#93;&#93;"></div>
18663
18664 !! html/parsoid
18665 <div title="[[Main Page]]"></div>
18666 !! end
18667
18668 !! test
18669 T4304: HTML attribute safety (italics)
18670 !! wikitext
18671 <div title="''foobar''"></div>
18672 !! html
18673 <div title="&#39;&#39;foobar&#39;&#39;"></div>
18674
18675 !! end
18676
18677 !! test
18678 T4304: HTML attribute safety (bold)
18679 !! wikitext
18680 <div title="'''foobar'''"></div>
18681 !! html
18682 <div title="&#39;&#39;&#39;foobar&#39;&#39;&#39;"></div>
18683
18684 !! end
18685
18686 !! test
18687 T4304: HTML attribute safety (ISBN)
18688 !! wikitext
18689 <div title="ISBN 1234567890"></div>
18690 !! html
18691 <div title="&#73;SBN 1234567890"></div>
18692
18693 !! end
18694
18695 !! test
18696 T4304: HTML attribute safety (RFC)
18697 !! wikitext
18698 <div title="RFC 1234"></div>
18699 !! html
18700 <div title="&#82;FC 1234"></div>
18701
18702 !! end
18703
18704 !! test
18705 T4304: HTML attribute safety (PMID)
18706 !! wikitext
18707 <div title="PMID 1234567890"></div>
18708 !! html
18709 <div title="&#80;MID 1234567890"></div>
18710
18711 !! end
18712
18713 !! test
18714 T4304: HTML attribute safety (web link)
18715 !! wikitext
18716 <div title="http://example.com/"></div>
18717 !! html
18718 <div title="http&#58;//example.com/"></div>
18719
18720 !! end
18721
18722 !! test
18723 T4304: HTML attribute safety (named web link)
18724 !! wikitext
18725 <div title="[http://example.com/ link]"></div>
18726 !! html/php
18727 <div title="&#91;http&#58;//example.com/ link&#93;"></div>
18728
18729 !! html/parsoid
18730 <div title="[http://example.com/ link]"></div>
18731 !! end
18732
18733 !! test
18734 T5244: HTML attribute safety (extension; safe)
18735 !! wikitext
18736 <div style="<nowiki>background:blue</nowiki>"></div>
18737 !! html/php
18738 <div style="background:blue"></div>
18739
18740 !! html/parsoid
18741 <div style="background:blue" data-parsoid='{"stx":"html","a":{"style":"background:blue"},"sa":{"style":"&lt;nowiki>background:blue&lt;/nowiki>"}}'></div>
18742 !! end
18743
18744 !! test
18745 T5244: HTML attribute safety (extension; unsafe)
18746 !! wikitext
18747 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
18748 !! html/php
18749 <div style="/* insecure input */"></div>
18750
18751 !! html/parsoid
18752 <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>
18753 !! end
18754
18755 # More MSIE fun discovered by Tom Gilder
18756
18757 !! test
18758 MSIE CSS safety test: spurious slash
18759 !! wikitext
18760 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
18761 !! html/php
18762 <div style="/* insecure input */">evil</div>
18763
18764 !! html/parsoid
18765 <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>
18766 !! end
18767
18768 !! test
18769 MSIE CSS safety test: hex code
18770 !! wikitext
18771 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
18772 !! html/php
18773 <div style="/* insecure input */">evil</div>
18774
18775 !! html/parsoid
18776 <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>
18777 !! end
18778
18779 !! test
18780 MSIE CSS safety test: comment in url
18781 !! wikitext
18782 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
18783 !! html/php
18784 <div style="background-image:u rl(javascript:alert(&#39;boo&#39;))">evil</div>
18785
18786 !! html/parsoid
18787 <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>
18788 !! end
18789
18790 !! test
18791 MSIE CSS safety test: comment in expression
18792 !! wikitext
18793 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
18794 !! html/php
18795 <div style="background-image:expres sion(alert(&#39;boo4&#39;))">evil4</div>
18796
18797 !! html/parsoid
18798 <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>
18799 !! end
18800
18801 !! test
18802 CSS safety test (all browsers): vertical tab (T57332 / CVE-2013-4567)
18803 !! wikitext
18804 <p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p>
18805 !! html/php
18806 <p style="/* invalid control char */">A</p>
18807
18808 !! html/parsoid
18809 <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>
18810 !! end
18811
18812 !! test
18813 MSIE 6 CSS safety test: Fullwidth (T57332)
18814 !! wikitext
18815 <p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p>
18816 <div style="top:EXPRESSION(alert())">B</div>
18817 !! html/php
18818 <p style="/* insecure input */">A</p>
18819 <div style="/* insecure input */">B</div>
18820
18821 !! html/parsoid
18822 <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>
18823 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"top:EXPRESSION(alert())"}}'>B</div>
18824 !! end
18825
18826 !! test
18827 MSIE 6 CSS safety test: IPA extensions (T57332)
18828 !! wikitext
18829 <div style="background-image:uʀʟ(javascript:alert())">A</div>
18830 <p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p>
18831 !! html/php
18832 <div style="/* insecure input */">A</div>
18833 <p style="/* insecure input */">B</p>
18834
18835 !! html/parsoid
18836 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:uʀʟ(javascript:alert())"}}'>A</div>
18837 <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>
18838 !! end
18839
18840 !! test
18841 MSIE 6 CSS safety test: sup/sub script (T57332)
18842 !! wikitext
18843 <div style="background-image:url⁽javascript:alert())">A</div>
18844 <div style="background-image:url₍javascript:alert())">B</div>
18845 <p style="font-size: 100px; color: expressioⁿ((title='XSSed'),'red')">C</p>
18846 !! html/php
18847 <div style="/* insecure input */">A</div>
18848 <div style="/* insecure input */">B</div>
18849 <p style="/* insecure input */">C</p>
18850
18851 !! html/parsoid
18852 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url⁽javascript:alert())"}}'>A</div>
18853 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url₍javascript:alert())"}}'>B</div>
18854 <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>
18855 !! end
18856
18857 !! test
18858 Opera -o-link CSS
18859 !! options
18860 parsoid=wt2html,html2html
18861 !! wikitext
18862 <div
18863 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;"
18864 style="-o-link:attr(title);-o-link-source:current">X</div>
18865 !! html/php
18866 <div title="data:text/html,&lt;img src=1 onerror=alert(1)&gt;" style="/* insecure input */">X</div>
18867
18868 !! html/parsoid
18869 <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>
18870 !! end
18871
18872 !! test
18873 MSIE 6 CSS safety test: Repetition markers (T57332)
18874 !! wikitext
18875 <p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p>
18876 <p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p>
18877 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">C</p>
18878 <p style="font-size: 100px; color: expresヽion((title='XSSed'),'red')">D</p>
18879 <p style="font-size: 100px; color: expresﹽion((title='XSSed'),'red')">E</p>
18880 <p style="font-size: 100px; color: expresﹼion((title='XSSed'),'red')">F</p>
18881 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">G</p>
18882 !! html/php
18883 <p style="/* insecure input */">A</p>
18884 <p style="/* insecure input */">B</p>
18885 <p style="/* insecure input */">C</p>
18886 <p style="/* insecure input */">D</p>
18887 <p style="/* insecure input */">E</p>
18888 <p style="/* insecure input */">F</p>
18889 <p style="/* insecure input */">G</p>
18890
18891 !! html/parsoid
18892 <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>
18893 <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>
18894 <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>
18895 <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>
18896 <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>
18897 <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>
18898 <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>
18899 !! end
18900
18901 !! test
18902 Table attribute legitimate extension
18903 !! wikitext
18904 {|
18905 !+ style="<nowiki>color:blue</nowiki>"|status
18906 |}
18907 !! html
18908 <table>
18909 <tr>
18910 <th style="color:blue">status
18911 </th></tr></table>
18912
18913 !!end
18914
18915 !! test
18916 Table attribute safety
18917 !! wikitext
18918 {|
18919 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"|status
18920 |}
18921 !! html
18922 <table>
18923 <tr>
18924 <th style="/* insecure input */">status
18925 </th></tr></table>
18926
18927 !! end
18928
18929 !! test
18930 CSS line continuation 1
18931 !! wikitext
18932 <div style="background-image: u\&#10;rl(test.jpg);"></div>
18933 !! html
18934 <div style="/* insecure input */"></div>
18935
18936 !! end
18937
18938 !! test
18939 CSS line continuation 2
18940 !! wikitext
18941 <div style="background-image: u\&#13;rl(test.jpg); "></div>
18942 !! html
18943 <div style="/* invalid control char */"></div>
18944
18945 !! end
18946
18947 !! article
18948 Template:Identity
18949 !! text
18950 {{{1}}}
18951 !! endarticle
18952
18953 !! test
18954 Expansion of multi-line templates in attribute values (T8255)
18955 !! wikitext
18956 <div style="background: {{identity|#00FF00}}">-</div>
18957 !! html
18958 <div style="background: #00FF00">-</div>
18959
18960 !! end
18961
18962 !! test
18963 Expansion of multi-line templates in attribute values (T8255 sanity check)
18964 !! wikitext
18965 <div style="background:
18966 #00FF00">-</div>
18967 !! html/php
18968 <div style="background: #00FF00">-</div>
18969
18970 !! html/parsoid
18971 <div style="background:
18972 #00FF00">-</div>
18973 !! end
18974
18975 !! test
18976 Expansion of multi-line templates in attribute values (T8255 sanity check 2)
18977 !! wikitext
18978 <div style="background: &#10;#00FF00">-</div>
18979 !! html
18980 <div style="background: &#10;#00FF00">-</div>
18981
18982 !! end
18983
18984 !! test
18985 Tags which are hidden from tidiers cannot pass through the Sanitizer
18986 !! wikitext
18987 <mw:toc><script>alert();</script></mw:toc>
18988 !! html+tidy
18989 <p>&lt;mw:toc&gt;&lt;script&gt;alert();&lt;/script&gt;&lt;/mw:toc&gt;
18990 </p>
18991 !! end
18992
18993 ###
18994 ### Parser hooks (see tests/parser/parserTestsParserHook.php for the <tag> extension)
18995 ###
18996
18997 !! test
18998 Parser hook: empty input
18999 !! wikitext
19000 <tag></tag>
19001 !! html/php
19002 <pre>
19003 ''
19004 array (
19005 )
19006 </pre>
19007
19008 !! html/parsoid
19009 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19010 !! end
19011
19012 ## Don't expect parsoid to rt this form.
19013 !! test
19014 Parser hook: empty input using terminated empty elements
19015 !! options
19016 parsoid=wt2html,html2html
19017 !! wikitext
19018 <tag/>
19019 !! html/php
19020 <pre>
19021 NULL
19022 array (
19023 )
19024 </pre>
19025
19026 !! html/parsoid
19027 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{}}' data-parsoid='{}' about="#mwt2"></pre>
19028 !! end
19029
19030 !! test
19031 Parser hook: empty input using terminated empty elements (space before)
19032 !! wikitext
19033 <tag />
19034 !! html/php
19035 <pre>
19036 NULL
19037 array (
19038 )
19039 </pre>
19040
19041 !! html/parsoid
19042 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{}}' data-parsoid='{}' about="#mwt2"></pre>
19043 !! end
19044
19045 !! test
19046 Parser hook: basic input
19047 !! wikitext
19048 <tag>input</tag>
19049 !! html/php
19050 <pre>
19051 'input'
19052 array (
19053 )
19054 </pre>
19055
19056 !! html/parsoid
19057 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
19058 !! end
19059
19060 ## Don't expect parsoid to rt this form.
19061 !! test
19062 Parser hook: case insensitive
19063 !! options
19064 parsoid=wt2html,html2html
19065 !! wikitext
19066 <TAG>input</TAG>
19067 !! html/php
19068 <pre>
19069 'input'
19070 array (
19071 )
19072 </pre>
19073
19074 !! html/parsoid
19075 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
19076 !! end
19077
19078 ## Don't expect parsoid to rt this form.
19079 !! test
19080 Parser hook: case insensitive, redux
19081 !! options
19082 parsoid=wt2html,html2html
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 !! test
19097 Parser hook: nested tags
19098 !! options
19099 parsoid=wt2html
19100 !! wikitext
19101 <tag><tag></tag></tag>
19102 !! html/php
19103 <pre>
19104 '<tag>'
19105 array (
19106 )
19107 </pre>&lt;/tag&gt;
19108
19109 !! html/php+tidy
19110 <pre>'<tag>'
19111 array (
19112 )
19113 </tag></pre><p>&lt;/tag&gt;
19114 </p>
19115 !! html/parsoid
19116 <pre typeof="mw:Extension/tag" about="#mwt2" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"&lt;tag>"}}'></pre><p>&lt;/tag></p>
19117 !! end
19118
19119 !! test
19120 Parser hook: basic arguments
19121 !! wikitext
19122 <tag width="200" height="100" depth="50" square=""></tag>
19123 !! html/php
19124 <pre>
19125 ''
19126 array (
19127 'width' => '200',
19128 'height' => '100',
19129 'depth' => '50',
19130 'square' => '',
19131 )
19132 </pre>
19133
19134 !! html/parsoid
19135 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19136 !! end
19137
19138 ## Don't expect parsoid to rt this form.
19139 !! test
19140 Parser hook: basic arguments, variations
19141 !! options
19142 parsoid=wt2html,html2html
19143 !! wikitext
19144 <tag width=200 height = "100" depth = '50' square></tag>
19145 !! html/php
19146 <pre>
19147 ''
19148 array (
19149 'width' => '200',
19150 'height' => '100',
19151 'depth' => '50',
19152 'square' => '',
19153 )
19154 </pre>
19155
19156 !! html/parsoid
19157 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19158 !! end
19159
19160 !! test
19161 Parser hook: argument containing a forward slash (T7344)
19162 !! wikitext
19163 <tag filename="/tmp/bla"></tag>
19164 !! html/php
19165 <pre>
19166 ''
19167 array (
19168 'filename' => '/tmp/bla',
19169 )
19170 </pre>
19171
19172 !! html/parsoid
19173 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"filename":"/tmp/bla"},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19174 !! end
19175
19176 ## Don't expect parsoid to rt this form.
19177 !! test
19178 Parser hook: empty input using terminated empty elements (T4374)
19179 !! options
19180 parsoid=wt2html,html2html
19181 !! wikitext
19182 <tag foo=bar/>text
19183 !! html/php
19184 <pre>
19185 NULL
19186 array (
19187 'foo' => 'bar',
19188 )
19189 </pre>text
19190
19191 !! html/parsoid
19192 <pre typeof="mw:Extension/tag" about="#mwt2" data-mw='{"name":"tag","attrs":{"foo":"bar"}}'></pre><p>text</p>
19193 !! end
19194
19195 ## </tag> should be output literally since there is no matching tag that begins it
19196 ## Don't expect parsoid to rt this form.
19197 !! test
19198 Parser hook: basic arguments using terminated empty elements (T4374)
19199 !! options
19200 parsoid=wt2html
19201 !! wikitext
19202 <tag width=200 height = "100" depth = '50' square/>
19203 other stuff
19204 </tag>
19205 !! html/php
19206 <pre>
19207 NULL
19208 array (
19209 'width' => '200',
19210 'height' => '100',
19211 'depth' => '50',
19212 'square' => '',
19213 )
19214 </pre>
19215 <p>other stuff
19216 &lt;/tag&gt;
19217 </p>
19218 !! html/parsoid
19219 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""}}' about="#mwt2"></pre><p>other stuff
19220 &lt;/tag></p>
19221 !! end
19222
19223 ## Don't expect parsoid to rt this form.
19224 !! test
19225 Parser hook: Don't allow unclosed extension tags
19226 !! options
19227 parsoid=wt2html
19228 !! wikitext
19229 test <tag>123
19230
19231 this is a '''test'''
19232 !! html/php
19233 <p>test &lt;tag&gt;123
19234 </p><p>this is a <b>test</b>
19235 </p>
19236 !! html/parsoid
19237 <p>test &lt;tag>123</p>
19238
19239 <p>this is a <b>test</b></p>
19240 !! end
19241
19242 !! test
19243 Parser hook: horizontal rule inside extension tag that outputs <pre>
19244 !! wikitext
19245 <tag>
19246 Hello
19247 <hr/>
19248 Goodbye
19249 </tag>
19250 !! html/php
19251 <pre>
19252 '
19253 Hello
19254 <hr/>
19255 Goodbye
19256 '
19257 array (
19258 )
19259 </pre>
19260
19261 !! end
19262
19263 ###
19264 ### (see tests/parser/parserTestsParserHook.php for the <statictag> extension)
19265 ###
19266
19267 !! test
19268 Parser hook: static parser hook not inside a comment
19269 !! wikitext
19270 <statictag>hello, world</statictag>
19271
19272 <statictag action="flush" />
19273 !! html/php
19274 <p><br />
19275 hello, world
19276 </p>
19277 !! html/parsoid
19278 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{},"body":{"extsrc":"hello, world"}}' data-parsoid='{}' about="#mwt2"></span></p>
19279 <p typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"}}' data-parsoid='{}' about="#mwt4">hello, world</p>
19280 !! end
19281
19282 !! test
19283 Parser hook: static parser hook inside a comment
19284 !! wikitext
19285 <!-- <statictag>hello, world</statictag> -->
19286 <statictag action="flush" />
19287 !! html/php
19288 <p><br />
19289 </p>
19290 !! html/parsoid
19291 <!-- <statictag&#x3E;hello, world</statictag&#x3E; -->
19292 <p typeof='mw:Extension/statictag' data-mw='{"name":"statictag","attrs":{"action":"flush"}}' data-parsoid='{}' about='#mwt2'></p>
19293 !! end
19294
19295 # Nested template calls; this case was broken by Parser.php rev 1.506,
19296 # since reverted.
19297
19298 !! article
19299 Template:One-parameter
19300 !! text
19301 (My parameter is: {{{1}}})
19302 !! endarticle
19303
19304 !! article
19305 Template:Map-one-parameter
19306 !! text
19307 {{{{{1}}}|{{{2}}}}}
19308 !! endarticle
19309
19310 !! test
19311 Nested template calls
19312 !! wikitext
19313 {{Map-one-parameter|One-parameter|param}}
19314 !! html
19315 <p>(My parameter is: param)
19316 </p>
19317 !! end
19318
19319
19320 ###
19321 ### Sanitizer
19322 ###
19323
19324 !! test
19325 Sanitizer: Closing of open tags
19326 !! wikitext
19327 <s></s><table></table>
19328 !! html/php+tidy
19329 <p><s></s></p><table></table>
19330 !! html/parsoid
19331 <p><s data-parsoid='{"stx":"html"}'></s></p><table data-parsoid='{"stx":"html"}'></table>
19332 !! end
19333
19334 !! test
19335 Sanitizer: Closing of open but not closed tags
19336 !! wikitext
19337 <s>foo
19338 !! html
19339 <p><s>foo</s>
19340 </p>
19341 !! end
19342
19343 !! test
19344 Sanitizer: Closing of closed but not open tags
19345 !! options
19346 parsoid=wt2html
19347 !! wikitext
19348 </s>
19349 !! html+tidy
19350 <p class="mw-empty-elt">
19351 </p>
19352 !! end
19353
19354 !! test
19355 Sanitizer: Closing of closed but not open table tags
19356 !! options
19357 parsoid=wt2html
19358 !! wikitext
19359 Table not started</td></tr></table>
19360 !! html+tidy
19361 <p>Table not started
19362 </p>
19363 !! end
19364
19365 !! test
19366 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
19367 !! config
19368 wgFragmentMode=[ 'html5', 'legacy' ]
19369 !! wikitext
19370 <span id="æ: v">byte</span>[[#æ: v|backlink]]
19371 !! html/php
19372 <p><span id="æ:_v">byte</span><a href="#æ:_v">backlink</a>
19373 </p>
19374 !! html/parsoid
19375 <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>
19376 !! end
19377
19378 !! test
19379 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id="" (legacy)
19380 !! config
19381 wgFragmentMode=[ 'legacy' ]
19382 !! wikitext
19383 <span id="æ: v">byte</span>[[#æ: v|backlink]]
19384 !! html/php
19385 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v">backlink</a>
19386 </p>
19387 !! end
19388
19389 # In HTML5, the restrictions are that id must contain at least one character,
19390 # and must not contain any space characters.
19391 !! test
19392 Sanitizer: Validating the contents of the id attribute (T6515)
19393 !! options
19394 disabled
19395 !! wikitext
19396 <br id="" /><br id="a space" />
19397 !! html
19398 Something ...
19399 !! end
19400
19401 # In HTML5, id must be unique amongst all the ids in the element's home subtree.
19402 !! test
19403 Sanitizer: Validating id attribute uniqueness (T6515, T8301)
19404 !! options
19405 disabled
19406 !! wikitext
19407 <br id="foo" /><br id="foo" />
19408 !! html
19409 Something need to be done. foo-2 ?
19410 !! end
19411
19412 !! test
19413 Sanitizer: Validating that <meta> and <link> work, but only for Microdata
19414 !! wikitext
19415 <div itemscope>
19416 <meta itemprop="hello" content="world">
19417 <meta http-equiv="refresh" content="5">
19418 <meta itemprop="hello" http-equiv="refresh" content="5">
19419 <link itemprop="hello" href="{{SERVER}}">
19420 <link rel="stylesheet" href="{{SERVER}}">
19421 <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
19422 </div>
19423 !! html
19424 <div itemscope="">
19425 <p> <meta itemprop="hello" content="world" />
19426 &lt;meta http-equiv="refresh" content="5"&gt;
19427 <meta itemprop="hello" content="5" />
19428 <link itemprop="hello" href="http&#58;//example.org" />
19429 &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"&gt;
19430 <link itemprop="hello" href="http&#58;//example.org" />
19431 </p>
19432 </div>
19433
19434 !! end
19435
19436 !! test
19437 Sanitizer: Strip comments from CSS attributes
19438 !! options
19439 parsoid=wt2html,wt2wt
19440 !! wikitext
19441 <span style="margin:/*negate mbox-text padding */-0.125em -0.45em; /*rainbow*/rgba(255, 0, 0, 0.3)">2013</span>
19442 !! html/php
19443 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span>
19444 </p>
19445 !! html/parsoid
19446 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span></p>
19447 !! end
19448
19449 !! test
19450 Sanitizer: Avoid unnecessary percent encoded characters in interwiki links
19451 !! wikitext
19452 [[meatball:Soft"Security]]
19453 !! html/php
19454 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Soft%22Security" class="extiw" title="meatball:Soft&quot;Security">meatball:Soft"Security</a>
19455 </p>
19456 !! html/parsoid
19457 <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>
19458 !! end
19459
19460 !! test
19461 Sanitizer: angle brackets are invalid, even in interwiki links (T182338)
19462 !! wikitext
19463 [[meatball:Foo<Bar]]
19464 [[meatball:Foo>Bar]]
19465 [[meatball:Foo&lt;bar]]
19466 [[meatball:Foo&gt;bar]]
19467 !! html/php
19468 <p>[[meatball:Foo&lt;Bar]]
19469 [[meatball:Foo&gt;Bar]]
19470 [[meatball:Foo&lt;bar]]
19471 [[meatball:Foo&gt;bar]]
19472 </p>
19473 !! html/parsoid
19474 <p>[[meatball:Foo&lt;Bar]]
19475 [[meatball:Foo>Bar]]
19476 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span>bar]]
19477 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;gt;","srcContent":">"}'>></span>bar]]</p>
19478 !! end
19479
19480 !! test
19481 Language converter: output gets cut off unexpectedly (T7757)
19482 !! options
19483 language=zh
19484 !! wikitext
19485 this bit is safe: }-
19486
19487 but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}-
19488
19489 then we get cut off here: }-
19490
19491 all additional text is vanished
19492 !! html/php
19493 <p>this bit is safe: }-
19494 </p><p>but if we add a conversion instance: xxx
19495 </p><p>then we get cut off here: }-
19496 </p><p>all additional text is vanished
19497 </p>
19498 !! html/parsoid
19499 <p>this bit is safe: }-</p>
19500 <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>
19501 <p>then we get cut off here: }-</p>
19502 <p>all additional text is vanished</p>
19503 !! end
19504
19505 !! test
19506 Language converter glossary rules inside attributes (T119158)
19507 !! options
19508 language=sr variant=sr-el
19509 !! wikitext
19510 -{H|foAjrjvi=>sr-el:" onload="alert(1)" data-foo="}-
19511
19512 [[File:Foobar.jpg|alt=-{}-foAjrjvi-{}-]]
19513 !! html/php
19514 <p>
19515 </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>
19516 </p>
19517 !! html/parsoid
19518 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"foAjrjvi","l":"sr-el","t":"\" onload=\"alert(1)\" data-foo=\""}]}'/></p>
19519
19520 <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>
19521 !! end
19522
19523 !! test
19524 Self closed html pairs (T7487)
19525 !! wikitext
19526 <center><font id="bug" />Centered text</center>
19527 <div><font id="bug2" />In div text</div>
19528 !! html+tidy
19529 <center><font id="bug"></font>Centered text</center>
19530 <div><font id="bug2"></font>In div text</div>
19531 !! end
19532
19533 !! test
19534 Punctuation: nbsp before exclamation
19535 !! wikitext
19536 C'est grave !
19537 !! html
19538 <p>C'est grave&#160;!
19539 </p>
19540 !! end
19541
19542 !! test
19543 Punctuation: CSS !important (T13874)
19544 !! wikitext
19545 <div style="width:50% !important">important</div>
19546 !! html
19547 <div style="width:50% !important">important</div>
19548
19549 !!end
19550
19551 !! test
19552 Punctuation: CSS ! important (T13874; with space after)
19553 !! wikitext
19554 <div style="width:50% ! important">important</div>
19555 !! html
19556 <div style="width:50%&#32;! important">important</div>
19557
19558 !!end
19559
19560 !! test
19561 HTML bullet list, closed tags (T7497)
19562 !! wikitext
19563 <ul>
19564 <li>One</li>
19565 <li>Two</li>
19566 </ul>
19567 !! html/php
19568 <ul>
19569 <li>One</li>
19570 <li>Two</li>
19571 </ul>
19572
19573 !! html/parsoid
19574 <ul data-parsoid='{"stx":"html"}'>
19575 <li data-parsoid='{"stx":"html"}'>One</li>
19576 <li data-parsoid='{"stx":"html"}'>Two</li>
19577 </ul>
19578
19579 !! end
19580
19581 !! test
19582 HTML bullet list, unclosed tags (T7497)
19583 !! wikitext
19584 <ul>
19585 <li>One
19586 <li>Two
19587 </ul>
19588 !! html/php+tidy
19589 <ul>
19590 <li>One
19591 </li><li>Two
19592 </li></ul>
19593 !! html/parsoid
19594 <ul data-parsoid='{"stx":"html"}'>
19595 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
19596 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
19597 </ul>
19598
19599 !! end
19600
19601 !! test
19602 HTML ordered list, closed tags (T7497)
19603 !! wikitext
19604 <ol>
19605 <li>One</li>
19606 <li>Two</li>
19607 </ol>
19608 !! html/php
19609 <ol>
19610 <li>One</li>
19611 <li>Two</li>
19612 </ol>
19613
19614 !! html/parsoid
19615 <ol data-parsoid='{"stx":"html"}'>
19616 <li data-parsoid='{"stx":"html"}'>One</li>
19617 <li data-parsoid='{"stx":"html"}'>Two</li>
19618 </ol>
19619
19620 !! end
19621
19622 !! test
19623 HTML ordered list, unclosed tags (T7497)
19624 !! options
19625 !! wikitext
19626 <ol>
19627 <li>One
19628 <li>Two
19629 </ol>
19630 !! html/php+tidy
19631 <ol>
19632 <li>One
19633 </li><li>Two
19634 </li></ol>
19635 !! html/parsoid
19636 <ol data-parsoid='{"stx":"html"}'>
19637 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
19638 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
19639 </ol>
19640
19641 !! end
19642
19643 !! test
19644 HTML nested bullet list, closed tags (T7497)
19645 !! wikitext
19646 <ul>
19647 <li>One</li>
19648 <li>Two:
19649 <ul>
19650 <li>Sub-one</li>
19651 <li>Sub-two</li>
19652 </ul>
19653 </li>
19654 </ul>
19655 !! html/php
19656 <ul>
19657 <li>One</li>
19658 <li>Two:
19659 <ul>
19660 <li>Sub-one</li>
19661 <li>Sub-two</li>
19662 </ul>
19663 </li>
19664 </ul>
19665
19666 !! html/parsoid
19667 <ul data-parsoid='{"stx":"html"}'>
19668 <li data-parsoid='{"stx":"html"}'>One</li>
19669 <li data-parsoid='{"stx":"html"}'>Two:
19670 <ul data-parsoid='{"stx":"html"}'>
19671 <li data-parsoid='{"stx":"html"}'>Sub-one</li>
19672 <li data-parsoid='{"stx":"html"}'>Sub-two</li>
19673 </ul>
19674 </li>
19675 </ul>
19676 !! end
19677
19678 !! test
19679 HTML nested bullet list, open tags (T7497)
19680 !! wikitext
19681 <ul>
19682 <li>One
19683 <li>Two:
19684 <ul>
19685 <li>Sub-one
19686 <li>Sub-two
19687 </ul>
19688 </ul>
19689 !! html+tidy
19690 <ul>
19691 <li>One
19692 </li><li>Two:
19693 <ul>
19694 <li>Sub-one
19695 </li><li>Sub-two
19696 </li></ul>
19697 </li></ul>
19698 !! end
19699
19700 !! test
19701 HTML nested ordered list, closed tags (T7497)
19702 !! wikitext
19703 <ol>
19704 <li>One</li>
19705 <li>Two:
19706 <ol>
19707 <li>Sub-one</li>
19708 <li>Sub-two</li>
19709 </ol>
19710 </li>
19711 </ol>
19712 !! html
19713 <ol>
19714 <li>One</li>
19715 <li>Two:
19716 <ol>
19717 <li>Sub-one</li>
19718 <li>Sub-two</li>
19719 </ol>
19720 </li>
19721 </ol>
19722
19723 !! end
19724
19725 !! test
19726 HTML nested ordered list, open tags (T7497)
19727 !! wikitext
19728 <ol>
19729 <li>One
19730 <li>Two:
19731 <ol>
19732 <li>Sub-one
19733 <li>Sub-two
19734 </ol>
19735 </ol>
19736 !! html/php
19737 <ol>
19738 <li>One
19739 <li>Two:
19740 <ol>
19741 <li>Sub-one
19742 <li>Sub-two
19743 </ol>
19744 </ol>
19745
19746 !! html/parsoid
19747 <ol>
19748 <li>One
19749 </li>
19750 <li>Two:
19751 <ol>
19752 <li>Sub-one
19753 </li>
19754 <li>Sub-two
19755 </li>
19756 </ol>
19757 </li>
19758 </ol>
19759
19760 !! end
19761
19762 !! test
19763 HTML ordered list item with parameters oddity
19764 !! wikitext
19765 <ol><li id="fragment">One</li>
19766 </ol>
19767 !! html
19768 <ol><li id="fragment">One</li>
19769 </ol>
19770
19771 !! end
19772
19773 # parsoid doesn't explicitly mark autonumbered links, see T55505
19774 !!test
19775 T7918: autonumbering
19776 !! wikitext
19777 [http://first/] [http://second] [ftp://ftp]
19778
19779 ftp://inlineftp
19780
19781 [mailto:enclosed@mail.tld With target]
19782
19783 [mailto:enclosed@mail.tld]
19784
19785 mailto:inline@mail.tld
19786 !! html/php
19787 <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>
19788 </p><p><a rel="nofollow" class="external free" href="ftp://inlineftp">ftp://inlineftp</a>
19789 </p><p><a rel="nofollow" class="external text" href="mailto:enclosed@mail.tld">With target</a>
19790 </p><p><a rel="nofollow" class="external autonumber" href="mailto:enclosed@mail.tld">[4]</a>
19791 </p><p><a rel="nofollow" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a>
19792 </p>
19793 !! html/parsoid
19794 <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>
19795 <p><a rel="mw:ExtLink" class="external free" href="ftp://inlineftp">ftp://inlineftp</a></p>
19796 <p><a rel="mw:ExtLink" class="external text" href="mailto:enclosed@mail.tld">With target</a></p>
19797 <p><a rel="mw:ExtLink" class="external autonumber" href="mailto:enclosed@mail.tld"></a></p>
19798 <p><a rel="mw:ExtLink" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a></p>
19799 !! end
19800
19801
19802 #
19803 # Security and HTML correctness
19804 # From Nick Jenkins' fuzz testing
19805 #
19806
19807 !! test
19808 Fuzz testing: Parser13
19809 !! wikitext
19810 {|
19811 | http://a|
19812 !! html
19813 <table>
19814 <tr>
19815 <td>
19816 </td>
19817 </tr>
19818 </table>
19819
19820 !! end
19821
19822 # Note that Parsoid output differs from the PHP parser here: the PHP
19823 # parser breaks the URL for the magic word, while in Parsoid the URL
19824 # production takes precedence.
19825 !! test
19826 Fuzz testing: Parser14
19827 !! wikitext
19828 ==onmouseover===
19829 http://__TOC__
19830 !! html/php
19831 <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>
19832 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>
19833 <ul>
19834 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
19835 </ul>
19836 </div>
19837
19838
19839 !! html/php+tidy
19840 <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>
19841 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>
19842 <ul>
19843 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
19844 </ul>
19845 </div>
19846 !! html/parsoid
19847 <h2 id="onmouseover="><span id="onmouseover.3D" typeof="mw:FallbackId"></span>onmouseover=</h2>
19848 <p><a rel="mw:ExtLink" class="external free" href="http://__TOC__" data-parsoid='{"stx":"url"}'>http://__TOC__</a></p>
19849 !! end
19850
19851 !! test
19852 Fuzz testing: Parser14-table
19853 !! options
19854 parsoid=wt2html,html2html
19855 !! wikitext
19856 ==a==
19857 {| STYLE=__TOC__
19858 !! html/php
19859 <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>
19860 <table style="&#95;_TOC&#95;_">
19861 <tr><td></td></tr>
19862 </table>
19863
19864 !! html/php+tidy
19865 <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>
19866 <table style="&#95;_TOC&#95;_">
19867 <tbody><tr><td></td></tr>
19868 </tbody></table>
19869 !! html/parsoid
19870 <h2 id="a">a</h2>
19871 <table style="__TOC__"></table>
19872 !! end
19873
19874 # Known to produce bogus xml (extra </td>)
19875 # Don't add the html/php section since it generates broken HTML
19876 !! test
19877 Fuzz testing: Parser16
19878 !! wikitext
19879 {|
19880 !https://||||||
19881 !! html+tidy
19882 <table>
19883 <tbody><tr>
19884 <th>https://</th>
19885 <th></th>
19886 <th></th>
19887 <th>
19888
19889 </th></tr>
19890 </tbody></table>
19891 !! end
19892
19893 !! test
19894 Fuzz testing: Parser21
19895 !! wikitext
19896 {|
19897 !irc://{{ftp://a" onmouseover="alert('hello world');"
19898 |
19899 !! html
19900 <table>
19901 <tr>
19902 <th><a rel="nofollow" class="external free" href="irc://{{ftp://a">irc://{{ftp://a</a>" onmouseover="alert('hello world');"
19903 </th>
19904 <td>
19905 </td>
19906 </tr>
19907 </table>
19908
19909 !! end
19910
19911 !! test
19912 Fuzz testing: Parser22
19913 !! wikitext
19914 http://===r:::https://b
19915
19916 {|
19917 !! html
19918 <p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a>
19919 </p>
19920 <table>
19921 <tr><td></td></tr>
19922 </table>
19923
19924 !! end
19925
19926 ## Remex doesn't account for fostered content.
19927 ## Known to produce bad XML for now
19928 !! test
19929 Fuzz testing: Parser24
19930 !! options
19931 parsoid=wt2html
19932 !! wikitext
19933 {|
19934 {{{|
19935 <u CLASS=
19936 | {{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}} >
19937 <br style="onmouseover='alert(document.cookie);' " />
19938
19939 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19940 |
19941 !! html/php
19942 <table>
19943 {{{|
19944 <u class="&#124;">}}}} &gt;
19945 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
19946
19947 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19948 <tr>
19949 <td></u>
19950 </td>
19951 </tr>
19952 </table>
19953
19954 !! html/php+tidy
19955
19956 {{{|
19957 <u class="&#124;">}}}} &gt;
19958 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
19959
19960 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19961 </u><table><tbody><tr>
19962 <td>
19963 </td>
19964 </tr>
19965 </tbody></table><p><u class="&#124;">
19966 </u></p>
19967 !! html/parsoid
19968 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>
19969 {{{|
19970 <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>"}'/>}}}} >
19971 <br style="onmouseover='alert(document.cookie);' " data-parsoid='{"stx":"html","selfClose":true}'/>
19972
19973 MOVE YOUR MOUSE CURSOR OVER THIS TEXT</u></p>
19974 <table data-parsoid='{"autoInsertedEnd":true}'><tbody><tr data-parsoid='{"autoInsertedStart":true}'><td></td></tr></tbody></table>
19975 !! end
19976
19977 # Note: the current result listed for this is not what the original one was,
19978 # but the original bug was JavaScript injection, which is fixed in any case.
19979 # It's not clear that the original result listed was any more correct than the
19980 # current one. Original result:
19981 # <p>{{{|
19982 # </p>
19983 # <li class="&#124;&#124;">
19984 # }}}blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
19985 !!test
19986 Fuzz testing: Parser25 (T8055)
19987 !! wikitext
19988 {{{
19989 |
19990 <LI CLASS=||
19991 >
19992 }}}blah" onmouseover="alert('hello world');" align="left"'''MOVE MOUSE CURSOR OVER HERE
19993 !! html/php
19994 <p>&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
19995 </p>
19996 !! html/parsoid
19997 <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"]}'>
19998 </span><p about="#mwt1">&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b></p>
19999 !! end
20000
20001 !!test
20002 Fuzz testing: URL adjacent extension (with space, clean)
20003 !! wikitext
20004 http://example.com <nowiki>junk</nowiki>
20005 !! html/php
20006 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> junk
20007 </p>
20008 !! html/parsoid
20009 <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>
20010 !! end
20011
20012 !!test
20013 Fuzz testing: URL adjacent extension (no space, dirty; nowiki)
20014 !! wikitext
20015 http://example.com<nowiki>junk</nowiki>
20016 !! html/php
20017 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>junk
20018 </p>
20019 !! html/parsoid
20020 <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>
20021 !! end
20022
20023 !! test
20024 Fuzz testing: URL adjacent extension (no space, dirty; pre)
20025 !! wikitext
20026 http://example.com<pre>junk</pre>
20027 !! html/php
20028 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre>
20029
20030 !! html/php+tidy
20031 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p><pre>junk</pre>
20032 !! html/parsoid
20033 <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>
20034 !! end
20035
20036 !! test
20037 Fuzz testing: image with bogus manual thumbnail
20038 !! wikitext
20039 [[Image:foobar.jpg|thumbnail= ]]
20040 !! html/php
20041 <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div>
20042
20043 !! html/parsoid
20044 <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>
20045 !! end
20046
20047 # Parsoid will emit the newline literally in wt2wt; see next test case.
20048 !! test
20049 Fuzz testing: encoded newline in generated HTML replacements (T8577)
20050 !! options
20051 parsoid=wt2html
20052 !! wikitext
20053 <pre dir="&#10;"></pre>
20054 !! html/php
20055 <pre dir="&#10;"></pre>
20056
20057 !! html/parsoid
20058 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
20059 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
20060 !! end
20061
20062 !! test
20063 Fuzz testing: encoded newline in generated HTML replacements, html2wt (T8577)
20064 !! options
20065 parsoid=html2wt
20066 !! html/parsoid
20067 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
20068 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
20069 !! wikitext
20070 <pre dir="
20071 "></pre>
20072 !! html/php
20073 <pre dir=""></pre>
20074
20075 !! end
20076
20077 !! test
20078 Templates in extension attributes are not expanded
20079 !! wikitext
20080 <pre dir="{{echo|ltr}}"></pre>
20081 !! html/php
20082 <pre dir="{{echo|ltr}}"></pre>
20083
20084 !! html/parsoid
20085 <pre typeof="mw:Extension/pre" about="#mwt2" dir="{{echo|ltr}}" data-mw='{"name":"pre","attrs":{"dir":"{{echo|ltr}}"},"body":{"extsrc":""}}'></pre>
20086 !! end
20087
20088 !! test
20089 Parsing optional HTML elements (T8171)
20090 !! options
20091 !! wikitext
20092 <table>
20093 <tr>
20094 <td> Some tabular data</td>
20095 <td> More tabular data ...
20096 <td> And yet som tabular data</td>
20097 </tr>
20098 </table>
20099 !! html
20100 <table>
20101 <tr>
20102 <td> Some tabular data</td>
20103 <td> More tabular data ...
20104 </td><td> And yet som tabular data</td>
20105 </tr>
20106 </table>
20107
20108 !! end
20109
20110 !! test
20111 Correct handling of <td>, <tr> (T8171)
20112 !! options
20113 !! wikitext
20114 <table>
20115 <tr>
20116 <td> Some tabular data</td>
20117 <td> More tabular data ...</td>
20118 <td> And yet som tabular data</td>
20119 </tr>
20120 </table>
20121 !! html
20122 <table>
20123 <tr>
20124 <td> Some tabular data</td>
20125 <td> More tabular data ...</td>
20126 <td> And yet som tabular data</td>
20127 </tr>
20128 </table>
20129
20130 !! end
20131
20132
20133 !! test
20134 Parsing crashing regression (fr:JavaScript)
20135 !! wikitext
20136 </body></x>
20137 !! html
20138 <p>&lt;/body&gt;&lt;/x&gt;
20139 </p>
20140 !! end
20141
20142 !! test
20143 Inline wiki vs wiki block nesting
20144 !! wikitext
20145 '''Bold paragraph
20146
20147 New wiki paragraph
20148 !! html
20149 <p><b>Bold paragraph</b>
20150 </p><p>New wiki paragraph
20151 </p>
20152 !! end
20153
20154 # FIXME: The current php output is documented
20155 # and desired output is the parsoid target.
20156 !! test
20157 Inline HTML vs wiki block nesting
20158 !! wikitext
20159 <b>Bold paragraph
20160
20161 New wiki paragraph
20162 !! html/php
20163 <p><b>Bold paragraph
20164 </p><p>New wiki paragraph</b>
20165 </p>
20166 !! html/php+tidy
20167 <p><b>Bold paragraph
20168 </b></p><p><b>New wiki paragraph
20169 </b></p>
20170 !! html/parsoid
20171 <p><b>Bold paragraph</b>
20172 </p><p>New wiki paragraph
20173 </p>
20174 !! end
20175
20176 # Original result was this:
20177 # <p><b>bold</b><b>bold<i>bolditalics</i></b>
20178 # </p>
20179 # While that might be marginally more intuitive, maybe, the six-apostrophe
20180 # construct is clearly pathological and the result stated here (which is what
20181 # the parser actually does) is about as reasonable as anything.
20182 !!test
20183 Mixing markup for italics and bold
20184 !! options
20185 !! wikitext
20186 '''bold''''''bold''bolditalics'''''
20187 !! html
20188 <p>'<i>bold'</i><b>bold<i>bolditalics</i></b>
20189 </p>
20190 !! end
20191
20192
20193 !! article
20194 Xyzzyx
20195 !! text
20196 Article for special page transclusion test
20197 !! endarticle
20198
20199 !! test
20200 Special page transclusion
20201 !! options
20202 !! wikitext
20203 {{Special:Prefixindex/Xyzzyx}}
20204 !! html
20205 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
20206 </ul>
20207
20208 !! end
20209
20210 !! test
20211 Special page transclusion twice (T7021)
20212 !! options
20213 !! wikitext
20214 {{Special:Prefixindex/Xyzzyx}}
20215 {{Special:Prefixindex/Xyzzyx}}
20216 !! html
20217 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
20218 </ul>
20219 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
20220 </ul>
20221
20222 !! end
20223
20224 !! test
20225 Transclusion of default MediaWiki message
20226 !! wikitext
20227 {{MediaWiki:Mainpage}}
20228 !! html
20229 <p>Main Page
20230 </p>
20231 !! end
20232
20233 !! test
20234 Transclusion of nonexistent MediaWiki message
20235 !! wikitext
20236 {{MediaWiki:Mainpagexxx}}
20237 !! html
20238 <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>
20239 </p>
20240 !! end
20241
20242 !! test
20243 Transclusion of MediaWiki message with underscore
20244 !! wikitext
20245 {{MediaWiki:history_short}}
20246 !! html
20247 <p>History
20248 </p>
20249 !! end
20250
20251 !! test
20252 Transclusion of MediaWiki message with space
20253 !! wikitext
20254 {{MediaWiki:history short}}
20255 !! html
20256 <p>History
20257 </p>
20258 !! end
20259
20260 !! test
20261 Invalid header with following text
20262 !! wikitext
20263 = x = y
20264 !! html
20265 <p>= x = y
20266 </p>
20267 !! end
20268
20269
20270 !! test
20271 Section extraction test (section 0)
20272 !! options
20273 section=0
20274 !! wikitext
20275 start
20276 ==a==
20277 ===aa===
20278 ====aaa====
20279 ==b==
20280 ===ba===
20281 ===bb===
20282 ====bba====
20283 ===bc===
20284 ==c==
20285 ===ca===
20286 !! html/php
20287 start
20288 !! end
20289
20290 !! test
20291 Section extraction test (section 1)
20292 !! options
20293 section=1
20294 !! wikitext
20295 start
20296 ==a==
20297 ===aa===
20298 ====aaa====
20299 ==b==
20300 ===ba===
20301 ===bb===
20302 ====bba====
20303 ===bc===
20304 ==c==
20305 ===ca===
20306 !! html/php
20307 ==a==
20308 ===aa===
20309 ====aaa====
20310 !! end
20311
20312 !! test
20313 Section extraction test (section 2)
20314 !! options
20315 section=2
20316 !! wikitext
20317 start
20318 ==a==
20319 ===aa===
20320 ====aaa====
20321 ==b==
20322 ===ba===
20323 ===bb===
20324 ====bba====
20325 ===bc===
20326 ==c==
20327 ===ca===
20328 !! html/php
20329 ===aa===
20330 ====aaa====
20331 !! end
20332
20333 !! test
20334 Section extraction test (section 3)
20335 !! options
20336 section=3
20337 !! wikitext
20338 start
20339 ==a==
20340 ===aa===
20341 ====aaa====
20342 ==b==
20343 ===ba===
20344 ===bb===
20345 ====bba====
20346 ===bc===
20347 ==c==
20348 ===ca===
20349 !! html/php
20350 ====aaa====
20351 !! end
20352
20353 !! test
20354 Section extraction test (section 4)
20355 !! options
20356 section=4
20357 !! wikitext
20358 start
20359 ==a==
20360 ===aa===
20361 ====aaa====
20362 ==b==
20363 ===ba===
20364 ===bb===
20365 ====bba====
20366 ===bc===
20367 ==c==
20368 ===ca===
20369 !! html/php
20370 ==b==
20371 ===ba===
20372 ===bb===
20373 ====bba====
20374 ===bc===
20375 !! end
20376
20377 !! test
20378 Section extraction test (section 5)
20379 !! options
20380 section=5
20381 !! wikitext
20382 start
20383 ==a==
20384 ===aa===
20385 ====aaa====
20386 ==b==
20387 ===ba===
20388 ===bb===
20389 ====bba====
20390 ===bc===
20391 ==c==
20392 ===ca===
20393 !! html/php
20394 ===ba===
20395 !! end
20396
20397 !! test
20398 Section extraction test (section 6)
20399 !! options
20400 section=6
20401 !! wikitext
20402 start
20403 ==a==
20404 ===aa===
20405 ====aaa====
20406 ==b==
20407 ===ba===
20408 ===bb===
20409 ====bba====
20410 ===bc===
20411 ==c==
20412 ===ca===
20413 !! html/php
20414 ===bb===
20415 ====bba====
20416 !! end
20417
20418 !! test
20419 Section extraction test (section 7)
20420 !! options
20421 section=7
20422 !! wikitext
20423 start
20424 ==a==
20425 ===aa===
20426 ====aaa====
20427 ==b==
20428 ===ba===
20429 ===bb===
20430 ====bba====
20431 ===bc===
20432 ==c==
20433 ===ca===
20434 !! html/php
20435 ====bba====
20436 !! end
20437
20438 !! test
20439 Section extraction test (section 8)
20440 !! options
20441 section=8
20442 !! wikitext
20443 start
20444 ==a==
20445 ===aa===
20446 ====aaa====
20447 ==b==
20448 ===ba===
20449 ===bb===
20450 ====bba====
20451 ===bc===
20452 ==c==
20453 ===ca===
20454 !! html/php
20455 ===bc===
20456 !! end
20457
20458 !! test
20459 Section extraction test (section 9)
20460 !! options
20461 section=9
20462 !! wikitext
20463 start
20464 ==a==
20465 ===aa===
20466 ====aaa====
20467 ==b==
20468 ===ba===
20469 ===bb===
20470 ====bba====
20471 ===bc===
20472 ==c==
20473 ===ca===
20474 !! html/php
20475 ==c==
20476 ===ca===
20477 !! end
20478
20479 !! test
20480 Section extraction test (section 10)
20481 !! options
20482 section=10
20483 !! wikitext
20484 start
20485 ==a==
20486 ===aa===
20487 ====aaa====
20488 ==b==
20489 ===ba===
20490 ===bb===
20491 ====bba====
20492 ===bc===
20493 ==c==
20494 ===ca===
20495 !! html/php
20496 ===ca===
20497 !! end
20498
20499 !! test
20500 Section extraction test (nonexistent section 11)
20501 !! options
20502 section=11
20503 !! wikitext
20504 start
20505 ==a==
20506 ===aa===
20507 ====aaa====
20508 ==b==
20509 ===ba===
20510 ===bb===
20511 ====bba====
20512 ===bc===
20513 ==c==
20514 ===ca===
20515 !! html/php
20516 !! end
20517
20518 !! test
20519 Section extraction test with bogus heading (section 1)
20520 !! options
20521 section=1
20522 !! wikitext
20523 ==a==
20524 ==bogus== not a legal section
20525 ==b==
20526 !! html/php
20527 ==a==
20528 ==bogus== not a legal section
20529 !! end
20530
20531 !! test
20532 Section extraction test with bogus heading (section 2)
20533 !! options
20534 section=2
20535 !! wikitext
20536 ==a==
20537 ==bogus== not a legal section
20538 ==b==
20539 !! html/php
20540 ==b==
20541 !! end
20542
20543 !! test
20544 Section extraction test with comment after heading (section 1)
20545 !! options
20546 section=1
20547 !! wikitext
20548 ==a==
20549 ==b== <!-- -->
20550 ==c==
20551 !! html/php
20552 ==a==
20553 !! end
20554
20555 !! test
20556 Section extraction test with comment after heading (section 2)
20557 !! options
20558 section=2
20559 !! wikitext
20560 ==a==
20561 ==b== <!-- -->
20562 ==c==
20563 !! html/php
20564 ==b== <!-- -->
20565 !! end
20566
20567 !! test
20568 Section extraction test with bogus <nowiki> heading (section 1)
20569 !! options
20570 section=1
20571 !! wikitext
20572 ==a==
20573 ==bogus== <nowiki>not a legal section</nowiki>
20574 ==b==
20575 !! html/php
20576 ==a==
20577 ==bogus== <nowiki>not a legal section</nowiki>
20578 !! end
20579
20580 !! test
20581 Section extraction test with bogus <nowiki> heading (section 2)
20582 !! options
20583 section=2
20584 !! wikitext
20585 ==a==
20586 ==bogus== <nowiki>not a legal section</nowiki>
20587 ==b==
20588 !! html/php
20589 ==b==
20590 !! end
20591
20592 # Formerly testing for T4587, now resolved by the use of unmarked sections
20593 # instead of respecting commented sections
20594 !! test
20595 Section extraction prefixed by comment (section 1)
20596 !! options
20597 section=1
20598 !! wikitext
20599 <!-- -->==sec1==
20600 ==sec2==
20601 !! html/php
20602 ==sec2==
20603 !!end
20604
20605 !! test
20606 Section extraction prefixed by comment (section 2)
20607 !! options
20608 section=2
20609 !! wikitext
20610 <!-- -->==sec1==
20611 ==sec2==
20612 !! html/php
20613
20614 !!end
20615
20616 # Formerly testing for T4607, now resolved by the use of unmarked sections
20617 # instead of respecting HTML-style headings
20618 !! test
20619 Section extraction, mixed wiki and html (section 1)
20620 !! options
20621 section=1
20622 !! wikitext
20623 <h2>unmarked</h2>
20624 unmarked
20625 ==1==
20626 one
20627 ==2==
20628 two
20629 !! html/php
20630 ==1==
20631 one
20632 !! end
20633
20634 !! test
20635 Section extraction, mixed wiki and html (section 2)
20636 !! options
20637 section=2
20638 !! wikitext
20639 <h2>unmarked</h2>
20640 unmarked
20641 ==1==
20642 one
20643 ==2==
20644 two
20645 !! html/php
20646 ==2==
20647 two
20648 !! end
20649
20650
20651 # Formerly testing for T5342
20652 !! test
20653 Section extraction, heading surrounded by <noinclude>
20654 !! options
20655 section=1
20656 !! wikitext
20657 <noinclude>==unmarked==</noinclude>
20658 ==marked==
20659 !! html/php
20660 ==marked==
20661 !!end
20662
20663 # Test behavior of T21910
20664 !! test
20665 Sectiion with all-equals
20666 !! options
20667 section=2
20668 !! wikitext
20669 ===
20670 The line above must have a trailing space
20671 === <!--
20672 --> <!-- -->
20673 But just in case it doesn't...
20674 !! html/php
20675 === <!--
20676 --> <!-- -->
20677 But just in case it doesn't...
20678 !! end
20679
20680 !! test
20681 Section replacement test (section 0)
20682 !! options
20683 replace=0,"xxx"
20684 !! wikitext
20685 start
20686 ==a==
20687 ===aa===
20688 ====aaa====
20689 ==b==
20690 ===ba===
20691 ===bb===
20692 ====bba====
20693 ===bc===
20694 ==c==
20695 ===ca===
20696 !! html/php
20697 xxx
20698
20699 ==a==
20700 ===aa===
20701 ====aaa====
20702 ==b==
20703 ===ba===
20704 ===bb===
20705 ====bba====
20706 ===bc===
20707 ==c==
20708 ===ca===
20709 !! end
20710
20711 !! test
20712 Section replacement test (section 1)
20713 !! options
20714 replace=1,"xxx"
20715 !! wikitext
20716 start
20717 ==a==
20718 ===aa===
20719 ====aaa====
20720 ==b==
20721 ===ba===
20722 ===bb===
20723 ====bba====
20724 ===bc===
20725 ==c==
20726 ===ca===
20727 !! html/php
20728 start
20729 xxx
20730
20731 ==b==
20732 ===ba===
20733 ===bb===
20734 ====bba====
20735 ===bc===
20736 ==c==
20737 ===ca===
20738 !! end
20739
20740 !! test
20741 Section replacement test (section 2)
20742 !! options
20743 replace=2,"xxx"
20744 !! wikitext
20745 start
20746 ==a==
20747 ===aa===
20748 ====aaa====
20749 ==b==
20750 ===ba===
20751 ===bb===
20752 ====bba====
20753 ===bc===
20754 ==c==
20755 ===ca===
20756 !! html/php
20757 start
20758 ==a==
20759 xxx
20760
20761 ==b==
20762 ===ba===
20763 ===bb===
20764 ====bba====
20765 ===bc===
20766 ==c==
20767 ===ca===
20768 !! end
20769
20770 !! test
20771 Section replacement test (section 3)
20772 !! options
20773 replace=3,"xxx"
20774 !! wikitext
20775 start
20776 ==a==
20777 ===aa===
20778 ====aaa====
20779 ==b==
20780 ===ba===
20781 ===bb===
20782 ====bba====
20783 ===bc===
20784 ==c==
20785 ===ca===
20786 !! html/php
20787 start
20788 ==a==
20789 ===aa===
20790 xxx
20791
20792 ==b==
20793 ===ba===
20794 ===bb===
20795 ====bba====
20796 ===bc===
20797 ==c==
20798 ===ca===
20799 !! end
20800
20801 !! test
20802 Section replacement test (section 4)
20803 !! options
20804 replace=4,"xxx"
20805 !! wikitext
20806 start
20807 ==a==
20808 ===aa===
20809 ====aaa====
20810 ==b==
20811 ===ba===
20812 ===bb===
20813 ====bba====
20814 ===bc===
20815 ==c==
20816 ===ca===
20817 !! html/php
20818 start
20819 ==a==
20820 ===aa===
20821 ====aaa====
20822 xxx
20823
20824 ==c==
20825 ===ca===
20826 !! end
20827
20828 !! test
20829 Section replacement test (section 5)
20830 !! options
20831 replace=5,"xxx"
20832 !! wikitext
20833 start
20834 ==a==
20835 ===aa===
20836 ====aaa====
20837 ==b==
20838 ===ba===
20839 ===bb===
20840 ====bba====
20841 ===bc===
20842 ==c==
20843 ===ca===
20844 !! html/php
20845 start
20846 ==a==
20847 ===aa===
20848 ====aaa====
20849 ==b==
20850 xxx
20851
20852 ===bb===
20853 ====bba====
20854 ===bc===
20855 ==c==
20856 ===ca===
20857 !! end
20858
20859 !! test
20860 Section replacement test (section 6)
20861 !! options
20862 replace=6,"xxx"
20863 !! wikitext
20864 start
20865 ==a==
20866 ===aa===
20867 ====aaa====
20868 ==b==
20869 ===ba===
20870 ===bb===
20871 ====bba====
20872 ===bc===
20873 ==c==
20874 ===ca===
20875 !! html/php
20876 start
20877 ==a==
20878 ===aa===
20879 ====aaa====
20880 ==b==
20881 ===ba===
20882 xxx
20883
20884 ===bc===
20885 ==c==
20886 ===ca===
20887 !! end
20888
20889 !! test
20890 Section replacement test (section 7)
20891 !! options
20892 replace=7,"xxx"
20893 !! wikitext
20894 start
20895 ==a==
20896 ===aa===
20897 ====aaa====
20898 ==b==
20899 ===ba===
20900 ===bb===
20901 ====bba====
20902 ===bc===
20903 ==c==
20904 ===ca===
20905 !! html/php
20906 start
20907 ==a==
20908 ===aa===
20909 ====aaa====
20910 ==b==
20911 ===ba===
20912 ===bb===
20913 xxx
20914
20915 ===bc===
20916 ==c==
20917 ===ca===
20918 !! end
20919
20920 !! test
20921 Section replacement test (section 8)
20922 !! options
20923 replace=8,"xxx"
20924 !! wikitext
20925 start
20926 ==a==
20927 ===aa===
20928 ====aaa====
20929 ==b==
20930 ===ba===
20931 ===bb===
20932 ====bba====
20933 ===bc===
20934 ==c==
20935 ===ca===
20936 !! html/php
20937 start
20938 ==a==
20939 ===aa===
20940 ====aaa====
20941 ==b==
20942 ===ba===
20943 ===bb===
20944 ====bba====
20945 xxx
20946
20947 ==c==
20948 ===ca===
20949 !!end
20950
20951 !! test
20952 Section replacement test (section 9)
20953 !! options
20954 replace=9,"xxx"
20955 !! wikitext
20956 start
20957 ==a==
20958 ===aa===
20959 ====aaa====
20960 ==b==
20961 ===ba===
20962 ===bb===
20963 ====bba====
20964 ===bc===
20965 ==c==
20966 ===ca===
20967 !! html/php
20968 start
20969 ==a==
20970 ===aa===
20971 ====aaa====
20972 ==b==
20973 ===ba===
20974 ===bb===
20975 ====bba====
20976 ===bc===
20977 xxx
20978 !! end
20979
20980 !! test
20981 Section replacement test (section 10)
20982 !! options
20983 replace=10,"xxx"
20984 !! wikitext
20985 start
20986 ==a==
20987 ===aa===
20988 ====aaa====
20989 ==b==
20990 ===ba===
20991 ===bb===
20992 ====bba====
20993 ===bc===
20994 ==c==
20995 ===ca===
20996 !! html/php
20997 start
20998 ==a==
20999 ===aa===
21000 ====aaa====
21001 ==b==
21002 ===ba===
21003 ===bb===
21004 ====bba====
21005 ===bc===
21006 ==c==
21007 xxx
21008 !! end
21009
21010 !! test
21011 Section replacement test with initial whitespace (T15728)
21012 !! options
21013 replace=2,"xxx"
21014 !! wikitext
21015 Preformatted initial line
21016 ==a==
21017 ===a===
21018 !! html/php
21019 Preformatted initial line
21020 ==a==
21021 xxx
21022 !! end
21023
21024
21025 !! test
21026 Section extraction, heading followed by pre with 20 spaces (T8398)
21027 !! options
21028 section=1
21029 !! wikitext
21030 ==a==
21031 a
21032 !! html/php
21033 ==a==
21034 a
21035 !! end
21036
21037 !! test
21038 Section extraction, heading followed by pre with 19 spaces (T8398 sanity check)
21039 !! options
21040 section=1
21041 !! wikitext
21042 ==a==
21043 a
21044 !! html/php
21045 ==a==
21046 a
21047 !! end
21048
21049
21050 !! test
21051 Section extraction, <pre> around bogus header (T12309)
21052 !! options
21053 section=2
21054 !! wikitext
21055 == Section One ==
21056 <pre>
21057 =======
21058 </pre>
21059
21060 == Section Two ==
21061 stuff
21062 !! html/php
21063 == Section Two ==
21064 stuff
21065 !! end
21066
21067 !! test
21068 Section replacement, <pre> around bogus header (T12309)
21069 !! options
21070 replace=2,"xxx"
21071 !! wikitext
21072 == Section One ==
21073 <pre>
21074 =======
21075 </pre>
21076
21077 == Section Two ==
21078 stuff
21079 !! html/php
21080 == Section One ==
21081 <pre>
21082 =======
21083 </pre>
21084
21085 xxx
21086 !! end
21087
21088 !! test
21089 Handling of &#x0A; in URLs
21090 !! wikitext
21091 *irc://&#x0A;a
21092 !! html/php
21093 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
21094
21095 !! html/parsoid
21096 <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>
21097 !! end
21098
21099 !! test
21100 Handling of %0A in URLs
21101 !! wikitext
21102 *irc://%0Aa
21103 !! html/php
21104 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
21105
21106 !! html/parsoid
21107 <ul><li><a rel="mw:ExtLink" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
21108 !! end
21109
21110 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
21111 !! test
21112 5 quotes, code coverage +1 line
21113 !! options
21114 parsoid=wt2html
21115 !! wikitext
21116 '''''
21117 !! html/php
21118 !! html/parsoid
21119 <p><b><i></i></b></p>
21120 !! end
21121
21122 # same html as previous, but wikitext adjusted to match parsoid html2wt
21123 # note that wt2html and html2html will put the <i> before the <b>
21124 !! test
21125 5 quotes, code coverage +1 line w/ nowiki (1)
21126 !! options
21127 parsoid=wt2wt,html2wt
21128 !! wikitext
21129 '''''<nowiki/>'''''
21130 !! html/php
21131 <p><i></i>
21132 </p>
21133 !! html/parsoid
21134 <p><b><i></i></b></p>
21135 !! end
21136
21137 # same as previous, just swapping the <i> and <b>
21138 !! test
21139 5 quotes, code coverage +1 line w/ nowiki (2)
21140 !! wikitext
21141 '''''<nowiki/>'''''
21142 !! html/php
21143 <p><i></i>
21144 </p>
21145 !! html/parsoid
21146 <p><i><b></b></i></p>
21147 !! end
21148
21149 !! test
21150 Special:Search page linking.
21151 !! wikitext
21152 {{Special:search}}
21153 !! html
21154 <p><a href="/wiki/Special:Search" title="Special:Search">Special:Search</a>
21155 </p>
21156 !! end
21157
21158 !! test
21159 {{!}} is a magic word
21160 !! wikitext
21161 {{!}} is a magic word there and {{!}} is still a magic word here
21162 | is not a magic word here but {{!}} is still a magic word here
21163 !! html/php
21164 <p>| is a magic word there and | is still a magic word here
21165 | is not a magic word here but | is still a magic word here
21166 </p>
21167 !! html/parsoid
21168 <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
21169 | 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>
21170 !! end
21171
21172 !! test
21173 Say the magic word
21174 !! options
21175 title=[[Parser test]]
21176 !! wikitext
21177 *{{PAGENAME}}
21178 *{{PAGENAMEE}}
21179 *{{FULLPAGENAME}}
21180 *{{FULLPAGENAMEE}}
21181 *{{BASEPAGENAME}}
21182 *{{BASEPAGENAMEE}}
21183 *{{SUBPAGENAME}}
21184 *{{SUBPAGENAMEE}}
21185 *{{ROOTPAGENAME}}
21186 *{{ROOTPAGENAMEE}}
21187 *{{TALKPAGENAME}}
21188 *{{TALKPAGENAMEE}}
21189 *{{SUBJECTPAGENAME}}
21190 *{{SUBJECTPAGENAMEE}}
21191 *{{NAMESPACEE}}
21192 *{{NAMESPACE}}
21193 *{{NAMESPACENUMBER}}
21194 *{{TALKSPACE}}
21195 *{{TALKSPACEE}}
21196 *{{SUBJECTSPACE}}
21197 *{{SUBJECTSPACEE}}
21198 *{{Dynamic|{{NUMBEROFUSERS}}|{{NUMBEROFPAGES}}|{{CURRENTVERSION}}|{{CONTENTLANGUAGE}}|{{DIRECTIONMARK}}|{{CURRENTTIMESTAMP}}|{{NUMBEROFARTICLES}}}}
21199 !! html
21200 <ul><li>Parser test</li>
21201 <li>Parser_test</li>
21202 <li>Parser test</li>
21203 <li>Parser_test</li>
21204 <li>Parser test</li>
21205 <li>Parser_test</li>
21206 <li>Parser test</li>
21207 <li>Parser_test</li>
21208 <li>Parser test</li>
21209 <li>Parser_test</li>
21210 <li>Talk:Parser test</li>
21211 <li>Talk:Parser_test</li>
21212 <li>Parser test</li>
21213 <li>Parser_test</li>
21214 <li></li>
21215 <li></li>
21216 <li>0</li>
21217 <li>Talk</li>
21218 <li>Talk</li>
21219 <li></li>
21220 <li></li>
21221 <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>
21222
21223 !! end
21224 ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included.
21225
21226 !! test
21227 Gallery with valid attributes
21228 !! wikitext
21229 <gallery type="123" summary="345">
21230 File:File:Foobar.jpg
21231 </gallery>
21232 !! html/php
21233 <ul class="gallery mw-gallery-traditional" type="123">
21234 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21235 <div class="thumb" style="height: 150px;">File:Foobar.jpg</div>
21236 <div class="gallerytext">
21237 </div>
21238 </div></li>
21239 </ul>
21240
21241 !! html/parsoid
21242 <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"}}'>
21243 <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>
21244 </ul>
21245 !! end
21246
21247 ## Parsoid thinks the "centre" here is a property, not a caption.
21248 !! test
21249 Gallery
21250 !! options
21251 parsoid={
21252 "modes": ["wt2html"],
21253 "nativeGallery": true
21254 }
21255 !! wikitext
21256 <gallery>
21257 image1.png |
21258 image2.gif|||||
21259
21260 image3|
21261 image4 |300px| centre
21262 image5.svg| http://///////
21263 [[x|xx]]]]
21264 * image6
21265 </gallery>
21266 !! html/php
21267 <ul class="gallery mw-gallery-traditional">
21268 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21269 <div class="thumb" style="height: 150px;">Image1.png</div>
21270 <div class="gallerytext">
21271 </div>
21272 </div></li>
21273 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21274 <div class="thumb" style="height: 150px;">Image2.gif</div>
21275 <div class="gallerytext">
21276 </div>
21277 </div></li>
21278 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21279 <div class="thumb" style="height: 150px;">Image3</div>
21280 <div class="gallerytext">
21281 </div>
21282 </div></li>
21283 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21284 <div class="thumb" style="height: 150px;">Image4</div>
21285 <div class="gallerytext">
21286 <pre>centre
21287 </pre>
21288 </div>
21289 </div></li>
21290 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21291 <div class="thumb" style="height: 150px;">Image5.svg</div>
21292 <div class="gallerytext">
21293 <p><a rel="nofollow" class="external free" href="http://///////">http://///////</a>
21294 </p>
21295 </div>
21296 </div></li>
21297 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21298 <div class="thumb" style="height: 150px;">* image6</div>
21299 <div class="gallerytext">
21300 </div>
21301 </div></li>
21302 </ul>
21303
21304 !! html/parsoid
21305 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21306 <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>
21307 <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>
21308 <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>
21309 <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>
21310 <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>
21311 <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>
21312 </ul>
21313 !! end
21314
21315 !! test
21316 Gallery (with options, html)
21317 !! options
21318 parsoid={
21319 "modes": ["wt2html", "html2html"],
21320 "nativeGallery": true
21321 }
21322 !! wikitext
21323 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
21324 File:Nonexistent.jpg|caption
21325 File:Nonexistent.jpg
21326 image:foobar.jpg|some '''caption''' [[Main Page]]
21327 image:foobar.jpg
21328 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
21329 </gallery>
21330 !! html/php
21331 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
21332 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
21333 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21334 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21335 <div class="gallerytext">
21336 <p>caption
21337 </p>
21338 </div>
21339 </div></li>
21340 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21341 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21342 <div class="gallerytext">
21343 </div>
21344 </div></li>
21345 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21346 <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>
21347 <div class="gallerytext">
21348 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21349 </p>
21350 </div>
21351 </div></li>
21352 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21353 <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>
21354 <div class="gallerytext">
21355 </div>
21356 </div></li>
21357 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21358 <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>
21359 <div class="gallerytext">
21360 <p>blabla.
21361 </p>
21362 </div>
21363 </div></li>
21364 </ul>
21365
21366 !! html/parsoid
21367 <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":{}}'>
21368 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
21369 <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>
21370 <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>
21371 <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>
21372 <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>
21373 <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>
21374 </ul>
21375 !! end
21376
21377 !! test
21378 Gallery (with options, extsrc)
21379 !! options
21380 parsoid={
21381 "nativeGallery": false
21382 }
21383 !! wikitext
21384 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
21385 File:Nonexistent.jpg|caption
21386 File:Nonexistent.jpg
21387 image:foobar.jpg|some '''caption''' [[Main Page]]
21388 image:foobar.jpg
21389 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
21390 </gallery>
21391 !! html/php
21392 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
21393 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
21394 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21395 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21396 <div class="gallerytext">
21397 <p>caption
21398 </p>
21399 </div>
21400 </div></li>
21401 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21402 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21403 <div class="gallerytext">
21404 </div>
21405 </div></li>
21406 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21407 <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>
21408 <div class="gallerytext">
21409 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21410 </p>
21411 </div>
21412 </div></li>
21413 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21414 <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>
21415 <div class="gallerytext">
21416 </div>
21417 </div></li>
21418 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21419 <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>
21420 <div class="gallerytext">
21421 <p>blabla.
21422 </p>
21423 </div>
21424 </div></li>
21425 </ul>
21426
21427 !! html/parsoid
21428 <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"}}'>
21429 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
21430 <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>
21431 <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>
21432 <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>
21433 <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>
21434 <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>
21435 </ul>
21436 !! end
21437
21438 !! test
21439 Gallery (without px units)
21440 !! wikitext
21441 <gallery widths="70" heights="40">
21442 File:Foobar.jpg
21443 </gallery>
21444 !! html/php
21445 <ul class="gallery mw-gallery-traditional">
21446 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21447 <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>
21448 <div class="gallerytext">
21449 </div>
21450 </div></li>
21451 </ul>
21452
21453 !! html/parsoid
21454 <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"}}'>
21455 <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>
21456 </ul>
21457 !! end
21458
21459 !! test
21460 Gallery (with invalid units)
21461 !! wikitext
21462 <gallery widths="70em" heights="40em">
21463 File:Foobar.jpg
21464 </gallery>
21465 !! html/php
21466 <ul class="gallery mw-gallery-traditional">
21467 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21468 <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>
21469 <div class="gallerytext">
21470 </div>
21471 </div></li>
21472 </ul>
21473
21474 !! html/parsoid
21475 <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"}}'>
21476 <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>
21477 </ul>
21478 !! end
21479
21480 !! test
21481 Gallery with link that has fragment
21482 !! options
21483 parsoid={
21484 "modes": ["wt2html", "html2html"],
21485 "nativeGallery": true
21486 }
21487 !! wikitext
21488 <gallery>
21489 image:foobar.jpg|link=Main_Page
21490 image:foobar.jpg|link=Main_Page#section
21491 image:foobar.jpg|link=Main Page#section|caption
21492 </gallery>
21493 !! html/php
21494 <ul class="gallery mw-gallery-traditional">
21495 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21496 <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>
21497 <div class="gallerytext">
21498 </div>
21499 </div></li>
21500 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21501 <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>
21502 <div class="gallerytext">
21503 </div>
21504 </div></li>
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/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>
21507 <div class="gallerytext">
21508 <p>caption
21509 </p>
21510 </div>
21511 </div></li>
21512 </ul>
21513
21514 !! html/parsoid
21515 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21516 <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>
21517 <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>
21518 <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>
21519 </ul>
21520 !! end
21521
21522 ## Whoops, Parsoid shouldn't be parsing templates in the attribute caption!
21523 !! test
21524 Gallery with template inside caption
21525 !! options
21526 parsoid={
21527 "nativeGallery": true
21528 }
21529 !! wikitext
21530 <gallery caption="{{echo|hi}}">
21531 File:Foobar.jpg|{{echo|ho}}
21532 </gallery>
21533 !! html/php
21534 <ul class="gallery mw-gallery-traditional">
21535 <li class='gallerycaption'>{{echo|hi}}</li>
21536 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21537 <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>
21538 <div class="gallerytext">
21539 <p>ho
21540 </p>
21541 </div>
21542 </div></li>
21543 </ul>
21544
21545 !! html/parsoid
21546 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21547 <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>
21548 <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>
21549 </ul>
21550 !! end
21551
21552 !! test
21553 Gallery with wikitext inside caption
21554 !! options
21555 parsoid={
21556 "nativeGallery": true
21557 }
21558 !! wikitext
21559 <gallery>
21560 File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]]
21561 File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}}
21562 </gallery>
21563 !! html/php
21564 <ul class="gallery mw-gallery-traditional">
21565 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21566 <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>
21567 <div class="gallerytext">
21568 <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>
21569 </p>
21570 </div>
21571 </div></li>
21572 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21573 <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>
21574 <div class="gallerytext">
21575 <p>This is a test template
21576 </p>
21577 </div>
21578 </div></li>
21579 </ul>
21580
21581 !! html/parsoid
21582 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21583 <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>
21584 <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>
21585 </ul>
21586 !! end
21587
21588 !! test
21589 Gallery (with showfilename option)
21590 !! options
21591 parsoid={
21592 "nativeGallery": true
21593 }
21594 !! wikitext
21595 <gallery showfilename="">
21596 File:Nonexistent.jpg|caption
21597 File:Nonexistent.jpg
21598 File:Foobar.jpg|some '''caption''' [[Main Page]]
21599 File:Foobar.jpg
21600 </gallery>
21601 !! html/php
21602 <ul class="gallery mw-gallery-traditional">
21603 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21604 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21605 <div class="gallerytext">
21606 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
21607 caption
21608 </p>
21609 </div>
21610 </div></li>
21611 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21612 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21613 <div class="gallerytext">
21614 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
21615 </p>
21616 </div>
21617 </div></li>
21618 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21619 <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>
21620 <div class="gallerytext">
21621 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
21622 some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21623 </p>
21624 </div>
21625 </div></li>
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="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>
21628 <div class="gallerytext">
21629 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
21630 </p>
21631 </div>
21632 </div></li>
21633 </ul>
21634
21635 !! html/parsoid
21636 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
21637 <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>
21638 <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>
21639 <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>
21640 <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>
21641 </ul>
21642 !! end
21643
21644 ## Should Parsoid be preserving these variations? See T151367
21645 !! test
21646 Gallery (with namespace-less filenames)
21647 !! options
21648 parsoid={
21649 "modes": ["wt2html", "html2html"],
21650 "nativeGallery": true
21651 }
21652 !! wikitext
21653 <gallery>
21654 File:Nonexistent.jpg
21655 Nonexistent.jpg
21656 image:foobar.jpg
21657 foobar.jpg
21658 </gallery>
21659 !! html/php
21660 <ul class="gallery mw-gallery-traditional">
21661 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21662 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21663 <div class="gallerytext">
21664 </div>
21665 </div></li>
21666 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21667 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21668 <div class="gallerytext">
21669 </div>
21670 </div></li>
21671 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21672 <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>
21673 <div class="gallerytext">
21674 </div>
21675 </div></li>
21676 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21677 <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>
21678 <div class="gallerytext">
21679 </div>
21680 </div></li>
21681 </ul>
21682
21683 !! html/parsoid
21684 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21685 <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>
21686 <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>
21687 <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>
21688 <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>
21689 </ul>
21690 !! end
21691
21692 !! test
21693 Gallery override link with wikilink (T36852)
21694 !! options
21695 parsoid={
21696 "nativeGallery": true
21697 }
21698 !! wikitext
21699 <gallery>
21700 File:Foobar.jpg|alt=galleryalt|link=Wikilink
21701 </gallery>
21702 !! html/php
21703 <ul class="gallery mw-gallery-traditional">
21704 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21705 <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>
21706 <div class="gallerytext">
21707 </div>
21708 </div></li>
21709 </ul>
21710
21711 !! html/parsoid
21712 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21713 <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>
21714 </ul>
21715 !! end
21716
21717 !! test
21718 Gallery override link with absolute external link (T36852)
21719 !! options
21720 parsoid={
21721 "nativeGallery": true
21722 }
21723 !! wikitext
21724 <gallery>
21725 File:Foobar.jpg|alt=galleryalt|link=http://www.example.org
21726 </gallery>
21727 !! html/php
21728 <ul class="gallery mw-gallery-traditional">
21729 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21730 <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>
21731 <div class="gallerytext">
21732 </div>
21733 </div></li>
21734 </ul>
21735
21736 !! html/parsoid
21737 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21738 <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>
21739 </ul>
21740 !! end
21741
21742 !! test
21743 Gallery override link with absolute external link with LanguageConverter
21744 !! options
21745 language=zh
21746 !! wikitext
21747 <gallery>
21748 File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org
21749 </gallery>
21750 !! html/php
21751 <ul class="gallery mw-gallery-traditional">
21752 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21753 <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>
21754 <div class="gallerytext">
21755 <p>caption
21756 </p>
21757 </div>
21758 </div></li>
21759 </ul>
21760
21761 !! html/parsoid
21762 <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"}}'>
21763 <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>
21764 </ul>
21765 !! end
21766
21767 !! test
21768 Gallery override link with malicious javascript (T36852)
21769 !! options
21770 parsoid={
21771 "modes": ["wt2html", "html2html"],
21772 "nativeGallery": true
21773 }
21774 !! wikitext
21775 <gallery>
21776 File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!');
21777 </gallery>
21778 !! html/php
21779 <ul class="gallery mw-gallery-traditional">
21780 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21781 <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>
21782 <div class="gallerytext">
21783 </div>
21784 </div></li>
21785 </ul>
21786
21787 !! html/parsoid
21788 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21789 <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>
21790 </ul>
21791 !! end
21792
21793 # Note that parsoid uses the invalid link as a caption, PHP does not.
21794 !! test
21795 Gallery with invalid title as link (T45964)
21796 !! options
21797 parsoid={
21798 "modes": ["wt2html", "html2html"],
21799 "nativeGallery": true
21800 }
21801 !! wikitext
21802 <gallery>
21803 File:Foobar.jpg|link=<
21804 </gallery>
21805 !! html/php
21806 <ul class="gallery mw-gallery-traditional">
21807 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21808 <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>
21809 <div class="gallerytext">
21810 </div>
21811 </div></li>
21812 </ul>
21813
21814 !! html/parsoid
21815 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21816 <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>
21817 </ul>
21818 !! end
21819
21820 !! test
21821 Serialize gallery without attrs in data-mw
21822 !! options
21823 parsoid={
21824 "modes": ["html2wt"],
21825 "nativeGallery": true
21826 }
21827 !! html/parsoid
21828 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'>
21829 <li class="gallerycaption">123</li>
21830 <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>
21831 </ul>
21832 !! wikitext
21833 <gallery caption="123">
21834 File:Test.png
21835 </gallery>
21836 !! end
21837
21838 !! test
21839 Gallery with class and style attributes
21840 !! options
21841 parsoid={
21842 "nativeGallery": true
21843 }
21844 !! wikitext
21845 <gallery class="center" style="text-align: center;">
21846 File:Foobar.jpg
21847 </gallery>
21848 !! html/php
21849 <ul class="gallery mw-gallery-traditional center" style="text-align: center;">
21850 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21851 <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>
21852 <div class="gallerytext">
21853 </div>
21854 </div></li>
21855 </ul>
21856
21857 !! html/parsoid
21858 <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":{}}'>
21859 <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>
21860 </ul>
21861 !! end
21862
21863 !! test
21864 Gallery in slideshow mode
21865 !! options
21866 parsoid={
21867 "nativeGallery": true
21868 }
21869 !! wikitext
21870 <gallery mode="slideshow" showthumbnails="">
21871 File:Foobar.jpg
21872 </gallery>
21873 !! html/php
21874 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1">
21875 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21876 <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>
21877 <div class="gallerytext">
21878 </div>
21879 </div></li>
21880 </ul>
21881
21882 !! html/parsoid
21883 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'>
21884 <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>
21885 </ul>
21886 !! end
21887
21888 !! test
21889 Serialize gallery image captions on a line
21890 !! options
21891 parsoid={
21892 "modes": ["html2wt"],
21893 "nativeGallery": true
21894 }
21895 !! html/parsoid
21896 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21897 <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>
21898 <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>
21899 </ul>
21900 !! wikitext
21901 <gallery>
21902 File:Foobar.jpg| hi ho
21903 File:Foobar.jpg|hi<br />ho
21904 </gallery>
21905 !! end
21906
21907 !! test
21908 HTML Hex character encoding (spells the word "JavaScript")
21909 !! options
21910 parsoid=wt2html,wt2wt,html2html
21911 !! wikitext
21912 &#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
21913 !! html/php
21914 <p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
21915 </p>
21916 !! html/parsoid
21917 <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>
21918 !! end
21919
21920 !! test
21921 HTML Hex character encoding bogus encoding (T28437 regression check)
21922 !! wikitext
21923 &#xsee;&#XSEE;
21924 !! html
21925 <p>&amp;#xsee;&amp;#XSEE;
21926 </p>
21927 !! end
21928
21929 !! test
21930 HTML Hex character encoding mixed case
21931 !! options
21932 parsoid=wt2html,wt2wt,html2html
21933 !! wikitext
21934 &#xEE;&#Xee;
21935 !! html/php
21936 <p>&#xee;&#xee;
21937 </p>
21938 !! html/parsoid
21939 <p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
21940 !! end
21941
21942 # See: https://www.w3.org/TR/html5/syntax.html#character-references
21943 # Note that U+000C (form feed) is not a valid XML character, so
21944 # it is banned even though allowed in HTML5.
21945 !! test
21946 Illegal character references (T106578)
21947 !! wikitext
21948 ; Null: &#00;
21949 ; FF: &#xC;
21950 ; CR: &#xD;
21951 ; Control (low): &#8;
21952 ; Control (high): &#x7F; &#x9F;
21953 ; Surrogate: &#xD83D;&#xDCA9;
21954 ; This is an okay astral character: &#x1F4A9;
21955 !! html+tidy
21956 <dl><dt>Null</dt>
21957 <dd>&amp;#00;</dd>
21958 <dt>FF</dt>
21959 <dd>&amp;#xC;</dd>
21960 <dt>CR</dt>
21961 <dd>&amp;#xD;</dd>
21962 <dt>Control (low)</dt>
21963 <dd>&amp;#8;</dd>
21964 <dt>Control (high)</dt>
21965 <dd>&amp;#x7F; &amp;#x9F;</dd>
21966 <dt>Surrogate</dt>
21967 <dd>&amp;#xD83D;&amp;#xDCA9;</dd>
21968 <dt>This is an okay astral character</dt>
21969 <dd>&#x1f4a9;</dd></dl>
21970 !! end
21971
21972 !! test
21973 __FORCETOC__ override
21974 !! wikitext
21975 __NEWSECTIONLINK__
21976 __FORCETOC__
21977 !! html/php
21978 <p><br />
21979 </p>
21980 !! end
21981
21982 !! test
21983 ISBN code coverage
21984 !! wikitext
21985 ISBN 978-0-1234-56&#x20;789
21986 !! html/php
21987 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a>&#x20;789
21988 </p>
21989 !! html/parsoid
21990 <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>
21991 !! end
21992
21993 !! test
21994 ISBN followed by 5 spaces
21995 !! wikitext
21996 ISBN
21997 !! html
21998 <p>ISBN
21999 </p>
22000 !! end
22001
22002 !! test
22003 Double ISBN
22004 !! wikitext
22005 ISBN ISBN 1234567890
22006 !! html/php
22007 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
22008 </p>
22009 !! html/parsoid
22010 <p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
22011 !! end
22012
22013 # Uppercase X and lowercase x as well
22014 !! test
22015 ISBN with an X
22016 !! wikitext
22017 ISBN 3-462-04561-X
22018 ISBN 3-462-04561-x
22019 ISBN 080442957X
22020 ISBN 080442957x
22021 ISBN 978080442957X
22022 ISBN 978080442957x
22023 !! html/php
22024 <p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a>
22025 <a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a>
22026 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a>
22027 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a>
22028 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a>
22029 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
22030 </p>
22031 !! html/parsoid
22032 <p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
22033 <a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
22034 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
22035 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
22036 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
22037 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
22038 !! end
22039
22040 !! test
22041 ISBN with empty prefix (parsoid test)
22042 !! wikitext
22043 ISBN 1234567890
22044 !! html/php
22045 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
22046 </p>
22047 !! html/parsoid
22048 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p>
22049 !! end
22050
22051 !! test
22052 T24905: <abbr> followed by ISBN followed by </a>
22053 !! wikitext
22054 <abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
22055 !! html/php
22056 <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>
22057 </p>
22058 !! html/parsoid
22059 <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>
22060 !! end
22061
22062 !! test
22063 Double RFC
22064 !! wikitext
22065 RFC RFC 1234
22066 !! html/php
22067 <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a>
22068 </p>
22069 !! html/parsoid
22070 <p>RFC <a href="https://tools.ietf.org/html/rfc1234" rel="mw:ExtLink" class="external mw-magiclink">RFC 1234</a></p>
22071 !! end
22072
22073 !! test
22074 Double RFC with a wiki link
22075 !! wikitext
22076 RFC [[RFC 1234]]
22077 !! html/php
22078 <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>
22079 </p>
22080 !! html/parsoid
22081 <p>RFC <a rel="mw:WikiLink" href="./RFC_1234" title="RFC 1234">RFC 1234</a></p>
22082 !! end
22083
22084 !! test
22085 RFC code coverage
22086 !! wikitext
22087 RFC 983&#x20;987
22088 !! html/php
22089 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
22090 </p>
22091 !! html/parsoid
22092 <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>
22093 !! end
22094
22095 !! test
22096 Centre-aligned image
22097 !! wikitext
22098 [[Image:foobar.jpg|centre]]
22099 !! html/php
22100 <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>
22101
22102 !! html/parsoid
22103 <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>
22104 !! end
22105
22106 !! test
22107 None-aligned image
22108 !! wikitext
22109 [[Image:foobar.jpg|none]]
22110 !! html/php
22111 <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>
22112
22113 !! html/parsoid
22114 <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>
22115 !! end
22116
22117 !! test
22118 Width + Height sized image (using px) (height is ignored)
22119 !! wikitext
22120 [[Image:foobar.jpg|640x480px]]
22121 !! html/php
22122 <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>
22123 </p>
22124 !! html/parsoid
22125 <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>
22126 !! end
22127
22128 !! test
22129 Width-sized image (using px, no following whitespace)
22130 !! wikitext
22131 [[Image:foobar.jpg|640px]]
22132 !! html/php
22133 <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>
22134 </p>
22135 !! html/parsoid
22136 <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>
22137 !! end
22138
22139 !! test
22140 Width-sized image (using px, with following whitespace - test regression from r39467)
22141 !! wikitext
22142 [[Image:foobar.jpg|640px ]]
22143 !! html/php
22144 <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>
22145 </p>
22146 !! html/parsoid
22147 <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>
22148 !!end
22149
22150 !! test
22151 Width-sized image (using px, with preceding whitespace - test regression from r39467)
22152 !! wikitext
22153 [[Image:foobar.jpg| 640px]]
22154 !! html/php
22155 <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>
22156 </p>
22157 !! html/parsoid
22158 <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>
22159 !! end
22160
22161 !! test
22162 Image with page parameter
22163 !! options
22164 djvu
22165 !! wikitext
22166 [[File:LoremIpsum.djvu|page=2]]
22167 !! html/php
22168 <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>
22169 </p>
22170 !! html/parsoid
22171 <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>
22172 !! end
22173
22174 !! test
22175 Another italics / bold test
22176 !! wikitext
22177 ''' ''x'
22178 !! html
22179 <pre>'<i> </i>x'
22180 </pre>
22181 !!end
22182
22183 # FIXME: The php output seems broken. It's interleaving some open/close tags.
22184 !! test
22185 dt/dd/dl test
22186 !! wikitext
22187 :;;;::
22188 !! html/php
22189 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dt></dl></dd></dl></dd></dl></dd></dl></dd></dl></dd></dl>
22190
22191 !! html/parsoid
22192 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dd></dl></dd></dl></dt></dl></dt></dl></dt></dl></dd></dl>
22193
22194 !!end
22195
22196 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
22197 !! test
22198 Images with the "|" character in the comment
22199 !! wikitext
22200 [[File:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
22201 !! html/php
22202 <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>
22203
22204 !! html/parsoid
22205 <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>
22206 !! end
22207
22208 !! test
22209 [Before] HTML without raw HTML enabled ($wgRawHtml==false)
22210 !! wikitext
22211 <html><script>alert(1);</script></html>
22212 !! html
22213 <p>&lt;html&gt;&lt;script&gt;alert(1);&lt;/script&gt;&lt;/html&gt;
22214 </p>
22215 !! end
22216
22217 !! test
22218 HTML with raw HTML ($wgRawHtml==true)
22219 !! options
22220 wgRawHtml=1
22221 !! wikitext
22222 <html><script>alert(1);</script></html>
22223 !! html/php
22224 <p><script>alert(1);</script>
22225 </p>
22226 !! html/parsoid
22227 <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>
22228 !! end
22229
22230 !! test
22231 Parents of subpages, one level up
22232 !! options
22233 subpage title=[[Subpage test/L1/L2/L3]]
22234 !! wikitext
22235 [[../|L2]]
22236 !! html
22237 <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>
22238 </p>
22239 !! end
22240
22241
22242 !! test
22243 Parents of subpages, one level up, not named
22244 !! options
22245 subpage title=[[Subpage test/L1/L2/L3]]
22246 !! wikitext
22247 [[../]]
22248 !! html
22249 <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>
22250 </p>
22251 !! end
22252
22253
22254
22255 !! test
22256 Parents of subpages, two levels up
22257 !! options
22258 subpage title=[[Subpage test/L1/L2/L3]]
22259 !! wikitext
22260 [[../../|L1]]2
22261
22262 [[../../|L1]]l
22263 !! html
22264 <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
22265 </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>
22266 </p>
22267 !! end
22268
22269 !! test
22270 Parents of subpages, two levels up, without trailing slash or name.
22271 !! options
22272 subpage title=[[Subpage test/L1/L2/L3]]
22273 !! wikitext
22274 [[../..]]
22275 !! html
22276 <p>[[../..]]
22277 </p>
22278 !! end
22279
22280 !! test
22281 Parents of subpages, two levels up, with lots of extra trailing slashes.
22282 !! options
22283 subpage title=[[Subpage test/L1/L2/L3]]
22284 !! wikitext
22285 [[../../////]]
22286 !! html
22287 <p><a href="/index.php?title=Subpage_test/L1&amp;action=edit&amp;redlink=1" class="new" title="Subpage test/L1 (page does not exist)">Subpage test/L1</a>
22288 </p>
22289 !! end
22290
22291 !! article
22292 Subpage test/L1/L2/L3Sibling
22293 !! text
22294 Sibling article
22295 !! endarticle
22296
22297 !! test
22298 Transclusion of a sibling page (one level up)
22299 !! options
22300 subpage title=[[Subpage test/L1/L2/L3]]
22301 !! wikitext
22302 {{../L3Sibling}}
22303 !! html
22304 <p>Sibling article
22305 </p>
22306 !! end
22307
22308 !! test
22309 Transclusion of a child page
22310 !! options
22311 subpage title=[[Subpage test/L1/L2]]
22312 !! wikitext
22313 {{/L3Sibling}}
22314 !! html
22315 <p>Sibling article
22316 </p>
22317 !! end
22318
22319 # This is wt2html only in Parsoid because we add <nowiki>
22320 # because of {{..}} and we don't expect to fix that to
22321 # eliminate the nowikis selective for {{..}} markup.
22322 !! test
22323 Non-transclusion because of too many up levels
22324 !! options
22325 subpage title=[[Subpage test/L1/L2/L3]]
22326 parsoid=wt2html
22327 !! wikitext
22328 {{../../../../More than parent}}
22329 !! html/php
22330 <p>{{../../../../More than parent}}
22331 </p>
22332 !! html/parsoid
22333 <p>{{../../../../More than parent}}</p>
22334 !! end
22335
22336 !! test
22337 Definition list code coverage
22338 !! wikitext
22339 ;title :def
22340 ;title :def
22341 ;title:def
22342 !! html/php
22343 <dl><dt>title</dt>
22344 <dd>def</dd>
22345 <dt>title</dt>
22346 <dd>def</dd>
22347 <dt>title</dt>
22348 <dd>def</dd></dl>
22349
22350 !! html/parsoid
22351 <dl><dt>title </dt><dd>def</dd>
22352 <dt>title </dt><dd>def</dd>
22353 <dt>title</dt><dd>def</dd></dl>
22354 !! end
22355
22356 !! test
22357 Don't fall for the self-closing div
22358 !! wikitext
22359 <div>hello world</div/>
22360 !! html
22361 <div>hello world</div>
22362
22363 !! end
22364
22365 !! test
22366 MSGNW magic word
22367 !! wikitext
22368 {{MSGNW:msg}}
22369 !! html/php
22370 <p>&#91;&#91;:Template:Msg&#93;&#93;
22371 </p>
22372 !! end
22373
22374 !! test
22375 RAW magic word
22376 !! wikitext
22377 {{RAW:QUERTY}}
22378 !! html
22379 <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>
22380 </p>
22381 !! end
22382
22383 # This isn't needed for XHTML conformance, but would be handy as a fallback security measure
22384 !! test
22385 Always escape literal '>' in output, not just after '<'
22386 !! wikitext
22387 ><>
22388 !! html
22389 <p>&gt;&lt;&gt;
22390 </p>
22391 !! end
22392
22393 !! test
22394 Template caching
22395 !! wikitext
22396 {{Test}}
22397 {{Test}}
22398 !! html
22399 <p>This is a test template
22400 This is a test template
22401 </p>
22402 !! end
22403
22404
22405 !! article
22406 MediaWiki:Fake
22407 !! text
22408 ==header==
22409 !! endarticle
22410
22411 !! test
22412 Inclusion of !userCanEdit() content
22413 !! wikitext
22414 {{MediaWiki:Fake}}
22415 !! html
22416 <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>
22417
22418 !! end
22419
22420
22421 !! test
22422 Out-of-order TOC heading levels
22423 !! wikitext
22424 ==2==
22425 ======6======
22426 ===3===
22427 =1=
22428 =====5=====
22429 ==2==
22430 !! html
22431 <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>
22432 <ul>
22433 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
22434 <ul>
22435 <li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
22436 <li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
22437 </ul>
22438 </li>
22439 <li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
22440 <ul>
22441 <li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
22442 <li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
22443 </ul>
22444 </li>
22445 </ul>
22446 </div>
22447
22448 <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>
22449 <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>
22450 <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>
22451 <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>
22452 <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>
22453 <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>
22454
22455 !! end
22456
22457
22458 !! test
22459 ISBN with a dummy number
22460 !! wikitext
22461 ISBN ---
22462 !! html
22463 <p>ISBN ---
22464 </p>
22465 !! end
22466
22467
22468 !! test
22469 ISBN with space-delimited number
22470 !! wikitext
22471 ISBN 92 9017 032 8
22472 !! html/php
22473 <p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a>
22474 </p>
22475 !! html/parsoid
22476 <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>
22477 !! end
22478
22479
22480 !! test
22481 ISBN with multiple spaces, no number
22482 !! wikitext
22483 ISBN foo
22484 !! html
22485 <p>ISBN foo
22486 </p>
22487 !! end
22488
22489
22490 !! test
22491 ISBN length
22492 !! wikitext
22493 ISBN 123456789
22494
22495 ISBN 1234567890
22496
22497 ISBN 12345678901
22498 !! html/php
22499 <p>ISBN 123456789
22500 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
22501 </p><p>ISBN 12345678901
22502 </p>
22503 !! html/parsoid
22504 <p>ISBN 123456789</p>
22505
22506 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
22507
22508 <p>ISBN 12345678901</p>
22509 !! end
22510
22511
22512 !! test
22513 ISBN with trailing year (T9110)
22514 !! wikitext
22515 ISBN 1-234-56789-0 - 2006
22516
22517 ISBN 1 234 56789 0 - 2006
22518 !! html/php
22519 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006
22520 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006
22521 </p>
22522 !! html/parsoid
22523 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p>
22524
22525 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p>
22526 !! end
22527
22528
22529 !! test
22530 anchorencode
22531 !! config
22532 wgFragmentMode=[ 'html5', 'legacy' ]
22533 !! wikitext
22534 {{anchorencode:foo bar©#%n}}
22535 !! html/php
22536 <p>foo_bar©#%n
22537 </p>
22538 !! html/parsoid
22539 <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>
22540 !! end
22541
22542 !! test
22543 anchorencode (legacy)
22544 !! config
22545 wgFragmentMode=[ 'legacy' ]
22546 !! wikitext
22547 {{anchorencode:foo bar©#%n}}
22548 !! html/php
22549 <p>foo_bar.C2.A9.23.25n
22550 </p>
22551 !! end
22552
22553 !! test
22554 anchorencode trims spaces
22555 !! config
22556 wgFragmentMode=[ 'html5', 'legacy' ]
22557 !! wikitext
22558 {{anchorencode: __pretty__please__}}
22559 !! html/php
22560 <p>pretty_please
22561 </p>
22562 !! html/parsoid
22563 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: __pretty__please__","function":"anchorencode"},"params":{},"i":0}}]}'>pretty_please</p>
22564 !! end
22565
22566 !! test
22567 anchorencode deals with links
22568 !! config
22569 wgFragmentMode=[ 'html5', 'legacy' ]
22570 !! wikitext
22571 {{anchorencode: [[hello|world]] [[hi]]}}
22572 !! html/php
22573 <p>world_hi
22574 </p>
22575 !! html/parsoid
22576 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: [[hello|world]] [[hi]]","function":"anchorencode"},"params":{},"i":0}}]}'>world_hi</p>
22577 !! end
22578
22579 !! test
22580 anchorencode deals with templates
22581 !! config
22582 wgFragmentMode=[ 'html5', 'legacy' ]
22583 !! wikitext
22584 {{anchorencode: {{Foo}} x}}
22585 !! html/php
22586 <p>FOO_x
22587 </p>
22588 !! html/parsoid
22589 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: {{Foo}} x","function":"anchorencode"},"params":{},"i":0}}]}'>FOO_x</p>
22590 !! end
22591
22592 !! test
22593 anchorencode encodes like the TOC generator: (T20431)
22594 !! config
22595 wgFragmentMode=[ 'html5', 'legacy' ]
22596 !! wikitext
22597 ===_ +:.3A%3A _ &&amp;]] x===
22598 {{anchorencode: _ +:.3A%3A _ &&amp;]] x}}
22599 __NOEDITSECTION__
22600 !! html/php
22601 <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>
22602 <p>+:.3A%3A_&amp;&amp;&#93;&#93;_x
22603 </p>
22604 !! html/parsoid
22605 <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>
22606 <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>
22607 <meta property="mw:PageProp/noeditsection"/>
22608 !! end
22609
22610 !! test
22611 anchorencode encodes like the TOC generator: (T20431) (legacy)
22612 !! config
22613 wgFragmentMode=[ 'legacy' ]
22614 !! wikitext
22615 ===_ +:.3A%3A&&amp;]]===
22616 {{anchorencode: _ +:.3A%3A&&amp;]] }}
22617 __NOEDITSECTION__
22618 !! html/php
22619 <h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&amp;&amp;]]</span></h3>
22620 <p>.2B:.3A.253A.26.26.5D.5D
22621 </p>
22622 !! end
22623
22624 !! test
22625 T8200: blockquotes and paragraph formatting
22626 !! wikitext
22627 <blockquote>
22628 foo
22629 </blockquote>
22630
22631 bar
22632
22633 baz
22634 !! html
22635 <blockquote>
22636 <p>foo
22637 </p>
22638 </blockquote>
22639 <p>bar
22640 </p>
22641 <pre>baz
22642 </pre>
22643 !! end
22644
22645 !! test
22646 T10293: Use of center tag ruins paragraph formatting
22647 !! wikitext
22648 <center>
22649 foo
22650 </center>
22651
22652 bar
22653
22654 baz
22655 !! html
22656 <center>
22657 <p>foo
22658 </p>
22659 </center>
22660 <p>bar
22661 </p>
22662 <pre>baz
22663 </pre>
22664 !! end
22665
22666 !!test
22667 Parsing of overlapping (improperly nested) inline html tags
22668 !! wikitext
22669 <span><s>x</span></s>
22670 !! html/php
22671 <p><span><s>x&lt;/span&gt;</s></span>
22672 </p>
22673 !! html/parsoid
22674 <p><span><s>x</s></span>
22675 </p>
22676 !!end
22677
22678 ###
22679 ### Language variants related tests
22680 ###
22681
22682 # Parsoid does not mark self-links.
22683 # Parsoid does not convert links; PHP will do any necessary redirects.
22684
22685 !! test
22686 Self-link in language variants
22687 !! options
22688 title=[[Dunav]] language=sr
22689 !! wikitext
22690 Both [[Dunav]] and [[Дунав]] are names for this river.
22691 !! html/php
22692 <p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
22693 </p>
22694 !! html/parsoid
22695 <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>
22696 !! end
22697
22698 !! article
22699 Дуна
22700 !! text
22701 content
22702 !! endarticle
22703
22704 !! test
22705 Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
22706 !! options
22707 title=[[Duna]] language=sr
22708 !! wikitext
22709 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
22710 !! html/php
22711 <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.
22712 </p>
22713 !! html/parsoid
22714 <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>
22715 !! end
22716
22717 !! test
22718 Link to a section of a variant of this title shouldn't be parsed as self-link
22719 !! options
22720 title=[[Duna]] language=sr
22721 !! wikitext
22722 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
22723 !! html/php
22724 <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.
22725 </p>
22726 !! html/parsoid
22727 <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>
22728 !! end
22729
22730 !! test
22731 Link to pages in language variants
22732 !! options
22733 language=sr
22734 !! wikitext
22735 Main Page can be written as [[Маин Паге]]
22736 !! html/php
22737 <p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>
22738 </p>
22739 !! html/parsoid
22740 <p>Main Page can be written as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a></p>
22741 !! end
22742
22743
22744 !! test
22745 Multiple links to pages in language variants
22746 !! options
22747 language=sr
22748 !! wikitext
22749 [[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
22750 !! html/php
22751 <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>.
22752 </p>
22753 !! html/parsoid
22754 <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>
22755 !! end
22756
22757
22758 !! test
22759 Simple template in language variants
22760 !! options
22761 language=sr
22762 !! wikitext
22763 {{тест}}
22764 !! html/php
22765 <p>This is a test template
22766 </p>
22767 !! end
22768
22769
22770 !! test
22771 Template with explicit namespace in language variants
22772 !! options
22773 language=sr
22774 !! wikitext
22775 {{Template:тест}}
22776 !! html/php
22777 <p>This is a test template
22778 </p>
22779 !! end
22780
22781
22782 !! test
22783 Basic test for template parameter in language variants
22784 !! options
22785 language=sr
22786 !! wikitext
22787 {{парамтест|param=foo}}
22788 !! html/php
22789 <p>This is a test template with parameter foo
22790 </p>
22791 !! end
22792
22793 !! test
22794 Simple category in language variants
22795 !! options
22796 language=sr cat
22797 !! wikitext
22798 [[Category:МедиаWики Усер'с Гуиде]]
22799 !! html/php
22800 cat=МедиаWики_Усер'с_Гуиде sort=
22801 !! html/parsoid
22802 <link rel="mw:PageProp/Category" href="./Категорија:МедиаWики_Усер'с_Гуиде" data-parsoid='{"stx":"simple","a":{"href":"./Категорија:МедиаWики_Усер&#39;с_Гуиде"},"sa":{"href":"Category:МедиаWики Усер&#39;с Гуиде"}}'/>
22803 !! end
22804
22805 !! article
22806 Category:分类
22807 !! text
22808 blah
22809 !! endarticle
22810
22811 !! article
22812 Category:分類
22813 !! text
22814 blah
22815 !! endarticle
22816
22817 ## We used to, but no longer wt2wt this test since the default serializer
22818 ## will normalize all categories to serialize on their own line.
22819 ## This wikitext usage is going to be fairly uncommon in production and
22820 ## selser will take care of preserving formatting in those scenarios.
22821 !! test
22822 Don't convert blue categorylinks to another variant (T35210)
22823 !! options
22824 cat
22825 language=zh
22826 parsoid=wt2html
22827 !! wikitext
22828 [[A]][[Category:分类]]
22829 !! html/php
22830 cat=分类 sort=
22831 !! html/parsoid
22832 <p><a rel="mw:WikiLink" href="./A" title="A">A</a></p>
22833 <link rel="mw:PageProp/Category" href="./Category:分类"/>
22834 !! end
22835
22836 !! test
22837 Stripping -{}- tags (language variants)
22838 !! options
22839 language=sr
22840 !! wikitext
22841 Latin proverb: -{Ne nuntium necare}-
22842 !! html/php
22843 <p>Latin proverb: Ne nuntium necare
22844 </p>
22845 !! html/parsoid
22846 <p>Latin proverb: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22847 !! end
22848
22849
22850 !! test
22851 Prevent conversion with -{}- tags (language variants)
22852 !! options
22853 language=sr variant=sr-ec
22854 !! wikitext
22855 Latinski: -{Ne nuntium necare}-
22856 !! html/php
22857 <p>Латински: Ne nuntium necare
22858 </p>
22859 !! html/parsoid
22860 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22861 !! end
22862
22863
22864 !! test
22865 Prevent conversion of text with -{}- tags (language variants)
22866 !! options
22867 language=sr variant=sr-ec
22868 !! wikitext
22869 Latinski: -{Ne nuntium necare}-
22870 !! html/php
22871 <p>Латински: Ne nuntium necare
22872 </p>
22873 !! html/parsoid
22874 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22875 !! end
22876
22877
22878 !! test
22879 Prevent conversion of links with -{}- tags (language variants)
22880 !! options
22881 language=sr variant=sr-ec
22882 !! wikitext
22883 -{[[Main Page]]}-
22884 !! html/php
22885 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
22886 </p>
22887 !! html/parsoid
22888 <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>
22889 !! end
22890
22891
22892 !! test
22893 -{}- tags within headlines (within html for parserConvert())
22894 !! config
22895 wgFragmentMode=[ 'html5', 'legacy' ]
22896 !! options
22897 language=sr variant=sr-ec
22898 !! wikitext
22899 ==-{Naslov}-==
22900
22901 Note that even an unprotected headline ID is not affected by language
22902 conversion:
22903
22904 ==Latinski==
22905 !! html/php
22906 <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>
22907 <p>Ноте тхат евен ан унпротецтед хеадлине ИД ис нот аффецтед бy лангуаге
22908 цонверсион:
22909 </p>
22910 <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>
22911
22912 !! html/parsoid
22913 <h2 id="-{Naslov}-"><span id="-.7BNaslov.7D-" typeof="mw:FallbackId"></span><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Naslov"}}'></span></h2>
22914
22915 <p>Note that even an unprotected headline ID is not affected by language
22916 conversion:</p>
22917
22918 <h2 id="Latinski">Latinski</h2>
22919 !! end
22920
22921 !! test
22922 Explicit definition of language variant alternatives
22923 !! options
22924 language=zh variant=zh-tw
22925 !! wikitext
22926 -{zh:China;zh-tw:Taiwan}-, not China
22927 !! html/php
22928 <p>Taiwan, not China
22929 </p>
22930 !! html/parsoid
22931 <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>
22932 !! end
22933
22934 !! test
22935 Filter syntax for language variants
22936 !! options
22937 language=zh variant=zh-tw
22938 !! wikitext
22939 foo-{zh;zh-hans;zh-hant|blog, WEBJOURNAL, WEBLOG}-quux
22940 !! html/php
22941 <p>fooblog, WEBJOURNAL, WEBLOGquux
22942 </p>
22943 !! html/parsoid
22944 <p>foo<span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"blog, WEBJOURNAL, WEBLOG"}}'></span>quux</p>
22945 !! end
22946
22947 # Note that Parsoid post-processing for language variants needs to
22948 # update the `title` attribute here, based on the mw:ExpandedAttrs property
22949 !! test
22950 Conversion around HTML tags
22951 !! options
22952 language=sr variant=sr-ec
22953 !! wikitext
22954 -{H|span=>sr-ec:script;title=>sr-ec:src}-
22955 <span title="La-{sr-el:L;sr-ec:C}-tin">ski</span>
22956 !! html/php
22957 <p>
22958 <span title="ЛаCтин">ски</span>
22959 </p>
22960 !! html/parsoid
22961 <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"}]}'/>
22962 <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>
22963 !! end
22964
22965 !! test
22966 Explicit session-wise two-way language variant mapping (A flag and - flag)
22967 !! options
22968 language=zh variant=zh-tw
22969 !! wikitext
22970 This is -{zh:China; zh-tw:Taiwan}-, but we'll forget that now.
22971
22972 Taiwan is not China.
22973
22974 But -{A|zh:China; zh-tw:Taiwan}- is China,
22975
22976 (This-{-|zh:China; zh-tw:Taiwan}- should be stripped!)
22977
22978 and -{China}- is China.
22979 !! html/php
22980 <p>This is Taiwan, but we'll forget that now.
22981 </p><p>Taiwan is not China.
22982 </p><p>But Taiwan is Taiwan,
22983 </p><p>(This should be stripped!)
22984 </p><p>and China is China.
22985 </p>
22986 !! html/parsoid
22987 <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>
22988 <p>Taiwan is not China.</p>
22989 <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>
22990 <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>
22991 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"China"}}'></span> is China.</p>
22992 !! end
22993
22994 !! test
22995 Explicit session-wise one-way language variant mapping (A flag and - flag)
22996 !! options
22997 language=zh variant=zh-tw
22998 !! wikitext
22999 This is -{COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}-, but we'll forget that now.
23000
23001 COUNTRY is China or Taiwan.
23002
23003 But -{A|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- is COUNTRY,
23004
23005 (This-{-|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
23006
23007 and -{COUNTRY}- is COUNTRY.
23008 !! html/php
23009 <p>This is Taiwan, but we'll forget that now.
23010 </p><p>COUNTRY is China or Taiwan.
23011 </p><p>But Taiwan is Taiwan,
23012 </p><p>(This should be stripped!)
23013 </p><p>and COUNTRY is COUNTRY.
23014 </p>
23015 !! html/parsoid
23016 <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>
23017 <p>COUNTRY is China or Taiwan.</p>
23018 <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>
23019 <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>
23020 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"COUNTRY"}}'></span> is COUNTRY.</p>
23021 !! end
23022
23023 !! test
23024 Explicit session-wise two-way language variant mapping (H flag for hide)
23025 !! options
23026 language=zh variant=zh-tw
23027 !! wikitext
23028 (This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
23029
23030 Taiwan is China.
23031 !! html/php
23032 <p>(This should be stripped!)
23033 </p><p>Taiwan is Taiwan.
23034 </p>
23035 !! html/parsoid
23036 <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>
23037 <p>Taiwan is China.</p>
23038 !! end
23039
23040 !! test
23041 Explicit session-wise one-way language variant mapping (H flag for hide)
23042 !! options
23043 language=zh variant=zh-tw
23044 !! wikitext
23045 (This-{H|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
23046
23047 COUNTRY is Taiwan or China.
23048 !! html/php
23049 <p>(This should be stripped!)
23050 </p><p>Taiwan is Taiwan or China.
23051 </p>
23052 !! html/parsoid
23053 <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>
23054 <p>COUNTRY is Taiwan or China.</p>
23055 !! end
23056
23057 ## Note that parsoid test runner does not support 'showtitle' option.
23058 !! test
23059 Adding explicit conversion rule for title (T flag)
23060 !! options
23061 language=zh variant=zh-tw showtitle
23062 !! wikitext
23063 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
23064
23065 Taiwan is China.
23066 !! html/php
23067 Taiwan
23068 <p>Should be stripped!
23069 </p><p>Taiwan is China.
23070 </p>
23071 !! html/parsoid
23072 <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>
23073 <p>Taiwan is China.</p>
23074 !! end
23075
23076 !! test
23077 Code coverage: T combined with H flag
23078 !! options
23079 language=zh variant=zh-tw showtitle
23080 !! wikitext
23081 Should be stripped-{T;H|zh:China; zh-tw:Taiwan}-!
23082
23083 Taiwan is China.
23084 !! html/php
23085 Taiwan
23086 <p>Should be stripped!
23087 </p><p>Taiwan is Taiwan.
23088 </p>
23089 !! html/parsoid
23090 <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>
23091 <p>Taiwan is China.</p>
23092 !! end
23093
23094 !! test
23095 Code coverage: T with no variants
23096 !! options
23097 language=zh variant=zh-tw showtitle
23098 !! wikitext
23099 -{H|zh:China; zh-tw:Taiwan}-
23100 Taiwan is China.-{T|Taiwan is China}-
23101 !! html/php
23102 Taiwan is China
23103 <p>
23104 Taiwan is Taiwan.
23105 </p>
23106 !! html/parsoid
23107 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
23108 Taiwan is China.<meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Taiwan is China"},"title":true}'/></p>
23109 !! end
23110
23111 !! test
23112 Code coverage: rules with no variants
23113 !! options
23114 language=zh variant=zh-tw
23115 !! wikitext
23116 -{H|zh:China; zh-tw:Taiwan}-
23117 Taiwan is China.
23118 -{H|China}-
23119 Taiwan is China.
23120 !! html/php
23121 <p>
23122 Taiwan is Taiwan.
23123
23124 Taiwan is China.
23125 </p>
23126 !! html/parsoid
23127 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
23128 Taiwan is China.
23129 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":"China"}]}'/>
23130 Taiwan is China.</p>
23131 !! end
23132
23133
23134 !! test
23135 Code coverage: D flag for conversion rule
23136 !! options
23137 language=zh variant=zh-tw
23138 !! wikitext
23139 -{D|zh-cn:XA; zh-tw:YA}-
23140 -{A;D|zh-cn:XB; zh-tw:YB}-
23141 -{D;H|zh-cn:XC; zh-tw:YC}-
23142
23143 -{D;H|FOO=>zh-tw:BAR;FOO=>zh-cn:BAT}-
23144
23145 -{D|0=>zh-tw:1}-
23146 -{A;D|2=>zh-tw:3}-
23147 -{D;H|4=>zh-tw:5}-
23148
23149 XA XB XC YA YB YC FOO BAR BAT 012345
23150 !! html/php
23151 <p>大陆:XA;台灣:YA;
23152
23153 大陆:XC;台灣:YC;
23154 </p><p>FOO⇒台灣:BAR;FOO⇒大陆:BAT;
23155 </p><p>0⇒台灣:1;
23156
23157 4⇒台灣:5;
23158 </p><p>XA YB YC YA YB YC BAR BAR BAT 013355
23159 </p>
23160 !! html/parsoid
23161 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"twoway":[{"l":"zh-cn","t":"XA"},{"l":"zh-tw","t":"YA"}]}'></span>
23162 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XB"},{"l":"zh-tw","t":"YB"}]}'/>
23163 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XC"},{"l":"zh-tw","t":"YC"}]}'></span></p>
23164 <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>
23165 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"oneway":[{"f":"0","l":"zh-tw","t":"1"}]}'></span>
23166 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"2","l":"zh-tw","t":"3"}]}'/>
23167 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"4","l":"zh-tw","t":"5"}]}'></span></p>
23168 <p>XA XB XC YA YB YC FOO BAR BAT 012345</p>
23169 !! end
23170
23171 !! test
23172 Code coverage: N flag for conversion rule
23173 !! options
23174 language=zh variant=zh-cn
23175 !! wikitext
23176 -{N|zh-cn}-
23177
23178 -{N|zh-tw}-
23179
23180 -{N|sr-ec}-
23181 !! html/php
23182 <p>大陆
23183 </p><p>台灣
23184 </p><p>српски (ћирилица)‎
23185 </p>
23186 !! html/parsoid
23187 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-cn"}}'></span></p>
23188 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-tw"}}'></span></p>
23189 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"sr-ec"}}'></span></p>
23190 !! end
23191
23192 # html2wt suppresses the bogus 'D' flag, so this is wt2html only
23193 !! test
23194 Code coverage: N flag for conversion rule (wt2html only)
23195 !! options
23196 language=zh variant=zh-cn
23197 parsoid=wt2html,html2html
23198 !! wikitext
23199 -{D;N|en}-
23200 !! html/php
23201 <p>English
23202 </p>
23203 !! html/parsoid
23204 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"en"}}' data-parsoid='{"fl":["D","N"]}'></span></p>
23205 !! end
23206
23207 !! test
23208 Testing that changing the language variant here in the tests actually works
23209 !! options
23210 language=zh variant=zh showtitle
23211 !! wikitext
23212 Should be stripped-{T|zh:China; zh-tw:Taiwan}-!
23213 !! html/php
23214 China
23215 <p>Should be stripped!
23216 </p>
23217 !! html/parsoid
23218 <p>Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
23219 !! end
23220
23221 !! test
23222 Recursive conversion of alt and title attrs shouldn't clear converter state
23223 !! options
23224 language=zh variant=zh-cn
23225 showtitle
23226 !! wikitext
23227 -{H|zh-cn:Exclamation; zh-tw:exclamation}-
23228 Should be stripped-{T|zh-cn:China; zh-tw:Taiwan}-<span title="exclamation">!</span>
23229 !! html/php
23230 China
23231 <p>
23232 Should be stripped<span title="Exclamation">!</span>
23233 </p>
23234 !! html/parsoid
23235 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh-cn","t":"Exclamation"},{"l":"zh-tw","t":"exclamation"}]}'/>
23236 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>
23237 !! end
23238
23239 !! test
23240 T26072: more test on conversion rule for title
23241 !! options
23242 language=zh variant=zh-tw showtitle
23243 !! wikitext
23244 This should be stripped-{T|zh:China; zh-tw:Taiwan}-!
23245
23246 This won't take interferes with the title rule-{H|zh:Beijing; zh-tw:Taipei}-.
23247 !! html/php
23248 Taiwan
23249 <p>This should be stripped!
23250 </p><p>This won't take interferes with the title rule.
23251 </p>
23252 !! html/parsoid
23253 <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>
23254 <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>
23255 !! end
23256
23257 !! test
23258 Partly disable title conversion if variant == main language code
23259 !! options
23260 language=zh variant=zh title=[[ZH]] showtitle
23261 !! wikitext
23262 -{T|zh-cn:CN;zh-tw:TW}-
23263 !! html/php
23264 ZH
23265 <p>
23266 </p>
23267 !! html/parsoid
23268 <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>
23269 !! end
23270
23271 !! test
23272 Partly disable title conversion if variant == main language code, more
23273 !! options
23274 language=zh variant=zh title=[[ZH]] showtitle
23275 !! wikitext
23276 -{T|TW}-
23277 !! html/php
23278 ZH
23279 <p>
23280 </p>
23281 !! html/parsoid
23282 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"TW"},"title":true}'/></p>
23283 !! end
23284
23285 !! test
23286 Raw output of variant escape tags (R flag)
23287 !! options
23288 language=zh variant=zh-tw
23289 !! wikitext
23290 Raw: -{R|zh:China;zh-tw:Taiwan}-
23291 !! html/php
23292 <p>Raw: zh:China;zh-tw:Taiwan
23293 </p>
23294 !! html/parsoid
23295 <p>Raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"zh:China;zh-tw:Taiwan"}}'></span></p>
23296 !! end
23297
23298 # html2wt suppresses the bogus 'D' flags, so this is wt2html only
23299 !! test
23300 Raw output of variant escape tags (R flag) (wt2html only)
23301 !! options
23302 language=zh variant=zh-tw
23303 parsoid=wt2html,html2html
23304 !! wikitext
23305 -{Variant}- -{D|syntax}- -{D;R|options}-
23306 !! html/php
23307 <p>Variant syntax options
23308 </p>
23309 !! html/parsoid
23310 <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>
23311 !! end
23312
23313 !! test
23314 Nested markup inside raw output of variant escape tags (R flag)
23315 !! options
23316 language=zh variant=zh-tw
23317 !! wikitext
23318 Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
23319 !! html/php
23320 <p>Nested raw: nested Taiwan nested
23321 </p>
23322 !! html/parsoid
23323 <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>
23324 !! end
23325
23326 !! test
23327 Nested markup and spaces inside raw output of variant escape tags (R flag)
23328 !! options
23329 language=zh variant=zh-tw
23330 !! wikitext
23331 X-{ outer -{ inner }- outer }-X
23332 !! html/php
23333 <p>X outer inner outer X
23334 </p>
23335 !! html/parsoid
23336 <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>
23337 !! end
23338
23339 !! test
23340 Templates inside raw output of variant escape tags (R flag)
23341 !! options
23342 language=zh variant=zh-tw
23343 !! wikitext
23344 Nested raw: -{R|nested {{echo|hi}} templates}-
23345 !! html/php
23346 <p>Nested raw: nested hi templates
23347 </p>
23348 !! html/parsoid
23349 <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>
23350 !! end
23351
23352 !! test
23353 Strings evaluating false shouldn't be ignored by Language converter (T51072)
23354 !! options
23355 language=zh variant=zh-cn
23356 !! wikitext
23357 -{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
23358 !! html/php
23359 <p>0
23360 </p>
23361 !! html/parsoid
23362 <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>
23363 !! end
23364
23365 !! test
23366 Conversion rules from [numeric-only string] to [something else] (T48634)
23367 !! options
23368 language=zh variant=zh-cn
23369 !! wikitext
23370 -{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
23371 !! html/php
23372 <p>D12345EE12345
23373 </p>
23374 !! html/parsoid
23375 <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>
23376 !! end
23377
23378 !! test
23379 Two-way converter rule entries with an empty value should be ignored (T53551)
23380 !! options
23381 language=zh variant=zh-cn
23382 !! wikitext
23383 -{H|zh-cn:foo;zh-tw:;}-foobar
23384 !! html/php
23385 <p>foobar
23386 </p>
23387 !! html/parsoid
23388 <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>
23389 !! end
23390
23391 !! test
23392 One-way converter rule entries with an empty "from" string should be ignored (T53551)
23393 !! options
23394 language=zh variant=zh-cn
23395 !! wikitext
23396 -{H|=>zh-cn:foo;}-foobar
23397 !! html/php
23398 <p>foobar
23399 </p>
23400 !! html/parsoid
23401 <p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[5]}' data-mw-variant='{"add":true,"oneway":[{"f":"","l":"zh-cn","t":"foo"}]}'/>foobar</p>
23402 !! end
23403
23404 !! test
23405 Empty converter rule entries shouldn't be inserted into the conversion table (T53551)
23406 !! options
23407 language=zh variant=zh-cn
23408 !! wikitext
23409 -{H|}-foobar
23410 !! html/php
23411 <p>foobar
23412 </p>
23413 !! html/parsoid
23414 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":""}]}'/>foobar</p>
23415 !! end
23416
23417 !! test
23418 Nested using of manual convert syntax
23419 !! options
23420 language=zh variant=zh-hk
23421 !! wikitext
23422 Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
23423 !! html/php
23424 <p>Nested: Hello Hong Kong!
23425 </p>
23426 !! html/parsoid
23427 <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>
23428 !! end
23429
23430 !! test
23431 HTML markups with conversion syntax in attribs, nested in other conversion blocks
23432 !! options
23433 language=zh variant=zh-cn
23434 !! wikitext
23435 -{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}-
23436 !! html/php
23437 <p><span title="X">A</span>
23438 </p>
23439 !! html/parsoid
23440 <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>
23441 !! end
23442
23443 !! test
23444 HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet in PHP parser)
23445 !! options
23446 language=zh variant=zh-cn
23447 !! wikitext
23448 -{<span title="-{X}-">A</span>}-
23449 !! html/php+disabled
23450 <p><span title="X">A</span>
23451 </p>
23452 !! html/parsoid
23453 <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>
23454 !! end
23455
23456 # Parsoid and PHP disagree on how to parse this example: Parsoid
23457 # insists that the content of a language converter element be a valid
23458 # DOM fragment or attribute string
23459 !! test
23460 Language converter markup with block content
23461 !! options
23462 language=zh variant=zh-cn
23463 !! wikitext
23464 <span>a-{b<div>c}-d
23465
23466 <span>a-{zh;zh-hans;zh-hant|b<div>c}-d
23467
23468 <span>a-{H|0=>zh-cn:x<span>y;0=>zh-tw:b<div>c}-d
23469 !! html/php+tidy
23470 <span>ab<div>cd
23471 <span>ab<div>cd
23472 <span>ad
23473 </span></div></span></div></span>
23474 !! html/parsoid
23475 <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
23476
23477 <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
23478
23479 <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>
23480 !! end
23481
23482 !! test
23483 LanguageConverter selser (1)
23484 !! options
23485 language=zh variant=zh-cn
23486 parsoid={
23487 "modes": ["wt2wt", "selser"],
23488 "changes": [
23489 ["span[typeof]", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
23490 ]
23491 }
23492 !! wikitext
23493 -{raw}-
23494 !! wikitext/edited
23495 -{edited}-
23496 !! end
23497
23498 !! test
23499 LanguageConverter selser (2)
23500 !! options
23501 language=zh variant=zh-cn
23502 parsoid={
23503 "modes": ["wt2wt", "selser"],
23504 "changes": [
23505 ["span[class='x']", "contents", "text", "-{foo}-"],
23506 ["a", "contents", "text", "-{"],
23507 ["span[typeof]", "attr", "data-mw", "{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"-{\"}},\"i\":0}}]}"]
23508 ]
23509 }
23510 !! wikitext
23511 <span class="x">TEXT1</span>
23512 [http://example.com TEXT2]
23513 [[Foo|TEXT3]]
23514 {{echo|TEXT4}}
23515 !! wikitext/edited
23516 <span class="x"><nowiki>-{foo}-</nowiki></span>
23517 [http://example.com -{]
23518 [[Foo|<nowiki>-{</nowiki>]]
23519 {{1x|<nowiki>-{</nowiki>}}
23520 !! end
23521
23522 # Tests LanguageVariantText in ConstrainedText
23523 !! test
23524 LanguageConverter selser (3)
23525 !! options
23526 language=zh variant=zh-cn
23527 parsoid={
23528 "modes": ["wt2wt", "selser"],
23529 "changes": [
23530 ["td > span", "attr", "typeof", "mw:LanguageVariant"],
23531 ["td > span", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
23532 ]
23533 }
23534 !! wikitext
23535 {|
23536 |-
23537 |<span>Foo</span>
23538 |}
23539 !! wikitext/edited
23540 {|
23541 |-
23542 |<nowiki/>-{edited}-
23543 |}
23544 !! end
23545
23546 # Tests LanguageVariantText._fromSelSer
23547 !! test
23548 LanguageConverter selser (4)
23549 !! options
23550 language=zh variant=zh-cn
23551 parsoid={
23552 "modes": ["wt2wt", "selser"],
23553 "changes": [
23554 ["td > span.x", "remove"]
23555 ]
23556 }
23557 !! wikitext
23558 {|
23559 |-
23560 |<span class="x">Foo</span>-{Bar}-
23561 ||<span class="x">Foo</span>-{Bar}-
23562 |}
23563 !! wikitext/edited
23564 {|
23565 |-
23566 |<nowiki/>-{Bar}-
23567 ||-{Bar}-
23568 |}
23569 !! end
23570
23571 # Since Parsoid is starting to emit canonical wikitext for links,
23572 # [http://example.com http://example.com] will not RT back to that
23573 # form anymore.
23574 # Parsoid does not language-convert links (it is done in a
23575 # post-processing step)
23576 !! test
23577 Proper conversion of text in external links
23578 !! options
23579 language=sr variant=sr-ec
23580 parsoid=wt2html
23581 !! wikitext
23582 http://www.google.com
23583 gopher://www.google.com
23584 [http://www.google.com http://www.google.com]
23585 [gopher://www.google.com gopher://www.google.com]
23586 [https://www.google.com irc://www.google.com]
23587 [ftp://www.google.com www.google.com/ftp://dir]
23588 [//www.google.com www.google.com]
23589 !! html/php
23590 <p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
23591 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
23592 <a rel="nofollow" class="external text" href="http://www.google.com">http://www.google.com</a>
23593 <a rel="nofollow" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
23594 <a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
23595 <a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
23596 <a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
23597 </p>
23598 !! html/parsoid
23599 <p><a rel="mw:ExtLink" class="external free" href="http://www.google.com">http://www.google.com</a>
23600 <a rel="mw:ExtLink" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
23601 <a rel="mw:ExtLink" class="external text" href="http://www.google.com">http://www.google.com</a>
23602 <a rel="mw:ExtLink" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
23603 <a rel="mw:ExtLink" class="external text" href="https://www.google.com">irc://www.google.com</a>
23604 <a rel="mw:ExtLink" class="external text" href="ftp://www.google.com">www.google.com/ftp://dir</a>
23605 <a rel="mw:ExtLink" class="external text" href="//www.google.com">www.google.com</a></p>
23606 !! end
23607
23608 !! test
23609 Do not convert roman numbers to language variants
23610 !! options
23611 language=sr variant=sr-ec
23612 !! wikitext
23613 Fridrih IV je car.
23614 !! html/php
23615 <p>Фридрих IV је цар.
23616 </p>
23617 !! html/parsoid
23618 <p>Fridrih IV je car.</p>
23619 !! end
23620
23621 !! test
23622 Unclosed language converter markup "-{"
23623 !! options
23624 language=sr
23625 !! wikitext
23626 -{T|hello
23627 !! html
23628 <p>-{T|hello
23629 </p>
23630 !! end
23631
23632 !! test
23633 Don't convert raw rule "-{R|=&gt;}-" to "=>"
23634 !! options
23635 language=sr
23636 !! wikitext
23637 -{R|=&gt;}-
23638 !! html/php
23639 <p>=&gt;
23640 </p>
23641 !! html/parsoid
23642 <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>
23643 !!end
23644
23645 !! test
23646 Don't break link parsing if language converter markup is in the caption.
23647 !! options
23648 language=sr variant=sr-ec
23649 !! wikitext
23650 [[Main Page|-{R|main page}-]]
23651 !! html/php
23652 <p><a href="/wiki/Main_Page" title="Маин Паге">main page</a>
23653 </p>
23654 !! html/parsoid
23655 <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>
23656 !! end
23657
23658 !! test
23659 T146304: Don't break template parsing if language converter markup is in the parameter.
23660 !! options
23661 language=sr variant=sr-ec
23662 !! wikitext
23663 {{echo|-{R|foo}-}}
23664 !! html/php
23665 <p>foo
23666 </p>
23667 !! html/parsoid
23668 <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>
23669 !! end
23670
23671 !! test
23672 T146305: Don't break image parsing if language converter markup is in the caption.
23673 !! options
23674 language=sr
23675 !! wikitext
23676 [[Датотека:Foobar.jpg|thumb|-{R|caption:}-]]
23677 !! html/php
23678 <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>
23679
23680 !! html/parsoid
23681 <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>
23682 !! end
23683
23684 !! test
23685 T146305: Don't break image parsing if nested language converter markup is in the caption.
23686 !! options
23687 language=zh variant=zh-cn
23688 !! wikitext
23689 [[File:Foobar.jpg|thumb|-{|zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
23690 !! html/php
23691 <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>
23692
23693 !! html/parsoid
23694 <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>
23695 !! end
23696
23697 # XXX html2wt disabled because rich markup in alt is not preserved.
23698 !! test
23699 Don't break gallery if language converter markup is inside.
23700 !! options
23701 language=zh
23702 !! wikitext
23703 <gallery>
23704 File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-
23705 File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt
23706 </gallery>
23707 !! html/php
23708 <ul class="gallery mw-gallery-traditional">
23709 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
23710 <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>
23711 <div class="gallerytext">
23712 <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>
23713 </p>
23714 </div>
23715 </div></li>
23716 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
23717 <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>
23718 <div class="gallerytext">
23719 <p>This is a test template
23720 </p>
23721 </div>
23722 </div></li>
23723 </ul>
23724
23725 !! html/parsoid
23726 <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"}}'>
23727 <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>
23728 <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>
23729 </ul>
23730 !! end
23731
23732 !! test
23733 T153135: Don't break list handling if language converter markup is in the item.
23734 !! options
23735 language=zh variant=zh-cn
23736 !! wikitext
23737 ;-{zh-cn:AAA;zh-tw:BBB}-
23738 ;-{R|foo:bar}-
23739 !! html/php
23740 <dl><dt>AAA</dt>
23741 <dt>foo:bar</dt></dl>
23742
23743 !! html/parsoid
23744 <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>
23745 <dt data-parsoid='{"dsr":[25,39,1,0]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"foo:bar"}}'></span></dt>
23746 </dl>
23747 !! end
23748
23749 // Note that parsoid does not protect colons unless language converter
23750 // markup is properly nested, because it is a backtracking parser.
23751 !! test
23752 T153135: Unclosed markup in definition list (code coverage)
23753 !! options
23754 language=zh variant=zh-cn
23755 !! wikitext
23756 ;<b>foo:bar
23757 ;-{zh-cn:AAA
23758 !! html/php+tidy
23759 <dl><dt><b>foo:bar</b></dt><b>
23760 <dt>-{zh-cn:AAA</dt></b></dl><p><b>
23761 </b></p>
23762 !! html/parsoid
23763 <dl><dt data-parsoid='{}'><b data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo:bar</b></dt><b data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
23764 <dt data-parsoid='{}'>-{zh-cn</dt><dd data-parsoid='{"stx":"row"}'>AAA</dd></b></dl>
23765 !! end
23766
23767 !! test
23768 T153135: Nested language converter markup in definition list (code coverage)
23769 !! options
23770 language=zh variant=zh-cn
23771 !! wikitext
23772 ;-{|zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
23773 !! html/php
23774 <dl><dt>AAA foo:bar bat:baz</dt>
23775 <dd>def</dd></dl>
23776
23777 !! html/parsoid
23778 <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>
23779 <dd data-parsoid='{"stx":"row","dsr":[49,53,1,0]}'>def</dd>
23780 </dl>
23781 !! end
23782
23783 # html2wt mode disabled due to <nowiki> insertion.
23784 !! test
23785 T153140: Don't break table handling if language converter markup is in the cell.
23786 !! options
23787 language=sr variant=sr-ec
23788 parsoid=wt2html,wt2wt,html2html
23789 !! wikitext
23790 {|
23791 |-
23792 | -{R|B}-
23793 |}
23794 !! html/php
23795 <table>
23796
23797 <tr>
23798 <td>B
23799 </td></tr></table>
23800
23801 !! html/parsoid
23802 <table>
23803 <tbody>
23804 <tr>
23805 <td><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"B"}}'></span></td>
23806 </tr>
23807 </tbody>
23808 </table>
23809 !! end
23810
23811 !! test
23812 Language converter tricky html2wt cases (1)
23813 !! options
23814 language=sr
23815 parsoid=html2wt,wt2wt
23816 !! html/parsoid
23817 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"}-"}}'></span></p>
23818 !! wikitext
23819 -{<nowiki>}-</nowiki>}-
23820 !! html/php
23821 <p>&#125;-
23822 </p>
23823 !! end
23824
23825 !! test
23826 Language converter tricky html2wt cases (2)
23827 !! options
23828 language=sr
23829 parsoid=html2wt,wt2wt
23830 !! html/parsoid
23831 <p>-{foo}-</p>
23832 !! wikitext
23833 <nowiki>-{foo}-</nowiki>
23834 !! html/php
23835 <p>-&#123;foo&#125;-
23836 </p>
23837 !! end
23838
23839 !! test
23840 Language converter tricky html2wt cases (3)
23841 !! options
23842 language=sr
23843 parsoid=html2wt,wt2wt
23844 !! html/parsoid
23845 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"|"}}'></span></p>
23846 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"R|raw"}}'></span></p>
23847 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"-{foo}-"}}'></span></p>
23848 !! wikitext
23849 -{R||}-
23850
23851 -{R|R|raw}-
23852
23853 -{<nowiki>-{foo}-</nowiki>}-
23854 !! html/php
23855 <p>|
23856 </p><p>R|raw
23857 </p><p>-&#123;foo&#125;-
23858 </p>
23859 !! end
23860
23861 !! test
23862 Language converter tricky html2wt cases (4)
23863 !! options
23864 language=sr
23865 parsoid=html2wt,wt2wt
23866 !! html/parsoid
23867 <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>
23868 !! wikitext
23869 -{R|{{echo|hey}}}-
23870 !! html/php
23871 <p>hey
23872 </p>
23873 !! end
23874
23875 # Note that the <nowiki> escaping added by parsoid for source text,
23876 # destination text, and language names only works on the PHP side
23877 # for *destination text*. (HTML entity escaping wouldn't work
23878 # any better.) This is probably a bug, at least for source texts.
23879 # (For language names PHP uses a precise regexp based on the languages
23880 # it currently knows have variants, which is fragile since this set
23881 # can grow/shrink over time.)
23882 !! test
23883 Language converter tricky html2wt cases (5)
23884 !! options
23885 language=zh variant=zh-cn
23886 !! html/parsoid
23887 <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>
23888 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"A","l":"bo:g;us","t":"B"}]}'/></p>
23889 <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>
23890 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"bo:g;us","t":"xyz"},{"l":"zh-cn","t":"abc"}]}'></span></p>
23891 <p>a:b=>c xyz</p>
23892 !! wikitext
23893 -{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
23894
23895 -{H|A=><nowiki>bo:g;us</nowiki>:B}-
23896
23897 -{A|zh-tw:xyz; zh-cn:<nowiki>0;zh-tw:bar</nowiki>}-
23898
23899 -{<nowiki>bo:g;us</nowiki>:xyz; zh-cn:abc}-
23900
23901 a:b=>c xyz
23902 !! html/php+disabled
23903 <p>foobat;xyz=&gt;zh-cn:abc
23904 </p><p>A
23905 </p><p>0;zh-tw:bar
23906 </p><p>abc
23907 </p><p>a:b=&gt;c 0;zh-tw:bar
23908 </p>
23909 !! end
23910
23911 !! test
23912 T179579: Nowiki and lc interaction
23913 !! options
23914 parsoid=wt2html
23915 language=sr
23916 !! wikitext
23917 -{</nowiki>123}-
23918
23919 -{123<nowiki>|</nowiki>456}-
23920 !! html/parsoid
23921 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&amp;lt;/nowiki>123"}}' data-parsoid='{"fl":[],"src":"-{&lt;/nowiki>123}-"}'></span></p>
23922
23923 <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>
23924 !! end
23925
23926 !! test
23927 T2529: Uncovered bullet
23928 !! wikitext
23929 *Foo {{bullet}}
23930 !! html
23931 <ul><li>Foo</li>
23932 <li>Bar</li></ul>
23933
23934 !! end
23935
23936 !! test
23937 T2529: Uncovered bullet in a deeply nested list
23938 !! wikitext
23939 *******Foo {{bullet}}
23940 !! html
23941 <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>
23942 <li>Bar</li></ul>
23943
23944 !! end
23945
23946 !! test
23947 T2529: Uncovered table already at line-start
23948 !! wikitext
23949 x
23950
23951 {{table}}
23952 y
23953 !! html
23954 <p>x
23955 </p>
23956 <table>
23957 <tr>
23958 <td>1</td>
23959 <td>2
23960 </td></tr>
23961 <tr>
23962 <td>3</td>
23963 <td>4
23964 </td></tr></table>
23965 <p>y
23966 </p>
23967 !! end
23968
23969 !! test
23970 T2529: Uncovered bullet in parser function result
23971 !! wikitext
23972 *Foo {{lc:{{bullet}} }}
23973 !! html
23974 <ul><li>Foo</li>
23975 <li>bar</li></ul>
23976
23977 !! end
23978
23979 !! test
23980 T7678: Double-parsed template argument
23981 !! wikitext
23982 {{lc:{{{1}}}|hello}}
23983 !! html
23984 <p>{{{1}}}
23985 </p>
23986 !! end
23987
23988 !! test
23989 T7678: Double-parsed template invocation
23990 !! wikitext
23991 {{lc:{{paramtest {{!}} param = hello }} }}
23992 !! html
23993 <p>{{paramtest | param = hello }}
23994 </p>
23995 !! end
23996
23997 !! test
23998 Case insensitivity of parser functions for non-ASCII characters (T10143)
23999 !! options
24000 language=cs
24001 title=[[Main Page]]
24002 !! wikitext
24003 {{PRVNÍVELKÉ:ěščř}}
24004 {{prvnívelké:ěščř}}
24005 {{PRVNÍMALÉ:ěščř}}
24006 {{prvnímalé:ěščř}}
24007 {{MALÁ:ěščř}}
24008 {{malá:ěščř}}
24009 {{VELKÁ:ěščř}}
24010 {{velká:ěščř}}
24011 !! html
24012 <p>Ěščř
24013 Ěščř
24014 ěščř
24015 ěščř
24016 ěščř
24017 ěščř
24018 ĚŠČŘ
24019 ĚŠČŘ
24020 </p>
24021 !! end
24022
24023 !! test
24024 Morwen/13: Unclosed link followed by heading
24025 !! wikitext
24026 [[link
24027 ==heading==
24028 !! html
24029 <p>[[link
24030 </p>
24031 <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>
24032
24033 !! end
24034
24035 !! test
24036 HHP2.1: Heuristics for headings in preprocessor parenthetical structures
24037 !! wikitext
24038 {{foo|
24039 =heading=
24040 !! html
24041 <p>{{foo|
24042 </p>
24043 <h1><span class="mw-headline" id="heading">heading</span></h1>
24044
24045 !! end
24046
24047 !! test
24048 HHP2.2: Heuristics for headings in preprocessor parenthetical structures
24049 !! wikitext
24050 {{foo|
24051 ==heading==
24052 !! html
24053 <p>{{foo|
24054 </p>
24055 <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>
24056
24057 !! end
24058
24059 !! test
24060 Tildes in comments
24061 !! options
24062 pst
24063 !! wikitext
24064 <!-- ~~~~ -->
24065 !! html/php
24066 <!-- ~~~~ -->
24067 !! end
24068
24069 !! test
24070 Paragraphs inside divs (no extra line breaks)
24071 !! wikitext
24072 <div>Line one
24073
24074 Line two</div>
24075 !! html
24076 <div>Line one
24077 Line two</div>
24078
24079 !! end
24080
24081 !! test
24082 Paragraphs inside divs (extra line break on open)
24083 !! wikitext
24084 <div>
24085 Line one
24086
24087 Line two</div>
24088 !! html
24089 <div>
24090 <p>Line one
24091 </p>
24092 Line two</div>
24093
24094 !! end
24095
24096 !! test
24097 Paragraphs inside divs (extra line break on close)
24098 !! wikitext
24099 <div>Line one
24100
24101 Line two
24102 </div>
24103 !! html
24104 <div>Line one
24105 <p>Line two
24106 </p>
24107 </div>
24108
24109 !! end
24110
24111 !! test
24112 Paragraphs inside divs (extra line break on open and close)
24113 !! wikitext
24114 <div>
24115 Line one
24116
24117 Line two
24118 </div>
24119 !! html
24120 <div>
24121 <p>Line one
24122 </p><p>Line two
24123 </p>
24124 </div>
24125
24126 !! end
24127
24128 # doBlockLevels screws up this output and Remex cleans up as much as it can.
24129 !! test
24130 Nesting tags, paragraphs on lines which begin with <div>
24131 !! wikitext
24132 <div></div><strong>A
24133 B</strong>
24134 !! html/php+tidy
24135 <div></div><p><strong>A
24136 </strong></p><strong></strong><p><strong>B</strong>
24137 </p>
24138 !! html/parsoid
24139 <div data-parsoid='{"stx":"html"}'></div><p><strong data-parsoid='{"stx":"html","autoInsertedEnd":true}'>A</strong></p>
24140 <p><strong data-parsoid='{"stx":"html","autoInsertedStart":true}'>B</strong></p>
24141 !! end
24142
24143 # T8200: <blockquote> should behave like <div> with respect to line breaks
24144 !! test
24145 T8200: paragraphs inside blockquotes (no extra line breaks)
24146 !! wikitext
24147 <blockquote>Line one
24148
24149 Line two</blockquote>
24150 !! html
24151 <blockquote>Line one
24152 Line two</blockquote>
24153
24154 !! html+tidy
24155 <blockquote><p>Line one
24156 Line two</p></blockquote>
24157 !! end
24158
24159 !! test
24160 T8200: paragraphs inside blockquotes (extra line break on open)
24161 !! wikitext
24162 <blockquote>
24163 Line one
24164
24165 Line two</blockquote>
24166 !! html
24167 <blockquote>
24168 <p>Line one
24169 </p>
24170 Line two</blockquote>
24171
24172 !! html+tidy
24173 <blockquote>
24174 <p>Line one
24175 </p><p>
24176 Line two</p></blockquote>
24177 !! end
24178
24179 !! test
24180 T8200: paragraphs inside blockquotes (extra line break on close)
24181 !! wikitext
24182 <blockquote>Line one
24183
24184 Line two
24185 </blockquote>
24186 !! html
24187 <blockquote>Line one
24188 <p>Line two
24189 </p>
24190 </blockquote>
24191
24192 !! html+tidy
24193 <blockquote><p>Line one
24194 </p><p>Line two
24195 </p>
24196 </blockquote>
24197 !! end
24198
24199 !! test
24200 T8200: paragraphs inside blockquotes (extra line break on open and close)
24201 !! wikitext
24202 <blockquote>
24203 Line one
24204
24205 Line two
24206 </blockquote>
24207 !! html
24208 <blockquote>
24209 <p>Line one
24210 </p><p>Line two
24211 </p>
24212 </blockquote>
24213
24214 !! end
24215
24216 ## This is a corner case interaction between the paragraph wrapping in the
24217 ## php parser's BlockLevelPass and Remex. `doBlockLevels` has a notion of
24218 ## some tags which close paragraphs (and thus prevent wrapping on their line),
24219 ## of which "div" is one, but do p-wrapping inside them. These are referred
24220 ## to as "never suppressing". Remex, for its part, doesn't traverse into
24221 ## "div"s to p-wrap. Hence, we only get this partial wrapping.
24222 !! test
24223 Paragraphs inside blockquotes/divs (no extra line breaks)
24224 !! wikitext
24225 <blockquote><div>Line one
24226
24227 Line two</div></blockquote>
24228 !! html
24229 <blockquote><div>Line one
24230 Line two</div></blockquote>
24231
24232 !! end
24233
24234 !! test
24235 Paragraphs inside blockquotes/divs (extra line break on open)
24236 !! wikitext
24237 <blockquote><div>
24238 Line one
24239
24240 Line two</div></blockquote>
24241 !! html
24242 <blockquote><div>
24243 <p>Line one
24244 </p>
24245 Line two</div></blockquote>
24246
24247 !! end
24248
24249 !! test
24250 Paragraphs inside blockquotes/divs (extra line break on close)
24251 !! wikitext
24252 <blockquote><div>Line one
24253
24254 Line two
24255 </div></blockquote>
24256 !! html
24257 <blockquote><div>Line one
24258 <p>Line two
24259 </p>
24260 </div></blockquote>
24261
24262 !! end
24263
24264 !! test
24265 Paragraphs inside blockquotes/divs (extra line break on open and close)
24266 !! wikitext
24267 <blockquote><div>
24268 Line one
24269
24270 Line two
24271 </div></blockquote>
24272 !! html
24273 <blockquote><div>
24274 <p>Line one
24275 </p><p>Line two
24276 </p>
24277 </div></blockquote>
24278
24279 !! end
24280
24281 !! test
24282 Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion
24283 !! options
24284 wgLinkHolderBatchSize=0
24285 !! wikitext
24286 [[meatball:1]]
24287 [[meatball:2]]
24288 [[meatball:3]]
24289 !! html
24290 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?1" class="extiw" title="meatball:1">meatball:1</a>
24291 <a href="http://www.usemod.com/cgi-bin/mb.pl?2" class="extiw" title="meatball:2">meatball:2</a>
24292 <a href="http://www.usemod.com/cgi-bin/mb.pl?3" class="extiw" title="meatball:3">meatball:3</a>
24293 </p>
24294 !! end
24295
24296 !! test
24297 Free external link invading image caption
24298 !! wikitext
24299 [[Image:Foobar.jpg|thumb|http://x|hello]]
24300 !! html/php
24301 <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>
24302
24303 !! html/parsoid
24304 <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>
24305 !! end
24306
24307 !! test
24308 T17196: localised external link numbers
24309 !! options
24310 language=fa
24311 !! wikitext
24312 [http://en.wikipedia.org/]
24313 !! html/php
24314 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/">[۱]</a>
24315 </p>
24316 !! html/parsoid
24317 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/"></a></p>
24318 !! end
24319
24320 !! test
24321 Multibyte character in padleft
24322 !! wikitext
24323 {{padleft:-Hello|7|Æ}}
24324 !! html/php
24325 <p>Æ-Hello
24326 </p>
24327 !! html/parsoid
24328 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:-Hello","function":"padleft"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Æ-Hello</p>
24329 !! end
24330
24331 !! test
24332 Multibyte character in padright
24333 !! wikitext
24334 {{padright:Hello-|7|Æ}}
24335 !! html/php
24336 <p>Hello-Æ
24337 </p>
24338 !! html/parsoid
24339 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:Hello-","function":"padright"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Hello-Æ</p>
24340 !! end
24341
24342 !!test
24343 formatdate parser function
24344 !! wikitext
24345 {{#formatdate:2009-03-24}}
24346 !! html
24347 <p><span class="mw-formatted-date" title="2009-03-24">2009-03-24</span>
24348 </p>
24349 !! end
24350
24351 !!test
24352 formatdate parser function, with default format
24353 !! wikitext
24354 {{#formatdate:2009-03-24|mdy}}
24355 !! html
24356 <p><span class="mw-formatted-date" title="2009-03-24">March 24, 2009</span>
24357 </p>
24358 !! end
24359
24360 !! test
24361 Spacing of numbers in formatted dates
24362 !! wikitext
24363 {{#formatdate:January 15}}
24364 !! html
24365 <p><span class="mw-formatted-date" title="01-15">January 15</span>
24366 </p>
24367 !! end
24368
24369 !! test
24370 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
24371 !! options
24372 language=nl title=[[MediaWiki:Common.css]]
24373 !! wikitext
24374 {{#formatdate:2009-03-24|dmy}}
24375 !! html
24376 <p><span class="mw-formatted-date" title="2009-03-24">24 March 2009</span>
24377 </p>
24378 !! end
24379
24380 #
24381 #
24382 #
24383
24384 #
24385 # Edit comments
24386 #
24387
24388 !! test
24389 Edit comment with link
24390 !! options
24391 comment
24392 !! wikitext
24393 I like the [[Main Page]] a lot
24394 !! html/php
24395 I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot
24396 !!end
24397
24398 !! test
24399 Edit comment with link and link text
24400 !! options
24401 comment
24402 !! wikitext
24403 I like the [[Main Page|best pages]] a lot
24404 !! html/php
24405 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
24406 !!end
24407
24408 !! test
24409 Edit comment with link and link text with suffix
24410 !! options
24411 comment
24412 !! wikitext
24413 I like the [[Main Page|best page]]s a lot
24414 !! html/php
24415 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
24416 !!end
24417
24418 !! test
24419 Edit comment with section link (non-local, eg in history list)
24420 !! options
24421 comment title=[[Main Page]]
24422 !! wikitext
24423 /* External links */ removed bogus entries
24424 !! html/php
24425 <a href="/wiki/Main_Page#External_links" title="Main Page">→External links</a>‎<span dir="auto"><span class="autocomment">: </span> removed bogus entries</span>
24426 !!end
24427
24428 !! test
24429 Edit comment with section link and text before it (non-local, eg in history list)
24430 !! options
24431 comment title=[[Main Page]]
24432 !! wikitext
24433 pre-comment text /* External links */ removed bogus entries
24434 !! html/php
24435 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>
24436 !!end
24437
24438 !! test
24439 Edit comment with section link (local, eg in diff view)
24440 !! options
24441 comment local title=[[Main Page]]
24442 !! wikitext
24443 /* External links */ removed bogus entries
24444 !! html/php
24445 <a href="#External_links">→External links</a>‎<span dir="auto"><span class="autocomment">: </span> removed bogus entries</span>
24446 !!end
24447
24448 !! test
24449 Edit comment with subpage link (T16080)
24450 !! options
24451 comment
24452 subpage
24453 title=[[Subpage test]]
24454 !! wikitext
24455 Poked at a [[/subpage]] here...
24456 !! html/php
24457 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> here...
24458 !!end
24459
24460 !! test
24461 Edit comment with subpage link and link text (T16080)
24462 !! options
24463 comment
24464 subpage
24465 title=[[Subpage test]]
24466 !! wikitext
24467 Poked at a [[/subpage|neat little page]] here...
24468 !! html/php
24469 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">neat little page</a> here...
24470 !!end
24471
24472 !! test
24473 Edit comment with bogus subpage link in non-subpage NS (T16080)
24474 !! options
24475 comment
24476 title=[[Subpage test]]
24477 !! wikitext
24478 Poked at a [[/subpage]] here...
24479 !! html/php
24480 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...
24481 !!end
24482
24483 !! test
24484 Edit comment with bare anchor link (local, as on diff)
24485 !! options
24486 comment
24487 local
24488 title=[[Main Page]]
24489 !! wikitext
24490 [[#section]]
24491 !! html/php
24492 <a href="#section">#section</a>
24493 !! end
24494
24495 !! test
24496 Edit comment with bare anchor link (non-local, as on history)
24497 !! options
24498 comment
24499 title=[[Main Page]]
24500 !! wikitext
24501 [[#section]]
24502 !! html/php
24503 <a href="/wiki/Main_Page#section" title="Main Page">#section</a>
24504 !! end
24505
24506 !! test
24507 Anchor starting with underscore
24508 !! options
24509 title=[[Foo]]
24510 !! wikitext
24511 [[#_ref|One]]
24512 !! html/php
24513 <p><a href="#_ref">One</a>
24514 </p>
24515 !! html/parsoid
24516 <p><a rel="mw:WikiLink" href="./Foo#_ref" data-parsoid='{"stx":"piped","a":{"href":"./Foo#_ref"},"sa":{"href":"#_ref"}}'>One</a></p>
24517 !! end
24518
24519 !! test
24520 Id starting with underscore
24521 !! wikitext
24522 <div id="_ref"></div>
24523 !! html/*
24524 <div id="_ref"></div>
24525
24526 !! end
24527
24528 !! test
24529 Edit comment with link with more than one pipe (T99346)
24530 !! options
24531 comment
24532 !! wikitext
24533 [[Main Page|Many|pipes]]
24534 !! html/php
24535 <a href="/wiki/Main_Page" title="Main Page">Many|pipes</a>
24536 !! end
24537
24538 !! test
24539 Complex edit comment with link with more than one pipe (T99346)
24540 !! options
24541 comment
24542 !! wikitext
24543 Created page with "<noinclude>[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]]</noinclude> === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..."
24544 !! html/php
24545 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;
24546 !! end
24547
24548 !! test
24549 Space normalisation on autocomment (T24784)
24550 !! options
24551 comment
24552 title=[[Main Page]]
24553 !! wikitext
24554 /* __hello__world__ */
24555 !! html/php
24556 <a href="/wiki/Main_Page#hello_world" title="Main Page">→__hello__world__</a>‎
24557 !! end
24558
24559 !! test
24560 percent-encoding and + signs in comments (T28410)
24561 !! options
24562 comment
24563 !! wikitext
24564 [[ABC%33D% ++]] [[ABC%33D% ++|+%20]]
24565 !! html/php
24566 <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>
24567 !! end
24568
24569 # Parsoid doesn't support this yet: see T75581
24570 # but it *should* omit the 'src' attribute if the image is bad.
24571 # PHP side of tests was disabled in
24572 # mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
24573 # because of issues in the PHP parserTests infrastructure
24574 # (but the output below is indeed what the PHP side emits)
24575 !! test
24576 Bad images - basic functionality
24577 !! wikitext
24578 [[File:Bad.jpg]]
24579 !! html/php+disabled
24580 !! html/parsoid
24581 <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>
24582 !! end
24583
24584 !! test
24585 Bad images - T18039: text after bad image disappears
24586 !! wikitext
24587 Foo bar
24588 [[File:Bad.jpg]]
24589 Bar foo
24590 !! html/php+disabled
24591 <p>Foo bar
24592 </p><p>Bar foo
24593 </p>
24594 !! html/parsoid
24595 <p>Foo bar
24596 <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>
24597 Bar foo</p>
24598 !! end
24599
24600 !! test
24601 Verify that displaytitle works (T24501) no displaytitle
24602 !! options
24603 showtitle
24604 !! config
24605 wgAllowDisplayTitle=true
24606 wgRestrictDisplayTitle=false
24607 !! wikitext
24608 this is not the the title
24609 !! html/php
24610 Parser test
24611 <p>this is not the the title
24612 </p>
24613 !! end
24614
24615 !! test
24616 Verify that displaytitle works (T24501) RestrictDisplayTitle=false
24617 !! options
24618 showtitle
24619 title=[[Screen]]
24620 !! config
24621 wgAllowDisplayTitle=true
24622 wgRestrictDisplayTitle=false
24623 !! wikitext
24624 this is not the the title
24625 {{DISPLAYTITLE:whatever}}
24626 !! html/php
24627 whatever
24628 <p>this is not the the title
24629 </p>
24630 !! end
24631
24632 !! test
24633 Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch
24634 !! options
24635 showtitle
24636 title=[[Screen]]
24637 !! config
24638 wgAllowDisplayTitle=true
24639 wgRestrictDisplayTitle=true
24640 !! wikitext
24641 this is not the the title
24642 {{DISPLAYTITLE:whatever}}
24643 !! html/php
24644 Screen
24645 <p>this is not the the title
24646 </p>
24647 !! end
24648
24649 !! test
24650 Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching
24651 !! options
24652 showtitle
24653 title=[[Screen]]
24654 !! config
24655 wgAllowDisplayTitle=true
24656 wgRestrictDisplayTitle=true
24657 !! wikitext
24658 this is not the the title
24659 {{DISPLAYTITLE:screen}}
24660 !! html/php
24661 screen
24662 <p>this is not the the title
24663 </p>
24664 !! end
24665
24666 !! test
24667 Verify that displaytitle works (T24501) AllowDisplayTitle=false
24668 !! options
24669 showtitle
24670 title=[[Screen]]
24671 !! config
24672 wgAllowDisplayTitle=false
24673 !! wikitext
24674 this is not the the title
24675 {{DISPLAYTITLE:screen}}
24676 !! html/php
24677 Screen
24678 <p>this is not the the title
24679 <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>
24680 </p>
24681 !! end
24682
24683 !! test
24684 Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE
24685 !! options
24686 showtitle
24687 title=[[Screen]]
24688 !! config
24689 wgAllowDisplayTitle=false
24690 !! wikitext
24691 this is not the the title
24692 !! html/php
24693 Screen
24694 <p>this is not the the title
24695 </p>
24696 !! end
24697
24698 !! test
24699 Verify that displaytitle handles inline CSS styles (T28547) - rejected value
24700 !! options
24701 showtitle
24702 title=[[Screen]]
24703 !! config
24704 wgAllowDisplayTitle=true
24705 wgRestrictDisplayTitle=true
24706 !! wikitext
24707 this is not the the title
24708 {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
24709 !! html/php
24710 <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
24711 <p>this is not the the title
24712 </p>
24713 !! end
24714
24715 !! test
24716 Verify that displaytitle handles inline CSS styles (T28547) - accepted value
24717 !! options
24718 showtitle
24719 title=[[Screen]]
24720 !! config
24721 wgAllowDisplayTitle=true
24722 wgRestrictDisplayTitle=true
24723 !! wikitext
24724 this is not the the title
24725 {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
24726 !! html/php
24727 <span style="color: red;">s</span>creen
24728 <p>this is not the the title
24729 </p>
24730 !! end
24731
24732 !! test
24733 Page status indicators: Empty name is invalid
24734 !! options
24735 showindicators
24736 !! wikitext
24737 <indicator name=" "></indicator>
24738 <indicator></indicator>
24739 !! html/php
24740 <p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
24741 <span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
24742 </p>
24743 !! end
24744
24745 !! test
24746 Page status indicators: Weird syntaxes that are okay
24747 !! options
24748 showindicators
24749 !! wikitext
24750 <indicator name="empty" />
24751 <indicator name="name"></indicator>
24752 !! html/php
24753 empty=
24754 name=
24755 <p><br />
24756 </p>
24757 !! end
24758
24759 !! test
24760 Page status indicators: Torture test
24761 !! options
24762 showindicators
24763 !! wikitext
24764 <indicator name="01">hello world</indicator>
24765 <indicator name="02">[[Main Page]]</indicator>
24766 <indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator>
24767 <indicator name="04">[[File:Foobar.jpg|25px]]</indicator>
24768 <indicator name="05">*foo
24769 *bar</indicator>
24770 <indicator name="06"><nowiki>foo</nowiki></indicator>
24771 <indicator name="07"> Preformatted</indicator>
24772 <indicator name="08"><div>Broken tag</indicator>
24773 <indicator name="09">{| class=wikitable
24774 |cell
24775 |}</indicator>
24776 <indicator name="10">Two
24777
24778 paragraphs</indicator>
24779 !! html/php
24780 01=hello world
24781 02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
24782 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" />
24783 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>
24784 05=<ul><li>foo</li>
24785 <li>bar</li></ul>
24786
24787 06=foo
24788 07=<pre>Preformatted
24789 </pre>
24790 08=<div>Broken tag</div>
24791
24792 09=<table class="wikitable">
24793 <tr>
24794 <td>cell
24795 </td></tr></table>
24796
24797 10=<p>Two
24798 </p><p>paragraphs
24799 </p>
24800 <p><br />
24801 </p><p><br />
24802 </p><p><br />
24803 </p><p><br />
24804 </p><p><br />
24805 </p>
24806 !! end
24807
24808 !! test
24809 preload: check <noinclude> and <includeonly>
24810 !! options
24811 preload
24812 !! wikitext
24813 Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
24814 !! html/php
24815 Hello kind world.
24816 !! end
24817
24818 !! test
24819 preload: check <onlyinclude>
24820 !! options
24821 preload
24822 !! wikitext
24823 Goodbye <onlyinclude>Hello world</onlyinclude>
24824 !! html/php
24825 Hello world
24826 !! end
24827
24828 !! test
24829 preload: can pass tags through if we want to
24830 !! options
24831 preload
24832 !! wikitext
24833 <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
24834 !! html/php
24835 <includeonly>Hello world</includeonly>
24836 !! end
24837
24838 !! test
24839 preload: check that it doesn't try to do tricks
24840 !! options
24841 preload
24842 !! wikitext
24843 * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
24844 !! html/php
24845 * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
24846 !! end
24847
24848 !! test
24849 Play a bit with r67090 and T5158
24850 !! wikitext
24851 <div style="width:50% !important">&nbsp;</div>
24852 <div style="width:50%&nbsp;!important">&nbsp;</div>
24853 <div style="width:50%&#160;!important">&nbsp;</div>
24854 <div style="border : solid;">&nbsp;</div>
24855 !! html/php
24856 <div style="width:50% !important">&#160;</div>
24857 <div style="width:50% !important">&#160;</div>
24858 <div style="width:50% !important">&#160;</div>
24859 <div style="border&#32;: solid;">&#160;</div>
24860
24861 !! html/parsoid
24862 <div style="width:50% !important" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
24863 <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>
24864 <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>
24865 <div style="border : solid;" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
24866
24867 !! end
24868
24869 !! test
24870 French spaces in wikitext
24871 !! wikitext
24872 foo ! bar ? bat 50 % is less than 75 %.
24873
24874 Hello : this ; is « something ‹ else › again »
24875 !! html
24876 <p>foo&#160;! bar&#160;? bat 50&#160;% is less than 75&#160;%.
24877 </p><p>Hello&#160;: this&#160;; is «&#160;something ‹&#160;else&#160;› again&#160;»
24878 </p>
24879 !! end
24880
24881 # It would be reasonable for Parsoid and PHP to differ here.
24882 # The PHP behavior is arguably a bug.
24883 !! test
24884 Corner case: french spaces in definition list
24885 !! wikitext
24886 ;foo : bar
24887 !! html+tidy
24888 <dl><dt>foo&#160;</dt>
24889 <dd>bar</dd></dl>
24890 !! end
24891
24892 !! test
24893 T5158: Test for French spaces in attributes
24894 !! wikitext
24895 <br style=" clear : both ; " />
24896 !! html/php
24897 <p><br style="clear&#32;: both&#32;;" />
24898 </p>
24899 !! end
24900
24901 !! test
24902 HTML5 data attributes
24903 !! wikitext
24904 <span data-foo="bar">Baz</span>
24905 <p data-abc-def_hij="">Quuz</p>
24906 !! html/php
24907 <p><span data-foo="bar">Baz</span>
24908 </p>
24909 <p data-abc-def_hij="">Quuz</p>
24910
24911 !! html/parsoid
24912 <p><span data-foo="bar" data-parsoid='{"stx":"html"}'>Baz</span></p>
24913 <p data-abc-def_hij="" data-parsoid='{"stx":"html"}'>Quuz</p>
24914 !! end
24915
24916 !! test
24917 Strip reserved data attributes
24918 !! wikitext
24919 <div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
24920 !! html/php
24921 <div data-ok="fred">d</div>
24922
24923 !! html/parsoid
24924 <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>
24925 !! end
24926
24927 !! test
24928 percent-encoding and + signs in internal links (T28410)
24929 !! wikitext
24930 [[User:+%]] [[Page+title%]]
24931 [[%+]] [[%+|%20]] [[%+ ]] [[%+r]]
24932 [[%]] [[+]] [[File:%+abc%39|foo|[[bar]]]]
24933 [[%33%45]] [[%33%45+]]
24934 !! html/php
24935 <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>
24936 <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>
24937 <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>
24938 <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>
24939 </p>
24940 !! html/parsoid
24941 <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>
24942 <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>
24943 <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>
24944 <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>
24945 !! end
24946
24947 !! test
24948 Special characters in embedded file links (T29679)
24949 !! wikitext
24950 [[File:Contains & ampersand.jpg]]
24951 [[File:Does not exist.jpg|Title with & ampersand]]
24952 !! html/php
24953 <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>
24954 <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>
24955 </p>
24956 !! html/parsoid
24957 <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>
24958 <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>
24959 !! end
24960
24961 !! test
24962 Confirm that 'apos' named character reference doesn't make it to output (not legal in HTML 4)
24963 !! wikitext
24964 Text&apos;s been normalized?
24965 !! html
24966 <p>Text&#39;s been normalized?
24967 </p>
24968 !! end
24969
24970 !! test
24971 T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
24972 !! wikitext
24973 http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
24974 !! html
24975 <p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> &lt;-- U+3000 (vim: ^Vu3000)
24976 </p>
24977 !! end
24978
24979 !! test
24980 T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
24981 !! wikitext
24982 [http://www.example.org/ ideograms]
24983 !! html
24984 <p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a>
24985 </p>
24986 !! end
24987
24988 !! test
24989 T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
24990 !! wikitext
24991 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
24992 !! html
24993 <p><img src="http://www.example.org/pic.png" alt="pic.png"/> &lt;-- U+3000 (vim: ^Vu3000)
24994 </p>
24995 !! end
24996
24997 !! article
24998 Mediawiki:loop1
24999 !! text
25000 {{Identical|A}}
25001 !! endarticle
25002
25003 !! article
25004 Mediawiki:loop2
25005 !! text
25006 {{Identical|B}}
25007 !! endarticle
25008
25009 !! article
25010 Template:Identical
25011 !! text
25012 {{int:loop1}}
25013 {{int:loop2}}
25014 !! endarticle
25015
25016 !! test
25017 T33098 Template which includes system messages which includes the template
25018 !! wikitext
25019 {{Identical}}
25020 !! html
25021 <p><span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
25022 <span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
25023 </p>
25024 !! end
25025
25026 !! test
25027 T33490 Turkish: ucfirst 'blah'
25028 !! options
25029 language=tr
25030 !! wikitext
25031 {{ucfirst:blah}}
25032 !! html
25033 <p>Blah
25034 </p>
25035 !! end
25036
25037 !! test
25038 T33490 Turkish: ucfirst 'ix'
25039 !! options
25040 language=tr
25041 !! wikitext
25042 {{ucfirst:ix}}
25043 !! html
25044 <p>İx
25045 </p>
25046 !! end
25047
25048 !! test
25049 T33490 Turkish: lcfirst 'BLAH'
25050 !! options
25051 language=tr
25052 !! wikitext
25053 {{lcfirst:BLAH}}
25054 !! html
25055 <p>bLAH
25056 </p>
25057 !! end
25058
25059 !! test
25060 T33490 Turkish: ucfırst (with a dotless i)
25061 !! options
25062 language=tr
25063 !! wikitext
25064 {{ucfırst:blah}}
25065 !! html
25066 <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>
25067 </p>
25068 !! end
25069
25070 !! test
25071 T33490 ucfırst (with a dotless i) with English language
25072 !! options
25073 language=en
25074 !! wikitext
25075 {{ucfırst:blah}}
25076 !! html
25077 <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>
25078 </p>
25079 !! end
25080
25081 # Note that Parsoid doesn't emit an explicit TOC.
25082 # Note also that the html2wt direction tends to emit an extra newline
25083 # between the __TOC__ magicword and the first heading unless *both*
25084 # the <meta> and the <h2> have a data-parsoid attribute set (even if
25085 # it's "{}").
25086
25087 !! test
25088 T28375: TOC with italics
25089 !! options
25090 title=[[Main Page]]
25091 !! wikitext
25092 __TOC__
25093 ==''Lost'' episodes==
25094 !! html/php
25095 <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>
25096 <ul>
25097 <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>
25098 </ul>
25099 </div>
25100
25101 <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>
25102
25103 !! html/parsoid
25104 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25105 <h2 id="Lost_episodes" data-parsoid='{}'><i>Lost</i> episodes</h2>
25106 !! end
25107
25108 !! test
25109 T28375: TOC with bold
25110 !! options
25111 title=[[Main Page]]
25112 !! wikitext
25113 __TOC__
25114 =='''should be bold''' then normal text==
25115 !! html/php
25116 <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>
25117 <ul>
25118 <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>
25119 </ul>
25120 </div>
25121
25122 <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>
25123
25124 !! html/parsoid
25125 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25126 <h2 id="should_be_bold_then_normal_text" data-parsoid='{}'><b>should be bold</b> then normal text</h2>
25127 !! end
25128
25129 !! test
25130 T35845: Headings become cursive in TOC when they contain an image
25131 !! options
25132 title=[[Main Page]]
25133 !! wikitext
25134 __TOC__
25135 ==Image [[Image:foobar.jpg]]==
25136 !! html/php
25137 <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>
25138 <ul>
25139 <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
25140 </ul>
25141 </div>
25142
25143 <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>
25144
25145 !! html/parsoid
25146 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25147 <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>
25148 !! end
25149
25150 !! test
25151 T35845 (2): Headings become bold in TOC when they contain a blockquote
25152 !! options
25153 title=[[Main Page]]
25154 !! wikitext
25155 __TOC__
25156 ==<blockquote>Quote</blockquote>==
25157 !! html/php
25158 <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>
25159 <ul>
25160 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
25161 </ul>
25162 </div>
25163
25164 <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>
25165
25166 !! html/php+tidy
25167 <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>
25168 <ul>
25169 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
25170 </ul>
25171 </div>
25172
25173 <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>
25174 !! html/parsoid
25175 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25176 <h2 id="Quote" data-parsoid='{}'><blockquote><p>Quote</p></blockquote></h2>
25177 !! end
25178
25179 !! test
25180 Unclosed tags in TOC
25181 !! config
25182 wgFragmentMode=[ 'html5', 'legacy' ]
25183 !! options
25184 title=[[Main Page]]
25185 !! wikitext
25186 __TOC__
25187 ==Proof: 2 < 3==
25188 <small>Hanc marginis exiguitas non caperet.</small>
25189 QED
25190 !! html/php
25191 <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>
25192 <ul>
25193 <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>
25194 </ul>
25195 </div>
25196
25197 <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>
25198 <p><small>Hanc marginis exiguitas non caperet.</small>
25199 QED
25200 </p>
25201 !! html/parsoid
25202 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25203 <h2 id="Proof:_2_&lt;_3" data-parsoid='{}'><span id="Proof:_2_.3C_3" typeof="mw:FallbackId"></span>Proof: 2 &lt; 3</h2>
25204 <p><small>Hanc marginis exiguitas non caperet.</small>
25205 QED</p>
25206 !! end
25207
25208 !! test
25209 Multiple tags in TOC
25210 !! wikitext
25211 __TOC__
25212 ==<i>Foo</i> <b>Bar</b>==
25213
25214 ==<i>Foo</i> <blockquote>Bar</blockquote>==
25215 !! html/php
25216 <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>
25217 <ul>
25218 <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>
25219 <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>
25220 </ul>
25221 </div>
25222
25223 <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>
25224 <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>
25225
25226 !! html/php+tidy
25227 <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>
25228 <ul>
25229 <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>
25230 <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>
25231 </ul>
25232 </div>
25233
25234 <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>
25235 <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>
25236 !! html/parsoid
25237 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25238 <h2 id="Foo_Bar" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b></h2>
25239
25240 <h2 id="Foo_Bar_2" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote><p>Bar</p></blockquote></h2>
25241 !! end
25242
25243 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
25244 # html5 tag parsing.
25245 !! test
25246 Tags with parameters in TOC
25247 !! options
25248 parsoid=wt2html
25249 !! wikitext
25250 __TOC__
25251 ==<sup class="in-h2">Hello</sup>==
25252
25253 ==<sup class="a > b">Evilbye</sup>==
25254 !! html/php
25255 <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>
25256 <ul>
25257 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
25258 <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>
25259 </ul>
25260 </div>
25261
25262 <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>
25263 <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>
25264
25265 !! html/parsoid
25266 <meta property="mw:PageProp/toc" />
25267 <h2 id="Hello"><sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup></h2>
25268
25269 <h2 id='b">Evilbye'><span id="b.22.3EEvilbye" typeof="mw:FallbackId"></span><sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup></h2>
25270 !! end
25271
25272 !! test
25273 span tags with directionality in TOC
25274 !! wikitext
25275 __TOC__
25276 ==<span dir="ltr">C++</span>==
25277
25278 ==<span dir="rtl">זבנג!</span>==
25279
25280 ==<span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span>==
25281
25282 ==<span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span>==
25283
25284 ==<span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span>==
25285 !! html/php
25286 <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>
25287 <ul>
25288 <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>
25289 <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>
25290 <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>
25291 <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>
25292 <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>
25293 </ul>
25294 </div>
25295
25296 <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>
25297 <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>
25298 <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>
25299 <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>
25300 <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>
25301
25302 !! html/parsoid
25303 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25304 <h2 id="C++" data-parsoid='{}'><span id="C.2B.2B" typeof="mw:FallbackId"></span><span dir="ltr">C++</span></h2>
25305 <h2 id="זבנג!"><span id=".D7.96.D7.91.D7.A0.D7.92.21" typeof="mw:FallbackId"></span><span dir="rtl">זבנג!</span></h2>
25306 <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>
25307 <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>
25308 <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>
25309 !! end
25310
25311 !! test
25312 T74884: bdi element in ToC
25313 !! wikitext
25314 __TOC__
25315 ==<bdi>test</bdi>==
25316 !! html/php
25317 <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>
25318 <ul>
25319 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
25320 </ul>
25321 </div>
25322
25323 <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>
25324
25325 !! html/parsoid
25326 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25327 <h2 id="test" data-parsoid='{}'><bdi>test</bdi></h2>
25328 !! end
25329
25330 !! test
25331 T35715: s/strike element in ToC
25332 !! wikitext
25333 __TOC__
25334 ==<s>test</s> test <strike>test</strike>==
25335 !! html/php
25336 <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>
25337 <ul>
25338 <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>
25339 </ul>
25340 </div>
25341
25342 <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>
25343
25344 !! html/parsoid
25345 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25346 <h2 id="test_test_test" data-parsoid='{}'><s>test</s> test <strike>test</strike></h2>
25347 !! end
25348
25349 !! test
25350 T198618: style element in ToC
25351 !! options
25352 styletag=1
25353 !! wikitext
25354 __TOC__
25355 ==<style>.foo {}</style>Style<style>.bar {}</style>==
25356 !! html/php
25357 <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>
25358 <ul>
25359 <li class="toclevel-1 tocsection-1"><a href="#Style"><span class="tocnumber">1</span> <span class="toctext">Style</span></a></li>
25360 </ul>
25361 </div>
25362
25363 <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>
25364
25365 !! html/parsoid
25366 <meta property="mw:PageProp/toc" data-parsoid="{}"/>
25367 <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>
25368 !! end
25369
25370 !! test
25371 T198618: script element in ToC
25372 !! options
25373 wgRawHtml=1
25374 !! wikitext
25375 __TOC__
25376 ==<html><script>alert(1);</script></html>Script<html><script>alert(1);</script></html>==
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="#Script"><span class="tocnumber">1</span> <span class="toctext">Script</span></a></li>
25381 </ul>
25382 </div>
25383
25384 <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>
25385
25386 !! html/parsoid
25387 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25388 <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>
25389 !! end
25390
25391 !! test
25392 Empty <p> tag in TOC, removed by Sanitizer (T92892)
25393 !! wikitext
25394 __TOC__
25395 ==x==
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="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
25400 </ul>
25401 </div>
25402
25403 <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>
25404
25405 !! html/parsoid
25406 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25407 <h2 id="x" data-parsoid='{}'>x</h2>
25408 !! end
25409
25410 !! article
25411 MediaWiki:T34057
25412 !! text
25413 == {{int:headline_sample}} ==
25414 !! endarticle
25415
25416 !! test
25417 T34057: Title needed when expanding <h> nodes.
25418 !! options
25419 title=[[Main Page]]
25420 !! wikitext
25421 {{int:T34057}}
25422 !! html
25423 <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>
25424
25425 !! end
25426
25427 !! test
25428 Strip marker in urlencode
25429 !! wikitext
25430 {{urlencode:x<nowiki/>y}}
25431 {{urlencode:x<nowiki/>y|wiki}}
25432 {{urlencode:x<nowiki/>y|path}}
25433 {{urlencode:x<pre id="one">two</pre>y}}
25434 !! html/php
25435 <p>xy
25436 xy
25437 xy
25438 xy
25439 </p>
25440 !! end
25441
25442 !! test
25443 Strip marker in lc
25444 !! wikitext
25445 {{lc:x<nowiki/>y}}
25446 !! html
25447 <p>xy
25448 </p>
25449 !! end
25450
25451 !! test
25452 Strip marker in uc
25453 !! wikitext
25454 {{uc:x<nowiki/>y}}
25455 !! html
25456 <p>XY
25457 </p>
25458 !! end
25459
25460 !! test
25461 Strip marker in formatNum
25462 !! wikitext
25463 {{formatnum:1<nowiki/>2}}
25464 {{formatnum:1<nowiki/>2|R}}
25465 !! html
25466 <p>12
25467 12
25468 </p>
25469 !! end
25470
25471 !! test
25472 Check noCommafy in formatNum
25473 !! options
25474 language=be-tarask
25475 !! wikitext
25476 {{formatnum:123456.78}}
25477 {{formatnum:123456.78|NOSEP}}
25478 !! html
25479 <p>123 456,78
25480 123456.78
25481 </p>
25482 !! end
25483
25484 !! test
25485 Wrong option for formatNum (T58199)
25486 !! wikitext
25487 {{formatnum:1,234.56|Random}}
25488 {{formatnum:1,234.56|EVERYTHING}}
25489 {{formatnum:1234.56|any argument that has the string 'NOSEP'}}
25490 !! html
25491 <p>1,234.56
25492 1,234.56
25493 1,234.56
25494 </p>
25495 !! end
25496
25497 !! test
25498 Strip marker in grammar
25499 !! options
25500 language=fi
25501 !! wikitext
25502 {{grammar:elative|foo<nowiki/>bar}}
25503 !! html
25504 <p>foobarista
25505 </p>
25506 !! end
25507
25508 !! test
25509 Strip marker in padleft
25510 !! wikitext
25511 {{padleft:|2|x<nowiki/>y}}
25512 !! html
25513 <p>xy
25514 </p>
25515 !! end
25516
25517 !! test
25518 Strip marker in padright
25519 !! wikitext
25520 {{padright:|2|x<nowiki/>y}}
25521 !! html
25522 <p>xy
25523 </p>
25524 !! end
25525
25526 !! test
25527 Strip marker in anchorencode
25528 !! wikitext
25529 {{anchorencode:x<nowiki/>y}}
25530 !! html/php
25531 <p>xy
25532 </p>
25533 !! html/parsoid
25534 <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>
25535 !! end
25536
25537 !! test
25538 nowiki inside link inside heading (T20295)
25539 !! wikitext
25540 ==[[foo|x<nowiki>y</nowiki>z]]==
25541 !! html
25542 <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>
25543
25544 !! end
25545
25546 !! test
25547 new support for bdi element (T33817)
25548 !! wikitext
25549 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
25550 !! html
25551 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
25552
25553 !!end
25554
25555 !! test
25556 Ignore pipe between table row attributes
25557 !! wikitext
25558 {|
25559 |quux
25560 |- id=foo | style='color: red'
25561 |bar
25562 |}
25563 !! html
25564 <table>
25565 <tr>
25566 <td>quux
25567 </td></tr>
25568 <tr id="foo" style="color: red">
25569 <td>bar
25570 </td></tr></table>
25571
25572 !! end
25573
25574 !!test
25575 Language parser function
25576 !! wikitext
25577 {{#language:ar}}
25578 !! html
25579 <p>العربية
25580 </p>
25581 !! end
25582
25583 !!test
25584 Padleft and padright (default 0-padding)
25585 !! wikitext
25586 {{padleft:xyz|5}}
25587 {{padright:xyz|5}}
25588 !! html/php
25589 <p>00xyz
25590 xyz00
25591 </p>
25592 !! html/parsoid
25593 <p><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:xyz","function":"padleft"},"params":{"1":{"wt":"5"}},"i":0}}]}'>00xyz</span>
25594 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:xyz","function":"padright"},"params":{"1":{"wt":"5"}},"i":0}}]}'>xyz00</span></p>
25595 !! end
25596
25597 !!test
25598 Padleft and padright (partial fill)
25599 !! wikitext
25600 {{padleft:xyz|6|ab}}
25601 {{padright:xyz|6|ab}}
25602 !! html/php
25603 <p>abaxyz
25604 xyzaba
25605 </p>
25606 !! html/parsoid
25607 <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>
25608 <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>
25609 !! end
25610
25611 !!test
25612 Padleft and padright as substr
25613 !! wikitext
25614 {{padleft:|3|abcde}}
25615 {{padright:|3|abcde}}
25616 !! html/php
25617 <p>abc
25618 abc
25619 </p>
25620 !! html/parsoid
25621 <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>
25622 <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>
25623 !! end
25624
25625 !! test
25626 Padleft and padright with non-numerical length (T180403)
25627 !! wikitext
25628 {{padleft:abcdef|junk}}
25629 {{padright:abcdef|junk}}
25630 !! html/php
25631 <p>abcdef
25632 abcdef
25633 </p>
25634 !! end
25635
25636 !!test
25637 Special parser function
25638 !! wikitext
25639 {{#special:RandomPage}}
25640 {{#special:BaDtItLe}}
25641 {{#special:Foobar}}
25642 !! html
25643 <p>Special:Random
25644 Special:Badtitle
25645 Special:Foobar
25646 </p>
25647 !! end
25648
25649 !!test
25650 T36939 - Case insensitive link parsing ([HttP://])
25651 !! wikitext
25652 [HttP://MediaWiki.Org/]
25653 !! html/php
25654 <p><a rel="nofollow" class="external autonumber" href="HttP://MediaWiki.Org/">[1]</a>
25655 </p>
25656 !! html/parsoid
25657 <p><a rel="mw:ExtLink" class="external autonumber" href="HttP://MediaWiki.Org/"></a></p>
25658 !! end
25659
25660 !!test
25661 T36939 - Case insensitive link parsing ([HttP:// title])
25662 !! wikitext
25663 [HttP://MediaWiki.Org/ MediaWiki]
25664 !! html
25665 <p><a rel="nofollow" class="external text" href="HttP://MediaWiki.Org/">MediaWiki</a>
25666 </p>
25667 !! end
25668
25669 !!test
25670 T36939 - Case insensitive link parsing (HttP://)
25671 !! wikitext
25672 HttP://MediaWiki.Org/
25673 !! html/php
25674 <p><a rel="nofollow" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a>
25675 </p>
25676 !! html/parsoid
25677 <p><a rel="mw:ExtLink" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a></p>
25678 !! end
25679
25680 !!test
25681 Disable TOC
25682 !! options
25683 notoc
25684 !! wikitext
25685 Lead
25686 ==Section 1==
25687 ==Section 2==
25688 ==Section 3==
25689 ==Section 4==
25690 ==Section 5==
25691 !! html
25692 <p>Lead
25693 </p>
25694
25695 <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>
25696 <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>
25697 <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>
25698 <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>
25699 <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>
25700
25701 !! end
25702
25703
25704 ###
25705 ### Parsoid-specific tests
25706 ### Parsoid-PHP parser incompatibilities
25707 ###
25708 !!test
25709 1. SOL-sensitive wikitext tokens as template-args
25710 !! options
25711 parsoid=wt2html,wt2wt
25712 !! wikitext
25713 {{echo|*a}}
25714 {{echo|#a}}
25715 {{echo|:a}}
25716 !! html/php+tidy
25717 <ul><li>a</li></ul>
25718 <ol><li>a</li></ol>
25719 <dl><dd>a</dd></dl>
25720 !! html/parsoid
25721 <span about="#mwt1" typeof="mw:Transclusion">
25722 </span><ul about="#mwt1"><li>a</li>
25723 </ul>
25724 <span about="#mwt2" typeof="mw:Transclusion">
25725 </span><ol about="#mwt2"><li>a</li>
25726 </ol>
25727 <span about="#mwt3" typeof="mw:Transclusion">
25728 </span><dl about="#mwt3"><dd>a</dd>
25729 </dl>
25730 !!end
25731
25732 #### -----------------------------------------------------------------
25733 #### Parsoid-specific functionality tests
25734 #### -----------------------------------------------------------------
25735
25736 # T65642/T68749: Formatting elt fixup around images.
25737 # We know wt2wt will fail, but we expect selser to pass.
25738 # Due to the nature of our testing, wt2wt and selser tests will enter the
25739 # blacklist and we'll catch selser regressions based on changes to the
25740 # blacklist entries for selser tests.
25741 !! test
25742 1. Treebuilder fixup of formatting elt
25743 !! options
25744 parsoid=wt2html,wt2wt
25745 !! wikitext
25746 {|
25747 |
25748 <small>
25749 [[Image:Foobar.jpg|right|Test]]
25750 </small>
25751 |}
25752 !! html/php+tidy
25753 <table>
25754 <tbody><tr>
25755 <td>
25756 <p><small>
25757 </small></p><small>
25758 <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>
25759 </small><p><small></small>
25760 </p>
25761 </td></tr></tbody></table>
25762 !! html/parsoid
25763 <table>
25764 <tbody><tr><td>
25765 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p><small data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
25766 <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>
25767 <p><small data-parsoid='{"stx":"html","autoInsertedStart":true}'></small></p></td></tr>
25768 </tbody></table>
25769 !! end
25770
25771 !! test
25772 2. Treebuilder fixup of formatting elt
25773 !! options
25774 parsoid=wt2html,wt2wt
25775 !! wikitext
25776 '''foo[[File:Foobar.jpg|thumb|caption]]bar'''
25777
25778 <small>[[Image:Foobar.jpg|right|300px]]</small>
25779 !! html/php+tidy
25780 <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>
25781 </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>
25782 !! html/parsoid
25783 <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>
25784
25785 <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>
25786 !! end
25787
25788 !! test
25789 3. Treebuilder fixup of formatting elt
25790 !! options
25791 parsoid=wt2html,wt2wt
25792 !! wikitext
25793 <small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
25794 !! html/php+tidy
25795 <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>
25796 </p>
25797 !! html/parsoid
25798 <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>
25799 !! end
25800
25801 !! test
25802 4. Treebuilder fixup of formatting elt: formatting tags around captionless images
25803 !! options
25804 parsoid=wt2html,wt2wt
25805 !! wikitext
25806 '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
25807 !! html/php+tidy
25808 <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>
25809 !! html/parsoid
25810 <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>
25811 !! end
25812
25813 #### ----------------------------------------------------------------
25814 #### Parsoid-only testing of Parsoid's impl of LST
25815 #### Not implemented yet, see
25816 #### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
25817 #### ----------------------------------------------------------------
25818
25819 ## We still need to support serializing the older format while content is stored.
25820 !! test
25821 LST Sections: Backwards compatibility
25822 !! options
25823 parsoid={
25824 "suppressErrors": true,
25825 "modes": ["html2wt"]
25826 }
25827 !! wikitext
25828 <section begin="2011-05-16" />
25829 <section end="2014-04-10 (MW 1.23wmf22)" />
25830 !! html/parsoid
25831 <p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/>
25832 <meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p>
25833 !! end
25834
25835 !! test
25836 LST Sections: Newfangled approach
25837 !! wikitext
25838 <section begin="2011-05-16" />
25839 <section end="2014-04-10 (MW 1.23wmf22)" />
25840 !! html/parsoid
25841 <p><span typeof="mw:Extension/section" about="#mwt4" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"}}'>
25842 </span>
25843 <span typeof="mw:Extension/section" about="#mwt6" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"}}'>
25844 </span></p>
25845 !! end
25846
25847 #--------- Test stripping of empty nodes in template content ----------
25848
25849 !! test
25850 Empty LI and TR nodes should be stripped from template content
25851 !! wikitext
25852 {{EmptyLITest}}
25853 {{EmptyTRTest}}
25854 !! html/parsoid
25855 <ul about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyLITest","href":"./Template:EmptyLITest"},"params":{},"i":0}}]}'>
25856 <li>a</li>
25857 <li>b</li>
25858 </ul>
25859 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRTest","href":"./Template:EmptyTRTest"},"params":{},"i":0}}]}'>
25860 <tbody>
25861 <tr>
25862 <td>foo</td>
25863 </tr>
25864 <tr>
25865 <td>bar</td>
25866 </tr>
25867 </tbody>
25868 </table>
25869 !! end
25870
25871 !! test
25872 Empty LI and TR nodes should not be stripped from top-level content
25873 !! wikitext
25874 *a
25875 *
25876 *b
25877
25878 {|
25879 |-
25880 |-
25881 |foo
25882 |}
25883 !! html/parsoid
25884 <ul>
25885 <li>a</li>
25886 <li class='mw-empty-elt'></li>
25887 <li>b</li>
25888 </ul>
25889 <table>
25890 <tbody>
25891 <tr class='mw-empty-elt'></tr>
25892 <tr>
25893 <td>foo</td>
25894 </tr>
25895 </tbody>
25896 </table>
25897 !! end
25898
25899 !! test
25900 Empty TR nodes should not be stripped if they have any attributes set
25901 !! wikitext
25902 {{EmptyTRWithHTMLAttrTest}}
25903 !! html/parsoid
25904 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'>
25905 <tr align='center'></tr>
25906 <tr><td>foo</td></tr>
25907 <tr align='center'></tr>
25908 <tr><td>bar</td></tr>
25909 </table>
25910 !! end
25911
25912 #### ----------------------------------------------------------------
25913 #### The following section of tests are primarily to test
25914 #### wikitext escaping capabilities of Parsoid. Given that
25915 #### escaping can be done any number of ways, the wikitext (input)
25916 #### is always adjusted to reflect how Parsoid adds nowiki
25917 #### escape tags.
25918 ####
25919 #### We are marking several tests as parsoid-only since the
25920 #### HTML in the result section is different from what the
25921 #### PHP parser generates for it.
25922 #### ----------------------------------------------------------------
25923
25924
25925 #### --------------- Headings ---------------
25926 #### 0. Unnested
25927 #### 1. Nested inside html <h1>=foo=</h1>
25928 #### 2. Outside heading nest on a single line <h1>foo</h1>*bar
25929 #### 3. Nested inside html with wikitext split by html tags
25930 #### 4. No escape needed
25931 #### 5. Empty headings <h1></h1>
25932 #### 6. Heading chars in SOL context
25933 #### ----------------------------------------
25934 !! test
25935 Headings: 0. Unnested
25936 !! options
25937 parsoid=html2wt
25938 !! html/parsoid
25939 <p>=foo=</p>
25940
25941 <p> =foo=
25942 <!--cmt-->
25943 =foo=</p>
25944
25945 <p>=foo<i>a</i>=</p>
25946 !! wikitext
25947 <nowiki>=foo=</nowiki>
25948
25949 <nowiki> </nowiki>=foo=
25950 <!--cmt-->
25951 <nowiki>=foo=</nowiki>
25952
25953 =foo''a''<nowiki>=</nowiki>
25954 !!end
25955
25956 # New headings and existing headings are handled differently
25957 !! test
25958 Headings: 1. Nested inside html
25959 !! options
25960 parsoid=html2wt
25961 !! html/parsoid
25962 <h1>=foo=</h1>
25963 <h2>=foo=</h2>
25964 <h3>=foo=</h3>
25965
25966 <h1 data-parsoid=''>=foo=</h1>
25967 <h2 data-parsoid=''>=foo=</h2>
25968 <h3 data-parsoid=''>=foo=</h3>
25969 <h4 data-parsoid=''>=foo=</h4>
25970 <h5 data-parsoid=''>=foo=</h5>
25971 <h6 data-parsoid=''>=foo=</h6>
25972 !! wikitext
25973 = =foo= =
25974
25975 == =foo= ==
25976
25977 === =foo= ===
25978
25979 =<nowiki>=foo=</nowiki>=
25980 ==<nowiki>=foo=</nowiki>==
25981 ===<nowiki>=foo=</nowiki>===
25982 ====<nowiki>=foo=</nowiki>====
25983 =====<nowiki>=foo=</nowiki>=====
25984 ======<nowiki>=foo=</nowiki>======
25985
25986 !!end
25987
25988 !! test
25989 Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
25990 !! options
25991 parsoid=html2wt
25992 !! html/parsoid
25993 <h1>foo</h1>*bar
25994 <h1>foo</h1>=bar
25995 <h1>foo</h1>=bar=
25996 !! wikitext
25997 = foo =
25998 <nowiki>*</nowiki>bar
25999
26000 = foo =
26001 =bar
26002
26003 = foo =
26004 <nowiki>=bar=</nowiki>
26005 !!end
26006
26007 !! test
26008 Headings: 3. Nested inside html with wikitext split by html tags
26009 !! options
26010 parsoid=html2wt
26011 !! html/parsoid
26012 <h1>=<b>bold</b>foo=</h1>
26013 !! wikitext
26014 = ='''bold'''foo= =
26015 !!end
26016
26017 !! test
26018 Headings: 4a. No escaping needed (testing just h1 and h2)
26019 !! options
26020 parsoid=html2wt
26021 !! html/parsoid
26022 <h1>=foo</h1>
26023 <h1>foo=</h1>
26024 <h1> =foo= </h1>
26025 <h1>=foo= bar</h1>
26026 <h2>=foo</h2>
26027 <h2>foo=</h2>
26028 <h1>=</h1>
26029 <h1><i>=</i>foo=</h1>
26030 !! wikitext
26031 = =foo =
26032
26033 = foo= =
26034
26035 = =foo= =
26036
26037 = =foo= bar =
26038
26039 == =foo ==
26040
26041 == foo= ==
26042
26043 = = =
26044
26045 = ''=''foo= =
26046 !!end
26047
26048 !! test
26049 Headings: 4b. No escaping needed (inside p-tags)
26050 !! options
26051 parsoid=html2wt
26052 !! html/parsoid
26053 <p>=foo= x
26054 =foo= <s></s>
26055 </p>
26056 !! wikitext
26057 =foo= x
26058 =foo= <s></s>
26059 !! html/php
26060 <p>=foo= x
26061 =foo= <s></s>
26062 </p>
26063 !!end
26064
26065 !! test
26066 Headings: 4c. Short headings (1)
26067 !! options
26068 parsoid=html2wt
26069 !! html/parsoid
26070 <p>===
26071 </p>
26072 !! wikitext
26073 <nowiki>===</nowiki>
26074 !! html/php
26075 <p>===
26076 </p>
26077 !! end
26078
26079 # in the html2wt direction we emit '= = =' or '=<nowiki>=</nowiki>='
26080 !! test
26081 Headings: 4d. Short headings (2)
26082 !! options
26083 parsoid=wt2html,html2html
26084 !! wikitext
26085 =
26086 ==
26087 ===
26088 ====
26089 =====
26090 !! html/php
26091 <p>=
26092 ==
26093 </p>
26094 <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>
26095 <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>
26096 <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>
26097
26098 !! html/parsoid
26099 <p>=
26100 ==</p>
26101 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
26102 <h1 id="=="><span id=".3D.3D" typeof="mw:FallbackId"></span>==</h1>
26103 <h2 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h2>
26104 !! end
26105
26106 !! test
26107 Headings: 5. Empty headings
26108 !! options
26109 parsoid=html2wt
26110 !! html/parsoid
26111 <h1 data-parsoid='{}'></h1>
26112
26113 <h2 data-parsoid='{}'></h2>
26114
26115 <h3 data-parsoid='{}'></h3>
26116
26117 <h4 data-parsoid='{}'></h4>
26118
26119 <h5 data-parsoid='{}'></h5>
26120
26121 <h6 data-parsoid='{}'></h6>
26122 !! wikitext
26123 =<nowiki/>=
26124
26125 ==<nowiki/>==
26126
26127 ===<nowiki/>===
26128
26129 ====<nowiki/>====
26130
26131 =====<nowiki/>=====
26132
26133 ======<nowiki/>======
26134 !!end
26135
26136 !! test
26137 Headings: 6a. Heading chars in SOL context (with trailing spaces)
26138 !! options
26139 parsoid=html2wt
26140 !! html/parsoid
26141 <p>=a=</p>
26142
26143 <p>=a=</p>
26144
26145 <p>=a=</p>
26146 !! wikitext
26147 <nowiki>=a=</nowiki>
26148
26149 <nowiki>=a=</nowiki>
26150
26151 <nowiki>=a=</nowiki>
26152 !!end
26153
26154 !! test
26155 Headings: 6b. Heading chars in SOL context (with trailing newlines)
26156 !! options
26157 parsoid=html2wt
26158 !! html/parsoid
26159 <p>=a=
26160 b</p>
26161
26162 <p>=a=
26163 b</p>
26164
26165 <p>=a=
26166 b</p>
26167 !! wikitext
26168 <nowiki>=a=</nowiki>
26169 b
26170
26171 <nowiki>=a=</nowiki>
26172 b
26173
26174 <nowiki>=a=</nowiki>
26175 b
26176 !!end
26177
26178 !! test
26179 Headings: 6c. Heading chars in SOL context (leading newline break)
26180 !! options
26181 parsoid=html2wt
26182 !! html/parsoid
26183 <p>a
26184 =b=</p>
26185 !! wikitext
26186 a
26187 <nowiki>=b=</nowiki>
26188 !!end
26189
26190 !! test
26191 Headings: 6d. Heading chars in SOL context (with interspersed comments)
26192 !! options
26193 parsoid=html2wt
26194 !! html/parsoid
26195 <!--c0--><p>=a=</p>
26196
26197 <!--c1--><p>=a=</p> <!--c2--> <!--c3-->
26198 !! wikitext
26199 <!--c0--><nowiki>=a=</nowiki>
26200
26201 <!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3-->
26202 !!end
26203
26204 !! test
26205 Headings: 6d. Heading chars in SOL context (No escaping needed)
26206 !! options
26207 parsoid=html2wt
26208 !! html/parsoid
26209 =a=<div>b</div>
26210 !! wikitext
26211 =a=<div>b</div>
26212 !!end
26213
26214 !! test
26215 Headings: 7. Insert a newline between new content and headings
26216 !! options
26217 parsoid=html2wt
26218 !! html/parsoid
26219 <h2>NEW</h2>
26220 <p>new</p>
26221 <h2 data-parsoid='{}'>A</h2>
26222 <p data-parsoid='{}'>a</p>
26223 !! wikitext
26224 == NEW ==
26225 new
26226
26227 ==A==
26228 a
26229
26230 !! end
26231
26232 !! test
26233 Headings: Used as horizontal rule
26234 !! config
26235 wgFragmentMode=[ 'html5', 'legacy' ]
26236 !! options
26237 parsoid=wt2html
26238 !! wikitext
26239 ===============
26240 !! html/php
26241 <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>
26242
26243 !! html/parsoid
26244 <h6 id="==="><span id=".3D.3D.3D" typeof="mw:FallbackId"></span>===</h6>
26245 !! end
26246
26247 #### --------------- Lists ---------------
26248 #### 0. Outside nests (*foo, etc.)
26249 #### 1. Nested inside html <ul><li>*foo</li></ul>
26250 #### 2. Inside definition lists
26251 #### 3. Only bullets at start should be escaped
26252 #### 4. No escapes needed
26253 #### 5. No unnecessary escapes
26254 #### 6. Escape bullets in SOL position
26255 #### 7. Escape bullets in a multi-line context
26256 #### ----------------------------------------
26257
26258 !! test
26259 Lists: 0. Outside nests
26260 !! options
26261 parsoid=html2wt
26262 !! html/parsoid
26263 <p>*foo</p>
26264
26265 <p>#foo</p>
26266
26267 <p>;Foo:bar</p>
26268 !! wikitext
26269 <nowiki>*</nowiki>foo
26270
26271 <nowiki>#</nowiki>foo
26272
26273 <nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar
26274 !!end
26275
26276 ## Making these next 3 tests Parsoid-only since they are html2wt tests
26277 ## to test wikitext escaping, and insignificant whitespace diffs
26278 ## cause PHP parser tests to barf
26279 !! test
26280 Lists: 1. Nested inside html (No unnecessary escapes)
26281 !! options
26282 parsoid=html2wt
26283 !! html/parsoid
26284 <ul>
26285 <li>*foo</li>
26286 <li>#foo</li>
26287 <li>:foo</li>
26288 <li>;foo</li>
26289 <li data-parsoid='{}'>*foo</li>
26290 <li data-parsoid='{}'>#foo</li>
26291 <li data-parsoid='{}'>:foo</li>
26292 <li data-parsoid='{}'>;foo</li>
26293 </ul>
26294
26295 <ol>
26296 <li>*foo</li>
26297 <li>#foo</li>
26298 <li>:foo</li>
26299 <li>;foo</li>
26300 <li data-parsoid='{}'>*foo</li>
26301 <li data-parsoid='{}'>#foo</li>
26302 <li data-parsoid='{}'>:foo</li>
26303 <li data-parsoid='{}'>;foo</li>
26304 </ol>
26305 !! wikitext
26306 * *foo
26307 * #foo
26308 * :foo
26309 * ;foo
26310 *<nowiki>*foo</nowiki>
26311 *<nowiki>#foo</nowiki>
26312 *<nowiki>:foo</nowiki>
26313 *<nowiki>;foo</nowiki>
26314
26315 # *foo
26316 # #foo
26317 # :foo
26318 # ;foo
26319 #<nowiki>*foo</nowiki>
26320 #<nowiki>#foo</nowiki>
26321 #<nowiki>:foo</nowiki>
26322 #<nowiki>;foo</nowiki>
26323 !!end
26324
26325 !! test
26326 Lists: 2. Inside definition lists
26327 !! options
26328 parsoid=html2wt
26329 !! html/parsoid
26330 <dl><dt>;foo</dt></dl>
26331 <dl><dt>:foo</dt></dl>
26332 <dl><dt>:foo</dt>
26333 <dd>bar</dd></dl>
26334 <dl><dd>:foo</dd></dl>
26335 !! wikitext
26336 ; ;foo
26337
26338 ; <nowiki>:foo</nowiki>
26339
26340 ; <nowiki>:foo</nowiki>
26341 : bar
26342
26343 : :foo
26344 !!end
26345
26346 !! test
26347 Lists: 3. Only bullets at start of text in wikitext-generated HTML should be escaped
26348 !! options
26349 parsoid=html2wt
26350 !! html/parsoid
26351 <ul>
26352 <li>*foo*bar</li>
26353 <li data-parsoid='{}'>*foo<i>it</i>*bar</li>
26354 </ul>
26355 !! wikitext
26356 * *foo*bar
26357 *<nowiki>*foo</nowiki>''it''*bar
26358 !!end
26359
26360 !! test
26361 Lists: 4. No escapes needed
26362 !! options
26363 parsoid=html2wt
26364 !! html/parsoid
26365 <ul>
26366 <li>foo*bar
26367 </li>
26368 </ul>
26369 <ul>
26370 <li><i>foo</i>*bar
26371 </li>
26372 </ul>
26373 <ul>
26374 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>: bar
26375 </li>
26376 </ul>
26377 <ul>
26378 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar
26379 </li>
26380 </ul>
26381 !! wikitext
26382 *foo*bar
26383
26384 *''foo''*bar
26385
26386 *[[Foo]]: bar
26387
26388 *[[Foo]]*bar
26389 !!end
26390
26391 !! test
26392 Lists: 5. No unnecessary escapes
26393 !! options
26394 parsoid=html2wt
26395 !! html/parsoid
26396 <ul><li> bar <span>[[foo]]</span></li></ul>
26397 <ul><li> =bar <span>[[foo]]</span></li></ul>
26398 <ul><li> [[bar <span>[[foo]]</span></li></ul>
26399 <ul><li> ]]bar <span>[[foo]]</span></li></ul>
26400 <ul><li> =bar <span>foo]]</span>=</li></ul>
26401 <ul><li> <s></s>: a</li></ul>
26402 <ul><li> <i>* foo</i></li></ul>
26403
26404 !! wikitext
26405 * bar <span><nowiki>[[foo]]</nowiki></span>
26406
26407 * =bar <span><nowiki>[[foo]]</nowiki></span>
26408
26409 * [[bar <span><nowiki>[[foo]]</nowiki></span>
26410
26411 * ]]bar <span><nowiki>[[foo]]</nowiki></span>
26412
26413 * =bar <span>foo]]</span>=
26414
26415 * <s></s>: a
26416
26417 * ''* foo''
26418 !!end
26419
26420 !! test
26421 Lists: 6. Escape bullets in SOL position
26422 !! options
26423 parsoid=html2wt
26424 !! html/parsoid
26425 <p><!--cmt-->*foo</p>
26426 !! wikitext
26427 <!--cmt--><nowiki>*</nowiki>foo
26428 !!end
26429
26430 !! test
26431 Lists: 7. Escape bullets in a multi-line context
26432 !! options
26433 parsoid=html2wt
26434 !! html/parsoid
26435 <p>a
26436 *b
26437 </p>
26438 !! wikitext
26439 a
26440 <nowiki>*</nowiki>b
26441 !!end
26442
26443 !! test
26444 Lists: 8. Escape colons only if not present in tags
26445 !! options
26446 parsoid=html2wt
26447 !! html/parsoid
26448 <dl><dt>a:b<i>c:d</i></dt></dl>
26449 !! wikitext
26450 ; <nowiki>a:b</nowiki>''c:d''
26451 !! end
26452
26453 #### --------------- HRs ---------------
26454 #### 1. Single line
26455 #### -----------------------------------
26456
26457 !! test
26458 HRs: 1. Single line
26459 !! options
26460 parsoid=html2wt
26461 !! html/parsoid
26462 <hr />----
26463 <hr />=foo=
26464 <hr />*foo
26465 !! wikitext
26466 ----<nowiki>----</nowiki>
26467 ----=foo=
26468 ----*foo
26469 !! end
26470
26471 #### --------------- Tables ---------------
26472 #### 1a. Simple example
26473 #### 1b. No escaping needed (!foo)
26474 #### 1c. No escaping needed (|foo)
26475 #### 1d. No escaping needed (|}foo)
26476 ####
26477 #### 2a. Nested in td (<td>foo|bar</td>)
26478 #### 2b. Nested in td (<td>foo||bar</td>)
26479 #### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
26480 ####
26481 #### 3a. Nested in th (<th>foo!bar</th>)
26482 #### 3b. Nested in th (<th>foo!!bar</th>)
26483 #### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
26484 ####
26485 #### 4a. Escape -
26486 #### 4b. Escape +
26487 #### 4c. No escaping needed
26488 #### --------------------------------------
26489
26490 !! test
26491 Tables: 1a. Simple example
26492 !! options
26493 parsoid=html2wt
26494 !! html/parsoid
26495 <p>{|
26496 |}
26497 </p>
26498 !! wikitext
26499 <nowiki>{|</nowiki>
26500 |}
26501 !! end
26502
26503 !! test
26504 Tables: 1b. No escaping needed
26505 !! options
26506 parsoid=html2wt
26507 !! html/parsoid
26508 <p>!foo
26509 </p>
26510 !! wikitext
26511 !foo
26512 !! end
26513
26514 !! test
26515 Tables: 1c. No escaping needed
26516 !! options
26517 parsoid=html2wt
26518 !! html/parsoid
26519 <p>|foo
26520 </p>
26521 !! wikitext
26522 |foo
26523 !! end
26524
26525 !! test
26526 Tables: 1d. No escaping needed
26527 !! options
26528 parsoid=html2wt
26529 !! html/parsoid
26530 <p>|}foo
26531 </p>
26532 !! wikitext
26533 |}foo
26534 !! end
26535
26536 !! test
26537 Tables: 2a. Nested in td
26538 !! options
26539 parsoid=html2wt
26540 !! html/parsoid
26541 <table><tbody><tr>
26542 <td>foo|bar</td></tr>
26543 <tr><td>x<div>a|b</div></td>
26544 </tbody></table>
26545 !! wikitext
26546 {|
26547 |<nowiki>foo|bar</nowiki>
26548 |-
26549 |x<div><nowiki>a|b</nowiki></div>
26550 |}
26551 !! html/php+tidy
26552 <table>
26553 <tbody><tr>
26554 <td>foo|bar
26555 </td></tr>
26556 <tr>
26557 <td>x<div>a|b</div>
26558 </td></tr></tbody></table>
26559 !! end
26560
26561 !! test
26562 Tables: 2b. Nested in td
26563 !! options
26564 parsoid=html2wt
26565 !! html/parsoid
26566 <table><tbody><tr>
26567 <td>foo||bar</td>
26568 <td>a<i>b||c</i></td>
26569 <td>a<i><div>b||c</div></i></td>
26570 </tr></tbody></table>
26571 !! wikitext
26572 {|
26573 |<nowiki>foo||bar</nowiki>
26574 |a''<nowiki>b||c</nowiki>''
26575 |a''<div><nowiki>b||c</nowiki></div>''
26576 |}
26577 !! html/php
26578 <table>
26579 <tr>
26580 <td>foo||bar
26581 </td>
26582 <td>a<i>b||c</i>
26583 </td>
26584 <td>a<i><div>b||c</div></i>
26585 </td></tr></table>
26586
26587 !! end
26588
26589 !! test
26590 Tables: 2c. Nested in td -- no escaping needed
26591 !! options
26592 parsoid=html2wt
26593 !! html/*
26594 <table>
26595 <tr>
26596 <td>foo!!bar
26597 </td></tr></table>
26598
26599 !! wikitext
26600 {|
26601 |foo!!bar
26602 |}
26603 !! end
26604
26605 !! test
26606 Tables: 3a. Nested in th
26607 !! options
26608 parsoid=html2wt
26609 !! html/*
26610 <table>
26611 <tr>
26612 <th>foo!bar
26613 </th></tr></table>
26614
26615 !! wikitext
26616 {|
26617 !foo!bar
26618 |}
26619 !! end
26620
26621 !! test
26622 Tables: 3b. Nested in th
26623 !! options
26624 parsoid=html2wt
26625 !! html/parsoid
26626 <table><tbody>
26627 <tr><th>foo!!bar</th>
26628 <th><i>foo|bar</i></th>
26629 <th><i>foo!!bar</i></th>
26630 <th><i><span>foo!!bar</span></i></th>
26631 </tr></tbody></table>
26632 !! wikitext
26633 {|
26634 !<nowiki>foo!!bar</nowiki>
26635 !''<nowiki>foo|bar</nowiki>''
26636 !''<nowiki>foo!!bar</nowiki>''
26637 !''<span><nowiki>foo!!bar</nowiki></span>''
26638 |}
26639 !! html/php
26640 <table>
26641 <tr>
26642 <th>foo!!bar
26643 </th>
26644 <th><i>foo|bar</i>
26645 </th>
26646 <th><i>foo!!bar</i>
26647 </th>
26648 <th><i><span>foo!!bar</span></i>
26649 </th></tr></table>
26650
26651 !! end
26652
26653 !! test
26654 Tables: 3c. Nested in th
26655 !! options
26656 parsoid=html2wt
26657 !! html/parsoid
26658 <table><tbody>
26659 <tr><th>foo||bar</th>
26660 <th><span typeof="mw:Nowiki">foo||bar</span></th>
26661 </tr></tbody></table>
26662 !! wikitext
26663 {|
26664 !<nowiki>foo||bar</nowiki>
26665 !<nowiki>foo||bar</nowiki>
26666 |}
26667 !! html/php
26668 <table>
26669 <tr>
26670 <th>foo||bar
26671 </th>
26672 <th>foo||bar
26673 </th></tr></table>
26674
26675 !! end
26676
26677 !! test
26678 Tables: 4a. Escape -
26679 !! options
26680 parsoid=html2wt
26681 !! html/*
26682 <table>
26683 <tr>
26684 <th>-bar
26685 </th></tr>
26686 <tr>
26687 <td>-bar
26688 </td></tr></table>
26689
26690 !! wikitext
26691 {|
26692 !-bar
26693 |-
26694 |<nowiki>-bar</nowiki>
26695 |}
26696 !! end
26697
26698 !! test
26699 Tables: 4b. Escape +
26700 !! options
26701 parsoid=html2wt
26702 !! html/*
26703 <table>
26704 <tr>
26705 <th>+bar
26706 </th></tr>
26707 <tr>
26708 <td>+bar
26709 </td></tr></table>
26710
26711 !! wikitext
26712 {|
26713 !+bar
26714 |-
26715 |<nowiki>+bar</nowiki>
26716 |}
26717 !! end
26718
26719 !! test
26720 Tables: 4c. No escaping needed
26721 !! options
26722 parsoid=html2wt
26723 !! html/parsoid
26724 <table><tbody>
26725 <tr><td>foo-bar</td><td>foo+bar</td></tr>
26726 <tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
26727 <tr><td>foo
26728 <p>bar|baz
26729 +bar
26730 -bar</p></td></tr>
26731 <tr><td>x
26732 <div>a|b</div></td>
26733 </tbody></table>
26734 !! wikitext
26735 {|
26736 |foo-bar
26737 |foo+bar
26738 |-
26739 |''foo''-bar
26740 |''foo''+bar
26741 |-
26742 |foo
26743 bar|baz
26744 +bar
26745 -bar
26746 |-
26747 |x
26748 <div>a|b</div>
26749 |}
26750 !! html/php
26751 <table>
26752 <tr>
26753 <td>foo-bar
26754 </td>
26755 <td>foo+bar
26756 </td></tr>
26757 <tr>
26758 <td><i>foo</i>-bar
26759 </td>
26760 <td><i>foo</i>+bar
26761 </td></tr>
26762 <tr>
26763 <td>foo
26764 <p>bar|baz
26765 +bar
26766 -bar
26767 </p>
26768 </td></tr>
26769 <tr>
26770 <td>x
26771 <div>a|b</div>
26772 </td></tr></table>
26773
26774 !! end
26775
26776 !! test
26777 Tables: 4d. No escaping needed
26778 !! options
26779 parsoid=html2wt
26780 !! html/parsoid
26781 <table>
26782 <tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
26783 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
26784 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
26785 </tbody></table>
26786 !! wikitext
26787 {|
26788 |[[Foo]]-bar
26789 ||+1
26790 ||-2
26791 |}
26792 !! html/php
26793 <table>
26794 <tr>
26795 <td><a href="/wiki/Foo" title="Foo">Foo</a>-bar
26796 </td>
26797 <td>+1
26798 </td>
26799 <td>-2
26800 </td></tr></table>
26801
26802 !! end
26803
26804 !! test
26805 Tables: 5. Empty table cells should get whitespace to avoid need for nowikis
26806 !! options
26807 parsoid=html2wt
26808 !! html/parsoid
26809 <table><tr><td></td><td align="center" data-parsoid='{"stx":"row"}'></td><td data-parsoid='{"stx":"row"}'></td></tr></table>
26810
26811 <table><tr><td></td><td align="center"></td><td></td></tr></table>
26812
26813 <table><tr><td></td><td align="center" data-parsoid='{"stx":"row", "startTagSrc":"{{!}}{{!}}"}'></td><td data-parsoid='{"stx":"row"}'></td></tr></table>
26814
26815 <table><tr><th></th><th align="center" data-parsoid='{"stx":"row"}'></th><th data-parsoid='{"stx":"row"}'></th></tr></table>
26816 !! wikitext
26817 {|
26818 | || align="center" | ||
26819 |}
26820
26821 {|
26822 |
26823 | align="center" |
26824 |
26825 |}
26826
26827 {|
26828 | {{!}}{{!}} align="center" | ||
26829 |}
26830
26831 {|
26832 ! !! align="center" | !!
26833 |}
26834 !! html/php+tidy
26835 <table>
26836 <tbody><tr>
26837 <td></td>
26838 <td align="center"></td>
26839 <td>
26840 </td></tr></tbody></table>
26841 <table>
26842 <tbody><tr>
26843 <td>
26844 </td>
26845 <td align="center">
26846 </td>
26847 <td>
26848 </td></tr></tbody></table>
26849 <table>
26850 <tbody><tr>
26851 <td></td>
26852 <td align="center"></td>
26853 <td>
26854 </td></tr></tbody></table>
26855 <table>
26856 <tbody><tr>
26857 <th></th>
26858 <th align="center"></th>
26859 <th>
26860 </th></tr></tbody></table>
26861 !! end
26862
26863 !! test
26864 T97430: Don't emit empty nowiki pairs around marker meta tags
26865 !! options
26866 parsoid=html2wt
26867 !! html/parsoid
26868 <p>*This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
26869 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
26870 !! wikitext
26871 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
26872 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
26873 !! end
26874
26875 !! test
26876 Unclosed xmlish element in table line shouldn't eat end delimiters
26877 !! options
26878 parsoid=html2wt
26879 !! html/parsoid
26880 <table>
26881 <tbody><tr><td> &lt;foo</td>
26882 <td> bar></td></tr>
26883 </tbody></table>
26884 !! wikitext
26885 {|
26886 | <foo
26887 | bar>
26888 |}
26889 !! html/php
26890 <table>
26891 <tr>
26892 <td>&lt;foo
26893 </td>
26894 <td>bar&gt;
26895 </td></tr></table>
26896
26897 !! end
26898
26899 #### --------------- Links ----------------
26900 #### 1. Quote marks in link text
26901 #### 2. Wikilinks: Escapes needed
26902 #### 3. Wikilinks: No escapes needed
26903 #### 4. Extlinks: Escapes needed
26904 #### 5. Extlinks: No escapes needed
26905 #### --------------------------------------
26906 !! test
26907 Links 1. WikiLinks: No escapes needed
26908 !! options
26909 parsoid=html2wt
26910 !! html/parsoid
26911 <p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
26912 <a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
26913 <a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
26914 !! wikitext
26915 [[Foo|Foo''boo'']]
26916 [[Foo|[Foobar]]]
26917 [[Foo|x [Foobar] x]]
26918 !! html/php
26919 <p><a href="/wiki/Foo" title="Foo">Foo<i>boo</i></a>
26920 <a href="/wiki/Foo" title="Foo">[Foobar]</a>
26921 <a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
26922 </p>
26923 !! end
26924
26925 !! test
26926 Links 2. WikiLinks: Escapes needed
26927 !! options
26928 parsoid=html2wt
26929 !! html/parsoid
26930 <a href="Foo" rel="mw:WikiLink">Foobar]</a>
26931 <a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
26932 <a href="Foo" rel="mw:WikiLink">[[Bar]]</a>
26933 <a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a>
26934 <a href="Foo" rel="mw:WikiLink">|Bar</a>
26935 <a href="Foo" rel="mw:WikiLink">]]bar</a>
26936 <a href="Foo" rel="mw:WikiLink">[[bar</a>
26937 <a href="Foo" rel="mw:WikiLink">x [[ y</a>
26938 <a href="Foo" rel="mw:WikiLink">x ]] y</a>
26939 <a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a>
26940 !! wikitext
26941 [[Foo|<nowiki>Foobar]</nowiki>]]
26942 [[Foo|x <nowiki>[http://google.com g]</nowiki> x]]
26943 [[Foo|<nowiki>[[Bar]]</nowiki>]]
26944 [[Foo|<nowiki>x [[Bar]] x</nowiki>]]
26945 [[Foo|<nowiki>|Bar</nowiki>]]
26946 [[Foo|<nowiki>]]bar</nowiki>]]
26947 [[Foo|<nowiki>[[bar</nowiki>]]
26948 [[Foo|<nowiki>x [[ y</nowiki>]]
26949 [[Foo|<nowiki>x ]] y</nowiki>]]
26950 [[Foo|<nowiki>x ]] y [[ z</nowiki>]]
26951 !! html/php
26952 <p><a href="/wiki/Foo" title="Foo">Foobar]</a>
26953 <a href="/wiki/Foo" title="Foo">x [http://google.com g] x</a>
26954 <a href="/wiki/Foo" title="Foo">[[Bar]]</a>
26955 <a href="/wiki/Foo" title="Foo">x [[Bar]] x</a>
26956 <a href="/wiki/Foo" title="Foo">|Bar</a>
26957 <a href="/wiki/Foo" title="Foo">]]bar</a>
26958 <a href="/wiki/Foo" title="Foo">[[bar</a>
26959 <a href="/wiki/Foo" title="Foo">x [[ y</a>
26960 <a href="/wiki/Foo" title="Foo">x ]] y</a>
26961 <a href="/wiki/Foo" title="Foo">x ]] y [[ z</a>
26962 </p>
26963 !! end
26964
26965 !! test
26966 Links 3. WikiLinks: No escapes needed
26967 !! options
26968 parsoid=html2wt
26969 !! html/parsoid
26970 <p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
26971 <a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
26972 !! wikitext
26973 [[Foo|[Foobar]]
26974 [[Foo|foo|bar]]
26975 !! html/php
26976 <p><a href="/wiki/Foo" title="Foo">[Foobar</a>
26977 <a href="/wiki/Foo" title="Foo">foo|bar</a>
26978 </p>
26979 !! end
26980
26981 !! test
26982 Links 4. ExtLinks: Escapes needed
26983 !! options
26984 parsoid=html2wt
26985 !! html/parsoid
26986 <p><a rel="mw:ExtLink" href="http://google.com">[google]</a>
26987 <a rel="mw:ExtLink" href="http://google.com">google]</a>
26988 <a rel="mw:ExtLink" href="http://google.com">goog] le</a></p>
26989 <p>[http://google.com]</p>
26990 <p>[http://google.com google]</p>
26991 <p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p>
26992 <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>
26993 !! wikitext
26994 [http://google.com <nowiki>[google]</nowiki>]
26995 [http://google.com <nowiki>google]</nowiki>]
26996 [http://google.com <nowiki>goog] le</nowiki>]
26997
26998 <nowiki>[http://google.com]</nowiki>
26999
27000 <nowiki>[http://google.com google]</nowiki>
27001
27002 [http://google.com<nowiki>]</nowiki>
27003
27004 [{{echo|http://google.com}}<nowiki>]</nowiki>
27005 !! html/php
27006 <p><a rel="nofollow" class="external text" href="http://google.com">[google]</a>
27007 <a rel="nofollow" class="external text" href="http://google.com">google]</a>
27008 <a rel="nofollow" class="external text" href="http://google.com">goog] le</a>
27009 </p><p>[http://google.com]
27010 </p><p>[http://google.com google]
27011 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
27012 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
27013 </p>
27014 !! end
27015
27016 !! test
27017 Links 5. ExtLinks: No escapes needed
27018 !! options
27019 parsoid=html2wt
27020 !! html/parsoid
27021 <p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
27022 <p>[<a ref="mw:ExtLink" href="http://google.com"></a>]</p>
27023 !! wikitext
27024 [http://google.com [google]
27025
27026 [[http://google.com]]
27027 !! html/php
27028 <p><a rel="nofollow" class="external text" href="http://google.com">[google</a>
27029 </p><p>[<a rel="nofollow" class="external autonumber" href="http://google.com">[1]</a>]
27030 </p>
27031 !! end
27032
27033 !! test
27034 Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300)
27035 !! options
27036 parsoid=html2wt
27037 !! html/parsoid
27038 <p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y
27039 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>?x
27040 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>&amp;x
27041 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>'x
27042 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,x
27043 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.x
27044 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
27045 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>:x
27046 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
27047 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>!x
27048 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>=x
27049 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>(x)
27050 <a rel="mw:ExtLink" href="http://example.com(x" data-parsoid='{"stx":"url"}'>http://example.com(x</a>)
27051 </p>
27052 !! wikitext
27053 x<nowiki/>http://example.com<nowiki/>y
27054 http://example.com<nowiki/>?x
27055 http://example.com<nowiki/>&x
27056 http://example.com<nowiki/>'x
27057 http://example.com<nowiki/>,x
27058 http://example.com<nowiki/>.x
27059 http://example.com<nowiki/>;x
27060 http://example.com<nowiki/>:x
27061 http://example.com<nowiki/>;x
27062 http://example.com<nowiki/>!x
27063 http://example.com<nowiki/>=x
27064 http://example.com<nowiki/>(x)
27065 http://example.com(x<nowiki/>)
27066 !! end
27067
27068 !! test
27069 Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
27070 !! options
27071 parsoid=html2wt
27072 !! html/parsoid
27073 <p>x
27074 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>
27075 y
27076 "<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>"
27077 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>)
27078 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>) foo
27079 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,
27080 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, foo
27081 </p>
27082 !! wikitext
27083 x
27084 http://example.com
27085 y
27086 "http://example.com"
27087 (http://example.com)
27088 (http://example.com) foo
27089 http://example.com,
27090 http://example.com, foo
27091 !! html/php
27092 <p>x
27093 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
27094 y
27095 "<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>"
27096 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
27097 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) foo
27098 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
27099 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, foo
27100 </p>
27101 !! end
27102
27103 !! test
27104 Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
27105 !! options
27106 parsoid=html2wt
27107 !! html/parsoid
27108 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\
27109 -<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p>
27110 !! wikitext
27111 http://example.com.,;:!?\
27112 -http://example.com:
27113 !! html/php
27114 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.,;:!?\
27115 -<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
27116 </p>
27117 !! end
27118
27119 !! test
27120 Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
27121 !! options
27122 parsoid=html2wt
27123 !! html/parsoid
27124 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
27125 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
27126 X<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
27127 !! wikitext
27128 RFC 123<nowiki/>4
27129 RFC 123<nowiki/>y
27130 X<nowiki/>RFC 123<nowiki/>y
27131 !! end
27132
27133 !! test
27134 Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
27135 !! options
27136 parsoid=html2wt
27137 !! html/parsoid
27138 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
27139 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
27140 -<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
27141 </p>
27142 !! wikitext
27143 RFC 123?foo
27144 RFC 123&foo
27145 -RFC 123-
27146 !! html/php
27147 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>?foo
27148 <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
27149 -<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>-
27150 </p>
27151 !! end
27152
27153 !! test
27154 Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300)
27155 !! options
27156 parsoid=html2wt
27157 !! html/parsoid
27158 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4
27159 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
27160 X<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
27161 !! wikitext
27162 PMID 123<nowiki/>4
27163 PMID 123<nowiki/>y
27164 X<nowiki/>PMID 123<nowiki/>y
27165 !! end
27166
27167 !! test
27168 Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300)
27169 !! options
27170 parsoid=html2wt
27171 !! html/parsoid
27172 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo
27173 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo
27174 -<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>-
27175 </p>
27176 !! wikitext
27177 PMID 123?foo
27178 PMID 123&foo
27179 -PMID 123-
27180 !! html/php
27181 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>?foo
27182 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>&amp;foo
27183 -<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>-
27184 </p>
27185 !! end
27186
27187 !! test
27188 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300)
27189 !! options
27190 parsoid=html2wt
27191 !! html/parsoid
27192 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
27193 <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
27194 a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
27195 </p>
27196 !! wikitext
27197 ISBN 1234567890<nowiki/>1
27198 ISBN 1234567890<nowiki/>x
27199 a<nowiki/>ISBN 1234567890<nowiki/>b
27200 !! end
27201
27202 !! test
27203 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (T66300)
27204 !! options
27205 parsoid=html2wt
27206 !! html/parsoid
27207 <p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
27208 !! wikitext
27209 -ISBN 1234567890's
27210 !! html/php
27211 <p>-<a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>'s
27212 </p>
27213 !! end
27214
27215 !! test
27216 Links 14. Protect link-like plain text. (Parsoid bug T78425)
27217 !! options
27218 parsoid=html2wt
27219 !! html/*
27220 <p>this is not a link: http://example.com
27221 </p>
27222 !! wikitext
27223 this is not a link: <nowiki>http://example.com</nowiki>
27224 !! end
27225
27226 !! test
27227 Links 15. Link trails can't become link prefixes.
27228 !! options
27229 language=is
27230 parsoid=html2wt
27231 !! html/parsoid
27232 <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>
27233 !! wikitext
27234 [[Söfnuður]]-[[00]]
27235 !! html/php
27236 <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>
27237 </p>
27238 !! end
27239
27240 #### --------------- Quotes ---------------
27241 #### 1. Quotes inside <b> and <i>
27242 #### 2. Link fragments separated by <i> and <b> tags
27243 #### 3. Link fragments inside <i> and <b>
27244 #### 4. No escaping needed
27245 #### --------------------------------------
27246 !! test
27247 1a. Quotes inside <b> and <i>
27248 !! options
27249 parsoid=html2wt
27250 !! html/*
27251 <p><i>'foo'</i>
27252 <i>''foo''</i>
27253 <i>'''foo'''</i>
27254 <i>foo</i>'s
27255 <b>'foo'</b>
27256 <b>''foo''</b>
27257 <b>'''foo'''</b>
27258 <b>foo'<i>bar'</i>baz</b>
27259 <b>foo</b>'s
27260 '<i>foo</i>
27261 <i>foo</i>'
27262 <i>foo'</i>'
27263 '<i>foo</i>'
27264 '<b>foo</b>
27265 <b>foo</b>'
27266 '<b>foo</b>'
27267 <i>fools'<span> errand</span></i>
27268 <i><span>fool</span>'s errand</i>
27269 '<i>foo</i> bar '<i>baz</i>
27270 a|!*#-:;+-~[]{}b'<i>x</i>
27271 </p>
27272 !! wikitext
27273 ''<nowiki/>'foo'''
27274 ''<nowiki>''foo''</nowiki>''
27275 ''<nowiki>'''foo'''</nowiki>''
27276 ''foo''<nowiki/>'s
27277 '''<nowiki/>'foo''''
27278 '''<nowiki>''foo''</nowiki>'''
27279 '''<nowiki>'''foo'''</nowiki>'''
27280 '''foo'<nowiki/>''bar'<nowiki/>''baz'''
27281 '''foo'''<nowiki/>'s
27282 '''foo''
27283 ''foo''<nowiki/>'
27284 ''foo'''<nowiki/>'
27285 '''foo''<nowiki/>'
27286 ''''foo'''
27287 '''foo'''<nowiki/>'
27288 ''''foo'''<nowiki/>'
27289 ''fools'<span> errand</span>''
27290 ''<span>fool</span>'s errand''
27291 '<nowiki/>''foo'' bar '''baz''
27292 a|!*#-:;+-~[]{}b'''x''
27293 !! end
27294
27295 !! test
27296 1b. Quotes inside <b> and <i> with other tags on same line
27297 !! options
27298 parsoid=html2wt
27299 !! html/parsoid
27300 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
27301 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
27302 <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>
27303 <a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" rel="mw:WikiLink" title="Bar">bar</a></i>
27304 '<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>
27305 '<i>foo</i> <div title="name">test</div>
27306 '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
27307 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
27308 <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>
27309 </ol>
27310 !! wikitext
27311 '''a'' foo ''[[bar]]''
27312 ''a''' foo ''[[bar]]''
27313 ''a''' foo '''{{echo|[[bar]]}}'''
27314 [[foo]] x'''[[bar]]''
27315 '''foo'' <ref>test</ref>
27316 '''foo'' <div title="name">test</div>
27317 '''foo'' and <br> bar
27318 <references />
27319 !! end
27320
27321 !! test
27322 2. Link fragments separated by <i> and <b> tags
27323 !! options
27324 parsoid=html2wt
27325 !! html/parsoid
27326 <p>[[<i>foo</i>hello]]</p>
27327 <p>[[<b>foo</b>hello]]</p>
27328 !! wikitext
27329 [[''foo''<nowiki>hello]]</nowiki>
27330
27331 [['''foo'''<nowiki>hello]]</nowiki>
27332 !! end
27333
27334 # FIXME: Escaping one or both of [[ and ]] is also acceptable --
27335 # this is one of the shortcomings of this format
27336 !! test
27337 3. Link fragments inside <i> and <b>
27338 !! options
27339 parsoid=html2wt
27340 !! html/parsoid
27341 <p><i>[[foo</i>]]</p>
27342 <p><b>[[foo</b>]]</p>
27343 !! wikitext
27344 ''[[foo''<nowiki>]]</nowiki>
27345
27346 '''[[foo'''<nowiki>]]</nowiki>
27347 !! end
27348
27349 !! test
27350 4. No escaping needed
27351 !! options
27352 parsoid=html2wt
27353 !! html/parsoid
27354 <p>'<span><i>bar</i></span>'
27355 '<span><b>bar</b></span>'
27356 'a:b'foo
27357 </p>
27358 !! wikitext
27359 '<span>''bar''</span>'
27360 '<span>'''bar'''</span>'
27361 'a:b'foo
27362 !! end
27363
27364 #### ----------- Paragraphs ---------------
27365 #### 1. No unnecessary escapes
27366 #### --------------------------------------
27367
27368 !! test
27369 1. No unnecessary escapes
27370 !! options
27371 parsoid=html2wt
27372 !! html/parsoid
27373 <p>bar <span>[[foo]]</span>
27374 </p><p>=bar <span>[[foo]]</span>
27375 </p><p>[[bar <span>[[foo]]</span>
27376 </p><p>]]bar <span>[[foo]]</span>
27377 </p><p>=bar <span>foo]]</span>=
27378 </p>
27379 !! wikitext
27380 bar <span><nowiki>[[foo]]</nowiki></span>
27381
27382 =bar <span><nowiki>[[foo]]</nowiki></span>
27383
27384 [[bar <span><nowiki>[[foo]]</nowiki></span>
27385
27386 ]]bar <span><nowiki>[[foo]]</nowiki></span>
27387
27388 =bar <span>foo]]</span><nowiki>=</nowiki>
27389 !!end
27390
27391 #### ----------------------- PRE --------------------------
27392 !! test
27393 1. Leading whitespace in SOL context should be escaped
27394 !! options
27395 parsoid=html2wt
27396 !! html/parsoid
27397 <p> a</p>
27398
27399 <p> a</p>
27400
27401 <p> a(tab)</p>
27402
27403 <p> a
27404 <!--cmt-->
27405 a</p>
27406
27407 <p>a
27408 b</p>
27409
27410 <p>a
27411 b</p>
27412
27413 <p>a
27414 b</p>
27415 !! wikitext
27416 <nowiki> </nowiki>a
27417
27418 <nowiki> </nowiki> a
27419
27420 a(tab)
27421
27422 <nowiki> </nowiki> a
27423 <!--cmt-->
27424 <nowiki> </nowiki>a
27425
27426 a
27427 <nowiki> </nowiki>b
27428
27429 a
27430 b
27431
27432 a
27433 b
27434 !! html/php
27435 <p> a
27436 </p><p> a
27437 </p><p> a(tab)
27438 </p><p> a
27439 a
27440 </p><p>a
27441 b
27442 </p><p>a
27443 b
27444 </p><p>a
27445 b
27446 </p>
27447 !! end
27448
27449 !! test
27450 2. Leading whitespace in non-indent-pre contexts should not be escaped
27451 !! options
27452 parsoid=html2wt
27453 !! html/parsoid
27454 <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>
27455 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
27456 <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>
27457 b</span></li>
27458 </ol>
27459 !! wikitext
27460 foo <ref>''a''
27461 b</ref>
27462 <references />
27463 !! end
27464
27465 !! test
27466 3. Leading whitespace in indent-pre suppressing contexts should not be escaped
27467 !! options
27468 parsoid=html2wt
27469 !! html/parsoid
27470 <blockquote>
27471 <p>
27472 a
27473 <span>b</span>
27474 c</p>
27475 </blockquote>
27476 !! wikitext
27477 <blockquote>
27478 a
27479 <span>b</span>
27480 c
27481 </blockquote>
27482 !! end
27483
27484 !! test
27485 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
27486 !! options
27487 parsoid=html2wt
27488 !! html/parsoid
27489 <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>
27490 !! wikitext
27491 [[File:Foobar.jpg|thumb|caption]]
27492 !! end
27493
27494 !! test
27495 5. Nowiki escaping should account for indent-pres
27496 !! options
27497 parsoid=html2wt
27498 !! html/parsoid
27499 <pre>==foo==</pre>
27500 !! wikitext
27501 ==foo==
27502 !! end
27503
27504 !! test
27505 T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
27506 !! options
27507 parsoid=html2wt
27508 !! html/parsoid
27509 <pre>
27510 * foo
27511 * bar
27512 </pre>
27513 !! wikitext
27514 * foo
27515 * bar
27516 !! end
27517
27518 !! test
27519 Whitespace scrubbing in SOL position should account for SOL-sensitive wikitext markup
27520 !! options
27521 parsoid = {
27522 "modes": ["html2wt"],
27523 "scrubWikitext": true
27524 }
27525 !! html/parsoid
27526 <p> foo</p>
27527 <p> %foo</p>
27528 <p> *foo</p>
27529 <p> #foo</p>
27530 <p> =foo=</p>
27531 <p><link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid="{}"> *foo</p>
27532 <p> <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid="{}">*foo</p>
27533 <p> <!--boo-->*foo</p>
27534 <p><!--boo--> *foo</p>
27535 <p><!--a--> <!--b--> <!--c--> <!--d--> <!--e--> foo</p>
27536 <p><!--a--> <!--b--> <!--c--> <!--d--> <!--e--> *foo</p>
27537 !! wikitext
27538 foo
27539
27540 %foo
27541
27542 <nowiki/>*foo
27543
27544 <nowiki/>#foo
27545
27546 <nowiki/>=foo=
27547
27548 [[Category:Foo]]
27549 <nowiki/>*foo
27550
27551 [[Category:Foo]]
27552 <nowiki>*</nowiki>foo
27553
27554 <nowiki/><!--boo-->*foo
27555
27556 <!--boo--><nowiki/>*foo
27557
27558 <!--a--><!--b--><!--c--><!--d--><!--e-->foo
27559
27560 <!--a--><nowiki/><!--b--><!--c--><!--d--><!--e-->*foo
27561 !! end
27562
27563 #### --------------- Behavior Switches --------------------
27564
27565 !! test
27566 1. Valid behavior switches should be escaped
27567 !! options
27568 parsoid=html2wt
27569 !! html/parsoid
27570 __TOC__
27571 <i>__TOC__</i>
27572 !! wikitext
27573 <nowiki>__TOC__</nowiki>
27574 ''<nowiki>__TOC__</nowiki>''
27575 !! end
27576
27577 !! test
27578 2. Invalid behavior switches should not be escaped
27579 !! options
27580 parsoid=html2wt
27581 !! html/parsoid
27582 __TOO__
27583 __|__
27584 !! wikitext
27585 __TOO__
27586 __|__
27587 !! end
27588
27589 # We use indent-pre as an indirect way to test for sol-transparent behavior.
27590 !! test
27591 Behavior switches should be SOL-transparent
27592 !! options
27593 parsoid=html2wt
27594 !! html/parsoid
27595 <meta property="mw:PageProp/toc" />
27596
27597 <!-- this one's bogus -->
27598 <pre>__TOO__</pre>
27599
27600 <pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre>
27601
27602 <meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre>
27603 !! wikitext
27604 __TOC__
27605
27606 <!-- this one's bogus -->
27607 __TOO__
27608
27609 __TOC__ foo
27610
27611 __TOC__
27612 bar
27613 !! end
27614
27615 #### --------------- HTML tags ---------------
27616 #### 1. a tags
27617 #### 2. other tags
27618 #### 3. multi-line html tag
27619 #### 4. extension tags
27620 #### -----------------------------------------
27621 !! test
27622 1. a tags
27623 !! options
27624 parsoid=html2wt
27625 !! html/parsoid
27626 &lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
27627 !! wikitext
27628 <a href="http://google.com">google</a>
27629 !! end
27630
27631 !! test
27632 2. other tags
27633 !! options
27634 parsoid=html2wt
27635 !! html/parsoid
27636 <ul><li> &lt;div&gt;foo&lt;/div&gt;</li>
27637 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
27638 <li> &lt;td&gt;</li></ul>
27639
27640 !! wikitext
27641 * <nowiki><div>foo</div></nowiki>
27642 * <nowiki><div style="color:red">foo</div></nowiki>
27643 * <nowiki><td></nowiki>
27644 !! end
27645
27646 !! test
27647 3. multi-line html tag
27648 !! options
27649 parsoid=html2wt
27650 !! html/parsoid
27651 <p>&lt;div
27652 &gt;foo&lt;/div
27653 &gt;
27654 </p>
27655 !! wikitext
27656 <nowiki><div
27657 >foo</div
27658 ></nowiki>
27659 !! end
27660
27661 !! test
27662 4. extension tags
27663 !! options
27664 parsoid=html2wt
27665 !! html/parsoid
27666 <p>&lt;ref&gt;foo&lt;/ref&gt;
27667 </p><p>&lt;ref&gt;bar
27668 </p><p>baz&lt;/ref&gt;
27669 </p>
27670 !! wikitext
27671 <nowiki><ref>foo</ref></nowiki>
27672
27673 <nowiki><ref>bar</nowiki>
27674
27675 baz<nowiki></ref></nowiki>
27676 !! end
27677
27678 !! test
27679 Parsoid: newline inducing block nodes don't suppress <nowiki>
27680 !! options
27681 parsoid=html2wt
27682 !! html/parsoid
27683 a<h1>foo</h1>
27684 !! wikitext
27685 <nowiki> </nowiki>a
27686
27687 = foo =
27688 !! end
27689
27690 #### --------------- Others ---------------
27691 !! test
27692 Escaping nowikis
27693 !! options
27694 parsoid=html2wt
27695 !! html/parsoid
27696 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
27697 </p>
27698 !! wikitext
27699 &lt;nowiki&gt;foo&lt;/nowiki&gt;
27700 !! end
27701
27702 ## The quote-char in the input is necessary for triggering the bug
27703 !! test
27704 (T54035) Nowiki-escaping should not get tripped by " :" in text
27705 !! options
27706 parsoid=html2wt
27707 !! html/parsoid
27708 <p>foo's bar :</p>
27709 !! wikitext
27710 foo's bar :
27711 !! end
27712
27713 #----------- End of wikitext escaping tests --------------
27714
27715 !! test
27716
27717 Tag-like HTML structures are passed through as text
27718 !! wikitext
27719 <x y>
27720
27721 <x.y>
27722
27723 <x-y>
27724
27725 1>2
27726
27727 x<y
27728
27729 a>b
27730
27731 1<d e>f
27732 !! html
27733 <p>&lt;x y&gt;
27734 </p><p>&lt;x.y&gt;
27735 </p><p>&lt;x-y&gt;
27736 </p><p>1&gt;2
27737 </p><p>x&lt;y
27738 </p><p>a&gt;b
27739 </p><p>1&lt;d e&gt;f
27740 </p>
27741 !! end
27742
27743 !! test
27744 HTML tag with necessary entities in attributes
27745 !! wikitext
27746 <span title="&amp;amp;">foo</span>
27747 !! html
27748 <p><span title="&amp;amp;">foo</span>
27749 </p>
27750 !! end
27751
27752 !! test
27753 HTML tag with 'unnecessary' entity encoding in attributes
27754 !! wikitext
27755 <span title="&amp;">foo</span>
27756 !! html
27757 <p><span title="&amp;">foo</span>
27758 </p>
27759 !! end
27760
27761 !! test
27762 HTML tag with broken attribute value quoting
27763 !! options
27764 parsoid=wt2html,html2html
27765 !! wikitext
27766 <span title="Hello world>Foo</span>
27767 !! html/php
27768 <p><span title="Hello world">Foo</span>
27769 </p>
27770 !! html/parsoid
27771 <p><span title="Hello world">Foo</span></p>
27772 !! end
27773
27774 !! test
27775 Self-closed tag with broken attribute value quoting
27776 !! options
27777 parsoid=wt2html,html2html
27778 !! wikitext
27779 <div title="Hello world />Foo
27780 !! html/php+tidy
27781 <div title="Hello world"></div><p>Foo
27782 </p>
27783 !! html/parsoid
27784 <div title="Hello world " data-parsoid='{"stx":"html","selfClose":true}'></div><p>Foo</p>
27785 !! end
27786
27787 !! test
27788 Table with broken attribute value quoting
27789 !! options
27790 parsoid=wt2html,html2html
27791 !! wikitext
27792 {|
27793 | title="Hello world|Foo
27794 |}
27795 !! html/php
27796 <table>
27797 <tr>
27798 <td title="Hello world">Foo
27799 </td></tr></table>
27800
27801 !! html/parsoid
27802 <table>
27803 <tr>
27804 <td title="Hello world">Foo
27805 </td></tr></table>
27806
27807 !! end
27808
27809 !! test
27810 Table with broken attribute value quoting on consecutive lines
27811 !! options
27812 parsoid=wt2html,html2html
27813 !! wikitext
27814 {|
27815 | title="Hello world|Foo
27816 | style="color:red|Bar
27817 |}
27818 !! html/php
27819 <table>
27820 <tr>
27821 <td title="Hello world">Foo
27822 </td>
27823 <td style="color:red">Bar
27824 </td></tr></table>
27825
27826 !! html/parsoid
27827 <table><tbody>
27828 <tr>
27829 <td title="Hello world">Foo
27830 </td><td style="color: red">Bar
27831 </td></tr></tbody></table>
27832
27833 !! end
27834
27835 !!test
27836 Accept empty td cell attribute
27837 !! wikitext
27838 {|
27839 | align="center" |foo|| |
27840 |}
27841 !! html
27842 <table>
27843 <tr>
27844 <td align="center">foo</td>
27845 <td>
27846 </td></tr></table>
27847
27848 !!end
27849
27850 !!test
27851 Non-empty attributes in th-cells
27852 !! wikitext
27853 {|
27854 !Foo!! style="color: red" |Bar
27855 |}
27856 !! html
27857 <table>
27858 <tr>
27859 <th>Foo</th>
27860 <th style="color: red">Bar
27861 </th></tr></table>
27862
27863 !!end
27864
27865 !!test
27866 Accept empty attributes in th-cells
27867 !! wikitext
27868 {|
27869 !|foo!!|bar
27870 |}
27871 !! html
27872 <table>
27873 <tr>
27874 <th>foo</th>
27875 <th>bar
27876 </th></tr></table>
27877
27878 !!end
27879
27880 !!test
27881 Empty table rows go away
27882 !! wikitext
27883 {|
27884 |Hello
27885 |there
27886 |- class="foo"
27887 |-
27888 |}
27889 !! html
27890 <table>
27891 <tr>
27892 <td>Hello
27893 </td>
27894 <td>there
27895 </td></tr>
27896
27897 </table>
27898
27899 !! end
27900
27901 ###
27902 ### Parsoid-centric tests for testing RTing of inter-element separators
27903 ### Edge cases not tested by existing parser tests and specific to
27904 ### Parsoid-specific serialization strategies.
27905 ###
27906
27907 !!test
27908 RT-ed inter-element separators should be valid separators
27909 !! wikitext
27910 {|
27911 |- [[foo]]
27912 |}
27913 !! html/php
27914 <table>
27915
27916 </table>
27917
27918 !! html/parsoid
27919 <table>
27920 <tbody><tr class='mw-empty-elt' data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
27921 </tbody></table>
27922 !!end
27923
27924 # Parsoid-only test of a DOM pass
27925 !!test
27926 Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out
27927 !! wikitext
27928 {|
27929 |<small>foo
27930 bar
27931 |}
27932
27933 {|
27934 |<small>foo<small>
27935 |}
27936 !! html/parsoid
27937 <table>
27938 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo
27939 <p>bar</p></small></td></tr>
27940 </tbody></table>
27941
27942 <table>
27943 <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>
27944 </tbody></table>
27945 !!end
27946
27947 # Note that the "style" attribute is really a template parameter here.
27948 # The = would have to be {{=}} if you wanted the literal.
27949 !!test
27950 Empty TD followed by TD with tpl-generated attribute
27951 !! wikitext
27952 {|
27953 |-
27954 |
27955 |{{echo|style='color:red'}}|foo
27956 |}
27957 !! html
27958 <table>
27959
27960 <tr>
27961 <td>
27962 </td>
27963 <td>foo
27964 </td></tr></table>
27965
27966 !!end
27967
27968 !!test
27969 Indented table with an empty td
27970 !! wikitext
27971 {|
27972 |-
27973 |
27974 |foo
27975 |}
27976 !! html
27977 <table>
27978
27979 <tr>
27980 <td>
27981 </td>
27982 <td>foo
27983 </td></tr></table>
27984
27985 !!end
27986
27987 !! test
27988 Indented table with blank lines in between (T85627)
27989 !! wikitext
27990 {|
27991 |foo
27992
27993
27994 |}
27995 !! html/php
27996 <table>
27997 <tr>
27998 <td>foo
27999 <p><br />
28000 </p>
28001 </td></tr></table>
28002
28003 !! html/parsoid
28004 <table>
28005 <tbody><tr><td>foo
28006 <p>
28007 <br /></p></td></tr>
28008 </tbody></table>
28009 !! end
28010
28011 !!test
28012 Indented block & table
28013 !! wikitext
28014 <div>foo</div>
28015 {|
28016 |foo
28017 |}
28018 !! html/php
28019 <div>foo</div>
28020 <table>
28021 <tr>
28022 <td>foo
28023 </td></tr></table>
28024
28025 !! html/parsoid
28026 <div data-parsoid='{"stx":"html"}'>foo</div>
28027 <table><tbody>
28028 <tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>foo</td></tr>
28029 </tbody></table>
28030 !!end
28031
28032 !! test
28033 Indent and comment before table row
28034 !! wikitext
28035 {|
28036 <!--hi-->|-
28037 |there
28038 |}
28039 !! html/php
28040 <table>
28041
28042 <tr>
28043 <td>there
28044 </td></tr></table>
28045
28046 !! html/parsoid
28047 <table>
28048 <!--hi--><tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
28049 <td data-parsoid='{"autoInsertedEnd":true}'> there</td></tr>
28050 </tbody></table>
28051 !! end
28052
28053 # PHP parser omits empty TR
28054 !!test
28055 Empty TR followed by a template-generated TR
28056 !! wikitext
28057 {|
28058 |-
28059 {{echo|<tr><td>foo</td></tr>}}
28060 |}
28061 !! html/php+tidy
28062 <table>
28063
28064 <tbody><tr><td>foo</td></tr>
28065 </tbody></table>
28066 !! html/parsoid
28067 <table>
28068 <tbody>
28069 <tr class='mw-empty-elt'></tr>
28070 <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}}]}'>
28071 <td>foo</td></tr>
28072 </tbody></table>
28073 !!end
28074
28075 ## PHP and parsoid output differ for this; as usual PHP omits empty
28076 ## elements, and since it strips the comments the TR is empty.
28077 !!test
28078 Empty TR followed by mixed-ws-comment line should RT correctly
28079 !! wikitext
28080 {|
28081 |-
28082 <!--c-->
28083 |-
28084 <!--c--> <!--d-->
28085 |}
28086 !! html/php+tidy
28087 <table>
28088
28089
28090 </table>
28091 !! html/parsoid
28092 <table>
28093 <tbody>
28094 <tr class='mw-empty-elt'></tr>
28095 <!--c-->
28096 <tr>
28097 <!--c--> </tr><!--d-->
28098 </tbody></table>
28099
28100 !!end
28101
28102 !!test
28103 Multi-line image caption generated by templates with/without trailing newlines
28104 !! wikitext
28105 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]]
28106 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]]
28107 !! html/parsoid
28108 <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>
28109 <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>
28110 !!end
28111
28112 !! test
28113 New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly
28114 !! options
28115 parsoid=html2wt
28116 !! html/parsoid
28117 <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>
28118
28119 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{}'/><h1>new heading</h1>
28120 !! wikitext
28121 <includeonly>foo</includeonly>
28122 new para
28123
28124 [[Category:Foo]]
28125
28126 = new heading =
28127 !! end
28128
28129 ## PHP emits broken html for this, and since this is primarily
28130 ## a Parsoid serializer test, marking this Parsoid only
28131 !!test
28132 Improperly nested inline or quotes tags with whitespace in between
28133 !! wikitext
28134 <span> <s>x</span> </s>
28135 ''' ''x''' ''
28136 !! html/parsoid
28137 <p><span> <s>x</s></span><s> </s>
28138 <b> <i>x</i></b><i> </i>
28139 </p>
28140 !!end
28141
28142 !!test
28143 Encapsulate protected attributes from wt
28144 !! wikitext
28145 <div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
28146
28147 {| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true"
28148 |ok
28149 |}
28150 !! html/parsoid
28151 <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>
28152
28153 <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">
28154 <tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'>ok</td></tr>
28155 </tbody></table>
28156 !!end
28157
28158 ## Currently the p-wrapper is fragile in how it adds / removes transformations.
28159 ## Having nested or stray pre tags results in the attempt to add duplicates,
28160 ## causing an assertion fail. This test tries to prevent that situation.
28161 !! test
28162 Ensure ParagraphWrapper can deal with stray closing pre tags
28163 !! options
28164 parsoid=wt2html
28165 !! wikitext
28166 plain text</pre>
28167 !! html/parsoid
28168 <p>plain text</p>
28169 !! end
28170
28171 ## Remex doesn't account for fostered content.
28172 !! test
28173 1. Ensure fostered text content is wrapped in element nodes
28174 !! options
28175 parsoid=wt2html
28176 !! wikitext
28177 <table>hi</table><table>ho</table>
28178 !! html/php+tidy
28179 hi<table></table>ho<table></table>
28180 !! html/parsoid
28181 <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>
28182 !! end
28183
28184 ## Remex doesn't account for fostered content.
28185 !! test
28186 2. Ensure fostered text content is wrapped in element nodes (traps regressions around fostered marker on the element getting lost)
28187 !! options
28188 parsoid=wt2html,wt2wt
28189 !! wikitext
28190 <table>
28191 <tr> || ||
28192 <td> a
28193 </table>
28194 !! html/php+tidy
28195 || ||
28196 <table>
28197 <tbody><tr><td> a
28198 </td></tr></tbody></table>
28199 !! html/parsoid
28200 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'> || ||</p>
28201 <table data-parsoid='{"stx":"html"}'>
28202 <tbody><tr data-parsoid='{"stx":"html","autoInsertedEnd":true}'><td data-parsoid='{"stx":"html","autoInsertedEnd":true}'> a
28203 </td></tr></tbody></table>
28204 !! end
28205
28206 ## Remex doesn't account for fostered content.
28207 !! test
28208 Encapsulation properly handles null DSR information from foster box
28209 !! options
28210 parsoid=wt2html,wt2wt
28211 !! wikitext
28212 {{echo|<table>foo<tr><td>bar</td></tr></table>}}
28213 !! html/parsoid
28214 <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>
28215 !! end
28216
28217 ## Remex doesn't account for fostered content.
28218 !! test
28219 1. Encapsulate foster-parented transclusion content
28220 !! options
28221 parsoid=wt2wt,wt2html
28222 !! wikitext
28223 <table>{{echo|foo<tr><td>bar</td></tr>}}</table>
28224 !! html/php+tidy
28225 foo<table><tbody><tr><td>bar</td></tr></tbody></table>
28226 !! html/parsoid
28227 <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>
28228 !! end
28229
28230 !! test
28231 2. Encapsulate foster-parented transclusion content
28232 !! options
28233 parsoid=wt2wt,wt2html
28234 !! wikitext
28235 <table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table>
28236 !! html/parsoid
28237 <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>
28238 <table>
28239 <tbody>
28240 <tr>
28241 <td>bar</td>
28242 </tr>
28243 </tbody>
28244 </table>
28245 !! end
28246
28247 !! test
28248 3. Encapsulate foster-parented transclusion content
28249 !! options
28250 parsoid=wt2wt,wt2html
28251 !! wikitext
28252 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
28253 !! html/parsoid
28254 <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;]}">
28255 <p>foo</p>
28256 </div>
28257 <table>
28258 <tbody>
28259 <tr>
28260 <td>bar</td>
28261 </tr>
28262 </tbody>
28263 </table>
28264 !! end
28265
28266 !! test
28267 4. Encapsulate foster-parented transclusion content
28268 !! options
28269 parsoid=wt2wt,wt2html
28270 !! wikitext
28271 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
28272 !! html/parsoid
28273 <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;]}">
28274 <p>foo</p>
28275 </div>
28276 <table>
28277 <tbody>
28278 <tr>
28279 <td>bar</td>
28280 </tr>
28281 </tbody>
28282 </table>
28283 !! end
28284
28285 ## Remex doesn't account for fostered content.
28286 !! test
28287 5. Encapsulate foster-parented transclusion content
28288 !!options
28289 parsoid=wt2wt,wt2html
28290 !! wikitext
28291 <table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table>
28292 !! html/php+tidy
28293 foo<table><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table>
28294 !! html/parsoid
28295 <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>
28296 !! end
28297
28298 ## Remex doesn't account for fostered content.
28299 !! test
28300 6. Encapsulate foster-parented transclusion content
28301 !! options
28302 parsoid=wt2wt,wt2html
28303 !! wikitext
28304 <table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p>
28305 !! html/php+tidy
28306 foo<table><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table><p>ok</p>
28307 !! html/parsoid
28308 <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>
28309 !! end
28310
28311 !! test
28312 7. Encapsulate foster-parented transclusion content
28313 !!options
28314 parsoid=wt2wt,wt2html
28315 !! wikitext
28316 <table>{{echo|<p>foo</p>}}<td>bar</td></table>
28317 !! html/parsoid
28318 <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>
28319 <table>
28320 <tbody>
28321 <tr>
28322 <td>bar</td>
28323 </tr>
28324 </tbody>
28325 </table>
28326 !! end
28327
28328 ## Remex doesn't account for fostered content.
28329 # Note that the wt is broken on purpose: the = should be {{=}} if you
28330 # don't want it to be a template parameter key.
28331 !! test
28332 8. Encapsulate foster-parented transclusion content
28333 !! options
28334 parsoid=wt2wt,wt2html
28335 !! wikitext
28336 {{echo|a
28337 }}{|{{echo|style='color:red'}}
28338 |-
28339 |b
28340 |}
28341 !! html/php+tidy
28342 <p>a
28343 </p>
28344 <table>
28345
28346 <tbody><tr>
28347 <td>b
28348 </td></tr></tbody></table>
28349 !! html/parsoid
28350 <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">
28351 </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">
28352 <tbody><tr>
28353 <td>b
28354 </td></tr></tbody></table>
28355 !! end
28356
28357 ## Remex doesn't account for fostered content.
28358 !! test
28359 9. Encapsulate foster-parented transclusion content
28360 !!options
28361 parsoid=wt2wt,wt2html
28362 !! wikitext
28363 <table>{{echo|hi</table>hello}}
28364 !! html/php+tidy
28365 hi<table></table><p>hello
28366 </p>
28367 !! html/parsoid
28368 <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>
28369 !! end
28370
28371 !! test
28372 Table in fosterable position
28373 !!options
28374 parsoid=wt2html
28375 !! wikitext
28376 {{OpenTable}}
28377 <div>
28378 {|
28379 |}
28380 </div>
28381 |}
28382 !! html/parsoid
28383 <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">
28384 </span>
28385 <table about="#mwt1" data-parsoid='{"autoInsertedEnd":true}'></table>
28386
28387 <table>
28388 </table>
28389 !! end
28390
28391 # Parsoid only for T66747
28392 !! test
28393 Properly encapsulate empty-content transclusions in fosterable positions
28394 !! wikitext
28395 <table>
28396 {{#if:|
28397 <td>foo</td>
28398 }}
28399 </table>
28400 !! html/parsoid
28401 <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"}]]}'>
28402
28403 </table>
28404 !! end
28405
28406 ## No longer captures its original intention
28407 !! test
28408 Always encapsulate foster box when template range is expanded to table
28409 !! options
28410 disabled
28411 parsoid=wt2wt
28412 !! wikitext
28413 {|
28414 hello
28415 {{OpenTable}}
28416 |}
28417 !! html/parsoid
28418
28419 !! end
28420
28421 !! test
28422 T115289: Unclosed table
28423 !! wikitext
28424 {{echo|<table>}}<!--c-->[[Category:Two]]
28425 !! html/parsoid
28426 <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>
28427 !! end
28428
28429 !! test
28430 T115289: Don't migrate newlines out of tables with fostered content
28431 !! wikitext
28432 <table><td></td>{{echo|<tr>[[Category:One]]}}<!--c-->[[Category:Two]]
28433 !! html/parsoid
28434 <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>
28435 !! end
28436
28437 !! test
28438 T73074: More fostering fun
28439 !! wikitext
28440 <table><td></td>{{echo|<tr>}}<!--c-->[[Category:Two]]
28441 !! html/parsoid
28442 <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>
28443 !! end
28444
28445 !!test
28446 Support <object> element with .data attribute
28447 !!options
28448 parsoid=html2wt
28449 !! html/parsoid
28450 <object data="test.swf"></object>
28451 !! wikitext
28452 <object data="test.swf"></object>
28453 !!end
28454
28455 !! test
28456 Don't block XML namespace declaration
28457 !! wikitext
28458 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span>
28459 !! html/php
28460 <p><span xmlns:dct="http&#58;//purl.org/dc/terms/" property="dct:title">MediaWiki</span>
28461 </p>
28462 !! html/parsoid
28463 <p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p>
28464 !! end
28465
28466 # -----------------------------------------------------------------
28467 # The following section of tests are primarily to spec requirements
28468 # around Parsoid's serialization (old, new, edited content)
28469 #
28470 # All these tests are marked Parsoid html2wt and html2html only
28471 # ----------------------------------------------------------------
28472
28473 !! test
28474 Ignore rel attribute in a-tags during serialization to url-links
28475 !! options
28476 parsoid=html2wt
28477 !! html/parsoid
28478 <a href='http://en.wikipedia.org/wiki/Foobar'>http://en.wikipedia.org/wiki/Foobar</a>
28479 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:ExtLink'>http://en.wikipedia.org/wiki/Foobar</a>
28480 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:WikiLink'>http://en.wikipedia.org/wiki/Foobar</a>
28481 !! wikitext
28482 http://en.wikipedia.org/wiki/Foobar
28483 http://en.wikipedia.org/wiki/Foobar
28484 http://en.wikipedia.org/wiki/Foobar
28485 !! end
28486
28487 # 'mi' is a localinterwiki prefix as well as a language
28488 !! test
28489 Serialize interwiki links pointing to the current wiki as plain wiki links (T67869)
28490 !! options
28491 parsoid=html2wt
28492 !! html/parsoid
28493 <p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p>
28494 !! wikitext
28495 [[Foo]]
28496 !! end
28497
28498 !! test
28499 Parsoid should accept interwiki shortcuts
28500 !! options
28501 parsoid=html2wt
28502 !! html/parsoid
28503 <p><a rel='mw:WikiLink' href='./fr:Foo'>Foo</a>
28504 <a rel='mw:ExtLink' href='./fr:Foo'>Foo</a>
28505 <a href='./fr:Foo'>Foo</a></p>
28506 <p><a rel='mw:WikiLink' href='fr%3AFoo'>Foo</a>
28507 <a rel='mw:ExtLink' href='fr%3AFoo'>Foo</a>
28508 <a href='fr%3AFoo'>Foo</a></p>
28509 <p><a href='FR%3AFoo'>Foo</a>
28510 <a href='./FR:Foo'>Foo</a></p>
28511 !! wikitext
28512 [[:fr:Foo|Foo]]
28513 [[:fr:Foo|Foo]]
28514 [[:fr:Foo|Foo]]
28515
28516 [[:fr:Foo|Foo]]
28517 [[:fr:Foo|Foo]]
28518 [[:fr:Foo|Foo]]
28519
28520 [[:fr:Foo|Foo]]
28521 [[:fr:Foo|Foo]]
28522 !! end
28523
28524 !! test
28525 Parsoid should not accept invalid interwiki shortcuts
28526 !! options
28527 parsoid=html2wt
28528 !! html/parsoid
28529 <p><a rel='mw:WikiLink' href='news:Foo'>Foo</a>
28530 <a rel='mw:ExtLink' href='news:Foo'>Foo</a>
28531 <a href='news:Foo'>Foo</a></p>
28532 !! wikitext
28533 [news:Foo Foo]
28534 [news:Foo Foo]
28535 [news:Foo Foo]
28536 !! end
28537
28538 # See T93839
28539 !! test
28540 New wikilinks should be serialized properly
28541 !! options
28542 parsoid=html2wt
28543 !! html/parsoid
28544 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
28545 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
28546 <a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a>
28547 <a href="http://en.wikipedia.org/wiki/Foo">http://en.wikipedia.org/wiki/Foo</a>
28548 <a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a>
28549 !! wikitext
28550 [[Foo]]
28551 [[Foo]]
28552 [[:en:Foo|//en.wikipedia.org/wiki/Foo]]
28553 http://en.wikipedia.org/wiki/Foo
28554 [[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]]
28555 !! end
28556
28557 !! test
28558 New wiki links (href variations)
28559 !! options
28560 parsoid=html2wt
28561 !! html/parsoid
28562 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
28563 <a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a>
28564 <a rel="mw:WikiLink" href="Foo bar">Foo_bar</a>
28565 <a rel="mw:WikiLink" href="./Toxine_bact%C3%A9rienne">Toxine bactérienne</a>
28566 !! wikitext
28567 [[Foo_bar]]
28568 [[Foo_bar]]
28569 [[Foo_bar]]
28570 [[Toxine bactérienne]]
28571 !! end
28572
28573 !! test
28574 New wiki links (content string variations)
28575 !! options
28576 parsoid=html2wt
28577 !! html/parsoid
28578 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
28579 <a rel="mw:WikiLink" href="./Foo_bar">Foo bar</a>
28580 <a rel="mw:WikiLink" href="./Foo_bar">./Foo_bar</a>
28581 !! wikitext
28582 [[Foo_bar]]
28583 [[Foo bar]]
28584 [[Foo_bar|./Foo_bar]]
28585 !! end
28586
28587 !! test
28588 New category links (href variations)
28589 !! options
28590 parsoid=html2wt
28591 !! html/parsoid
28592 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" />
28593 <link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" />
28594 <link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" />
28595 !! wikitext
28596 [[Category:Toxine bactérienne]]
28597 [[Category:Toxine bactérienne]]
28598 [[Category:Toxine bactérienne]]
28599 !! end
28600
28601 !! test
28602 New sol transparent links don't need indent-pre nowiki protection
28603 !! options
28604 parsoid=html2wt
28605 language=de
28606 !! html/parsoid
28607 <link rel="mw:PageProp/redirect" href="./Main_Page">
28608 <!-- this is good --> <link rel="mw:PageProp/Category" href="./Category:Good" />
28609 <!-- this is great --> <link rel="mw:PageProp/Category" href="./Kategorie:Great" />
28610 !! wikitext
28611 #WEITERLEITUNG [[Main Page]]
28612 <!-- this is good --> [[Category:Good]]
28613 <!-- this is great --> [[Kategorie:Great]]
28614 !! end
28615
28616 !! test
28617 New interlanguage links (href variations)
28618 !! options
28619 parsoid=html2wt
28620 !! html/parsoid
28621 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" />
28622 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" />
28623 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" />
28624 !! wikitext
28625 [[es:Toxine bactérienne]]
28626 [[es:Toxine_bactérienne]]
28627 [[es:Toxine_bactérienne]]
28628 !! end
28629
28630 !! test
28631 Image: Modifying size of an image (1)
28632 !! options
28633 parsoid={
28634 "modes": ["wt2wt"],
28635 "changes": [
28636 ["img[height]", "attr", "height", "22"],
28637 ["img[width]", "attr", "width", "200"]
28638 ]
28639 }
28640 !! wikitext
28641 [[Image:Foobar.jpg|230x230px]]
28642 !! wikitext/edited
28643 [[Image:Foobar.jpg|200x200px]]
28644 !!end
28645
28646 !! test
28647 Image: Modifying size of an image (2)
28648 !! options
28649 parsoid={
28650 "modes": ["wt2wt"],
28651 "changes": [
28652 ["img[height]", "attr", "height", "100"],
28653 ["img[width]", "attr", "width", "500"]
28654 ]
28655 }
28656 !! wikitext
28657 [[Image:Foobar.jpg|230x230px]]
28658 !! wikitext/edited
28659 [[Image:Foobar.jpg|500x500px]]
28660 !!end
28661
28662 # Change in size is ignored so long as class='mw-default-size'
28663 !! test
28664 Image: Modifying size of an image (3)
28665 !! options
28666 parsoid={
28667 "modes": ["wt2wt"],
28668 "changes": [
28669 ["figure[class]", "removeClass", "mw-default-size"],
28670 ["figure img", "attr", "height", "19"],
28671 ["figure img", "attr", "width", "170"]
28672 ]
28673 }
28674 !! wikitext
28675 [[Image:Foobar.jpg|thumb]]
28676 !! wikitext/edited
28677 [[Image:Foobar.jpg|thumb|170x170px]]
28678 !!end
28679
28680 !! test
28681 Image: Modifying alignment of an image (T50665)
28682 !! options
28683 parsoid={
28684 "modes": ["wt2wt"],
28685 "changes": [
28686 ["figure[class]", "removeClass", "mw-halign-right"],
28687 ["figure[class]", "addClass", "mw-halign-left"]
28688 ]
28689 }
28690 !! wikitext
28691 [[Image:Foobar.jpg|thumb|caption|right]]
28692 !! wikitext/edited
28693 [[Image:Foobar.jpg|thumb|caption|left]]
28694 !! end
28695
28696 !! test
28697 Image: Modifying mw-default-size of an frameless image (T64805)
28698 !! options
28699 parsoid={
28700 "modes": ["wt2wt"],
28701 "changes": [
28702 ["figure.mw-default-size", "removeClass", "mw-default-size"]
28703 ]
28704 }
28705 !! wikitext
28706 [[Image:Foobar.jpg|frameless|right]]
28707 !! wikitext/edited
28708 [[Image:Foobar.jpg|frameless|right|220x220px]]
28709 !! end
28710
28711 !! test
28712 Image: Modifying valign of an image (T51221)
28713 !! options
28714 parsoid={
28715 "modes": ["wt2wt"],
28716 "changes": [
28717 ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
28718 ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
28719 ]
28720 }
28721 !! wikitext
28722 [[File:Foobar.jpg|20px|middle]]
28723 !! wikitext/edited
28724 [[File:Foobar.jpg|20px|text-top]]
28725 !! end
28726
28727 !! test
28728 Image: Modifying alt attribute of an image (T58400)
28729 !! options
28730 parsoid={
28731 "modes": ["wt2wt"],
28732 "changes": [
28733 ["img[alt]", "attr", "alt", "some alternate edited text"]
28734 ]
28735 }
28736 !! wikitext
28737 [[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
28738 !! wikitext/edited
28739 [[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
28740 !!end
28741
28742 !! test
28743 Image: Modifying caption of an image
28744 !! options
28745 parsoid={
28746 "modes": ["wt2wt"],
28747 "changes": [
28748 ["figcaption", "text", "new caption"]
28749 ]
28750 }
28751 !! wikitext
28752 [[Image:Foobar.jpg|thumb|original caption]]
28753 !! wikitext/edited
28754 [[Image:Foobar.jpg|thumb|new caption]]
28755 !!end
28756
28757 !! test
28758 Image: empty alt attribute (T50924)
28759 !! wikitext
28760 [[File:Foobar.jpg|thumb|alt=|bar]]
28761 !! html/php+tidy
28762 <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>
28763 !! html/parsoid
28764 <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>
28765 !! end
28766
28767 !! test
28768 Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
28769 !! options
28770 parsoid=html2wt
28771 language=ar
28772 disabled
28773 !! html/parsoid
28774 <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>
28775 !! wikitext
28776 [[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
28777 !! end
28778
28779 !! test
28780 Image: Block level image should have \n before and after
28781 !! wikitext
28782 123
28783 [[File:Foobar.jpg|right|thumb|150x150px]]
28784 456
28785 !! html/parsoid
28786 <p>123</p>
28787 <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>
28788 <p>456</p>
28789 !! end
28790
28791 !! test
28792 Image: New block level image should have \n before and after (existing content)
28793 !! wikitext
28794 123
28795 [[File:Foobar.jpg|right|thumb|150x150px]]
28796 456
28797 !! html/parsoid
28798 <p>123</p>
28799 <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>
28800 <p>456</p>
28801 !! end
28802
28803 !! test
28804 Image: upright option (parsoid)
28805 !! wikitext
28806 [[File:Foobar.jpg|thumb|upright|caption]]
28807 [[File:Foobar.jpg|thumb|upright=0.5|caption]]
28808 [[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]]
28809 !! html/parsoid
28810 <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>
28811 <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>
28812 <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>
28813 !! end
28814
28815 !! test
28816 Image: upright option is ignored on inline and frame images (parsoid)
28817 !! wikitext
28818 [[File:Foobar.jpg|500x500px|upright=0.5|caption]]
28819 !! html/parsoid
28820 <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>
28821 !! end
28822
28823 !! test
28824 Image: in template parameter with empty parameter
28825 !! wikitext
28826 {{echo|[[File:Foobar.jpg|link=]]}}
28827 !! html/parsoid
28828 <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>
28829 !! end
28830
28831 !! test
28832 Image: from basic HTML (1)
28833 !! options
28834 parsoid=html2wt
28835 !! html/parsoid
28836 <span typeof="mw:Image">
28837 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
28838 </span>
28839 !! wikitext
28840 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
28841 !! end
28842
28843 !! test
28844 Image: from basic HTML (2)
28845 !! options
28846 parsoid=html2wt
28847 !! html/parsoid
28848 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
28849 !! wikitext
28850 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
28851 !! end
28852
28853 !! test
28854 Image: from basic HTML (3)
28855 !! options
28856 parsoid=html2wt
28857 !! html/parsoid
28858 <a href="Main"><img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"></a>
28859 !! wikitext
28860 [[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
28861 !! end
28862
28863 !! test
28864 Image: from basic HTML (4)
28865 !! options
28866 parsoid=html2wt
28867 !! html/parsoid
28868 <img src="./File:Foobar.jpg">
28869 !! wikitext
28870 [[File:Foobar.jpg|link=]]
28871 !! end
28872
28873 !! test
28874 Image: Invalid title as link
28875 !! wikitext
28876 [[File:Foobar.jpg|link=<]]
28877 !! html/php
28878 <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>
28879 </p>
28880 !! html/parsoid
28881 <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>
28882 !! end
28883
28884 !! test
28885 Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
28886 !! options
28887 parsoid=html2wt
28888 !! html/parsoid
28889 <ul>
28890 <li><p>foo</p></li>
28891 </ul>
28892 !! wikitext
28893 * foo
28894 !! end
28895
28896 !! test
28897 Lists: Serialize correctly even when list tags has unneeded whitespace between tags
28898 !! options
28899 parsoid=html2wt
28900 !! html/parsoid
28901 <ul> <li>foo</li></ul>
28902 !! wikitext
28903 * foo
28904 !! end
28905
28906 !! test
28907 Don't strip leading whitespace when handling indent-pre suppressing tags
28908 !! options
28909 parsoid=html2wt
28910 !! html/parsoid
28911 <table>
28912 <tr><td> indented row</td></tr>
28913 </table>
28914 <blockquote><p>
28915 <b>This is very bold of you!</b>
28916 </p>
28917 <table><tr><td>
28918 indented cell (no pre-wrapping!)
28919 </td></tr></table>
28920 </blockquote>
28921 <p>foo</p>
28922 <div>bar</div>
28923 !! wikitext
28924 {|
28925 | indented row
28926 |}
28927 <blockquote>
28928 '''This is very bold of you!'''
28929
28930 {|
28931 |
28932 indented cell (no pre-wrapping!)
28933 |}
28934 </blockquote>
28935 foo
28936 <div>bar</div>
28937 !! end
28938
28939 !! test
28940 Nowiki-wrap leading whitespace when handling indent-pre inducing tags
28941 !! options
28942 parsoid=html2wt
28943 !! html/parsoid
28944 <p>foo</p>
28945 <span>bar</span>
28946
28947 <span>foo2
28948 </span>bar2
28949
28950 <div>foo</div>
28951 <span>bar</span>
28952
28953 <div>
28954 <span>foo</span>
28955 </div>
28956 !! wikitext
28957 foo
28958
28959 <span>bar</span>
28960
28961 <span>foo2
28962 <nowiki> </nowiki></span>bar2
28963
28964 <div>foo</div>
28965 <nowiki> </nowiki><span>bar</span>
28966
28967 <div>
28968 <nowiki> </nowiki><span>foo</span>
28969 </div>
28970 !! end
28971
28972 !! test
28973 Lists: Dont insert newlines in a serialized list item.
28974 !! options
28975 parsoid=html2wt
28976 !! html/parsoid
28977 <ul><li>a<br>b</li><li>c</li></ul>
28978 !! wikitext
28979 * a<br />b
28980 * c
28981 !! end
28982
28983 !! test
28984 1. Headings: Force sol-transparent links and behavior switches to serialize before/after
28985 !! options
28986 parsoid={
28987 "modes": ["html2wt"],
28988 "scrubWikitext": false
28989 }
28990 !! html/parsoid
28991 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
28992 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
28993
28994 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
28995 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
28996
28997 <h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2>
28998
28999 <h2><meta property="mw:PageProp/toc" /> ok</h2>
29000 !! wikitext
29001 == hello there [[Category:A1]] ==
29002
29003 == [[Category:A2]] hi pal ==
29004
29005 == <!--foo--> [[Category:A3]] how goes it ==
29006
29007 == it goes well [[Category:A4]] <!--bar--> ==
29008
29009 ==howdy [[Category:A5]]==
29010
29011 == __TOC__ ok ==
29012 !! end
29013
29014 !! test
29015 2. Headings: Force sol-transparent links and behavior switches to serialize before/after
29016 !! options
29017 parsoid={
29018 "modes": ["html2wt"],
29019 "scrubWikitext": true
29020 }
29021 !! html/parsoid
29022 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
29023 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
29024
29025 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
29026 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
29027
29028 <h2><meta property="mw:PageProp/toc" /> ok</h2>
29029 !! wikitext
29030 == hello there ==
29031 [[Category:A1]]
29032 [[Category:A2]]
29033
29034 == hi pal ==
29035
29036 <!--foo-->[[Category:A3]]
29037
29038 == how goes it ==
29039
29040 == it goes well ==
29041 [[Category:A4]] <!--bar-->
29042
29043 __TOC__
29044
29045 == ok ==
29046 !! end
29047
29048 !! test
29049 Headings: Don't hoist metas that come from templates
29050 !! options
29051 parsoid={
29052 "modes": ["html2wt"],
29053 "scrubWikitext": true
29054 }
29055 !! html/parsoid
29056 <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>
29057 !! wikitext
29058 == {{echo|foo [[Category:Foo]]}} ==
29059 !! end
29060
29061 !! test
29062 Headings: Category in ref isn't hoisted
29063 !! options
29064 parsoid={
29065 "modes": ["html2wt"],
29066 "scrubWikitext": true
29067 }
29068 !! html/parsoid
29069 <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>
29070
29071 <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>
29072 !! wikitext
29073 == foo <ref>bar
29074 [[Category:Baz]] </ref> ==
29075
29076 <references />
29077 !! end
29078
29079 !! test
29080 Parsoid: Serialize positional parameters with = in them as named parameter
29081 !! options
29082 parsoid=html2wt
29083 !! html/parsoid
29084 <p about="#mwt1" typeof="mw:Transclusion"
29085 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p>
29086
29087 <p about="#mwt1" typeof="mw:Transclusion"
29088 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p>
29089
29090 <!--Orig params with data-parsoid has heuristics for handling = chars-->
29091 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
29092 <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>
29093 !! wikitext
29094 {{echo|1=f=oo}}
29095
29096 {{echo|1=f=oo|2=bar}}
29097
29098 <!--Orig params with data-parsoid has heuristics for handling = chars-->
29099 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
29100 {{echo|<nowiki>f=oo</nowiki>|bar}}
29101 !! end
29102
29103 !! test
29104 Parsoid: Serialize positional parameters with = in extlink as named parameter
29105 !! options
29106 parsoid=html2wt
29107 !! html/parsoid
29108 <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>
29109 !! wikitext
29110 {{echo|1=http://stuff?is=ok}}
29111 !! end
29112
29113 !! test
29114 Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes
29115 !! options
29116 parsoid=html2wt
29117 !! html/parsoid
29118 <div>a<p>b</p></div>
29119 <div>a
29120 <p>b</p></div>
29121 <div>
29122 a
29123 <p>b</p></div>
29124 !! wikitext
29125 <div>a
29126 b
29127 </div>
29128 <div>a
29129 b
29130 </div>
29131 <div>
29132 a
29133
29134 b
29135 </div>
29136 !! end
29137
29138 !! test
29139 Substrings resembling wikitext in hrefs should not get nowiki escapes
29140 !! options
29141 parsoid=html2wt
29142 !! html/parsoid
29143 <a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a>
29144 !! wikitext
29145 [[Foo''bar''baz]]
29146 !! end
29147
29148 !! test
29149 Enforce single-line context in the serializer
29150 !! options
29151 parsoid=html2wt
29152 !! html/parsoid
29153 <h2>testing
29154 123</h2>
29155
29156 <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">
29157 </span><span about="#mwt1">you</span> </h2>
29158
29159 <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>
29160
29161 <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
29162 there</span></li></ol>
29163
29164 <ul><li>asd
29165 sdf</li></ul>
29166
29167 <ul><li>foo
29168 bar
29169 baz</li>
29170 <li>foo <b>bar</b>
29171 baz</li></ul>
29172
29173 <dl><dt>hi
29174 ho </dt><dd data-parsoid='{"stx":"row"}'> hi
29175 ho</dd></dl>
29176
29177 <dl><dd> <table>
29178 <tbody><tr><td> ha
29179 ha
29180 ha</td></tr>
29181 </tbody></table></dd></dl>
29182 !! wikitext
29183 == testing 123 ==
29184
29185 == hi {{bogus|there
29186 you}} ==
29187
29188 == foo <ref>hello
29189 there</ref> ==
29190
29191 <references />
29192
29193 * asd sdf
29194
29195 * foo bar baz
29196 * foo '''bar''' baz
29197
29198 ; hi ho : hi ho
29199
29200 : {|
29201 | ha
29202 ha
29203 ha
29204 |}
29205 !! end
29206
29207 !! test
29208 Serialize new placeholder space without spans
29209 !! options
29210 parsoid=html2wt
29211 !! html/parsoid
29212 <p>foo<span typeof="mw:Placeholder"> </span>: bar</p>
29213
29214 <p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p>
29215
29216 <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>
29217 !! wikitext
29218 foo : bar
29219
29220 foo : bar
29221
29222 <ref>foo : bar</ref>ok
29223 !! end
29224
29225
29226 #-----------------------
29227 # Tag minimization tests
29228 #-----------------------
29229
29230 !! test
29231 1. I/B quote minimization: wikitext-only tags should be combined
29232 !! options
29233 parsoid=html2wt
29234 !! html/parsoid
29235 <p><i>A</i><i>B</i></p>
29236 <p><b>A</b><b>B</b></p>
29237 <p><i>A</i><b><i>B</i></b></p>
29238 <p><b>A</b><i><b>B</b></i></p>
29239 <p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p>
29240 <p><i><b>A</b></i><i><b>B</b></i></p>
29241 <p><i><b>A</b></i><b><i>B</i></b></p>
29242 <p><b><i>A</i></b><i><b>B</b></i></p>
29243 !! wikitext
29244 ''AB''
29245
29246 '''AB'''
29247
29248 ''A'''B'''''
29249
29250 '''A''B'''''
29251
29252 '''A''BC''D'''
29253
29254 '''''AB'''''
29255
29256 '''''AB'''''
29257
29258 '''''AB'''''
29259 !! end
29260
29261 !! test
29262 2. I/B quote minimization: wikitext and html tags should not be combined
29263 !! options
29264 parsoid=html2wt
29265 !! html/parsoid
29266 <p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
29267 <p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
29268 !! wikitext
29269 ''A''<i>B</i>
29270
29271 ''A''<nowiki/>'''<i>B</i>'''
29272 !! end
29273
29274 !! test
29275 3. I/B quote minimization: templated content stops minimization
29276 !! options
29277 parsoid=html2wt
29278 !! html/parsoid
29279 <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>
29280 <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>
29281 !! wikitext
29282 ''A''{{echo|''B''}}
29283
29284 ''A''{{echo|'''''B'''''}}
29285 !! end
29286
29287 !! test
29288 4. I/B quote minimization: new content should be mimimized with adjacent old content
29289 !! options
29290 parsoid=html2wt
29291 !! html/parsoid
29292 <p><i>A</i><i>B</i></p>
29293 <p><b>A</b><b>B</b></p>
29294 <p><i>A</i><b><i>B</i></b></p>
29295 !! wikitext
29296 ''AB''
29297
29298 '''AB'''
29299
29300 ''A'''B'''''
29301 !! end
29302
29303 !! test
29304 5a. Merge adjacent quote nodes if they've been edited
29305 !! options
29306 parsoid={
29307 "modes": ["wt2wt", "selser"],
29308 "changes": [
29309 ["p", "contents", "remove", ":contains('b')"]
29310 ]
29311 }
29312 !! wikitext
29313 ''a''b''c''
29314 !! wikitext/edited
29315 ''ac''
29316 !! end
29317
29318 !! test
29319 5b. Merge adjacent quote nodes if they've been edited
29320 !! options
29321 parsoid={
29322 "modes": ["wt2wt", "selser"],
29323 "changes": [
29324 ["#x", "remove"]
29325 ]
29326 }
29327 !! wikitext
29328 ''a''<span id="x">b</span>''c''
29329 !! wikitext/edited
29330 ''ac''
29331 !! end
29332
29333 !! test
29334 1. Merge adjacent link nodes as long as at least one element is new
29335 !! options
29336 parsoid={
29337 "modes": ["html2wt"],
29338 "scrubWikitext": true
29339 }
29340 !! html/parsoid
29341 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29342 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29343 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a>
29344 !! wikitext
29345 [[Football]]
29346 [[Football]]
29347 [[Football|Foot]][[Football|ball]]
29348 !! end
29349
29350 !! test
29351 2. Merge adjacent link nodes and enable additional normalizations
29352 !! options
29353 parsoid={
29354 "modes": ["html2wt"],
29355 "scrubWikitext": true
29356 }
29357 !! html/parsoid
29358 <a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a>
29359 !! wikitext
29360 ''[[Football]]''
29361 !! end
29362
29363 !! test
29364 3. Don't merge adjacent link nodes if scrubWikitext is false
29365 !! options
29366 parsoid={
29367 "modes": ["html2wt"],
29368 "scrubWikitext": false
29369 }
29370 !! html/parsoid
29371 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29372 !! wikitext
29373 [[Football|Foot]][[Football|ball]]
29374 !! end
29375
29376 !! test
29377 1. Move format tags outside of WikiLink
29378 !! options
29379 parsoid={
29380 "modes": ["html2wt"],
29381 "scrubWikitext": true
29382 }
29383 !! html/parsoid
29384 <a rel="mw:WikiLink" href="./Football"><i>Football</i></a>
29385 <a rel="mw:WikiLink" href="./Football"><i><b>Football</b></i></a>
29386 <a rel="mw:WikiLink" href="./Football"><u><i><b>Football</b></i></u></a>
29387 !! wikitext
29388 ''[[Football]]''
29389 '''''[[Football]]'''''
29390 <u>'''''[[Football]]'''''</u>
29391 !! end
29392
29393 !! test
29394 2. Move format tags outside of WikiLink with mergable A tags
29395 !! options
29396 parsoid={
29397 "modes": ["html2wt"],
29398 "scrubWikitext": true
29399 }
29400 !! html/parsoid
29401 <a rel="mw:WikiLink" href="./Football"><i><b>Foot</b></i></a><a rel="mw:WikiLink" href="./Football"><i><b>ball</b></i></a>
29402 !! wikitext
29403 '''''[[Football]]'''''
29404 !! end
29405
29406 !! test
29407 3. Move format tags outside of WikiLink while preserving formats already outside WikiLink
29408 !! options
29409 parsoid={
29410 "modes": ["html2wt"],
29411 "scrubWikitext": true
29412 }
29413 !! html/parsoid
29414 <font color="red"><a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><u><b>Foo</b></u></a></font>
29415 !! wikitext
29416 <font color="red"><u>'''[[Foo]]'''</u></font>
29417 !! end
29418
29419 !! test
29420 4. Do not move format tags outside of WikiLink which includes attributes color, style and class
29421 !! options
29422 parsoid={
29423 "modes": ["html2wt"],
29424 "scrubWikitext": true
29425 }
29426 !! html/parsoid
29427 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><font color="red">Foo</font></a>
29428 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><span style="color: blue; font-size: 46px;">Foo></span></a>
29429 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><span class="Bar">Foo</span></a>
29430 !! wikitext
29431 [[Foo|<font color="red">Foo</font>]]
29432 [[Foo|<span style="color: blue; font-size: 46px;">Foo></span>]]
29433 [[Foo|<span class="Bar">Foo</span>]]
29434 !! end
29435
29436 !! test
29437 5. T194083 Regression test: Manual edit test that also enables scrubWikitext to move format tags outside wikilinks
29438 !! options
29439 parsoid={
29440 "modes": ["selser"],
29441 "scrubWikitext": true,
29442 "changes": [
29443 ["a", "html", "<i>Foo</i>"]
29444 ]
29445 }
29446 !! wikitext
29447 [[Foo]]
29448 !! wikitext/edited
29449 ''[[Foo]]''
29450 !! end
29451
29452 !! test
29453 6. Regression test: Manual edit test to ensure diff markers are not lost
29454 !! options
29455 parsoid={
29456 "modes": ["selser"],
29457 "scrubWikitext": true,
29458 "changes": [
29459 ["i", "wrap", "<a href='./Foo' rel='mw:WikiLink'></a>"]
29460 ]
29461 }
29462 !! wikitext
29463 ''Foo''
29464 !! wikitext/edited
29465 ''[[Foo]]''
29466 !! end
29467
29468 !! test
29469 7. T194083 Regression test: Manual edit test to ensure nested diff markers aren't inserted
29470 !! options
29471 parsoid={
29472 "modes": ["selser"],
29473 "scrubWikitext": true,
29474 "changes": [
29475 ["div", "after", "\n<p><a href='./Foo' rel='mw:WikiLink'>Foo </a>, placeholder</p>"]
29476 ]
29477 }
29478 !! wikitext
29479 <div>placeholder</div>
29480 !! wikitext/edited
29481 <div>placeholder</div>
29482 [[Foo]] , placeholder
29483 !! end
29484
29485 #------------------------------
29486 # End of tag minimization tests
29487 #------------------------------
29488
29489 !!test
29490 T56262: New entities
29491 !! options
29492 parsoid=html2wt
29493 !! html/parsoid
29494 <span typeof="mw:Entity">&nbsp;</span>
29495 !! wikitext
29496 &nbsp;
29497 !! end
29498
29499 ## Note that there is no wikitext output for 'unknownproperty' ##
29500 ## Unknown magic words are silently dropped ##
29501
29502 !! test
29503 Magic words
29504 !! options
29505 parsoid=html2wt
29506 !! html/parsoid
29507 <meta property='mw:PageProp/toc' />
29508 <meta property='mw:PageProp/notoc' />
29509 <meta property='mw:PageProp/forcetoc' />
29510 <meta property='mw:PageProp/index' />
29511 <meta property='mw:PageProp/noindex' />
29512 <meta property='mw:PageProp/nogallery' />
29513 <meta property='mw:PageProp/noeditsection' />
29514 <meta property='mw:PageProp/notitleconvert' />
29515 <meta property='mw:PageProp/nocontentconvert' />
29516 <meta property='mw:PageProp/unknownproperty' />
29517 !! wikitext
29518 __TOC__
29519 __NOTOC__
29520 __FORCETOC__
29521 __INDEX__
29522 __NOINDEX__
29523 __NOGALLERY__
29524 __NOEDITSECTION__
29525 __NOTITLECONVERT__
29526 __NOCONTENTCONVERT__
29527 !! end
29528
29529 !! test
29530 Consecutive <pre>s should not get merged
29531 !! options
29532 parsoid=html2wt,html2html
29533 !! html/parsoid
29534 <pre>a</pre><pre>b</pre>
29535
29536 <pre>c
29537 </pre><pre>
29538 d</pre>
29539
29540 <pre>e
29541
29542 </pre><pre>
29543
29544 f</pre>
29545 !! wikitext
29546 a
29547
29548 b
29549
29550 c
29551
29552 d
29553
29554 e
29555
29556
29557
29558 f
29559 !! end
29560
29561 !! test
29562 Edited ISBN links not serializable as ISBN links should serialize as wikilinks
29563 !! options
29564 parsoid=html2wt
29565 !! html/parsoid
29566 <a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a>
29567 !! wikitext
29568 [[Special:BookSources/1234567890|ISBN 1234567895]]
29569 !! end
29570
29571 !! test
29572 Edited RFC links not serializable as RFC links should serialize as extlinks
29573 !! options
29574 parsoid=html2wt
29575 !! html/parsoid
29576 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
29577 !! wikitext
29578 [https://tools.ietf.org/html/rfc123 New RFC]
29579 !! end
29580
29581 !! test
29582 Edited PMID links not serializable as PMID links should serialize as extlinks
29583 !! options
29584 parsoid=html2wt
29585 !! html/parsoid
29586 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a>
29587 !! wikitext
29588 [//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID]
29589 !! end
29590
29591 !! test
29592 WTS of autolinks with trailing/surrounding context
29593 !! options
29594 parsoid=html2wt
29595 !! html/parsoid
29596 <p><a href="http://cscott.net">http://cscott.net</a><b>foo</b></p>
29597 <p><a href="http://cscott.net">http://cscott.net</a><b data-parsoid='{"stx":"html"}'>foo</b></p>
29598 <p><b><a href="http://cscott.net">http://cscott.net</a></b></p>
29599 <p><b><a href="http://cscott.net">http://cscott.net</a> </b></p>
29600 <p><b><a href="http://cscott.net">http://cscott.net</a>x</b></p>
29601 <p><a href="http://cscott.net">http://cscott.net</a>x</p>
29602 !! wikitext
29603 http://cscott.net'''foo'''
29604
29605 http://cscott.net<b>foo</b>
29606
29607 '''http://cscott.net'''
29608
29609 '''http://cscott.net '''
29610
29611 '''http://cscott.net<nowiki/>x'''
29612
29613 http://cscott.net<nowiki/>x
29614 !! end
29615
29616 !! test
29617 WTS of autolinks with nowikis (round-trip)
29618 !! wikitext
29619 x<nowiki/>http://cscott.net<nowiki/>x
29620 !! html/parsoid
29621 <p>x<a rel="mw:ExtLink" class="external free" href="http://cscott.net">http://cscott.net</a>x</p>
29622 !! end
29623
29624 # this is the "easy" test because it leaves in place all the
29625 # data-parsoid information indicating this is an autolink
29626 !! test
29627 WTS of autolinks with escapes (editing)
29628 !! options
29629 parsoid={
29630 "modes": ["wt2wt"],
29631 "changes": [
29632 [ "span", "remove" ]
29633 ]
29634 }
29635 !! wikitext
29636 x<nowiki/>http://cscott.net<nowiki/>x
29637 !! wikitext/edited
29638 x<nowiki/>http://cscott.net<nowiki/>x
29639 !! end
29640
29641 !! test
29642 WTS of edited autolink-like text (T103364)
29643 !! options
29644 parsoid={
29645 "modes": ["wt2wt"],
29646 "changes": [
29647 [ "span[typeof]", "removeAttr", "typeof" ]
29648 ]
29649 }
29650 !! wikitext
29651 Not a link: <nowiki>http://example.com</nowiki>.
29652 !! wikitext/edited
29653 Not a link: <span><nowiki>http://example.com</nowiki></span>.
29654 !! end
29655
29656 !! test
29657 WTS of newly-authored autolink-like text (T103364)
29658 !! options
29659 parsoid=html2wt
29660 !! html/parsoid
29661 <p>http://example.com is not a link.</p>
29662 !! wikitext
29663 <nowiki>http://example.com</nowiki> is not a link.
29664 !! end
29665
29666 !! test
29667 WTS of autolink-like text after an autolink (T108563)
29668 !! options
29669 parsoid=html2wt
29670 !! html/parsoid
29671 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p>
29672 !! wikitext
29673 http://example.com <nowiki>http://example.com</nowiki> is not a link.
29674 !! end
29675
29676 !! test
29677 Magic links inside links (not autolinked)
29678 !! wikitext
29679 [[Foo|http://example.com]]
29680 [[Foo|RFC 1234]]
29681 [[Foo|PMID 1234]]
29682 [[Foo|ISBN 123456789x]]
29683
29684 [http://foo.com http://example.com]
29685 [http://foo.com RFC 1234]
29686 [http://foo.com PMID 1234]
29687 [http://foo.com ISBN 123456789x]
29688 !! html+tidy
29689 <p><a href="/wiki/Foo" title="Foo">http://example.com</a>
29690 <a href="/wiki/Foo" title="Foo">RFC 1234</a>
29691 <a href="/wiki/Foo" title="Foo">PMID 1234</a>
29692 <a href="/wiki/Foo" title="Foo">ISBN 123456789x</a>
29693 </p><p><a rel="nofollow" class="external text" href="http://foo.com">http://example.com</a>
29694 <a rel="nofollow" class="external text" href="http://foo.com">RFC 1234</a>
29695 <a rel="nofollow" class="external text" href="http://foo.com">PMID 1234</a>
29696 <a rel="nofollow" class="external text" href="http://foo.com">ISBN 123456789x</a>
29697 </p>
29698 !! html/parsoid
29699 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a>
29700 <a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a>
29701 <a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a>
29702 <a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p>
29703
29704 <p><a rel="mw:ExtLink" class="external text" href="http://foo.com">http://example.com</a>
29705 <a rel="mw:ExtLink" class="external text" href="http://foo.com">RFC 1234</a>
29706 <a rel="mw:ExtLink" class="external text" href="http://foo.com">PMID 1234</a>
29707 <a rel="mw:ExtLink" class="external text" href="http://foo.com">ISBN 123456789x</a></p>
29708 !! end
29709
29710 !! test
29711 Magic links inside image captions (autolinked)
29712 !! wikitext
29713 [[File:Foobar.jpg|thumb|http://example.com]]
29714 [[File:Foobar.jpg|thumb|RFC 1234]]
29715 [[File:Foobar.jpg|thumb|PMID 1234]]
29716 [[File:Foobar.jpg|thumb|ISBN 123456789x]]
29717 !! html+tidy
29718 <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>
29719 <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>
29720 <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>
29721 <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>
29722 !! html/parsoid
29723 <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>
29724 <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>
29725 <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>
29726 <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>
29727 !! end
29728
29729 !! test
29730 WTS of magic word text (T109371)
29731 !! options
29732 parsoid=html2wt
29733 !! html/parsoid
29734 <p>RFC 1234</p>
29735 <p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p>
29736 <p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p>
29737 !! wikitext
29738 <nowiki>RFC 1234</nowiki>
29739
29740 [http://foo.com RFC 1234]
29741
29742 [[Foo|RFC 1234]]
29743 !! end
29744
29745 !! test
29746 Edited Redirect link should emit a non-piped wikitext link
29747 !! options
29748 parsoid=html2wt
29749 !! html/parsoid
29750 <link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>
29751 !! wikitext
29752 #REDIRECT [[Bar]]
29753 !! end
29754
29755 !! test
29756 T75121: Infer extension name from typeOf if data-mw is not present
29757 !! options
29758 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
29759 !! html/parsoid
29760 <div typeOf="mw:Extension/foo"></div>
29761 !! wikitext
29762 <foo />
29763 !! end
29764
29765 # Note that the <p> wrapping isn't present in PHP parser output
29766 # The important thing for this test is that P-wrapping doesn't
29767 # interfere with the <nowiki> protection for leading - in <td>
29768 # (which isn't necessary for <th>).
29769 !! test
29770 T88318: p-wrapped dash in table.
29771 !! options
29772 parsoid=html2wt,wt2wt
29773 !! html/parsoid
29774 <table><tbody>
29775 <tr><th><p>-</p></th><th><p>- </p></th></tr>
29776 <tr><td><p>-</p></td><td><p>- </p></td></tr>
29777 <tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr>
29778 </tbody></table>
29779 !! wikitext
29780 {|
29781 !-
29782 !-
29783 |-
29784 |<nowiki>-</nowiki>
29785 |<nowiki>- </nowiki>
29786 |-
29787 |<small>-</small>
29788 |<br />
29789 -
29790 |<br />-
29791 |}
29792 !! html/php+tidy
29793 <table>
29794 <tbody><tr>
29795 <th>-
29796 </th>
29797 <th>-
29798 </th></tr>
29799 <tr>
29800 <td>-
29801 </td>
29802 <td>-
29803 </td></tr>
29804 <tr>
29805 <td><small>-</small>
29806 </td>
29807 <td><br />
29808 <p>-
29809 </p>
29810 </td>
29811 <td><br />-
29812 </td></tr></tbody></table>
29813 !! end
29814
29815 !! test
29816 T149209: WTS: Handle newlines in table cells properly
29817 !! options
29818 parsoid=html2wt
29819 !! html/parsoid
29820 <table>
29821 <tbody>
29822 <tr><td>a
29823 b
29824 </td><td data-parsoid='{"stx":"row"}'>c</td></tr>
29825 <tr><td><p>x</p>
29826 </td><td data-parsoid='{"stx":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr>
29827 </tbody></table>
29828 <table>
29829 <tbody>
29830 <tr><th>a
29831 b
29832 </th><th data-parsoid='{"stx":"row"}'>c</th></tr>
29833 <tr><th><p>x</h>
29834 </th><th data-parsoid='{"stx":"row"}'>y</th></tr>
29835 </tbody></table>
29836 !! wikitext
29837 {|
29838 |a
29839 b
29840 |c
29841 |-
29842 |x
29843 {{!}}y
29844 |}
29845 {|
29846 !a
29847 b
29848 !c
29849 |-
29850 !x
29851 !y
29852 |}
29853 !! end
29854
29855 !! test
29856 T149209: Selser: Handle newlines in table cells properly
29857 !! options
29858 parsoid={
29859 "modes": ["selser"],
29860 "changes": [
29861 [ "#h1", "html", "a\nb\n" ],
29862 [ "#h2", "html", "a\nb\n" ],
29863 [ "#c1", "html", "a\nb\n" ],
29864 [ "#c2", "html", "<p>a</p>" ],
29865 [ "#c3", "html", "<p>a</p>" ],
29866 [ "#c4", "html", "edit-me<p>a</p>" ]
29867 ]
29868 }
29869 !! wikitext
29870 {|
29871 ! id="h1" |edit-me!!1
29872 |-
29873 ! id="h2" |edit-me||2
29874 |-
29875 | id="c1" |edit-me||3
29876 |-
29877 | id="c2" |edit-me||4
29878 |-
29879 | id="c3" |edit-me||p||q||r
29880 |-
29881 | id="c4" |edit-me||p||q||r
29882 |}
29883 !! wikitext/edited
29884 {|
29885 ! id="h1" |a
29886 b
29887 !1
29888 |-
29889 ! id="h2" |a
29890 b
29891 !2
29892 |-
29893 | id="c1" |a
29894 b
29895 |3
29896 |-
29897 | id="c2" |a
29898 |4
29899 |-
29900 | id="c3" |a
29901 |p||q||r
29902 |-
29903 | id="c4" |edit-me
29904 a
29905 |p||q||r
29906 |}
29907 !! end
29908
29909 !! test
29910 HTML id attribute with Parsoid-like element ids should not be serialized to wikitext
29911 !! options
29912 parsoid=html2wt
29913 !! html/parsoid
29914 <table id='mwAb'>
29915 <td id='mwAc'>foo</td>
29916 <td id='serialize-this'>bar</td>
29917 </table>
29918 !! wikitext
29919 {|
29920 |foo
29921 | id="serialize-this" |bar
29922 |}
29923 !! end
29924
29925 !! test
29926 Parsoid-like element ids should not be serialized to wikitext unless shadowed
29927 !! options
29928 parsoid=html2wt
29929 !! html/parsoid
29930 <div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div>
29931 !! wikitext
29932 <div id="hello">ok</div>
29933 !! end
29934
29935 !! test
29936 Testing serialization after deletion in references
29937 !! options
29938 parsoid={
29939 "modes": ["wt2wt"],
29940 "changes": [
29941 ["#x", "remove"]
29942 ]
29943 }
29944 !! wikitext
29945 hi <ref><div id="x">ho</div></ref>
29946
29947 <references />
29948 !! wikitext/edited
29949 hi <ref></ref>
29950
29951 <references />
29952 !! end
29953
29954 !!test
29955 Testing serialization after deletion of table cells
29956 !!options
29957 parsoid={
29958 "modes": ["wt2wt", "selser"],
29959 "changes": [
29960 ["#x", "remove"]
29961 ]
29962 }
29963 !!wikitext
29964 {|
29965 !h1 !!h2 !!h3
29966 | id="x" |c1 {{!}}{{!}}{{!}}c2 |||c3
29967 |}
29968 !! wikitext/edited
29969 {|
29970 !h1!!h2!!h3
29971 |c2|||c3
29972 |}
29973 !!end
29974
29975 !! test
29976 Testing selser after addition of new row before first row (T125419)
29977 !! options
29978 parsoid={
29979 "modes": ["wt2wt", "selser"],
29980 "changes": [
29981 [ "tr", "before", "<tr><td>X</td></tr>" ]
29982 ]
29983 }
29984 !! wikitext
29985 {|
29986 |a
29987 |}
29988 !! wikitext/edited
29989 {|
29990 |X
29991 |-
29992 |a
29993 |}
29994 !! end
29995
29996 !! test
29997 Serialize new table rows in a HTML table using HTML tags
29998 !! options
29999 parsoid={
30000 "modes": ["wt2wt", "selser"],
30001 "changes": [
30002 [ "tr", "before", "<tr><td>X</td></tr>" ]
30003 ]
30004 }
30005 !! wikitext
30006 <table><tr><td>a</td></tr></table>
30007 !! wikitext/edited
30008 <table><tr><td>X</td></tr><tr><td>a</td></tr></table>
30009 !! end
30010
30011 !! test
30012 Serialize new table cells in a HTML row using HTML tags
30013 !! options
30014 parsoid={
30015 "modes": ["wt2wt", "selser"],
30016 "changes": [
30017 [ "td", "before", "<td>X</td>" ]
30018 ]
30019 }
30020 !! wikitext
30021 <table><tr><td>a</td></tr></table>
30022 !! wikitext/edited
30023 <table><tr><td>X</td><td>a</td></tr></table>
30024 !! end
30025
30026 !! test
30027 Serialize wikitext list items as HTML list items when embedded in a HTML list
30028 !! options
30029 parsoid=html2wt
30030 !! html/parsoid
30031 <ul data-parsoid='{"stx": "html"}'>
30032 <li data-parsoid='{}'>a</li>
30033 <li>b</li>
30034 </ul>
30035 !! wikitext
30036 <ul>
30037 <li>a</li>
30038 <li>b</li>
30039 </ul>
30040 !! html/php+tidy
30041 <ul>
30042 <li>a</li>
30043 <li>b</li>
30044 </ul>
30045 !! end
30046
30047 # Nested list should be inside <li>, that is
30048 # <ul><li>foo<ul>..</ul></li></ul> instead of
30049 # <ul><li>foo</li><ul>..</ul></ul>
30050 # See https://stackoverflow.com/questions/5899337/proper-way-to-make-html-nested-list
30051 !! test
30052 Wikitext lists can be nested inside HTML lists
30053 !! options
30054 parsoid=html2wt
30055 !! html/parsoid
30056 <ul data-parsoid='{"stx": "html"}'>
30057 <li data-parsoid='{"stx": "html"}'>a
30058 <ul><li>b</li></ul>
30059 </li>
30060 </ul>
30061
30062 <ul data-parsoid='{"stx": "html"}'>
30063 <li>x
30064 <ul><li>y</li></ul>
30065 </li>
30066 </ul>
30067 !! wikitext
30068 <ul>
30069 <li>a
30070 * b
30071 </li>
30072 </ul>
30073
30074 <ul>
30075 <li>x
30076 * y
30077 </li>
30078 </ul>
30079 !! html/php+tidy
30080 <ul>
30081 <li>a
30082 <ul><li>b</li></ul>
30083 </li>
30084 </ul>
30085 <ul>
30086 <li>x
30087 <ul><li>y</li></ul>
30088 </li>
30089 </ul>
30090 !! end
30091
30092 !! test
30093 WTS change modes
30094 !! options
30095 parsoid={
30096 "modes": ["wt2wt"],
30097 "changes": [
30098 [ "#xyz", "before", "<b>before</b> stuff " ],
30099 [ "#xyz", "after", " stuff <i>after</i>" ],
30100 [ "#xyz", "html", "x <b>y</b> z" ]
30101 ]
30102 }
30103 !! wikitext
30104 <span id="xyz">hello</span>
30105 !! wikitext/edited
30106 '''before''' stuff <span id="xyz">x '''y''' z</span> stuff ''after''
30107 !! end
30108
30109 !! test
30110 Never serialize a-tag as html, regardless of what data-parsoid has to say
30111 !! options
30112 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
30113 !! html/parsoid
30114 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a>
30115 !! wikitext
30116 [[Foo]]
30117 !! end
30118
30119 ## SSS FIXME: This is broken output nevertheless.
30120 ## What might be a reasonable non-broken output for this?
30121 ## This is an edge case unlikely to be seen in production
30122 ## that I am not wasting more time on this right now.
30123 !! test
30124 Never serialize a-tag as html, no matter what attributes it has
30125 !! options
30126 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
30127 !! html/parsoid
30128 <a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a>
30129 !! wikitext
30130 [http://boo.org http://boohoo.org]
30131 !! end
30132
30133 # Misnested is an indication that selser can reuse the source but these have
30134 # shown to sneak through on occasion. See T101768.
30135 # The original wikitext here is: [http://test.com [[one]] two three]
30136 !! test
30137 Strip span tags added to mark misnested links
30138 !! options
30139 parsoid=html2wt
30140 !! html/parsoid
30141 <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>
30142 !! wikitext
30143 [http://test.com][[one]] two three
30144 !! end
30145
30146 !! test
30147 Catch regression when unpacking misnested links
30148 !! options
30149 parsoid=wt2html
30150 !! wikitext
30151 {{echo|hi}}[http://example.com [[ho]]]
30152 !! html/parsoid
30153 <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>
30154 !! end
30155
30156 !! test
30157 Catch regression when unpacking with trailing content
30158 !! wikitext
30159 {{echo|Foo <references/> bar}}
30160 !! html/parsoid
30161 <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>
30162 !! end
30163
30164 !! test
30165 Use data-parsoid.firstWikitextNode to compute newline constraints for template content
30166 !! options
30167 parsoid=html2wt
30168 !! html/parsoid
30169 <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|}"]}'>
30170 <tbody><tr><td>d
30171 </td></tr>
30172 </tbody></table>
30173 !! wikitext
30174 {{echo|a}}
30175 {|{{echo|c
30176 {{!}}d
30177 }}
30178 |}
30179 !! end
30180
30181 ## This test verifies the presence and computation of this attribute indirectly
30182 ## by making an edit and ensuring that the serialization is correct (which it would be
30183 ## only if firstWikitextNode is properly set).
30184 !! test
30185 data-parsoid.firstWikitextNode should be computed properly in the presence of fostered content
30186 !! options
30187 parsoid= {
30188 "modes": ["wt2wt"],
30189 "changes": [
30190 [ "div#x", "remove" ],
30191 [ "div", "before", "<div>new</div>" ]
30192 ]
30193 }
30194 !! wikitext
30195 <div id="x">foo</div>
30196 {|
30197 {{echo|<div>boo</div>
30198 {{!}}b}}
30199 |c
30200 |}
30201 !! wikitext/edited
30202
30203 <div>new</div>
30204 {|
30205 {{echo|<div>boo</div>
30206 {{!}}b}}
30207 |c
30208 |}
30209 !! end
30210
30211 # --------------------------------------------
30212 # Tests spec'ing wikitext serialization norms |
30213 # --------------------------------------------
30214
30215 !! test
30216 Serialize multi-line indent-pre starting with wikitext syntax
30217 !! options
30218 parsoid=html2wt
30219 !! html/parsoid
30220 <pre>* 1
30221 ** 2
30222 * 3</pre>
30223 !! wikitext
30224 * 1
30225 ** 2
30226 * 3
30227 !! end
30228
30229 !! test
30230 1. Categories should always be serialized on their own line
30231 !! options
30232 parsoid=html2wt
30233 !! html/parsoid
30234 foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar
30235 !! wikitext
30236 foo
30237 [[Category:Foo]]
30238 bar
30239 !! end
30240
30241 !! test
30242 2. Categories that are part of templates should not introduce a line break
30243 !! wikitext
30244 foo {{echo|<span>bar</span> [[Category:baz]]}} bar
30245 !! html/parsoid
30246 <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>
30247 !! end
30248
30249 # Careful while editing these next 2 tests. There are \u200f characters
30250 # before and after the <link> tags in the HTML and following some
30251 # of the categories in wikitext
30252 # Do not remove these characters in edits.
30253 #
30254 # As part of the serialization, these bidi characters will get stripped.
30255 !! test
30256 RTL (\u200f) and LTR (\u200e) markers around category tags should be stripped
30257 !! options
30258 parsoid={
30259 "modes": ["html2wt"],
30260 "scrubWikitext": true
30261 }
30262 !! html/parsoid
30263 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏
30264 ‏<link rel="mw:PageProp/Category" href="./קטגוריה:_שיטות_משפט" />‏</p>
30265 !! wikitext
30266 [[קטגוריה:טקסים]]
30267 [[קטגוריה: שיטות משפט]]
30268 !! end
30269
30270 !! test
30271 RTL (\u200f) and LTR (\u200e) markers should not be stripped if followed by a text node
30272 !! options
30273 parsoid={
30274 "modes": ["html2wt"],
30275 "scrubWikitext": true
30276 }
30277 !! html/parsoid
30278 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏y</p>
30279 !! wikitext
30280 [[קטגוריה:טקסים]]
30281 ‏y
30282 !! end
30283
30284 !! test
30285 Lists: Add space after bullets
30286 !! options
30287 parsoid=html2wt
30288 !! html/parsoid
30289 <ul>
30290 <li>foo</li>
30291 <li> bar</li>
30292 <li><span> baz</span></li>
30293 </ul>
30294 !! wikitext
30295 * foo
30296 * bar
30297 * <span> baz</span>
30298 !! end
30299
30300 !! test
30301 1. Headings: Add space before/after == (T53744)
30302 !! options
30303 parsoid=html2wt
30304 !! html/parsoid
30305 <h2>foo</h2>
30306 <h2> bar</h2>
30307 <h2>baz </h2>
30308 <h2><span> baz</span></h2>
30309 !! wikitext
30310 == foo ==
30311
30312 == bar ==
30313
30314 == baz ==
30315
30316 == <span> baz</span> ==
30317 !! end
30318
30319 !! test
30320 2. Headings: Add space before/after == even after hoisted content
30321 !! options
30322 parsoid={
30323 "modes": ["html2wt"],
30324 "scrubWikitext": true
30325 }
30326 !! html/parsoid
30327 <h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2>
30328 !! wikitext
30329 [[Category:A2]]
30330
30331 == ok ==
30332 !! end
30333
30334 !! test
30335 1. Headings: suppress newly created empty headings
30336 !! options
30337 parsoid={
30338 "modes": ["html2wt"],
30339 "scrubWikitext": true
30340 }
30341 !! html/parsoid
30342 <h2></h2>
30343 !! wikitext
30344 !! end
30345
30346 !! test
30347 2. Headings: don't suppress empty headings if scrubWikitext is false
30348 !! options
30349 parsoid=html2wt
30350 !! html/parsoid
30351 <h2></h2>
30352 !! wikitext
30353 ==<nowiki/>==
30354 !! end
30355
30356 !! test
30357 3. Headings: suppress empty headings on edits
30358 !! options
30359 parsoid={
30360 "modes": ["selser"],
30361 "scrubWikitext": true,
30362 "changes": [
30363 [ "#x", "remove"]
30364 ]
30365 }
30366 !! wikitext
30367 ==<span id="x">foo</span>==
30368 !! wikitext/edited
30369 !! end
30370
30371 !! test
30372 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = true)
30373 !! options
30374 parsoid={
30375 "modes": ["html2wt"],
30376 "scrubWikitext": true
30377 }
30378 !! html/parsoid
30379 <h2>foo<br/>bar</h2>
30380 <h2>foo <span><br/>bar</span> baz</h2>
30381 !! wikitext
30382 == foo bar ==
30383
30384 == foo <span> bar</span> baz ==
30385 !! end
30386
30387 !! test
30388 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = false)
30389 !! options
30390 parsoid={
30391 "modes": ["html2wt"],
30392 "scrubWikitext": false
30393 }
30394 !! html/parsoid
30395 <h2>foo<br/>bar</h2>
30396 !! wikitext
30397 == foo<br />bar ==
30398 !! end
30399
30400 !! test
30401 1. WT Quote Tags: suppress newly created empty style tags
30402 !! options
30403 parsoid={
30404 "modes": ["html2wt"],
30405 "scrubWikitext": true
30406 }
30407 !! html/parsoid
30408 <i></i><b></b>
30409 !! wikitext
30410 !! end
30411
30412 !! test
30413 2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false
30414 !! options
30415 parsoid=html2wt
30416 !! html/parsoid
30417 <i></i><b></b>
30418 !! wikitext
30419 ''<nowiki/>'''''<nowiki/>'''
30420 !! end
30421
30422 !! test
30423 3. WT Quote Tags: suppress empty style tags on edits
30424 !! options
30425 parsoid={
30426 "modes": ["selser"],
30427 "scrubWikitext": true,
30428 "changes": [
30429 [ "#x", "remove"]
30430 ]
30431 }
30432 !! wikitext
30433 '''<span id="x">foo</span>'''
30434 !! wikitext/edited
30435 !! end
30436
30437 !! test
30438 1. Anchors: suppress newly created empty anchors
30439 !! options
30440 parsoid={
30441 "modes": ["html2wt"],
30442 "scrubWikitext": true
30443 }
30444 !! html/parsoid
30445 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
30446 !! wikitext
30447 !! end
30448
30449 !! test
30450 2. Anchors: don't suppress empty anchors if scrubWikitext is false
30451 !! options
30452 parsoid={
30453 "modes": ["html2wt"],
30454 "scrubWikitext": false
30455 }
30456 !! html/parsoid
30457 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
30458 !! wikitext
30459 [[Test|<nowiki/>]]
30460 !! end
30461
30462 !! test
30463 3. Anchors: suppress empty anchors on edits
30464 !! options
30465 parsoid={
30466 "modes": ["selser"],
30467 "scrubWikitext": true,
30468 "changes": [
30469 [ "#x", "remove"]
30470 ]
30471 }
30472 !! wikitext
30473 [[Test|<span id="x">foo</span>]]
30474 !! wikitext/edited
30475 !! end
30476
30477 !! test
30478 3a. Anchors: do not suppress numbered extlinks
30479 !! options
30480 parsoid={
30481 "modes": ["wt2wt"],
30482 "scrubWikitext": true
30483 }
30484 !! wikitext
30485 [http://foo.com]
30486 !! html/parsoid
30487 <a rel="mw:ExtLink" href="http://foo.com"></a>
30488 !! end
30489
30490 !! test
30491 3b. Anchors: do not suppress numbered extlinks
30492 !! options
30493 parsoid={
30494 "modes": ["wt2wt"],
30495 "scrubWikitext": true,
30496 "changes": [
30497 [ "#x", "remove"]
30498 ]
30499 }
30500 !! wikitext
30501 [http://foo.com <span id="x">foo</span>]
30502 !! wikitext/edited
30503 [http://foo.com]
30504 !! end
30505
30506 !!test
30507 Normalizations should be restricted to edited content
30508 !!options
30509 parsoid={
30510 "modes": ["selser"],
30511 "scrubWikitext": true,
30512 "changes": [
30513 [ "h1", "before", "<i></i>"]
30514 ]
30515 }
30516 !!wikitext
30517 a
30518 = =
30519 b
30520 !!wikitext/edited
30521 a
30522 = =
30523 b
30524 !!end
30525
30526 !! test
30527 1. Multiple normalizations (html2wt)
30528 !! options
30529 parsoid={
30530 "modes": ["html2wt"],
30531 "scrubWikitext": true
30532 }
30533 !! html/parsoid
30534 <h2><i></i></h2>
30535 <p><a href='Foo' rel='mw:WikiLink'>foo<i></i>
30536 </a><b><i></i></b>x</p>
30537 !! wikitext
30538
30539 [[foo]]
30540 x
30541
30542 !! end
30543
30544 !! test
30545 2. Multiple normalizations (selser)
30546 !! options
30547 parsoid={
30548 "modes": ["selser"],
30549 "scrubWikitext": true,
30550 "changes": [
30551 [ "#x", "after", "<h1><i></i></h1>\n<p> bar<b></b></p>"]
30552 ]
30553 }
30554 !! wikitext
30555 <div id="x">foo</div>
30556 !! wikitext/edited
30557 <div id="x">foo</div>
30558 bar
30559 !! end
30560
30561 !! test
30562 1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
30563 !! options
30564 parsoid={
30565 "modes": ["html2wt"],
30566 "scrubWikitext": true
30567 }
30568 !! html/parsoid
30569 <p> hi</p>
30570 <p> hello</p>
30571 !! wikitext
30572 hi
30573
30574 hello
30575 !! end
30576
30577 !! test
30578 2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false
30579 !! options
30580 parsoid=html2wt
30581 !! html/parsoid
30582 <p> hi</p>
30583 <p> hello</p>
30584 !! wikitext
30585 <nowiki> </nowiki>hi
30586
30587 <nowiki> </nowiki> hello
30588 !! end
30589
30590 !! test
30591 3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
30592 !! options
30593 parsoid={
30594 "modes": ["html2wt"],
30595 "scrubWikitext": true
30596 }
30597 !! html/parsoid
30598 <p>Foo
30599 bar
30600 baz</p>
30601
30602 <table><tr><td>Foo
30603 bar
30604 baz bang</td></tr></table>
30605
30606 <p><!--boo--> foo
30607 bar</p>
30608
30609 <p> foo
30610 bar<span>boo</span></p>
30611 !! wikitext
30612 Foo
30613 bar
30614 baz
30615
30616 {|
30617 |Foo
30618 bar
30619 baz bang
30620 |}
30621
30622 <!--boo-->foo
30623 bar
30624
30625 foo
30626 bar<span>boo</span>
30627 !! end
30628
30629 !! test
30630 4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs
30631 !! options
30632 parsoid={
30633 "modes": ["selser"],
30634 "scrubWikitext": true,
30635 "changes": [
30636 [ "p", "html", " a\n b" ]
30637 ]
30638 }
30639 !! wikitext
30640 xyz
30641 !! wikitext/edited
30642 a
30643 b
30644 !! end
30645
30646 !! test
30647 1. New links that end in spaces
30648 !! options
30649 parsoid={
30650 "modes": ["html2wt"],
30651 "scrubWikitext": false
30652 }
30653 !! html/parsoid
30654 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
30655 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
30656 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
30657 !! wikitext
30658 [[Berlin ]]<nowiki/>is the capital of Germany.
30659
30660 [[Foo ]]'''bar'''
30661
30662 [[Boston ]] is a city.
30663 !! end
30664
30665 !! test
30666 2. New links that end in spaces
30667 !! options
30668 parsoid={
30669 "modes": ["html2wt"],
30670 "scrubWikitext": true
30671 }
30672 !! html/parsoid
30673 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
30674 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
30675 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
30676 !! wikitext
30677 [[Berlin]] is the capital of Germany.
30678
30679 [[Foo]] '''bar'''
30680
30681 [[Boston]] is a city.
30682 !! end
30683
30684 !! test
30685 1. Table cells with escapable prefixes
30686 !! options
30687 parsoid={
30688 "modes": ["html2wt"],
30689 "scrubWikitext": false
30690 }
30691 !! html/parsoid
30692 <table>
30693 <tr><td>a</td></tr>
30694 <tr><td>-</td></tr>
30695 <tr><td>+</td></tr>
30696 </table>
30697 !! wikitext
30698 {|
30699 |a
30700 |-
30701 |<nowiki>-</nowiki>
30702 |-
30703 |<nowiki>+</nowiki>
30704 |}
30705 !! end
30706
30707 !! test
30708 2. Table cells with escapable prefixes
30709 !! options
30710 parsoid={
30711 "modes": ["html2wt"],
30712 "scrubWikitext": true
30713 }
30714 !! html/parsoid
30715 <table>
30716 <tr><td>a</td></tr>
30717 <tr><td>-</td></tr>
30718 <tr><td>+</td></tr>
30719 </table>
30720 !! wikitext
30721 {|
30722 |a
30723 |-
30724 | -
30725 |-
30726 | +
30727 |}
30728 !! end
30729
30730 !! test
30731 3a. Table cells with escapable prefixes after edits
30732 !! options
30733 parsoid={
30734 "modes": ["selser"],
30735 "scrubWikitext": true,
30736 "changes": [
30737 [ "table tbody tr:first-child td:first-child", "remove"]
30738 ]
30739 }
30740 !! wikitext
30741 {|
30742 |a||-
30743 |}
30744 !! wikitext/edited
30745 {|
30746 | -
30747 |}
30748 !! end
30749
30750 !! test
30751 3b. Table cells with escapable prefixes after edits
30752 !! options
30753 parsoid={
30754 "modes": ["selser"],
30755 "scrubWikitext": true,
30756 "changes": [
30757 [ "table tbody tr:first-child td:first-child", "html", "-" ],
30758 [ "#x", "remove" ]
30759 ]
30760 }
30761 !! wikitext
30762 {|
30763 |pqr
30764 |<span id="x">foo</span>+
30765 |}
30766 !! wikitext/edited
30767 {|
30768 | -
30769 | +
30770 |}
30771 !! end
30772
30773 # FIXME: This test will fail because
30774 # normalization doesn't realize that the id attribute
30775 # will eliminate the escapable scenario
30776 !! test
30777 4a. Table cells without escapable prefixes after edits
30778 !! options
30779 parsoid={
30780 "modes": ["selser"],
30781 "scrubWikitext": true,
30782 "changes": [
30783 [ "#x", "html", "-" ]
30784 ]
30785 }
30786 !! wikitext
30787 {|
30788 | id="x" |abcd
30789 |}
30790 !! wikitext/edited
30791 {|
30792 | id="x" |-
30793 |}
30794 !! end
30795
30796 ## This tests normalizer's ability to discriminate between
30797 ## cells having identical content.
30798 !! test
30799 4b. Table cells without escapable prefixes after edits
30800 !! options
30801 parsoid={
30802 "modes": ["selser"],
30803 "scrubWikitext": true,
30804 "changes": [
30805 [ "td", "html", "-" ]
30806 ]
30807 }
30808 !! wikitext
30809 {|
30810 |a||b
30811 |}
30812 !! wikitext/edited
30813 {|
30814 | -||-
30815 |}
30816 !! end
30817
30818 ## This tests normalizer's ability to not be tripped by
30819 ## comments (and whitespace)
30820 !! test
30821 4c. Table cells without escapable prefixes after edits
30822 !! options
30823 parsoid={
30824 "modes": ["selser"],
30825 "scrubWikitext": true,
30826 "changes": [
30827 [ "table tbody tr td:first-child", "remove" ]
30828 ]
30829 }
30830 !! wikitext
30831 {|
30832 |-
30833 <!--foo--> |a||-
30834 |}
30835 !! wikitext/edited
30836 {|
30837 |-
30838 <!--foo--> | -
30839 |}
30840 !! end
30841
30842 ## This tests normalizer's ability to handle HTML cells
30843 !! test
30844 4d. Table cells without escapable prefixes after edits
30845 !! options
30846 parsoid={
30847 "modes": ["selser"],
30848 "scrubWikitext": true,
30849 "changes": [
30850 [ "td", "html", "-" ]
30851 ]
30852 }
30853 !! wikitext
30854 <table>
30855 <tr><td>a</td></tr>
30856 </table>
30857 !! wikitext/edited
30858 <table>
30859 <tr><td>-</td></tr>
30860 </table>
30861 !! end
30862
30863 ## T111151 Remove font elements without attributes
30864 !! test
30865 5a. font tags without attributes should be dropped in scrubWikitext mode
30866 !! options
30867 parsoid={
30868 "modes": ["html2wt"],
30869 "scrubWikitext": true
30870 }
30871 !! html/parsoid
30872 <font>foo</font>
30873 <font><font>bar</font></font>
30874 <font class="x">boo</font>
30875 !! wikitext
30876 foo
30877 bar
30878 <font class="x">boo</font>
30879 !! end
30880
30881 !! test
30882 5b. font tags should not be dropped without scrubWikitext being enabled
30883 !! options
30884 parsoid={
30885 "modes": ["html2wt"],
30886 "scrubWikitext": false
30887 }
30888 !! html/parsoid
30889 <font>foo</font>
30890 !! wikitext
30891 <font>foo</font>
30892 !! end
30893
30894 !! test
30895 Escape nowiki DOM elements
30896 !! options
30897 parsoid=html2wt
30898 !! html/parsoid
30899 <nowiki><i>foo</i></nowiki>
30900 !! wikitext
30901 &lt;nowiki&gt;''foo''&lt;/nowiki&gt;
30902 !! end
30903
30904 # This is meant to be an interim fix while we go about figuring out
30905 # how to not introduce these trailing <nowiki/>s in the first place.
30906 !! test
30907 T115717: Strip trailing <nowiki/>s (without affecting valid uses)
30908 !! options
30909 parsoid=html2wt
30910 !! html/parsoid
30911 <p>x<meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/>
30912 y</p>
30913 <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>
30914 <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>
30915 !! wikitext
30916 x
30917 y
30918
30919 {{echo|
30920 1 = <nowiki/>}}
30921
30922 {{echo|
30923 1 = <nowiki/>
30924 }}
30925 !! end
30926
30927 !! test
30928 New list is serialized on newlines
30929 !! options
30930 parsoid=html2wt
30931 !! html/parsoid
30932 <p>The quick brown fox jumps over the lazy dog.</p><ul>
30933 <li>Yesterday</li>
30934 <li>Today</li>
30935 <li>Tomorrow</li>
30936 </ul><p>The quick onyx goblin jumps over the lazy dwarf.</p>
30937 !! wikitext
30938 The quick brown fox jumps over the lazy dog.
30939
30940 * Yesterday
30941 * Today
30942 * Tomorrow
30943
30944 The quick onyx goblin jumps over the lazy dwarf.
30945 !! end
30946
30947 !! test
30948 New lists in formatting elements serialized w/o newlines
30949 !! options
30950 parsoid=html2wt
30951 !! html/parsoid
30952 <small>
30953
30954 <ul>
30955 <li>123</li>
30956 </ul>
30957
30958 </small>
30959
30960 <small><ul><li>hi</li></ul></small>
30961 !! wikitext
30962 <small>
30963 * 123
30964 </small>
30965
30966 <small>
30967 * hi
30968 </small>
30969 !! end
30970
30971 !! test
30972 New list in table doesn't need newlines
30973 !! options
30974 parsoid=html2wt
30975 !! html/parsoid
30976 <table><tr><td><ul><li>test</li><li>123</li></td></tr></table>
30977 !! wikitext
30978 {|
30979 |
30980 * test
30981 * 123
30982 |}
30983 !! end
30984
30985 # ---------------------------------------------------
30986 # End of tests spec'ing wikitext serialization norms |
30987 # ---------------------------------------------------
30988
30989 # T104032
30990 !! test
30991 Bare inline nodes not wrapped inside p-tags should be treated as p-wrapped
30992 !! options
30993 parsoid=html2wt
30994 !! html/parsoid
30995 a<p>b</p>
30996 <b>c</b><p>d</p>
30997 <table><tr>
30998 <td>a<p>b</p></td>
30999 <td><b>c</b><p>d</p></td>
31000 </tr></table>
31001 !! wikitext
31002 a
31003
31004 b
31005
31006 '''c'''
31007
31008 d
31009 {|
31010 |a
31011 b
31012 |'''c'''
31013 d
31014 |}
31015 !! end
31016
31017 !! test
31018 Anchor without href scenarios
31019 !! options
31020 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
31021 !! html/parsoid
31022 <a class="bc"></a>
31023 <a class="no">dice</a>
31024 <a name="foo"></a>
31025 !! wikitext
31026
31027 dice
31028 <span name="foo"></span>
31029 !! end
31030
31031 !! test
31032 New transclusion added after a list should be serialized after the list
31033 !! options
31034 parsoid=html2wt
31035 !! html/parsoid
31036 <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>
31037 !! wikitext
31038 * a
31039 {{echo|foo}}
31040 !! end
31041
31042 # -----------------------------------------------------------------
31043 # End of section for Parsoid-only html2wt tests for serialization
31044 # of new content
31045 # -----------------------------------------------------------------
31046
31047 # -----------------------------------------------------------------
31048 # The following section of tests are primarily to spec behavior of
31049 # the selective serializer. All these tests have manual selser
31050 # changes. The automated selser changes for all tests handle the
31051 # wide variation of changes, but these tests here capture specs
31052 # deterministically.
31053 # ----------------------------------------------------------------
31054
31055 ## T90517
31056 !! test
31057 Selser: New comments should not be lost
31058 !! options
31059 parsoid={
31060 "modes": ["selser"],
31061 "changes": [
31062 [ "#a", "after", "<!--c1-->" ],
31063 [ "#b", "before", "<!--c2-->" ]
31064 ]
31065 }
31066 !! wikitext
31067 <span id="a">a</span>
31068
31069 <span id="b">b</span>
31070 !! wikitext/edited
31071 <span id="a">a</span><!--c1-->
31072
31073 <!--c2--><span id="b">b</span>
31074 !! end
31075
31076 ## T89383
31077 !! test
31078 Selser: Check for validity of DSR before using it
31079 !! options
31080 parsoid={
31081 "modes": ["selser"],
31082 "changes": [
31083 [ "#a", "before", "<meta property='mw:PageProp/displaytitle' content='foo'>" ]
31084 ]
31085 }
31086 !! wikitext
31087 <span id="a">a</span>
31088 !! wikitext/edited
31089 {{DISPLAYTITLE:foo}}
31090 <span id="a">a</span>
31091 !! end
31092
31093 !! test
31094 1. DOMDiff: Changes to <ref> content should be looked up using id
31095 !! options
31096 parsoid={
31097 "modes": ["selser"],
31098 "changes": [
31099 ["#X", "after", "bar"],
31100 ["#Y", "after", "baz"]
31101 ]
31102 }
31103 !! wikitext
31104 X <ref><span id="X">foo</span></ref>
31105 Y <ref name="a" />
31106 <references>
31107 <ref name="a"><span id="Y">foo</span></ref>
31108 </references>
31109 !! wikitext/edited
31110 X <ref><span id="X">foo</span>bar</ref>
31111 Y <ref name="a" />
31112 <references>
31113 <ref name="a"><span id="Y">foo</span>baz</ref>
31114 </references>
31115 !! end
31116
31117 !! test
31118 2. DOMDiff: Changes to <ref> content should be looked up using id
31119 !! options
31120 parsoid={
31121 "modes": ["selser"],
31122 "changes": [
31123 ["#Z", "after", "bar"]
31124 ]
31125 }
31126 !! wikitext
31127 A <ref>foo bar for a</ref>
31128 B <ref group="X" name="b" />
31129
31130 <references />
31131
31132 <references group="X">
31133 <ref name="b"><span id="Z">foo</span></ref>
31134 </references>
31135 !! wikitext/edited
31136 A <ref>foo bar for a</ref>
31137 B <ref group="X" name="b" />
31138
31139 <references />
31140
31141 <references group="X">
31142 <ref name="b"><span id="Z">foo</span>bar</ref>
31143 </references>
31144 !! end
31145
31146 !! test
31147 DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388)
31148 !! options
31149 parsoid={
31150 "modes": ["selser"],
31151 "changes": [
31152 [ "div:first-child", "text", "bar" ]
31153 ]
31154 }
31155 !! wikitext
31156 <div style="{{1x|color:red;}}%">foo</div>
31157 !! wikitext/edited
31158 <div style="{{1x|color:red;}}%">bar</div>
31159 !! end
31160
31161 !! test
31162 Empty LI (T49673)
31163 !! wikitext
31164 *a
31165 *
31166 *
31167 *b
31168 !! html+tidy
31169 <ul><li>a</li>
31170 <li class="mw-empty-elt"></li>
31171 <li class="mw-empty-elt"></li>
31172 <li>b</li></ul>
31173 !! end
31174
31175 !! test
31176 Thumbnail output
31177 !! wikitext
31178 [[File:Thumb.png|thumb]]
31179 !! html/php+tidy
31180 <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>
31181 !! html/parsoid
31182 <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>
31183 !! end
31184
31185 !! test
31186 unclosed internal link XSS (T137264)
31187 !! wikitext
31188 [[#%3Cscript%3Ealert(1)%3C/script%3E|
31189 !! html/php
31190 <p>[[#&lt;script&gt;alert(1)&lt;/script&gt;|
31191 </p>
31192 !! html/parsoid
31193 <p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p>
31194 !! end
31195
31196 !! test
31197 Validating that <style> isn't eaten by tidy (T167349)
31198 !! options
31199 styletag=1
31200 !! wikitext
31201 <div class="foo">
31202 <style>.foo::before { content: "<foo>"; }</style>
31203 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
31204 </div>
31205 !! html/php+tidy
31206 <div class="foo">
31207 <style>.foo::before { content: "<foo>"; }</style>
31208 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
31209 </div>
31210 !! html/parsoid
31211 <div class="foo">
31212 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31213 <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>
31214 </div>
31215 !! end
31216
31217 ## Right now, Parsoid doesn't de-duplicate style tags.
31218 ## So, we shouldn't see link tags that need to bypass the sanitizer.
31219 ## In a followup patch, when we de-duplicate style tags and
31220 ## introduce link tags, we'll add a hook for link tags in
31221 ## the parser test runner script.
31222 !! test
31223 Validating that <style> isn't wrapped in a paragraph (T186965)
31224 !! options
31225 styletag=1
31226 !! wikitext
31227 A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31228
31229 <style>.foo::before { content: "<foo>"; }</style>
31230
31231 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
31232
31233 But if it's on a line with other content, let it be wrapped.
31234
31235 <style>.foo::before { content: "<foo>"; }</style> bar
31236
31237 foo <style>.foo::before { content: "<foo>"; }</style>
31238
31239 foo <style>.foo::before { content: "<foo>"; }</style> bar
31240
31241 And the same if we have non-paragraph-breaking whitespace
31242
31243 foo
31244 <style>.foo::before { content: "<foo>"; }</style>
31245 bar
31246 !! html/php
31247 <p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31248 </p>
31249 <style>.foo::before { content: "<foo>"; }</style>
31250 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
31251 <p>But if it's on a line with other content, let it be wrapped.
31252 </p><p><style>.foo::before { content: "<foo>"; }</style> bar
31253 </p><p>foo <style>.foo::before { content: "<foo>"; }</style>
31254 </p><p>foo <style>.foo::before { content: "<foo>"; }</style> bar
31255 </p><p>And the same if we have non-paragraph-breaking whitespace
31256 </p><p>foo
31257 <style>.foo::before { content: "<foo>"; }</style>
31258 bar
31259 </p>
31260 !! html/parsoid
31261 <p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph</p>
31262
31263 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31264
31265 <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>
31266
31267 <p>But if it's on a line with other content, let it be wrapped.</p>
31268
31269 <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>
31270
31271 <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>
31272
31273 <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>
31274
31275 <p>And the same if we have non-paragraph-breaking whitespace</p>
31276
31277 <p>foo
31278 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31279 bar</p>
31280 !! end
31281
31282 !! test
31283 Validating that <link> isn't wrapped in a paragraph (T186965)
31284 !! options
31285 styletag=1
31286 !! wikitext
31287 A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31288
31289 <link rel="foo" href="bar"/>
31290
31291 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
31292
31293 But if it's on a line with other content, let it be wrapped.
31294
31295 <link rel="foo" href="bar"/> bar
31296
31297 foo <link rel="foo" href="bar"/>
31298
31299 foo <link rel="foo" href="bar"/> bar
31300
31301 And the same if we have non-paragraph-breaking whitespace
31302
31303 foo
31304 <link rel="foo" href="bar"/>
31305 bar
31306 !! html/php
31307 <p>A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31308 </p>
31309 <link rel="foo" href="bar"/>
31310 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
31311 <p>But if it's on a line with other content, let it be wrapped.
31312 </p><p><link rel="foo" href="bar"/> bar
31313 </p><p>foo <link rel="foo" href="bar"/>
31314 </p><p>foo <link rel="foo" href="bar"/> bar
31315 </p><p>And the same if we have non-paragraph-breaking whitespace
31316 </p><p>foo
31317 <link rel="foo" href="bar"/>
31318 bar
31319 </p>
31320 !! end
31321
31322 !! test
31323 Extension returning multiple nodes starting with a style tag roundtrips
31324 !! options
31325 wgRawHtml=1
31326 !! wikitext
31327 <table>
31328 {{echo|<html><style>.hi { color: red; }</style>
31329 </html>}}
31330 <tr><td class="hi">ho</td></tr>
31331 </table>
31332 !! html/parsoid
31333 <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">
31334 </span></p><table about="#mwt5" data-parsoid='{"stx":"html"}'>
31335
31336 <tbody><tr><td class="hi">ho</td></tr>
31337 </tbody></table>
31338 !! end
31339
31340 !! test
31341 Decoding of HTML entities in headings and links for IDs and link fragments (T103714)
31342 !! config
31343 wgFragmentMode=[ 'html5', 'legacy' ]
31344 !! wikitext
31345 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
31346 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
31347 !! html/php
31348 <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>
31349 <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>
31350 </p>
31351 !! html/parsoid
31352 <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>
31353 <p><a rel="mw:WikiLink" href="./Main_Page#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E"},"sa":{"href":"#A&amp;B&amp;amp;C&amp;amp;amp;D&amp;amp;amp;amp;E"}}'>#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a></p>
31354 !! end
31355
31356 !! test
31357 Decoding of HTML entities in headings and links for IDs and link fragments (T103714) (legacy)
31358 !! config
31359 wgFragmentMode=[ 'legacy' ]
31360 !! wikitext
31361 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
31362 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
31363 !! html/php
31364 <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>
31365 <p><a href="#A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a>
31366 </p>
31367 !! end
31368
31369 !! test
31370 Decoding of HTML entities in embedded HTML tags
31371 !! wikitext
31372 <table class="1&2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
31373 !! html/php
31374 <table class="1&amp;2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
31375
31376 !! html/parsoid
31377 <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>
31378 !! end
31379
31380 !! test
31381 Decoding of HTML entities in indicator names for IDs (T104196)
31382 !! options
31383 parsoid=wt2html,html2html
31384 showindicators
31385 !! wikitext
31386 <indicator name="1&2&amp;3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
31387 !! html/php
31388 1&2&3&amp;4&amp;amp;5=Indicator
31389
31390 !! html/parsoid
31391 <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>
31392 !! end
31393
31394 # this version of the test strips out the ambiguity so Parsoid rts cleanly
31395 !! test
31396 Decoding of HTML entities in indicator names for IDs (unambiguous) (T104196)
31397 !! options
31398 showindicators
31399 !! wikitext
31400 <indicator name="1&2&3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
31401 !! html/php
31402 1&2&3&amp;4&amp;amp;5=Indicator
31403
31404 !! html/parsoid
31405 <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>
31406 !! end
31407
31408 # This fragment mode is what Parsoid supports.
31409 !! test
31410 HTML5 ids: fallback to legacy
31411 !! config
31412 wgFragmentMode=[ 'html5', 'legacy' ]
31413 !! wikitext
31414 ==Foo bar==
31415
31416 ==foo Bar==
31417
31418 ==Тест==
31419
31420 ==Тест==
31421
31422 ==тест==
31423
31424 ==Hey < # " > % : '==
31425 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31426
31427 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31428
31429 <!-- These two links should produce identical HTML -->
31430 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31431
31432 !! html/php
31433 <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>
31434 <ul>
31435 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31436 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31437 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
31438 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
31439 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
31440 <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>
31441 </ul>
31442 </div>
31443
31444 <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>
31445 <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>
31446 <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>
31447 <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>
31448 <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>
31449 <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>
31450 <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>
31451 </p><p>💩 <span id="💩"></span>
31452 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
31453 </p>
31454 !! html/parsoid
31455 <h2 id="Foo_bar">Foo bar</h2>
31456
31457 <h2 id="foo_Bar_2">foo Bar</h2>
31458
31459 <h2 id="Тест"><span id=".D0.A2.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>Тест</h2>
31460
31461 <h2 id="Тест_2"><span id=".D0.A2.D0.B5.D1.81.D1.82_2" typeof="mw:FallbackId"></span>Тест</h2>
31462
31463 <h2 id="тест"><span id=".D1.82.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>тест</h2>
31464
31465 <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>
31466 <p><a rel="mw:WikiLink" href="./Main_Page#Foo_bar">#Foo bar</a> <a rel="mw:WikiLink" href="./Main_Page#foo_Bar">#foo Bar</a> <a rel="mw:WikiLink" href="./Main_Page#Тест">#Тест</a> <a rel="mw:WikiLink" href="./Main_Page#тест">#тест</a> <a rel="mw:WikiLink" href="./Main_Page#Hey_&lt;_#_&quot;_>_%_:_'" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Hey_&lt;_#_\"_>_%_:_&#39;"},"sa":{"href":"#Hey &lt; # \" > % : &#39;"}}'>#Hey &lt; # " > % : '</a></p>
31467
31468 <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>
31469
31470 <!-- These two links should produce identical HTML -->
31471 <p><a rel="mw:WikiLink" href="./Main_Page#啤酒">#啤酒</a> <a rel="mw:WikiLink" href="./Main_Page#啤酒" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#啤酒"},"sa":{"href":"#%E5%95%A4%E9%85%92"}}'>#啤酒</a></p>
31472 !! end
31473
31474 # Parsoid doesn't support this mode
31475 !! test
31476 HTML5 ids: legacy with a fallback to modern
31477 !! config
31478 wgFragmentMode=[ 'legacy', 'html5' ]
31479 !! wikitext
31480 ==Foo bar==
31481
31482 ==foo Bar==
31483
31484 ==Тест==
31485
31486 ==Тест==
31487
31488 ==тест==
31489
31490 ==Hey < # " > % : '==
31491 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31492
31493 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31494
31495 <!-- These two links should produce identical HTML -->
31496 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31497
31498 !! html/php
31499 <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>
31500 <ul>
31501 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31502 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31503 <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>
31504 <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>
31505 <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>
31506 <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>
31507 </ul>
31508 </div>
31509
31510 <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>
31511 <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>
31512 <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>
31513 <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>
31514 <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>
31515 <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>
31516 <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>
31517 </p><p>.F0.9F.92.A9 <span id=".F0.9F.92.A9"></span>
31518 </p><p><a href="#.E5.95.A4.E9.85.92">#啤酒</a> <a href="#.E5.95.A4.E9.85.92">#啤酒</a>
31519 </p>
31520 !! end
31521
31522 # Parsoid doesn't support this mode.
31523 !! test
31524 HTML5 ids: no legacy
31525 !! config
31526 wgFragmentMode=[ 'html5' ]
31527 !! wikitext
31528 ==Foo bar==
31529
31530 ==foo Bar==
31531
31532 ==Тест==
31533
31534 ==Тест==
31535
31536 ==тест==
31537
31538 ==Hey < # " > % : '==
31539 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31540
31541 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31542
31543 <!-- These two links should produce identical HTML -->
31544 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31545
31546 !! html/php
31547 <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>
31548 <ul>
31549 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31550 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31551 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
31552 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
31553 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
31554 <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>
31555 </ul>
31556 </div>
31557
31558 <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>
31559 <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>
31560 <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>
31561 <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>
31562 <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>
31563 <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>
31564 <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>
31565 </p><p>💩 <span id="💩"></span>
31566 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
31567 </p>
31568 !! end
31569
31570 !! test
31571 T90902: Normalize weird characters in section IDs
31572 !! config
31573 wgFragmentMode=[ 'html5', 'legacy' ]
31574 !! wikitext
31575 ==Foo&nbsp;bar==
31576 [[#Foo&nbsp;bar]]
31577
31578 !! html/php
31579 <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>
31580 <p><a href="#Foo_bar">#Foo&#160;bar</a>
31581 </p>
31582 !! html/parsoid
31583 <h2 id="Foo_bar"> Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span>bar </h2>
31584 <p><a rel="mw:WikiLink" href="./Main_Page#Foo_bar" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Foo_bar"},"sa":{"href":"#Foo&amp;nbsp;bar"}}'>#Foo bar</a></p>
31585 !! end
31586
31587 !! test
31588 T51672: Test for brackets in attributes of elements in external link texts
31589 !! wikitext
31590 [http://example.com/ link <span title="title with [brackets]">span</span>]
31591 [http://example.com/ link <span title="title with &#91;brackets&#93;">span</span>]
31592
31593 !! html/php
31594 <p><a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
31595 <a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
31596 </p>
31597 !! html/parsoid
31598 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/">link <span title="title with [brackets]">span</span></a>
31599 <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>
31600 !! end
31601
31602 !! test
31603 T72875: Test for brackets in attributes of elements in internal link texts
31604 !! wikitext
31605 [[Foo|link <span title="title with [[double brackets]]">span</span>]]
31606 [[Foo|link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span>]]
31607
31608 !! html/php
31609 <p><a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
31610 <a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
31611 </p>
31612 !! html/parsoid
31613 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">link <span title="title with [[double brackets]]">span</span></a>
31614 <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>
31615 !! end
31616
31617 !! test
31618 T199926: html arrow wt: Parsoid sometimes trips up on verticalbar chars in hrefs
31619 !! options
31620 parsoid={
31621 "modes": ["html2wt"]
31622 }
31623 !! html/parsoid
31624 <a href="https://stats.wikimedia.org/v2/#/fr.wikipedia.org/reading/page-views-by-country/normal|map|2-Year~2016060100~2018071100|~total">9</a>
31625 <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>
31626 !! wikitext
31627 [https://stats.wikimedia.org/v2/#/fr.wikipedia.org/reading/page-views-by-country/normal|map|2-Year~2016060100~2018071100|~total 9]
31628 [[stats:v2/#/fr.wikipedia.org/reading/page-views-by-country/normal%7Cmap%7C2-Year~2016060100~2018071100%7C~total|10]]
31629 !! end
31630
31631 !! test
31632 T179544: {{anchorencode:}} output should be always usable in links
31633 !! config
31634 wgFragmentMode=[ 'html5' ]
31635 !! wikitext
31636 <span id="{{anchorencode:[foo]}}"></span>[[#{{anchorencode:[foo]}}]]
31637 !! html/php
31638 <p><span id="&#91;foo&#93;"></span><a href="#[foo]">#&#91;foo&#93;</a>
31639 </p>
31640 !! html/parsoid
31641 <p><span id="[foo]" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html","a":{"id":"[foo]"},"sa":{"id":"{{anchorencode:[foo]}}"}}' data-mw='{"attribs":[[{"txt":"id"},{"html":"&lt;span typeof=\"mw:Transclusion mw:Entity\" about=\"#mwt1\" data-parsoid=&apos;{\"srcContent\":\"[\",\"dsr\":[10,32,null,null],\"pi\":[[]]}&apos; data-mw=&apos;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"anchorencode:[foo]\",\"function\":\"anchorencode\"},\"params\":{},\"i\":0}}]}&apos;>[&lt;/span>&lt;span about=\"#mwt1\" data-parsoid=\"{}\">foo&lt;/span>&lt;span typeof=\"mw:Entity\" about=\"#mwt1\" data-parsoid=&apos;{\"src\":\"&amp;amp;#x5D;\",\"srcContent\":\"]\"}&apos;>]&lt;/span>"}]]}'></span><a typeof="mw:ExpandedAttrs" about="#mwt4" rel="mw:WikiLink" href="./Main_Page#[foo]" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#[foo]"},"sa":{"href":"#{{anchorencode:[foo]}}"}}' data-mw='{"attribs":[[{"txt":"href"},{"html":"#&lt;span typeof=\"mw:Transclusion mw:Entity\" about=\"#mwt2\" data-parsoid=&apos;{\"srcContent\":\"[\",\"dsr\":[44,66,null,null],\"pi\":[[]]}&apos; data-mw=&apos;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"anchorencode:[foo]\",\"function\":\"anchorencode\"},\"params\":{},\"i\":0}}]}&apos;>[&lt;/span>&lt;span about=\"#mwt2\" data-parsoid=\"{}\">foo&lt;/span>&lt;span typeof=\"mw:Entity\" about=\"#mwt2\" data-parsoid=&apos;{\"src\":\"&amp;amp;#x5D;\",\"srcContent\":\"]\"}&apos;>]&lt;/span>"}]]}'>#[foo]</a></p>
31642 !! end
31643
31644 ## ------------------------------
31645 ## Parsoid section-wrapping tests
31646 ## ------------------------------
31647 !! test
31648 Section wrapping for well-nested sections (no leading content)
31649 !! options
31650 parsoid={
31651 "wrapSections": true
31652 }
31653 !! wikitext
31654 =1=
31655 a
31656
31657 =2=
31658 b
31659
31660 ==2.1==
31661 c
31662
31663 ==2.2==
31664 d
31665
31666 ===2.2.1===
31667 e
31668
31669 =3=
31670 f
31671 !! html/parsoid
31672 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
31673 <p>a</p>
31674
31675 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
31676 <p>b</p>
31677
31678 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
31679 <p>c</p>
31680
31681 </section><section data-mw-section-id="4"><h2 id="2.2">2.2</h2>
31682 <p>d</p>
31683
31684 <section data-mw-section-id="5"><h3 id="2.2.1">2.2.1</h3>
31685 <p>e</p>
31686
31687 </section></section></section><section data-mw-section-id="6"><h1 id="3">3</h1>
31688 <p>f</p>
31689
31690 </section>
31691 !! end
31692
31693 !! test
31694 Section wrapping for well-nested sections (with leading content)
31695 !! options
31696 parsoid={
31697 "wrapSections": true
31698 }
31699 !! wikitext
31700 Para 1.
31701
31702 Para 2 with a <div>nested in it</div>
31703
31704 Para 3.
31705
31706 =1=
31707 a
31708
31709 =2=
31710 b
31711
31712 ==2.1==
31713 c
31714 !! html/parsoid
31715 <section data-mw-section-id="0"><p>Para 1.</p>
31716
31717 <p>Para 2 with a </p><div>nested in it</div>
31718
31719 <p>Para 3.</p>
31720
31721 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
31722 <p>a</p>
31723
31724 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
31725 <p>b</p>
31726
31727 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
31728 <p>c</p>
31729
31730 </section></section>
31731 !! end
31732
31733 !! test
31734 Section wrapping with template-generated sections (good nesting 1)
31735 !! options
31736 parsoid={
31737 "wrapSections": true
31738 }
31739 !! wikitext
31740 =1=
31741 a
31742
31743 {{echo|1=
31744 ==1.1==
31745 b
31746 }}
31747
31748 ==1.2==
31749 c
31750
31751 =2=
31752 d
31753 !! html/parsoid
31754 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
31755 <p>a</p>
31756
31757 <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">
31758 </span><p about="#mwt1">b</p>
31759 </section><section data-mw-section-id="3"><h2 id="1.2">1.2</h2>
31760 <p>c</p>
31761
31762 </section></section><section data-mw-section-id="4"><h1 id="2">2</h1>
31763 <p>d</p></section>
31764 !! end
31765
31766 # In this example, the template scope is mildly expanded to incorporate the
31767 # trailing newline after the transclusion since that is part of section 1.1.1
31768 !! test
31769 Section wrapping with template-generated sections (good nesting 2)
31770 !! options
31771 parsoid={
31772 "wrapSections": true,
31773 "modes": ["wt2html", "wt2wt"]
31774 }
31775 !! wikitext
31776 =1=
31777 a
31778
31779 {{echo|1=
31780 ==1.1==
31781 b
31782 ===1.1.1===
31783 d
31784 }}
31785 =2=
31786 e
31787 !! html/parsoid
31788 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
31789 <p>a</p>
31790
31791 <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">
31792 </span><p about="#mwt1">b</p><span about="#mwt1">
31793 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.1.1">1.1.1</h3><span about="#mwt1">
31794 </span><p about="#mwt1">d</p><span about="#mwt1">
31795 </span></section></section></section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="2">2</h1>
31796 <p>e</p></section>
31797 !! end
31798
31799 # In this example, the template scope is mildly expanded to incorporate the
31800 # trailing newline after the transclusion since that is part of section 1.2.1
31801 !! test
31802 Section wrapping with template-generated sections (good nesting 3)
31803 !! options
31804 parsoid={
31805 "wrapSections": true,
31806 "modes": ["wt2html", "wt2wt"]
31807 }
31808 !! wikitext
31809 =1=
31810 a
31811
31812 {{echo|1=
31813 x
31814 ==1.1==
31815 b
31816 ==1.2==
31817 c
31818 ===1.2.1===
31819 d
31820 }}
31821 =2=
31822 e
31823 !! html/parsoid
31824 <section data-mw-section-id="0"></section><section data-mw-section-id="1" data-parsoid="{}"><h1 id="1"> 1 </h1>
31825 <p>a</p>
31826
31827 <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">
31828 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.1">1.1</h2><span about="#mwt1">
31829 </span><p about="#mwt1">b</p><span about="#mwt1">
31830 </span></section><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.2">1.2</h2><span about="#mwt1">
31831 </span><p about="#mwt1">c</p><span about="#mwt1">
31832 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.2.1">1.2.1</h3><span about="#mwt1">
31833 </span><p about="#mwt1">d</p><span about="#mwt1">
31834 </span></section></section></section><section data-mw-section-id="5"><h1 id="2">2</h1>
31835 <p>e</p></section>
31836 !! end
31837
31838 # Because of section-wrapping and template-wrapping interactions,
31839 # the scope of the template is expanded so that the template markup
31840 # is valid in the presence of <section> tags.
31841 # This exercises the s1 is null scenario in the wrapSections code
31842 !! test
31843 Section wrapping with template-generated sections (bad nesting 1)
31844 !! options
31845 parsoid={
31846 "wrapSections": true
31847 }
31848 !! wikitext
31849 <div>
31850 a
31851
31852 {{echo|
31853 =1=
31854 b
31855 }}
31856
31857 c
31858 </div>
31859 !! html/parsoid
31860 <section data-mw-section-id="-1"></section><section data-mw-section-id="-2"><div data-parsoid='{"stx":"html"}'>
31861 <p>a</p>
31862
31863 <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"]}'>
31864 </span><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="1">1</h1><span about="#mwt1">
31865 </span><p about="#mwt1">b
31866 </p><span about="#mwt1">
31867
31868 </span><p about="#mwt1">c</p><span about="#mwt1">
31869 </span></section></div></section>
31870 !! end
31871
31872 # Because of section-wrapping and template-wrapping interactions,
31873 # the scope of the template is expanded so that the template markup
31874 # is valid in the presence of <section> tags.
31875 # This exercises the s1 is ancestor of s2 scenario in the wrapSections code
31876 !! test
31877 Section wrapping with template-generated sections (bad nesting 2)
31878 !! options
31879 parsoid={
31880 "wrapSections": true
31881 }
31882 !! wikitext
31883 =1=
31884 a
31885
31886 {{echo|1=
31887 =2=
31888 b
31889 ==2.1==
31890 c
31891 }}
31892
31893 d
31894
31895 =3=
31896 e
31897 !! html/parsoid
31898 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
31899 <p>a</p>
31900
31901 </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">
31902 </span><p about="#mwt1">b</p><span about="#mwt1">
31903 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="2.1">2.1</h2><span about="#mwt1">
31904 </span><p about="#mwt1">c</p><span about="#mwt1">
31905
31906 </span><p about="#mwt1">d</p><span about="#mwt1">
31907
31908 </span></section></section><section data-mw-section-id="4"><h1 id="3">3</h1>
31909 <p>e</p></section>
31910 !! end
31911
31912 # Because of section-wrapping and template-wrapping interactions,
31913 # additional template wrappers are added to <section> tags
31914 # so that template wrapping semantics are valid whether section
31915 # tags are retained or stripped. But, the template scope can expand
31916 # greatly when accounting for section tags.
31917 # This exercises the s1 and s2 are in different subtrees scenario
31918 !! test
31919 Section wrapping with template-generated sections (bad nesting 3)
31920 !! options
31921 parsoid={
31922 "wrapSections": true,
31923 "modes": ["wt2html", "wt2wt"]
31924 }
31925 !! wikitext
31926 =1=
31927 a
31928
31929 {{echo|1=
31930 ==1.2==
31931 b
31932 =2=
31933 c
31934 }}
31935
31936 d
31937
31938 =3=
31939 e
31940 !! html/parsoid
31941 <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>
31942 <p>a</p>
31943
31944 <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">
31945 </span><p about="#mwt1">b</p><span about="#mwt1">
31946 </span></section></section><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="2">2</h1><span about="#mwt1">
31947 </span><p about="#mwt1">c</p>
31948
31949 <p>d</p>
31950 </section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="3">3</h1>
31951 <p>e</p></section>
31952 !! end
31953
31954 !! test
31955 Section wrapping with uneditable lead section + div wrapping multiple sections
31956 !! options
31957 parsoid={
31958 "wrapSections": true
31959 }
31960 !! wikitext
31961 foo
31962
31963 <div style="border:1px solid red;">
31964 =1=
31965 a
31966
31967 ==1.1==
31968 b
31969
31970 =2=
31971 c
31972 </div>
31973
31974 =3=
31975 d
31976
31977 ==3.1==
31978 e
31979 !! html/parsoid
31980 <section data-mw-section-id="-1"><p>foo</p>
31981
31982 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
31983 <section data-mw-section-id="1"><h1 id="1">1</h1>
31984 <p>a</p>
31985
31986 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
31987 <p>b</p>
31988
31989 </section></section><section data-mw-section-id="-1"><h1 id="2">2</h1>
31990 <p>c</p>
31991 </section></div>
31992
31993 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
31994 <p>d</p>
31995
31996 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
31997 <p>e</p>
31998 </section></section>
31999 !! end
32000
32001 !! test
32002 Section wrapping with editable lead section + div overlapping multiple sections
32003 !! options
32004 parsoid={
32005 "wrapSections": true
32006 }
32007 !! wikitext
32008 foo
32009
32010 =1=
32011 a
32012 <div style="border:1px solid red;">
32013 b
32014
32015 ==1.1==
32016 c
32017
32018 =2=
32019 d
32020 </div>
32021 e
32022
32023 =3=
32024 f
32025
32026 ==3.1==
32027 g
32028 !! html/parsoid
32029 <section data-mw-section-id="0"><p>foo</p>
32030
32031 </section><section data-mw-section-id="-1"><h1 id="1">1</h1>
32032 <p>a</p>
32033 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
32034 <p>b</p>
32035
32036 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
32037 <p>c</p>
32038
32039 </section><section data-mw-section-id="-1"><h1 id="2">2</h1>
32040 <p>d</p>
32041 </section></div>
32042 <p>e</p>
32043
32044 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
32045 <p>f</p>
32046
32047 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
32048 <p>g</p>
32049 </section></section>
32050 !! end
32051
32052 !! test
32053 HTML header tags should not be wrapped in section tags
32054 !! options
32055 parsoid={
32056 "wrapSections": true
32057 }
32058 !! wikitext
32059 foo
32060
32061 <h1>a</h1>
32062
32063 =b=
32064
32065 <h1>c</h1>
32066
32067 =d=
32068 !! html/parsoid
32069 <section data-mw-section-id="0"><p>foo</p>
32070
32071 <h1 id="a" data-parsoid='{"stx":"html"}'>a</h1>
32072
32073 </section><section data-mw-section-id="1"><h1 id="b">b</h1>
32074
32075 <h1 id="c" data-parsoid='{"stx":"html"}'>c</h1>
32076
32077 </section><section data-mw-section-id="2"><h1 id="d">d</h1></section>
32078 !! end
32079
32080 !! test
32081 Lead section containing only whitespace and comments.
32082 !! options
32083 parsoid={
32084 "wrapSections": true
32085 }
32086 !! wikitext
32087
32088 <!-- this is a comment, presumably significant to editors -->
32089 =1=
32090 a
32091
32092 =2=
32093 b
32094 !! html/parsoid
32095 <section data-mw-section-id="0" data-parsoid="{}">
32096 <!-- this is a comment, presumably significant to editors -->
32097 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
32098 <p>a</p>
32099
32100 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
32101 <p>b</p></section>
32102 !! end
32103
32104 !! test
32105 Pseudo-sections emitted by templates should have id -2
32106 !! options
32107 parsoid={
32108 "wrapSections": true
32109 }
32110 !! wikitext
32111 foo
32112 {{echo|<div>
32113 ==a==
32114 ==b==
32115 </div>
32116 }}
32117 !! html/parsoid
32118 <section data-mw-section-id="-1"><p>foo</p>
32119 </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}}]}'>
32120 <section data-mw-section-id="-1"><h2 id="a">a</h2>
32121 </section><section data-mw-section-id="-1"><h2 id="b">b</h2>
32122 </section></div><span about="#mwt1">
32123 </span></section>
32124 !! end
32125
32126 ##########################################################################
32127 Tests demonstrating white-space insensitivity in input wikitext
32128 for wikitext headings, wikitext list items, and wikitext table captions,
32129 headings, and cells. HTML versions of the same should preserve whitespace.
32130 ##########################################################################
32131 !! test
32132 Trim whitespace in wikitext headings, list items, table captions, headings, and cells
32133 !! options
32134 parsoid={
32135 "modes": ["wt2html"],
32136 "preserveIEW": true
32137 }
32138 !! wikitext
32139 __NOTOC__
32140 == <!--c1--> <!--c2--> Spaces <!--c3--> <!--c4--> ==
32141 == <!--c1--> <!--c2--> Tabs <!--c3--><!--c4--> ==
32142 == <!--Headings with fallback ids--> Личная жизнь ==
32143 * <!--c1--> <!--c2--> List item <!--c3--> <!--c4-->
32144 ; <!--term to define--> term : <!--term's definition--> definition
32145 {|
32146 |+ <!--c1--> <!--c2--> Table Caption <!--c3--> <!--c4-->
32147 |-
32148 ! <!--c1--> <!--c2--> Table Heading 1 <!--c3--> <!--c4--> !! Table Heading 2 <!--c5-->
32149 |-
32150 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
32151 |-
32152 | class="foo" || <!--c1--> <!--c2--> Table Cell 3 <!--c3--> <!--c4-->
32153 |-
32154 | <!--c1--> testing [[one|two]] <!--c2--> | <!--c3--> some content
32155 |}
32156 : {|
32157 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
32158 |} foo <!--c1-->
32159 !! html/php+tidy
32160 <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>
32161 <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>
32162 <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>
32163 <ul><li>List item</li></ul>
32164 <dl><dt>term&#160;</dt>
32165 <dd>definition</dd></dl>
32166 <table>
32167 <caption>Table Caption
32168 </caption>
32169 <tbody><tr>
32170 <th>Table Heading 1</th>
32171 <th>Table Heading 2
32172 </th></tr>
32173 <tr>
32174 <td>Table Cell 1</td>
32175 <td>Table Cell 2
32176 </td></tr>
32177 <tr>
32178 <td>class="foo"</td>
32179 <td>Table Cell 3
32180 </td></tr>
32181 <tr>
32182 <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
32183 </td></tr></tbody></table>
32184 <dl><dd><table>
32185 <tbody><tr>
32186 <td>Table Cell 1</td>
32187 <td>Table Cell 2
32188 </td></tr></tbody></table> foo</dd></dl>
32189 !! html/parsoid
32190 <meta property="mw:PageProp/notoc">
32191 <h2 id="Spaces"><!--c1--><!--c2-->Spaces<!--c3--><!--c4--></h2>
32192 <h2 id="Tabs"><!--c1--><!--c2-->Tabs<!--c3--><!--c4--></h2>
32193 <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>
32194 <ul><li><!--c1--><!--c2-->List item<!--c3--><!--c4--></li></ul>
32195 <dl><dt><!--term to define-->term&nbsp;</dt><dd><!--term's definition-->definition</dd></dl>
32196 <table>
32197 <caption><!--c1--><!--c2-->Table Caption<!--c3--><!--c4--></caption>
32198 <tbody><tr>
32199 <th><!--c1--><!--c2-->Table Heading 1<!--c3--><!--c4--></th><th>Table Heading 2<!--c5--></th></tr>
32200 <tr>
32201 <td><!--c1--><!--c2-->Table Cell 1<!--c3--><!--c4--></td><td>Table Cell 2<!--c5--></td></tr>
32202 <tr>
32203 <td>class="foo"</td><td><!--c1--><!--c2-->Table Cell 3<!--c3--><!--c4--></td></tr>
32204 <tr>
32205 <td><!--c1-->testing <a rel="mw:WikiLink" href="./One" title="One">two</a> <!--c2--> | <!--c3--> some content</td></tr>
32206 </tbody></table>
32207 <dl><dd><table>
32208 <tbody><tr><td><!--c1--><!--c2-->Table Cell 1<!--c3--><!--c4--></td><td>Table Cell 2<!--c5--></td></tr>
32209 </tbody></table> foo<!--c1--></dd></dl>
32210 !! end
32211
32212 # Looks like <caption> is not accepted in HTML
32213 !! test
32214 Do not trim whitespace in HTML headings, list items, table captions, headings, and cells
32215 !! options
32216 parsoid={
32217 "modes": ["wt2html"],
32218 "preserveIEW": true
32219 }
32220 !! wikitext
32221 __NOTOC__
32222 <h2> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
32223 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
32224 <table>
32225 <tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> <th></tr>
32226 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> <th></tr>
32227 </table>
32228 !! html/php+tidy
32229 <h2><span class="mw-headline" id="Heading"> Heading </span></h2>
32230 <ul><li> List item </li></ul>
32231 <table>
32232 <tbody><tr><th> Table Heading </th><th></th></tr>
32233 <tr><td> Table Cell </td><th></th></tr>
32234 </tbody></table>
32235 !! html/parsoid
32236 <meta property="mw:PageProp/notoc"/>
32237 <h2 id="Heading"> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
32238 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
32239 <table>
32240 <tbody><tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> </th><th></th></tr>
32241 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> </td><th></th></tr>
32242 </tbody></table>
32243 !! end
32244
32245 !! test
32246 Do not trim whitespace in links and quotes
32247 !! options
32248 parsoid={
32249 "modes": ["wt2html"],
32250 "preserveIEW": true
32251 }
32252 !! wikitext
32253 foo '' <!--c1--> italic <!--c2--> '' and ''' <!--c3--> bold <!--c4--> '''
32254 [[Foo| some text ]]
32255 !! html/php+tidy
32256 <p>foo <i> italic </i> and <b> bold </b>
32257 <a href="/wiki/Foo" title="Foo"> some text </a>
32258 </p>
32259 !! html/parsoid
32260 <p>foo <i> <!--c1--> italic <!--c2--> </i> and <b> <!--c3--> bold <!--c4--> </b>
32261 <a rel="mw:WikiLink" href="./Foo" title="Foo"> some text </a></p>
32262 !! end
32263
32264 !! test
32265 Remove p tags surrounding a single element in a figcaption
32266 !! options
32267 parsoid=html2wt
32268 !! wikitext
32269 [[File:Foobar.jpg|right|200x200px|Caption]]
32270 !! html/parsoid
32271 <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>
32272 !! end
32273
32274 !! test
32275 Selser preserves lack of newline before list and allows newline after the list
32276 !! options
32277 parsoid={
32278 "modes": ["selser"],
32279 "scrubWikitext": true,
32280 "changes": [
32281 [ "ul", "after", "<p>footer</p>" ]
32282 ]
32283 }
32284 !! wikitext
32285 header
32286 *foo
32287 *bar
32288 !! wikitext/edited
32289 header
32290 *foo
32291 *bar
32292
32293 footer
32294 !! end
32295
32296
32297 !! test
32298 Selser does not introduce newlines between unedited paragraph preceding the list
32299 !! options
32300 parsoid={
32301 "modes": ["selser"],
32302 "changes": [
32303 [ "table tbody tr td p:last-child", "empty" ]
32304 ]
32305 }
32306 !! wikitext
32307 {|
32308 |
32309 header
32310 *foo
32311 *bar
32312 footer
32313 |}
32314 !! wikitext/edited
32315 {|
32316 |
32317 header
32318 *foo
32319 *bar
32320
32321 |}
32322 !! end
32323
32324 !! test
32325 Selser does not introduce newlines between unedited paragraph following the list
32326 !! options
32327 parsoid={
32328 "modes": ["selser"],
32329 "changes": [
32330 [ "table tbody tr td p:first-child", "empty" ]
32331 ]
32332 }
32333 !! wikitext
32334 {|
32335 |
32336 header
32337 *foo
32338 *bar
32339 footer
32340 |}
32341 !! wikitext/edited
32342 {|
32343 |
32344
32345 *foo
32346 *bar
32347 footer
32348 |}
32349 !! end
32350
32351 !! test
32352 Remove a list item but do not insert newline above list
32353 !! options
32354 parsoid={
32355 "modes": ["selser"],
32356 "changes": [
32357 [ "ul li:last-child", "remove" ]
32358 ]
32359 }
32360 !! wikitext
32361 header
32362 *foo
32363 *bar
32364 footer
32365 !! wikitext/edited
32366 header
32367 *foo
32368 footer
32369 !! end