Fix parsing of <pre> tags generated by extension tag hooks
[lhc/web/wiklou.git] / tests / parser / parserTests.txt
1 # MediaWiki Parser test cases
2 # Some taken from https://meta.wikimedia.org/wiki/Parser_testing
3 # All (C) their respective authors and released under the GPL
4 #
5 # The syntax should be fairly self-explanatory.
6 #
7 # Currently supported test options:
8 # One of the following three:
9 #
10 # (default) generate HTML output
11 # pst apply pre-save transform
12 # msg apply message transform
13 #
14 # Plus any combination of these:
15 #
16 # cat add category links
17 # (ignored by Parsoid, since it emits <link>s)
18 # ill add inter-language links
19 # (ignored by Parsoid, since it emits <link>s)
20 # subpage enable subpages (disabled by default)
21 # title=[[XXX]] run test using article title XXX
22 # language=XXX set content language to XXX for this test
23 # variant=XXX set the variant of language for this test (eg zh-tw)
24 # disabled do not run test
25 # parsoid parsoid-specific options (not run by PHP parser unless
26 # the test includes an html/php section)
27 # php php-only test (not run by the parsoid parser unless
28 # the test includes an html/parsoid section)
29 # showtitle make the first line the title
30 # showindicators make the first lines the page status indicators
31 # comment run through Linker::formatComment() instead of main parser
32 # local format section links in edit comment text as local links
33 # notoc disable table of contents
34 # thumbsize=NNN set the default thumb size to NNNpx for this test
35 # wrap include the normal wrapper <div class="mw-parser-output"> (since 1.30)
36 #
37 # You can also set the following parser properties via test options:
38 # wgEnableUploads, wgAllowExternalImages, wgMaxTocLevel,
39 # wgLinkHolderBatchSize, wgRawHtml, wgInterwikiMagic,
40 # wgEnableMagicLinks
41 #
42 # For testing purposes, temporary articles can created:
43 # !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
44 # where '/' denotes a newline.
45
46 # This is the standard article assumed to exist.
47 !! article
48 Main Page
49 !! text
50 blah blah
51 !! endarticle
52
53 !!article
54 Foo
55 !!text
56 FOO
57 !!endarticle
58
59 !!article
60 Template:Foo
61 !!text
62 FOO
63 !!endarticle
64
65 !! article
66 Template:Blank
67 !! text
68 !! endarticle
69
70 !! article
71 Template:pipe
72 !! text
73 |
74 !! endarticle
75
76 !! article
77 Template:=
78 !! text
79 <nowiki>=</nowiki>
80 !! endarticle
81
82 !!article
83 MediaWiki:bad image list
84 !!text
85 * [[File:Bad.jpg]] except [[Nasty page]]
86 !!endarticle
87
88 !! article
89 Template:inner list
90 !! text
91 * item 1
92 !! endarticle
93
94 !! article
95 Template:tbl-start
96 !! text
97 {|
98 !! endarticle
99
100 !! article
101 Template:tbl-end
102 !! text
103 |}
104 !! endarticle
105
106 !! article
107 Template:echo
108 !! text
109 {{{1}}}
110 !! endarticle
111
112 // For Serbian; localize Template namespace
113 !! article
114 Шаблон:Echo
115 !! text
116 {{{1}}}
117 !! endarticle
118
119 !! article
120 Template:echo_with_span
121 !! text
122 <span>{{{1}}}</span>
123 !! endarticle
124
125 !! article
126 Template:echo_with_div
127 !! text
128 <div>{{{1}}}</div>
129 !! endarticle
130
131 !! article
132 Template:blank_param
133 !! text
134 {{{1}}}
135 {{{}}}
136 !! endarticle
137
138 !! article
139 Template:table_attribs
140 !! text
141 <noinclude>
142 |</noinclude>style="color:red;"|Foo
143 !! endarticle
144
145 !! article
146 Template:table_attribs_2
147 !! text
148 <noinclude>
149 |</noinclude>style="color:red;"|Foo
150 |Bar||Baz
151 !! endarticle
152
153 !! article
154 Template:table_attribs_3
155 !! text
156 <noinclude>
157 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo
158 !! endarticle
159
160 !! article
161 Template:table_attribs_4
162 !! text
163 | style="background-color:#DC241f;" width="10px" |
164 !! endarticle
165
166 !! article
167 Template:table_attribs_5
168 !! text
169 <noinclude>
170 |</noinclude>style="color:red;"||Bar
171 !! endarticle
172
173 !! article
174 Template:table_attribs_6
175 !! text
176 style="background: <nowiki>
177
178
179 red;</nowiki>" |
180 !! endarticle
181
182 !! article
183 Template:table_attribs_7
184 !! text
185 <noinclude>
186 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo<ref>foo</ref>
187 !! endarticle
188
189 !! article
190 Template:table_header_cells
191 !! text
192 {{table_attribs}}!!style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
193 !! endarticle
194
195 !! article
196 Template:table_cells
197 !! text
198 {{table_attribs}}||style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
199 !! endarticle
200
201 !! article
202 Template:PartialTable
203 !! text
204 {|
205 |-
206 !! endarticle
207
208 !! article
209 Template:image_attribs
210 !! text
211 <noinclude>
212 [[File:foobar.jpg|</noinclude>right|Caption text<noinclude>]]</noinclude>
213 !! endarticle
214
215 ## See T48811 for details
216 !! article
217 Template:mixed_attr_content_template
218 !! text
219 style="color:red;" title="T48811"
220 |-
221 |foo
222 !! endarticle
223
224 !! article
225 Template:definition_list
226 !! text
227 one
228 ::two
229 !! endarticle
230
231 !! article
232 A?b
233 !! text
234 Weirdo titles!
235 !! endarticle
236
237 !!article
238 Template:Bullet
239 !!text
240 * Bar
241 !!endarticle
242
243 !!article
244 Template:OpenTable
245 !!text
246 {|
247 !!endarticle
248
249 !!article
250 Template:EmptyLITest
251 !!text
252 *a
253 *
254 *
255 *b
256 !!endarticle
257
258 !!article
259 Template:EmptyTRTest
260 !!text
261 {|
262 |-
263 |-
264 |foo
265 |-
266 |-
267 |bar
268 |}
269 !!endarticle
270
271 !!article
272 Template:EmptyTRWithHTMLAttrTest
273 !!text
274 <table>
275 <tr align="center"></tr>
276 <tr><td>foo</td></tr>
277 <tr align="center"></tr>
278 <tr><td>bar</td></tr>
279 </table>
280 !!endarticle
281
282 !! article
283 Template:With: Colon
284 !! text
285 Template with colon
286 !! endarticle
287
288 ###
289 ### Basic tests
290 ###
291
292 !! test
293 Blank input
294 !! wikitext
295 !! html
296 !! end
297
298 !! test
299 Simple paragraph
300 !! wikitext
301 This is a simple paragraph.
302 !! html
303 <p>This is a simple paragraph.
304 </p>
305 !! end
306
307 !! test
308 Paragraphs with extra newline spacing
309 !! wikitext
310 foo
311
312 bar
313
314
315 baz
316
317
318
319 booz
320 !! html
321 <p>foo
322 </p><p>bar
323 </p><p><br />
324 baz
325 </p><p><br />
326 </p><p>booz
327 </p>
328 !! end
329
330 !! test
331 Paragraphs with newline spacing with comment lines in between
332 !! wikitext
333 ----
334 a
335 <!--foo-->
336 b
337 ----
338 a
339 <!--foo--><!--More than 1 comment, still stripped-->
340 b
341 ----
342 a
343 <!--foo--> <!----> <!-- bar -->
344 b
345 ----
346 a
347 <!--foo-->
348
349 b
350 ----
351 a
352
353 <!--foo-->
354 b
355 ----
356 a
357 <!--foo-->
358
359
360 b
361 ----
362 a
363
364
365 <!--foo-->
366 b
367 ----
368 !! html
369 <hr />
370 <p>a
371 b
372 </p>
373 <hr />
374 <p>a
375 b
376 </p>
377 <hr />
378 <p>a
379 b
380 </p>
381 <hr />
382 <p>a
383 </p><p>b
384 </p>
385 <hr />
386 <p>a
387 </p><p>b
388 </p>
389 <hr />
390 <p>a
391 </p><p><br />
392 b
393 </p>
394 <hr />
395 <p>a
396 </p><p><br />
397 b
398 </p>
399 <hr />
400
401 !! end
402
403 !! test
404 Paragraphs with newline spacing with non-empty white-space lines in between
405 !! wikitext
406 ----
407 a
408
409 b
410 ----
411 a
412
413
414 b
415 ----
416 !! html
417 <hr />
418 <p>a
419 </p><p>b
420 </p>
421 <hr />
422 <p>a
423 </p><p><br />
424 b
425 </p>
426 <hr />
427
428 !! end
429
430 !! test
431 Paragraphs with newline spacing with non-empty mixed comment and white-space lines in between
432 !! wikitext
433 ----
434 a
435 <!--foo-->
436 b
437 ----
438 a
439 <!--foo--><!--More than 1 comment doesn't disable stripping of this line!-->
440 b
441 ----
442 a
443
444 <!--foo-->
445 <!--bar-->
446 b
447 ----
448 a
449
450 <!--foo-->
451 <!--bar-->
452
453 b
454 ----
455 !! html
456 <hr />
457 <p>a
458 b
459 </p>
460 <hr />
461 <p>a
462 b
463 </p>
464 <hr />
465 <p>a
466 </p><p>b
467 </p>
468 <hr />
469 <p>a
470 </p><p><br />
471 b
472 </p>
473 <hr />
474
475 !! end
476
477 !! test
478 Extra newlines: More paragraphs with indented comment
479 !! wikitext
480 a
481
482 <!--boo-->
483
484 b
485 !! html
486 <p>a
487 </p><p><br />
488 b
489 </p>
490 !!end
491
492 !! test
493 Extra newlines followed by heading
494 !! wikitext
495 a
496
497
498
499 =b=
500 [[a]]
501
502
503 =b=
504 !! html
505 <p>a
506 </p><p><br />
507 </p>
508 <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>
509 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
510 </p><p><br />
511 </p>
512 <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>
513
514 !! end
515
516 !! test
517 Extra newlines between heading and content are swallowed
518 !! wikitext
519 =b=
520
521
522
523 [[a]]
524 !! html
525 <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>
526 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
527 </p>
528 !! end
529
530 !! test
531 Heading with line break in nowiki
532 !! options
533 parsoid=wt2html
534 !! config
535 wgFragmentMode=[ 'html5', 'legacy' ]
536 !! wikitext
537 == A <nowiki>B
538 C</nowiki> ==
539 !! html/php
540 <h2><span id="A_B.0AC"></span><span class="mw-headline" id="A_B
541 C">A B
542 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>
543
544 !! html/parsoid
545 <h2 id="A_B
546 C"><span id="A_B.0AC" typeof="mw:FallbackId"></span> A <span typeof="mw:Nowiki">B
547 C</span> </h2>
548 !! end
549
550 !! test
551 Parsing an URL
552 !! wikitext
553 http://fr.wikipedia.org/wiki/🍺
554 <!-- EasterEgg we love beer, better be able be able to link to it -->
555 !! html
556 <p><a rel="nofollow" class="external free" href="http://fr.wikipedia.org/wiki/🍺">http://fr.wikipedia.org/wiki/🍺</a>
557 </p>
558 !! end
559
560 !! test
561 Simple list
562 !! wikitext
563 * Item 1
564 * Item 2
565 !! html
566 <ul><li> Item 1</li>
567 <li> Item 2</li></ul>
568
569 !! end
570
571 !! test
572 Italics and bold
573 !! wikitext
574 * plain
575 * plain''italic''plain
576 * plain''italic''plain''italic''plain
577 * plain'''bold'''plain
578 * plain'''bold'''plain'''bold'''plain
579 * plain''italic''plain'''bold'''plain
580 * plain'''bold'''plain''italic''plain
581 * plain''italic'''bold-italic'''italic''plain
582 * plain'''bold''bold-italic''bold'''plain
583 * plain'''''bold-italic'''italic''plain
584 * plain'''''bold-italic''bold'''plain
585 * plain''italic'''bold-italic'''''plain
586 * plain'''bold''bold-italic'''''plain
587 * plain l'''italic''plain
588 * plain l''''bold''' plain
589 !! html
590 <ul><li> plain</li>
591 <li> plain<i>italic</i>plain</li>
592 <li> plain<i>italic</i>plain<i>italic</i>plain</li>
593 <li> plain<b>bold</b>plain</li>
594 <li> plain<b>bold</b>plain<b>bold</b>plain</li>
595 <li> plain<i>italic</i>plain<b>bold</b>plain</li>
596 <li> plain<b>bold</b>plain<i>italic</i>plain</li>
597 <li> plain<i>italic<b>bold-italic</b>italic</i>plain</li>
598 <li> plain<b>bold<i>bold-italic</i>bold</b>plain</li>
599 <li> plain<i><b>bold-italic</b>italic</i>plain</li>
600 <li> plain<b><i>bold-italic</i>bold</b>plain</li>
601 <li> plain<i>italic<b>bold-italic</b></i>plain</li>
602 <li> plain<b>bold<i>bold-italic</i></b>plain</li>
603 <li> plain l'<i>italic</i>plain</li>
604 <li> plain l'<b>bold</b> plain</li></ul>
605
606 !! end
607
608 # this example taken from the [[simple:Moon]] article (T49326)
609 !! test
610 Italics and possessives (1)
611 !! wikitext
612 obtained by ''[[Lunar Prospector]]'''s gamma-ray spectrometer
613 !! html
614 <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
615 </p>
616 !! end
617
618 # this example taken from [[en:Flaming Pie]] (T51926)
619 !! test
620 Italics and possessives (2)
621 !! wikitext
622 '''''Flaming Pie''''' is ... released in 1997. In ''Flaming Pie'''s liner notes
623 !! html
624 <p><i><b>Flaming Pie</b></i> is ... released in 1997. In <i>Flaming Pie'</i>s liner notes
625 </p>
626 !! end
627
628 # this example taken from [[en:Dictionary]] (T51926)
629 !! test
630 Italics and possessives (3)
631 !! wikitext
632 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''.
633 !! html
634 <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>.
635 </p>
636 !! end
637
638
639 ###
640 ### 2-quote opening sequence tests
641 ###
642 !! test
643 Italics and bold: 2-quote opening sequence: (2,2)
644 !! wikitext
645 ''foo''
646 !! html
647 <p><i>foo</i>
648 </p>
649 !!end
650
651 !! test
652 Italics and bold: 2-quote opening sequence: (2,3)
653 !! wikitext
654 ''foo'''
655 !! html/*
656 <p><i>foo'</i>
657 </p>
658 !!end
659
660 !! test
661 Italics and bold: 2-quote opening sequence: (2,4)
662 !! options
663 parsoid=wt2html
664 !! wikitext
665 ''foo''''
666 !! html/*
667 <p><i>foo''</i>
668 </p>
669 !!end
670
671 # same html as previous, but wikitext adjusted to match parsoid html2wt
672 !! test
673 Italics and bold: 2-quote opening sequence: (2,4) w/ nowiki
674 !! wikitext
675 ''foo<nowiki>''</nowiki>''
676 !! html
677 <p><i>foo''</i>
678 </p>
679 !! end
680
681 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
682 !! test
683 Italics and bold: 2-quote opening sequence: (2,5)
684 !! options
685 parsoid=wt2html
686 !! wikitext
687 ''foo'''''
688 !! html/php
689 <p><i>foo</i>
690 </p>
691 !! html/parsoid
692 <p><i>foo</i><b></b>
693 </p>
694 !!end
695
696 # same html as previous, but wikitext adjusted to match parsoid html2wt
697 !! test
698 Italics and bold: 2-quote opening sequence: (2,5+3) w/ nowiki
699 !! wikitext
700 ''foo'''''<nowiki/>'''
701 !! html/php
702 <p><i>foo</i>
703 </p>
704 !! html/parsoid
705 <p><i>foo</i><b></b>
706 </p>
707 !! end
708
709
710 ###
711 ### 3-quote opening sequence tests
712 ###
713
714 !! test
715 Italics and bold: 3-quote opening sequence: (3,2)
716 !! wikitext
717 '''foo''
718 !! html/*
719 <p>'<i>foo</i>
720 </p>
721 !!end
722
723 !! test
724 Italics and bold: 3-quote opening sequence: (3,3)
725 !! wikitext
726 '''foo'''
727 !! html
728 <p><b>foo</b>
729 </p>
730 !!end
731
732 !! test
733 Italics and bold: 3-quote opening sequence: (3,4)
734 !! wikitext
735 '''foo''''
736 !! html/*
737 <p><b>foo'</b>
738 </p>
739 !!end
740
741 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
742 !! test
743 Italics and bold: 3-quote opening sequence: (3,5)
744 !! options
745 parsoid=wt2html
746 !! wikitext
747 '''foo'''''
748 !! html/php
749 <p><b>foo</b>
750 </p>
751 !! html/parsoid
752 <p><b>foo</b><i></i>
753 </p>
754 !!end
755
756 # same html as previous, but wikitext adjusted to match parsoid html2wt
757 !! test
758 Italics and bold: 3-quote opening sequence: (3,5+2) w/ nowiki
759 !! wikitext
760 '''foo'''''<nowiki/>''
761 !! html/php
762 <p><b>foo</b>
763 </p>
764 !! html/parsoid
765 <p><b>foo</b><i></i>
766 </p>
767 !! end
768
769
770 ###
771 ### 4-quote opening sequence tests
772 ###
773
774 !! test
775 Italics and bold: 4-quote opening sequence: (4,2)
776 !! options
777 parsoid=wt2html
778 !! wikitext
779 ''''foo''
780 !! html/*
781 <p>''<i>foo</i>
782 </p>
783 !!end
784
785 # same html as previous, but wikitext adjusted to match parsoid html2wt
786 !! test
787 Italics and bold: 4-quote opening sequence: (4,2) w/ nowiki
788 !! wikitext
789 <nowiki>''</nowiki>''foo''
790 !! html
791 <p>''<i>foo</i>
792 </p>
793 !! end
794
795 !! test
796 Italics and bold: 4-quote opening sequence: (4,3)
797 !! wikitext
798 ''''foo'''
799 !! html/*
800 <p>'<b>foo</b>
801 </p>
802 !!end
803
804 !! test
805 Italics and bold: 4-quote opening sequence: (4,4)
806 !! options
807 parsoid=wt2html
808 !! wikitext
809 ''''foo''''
810 !! html/*
811 <p>'<b>foo'</b>
812 </p>
813 !!end
814
815 # same html as previous, but wikitext adjusted to match parsoid html2wt
816 !! test
817 Italics and bold: 4-quote opening sequence: (4,4) w/ nowiki
818 !! wikitext
819 '<nowiki/>'''foo''''
820 !! html
821 <p>'<b>foo'</b>
822 </p>
823 !! end
824
825 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
826 !! test
827 Italics and bold: 4-quote opening sequence: (4,5)
828 !! options
829 parsoid=wt2html
830 !! wikitext
831 ''''foo'''''
832 !! html/php
833 <p>'<b>foo</b>
834 </p>
835 !! html/parsoid
836 <p>'<b>foo</b><i></i>
837 </p>
838 !!end
839
840 # same html as previous, but wikitext adjusted to match parsoid html2wt
841 !! test
842 Italics and bold: 4-quote opening sequence: (4,5+2) w/ nowiki
843 !! wikitext
844 '<nowiki/>'''foo'''''<nowiki/>''
845 !! html/php
846 <p>'<b>foo</b>
847 </p>
848 !! html/parsoid
849 <p>'<b>foo</b><i></i>
850 </p>
851 !! end
852
853
854 ###
855 ### 5-quote opening sequence tests
856 ###
857
858 !! test
859 Italics and bold: 5-quote opening sequence: (5,2)
860 !! options
861 parsoid=wt2html
862 !! wikitext
863 '''''foo''
864 !! html/*
865 <p><b><i>foo</i></b>
866 </p>
867 !!end
868
869 # same html as previous, but wikitext adjusted to match parsoid html2wt
870 !! test
871 Italics and bold: 5-quote opening sequence: (5,2+3)
872 !! wikitext
873 '''''foo'''''
874 !! html/*
875 <p><i><b>foo</b></i>
876 </p>
877 !! end
878
879 !! test
880 Italics and bold: 5-quote opening sequence: (5,3)
881 !! options
882 parsoid=wt2html
883 !! wikitext
884 '''''foo'''
885 !! html/*
886 <p><i><b>foo</b></i>
887 </p>
888 !!end
889
890 # same html as previous, but wikitext adjusted to match parsoid html2wt
891 !! test
892 Italics and bold: 5-quote opening sequence: (5,3+2)
893 !! wikitext
894 '''''foo'''''
895 !! html
896 <p><i><b>foo</b></i>
897 </p>
898 !! end
899
900 !! test
901 Italics and bold: 5-quote opening sequence: (5,4)
902 !! options
903 parsoid=wt2html
904 !! wikitext
905 '''''foo''''
906 !! html/*
907 <p><i><b>foo'</b></i>
908 </p>
909 !!end
910
911 !! test
912 Italics and bold: 5-quote opening sequence: (5,5)
913 !! wikitext
914 '''''foo'''''
915 !! html
916 <p><i><b>foo</b></i>
917 </p>
918 !!end
919
920 !! test
921 Italics and bold: 5-quote opening sequence: (5,6)
922 !! wikitext
923 '''''foo''''''
924 !! html/*
925 <p><i><b>foo'</b></i>
926 </p>
927 !! end
928
929 ###
930 ### multiple quote sequences in a line
931 ###
932
933 !! test
934 Italics and bold: multiple quote sequences: (2,4,2)
935 !! options
936 parsoid=wt2html
937 !! wikitext
938 ''foo''''bar''
939 !! html/*
940 <p><i>foo'<b>bar</b></i>
941 </p>
942 !! end
943
944 # same html as previous, but wikitext adjusted to match parsoid html2wt
945 !! test
946 Italics and bold: multiple quote sequences: (2,4,2+3) w/ nowiki
947 !! wikitext
948 ''foo'<nowiki/>'''bar'''''
949 !! html
950 <p><i>foo'<b>bar</b></i>
951 </p>
952 !! end
953
954 !! test
955 Italics and bold: multiple quote sequences: (2,4,3)
956 !! options
957 parsoid=wt2html
958 !! wikitext
959 ''foo''''bar'''
960 !! html/*
961 <p><i>foo'<b>bar</b></i>
962 </p>
963 !! end
964
965 # same html as previous, but wikitext adjusted to match parsoid html2wt
966 !! test
967 Italics and bold: multiple quote sequences: (2,4,3+2) w/ nowiki
968 !! wikitext
969 ''foo'<nowiki/>'''bar'''''
970 !! html
971 <p><i>foo'<b>bar</b></i>
972 </p>
973 !! end
974
975 !! test
976 Italics and bold: multiple quote sequences: (2,4,4)
977 !! options
978 parsoid=wt2html
979 !! wikitext
980 ''foo''''bar''''
981 !! html/*
982 <p><i>foo'<b>bar'</b></i>
983 </p>
984 !! end
985
986 # same html as previous, but wikitext adjusted to match parsoid html2wt
987 !! test
988 Italics and bold: multiple quote sequences: (2,4,4+2) w/ nowiki
989 !! wikitext
990 ''foo'<nowiki/>'''bar'<nowiki/>'''''
991 !! html
992 <p><i>foo'<b>bar'</b></i>
993 </p>
994 !! end
995
996 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
997 !! test
998 Italics and bold: multiple quote sequences: (3,4,2)
999 !! options
1000 parsoid=wt2html
1001 !! wikitext
1002 '''foo''''bar''
1003 !! html/php
1004 <p><b>foo'</b>bar
1005 </p>
1006 !! html/parsoid
1007 <p><b>foo'</b>bar<i></i>
1008 </p>
1009 !! end
1010
1011 # same html as previous, but wikitext adjusted to match parsoid html2wt
1012 !! test
1013 Italics and bold: multiple quote sequences: (3,4,2+2) w/ nowiki
1014 !! wikitext
1015 '''foo''''bar''<nowiki/>''
1016 !! html/php
1017 <p><b>foo'</b>bar
1018 </p>
1019 !! html/parsoid
1020 <p><b>foo'</b>bar<i></i>
1021 </p>
1022 !! end
1023
1024 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1025 !! test
1026 Italics and bold: multiple quote sequences: (3,4,3)
1027 !! options
1028 parsoid=wt2html
1029 !! wikitext
1030 '''foo''''bar'''
1031 !! html/php
1032 <p><b>foo'</b>bar
1033 </p>
1034 !! html/parsoid
1035 <p><b>foo'</b>bar<b></b>
1036 </p>
1037 !! end
1038
1039 # same html as previous, but wikitext adjusted to match parsoid html2wt
1040 !! test
1041 Italics and bold: multiple quote sequences: (3,4,3+3) w/ nowiki
1042 !! wikitext
1043 '''foo''''bar'''<nowiki/>'''
1044 !! html/php
1045 <p><b>foo'</b>bar
1046 </p>
1047 !! html/parsoid
1048 <p><b>foo'</b>bar<b></b>
1049 </p>
1050 !! end
1051
1052 ###
1053 ### other quote tests
1054 ###
1055 !! test
1056 Italics and bold: other quote tests: (2,3,5)
1057 !! wikitext
1058 ''this is about '''foo's family'''''
1059 !! html
1060 <p><i>this is about <b>foo's family</b></i>
1061 </p>
1062 !!end
1063
1064
1065 !! test
1066 Italics and bold: other quote tests: (2,(3,3),2)
1067 !! wikitext
1068 ''this is about '''foo's''' family''
1069 !! html
1070 <p><i>this is about <b>foo's</b> family</i>
1071 </p>
1072 !!end
1073
1074
1075 !! test
1076 Italics and bold: other quote tests: (3,2,3,2)
1077 !! options
1078 parsoid=wt2html
1079 !! wikitext
1080 '''this is about ''foo'''s family''
1081 !! html/*
1082 <p><b>this is about <i>foo</i></b><i>s family</i>
1083 </p>
1084 !!end
1085
1086
1087 # same html as previous, but wikitext adjusted to match parsoid html2wt
1088 !! test
1089 Italics and bold: other quote tests: (3,2,3+2+2,2)
1090 !! wikitext
1091 '''this is about ''foo'''''<nowiki/>''s family''
1092 !! html
1093 <p><b>this is about <i>foo</i></b><i>s family</i>
1094 </p>
1095 !! end
1096
1097
1098 !! test
1099 Italics and bold: other quote tests: (3,2,3,3)
1100 !! wikitext
1101 '''this is about ''foo'''s family'''
1102 !! html/*
1103 <p>'<i>this is about </i>foo<b>s family</b>
1104 </p>
1105 !!end
1106
1107
1108 !! test
1109 Italics and bold: other quote tests: (3,(2,2),3)
1110 !! wikitext
1111 '''this is about ''foo's'' family'''
1112 !! html
1113 <p><b>this is about <i>foo's</i> family</b>
1114 </p>
1115 !!end
1116
1117
1118 !! test
1119 Italicized possessive
1120 !! wikitext
1121 The ''[[Main Page]]'''s talk page.
1122 !! html/php
1123 <p>The <i><a href="/wiki/Main_Page" title="Main Page">Main Page</a>'</i>s talk page.
1124 </p>
1125 !! html/parsoid
1126 <p>The <i><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>'</i>s talk page.</p>
1127 !! end
1128
1129 !! test
1130 Quote balancing context should be restricted to td/th cells on the same wikitext line
1131 !! options
1132 parsoid=wt2html,wt2wt
1133 !! wikitext
1134 {|
1135 !''a!!''b
1136 |''a||''b
1137 |}
1138 !! html+tidy
1139 <table>
1140 <tbody><tr>
1141 <th><i>a</i></th>
1142 <th><i>b</i>
1143 </th>
1144 <td><i>a</i></td>
1145 <td><i>b</i>
1146 </td></tr></tbody></table>
1147 !! end
1148
1149 ###
1150 ### Non-html5 tags
1151 ###
1152
1153 !! test
1154 Non-html5 tags should be accepted
1155 !! wikitext
1156 <center>''foo''</center>
1157 <big>''foo''</big>
1158 <font>''foo''</font>
1159 <strike>''foo''</strike>
1160 <tt>''foo''</tt>
1161 !! html
1162 <center><i>foo</i></center>
1163 <p><big><i>foo</i></big>
1164 <font><i>foo</i></font>
1165 <strike><i>foo</i></strike>
1166 <tt><i>foo</i></tt>
1167 </p>
1168 !! end
1169
1170 !! test
1171 <wbr> is valid wikitext (T54468)
1172 !! wikitext
1173 <wbr>
1174 !! html
1175 <p><wbr />
1176 </p>
1177 !! end
1178
1179 # <strike> is HTML4, <s> is HTML4/5.
1180 !! test
1181 <s> or <strike> for strikethrough
1182 !! wikitext
1183 <strike>strike</strike>
1184
1185 <s>s</s>
1186 !! html
1187 <p><strike>strike</strike>
1188 </p><p><s>s</s>
1189 </p>
1190 !! end
1191
1192 ## a not permitted
1193 ## i,b,br omitted
1194 !! test
1195 Text-level semantic html elements in wikitext
1196 !! wikitext
1197 <em>text</em>
1198 <strong>text</strong>
1199 <small>text</small>
1200 <s>text</s>
1201 <cite>text</cite>
1202 <q>text</q>
1203 <dfn>text</dfn>
1204 <abbr>text</abbr>
1205 <data>text</data>
1206 <time>text</time>
1207 <code>text</code>
1208 <var>text</var>
1209 <samp>text</samp>
1210 <kbd>text</kbd>
1211 <sub>text</sub>
1212 <u>text</u>
1213 <mark>text</mark>
1214 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1215 <bdi>text</bdi>
1216 <bdo>text</bdo>
1217 <span>text</span>
1218 <wbr />
1219 !! html
1220 <p><em>text</em>
1221 <strong>text</strong>
1222 <small>text</small>
1223 <s>text</s>
1224 <cite>text</cite>
1225 <q>text</q>
1226 <dfn>text</dfn>
1227 <abbr>text</abbr>
1228 <data>text</data>
1229 <time>text</time>
1230 <code>text</code>
1231 <var>text</var>
1232 <samp>text</samp>
1233 <kbd>text</kbd>
1234 <sub>text</sub>
1235 <u>text</u>
1236 <mark>text</mark>
1237 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1238 <bdi>text</bdi>
1239 <bdo>text</bdo>
1240 <span>text</span>
1241 <wbr />
1242 </p>
1243 !! end
1244
1245 # test cases taken from
1246 # https://www.w3.org/TR/html5/text-level-semantics.html#the-ruby-element
1247 !! test
1248 Ruby markup (W3C-style)
1249 !! wikitext
1250 ; Mono-ruby for individual base characters
1251 : <ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby>
1252 ; Group ruby
1253 : <ruby>今日<rt>きょう</rt></ruby>
1254 ; Jukugo ruby
1255 : <ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby>
1256 ; Inline ruby
1257 : <ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby>
1258 ; Double-sided ruby
1259 : <ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby>
1260 <ruby>
1261 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1262 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1263 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1264 </ruby>
1265 !! html
1266 <dl><dt> Mono-ruby for individual base characters</dt>
1267 <dd> <ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby></dd>
1268 <dt> Group ruby</dt>
1269 <dd> <ruby>今日<rt>きょう</rt></ruby></dd>
1270 <dt> Jukugo ruby</dt>
1271 <dd> <ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby></dd>
1272 <dt> Inline ruby</dt>
1273 <dd> <ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby></dd>
1274 <dt> Double-sided ruby</dt>
1275 <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>
1276 <p><ruby>
1277 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1278 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1279 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1280 </ruby>
1281 </p>
1282 !! end
1283
1284 # The next two test different paths in the sanitizer.
1285 !! test
1286 Non-word characters don't terminate tag names (T19663, T42670, T54022)
1287 !! wikitext
1288 <blockquote|>a</blockquote>
1289
1290 <b→> doesn't terminate </b→>
1291
1292 <bä> doesn't terminate </bä>
1293
1294 <boo> doesn't terminate </boo>
1295
1296 <s.foo> doesn't terminate </s.foo>
1297
1298 <sub-ID#1>
1299 !! html
1300 <p>&lt;blockquote|&gt;a&lt;/blockquote&gt;
1301 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1302 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1303 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1304 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1305 </p><p>&lt;sub-ID#1&gt;
1306 </p>
1307 !! end
1308
1309 !! test
1310 Non-word characters don't terminate tag names
1311 !! wikitext
1312 <blockquote|>a</blockquote>
1313
1314 <b→> doesn't terminate </b→>
1315
1316 <bä> doesn't terminate </bä>
1317
1318 <boo> doesn't terminate </boo>
1319
1320 <s.foo> doesn't terminate </s.foo>
1321
1322 <sub-ID#1>
1323 !! html+tidy
1324 <p>&lt;blockquote|&gt;a
1325 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1326 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1327 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1328 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1329 </p><p>&lt;sub-ID#1&gt;
1330 </p>
1331 !! end
1332
1333 ###
1334 ### See tests/parser/parserTestsParserHook.php for the <tåg> extension)
1335 ### This checks that HTML5 tags (with non-word characters in the tag
1336 ### name) make it safely through the parser -- the Sanitizer will
1337 ### munge them later, as it should.
1338 ###
1339 !! test
1340 Non-word characters are valid in extension tags (T19663)
1341 !! wikitext
1342 <tåg>tåg</tåg>
1343 !! html/php
1344 <pre>
1345 'tåg'
1346 array (
1347 )
1348 </pre>
1349
1350 !! html/parsoid
1351 <pre typeof="mw:Extension/tåg" data-mw='{"name":"tåg","attrs":{},"body":{"extsrc":"tåg"}}' data-parsoid='{}' about="#mwt2"></pre>
1352 !! end
1353
1354 !! test
1355 Isolated close tags should be treated as literal text (T54760)
1356 !! options
1357 parsoid=wt2html
1358 !! wikitext
1359 </b>
1360
1361 <s.foo>s</s>
1362 !! html/php+tidy
1363 <p class="mw-empty-elt">
1364 </p><p>&lt;s.foo&gt;s
1365 </p>
1366 !! html/parsoid
1367 <p>&lt;s.foo&gt;s</p>
1368 !! end
1369
1370 ###
1371 ### Special characters
1372 ###
1373
1374 !! test
1375 Bare pipe character (T54363)
1376 !! wikitext
1377 |
1378 !! html
1379 <p>|
1380 </p>
1381 !! end
1382
1383 !! test
1384 Bare pipe character from a template (T54363)
1385 !! wikitext
1386 {{pipe}}
1387 !! html
1388 <p>|
1389 </p>
1390 !! end
1391
1392 ###
1393 ### <nowiki> test cases
1394 ###
1395
1396 !! test
1397 <nowiki> unordered list
1398 !! wikitext
1399 <nowiki>* This is not an unordered list item.</nowiki>
1400 !! html/php
1401 <p>* This is not an unordered list item.
1402 </p>
1403 !! html/parsoid
1404 <p><span typeof="mw:Nowiki">* This is not an unordered list item.</span></p>
1405 !! end
1406
1407 !! test
1408 <nowiki> spacing
1409 !! wikitext
1410 <nowiki>Lorem ipsum dolor
1411
1412 sed abit.
1413 sed nullum.
1414
1415 :and a colon
1416 </nowiki>
1417 !! html/php
1418 <p>Lorem ipsum dolor
1419
1420 sed abit.
1421 sed nullum.
1422
1423 :and a colon
1424
1425 </p>
1426 !! html/parsoid
1427 <p><span typeof="mw:Nowiki">Lorem ipsum dolor
1428
1429 sed abit.
1430 sed nullum.
1431
1432 :and a colon
1433 </span></p>
1434 !! end
1435
1436 !! test
1437 Don't parse <nowiki><span class="error"></nowiki> (T149622)
1438 !! wikitext
1439 <nowiki><span class="error"></nowiki>
1440 !! html/php
1441 <p>&lt;span class="error"&gt;
1442 </p>
1443 !! html/parsoid
1444 <p><span typeof="mw:Nowiki">&lt;span class="error"></span></p>
1445 !! end
1446
1447 !! test
1448 nowiki 3
1449 !! wikitext
1450 :There is not nowiki.
1451 :There is <nowiki>nowiki</nowiki>.
1452
1453 #There is not nowiki.
1454 #There is <nowiki>nowiki</nowiki>.
1455
1456 *There is not nowiki.
1457 *There is <nowiki>nowiki</nowiki>.
1458 !! html/php
1459 <dl><dd>There is not nowiki.</dd>
1460 <dd>There is nowiki.</dd></dl>
1461 <ol><li>There is not nowiki.</li>
1462 <li>There is nowiki.</li></ol>
1463 <ul><li>There is not nowiki.</li>
1464 <li>There is nowiki.</li></ul>
1465
1466 !! html/parsoid
1467 <dl><dd data-parsoid='{}'>There is not nowiki.</dd>
1468 <dd data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</dd></dl>
1469
1470 <ol><li data-parsoid='{}'>There is not nowiki.</li>
1471 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ol>
1472
1473 <ul><li data-parsoid='{}'>There is not nowiki.</li>
1474 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ul>
1475 !! end
1476
1477 !! test
1478 Entities inside <nowiki>
1479 !! wikitext
1480 <nowiki>&lt;</nowiki>
1481 !! html/php
1482 <p>&lt;
1483 </p>
1484 !! html/parsoid
1485 <p><span typeof="mw:Nowiki"><span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span></span></p>
1486 !! end
1487
1488 !! test
1489 Entities inside template parameters
1490 !! wikitext
1491 {{echo|&ndash;}}
1492 !! html/php+tidy
1493 <p>&#8211;
1494 </p>
1495 !! html/parsoid
1496 <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>
1497 !! end
1498
1499 !! test
1500 Properly escape nowiki when combined with other wiki markup
1501 !! options
1502 parsoid=html2wt
1503 !! html/parsoid
1504 <p>* &lt;/nowiki&gt; tag</p>
1505 !! wikitext
1506 <nowiki>*</nowiki> <nowiki>&lt;/nowiki&gt;</nowiki> tag
1507 !! end
1508
1509 !! test
1510 T93824: Put escaped HTML tags inside nowiki
1511 !! options
1512 parsoid=html2wt
1513 !! html/parsoid
1514 <p>&lt;h2&gt;foo&lt;/h2&gt;</p>
1515 !! wikitext
1516 <nowiki><h2>foo</h2></nowiki>
1517 !! end
1518
1519 !! test
1520 T71950: 1. Put nowiki as close to cause as possible, even with non-quote escapable chars
1521 !! options
1522 parsoid=html2wt
1523 !! html/parsoid
1524 <p>This text: L'<a rel="mw:WikiLink" href="./Foo">Foo</a>
1525 This text: L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1526 This text: L'''<a rel="mw:WikiLink" href="./Foo">Foo</a>''</p>
1527 !! wikitext
1528 This text: L'[[Foo]]
1529 This text: L<nowiki>''</nowiki>[[Foo]]
1530 This text: L<nowiki>'''</nowiki>[[Foo]]<nowiki>''</nowiki>
1531 !! end
1532
1533 # This test fails because wikitext whitespace is not normalized before comparing.
1534 !! test
1535 T71950: 2. Put nowiki as close to cause as possible, after ' :'
1536 !! options
1537 parsoid=html2wt
1538 !! html/parsoid
1539 <p>This text : L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1540 </p>
1541 !! wikitext
1542 This text : L<nowiki>''</nowiki>[[Foo]]
1543 !! end
1544
1545 # This test and the next one are html2wt only as they test that incorrect wikitext
1546 # passed in template arguments gets escaped or wrapped in nowikis where required.
1547 !! test
1548 T71482: Use {{!}} instead of nowiki for single pipe in template argument
1549 !! options
1550 parsoid=html2wt
1551 !! html/parsoid
1552 <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>
1553 <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>
1554 !! wikitext
1555 {{echo|foo{{!}}bar}}
1556 {{echo|<nowiki>foo|bar |[[</nowiki>}}
1557 !! end
1558
1559 !! test
1560 T53961: Output correct nowikis in template arguments
1561 !! options
1562 parsoid=html2wt
1563 !! html/parsoid
1564 <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>
1565 <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>
1566 <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>
1567 <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>
1568 <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>
1569 !! wikitext
1570 {{echo|a [ b}}
1571 {{echo|<nowiki>a }} b</nowiki>}}
1572 {{echo|<nowiki>a [[ b</nowiki>}}
1573 {{echo|<nowiki>a | {{ ]]</nowiki>}}
1574 {{echo|a <nowiki>}</nowiki>}}
1575 !! end
1576
1577 !! test
1578 Cases where "!!" needs nowiki protection
1579 !! options
1580 parsoid=html2wt
1581 !! html/parsoid
1582 <table>
1583 <tr><th>this needs protection !! here</th></tr>
1584 </table>
1585
1586 <table>
1587 <tr><th>this does not need
1588 protection !! here</th></tr>
1589 </table>
1590 !! wikitext
1591 {|
1592 !<nowiki>this needs protection !! here</nowiki>
1593 |}
1594
1595 {|
1596 !this does not need
1597 protection !! here
1598 |}
1599 !! end
1600
1601 ###
1602 ### Comments
1603 ###
1604 !! test
1605 Comments and Indent-Pre
1606 !! wikitext
1607 <!-- comment 1 --> asdf
1608
1609 <!-- comment 1 --> asdf
1610 <!-- comment 2 -->
1611
1612 <!-- comment 1 --> asdf
1613 <!-- comment 2 -->xyz
1614
1615 <!-- comment 1 --> asdf
1616 <!-- comment 2 --> xyz
1617 !! html
1618 <pre>asdf
1619 </pre>
1620 <pre>asdf
1621 </pre>
1622 <pre>asdf
1623 </pre>
1624 <p>xyz
1625 </p>
1626 <pre>asdf
1627 xyz
1628 </pre>
1629 !! end
1630
1631 !! test
1632 Comment test 2a
1633 !! wikitext
1634 asdf
1635 <!-- comment 1 -->
1636 jkl
1637 !! html
1638 <p>asdf
1639 jkl
1640 </p>
1641 !! end
1642
1643 !! test
1644 Comment test 2b
1645 !! wikitext
1646 asdf
1647 <!-- comment 1 -->
1648
1649 jkl
1650 !! html
1651 <p>asdf
1652 </p><p>jkl
1653 </p>
1654 !! end
1655
1656 !! test
1657 Comment test 3
1658 !! wikitext
1659 asdf
1660 <!-- comment 1 -->
1661 <!-- comment 2 -->
1662 jkl
1663 !! html
1664 <p>asdf
1665 jkl
1666 </p>
1667 !! end
1668
1669 !! test
1670 Comment test 4
1671 !! wikitext
1672 asdf<!-- comment 1 -->jkl
1673 !! html
1674 <p>asdfjkl
1675 </p>
1676 !! end
1677
1678 !! test
1679 Comment spacing
1680 !! wikitext
1681 a
1682 <!-- foo --> b <!-- bar -->
1683 c
1684 !! html
1685 <p>a
1686 </p>
1687 <pre> b
1688 </pre>
1689 <p>c
1690 </p>
1691 !! end
1692
1693 !! test
1694 Comment whitespace
1695 !! wikitext
1696 <!-- returns a single newline, not nothing, since the newline after > is not stripped -->
1697 !! html
1698
1699 !! end
1700
1701 !! test
1702 Comment semantics and delimiters
1703 !! wikitext
1704 <!-- --><!----><!-----><!------>
1705 !! html/php
1706
1707 !! html/parsoid
1708 <!-- --><!----><!--&#x2D;--><!--&#x2D;&#x2D;-->
1709 !! end
1710
1711 !! test
1712 Comment semantics and delimiters, redux
1713 !! wikitext
1714 <!-- In SGML every "foo" here would actually show up in the text -- foo -- bar
1715 -- foo -- funky huh? ... -->
1716 !! html/php
1717
1718 !! html/parsoid
1719 <!-- In SGML every "foo" here would actually show up in the text &#x2D;&#x2D; foo &#x2D;&#x2D; bar
1720 &#x2D;&#x2D; foo &#x2D;&#x2D; funky huh? ... -->
1721 !! end
1722
1723 !! test
1724 Comment semantics and delimiters: directors cut
1725 !! wikitext
1726 <!-- ... However we like to keep things simple and somewhat XML-ish so we eat
1727 everything starting with < followed by !-- until the first -- and > we see,
1728 that wouldn't be valid XML however, since in XML -- has to terminate a comment
1729 -->-->
1730 !! html/php
1731 <p>--&gt;
1732 </p>
1733 !! html/parsoid
1734 <!-- ... However we like to keep things simple and somewhat XML&#x2D;ish so we eat
1735 everything starting with < followed by !&#x2D;&#x2D; until the first &#x2D;&#x2D; and &#x3E; we see,
1736 that wouldn't be valid XML however, since in XML &#x2D;&#x2D; has to terminate a comment
1737 --><p>--></p>
1738 !! end
1739
1740 !! test
1741 Comment semantics: nesting
1742 !! wikitext
1743 <!--<!-- no, we're not going to do anything fancy here -->-->
1744 !! html/php
1745 <p>--&gt;
1746 </p>
1747 !! html/parsoid
1748 <!--<!&#x2D;&#x2D; no, we're not going to do anything fancy here --><p>--></p>
1749 !! end
1750
1751 # Parsoid closes the unclosed comment, even if it means a slight
1752 # round-trip diff.
1753 !! test
1754 Comment semantics: unclosed comment at end
1755 !! options
1756 parsoid=wt2html,html2html
1757 !! wikitext
1758 <!--This comment will run out to the end of the document
1759 !! html/php
1760
1761 !! html/parsoid
1762 <!--This comment will run out to the end of the document-->
1763 !! end
1764
1765 !! test
1766 Comment semantics: normalize comments to play nice with XML and browsers
1767 !! wikitext
1768 <!-- Browsers --!> think this is closed -->
1769 <!--> This would normally be text -->
1770 <!---> As would this -->
1771 <!-- XML doesn't like trailing dashes -------->
1772 <!-- Nor doubled hyphens -- anywhere in the data -->
1773 But this is not a comment.
1774 !! html/php
1775 <p>But this is not a comment.
1776 </p>
1777 !! html/parsoid
1778 <!-- Browsers &#x2D;&#x2D;!&#x3E; think this is closed -->
1779 <!--&#x3E; This would normally be text -->
1780 <!--&#x2D;&#x3E; As would this -->
1781 <!-- XML doesn't like trailing dashes &#x2D;&#x2D;&#x2D;&#x2D;&#x2D;&#x2D;-->
1782 <!-- Nor doubled hyphens &#x2D;&#x2D; anywhere in the data -->
1783 <p>But this is not a comment.</p>
1784 !! end
1785
1786 !! test
1787 Comment semantics: round-trip even text which contains encoded -->
1788 !! wikitext
1789 <!-- hello & goodbye - > --&gt; --&amp;gt; --&xx -->
1790 !! html/parsoid
1791 <!-- hello &#x26; goodbye &#x2D; &#x3E; &#x2D;&#x2D;&#x3E; &#x2D;&#x2D;&#x26;gt; &#x2D;&#x2D;&#x26;xx -->
1792 !! end
1793
1794 !! test
1795 Comment in template title
1796 !! wikitext
1797 {{f<!---->oo}}
1798 !! html
1799 <p>FOO
1800 </p>
1801 !! end
1802
1803 !! test
1804 Comment on its own line post-expand
1805 !! wikitext
1806 a
1807 {{blank}}<!---->
1808 b
1809 !! html
1810 <p>a
1811 </p><p>b
1812 </p>
1813 !! end
1814
1815 !! test
1816 Comment on its own line post-expand with non-significant whitespace
1817 !! wikitext
1818 a
1819 {{blank}} <!---->
1820 b
1821 !! html
1822 <p>a
1823 </p><p>b
1824 </p>
1825 !! end
1826
1827 !! test
1828 Multiple comments should still parse as SOL-transparent
1829 !! options
1830 parsoid=wt2html,wt2wt
1831 !! wikitext
1832 <!--c1-->*a
1833 <!--c2--><!--c3--><!--c4-->*b
1834 !! html/php
1835 <ul><li>a</li>
1836 <li>b</li></ul>
1837
1838 !! html/parsoid
1839 <!--c1--><ul>
1840 <li>a
1841 </li>
1842 <!--c2--><!--c3--><!--c4-->
1843 <li>b
1844 </li>
1845 </ul>
1846 !! end
1847
1848 ## Make sure ">" gets escaped in comments to avoid XSS
1849 !! test
1850 IE conditional comments
1851 !! wikitext
1852 <!--[if lt IE 9]>
1853 <script>alert('hi');</script>
1854 <![endif]-->
1855 !! html/parsoid
1856 <!--[if lt IE 9]&#x3E;
1857 <script&#x3E;alert('hi');</script&#x3E;
1858 <![endif]-->
1859 !! end
1860
1861 ###
1862 ### paragraph wrapping tests
1863 ###
1864
1865 !! test
1866 No block tags
1867 !! wikitext
1868 a
1869
1870 b
1871 !! html
1872 <p>a
1873 </p><p>b
1874 </p>
1875 !! end
1876
1877 !! test
1878 Block tag on one line (<div>)
1879 !! wikitext
1880 a <div>foo</div>
1881
1882 b
1883 !! html
1884 a <div>foo</div>
1885 <p>b
1886 </p>
1887 !! html+tidy
1888 <p>a </p><div>foo</div>
1889 <p>b
1890 </p>
1891 !! end
1892
1893 # Remex wraps empty tag runs with p-tags.
1894 # Parsoid strips them out during p-wrapping.
1895 !! test
1896 No p-wrappable content
1897 !! wikitext
1898 <span><div>x</div></span>
1899 <span><s><div>x</div></s></span>
1900 <small><em></em></small><span><s><div>x</div></s></span>
1901 !! html/php+tidy
1902 <span><div>x</div></span>
1903 <span><s><div>x</div></s></span>
1904 <p><small><em></em></small></p><span><s><div>x</div></s></span>
1905 !! html/parsoid
1906 <span><div>x</div></span>
1907 <span><s><div>x</div></s></span>
1908 <small><em></em></small><span><s><div>x</div></s></span>
1909 !! end
1910
1911 # T177612: Parsoid-only test
1912 !! test
1913 Transclusion meta tags shouldn't trip Parsoid's useless p-wrapper stripping code
1914 !! wikitext
1915 {{echo|<span><div>x</div></span>}}
1916 x
1917 !! html/parsoid
1918 <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>
1919 <p>x</p>
1920 !! end
1921
1922 !! test
1923 Block tag on one line (<blockquote>)
1924 !! wikitext
1925 a <blockquote>foo</blockquote>
1926
1927 b
1928 !! html
1929 a <blockquote>foo</blockquote>
1930 <p>b
1931 </p>
1932 !! html+tidy
1933 <p>a </p><blockquote><p>foo</p></blockquote>
1934 <p>b
1935 </p>
1936 !! end
1937
1938 !! test
1939 Block tag on both lines (<div>)
1940 !! wikitext
1941 a <div>foo</div>
1942
1943 b <div>foo</div>
1944 !! html
1945 a <div>foo</div>
1946 b <div>foo</div>
1947
1948 !! html+tidy
1949 <p>a </p><div>foo</div><p>
1950 b </p><div>foo</div>
1951 !! end
1952
1953 !! test
1954 Block tag on both lines (<blockquote>)
1955 !! wikitext
1956 a <blockquote>foo</blockquote>
1957
1958 b <blockquote>foo</blockquote>
1959 !! html
1960 a <blockquote>foo</blockquote>
1961 b <blockquote>foo</blockquote>
1962
1963 !! html+tidy
1964 <p>a </p><blockquote><p>foo</p></blockquote><p>
1965 b </p><blockquote><p>foo</p></blockquote>
1966 !! end
1967
1968 !! test
1969 Multiple lines without block tags
1970 !! wikitext
1971 <div>foo</div> a
1972 b
1973 c
1974 d<!--foo--> e
1975 x <div>foo</div> z
1976 !! html
1977 <div>foo</div> a
1978 <p>b
1979 c
1980 d e
1981 </p>
1982 x <div>foo</div> z
1983
1984 !! html+tidy
1985 <div>foo</div><p> a
1986 </p><p>b
1987 c
1988 d e
1989 </p><p>
1990 x </p><div>foo</div><p> z
1991 </p>
1992 !! end
1993
1994 # The difference between Parsoid & Remex here
1995 # is because of Parsoid's Tidy-emulation code
1996 # for p-wrapping. We'll start work to remove this
1997 # emulation code in Parsoid sooner than later.
1998 # Remex wraps empty tag runs with p-tags.
1999 # Parsoid strips them out in a separate pass.
2000 !! test
2001 Empty lines between lines with block tags
2002 !! wikitext
2003 <div></div>
2004
2005
2006 <div></div>a
2007
2008 b
2009 <div>a</div>b
2010
2011 <div>b</div>d
2012
2013
2014 <div>e</div>
2015 !! html
2016 <div></div>
2017 <p><br />
2018 </p>
2019 <div></div>a
2020 <p>b
2021 </p>
2022 <div>a</div>b
2023 <div>b</div>d
2024 <p><br />
2025 </p>
2026 <div>e</div>
2027
2028 !! html+tidy
2029 <div></div>
2030 <p><br />
2031 </p>
2032 <div></div><p>a
2033 </p><p>b
2034 </p>
2035 <div>a</div><p>b
2036 </p><div>b</div><p>d
2037 </p><p><br />
2038 </p>
2039 <div>e</div>
2040 !! html/parsoid
2041 <div data-parsoid='{"stx":"html"}'></div>
2042
2043 <p><br /></p>
2044 <div data-parsoid='{"stx":"html"}'></div><p>a</p>
2045
2046 <p>b</p>
2047 <div data-parsoid='{"stx":"html"}'>a</div><p>b</p>
2048
2049 <div data-parsoid='{"stx":"html"}'>b</div><p>d</p>
2050
2051 <p><br /></p>
2052 <div data-parsoid='{"stx":"html"}'>e</div>
2053 !! end
2054
2055 !! test
2056 Unclosed HTML p-tags should be handled properly
2057 !! wikitext
2058 <div><p>foo</div>
2059 a
2060
2061 b
2062 !! html/php+tidy
2063 <div><p>foo</p></div>
2064 <p>a
2065 </p><p>b
2066 </p>
2067 !! html/parsoid
2068 <div data-parsoid='{"stx":"html"}'><p data-parsoid='{"stx":"html", "autoInsertedEnd":true}'>foo</p></div>
2069 <p>a</p>
2070 <p>b</p>
2071 !! end
2072
2073 ## SSS FIXME: I can come up with other scenarios where this doesn't work because
2074 ## of eager output of buffered tokens in the p-wrapper. But, I'm going to ignore
2075 ## them for now.
2076 !! test
2077 1. P-wrapping should leave sol-transparent tags outside p-tags where possible
2078 !! options
2079 parsoid=wt2html
2080 !! wikitext
2081 a [[Category:A1]] [[Category:A2]]
2082 [[Category:A3]]
2083 [[Category:A4]]
2084 !! html/parsoid
2085 <p>a</p>
2086 <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"/>
2087 !! end
2088
2089 !! test
2090 2. P-wrapping should leave sol-transparent tags outside p-tags where possible
2091 !! options
2092 parsoid=wt2html
2093 !! wikitext
2094 [[Category:A1]]a
2095 !! html/parsoid
2096 <link rel="mw:PageProp/Category" href="./Category:A1"/><p>a</p>
2097 !! end
2098
2099 !! test
2100 No paragraph necessary for SOL transparent template
2101 !! wikitext
2102 <span><div>foo</div></span>
2103 [[Category:Foo]]
2104
2105 <span><div>foo</div></span>
2106 {{echo|[[Category:Foo]]}}
2107 !! html/php
2108 <span><div>foo</div></span>
2109 <span><div>foo</div></span>
2110
2111 !! html/parsoid
2112 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2113 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
2114
2115 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2116 <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}}]}'/>
2117 !! end
2118
2119 !! test
2120 Avoid expanding multiline sol transparent template ranges unnecessarily
2121 !! wikitext
2122 hi
2123
2124
2125 {{echo|<br/>
2126 }}
2127
2128 [[Category:Ho]]
2129 !! html/php
2130 <p>hi
2131 </p><p><br />
2132 <br />
2133 </p>
2134 !! html/parsoid
2135 <p>hi</p>
2136
2137 <p><br />
2138 <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">
2139 </span></p>
2140
2141 <link rel="mw:PageProp/Category" href="./Category:Ho" />
2142 !! end
2143
2144 ###
2145 ### Preformatted text
2146 ###
2147
2148 !! test
2149 Preformatted text
2150 !! wikitext
2151 This is some
2152 Preformatted text
2153 With ''italic''
2154 And '''bold'''
2155 And a [[Main Page|link]]
2156 !! html
2157 <pre>This is some
2158 Preformatted text
2159 With <i>italic</i>
2160 And <b>bold</b>
2161 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
2162 </pre>
2163 !! end
2164
2165 !! test
2166 Tabs don't trigger preformatted text
2167 !! wikitext
2168 This is not
2169 preformatted text.
2170 This is preformatted text.
2171 So is this.
2172 !! html/php
2173 <p> This is not
2174 preformatted text.
2175 </p>
2176 <pre>This is preformatted text.
2177 So is this.
2178 </pre>
2179 !! html/parsoid
2180 <p> This is not
2181 preformatted text.</p>
2182 <pre>This is preformatted text.
2183 So is this.</pre>
2184 !! end
2185
2186 !! test
2187 Space before tab needs nowiki pre protection
2188 !! options
2189 parsoid=html2wt
2190 !! html/parsoid
2191 <p> a</p>
2192 !! wikitext
2193 <nowiki> </nowiki> a
2194 !! end
2195
2196 !! test
2197 Ident preformatting with inline content
2198 !! wikitext
2199 a
2200 ''b''
2201 !! html
2202 <pre>a
2203 <i>b</i>
2204 </pre>
2205 !! end
2206
2207 !! test
2208 <pre> with <nowiki> inside (compatibility with 1.6 and earlier)
2209 !! wikitext
2210 <pre><nowiki>
2211 <b>
2212 <cite>
2213 <em>
2214 </nowiki></pre>
2215 !! html
2216 <pre>
2217 &lt;b&gt;
2218 &lt;cite&gt;
2219 &lt;em&gt;
2220 </pre>
2221
2222 !! end
2223
2224 !! test
2225 Regression with preformatted in <center>
2226 !! wikitext
2227 <center>
2228 Blah
2229 </center>
2230 !! html
2231 <center>
2232 <pre>Blah
2233 </pre>
2234 </center>
2235
2236 !! end
2237
2238 !! test
2239 T54763: Preformatted in <blockquote>
2240 !! wikitext
2241 <blockquote>
2242 Blah
2243 {|
2244 |
2245 indented cell (no pre-wrapping!)
2246 |}
2247 </blockquote>
2248 !! html
2249 <blockquote>
2250 <p> Blah
2251 </p>
2252 <table>
2253 <tr>
2254 <td>
2255 <p> indented cell (no pre-wrapping!)
2256 </p>
2257 </td></tr></table>
2258 </blockquote>
2259
2260 !! end
2261
2262 !! test
2263 T53086: Double newlines in blockquotes should be turned into paragraphs
2264 !! wikitext
2265 <blockquote>
2266 Foo
2267
2268 Bar
2269 </blockquote>
2270 !! html
2271 <blockquote>
2272 <p>Foo
2273 </p><p>Bar
2274 </p>
2275 </blockquote>
2276
2277 !! end
2278
2279 !! test
2280 T17491: <ins>/<del> in blockquote
2281 !! wikitext
2282 <blockquote>
2283 Foo <del>bar</del> <ins>baz</ins> quux
2284 </blockquote>
2285 !! html
2286 <blockquote>
2287 <p>Foo <del>bar</del> <ins>baz</ins> quux
2288 </p>
2289 </blockquote>
2290
2291 !! end
2292
2293 !! test
2294 T17491: <ins>/<del> in blockquote (2)
2295 !! wikitext
2296 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2297 </blockquote>
2298 !! html
2299 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2300 </blockquote>
2301
2302 !! html+tidy
2303 <blockquote><p>Foo </p><del>bar</del> <ins>baz</ins><p> quux
2304 </p></blockquote>
2305 !! end
2306
2307 !! test
2308 <pre> with attributes (T5202)
2309 !! wikitext
2310 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2311 !! html
2312 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2313
2314 !! end
2315
2316 !! test
2317 <pre> with width attribute (T5202)
2318 !! wikitext
2319 <pre width="8">Narrow screen goodies</pre>
2320 !! html
2321 <pre width="8">Narrow screen goodies</pre>
2322
2323 !! end
2324
2325 !! test
2326 <pre> with forbidden attribute (T5202)
2327 !! wikitext
2328 <pre width="8" onmouseover="alert(document.cookie)">Narrow screen goodies</pre>
2329 !! html
2330 <pre width="8">Narrow screen goodies</pre>
2331
2332 !! end
2333
2334 !! test
2335 Entities inside <pre>
2336 !! wikitext
2337 <pre>&lt;</pre>
2338 !! html
2339 <pre>&lt;</pre>
2340
2341 !! end
2342
2343 !! test
2344 <pre> with forbidden attribute values (T5202)
2345 !! wikitext
2346 <pre width="8" style="border-width: expression(alert(document.cookie))">Narrow screen goodies</pre>
2347 !! html
2348 <pre width="8" style="/* insecure input */">Narrow screen goodies</pre>
2349
2350 !! end
2351
2352 !! test
2353 <nowiki> inside <pre> (T15238)
2354 !! wikitext
2355 <pre>
2356 <nowiki>
2357 </pre>
2358 <pre>
2359 <nowiki></nowiki>
2360 </pre>
2361 <pre><nowiki><nowiki></nowiki>Foo<nowiki></nowiki></nowiki></pre>
2362 !! html
2363 <pre>
2364 &lt;nowiki&gt;
2365 </pre>
2366 <pre>
2367
2368 </pre>
2369 <pre>&lt;nowiki&gt;Foo&lt;/nowiki&gt;</pre>
2370
2371 !! end
2372
2373 !! test
2374 <nowiki> inside of #tag:pre
2375 !! wikitext
2376 {{#tag:pre|Foo <nowiki>&rarr;bar</nowiki>}}
2377 !! html/php
2378 <pre>Foo &#8594;bar</pre>
2379
2380 !! html/parsoid
2381 <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>
2382 !! end
2383
2384 ## Don't expect this to rt, Parsoid drops the unmatched closing pre tags that
2385 ## aren't enclosed in nowikis.
2386 !! test
2387 <nowiki> and <pre> preference (first one wins)
2388 !! options
2389 parsoid=wt2html
2390 !! wikitext
2391 <pre>
2392 <nowiki>
2393 </pre>
2394 </nowiki>
2395 </pre>
2396
2397 <nowiki>
2398 <pre>
2399 <nowiki>
2400 </pre>
2401 </nowiki>
2402 </pre>
2403
2404 !! html/php
2405 <pre>
2406 &lt;nowiki&gt;
2407 </pre>
2408 <p>&lt;/nowiki&gt;
2409 &lt;/pre&gt;
2410 </p><p>
2411 &lt;pre&gt;
2412 &lt;nowiki&gt;
2413 &lt;/pre&gt;
2414
2415 &lt;/pre&gt;
2416 </p>
2417 !! html/parsoid
2418 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n&lt;nowiki>\n"}}'>&lt;nowiki>
2419 </pre>
2420 <p>&lt;/nowiki></p>
2421
2422
2423 <p><span typeof="mw:Nowiki">
2424 &lt;pre>
2425 &lt;nowiki>
2426 &lt;/pre>
2427 </span></p>
2428 !! end
2429
2430 !! test
2431 </pre> inside nowiki
2432 !! wikitext
2433 <nowiki></pre></nowiki>
2434 !! html
2435 <p>&lt;/pre&gt;
2436 </p>
2437 !! end
2438
2439 !! test
2440 Empty pre; pre inside other HTML tags (T56946)
2441 !! wikitext
2442 a
2443
2444 <div><pre>
2445 foo
2446 </pre></div>
2447 <pre></pre>
2448 !! html/php+tidy
2449 <p>a
2450 </p>
2451 <div><pre>foo
2452 </pre></div>
2453 <pre></pre>
2454 !! html/parsoid
2455 <p>a</p>
2456
2457 <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
2458 </pre></div>
2459 <pre typeof="mw:Extension/pre" about="#mwt4" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":""}}'></pre>
2460 !! end
2461
2462 !! test
2463 HTML pre followed by indent-pre
2464 !! wikitext
2465 <pre>foo</pre>
2466 bar
2467 !! html
2468 <pre>foo</pre>
2469 <pre>bar
2470 </pre>
2471 !! end
2472
2473 !! test
2474 Block tag pre
2475 !! wikitext
2476 <p><pre>foo</pre></p>
2477 !! html/php+tidy
2478 <p class="mw-empty-elt"></p><pre>foo</pre><p class="mw-empty-elt"></p>
2479 !! html/parsoid
2480 <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>
2481 !! end
2482
2483 !!test
2484 Templates: Indent-Pre: 1a. Templates that break a line should suppress <pre>
2485 !! wikitext
2486 {{echo|}}
2487 !! html
2488
2489 !!end
2490
2491 !!test
2492 Templates: Indent-Pre: 1b. Templates that break a line should suppress <pre>
2493 !! wikitext
2494 {{echo|
2495 foo}}
2496 !! html
2497 <p>foo
2498 </p>
2499 !!end
2500
2501 !! test
2502 Templates: Indent-Pre: 1c: Wrapping should be based on expanded content
2503 !! wikitext
2504 {{echo|a
2505 b}}
2506 !! html
2507 <pre>a
2508 </pre>
2509 <p>b
2510 </p>
2511 !!end
2512
2513 !! test
2514 Templates: Indent-Pre: 1d: Wrapping should be based on expanded content
2515 !! wikitext
2516 {{echo|a
2517 b
2518 c
2519 d
2520 e
2521 }}
2522 !! html
2523 <pre>a
2524 </pre>
2525 <p>b
2526 c
2527 </p>
2528 <pre>d
2529 </pre>
2530 <p>e
2531 </p>
2532 !!end
2533
2534 !!test
2535 Templates: Indent-Pre: 1e. Wrapping should be based on expanded content
2536 !! wikitext
2537 {{echo| foo}}
2538
2539 {{echo| foo}}{{echo| bar}}
2540
2541 {{echo| foo}}
2542 {{echo| bar}}
2543
2544 {{echo|<!--cmt--> foo}}
2545
2546 <!--cmt-->{{echo| foo}}
2547
2548 {{echo|{{echo| }}bar}}
2549 !! html
2550 <pre>foo
2551 </pre>
2552 <pre>foo bar
2553 </pre>
2554 <pre>foo
2555 bar
2556 </pre>
2557 <pre>foo
2558 </pre>
2559 <pre>foo
2560 </pre>
2561 <pre>bar
2562 </pre>
2563 !!end
2564
2565 !! test
2566 Templates: Indent-Pre: 1f: Wrapping should be based on expanded content
2567 !! wikitext
2568 {{echo| }}a
2569
2570 {{echo|
2571 }}a
2572
2573 {{echo|
2574 b}}
2575
2576 {{echo|a
2577 }}b
2578
2579 {{echo|a
2580 }} b
2581 !! html
2582 <pre>a
2583 </pre>
2584 <p><br />
2585 </p>
2586 <pre>a
2587 </pre>
2588 <p><br />
2589 </p>
2590 <pre>b
2591 </pre>
2592 <p>a
2593 </p>
2594 <pre>b
2595 </pre>
2596 <p>a
2597 </p>
2598 <pre>b
2599 </pre>
2600 !!end
2601
2602 ## Hmm, should Parsoid rt this?
2603 !! test
2604 Pres with newline attributes
2605 !! options
2606 parsoid=wt2html,html2html
2607 !! wikitext
2608 <pre class="one
2609 two">hi</pre>
2610 !! html/php
2611 <pre class="one two">hi</pre>
2612
2613 !! html/parsoid
2614 <pre typeof="mw:Extension/pre" about="#mwt2" class="one two" data-mw='{"name":"pre","attrs":{"class":"one two"},"body":{"extsrc":"hi"}}'>hi</pre>
2615 !! end
2616
2617 !! test
2618 Things that look like <pre> tags aren't treated as such
2619 !! wikitext
2620 Barack Obama <President> of the United States
2621 <President></President>
2622 !! html
2623 <p>Barack Obama &lt;President&gt; of the United States
2624 &lt;President&gt;&lt;/President&gt;
2625 </p>
2626 !! end
2627
2628 !! test
2629 Handle broken pre-like tags (T66025)
2630 !! options
2631 parsoid=wt2html
2632 !! wikitext
2633 {{echo|<pre <pre>x</pre>}}
2634
2635 <table><pre </table>
2636 !! html/php
2637 <pre>x</pre>
2638 <table>&lt;pre </table>
2639
2640 !! html/php+tidy
2641 <pre>x</pre>
2642 &lt;pre <table></table>
2643 !! html/parsoid
2644 <pre about="#mwt1" typeof="mw:Transclusion mw:Extension/pre" data-parsoid='{"a":{"&lt;pre":null},"sa":{"&lt;pre":""},"stx":"html","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>
2645
2646
2647 <p>&lt;pre </p>
2648
2649 <table></table>
2650 !! end
2651
2652 !! test
2653 Parsoid: handle pre with space after attribute
2654 !! options
2655 parsoid=wt2html
2656 !! wikitext
2657 <pre style="width:50%;" >{{echo|foo}}</pre>
2658 !! html/php
2659 <pre style="width:50%;">{{echo|foo}}</pre>
2660
2661 !! html/parsoid
2662 <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>
2663 !! end
2664
2665 # TODO / maybe: fix wt2wt for this
2666 !! test
2667 Parsoid: Don't paragraph-wrap fosterable content
2668 !! options
2669 parsoid=wt2html
2670 !! wikitext
2671 {|
2672 <td></td>
2673 <td></td>
2674
2675
2676
2677 |}
2678 !! html
2679 <table>
2680
2681 <tbody>
2682 <tr>
2683 <td></td>
2684
2685 <td></td></tr>
2686
2687
2688
2689 </tbody></table>
2690 !! end
2691
2692 !! test
2693 Self-closed pre
2694 !! wikitext
2695 <pre />
2696 !! html/php
2697 <pre></pre>
2698
2699 !! html/parsoid
2700 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":null}'></pre>
2701 !! end
2702
2703 !! test
2704 Parsoid: Don't paragraph-wrap fosterable content even if table syntax is unbalanced
2705 !! options
2706 parsoid=wt2html
2707 !! wikitext
2708 {|
2709 <td>
2710 <td>
2711 </td>
2712
2713
2714
2715 |}
2716 !! html
2717 <table>
2718
2719 <tbody>
2720 <tr>
2721 <td></td>
2722
2723 <td>
2724 </td></tr>
2725
2726
2727
2728 </tbody></table>
2729 !! end
2730
2731
2732 #--------------------------------------------------------------------
2733 # Transclusion parameter whitespace stripping tests
2734 # Behavior is different for positional and named parameters
2735 #--------------------------------------------------------------------
2736 !! test
2737 Templates: Strip leading and trailing whitespace from named-param values
2738 !! wikitext
2739 {{echo|1= a }}
2740
2741 {{echo|1= {{echo|b}} }}
2742
2743 {{echo| 1 =
2744 c }}
2745
2746 {{echo| 1 =
2747 * d
2748 }}
2749 !! html
2750 <p>a
2751 </p><p>b
2752 </p><p>c
2753 </p>
2754 <ul><li> d</li></ul>
2755
2756 !! end
2757
2758 !! test
2759 Templates: Don't strip whitespace from positional-param values
2760 !! wikitext
2761 {{echo|a }}
2762
2763 {{echo|{{echo|b}} }}
2764
2765 {{echo| c
2766 }}
2767
2768 {{echo| {{echo|d}}
2769 }}
2770
2771 {{echo|
2772 e}}
2773
2774 {{echo|
2775 * f}}
2776
2777 {{echo|
2778 }}g
2779 !! html
2780 <p>a
2781 </p><p>b
2782 </p>
2783 <pre>c
2784 </pre>
2785 <p><br />
2786 </p>
2787 <pre>d
2788 </pre>
2789 <p><br />
2790 </p>
2791 <pre>e
2792 </pre>
2793 <p><br />
2794 </p>
2795 <ul><li> f</li></ul>
2796 <p><br />
2797 </p>
2798 <pre>g
2799 </pre>
2800 !! end
2801
2802 !! test
2803 Templates: Don't recognize targets split by newlines
2804 !! options
2805 parsoid=wt2html
2806 !! wikitext
2807 {{ech
2808 o|foo}}
2809 !! html/php
2810 <p>{{ech
2811 o|foo}}
2812 </p>
2813 !! html/parsoid
2814 <p>{{ech
2815 o|foo}}</p>
2816 !! end
2817
2818 !! test
2819 Templates: Recognize targets when newlines and comments don't split the target
2820 !! options
2821 parsoid=wt2html
2822 !! wikitext
2823 {{
2824 <!--X--> ech<!--X-->o<!--X-->
2825 <!--X--> <!--X-->
2826
2827 |foo}}
2828 !! html/php
2829 <p>foo
2830 </p>
2831 !! html/parsoid
2832 <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>
2833 !! end
2834
2835 !! test
2836 Templates: Handle empty comment-and-ws-only lines correctly
2837 !! wikitext
2838 {{echo|foo
2839 <!--should be ignored-->
2840 <!--should be ignored as well-->
2841 bar}}
2842 !! html/php
2843 <p>foo
2844 bar
2845 </p>
2846 !! html/parsoid
2847 <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>
2848 !! end
2849
2850 !! test
2851 Templates: Handle comments in the target
2852 !! wikitext
2853 {{echo
2854 <!-- should be ignored -->
2855 |foo}}
2856
2857 {{echo
2858 <!-- should be ignored and spaces on next line should not trip us up (T147742) -->
2859 |foo}}
2860
2861 {{echo<!-- should be ignored -->
2862 |foo}}
2863
2864 {{echo<!-- should be ignored -->|foo}}
2865
2866 {{<!-- should be ignored -->echo|foo}}
2867 !! html/php
2868 <p>foo
2869 </p><p>foo
2870 </p><p>foo
2871 </p><p>foo
2872 </p><p>foo
2873 </p>
2874 !! html/parsoid
2875 <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>
2876
2877 <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>
2878
2879 <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>
2880
2881 <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>
2882
2883 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
2884 !! end
2885
2886 !! test
2887 Templates: Handle comments in parameter names (T69657)
2888 !! wikitext
2889 {{echo|1
2890 <!-- should be ignored -->
2891 =foo}}
2892
2893 {{echo|
2894 <!-- should be ignored -->
2895 1 = foo}}
2896
2897 {{echo|1<!-- should be ignored -->=foo}}
2898
2899 {{echo|<!-- should be ignored -->1=foo}}
2900 !! html/php
2901 <p>foo
2902 </p><p>foo
2903 </p><p>foo
2904 </p><p>foo
2905 </p>
2906 !! html/parsoid
2907 <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>
2908
2909 <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>
2910
2911 <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>
2912
2913 <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>
2914 !! end
2915
2916 !! test
2917 Templates: Other wikitext in parameter names (T69657)
2918 !! wikitext
2919 {{echo|''1''=foo}}
2920 !! html/php
2921 <p>{{{1}}}
2922 </p>
2923 !! html/parsoid
2924 <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>
2925 !! end
2926
2927 !! test
2928 Templates: With colons
2929 !! wikitext
2930 {{With: Colon}}
2931 !! html/php
2932 <p>Template with colon
2933 </p>
2934 !! html/parsoid
2935 <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>
2936 !! end
2937
2938 #--------------------------------------------------------------------
2939 # Transclusion parameter escaping tests
2940 #--------------------------------------------------------------------
2941
2942 !! test
2943 Templates: Parsoid parameter escaping test 1
2944 !! wikitext
2945 {{echo|[foo]|{{echo|[bar]}}}}
2946 !! html/php+tidy
2947 <p>[foo]
2948 </p>
2949 !! html/parsoid
2950 <p about="#mwt1" typeof="mw:Transclusion"
2951 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[foo]"},"2":{"wt":"{{echo|[bar]}}"}},"i":0}}]}'>[foo]</p>
2952 !! end
2953
2954 !! test
2955 Parsoid: Pipes in external links in template parameter
2956 !! wikitext
2957 {{echo|[{{echo|http://example.com}} link]}}
2958 !! html/php+tidy
2959 <p><a rel="nofollow" class="external text" href="http://example.com">link</a>
2960 </p>
2961 !! html/parsoid
2962 <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>
2963 !! end
2964
2965 !! test
2966 Parsoid: pipe in transclusion parameter
2967 !! wikitext
2968 {{echo|http://foo.com/a&#124;b}}
2969 !! html/php+tidy
2970 <p><a rel="nofollow" class="external free" href="http://foo.com/a%7Cb">http://foo.com/a%7Cb</a>
2971 </p>
2972 !! html/parsoid
2973 <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>
2974 !! end
2975
2976 !! test
2977 Parsoid: Pipe in external link target and content in template parameter
2978 !! options
2979 parsoid=html2wt,wt2wt
2980 !! wikitext
2981 {{echo|[http://foo.com/a&#124;b a&#124;b]}}
2982 !! html/php+tidy
2983 <p><a rel="nofollow" class="external text" href="http://foo.com/a%7Cb">a&#124;b</a>
2984 </p>
2985 !! html/parsoid
2986 <p><a rel="mw:ExtLink" href="http://foo.com/a|b" about="#mwt1"
2987 typeof="mw:Transclusion"
2988 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},
2989 "params":{"1":{"wt":"[http://foo.com/a|b a|b]"}},"i":0}}]}'>a|b</a></p>
2990 !! end
2991
2992 !! test
2993 Parsoid: Pipe in template with nested template in external link target in template parameter (seriously)
2994 !! options
2995 parsoid
2996 !! wikitext
2997 {{echo|[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]}}
2998 !! html
2999 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]"}},"i":0}}]}'>[Main Page bar]</p>
3000 !! end
3001
3002 !! test
3003 Templates: Don't escape already nowiki-escaped text in template parameters
3004 !! options
3005 parsoid=html2wt,wt2wt
3006 !! wikitext
3007 {{echo|foo<nowiki>|</nowiki>bar}}
3008 {{echo|<nowiki>&lt;div&gt;</nowiki>}}
3009 {{echo|<nowiki></nowiki>}}
3010 !! html/php+tidy
3011 <p>foo|bar
3012 &lt;div&gt;
3013
3014 </p>
3015 !! html/parsoid
3016 <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>
3017 <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>
3018 <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>
3019 </p>
3020 !! end
3021
3022 ## T54824
3023 !! test
3024 Templates: '=' char in nested transclusions should not trigger nowiki escapes or conversion to named param
3025 !! options
3026 parsoid=html2wt,wt2wt
3027 !! wikitext
3028 {{echo|{{echo|1=bar}}}}
3029 !! html/php+tidy
3030 <p>bar
3031 </p>
3032 !! html/parsoid
3033 <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>
3034 !! end
3035
3036 ## T58733
3037 !! test
3038 Templates parameters with special tokenizing behavior dont get modified because of arg escaping
3039 !! wikitext
3040 {{echo|a : b}}
3041 !! html/php+tidy
3042 <p>a&#160;: b
3043 </p>
3044 !! html/parsoid
3045 <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>
3046 !! end
3047
3048 ## T73412
3049 !! test
3050 Templates: Preserve blank parameter names
3051 !! wikitext
3052 {{echo|=foo}}
3053 !! html/php+tidy
3054 <p>{{{1}}}
3055 </p>
3056 !! html/parsoid
3057 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"":{"wt":"foo"}},"i":0}}]}'>{{{1}}}</p>
3058 !! end
3059
3060 !! test
3061 Templates: Preserve blank parameter names in other positions
3062 !! wikitext
3063 {{blank_param|bar|=foo}}
3064 !! html/php+tidy
3065 <p>bar
3066 foo
3067 </p>
3068 !! html/parsoid
3069 <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
3070 foo</p>
3071 !! end
3072
3073 ###
3074 ### Parsoid-centric tests for testing RT edge cases for pre
3075 ###
3076
3077 !!test
3078 1a. Indent-Pre and Comments
3079 !! wikitext
3080 a
3081 <!--a-->
3082 c
3083 !! html
3084 <pre>a
3085 </pre>
3086 <p>c
3087 </p>
3088 !!end
3089
3090 !!test
3091 1b. Indent-Pre and Comments
3092 !! wikitext
3093 a
3094 <!--a-->
3095 c
3096 !! html
3097 <pre>a
3098 </pre>
3099 <p>c
3100 </p>
3101 !!end
3102
3103 !!test
3104 1c. Indent-Pre and Comments
3105 !! wikitext
3106 <!--a--> a
3107
3108 <!--a--> a
3109 !! html
3110 <pre> a
3111 </pre>
3112 <pre> a
3113 </pre>
3114 !!end
3115
3116 !!test
3117 1d. Indent-Pre and Comments
3118 (Pre-handler currently cannot distinguish between comment/ws order and normalizes them to [comment,ws] order)
3119 !! wikitext
3120 <!--a--> a
3121
3122 <!--b-->b
3123 !! html
3124 <pre>a
3125 </pre>
3126 <pre>b
3127 </pre>
3128 !!end
3129
3130 !!test
3131 2a. Indent-Pre and tables
3132 !! wikitext
3133 {|
3134 |-
3135 !h1!!h2
3136 |foo||bar
3137 |}
3138 !! html
3139 <table>
3140
3141 <tr>
3142 <th>h1</th>
3143 <th>h2
3144 </th>
3145 <td>foo</td>
3146 <td>bar
3147 </td></tr></table>
3148
3149 !!end
3150
3151 !!test
3152 2b. Indent-Pre and tables
3153 !! wikitext
3154 {|
3155 |-
3156 |foo
3157 |}
3158 !! html
3159 <table>
3160
3161 <tr>
3162 <td>foo
3163 </td></tr></table>
3164
3165 !!end
3166
3167 !!test
3168 2c. Indent-Pre and tables (T44252)
3169 !! wikitext
3170 {|
3171 |+ foo
3172 ! | bar
3173 |}
3174 !! html
3175 <table>
3176 <caption> foo
3177 </caption>
3178 <tr>
3179 <th> bar
3180 </th></tr></table>
3181
3182 !!end
3183
3184 !!test
3185 2d. Indent-Pre and tables
3186 !! wikitext
3187 a
3188 {|
3189 | b
3190 |}
3191 !! html/php
3192 <pre>a
3193 </pre>
3194 <table>
3195 <tr>
3196 <td> b
3197 </td></tr></table>
3198
3199 !! html/parsoid
3200 <pre>a</pre>
3201 <table>
3202 <tbody><tr><td> b</td></tr>
3203 </tbody></table>
3204 !!end
3205
3206 !!test
3207 2e. Indent-Pre and table-line syntax
3208 !! wikitext
3209 a
3210 | b
3211 | c
3212 !! html/php
3213 <pre>a
3214 | b
3215 | c
3216 </pre>
3217 !!end
3218
3219 !!test
3220 2f. Indent-pre started by table-line syntax
3221 !! wikitext
3222 a
3223 | b
3224 | c
3225 !! html/php
3226 <p>a
3227 </p>
3228 <pre>| b
3229 | c
3230 </pre>
3231 !! html/parsoid
3232 <p>a</p>
3233 <pre>
3234 | b
3235 | c</pre>
3236 !!end
3237
3238 !! test
3239 2g. Indented table markup mixed with indented pre content (proposed in T8200)
3240 !! wikitext
3241 <table>
3242 <tr>
3243 <td>
3244 Text that should be rendered preformatted
3245 </td>
3246 </tr>
3247 </table>
3248 !! html
3249 <table>
3250 <tr>
3251 <td>
3252 <pre>Text that should be rendered preformatted
3253 </pre>
3254 </td>
3255 </tr>
3256 </table>
3257
3258 !! end
3259
3260 !!test
3261 3a. Indent-Pre and block tags (single-line html)
3262 !! wikitext
3263 a <p> foo </p>
3264 b <div> foo </div>
3265 c <blockquote> foo </blockquote>
3266 <span> foo </span>
3267 !! html
3268 a <p> foo </p>
3269 b <div> foo </div>
3270 c <blockquote> foo </blockquote>
3271 <pre><span> foo </span>
3272 </pre>
3273 !! html/parsoid
3274 <p>a </p><p data-parsoid='{"stx":"html"}'> foo </p>
3275 <p>b </p><div data-parsoid='{"stx":"html"}'> foo </div>
3276 <p>c </p><blockquote data-parsoid='{"stx":"html"}'> foo </blockquote>
3277 <pre><span> foo </span>
3278 </pre>
3279 !! html/php+tidy
3280 <p> a </p><p> foo </p><p>
3281 b </p><div> foo </div><p>
3282 c </p><blockquote><p> foo </p></blockquote>
3283 <pre><span> foo </span>
3284 </pre>
3285 !! end
3286
3287 !!test
3288 3b. Indent-Pre and block tags (multi-line html)
3289 !! wikitext
3290 a <span>foo</span>
3291 b <div> foo </div>
3292 !! html
3293 <pre>a <span>foo</span>
3294 </pre>
3295 b <div> foo </div>
3296
3297 !! html/parsoid
3298 <pre>a <span data-parsoid='{"stx":"html"}'>foo</span></pre>
3299 b <div data-parsoid='{"stx":"html"}'> foo </div>
3300 !! html/php+tidy
3301 <pre>a <span>foo</span>
3302 </pre><p>
3303 b </p><div> foo </div>
3304 !!end
3305
3306 !!test
3307 3c. Indent-Pre and block tags (pre-content on separate line)
3308 !! wikitext
3309 <p>
3310 foo
3311 </p>
3312
3313 <div>
3314 foo
3315 </div>
3316
3317 <center>
3318 foo
3319 </center>
3320
3321 <blockquote>
3322 foo
3323 </blockquote>
3324
3325 <blockquote>
3326 <pre>
3327 foo
3328 </pre>
3329 </blockquote>
3330
3331 <table><tr><td>
3332 foo
3333 </td></tr></table>
3334
3335 <ul><li>
3336 foo
3337 </li></ul>
3338
3339 !! html
3340 <p>
3341 foo
3342 </p>
3343 <div>
3344 <pre>foo
3345 </pre>
3346 </div>
3347 <center>
3348 <pre>foo
3349 </pre>
3350 </center>
3351 <blockquote>
3352 <p> foo
3353 </p>
3354 </blockquote>
3355 <blockquote>
3356 <pre>
3357 foo
3358 </pre>
3359 </blockquote>
3360 <table><tr><td>
3361 <pre>foo
3362 </pre>
3363 </td></tr></table>
3364 <ul><li>
3365 foo
3366 </li></ul>
3367
3368 !!end
3369
3370 !! test
3371 4. Indent-Pre and extension tags
3372 !! wikitext
3373 a <tag />
3374 !! html/php
3375 a <pre>
3376 NULL
3377 array (
3378 )
3379 </pre>
3380
3381 !! html/parsoid
3382 a <pre typeof="mw:Extension/tag" about="#mwt2" data-parsoid='{}' data-mw='{"name":"tag","attrs":{},"body":null}'></pre>
3383 !! end
3384
3385 !! test
3386 5. Indent-Pre and html pre
3387 !! wikitext
3388 <pre class="123">hi</pre>
3389 !! html/php
3390 <pre class="123">hi</pre>
3391
3392 !! html/parsoid
3393 <pre typeof="mw:Extension/pre" about="#mwt2" class="123" data-mw='{"name":"pre","attrs":{"class":"123"},"body":{"extsrc":"hi"}}'>hi</pre>
3394 !! end
3395
3396 !!test
3397 Render paragraphs when indent-pre is suppressed in blocklevels
3398 !! wikitext
3399 <blockquote>
3400 foo
3401
3402 bar
3403 </blockquote>
3404 !! html
3405 <blockquote>
3406 <p> foo
3407 </p><p> bar
3408 </p>
3409 </blockquote>
3410
3411 !!end
3412
3413 !!test
3414 4. Multiple spaces at start-of-line
3415 !! wikitext
3416 <p> foo </p>
3417 foo
3418 {|
3419 |foo
3420 |}
3421 !! html
3422 <p> foo </p>
3423 <pre> foo
3424 </pre>
3425 <table>
3426 <tr>
3427 <td>foo
3428 </td></tr></table>
3429
3430 !!end
3431
3432 ## NOTE: the leading white-space chars on empty line are significant
3433 !! test
3434 5a. White-space in indent-pre
3435 !! wikitext
3436 a<br />
3437
3438 b
3439 !! html
3440 <pre>a<br />
3441
3442 b
3443 </pre>
3444 !! end
3445
3446 ## NOTE: the leading white-space chars on empty line are significant
3447 !! test
3448 5b. White-space in indent-pre
3449 !! wikitext
3450 a
3451
3452 b
3453
3454
3455 c
3456 !! html
3457 <pre>a
3458
3459 b
3460
3461
3462 c
3463 </pre>
3464 !! end
3465
3466 !! test
3467 5c. White-space in indent-pre
3468 !! wikitext
3469 ''a''
3470 ''b''
3471 ''c''
3472 !! html
3473 <pre><i>a</i>
3474 <i>b</i>
3475 <i>c</i>
3476 </pre>
3477 !! end
3478
3479 !! test
3480 6. Pre-blocks should extend across lines with leading WS even when there is no wrappable content
3481 !! wikitext
3482 a
3483
3484 <!-- continue -->
3485 b
3486
3487 c
3488
3489 d
3490 !! html
3491 <pre>a
3492
3493 b
3494 </pre>
3495 <pre>c
3496
3497 </pre>
3498 <p>d
3499 </p>
3500 !! end
3501
3502 !! test
3503 7a. Indent-pre and category links
3504 !! options
3505 parsoid=wt2html,wt2wt
3506 !! wikitext
3507 [[Category:foo]] <!-- No pre-wrapping -->
3508 {{echo| [[Category:foo]]}} <!-- No pre-wrapping -->
3509 !! html/php+tidy
3510 !! html/parsoid
3511 <link rel="mw:PageProp/Category" href="./Category:Foo"> <!-- No pre&#x2D;wrapping -->
3512 <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 -->
3513 !! end
3514
3515 ## We used to, but no longer wt2wt this test since the default serializer
3516 ## will normalize all categories to serialize on their own line.
3517 ## This wikitext usage is going to be fairly uncommon in production and
3518 ## selser will take care of preserving formatting in those scenarios.
3519 !! test
3520 7b. Indent-pre and category links
3521 !! options
3522 parsoid=wt2html
3523 !! wikitext
3524 [[Category:foo]] a
3525 [[Category:foo]] {{echo|b}}
3526 !! html/parsoid
3527 <pre><link rel="mw:PageProp/Category" href="./Category:Foo"> a
3528 <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>
3529 !! end
3530
3531 !! test
3532 Indent-Pre: Newlines in comments shouldn't affect sol state
3533 !! wikitext
3534 a <!--
3535 foo
3536 --> b
3537 !! html/php+tidy
3538 <p>a b
3539 </p>
3540 !! html/parsoid
3541 <p>a <!--
3542 foo
3543 --> b</p>
3544 !! end
3545
3546 ###
3547 ### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric)
3548 ###
3549
3550 !!test
3551 HTML-pre: 1. embedded newlines
3552 !! wikitext
3553 <pre>foo</pre>
3554
3555 <pre>
3556 foo
3557 </pre>
3558
3559 <pre>
3560
3561 foo
3562 </pre>
3563
3564 <pre>
3565
3566
3567 foo
3568 </pre>
3569 !! html/php+tidy
3570 <pre>foo</pre>
3571 <pre>foo
3572 </pre>
3573 <pre>
3574
3575 foo
3576 </pre>
3577 <pre>
3578
3579
3580 foo
3581 </pre>
3582 !! html/parsoid
3583 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre>
3584
3585 <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
3586 </pre>
3587
3588 <pre typeof="mw:Extension/pre" about="#mwt6" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\nfoo\n"}}'>
3589
3590 foo
3591 </pre>
3592
3593 <pre typeof="mw:Extension/pre" about="#mwt8" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\nfoo\n"}}'>
3594
3595
3596 foo
3597 </pre>
3598 !!end
3599
3600 !! test
3601 HTML-pre: big spaces
3602 !! wikitext
3603 <pre>
3604
3605
3606
3607
3608 haha
3609
3610
3611
3612
3613 haha
3614
3615
3616
3617
3618 </pre>
3619 !! html/php+tidy
3620 <pre>
3621
3622
3623
3624
3625 haha
3626
3627
3628
3629
3630 haha
3631
3632
3633
3634
3635 </pre>
3636 !! html/parsoid
3637 <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"}}'>
3638
3639
3640
3641
3642 haha
3643
3644
3645
3646
3647 haha
3648
3649
3650
3651
3652 </pre>
3653 !! end
3654
3655 !!test
3656 HTML-pre: 2: indented text
3657 !! wikitext
3658 <pre>
3659 foo
3660 </pre>
3661 !! html
3662 <pre>
3663 foo
3664 </pre>
3665
3666 !!end
3667
3668 !!test
3669 HTML-pre: 3: other wikitext
3670 !! wikitext
3671 <pre>
3672 * foo
3673 # bar
3674 = no-h =
3675 '' no-italic ''
3676 [[ NoLink ]]
3677 </pre>
3678 !! html/php
3679 <pre>
3680 * foo
3681 # bar
3682 = no-h =
3683 '' no-italic ''
3684 [[ NoLink ]]
3685 </pre>
3686
3687 !! html/parsoid
3688 <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
3689 # bar
3690 = no-h =
3691 '' no-italic ''
3692 [[ NoLink ]]
3693 </pre>
3694 !!end
3695
3696 ###
3697 ### Definition lists
3698 ###
3699 !! test
3700 Simple definition
3701 !! wikitext
3702 ; name : Definition
3703 !! html
3704 <dl><dt> name&#160;</dt>
3705 <dd> Definition</dd></dl>
3706
3707 !! end
3708
3709 !! test
3710 Definition list for indentation only
3711 !! wikitext
3712 : Indented text
3713 !! html
3714 <dl><dd> Indented text</dd></dl>
3715
3716 !! end
3717
3718 !! test
3719 Definition list with no space
3720 !! wikitext
3721 ;name:Definition
3722 !! html
3723 <dl><dt>name</dt>
3724 <dd>Definition</dd></dl>
3725
3726 !!end
3727
3728 !! test
3729 Definition list with URL link
3730 !! wikitext
3731 ; http://example.com/ : definition
3732 !! html
3733 <dl><dt> <a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&#160;</dt>
3734 <dd> definition</dd></dl>
3735
3736 !! end
3737
3738 !! test
3739 Definition list with bracketed URL link
3740 !! wikitext
3741 ;[http://www.example.com/ Example]:Something about it
3742 !! html
3743 <dl><dt><a rel="nofollow" class="external text" href="http://www.example.com/">Example</a></dt>
3744 <dd>Something about it</dd></dl>
3745
3746 !! end
3747
3748 !! test
3749 Definition list with wikilink containing colon
3750 !! wikitext
3751 ; [[Help:FAQ]]: The least-read page on Wikipedia
3752 !! html
3753 <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>
3754 <dd> The least-read page on Wikipedia</dd></dl>
3755
3756 !! end
3757
3758 # At Brion's and JeLuF's insistence... :)
3759 !! test
3760 Definition list with news link containing colon
3761 !! wikitext
3762 ; news:alt.wikipedia.rox: This isn't even a real newsgroup!
3763 !! html/php
3764 <dl><dt> <a rel="nofollow" class="external free" href="news:alt.wikipedia.rox">news:alt.wikipedia.rox</a></dt>
3765 <dd> This isn't even a real newsgroup!</dd></dl>
3766
3767 !! html/parsoid
3768 <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>
3769 !! end
3770
3771 !! test
3772 Malformed definition list with colon
3773 !! wikitext
3774 ; news:alt.wikipedia.rox -- don't crash or enter an infinite loop
3775 !! html
3776 <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>
3777
3778 !! end
3779
3780 !! test
3781 Definition lists: colon in external link text
3782 !! wikitext
3783 ; [http://www.wikipedia2.org/ Wikipedia : The Next Generation]: OK, I made that up
3784 !! html
3785 <dl><dt> <a rel="nofollow" class="external text" href="http://www.wikipedia2.org/">Wikipedia&#160;: The Next Generation</a></dt>
3786 <dd> OK, I made that up</dd></dl>
3787
3788 !! end
3789
3790 !! test
3791 Definition lists: colon in HTML attribute
3792 !! wikitext
3793 ;<b style="display: inline">bold</b>
3794 !! html
3795 <dl><dt><b style="display: inline">bold</b></dt></dl>
3796
3797 !! end
3798
3799 !! test
3800 Definition lists: self-closed tag
3801 !! wikitext
3802 ;one<br/>two : two-line fun
3803 !! html
3804 <dl><dt>one<br />two&#160;</dt>
3805 <dd> two-line fun</dd></dl>
3806
3807 !! end
3808
3809 !! test
3810 Definition lists: ignore colons inside tags
3811 !! wikitext
3812 ;one <b>two : tag <i>fun:</i>:</b>: def
3813 !! html
3814 <dl><dt>one <b>two&#160;: tag <i>fun:</i>:</b></dt>
3815 <dd> def</dd></dl>
3816
3817 !! end
3818
3819 !! test
3820 Definition lists: excess closed tags
3821 !! wikitext
3822 ;one</b>two : bad tag fun
3823 !! html/php+tidy
3824 <dl><dt>onetwo&#160;</dt>
3825 <dd> bad tag fun</dd></dl>
3826 !! html/parsoid
3827 <dl>
3828 <dt>onetwo</dt>
3829 <dd>bad tag fun</dd>
3830 </dl>
3831 !! end
3832
3833 !! test
3834 T13748: Literal closing tags
3835 !! wikitext
3836 <dl>
3837 <dt>test 1</dt>
3838 <dd>test test test test test</dd>
3839 <dt>test 2</dt>
3840 <dd>test test test test test</dd>
3841 </dl>
3842 !! html
3843 <dl>
3844 <dt>test 1</dt>
3845 <dd>test test test test test</dd>
3846 <dt>test 2</dt>
3847 <dd>test test test test test</dd>
3848 </dl>
3849
3850 !! end
3851
3852 !! test
3853 Definition and unordered list using wiki syntax nested in unordered list using html tags.
3854 !! wikitext
3855 <ul><li>
3856 ; term : description
3857 * unordered
3858 </li></ul>
3859 !! html
3860 <ul><li>
3861 <dl><dt> term&#160;</dt>
3862 <dd> description</dd></dl>
3863 <ul><li> unordered</li></ul>
3864 </li></ul>
3865
3866 !! end
3867
3868 !! test
3869 Definition list with empty definition and following paragraph
3870 !! wikitext
3871 ; term:
3872 Paragraph text
3873 !! html
3874 <dl><dt> term</dt>
3875 <dd></dd></dl>
3876 <p>Paragraph text
3877 </p>
3878 !! end
3879
3880 !! test
3881 Nested definition lists using html syntax
3882 !! wikitext
3883 <dl><dt>x</dt>
3884 <dd>a</dd>
3885 <dd>b</dd></dl>
3886 !! html
3887 <dl><dt>x</dt>
3888 <dd>a</dd>
3889 <dd>b</dd></dl>
3890
3891 !! end
3892
3893 !! test
3894 Definition Lists: No nesting: Multiple dd's
3895 !! wikitext
3896 ;x
3897 :a
3898 :b
3899 !! html
3900 <dl><dt>x</dt>
3901 <dd>a</dd>
3902 <dd>b</dd></dl>
3903
3904 !! end
3905
3906 !! test
3907 Definition Lists: Indentation: Regular
3908 !! wikitext
3909 :i1
3910 ::i2
3911 :::i3
3912 !! html
3913 <dl><dd>i1
3914 <dl><dd>i2
3915 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
3916
3917 !! end
3918
3919 !! test
3920 Definition Lists: Indentation: Missing 1st level
3921 !! wikitext
3922 ::i2
3923 :::i3
3924 !! html
3925 <dl><dd><dl><dd>i2
3926 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
3927
3928 !! end
3929
3930 !! test
3931 Definition Lists: Indentation: Multi-level indent
3932 !! wikitext
3933 :::i3
3934 !! html
3935 <dl><dd><dl><dd><dl><dd>i3</dd></dl></dd></dl></dd></dl>
3936
3937 !! end
3938
3939 !! test
3940 Definition Lists: Hacky use to indent tables
3941 !! wikitext
3942 ::{|
3943 |foo
3944 |bar
3945 |}
3946 this text
3947 should be left alone
3948 !! html
3949 <dl><dd><dl><dd><table>
3950 <tr>
3951 <td>foo
3952 </td>
3953 <td>bar
3954 </td></tr></table></dd></dl></dd></dl>
3955 <p>this text
3956 should be left alone
3957 </p>
3958 !! end
3959
3960 !! test
3961 Definition Lists: Hacky use to indent tables, with comments (T65979)
3962 !! wikitext
3963 <!-- foo -->
3964 ::{|
3965 |foo
3966 |bar
3967 |}<!-- bar -->
3968 this text
3969 should be left alone
3970 !! html/parsoid
3971 <!-- foo -->
3972 <dl><dd><dl><dd><table><tr>
3973 <td>foo</td>
3974 <td>bar</td>
3975 </tr></table><!-- bar --></dd></dl></dd></dl>
3976 <p>this text
3977 should be left alone</p>
3978 !! end
3979
3980 !! test
3981 Definition Lists: Hacky use to indent tables, with comment before table
3982 !! wikitext
3983 ::<!-- foo -->{|
3984 |foo
3985 |}
3986 !! html/parsoid
3987 <dl><dd><dl><dd><!-- foo --><table><tr>
3988 <td>foo</td>
3989 </tr></table></dd></dl></dd></dl>
3990 !! end
3991
3992 # The trailing whitespace in this test is to catch a regression in
3993 # Parsoid after T54473.
3994 !! test
3995 Definition Lists: Hacky use to indent tables (WS-insensitive)
3996 !! wikitext
3997 : {|
3998 |a
3999 |}
4000 !! html/php
4001 <dl><dd><table>
4002 <tr>
4003 <td>a
4004 </td></tr></table></dd></dl>
4005
4006 !! html/parsoid
4007 <dl><dd> <table>
4008 <tbody><tr><td>a</td></tr>
4009 </tbody></table> </dd></dl>
4010 !! end
4011
4012 ## The PHP parser treats : items (dd) without a corresponding ; item (dt)
4013 ## as an empty dt item. It also ignores all but the last ";" when followed
4014 ## by ":" later on. So, ";" are not ignored in ";;;t3" but are ignored in
4015 ## ";;;t3 :d1". So, PHP parser behavior is a little inconsistent wrt multiple
4016 ## ";"s.
4017 ##
4018 ## Ex: ";;t2 ::d2" is transformed into:
4019 ##
4020 ## <dl>
4021 ## <dt>t2 </dt>
4022 ## <dd>
4023 ## <dl>
4024 ## <dt></dt>
4025 ## <dd>d2</dd>
4026 ## </dl>
4027 ## </dd>
4028 ## </dl>
4029 ##
4030 ## But, Parsoid treats "; :" as a tight atomic unit and excess ":" as plain text
4031 ## So, the same wikitext above (;;t2 ::d2) is transformed into:
4032 ##
4033 ## <dl>
4034 ## <dt>
4035 ## <dl>
4036 ## <dt>t2 </dt>
4037 ## <dd>:d2</dd>
4038 ## </dl>
4039 ## </dt>
4040 ## </dl>
4041 ##
4042 ## All Parsoid only definition list tests have this difference.
4043 ##
4044 ## See also: https://phabricator.wikimedia.org/T8569
4045 ## and https://lists.wikimedia.org/pipermail/wikitext-l/2011-November/000483.html
4046
4047 !! test
4048 Table / list interaction: indented table with lists in table contents
4049 !! wikitext
4050 :{|
4051 |-
4052 | a
4053 * b
4054 |-
4055 | c
4056 * d
4057 |}
4058 !! html
4059 <dl><dd><table>
4060
4061 <tr>
4062 <td> a
4063 <ul><li> b</li></ul>
4064 </td></tr>
4065 <tr>
4066 <td> c
4067 <ul><li> d</li></ul>
4068 </td></tr></table></dd></dl>
4069
4070 !! end
4071
4072 !!test
4073 Table / list interaction: lists nested in tables nested in indented lists
4074 !! wikitext
4075 :{|
4076 |
4077 :a
4078 :b
4079 |
4080 *c
4081 *d
4082 |}
4083
4084 *e
4085 *f
4086 !! html
4087 <dl><dd><table>
4088 <tr>
4089 <td>
4090 <dl><dd>a</dd>
4091 <dd>b</dd></dl>
4092 </td>
4093 <td>
4094 <ul><li>c</li>
4095 <li>d</li></ul>
4096 </td></tr></table></dd></dl>
4097 <ul><li>e</li>
4098 <li>f</li></ul>
4099
4100 !!end
4101
4102 !! test
4103 Definition Lists: Nesting: Multi-level (Parsoid only)
4104 !! wikitext
4105 ;t1 :d1
4106 ;;t2 ::d2
4107 ;;;t3 :::d3
4108 !! html/parsoid
4109 <dl>
4110 <dt>t1 </dt>
4111 <dd>d1</dd>
4112 <dt>
4113 <dl>
4114 <dt>t2 </dt>
4115 <dd>:d2</dd>
4116 <dt>
4117 <dl>
4118 <dt>t3 </dt>
4119 <dd>::d3</dd>
4120 </dl>
4121 </dt>
4122 </dl>
4123 </dt>
4124 </dl>
4125
4126
4127 !! end
4128
4129
4130 !! test
4131 Definition Lists: Nesting: Test 2
4132 !! wikitext
4133 ;t1
4134 ::d2
4135 !! html+tidy
4136 <dl><dt>t1</dt>
4137 <dd>
4138 <dl><dd>d2</dd></dl></dd></dl>
4139 !! end
4140
4141
4142 !! test
4143 Definition Lists: Nesting: Test 3
4144 !! wikitext
4145 :;t1
4146 ::::d2
4147 !! html+tidy
4148 <dl><dd><dl><dt>t1</dt>
4149 <dd>
4150 <dl><dd><dl><dd>d2</dd></dl></dd></dl></dd></dl></dd></dl>
4151 !! end
4152
4153
4154 !! test
4155 Definition Lists: Nesting: Test 4
4156 !! wikitext
4157 ::;t3
4158 :::d3
4159 !! html
4160 <dl><dd><dl><dd><dl><dt>t3</dt>
4161 <dd>d3</dd></dl></dd></dl></dd></dl>
4162
4163 !! end
4164
4165
4166 ## The Parsoid team believes the following three test exposes a
4167 ## bug in the PHP parser. (Parsoid team thinks the PHP parser is
4168 ## wrong to close the <dl> after the <dt> containing the <ul>.)
4169 ## It also exposes a "misfeature" in tidy, which doesn't like
4170 ## <dl> tags with a single <dt> child; it converts the <dt> into
4171 ## a <dd> in that case. (Parsoid leaves the <dt> alone!)
4172 !! test
4173 Definition Lists: Mixed Lists: Test 1
4174 !! wikitext
4175 :;* foo
4176 ::* bar
4177 :; baz
4178 !! html/php
4179 <dl><dd><dl><dt><ul><li> foo</li>
4180 <li> bar</li></ul></dt></dl>
4181 <dl><dt> baz</dt></dl></dd></dl>
4182
4183 !! html/php+tidy
4184 <dl><dd><dl><dt><ul><li> foo</li>
4185 <li> bar</li></ul></dt></dl>
4186 <dl><dt> baz</dt></dl></dd></dl>
4187 !! html/parsoid
4188 <dl>
4189 <dd><dl>
4190 <dt><ul>
4191 <li> foo
4192 </li>
4193 </ul></dt>
4194 <dd><ul>
4195 <li> bar
4196 </li>
4197 </ul></dd>
4198 <dt> baz</dt>
4199 </dl></dd>
4200 </dl>
4201 !! end
4202
4203 !! test
4204 Definition Lists: Mixed Lists: Test 2
4205 !! wikitext
4206 *: d1
4207 *: d2
4208 !! html
4209 <ul><li><dl><dd> d1</dd>
4210 <dd> d2</dd></dl></li></ul>
4211
4212 !! end
4213
4214
4215 !! test
4216 Definition Lists: Mixed Lists: Test 3
4217 !! wikitext
4218 *::: d1
4219 *::: d2
4220 !! html
4221 <ul><li><dl><dd><dl><dd><dl><dd> d1</dd>
4222 <dd> d2</dd></dl></dd></dl></dd></dl></li></ul>
4223
4224 !! end
4225
4226
4227 !! test
4228 Definition Lists: Mixed Lists: Test 4
4229 !! wikitext
4230 *;d1 :d2
4231 *;d3 :d4
4232 !! html
4233 <ul><li><dl><dt>d1&#160;</dt>
4234 <dd>d2</dd>
4235 <dt>d3&#160;</dt>
4236 <dd>d4</dd></dl></li></ul>
4237
4238 !! end
4239
4240
4241 !! test
4242 Definition Lists: Mixed Lists: Test 5
4243 !! wikitext
4244 *:d1
4245 *:: d2
4246 !! html
4247 <ul><li><dl><dd>d1
4248 <dl><dd> d2</dd></dl></dd></dl></li></ul>
4249
4250 !! end
4251
4252
4253 !! test
4254 Definition Lists: Mixed Lists: Test 6
4255 !! wikitext
4256 #*:d1
4257 #*::: d3
4258 !! html
4259 <ol><li><ul><li><dl><dd>d1
4260 <dl><dd><dl><dd> d3</dd></dl></dd></dl></dd></dl></li></ul></li></ol>
4261
4262 !! end
4263
4264
4265 !! test
4266 Definition Lists: Mixed Lists: Test 7
4267 !! wikitext
4268 :* d1
4269 :* d2
4270 !! html
4271 <dl><dd><ul><li> d1</li>
4272 <li> d2</li></ul></dd></dl>
4273
4274 !! end
4275
4276
4277 !! test
4278 Definition Lists: Mixed Lists: Test 8
4279 !! wikitext
4280 :* d1
4281 ::* d2
4282 !! html
4283 <dl><dd><ul><li> d1</li></ul>
4284 <dl><dd><ul><li> d2</li></ul></dd></dl></dd></dl>
4285
4286 !! end
4287
4288
4289 !! test
4290 Definition Lists: Mixed Lists: Test 9
4291 !! wikitext
4292 *;foo :bar
4293 !! html
4294 <ul><li><dl><dt>foo&#160;</dt>
4295 <dd>bar</dd></dl></li></ul>
4296
4297 !! end
4298
4299
4300 !! test
4301 Definition Lists: Mixed Lists: Test 10
4302 !! wikitext
4303 *#;foo :bar
4304 !! html
4305 <ul><li><ol><li><dl><dt>foo&#160;</dt>
4306 <dd>bar</dd></dl></li></ol></li></ul>
4307
4308 !! end
4309
4310 # The Parsoid team disagrees with the PHP parser's seemingly-random
4311 # rules regarding dd/dt on the next few tests. Parsoid is more
4312 # consistent, and recognizes the shared nesting and keeps the
4313 # still-open tags around until the nesting is complete.
4314
4315 # This is a regression test for T175099
4316 !! test
4317 Definition Lists: Mixed Lists: Test 11
4318 !! wikitext
4319 ;a
4320 :*b
4321 !! html/php
4322 <dl><dt>a</dt>
4323 <dd>
4324 <ul><li>b</li></ul></dd></dl>
4325
4326 !! html/parsoid
4327 <dl><dt>a
4328 <dd><ul><li>b</li></ul></dd></dl>
4329 !! end
4330
4331 # FIXME: Maybe get rid of this test?
4332 !! test
4333 Definition Lists: Mixed Lists: Test 12
4334 !! wikitext
4335 *#*#;*;;foo :bar
4336 *#*#;boo :baz
4337 !! html/php
4338 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</dt>
4339 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dd></dl></li></ul></dd></dl>
4340 <dl><dt>boo&#160;</dt>
4341 <dd>baz</dd></dl></li></ol></li></ul></li></ol></li></ul>
4342
4343 !! html/php+tidy
4344 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</dt>
4345 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dt></dl></li></ul></dd></dl></li></ol></li></ul>
4346 <dl><dt>boo&#160;</dt>
4347 <dd>baz</dd></dl></li></ol></li></ul>
4348 !! html/parsoid
4349 <ul>
4350 <li>
4351 <ol>
4352 <li>
4353 <ul>
4354 <li>
4355 <ol>
4356 <li>
4357 <dl>
4358 <dt>
4359 <ul>
4360 <li>
4361 <dl>
4362 <dt>
4363 <dl>
4364 <dt>foo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
4365 <dd data-parsoid='{"stx":"row"}'>bar</dd>
4366 </dl></dt>
4367 </dl></li>
4368 </ul></dt>
4369 <dt>boo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
4370 <dd data-parsoid='{"stx":"row"}'>baz</dd>
4371 </dl></li>
4372 </ol></li>
4373 </ul></li>
4374 </ol></li>
4375 </ul>
4376 !! end
4377
4378 # FIXME: Maybe get rid of this test?
4379 # From whitelist:
4380 # * The test is wrong, there are two colons where there should be :;
4381 # * The PHP parser is wrong to close the <dl> after the <dt> containing the <ul>.
4382 !! test
4383 Definition Lists: Weird Ones: Test 1
4384 !! wikitext
4385 *#;*::;; foo : bar (who uses this?)
4386 !! html/php+tidy
4387 <ul><li><ol><li><dl><dt> foo&#160;</dt>
4388 <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>
4389 !! html/parsoid
4390 <ul>
4391 <li>
4392 <ol>
4393 <li>
4394 <dl>
4395 <dt>
4396 <ul>
4397 <li>
4398 <dl>
4399 <dd>
4400 <dl>
4401 <dd>
4402 <dl>
4403 <dt>
4404 <dl>
4405 <dt> foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span></dt>
4406 <dd data-parsoid='{"stx":"row"}'> bar (who uses this?)</dd>
4407 </dl></dt>
4408 </dl></dd>
4409 </dl></dd>
4410 </dl></li>
4411 </ul></dt>
4412 </dl></li>
4413 </ol></li>
4414 </ul>
4415 !! end
4416
4417 !! test
4418 Definition Lists: colons occurring in tags
4419 !! wikitext
4420 ;a:b
4421 ;'''a:b'''
4422 ;<i>a:b</i>
4423 ;<span>a:b</span>
4424 ;<div>a:b</div>
4425 ;<div>a
4426 :b</div>
4427 ;{{echo|a:b}}
4428 ;{{echo|''a:b''}}
4429 ;;;''a:b''
4430 !! html+tidy
4431 <dl><dt>a</dt>
4432 <dd>b</dd>
4433 <dt><b>a:b</b></dt>
4434 <dt><i>a:b</i></dt>
4435 <dt><span>a:b</span></dt>
4436 <dt><div>a:b</div></dt>
4437 <dt><div>a</div></dt>
4438 <dd>b</dd>
4439 <dt>a</dt>
4440 <dd>b</dd>
4441 <dt><i>a:b</i></dt></dl>
4442 <dl><dt><dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4443 !! html/parsoid
4444 <dl><dt>a</dt><dd data-parsoid='{"stx":"row"}'>b</dd>
4445 <dt><b>a:b</b></dt>
4446 <dt><i data-parsoid='{"stx":"html"}'>a:b</i></dt>
4447 <dt><span data-parsoid='{"stx":"html"}'>a:b</span></dt>
4448 <dt><div data-parsoid='{"stx":"html"}'>a:b</div></dt>
4449 <dt><div data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</div></dt>
4450 <dd>b</dd>
4451 <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>
4452 <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>
4453 <dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4454 !! end
4455
4456 # Parsoid's output differs here again because it shares
4457 # nesting between the two lists unlike the PHP parser.
4458 # Unsure which is more desirable.
4459 !! test
4460 Definition Lists: colons and tables 1
4461 !! wikitext
4462 :{|
4463 | x
4464 |}
4465 :{|
4466 | y
4467 |}
4468 !! html/php
4469 <dl><dd><table>
4470 <tr>
4471 <td> x
4472 </td></tr></table></dd></dl>
4473 <dl><dd><table>
4474 <tr>
4475 <td> y
4476 </td></tr></table></dd></dl>
4477
4478 !! html/parsoid
4479 <dl><dd><table>
4480 <tr>
4481 <td> x
4482 </td></tr></table></dd>
4483 <dd><table>
4484 <tr>
4485 <td> y
4486 </td></tr></table></dd></dl>
4487 !! end
4488
4489 # FIXME: Does this need a html/php section?
4490 !! test
4491 Definition Lists: template interaction
4492 !! wikitext
4493 ::{{definition_list}}
4494
4495 :one
4496 ::{{definition_list}}
4497 :::two
4498 :::three
4499 ::four
4500 !! html/parsoid
4501 <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">
4502 </span><dd about="#mwt1">two</dd></dl></dd></dl>
4503
4504 <dl><dd data-parsoid='{}'>one
4505 <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">
4506 </span><dd about="#mwt2">two
4507 <dl><dd>two</dd>
4508 <dd>three</dd></dl></dd>
4509 <dd data-parsoid='{}'>four</dd></dl></dd></dl>
4510 !! end
4511
4512
4513 ###
4514 ### External links
4515 ###
4516 !! test
4517 External links: non-bracketed
4518 !! wikitext
4519 Non-bracketed: http://example.com
4520 !! html
4521 <p>Non-bracketed: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4522 </p>
4523 !! end
4524
4525 # parsoid doesn't explicitly mark autonumbered links, see T55505
4526 !! test
4527 External links: numbered
4528 !! wikitext
4529 Numbered: [http://example.com]
4530 Numbered: [http://example.net]
4531 Numbered: [http://example.com]
4532 !! html/php
4533 <p>Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>
4534 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.net">[2]</a>
4535 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[3]</a>
4536 </p>
4537 !! html/parsoid
4538 <p>Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>
4539 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.net"></a>
4540 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a></p>
4541 !!end
4542
4543 !! test
4544 External links: specified text
4545 !! wikitext
4546 Specified text: [http://example.com link]
4547 !! html
4548 <p>Specified text: <a rel="nofollow" class="external text" href="http://example.com">link</a>
4549 </p>
4550 !!end
4551
4552 !! test
4553 External links: trail
4554 !! wikitext
4555 Linktrails should not work for external links: [http://example.com link]s
4556 !! html
4557 <p>Linktrails should not work for external links: <a rel="nofollow" class="external text" href="http://example.com">link</a>s
4558 </p>
4559 !! end
4560
4561 !! test
4562 External links: dollar sign in URL
4563 !! wikitext
4564 http://example.com/1$2345
4565 !! html
4566 <p><a rel="nofollow" class="external free" href="http://example.com/1$2345">http://example.com/1$2345</a>
4567 </p>
4568 !! end
4569
4570 # parsoid doesn't explicitly mark autonumbered links, see T55505
4571 !! test
4572 External links: dollar sign in URL (autonumber)
4573 !! wikitext
4574 [http://example.com/1$2345]
4575 !! html/php
4576 <p><a rel="nofollow" class="external autonumber" href="http://example.com/1$2345">[1]</a>
4577 </p>
4578 !! html/parsoid
4579 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/1$2345"></a></p>
4580 !!end
4581
4582 !! test
4583 External links: open square bracket forbidden in URL (T6377)
4584 !! options
4585 parsoid=wt2html,wt2wt,html2html
4586 !! wikitext
4587 http://example.com/1[2345
4588 !! html/php
4589 <p><a rel="nofollow" class="external free" href="http://example.com/1">http://example.com/1</a>[2345
4590 </p>
4591 !! html/parsoid
4592 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/1">http://example.com/1</a>[2345</p>
4593 !! end
4594
4595 !! test
4596 External links: open square bracket forbidden in URL (named) (T6377)
4597 !! options
4598 parsoid=wt2html,html2html
4599 !! wikitext
4600 [http://example.com/1[2345]
4601 !! html/php
4602 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4603 </p>
4604 !! html/parsoid
4605 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/1">[2345</a></p>
4606 !!end
4607
4608 # parsoid adds a space before the link name
4609 !! test
4610 External links: open square bracket forbidden in URL (named) (T6377)
4611 Parsoid variant.
4612 !! wikitext
4613 [http://example.com/1 [2345]
4614 !! html
4615 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4616 </p>
4617 !!end
4618
4619 !! test
4620 External links: nowiki in URL link text (T8230)
4621 !! wikitext
4622 [http://example.com/ <nowiki>''example site''</nowiki>]
4623 !! html
4624 <p><a rel="nofollow" class="external text" href="http://example.com/">''example site''</a>
4625 </p>
4626 !! end
4627
4628 !! test
4629 External links: newline forbidden in text (T8230 regression check)
4630 !! wikitext
4631 [http://example.com/ first
4632 second]
4633 !! html
4634 <p>[<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a> first
4635 second]
4636 </p>
4637 !!end
4638
4639 !! test
4640 External links: Pipe char between url and text
4641 !! wikitext
4642 [http://example.com | link]
4643 !! html
4644 <p><a rel="nofollow" class="external text" href="http://example.com">| link</a>
4645 </p>
4646 !!end
4647
4648 !! test
4649 External links: protocol-relative URL in brackets
4650 !! wikitext
4651 [//example.com/ Test]
4652 !! html
4653 <p><a rel="nofollow" class="external text" href="//example.com/">Test</a>
4654 </p>
4655 !! end
4656
4657 # parsoid doesn't explicitly mark autonumbered links, see T55505
4658 !! test
4659 External links: protocol-relative URL in brackets without text
4660 !! wikitext
4661 [//example.com]
4662 !! html/php
4663 <p><a rel="nofollow" class="external autonumber" href="//example.com">[1]</a>
4664 </p>
4665 !! html/parsoid
4666 <p><a rel="mw:ExtLink" class="external autonumber" href="//example.com"></a></p>
4667 !! end
4668
4669 !! test
4670 External links: protocol-relative URL in free text is left alone
4671 !! wikitext
4672 //example.com/Foo
4673 !! html
4674 <p>//example.com/Foo
4675 </p>
4676 !!end
4677
4678 !! test
4679 External links: protocol-relative URL in the middle of a word is left alone (T32269)
4680 !! wikitext
4681 foo//example.com/Foo
4682 !! html
4683 <p>foo//example.com/Foo
4684 </p>
4685 !! end
4686
4687 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
4688 !! test
4689 External links: with no contents
4690 !! options
4691 parsoid=wt2html,wt2wt
4692 !! wikitext
4693 [http://en.wikipedia.org/wiki/Foo]
4694
4695 [[wikipedia:Foo|Bar]]
4696
4697 [[wikipedia:Foo|<span>Bar</span>]]
4698 !! html/php
4699 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo">[1]</a>
4700 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
4701 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo"><span>Bar</span></a>
4702 </p>
4703 !! html/parsoid
4704 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo"></a></p>
4705 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo">Bar</a></p>
4706 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo"><span>Bar</span></a></p>
4707 !! end
4708
4709 !! test
4710 External links: Free with trailing punctuation
4711 !! wikitext
4712 http://example.com,
4713 http://example.com;
4714 http://example.com\
4715 http://example.com.
4716 http://example.com:
4717 http://example.com!
4718 http://example.com?
4719 http://example.com)
4720 http://example.com/url_with_(brackets)
4721 (http://example.com/url_without_brackets)
4722 http://example.com/url_with_entity&amp;
4723 http://example.com/url_with_entity&#x26;
4724 http://example.com/url_with_entity&#038;
4725 http://example.com/url_with_entity&nbsp;
4726 http://example.com/url_with_entity&#xA0;
4727 http://example.com/url_with_entity&#160;
4728 http://example.com/url_with_entity&lt;
4729 http://example.com/url_with_entity&#x3C;
4730 http://example.com/url_with_entity&#60;
4731 !! html/php
4732 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
4733 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>;
4734 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>\
4735 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.
4736 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
4737 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>!
4738 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>?
4739 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
4740 <a rel="nofollow" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
4741 (<a rel="nofollow" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
4742 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4743 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4744 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4745 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
4746 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#xa0;
4747 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
4748 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&lt;
4749 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#x3c;
4750 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#60;
4751 </p>
4752 !! html/parsoid
4753 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>,
4754 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>;
4755 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>\
4756 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>.
4757 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>:
4758 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>!
4759 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>?
4760 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>)
4761 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
4762 (<a rel="mw:ExtLink" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
4763 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4764 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4765 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4766 <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>
4767 <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>
4768 <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>
4769 <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>
4770 <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>
4771 <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>
4772 !! end
4773
4774 !! test
4775 External links: tricky Parsoid html2html case
4776 !! options
4777 parsoid=wt2html,wt2wt,html2html
4778 !! wikitext
4779 http://example.com/url_with_entity&amp;amp;
4780 !! html/php
4781 <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>;
4782 </p>
4783 !! html/parsoid
4784 <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>
4785 !! end
4786
4787 !! test
4788 External links: Free with trailing quotes (T113666)
4789 !! wikitext
4790 '''News:''' Stuff here
4791
4792 news:'a'b''c''d e
4793 !! html/php
4794 <p><b>News:</b> Stuff here
4795 </p><p><a rel="nofollow" class="external free" href="news:&#39;a&#39;b">news:'a'b</a><i>c</i>d e
4796 </p>
4797 !! html/parsoid
4798 <p><b>News:</b> Stuff here</p>
4799 <p><a rel="mw:ExtLink" class="external free" href="news:'a'b">news:'a'b</a><i>c</i>d e</p>
4800 !! end
4801
4802 !! test
4803 External links: with entity
4804 !! wikitext
4805 [http://&#x20;www.librarieswithoutborders.org Libraries without borders]
4806 !! html/php
4807 <p><a rel="nofollow" class="external text" href="http://+www.librarieswithoutborders.org">Libraries without borders</a>
4808 </p>
4809 !! html/parsoid
4810 <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>
4811 !! end
4812
4813 !! test
4814 External links: Lone protocols are never linked (T105697)
4815 !! wikitext
4816 http://
4817 http://;
4818 (http://)
4819 bitcoin:
4820 bitcoin:;
4821 (bitcoin:)
4822 !! html
4823 <p>http://
4824 http://;
4825 (http://)
4826 bitcoin:
4827 bitcoin:;
4828 (bitcoin:)
4829 </p>
4830 !! end
4831
4832 !! test
4833 External links: No preceding word characters allowed (T67278)
4834 !! wikitext
4835 NOPEhttp://example.com
4836 N0http://example.com
4837 ok:http://example.com
4838 ok-http://example.com
4839 !! html
4840 <p>NOPEhttp://example.com
4841 N0http://example.com
4842 ok:<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4843 ok-<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4844 </p>
4845 !! end
4846
4847 !! test
4848 External links: nofollow domain exception
4849 !! wikitext
4850 A [https://no-nofollow.org/foobar link], and another [https://example.org link].
4851 !! html
4852 <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>.
4853 </p>
4854 !!end
4855
4856 !! test
4857 External image
4858 !! wikitext
4859 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
4860 !! html
4861 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
4862 </p>
4863 !! end
4864
4865 !! test
4866 External image from https
4867 !! wikitext
4868 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
4869 !! html
4870 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
4871 </p>
4872 !! end
4873
4874 !! test
4875 External image (when not allowed)
4876 !! options
4877 wgAllowExternalImages=0
4878 !! wikitext
4879 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
4880 !! html
4881 <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>
4882 </p>
4883 !! end
4884
4885 !! test
4886 Link to non-http image, no img tag
4887 !! wikitext
4888 Link to non-http image, no img tag: ftp://example.com/test.jpg
4889 !! html
4890 <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>
4891 </p>
4892 !! end
4893
4894 !! test
4895 External links: terminating separator
4896 !! wikitext
4897 Terminating separator: http://example.com/thing,
4898 !! html
4899 <p>Terminating separator: <a rel="nofollow" class="external free" href="http://example.com/thing">http://example.com/thing</a>,
4900 </p>
4901 !! end
4902
4903 !! test
4904 External links: intervening separator
4905 !! wikitext
4906 Intervening separator: http://example.com/1,2,3
4907 !! html
4908 <p>Intervening separator: <a rel="nofollow" class="external free" href="http://example.com/1,2,3">http://example.com/1,2,3</a>
4909 </p>
4910 !! end
4911
4912 !! test
4913 External links: old bug with URL in query
4914 !! wikitext
4915 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
4916 !! html
4917 <p>Old bug with URL in query: <a rel="nofollow" class="external text" href="http://example.com/thing?url=http://example.com">link</a>
4918 </p>
4919 !! end
4920
4921 !! test
4922 External links: old URL-in-URL bug, mixed protocols
4923 !! wikitext
4924 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
4925 !! html
4926 <p>And again with mixed protocols: <a rel="nofollow" class="external text" href="ftp://example.com?url=http://example.com">link</a>
4927 </p>
4928 !!end
4929
4930 # Since Parsoid is starting to emit canonical wikitext for links,
4931 # [http://example.com http://example.com] will not RT back to that
4932 # form anymore.
4933 !! test
4934 External links: URL in text
4935 !! options
4936 parsoid=wt2html
4937 !! wikitext
4938 URL in text: [http://example.com http://example.com]
4939 !! html/php
4940 <p>URL in text: <a rel="nofollow" class="external text" href="http://example.com">http://example.com</a>
4941 </p>
4942 !! html/parsoid
4943 <p>URL in text: <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a></p>
4944 !! end
4945
4946 !! test
4947 External links: Clickable images
4948 !! wikitext
4949 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
4950 !! html/php
4951 <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>
4952 </p>
4953 !! html/parsoid
4954 <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>
4955 !! end
4956
4957 !! test
4958 External links: raw ampersand
4959 !! wikitext
4960 Old &amp; use: http://x&y
4961 !! html
4962 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
4963 </p>
4964 !! end
4965
4966 !! test
4967 External links: encoded ampersand
4968 !! wikitext
4969 Old &amp; use: http://x&amp;y
4970 !! html/php
4971 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
4972 </p>
4973 !! html/parsoid
4974 <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>
4975 !! end
4976
4977 !! test
4978 External links: encoded equals (T8102)
4979 !! wikitext
4980 http://example.com/?foo&#61;bar
4981 !! html/php
4982 <p><a rel="nofollow" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a>
4983 </p>
4984 !! html/parsoid
4985 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a></p>
4986 !! end
4987
4988 ##
4989 ## Note that parsoid doesn't explicit mark autonumbered links, nor
4990 ## does it number them. As discussed in T55505, we can identify
4991 ## autonumbered links via CSS.
4992 ##
4993
4994 !! test
4995 External links: [raw ampersand]
4996 !! wikitext
4997 Old &amp; use: [http://x&y]
4998 !! html/php
4999 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5000 </p>
5001 !! html/parsoid
5002 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&amp;y"></a></p>
5003 !! end
5004
5005 # note that parsoid html is identical to [raw ampersand] case; so html2wt
5006 # mode will return the [raw ampersand] wikitext
5007 !! test
5008 External links: [encoded ampersand]
5009 !! options
5010 parsoid=wt2html,wt2wt,html2html
5011 !! wikitext
5012 Old &amp; use: [http://x&amp;y]
5013 !! html/php
5014 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5015 </p>
5016 !! html/parsoid
5017 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&amp;y"></a></p>
5018 !! end
5019
5020 !! test
5021 External links: [raw equals]
5022 !! wikitext
5023 [http://example.com/?foo=bar]
5024 !! html/php
5025 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5026 </p>
5027 !! html/parsoid
5028 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/?foo=bar"></a></p>
5029 !! end
5030
5031 # note that parsoid html is identical to [raw equals] case; so html2wt
5032 # mode will return the [raw equals] wikitext
5033 !! test
5034 External links: [encoded equals] (T8102)
5035 !! options
5036 parsoid=wt2html,wt2wt,html2html
5037 !! wikitext
5038 [http://example.com/?foo&#61;bar]
5039 !! html/php
5040 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5041 </p>
5042 !! html/parsoid
5043 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/?foo=bar"></a></p>
5044 !! end
5045
5046 # xxx parsoid strips the IDN character, so the round-trip tests will
5047 # obviously fail and are disabled. --cscott
5048 !! test
5049 External links: [IDN ignored character reference in hostname; strip it right off]
5050 !! options
5051 parsoid=wt2html,wt2wt,html2html
5052 !! wikitext
5053 [http://e&zwnj;xample.com/]
5054 !! html/php
5055 <p><a rel="nofollow" class="external autonumber" href="http://example.com/">[1]</a>
5056 </p>
5057 !! html/parsoid
5058 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/"></a></p>
5059 !! end
5060
5061 # FIXME: This test (the IDN characters in the text of a link) is an inconsistency.
5062 # Where an external link could easily circumvent the sanitization of the text of
5063 # a link like this (where an IDN-ignore character is in the URL somewhere), this
5064 # test demands a higher standard. That's a bit strange.
5065 #
5066 # Example:
5067 #
5068 # http://e‌xample.com -> [http://example.com|http://example.com]
5069 # [http://example.com|http://e‌xample.com] -> [http://example.com|http://e‌xample.com]
5070 #
5071 # The first example is sanitized, but the second is not. Any security benefits
5072 # from this production are trivial to circumvent. Either remove this test and
5073 # let the parser(s) do their thing unaccosted, or fix the inconsistency and change
5074 # the test accordingly.
5075 #
5076 # All our love,
5077 # The Parsoid team.
5078 # xxx parsoid strips the IDN character, so the round-trip tests will
5079 # obviously fail and are disabled. --cscott
5080 !! test
5081 External links: IDN ignored character reference in hostname; strip it right off
5082 !! options
5083 parsoid=wt2html,html2html
5084 !! wikitext
5085 http://e&zwnj;xample.com/
5086 !! html/php
5087 <p><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>
5088 </p>
5089 !! html/parsoid
5090 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/">http://example.com/</a></p>
5091 !! end
5092
5093 !! test
5094 External links: www.jpeg.org (T2554)
5095 !! wikitext
5096 http://www.jpeg.org
5097 !! html
5098 <p><a rel="nofollow" class="external free" href="http://www.jpeg.org">http://www.jpeg.org</a>
5099 </p>
5100 !! end
5101
5102 # parsoid doesn't explicitly mark autonumbered links, see T55505
5103 !! test
5104 External links: URL within URL (T2002)
5105 !! wikitext
5106 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
5107 !! html/php
5108 <p><a rel="nofollow" class="external autonumber" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp">[1]</a>
5109 </p>
5110 !! html/parsoid
5111 <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>
5112 !! end
5113
5114 !! test
5115 T2361: URL inside bracketed URL
5116 !! wikitext
5117 [http://www.example.com/foo http://www.example.com/bar]
5118 !! html
5119 <p><a rel="nofollow" class="external text" href="http://www.example.com/foo">http://www.example.com/bar</a>
5120 </p>
5121 !! end
5122
5123 !! test
5124 T2361: URL within URL, not bracketed
5125 !! wikitext
5126 http://www.example.com/foo?=http://www.example.com/bar
5127 !! html
5128 <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>
5129 </p>
5130 !! end
5131
5132 !! test
5133 T2289: ">"-token in URL-tail
5134 !! wikitext
5135 http://www.example.com/<hello>
5136 !! html
5137 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>&lt;hello&gt;
5138 </p>
5139 !!end
5140
5141 !! test
5142 T2289: literal ">"-token in URL-tail
5143 !! wikitext
5144 http://www.example.com/<b>html</b>
5145 !! html/php
5146 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a><b>html</b>
5147 </p>
5148 !! html/parsoid
5149 <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>
5150 !! end
5151
5152 !! test
5153 T2289: ">"-token in bracketed URL
5154 !! wikitext
5155 [http://www.example.com/<hello> stuff]
5156 !! html
5157 <p><a rel="nofollow" class="external text" href="http://www.example.com/">&lt;hello&gt; stuff</a>
5158 </p>
5159 !!end
5160
5161 !! test
5162 T2289: literal ">"-token in bracketed URL
5163 !! wikitext
5164 [http://www.example.com/<b>html</b> stuff]
5165 !! html
5166 <p><a rel="nofollow" class="external text" href="http://www.example.com/"><b>html</b> stuff</a>
5167 </p>
5168 !!end
5169
5170 !! test
5171 T2289: literal double quote at end of URL
5172 !! wikitext
5173 http://www.example.com/"hello"
5174 !! html
5175 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>"hello"
5176 </p>
5177 !!end
5178
5179 !! test
5180 T2289: literal double quote in bracketed URL
5181 !! wikitext
5182 [http://www.example.com/"hello" stuff]
5183 !! html
5184 <p><a rel="nofollow" class="external text" href="http://www.example.com/">"hello" stuff</a>
5185 </p>
5186 !!end
5187
5188 !! test
5189 External links: multiple legal whitespace is fine, Magnus. Don't break it please. (T7081)
5190 !! wikitext
5191 [http://www.example.com test]
5192 !! html
5193 <p><a rel="nofollow" class="external text" href="http://www.example.com">test</a>
5194 </p>
5195 !! end
5196
5197 !! test
5198 External links: link text with spaces
5199 !! wikitext
5200 [http://www.example.com a b c]
5201 [http://www.example.com ''a'' ''b'']
5202 !! html
5203 <p><a rel="nofollow" class="external text" href="http://www.example.com">a b c</a>
5204 <a rel="nofollow" class="external text" href="http://www.example.com"><i>a</i> <i>b</i></a>
5205 </p>
5206 !! end
5207
5208 # Note edge case difference between PHP and Parsoid here.
5209 !! test
5210 External links: wiki links within external link (T5695)
5211 !! options
5212 parsoid=wt2html,html2html
5213 !! wikitext
5214 [http://example.com [[wikilink]] embedded in ext link]
5215
5216 [http://example.com test [[wikilink]] embedded in ext link]
5217 !! html/php
5218 <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>
5219 </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>
5220 </p>
5221 !! html/parsoid
5222 <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>
5223 <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>
5224 !! end
5225
5226 !! test
5227 T2787: Links with one slash after the url protocol are invalid
5228 !! wikitext
5229 http:/example.com
5230
5231 [http:/example.com title]
5232 !! html
5233 <p>http:/example.com
5234 </p><p>[http:/example.com title]
5235 </p>
5236 !! end
5237
5238 !! test
5239 Bracketed external links with template-generated invalid target
5240 !! wikitext
5241 [{{echo|http:/example.com}} title]
5242 !! html
5243 <p>[http:/example.com title]
5244 </p>
5245 !! end
5246
5247 # wt2html only because Parsoid would want to add <nowiki>s coming from html
5248 !! test
5249 Broken wikilinks (but not external links) prevent templates from closing
5250 !! options
5251 parsoid=wt2html
5252 !! wikitext
5253 [http://example.com x
5254
5255 {{echo|[http://example.com x}}
5256
5257 [[Foo
5258
5259 {{echo|[[Foo}}
5260 !! html/php
5261 <p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5262 </p><p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5263 </p><p>[[Foo
5264 </p><p>{{echo|[[Foo}}
5265 </p>
5266 !! html/parsoid
5267 <p>[<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a> x</p>
5268 <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>
5269 <p>[[Foo</p>
5270 <p>{{echo|[[Foo}}</p>
5271 !! end
5272
5273 !! test
5274 Wikilinks with embedded newlines are not broken
5275 !! wikitext
5276 {{echo|[[ Foo
5277 B
5278 C]]}}
5279 !! html/php
5280 <p>[[ Foo
5281 B
5282 C]]
5283 </p>
5284 !! html/parsoid
5285 <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>
5286 !! end
5287
5288 !! test
5289 Broken templates
5290 !! options
5291 parsoid=wt2html
5292 !! wikitext
5293 {{echo|[[Foo|}}]]
5294
5295 [[Foo|{{echo|]]}}
5296 !! html/php
5297 <p>{{echo|<a href="/wiki/Foo" title="Foo">}}</a>
5298 </p><p>[[Foo|]]
5299 </p>
5300 !! html/parsoid
5301 <p>{{echo|<a rel="mw:WikiLink" href="./Foo" title="Foo">}}</a></p>
5302 <p>[[Foo|<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"]]"}},"i":0}}]}'>]]</span></p>
5303 !! end
5304
5305 !! test
5306 T4702: Mismatched <i>, <b> and <a> tags are invalid
5307 !! wikitext
5308 ''[http://example.com text'']
5309 [http://example.com '''text]'''
5310 ''Something [http://example.com in italic'']
5311 ''Something [http://example.com mixed''''', even bold]'''
5312 '''''Now [http://example.com both''''']
5313 !! html
5314 <p><a rel="nofollow" class="external text" href="http://example.com"><i>text</i></a>
5315 <a rel="nofollow" class="external text" href="http://example.com"><b>text</b></a>
5316 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>in italic</i></a>
5317 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>mixed</i><b>, even bold</b></a>
5318 <i><b>Now </b></i><a rel="nofollow" class="external text" href="http://example.com"><i><b>both</b></i></a>
5319 </p>
5320 !! end
5321
5322
5323 !! test
5324 T6781: %26 in URL
5325 !! wikitext
5326 http://www.example.com/?title=AT%26T
5327 !! html/php
5328 <p><a rel="nofollow" class="external free" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a>
5329 </p>
5330 !! html/parsoid
5331 <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>
5332 !! end
5333
5334 # According to https://www.w3.org/TR/2011/WD-html5-20110525/Overview.html#parsing-urls a plain
5335 # % is actually legal in HTML5. Any change in output would need testing though.
5336 !! test
5337 T6781, T7267: %25 in URL
5338 !! wikitext
5339 http://www.example.com/?title=100%25_Bran
5340 !! html/php
5341 <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>
5342 </p>
5343 !! html/parsoid
5344 <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>
5345 !! end
5346
5347 !! test
5348 T6781, T7267: %28, %29 in URL
5349 !! wikitext
5350 http://www.example.com/?title=Ben-Hur_%281959_film%29
5351 !! html/php
5352 <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>
5353 </p>
5354 !! html/parsoid
5355 <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>
5356 !! end
5357
5358
5359 !! test
5360 T6781: %26 in autonumber URL
5361 !! wikitext
5362 [http://www.example.com/?title=AT%26T]
5363 !! html/php
5364 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=AT%26T">[1]</a>
5365 </p>
5366 !! html/parsoid
5367 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=AT%26T"></a></p>
5368 !! end
5369
5370 !! test
5371 T6781, T7267: %26 in autonumber URL
5372 !! wikitext
5373 [http://www.example.com/?title=100%25_Bran]
5374 !! html/php
5375 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=100%25_Bran">[1]</a>
5376 </p>
5377 !! html/parsoid
5378 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=100%25_Bran"></a></p>
5379 !! end
5380
5381 !! test
5382 T6781, T7267: %28, %29 in autonumber URL
5383 !! wikitext
5384 [http://www.example.com/?title=Ben-Hur_%281959_film%29]
5385 !! html/php
5386 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">[1]</a>
5387 </p>
5388 !! html/parsoid
5389 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29"></a></p>
5390 !! end
5391
5392
5393 !! test
5394 T6781: %26 in bracketed URL
5395 !! wikitext
5396 [http://www.example.com/?title=AT%26T link]
5397 !! html/php
5398 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=AT%26T">link</a>
5399 </p>
5400 !! html/parsoid
5401 <p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=AT%26T">link</a></p>
5402 !! end
5403
5404 !! test
5405 T6781, T7267: %25 in bracketed URL
5406 !! wikitext
5407 [http://www.example.com/?title=100%25_Bran link]
5408 !! html
5409 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=100%25_Bran">link</a>
5410 </p>
5411 !! end
5412
5413 !! test
5414 T6781, T7267: %28, %29 in bracketed URL
5415 !! wikitext
5416 [http://www.example.com/?title=Ben-Hur_%281959_film%29 link]
5417 !! html/php
5418 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a>
5419 </p>
5420 !! html/parsoid
5421 <p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a></p>
5422 !! end
5423
5424 !! test
5425 External link containing a period in the anchor. (T65947)
5426 !! wikitext
5427 [//foo.org/bar#baz. bang]
5428
5429 [//foo.org/bar. bang]
5430 !! html/php
5431 <p><a rel="nofollow" class="external text" href="//foo.org/bar#baz.">bang</a>
5432 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar.">bang</a>
5433 </p>
5434 !! html/parsoid
5435 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar#baz.">bang</a></p>
5436 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar.">bang</a></p>
5437 !! end
5438
5439 !! test
5440 External link containing a single quote. (T65947)
5441 !! wikitext
5442 [//foo.org/bar'baz]
5443
5444 [//foo.org/bar'baz bang]
5445 !! html/php
5446 <p><a rel="nofollow" class="external autonumber" href="//foo.org/bar&#39;baz">[1]</a>
5447 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar&#39;baz">bang</a>
5448 </p>
5449 !! html/parsoid
5450 <p><a rel="mw:ExtLink" class="external autonumber" href="//foo.org/bar'baz"></a></p>
5451 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar'baz">bang</a></p>
5452 !! end
5453
5454 !! test
5455 External link containing double-single-quotes in text '' (T6598 sanity check)
5456 !! wikitext
5457 Some [http://example.com/ pretty ''italics'' and stuff]!
5458 !! html
5459 <p>Some <a rel="nofollow" class="external text" href="http://example.com/">pretty <i>italics</i> and stuff</a>!
5460 </p>
5461 !! end
5462
5463 !! test
5464 External link containing double-single-quotes in text embedded in italics (T6598 sanity check)
5465 !! wikitext
5466 ''Some [http://example.com/ pretty ''italics'' and stuff]!''
5467 !! html
5468 <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>
5469 </p>
5470 !! end
5471
5472 # Don't add the html/php section since the output is broken and there isn't any reason to spec it
5473 !! test
5474 External link containing double-single-quotes with no space separating the url from text in italics
5475 !! wikitext
5476 [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]].]
5477 !! html/php+tidy
5478 <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>.
5479 </p>
5480 !! html/parsoid
5481 <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>
5482 !! end
5483
5484 !! test
5485 External link with comments in link text
5486 !! wikitext
5487 [http://www.google.com Google <!-- comment -->]
5488 !! html/php
5489 <p><a rel="nofollow" class="external text" href="http://www.google.com">Google </a>
5490 </p>
5491 !! html/parsoid
5492 <p><a rel="mw:ExtLink" class="external text" href="http://www.google.com">Google <!-- comment --></a></p>
5493 !! end
5494
5495 !! test
5496 External link to bare IPv4 address
5497 !! wikitext
5498 [http://192.168.0.1 Link]
5499 !! html/php
5500 <p><a rel="nofollow" class="external text" href="http://192.168.0.1">Link</a>
5501 </p>
5502 !! html/parsoid
5503 <p><a rel="mw:ExtLink" class="external text" href="http://192.168.0.1">Link</a></p>
5504 !! end
5505
5506 !! test
5507 URL-encoding in URL functions (single parameter)
5508 !! wikitext
5509 {{localurl:Some page|amp=&}}
5510 !! html
5511 <p>/index.php?title=Some_page&amp;amp=&amp;
5512 </p>
5513 !! end
5514
5515 !! test
5516 URL-encoding in URL functions (multiple parameters)
5517 !! wikitext
5518 {{localurl:Some page|q=?&amp=&}}
5519 !! html
5520 <p>/index.php?title=Some_page&amp;q=?&amp;amp=&amp;
5521 </p>
5522 !! end
5523
5524 !! test
5525 Brackets in urls
5526 !! wikitext
5527 http://example.com/index.php?foozoid%5B%5D=bar
5528
5529 http://example.com/index.php?foozoid&#x5B;&#x5D;=bar
5530 !! html/php
5531 <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>
5532 </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>
5533 </p>
5534 !! html/parsoid
5535 <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>
5536
5537 <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>
5538 !! end
5539
5540 !! test
5541 IPv6 urls, autolink format (T23261)
5542 !! wikitext
5543 http://[2404:130:0:1000::187:2]/index.php
5544
5545 Examples from RFC 2373, section 2.2:
5546 * http://[1080::8:800:200C:417A]/unicast
5547 * http://[FF01::101]/multicast
5548 * http://[::1]/loopback
5549 * http://[::]/unspecified
5550 * http://[::13.1.68.3]/ipv4compat
5551 * http://[::FFFF:129.144.52.38]/ipv4compat
5552
5553 Examples from RFC 2732, section 2:
5554 * http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
5555 * http://[1080:0:0:0:8:800:200C:417A]/index.html
5556 * http://[3ffe:2a00:100:7031::1]
5557 * http://[1080::8:800:200C:417A]/foo
5558 * http://[::192.9.5.5]/ipng
5559 * http://[::FFFF:129.144.52.38]:80/index.html
5560 * http://[2010:836B:4179::836B:4179]
5561
5562 !! html/php
5563 <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>
5564 </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:
5565 </p>
5566 <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>
5567 <li> <a rel="nofollow" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5568 <li> <a rel="nofollow" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5569 <li> <a rel="nofollow" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5570 <li> <a rel="nofollow" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5571 <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>
5572 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5573 </p>
5574 <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>
5575 <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>
5576 <li> <a rel="nofollow" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5577 <li> <a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
5578 <li> <a rel="nofollow" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5579 <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>
5580 <li> <a rel="nofollow" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5581
5582 !! html/parsoid
5583 <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>
5584
5585 <p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink" class="external text">RFC 2373</a>, section 2.2:</p>
5586 <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>
5587 <li> <a rel="mw:ExtLink" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5588 <li> <a rel="mw:ExtLink" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5589 <li> <a rel="mw:ExtLink" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5590 <li> <a rel="mw:ExtLink" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5591 <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>
5592
5593 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external text">RFC 2732</a>, section 2:</p>
5594 <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>
5595 <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>
5596 <li> <a rel="mw:ExtLink" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5597 <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>
5598 <li> <a rel="mw:ExtLink" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5599 <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>
5600 <li> <a rel="mw:ExtLink" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5601 !! end
5602
5603 !! test
5604 IPv6 urls, bracketed format (T23261)
5605 !! wikitext
5606 [http://[2404:130:0:1000::187:2]/index.php test]
5607
5608 Examples from RFC 2373, section 2.2:
5609 * [http://[1080::8:800:200C:417A] unicast]
5610 * [http://[FF01::101] multicast]
5611 * [http://[::1]/ loopback]
5612 * [http://[::] unspecified]
5613 * [http://[::13.1.68.3] ipv4compat]
5614 * [http://[::FFFF:129.144.52.38] ipv4compat]
5615
5616 Examples from RFC 2732, section 2:
5617 * [http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html 1]
5618 * [http://[1080:0:0:0:8:800:200C:417A]/index.html 2]
5619 * [http://[3ffe:2a00:100:7031::1] 3]
5620 * [http://[1080::8:800:200C:417A]/foo 4]
5621 * [http://[::192.9.5.5]/ipng 5]
5622 * [http://[::FFFF:129.144.52.38]:80/index.html 6]
5623 * [http://[2010:836B:4179::836B:4179] 7]
5624
5625 !! html/php
5626 <p><a rel="nofollow" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a>
5627 </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:
5628 </p>
5629 <ul><li> <a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5630 <li> <a rel="nofollow" class="external text" href="http://[FF01::101]">multicast</a></li>
5631 <li> <a rel="nofollow" class="external text" href="http://[::1]/">loopback</a></li>
5632 <li> <a rel="nofollow" class="external text" href="http://[::]">unspecified</a></li>
5633 <li> <a rel="nofollow" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5634 <li> <a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5635 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5636 </p>
5637 <ul><li> <a rel="nofollow" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
5638 <li> <a rel="nofollow" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5639 <li> <a rel="nofollow" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5640 <li> <a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5641 <li> <a rel="nofollow" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
5642 <li> <a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5643 <li> <a rel="nofollow" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5644
5645 !! html/parsoid
5646 <p><a rel="mw:ExtLink" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a></p>
5647
5648 <p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink" class="external text">RFC 2373</a>, section 2.2:</p>
5649 <ul><li> <a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5650 <li> <a rel="mw:ExtLink" class="external text" href="http://[FF01::101]">multicast</a></li>
5651 <li> <a rel="mw:ExtLink" class="external text" href="http://[::1]/">loopback</a></li>
5652 <li> <a rel="mw:ExtLink" class="external text" href="http://[::]">unspecified</a></li>
5653 <li> <a rel="mw:ExtLink" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5654 <li> <a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5655
5656 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external text">RFC 2732</a>, section 2:</p>
5657 <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>
5658 <li> <a rel="mw:ExtLink" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5659 <li> <a rel="mw:ExtLink" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5660 <li> <a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5661 <li> <a rel="mw:ExtLink" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
5662 <li> <a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5663 <li> <a rel="mw:ExtLink" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5664 !! end
5665
5666 !! test
5667 Non-extlinks in brackets
5668 !! wikitext
5669 [foo]
5670 [foo bar]
5671 [foo ''bar'']
5672 [fool's] errand
5673 [fool's errand]
5674 [{{echo|foo}}]
5675 [{{echo|foo}} bar]
5676 [{{echo|foo}} ''bar'']
5677 [{{echo|foo}}l's] errand
5678 [{{echo|foo}}l's errand]
5679 [url={{echo|foo}}]
5680 [url=http://example.com]
5681 [http:// bare protocols don't count]
5682 !! html/php
5683 <p>[foo]
5684 [foo bar]
5685 [foo <i>bar</i>]
5686 [fool's] errand
5687 [fool's errand]
5688 [foo]
5689 [foo bar]
5690 [foo <i>bar</i>]
5691 [fool's] errand
5692 [fool's errand]
5693 [url=foo]
5694 [url=<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>]
5695 [http:// bare protocols don't count]
5696 </p>
5697 !! html/parsoid
5698 <p>[foo]
5699 [foo bar]
5700 [foo <i>bar</i>]
5701 [fool's] errand
5702 [fool's errand]
5703 [<span about="#mwt19" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>]
5704 [<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]
5705 [<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>]
5706 [<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
5707 [<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]
5708 [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>]
5709 [url=<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>]
5710 [http:// bare protocols don't count]</p>
5711 !! end
5712
5713 !! test
5714 Percent encoding in external links
5715 !! wikitext
5716 [https://github.com/search?l=&q=ResourceLoader+%40wikimedia Search]
5717 !! html/php
5718 <p><a rel="nofollow" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a>
5719 </p>
5720 !! html/parsoid
5721 <p><a rel="mw:ExtLink" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a></p>
5722 !! end
5723
5724 !! test
5725 Use url link syntax for links where the content is equal the link target
5726 !! wikitext
5727 http://example.com
5728 !! html/php
5729 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5730 </p>
5731 !! html/parsoid
5732 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a></p>
5733 !! end
5734
5735 !! test
5736 Parenthesis in external links, especially URL links
5737 !! wikitext
5738 http://example.com)
5739
5740 http://example.com/test)
5741
5742 http://example.com/(test)
5743
5744 http://example.com/((test)
5745
5746 (http://example.com/(test))
5747
5748 (http://example.com/(test)))))
5749
5750 http://example.com/a)b
5751
5752 [http://example.com) foo]
5753 !! html/php
5754 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
5755 </p><p><a rel="nofollow" class="external free" href="http://example.com/test">http://example.com/test</a>)
5756 </p><p><a rel="nofollow" class="external free" href="http://example.com/(test)">http://example.com/(test)</a>
5757 </p><p><a rel="nofollow" class="external free" href="http://example.com/((test)">http://example.com/((test)</a>
5758 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test))">http://example.com/(test))</a>
5759 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a>
5760 </p><p><a rel="nofollow" class="external free" href="http://example.com/a)b">http://example.com/a)b</a>
5761 </p><p><a rel="nofollow" class="external text" href="http://example.com)">foo</a>
5762 </p>
5763 !! html/parsoid
5764 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>)</p>
5765 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/test">http://example.com/test</a>)</p>
5766 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/(test)">http://example.com/(test)</a></p>
5767 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/((test)">http://example.com/((test)</a></p>
5768 <p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test))">http://example.com/(test))</a></p>
5769 <p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a></p>
5770 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/a)b">http://example.com/a)b</a></p>
5771 <p><a rel="mw:ExtLink" class="external text" href="http://example.com)">foo</a></p>
5772 !! end
5773
5774 !! test
5775 Parenthesis in external links, w/ transclusion or comment
5776 !! wikitext
5777 (http://example.com/{{echo|hi}})
5778
5779 (http://example.com<!-- hi -->)
5780 !! html/php
5781 <p>(<a rel="nofollow" class="external free" href="http://example.com/hi">http://example.com/hi</a>)
5782 </p><p>(<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
5783 </p>
5784 !! html/parsoid
5785 <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>
5786
5787 <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>
5788 !! end
5789
5790 !! test
5791 Serialize <a> tags with invalid link targets as plain text
5792 !! options
5793 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
5794 !! html/parsoid
5795 <a rel="mw:WikiLink" href="[[foo]]">text</a>
5796 <a rel="mw:WikiLink" href="[[foo]]">*text</a>
5797 <a rel="mw:WikiLink" href="[[foo]]">[[foo]]</a>
5798 <a rel="mw:WikiLink" href="[[foo]]">*a [[foo]]</a>
5799 !! wikitext
5800 text
5801 <nowiki>*</nowiki>text
5802 <nowiki>[[foo]]</nowiki>
5803 <nowiki>*</nowiki>a <nowiki>[[foo]]</nowiki>
5804 !! end
5805
5806 !! test
5807 mw:ExtLink -vs- mw:WikiLink (T94723)
5808 !! options
5809 parsoid=html2wt
5810 !! html/parsoid
5811 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"piped","a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>Bar</a>
5812 <a rel="mw:WikiLink" href="./Foo" title="Foo">Bar</a>
5813 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
5814 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
5815 <p>
5816 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
5817 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
5818 </p>
5819 !! wikitext
5820 [[Foo|Bar]]
5821 [[Foo|Bar]]
5822 [[:en:Foo|Bar]]
5823 [[:en:Foo|Bar]]
5824
5825 [[:en:European_Robin|European Robin]]
5826 [[:en:European_Robin|European Robin]]
5827 !! end
5828
5829 !! test
5830 mw:ExtLink linking to a interwiki URL can be round-tripped losslessly (T94723)
5831 !! options
5832 parsoid=wt2wt
5833 !! wikitext
5834 [http://en.wikipedia.org/wiki/European_Robin European Robin]
5835 !! html/parsoid
5836 THIS SECTION IS NOT USED (but Parsoid won't run the test without it)
5837 !! end
5838
5839
5840 ###
5841 ### Quotes
5842 ###
5843
5844 !! test
5845 Quotes
5846 !! wikitext
5847 Normal text. '''Bold text.''' Normal text. ''Italic text.''
5848
5849 Normal text. '''''Bold italic text.''''' Normal text.
5850 !! html
5851 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
5852 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
5853 </p>
5854 !! end
5855
5856
5857 # Parsoid inserts an empty bold tag pair at the end of the line, that the PHP
5858 # parser strips. The wikitext contains just the first half of the bold
5859 # quote pair.
5860 !! test
5861 Unclosed and unmatched quotes
5862 !! wikitext
5863 '''''Bold italic text '''with bold deactivated''' in between.'''''
5864
5865 '''''Bold italic text ''with italic deactivated'' in between.'''''
5866
5867 '''Bold text..
5868
5869 ..spanning two paragraphs (should not work).'''
5870
5871 '''Bold tag left open
5872
5873 ''Italic tag left open
5874
5875 Normal text.
5876
5877 <!-- Unmatching number of opening, closing tags: -->
5878 '''This year''''s election ''should'' beat '''last year''''s.
5879
5880 ''Tom'''s car is bigger than ''Susan'''s.
5881
5882 Plain ''italic'''s plain
5883 !! html/php
5884 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
5885 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
5886 </p><p><b>Bold text..</b>
5887 </p><p>..spanning two paragraphs (should not work).
5888 </p><p><b>Bold tag left open</b>
5889 </p><p><i>Italic tag left open</i>
5890 </p><p>Normal text.
5891 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
5892 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
5893 </p><p>Plain <i>italic'</i>s plain
5894 </p>
5895 !! html/parsoid
5896 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
5897 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
5898 </p><p><b>Bold text..</b>
5899 </p><p>..spanning two paragraphs (should not work).<b></b>
5900 </p><p><b>Bold tag left open</b>
5901 </p><p><i>Italic tag left open</i>
5902 </p><p>Normal text.
5903 </p>
5904 <!-- Unmatching number of opening, closing tags: -->
5905 <p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
5906 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
5907 </p><p>Plain <i>italic'</i>s plain
5908 </p>
5909 !! end
5910
5911 ###
5912 ### Tables
5913 ###
5914 ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
5915 ###
5916
5917 # This should not produce <table></table> as <table><tr><td></td></tr></table>
5918 # is the bare minimum required by the spec, see:
5919 # https://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
5920 # Parsoid team replies: empty table tags are legal in HTML5
5921 !! test
5922 A table with no data.
5923 !! options
5924 parsoid=wt2html
5925 !! wikitext
5926 {||}
5927 !! html/php
5928
5929 !! html/parsoid
5930 <table></table>
5931
5932 !! end
5933
5934 !! test
5935 A table with stray table end tags on start tag line (wt2html)
5936 !! options
5937 parsoid=wt2html
5938 !! wikitext
5939 {|style="color: red;"|}
5940
5941 {|style="color: red;" |}
5942 |foo
5943 |}
5944
5945 {|style="color: red;"|} id="foo"
5946 |foo
5947 |}
5948
5949 {|style="color: red;" |} id="foo"
5950 |foo
5951 |}
5952 !! html
5953 <table style="color: red;"></table>
5954
5955 <table style="color: red;">
5956 <tbody><tr>
5957 <td>foo</td>
5958 </tr></tbody>
5959 </table>
5960
5961 <table style="color: red;" id="foo">
5962 <tbody><tr>
5963 <td>foo</td>
5964 </tr></tbody>
5965 </table>
5966
5967 <table style="color: red;" id="foo">
5968 <tbody><tr>
5969 <td>foo</td>
5970 </tr></tbody>
5971 </table>
5972
5973 !! end
5974
5975 !! test
5976 A table with no data (take 2)
5977 !! wikitext
5978 {|
5979 |}
5980 !! html/parsoid
5981 <table></table>
5982 !! end
5983
5984 # A table with nothing but a caption is invalid XHTML, we might want to render
5985 # this as <p>caption</p>
5986 # Parsoid team replies: table with only a caption is legal in HTML5
5987 !! test
5988 A table with nothing but a caption
5989 !! wikitext
5990 {|
5991 |+ caption
5992 |}
5993 !! html/php
5994 <table>
5995 <caption> caption
5996 </caption><tr><td></td></tr></table>
5997
5998 !! html/parsoid
5999 <table><caption> caption</caption></table>
6000 !! end
6001
6002 !! test
6003 A table with caption with default-spaced attributes and a table row
6004 !! wikitext
6005 {|
6006 |+ style="color: red;" | caption1
6007 |-
6008 | foo
6009 |}
6010 !! html
6011 <table>
6012 <caption style="color: red;"> caption1
6013 </caption>
6014 <tr>
6015 <td> foo
6016 </td></tr></table>
6017
6018 !! end
6019
6020 !! test
6021 A table with captions with non-default spaced attributes and a table row
6022 !! wikitext
6023 {|
6024 |+style="color: red;"|caption2
6025 |+ style="color: red;"| caption3
6026 |-
6027 | foo
6028 |}
6029 !! html
6030 <table>
6031 <caption style="color: red;">caption2
6032 </caption>
6033 <caption style="color: red;"> caption3
6034 </caption>
6035 <tr>
6036 <td> foo
6037 </td></tr></table>
6038
6039 !! end
6040
6041 !! test
6042 Table td-cell syntax variations
6043 !! wikitext
6044 {|
6045 | foo bar foo | baz
6046 | foo bar foo || baz
6047 | style='color:red;' | baz
6048 | style='color:red;' || baz
6049 |}
6050 !! html
6051 <table>
6052 <tr>
6053 <td> baz
6054 </td>
6055 <td> foo bar foo </td>
6056 <td> baz
6057 </td>
6058 <td style="color:red;"> baz
6059 </td>
6060 <td> style='color:red;' </td>
6061 <td> baz
6062 </td></tr></table>
6063
6064 !! end
6065
6066 !! test
6067 Simple table
6068 !! wikitext
6069 {|
6070 | 1 || 2
6071 |-
6072 | 3 || 4
6073 |}
6074 !! html
6075 <table>
6076 <tr>
6077 <td> 1 </td>
6078 <td> 2
6079 </td></tr>
6080 <tr>
6081 <td> 3 </td>
6082 <td> 4
6083 </td></tr></table>
6084
6085 !! end
6086
6087 !! test
6088 Simple table but with multiple dashes for row wikitext
6089 !! wikitext
6090 {|
6091 | foo
6092 |-----
6093 | bar
6094 |}
6095 !! html
6096 <table>
6097 <tr>
6098 <td> foo
6099 </td></tr>
6100 <tr>
6101 <td> bar
6102 </td></tr></table>
6103
6104 !! end
6105
6106 !! test
6107 Multiplication table
6108 !! wikitext
6109 {| border="1" cellpadding="2"
6110 |+Multiplication table
6111 |-
6112 ! &times; !! 1 !! 2 !! 3
6113 |-
6114 ! 1
6115 | 1 || 2 || 3
6116 |-
6117 ! 2
6118 | 2 || 4 || 6
6119 |-
6120 ! 3
6121 | 3 || 6 || 9
6122 |-
6123 ! 4
6124 | 4 || 8 || 12
6125 |-
6126 ! 5
6127 | 5 || 10 || 15
6128 |}
6129 !! html
6130 <table border="1" cellpadding="2">
6131 <caption>Multiplication table
6132 </caption>
6133 <tr>
6134 <th> &#215; </th>
6135 <th> 1 </th>
6136 <th> 2 </th>
6137 <th> 3
6138 </th></tr>
6139 <tr>
6140 <th> 1
6141 </th>
6142 <td> 1 </td>
6143 <td> 2 </td>
6144 <td> 3
6145 </td></tr>
6146 <tr>
6147 <th> 2
6148 </th>
6149 <td> 2 </td>
6150 <td> 4 </td>
6151 <td> 6
6152 </td></tr>
6153 <tr>
6154 <th> 3
6155 </th>
6156 <td> 3 </td>
6157 <td> 6 </td>
6158 <td> 9
6159 </td></tr>
6160 <tr>
6161 <th> 4
6162 </th>
6163 <td> 4 </td>
6164 <td> 8 </td>
6165 <td> 12
6166 </td></tr>
6167 <tr>
6168 <th> 5
6169 </th>
6170 <td> 5 </td>
6171 <td> 10 </td>
6172 <td> 15
6173 </td></tr></table>
6174
6175 !! end
6176
6177 !! test
6178 Accept "||" in table headings
6179 !! wikitext
6180 {|
6181 !h1 || h2
6182 |}
6183 !! html
6184 <table>
6185 <tr>
6186 <th>h1 </th>
6187 <th> h2
6188 </th></tr></table>
6189
6190 !! end
6191
6192 !! test
6193 Accept "!!" in table data
6194 !! wikitext
6195 {|
6196 | Foo!! ||
6197 |}
6198 !! html
6199 <table>
6200 <tr>
6201 <td> Foo!! </td>
6202 <td>
6203 </td></tr></table>
6204
6205 !! html/parsoid
6206 <table>
6207 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'> Foo!! </td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'></td></tr>
6208 </tbody></table>
6209 !! end
6210
6211 !! test
6212 Accept "||" in indented table headings
6213 !! wikitext
6214 :{|
6215 !h1 || h2
6216 |}
6217 !! html
6218 <dl><dd><table>
6219 <tr>
6220 <th>h1 </th>
6221 <th> h2
6222 </th></tr></table></dd></dl>
6223
6224 !! end
6225
6226 !! test
6227 Accept "!!" in templates
6228 !! wikitext
6229 {|
6230 !a {{echo|b!!c}}
6231 |}
6232 !! html/php
6233 <table>
6234 <tr>
6235 <th>a b</th>
6236 <th>c
6237 </th></tr></table>
6238
6239 !! html/parsoid
6240 <table>
6241 <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>
6242 !! end
6243
6244 !! test
6245 Accept "!!" in table headings after newline
6246 !! wikitext
6247 {|
6248 !a
6249 b!!c
6250 |}
6251 !! html/php
6252 <table>
6253 <tr>
6254 <th>a
6255 <p>b!!c
6256 </p>
6257 </th></tr></table>
6258
6259 !! html/parsoid
6260 <table>
6261 <tbody><tr><th>a
6262 <p>b!!c</p></th></tr>
6263 </tbody></table>
6264 !! end
6265
6266 !! test
6267 Accept "!!" in table data of mixed wikitext / html syntax
6268 !! wikitext
6269 {|
6270 !a
6271 <tr><td>b!!c</td></tr>
6272 |}
6273 !! html/php+tidy
6274 <table>
6275 <tbody><tr>
6276 <th>a
6277 </th></tr><tr><td>b!!c</td></tr>
6278 </tbody></table>
6279 !! html/parsoid
6280 <table>
6281 <tbody><tr><th>a</th></tr>
6282 <tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>b!!c</td></tr>
6283 </tbody></table>
6284 !! end
6285
6286 !! test
6287 Accept empty attributes in td/th cells (td/th cells starting with leading ||)
6288 !! wikitext
6289 {|
6290 !| h1
6291 || a
6292 |}
6293 !! html
6294 <table>
6295 <tr>
6296 <th> h1
6297 </th>
6298 <td> a
6299 </td></tr></table>
6300
6301 !! end
6302
6303 !!test
6304 Accept "| !" at start of line in tables (ignore !-attribute)
6305 !! wikitext
6306 {|
6307 |-
6308 | !style="color:red" | bar
6309 |}
6310 !! html
6311 <table>
6312
6313 <tr>
6314 <td> bar
6315 </td></tr></table>
6316
6317 !!end
6318
6319 !!test
6320 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 +/-
6321 !! wikitext
6322 {|
6323 |-
6324 |style='color:red;'|+1
6325 |style='color:blue;'|-1
6326 |-
6327 | 1 || 2 || 3
6328 | 1 ||+2 ||-3
6329 |-
6330 | +1
6331 | -1
6332 |}
6333 !! html
6334 <table>
6335
6336 <tr>
6337 <td style="color:red;">+1
6338 </td>
6339 <td style="color:blue;">-1
6340 </td></tr>
6341 <tr>
6342 <td> 1 </td>
6343 <td> 2 </td>
6344 <td> 3
6345 </td>
6346 <td> 1 </td>
6347 <td>+2 </td>
6348 <td>-3
6349 </td></tr>
6350 <tr>
6351 <td> +1
6352 </td>
6353 <td> -1
6354 </td></tr></table>
6355
6356 !!end
6357
6358 !! test
6359 Table rowspan
6360 !! wikitext
6361 {| border=1
6362 | Cell 1, row 1
6363 |rowspan=2| Cell 2, row 1 (and 2)
6364 | Cell 3, row 1
6365 |-
6366 | Cell 1, row 2
6367 | Cell 3, row 2
6368 |}
6369 !! html
6370 <table border="1">
6371 <tr>
6372 <td> Cell 1, row 1
6373 </td>
6374 <td rowspan="2"> Cell 2, row 1 (and 2)
6375 </td>
6376 <td> Cell 3, row 1
6377 </td></tr>
6378 <tr>
6379 <td> Cell 1, row 2
6380 </td>
6381 <td> Cell 3, row 2
6382 </td></tr></table>
6383
6384 !! end
6385
6386 !! test
6387 Nested table
6388 !! wikitext
6389 {| border=1
6390 | &alpha;
6391 |
6392 {| bgcolor=#ABCDEF border=2
6393 |nested
6394 |-
6395 |table
6396 |}
6397 |the original table again
6398 |}
6399 !! html
6400 <table border="1">
6401 <tr>
6402 <td> &#945;
6403 </td>
6404 <td>
6405 <table bgcolor="#ABCDEF" border="2">
6406 <tr>
6407 <td>nested
6408 </td></tr>
6409 <tr>
6410 <td>table
6411 </td></tr></table>
6412 </td>
6413 <td>the original table again
6414 </td></tr></table>
6415
6416 !! end
6417
6418 !! test
6419 Invalid attributes in table cell (T3830)
6420 !! wikitext
6421 {|
6422 |Cell:|broken
6423 |}
6424 !! html
6425 <table>
6426 <tr>
6427 <td>broken
6428 </td></tr></table>
6429
6430 !! end
6431
6432 !! test
6433 Table cell attributes: Pipes protected by nowikis should be treated as a plain character
6434 !! wikitext
6435 {|
6436 | title="foo" |bar
6437 | title="foo<nowiki>|</nowiki>" |bar
6438 | title="foo<nowiki>|</nowiki>" bar
6439 |}
6440 !! html/php
6441 <table>
6442 <tr>
6443 <td title="foo">bar
6444 </td>
6445 <td title="foo&#124;">bar
6446 </td>
6447 <td> title="foo|" bar
6448 </td></tr></table>
6449
6450 !! html/parsoid
6451 <table>
6452 <tbody><tr><td title="foo">bar</td>
6453 <td title="foo|" data-parsoid='{"a":{"title":"foo|"},"sa":{"title":"foo&lt;nowiki>|&lt;/nowiki>"},"autoInsertedEnd":true}'>bar</td>
6454 <td> title="foo<span typeof="mw:Nowiki">|</span>" bar</td></tr>
6455 </tbody></table>
6456 !! end
6457
6458 # See: http://lists.wikimedia.org/mailman/htdig/wikitech-l/2006-April/022293.html
6459 # N.B. The "|}" to close the table is missing from the input, so parsoid's
6460 # *2wt modes will fail.
6461 !! test
6462 Table security: embedded pipes
6463 !! options
6464 parsoid=wt2html,html2html
6465 !! wikitext
6466 {|
6467 | |[ftp://|x||]" onmouseover="alert(document.cookie)">test
6468 !! html/php
6469 <table>
6470 <tr>
6471 <td>[<a rel="nofollow" class="external free" href="ftp://%7Cx">ftp://%7Cx</a></td>
6472 <td>]" onmouseover="alert(document.cookie)"&gt;test
6473 </td>
6474 </tr>
6475 </table>
6476
6477 !! html/parsoid
6478 <table><tbody>
6479 <tr>
6480 <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>
6481 !! end
6482
6483 !! test
6484 Element attributes with double ! should not be broken up by <th>
6485 !! wikitext
6486 {|
6487 ! hi <div class="!!">ha</div> ho
6488 |}
6489 !! html/php
6490 <table>
6491 <tr>
6492 <th> hi <div class="!!">ha</div> ho
6493 </th></tr></table>
6494
6495 !! html/parsoid
6496 <table>
6497 <tbody><tr><th> hi <div class="!!" data-parsoid='{"stx":"html"}'>ha</div> ho</th></tr>
6498 </tbody></table>
6499 !! end
6500
6501 !! test
6502 ! and || in element attributes should not be parsed as <th>/<td>
6503 !! wikitext
6504 {|
6505 | <div style="color: red !important;" data-contrived="put this here ||">hi</div>
6506 |}
6507 !! html/php
6508 <table>
6509 <tr>
6510 <td> <div style="color: red !important;" data-contrived="put this here &#124;&#124;">hi</div>
6511 </td></tr></table>
6512
6513 !! html/parsoid
6514 <table>
6515 <tbody><tr><td> <div style="color: red !important;" data-contrived="put this here ||" data-parsoid='{"stx":"html"}'>hi</div></td></tr>
6516 </tbody></table>
6517 !! end
6518
6519 # FIXME: The output seems broken. Filed as T110268.
6520 !! test
6521 ! and || in td attributes should not be parsed as <th>/<td>
6522 !! options
6523 parsoid=wt2html
6524 !! wikitext
6525 {|
6526 | style="color: red !important;" data-contrived="put this here ||" | foo
6527 |}
6528 !! html/php
6529 <table>
6530 <tr>
6531 <td> style="color: red !important;" data-contrived="put this here </td>
6532 <td> foo
6533 </td></tr></table>
6534
6535 !! html/parsoid
6536 <table>
6537 <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>
6538 </tbody></table>
6539 !! end
6540
6541 !! test
6542 Break on | in element attribute in template
6543 !! options
6544 parsoid=wt2html,html2html
6545 !! wikitext
6546 {{echo|1=<div class="hi|ho">ha</div>}}
6547 !! html/php
6548 <p>ho"&gt;ha&lt;/div&gt;
6549 </p>
6550 !! html/parsoid
6551 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"ho\">ha&lt;/div>"}},"i":0}}]}'>ho">ha</span>
6552 !! end
6553
6554 !! test
6555 Break on | in element attribute name in template
6556 !! wikitext
6557 {{echo|<div cla|ss="hiho">ha</div>}}
6558 !! html/parsoid
6559 <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>
6560 !! end
6561
6562 !! test
6563 Don't break on | in extension attribute in template
6564 !! wikitext
6565 {{echo|<ref name="hi|ho">ha</ref>}}
6566
6567 <references />
6568 !! html/parsoid
6569 <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>
6570
6571 <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>
6572 !! end
6573
6574 ## We don't support roundtripping of these attributes in Parsoid.
6575 ## Selective serialization takes care of preventing dirty diffs.
6576 ## But, on edits, we dirty-diff the invalid attribute text.
6577 !! test
6578 Invalid text in table attributes should be discarded
6579 !! options
6580 parsoid=wt2html
6581 !! wikitext
6582 {| <span>boo</span> style='border:1px solid black'
6583 | <span>boo</span> style='color:blue' | 1
6584 |<span>boo</span> style='color:blue'| 2
6585 |}
6586 !! html/php
6587 <table style="border:1px solid black">
6588 <tr>
6589 <td style="color:blue"> 1
6590 </td>
6591 <td style="color:blue"> 2
6592 </td></tr></table>
6593
6594 !! html/parsoid
6595 <table style="border:1px solid black">
6596 <tr>
6597 <td style="color:blue"> 1</td>
6598 <td style="color:blue"> 2</td>
6599 </tr>
6600 </table>
6601 !! end
6602
6603 !! test
6604 Invalid text in table attributes should be preserved by selective serializer
6605 !! options
6606 parsoid={
6607 "modes": ["selser"],
6608 "changes": [
6609 ["td:first-child", "text", "abc"],
6610 ["td + td", "text", "xyz"]
6611 ]
6612 }
6613 !! wikitext
6614 {| <span>boo</span> style='border:1px solid black'
6615 | <span>boo</span> style='color:blue' | 1
6616 |<span>boo</span> style='color:blue'| 2
6617 |}
6618 !! wikitext/edited
6619 {| <span>boo</span> style='border:1px solid black'
6620 | <span>boo</span> style='color:blue' |abc
6621 |<span>boo</span> style='color:blue'|xyz
6622 |}
6623 !! end
6624
6625 !! test
6626 1. Template-generated table cell attributes and cell content
6627 !! wikitext
6628 {|
6629 |{{table_attribs}}
6630 | {{table_attribs}}
6631 || {{table_attribs_5}}
6632 | <!--foo--> <!--bar--> <!--baz--> {{table_attribs}}
6633 |align=center {{table_attribs}}
6634 | <!--foo--> align=center <!--bar--> {{table_attribs}}
6635 |}
6636 !! html
6637 <table>
6638 <tr>
6639 <td style="color:red;">Foo
6640 </td>
6641 <td style="color:red;">Foo
6642 </td>
6643 <td> style="color:red;"</td>
6644 <td>Bar
6645 </td>
6646 <td style="color:red;">Foo
6647 </td>
6648 <td align="center" style="color:red;">Foo
6649 </td>
6650 <td align="center" style="color:red;">Foo
6651 </td></tr></table>
6652
6653 !! end
6654
6655 !! test
6656 2. Template-generated table cell attributes and cell content
6657 !! wikitext
6658 {|
6659 |{{table_attribs_2}}
6660 |}
6661 !! html/php
6662 <table>
6663 <tr>
6664 <td style="color:red;">Foo
6665 </td>
6666 <td>Bar</td>
6667 <td>Baz
6668 </td></tr></table>
6669
6670 !! html/parsoid
6671 <table>
6672 <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>
6673 <td about="#mwt1">Bar</td><td about="#mwt1">Baz</td></tr>
6674 </tbody></table>
6675 !! end
6676
6677 !! test
6678 3. Template-generated table cell attributes and cell content
6679 !! wikitext
6680 {|
6681 !align=center {{table_header_cells}}
6682 |-
6683 |align=center {{table_cells}}
6684 |}
6685 !! html/php
6686 <table>
6687 <tr>
6688 <th align="center" style="color:red;">Foo</th>
6689 <th style="color:red;"><i>Bar</i></th>
6690 <th style="color:brown;"><i>Foo</i> and Baz
6691 </th></tr>
6692 <tr>
6693 <td align="center" style="color:red;">Foo</td>
6694 <td style="color:red;"><i>Bar</i></td>
6695 <td style="color:brown;"><i>Foo</i> and Baz
6696 </td></tr></table>
6697
6698 !! html/parsoid
6699 <table>
6700 <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>
6701 <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>
6702 </tbody></table>
6703 !! end
6704
6705 !! test
6706 4. Template-generated table cell attributes and cell content inside a templated table
6707 !! wikitext
6708 {{tbl-start}}
6709 !align=center {{table_header_cells}}
6710 |-
6711 |align=center {{table_cells}}
6712 {{tbl-end}}
6713 !! html/php
6714 <table>
6715 <tr>
6716 <th align="center" style="color:red;">Foo</th>
6717 <th style="color:red;"><i>Bar</i></th>
6718 <th style="color:brown;"><i>Foo</i> and Baz
6719 </th></tr>
6720 <tr>
6721 <td align="center" style="color:red;">Foo</td>
6722 <td style="color:red;"><i>Bar</i></td>
6723 <td style="color:brown;"><i>Foo</i> and Baz
6724 </td></tr></table>
6725
6726 !! html/parsoid
6727 <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}}]}'>
6728 <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>
6729 <tr>
6730 <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>
6731 </tbody></table>
6732 !! end
6733
6734 ## Edge case fix to prevent future regressions
6735 !! test
6736 T107652: <ref>s in templates that also generate table cell attributes should be rendered properly
6737 !! wikitext
6738 {|
6739 |{{table_attribs_7}}
6740 |}
6741 <references />
6742 !! html/parsoid
6743 <table>
6744 <tbody><tr><td style="background:#f9f9f9;" typeof="mw:Transclusion" about="#mwt1" data-mw='{"parts":["|",{"template":{"target":{"wt":"table_attribs_7","href":"./Template:Table_attribs_7"},"params":{},"i":0}}]}'>Foo<sup class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{}}'><a href="./Main_Page#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></s></td></tr>
6745 </tbody></table>
6746 <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>
6747 !! end
6748
6749 !! test
6750 Table with row followed by newlines and table heading
6751 !! options
6752 parsoid=wt2html,html2html
6753 !! wikitext
6754 {|
6755 |-
6756
6757 ! foo
6758 |}
6759 !! html/*
6760 <table>
6761
6762
6763 <tr>
6764 <th> foo
6765 </th></tr></table>
6766
6767 !! end
6768
6769 !! test
6770 Table with empty line following the start tag
6771 !! options
6772 parsoid=wt2html,html2html
6773 !! wikitext
6774 {|
6775
6776 |-
6777 | foo
6778 |}
6779 !! html/*
6780 <table>
6781
6782
6783 <tr>
6784 <td> foo
6785 </td></tr></table>
6786
6787 !! end
6788
6789 !! test
6790 Table attributes with empty value
6791 !! options
6792 parsoid=wt2html,html2html
6793 !! wikitext
6794 {|
6795 | style=| hello
6796 |}
6797 !! html/php
6798 <table>
6799 <tr>
6800 <td style=""> hello
6801 </td></tr></table>
6802
6803 !! html/parsoid
6804 <table>
6805 <tbody><tr><td style=""> hello</td></tr>
6806 </tbody></table>
6807 !! end
6808
6809 !! test
6810 Wikitext table with a lot of comments
6811 !! wikitext
6812 {|
6813 <!-- c0 -->
6814 | foo
6815 <!-- c1 -->
6816 |-<!-- c2 -->
6817 <!-- c3 -->
6818 |<!-- c4 -->
6819 <!-- c5 -->
6820 |}
6821 !! html
6822 <table>
6823 <tr>
6824 <td> foo
6825 </td></tr>
6826 <tr>
6827 <td>
6828 </td></tr></table>
6829
6830 !! end
6831
6832 !! test
6833 Wikitext table comments represented in parsoid dom
6834 !! wikitext
6835 {|<!--c1--><!--c2-->
6836 |-<!--c3-->
6837 | x
6838 |}
6839 !! html/php+tidy
6840 <table>
6841
6842 <tbody><tr>
6843 <td> x
6844 </td></tr></tbody></table>
6845 !! html/parsoid
6846 <table><!--c1--><!--c2-->
6847 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'><!--c3-->
6848 <td data-parsoid='{"autoInsertedEnd":true}'> x</td></tr>
6849 </tbody></table>
6850 !! end
6851
6852 !! test
6853 Wikitext table with double-line table cell
6854 !! wikitext
6855 {|
6856 |a
6857 b
6858 |}
6859 !! html
6860 <table>
6861 <tr>
6862 <td>a
6863 <p>b
6864 </p>
6865 </td></tr></table>
6866
6867 !! end
6868
6869 !! test
6870 Table cell with a single comment
6871 !! wikitext
6872 {|
6873 | <!-- c1 -->
6874 | a
6875 |}
6876 !! html
6877 <table>
6878 <tr>
6879 <td>
6880 </td>
6881 <td> a
6882 </td></tr></table>
6883
6884 !! end
6885
6886 !! test
6887 Table-cell after a comment-only-empty-line
6888 !! wikitext
6889 {|
6890 |a
6891 <!--c1-->
6892 <!--c2-->| b
6893 |}
6894 !! html
6895 <table>
6896 <tr>
6897 <td>a
6898 </td>
6899 <td> b
6900 </td></tr></table>
6901
6902 !! html/parsoid
6903 <table>
6904 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>a</td>
6905 <!--c1-->
6906 <!--c2--><td data-parsoid='{"autoInsertedEnd":true}'> b</td></tr>
6907 </tbody></table>
6908
6909 !! end
6910
6911 !! test
6912 Build table with {{!}}
6913 !! wikitext
6914 {{{!}} class="wikitable"
6915 ! header
6916 ! second header
6917 {{!}}- style="color:red;"
6918 {{!}} data {{!}}{{!}} style="color:red;" {{!}} second data
6919 {{!}}}
6920 !! html
6921 <table class="wikitable">
6922 <tr>
6923 <th> header
6924 </th>
6925 <th> second header
6926 </th></tr>
6927 <tr style="color:red;">
6928 <td> data </td>
6929 <td style="color:red;"> second data
6930 </td></tr></table>
6931
6932 !! end
6933
6934 !! test
6935 Build table with pipe as data
6936 !! wikitext
6937 {| class="wikitable"
6938 ! header
6939 ! second header
6940 |- style="color:red;"
6941 | data || style="color:red;" | second data
6942 |-
6943 | style="color:red;" | data with | || style="color:red;" | second data with |
6944 |-
6945 || data with | ||| second data with |
6946 |}
6947 !! html
6948 <table class="wikitable">
6949 <tr>
6950 <th> header
6951 </th>
6952 <th> second header
6953 </th></tr>
6954 <tr style="color:red;">
6955 <td> data </td>
6956 <td style="color:red;"> second data
6957 </td></tr>
6958 <tr>
6959 <td style="color:red;"> data with | </td>
6960 <td style="color:red;"> second data with |
6961 </td></tr>
6962 <tr>
6963 <td> data with | </td>
6964 <td> second data with |
6965 </td></tr></table>
6966
6967 !! end
6968
6969 !! test
6970 Build table with wikilink
6971 !! wikitext
6972 {| class="wikitable"
6973 ! header || second header
6974 |- style="color:red;"
6975 | data [[Main Page|linktext]] || second data [[Main Page|linktext]]
6976 |-
6977 | data || second data [[Main Page|link|text with pipe]]
6978 |}
6979 !! html
6980 <table class="wikitable">
6981 <tr>
6982 <th> header </th>
6983 <th> second header
6984 </th></tr>
6985 <tr style="color:red;">
6986 <td> data <a href="/wiki/Main_Page" title="Main Page">linktext</a> </td>
6987 <td> second data <a href="/wiki/Main_Page" title="Main Page">linktext</a>
6988 </td></tr>
6989 <tr>
6990 <td> data </td>
6991 <td> second data <a href="/wiki/Main_Page" title="Main Page">link|text with pipe</a>
6992 </td></tr></table>
6993
6994 !! end
6995
6996 # The expected HTML structure in this test is debatable. The PHP parser does
6997 # not parse this kind of table at all. The main focus for Parsoid is on
6998 # round-tripping, so this output is ok for now. TODO: revisit!
6999 !! test
7000 Wikitext table with html-syntax row
7001 !! wikitext
7002 {|
7003 |-
7004 <td>foo</td>
7005 |}
7006 !! html/parsoid
7007 <table>
7008 <tbody>
7009 <tr>
7010 <td>foo</td></tr></tbody></table>
7011 !! end
7012
7013 !! test
7014 Fostered content in tables: Plain text
7015 !! options
7016 parsoid=wt2html,html2html
7017 !! wikitext
7018 {|
7019 |-
7020 a
7021 |}
7022 !! html/php
7023 <table>
7024
7025 a
7026 </table>
7027
7028 !! html/php+tidy
7029
7030
7031 a
7032 <table></table>
7033 !! html/parsoid
7034 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>a</p><table>
7035 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7036
7037 </tr></tbody></table>
7038 !! end
7039
7040 !! test
7041 Fostered content in tables: Lists
7042 !! options
7043 parsoid=wt2html,html2html
7044 !! wikitext
7045 {|
7046 |-
7047 *a
7048 |}
7049 !! html/php
7050 <table>
7051
7052 <ul><li>a</li></ul>
7053 </table>
7054
7055 !! html/php+tidy
7056 <ul><li>a</li></ul><table>
7057
7058
7059 </table>
7060 !! html/parsoid
7061 <ul data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><li>a</li></ul><table>
7062 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7063
7064 </tr></tbody></table>
7065 !! end
7066
7067 !! test
7068 Template generated table cell with attributes
7069 !! wikitext
7070 {|
7071 |-
7072 {{table_attribs_4}} || a || b
7073 |}
7074 !! html/php+tidy
7075 <table>
7076
7077 <tbody><tr>
7078 <td style="background-color:#DC241f;" width="10px"> </td>
7079 <td> a </td>
7080 <td> b
7081 </td></tr></tbody></table>
7082 !! html/parsoid
7083 <table>
7084 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7085 <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>
7086 !! end
7087
7088 !! test
7089 Parsoid: Round-trip tables directly followed by content (T53219)
7090 !! options
7091 parsoid=wt2html,wt2wt
7092 !! wikitext
7093 {|
7094 |foo
7095 |} bar
7096
7097 {|
7098 |baz
7099 |}<b>quux</b>
7100 !! html+tidy
7101 <table>
7102 <tbody><tr>
7103 <td>foo
7104 </td></tr></tbody></table><p> bar
7105 </p><table>
7106 <tbody><tr>
7107 <td>baz
7108 </td></tr></tbody></table><p><b>quux</b>
7109 </p>
7110 !! end
7111
7112 !! test
7113 Parsoid: Default to a newline after tables in new content (T53219)
7114 !! options
7115 parsoid=html2wt
7116 !! html/parsoid
7117 <table><tbody>
7118 <tr><td>foo</td></tr></tbody></table> bar
7119 <table><tbody>
7120 <tr><td>baz</td></tr></tbody></table><b>quux</b>
7121 !! wikitext
7122 {|
7123 |foo
7124 |}
7125 <nowiki> </nowiki>bar
7126 {|
7127 |baz
7128 |}
7129 '''quux'''
7130 !! end
7131
7132 !! test
7133 Parsoid: newline inducing block nodes don't suppress <nowiki>
7134 !! options
7135 parsoid=html2wt
7136 !! html/parsoid
7137 a<h1>foo</h1>
7138 !! wikitext
7139 <nowiki> </nowiki>a
7140
7141 = foo =
7142 !! end
7143
7144 !! test
7145 Parsoid: Row-syntax table headings followed by comment & table cells
7146 !! options
7147 parsoid=wt2html,wt2wt
7148 !! wikitext
7149 {|
7150 ! foo || bar
7151 <!-- foo --> || baz || quux
7152 |}
7153 !! html/php
7154 <table>
7155 <tr>
7156 <th> foo </th>
7157 <th> bar
7158 </th>
7159 <td> baz </td>
7160 <td> quux
7161 </td></tr></table>
7162
7163 !! html/parsoid
7164 <table>
7165 <tbody><tr><th> foo </th><th> bar
7166 <!-- foo --> </th><td> baz </td><td> quux</td></tr>
7167 </tbody></table>
7168 !! end
7169
7170 !!test
7171 Parsoid: Recover better from broken table attributes
7172 !!options
7173 parsoid=wt2html
7174 !!wikitext
7175 {| class="foo
7176 | class="bar" |
7177 foo
7178 |}
7179 !!html/php+tidy
7180 <table class="foo">
7181 <tbody><tr>
7182 <td class="bar">
7183 <p>foo
7184 </p>
7185 </td></tr></tbody></table>
7186 !!html/parsoid
7187 <table class="foo">
7188 <tr>
7189 <td class="bar">
7190 <p>foo</p></td></tr>
7191 </tbody></table>
7192 !!end
7193
7194 !! test
7195 Tables: Digest broken attributes on table and tr tag
7196 !! options
7197 parsoid=wt2html
7198 !! wikitext
7199 {| || |} ++
7200 |- || || ++ --
7201 |- > [
7202 |}
7203 !! html
7204 <table>
7205 <tbody>
7206 <tr class='mw-empty-elt'></tr>
7207 <tr class='mw-empty-elt'></tr>
7208 </tbody></table>
7209 !! end
7210
7211 # T137406: Whitespace in the HTML
7212 !! test
7213 1. Generate correct wikitext for tables with thead/tbody/tfoot
7214 !! options
7215 parsoid=html2wt
7216 !! html/parsoid
7217 <table>
7218 <caption>Test</caption>
7219 <thead>
7220 <tr>
7221 <th>Month</th>
7222 <th>Savings</th>
7223 </tr>
7224 </thead>
7225 <tbody>
7226 <tr>
7227 <td>January</td>
7228 <td>$100</td>
7229 </tr>
7230 <tr>
7231 <td>February</td>
7232 <td>$80</td>
7233 </tr>
7234 </tbody>
7235 <tfoot>
7236 <tr>
7237 <td>Sum</td>
7238 <td>$180</td>
7239 </tr>
7240 </tfoot>
7241 </table>
7242 !! wikitext
7243 {|
7244 |+Test
7245 !Month
7246 !Savings
7247 |-
7248 |January
7249 |$100
7250 |-
7251 |February
7252 |$80
7253 |-
7254 |Sum
7255 |$180
7256 |}
7257 !! html/php+tidy
7258 <table>
7259 <caption>Test
7260 </caption>
7261 <tbody><tr>
7262 <th>Month
7263 </th>
7264 <th>Savings
7265 </th></tr>
7266 <tr>
7267 <td>January
7268 </td>
7269 <td>$100
7270 </td></tr>
7271 <tr>
7272 <td>February
7273 </td>
7274 <td>$80
7275 </td></tr>
7276 <tr>
7277 <td>Sum
7278 </td>
7279 <td>$180
7280 </td></tr></tbody></table>
7281 !! end
7282
7283 # T137406: No whitespace in the HTML
7284 !! test
7285 2. Generate correct wikitext for tables with thead/tbody/tfoot
7286 !! options
7287 parsoid=html2wt
7288 !! html/parsoid
7289 <table><thead><tr><th>heading</th></tr></thead><tbody><tr><td>foo</td></tr></tbody></table>
7290 !! wikitext
7291 {|
7292 !heading
7293 |-
7294 |foo
7295 |}
7296 !! end
7297
7298 !! test
7299 Testing serialization after deletion in references
7300 !! options
7301 parsoid={
7302 "modes": ["wt2wt"],
7303 "changes": [
7304 ["#x", "remove"]
7305 ]
7306 }
7307 !! wikitext
7308 hi <ref><div id="x">ho</div></ref>
7309
7310 <references />
7311 !! wikitext/edited
7312 hi <ref></ref>
7313
7314 <references />
7315 !! end
7316
7317 !!test
7318 Testing serialization after deletion of table cells
7319 !!options
7320 parsoid={
7321 "modes": ["wt2wt", "selser"],
7322 "changes": [
7323 ["#x", "remove"]
7324 ]
7325 }
7326 !!wikitext
7327 {|
7328 !h1 !!h2 !!h3
7329 | id="x" |c1 {{!}}{{!}}{{!}}c2 |||c3
7330 |}
7331 !! wikitext/edited
7332 {|
7333 !h1 !!h2 !!h3
7334 |c2 |||c3
7335 |}
7336 !!end
7337
7338 !! test
7339 Testing selser after addition of new row before first row (T125419)
7340 !! options
7341 parsoid={
7342 "modes": ["wt2wt", "selser"],
7343 "changes": [
7344 [ "tr", "before", "<tr><td>X</td></tr>" ]
7345 ]
7346 }
7347 !! wikitext
7348 {|
7349 |a
7350 |}
7351 !! wikitext/edited
7352 {|
7353 |X
7354 |-
7355 |a
7356 |}
7357 !! end
7358
7359 !! test
7360 Serialize new table rows in a HTML table using HTML tags
7361 !! options
7362 parsoid={
7363 "modes": ["wt2wt", "selser"],
7364 "changes": [
7365 [ "tr", "before", "<tr><td>X</td></tr>" ]
7366 ]
7367 }
7368 !! wikitext
7369 <table><tr><td>a</td></tr></table>
7370 !! wikitext/edited
7371 <table><tr><td>X</td></tr><tr><td>a</td></tr></table>
7372 !! end
7373
7374 !! test
7375 Serialize new table cells in a HTML row using HTML tags
7376 !! options
7377 parsoid={
7378 "modes": ["wt2wt", "selser"],
7379 "changes": [
7380 [ "td", "before", "<td>X</td>" ]
7381 ]
7382 }
7383 !! wikitext
7384 <table><tr><td>a</td></tr></table>
7385 !! wikitext/edited
7386 <table><tr><td>X</td><td>a</td></tr></table>
7387 !! end
7388
7389 !! test
7390 Wikitext tables can be nested inside HTML tables
7391 !! options
7392 parsoid=html2wt
7393 !! html
7394 <table data-parsoid='{"stx":"html"}'>
7395 <tr><td>
7396 <table>
7397 <tr><td>foo</td></tr>
7398 </table>
7399 </td></tr>
7400 </table>
7401 !! wikitext
7402 <table>
7403 <tr><td>
7404 {|
7405 |foo
7406 |}
7407 </td></tr>
7408 </table>
7409 !! end
7410
7411 !! test
7412 Serialize wikitext list items as HTML list items when embedded in a HTML list
7413 !! options
7414 parsoid=html2wt
7415 !! html
7416 <ul data-parsoid='{"stx": "html"}'>
7417 <li data-parsoid='{}'>a</li>
7418 <li>b</li>
7419 </ul>
7420 !! wikitext
7421 <ul>
7422 <li>a</li>
7423 <li>b</li>
7424 </ul>
7425 !! end
7426
7427 # SSS FIXME: Is this actually a good thing given the
7428 # odd nested list output that is generated by MW?
7429 # <ul><li>foo<ul>..</ul></li></ul> instead of
7430 # <ul><li>foo</li><ul>..</ul></ul>
7431 !! test
7432 Wikitext lists can be nested inside HTML lists
7433 !! options
7434 parsoid=html2wt
7435 !! html
7436 <ul data-parsoid='{"stx": "html"}'>
7437 <li data-parsoid='{"stx": "html"}'>a
7438 <ul><li>b</li></ul>
7439 </li>
7440 </ul>
7441
7442 <ul data-parsoid='{"stx": "html"}'>
7443 <li>x
7444 <ul><li>y</li></ul>
7445 </li>
7446 </ul>
7447 !! wikitext
7448 <ul>
7449 <li>a
7450 * b
7451 </li>
7452 </ul>
7453
7454 <ul>
7455 <li>x
7456 * y
7457 </li>
7458 </ul>
7459 !! end
7460
7461 ###
7462 ### Internal links
7463 ###
7464 !! test
7465 Plain link, capitalized
7466 !! wikitext
7467 [[Main Page]]
7468 !! html
7469 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
7470 </p>
7471 !! end
7472
7473 !! test
7474 Plain link, uncapitalized
7475 !! wikitext
7476 [[main Page]]
7477 !! html
7478 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
7479 </p>
7480 !! end
7481
7482 !! test
7483 Piped link
7484 !! wikitext
7485 [[Main Page|The Main Page]]
7486 !! html
7487 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7488 </p>
7489 !! end
7490
7491 !! test
7492 Piped link with comment in link text
7493 !! wikitext
7494 [[Main Page|The Main<!--front--> Page]]
7495 !! html
7496 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7497 </p>
7498 !! end
7499
7500 !! test
7501 Piped link with multiple pipe characters in link text
7502 !! wikitext
7503 [[Main Page||The|Main|Page|]]
7504 !! html/php
7505 <p><a href="/wiki/Main_Page" title="Main Page">|The|Main|Page|</a>
7506 </p>
7507 !! html/parsoid
7508 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">|The|Main|Page|</a></p>
7509 !! end
7510
7511 !! test
7512 Piped link with no link text
7513 !! wikitext
7514 [[Thomas Bek (bishop of St David's)|]]
7515 !! html/php
7516 <p>[[Thomas Bek (bishop of St David's)|]]
7517 </p>
7518 !! html/parsoid
7519 <p>[[Thomas Bek (bishop of St David's)|]]</p>
7520 !! end
7521
7522 !! test
7523 Piped link with empty link text
7524 !! wikitext
7525 [[Main Page|<nowiki/>]] - empty nowiki
7526 [[Main Page| ]] - empty space
7527 [[Main Page|&nbsp;]] - empty non breaking space
7528 !! html/php
7529 <p><a href="/wiki/Main_Page" title="Main Page"></a> - empty nowiki
7530 <a href="/wiki/Main_Page" title="Main Page"> </a> - empty space
7531 <a href="/wiki/Main_Page" title="Main Page">&#160;</a> - empty non breaking space
7532 </p>
7533 !! html/parsoid
7534 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:Nowiki"></span></a> - empty nowiki
7535 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page"> </a> - empty space
7536 <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>
7537 !! end
7538
7539 !! test
7540 Broken link
7541 !! wikitext
7542 [[Zigzagzogzagzig]]
7543 !! html
7544 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig</a>
7545 </p>
7546 !! end
7547
7548 !! test
7549 Broken link with fragment
7550 !! wikitext
7551 [[Zigzagzogzagzig#zug]]
7552 !! html
7553 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig#zug</a>
7554 </p>
7555 !! end
7556
7557 !! test
7558 Special page link with fragment
7559 !! wikitext
7560 [[Special:Version#anchor]]
7561 !! html
7562 <p><a href="/wiki/Special:Version#anchor" title="Special:Version">Special:Version#anchor</a>
7563 </p>
7564 !! end
7565
7566 !! test
7567 Nonexistent special page link with fragment
7568 !! wikitext
7569 [[Special:ThisNameWillHopefullyNeverBeUsed#anchor]]
7570 !! html
7571 <p><a href="/wiki/Special:ThisNameWillHopefullyNeverBeUsed" class="new" title="Special:ThisNameWillHopefullyNeverBeUsed (page does not exist)">Special:ThisNameWillHopefullyNeverBeUsed#anchor</a>
7572 </p>
7573 !! end
7574
7575 !! test
7576 Link with prefix
7577 !! wikitext
7578 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
7579 !! html
7580 <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>
7581 </p>
7582 !! end
7583
7584 !! test
7585 Link with suffix
7586 !! wikitext
7587 [[Main Page]]xxx, [[Main Page]]XXX, [[Main Page]]!!!
7588 !! html
7589 <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>!!!
7590 </p>
7591 !! end
7592
7593 !! article
7594 prefixed article
7595 !! text
7596 Some text
7597 !! endarticle
7598
7599 !! test
7600 T45661: Piped links with identical prefixes
7601 !! wikitext
7602 [[prefixed article|prefixed articles with spaces]]
7603
7604 [[prefixed article|prefixed articlesaoeu]]
7605
7606 [[Main Page|Main Page test]]
7607 !! html
7608 <p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articles with spaces</a>
7609 </p><p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articlesaoeu</a>
7610 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page test</a>
7611 </p>
7612 !! end
7613
7614
7615 !! test
7616 Link with HTML entity in suffix / tail
7617 !! wikitext
7618 [[Main Page]]&quot;, [[Main Page]]&#97;
7619 !! html/php
7620 <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;
7621 </p>
7622 !! html/parsoid
7623 <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>
7624 !! end
7625
7626 !! test
7627 Link with 3 brackets
7628 !! wikitext
7629 [[[Main Page]]]
7630 Foo [[[Main Page]]]
7631 !! html
7632 <p>[[[Main Page]]]
7633 Foo [[[Main Page]]]
7634 </p>
7635 !! end
7636
7637 !! test
7638 Link with 4 brackets
7639 !! wikitext
7640 [[[[Main Page]]]]
7641 !! html
7642 <p>[[<a href="/wiki/Main_Page" title="Main Page">Main Page</a>]]
7643 </p>
7644 !! end
7645
7646 !! test
7647 Piped link with 3 brackets
7648 !! wikitext
7649 [[[main page|the main page]]]
7650 !! html
7651 <p>[[[main page|the main page]]]
7652 </p>
7653 !! end
7654
7655 !! test
7656 Piped link with extlink-like text
7657 !! wikitext
7658 [[Main Page|[bar]]]
7659 [[Main Page|This is a [bar]]]
7660 [[Main Page|[bar]]
7661 !! html/php
7662 <p><a href="/wiki/Main_Page" title="Main Page">[bar]</a>
7663 <a href="/wiki/Main_Page" title="Main Page">This is a [bar]</a>
7664 <a href="/wiki/Main_Page" title="Main Page">[bar</a>
7665 </p>
7666 !! html/parsoid
7667 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar]</a>
7668 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>This is a [bar]</a>
7669 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar</a></p>
7670 !! end
7671
7672 !! test
7673 Link with multiple pipes
7674 !! wikitext
7675 [[Main Page|The|Main|Page]]
7676 !! html
7677 <p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a>
7678 </p>
7679 !! end
7680
7681 !! test
7682 Anchor containing a #. (T65430)
7683 !! config
7684 wgFragmentMode=[ 'html5', 'legacy' ]
7685 !! wikitext
7686 [[Main Page#And#Link]]
7687 !! html/php
7688 <p><a href="/wiki/Main_Page#And#Link" title="Main Page">Main Page#And#Link</a>
7689 </p>
7690 !! html/parsoid
7691 <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>
7692 !! end
7693
7694 !! test
7695 Link to namespaces
7696 !! wikitext
7697 [[Talk:Parser testing]], [[Meta:Disclaimers]]
7698 !! html
7699 <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>
7700 </p>
7701 !! end
7702
7703 !! test
7704 Link with space in namespace
7705 !! wikitext
7706 [[User talk:Foo bar]]
7707 !! html
7708 <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>
7709 </p>
7710 !! end
7711
7712 !! article
7713 MemoryAlpha:AlphaTest
7714 !! text
7715 This is an article in the MemoryAlpha namespace
7716 (which shadows the memoryalpha interwiki link).
7717 !! endarticle
7718
7719 !! test
7720 Namespace takes precedence over interwiki link (T53680)
7721 !! wikitext
7722 [[MemoryAlpha:AlphaTest]]
7723 !! html
7724 <p><a href="/wiki/MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a>
7725 </p>
7726 !! end
7727
7728 # The previous test doesn't work correctly in html2*, due to not recognizing the
7729 # link as an internal one. This one checks for the correct behavior.
7730 !! test
7731 Link to namespace preferred over interwiki with correct rel attribute
7732 !! options
7733 parsoid=html2wt,html2html
7734 !! html/parsoid
7735 <p><a rel="mw:WikiLink" href="./MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a></p>
7736 !! wikitext
7737 [[MemoryAlpha:AlphaTest]]
7738 !! end
7739
7740 !! test
7741 Piped link to namespace
7742 !! wikitext
7743 [[Meta:Disclaimers|The disclaimers]]
7744 !! html
7745 <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>
7746 </p>
7747 !! end
7748
7749 !! test
7750 Link containing }
7751 !! wikitext
7752 [[Usually caused by a typo (oops}]]
7753 !! html
7754 <p>[[Usually caused by a typo (oops}]]
7755 </p>
7756 !! end
7757
7758 !! article
7759 7% Solution
7760 !! text
7761 Just a test of an article title containing a percent.
7762 !! endarticle
7763
7764 !! test
7765 Link containing % (not as a hex sequence)
7766 !! wikitext
7767 [[7% Solution]]
7768 [[7% Solution|7%25 Solution]]
7769 !! html/php
7770 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
7771 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
7772 </p>
7773 !! html/parsoid
7774 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
7775 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
7776 !! end
7777
7778 # note that the parsoid HTML is identical to the previous test output,
7779 # so the previous test ensures that the html2wt mode will generate the
7780 # "not as a hex sequence" wikitext.
7781 !! test
7782 Link containing % as a single hex sequence interpreted to char
7783 !! options
7784 parsoid=wt2wt,wt2html,html2html
7785 !! wikitext
7786 [[7%25 Solution]]
7787 [[7%25 Solution|7%25 Solution]]
7788 !! html/php
7789 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
7790 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
7791 </p>
7792 !! html/parsoid
7793 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
7794 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
7795 !!end
7796
7797 !! test
7798 Link containing % as a double hex sequence interpreted to hex sequence
7799 !! wikitext
7800 [[7%2525 Solution]]
7801 !! html
7802 <p>[[7%2525 Solution]]
7803 </p>
7804 !!end
7805
7806 ## Example for such a section: == < ==
7807 !! test
7808 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors
7809 !! config
7810 wgFragmentMode=[ 'html5', 'legacy' ]
7811 !! wikitext
7812 [[%23%3c]][[%23%3e]]
7813 !! html/php
7814 <p><a href="#&lt;">#&lt;</a><a href="#&gt;">#&gt;</a>
7815 </p>
7816 !! html/parsoid
7817 <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>
7818 !! end
7819
7820 ## Example for such a section: == < ==
7821 !! test
7822 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors (legacy)
7823 !! config
7824 wgFragmentMode=[ 'legacy' ]
7825 !! wikitext
7826 [[%23%3c]][[%23%3e]]
7827 !! html/php
7828 <p><a href="#.3C">#&lt;</a><a href="#.3E">#&gt;</a>
7829 </p>
7830 !! end
7831
7832 !! test
7833 Link containing "<#" and ">#" as a hex sequences
7834 !! wikitext
7835 [[%3c%23]][[%3e%23]]
7836 !! html
7837 <p>[[%3c%23]][[%3e%23]]
7838 </p>
7839 !! end
7840
7841 !! test
7842 Link containing an equals sign
7843 !! wikitext
7844 [[Special:BookSources/isbn=4-00-026157-6]]
7845 !! html/php
7846 <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>
7847 </p>
7848 !! html/parsoid
7849 <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>
7850 !! end
7851
7852 !! article
7853 Foo~bar
7854 !! text
7855 Just a test of an article title containing a tilde.
7856 !! endarticle
7857
7858 # note that links containing signatures, like [[Foo~~~~]], are
7859 # massaged by the pre-save transform (PST) and so the tildes are never
7860 # seen by the parser.
7861 !! test
7862 Link containing a tilde
7863 !! wikitext
7864 [[Foo~bar]]
7865 !! html/php
7866 <p><a href="/wiki/Foo~bar" title="Foo~bar">Foo~bar</a>
7867 </p>
7868 !! html/parsoid
7869 <p><a rel="mw:WikiLink" href="./Foo~bar" title="Foo~bar">Foo~bar</a></p>
7870 !! end
7871
7872 !! test
7873 Link containing double-single-quotes '' (T6598)
7874 !! wikitext
7875 [[Lista d''e paise d''o munno]]
7876 !! html/php
7877 <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>
7878 </p>
7879 !! html/parsoid
7880 <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>
7881 !! end
7882
7883 !! test
7884 Link containing double quotes and spaces
7885 !! wikitext
7886 [[Cool "Gator"]]
7887 !! html/php
7888 <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>
7889 </p>
7890 !! html/parsoid
7891 <p><a rel="mw:WikiLink" href='./Cool_"Gator"' title='Cool "Gator"'>Cool "Gator"</a></p>
7892 !! end
7893
7894 !! test
7895 File containing double quotes and spaces
7896 !! wikitext
7897 [[File:Cool "Gator".png]]
7898 !! html/parsoid
7899 <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>
7900 !! end
7901
7902 !! test
7903 Redirect containing double quotes and spaces
7904 !! wikitext
7905 #REDIRECT [[Cool "Gator"]]
7906 !! html/parsoid
7907 <link rel="mw:PageProp/redirect" href="./Cool_%22Gator%22" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Cool_%22Gator%22"},"sa":{"href":"Cool \"Gator\""}}'/>
7908 !! end
7909
7910 !! test
7911 Link containing double-single-quotes '' in text (T6598 sanity check)
7912 !! wikitext
7913 Some [[Link|pretty ''italics'' and stuff]]!
7914 !! html/php
7915 <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>!
7916 </p>
7917 !! html/parsoid
7918 <p>Some <a rel="mw:WikiLink" href="./Link" title="Link">pretty <i>italics</i> and stuff</a>!</p>
7919 !! end
7920
7921 !! test
7922 Link containing double-single-quotes '' in text embedded in italics (T6598 sanity check)
7923 !! wikitext
7924 ''Some [[Link|pretty ''italics'' and stuff]]!''
7925 !! html
7926 <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>
7927 </p>
7928 !! end
7929
7930 !! test
7931 Link with double quotes in title part (literal) and alternate part (interpreted)
7932 !! wikitext
7933 [[File:Denys_Savchenko_''Pentecoste''.jpg]]
7934
7935 [[''Pentecoste'']]
7936
7937 [[''Pentecoste''|Pentecoste]]
7938
7939 [[''Pentecoste''|''Pentecoste'']]
7940 !! html/php
7941 <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>
7942 </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>
7943 </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>
7944 </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>
7945 </p>
7946 !! html/parsoid
7947 <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>
7948 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">''Pentecoste''</a></p>
7949 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">Pentecoste</a></p>
7950 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''"><i>Pentecoste</i></a></p>
7951 !! end
7952
7953 !! test
7954 Broken image links with HTML captions (T41700)
7955 !! wikitext
7956 [[File:Nonexistent|<script></script>]]
7957 [[File:Nonexistent|100x100px|<script></script>]]
7958 [[File:Nonexistent|&lt;]]
7959 [[File:Nonexistent|a<i>b</i>c]]
7960 !! html/php
7961 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
7962 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
7963 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;</a>
7964 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">abc</a>
7965 </p>
7966 !! html/parsoid
7967 <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>
7968 <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>
7969 <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>
7970 <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>
7971 !! end
7972
7973 !! test
7974 Plain link to URL
7975 !! wikitext
7976 [[http://www.example.com]]
7977 !! html/php
7978 <p>[<a rel="nofollow" class="external autonumber" href="http://www.example.com">[1]</a>]
7979 </p>
7980 !! html/parsoid
7981 <p>[<a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com"></a>]</p>
7982 !! end
7983
7984 !! test
7985 Plain link to URL with link text
7986 !! wikitext
7987 [[http://www.example.com Link text]]
7988 !! html
7989 <p>[<a rel="nofollow" class="external text" href="http://www.example.com">Link text</a>]
7990 </p>
7991 !! end
7992
7993 !! test
7994 Plain link to protocol-relative URL
7995 !! wikitext
7996 [[//www.example.com]]
7997 !! html/php
7998 <p>[<a rel="nofollow" class="external autonumber" href="//www.example.com">[1]</a>]
7999 </p>
8000 !! html/parsoid
8001 <p>[<a rel="mw:ExtLink" class="external autonumber" href="//www.example.com"></a>]</p>
8002 !! end
8003
8004 !! test
8005 Plain link to protocol-relative URL with link text
8006 !! wikitext
8007 [[//www.example.com Link text]]
8008 !! html
8009 <p>[<a rel="nofollow" class="external text" href="//www.example.com">Link text</a>]
8010 </p>
8011 !! end
8012
8013 !! test
8014 Plain link to page with question mark in title
8015 !! wikitext
8016 [[A?b]]
8017
8018 [[A?b|Baz]]
8019 !! html
8020 <p><a href="/wiki/A%3Fb" title="A?b">A?b</a>
8021 </p><p><a href="/wiki/A%3Fb" title="A?b">Baz</a>
8022 </p>
8023 !! end
8024
8025 # I'm fairly sure the expected result here is wrong.
8026 # We want these to be URL links, not pseudo-pages with URLs for titles....
8027 # However the current output is also pretty screwy.
8028 #
8029 # ----
8030 # I'm changing it to match the current output--it arguably makes more
8031 # sense in the light of the test above. Old expected result was:
8032 #<p>Piped link to URL: <a href="/index.php?title=Http://www.example.com&amp;action=edit" class="new">an example URL</a>
8033 #</p>
8034 # But I think this test is bordering on "garbage in, garbage out" anyway.
8035 # -- wtm
8036 !! test
8037 Piped link to URL
8038 !! wikitext
8039 Piped link to URL: [[http://www.example.com|an example URL]]
8040 !! html/php
8041 <p>Piped link to URL: [<a rel="nofollow" class="external text" href="http://www.example.com%7Can">example URL</a>]
8042 </p>
8043 !! html/parsoid
8044 <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>
8045 !! end
8046
8047 !! test
8048 Plain link in template argument
8049 !! options
8050 parsoid=wt2html
8051 !! wikitext
8052 {{echo|[http://www.example.com |123]}}
8053
8054 {{echo|[[http://www.example.com |123]]}}
8055
8056 {{echo|[[http://www.example.com |123]}}
8057
8058 {{echo|[http://www.example.com |123]]}}
8059 !! html/php
8060 <p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8061 </p><p>[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>]
8062 </p><p>{{echo|[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>}}
8063 </p><p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8064 </p>
8065 !! html/parsoid
8066 <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>
8067
8068 <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>
8069
8070 <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>
8071
8072 <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>
8073 !! end
8074
8075 !! test
8076 T2002: [[page|http://url/]] should link to page, not http://url/
8077 !! wikitext
8078 [[Main Page|http://url/]]
8079 !! html/php
8080 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
8081 </p>
8082 !! html/parsoid
8083 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">http://url/</a></p>
8084 !! end
8085
8086 # Parsoid does not mark self-links, by design.
8087 !! test
8088 T2337: Escaped self-links should be bold
8089 !! options
8090 title=[[Bug462]]
8091 !! wikitext
8092 [[Bu&#103;462]] [[Bug462]]
8093 !! html/php+tidy
8094 <p><a class="mw-selflink selflink">Bu&#103;462</a> <a class="mw-selflink selflink">Bug462</a>
8095 </p>
8096 !! html/parsoid
8097 <p><a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a> <a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a></p>
8098 !! end
8099
8100 !! test
8101 Self-link to section should not be bold
8102 !! options
8103 title=[[Main Page]]
8104 !! wikitext
8105 [[Main Page#section]]
8106 !! html
8107 <p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
8108 </p>
8109 !! end
8110
8111 !! article
8112 00
8113 !! text
8114 This is 00.
8115 !! endarticle
8116
8117 !!test
8118 Self-link to numeric title
8119 !!options
8120 title=[[0]]
8121 !! wikitext
8122 [[0]]
8123 !! html
8124 <p><a class="mw-selflink selflink">0</a>
8125 </p>
8126 !!end
8127
8128 !!test
8129 Link to numeric-equivalent title
8130 !!options
8131 title=[[0]]
8132 !! wikitext
8133 [[00]]
8134 !! html
8135 <p><a href="/wiki/00" title="00">00</a>
8136 </p>
8137 !!end
8138
8139 !! test
8140 <nowiki> inside a link
8141 !! wikitext
8142 [[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
8143 !! html
8144 <p>[[Main Page]] <a href="/wiki/Main_Page" title="Main Page">the main page [it's not very good]</a>
8145 </p>
8146 !! end
8147
8148 !! test
8149 Non-breaking spaces in title
8150 !! wikitext
8151 [[&nbsp; Main &nbsp; Page &nbsp;]]
8152 !! html
8153 <p><a href="/wiki/Main_Page" title="Main Page">&#160; Main &#160; Page &#160;</a>
8154 </p>
8155 !!end
8156
8157 # Add new article for the test below so that it doesn't red-link
8158 !! article
8159 Foo bar baz
8160 !! text
8161 boo
8162 !! endarticle
8163
8164 !! test
8165 Multiple spaces in titles should normalize to a single underscore
8166 !! options
8167 parsoid=wt2html,wt2wt
8168 !! wikitext
8169 [[Foo bar baz|x]]
8170 [[Foo bar baz|x]]
8171 [[Foo bar baz|x]]
8172 !! html/php
8173 <p><a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8174 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8175 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8176 </p>
8177 !! html/parsoid
8178 <p><a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8179 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8180 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8181 </p>
8182 !! end
8183
8184 !! test
8185 Internal link with ca linktrail, surrounded by bold apostrophes (T29473 primary issue)
8186 !! options
8187 language=ca
8188 !! wikitext
8189 '''[[Main Page]]'''
8190 !! html
8191 <p><b><a href="/wiki/Main_Page" title="Main Page">Main Page</a></b>
8192 </p>
8193 !! end
8194
8195 !! test
8196 Internal link with ca linktrail, surrounded by italic apostrophes (T29473 primary issue)
8197 !! options
8198 language=ca
8199 !! wikitext
8200 ''[[Main Page]]''
8201 !! html
8202 <p><i><a href="/wiki/Main_Page" title="Main Page">Main Page</a></i>
8203 </p>
8204 !! end
8205
8206 !! test
8207 Internal link with en linktrail: no apostrophes (T29473)
8208 !! options
8209 language=en
8210 !! wikitext
8211 [[Something]]'nice
8212 !! html
8213 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (page does not exist)">Something</a>'nice
8214 </p>
8215 !! end
8216
8217 !! test
8218 Internal link with ca linktrail with apostrophes (T29473)
8219 !! options
8220 language=ca
8221 !! wikitext
8222 [[Something]]'nice
8223 !! html
8224 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (encara no existeix)">Something'nice</a>
8225 </p>
8226 !! end
8227
8228 !! test
8229 Internal link with kaa linktrail with apostrophes (T29473)
8230 !! options
8231 language=kaa
8232 !! wikitext
8233 [[Something]]'nice
8234 !! html
8235 <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>
8236 </p>
8237 !! end
8238
8239 !! test
8240 Link with multiple ":" in a subpage-supporting namespace (T65636)
8241 !! wikitext
8242 [[User:Foo/Test/63636:Bar|Test]]
8243 !! html/php
8244 <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>
8245 </p>
8246 !! html/parsoid
8247 <p><a rel="mw:WikiLink" href="./User:Foo/Test/63636:Bar" title="User:Foo/Test/63636:Bar">Test</a></p>
8248 !! end
8249
8250 ## Mainly a sanity check for Parsoid
8251 !! test
8252 Handle title parsing for subpages
8253 !! options
8254 title=[[/123123]]
8255 subpage
8256 !! wikitext
8257 123
8258 !! html/php
8259 <p>123
8260 </p>
8261 !! html/parsoid
8262 <p>123</p>
8263 !! end
8264
8265 !! article
8266 User:Test/123
8267 !! text
8268 test 123
8269 !! endarticle
8270
8271 !! test
8272 Link to a subpage from a namespace other than main
8273 !! options
8274 title=[[User:Test]]
8275 subpage
8276 !! wikitext
8277 [[/123]]
8278 !! html/php
8279 <p><a href="/wiki/User:Test/123" title="User:Test/123">/123</a>
8280 </p>
8281 !! html/parsoid
8282 <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>
8283 !! end
8284
8285 !! test
8286 Ensure that transclusion titles are not url-decoded
8287 !! options
8288 subpage title=[[Test]]
8289 parsoid=wt2html
8290 !! wikitext
8291 {{Bar%C3%A9}} {{/Bar%C3%A9}}
8292 !! html/php
8293 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}
8294 </p>
8295 !! html/parsoid
8296 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}</p>
8297 !! end
8298
8299 !! test
8300 Purely hash wikilink
8301 !! options
8302 title=[[User:Test/123]]
8303 subpage
8304 !! wikitext
8305 [[#a|b]]
8306 !! html/php
8307 <p><a href="#a">b</a>
8308 </p>
8309 !! html/parsoid
8310 <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>
8311 !! end
8312
8313 !! test
8314 Serialization of purely hash wikilink
8315 !! options
8316 title=[[User:Test/123]]
8317 subpage
8318 parsoid=html2wt
8319 !! html/parsoid
8320 <p><a href="#a">[[</a></p>
8321 !! wikitext
8322 [[#a|<nowiki>[[</nowiki>]]
8323 !! html/php
8324 <p><a href="#a">[[</a>
8325 </p>
8326 !! end
8327
8328 !! test
8329 1. Interaction of linktrail and template encapsulation
8330 !! wikitext
8331 {{echo|[[Foo]]}}l
8332 !! html/parsoid
8333 <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>
8334 !! end
8335
8336 !! test
8337 2. Interaction of linktrail and template encapsulation
8338 !! options
8339 parsoid
8340 !! wikitext
8341 {{echo|Some [[Fool]]}}s
8342 !! html
8343 <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>
8344 !! end
8345
8346 !! test
8347 3. Interaction of linktrail and template encapsulation
8348 !! options
8349 parsoid
8350 !! wikitext
8351 {{echo|Some [[Fool]]s are '''bold and foolish'''}}
8352 !! html
8353 <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>
8354 !! end
8355
8356 !! article
8357 Söfnuður
8358 !! text
8359 Test.
8360 !! endarticle
8361
8362 !! test
8363 Internal link with is link prefix
8364 !! options
8365 language=is
8366 !! wikitext
8367 Aðrir mótmælenda[[söfnuður|söfnuðir]] og
8368 !! html
8369 <p>Aðrir <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a> og
8370 </p>
8371 !! end
8372
8373 !! article
8374 Mótmælendatrú
8375 !! text
8376 Test.
8377 !! endarticle
8378
8379 !! test
8380 Internal link with is link trail and link prefix
8381 !! options
8382 language=is
8383 !! wikitext
8384 [[mótmælendatrú|xxx]]ar
8385 [[mótmælendatrú]]ar
8386 mótmælenda[[söfnuður]]
8387 mótmælenda[[söfnuður|söfnuðir]]
8388 mótmælenda[[söfnuður|söfnuðir]]xxx
8389 !! html
8390 <p><a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">xxxar</a>
8391 <a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">mótmælendatrúar</a>
8392 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuður</a>
8393 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a>
8394 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðirxxx</a>
8395 </p>
8396 !! end
8397
8398 !! test
8399 Parsoid link trail escaping
8400 !! options
8401 parsoid=html2wt,html2html
8402 !! html/parsoid
8403 <p><a rel="mw:WikiLink" href="./Apple" title="Apple">apple</a>s</p>
8404 !! wikitext
8405 [[apple]]<nowiki/>s
8406 !! end
8407
8408 !! test
8409 Parsoid link prefix escaping
8410 !! options
8411 language=is
8412 parsoid=html2wt,html2html
8413 !! html/parsoid
8414 <p>Aðrir mótmælenda<a rel="mw:WikiLink" href="./Söfnuður" title="Söfnuður">söfnuður</a></p>
8415 !! wikitext
8416 Aðrir mótmælenda<nowiki/>[[söfnuður]]
8417 !! end
8418
8419 !! test
8420 Parsoid link bracket escaping
8421 !! options
8422 parsoid=html2wt,html2html
8423 !! html/parsoid
8424 <p><a rel="mw:WikiLink" href="./Test" title="Test">Test</a></p>
8425 <p>[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]</p>
8426 <p>[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]</p>
8427 <p>[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]</p>
8428 <p>[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]</p>
8429 <p>[[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]]</p>
8430 !! wikitext
8431 [[Test]]
8432
8433 [<nowiki/>[[Test]]]
8434
8435 [[[[Test]]]]
8436
8437 [[[<nowiki/>[[Test]]]]]
8438
8439 [[[[[[Test]]]]]]
8440
8441 [[[[[<nowiki/>[[Test]]]]]]]
8442 !! end
8443
8444 !! test
8445 Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved
8446 !! wikitext
8447 [[Foo| bar]]
8448
8449 [[Foo| ''bar'']]
8450
8451 [http://wp.org foo]
8452
8453 [http://wp.org ''foo'']
8454 !! html
8455 <p><a href="/wiki/Foo" title="Foo"> bar</a>
8456 </p><p><a href="/wiki/Foo" title="Foo"> <i>bar</i></a>
8457 </p><p><a rel="nofollow" class="external text" href="http://wp.org">foo</a>
8458 </p><p><a rel="nofollow" class="external text" href="http://wp.org"><i>foo</i></a>
8459 </p>
8460 !! end
8461
8462 !! test
8463 Parsoid: Scoped parsing should handle mixed transclusions and plain text
8464 !! wikitext
8465 [[Foo|{{echo|a}} b {{echo|c}}]]
8466 !! html/parsoid
8467 <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>
8468 !! end
8469
8470 !! test
8471 Link with angle bracket after anchor
8472 !! config
8473 wgFragmentMode=[ 'html5', 'legacy' ]
8474 !! wikitext
8475 [[Foo#<bar>]]
8476 !! html/php
8477 <p><a href="/wiki/Foo#&lt;bar&gt;" title="Foo">Foo#&lt;bar&gt;</a>
8478 </p>
8479 !! html/parsoid
8480 <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>
8481 !! end
8482
8483 !! test
8484 Link with angle bracket after anchor (legacy)
8485 !! config
8486 wgFragmentMode=[ 'legacy' ]
8487 !! wikitext
8488 [[Foo#<bar>]]
8489 !! html/php
8490 <p><a href="/wiki/Foo#.3Cbar.3E" title="Foo">Foo#&lt;bar&gt;</a>
8491 </p>
8492 !! end
8493
8494 ###
8495 ### Interwiki links (see maintenance/interwiki.sql)
8496 ###
8497
8498 !! test
8499 Inline interwiki link
8500 !! options
8501 parsoid=wt2html,wt2wt,html2html
8502 !! wikitext
8503 [[MeatBall:SoftSecurity]]
8504 !! html/php
8505 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
8506 </p>
8507 !! html/parsoid
8508 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a></p>
8509 !! end
8510
8511 !! test
8512 Inline interwiki link with empty title (T4372)
8513 !! options
8514 parsoid=wt2html,wt2wt,html2html
8515 !! wikitext
8516 [[MeatBall:]]
8517 !! html/php
8518 <p><a href="http://www.usemod.com/cgi-bin/mb.pl" class="extiw" title="meatball:">MeatBall:</a>
8519 </p>
8520 !! html/parsoid
8521 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?" title="meatball:">MeatBall:</a></p>
8522 !! end
8523
8524 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
8525 !! test
8526 Interwiki link encoding conversion (T3636)
8527 !! options
8528 parsoid=wt2html,wt2wt
8529 !! wikitext
8530 *[[Wikipedia:ro:Olteni&#0355;a]]
8531 *[[Wikipedia:ro:Olteni&#355;a]]
8532 !! html
8533 <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>
8534 <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>
8535
8536 !! html/php+tidy
8537 <ul>
8538 <li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
8539 <li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
8540 </ul>
8541 !! html/parsoid
8542 <ul>
8543 <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>
8544 <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>
8545 </ul>
8546 !! end
8547
8548 !! test
8549 Interwiki link with fragment (T4130)
8550 !! wikitext
8551 [[MeatBall:SoftSecurity#foo]]
8552 !! html
8553 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity#foo</a>
8554 </p>
8555 !! end
8556
8557 !! test
8558 Link scenarios with escaped fragments
8559 !! config
8560 wgFragmentMode=[ 'html5', 'legacy' ]
8561 !! wikitext
8562 [[#Is this great?]]
8563 [[Foo#Is this great?]]
8564 [[meatball:Foo#Is this great?]]
8565 !! html/php
8566 <p><a href="#Is_this_great?">#Is this great?</a>
8567 <a href="/wiki/Foo#Is_this_great?" title="Foo">Foo#Is this great?</a>
8568 <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>
8569 </p>
8570 !! html/parsoid
8571 <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>
8572 <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>
8573 <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>
8574 !! end
8575
8576 !! test
8577 Link scenarios with escaped fragments (legacy)
8578 !! config
8579 wgFragmentMode=[ 'legacy' ]
8580 !! wikitext
8581 [[#Is this great?]]
8582 [[Foo#Is this great?]]
8583 [[meatball:Foo#Is this great?]]
8584 !! html/php
8585 <p><a href="#Is_this_great.3F">#Is this great?</a>
8586 <a href="/wiki/Foo#Is_this_great.3F" title="Foo">Foo#Is this great?</a>
8587 <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>
8588 </p>
8589 !! end
8590
8591 # Ideally the wikipedia: prefix here should be proto-relative too
8592 # [CSA]: this is kind of a bogus test, as the PHP parser test doesn't
8593 # define the 'en' prefix, and originally the test used 'wikipedia',
8594 # which isn't a localinterwiki prefix hence the links to the 'en:Foo'
8595 # article.
8596 !! test
8597 Different interwiki prefixes mapping to the same URL
8598 !! wikitext
8599 [[:en:Foo]]
8600
8601 [[:en:Foo|Foo]]
8602
8603 [[wikipedia:Foo]]
8604
8605 [[:wikipedia:Foo|Foo]]
8606
8607 [[wikipedia:en:Foo]]
8608
8609 [[:wikipedia:en:Foo]]
8610
8611 [[ wikiPEdia :Foo]]
8612 !! html/parsoid
8613 <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>
8614
8615 <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>
8616
8617 <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>
8618
8619 <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>
8620
8621 <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>
8622
8623 <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>
8624
8625 <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>
8626 !! end
8627
8628 !! test
8629 Interwiki links that cannot be represented in wiki syntax
8630 !! wikitext
8631 [[meatball:ok]]
8632 [[meatball:ok#foo|ok with fragment]]
8633 [[meatball:ok_as_well?|ok ending with ? mark]]
8634 [http://de.wikipedia.org/wiki/Foo?action=history has query]
8635 [http://de.wikipedia.org/wiki/#foo is just fragment]
8636
8637 !! html/php
8638 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?ok" class="extiw" title="meatball:ok">meatball:ok</a>
8639 <a href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" class="extiw" title="meatball:ok">ok with fragment</a>
8640 <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>
8641 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8642 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a>
8643 </p>
8644 !! html/parsoid
8645 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok" title="meatball:ok">meatball:ok</a>
8646 <a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" title="meatball:ok">ok with fragment</a>
8647 <a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok_as_well?" title="meatball:ok as well?">ok ending with ? mark</a>
8648 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8649 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a></p>
8650 !! end
8651
8652 !! test
8653 Interwiki links: trail
8654 !! wikitext
8655 [[wikipedia:Foo|Ba]]r
8656 !! html/php
8657 <p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
8658 </p>
8659 !! html/parsoid
8660 <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>
8661 !! end
8662
8663 !! test
8664 Local interwiki link
8665 !! options
8666 parsoid=wt2html,wt2wt,html2html
8667 !! wikitext
8668 [[local:Template:Foo]]
8669 !! html/php
8670 <p><a href="/wiki/Template:Foo" title="Template:Foo">local:Template:Foo</a>
8671 </p>
8672 !! html/parsoid
8673 <p><a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">local:Template:Foo</a></p>
8674 !! end
8675
8676 # Parsoid does not mark self-links, by design.
8677 !! test
8678 Local interwiki link: self-link to current page
8679 !! options
8680 title=[[Main Page]]
8681 parsoid=wt2html,wt2wt,html2html
8682 !! wikitext
8683 [[local:Main Page]]
8684 !! html/php
8685 <p><a class="mw-selflink selflink">local:Main Page</a>
8686 </p>
8687 !! html/parsoid
8688 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:Main Page</a></p>
8689 !! end
8690
8691 !! test
8692 Local interwiki link: prefix only (T66167)
8693 !! options
8694 parsoid=wt2html,wt2wt,html2html
8695 !! wikitext
8696 [[local:]]
8697 !! html/php
8698 <p><a href="/wiki/Main_Page" title="Main Page">local:</a>
8699 </p>
8700 !! html/parsoid
8701 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:</a></p>
8702 !! end
8703
8704 !! test
8705 Local interwiki link: with additional interwiki prefix (T63357)
8706 !! options
8707 parsoid=wt2html,wt2wt,html2html
8708 !! wikitext
8709 [[local:meatball:Hello]]
8710 !! html/php
8711 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Hello" class="extiw" title="meatball:Hello">local:meatball:Hello</a>
8712 </p>
8713 !! html/parsoid
8714 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?Hello" title="meatball:Hello">local:meatball:Hello</a></p>
8715 !! end
8716
8717 !! test
8718 Multiple local interwiki link prefixes
8719 !! wikitext
8720 [[local:local:local:local:mi:local:Foo]]
8721 !! options
8722 parsoid=wt2html,wt2wt,html2html
8723 !! html/php
8724 <p><a href="/wiki/Foo" title="Foo">local:local:local:local:mi:local:Foo</a>
8725 </p>
8726 !! html/parsoid
8727 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">local:local:local:local:mi:local:Foo</a></p>
8728 !! end
8729
8730 ###
8731 ### Interlanguage links
8732 ### Language links (so that searching for '### language' matches..)
8733 ###
8734
8735 !! test
8736 Interlanguage link
8737 !! wikitext
8738 Blah blah blah
8739 [[zh:Chinese]]
8740 !! html/php
8741 <p>Blah blah blah
8742 </p>
8743 !! html/parsoid
8744 <p>Blah blah blah</p>
8745 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8746 !! end
8747
8748 ## parsoid html2wt will lose the space variations
8749 !! test
8750 Interlanguage link with spacing
8751 !! options
8752 parsoid=wt2html,wt2wt,html2html
8753 !! wikitext
8754 Blah blah blah
8755 [[ zh : Chinese ]]
8756 !! html/php
8757 <p>Blah blah blah
8758 </p>
8759 !! html/parsoid
8760 <p>Blah blah blah</p>
8761 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8762 !! end
8763
8764 !! test
8765 Double interlanguage link
8766 !! wikitext
8767 Blah blah blah
8768 [[es:Spanish]]
8769 [[zh:Chinese]]
8770 !! html/php
8771 <p>Blah blah blah
8772 </p>
8773 !! html/parsoid
8774 <p>Blah blah blah</p>
8775 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
8776 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8777 !! end
8778
8779 ## parsoid html2wt will lose the space variations
8780 !! test
8781 Interlanguage link variations
8782 !! options
8783 parsoid=wt2html,wt2wt,html2html
8784 !! wikitext
8785 Blah blah blah
8786 [[ es :Spanish]]
8787 [[ ZH :Chinese]]
8788 [[es:Foo_bar]]
8789 !! html/php
8790 <p>Blah blah blah
8791 </p>
8792 !! html/parsoid
8793 <p>Blah blah blah</p>
8794 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish" />
8795 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese" />
8796 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar" />
8797 !! end
8798
8799 !! test
8800 Escaping of interlanguage links (T129218, T156308)
8801 !! wikitext
8802 Blah blah blah
8803 [[:es:Spanish]]
8804 [[ : zh : Chinese ]]
8805 !! html/php
8806 <p>Blah blah blah
8807 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
8808 <a href="http://zh.wikipedia.org/wiki/Chinese" class="extiw" title="zh:Chinese"> zh : Chinese </a>
8809 </p>
8810 !! html/parsoid
8811 <p>Blah blah blah
8812 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
8813 <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh : Chinese </a></p>
8814 !! end
8815
8816 !! test
8817 Multiple colons escaping interlanguage links
8818 !! options
8819 parsoid=wt2html
8820 !! wikitext
8821 [[:es:Spanish]]
8822 [[::es:Spanish]]
8823 [[:::es:Spanish]]
8824 !! html/php
8825 <p><a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
8826 [[::es:Spanish]]
8827 [[:::es:Spanish]]
8828 </p>
8829 !! html/parsoid
8830 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
8831 [[::es:Spanish]]
8832 [[:::es:Spanish]]</p>
8833 !! end
8834
8835 ## parsoid html2wt will normalize the space to _
8836 !! test
8837 Space and question mark encoding in interlanguage links (T95473)
8838 !! options
8839 parsoid=wt2html,wt2wt,html2html
8840 !! wikitext
8841 Blah blah blah
8842 [[es:Foo bar?]]
8843 !! html/php
8844 <p>Blah blah blah
8845 </p>
8846 !! html/parsoid
8847 <p>Blah blah blah</p>
8848 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar%3F" />
8849 !! end
8850
8851 !! test
8852 Interlanguage link, with prefix links
8853 !! options
8854 language=ln
8855 !! wikitext
8856 Blah blah blah
8857 [[zh:Chinese]]
8858 !! html/php
8859 <p>Blah blah blah
8860 </p>
8861 !! html/parsoid
8862 <p>Blah blah blah</p>
8863 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8864 !! end
8865
8866 !! test
8867 Double interlanguage link, with prefix links (T10897)
8868 !! options
8869 language=ln
8870 !! wikitext
8871 Blah blah blah
8872 [[es:Spanish]]
8873 [[zh:Chinese]]
8874 !! html/php
8875 <p>Blah blah blah
8876 </p>
8877 !! html/parsoid
8878 <p>Blah blah blah</p>
8879 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
8880 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8881 !! end
8882
8883 !! test
8884 "Extra" interlanguage links (T34189 / gerrit 111390)
8885 !! wikitext
8886 Blah blah blah
8887 [[mul:Article]]
8888 !! html/php
8889 <p>Blah blah blah
8890 </p>
8891 !! html/parsoid
8892 <p>Blah blah blah</p>
8893 <link rel="mw:PageProp/Language" title="Multilingual" href="http://wikisource.org/wiki/Article"/>
8894 !! end
8895
8896 ## PHP parser tests script needs an update
8897 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
8898 !! test
8899 Language links render as inline links if $wgInterwikiMagic=false
8900 !! options
8901 wgInterwikiMagic=false
8902 parsoid=wt2html,wt2wt,html2html
8903 !! wikitext
8904 Blah blah blah
8905 [[zh:Chinese]]
8906 !! html/parsoid
8907 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
8908 !! end
8909
8910 ## PHP parser tests script needs an update
8911 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
8912 !! test
8913 Language links render as inline links in the Talk namespace
8914 !! options
8915 title=Talk:Foo
8916 parsoid=wt2html,wt2wt,html2html
8917 !! wikitext
8918 Blah blah blah
8919 [[zh:Chinese]]
8920 !! html/parsoid
8921 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
8922 !! end
8923
8924 !! test
8925 Parsoid-specific test: Wikilinks with &nbsp; should RT properly
8926 !! options
8927 language=ln
8928 !! wikitext
8929 [[WW&nbsp;II]]
8930 !! html
8931 <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>
8932 </p>
8933 !! end
8934
8935 !! test
8936 Parsoid T55221: Wikilinks should be properly entity-escaped
8937 !! options
8938 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
8939 !! html/parsoid
8940 <p>He&amp;nbsp;llo <a href="./Foo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
8941 <p>He&amp;nbsp;llo <a href="./He&amp;nbsp;llo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
8942 !! wikitext
8943 He&amp;nbsp;llo [[Foo|He&amp;nbsp;llo]]
8944
8945 He&amp;nbsp;llo He&amp;nbsp;llo
8946 !! html/php
8947 <p>He&amp;nbsp;llo <a href="/wiki/Foo" title="Foo">He&amp;nbsp;llo</a>
8948 </p><p>He&amp;nbsp;llo He&amp;nbsp;llo
8949 </p>
8950 !! end
8951
8952 # html2wt will fail because of title normalization without data-parsoid
8953 !! test
8954 Parsoid: handle constructor well
8955 !! options
8956 parsoid=wt2html,wt2wt
8957 !! wikitext
8958 [[constructor]]
8959
8960 [[constructor:foo]]
8961 !! html/php
8962 <p><a href="/index.php?title=Constructor&amp;action=edit&amp;redlink=1" class="new" title="Constructor (page does not exist)">constructor</a>
8963 </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>
8964 </p>
8965 !! html/parsoid
8966 <p><a rel="mw:WikiLink" href="./Constructor" title="Constructor" data-parsoid='{"stx":"simple","a":{"href":"./Constructor"},"sa":{"href":"constructor"}}'>constructor</a></p>
8967
8968 <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>
8969 !! end
8970
8971 !! article
8972 ko:
8973 !! text
8974 Test.
8975 !! endarticle
8976
8977 # Note that `ko` isn't a known interlanguage prefix
8978 !! test
8979 Parsoid: recognize interlanguage links without a target page
8980 !! options
8981 ill
8982 !! wikitext
8983 [[es:]]
8984
8985 [[ko:]]
8986 !! html/php
8987 es:
8988 !! html/parsoid
8989 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/"/>
8990
8991 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
8992 !! end
8993
8994 # Note that `ko` isn't a known interwiki prefix
8995 !! test
8996 Parsoid: recognize interwiki links without a target page
8997 !! options
8998 parsoid=wt2html,wt2wt,html2html
8999 !! wikitext
9000 [[:es:]]
9001
9002 [[:ko:]]
9003 !! html/php
9004 <p><a href="http://es.wikipedia.org/wiki/" class="extiw" title="es:">es:</a>
9005 </p><p><a href="/wiki/Ko:" title="Ko:">ko:</a>
9006 </p>
9007 !! html/parsoid
9008 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/" title="es:">es:</a></p>
9009 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9010 !! end
9011
9012 !! test
9013 Handle interwiki links pointing to the current wiki as plain wiki links (T47209)
9014 !! wikitext
9015 [[mi:Foo]]
9016 !! html/php
9017 <p><a href="/wiki/Foo" title="Foo">mi:Foo</a>
9018 </p>
9019 !! html/parsoid
9020 <p><a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo"},"sa":{"href":"mi:Foo"}}'>mi:Foo</a></p>
9021 !! end
9022
9023 !! test
9024 Interlanguage link with preceding local interwiki link (T70085)
9025 !! options
9026 parsoid=wt2html,wt2wt,html2html
9027 !! wikitext
9028 Blah blah blah
9029 [[local:es:Spanish]]
9030 !! html/php
9031 <p>Blah blah blah
9032 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">local:es:Spanish</a>
9033 </p>
9034 !! html/parsoid
9035 <p>Blah blah blah
9036 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">local:es:Spanish</a></p>
9037 !! end
9038
9039 !! test
9040 Looks like an interlanguage link, but is actually a local interwiki
9041 !! options
9042 parsoid=wt2html,wt2wt,html2html
9043 !! wikitext
9044 Blah blah blah
9045 [[mi:Template:Foo]]
9046 !! html/php
9047 <p>Blah blah blah
9048 <a href="/wiki/Template:Foo" title="Template:Foo">mi:Template:Foo</a>
9049 </p>
9050 !! html/parsoid
9051 <p>Blah blah blah
9052 <a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">mi:Template:Foo</a></p>
9053 !! end
9054
9055 ###
9056 ### Redirects, Parsoid-only
9057 ###
9058
9059 !! test
9060 1. Simple redirect to page
9061 !! wikitext
9062 #REDIRECT [[Main Page]]
9063 !! html/parsoid
9064 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9065 !! end
9066
9067 !! test
9068 2. Other redirect variants
9069 !! wikitext
9070 #REDIRECT [[Main_Page]]
9071 !! html/parsoid
9072 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Main_Page"},"sa":{"href":"Main_Page"}}'/>
9073 !! end
9074
9075 # Not a valid redirect in PHP (although perhaps it was, once upon a time)
9076 # This tests the Parsoid bail-out code.
9077 !! test
9078 3. Other redirect variants
9079 !! options
9080 parsoid=wt2html
9081 !! wikitext
9082 #REDIRECT [[<nowiki>[[Bar]]</nowiki>]]
9083 !! html/parsoid
9084 <ol><li>REDIRECT [[<span typeof="mw:Nowiki">[[Bar]]</span>]]</li></ol>
9085 !! end
9086
9087 !! test
9088 4. Redirect to a templated destination
9089 !! wikitext
9090 #REDIRECT [[{{echo|Foo}}bar]]
9091 !! html/parsoid
9092 <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"}]]}'/>
9093 !! end
9094
9095 !! test
9096 Empty redirect
9097 !! options
9098 parsoid=wt2html,wt2wt
9099 !! wikitext
9100 #REDIRECT [[]]
9101 !! html/parsoid
9102 <ol>
9103 <li>REDIRECT [[]]</li></ol>
9104 !! end
9105
9106 !! test
9107 Optional colon in #REDIRECT
9108 !! options
9109 # the colon is archaic syntax. we support it for wt2html, but we
9110 # don't care that it roundtrips back to the modern syntax.
9111 parsoid=wt2html,html2html
9112 !! wikitext
9113 #REDIRECT:[[Main Page]]
9114 !! html/parsoid
9115 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9116 !! end
9117
9118 !! test
9119 Whitespace in #REDIRECT with optional colon
9120 !! options
9121 # the colon and gratuitous whitespace is archaic syntax. we support
9122 # it for wt2html, but we don't care that it roundtrips back to the
9123 # modern syntax (without extra whitespace)
9124 parsoid=wt2html,html2html
9125 !! wikitext
9126
9127 #REDIRECT
9128 :
9129 [[Main Page]]
9130 !! html/parsoid
9131 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9132 !! end
9133
9134 !! test
9135 Piped link in #REDIRECT
9136 !! options
9137 # content after piped link is ignored. we support this syntax,
9138 # but don't care that the piped link is lost when we roundtrip this.
9139 parsoid=wt2html
9140 !! wikitext
9141 #REDIRECT [[Main Page|bar]]
9142 !! html/parsoid
9143 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9144 !! end
9145
9146 !! test
9147 Redirect to category (T104502)
9148 !! options
9149 parsoid=wt2html,wt2wt
9150 !! wikitext
9151 #REDIRECT [[Category:Foo]]
9152 !! html/parsoid
9153 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9154 !! end
9155
9156 !! test
9157 Redirect to category with URL encoding (T104502)
9158 !! options
9159 parsoid=wt2html
9160 !! wikitext
9161 #REDIRECT [[Category%3AFoo]]
9162 !! html/parsoid
9163 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9164 !! end
9165
9166 !! test
9167 Redirect to category page
9168 !! wikitext
9169 #REDIRECT [[:Category:Foo]]
9170 !! html/parsoid
9171 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9172 !! end
9173
9174 !! test
9175 Redirect to image page (1)
9176 !! wikitext
9177 #REDIRECT [[File:Wiki.png]]
9178 !! html/parsoid
9179 <link rel="mw:PageProp/redirect" href="./File:Wiki.png"/>
9180 !! end
9181
9182 !! test
9183 Redirect to image page (2)
9184 !! wikitext
9185 #REDIRECT [[Image:Wiki.png]]
9186 !! html/parsoid
9187 <link rel="mw:PageProp/redirect" href="./File:Wiki.png" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./File:Wiki.png"},"sa":{"href":"Image:Wiki.png"}}'/>
9188 !! end
9189
9190 # html2wt disabled because wts serializes as "#REDIRECT [[:en:File:Wiki.png]]"
9191 # Next test confirms this.
9192 !! test
9193 Redirect to language (1) (T104918)
9194 !! options
9195 parsoid=wt2html,wt2wt,html2html
9196 !! wikitext
9197 #REDIRECT [[en:File:Wiki.png]]
9198 !! html/parsoid
9199 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9200 !! end
9201
9202 !! test
9203 Redirect to language (2) (T104918)
9204 !! wikitext
9205 #REDIRECT [[:en:File:Wiki.png]]
9206 !! html/parsoid
9207 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9208 !! end
9209
9210 !! test
9211 Redirect to interwiki (T104918)
9212 !! wikitext
9213 #REDIRECT [[meatball:File:Wiki.png]]
9214 !! html/parsoid
9215 <link rel="mw:PageProp/redirect" href="http://www.usemod.com/cgi-bin/mb.pl?File:Wiki.png"/>
9216 !! end
9217
9218 !! test
9219 Non-English #REDIRECT
9220 !! options
9221 language=is
9222 !! wikitext
9223 #TILVÍSUN [[Main Page]]
9224 !! html/parsoid
9225 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#TILVÍSUN ","a":{"href":"./Main_Page"},"sa":{"href":"Main Page"}}'/>
9226 !! end
9227
9228 !! test
9229 Redirect syntax under text isn't considered a redirect
9230 !! wikitext
9231 some text
9232 #redirect [[Main Page]]
9233 !! html/parsoid
9234 <p>some text</p>
9235 <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>
9236 !! end
9237
9238 !! test
9239 New redirect
9240 !! options
9241 parsoid=html2wt
9242 !! html/parsoid
9243 <p>Foo<link rel="mw:PageProp/redirect" href="./Foo"/></p>
9244 !! wikitext
9245 #REDIRECT [[Foo]]
9246 Foo
9247 !! end
9248
9249 !! test
9250 Redirect followed by block on the same line
9251 !! options
9252 parsoid=wt2html
9253 !! wikitext
9254 #REDIRECT [[Main Page]]<!-- haha -->== hi ==
9255 !! html/parsoid
9256 <link rel="mw:PageProp/redirect" href="./Main_Page"/><!-- haha --><h2 id="hi"> hi </h2>
9257 !! end
9258
9259 !! test
9260 Redirect followed by a newline
9261 !! wikitext
9262 #REDIRECT [[Main Page]]
9263 A newline
9264 !! html/parsoid
9265 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9266 <p>A newline</p>
9267 !! end
9268
9269 !! test
9270 Redirect followed by multiple newlines
9271 !! wikitext
9272 #REDIRECT [[Main Page]]
9273
9274
9275 A newline
9276 !! html/parsoid
9277 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9278
9279 <p><br/>
9280 A newline</p>
9281 !! end
9282
9283 !! test
9284 Drop duplicate redirects
9285 !! options
9286 parsoid=html2wt
9287 !! html/parsoid
9288 <link rel="mw:PageProp/redirect" href="./Foo"/>
9289 <link rel="mw:PageProp/redirect" href="./Bar"/>
9290 <link rel="mw:PageProp/redirect" href="./Baz"/>
9291 !! wikitext
9292 #REDIRECT [[Foo]]
9293 !! end
9294
9295 ##
9296 ## XHTML tidiness
9297 ###
9298
9299 !! test
9300 <br> to <br />
9301 !! wikitext
9302 1<br>2<br />3
9303 !! html
9304 <p>1<br />2<br />3
9305 </p>
9306 !! end
9307
9308 !! test
9309 Broken br tag sanitization
9310 !! wikitext
9311 </br>
9312 !! html/php
9313 <p>&lt;/br&gt;
9314 </p>
9315 !! end
9316
9317 # TODO: Fix html2html mode (T53055)!
9318 !! test
9319 Parsoid: Broken br tag recognition
9320 !! options
9321 parsoid=wt2html
9322 !! wikitext
9323 </br>
9324
9325 <br/ >
9326 !! html+tidy
9327 <p><br />
9328 </p><p><br />
9329 </p>
9330 !! end
9331
9332 !! test
9333 Incorrecly removing closing slashes from correctly formed XHTML
9334 !! wikitext
9335 <br style="clear:both;" />
9336 !! html
9337 <p><br style="clear:both;" />
9338 </p>
9339 !! end
9340
9341 !! test
9342 Failing to transform badly formed HTML into correct XHTML
9343 !! wikitext
9344 <br style="clear: left;">
9345 <br style="clear: right;">
9346 <br style="clear: both;">
9347 !! html
9348 <p><br style="clear: left;" />
9349 <br style="clear: right;" />
9350 <br style="clear: both;" />
9351 </p>
9352 !!end
9353
9354 ## FIXME: Is Parsoid's acceptance of self-closing html-tags
9355 ## a feature or a bug? See https://phabricator.wikimedia.org/T76962
9356 !! test
9357 Handling html with a div self-closing tag
9358 !! wikitext
9359 <div title />
9360 <div title/>
9361 <div title/ >
9362 <div title=bar />
9363 <div title=bar/>
9364 <div title=bar/ >
9365 !! html/php
9366 <p>&lt;div title /&gt;
9367 &lt;div title/&gt;
9368 </p>
9369 <div>
9370 <p>&lt;div title=bar /&gt;
9371 &lt;div title=bar/&gt;
9372 </p>
9373 <div title="bar/"></div>
9374 </div>
9375
9376 !! html/parsoid
9377 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9378 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9379 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9380 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9381 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9382 <div title="bar/" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></div>
9383 !! end
9384
9385 !! test
9386 Handling html with a br self-closing tag
9387 !! wikitext
9388 <br title />
9389 <br title/>
9390 <br title/ >
9391 <br title=bar />
9392 <br title=bar/>
9393 <br title=bar/ >
9394 !! html/php
9395 <p><br title="" />
9396 <br title="" />
9397 <br />
9398 <br title="bar" />
9399 <br title="bar" />
9400 <br title="bar/" />
9401 </p>
9402 !! html/parsoid
9403 <p><br title="" />
9404 <br title="" />
9405 <br title="" />
9406 <br title="bar" />
9407 <br title="bar" />
9408 <br title="bar/" />
9409 </p>
9410 !! end
9411
9412 !! test
9413 Horizontal ruler (should it add that extra space?)
9414 !! wikitext
9415 <hr>
9416 <hr >
9417 foo <hr
9418 > bar
9419 !! html+tidy
9420 <hr />
9421 <hr /><p>
9422 foo </p><hr /><p> bar
9423 </p>
9424 !! end
9425
9426 !! test
9427 Horizontal ruler -- 4+ dashes render hr
9428 !! wikitext
9429 ----
9430 !! html
9431 <hr />
9432
9433 !! end
9434
9435 !! test
9436 Horizontal ruler -- eats additional dashes on the same line
9437 !! wikitext
9438 ---------
9439 !! html
9440 <hr />
9441
9442 !! end
9443
9444 !! test
9445 Horizontal ruler -- does not collapse dashes on consecutive lines
9446 !! wikitext
9447 ----
9448 ----
9449 !! html
9450 <hr />
9451 <hr />
9452
9453 !! end
9454
9455 !! test
9456 Horizontal ruler -- <4 dashes render as plain text
9457 !! wikitext
9458 ---
9459 !! html
9460 <p>---
9461 </p>
9462 !! end
9463
9464 !! test
9465 Horizontal ruler -- Supports content following dashes on same line
9466 !! wikitext
9467 ---- Foo
9468 !! html
9469 <hr /> Foo
9470
9471 !! html+tidy
9472 <hr /><p> Foo
9473 </p>
9474 !! end
9475
9476 ###
9477 ### Block-level elements
9478 ###
9479 !! test
9480 Common list
9481 !! wikitext
9482 *Common list
9483 * item 2
9484 *item 3
9485 !! html
9486 <ul><li>Common list</li>
9487 <li> item 2</li>
9488 <li>item 3</li></ul>
9489
9490 !! end
9491
9492 !! test
9493 Numbered list
9494 !! wikitext
9495 #Numbered list
9496 #item 2
9497 # item 3
9498 !! html
9499 <ol><li>Numbered list</li>
9500 <li>item 2</li>
9501 <li> item 3</li></ol>
9502
9503 !! end
9504
9505 !! test
9506 Mixed list
9507 !! wikitext
9508 *Mixed list
9509 *# with numbers
9510 ** and bullets
9511 *# and numbers
9512 *bullets again
9513 **bullet level 2
9514 ***bullet level 3
9515 ***#Number on level 4
9516 **bullet level 2
9517 **#Number on level 3
9518 **#Number on level 3
9519 *#number level 2
9520 *Level 1
9521 *** Level 3
9522 #** Level 3, but ordered
9523 !! html
9524 <ul><li>Mixed list
9525 <ol><li> with numbers</li></ol>
9526 <ul><li> and bullets</li></ul>
9527 <ol><li> and numbers</li></ol></li>
9528 <li>bullets again
9529 <ul><li>bullet level 2
9530 <ul><li>bullet level 3
9531 <ol><li>Number on level 4</li></ol></li></ul></li>
9532 <li>bullet level 2
9533 <ol><li>Number on level 3</li>
9534 <li>Number on level 3</li></ol></li></ul>
9535 <ol><li>number level 2</li></ol></li>
9536 <li>Level 1
9537 <ul><li><ul><li> Level 3</li></ul></li></ul></li></ul>
9538 <ol><li><ul><li><ul><li> Level 3, but ordered</li></ul></li></ul></li></ol>
9539
9540 !! end
9541
9542 !! test
9543 1. Nested mixed wikitext and html list
9544 !! wikitext
9545 * hi
9546 * <ul><li>ho</li></ul>
9547 * hi
9548 ** ho
9549 !! html/php
9550 <ul><li> hi</li>
9551 <li> <ul><li>ho</li></ul></li>
9552 <li> hi
9553 <ul><li> ho</li></ul></li></ul>
9554
9555 !! html/parsoid
9556 <ul><li> hi</li>
9557 <li> <ul data-parsoid='{"stx":"html"}'><li data-parsoid='{"stx":"html"}'>ho</li></ul></li>
9558 <li> hi
9559 <ul><li> ho</li></ul></li></ul>
9560 !! end
9561
9562 !! test
9563 2. Nested mixed wikitext and html list (incompatible)
9564 !! wikitext
9565 ; hi
9566 : {{echo|<li>ho</li>}}
9567 !! html/php
9568 <dl><dt> hi</dt>
9569 <dd> <li>ho</li></dd></dl>
9570
9571 !! html/parsoid
9572 <dl><dt> hi</dt>
9573 <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>
9574 !! end
9575
9576 !! test
9577 Nested lists 1
9578 !! wikitext
9579 *foo
9580 **bar
9581 !! html
9582 <ul><li>foo
9583 <ul><li>bar</li></ul></li></ul>
9584
9585 !! end
9586
9587 !! test
9588 Nested lists 2
9589 !! wikitext
9590 **foo
9591 *bar
9592 !! html
9593 <ul><li><ul><li>foo</li></ul></li>
9594 <li>bar</li></ul>
9595
9596 !! end
9597
9598 !! test
9599 Nested lists 3 (first element empty)
9600 !! wikitext
9601 *
9602 **bar
9603 !! html
9604 <ul><li>
9605 <ul><li>bar</li></ul></li></ul>
9606
9607 !! end
9608
9609 !! test
9610 Nested lists 4 (first element empty)
9611 !! wikitext
9612 **
9613 *bar
9614 !! html
9615 <ul><li><ul><li></li></ul></li>
9616 <li>bar</li></ul>
9617
9618 !! end
9619
9620 !! test
9621 Nested lists 5 (both elements empty)
9622 !! wikitext
9623 **
9624 *
9625 !! html
9626 <ul><li><ul><li></li></ul></li>
9627 <li></li></ul>
9628
9629 !! end
9630
9631 !! test
9632 Nested lists 6 (both elements empty)
9633 !! wikitext
9634 *
9635 **
9636 !! html
9637 <ul><li>
9638 <ul><li></li></ul></li></ul>
9639
9640 !! end
9641
9642 !! test
9643 Nested lists 7 (skip initial nesting levels)
9644 !! wikitext
9645 *** foo
9646 !! html
9647 <ul><li><ul><li><ul><li> foo</li></ul></li></ul></li></ul>
9648
9649 !! end
9650
9651 !! test
9652 Nested lists 8 (multiple nesting transitions)
9653 !! wikitext
9654 * foo
9655 *** bar
9656 ** baz
9657 * boo
9658 !! html
9659 <ul><li> foo
9660 <ul><li><ul><li> bar</li></ul></li>
9661 <li> baz</li></ul></li>
9662 <li> boo</li></ul>
9663
9664 !! end
9665
9666 !! test
9667 Nested lists 9 (extension interaction)
9668 !! options
9669 parsoid
9670 !! wikitext
9671 *<references />
9672 !! html/parsoid
9673 <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>
9674 !! end
9675
9676 !! test
9677 1. Lists with start-of-line-transparent tokens before bullets: Comments
9678 !! wikitext
9679 *foo
9680 *<!--cmt-->bar
9681 <!--cmt-->*baz
9682 !! html
9683 <ul><li>foo</li>
9684 <li>bar</li>
9685 <li>baz</li></ul>
9686
9687 !! end
9688
9689 !! test
9690 2. Lists with start-of-line-transparent tokens before bullets: Template close
9691 !! wikitext
9692 *foo {{echo|bar
9693 }}*baz
9694 !! html
9695 <ul><li>foo bar</li>
9696 <li>baz</li></ul>
9697
9698 !! end
9699
9700 !! test
9701 List items are not parsed correctly following a <pre> block (T2785)
9702 !! wikitext
9703 * <pre>foo</pre>
9704 * <pre>bar</pre>
9705 * zar
9706 !! html/php
9707 <ul><li> <pre>foo</pre></li>
9708 <li> <pre>bar</pre></li>
9709 <li> zar</li></ul>
9710
9711 !! html/parsoid
9712 <ul><li> <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre></li>
9713 <li> <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"bar"}}'>bar</pre></li>
9714 <li> zar</li></ul>
9715 !! end
9716
9717 !! test
9718 List items from template
9719 !! wikitext
9720
9721 {{inner list}}
9722 * item 2
9723
9724 * item 0
9725 {{inner list}}
9726 * item 2
9727
9728 * item 0
9729 * notSOL{{inner list}}
9730 * item 2
9731 !! html
9732 <ul><li> item 1</li>
9733 <li> item 2</li></ul>
9734 <ul><li> item 0</li>
9735 <li> item 1</li>
9736 <li> item 2</li></ul>
9737 <ul><li> item 0</li>
9738 <li> notSOL</li>
9739 <li> item 1</li>
9740 <li> item 2</li></ul>
9741
9742 !! end
9743
9744 !! test
9745 List interrupted by empty line or heading
9746 !! wikitext
9747 * foo
9748
9749 ** bar
9750 == A heading ==
9751 * Another list item
9752 !! html
9753 <ul><li> foo</li></ul>
9754 <ul><li><ul><li> bar</li></ul></li></ul>
9755 <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>
9756 <ul><li> Another list item</li></ul>
9757
9758 !!end
9759
9760 !!test
9761 Multiple list tags generated by templates
9762 !! wikitext
9763 {{echo|<li>}}a
9764 {{echo|<li>}}b
9765 {{echo|<li>}}c
9766 !! html
9767 <li>a
9768 <li>b
9769 <li>c</li>
9770 </li>
9771 </li>
9772
9773 !! html+tidy
9774 <li>a
9775 </li><li>b
9776 </li><li>c
9777 </li>
9778 !!end
9779
9780 !!test
9781 Single-comment whitespace lines dont break lists, and neither do multi-comment whitespace lines
9782 !! wikitext
9783 *a
9784 <!--This line will NOT split the list-->
9785 *b
9786 <!--This line will NOT split the list either-->
9787 *c
9788 <!--foo--> <!----> <!--This line NOT split the list either-->
9789 *d
9790 !! html
9791 <ul><li>a</li>
9792 <li>b</li>
9793 <li>c</li>
9794 <li>d</li></ul>
9795
9796 !!end
9797
9798 !!test
9799 Replacing whitespace with tabs still doesn't break the list (gerrit 78327)
9800 !! wikitext
9801 *a
9802 <!--This line will NOT split the list-->
9803 *b
9804 <!--This line will NOT split the list either-->
9805 *c
9806 <!--foo--> <!----> <!--This line NOT split the list
9807 either-->
9808 *d
9809 !! html
9810 <ul><li>a</li>
9811 <li>b</li>
9812 <li>c</li>
9813 <li>d</li></ul>
9814
9815 !!end
9816
9817 # FIXME: Parsoid has a dedicated DOM pass to mimic this Tidy-specific li-hack
9818 # That pass could possibly be removed.
9819 !!test
9820 Test the li-hack (a hack from Tidy days, but doesn't work as advertised with Remex)
9821 !!options
9822 parsoid=wt2html,wt2wt
9823 !! wikitext
9824 * foo
9825 * <li>li-hack
9826 * {{echo|<li>templated li-hack}}
9827 * <!--foo--> <li> unsupported li-hack with preceding comments
9828
9829 <ul>
9830 <li><li>not a li-hack
9831 </li>
9832 </ul>
9833 !! html+tidy
9834 <ul><li> foo</li>
9835 <li class="mw-empty-elt"> </li><li>li-hack</li>
9836 <li class="mw-empty-elt"> </li><li>templated li-hack</li>
9837 <li class="mw-empty-elt"> </li><li> unsupported li-hack with preceding comments</li></ul>
9838 <ul>
9839 <li class="mw-empty-elt"></li><li>not a li-hack
9840 </li>
9841 </ul>
9842 !! html/parsoid
9843 <ul><li> foo</li>
9844 <li data-parsoid='{"stx":"html","autoInsertedEnd":true,"liHackSrc":"* "}'>li-hack</li>
9845 <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>
9846 <li data-parsoid='{"autoInsertedEnd":true}'> <!--foo--> </li><li data-parsoid='{"stx":"html","autoInsertedEnd":true}'> unsupported li-hack with preceding comments</li></ul>
9847
9848 <ul data-parsoid='{"stx":"html"}'>
9849 <li class="mw-empty-elt" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></li><li data-parsoid='{"stx":"html"}'>not a li-hack
9850 </li>
9851 </ul>
9852
9853 !!end
9854
9855 !! test
9856 Parsoid: Make sure nested lists are serialized on their own line even if HTML contains no newlines
9857 !! options
9858 parsoid
9859 !! wikitext
9860 # foo
9861 ## bar
9862 * foo
9863 ** bar
9864 : foo
9865 :: bar
9866 !! html
9867 <ol>
9868 <li> foo<ol>
9869 <li> bar</li>
9870 </ol></li>
9871 </ol><ul>
9872 <li> foo<ul>
9873 <li> bar</li>
9874 </ul></li>
9875 </ul><dl>
9876 <dd> foo<dl>
9877 <dd> bar</dd>
9878 </dl></dd>
9879 </dl>
9880 !! end
9881
9882 !! test
9883 Parsoid: Test of whitespace serialization with Templated bullets
9884 !! options
9885 parsoid
9886 !! wikitext
9887 * {{bullet}}
9888 !! html/parsoid
9889 <ul>
9890 <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>
9891 </ul>
9892 !! end
9893
9894 # ------------------------------------------------------------------------
9895 # The next set of tests are about Parsoid's ability to handle badly nested
9896 # tags (parse, minimize scope of fixup, and roundtrip back)
9897 # ------------------------------------------------------------------------
9898
9899 # Remex and Parsoid output stems from list handling diffs because Parsoid & PHP parser.
9900 # Parsoid's list handling is more aware of block structure.
9901 !! test
9902 Unbalanced closing block tags break a list
9903 !! wikitext
9904 <div>
9905 *a</div><div>
9906 *b</div>
9907 !! html+tidy
9908 <div>
9909 <ul><li>a</li></ul></div><div>
9910 <li>b</li></div>
9911 !! html+parsoid
9912 <div><ul>
9913 <li>a</li>
9914 </ul></div>
9915 <div><ul>
9916 <li>b</li>
9917 </ul></div>
9918 !! end
9919
9920 !! test
9921 Unbalanced closing non-block tags don't break a list
9922 !! wikitext
9923 <span>
9924 *a</span><span>
9925 *b</span>
9926 !! html/php+tidy
9927 <p><span>
9928 </span></p>
9929 <ul><li>a<span></span></li>
9930 <li>b</li></ul>
9931 !! html/parsoid
9932 <span>
9933 <ul>
9934 <li>a<span></span></li>
9935 <li>b</li>
9936 </ul>
9937 </span>
9938 !! end
9939
9940 # Parsoid does some post-dom-building cleanup
9941 # which is why its output differs from Remex.
9942 !! test
9943 Unclosed formatting tags that straddle lists are closed and reopened
9944 !! options
9945 parsoid=wt2html,wt2wt,html2html
9946 !! wikitext
9947 # <s> a
9948 # b </s>
9949 !! html/php+tidy
9950 <ol><li> <s> a</s></li><s>
9951 </s><li><s> b </s></li></ol>
9952 !! html/parsoid
9953 <ol><li> <s> a</s><s></s></li>
9954 <li><s> b </s></li></ol>
9955 !! end
9956
9957 # Output is ugly because of all the misnested tag fixups.
9958 # Remex is wrapping p-tags around empty elements.
9959 # Parsoid has special-case handling of this pattern of
9960 # wrapping lists in formatting tags.
9961 # FIXME: Should we remove this code from Parsoid? Or add
9962 # special support in Remex? If the latter, maybe just wait
9963 # for Parsoid to become the default parser.
9964 # See T70395.
9965 !!test
9966 1. List embedded in a formatting tag
9967 !! wikitext
9968 <small>
9969 * foo
9970 </small>
9971 !! html/php+tidy
9972 <p><small>
9973 </small></p><small><ul><li> foo</li></ul></small><small></small><p><small></small>
9974 </p>
9975 !! html/parsoid
9976 <small>
9977 <ul>
9978 <li> foo</li>
9979 </ul>
9980 </small>
9981 !!end
9982
9983 # Output is ugly because of all the misnested tag fixups
9984 # Remex is wrapping p-tags around empty elements.
9985 # Parsoid has code that strips useless p-tags.
9986 !!test
9987 2. List embedded in a formatting tag in a misnested way
9988 !! wikitext
9989 <small>
9990 *a
9991 *b</small>
9992 !! html/php+tidy
9993 <p><small>
9994 </small></p><small></small><ul><small><li>a</li>
9995 </small><li><small>b</small></li></ul>
9996 !! html/parsoid
9997 <small></small>
9998 <ul><small>
9999 <li>a</li>
10000 </small>
10001 <li><small>b</small></li>
10002 </ul>
10003 !!end
10004
10005 !! test
10006 Table with missing opening <tr> tag
10007 !! options
10008 parsoid=wt2html,wt2wt
10009 !! wikitext
10010 <table>
10011 <td>foo</td>
10012 </tr>
10013 </table>
10014 !! html+tidy
10015 <table>
10016 <tbody><tr><td>foo</td>
10017 </tr>
10018 </tbody></table>
10019 !! end
10020
10021 ###
10022 ### Magic Words
10023 ###
10024
10025 # Note that the current date is hard-coded as
10026 # 1970-01-01T00:02:03Z (a Thursday)
10027 # when running parser tests. The timezone is also fixed to GMT, so
10028 # local date will be identical to current date.
10029
10030 !! test
10031 Magic Word: {{CURRENTDAY}}
10032 !! wikitext
10033 {{CURRENTDAY}}
10034 !! html
10035 <p>1
10036 </p>
10037 !! end
10038
10039 !! test
10040 Magic Word: {{CURRENTDAY2}}
10041 !! wikitext
10042 {{CURRENTDAY2}}
10043 !! html
10044 <p>01
10045 </p>
10046 !! end
10047
10048 !! test
10049 Magic Word: {{CURRENTDAYNAME}}
10050 !! wikitext
10051 {{CURRENTDAYNAME}}
10052 !! html
10053 <p>Thursday
10054 </p>
10055 !! end
10056
10057 !! test
10058 Magic Word: {{CURRENTDOW}}
10059 !! wikitext
10060 {{CURRENTDOW}}
10061 !! html
10062 <p>4
10063 </p>
10064 !! end
10065
10066 !! test
10067 Magic Word: {{CURRENTMONTH}}
10068 !! wikitext
10069 {{CURRENTMONTH}}
10070 !! html
10071 <p>01
10072 </p>
10073 !! end
10074
10075 !! test
10076 Magic Word: {{CURRENTMONTH1}}
10077 !! wikitext
10078 {{CURRENTMONTH1}}
10079 !! html
10080 <p>1
10081 </p>
10082 !! end
10083
10084 !! test
10085 Magic Word: {{CURRENTMONTHABBREV}}
10086 !! wikitext
10087 {{CURRENTMONTHABBREV}}
10088 !! html
10089 <p>Jan
10090 </p>
10091 !! end
10092
10093 !! test
10094 Magic Word: {{CURRENTMONTHNAME}}
10095 !! wikitext
10096 {{CURRENTMONTHNAME}}
10097 !! html
10098 <p>January
10099 </p>
10100 !! end
10101
10102 !! test
10103 Magic Word: {{CURRENTMONTHNAMEGEN}}
10104 !! wikitext
10105 {{CURRENTMONTHNAMEGEN}}
10106 !! html
10107 <p>January
10108 </p>
10109 !! end
10110
10111 !! test
10112 Magic Word: {{CURRENTTIME}}
10113 !! wikitext
10114 {{CURRENTTIME}}
10115 !! html
10116 <p>00:02
10117 </p>
10118 !! end
10119
10120 !! test
10121 Magic Word: {{CURRENTHOUR}}
10122 !! wikitext
10123 {{CURRENTHOUR}}
10124 !! html
10125 <p>00
10126 </p>
10127 !! end
10128
10129 !! test
10130 Magic Word: {{CURRENTWEEK}} (T6594)
10131 !! wikitext
10132 {{CURRENTWEEK}}
10133 !! html
10134 <p>1
10135 </p>
10136 !! end
10137
10138 !! test
10139 Magic Word: {{CURRENTYEAR}}
10140 !! wikitext
10141 {{CURRENTYEAR}}
10142 !! html
10143 <p>1970
10144 </p>
10145 !! end
10146
10147 !! test
10148 Magic Word: {{CURRENTTIMESTAMP}}
10149 !! wikitext
10150 {{CURRENTTIMESTAMP}}
10151 !! html
10152 <p>19700101000203
10153 </p>
10154 !! end
10155
10156 !! test
10157 Magic Words LOCAL (UTC)
10158 !! wikitext
10159 * {{LOCALMONTH}}
10160 * {{LOCALMONTH1}}
10161 * {{LOCALMONTHNAME}}
10162 * {{LOCALMONTHNAMEGEN}}
10163 * {{LOCALMONTHABBREV}}
10164 * {{LOCALDAY}}
10165 * {{LOCALDAY2}}
10166 * {{LOCALDAYNAME}}
10167 * {{LOCALYEAR}}
10168 * {{LOCALTIME}}
10169 * {{LOCALHOUR}}
10170 * {{LOCALWEEK}}
10171 * {{LOCALDOW}}
10172 * {{LOCALTIMESTAMP}}
10173 !! html
10174 <ul><li> 01</li>
10175 <li> 1</li>
10176 <li> January</li>
10177 <li> January</li>
10178 <li> Jan</li>
10179 <li> 1</li>
10180 <li> 01</li>
10181 <li> Thursday</li>
10182 <li> 1970</li>
10183 <li> 00:02</li>
10184 <li> 00</li>
10185 <li> 1</li>
10186 <li> 4</li>
10187 <li> 19700101000203</li></ul>
10188
10189 !! end
10190
10191 !! test
10192 Magic Word: {{FULLPAGENAME}}
10193 !! options
10194 title=[[User:Ævar Arnfjörð Bjarmason]]
10195 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10196 !! wikitext
10197 {{FULLPAGENAME}}
10198 !! html/*
10199 <p>User:Ævar Arnfjörð Bjarmason
10200 </p>
10201 !! end
10202
10203 !! test
10204 Magic Word: {{FULLPAGENAMEE}}
10205 !! options
10206 title=[[User:Ævar Arnfjörð Bjarmason]]
10207 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10208 !! wikitext
10209 {{FULLPAGENAMEE}}
10210 !! html/*
10211 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10212 </p>
10213 !! end
10214
10215 !! test
10216 Magic Word: {{TALKSPACE}}
10217 !! options
10218 title=[[User:Ævar Arnfjörð Bjarmason]]
10219 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10220 !! wikitext
10221 {{TALKSPACE}}
10222 !! html/*
10223 <p>User talk
10224 </p>
10225 !! end
10226
10227 !! test
10228 Magic Word: {{TALKSPACE}}, same namespace
10229 !! options
10230 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10231 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10232 !! wikitext
10233 {{TALKSPACE}}
10234 !! html/*
10235 <p>User talk
10236 </p>
10237 !! end
10238
10239 !! test
10240 Magic Word: {{TALKSPACE}}, main namespace
10241 !! options
10242 title=[[Parser Test]]
10243 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10244 !! wikitext
10245 {{TALKSPACE}}
10246 !! html/*
10247 <p>Talk
10248 </p>
10249 !! end
10250
10251 !! test
10252 Magic Word: {{TALKSPACEE}}
10253 !! options
10254 title=[[User:Ævar Arnfjörð Bjarmason]]
10255 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10256 !! wikitext
10257 {{TALKSPACEE}}
10258 !! html/*
10259 <p>User_talk
10260 </p>
10261 !! end
10262
10263 !! test
10264 Magic Word: {{SUBJECTSPACE}}
10265 !! options
10266 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10267 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10268 !! wikitext
10269 {{SUBJECTSPACE}}
10270 !! html/*
10271 <p>User
10272 </p>
10273 !! end
10274
10275 !! test
10276 Magic Word: {{SUBJECTSPACE}}, same namespace
10277 !! options
10278 title=[[User:Ævar Arnfjörð Bjarmason]]
10279 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10280 !! wikitext
10281 {{SUBJECTSPACE}}
10282 !! html/*
10283 <p>User
10284 </p>
10285 !! end
10286
10287 !! test
10288 Magic Word: {{SUBJECTSPACE}}, main namespace
10289 !! options
10290 title=[[Parser Test]]
10291 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10292 !! wikitext
10293 {{SUBJECTSPACE}}
10294 !! html/*
10295
10296 !! end
10297
10298 !! test
10299 Magic Word: {{SUBJECTSPACEE}}
10300 !! options
10301 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10302 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10303 !! wikitext
10304 {{SUBJECTSPACEE}}
10305 !! html/*
10306 <p>User
10307 </p>
10308 !! end
10309
10310 !! test
10311 Magic Word: {{NAMESPACE}}
10312 !! options
10313 title=[[User:Ævar Arnfjörð Bjarmason]]
10314 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10315 !! wikitext
10316 {{NAMESPACE}}
10317 !! html/*
10318 <p>User
10319 </p>
10320 !! end
10321
10322 !! test
10323 Magic Word: {{NAMESPACEE}}
10324 !! options
10325 title=[[User:Ævar Arnfjörð Bjarmason]]
10326 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10327 !! wikitext
10328 {{NAMESPACEE}}
10329 !! html/*
10330 <p>User
10331 </p>
10332 !! end
10333
10334 !! test
10335 Magic Word: {{NAMESPACENUMBER}}
10336 !! options
10337 title=[[User:Ævar Arnfjörð Bjarmason]]
10338 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10339 !! wikitext
10340 {{NAMESPACENUMBER}}
10341 !! html/*
10342 <p>2
10343 </p>
10344 !! end
10345
10346 !! test
10347 Magic Word: {{SUBPAGENAME}}
10348 !! options
10349 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10350 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10351 !! wikitext
10352 {{SUBPAGENAME}}
10353 !! html/*
10354 <p>sub ö
10355 </p>
10356 !! end
10357
10358 !! test
10359 Magic Word: {{SUBPAGENAMEE}}
10360 !! options
10361 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10362 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10363 !! wikitext
10364 {{SUBPAGENAMEE}}
10365 !! html/*
10366 <p>sub_%C3%B6
10367 </p>
10368 !! end
10369
10370 !! test
10371 Magic Word: {{ROOTPAGENAME}}
10372 !! options
10373 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10374 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10375 !! wikitext
10376 {{ROOTPAGENAME}}
10377 !! html/*
10378 <p>Ævar Arnfjörð Bjarmason
10379 </p>
10380 !! end
10381
10382 !! test
10383 Magic Word: {{ROOTPAGENAMEE}}
10384 !! options
10385 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10386 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10387 !! wikitext
10388 {{ROOTPAGENAMEE}}
10389 !! html/*
10390 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10391 </p>
10392 !! end
10393
10394 !! test
10395 Magic Word: {{BASEPAGENAME}}
10396 !! options
10397 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10398 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10399 !! wikitext
10400 {{BASEPAGENAME}}
10401 !! html/*
10402 <p>Ævar Arnfjörð Bjarmason
10403 </p>
10404 !! end
10405
10406 !! test
10407 Magic Word: {{BASEPAGENAMEE}}
10408 !! options
10409 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10410 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10411 !! wikitext
10412 {{BASEPAGENAMEE}}
10413 !! html/*
10414 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10415 </p>
10416 !! end
10417
10418 !! test
10419 Magic Word: {{TALKPAGENAME}}
10420 !! options
10421 title=[[User:Ævar Arnfjörð Bjarmason]]
10422 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10423 !! wikitext
10424 {{TALKPAGENAME}}
10425 !! html/*
10426 <p>User talk:Ævar Arnfjörð Bjarmason
10427 </p>
10428 !! end
10429
10430 !! test
10431 Magic Word: {{TALKPAGENAMEE}}
10432 !! options
10433 title=[[User:Ævar Arnfjörð Bjarmason]]
10434 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10435 !! wikitext
10436 {{TALKPAGENAMEE}}
10437 !! html/*
10438 <p>User_talk:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10439 </p>
10440 !! end
10441
10442 !! test
10443 Magic Word: {{SUBJECTPAGENAME}}
10444 !! options
10445 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10446 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10447 !! wikitext
10448 {{SUBJECTPAGENAME}}
10449 !! html/*
10450 <p>User:Ævar Arnfjörð Bjarmason
10451 </p>
10452 !! end
10453
10454 !! test
10455 Magic Word: {{SUBJECTPAGENAMEE}}
10456 !! options
10457 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10458 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10459 !! wikitext
10460 {{SUBJECTPAGENAMEE}}
10461 !! html/*
10462 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10463 </p>
10464 !! end
10465
10466 !! test
10467 Magic Word: {{NUMBEROFFILES}}
10468 !! options
10469 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10470 !! wikitext
10471 {{NUMBEROFFILES}}
10472 !! html/*
10473 <p>7
10474 </p>
10475 !! end
10476
10477 !! test
10478 Magic Word: {{PAGENAME}}
10479 !! options
10480 title=[[User:Ævar Arnfjörð Bjarmason]]
10481 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10482 !! wikitext
10483 {{PAGENAME}}
10484 !! html/*
10485 <p>Ævar Arnfjörð Bjarmason
10486 </p>
10487 !! end
10488
10489 !! test
10490 Magic Word: {{PAGENAME}} with metacharacters
10491 !! options
10492 title=[['foo & bar = baz']]
10493 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10494 !! wikitext
10495 ''{{PAGENAME}}''
10496 !! html+tidy
10497 <p><i>&#39;foo &#38; bar &#61; baz&#39;</i>
10498 </p>
10499 !! end
10500
10501 !! test
10502 Magic Word: {{PAGENAME}} with metacharacters (T28781)
10503 !! options
10504 title=[[*RFC 1234 http://example.com/]]
10505 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10506 !! wikitext
10507 {{PAGENAME}}
10508 !! html+tidy
10509 <p>&#42;RFC&#32;1234 http&#58;//example.com/
10510 </p>
10511 !! end
10512
10513 !! test
10514 Magic Word: {{PAGENAMEE}}
10515 !! options
10516 title=[[User:Ævar Arnfjörð Bjarmason]]
10517 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10518 !! wikitext
10519 {{PAGENAMEE}}
10520 !! html/*
10521 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10522 </p>
10523 !! end
10524
10525 !! test
10526 Magic Word: {{PAGENAMEE}} with metacharacters (T28781)
10527 !! options
10528 title=[[*RFC 1234 http://example.com/]]
10529 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10530 !! wikitext
10531 {{PAGENAMEE}}
10532 !! html+tidy
10533 <p>&#42;RFC_1234_http&#58;//example.com/
10534 </p>
10535 !! end
10536
10537 !! test
10538 Magic Word: {{REVISIONID}}
10539 !! options
10540 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10541 showflags
10542 !! wikitext
10543 {{REVISIONID}}
10544 !! html/*
10545 <p>1337
10546 </p>
10547 flags=vary-revision-id
10548 !! end
10549
10550 !! test
10551 Magic Word: {{SCRIPTPATH}}
10552 !! options
10553 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10554 !! wikitext
10555 {{SCRIPTPATH}}
10556 !! html/*
10557
10558 !! end
10559
10560 !! test
10561 Magic Word: {{STYLEPATH}}
10562 !! options
10563 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10564 !! wikitext
10565 {{STYLEPATH}}
10566 !! html/*
10567 <p>/skins
10568 </p>
10569 !! end
10570
10571 !! test
10572 Magic Word: {{SERVER}}
10573 !! options
10574 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10575 !! wikitext
10576 {{SERVER}}
10577 !! html/*
10578 <p><a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10579 </p>
10580 !! end
10581
10582 !! test
10583 Magic Word: {{SERVERNAME}}
10584 !! options
10585 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10586 !! wikitext
10587 {{SERVERNAME}}
10588 !! html/*
10589 <p>example.org
10590 </p>
10591 !! end
10592
10593 !! test
10594 Magic Word: {{SITENAME}}
10595 !! options
10596 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10597 !! wikitext
10598 {{SITENAME}}
10599 !! html/*
10600 <p>MediaWiki
10601 </p>
10602 !! end
10603
10604 !! test
10605 Magic Word: {{PAGELANGUAGE}}
10606 !! options
10607 language=fr
10608 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10609 !! wikitext
10610 {{PAGELANGUAGE}}
10611 !! html/*
10612 <p>fr
10613 </p>
10614 !! end
10615
10616 !! test
10617 Magic Word: {{PAGELANGUAGE}} on a page with no explicitly set language
10618 !! options
10619 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10620 !! wikitext
10621 {{PAGELANGUAGE}}
10622 !! html/*
10623 <p>en
10624 </p>
10625 !! end
10626
10627 !! test
10628 Case-sensitive magic words, when cased differently, should just be template transclusions
10629 !! wikitext
10630 {{CurrentMonth}}
10631 {{currentday}}
10632 {{cURreNTweEK}}
10633 {{currentHour}}
10634 !! html
10635 <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>
10636 <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>
10637 <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>
10638 <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>
10639 </p>
10640 !! end
10641
10642 !! test
10643 Case-insensitive magic words should still work with weird casing.
10644 !! wikitext
10645 {{sErVeRNaMe}}
10646 {{LCFirst:AOEU}}
10647 {{ucFIRST:aoeu}}
10648 {{SERver}}
10649 !! html
10650 <p>example.org
10651 aOEU
10652 Aoeu
10653 <a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10654 </p>
10655 !! end
10656
10657 # From plwiki:PLOS_ONE
10658 !! test
10659 Parsoid: Page property magic word with magic word contents
10660 !! wikitext
10661 {{DISPLAYTITLE:''{{PAGENAME}}''}}
10662 !! html/parsoid
10663 <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>"}]]}'/>
10664 !! end
10665
10666 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
10667 # But, this is a limitation of our representation and is documented in
10668 # TemplateHandler.js in processSpecialMagicWord
10669 !! test
10670 Parsoid: Template-generated DISPLAYTITLE
10671 !! wikitext
10672 {{{{echo|DISPLAYTITLE}}:Foo}}
10673 !! options
10674 showtitle
10675 !! config
10676 wgAllowDisplayTitle=true
10677 wgRestrictDisplayTitle=false
10678 !! html/php
10679 Foo
10680
10681 !! html/parsoid
10682 <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"}]]}'/>
10683 !! end
10684
10685 !! test
10686 Namespace 1 {{ns:1}}
10687 !! wikitext
10688 {{ns:1}}
10689 !! html
10690 <p>Talk
10691 </p>
10692 !! end
10693
10694 !! test
10695 Namespace 1 {{ns:01}}
10696 !! wikitext
10697 {{ns:01}}
10698 !! html
10699 <p>Talk
10700 </p>
10701 !! end
10702
10703 !! test
10704 Namespace 0 {{ns:0}} (T6783)
10705 !! wikitext
10706 {{ns:0}}
10707 !! html
10708
10709 !! end
10710
10711 !! test
10712 Namespace 0 {{ns:00}} (T6783)
10713 !! wikitext
10714 {{ns:00}}
10715 !! html
10716
10717 !! end
10718
10719 !! test
10720 Namespace -1 {{ns:-1}}
10721 !! wikitext
10722 {{ns:-1}}
10723 !! html
10724 <p>Special
10725 </p>
10726 !! end
10727
10728 !! test
10729 Namespace User {{ns:User}}
10730 !! wikitext
10731 {{ns:User}}
10732 !! html
10733 <p>User
10734 </p>
10735 !! end
10736
10737 !! test
10738 Namespace User talk {{ns:User_talk}}
10739 !! wikitext
10740 {{ns:User_talk}}
10741 !! html
10742 <p>User talk
10743 </p>
10744 !! end
10745
10746 !! test
10747 Namespace User talk {{ns:uSeR tAlK}}
10748 !! wikitext
10749 {{ns:uSeR tAlK}}
10750 !! html
10751 <p>User talk
10752 </p>
10753 !! end
10754
10755 !! test
10756 Namespace File {{ns:File}}
10757 !! wikitext
10758 {{ns:File}}
10759 !! html
10760 <p>File
10761 </p>
10762 !! end
10763
10764 !! test
10765 Namespace File {{ns:Image}}
10766 !! wikitext
10767 {{ns:Image}}
10768 !! html
10769 <p>File
10770 </p>
10771 !! end
10772
10773 !! test
10774 Namespace (lang=de) Benutzer {{ns:User}}
10775 !! options
10776 language=de
10777 !! wikitext
10778 {{ns:User}}
10779 !! html
10780 <p>Benutzer
10781 </p>
10782 !! end
10783
10784 !! test
10785 Namespace (lang=de) Benutzer Diskussion {{ns:3}}
10786 !! options
10787 language=de
10788 !! wikitext
10789 {{ns:3}}
10790 !! html
10791 <p>Benutzer Diskussion
10792 </p>
10793 !! end
10794
10795 !! test
10796 Urlencode
10797 !! wikitext
10798 {{urlencode:hi world?!}}
10799 {{urlencode:hi world?!|WIKI}}
10800 {{urlencode:hi world?!|PATH}}
10801 {{urlencode:hi world?!|QUERY}}
10802 !! html/php
10803 <p>hi+world%3F%21
10804 hi_world%3F!
10805 hi%20world%3F%21
10806 hi+world%3F%21
10807 </p>
10808 !! end
10809
10810 !! test
10811 Magic Word: prioritize type info over data-parsoid
10812 !! options
10813 parsoid=html2wt
10814 !! html/parsoid
10815 <meta property="mw:PageProp/forcetoc" data-parsoid='{"magicSrc":"__NOTOC__"}'/>
10816 !! wikitext
10817 __FORCETOC__
10818 !! end
10819
10820 !! test
10821 Magic Word: serialize on separate line (parsoid)
10822 !! options
10823 parsoid=wt2wt,html2wt
10824 !! wikitext
10825 foo
10826 __NOTOC__
10827 bar
10828 !! html/parsoid
10829 foo<meta property="mw:PageProp/notoc"/>bar
10830 !! end
10831
10832 !! test
10833 Magic Word: rt non-english wikis
10834 !! options
10835 parsoid=wt2wt
10836 language=de
10837 !! wikitext
10838 __NOEDITSECTION__
10839 !! html/parsoid
10840 <meta property="mw:PageProp/noeditsection" data-parsoid='{"magicSrc":"__NOEDITSECTION__"}'/>
10841 !! end
10842
10843 !!test
10844 __proto__ is treated as normal wikitext (T105997)
10845 !!wikitext
10846 __proto__
10847 !!html
10848 <p>__proto__
10849 </p>
10850 !!end
10851
10852 ###
10853 ### Magic links
10854 ###
10855 !! test
10856 Magic links: internal link to RFC (T2479)
10857 !! wikitext
10858 [[RFC 123]]
10859 !! html/php
10860 <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>
10861 </p>
10862 !! html/parsoid
10863 <p><a rel="mw:WikiLink" href="./RFC_123" title="RFC 123">RFC 123</a></p>
10864 !! end
10865
10866 !! test
10867 Magic links: RFC (T2479)
10868 !! wikitext
10869 RFC 822
10870 !! html/php
10871 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
10872 </p>
10873 !! html/parsoid
10874 <p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external text">RFC 822</a></p>
10875 !! end
10876
10877 !! test
10878 Magic links: RFC (T67278)
10879 !! wikitext
10880 This is RFC 822 but thisRFC 822 is not RFC 822linked.
10881 !! html/php
10882 <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.
10883 </p>
10884 !! html/parsoid
10885 <p>This is <a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external text">RFC 822</a> but thisRFC 822 is not RFC 822linked.</p>
10886 !! end
10887
10888 !! test
10889 Magic links: RFC (w/ non-newline whitespace, T30950/T31025)
10890 !! wikitext
10891 RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 822
10892 RFC
10893 822
10894 !! html/php
10895 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
10896 RFC
10897 822
10898 </p>
10899 !! html/parsoid
10900 <p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external text">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>
10901 RFC
10902 822</p>
10903 !! end
10904
10905 !! test
10906 Magic links: ISBN (T3937)
10907 !! wikitext
10908 ISBN 0-306-40615-2
10909 !! html/php
10910 <p><a href="/wiki/Special:BookSources/0306406152" class="internal mw-magiclink-isbn">ISBN 0-306-40615-2</a>
10911 </p>
10912 !! html/parsoid
10913 <p><a href="./Special:BookSources/0306406152" rel="mw:WikiLink">ISBN 0-306-40615-2</a></p>
10914 !! end
10915
10916 !! test
10917 Magic links: ISBN (T67278)
10918 !! wikitext
10919 This is ISBN 978-0-316-09811-3 but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.
10920 !! html/php
10921 <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.
10922 </p>
10923 !! html/parsoid
10924 <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>
10925 !! end
10926
10927 !! test
10928 Magic links: ISBN (w/ non-newline whitespace, T30950/T31025)
10929 !! wikitext
10930 ISBN &nbsp;&#160;&#0160;&#xA0;&#Xa0; 978&nbsp;0&#160;316&#0160;09811&#xA0;3
10931 ISBN
10932 9780316098113
10933 ISBN 978
10934 0316098113
10935 !! html/php
10936 <p><a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978 0 316 09811 3</a>
10937 ISBN
10938 9780316098113
10939 ISBN 978
10940 0316098113
10941 </p>
10942 !! html/parsoid
10943 <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>
10944 ISBN
10945 9780316098113
10946 ISBN 978
10947 0316098113</p>
10948 !! end
10949
10950 !! test
10951 Magic links: PMID incorrectly converts space to underscore
10952 !! wikitext
10953 PMID 1234
10954 !! html/php
10955 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
10956 </p>
10957 !! html/parsoid
10958 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external text">PMID 1234</a></p>
10959 !! end
10960
10961 !! test
10962 Magic links: PMID (T67278)
10963 !! wikitext
10964 This is PMID 1234 but thisPMID 1234 is not PMID 1234linked.
10965 !! html/php
10966 <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.
10967 </p>
10968 !! html/parsoid
10969 <p>This is <a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external text">PMID 1234</a> but thisPMID 1234 is not PMID 1234linked.</p>
10970 !! end
10971
10972 !! test
10973 Magic links: PMID (w/ non-newline whitespace, T30950/T31025)
10974 !! wikitext
10975 PMID &nbsp;&#160;&#0160;&#xA0;&#Xa0; 1234
10976 PMID
10977 1234
10978 !! html/php
10979 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
10980 PMID
10981 1234
10982 </p>
10983 !! html/parsoid
10984 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external text">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>
10985 PMID
10986 1234</p>
10987 !! end
10988
10989 # <nowiki> nodes shouldn't be inserted during html2wt by Parsoid,
10990 # since these are ExtLinkText, not MagicLinkText
10991 !! test
10992 Magic links: use appropriate serialization for "almost" magic links.
10993 !! wikitext
10994 X[[Special:BookSources/0978739256|foo]]
10995
10996 X[https://tools.ietf.org/html/rfc1234 foo]
10997 !! html/php
10998 <p>X<a href="/wiki/Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a>
10999 </p><p>X<a rel="nofollow" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a>
11000 </p>
11001 !! html/parsoid
11002 <p>X<a rel="mw:WikiLink" href="./Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a></p>
11003 <p>X<a rel="mw:ExtLink" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a></p>
11004 !! end
11005
11006 !! test
11007 Magic links: All disabled (T47942)
11008 !! options
11009 wgEnableMagicLinks={"ISBN":false, "PMID":false, "RFC":false}
11010 !! wikitext
11011 ISBN 0-306-40615-2
11012 PMID 1234
11013 RFC 4321
11014 !! html/php
11015 <p>ISBN 0-306-40615-2
11016 PMID 1234
11017 RFC 4321
11018 </p>
11019 !! end
11020
11021 ###
11022 ### Templates
11023 ####
11024
11025 !! test
11026 Nonexistent template
11027 !! wikitext
11028 {{thistemplatedoesnotexist}}
11029 !! html
11030 <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>
11031 </p>
11032 !! end
11033
11034 !! test
11035 Template with invalid target containing tags
11036 !! wikitext
11037 {{a<b>b</b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11038 !! html
11039 <p>{{a<b>b</b>|foo|a=b|a = b}}
11040 </p>
11041 !! end
11042
11043 !! test
11044 Template with invalid target containing unclosed tag
11045 !! wikitext
11046 {{a<b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11047 !! html
11048 <p>{{a<b>|foo|a=b|a = b}}</b>
11049 </p>
11050 !! end
11051
11052 !! test
11053 Template with invalid target containing wikilink
11054 !! wikitext
11055 {{[[Main Page]]}}
11056 !! html/php
11057 <p>{{<a href="/wiki/Main_Page" title="Main Page">Main Page</a>}}
11058 </p>
11059 !! html/parsoid
11060 <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>
11061 !! end
11062
11063 !! test
11064 Template with just whitespace in it, T70421
11065 !! wikitext
11066 {{echo|{{ }}}}
11067 !! html/parsoid
11068 <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>
11069 !! end
11070
11071 !! article
11072 Template:test
11073 !! text
11074 This is a test template
11075 !! endarticle
11076
11077 !! test
11078 Simple template
11079 !! wikitext
11080 {{test}}
11081 !! html
11082 <p>This is a test template
11083 </p>
11084 !! end
11085
11086 !! test
11087 Template with explicit namespace
11088 !! wikitext
11089 {{Template:test}}
11090 !! html
11091 <p>This is a test template
11092 </p>
11093 !! end
11094
11095
11096 !! article
11097 Template:paramtest
11098 !! text
11099 This is a test template with parameter {{{param}}}
11100 !! endarticle
11101
11102 !! test
11103 Template parameter
11104 !! wikitext
11105 {{paramtest|param=foo}}
11106 !! html
11107 <p>This is a test template with parameter foo
11108 </p>
11109 !! end
11110
11111 !! article
11112 Template:paramtestnum
11113 !! text
11114 [[{{{1}}}|{{{2}}}]]
11115 !! endarticle
11116
11117 !! test
11118 Template unnamed parameter
11119 !! wikitext
11120 {{paramtestnum|Main Page|the main page}}
11121 !! html
11122 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
11123 </p>
11124 !! end
11125
11126 !! article
11127 Template:templatesimple
11128 !! text
11129 (test)
11130 !! endarticle
11131
11132 !! article
11133 Template:templateredirect
11134 !! text
11135 #redirect [[Template:templatesimple]]
11136 !! endarticle
11137
11138 !! article
11139 Template:templateasargtestnum
11140 !! text
11141 {{{{{1}}}}}
11142 !! endarticle
11143
11144 !! article
11145 Template:templateasargtest
11146 !! text
11147 {{template{{{templ}}}}}
11148 !! endarticle
11149
11150 !! article
11151 Template:templateasargtest2
11152 !! text
11153 {{{{{templ}}}}}
11154 !! endarticle
11155
11156 !! test
11157 Template with template name as unnamed argument
11158 !! wikitext
11159 {{templateasargtestnum|templatesimple}}
11160 !! html
11161 <p>(test)
11162 </p>
11163 !! end
11164
11165 !! test
11166 Template with template name as argument
11167 !! wikitext
11168 {{templateasargtest|templ=simple}}
11169 !! html
11170 <p>(test)
11171 </p>
11172 !! end
11173
11174 !! test
11175 Template with template name as argument (2)
11176 !! wikitext
11177 {{templateasargtest2|templ=templatesimple}}
11178 !! html
11179 <p>(test)
11180 </p>
11181 !! end
11182
11183 !! article
11184 Template:templateasargtestdefault
11185 !! text
11186 {{{{{templ|templatesimple}}}}}
11187 !! endarticle
11188
11189 !! article
11190 Template:templa
11191 !! text
11192 '''templ'''
11193 !! endarticle
11194
11195 !! test
11196 Template with default value
11197 !! wikitext
11198 {{templateasargtestdefault}}
11199 !! html
11200 <p>(test)
11201 </p>
11202 !! end
11203
11204 !! test
11205 Template with default value (value set)
11206 !! wikitext
11207 {{templateasargtestdefault|templ=templa}}
11208 !! html
11209 <p><b>templ</b>
11210 </p>
11211 !! end
11212
11213 !! test
11214 Template redirect
11215 !! wikitext
11216 {{templateredirect}}
11217 !! html/php
11218 <p>(test)
11219 </p>
11220 !! html/parsoid
11221 <link rel="mw:PageProp/redirect" href="./Template:Templatesimple" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"templateredirect","href":"./Template:Templateredirect"},"params":{},"i":0}}]}'/>
11222 !! end
11223
11224 !! test
11225 Template with argument in separate line
11226 !! wikitext
11227 {{ templateasargtest |
11228 templ = simple }}
11229 !! html
11230 <p>(test)
11231 </p>
11232 !! end
11233
11234 !! test
11235 Template with complex template as argument
11236 !! wikitext
11237 {{paramtest|
11238 param ={{ templateasargtest |
11239 templ = simple }}}}
11240 !! html
11241 <p>This is a test template with parameter (test)
11242 </p>
11243 !! end
11244
11245 !! test
11246 Templates with templated name
11247 !! wikitext
11248 {{{{echo|echo}}|foo}}
11249 {{{{echo|inner list}} }}
11250 !! html
11251 <p>foo
11252 </p>
11253 <ul><li> item 1</li></ul>
11254
11255 !! html/parsoid
11256 <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>
11257 <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>
11258 !! end
11259
11260 ## Regression test; the output here isn't really that interesting.
11261 !! test
11262 Templates with templated name and top level template args
11263 !! wikitext
11264 {{1{{2{{{3}}}|4=5}}}}
11265 !! html/parsoid
11266 <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>
11267 !! end
11268
11269 # Parsoid markup is deliberate "broken". This is an edge case.
11270 # See long comment in TemplateHandler.js:convertAttribsToString.
11271 !! test
11272 Templates with invalid templated targets
11273 !! wikitext
11274 {{echo
11275 {{echo|foo}}
11276 }}
11277 !! html/php
11278 <p>{{echo
11279 foo
11280 }}
11281 </p>
11282 !! html/parsoid
11283 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n{{echo|foo}}\n"},"params":{},"i":0}}]}'>{{echo
11284 foo }}</p>
11285 !! end
11286
11287 !! test
11288 Template with thumb image (with link in description)
11289 !! wikitext
11290 {{paramtest|param=[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
11291 !! html/php
11292 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>
11293
11294 !! html+tidy
11295 <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>
11296 !! html/parsoid
11297 <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>
11298 !! end
11299
11300 !! article
11301 Template:complextemplate
11302 !! text
11303 {{{1}}} {{paramtest|
11304 param ={{{param}}}}}
11305 !! endarticle
11306
11307 !! test
11308 Template with complex arguments
11309 !! wikitext
11310 {{complextemplate|
11311 param ={{ templateasargtest |
11312 templ = simple }}|[[Template:complextemplate|link]]}}
11313 !! html
11314 <p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test)
11315 </p>
11316 !! end
11317
11318 !! test
11319 T2553: link with two variables in a piped link
11320 !! wikitext
11321 {|
11322 |[[{{{1}}}|{{{2}}}]]
11323 |}
11324 !! html/php
11325 <table>
11326 <tr>
11327 <td>[[{{{1}}}|{{{2}}}]]
11328 </td></tr></table>
11329
11330 !! html/parsoid
11331 <table>
11332 <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>
11333 </tbody></table>
11334 !! end
11335
11336 # See: T2553
11337 !! test
11338 Abort table cell attribute parsing on wikilink
11339 !! wikitext
11340 {|
11341 | testing [[one|two]] | three || four
11342 | testing one two | three || four
11343 | testing="[[one|two]]" | three || four
11344 |}
11345 !! html/php
11346 <table>
11347 <tr>
11348 <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>
11349 <td> four
11350 </td>
11351 <td> three </td>
11352 <td> four
11353 </td>
11354 <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>
11355 <td> four
11356 </td></tr></table>
11357
11358 !! html/parsoid
11359 <table>
11360 <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>
11361 <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>
11362 <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>
11363 </tbody></table>
11364 !! end
11365
11366 !! test
11367 Don't abort table cell attribute parsing if wikilink is found in template arg
11368 !! wikitext
11369 {|
11370 | Test {{#tag:ref|One two "[[three]]" four}}
11371 |}
11372 !! html/parsoid
11373 <table>
11374 <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>
11375 </tbody></table>
11376 !! end
11377
11378 !! test
11379 Magic variable as template parameter
11380 !! wikitext
11381 {{paramtest|param={{SITENAME}}}}
11382 !! html
11383 <p>This is a test template with parameter MediaWiki
11384 </p>
11385 !! end
11386
11387 !! article
11388 Template:linktest
11389 !! text
11390 [[{{{param}}}|link]]
11391 !! endarticle
11392
11393 !! test
11394 Template parameter as link source
11395 !! wikitext
11396 {{linktest|param=Main Page}}
11397 !! html
11398 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
11399 </p>
11400 !! end
11401
11402 !!article
11403 Template:paramtest2
11404 !! text
11405 including another template, {{paramtest|param={{{arg}}}}}
11406 !! endarticle
11407
11408 !! test
11409 Template passing argument to another template
11410 !! wikitext
11411 {{paramtest2|arg='hmm'}}
11412 !! html
11413 <p>including another template, This is a test template with parameter 'hmm'
11414 </p>
11415 !! end
11416
11417 !! article
11418 Template:Linktest2
11419 !! text
11420 Main Page
11421 !! endarticle
11422
11423 !! test
11424 Template as link source
11425 !! wikitext
11426 [[{{linktest2}}]]
11427
11428 [[{{linktest2}}|Main Page]]
11429
11430 [[{{linktest2}}]]Page
11431 !! html
11432 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11433 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11434 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>Page
11435 </p>
11436 !! end
11437
11438
11439 !! article
11440 Template:loop1
11441 !! text
11442 {{loop2}}
11443 !! endarticle
11444
11445 !! article
11446 Template:loop2
11447 !! text
11448 {{loop1}}
11449 !! endarticle
11450
11451 !! test
11452 Template infinite loop
11453 !! wikitext
11454 {{loop1}}
11455 !! html
11456 <p><span class="error">Template loop detected: <a href="/wiki/Template:Loop1" title="Template:Loop1">Template:Loop1</a></span>
11457 </p>
11458 !! end
11459
11460 !! test
11461 Template from main namespace
11462 !! wikitext
11463 {{:Main Page}}
11464 !! html
11465 <p>blah blah
11466 </p>
11467 !! end
11468
11469 !! article
11470 Template:table
11471 !! text
11472 {|
11473 | 1 || 2
11474 |-
11475 | 3 || 4
11476 |}
11477 !! endarticle
11478
11479 !! test
11480 T2529: Template with table, not included at beginning of line
11481 !! wikitext
11482 foo {{table}}
11483 !! html
11484 <p>foo
11485 </p>
11486 <table>
11487 <tr>
11488 <td> 1 </td>
11489 <td> 2
11490 </td></tr>
11491 <tr>
11492 <td> 3 </td>
11493 <td> 4
11494 </td></tr></table>
11495
11496 !! end
11497
11498 !! test
11499 T2523: Template shouldn't eat newline (or add an extra one before table)
11500 !! wikitext
11501 foo
11502 {{table}}
11503 !! html
11504 <p>foo
11505 </p>
11506 <table>
11507 <tr>
11508 <td> 1 </td>
11509 <td> 2
11510 </td></tr>
11511 <tr>
11512 <td> 3 </td>
11513 <td> 4
11514 </td></tr></table>
11515
11516 !! end
11517
11518 !! test
11519 T2041: Template parameters shown as broken links
11520 !! wikitext
11521 {{{parameter}}}
11522 !! html
11523 <p>{{{parameter}}}
11524 </p>
11525 !! end
11526
11527 !! test
11528 Template with targets containing wikilinks
11529 !! options
11530 parsoid=wt2html
11531 !! wikitext
11532 {{[[foo]]}}
11533
11534 {{[[{{echo|foo}}]]}}
11535
11536 {{{{echo|[[foo}}]]}}
11537 !! html/php
11538 <p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11539 </p><p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11540 </p><p>{{[[foo}}]]
11541 </p>
11542 !! html/parsoid
11543 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">foo</a>}}</p>
11544 <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>
11545 <p>{{<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[foo}}]]"}},"i":0}}]}'>[[foo}}]]</span></p>
11546 !! end
11547
11548 !! article
11549 Template:''
11550 !! text
11551 bar
11552 !! endarticle
11553
11554 !! test
11555 Templates: Double quotes as template target
11556 !! wikitext
11557 foo {{''}} baz
11558 !! html/php
11559 <p>foo bar baz
11560 </p>
11561 !! html/parsoid
11562 <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
11563 </p>
11564 !! end
11565
11566 ## This test is about making sure Parsoid's data-mw is well formed in the
11567 ## face of multiple templates with intersecting and overlapping ranges. The
11568 ## wikitext itself is wretched.
11569 !! test
11570 Templates with intersecting and overlapping ranges
11571 !! wikitext
11572 {|{{echo|
11573 <p>ha</p>}}
11574 {|{{echo|
11575 <p>ho</p>}}
11576 {{echo|{{!}}hi}}
11577 |}
11578 !! html/php+tidy
11579 <p>ha</p><table>
11580
11581 </table><p>ho</p><table>
11582
11583 <tbody><tr>
11584 <td>hi
11585 </td></tr></tbody></table>
11586 !! html/parsoid
11587 <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":""}]]}'>
11588
11589 </table><p about="#mwt1">ho</p><table about="#mwt1" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"","html":""},{"html":""}]]}'>
11590
11591 <tbody><tr><td>hi</td></tr>
11592 </tbody></table>
11593 !! end
11594
11595 !! article
11596 Template:MSGNW test
11597 !! text
11598 ''None'' of '''this''' should be
11599 * interpreted
11600 but rather passed unmodified
11601 {{test}}
11602 <gallery>
11603 File:Foobar.jpg
11604 </gallery>
11605 <!-- comment -->
11606 !! endarticle
11607
11608 # hmm, fix this or just deprecate msgnw and document its behavior?
11609 !! test
11610 msgnw keyword
11611 !! wikitext
11612 {{msgnw:MSGNW test}}
11613 !! html/php
11614 <p>&#39;&#39;None&#39;&#39; of &#39;&#39;&#39;this&#39;&#39;&#39; should be
11615 &#42; interpreted
11616 &#32;but rather passed unmodified
11617 &#123;&#123;test&#125;&#125;
11618 &#60;gallery&#62;
11619 File:Foobar.jpg
11620 &#60;/gallery&#62;
11621 &#60;!-- comment --&#62;
11622 </p>
11623 !! end
11624
11625 !! test
11626 int keyword
11627 !! wikitext
11628 {{int:youhavenewmessages|lots of money|not!}}
11629 !! html
11630 <p>You have lots of money (not!).
11631 </p>
11632 !! end
11633
11634 !! test
11635 int keyword - non-existing message
11636 !! wikitext
11637 {{int:var}}
11638 !! html
11639 <p>⧼var⧽
11640 </p>
11641 !! end
11642
11643 !! article
11644 Template:Includes
11645 !! text
11646 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11647 !! endarticle
11648
11649 !! test
11650 <includeonly> and <noinclude> being included
11651 !! wikitext
11652 {{Includes}}
11653 !! html
11654 <p>Foobar
11655 </p>
11656 !! end
11657
11658 !! article
11659 Template:Includes2
11660 !! text
11661 <onlyinclude>Foo</onlyinclude>bar
11662 !! endarticle
11663
11664 !! test
11665 <onlyinclude> being included
11666 !! wikitext
11667 {{Includes2}}
11668 !! html
11669 <p>Foo
11670 </p>
11671 !! end
11672
11673
11674 !! article
11675 Template:Includes3
11676 !! text
11677 <onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly>
11678 !! endarticle
11679
11680 !! test
11681 <onlyinclude> and <includeonly> being included
11682 !! wikitext
11683 {{Includes3}}
11684 !! html
11685 <p>Foo
11686 </p>
11687 !! end
11688
11689 !! test
11690 <includeonly> and <noinclude> on a page
11691 !! wikitext
11692 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11693 !! html
11694 <p>Foozar
11695 </p>
11696 !! end
11697
11698 !! test
11699 Un-closed <noinclude>
11700 !! wikitext
11701 <noinclude>
11702 !! html
11703 !! end
11704
11705 !! test
11706 <onlyinclude> on a page
11707 !! wikitext
11708 <onlyinclude>Foo</onlyinclude>bar
11709 !! html
11710 <p>Foobar
11711 </p>
11712 !! end
11713
11714 !! test
11715 Un-closed <onlyinclude>
11716 !! wikitext
11717 <onlyinclude>
11718 !! html
11719 !! end
11720
11721 !!test
11722 Self-closed noinclude, includeonly, onlyinclude tags
11723 !! wikitext
11724 <noinclude />
11725 <includeonly />
11726 <onlyinclude />
11727 !! html
11728 <p><br />
11729 </p>
11730 !!end
11731
11732 !!test
11733 Unbalanced includeonly and noinclude tags
11734 !! wikitext
11735 {|
11736 |a</noinclude>
11737 |b</noinclude></noinclude>
11738 |c</noinclude></includeonly>
11739 |d</includeonly></includeonly>
11740 |}
11741 !! html
11742 <table>
11743 <tr>
11744 <td>a
11745 </td>
11746 <td>b
11747 </td>
11748 <td>c&lt;/includeonly&gt;
11749 </td>
11750 <td>d&lt;/includeonly&gt;&lt;/includeonly&gt;
11751 </td></tr></table>
11752
11753 !!end
11754
11755 !! article
11756 Template:Includeonly section
11757 !! text
11758 <includeonly>
11759 ==Includeonly section==
11760 </includeonly>
11761 ==Section T-1==
11762 !!endarticle
11763
11764 !! test
11765 T8563: Edit link generation for section shown by <includeonly>
11766 !! wikitext
11767 {{includeonly section}}
11768 !! html
11769 <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>
11770 <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>
11771
11772 !! end
11773
11774 # Uses same input as the contents of [[Template:Includeonly section]]
11775 !! test
11776 T8563: Section extraction for section shown by <includeonly>
11777 !! options
11778 section=T-2
11779 !! wikitext
11780 <includeonly>
11781 ==Includeonly section==
11782 </includeonly>
11783 ==Section T-2==
11784 !! html
11785 ==Section T-2==
11786 !! end
11787
11788 !! test
11789 T8563: Edit link generation for section suppressed by <includeonly>
11790 !! wikitext
11791 <includeonly>
11792 ==Includeonly section==
11793 </includeonly>
11794 ==Section 1==
11795 !! html
11796 <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>
11797
11798 !! end
11799
11800 !! test
11801 T8563: Section extraction for section suppressed by <includeonly>
11802 !! options
11803 section=1
11804 !! wikitext
11805 <includeonly>
11806 ==Includeonly section==
11807 </includeonly>
11808 ==Section 1==
11809 !! html
11810 ==Section 1==
11811 !! end
11812
11813 !! test
11814 Un-closed <includeonly>
11815 !! wikitext
11816 <includeonly>
11817 !! html/php
11818 !! html/parsoid
11819 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>"}'/>
11820 !! end
11821
11822 ## We used to, but no longer wt2wt this test since the default serializer
11823 ## will normalize the include directives to serialize on their own line.
11824 ## Selser will take care of preserving formatting in scenarios where they
11825 ## intermingled with other wikitext.
11826 !! test
11827 Includes and comments at SOL
11828 !! options
11829 parsoid=wt2html,html2html
11830 !! wikitext
11831 <!-- comment --><noinclude><!-- comment --></noinclude><!-- comment -->== hu ==
11832
11833 <noinclude>
11834 some
11835 </noinclude>* stuff
11836 * here
11837
11838 <includeonly>can have stuff</includeonly>=== here ===
11839
11840 !! html/php
11841 <h2><span class="mw-headline" id="hu">hu</span></h2>
11842 <p>some
11843 </p>
11844 <ul><li> stuff</li>
11845 <li> here</li></ul>
11846 <h3><span class="mw-headline" id="here">here</span></h3>
11847
11848 !! html/parsoid
11849 <!-- 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>
11850
11851 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
11852 <p>some</p>
11853 <meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/><ul><li> stuff</li>
11854 <li> here</li></ul>
11855
11856 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>can have stuff&lt;/includeonly>"}'/><meta typeof="mw:Includes/IncludeOnly/End" data-parsoid='{"src":""}'/><h3 id="here"> here </h3>
11857
11858 !! end
11859
11860 # TODO: test with DOM fragment reuse!
11861 !! test
11862 Parsoid: DOM fragment reuse
11863 !! options
11864 parsoid=wt2wt,wt2html
11865 !! wikitext
11866 a{{echo|b<table></table>c}}d
11867
11868 a{{echo|b
11869 <table></table>
11870 c}}d
11871
11872 {{echo|a
11873
11874 <table></table>
11875
11876 b}}
11877 !! html
11878 <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>
11879
11880 <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">
11881 </span><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><span about="#mwt2">
11882 </span><p about="#mwt2">cd</p>
11883
11884 <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">
11885
11886 </span><table about="#mwt3" data-parsoid='{"stx":"html"}'></table><span about="#mwt3">
11887
11888 </span><p about="#mwt3">b</p>
11889 !! end
11890
11891 !! test
11892 Parsoid: Merge double tds (T52603)
11893 !! options
11894 parsoid
11895 !! wikitext
11896 {|
11897 |{{echo|{{!}} foo}}
11898 |}
11899 !! html
11900 <table><tbody>
11901 <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>
11902 </tbody></table>
11903 !! end
11904
11905 !! test
11906 Parsoid: Merge double tds in nested transclusion content (T52603)
11907 !! options
11908 parsoid
11909 !! wikitext
11910 {{echo|<div>}}
11911 {|
11912 |{{echo|{{!}} foo}}
11913 |}
11914 {{echo|</div>}}
11915 !! html
11916 <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}}]}'>
11917 <table><tbody>
11918 <tr><td data-mw='{"parts":["|"]}'> foo</td></tr>
11919 </tbody></table>
11920 </div>
11921 !! end
11922
11923 ###
11924 ### <includeonly> and <noinclude> in attributes
11925 ###
11926 !!test
11927 0. includeonly around the entire attribute
11928 !! wikitext
11929 <span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
11930 !! html
11931 <p><span id="v2">bar</span>
11932 </p>
11933 !!end
11934
11935 !!test
11936 1. includeonly in html attr key
11937 !! wikitext
11938 <span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
11939 !! html
11940 <p><span id="foo">bar</span>
11941 </p>
11942 !!end
11943
11944 !!test
11945 2. includeonly in html attr value
11946 !! wikitext
11947 <span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
11948 <span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
11949 !! html
11950 <p><span id="v1">bar</span>
11951 <span id="v1">bar</span>
11952 </p>
11953 !!end
11954
11955 !!test
11956 3. includeonly in part of an attr value
11957 !! wikitext
11958 <span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
11959 !! html
11960 <p><span style="color:red;">bar</span>
11961 </p>
11962 !!end
11963
11964 !!test
11965 4. includeonly in table attributes
11966 !! wikitext
11967 {|
11968 |- <noinclude>
11969 |-
11970 |a
11971 </noinclude>
11972 |- <includeonly>
11973 |-
11974 |b
11975 </includeonly>
11976 |}
11977 !! html
11978 <table>
11979
11980
11981 <tr>
11982 <td>a
11983 </td></tr>
11984 </table>
11985
11986 !!end
11987
11988 ###
11989 ### Preprocessor precedence tests
11990 ### See: https://www.mediawiki.org/wiki/Preprocessor_ABNF
11991 ###
11992 ##{{[[-{{{{{{[[Foo|bar}}]]}-}}}}}]]
11993 !! test
11994 Preprocessor precedence 1: link is rightmost opening
11995 !! options
11996 parsoid=wt2html
11997 !! wikitext
11998 {{[[Foo|bar}}]]
11999
12000 But close-brace is not a valid character in a link title:
12001 {{[[Foo}}|bar]]
12002
12003 However, we can still tell this was handled as a link in the preprocessor:
12004 {{echo|[[Foo}}|bar]]|bat}}
12005 !! html/php
12006 <p>{{<a href="/wiki/Foo" title="Foo">bar}}</a>
12007 </p><p>But close-brace is not a valid character in a link title:
12008 {{[[Foo}}|bar]]
12009 </p><p>However, we can still tell this was handled as a link in the preprocessor:
12010 [[Foo}}|bar]]
12011 </p>
12012 !! html/parsoid
12013 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">bar}}</a></p>
12014 <p>But close-brace is not a valid character in a link title: {{[[Foo}}|bar]]</p>
12015 <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>
12016 !! end
12017
12018 !! test
12019 Preprocessor precedence 2: template is rightmost opening
12020 !! options
12021 language=zh
12022 !! wikitext
12023 -{{echo|foo}-}}-
12024 !! html/php
12025 <p>-foo}--
12026 </p>
12027 !! html/parsoid
12028 <p>-<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}-"}},"i":0}}]}'>foo}-</span>-</p>
12029 !! end
12030
12031 !! test
12032 Preprocessor precedence 3: language converter is rightmost opening
12033 !! options
12034 language=zh
12035 parsoid=wt2html
12036 !! wikitext
12037 {{echo|hi}}
12038
12039 {{-{R|echo|hi}}}-
12040
12041 [[-{R|raw]]}-
12042 !! html/php
12043 <p>hi
12044 </p><p>{{echo|hi}}
12045 </p><p>[[raw]]
12046 </p>
12047 !! html/parsoid
12048 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"}},"i":0}}]}'>hi</p>
12049 <p>{{<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"echo|hi}}"}}'></span></p>
12050 <p>[[<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw]]"}}'></span></p>
12051 !! end
12052
12053 !! test
12054 Preprocessor precedence 4: left-most angle bracket
12055 !! options
12056 language=zh
12057 !! wikitext
12058 <!--{raw}-->
12059 !! html/php
12060 !! html/parsoid
12061 <!--{raw}-->
12062 !! end
12063
12064 !! article
12065 Template:Precedence5
12066 !! text
12067 {{{{{1}}}}}
12068 !! endarticle
12069
12070 !! test
12071 Preprocessor precedence 5: tplarg takes precedence over template
12072 !! wikitext
12073 {{Precedence5|Bullet}}
12074 !! html/php
12075 <ul><li> Bar</li></ul>
12076
12077 !! html/parsoid
12078 <ul typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Precedence5","href":"./Template:Precedence5"},"params":{"1":{"wt":"Bullet"}},"i":0}}]}'><li> Bar</li></ul>
12079 !! end
12080
12081 !! test
12082 Preprocessor precedence 6: broken link is rightmost opening
12083 !! options
12084 parsoid=wt2html
12085 !! wikitext
12086 {{echo|[[Foo}}
12087
12088 {{echo|[[Foo|bar|bat=baz}}
12089 !! html/php
12090 <p>{{echo|[[Foo}}
12091 </p><p>{{echo|[[Foo|bar|bat=baz}}
12092 </p>
12093 !! html/parsoid
12094 <p>{{echo|[[Foo}}</p>
12095 <p>{{echo|[[Foo|bar|bat=baz}}</p>
12096 !! end
12097
12098 # This next test exposes a difference between PHP and Parsoid:
12099 # Given [[Foo|{{echo|Bar]]x}}y]]z:
12100 # 1) Both PHP and Parsoid ignore the `]]` inside the `echo` in the
12101 # "preprocessor" stage. The `{{echo` extends until the `x}}`, and the
12102 # outer `[[Foo` extends until the `y]]`
12103 # 2a) But then the PHP preprocessor emits `[[Foo|Bar]]xy]]z` as an
12104 # intermediate result (after template expansion), and link processing
12105 # happens on this intermediate result, which moves the wikilink
12106 # boundary leftward to `[[Foo|Bar]]`
12107 # 2b) Parsoid works in a single step, so it's going to keep the
12108 # wikilink as extending to the `y]]`
12109 # 3a) Then PHP does linktrail processing which slurps up the trailing
12110 # `xy` inside the link.
12111 # 3b) Parsoid will do linktrail processing to slurp up the trailing
12112 # `z` inside the link.
12113 # This is "correct" behavior. Parsoid's basic worldview is that the
12114 # `]]` inside the template shouldn't be allowed to leak out to affect
12115 # the surrounding wikilink. PHP may match Parsoid (in the future)
12116 # if you use {{#balance}} (T114445).
12117
12118 !! test
12119 Preprocessor precedence 7: broken template is rightmost opening
12120 !! options
12121 parsoid=wt2html
12122 !! wikitext
12123 [[Foo|{{echo|Bar]]
12124
12125 [[Foo|{{echo|Bar]]-x}}-y]]-z
12126
12127 Careful: linktrails can move the end of the wikilink:
12128 [[Foo|{{echo|y']]a}}l]]l
12129 !! html/php
12130 <p><a href="/wiki/Foo" title="Foo">{{echo|Bar</a>
12131 </p><p><a href="/wiki/Foo" title="Foo">Bar</a>-x-y]]-z
12132 </p><p>Careful: linktrails can move the end of the wikilink:
12133 <a href="/wiki/Foo" title="Foo">y'al</a>]]l
12134 </p>
12135 !! html/parsoid
12136 <p>[[Foo|{{echo|Bar]]</p>
12137 <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>
12138 <p>Careful: linktrails can move the end of the wikilink:
12139 <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>
12140 !! end
12141
12142 !! test
12143 Preprocessor precedence 8: broken language converter is rightmost opening
12144 !! options
12145 language=zh
12146 !! wikitext
12147 [[Foo-{R|raw]]
12148 !! html
12149 <p>[[Foo-{R|raw]]
12150 </p>
12151 !! end
12152
12153 !! article
12154 Template:Preprocessor_precedence_9
12155 !! text
12156 ;4: {{{{1}}}}
12157 ;5: {{{{{2}}}}}
12158 ;6: {{{{{{3}}}}}}
12159 ;7: {{{{{{{4}}}}}}}
12160 !! endarticle
12161
12162 !! test
12163 Preprocessor precedence 9: groups of braces
12164 !! wikitext
12165 {{Preprocessor precedence 9|Four|Bullet|1|2}}
12166 !! html/php
12167 <dl><dt>4</dt>
12168 <dd> {Four}</dd>
12169 <dt>5</dt>
12170 <dd> </dd></dl>
12171 <ul><li> Bar</li></ul>
12172 <dl><dt>6</dt>
12173 <dd> Four</dd>
12174 <dt>7</dt>
12175 <dd> {Bullet}</dd></dl>
12176
12177 !! html/parsoid
12178 <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}}]}'>
12179 <dt>4</dt>
12180 <dd>{Four}</dd>
12181 <dt>5</dt>
12182 <dd></dd>
12183 </dl><ul about="#mwt1">
12184 <li>Bar</li>
12185 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12186 <dt>6</dt>
12187 <dd>Four</dd>
12188 <dt>7</dt>
12189 <dd>{Bullet}</dd>
12190 </dl>
12191 !! end
12192
12193 !! article
12194 Template:Preprocessor_precedence_10
12195 !! text
12196 ;1: -{R|raw}-
12197 ;2: -{{Bullet}}-
12198 ;3: -{{{1}}}-
12199 ;4: -{{{{2}}}}-
12200 ;5: -{{{{{3}}}}}-
12201 ;6: -{{{{{{4}}}}}}-
12202 ;7: -{{{{{{{5}}}}}}}-
12203 !! endarticle
12204
12205 !! test
12206 Preprocessor precedence 10: groups of braces with leading dash
12207 !! options
12208 language=zh
12209 !! wikitext
12210 {{Preprocessor precedence 10|Three|raw2|Bullet|1|2}}
12211 !! html/php
12212 <dl><dt>1</dt>
12213 <dd> raw</dd>
12214 <dt>2</dt>
12215 <dd> -</dd></dl>
12216 <ul><li> Bar-</li></ul>
12217 <dl><dt>3</dt>
12218 <dd> -Three-</dd>
12219 <dt>4</dt>
12220 <dd> raw2</dd>
12221 <dt>5</dt>
12222 <dd> -</dd></dl>
12223 <ul><li> Bar-</li></ul>
12224 <dl><dt>6</dt>
12225 <dd> -Three-</dd>
12226 <dt>7</dt>
12227 <dd> raw2</dd></dl>
12228
12229 !! html/parsoid
12230 <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}}]}'>
12231 <dt>1</dt>
12232 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw"}}'></span></dd>
12233 <dt>2</dt>
12234 <dd>-</dd>
12235 </dl><ul about="#mwt1">
12236 <li>Bar-</li>
12237 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12238 <dt>3</dt>
12239 <dd>-Three-</dd>
12240 <dt>4</dt>
12241 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12242 <dt>5</dt>
12243 <dd>-</dd>
12244 </dl><ul about="#mwt1">
12245 <li>Bar-</li>
12246 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12247 <dt>6</dt>
12248 <dd>-Three-</dd>
12249 <dt>7</dt>
12250 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12251 </dl>
12252 !! end
12253
12254 !! test
12255 Preprocessor precedence 11: found during visual diff testing
12256 !! wikitext
12257 {{#tag:span|-{{#tag:span|-{{echo|x}}}}}}
12258
12259 {{echo|-{{echo|-{{echo|x}}}}}}
12260
12261 {{echo|-{{echo|x}}}}
12262 !! html/php
12263 <p><span>-<span>-x</span></span>
12264 </p><p>--x
12265 </p><p>-x
12266 </p>
12267 !! html/parsoid
12268 <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>
12269
12270 <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>
12271
12272 <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>
12273 !! end
12274
12275 !! test
12276 Preprocessor precedence 12: broken language converter closed by brace.
12277 !! options
12278 parsoid=wt2html
12279 !! wikitext
12280 This form breaks the template, which is unfortunate:
12281 * {{echo|foo-{bar}bat}}
12282
12283 But if the broken language converter markup is inside an extension
12284 tag, nothing bad happens:
12285 * <nowiki>foo-{bar}bat</nowiki>
12286 * {{echo|<nowiki>foo-{bar}bat</nowiki>}}
12287 * <pre>foo-{bar}bat</pre>
12288 * {{echo|<pre>foo-{bar}bat</pre>}}
12289
12290 <tag>foo-{bar}bat</tag>
12291 {{echo|<tag>foo-{bar}bat</tag>}}
12292
12293 !! html/php+tidy
12294 <p>This form breaks the template, which is unfortunate:
12295 </p>
12296 <ul><li> {{echo|foo-{bar}bat}}</li></ul>
12297 <p>But if the broken language converter markup is inside an extension
12298 tag, nothing bad happens:
12299 </p>
12300 <ul><li> foo-&#123;bar}bat</li>
12301 <li> foo-&#123;bar}bat</li>
12302 <li> <pre>foo-{bar}bat</pre></li>
12303 <li> <pre>foo-{bar}bat</pre></li></ul>
12304 <pre>'foo-{bar}bat'
12305 array (
12306 )
12307 </pre>
12308 <pre>'foo-{bar}bat'
12309 array (
12310 )
12311 </pre>
12312 !! html/parsoid
12313 <p>This form breaks the template, which is unfortunate:</p>
12314 <ul>
12315 <li>{{echo|foo-{bar}bat}}</li>
12316 </ul>
12317 <p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p>
12318 <ul>
12319 <li><span typeof="mw:Nowiki">foo-{bar}bat</span></li>
12320 <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>
12321 <li><pre typeof="mw:Extension/pre" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo-{bar}bat"}}'>foo-{bar}bat</pre></li>
12322 <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>
12323 </ul>
12324 <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>
12325 !! end
12326
12327 !! test
12328 Preprocessor precedence 13: broken language converter in external link
12329 !! options
12330 parsoid=wt2html
12331 !! wikitext
12332 * [http://example.com/-{foo Example in URL]
12333 * [http://example.com Example in -{link} description]
12334 * {{echo|[http://example.com/-{foo Breaks template, however]}}
12335 !! html/php+tidy
12336 <ul><li> <a rel="nofollow" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12337 <li> <a rel="nofollow" class="external text" href="http://example.com">Example in -{link} description</a></li>
12338 <li> {{echo|<a rel="nofollow" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li></ul>
12339 !! html/parsoid
12340 <ul>
12341 <li><a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12342 <li><a rel="mw:ExtLink" class="external text" href="http://example.com">Example in -{link} description</a></li>
12343 <li>{{echo|<a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
12344 </ul>
12345 !! end
12346
12347 !! test
12348 Preprocessor precedence 14: broken language converter in comment
12349 !! wikitext
12350 * <!--{{foo}}--> ...should be ok
12351 * <!---{{foo}}--> ...extra dashes
12352 * {{echo|foo<!-- -{bar} -->bat}} ...should be ok
12353 !! html/php+tidy
12354 <ul><li> ...should be ok</li>
12355 <li> ...extra dashes</li>
12356 <li> foobat ...should be ok</li></ul>
12357 !! html/parsoid
12358 <ul>
12359 <li><!--{{foo}}--> ...should be ok</li>
12360 <li><!--&#x2D;{{foo}}--> ...extra dashes</li>
12361 <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>
12362 </ul>
12363 !! end
12364
12365 !! test
12366 Preprocessor precedence 15: broken brace markup in headings
12367 !! config
12368 wgFragmentMode=[ 'html5', 'legacy' ]
12369 !! options
12370 parsoid=wt2html
12371 !! wikitext
12372 __NOTOC__ __NOEDITSECTION__
12373 ===1 foo[bar 1===
12374 1
12375 ===2 foo[[bar 2===
12376 2
12377 ===3 foo{bar 3===
12378 3
12379 ===4 foo{{bar 4===
12380 4
12381 ===5 foo{{{bar 5===
12382 5
12383 ===6 foo-{bar 6===
12384 6
12385 !! html/php+tidy
12386 <h3><span id="1_foo.5Bbar_1"></span><span class="mw-headline" id="1_foo[bar_1">1 foo[bar 1</span></h3>
12387 <p>1
12388 </p>
12389 <h3><span id="2_foo.5B.5Bbar_2"></span><span class="mw-headline" id="2_foo[[bar_2">2 foo[[bar 2</span></h3>
12390 <p>2
12391 </p>
12392 <h3><span id="3_foo.7Bbar_3"></span><span class="mw-headline" id="3_foo{bar_3">3 foo{bar 3</span></h3>
12393 <p>3
12394 </p>
12395 <h3><span id="4_foo.7B.7Bbar_4"></span><span class="mw-headline" id="4_foo{{bar_4">4 foo{{bar 4</span></h3>
12396 <p>4
12397 </p>
12398 <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>
12399 <p>5
12400 </p>
12401 <h3><span id="6_foo-.7Bbar_6"></span><span class="mw-headline" id="6_foo-{bar_6">6 foo-{bar 6</span></h3>
12402 <p>6
12403 </p>
12404 !! html/parsoid
12405 <meta property="mw:PageProp/notoc"/> <meta property="mw:PageProp/noeditsection"/>
12406 <h3 id="1_foo[bar_1"><span id="1_foo.5Bbar_1" typeof="mw:FallbackId"></span>1 foo[bar 1</h3>
12407 <p>1</p>
12408 <h3 id="2_foo[[bar_2"><span id="2_foo.5B.5Bbar_2" typeof="mw:FallbackId"></span>2 foo[[bar 2</h3>
12409 <p>2</p>
12410 <h3 id="3_foo{bar_3"><span id="3_foo.7Bbar_3" typeof="mw:FallbackId"></span>3 foo{bar 3</h3>
12411 <p>3</p>
12412 <h3 id="4_foo{{bar_4"><span id="4_foo.7B.7Bbar_4" typeof="mw:FallbackId"></span>4 foo{{bar 4</h3>
12413 <p>4</p>
12414 <h3 id="5_foo{{{bar_5"><span id="5_foo.7B.7B.7Bbar_5" typeof="mw:FallbackId"></span>5 foo{{{bar 5</h3>
12415 <p>5</p>
12416 <h3 id="6_foo-{bar_6"><span id="6_foo-.7Bbar_6" typeof="mw:FallbackId"></span>6 foo-{bar 6</h3>
12417 <p>6</p>
12418 !! end
12419
12420 !! test
12421 Preprocessor precedence 16: matching closing braces to opening braces
12422 !! options
12423 language=zh
12424 parsoid=wt2html
12425 !! wikitext
12426 -{{{echo|foo}}bar}-
12427 !! html/php
12428 <p>foobar
12429 </p>
12430 !! html/parsoid
12431 <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>
12432 !! end
12433
12434 !! test
12435 Preprocessor precedence 17: template w/o target shouldn't prevent closing
12436 !! options
12437 parsoid=wt2html
12438 !! wikitext
12439 {{echo|hi {{}}}}
12440 !! html/php
12441 <p>hi {{}}
12442 </p>
12443 !! html/parsoid
12444 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi {{}}"}},"i":0}}]}'>hi {{}}</p>
12445 !! end
12446
12447 ###
12448 ### Token Stream Patcher tests
12449 ###
12450 ### These tests won't always pass wt2wt and other modes because
12451 ### on serialization, the table will be output on a new line.
12452 ### For now, we are blacklisting them, and using this to test selser.
12453 ###
12454
12455 !!test
12456 1. Table tag in SOL posn. should get reparsed correctly with valid TSR
12457 !!options
12458 parsoid=wt2html,wt2wt
12459 !!wikitext
12460 {{echo|}}{| width = '100%'
12461 |foo
12462 |}
12463 !!html/parsoid
12464 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":""}},"i":0}}]}'></span><table width="100%">
12465 <tbody><tr><td>foo</td></tr>
12466 </tbody></table>
12467 !!end
12468
12469 ## We used to, but no longer wt2wt this test since the default serializer
12470 ## will normalize the include directives to serialize on their own line.
12471 ## Selser will take care of preserving formatting in scenarios where they
12472 ## intermingled with other wikitext.
12473 !!test
12474 2. Table tag in SOL posn. should get reparsed correctly with valid TSR
12475 !!options
12476 parsoid=wt2html
12477 !!wikitext
12478 <includeonly>a</includeonly>{| {{{b}}}
12479 |c
12480 |}
12481 !!html/parsoid
12482 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>a&lt;/includeonly>"}'/><meta typeof="mw:Includes/IncludeOnly/End" data-parsoid='{"src":""}'/><table about="#mwt2" typeof="mw:ExpandedAttrs" data-parsoid='{"a":{"{{{b}}}":null},"sa":{"{{{b}}}":""}}' data-mw='{"attribs":[[{"txt":"{{{b}}}","html":"&lt;span about=\"#mwt1\" typeof=\"mw:Param\" data-parsoid=&#39;{\"pi\":[[]],\"dsr\":[31,38,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"templatearg\":{\"target\":{\"wt\":\"b\"},\"params\":{},\"i\":0}}]}&#39;>{{{b}}}&lt;/span>"},{"html":""}]]}'>
12483 <tbody><tr><td>c</td></tr>
12484 </tbody></table>
12485 !!end
12486
12487 !! test
12488 Table wikitext syntax outside wiki-tables
12489 !! wikitext
12490 a
12491 |+ not a caption
12492 ! not a table heading
12493 |- not a table row
12494 | not a table cell
12495 | class="foo bar" | baz
12496 b
12497 |}
12498 |-
12499 c
12500 !! html
12501 <p>a
12502 |+ not a caption
12503 ! not a table heading
12504 |- not a table row
12505 | not a table cell
12506 | class="foo bar" | baz
12507 b
12508 |}
12509 |-
12510 c
12511 </p>
12512 !! end
12513
12514 ###
12515 ### Testing parsing of templates where a template arg
12516 ### has the same name as the template itself.
12517 ###
12518
12519 !! article
12520 Template:quote
12521 !! text
12522 {{{quote|{{{1}}}}}}
12523 !! endarticle
12524
12525 !!test
12526 Templates: Template Name/Arg clash: 1. Use of positional param
12527 !! wikitext
12528 {{quote|foo}}
12529 !! html
12530 <p>foo
12531 </p>
12532 !!end
12533
12534 !!test
12535 Templates: Template Name/Arg clash: 2. Use of named param
12536 !! wikitext
12537 {{quote|quote=foo}}
12538 !! html
12539 <p>foo
12540 </p>
12541 !!end
12542
12543 !!test
12544 Templates: Template Name/Arg clash: 3. Use of named param with empty input
12545 !! wikitext
12546 {{quote|quote}}
12547 !! html
12548 <p>quote
12549 </p>
12550 !!end
12551
12552 ###
12553 ### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
12554 ###
12555
12556 !!test
12557 Templates: 1. Simple use
12558 !! wikitext
12559 {{echo|Foo}}
12560 !! html
12561 <p>Foo
12562 </p>
12563 !!end
12564
12565 !!test
12566 Templates: 2. Inside a block tag
12567 !! wikitext
12568 <div>{{echo|Foo}}</div>
12569 <blockquote>{{echo|Foo}}</blockquote>
12570 !! html
12571 <div>Foo</div>
12572 <blockquote>Foo</blockquote>
12573
12574 !! html+tidy
12575 <div>Foo</div>
12576 <blockquote><p>Foo</p></blockquote>
12577 !!end
12578
12579 !!test
12580 Templates: P-wrapping: 1a. Templates on consecutive lines
12581 !! wikitext
12582 {{echo|Foo}}
12583 {{echo|bar}}
12584 !! html
12585 <p>Foo
12586 bar
12587 </p>
12588 !!end
12589
12590 !!test
12591 Templates: P-wrapping: 1b. Templates on consecutive lines
12592 !! wikitext
12593 Foo
12594
12595 {{echo|bar}}
12596 {{echo|baz}}
12597 !! html
12598 <p>Foo
12599 </p><p>bar
12600 baz
12601 </p>
12602 !!end
12603
12604 !!test
12605 Templates: P-wrapping: 1c. Templates on consecutive lines
12606 !! wikitext
12607 {{echo|Foo}}
12608 {{echo|bar}} <div>baz</div>
12609 !! html
12610 <p>Foo
12611 </p>
12612 bar <div>baz</div>
12613
12614 !! html+tidy
12615 <p>Foo
12616 </p><p>
12617 bar </p><div>baz</div>
12618 !! end
12619
12620 !!test
12621 Templates: P-wrapping: 1d. Template preceded by comment-only line
12622 !!options
12623 parsoid
12624 !! wikitext
12625 <!-- foo -->
12626 {{echo|Bar}}
12627 !! html
12628 <!-- foo -->
12629
12630 <p about="#mwt223" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar"}},"i":0}}]}'>Bar</p>
12631 !!end
12632
12633 !!test
12634 Templates: Inline Text: 1. Multiple template uses
12635 !! wikitext
12636 {{echo|Foo}}bar{{echo|baz}}
12637 !! html
12638 <p>Foobarbaz
12639 </p>
12640 !!end
12641
12642 !!test
12643 Templates: Inline Text: 2. Back-to-back template uses
12644 !! wikitext
12645 {{echo|Foo}}{{echo|bar}}
12646 !! html
12647 <p>Foobar
12648 </p>
12649 !!end
12650
12651 !!test
12652 Templates: Block Tags: 1. Multiple template uses
12653 !! wikitext
12654 {{echo|<div>Foo</div>}}<div>bar</div>{{echo|<div>baz</div>}}
12655 !! html
12656 <div>Foo</div><div>bar</div><div>baz</div>
12657
12658 !!end
12659
12660 !!test
12661 Templates: Block Tags: 2. Back-to-back template uses
12662 !! wikitext
12663 {{echo|<div>Foo</div>}}{{echo|<div>bar</div>}}
12664 !! html
12665 <div>Foo</div><div>bar</div>
12666
12667 !!end
12668
12669 # This is an edge case relating to paragraph wrapping.
12670 !!test
12671 Templates: Correctly encapsulate templates producing </p> tag without a corresponding <p> tag
12672 !! wikitext
12673 {{echo|a
12674 b</p>}}
12675 !! html/parsoid
12676 <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
12677 b</p>
12678 !!end
12679
12680 !!test
12681 Templates: Links: 1. Simple example
12682 !! wikitext
12683 {{echo|[[Foo|bar]]}}
12684 !! html
12685 <p><a href="/wiki/Foo" title="Foo">bar</a>
12686 </p>
12687 !!end
12688
12689 !!test
12690 Templates: Links: 2. Generation of link href
12691 !! wikitext
12692 [[{{echo|Foo}}|bar]]
12693 !! html
12694 <p><a href="/wiki/Foo" title="Foo">bar</a>
12695 </p>
12696 !!end
12697
12698 !!test
12699 Templates: Links: 3. Generation of part of a link href
12700 !! wikitext
12701 [[Fo{{echo|o}}|bar]]
12702
12703 [[Foo{{echo|bar}}]]
12704
12705 [[Foo{{echo|bar}}baz]]
12706
12707 [[Foo{{echo|bar}}|bar]]
12708
12709 [[:Foo{{echo|bar}}]]
12710
12711 [[:Foo{{echo|bar}}|bar]]
12712 !! html
12713 <p><a href="/wiki/Foo" title="Foo">bar</a>
12714 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12715 </p><p><a href="/index.php?title=Foobarbaz&amp;action=edit&amp;redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a>
12716 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12717 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12718 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12719 </p>
12720 !!end
12721
12722 !!test
12723 Templates: Links: 4. Multiple templates generating link href
12724 !! wikitext
12725 [[{{echo|F}}{{echo|o}}ob{{echo|ar}}]]
12726 !! html
12727 <p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12728 </p>
12729 !!end
12730
12731 !!test
12732 Templates: Links: 5. Generation of link text
12733 !! wikitext
12734 [[Foo|{{echo|bar}}]]
12735 !! html
12736 <p><a href="/wiki/Foo" title="Foo">bar</a>
12737 </p>
12738 !!end
12739
12740 !!test
12741 Templates: Links: 5. Nested templates (only outermost template should be marked)
12742 !! wikitext
12743 {{echo|[[{{echo|Foo}}|bar]]}}
12744 !! html
12745 <p><a href="/wiki/Foo" title="Foo">bar</a>
12746 </p>
12747 !!end
12748
12749 !!test
12750 Templates: HTML Tag: 1. Generation of HTML attr. key
12751 !! wikitext
12752 <div {{echo|style}}="color:red;">foo</div>
12753 !! html
12754 <div style="color:red;">foo</div>
12755
12756 !!end
12757
12758 !!test
12759 Templates: HTML Tag: 2. Generation of HTML attr. value
12760 !! wikitext
12761 <div style={{echo|'color:red;'}}>foo</div>
12762 !! html
12763 <div style="color:red;">foo</div>
12764
12765 !!end
12766
12767 !!test
12768 Templates: HTML Tag: 3. Generation of HTML attr key and value
12769 !! wikitext
12770 <div {{echo|style}}={{echo|'color:red;'}}>foo</div>
12771 !! html
12772 <div style="color:red;">foo</div>
12773
12774 !!end
12775
12776 !!test
12777 Templates: HTML Tag: 4. Generation of starting piece of HTML attr value
12778 !! wikitext
12779 <div title="{{echo|This is a long title}} with just one piece templated">foo</div>
12780 !! html
12781 <div title="This is a long title with just one piece templated">foo</div>
12782
12783 !!end
12784
12785 !!test
12786 Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
12787 !! wikitext
12788 <div title="This is a long title with just {{echo|one piece}} templated">foo</div>
12789 !! html
12790 <div title="This is a long title with just one piece templated">foo</div>
12791
12792 !!end
12793
12794 !!test
12795 Templates: HTML Tag: 6. Generation of end piece of HTML attr value
12796 !! wikitext
12797 <div title="This is a long title with just one piece {{echo|templated}}">foo</div>
12798 !! html
12799 <div title="This is a long title with just one piece templated">foo</div>
12800
12801 !!end
12802
12803 # SSS FIXME: While it is great we added support for all this,
12804 # do we want to make this part of the spec? Maybe we want to
12805 # deprecate this kind of usage in the future?
12806 !!test
12807 Templates: HTML Tag: 7. Generation of partial attribute key string
12808 !! wikitext
12809 <div st{{echo|yle}}="color:red;">foo</div>
12810 !! html
12811 <div style="color:red;">foo</div>
12812
12813 !!end
12814
12815 !! test
12816 Templates: HTML Tag: 8. Template-generated attribute (k=v)
12817 !! wikitext
12818 <div {{echo|1=id="v1"}}>bar</div>
12819 !! html
12820 <div id="v1">bar</div>
12821
12822 !!end
12823
12824 !! test
12825 Templates: HTML Tag: 9. Multiple template-generated attributes
12826 !! wikitext
12827 <div {{echo|1=id="v1" title="foo"}}>bar</div>
12828 !! html
12829 <div id="v1" title="foo">bar</div>
12830
12831 !!end
12832
12833 !! test
12834 Templates: Support for templates generating attributes and content
12835 !! wikitext
12836 {| {{mixed_attr_content_template}}
12837 |-
12838 |bar
12839 |}
12840 !! html/php
12841 <table style="color:red;" title="T48811">
12842
12843 <tr>
12844 <td>foo
12845 </td></tr>
12846 <tr>
12847 <td>bar
12848 </td></tr></table>
12849
12850 !! html/parsoid
12851 <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|}"]}'>
12852 <tbody><tr>
12853 <td>foo</td></tr>
12854 <tr>
12855 <td>bar</td></tr>
12856 </tbody></table>
12857 !!end
12858
12859 !! test
12860 1. Entities and nowikis inside templated attributes should be handled correctly
12861 !! wikitext
12862 <div {{echo|style{{=}}"background:&#35;f9f9f9;"}}>foo</div>
12863 !! html/php
12864 <div style="background:#f9f9f9;">foo</div>
12865
12866 !! html/parsoid
12867 <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>
12868 !! end
12869
12870 !! test
12871 2. Entities and nowikis inside templated attributes should be handled correctly
12872 !! wikitext
12873 {|
12874 |{{table_attribs_3}}
12875 |}
12876 !! html/php
12877 <table>
12878 <tr>
12879 <td style="background:#f9f9f9;">Foo
12880 </td></tr></table>
12881
12882 !! html/parsoid
12883 <table>
12884 <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>
12885 </tbody></table>
12886 !! end
12887
12888 !! test
12889 3. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
12890 !! wikitext
12891 {{tbl-start}}
12892 |{{table_attribs_3}}
12893 {{tbl-end}}
12894 !! html/php
12895 <table>
12896 <tr>
12897 <td style="background:#f9f9f9;">Foo
12898 </td></tr></table>
12899
12900 !! html/parsoid
12901 <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}}]}'>
12902 <tbody><tr><td style="background:#f9f9f9;">Foo</td></tr>
12903 </tbody></table>
12904 !! end
12905
12906 # T107622
12907 !! test
12908 4. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
12909 !! wikitext
12910 {|
12911 | {{table_attribs_6}} hi
12912 |}
12913 !! html/php
12914 <table>
12915 <tr>
12916 <td style="background: red;"> hi
12917 </td></tr></table>
12918
12919 !! html/parsoid
12920 <table>
12921 <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>
12922 </tbody></table>
12923 !! end
12924
12925 !!test
12926 Templates: HTML Tables: 1. Generating start of a HTML table
12927 !! wikitext
12928 {{echo|<table><tr><td>foo</td>}}</tr></table>
12929 !! html
12930 <table><tr><td>foo</td></tr></table>
12931
12932 !!end
12933
12934 !!test
12935 Templates: HTML Tables: 2a. Generating middle of a HTML table
12936 !! wikitext
12937 <table><tr>{{echo|<td>foo</td>}}</tr></table>
12938 !! html
12939 <table><tr><td>foo</td></tr></table>
12940
12941 !!end
12942
12943 !!test
12944 Templates: HTML Tables: 2b. Generating middle of a HTML table
12945 !! wikitext
12946 <table>{{echo|<tr><td>foo</td></tr>}}</table>
12947 !! html
12948 <table><tr><td>foo</td></tr></table>
12949
12950 !!end
12951
12952 !!test
12953 Templates: HTML Tables: 3. Generating end of a HTML table
12954 !! wikitext
12955 <table><tr>{{echo|<td>foo</td></tr></table>}}
12956 !! html
12957 <table><tr><td>foo</td></tr></table>
12958
12959 !!end
12960
12961 !!test
12962 Templates: HTML Tables: 4a. Generating a single tag of a HTML table
12963 !! wikitext
12964 {{echo|<table>}}<tr><td>foo</td></tr></table>
12965 !! html
12966 <table><tr><td>foo</td></tr></table>
12967
12968 !!end
12969
12970 !!test
12971 Templates: HTML Tables: 4b. Generating a single tag of a HTML table
12972 !! wikitext
12973 <table>{{echo|<tr>}}<td>foo</td></tr></table>
12974 !! html
12975 <table><tr><td>foo</td></tr></table>
12976
12977 !!end
12978
12979 !!test
12980 Templates: HTML Tables: 4c. Generating a single tag of a HTML table
12981 !! wikitext
12982 <table><tr>{{echo|<td>}}foo</td></tr></table>
12983 !! html
12984 <table><tr><td>foo</td></tr></table>
12985
12986 !!end
12987
12988 !!test
12989 Templates: HTML Tables: 4d. Generating a single tag of a HTML table
12990 !! wikitext
12991 <table><tr><td>foo{{echo|</td>}}</tr></table>
12992 !! html
12993 <table><tr><td>foo</td></tr></table>
12994
12995 !!end
12996
12997 !!test
12998 Templates: HTML Tables: 4e. Generating a single tag of a HTML table
12999 !! wikitext
13000 <table><tr><td>foo</td>{{echo|</tr>}}</table>
13001 !! html
13002 <table><tr><td>foo</td></tr></table>
13003
13004 !!end
13005
13006 !!test
13007 Templates: HTML Tables: 4f. Generating a single tag of a HTML table
13008 !! wikitext
13009 <table><tr><td>foo</td></tr>{{echo|</table>}}
13010 !! html
13011 <table><tr><td>foo</td></tr></table>
13012
13013 !!end
13014
13015 !!test
13016 Templates: HTML Tables: 5. Proper fostering of categories from inside
13017 !!options
13018 parsoid=wt2html,wt2wt
13019 !! wikitext
13020 <table>[[Category:foo1]]<tr><td>foo</td></tr></table>
13021 <!--Two categories (T52330)-->
13022 <table>[[Category:bar1]][[Category:bar2]]<tr><td>foo</td></tr></table>
13023 !! html
13024 <link rel="mw:PageProp/Category" href="./Category:Foo1"><table><tbody><tr><td>foo</td></tr></tbody></table>
13025 <!--Two categories (T52330)-->
13026 <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>
13027 !!end
13028
13029 !!test
13030 Templates: Wiki Tables: 1a. Fostering of entire template content
13031 !! wikitext
13032 {|
13033 {{echo|a}}
13034 |}
13035 !! html
13036 <table>
13037 a
13038 <tr><td></td></tr></table>
13039
13040 !! html+tidy
13041
13042 a
13043 <table><tbody><tr><td></td></tr></tbody></table>
13044 !! end
13045
13046 !!test
13047 Templates: Wiki Tables: 1b. Fostering of entire template content
13048 !! wikitext
13049 {|
13050 {{echo|<div>}}
13051 foo
13052 {{echo|</div>}}
13053 |}
13054 !! html
13055 <table>
13056 <div>
13057 <p>foo
13058 </p>
13059 </div>
13060 <tr><td></td></tr></table>
13061
13062 !! html/php+tidy
13063 <div>
13064 <p>foo
13065 </p>
13066 </div><table>
13067
13068 <tbody><tr><td></td></tr></tbody></table>
13069 !! html/parsoid
13070 <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|}"]}'>
13071 <p>foo</p>
13072 </div><table about="#mwt3">
13073
13074 </table>
13075 !! end
13076
13077 !!test
13078 Templates: Wiki Tables: 2. Fostering of partial template content
13079 !! wikitext
13080 {|
13081 {{echo|a
13082 <div>b</div>}}
13083 |}
13084 !! html
13085 <table>
13086 a
13087 <div>b</div>
13088 <tr><td></td></tr></table>
13089
13090 !! html/php+tidy
13091
13092 a
13093 <div>b</div><table>
13094 <tbody><tr><td></td></tr></tbody></table>
13095 !! html/parsoid
13096 <p about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":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">
13097
13098
13099 </table>
13100 !! end
13101
13102 !!test
13103 Templates: Wiki Tables: 3. td-content via multiple templates
13104 !! wikitext
13105 {|
13106 {{echo|{{pipe}}a}}{{echo|b}}
13107 |}
13108 !! html
13109 <table>
13110 <tr>
13111 <td>ab
13112 </td></tr></table>
13113
13114 !!end
13115
13116 !!test
13117 Templates: Wiki Tables: 4. Templated tags, no content
13118 !! wikitext
13119 {{tbl-start}}
13120 {{tbl-end}}
13121 !! html
13122 <table>
13123 <tr><td></td></tr></table>
13124
13125 !!end
13126
13127 !!test
13128 Templates: Wiki Tables: 5. Templated tags, regular td-tags
13129 !! wikitext
13130 {{tbl-start}}
13131 |foo
13132 {{tbl-end}}
13133 !! html
13134 <table>
13135 <tr>
13136 <td>foo
13137 </td></tr></table>
13138
13139 !!end
13140
13141 !!test
13142 Templates: Wiki Tables: 6. Templated tags, templated td-tags
13143 !! wikitext
13144 {{tbl-start}}
13145 {{!}}foo
13146 {{tbl-end}}
13147 !! html
13148 <table>
13149 <tr>
13150 <td>foo
13151 </td></tr></table>
13152
13153 !!end
13154
13155 ## This test case is very specific to Parsoid's internals
13156 ## and is hence only tested for Parsoid's code. Parsoid uses
13157 ## a <meta> marker tag for <ref> tags and they are expanded
13158 ## much later. We are verifying that this <meta> tag usage
13159 ## doesn't prevent foster parenting.
13160 !!test
13161 Templates: Wiki Tables: 7. Fosterable <ref>s should get fostered
13162 !!wikitext
13163 {{PartialTable}}<ref>foo</ref>
13164 |}
13165
13166 <references />
13167 !!html/parsoid
13168 <sup about="#mwt2" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Transclusion mw:Extension/ref" data-mw='{"parts":[{"template":{"target":{"wt":"PartialTable","href":"./Template:PartialTable"},"params":{},"i":0}},"&lt;ref>foo&lt;/ref>\n|}"]}'><a href="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></sup><table about="#mwt2">
13169 <tbody>
13170 </tbody></table>
13171
13172 <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>
13173 !!end
13174
13175 !! test
13176 Templates: Wiki Tables: 8. Fosterable meta-tags should get fostered
13177 !! wikitext
13178 {{echo|
13179 {{{!}}
13180 {{!}}-}}
13181 <onlyinclude>
13182 |foo
13183 </onlyinclude>
13184 {{!}}}
13185 !! html/parsoid
13186 <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{{!}}}"]}'>
13187 </span><meta typeof="mw:Includes/OnlyInclude" about="#mwt1"/><table about="#mwt1">
13188 <tbody><tr>
13189
13190 <td>foo
13191 <meta typeof="mw:Includes/OnlyInclude/End"/></td></tr>
13192 </tbody></table>
13193 !! end
13194
13195 !!test
13196 Templates: Lists: Multi-line list-items via templates
13197 !! wikitext
13198 *{{echo|a {{nonexistent|
13199 unused}}}}
13200 *{{echo|b {{nonexistent|
13201 unused}}}}
13202 !! html
13203 <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>
13204 <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>
13205
13206 !!end
13207
13208 !!test
13209 Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo)
13210 !! wikitext
13211 {{echo|''a}}{{echo|b''c''d}}{{echo|''e}}
13212 !! html
13213 <p><i>ab</i>c<i>d</i>e
13214 </p>
13215 !!end
13216
13217 !!test
13218 Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span)
13219 (PHP parser generates misnested html)
13220 !! wikitext
13221 {{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}}
13222 !! html/parsoid
13223 <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>
13224 !!end
13225
13226 !!test
13227 Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div)
13228 (PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s)
13229 !! options
13230 parsoid=wt2html,wt2wt
13231 !! wikitext
13232 {{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}}
13233 !! html
13234 <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>
13235 <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>
13236 <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>
13237 !!end
13238
13239 !!test
13240 Templates: Ugly nesting: 4. Divs opened/closed across templates
13241 !! wikitext
13242 a<div>b{{echo|c</div>d}}e
13243 !! html
13244 a<div>bc</div>de
13245
13246 !! html+tidy
13247 <p>a</p><div>bc</div><p>de
13248 </p>
13249 !! end
13250
13251 !! test
13252 Templates: Ugly templates: 3. newline-only template parameter
13253 !! wikitext
13254 foo {{echo|
13255 }}
13256 !! html
13257 <p>foo
13258 </p>
13259 !! end
13260
13261 # This looks like a bug: a single newline triggers p/br for some reason.
13262 !! test
13263 Templates: Ugly templates: 4. newline-only template parameter inconsistency
13264 !! wikitext
13265 {{echo|
13266 }}
13267 !! html
13268 <p><br />
13269 </p>
13270 !! end
13271
13272 # T66017 -- ugly wikitext with fostered content generates two template ranges that
13273 # have a true overlap (T1-start - T2-start - T1-end - T2-end).
13274 !! test
13275 Templates: Ugly templates: 5. Template encapsulation test: Non-trivial overlap of template ranges is properly handled
13276 !! wikitext
13277 {{echo|<table>}}
13278 {{echo|<div>foo}}
13279 {{echo|</table>}}
13280 !! html/parsoid
13281 <div about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;table>"}},"i":0}},"\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;div>foo"}},"i":1}},"\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;/table>"}},"i":2}}]}' data-parsoid='{"stx":"html","autoInsertedEnd":true,"pi":[[{"k":"1"}],[{"k":"1"}],[{"k":"1"}]]}'>foo
13282 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13283 </table>
13284 !! end
13285
13286 # T66017 -- ugly wikitext with fostered content generates two template ranges
13287 # that are "identical" and generate nesting cycles in the algorithm
13288 !! test
13289 Templates: Ugly templates: 6. Template encapsulation test: Cyclical nesting of template ranges is properly handled
13290 !! wikitext
13291 {{echo|<table><tr><td><table>}}
13292 {{echo|<div>}}
13293 {{echo|</div>}}
13294 !! html/parsoid
13295 <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"}'>
13296 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13297 </table></td></tr></tbody></table>
13298 !! end
13299
13300 !! test
13301 Templates: Parameters substituted at the top-level
13302 !! wikitext
13303 {{{foo|''who'' {{echo|me}}? '''never!'''}}}
13304
13305 {{{foo|bar|baz}}}
13306 !! html/php
13307 <p><i>who</i> me? <b>never!</b>
13308 </p><p>bar
13309 </p>
13310 !! html/parsoid
13311 <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>
13312
13313 <p about="#mwt3" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"foo"},"params":{"1":{"wt":"bar"},"2":{"wt":"baz"}},"i":0}}]}'>bar</p>
13314 !! end
13315
13316 !! test
13317 Templates: Param with empty arg in the final position
13318 !! wikitext
13319 {{{hi|}}}
13320 !! html/parsoid
13321 <span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"hi"},"params":{"1":{"wt":""}},"i":0}}]}'></span>
13322 !! end
13323
13324 !!test
13325 Parser Functions: 1. Simple example
13326 !! wikitext
13327 {{uc:foo}}
13328 !! html
13329 <p>FOO
13330 </p>
13331 !!end
13332
13333 !!test
13334 Parser Functions: 2. Nested use (only outermost should be marked up)
13335 !! wikitext
13336 {{uc:{{lc:FOO}}}}
13337 !! html
13338 <p>FOO
13339 </p>
13340 !!end
13341
13342 ###
13343 ### Pre-save transform tests
13344 ###
13345 !! test
13346 pre-save transform: subst:
13347 !! options
13348 pst
13349 !! wikitext
13350 {{subst:test}}
13351 !! html/php
13352 This is a test template
13353 !! end
13354
13355 !! test
13356 pre-save transform: normal template
13357 !! options
13358 pst
13359 !! wikitext
13360 {{test}}
13361 !! html/php
13362 {{test}}
13363 !! end
13364
13365 !! test
13366 pre-save transform: nonexistent template
13367 !! options
13368 pst
13369 !! wikitext
13370 {{thistemplatedoesnotexist}}
13371 !! html/php
13372 {{thistemplatedoesnotexist}}
13373 !! end
13374
13375 !! test
13376 pre-save transform: subst magic variables
13377 !! options
13378 pst
13379 !! wikitext
13380 {{subst:SITENAME}}
13381 !! html/php
13382 MediaWiki
13383 !! end
13384
13385 # This is T2089, which I fixed. -- wtm
13386 !! test
13387 pre-save transform: subst: templates with parameters
13388 !! options
13389 pst
13390 !! wikitext
13391 {{subst:paramtest|param="something else"}}
13392 !! html/php
13393 This is a test template with parameter "something else"
13394 !! end
13395
13396 !! article
13397 Template:nowikitest
13398 !! text
13399 <nowiki>'''not wiki'''</nowiki>
13400 !! endarticle
13401
13402 !! test
13403 pre-save transform: nowiki in subst (T3188)
13404 !! options
13405 pst
13406 !! wikitext
13407 {{subst:nowikitest}}
13408 !! html/php
13409 <nowiki>'''not wiki'''</nowiki>
13410 !! end
13411
13412 !! article
13413 Template:commenttest
13414 !! text
13415 This template has <!-- a comment --> in it.
13416 !! endarticle
13417
13418 !! test
13419 pre-save transform: comment in subst (T3936)
13420 !! options
13421 pst
13422 !! wikitext
13423 {{subst:commenttest}}
13424 !! html/php
13425 This template has <!-- a comment --> in it.
13426 !! end
13427
13428 !! test
13429 pre-save transform: unclosed tag
13430 !! options
13431 pst
13432 !! wikitext
13433 <nowiki>'''not wiki'''
13434 !! html/php
13435 <nowiki>'''not wiki'''
13436 !! end
13437
13438 !! test
13439 pre-save transform: mixed tag case
13440 !! options
13441 pst
13442 !! wikitext
13443 <NOwiki>'''not wiki'''</noWIKI>
13444 !! html/php
13445 <NOwiki>'''not wiki'''</noWIKI>
13446 !! end
13447
13448 !! test
13449 pre-save transform: unclosed comment in <nowiki>
13450 !! options
13451 pst
13452 !! wikitext
13453 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13454 !! html/php
13455 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13456 !!end
13457
13458 # Leading @ in this template definition works around a limitation
13459 # in parsoid's parserTests which otherwise strips the <span> from the
13460 # result (confusing it for a template wrapper)
13461 !! article
13462 Template:dangerous
13463 !!text
13464 @<span onmouseover="alert('crap')">Oh no</span>
13465 !!endarticle
13466
13467 !!test
13468 (confirming safety of fix for subst T3936)
13469 !! wikitext
13470 {{Template:dangerous}}
13471 !! html
13472 <p>@<span>Oh no</span>
13473 </p>
13474 !! end
13475
13476 !! test
13477 pre-save transform: comment containing gallery (T7024)
13478 !! options
13479 pst
13480 !! wikitext
13481 <!-- <gallery>data</gallery> -->
13482 !! html/php
13483 <!-- <gallery>data</gallery> -->
13484 !!end
13485
13486 !! test
13487 pre-save transform: comment containing extension
13488 !! options
13489 pst
13490 !! wikitext
13491 <!-- <tag>data</tag> -->
13492 !! html/php
13493 <!-- <tag>data</tag> -->
13494 !!end
13495
13496 !! test
13497 pre-save transform: comment containing nowiki
13498 !! options
13499 pst
13500 !! wikitext
13501 <!-- <nowiki>data</nowiki> -->
13502 !! html/php
13503 <!-- <nowiki>data</nowiki> -->
13504 !!end
13505
13506 !! test
13507 pre-save transform: <noinclude> in subst (T5298)
13508 !! options
13509 pst
13510 !! wikitext
13511 {{subst:Includes}}
13512 !! html/php
13513 Foobar
13514 !! end
13515
13516 !! test
13517 pre-save transform: <onlyinclude> in subst (T5298)
13518 !! options
13519 pst
13520 !! wikitext
13521 {{subst:Includes2}}
13522 !! html/php
13523 Foo
13524 !! end
13525
13526 !! article
13527 Template:SubstTest
13528 !!text
13529 {{<includeonly>subst:</includeonly>Includes}}
13530 !! endarticle
13531
13532 !! article
13533 Template:SafeSubstTest
13534 !! text
13535 {{<includeonly>safesubst:</includeonly>Includes}}
13536 !! endarticle
13537
13538 !! test
13539 T24297: safesubst: works during PST
13540 !! options
13541 pst
13542 !! wikitext
13543 {{subst:SafeSubstTest}}{{safesubst:SubstTest}}
13544 !! html/php
13545 FoobarFoobar
13546 !! end
13547
13548 !! test
13549 T24297: safesubst: works during normal parse
13550 !! wikitext
13551 {{SafeSubstTest}}
13552 !! html
13553 <p>Foobar
13554 </p>
13555 !! end
13556
13557 !! test
13558 subst: does not work during normal parse
13559 !! wikitext
13560 {{SubstTest}}
13561 !! html
13562 <p>{{subst:Includes}}
13563 </p>
13564 !! end
13565
13566 !! test
13567 pre-save transform: context links ("pipe trick")
13568 !! options
13569 pst
13570 !! wikitext
13571 [[Article (context)|]]
13572 [[Bar:Article|]]
13573 [[:Bar:Article|]]
13574 [[Bar:Article (context)|]]
13575 [[:Bar:Article (context)|]]
13576 [[|Article]]
13577 [[|Article (context)]]
13578 [[Bar:X (Y) Z|]]
13579 [[:Bar:X (Y) Z|]]
13580 !! html/php
13581 [[Article (context)|Article]]
13582 [[Bar:Article|Article]]
13583 [[:Bar:Article|Article]]
13584 [[Bar:Article (context)|Article]]
13585 [[:Bar:Article (context)|Article]]
13586 [[Article]]
13587 [[Article (context)]]
13588 [[Bar:X (Y) Z|X (Y) Z]]
13589 [[:Bar:X (Y) Z|X (Y) Z]]
13590 !! end
13591
13592 !! test
13593 pre-save transform: context links ("pipe trick") with interwiki prefix
13594 !! options
13595 pst
13596 !! wikitext
13597 [[interwiki:Article|]]
13598 [[:interwiki:Article|]]
13599 [[interwiki:Bar:Article|]]
13600 [[:interwiki:Bar:Article|]]
13601 !! html/php
13602 [[interwiki:Article|Article]]
13603 [[:interwiki:Article|Article]]
13604 [[interwiki:Bar:Article|Bar:Article]]
13605 [[:interwiki:Bar:Article|Bar:Article]]
13606 !! end
13607
13608 !! test
13609 pre-save transform: context links ("pipe trick") with parens in title
13610 !! options
13611 pst title=[[Somearticle (context)]]
13612 !! wikitext
13613 [[|Article]]
13614 !! html/php
13615 [[Article (context)|Article]]
13616 !! end
13617
13618 !! test
13619 pre-save transform: context links ("pipe trick") with comma in title
13620 !! options
13621 pst title=[[Someplace, Somewhere]]
13622 !! wikitext
13623 [[|Otherplace]]
13624 [[Otherplace, Elsewhere|]]
13625 [[Otherplace, Elsewhere, Anywhere|]]
13626 !! html/php
13627 [[Otherplace, Somewhere|Otherplace]]
13628 [[Otherplace, Elsewhere|Otherplace]]
13629 [[Otherplace, Elsewhere, Anywhere|Otherplace]]
13630 !! end
13631
13632 !! test
13633 pre-save transform: context links ("pipe trick") with parens and comma
13634 !! options
13635 pst title=[[Someplace (IGNORED), Somewhere]]
13636 !! wikitext
13637 [[|Otherplace]]
13638 [[Otherplace (place), Elsewhere|]]
13639 !! html/php
13640 [[Otherplace, Somewhere|Otherplace]]
13641 [[Otherplace (place), Elsewhere|Otherplace]]
13642 !! end
13643
13644 !! test
13645 pre-save transform: context links ("pipe trick") with comma and parens
13646 !! options
13647 pst title=[[Who, me? (context)]]
13648 !! wikitext
13649 [[|Yes, you.]]
13650 [[Me, Myself, and I (1937 song)|]]
13651 !! html/php
13652 [[Yes, you. (context)|Yes, you.]]
13653 [[Me, Myself, and I (1937 song)|Me, Myself, and I]]
13654 !! end
13655
13656 !! test
13657 pre-save transform: context links ("pipe trick") with namespace
13658 !! options
13659 pst title=[[Ns:Somearticle]]
13660 !! wikitext
13661 [[|Article]]
13662 !! html/php
13663 [[Ns:Article|Article]]
13664 !! end
13665
13666 !! test
13667 pre-save transform: context links ("pipe trick") with namespace and parens
13668 !! options
13669 pst title=[[Ns:Somearticle (context)]]
13670 !! wikitext
13671 [[|Article]]
13672 !! html/php
13673 [[Ns:Article (context)|Article]]
13674 !! end
13675
13676 !! test
13677 pre-save transform: context links ("pipe trick") with namespace and comma
13678 !! options
13679 pst title=[[Ns:Somearticle, Context, Whatever]]
13680 !! wikitext
13681 [[|Article]]
13682 !! html/php
13683 [[Ns:Article, Context, Whatever|Article]]
13684 !! end
13685
13686 !! test
13687 pre-save transform: context links ("pipe trick") with namespace, comma and parens
13688 !! options
13689 pst title=[[Ns:Somearticle, Context (context)]]
13690 !! wikitext
13691 [[|Article]]
13692 !! html/php
13693 [[Ns:Article (context)|Article]]
13694 !! end
13695
13696 !! test
13697 pre-save transform: context links ("pipe trick") with namespace, parens and comma
13698 !! options
13699 pst title=[[Ns:Somearticle (IGNORED), Context]]
13700 !! wikitext
13701 [[|Article]]
13702 !! html/php
13703 [[Ns:Article, Context|Article]]
13704 !! end
13705
13706 !! test
13707 pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, T32149)
13708 !! options
13709 pst
13710 !! wikitext
13711 [[Article(context)|]]
13712 [[Bar:Article(context)|]]
13713 [[:Bar:Article(context)|]]
13714 [[|Article(context)]]
13715 [[Bar:X(Y)Z|]]
13716 [[:Bar:X(Y)Z|]]
13717 !! html/php
13718 [[Article(context)|Article]]
13719 [[Bar:Article(context)|Article]]
13720 [[:Bar:Article(context)|Article]]
13721 [[Article(context)]]
13722 [[Bar:X(Y)Z|X(Y)Z]]
13723 [[:Bar:X(Y)Z|X(Y)Z]]
13724 !! end
13725
13726 !! test
13727 pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, T32149)
13728 !! options
13729 pst
13730 !! wikitext
13731 [[Article (context)|]]
13732 [[Bar:Article (context)|]]
13733 [[:Bar:Article (context)|]]
13734 [[|Article (context)]]
13735 [[Bar:X (Y) Z|]]
13736 [[:Bar:X (Y) Z|]]
13737 !! html/php
13738 [[Article (context)|Article]]
13739 [[Bar:Article (context)|Article]]
13740 [[:Bar:Article (context)|Article]]
13741 [[Article (context)]]
13742 [[Bar:X (Y) Z|X (Y) Z]]
13743 [[:Bar:X (Y) Z|X (Y) Z]]
13744 !! end
13745
13746 !! test
13747 pre-save transform: context links ("pipe trick") with parens and no space (Korean style, T32149)
13748 !! options
13749 pst
13750 !! wikitext
13751 [[Article(context)|]]
13752 [[Bar:Article(context)|]]
13753 [[:Bar:Article(context)|]]
13754 [[|Article(context)]]
13755 [[Bar:X(Y)Z|]]
13756 [[:Bar:X(Y)Z|]]
13757 !! html/php
13758 [[Article(context)|Article]]
13759 [[Bar:Article(context)|Article]]
13760 [[:Bar:Article(context)|Article]]
13761 [[Article(context)]]
13762 [[Bar:X(Y)Z|X(Y)Z]]
13763 [[:Bar:X(Y)Z|X(Y)Z]]
13764 !! end
13765
13766 !! test
13767 pre-save transform: context links ("pipe trick") with commas (T23660)
13768 !! options
13769 pst
13770 !! wikitext
13771 [[Article (context), context|]]
13772 [[Article (context),context|]]
13773 [[Bar:Article (context), context|]]
13774 [[Bar:Article (context),context|]]
13775 [[:Bar:Article (context), context|]]
13776 [[:Bar:Article (context),context|]]
13777 !! html/php
13778 [[Article (context), context|Article]]
13779 [[Article (context),context|Article]]
13780 [[Bar:Article (context), context|Article]]
13781 [[Bar:Article (context),context|Article]]
13782 [[:Bar:Article (context), context|Article]]
13783 [[:Bar:Article (context),context|Article]]
13784 !! end
13785
13786 !! test
13787 Parsoid: backwards pipe trick
13788 !! wikitext
13789 [[|'''bar''']]
13790 !! html/php
13791 <p>[[|<b>bar</b>]]
13792 </p>
13793 !! html/parsoid
13794 <p>[[|<b>bar</b>]]</p>
13795 !! end
13796
13797 !! test
13798 pre-save transform: trim trailing empty lines
13799 !! options
13800 pst
13801 !! wikitext
13802 Empty lines are trimmed
13803
13804
13805
13806
13807 !! html/php
13808 Empty lines are trimmed
13809 !! end
13810
13811 !! test
13812 pre-save transform: Signature expansion
13813 !! options
13814 pst
13815 !! wikitext
13816 * ~~~
13817 * ~~~~
13818 * ~~~~~
13819 * <noinclude>~~~</noinclude>
13820 * <includeonly>~~~</includeonly>
13821 * <onlyinclude>~~~</onlyinclude>
13822 !! html/php
13823 * [[Special:Contributions/127.0.0.1|127.0.0.1]]
13824 * [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
13825 * 00:02, 1 January 1970 (UTC)
13826 * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
13827 * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
13828 * <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>
13829 !! end
13830
13831
13832 !! test
13833 ParserOutput flags from signature expansion (T84843)
13834 !! options
13835 pst
13836 showflags
13837 !! wikitext
13838 ~~~~
13839 !! html/php
13840 [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
13841 flags=user-signature
13842 !! end
13843
13844
13845 !! test
13846 pre-save transform: Signature expansion in nowiki tags (T2093)
13847 !! options
13848 pst disabled
13849 !! wikitext
13850 Shall not expand:
13851
13852 <nowiki>~~~~</nowiki>
13853
13854 <includeonly><nowiki>~~~~</nowiki></includeonly>
13855
13856 <noinclude><nowiki>~~~~</nowiki></noinclude>
13857
13858 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
13859
13860 {{subst:Foo}} shall be converted to FOO
13861
13862 As well as inside noinclude/onlyinclude
13863 <noinclude>{{subst:Foo}}</noinclude>
13864 <onlyinclude>{{subst:Foo}}</onlyinclude>
13865
13866 But not inside includeonly
13867 <includeonly>{{subst:Foo}}</includeonly>
13868 !! html/php
13869 Shall not expand:
13870
13871 <nowiki>~~~~</nowiki>
13872
13873 <includeonly><nowiki>~~~~</nowiki></includeonly>
13874
13875 <noinclude><nowiki>~~~~</nowiki></noinclude>
13876
13877 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
13878
13879 FOO shall be converted to FOO
13880
13881 As well as inside noinclude/onlyinclude
13882 <noinclude>FOO</noinclude>
13883 <onlyinclude>FOO</onlyinclude>
13884
13885 But not inside includeonly
13886 <includeonly>{{subst:Foo}}</includeonly>
13887 !! end
13888
13889 !! test
13890 Parsoid: Recognize nowiki with trailing space in tags
13891 !! options
13892 parsoid=wt2html
13893 !! wikitext
13894 <nowiki ><div>[[foo]]</nowiki >
13895
13896 a<nowiki / >b
13897
13898 c<nowiki />d
13899
13900 e<nowiki/ >f
13901 !! html
13902 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
13903 <p>ab</p>
13904 <p>cd</p>
13905 <p>ef</p>
13906 !! end
13907
13908 !! test
13909 Parsoid: Recognize nowiki with odd capitalization
13910 !! options
13911 parsoid=wt2html
13912 !! wikitext
13913 <noWikI ><div>[[foo]]</Nowiki >
13914 !! html
13915 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
13916 !! end
13917
13918
13919 !! test
13920 Parsoid: Escape nowiki with trailing space in tags
13921 !! options
13922 parsoid=html2wt
13923 !! html/parsoid
13924 <p>&lt;nowiki &gt; foo &lt/nowiki ></p>
13925 <p>a&lt;nowiki /&gt;b</p>
13926 <p>c&lt;nowiki/ &gt;d</p>
13927 !! wikitext
13928 &lt;nowiki &gt; foo &lt;/nowiki &gt;
13929
13930 a&lt;nowiki /&gt;b
13931
13932 c&lt;nowiki/ &gt;d
13933 !! end
13934
13935 !! test
13936 Parsoid: Escape weird noWikI capitalizations
13937 !! options
13938 parsoid=html2wt
13939 !! html/parsoid
13940 <p>&lt;noWikI &gt; foo &lt/NoWikI ></p>
13941 !! wikitext
13942 &lt;noWikI &gt; foo &lt;/NoWikI &gt;
13943 !! end
13944
13945 ###
13946 ### Message transform tests
13947 ###
13948 !! test
13949 message transform: magic variables
13950 !! options
13951 msg
13952 !! wikitext
13953 {{SITENAME}}
13954 !! html
13955 MediaWiki
13956 !! end
13957
13958 !! test
13959 message transform: should not transform wiki markup
13960 !! options
13961 msg
13962 !! wikitext
13963 ''test''
13964 !! html
13965 ''test''
13966 !! end
13967
13968 !! test
13969 message transform: <noinclude> in transcluded template (T6926)
13970 !! options
13971 msg
13972 !! wikitext
13973 {{Includes}}
13974 !! html
13975 Foobar
13976 !! end
13977
13978 !! test
13979 message transform: <onlyinclude> in transcluded template (T6926)
13980 !! options
13981 msg
13982 !! wikitext
13983 {{Includes2}}
13984 !! html
13985 Foo
13986 !! end
13987
13988 !! test
13989 {{#special:}} page name, known
13990 !! options
13991 msg
13992 !! wikitext
13993 {{#special:Recentchanges}}
13994 !! html
13995 Special:RecentChanges
13996 !! end
13997
13998 !! test
13999 {{#special:}} page name with subpage, known
14000 !! options
14001 msg
14002 !! wikitext
14003 {{#special:Recentchanges/param}}
14004 !! html
14005 Special:RecentChanges/param
14006 !! end
14007
14008 !! test
14009 {{#special:}} page name, unknown
14010 !! options
14011 msg
14012 !! wikitext
14013 {{#special:foobar nonexistent}}
14014 !! html
14015 Special:Foobar nonexistent
14016 !! end
14017
14018 !! test
14019 {{#speciale:}} page name, known
14020 !! options
14021 msg
14022 !! wikitext
14023 {{#speciale:Recentchanges}}
14024 !! html
14025 Special:RecentChanges
14026 !! end
14027
14028 !! test
14029 {{#speciale:}} page name with subpage, known
14030 !! options
14031 msg
14032 !! wikitext
14033 {{#speciale:Recentchanges/param}}
14034 !! html
14035 Special:RecentChanges/param
14036 !! end
14037
14038 !! test
14039 {{#speciale:}} page name, unknown
14040 !! options
14041 msg
14042 !! wikitext
14043 {{#speciale:foobar nonexistent}}
14044 !! html
14045 Special:Foobar_nonexistent
14046 !! end
14047
14048 ###
14049 ### Images
14050 ###
14051 ### For Parsoid-specific tests, see
14052 #### https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
14053
14054 !! test
14055 Simple image
14056 !! options
14057 parsoid=wt2html,wt2wt,html2html
14058 !! wikitext
14059 [[Image:foobar.jpg]]
14060 !! html/php
14061 <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>
14062 </p>
14063 !! html/parsoid
14064 <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>
14065 !! end
14066
14067 !! test
14068 Serialize simple image with span wrapper
14069 !! options
14070 parsoid=html2wt
14071 !! html/parsoid
14072 <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>
14073 !! wikitext
14074 [[File:Foobar.jpg]]
14075 !! end
14076
14077 !! test
14078 Simple image (using File: namespace, now canonical)
14079 !! wikitext
14080 [[File:Foobar.jpg]]
14081 !! html/php
14082 <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>
14083 </p>
14084 !! html/parsoid
14085 <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>
14086 !! end
14087
14088 !! test
14089 Right-aligned image
14090 !! wikitext
14091 [[File:Foobar.jpg|right]]
14092 !! html/php
14093 <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>
14094
14095 !! html/parsoid
14096 <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>
14097 !! end
14098
14099 !! test
14100 Image with caption
14101 !! wikitext
14102 [[File:Foobar.jpg|right|Caption text]]
14103 !! html/php
14104 <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>
14105
14106 !! html/parsoid
14107 <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>
14108 !! end
14109
14110 !! test
14111 Image with caption, T55312 #1
14112 !! wikitext
14113 [[File:Foobar.jpg|right|Caption page stuff]]
14114 !! html/php
14115 <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>
14116
14117 !! html/parsoid
14118 <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>
14119 !! end
14120
14121 !! test
14122 Image with caption, T55312 #2
14123 !! wikitext
14124 [[File:Foobar.jpg|right|Caption page=]]
14125 !! html/php
14126 <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>
14127
14128 !! html/parsoid
14129 <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>
14130 !! end
14131
14132 !! test
14133 Image with caption, T55312 #3
14134 !! wikitext
14135 [[File:Foobar.jpg|right|Caption page=stuff]]
14136 !! html/php
14137 <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>
14138
14139 !! html/parsoid
14140 <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>
14141 !! end
14142
14143 !! test
14144 Image caption with pipe entity
14145 !! wikitext
14146 [[File:Foobar.jpg|thumb|one &#x7C; two]]
14147 [[File:Foobar.jpg|thumb|one ''two'' &#x7C; three]]
14148 !! html/php
14149 <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>
14150 <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>
14151
14152 !! html/parsoid
14153 <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>
14154 <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>
14155 !! end
14156
14157 !! test
14158 Allow empty links in image captions (T62753)
14159 !! options
14160 thumbsize=220
14161 !! wikitext
14162 [[File:Foobar.jpg|thumb|Caption [[Link1]]
14163 [[]]
14164 [[Link2]]
14165 ]]
14166 !! html/php
14167 <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>
14168
14169 !! html/parsoid
14170 <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>
14171 [[]]
14172 <a rel="mw:WikiLink" href="./Link2" title="Link2" data-parsoid='{"stx":"simple","a":{"href":"./Link2"},"sa":{"href":"Link2"}}'>Link2</a>
14173 </figcaption></figure>
14174 !! end
14175
14176 !! test
14177 Titles in unlinked images (T23454)
14178 !! wikitext
14179 [[File:Foobar.jpg|link=|stuff]]
14180 !! html/php
14181 <p><img alt="stuff" src="http://example.com/images/3/3a/Foobar.jpg" title="stuff" width="1941" height="220" />
14182 </p>
14183 !! html/parsoid
14184 <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>
14185 !! end
14186
14187 !! test
14188 Link with empty target
14189 !! wikitext
14190 [[]]
14191 !! html
14192 <p>[[]]
14193 </p>
14194 !! end
14195
14196 !! test
14197 Image with link trail
14198 !! wikitext
14199 Linktrails should not work for images: [[File:Foobar.jpg]]s
14200 !! html/php
14201 <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
14202 </p>
14203 !! html/parsoid
14204 <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>
14205 !! end
14206
14207 !! test
14208 Image with empty attribute
14209 !! options
14210 parsoid=wt2html,wt2wt,html2html
14211 !! wikitext
14212 [[File:Foobar.jpg|right||Caption text]]
14213 !! html/php
14214 <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>
14215
14216 !! html/parsoid
14217 <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>
14218 !! end
14219
14220 !! test
14221 1. Block image with individual attributes from templates
14222 !! wikitext
14223 [[File:Foobar.jpg|thumb|{{echo|137px}}|This is a caption]]
14224 !! html/php
14225 <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>
14226
14227 !! html/parsoid
14228 <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>
14229 !! end
14230
14231 !! test
14232 2. Block Image with individual attributes from templates
14233 !! wikitext
14234 [[File:Foobar.jpg|{{echo|thumb}}|{{echo|137px}}|This is a caption]]
14235 !! html/php
14236 <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>
14237
14238 !! html/parsoid
14239 <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>
14240 !! end
14241
14242 !! test
14243 3. Inline image with individual attributes from templates
14244 !! wikitext
14245 [[File:Foobar.jpg|{{echo|50px}}]]
14246 !! html/php
14247 <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>
14248 </p>
14249 !! html/parsoid
14250 <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>
14251 !! end
14252
14253 ## Parsoid does not provide editing support for images where templates produce multiple image attributes.
14254 ## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
14255 !! test
14256 Image with multiple attributes from the same template
14257 !! wikitext
14258 [[File:Foobar.jpg|{{image_attribs}}]]
14259 !! html/php
14260 <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>
14261
14262 !! html/parsoid
14263 <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>
14264 !! end
14265
14266 !! test
14267 Image with link tails
14268 !! options
14269 thumbsize=220
14270 !! wikitext
14271 123[[File:Foobar.jpg]]456
14272 123[[File:Foobar.jpg|right]]456
14273 123[[File:Foobar.jpg|thumb]]456
14274 !! html/php
14275 <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
14276 </p>
14277 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
14278 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
14279
14280 !! html/php+tidy
14281 <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
14282 </p><p>
14283 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
14284 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
14285 </p>
14286 !! html/parsoid
14287 <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>
14288 <p>123</p><figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure><p>456</p>
14289 <p>123</p><figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a></figure><p>456</p>
14290 !! end
14291
14292 !! test
14293 Image with multiple captions -- only last one is accepted
14294 !! wikitext
14295 [[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]]
14296 !! html/php
14297 <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>
14298
14299 !! html/parsoid
14300 <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>
14301 !! end
14302
14303 !! test
14304 Image with multiple widths -- use last
14305 !! wikitext
14306 [[File:Foobar.jpg|200px|300px|caption]]
14307 !! html/php
14308 <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>
14309 </p>
14310 !! html/parsoid
14311 <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>
14312 !! end
14313
14314 !! test
14315 Image with multiple alignments -- use first (T50664)
14316 !! options
14317 thumbsize=220
14318 !! wikitext
14319 [[File:Foobar.jpg|thumb|left|right|center|caption]]
14320
14321 [[File:Foobar.jpg|middle|text-top|caption]]
14322 !! html/php
14323 <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>
14324 <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>
14325 </p>
14326 !! html/parsoid
14327 <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>
14328 <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>
14329 !! end
14330
14331 !! test
14332 Image with width attribute at different positions
14333 !! wikitext
14334 [[File:Foobar.jpg|200px|right|Caption]]
14335 [[File:Foobar.jpg|right|200px|Caption]]
14336 [[File:Foobar.jpg|right|Caption|200px]]
14337 !! html/php
14338 <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>
14339 <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>
14340 <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>
14341
14342 !! html/parsoid
14343 <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>
14344 <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>
14345 <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>
14346 !! end
14347
14348 # a sad bit of backward-compatibility
14349 !! test
14350 Image with size specified with pxpx (T15500, T53628)
14351 !! options
14352 parsoid=wt2html,wt2wt,html2html
14353 !! wikitext
14354 [[File:Foobar.jpg|20pxpx]]
14355 [[File:Foobar.jpg|200x20pxpx]]
14356 !! html/php
14357 <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>
14358 <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>
14359 </p>
14360 !! html/parsoid
14361 <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>
14362 !! end
14363
14364 !! test
14365 Image with link parameter, wiki target
14366 !! wikitext
14367 [[File:Foobar.jpg|link=Main Page]]
14368 !! html/php
14369 <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>
14370 </p>
14371 !! html/parsoid
14372 <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>
14373 !! end
14374
14375 # parsoid T51293 (part 1)
14376 !! test
14377 Image with link parameter, URL target
14378 !! wikitext
14379 [[File:Foobar.jpg|link=http://example.com/]]
14380 !! html/php
14381 <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>
14382 </p>
14383 !! html/parsoid
14384 <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>
14385 !! end
14386
14387 # parsoid T51293 (part 2)
14388 !! test
14389 Image with link parameter, protocol-less URL target
14390 !! wikitext
14391 [[File:Foobar.jpg|link=//example.com/]]
14392 !! html/php
14393 <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>
14394 </p>
14395 !! html/parsoid
14396 <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>
14397 !! end
14398
14399 !! test
14400 Escaping non-block captions (T107435)
14401 !! options
14402 parsoid={
14403 "modes": ["wt2wt"],
14404 "changes": [
14405 ["[typeof~='mw:Image']", "attr", "data-mw", "{\"caption\": \"|\"}"]
14406 ]
14407 }
14408 !! wikitext
14409 [[Image:Foobar.jpg|caption]]
14410 !! wikitext/edited
14411 [[Image:Foobar.jpg|<nowiki>|</nowiki>]]
14412 !! end
14413
14414 # wgExternalLinkTarget not supported by Parsoid
14415 !! test
14416 Image with link parameter, wgExternalLinkTarget
14417 !! wikitext
14418 [[Image:foobar.jpg|link=http://example.com/]]
14419 !! config
14420 wgExternalLinkTarget='foobar'
14421 !! html/php
14422 <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>
14423 </p>
14424 !! end
14425
14426 !! test
14427 Image with link parameter, wgNoFollowLinks set to false
14428 !! wikitext
14429 [[Image:foobar.jpg|link=http://example.com/]]
14430 !! config
14431 wgNoFollowLinks=false
14432 !! html/php
14433 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14434 </p>
14435 !! end
14436
14437 !! test
14438 Image with link parameter, wgNoFollowDomainExceptions
14439 !! wikitext
14440 [[Image:foobar.jpg|link=http://example.com/]]
14441 !! config
14442 wgNoFollowDomainExceptions='example.com'
14443 !! html/php
14444 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14445 </p>
14446 !! end
14447
14448 # wgExternalLinkTarget not supported by Parsoid
14449 !! test
14450 Image with link parameter, wgExternalLinkTarget, unnamed parameter
14451 !! wikitext
14452 [[Image:foobar.jpg|link=http://example.com/|Title]]
14453 !! config
14454 wgExternalLinkTarget='foobar'
14455 !! html/php
14456 <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>
14457 </p>
14458 !! end
14459
14460 !! test
14461 Image with empty link parameter
14462 !! wikitext
14463 [[File:Foobar.jpg|link=]]
14464 !! html/php
14465 <p><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" />
14466 </p>
14467 !! html/parsoid
14468 <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>
14469 !! end
14470
14471 !! test
14472 Image with link parameter (wiki target) and unnamed parameter
14473 !! wikitext
14474 [[File:Foobar.jpg|link=Main_Page|Title]]
14475 !! html/php
14476 <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>
14477 </p>
14478 !! html/parsoid
14479 <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>
14480 !! end
14481
14482 !! test
14483 Image with link parameter (URL target) and unnamed parameter
14484 !! wikitext
14485 [[File:Foobar.jpg|link=http://example.com/|Title]]
14486 !! html/php
14487 <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>
14488 </p>
14489 !! html/parsoid
14490 <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>
14491 !! end
14492
14493 !! test
14494 Thumbnail image with link parameter
14495 !! options
14496 thumbsize=220
14497 parsoid=wt2html,wt2wt,html2html
14498 !! wikitext
14499 [[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
14500 !! html/php
14501 <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>
14502
14503 !! html/parsoid
14504 <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>
14505 !! end
14506
14507 !! test
14508 Manually-specified thumbnail image
14509 !! options
14510 thumbsize=220
14511 !! wikitext
14512 [[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
14513 !! html/php
14514 <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>
14515
14516 !! html/parsoid
14517 <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>
14518 !! end
14519
14520 !! test
14521 Manually-specified thumbnail image with explicit link to wiki page
14522 !! options
14523 thumbsize=220
14524 parsoid=wt2html,wt2wt,html2html
14525 !! wikitext
14526 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
14527 !! html/php
14528 <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>
14529
14530 !! html/parsoid
14531 <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>
14532 !! end
14533
14534 !! test
14535 Manually-specified thumbnail image with explicit link to url
14536 !! options
14537 thumbsize=220
14538 parsoid=wt2html,wt2wt,html2html
14539 !! wikitext
14540 [[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
14541 !! html/php
14542 <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>
14543
14544 !! html/parsoid
14545 <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>
14546 !! end
14547
14548 !! test
14549 Manually-specified thumbnail image with explicit no link
14550 !! options
14551 thumbsize=220
14552 parsoid=wt2html,wt2wt,html2html
14553 !! wikitext
14554 [[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
14555 !! html/php
14556 <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>
14557
14558 !! html/parsoid
14559 <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>
14560 !! end
14561
14562 !! test
14563 Manually-specified thumbnail image with explicit link and alt text
14564 !! options
14565 thumbsize=220
14566 parsoid=wt2html,wt2wt,html2html
14567 !! wikitext
14568 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
14569 !! html/php
14570 <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>
14571
14572 !! html/parsoid
14573 <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>
14574 !! end
14575
14576 !! test
14577 Image with frame and link
14578 !! options
14579 parsoid=wt2html,wt2wt,html2html
14580 !! wikitext
14581 [[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
14582 !! html/php
14583 <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>
14584
14585 !! html/parsoid
14586 <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>
14587 !! end
14588
14589 !! test
14590 Image with frame and link and explicit alt
14591 !! options
14592 parsoid=wt2html,wt2wt,html2html
14593 !! wikitext
14594 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]]
14595 !! html/php
14596 <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>
14597
14598 !! html/parsoid
14599 <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>
14600 !! end
14601
14602 !! test
14603 Image with wiki markup in implicit alt
14604 !! wikitext
14605 [[Image:Foobar.jpg|testing '''bold''' in alt]]
14606
14607 [[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
14608 !! html/php
14609 <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>
14610 </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>
14611 </p>
14612 !! html/parsoid
14613 <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>
14614
14615 <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>
14616 !! end
14617
14618 !! test
14619 Alt image option should handle most kinds of wikitext without barfing
14620 !! wikitext
14621 [[Image:Foobar.jpg|thumb|This is the image caption|alt=This is a [[link]] and a {{echo|''bold template''}}.]]
14622 !! html/php
14623 <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>
14624
14625 !! html/parsoid
14626 <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>
14627 !! end
14628
14629 !! test
14630 Image with table with attributes in caption
14631 !! options
14632 parsoid=wt2html,html2html
14633 !! wikitext
14634 [[File:Foobar.jpg|thumb|
14635 {| class="123" |
14636 |- class="456" |
14637 | ha
14638 |}
14639 ]]
14640 !! html/parsoid
14641 <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>
14642 <table class="123">
14643 <tbody><tr class="456" data-parsoid='{"startTagSrc":"|-"}'>
14644 <td> ha</td></tr>
14645 </tbody></table>
14646 </figcaption></figure>
14647 !! end
14648
14649 !! test
14650 Image with table with rows from templates in caption
14651 !! wikitext
14652 [[File:Foobar.jpg|thumb|
14653 {|
14654 {{echo|{{!}} hi}}
14655 |}
14656 ]]
14657 !! html/parsoid
14658 <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>
14659 <table>
14660 <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>
14661 </tbody></table>
14662 </figcaption></figure>
14663 !! end
14664
14665 !! test
14666 Image with nested tables in caption
14667 !! wikitext
14668 [[File:Foobar.jpg|thumb|Foo<br />
14669 {|
14670 |
14671 {|
14672 |z
14673 |}
14674 |}
14675 ]]
14676 !! html/parsoid
14677 <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}'/>
14678 <table>
14679 <tbody><tr><td>
14680 <table>
14681 <tbody><tr><td>z</td></tr>
14682 </tbody></table></td></tr>
14683 </tbody></table>
14684 </figcaption></figure>
14685 !! end
14686
14687 ###################
14688 # Conflicting image format options.
14689 # First option specified should 'win'.
14690 # All three cases in each test should be identical.
14691
14692 !! test
14693 Image with 'frameless' first.
14694 !! options
14695 parsoid=wt2html,wt2wt,html2html
14696 !! wikitext
14697 [[File:Foobar.jpg|frameless|caption]]
14698
14699 [[File:Foobar.jpg|frameless|frame|caption]]
14700
14701 [[File:Foobar.jpg|frameless|thumb|caption]]
14702 !! html/php
14703 <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>
14704 </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>
14705 </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>
14706 </p>
14707 !! html/parsoid
14708 <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>
14709 <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>
14710 <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>
14711 !! end
14712
14713 !! test
14714 Image with 'frame' first.
14715 !! options
14716 parsoid=wt2html,wt2wt,html2html
14717 !! wikitext
14718 [[File:Foobar.jpg|frame|caption]]
14719 [[File:Foobar.jpg|frame|frameless|caption]]
14720 [[File:Foobar.jpg|frame|thumb|caption]]
14721 !! html/php
14722 <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>
14723 <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>
14724 <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>
14725
14726 !! html/parsoid
14727 <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>
14728 <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>
14729 <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>
14730 !! end
14731
14732 !! test
14733 Image with 'thumb' first.
14734 !! options
14735 parsoid=wt2html,wt2wt,html2html
14736 !! wikitext
14737 [[File:Foobar.jpg|thumb|caption]]
14738 [[File:Foobar.jpg|thumb|frameless|caption]]
14739 [[File:Foobar.jpg|thumb|frame|caption]]
14740 !! html/php
14741 <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>
14742 <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>
14743 <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>
14744
14745 !! html/parsoid
14746 <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>
14747 <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>
14748 <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>
14749 !! end
14750
14751 ###################
14752 # Image sizing.
14753 # See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
14754 # and https://phabricator.wikimedia.org/T64258
14755 # Foobar has actual size of 1941x220
14756 # 1. Thumbs & frameless always reduce, can't be enlarged unless it's
14757 # a scalable format.
14758 # 2. Framed images always ignore size options; always render at default size.
14759 # 3. "Unspecified format" and border are the only types which can be
14760 # enlarged.
14761
14762 !! test
14763 Image: unspecified format and border enlarge
14764 !! options
14765 parsoid=wt2html,wt2wt,html2html
14766 !! wikitext
14767 [[File:Foobar.jpg|2000px]]
14768
14769 [[File:Foobar.jpg|border|2000px]]
14770 !! html/php
14771 <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>
14772 </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>
14773 </p>
14774 !! html/parsoid
14775 <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>
14776 <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>
14777 !! end
14778
14779 !! test
14780 Image: "unspecified format" and border reduce
14781 !! options
14782 parsoid=wt2html,wt2wt,html2html
14783 !! wikitext
14784 [[File:Foobar.jpg|1000px]]
14785
14786 [[File:Foobar.jpg|border|1000px]]
14787 !! html/php
14788 <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>
14789 </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>
14790 </p>
14791 !! html/parsoid
14792 <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>
14793 <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>
14794 !! end
14795
14796 !! test
14797 Image: thumbs reduce
14798 !! options
14799 parsoid=wt2html,wt2wt,html2html
14800 !! wikitext
14801 [[File:Foobar.jpg|thumb|50px]]
14802 !! html/php
14803 <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>
14804
14805 !! html/parsoid
14806 <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>
14807 !! end
14808
14809 !! test
14810 Image: bitmap thumbs can't be enlarged past original size, but vector can.
14811 !! options
14812 parsoid=wt2html,wt2wt,html2html
14813 !! wikitext
14814 [[File:Foobar.jpg|thumb|2000px]]
14815
14816 [[File:Foobar.svg|thumb|2000px]]
14817 !! html/php
14818 <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>
14819 <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>
14820
14821 !! html/parsoid
14822 <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>
14823 <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>
14824 !! end
14825
14826 !! test
14827 Image: frameless can reduce in size
14828 !! options
14829 parsoid=wt2html,wt2wt,html2html
14830 !! wikitext
14831 [[File:Foobar.jpg|frameless|50px]]
14832 !! html/php
14833 <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>
14834 </p>
14835 !! html/parsoid
14836 <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>
14837 !! end
14838
14839 !! test
14840 Image: bitmap frameless can't be enlarged past original size, but vector can
14841 !! options
14842 parsoid=wt2html,wt2wt,html2html
14843 !! wikitext
14844 [[File:Foobar.jpg|frameless|2000px]]
14845
14846 [[File:Foobar.svg|frameless|2000px]]
14847 !! html/php
14848 <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>
14849 </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>
14850 </p>
14851 !! html/parsoid
14852 <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>
14853 <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>
14854 !! end
14855
14856 !! test
14857 Image: framed images are always unscaled.
14858 !! options
14859 parsoid=wt2html,wt2wt,html2html
14860 !! wikitext
14861 [[File:Foobar.jpg|frame]]
14862
14863 [[File:Foobar.jpg|frame|50px]]
14864
14865 [[File:Foobar.jpg|frame|50x50px]]
14866
14867 [[File:Foobar.jpg|frame|2000px]]
14868 !! html/php
14869 <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>
14870 <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>
14871 <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>
14872 <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>
14873
14874 !! html/parsoid
14875 <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>
14876 <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>
14877 <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>
14878 <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>
14879 !! end
14880
14881 ###################
14882
14883 !! test
14884 Link to image page- image page normally doesn't exists, hence edit link
14885 Add test with existing image page
14886 #<p><a href="/wiki/File:Test" title="Image:Test">Image:test</a>
14887 !! wikitext
14888 [[:Image:test]]
14889 !! html
14890 <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>
14891 </p>
14892 !! end
14893
14894 !! test
14895 T20784 Link to non-existent image page with caption should use caption as link text
14896 !! wikitext
14897 [[:Image:test|caption]]
14898 !! html
14899 <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>
14900 </p>
14901 !! end
14902
14903 !! test
14904 Frameless image caption with a free URL
14905 !! wikitext
14906 [[File:Foobar.jpg|http://example.com]]
14907 !! html/php
14908 <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>
14909 </p>
14910 !! html/parsoid
14911 <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>
14912 !! end
14913
14914 !! test
14915 Thumbnail image caption with a free URL
14916 !! options
14917 thumbsize=220
14918 !! wikitext
14919 [[File:Foobar.jpg|thumb|http://example.com]]
14920 !! html/php
14921 <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>
14922
14923 !! html/parsoid
14924 <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>
14925 !! end
14926
14927 !! test
14928 Thumbnail image caption with a free URL and explicit alt
14929 !! options
14930 thumbsize=220
14931 parsoid=wt2html,wt2wt,html2html
14932 !! wikitext
14933 [[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]]
14934 !! html/php
14935 <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>
14936
14937 !! html/parsoid
14938 <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>
14939 !! end
14940
14941 !! test
14942 SVG thumbnails with no language set
14943 !! options
14944 !! wikitext
14945 [[File:Foobar.svg|thumb|caption]]
14946 !! html/php
14947 <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>
14948
14949 !! html/parsoid
14950 <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>
14951 !! end
14952
14953 !! test
14954 SVG thumbnails with language de
14955 !! options
14956 parsoid=wt2html,wt2wt,html2html
14957 !! wikitext
14958 [[File:Foobar.svg|thumb|caption|lang=de]]
14959 !! html/php
14960 <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>
14961
14962 !! html/parsoid
14963 <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>
14964 !! end
14965
14966 !! test
14967 SVG thumbnails with invalid language code
14968 !! options
14969 parsoid=wt2html,wt2wt,html2html
14970 !! wikitext
14971 [[File:Foobar.svg|thumb|caption|lang=invalid:language:code]]
14972 !! html/php
14973 <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>
14974
14975 !! html/parsoid
14976 <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>
14977 !! end
14978
14979 !! test
14980 T3887: A ISBN with a thumbnail
14981 !! wikitext
14982 [[File:Foobar.jpg|thumb|ISBN 1235467890]]
14983 !! html/php
14984 <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>
14985
14986 !! html/parsoid
14987 <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>
14988 !! end
14989
14990 !! test
14991 T3887: A RFC with a thumbnail
14992 !! wikitext
14993 [[File:Foobar.jpg|thumb|This is RFC 12354]]
14994 !! html/php
14995 <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>
14996
14997 !! html/parsoid
14998 <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 text">RFC 12354</a></figcaption></figure>
14999 !! end
15000
15001 !! test
15002 T3887: A mailto link with a thumbnail
15003 !! wikitext
15004 [[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
15005 !! html/php
15006 <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>
15007
15008 !! html/parsoid
15009 <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>
15010 !! end
15011
15012 # Pending resolution to T2368
15013 !! test
15014 T2648: Frameless image caption with a link
15015 !! wikitext
15016 [[File:Foobar.jpg|text with a [[link]] in it]]
15017 !! html/php
15018 <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>
15019 </p>
15020 !! html/parsoid
15021 <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>
15022 !! end
15023
15024 !! test
15025 T2648: Frameless image caption with a link (suffix)
15026 !! wikitext
15027 [[File:Foobar.jpg|text with a [[link]]foo in it]]
15028 !! html/php
15029 <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>
15030 </p>
15031 !! html/parsoid
15032 <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>
15033 !! end
15034
15035 !! test
15036 T2648: Frameless image caption with an interwiki link
15037 !! wikitext
15038 [[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
15039 !! html/php
15040 <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>
15041 </p>
15042 !! html/parsoid
15043 <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>
15044 !! end
15045
15046 !! test
15047 T2648: Frameless image caption with a piped interwiki link
15048 !! wikitext
15049 [[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
15050 !! html/php
15051 <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>
15052 </p>
15053 !! html/parsoid
15054 <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>
15055 !! end
15056
15057 !! test
15058 T107474: Frameless image caption with <nowiki>
15059 !! wikitext
15060 [[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]]
15061 !! html/parsoid
15062 <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>
15063 !! end
15064
15065 !! test
15066 Escape HTML special chars in image alt text
15067 !! wikitext
15068 [[File:Foobar.jpg|& < > "]]
15069 !! html/php
15070 <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>
15071 </p>
15072 !! html/parsoid
15073 <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>
15074 !! end
15075
15076 !! test
15077 Escape HTML special chars in image alt text with LanguageConverter
15078 !! options
15079 language=zh
15080 !! wikitext
15081 [[File:Foobar.jpg|& < > "]]
15082 !! html/php
15083 <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>
15084 </p>
15085 !! html/parsoid
15086 <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>
15087 !! end
15088
15089 !! test
15090 Entities in file name and attributes
15091 !! wikitext
15092 [[File:7%25 solution.gif|manualthumb=7%25 solution.gif|link=7%25 solution|[[7%25 solution]]]]
15093 !! html/php
15094 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=7%25_solution.gif" class="new" title="File:7% solution.gif">7% solution</a>
15095 </p>
15096 !! html/parsoid
15097 <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>
15098 !! end
15099
15100 !! test
15101 T2499: Alt text should have &#1234;, not &amp;1234;
15102 !! wikitext
15103 [[File:Foobar.jpg|&#9792;]]
15104 !! html/php
15105 <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>
15106 </p>
15107 !! html/parsoid
15108 <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>
15109 !! end
15110
15111 !! test
15112 Broken image caption with link
15113 !! options
15114 parsoid=wt2html,wt2wt,html2html
15115 !! wikitext
15116 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
15117 !! html/php
15118 <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.
15119 </p>
15120 !! html/parsoid
15121 <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>
15122 !! end
15123
15124 !! test
15125 Image caption containing another image
15126 !! wikitext
15127 [[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
15128 !! html/php
15129 <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>
15130
15131 !! html/parsoid
15132 <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>
15133 !! end
15134
15135 !! test
15136 Image: caption containing a newline
15137 !! wikitext
15138 [[File:Foobar.jpg|This
15139 *is some text]]
15140 !! html/php
15141 <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>
15142 </p>
15143 !! html/parsoid
15144 <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>
15145 !!end
15146
15147 !!test
15148 Image: caption containing leading space
15149 (The leading space should not trigger nowiki escaping in wt2wt mode)
15150 !! wikitext
15151 [[File:Foobar.jpg|thumb| bar]]
15152 !! html/php
15153 <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>
15154
15155 !! html/parsoid
15156 <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>
15157 !!end
15158
15159 !! test
15160 Image: caption containing a table
15161 !! options
15162 parsoid=wt2html,wt2wt,html2html
15163 !! wikitext
15164 [[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
15165 {|
15166 ! Foo !! Bar
15167 |-
15168 | Foo1 || Bar1
15169 |}
15170 and some more text.]]
15171 !! html/php
15172 <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>
15173
15174 !! html/parsoid
15175 <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
15176 <table>
15177 <tbody>
15178 <tr><th>Foo </th><th>Bar</th></tr>
15179 <tr>
15180 <td>Foo1 </td>
15181 <td>Bar1</td></tr></tbody></table>and some more text.</figcaption></figure>
15182 !! end
15183
15184 !! test
15185 T5090: External links other than http: in image captions
15186 !! wikitext
15187 [[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
15188 !! html/php
15189 <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>
15190
15191 !! html/parsoid
15192 <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>
15193 !! end
15194
15195 !! test
15196 Custom class
15197 !! options
15198 parsoid=wt2html,wt2wt,html2html
15199 !! wikitext
15200 [[Image:foobar.jpg|a|class=b]]
15201 !! html/php
15202 <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>
15203 </p>
15204 !! html/parsoid
15205 <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>
15206 !! end
15207
15208 !! test
15209 Localized image handling (1).
15210 !! options
15211 parsoid=wt2html,wt2wt,html2html
15212 language=es
15213 !! wikitext
15214 [[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]]
15215 !! html/php
15216 <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>
15217
15218 !! html/parsoid
15219 <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>
15220 !! end
15221
15222 !! test
15223 Localized image handling (2).
15224 !! options
15225 thumbsize=220
15226 parsoid=wt2html,wt2wt,html2html
15227 language=es
15228 !! wikitext
15229 [[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
15230 !! html/php
15231 <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>
15232
15233 !! html/parsoid
15234 <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>
15235 !! end
15236
15237 !! test
15238 Localized image handling (3).
15239 !! options
15240 language=fa
15241 parsoid=html2wt
15242 !! html/parsoid
15243 <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>
15244 !! wikitext
15245 [[File:Foobar.jpg|بندانگشتی]]
15246 !! end
15247
15248 !! test
15249 "border", "frameless" and "class" attributes on an image.
15250 !! options
15251 thumbsize=220
15252 parsoid=wt2html,wt2wt,html2html
15253 !! wikitext
15254 [[File:Foobar.jpg|frameless|border|class=extra|caption]]
15255 !! html/php
15256 <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>
15257 </p>
15258 !! html/parsoid
15259 <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>
15260 !! end
15261
15262 # Note that 'right' is the default alignment, despite the misspelled 'righ' below
15263 !! test
15264 Invalid image attributes (T64500)
15265 !! options
15266 thumbsize=220
15267 parsoid=wt2html,wt2wt,html2html
15268 !! wikitext
15269 [[File:Foobar.jpg|thumb|float|left|caption]]
15270
15271 [[File:Foobar.jpg|thumb|righ|caption]]
15272
15273 [[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]]
15274 !! html/php
15275 <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>
15276 <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>
15277 <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>
15278
15279 !! html/parsoid
15280 <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>
15281 <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>
15282 <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>
15283 !! end
15284
15285 !! article
15286 File:Barfoo.jpg
15287 !! text
15288 #REDIRECT [[File:Barfoo.jpg]]
15289 !! endarticle
15290
15291 # FIXME: Parsoid should run this test -- but we'd need to teach the
15292 # mockAPI about the redirected Barfoo.jpg image.
15293 !! test
15294 Redirected image
15295 !! wikitext
15296 [[Image:Barfoo.jpg]]
15297 !! html/php
15298 <p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
15299 </p>
15300 !! end
15301
15302 !! test
15303 Missing image with uploads disabled
15304 !! options
15305 wgEnableUploads=0
15306 !! wikitext
15307 [[File:Foobaz.jpg]]
15308 !! html/php
15309 <p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a>
15310 </p>
15311 !! html/parsoid
15312 <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>
15313 !! end
15314
15315 # Parsoid-specific testing for images
15316 # https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
15317 # Currently imperfect due to a flaw in the Parsoid testrunner
15318 # Work in progress
15319 # THESE TESTS SHOULD BE MOVED UP and merged with the php-specific
15320 # image tests.
15321
15322 !! test
15323 Parsoid-specific image handling - simple image with size and middle alignment
15324 !! wikitext
15325 [[File:Foobar.jpg|middle|50px]]
15326 !! html/parsoid
15327 <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>
15328 !! end
15329
15330 !! test
15331 Parsoid-specific image handling - simple image with size, middle alignment,
15332 non-standard namespace alias
15333 !! options
15334 parsoid=wt2wt,wt2html,html2html
15335 !! wikitext
15336 [[Image:Foobar.jpg|middle|50px]]
15337 !! html/parsoid
15338 <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>
15339 !! end
15340
15341 !! test
15342 Parsoid-specific image handling - simple image with size and middle alignment
15343 (existing content)
15344 !! wikitext
15345 [[File:Foobar.jpg|50px|middle]]
15346 !! html/parsoid
15347 <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>
15348 !! end
15349
15350 !! test
15351 Parsoid-specific image handling - simple image with size and middle alignment
15352 and non-standard namespace name
15353 !! options
15354 parsoid=wt2html,wt2wt,html2html
15355 !! wikitext
15356 [[Image:Foobar.jpg|50px|middle]]
15357 !! html/parsoid
15358 <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>
15359 !! end
15360
15361 !! test
15362 Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
15363 !! wikitext
15364 [[File:Foobar.jpg|500x10px|baseline|caption]]
15365 !! html/parsoid
15366 <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>
15367 !! end
15368
15369 !! test
15370 Parsoid-specific image handling - simple image with border and size spec
15371 !! wikitext
15372 [[File:Foobar.jpg|50px|border|caption]]
15373 !! html/parsoid
15374 <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>
15375 !! end
15376
15377 !! test
15378 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15379 !! wikitext
15380 [[File:Foobar.jpg|left|baseline|thumb|caption content]]
15381 !! html/parsoid
15382 <figure class="mw-default-size mw-halign-left mw-valign-baseline" 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>
15383 !! end
15384
15385 !! test
15386 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15387 (existing content)
15388 !! wikitext
15389 [[File:Foobar.jpg|thumb|left|baseline|caption content]]
15390 !! html/parsoid
15391 <figure class="mw-default-size mw-halign-left mw-valign-baseline" 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>
15392 !! end
15393
15394 !! test
15395 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption
15396 !! wikitext
15397 [[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
15398 !! html/parsoid
15399 <figure class="mw-halign-right mw-valign-middle" 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>
15400 !! end
15401
15402 !! test
15403 Parsoid-specific image handling - thumbnail with specific size, halign,
15404 valign, and caption (existing content)
15405 !! wikitext
15406 [[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
15407 !! html/parsoid
15408 <figure class="mw-halign-right mw-valign-middle" 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>
15409 !! end
15410
15411 !! test
15412 Parsoid-specific image handling - framed image with specific size and caption
15413 (size is ignored)
15414 !! options
15415 parsoid=wt2html,wt2wt,html2html
15416 !! wikitext
15417 [[File:Foobar.jpg|frame|500x50px|caption]]
15418 !! html/parsoid
15419 <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>
15420 !! end
15421
15422 !! test
15423 Parsoid-specific image handling - framed image with specific size, halign, valign, and caption
15424 (size is ignored)
15425 !! options
15426 parsoid=wt2html,wt2wt,html2html
15427 !! wikitext
15428 [[File:Foobar.jpg|left|baseline|frame|500x50px|caption]]
15429 !! html/parsoid
15430 <figure class="mw-halign-left mw-valign-baseline" 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>
15431 !! end
15432
15433 !! test
15434 Parsoid-specific image handling - frameless image with specific size, border, and caption
15435 !! wikitext
15436 [[File:Foobar.jpg|frameless|442x50px|border|caption]]
15437 !! html/parsoid
15438 <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>
15439 !! end
15440
15441 !! test
15442 Parsoid-specific image handling - simple image with a formatted caption
15443 !! wikitext
15444 [[File:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]]
15445 !! html/parsoid
15446 <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>
15447 !! end
15448
15449 !! test
15450 Parsoid-specific image handling - caption with a template in it
15451 !! wikitext
15452 [[File:Foobar.jpg|thumb|200x23px|This caption has a {{echo|transclusion}} in it.]]
15453 !! html/parsoid
15454 <figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="23" width="200"></a><figcaption>This caption has a <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>
15455 !! end
15456
15457 !! test
15458 Parsoid-specific image handling - caption with unbalanced tags in it
15459 !! options
15460 parsoid=wt2html,wt2wt,html2html
15461 !! wikitext
15462 foo
15463 [[File:Foobar.jpg|thumb|200x200px|This caption has a <center>unbalanced tag in it.]]
15464 bar
15465 !! html/parsoid
15466 <p>foo</p>
15467 <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>
15468 <p>bar</p>
15469 !! end
15470
15471 !! test
15472 Parsoid-specific image handling - empty caption (1)
15473 !! options
15474 parsoid=wt2html,wt2wt
15475 !! wikitext
15476 [[File:Foobar.jpg|thumb|]]
15477 !! html/parsoid
15478 <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>
15479 !! end
15480
15481 # empty captions don't get serialized unless we're in the "round trip" case
15482 !! test
15483 Parsoid-specific image handling - empty caption (2)
15484 !! options
15485 parsoid=html2wt
15486 !! html/parsoid
15487 <figure class="mw-default-size" typeof="mw:Image/Thumb">
15488 <a href="./File:Foobar.jpg">
15489 <img resource="./File:Foobar.jpg"
15490 src="//example.com/images/3/3a/Foobar.jpg"
15491 data-file-width="1941" data-file-height="220" data-file-type="bitmap"
15492 height="25" width="220"/>
15493 </a>
15494 <figcaption></figcaption>
15495 </figure>
15496 !! wikitext
15497 [[File:Foobar.jpg|thumb]]
15498 !! end
15499
15500 !! test
15501 Parsoid-specific image handling - whitespace caption
15502 !! wikitext
15503 [[File:Foobar.jpg|thumb| ]]
15504 !! html/parsoid
15505 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption> </figcaption></figure>
15506 !! end
15507
15508 !! test
15509 Parsoid-specific image handling - lang option
15510 !! wikitext
15511 foo
15512 [[File:Foobar.svg|lang=de|caption]]
15513 bar
15514 !! html/parsoid
15515 <p>foo
15516 <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>
15517 bar</p>
15518 !! end
15519
15520 ## Edge case bugs in Parsoid from T93580
15521 !! test
15522 T93580: 1. Templated <ref> inside block images
15523 !! wikitext
15524 [[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]]
15525
15526 <references />
15527 !! html/parsoid
15528 <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>
15529
15530 <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>
15531 !! end
15532
15533 !! test
15534 T93580: 2. <ref> inside inline images
15535 !! wikitext
15536 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: <ref>foo</ref>]]
15537
15538 <references />
15539 !! html/parsoid
15540 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"Undisplayed caption in inline image with ref: &lt;ref>foo&lt;/ref>"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: &lt;sup about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-parsoid=&#39;{\"dsr\":[64,78,5,6]}&#39; data-mw=&#39;{\"name\":\"ref\",\"body\":{\"id\":\"mw-reference-text-cite_note-1\"},\"attrs\":{}}&#39;>&lt;a href=\"./Main_Page#cite_note-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]&lt;/span>&lt;/a>&lt;/sup>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{"href":"File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p>
15541
15542 <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>
15543 !! end
15544
15545 !! test
15546 T93580: 3. Templated <ref> inside inline images
15547 !! wikitext
15548 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}]]
15549
15550 <references />
15551 !! html/parsoid
15552 <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>
15553
15554 <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>
15555 !! end
15556
15557 ###
15558 ### Subpages
15559 ###
15560 !! article
15561 Subpage test/subpage
15562 !! text
15563 foo
15564 !! endarticle
15565
15566 !! test
15567 Subpage link
15568 !! options
15569 subpage title=[[Subpage test]]
15570 !! wikitext
15571 [[/subpage]]
15572 !! html
15573 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
15574 </p>
15575 !! end
15576
15577 !! test
15578 Subpage noslash link
15579 !! options
15580 subpage title=[[Subpage test]]
15581 !! wikitext
15582 [[/subpage/]]
15583 !! html
15584 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
15585 </p>
15586 !! end
15587
15588 !! article
15589 Subpage test/1/2/subpage
15590 !! text
15591 blah
15592 !! endarticle
15593
15594 !! test
15595 Relative subpage noslash link
15596 !! options
15597 parsoid=wt2wt,wt2html,html2html
15598 subpage title=[[Subpage test/1/2/3/4]]
15599 !! wikitext
15600 [[../../subpage/]]
15601
15602 [[../../subpage]]
15603 !! html/php
15604 <p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a>
15605 </p><p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage test/1/2/subpage</a>
15606 </p>
15607 !! html/parsoid
15608 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a></p>
15609 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage_test/1/2/subpage</a></p>
15610 !! end
15611
15612 !! test
15613 Parsoid: dot-slash prefixed wikilinks
15614 !! wikitext
15615 [[./foo]]
15616
15617 [[././bar]]
15618
15619 [[././baz/]]
15620 !! html/php
15621 <p>[[./foo]]
15622 </p><p>[[././bar]]
15623 </p><p>[[././baz/]]
15624 </p>
15625 !! html/parsoid
15626 <p>[[./foo]]
15627 </p><p>[[././bar]]
15628 </p><p>[[././baz/]]
15629 </p>
15630 !! end
15631
15632 !! test
15633 Render invalid page names as plain text (T53090)
15634 !! wikitext
15635 [[./../foo|bar]]
15636 [[foo�|bar]]
15637 [[foo/.|bar]]
15638 [[foo/..|bar]]
15639 [[foo~~~bar]]
15640 [[foo>bar]]
15641 [[foo[bar]]
15642 [[.]]
15643 [[..]]
15644 [[foo././bar]]
15645 [[foo[http://example.com]xyz]]
15646
15647 [[{{echo|./../foo}}|bar]]
15648 [[{{echo|foo/.}}|bar]]
15649 [[{{echo|foo/..}}|bar]]
15650 [[{{echo|foo~~~~bar}}]]
15651 [[{{echo|foo>bar}}]]
15652 [[{{echo|foo././bar}}]]
15653 [[{{echo|foo{bar}}]]
15654 [[{{echo|foo}bar}}]]
15655 [[{{echo|foo[bar}}]]
15656 [[{{echo|foo]bar}}]]
15657 [[{{echo|foo<bar}}]]
15658 !!html/php
15659 <p>[[./../foo|bar]]
15660 [[foo�|bar]]
15661 [[foo/.|bar]]
15662 [[foo/..|bar]]
15663 [[foo~~~bar]]
15664 [[foo&gt;bar]]
15665 [[foo[bar]]
15666 [[.]]
15667 [[..]]
15668 [[foo././bar]]
15669 [[foo<a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>xyz]]
15670 </p><p>[[./../foo|bar]]
15671 [[foo/.|bar]]
15672 [[foo/..|bar]]
15673 [[foo~~~~bar]]
15674 [[foo&gt;bar]]
15675 [[foo././bar]]
15676 [[foo{bar]]
15677 [[foo}bar]]
15678 [[foo[bar]]
15679 [[foo]bar]]
15680 [[foo&lt;bar]]
15681 </p>
15682 !!html/parsoid
15683 <p>[[./../foo|bar]]
15684 [[foo�|bar]]
15685 [[foo/.|bar]]
15686 [[foo/..|bar]]
15687 [[foo~~~bar]]
15688 [[foo>bar]]
15689 [[foo[bar]]
15690 [[.]]
15691 [[..]]
15692 [[foo././bar]]
15693 [[foo<a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>xyz]]</p>
15694
15695 <p>[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"./../foo"}},"i":0}}]}'>./../foo</span>|bar]]
15696 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/."}},"i":0}}]}'>foo/.</span>|bar]]
15697 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/.."}},"i":0}}]}'>foo/..</span>|bar]]
15698 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo~~~~bar"}},"i":0}}]}'>foo~~~~bar</span>]]
15699 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo>bar"}},"i":0}}]}'>foo>bar</span>]]
15700 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo././bar"}},"i":0}}]}'>foo././bar</span>]]
15701 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo{bar"}},"i":0}}]}'>foo{bar</span>]]
15702 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}bar"}},"i":0}}]}'>foo}bar</span>]]
15703 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo[bar"}},"i":0}}]}'>foo[bar</span>]]
15704 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo]bar"}},"i":0}}]}'>foo]bar</span>]]
15705 [[<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>
15706 !!end
15707
15708 !! test
15709 Disabled subpages
15710 !! wikitext
15711 [[/subpage]]
15712 !! html
15713 <p><a href="/index.php?title=/subpage&amp;action=edit&amp;redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a>
15714 </p>
15715 !! end
15716
15717 !! test
15718 T2561: {{/Subpage}}
15719 !! options
15720 subpage title=[[Page]]
15721 !! wikitext
15722 {{/Subpage}}
15723 !! html
15724 <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>
15725 </p>
15726 !! end
15727
15728 ###
15729 ### Categories
15730 ###
15731 !! article
15732 Category:MediaWiki User's Guide
15733 !! text
15734 blah
15735 !! endarticle
15736
15737 !! test
15738 Link to category
15739 !! wikitext
15740 [[:Category:MediaWiki User's Guide]]
15741 !! html
15742 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User&#39;s Guide">Category:MediaWiki User's Guide</a>
15743 </p>
15744 !! end
15745
15746 !! test
15747 Simple category
15748 !! options
15749 cat
15750 !! wikitext
15751 [[Category:MediaWiki User's Guide]]
15752 !! html/php
15753 cat=MediaWiki_User's_Guide sort=
15754 !! html/parsoid
15755 <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"}}'/>
15756 !! end
15757
15758 !! test
15759 PAGESINCATEGORY invalid title fatal (r33546 fix)
15760 !! wikitext
15761 {{PAGESINCATEGORY:<bogus>}}
15762 !! html
15763 <p>0
15764 </p>
15765 !! end
15766
15767 !! test
15768 Category with different sort key
15769 !! options
15770 cat
15771 !! wikitext
15772 [[Category:MediaWiki User's Guide|Foo]]
15773 !! html/php
15774 cat=MediaWiki_User's_Guide sort=Foo
15775 !! html/parsoid
15776 <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"}}'/>
15777 !! end
15778
15779 !! test
15780 Category with identical sort key
15781 !! options
15782 cat
15783 !! wikitext
15784 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
15785 !! html/php
15786 cat=MediaWiki_User's_Guide sort=MediaWiki User's Guide
15787 !! html/parsoid
15788 <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"}}'/>
15789 !! end
15790
15791 !! test
15792 Category with empty sort key
15793 !! options
15794 cat
15795 pst
15796 !! wikitext
15797 [[Category:MediaWiki User's Guide|]]
15798 !! html/php
15799 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
15800 !! end
15801
15802 !! test
15803 Category with empty sort key and parentheses
15804 !! options
15805 cat
15806 pst
15807 !! wikitext
15808 [[Category:Foo (bar)|]]
15809 !! html/php
15810 [[Category:Foo (bar)|Foo]]
15811 !! end
15812
15813 !! test
15814 Category with link tail
15815 !! options
15816 cat
15817 pst
15818 !! wikitext
15819 123[[Category:Foo]]456
15820 !! html/php
15821 123[[Category:Foo]]456
15822 !! end
15823
15824 !! test
15825 Category with template
15826 !! options
15827 cat
15828 pst
15829 !! wikitext
15830 [[Category:{{echo|Foo}}]]
15831 !! html/php
15832 [[Category:{{echo|Foo}}]]
15833 !! end
15834
15835 !! test
15836 Category with template in sort key
15837 !! options
15838 cat
15839 pst
15840 !! wikitext
15841 [[Category:Foo|{{echo|Bar}}]]
15842 !! html/php
15843 [[Category:Foo|{{echo|Bar}}]]
15844 !! end
15845
15846 !! test
15847 Category with template in sort key and title
15848 !! options
15849 cat
15850 pst
15851 !! wikitext
15852 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
15853 !! html/php
15854 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
15855 !! end
15856
15857 ## We used to, but no longer wt2wt this test since the default serializer
15858 ## will normalize all categories to serialize on their own line.
15859 ## This wikitext usage is going to be fairly uncommon in production and
15860 ## selser will take care of preserving formatting in those scenarios.
15861 !! test
15862 Category / paragraph interactions
15863 !! options
15864 parsoid=wt2html
15865 !! wikitext
15866 Foo [[Category:Baz]] Bar
15867
15868 Foo [[Category:Baz]]
15869 Bar
15870
15871 Foo
15872 [[Category:Baz]]
15873 Bar
15874
15875 Foo
15876 [[Category:Baz]] Bar
15877
15878 Foo
15879 [[Category:Baz]]
15880 [[Category:Baz]]
15881 [[Category:Baz]]
15882 Bar
15883
15884 [[Category:Baz]]
15885 [[Category:Baz]]
15886 [[Category:Baz]]
15887
15888 [[Category:Baz]]
15889 {{echo|[[Category:Baz]]}}
15890 [[Category:Baz]]
15891 !! html/php
15892 <p>Foo Bar
15893 </p><p>Foo
15894 Bar
15895 </p><p>Foo
15896 Bar
15897 </p><p>Foo Bar
15898 </p><p>Foo
15899 Bar
15900 </p>
15901 !! html/parsoid
15902 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15903 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15904 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15905 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15906 <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>
15907 <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}}]}'/>
15908 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
15909 !! end
15910
15911 ## We used to, but no longer wt2wt this test since the default serializer
15912 ## will normalize all categories to serialize on their own line.
15913 ## This wikitext usage is going to be fairly uncommon in production and
15914 ## selser will take care of preserving formatting in those scenarios.
15915 ##
15916 ## The whitespace on the empty line is part of the test. Please do not delete
15917 !! test
15918 1. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
15919 !! options
15920 parsoid=wt2html
15921 !! wikitext
15922 This
15923
15924 [[Category:Foo]] and this should be part of same paragraph (not an indent-pre)
15925
15926 {{echo|[[Category:Foo]] and so should this!}}
15927 !! html/php
15928 <p>This and this should be part of same paragraph (not an indent-pre) and so should this!
15929 </p>
15930 !! html/parsoid
15931 <p>This
15932
15933 <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of same paragraph (not an indent-pre)
15934
15935 <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>
15936 !! end
15937
15938 ## Parsoid will not try to wt2wt this while preserving newlines because
15939 ## it suppresses excess newlines within list items -- and we don't want to
15940 ## introduce a special case just for categories, which is, in reality somewhat
15941 ## odd behavior -- categories are unlikely to be used in list items like this
15942 ## in top-level pages and are only likely to show up in template-generated
15943 ## list items where this RT-ing is a non-issue.
15944 ##
15945 ## The whitespace on the empty line is part of the test. Please do not delete
15946 !! test
15947 2. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
15948 !! options
15949 parsoid=wt2html
15950 !! wikitext
15951 * This
15952
15953 [[Category:Foo]] and this should be part of the same list item
15954 * So should this
15955
15956 {{echo|[[Category:Foo]] and this should be part of the same list item}}
15957 !! html
15958 <ul><li>This and this should be part of the same list item</li>
15959 <li>So should this and this should be part of the same list item</li></ul>
15960 !! html/parsoid
15961 <ul>
15962 <li>This <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of the same list item</li>
15963 <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>
15964 </ul>
15965 !! end
15966
15967 ## Newlines and categories that follow the last item of a list
15968 ## are treated differently because this (list followed by categories)
15969 ## is an extremely common pattern on wikis.
15970 !! test
15971 3. Categories and newlines: newline suppression for last list item should RT properly
15972 !! wikitext
15973 * a
15974 * b
15975
15976 [[Category:Foo]]
15977
15978 [[Category:Bar]]
15979 [[Category:Baz]]
15980 !! html/parsoid
15981 <ul><li> a</li>
15982 <li> b</li></ul>
15983
15984 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
15985
15986 <link rel="mw:PageProp/Category" href="./Category:Bar" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
15987 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
15988 !! end
15989
15990 !! test
15991 4. Categories and newlines: newline suppression for last list item should RT properly
15992 !! wikitext
15993 * a
15994 **** b
15995
15996 [[Category:Foo]]
15997 !! html/parsoid
15998 <ul><li> a
15999 <ul><li><ul><li><ul><li> b</li></ul></li></ul></li></ul></li></ul>
16000
16001 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16002 !! end
16003
16004 ## only wt2html for this to make sure the algo only applies to the rightmost path
16005 !! test
16006 5. Categories and newlines: migrateTrailingCategories dom pass should only run on the rightmost path of nested lists
16007 !! options
16008 parsoid=wt2html
16009 !! wikitext
16010 * a
16011 ** b
16012 [[Category:Foo]]
16013 * c
16014 ** d
16015 [[Category:Foo]]
16016 !! html/parsoid
16017 <ul><li> a
16018 <ul><li> b
16019 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul></li>
16020 <li> c
16021 <ul><li> d</li></ul></li></ul>
16022 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16023 !! end
16024
16025 ## We used to, but no longer wt2wt this test since the default serializer
16026 ## will normalize all categories to serialize on their own line.
16027 ## This wikitext usage is going to be fairly uncommon in production and
16028 ## selser will take care of preserving formatting in those scenarios.
16029 !! test
16030 6. Categories and newlines: migrateTrailingCategories dom pass should not migrate categories not preceded by newlines
16031 !! options
16032 parsoid=wt2html
16033 !! wikitext
16034 * a [[Category:Foo]]
16035 !! html/parsoid
16036 <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>
16037 !! end
16038
16039 # This test also demonstrates because of newline+category tunneling
16040 # through the list hander, template wrapping doesn't expand to the
16041 # containing list when the list item swallows the category.
16042 !! test
16043 7. Categories and newlines: migrateTrailingCategories dom pass should leave template content alone
16044 !! wikitext
16045 * {{echo|a
16046 [[Category:Foo]]}}
16047 !! html/parsoid
16048 <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
16049 </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>
16050 !! end
16051
16052 !! test
16053 8. Categories and newlines: migrateTrailingCategories dom pass should not get tripped by intervening templates
16054 !! wikitext
16055 * a
16056
16057 {{echo|[[Category:Foo]]
16058 [[Category:Bar]]}}
16059 [[Category:Baz]]
16060 !! html/parsoid
16061 <ul><li> a</li></ul>
16062
16063 <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">
16064 </span><link rel="mw:PageProp/Category" href="./Category:Bar" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
16065 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
16066 !! end
16067
16068 !! test
16069 9. Categories and newlines: should behave properly with linkprefix (T87753)
16070 !! options
16071 language=ar
16072 !! wikitext
16073 foo bar
16074 foo bar
16075 [[تصنيف:Foo]]
16076 [[تصنيف:Bar]]
16077 !! html/php
16078 <p>foo bar
16079 foo bar
16080 </p>
16081 !! html/parsoid
16082 <p>foo bar
16083 foo bar</p>
16084 <link rel="mw:PageProp/Category" href="./تصنيف:Foo"/>
16085 <link rel="mw:PageProp/Category" href="./تصنيف:Bar"/>
16086 !! end
16087
16088 !! test
16089 10. No regressions on internal links following category (T174639)
16090 !! options
16091 parsoid=wt2html,html2html
16092 !! wikitext
16093 [[Category:Foo]]<div>a
16094
16095 [[Foo]]</div>
16096 !! html/php
16097 <div>a
16098 <a href="/wiki/Foo" title="Foo">Foo</a></div>
16099
16100 !! html/parsoid
16101 <link rel="mw:PageProp/Category" href="./Category:Foo"/><div>a
16102
16103 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></div>
16104 !! end
16105
16106 # Note that Parsoid differs slightly from PHP due to T175421
16107 !! test
16108 11. Special case where only newlines separate links (T175416)
16109 !! options
16110 parsoid=wt2html,html2html
16111 !! wikitext
16112 [[Category:Foo]]
16113
16114 [[Foo]][[es:Alimento]]
16115
16116 [[Foo]]
16117 !! html/php
16118 <p><br />
16119 <a href="/wiki/Foo" title="Foo">Foo</a>
16120 </p><p><a href="/wiki/Foo" title="Foo">Foo</a>
16121 </p>
16122 !! html/parsoid
16123 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
16124
16125 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p><link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
16126
16127 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p>
16128 !! end
16129
16130 !! test
16131 Category links with multiple namespaces
16132 !! wikitext
16133 [[Category:Project:Foo]]
16134 !! html/parsoid
16135 <link rel="mw:PageProp/Category" href="./Category:Project:Foo" />
16136 !! end
16137
16138 !! test
16139 Parsoid: Serialize link to category page with colon escape
16140 !! options
16141 parsoid
16142 !! wikitext
16143
16144 [[:Category:Foo]]
16145 [[:Category:Foo|Bar]]
16146 !! html
16147 <p>
16148 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Category:Foo</a>
16149 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Bar</a>
16150 </p>
16151 !! end
16152
16153 # We used to, but no longer wt2wt this test since the default serializer
16154 # will normalize all categories to serialize on their own line.
16155 # This wikitext usage is going to be fairly uncommon in production and
16156 # selser will take care of preventing whitespace insertion if this
16157 # occurs in an article.
16158 #
16159 # html2html disabled for the same reason (whitespace insertion between
16160 # x and y).
16161 #
16162 # html2wt disabled because it localizes the "Category" namespace.
16163 !! test
16164 Link prefix/suffixes aren't applied to category links
16165 !! options
16166 parsoid=wt2html
16167 language=is
16168 !! wikitext
16169 x[[Category:Foo]]y
16170 !! html/php
16171 <p>xy
16172 </p>
16173 !! html/parsoid
16174 <p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p>
16175 !! end
16176
16177 !! test
16178 Link prefix/suffixes aren't applied to language links
16179 !! options
16180 parsoid=wt2html
16181 language=is
16182 !! wikitext
16183 x[[es:Foo]]y
16184 !! html/php
16185 <p>xy
16186 </p>
16187 !! html/parsoid
16188 <p>x<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo" data-parsoid=""/>y</p>
16189 !! end
16190
16191 !! test
16192 Parsoid: Serialize link to file page with colon escape
16193 !! options
16194 parsoid
16195 !! wikitext
16196
16197 [[:File:Foo.png]]
16198 [[:File:Foo.png|Bar]]
16199 !! html
16200 <p>
16201 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">File:Foo.png</a>
16202 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">Bar</a>
16203 </p>
16204 !! end
16205
16206 !! test
16207 Parsoid: Serialize a genuine category link without colon escape
16208 !! options
16209 parsoid
16210 !! wikitext
16211 [[Category:Foo]]
16212 [[Category:Foo|Bar]]
16213 !! html
16214 <link rel="mw:PageProp/Category" href="./Category:Foo">
16215 <link rel="mw:PageProp/Category" href="./Category:Foo#Bar">
16216 !! end
16217
16218 !! test
16219 Normalize hrefs properly before testing for invalid link targets (T72894)
16220 !! options
16221 parsoid=html2wt
16222 !! html/parsoid
16223 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/>
16224 !! wikitext
16225 [[Category:Toxine bactérienne]]
16226 !! end
16227
16228 !! test
16229 Parsoid: Defaultsort
16230 !! wikitext
16231 {{DEFAULTSORT:Foo}}
16232 !! html/parsoid
16233 <meta property="mw:PageProp/categorydefaultsort" content="Foo"/>
16234 !! end
16235
16236 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
16237 # But, this is a limitation of our representation and is documented in
16238 # TemplateHandler.js in processSpecialMagicWord
16239 !! test
16240 Parsoid: Defaultsort (template-generated)
16241 !! wikitext
16242 {{{{echo|DEFAULTSORT}}:Foo}}
16243 !! html/parsoid
16244 <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"}]]}'/>
16245 !! end
16246
16247 ###
16248 ### Inter-language links
16249 ###
16250 !! test
16251 Interlanguage links
16252 !! options
16253 ill
16254 !! wikitext
16255 [[es:Alimento]]
16256 [[fr:Nourriture]]
16257 [[zh:食品]]
16258 !! html/php
16259 es:Alimento fr:Nourriture zh:食品
16260 !! html/parsoid
16261 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
16262 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Nourriture"/>
16263 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/食品"/>
16264 !! end
16265
16266 !! test
16267 Duplicate interlanguage links (T26502)
16268 !! options
16269 ill
16270 !! wikitext
16271 [[es:1]]
16272 [[es:2]]
16273 [[fr:1]]
16274 [[fr:2]]
16275 !! html/php
16276 es:1 fr:1
16277 !! html/parsoid
16278 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/1"/>
16279 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/2"/>
16280 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/1"/>
16281 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/2"/>
16282 !! end
16283
16284 ###
16285 ### Sections
16286 ###
16287 !! test
16288 Basic section headings
16289 !! wikitext
16290 == Headline 1 ==
16291 Some text
16292
16293 ==Headline 2==
16294 More
16295 ===Smaller headline===
16296 Blah blah
16297 !! html
16298 <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>
16299 <p>Some text
16300 </p>
16301 <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>
16302 <p>More
16303 </p>
16304 <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>
16305 <p>Blah blah
16306 </p>
16307 !! end
16308
16309 !! test
16310 Section headings with TOC
16311 !! wikitext
16312 == Headline 1 ==
16313 === Subheadline 1 ===
16314 ===== Skipping a level =====
16315 ====== Skipping a level ======
16316
16317 == Headline 2 ==
16318 Some text
16319 ===Another headline===
16320 !! html
16321 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16322 <ul>
16323 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
16324 <ul>
16325 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
16326 <ul>
16327 <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>
16328 <ul>
16329 <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>
16330 </ul>
16331 </li>
16332 </ul>
16333 </li>
16334 </ul>
16335 </li>
16336 <li class="toclevel-1 tocsection-5"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
16337 <ul>
16338 <li class="toclevel-2 tocsection-6"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
16339 </ul>
16340 </li>
16341 </ul>
16342 </div>
16343
16344 <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>
16345 <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>
16346 <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>
16347 <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>
16348 <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>
16349 <p>Some text
16350 </p>
16351 <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>
16352
16353 !! end
16354
16355 !! test
16356 TOC anchors don't collide
16357 !! wikitext
16358 __FORCETOC__
16359 == Headline 2 ==
16360 == Headline ==
16361 == Headline 2 ==
16362 == Headline ==
16363 !! html/php
16364 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16365 <ul>
16366 <li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
16367 <li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
16368 <li class="toclevel-1 tocsection-3"><a href="#Headline_2_2"><span class="tocnumber">3</span> <span class="toctext">Headline 2</span></a></li>
16369 <li class="toclevel-1 tocsection-4"><a href="#Headline_3"><span class="tocnumber">4</span> <span class="toctext">Headline</span></a></li>
16370 </ul>
16371 </div>
16372
16373 <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>
16374 <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>
16375 <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>
16376 <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>
16377
16378 !! end
16379
16380 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
16381 # Parsoid html2wt direction adds <nowiki> for level 7 and up.
16382 !! test
16383 Handling of sections up to level 6 and beyond
16384 !! options
16385 parsoid=wt2html
16386 !! wikitext
16387 = Level 1 Heading=
16388 == Level 2 Heading==
16389 === Level 3 Heading===
16390 ==== Level 4 Heading====
16391 ===== Level 5 Heading=====
16392 ====== Level 6 Heading======
16393 ======= Level 7 Heading=======
16394 ======== Level 8 Heading========
16395 ========= Level 9 Heading=========
16396 ========== Level 10 Heading==========
16397 !! html/php
16398 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16399 <ul>
16400 <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
16401 <ul>
16402 <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>
16403 <ul>
16404 <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>
16405 <ul>
16406 <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>
16407 <ul>
16408 <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>
16409 <ul>
16410 <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>
16411 <li class="toclevel-6 tocsection-7"><a href="#.3D_Level_7_Heading.3D"><span class="tocnumber">1.1.1.1.1.2</span> <span class="toctext">= Level 7 Heading=</span></a></li>
16412 <li class="toclevel-6 tocsection-8"><a href="#.3D.3D_Level_8_Heading.3D.3D"><span class="tocnumber">1.1.1.1.1.3</span> <span class="toctext">== Level 8 Heading==</span></a></li>
16413 <li class="toclevel-6 tocsection-9"><a href="#.3D.3D.3D_Level_9_Heading.3D.3D.3D"><span class="tocnumber">1.1.1.1.1.4</span> <span class="toctext">=== Level 9 Heading===</span></a></li>
16414 <li class="toclevel-6 tocsection-10"><a href="#.3D.3D.3D.3D_Level_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>
16415 </ul>
16416 </li>
16417 </ul>
16418 </li>
16419 </ul>
16420 </li>
16421 </ul>
16422 </li>
16423 </ul>
16424 </li>
16425 </ul>
16426 </div>
16427
16428 <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>
16429 <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>
16430 <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>
16431 <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>
16432 <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>
16433 <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>
16434 <h6><span class="mw-headline" id=".3D_Level_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>
16435 <h6><span class="mw-headline" id=".3D.3D_Level_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>
16436 <h6><span class="mw-headline" id=".3D.3D.3D_Level_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>
16437 <h6><span class="mw-headline" id=".3D.3D.3D.3D_Level_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>
16438
16439 !! html/parsoid
16440 <h1 id="Level_1_Heading" data-parsoid='{}'> Level 1 Heading</h1>
16441 <h2 id="Level_2_Heading" data-parsoid='{}'> Level 2 Heading</h2>
16442 <h3 id="Level_3_Heading" data-parsoid='{}'> Level 3 Heading</h3>
16443 <h4 id="Level_4_Heading" data-parsoid='{}'> Level 4 Heading</h4>
16444 <h5 id="Level_5_Heading" data-parsoid='{}'> Level 5 Heading</h5>
16445 <h6 id="Level_6_Heading" data-parsoid='{}'> Level 6 Heading</h6>
16446 <h6 id="=_Level_7_Heading=" data-parsoid='{}'><span id=".3D_Level_7_Heading.3D" typeof="mw:FallbackId"></span>= Level 7 Heading=</h6>
16447 <h6 id="==_Level_8_Heading==" data-parsoid='{}'><span id=".3D.3D_Level_8_Heading.3D.3D" typeof="mw:FallbackId"></span>== Level 8 Heading==</h6>
16448 <h6 id="===_Level_9_Heading===" data-parsoid='{}'><span id=".3D.3D.3D_Level_9_Heading.3D.3D.3D" typeof="mw:FallbackId"></span>=== Level 9 Heading===</h6>
16449 <h6 id="====_Level_10_Heading====" data-parsoid='{}'><span id=".3D.3D.3D.3D_Level_10_Heading.3D.3D.3D.3D" typeof="mw:FallbackId"></span>==== Level 10 Heading====</h6>
16450 !! end
16451
16452 !! test
16453 TOC regression (T11764)
16454 !! wikitext
16455 == title 1 ==
16456 === title 1.1 ===
16457 ==== title 1.1.1 ====
16458 === title 1.2 ===
16459 == title 2 ==
16460 === title 2.1 ===
16461 !! html
16462 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16463 <ul>
16464 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16465 <ul>
16466 <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>
16467 <ul>
16468 <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>
16469 </ul>
16470 </li>
16471 <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>
16472 </ul>
16473 </li>
16474 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16475 <ul>
16476 <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>
16477 </ul>
16478 </li>
16479 </ul>
16480 </div>
16481
16482 <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>
16483 <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>
16484 <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>
16485 <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>
16486 <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>
16487 <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>
16488
16489 !! end
16490
16491 !! test
16492 TOC for heading containing <span id="..."></span> (T96153)
16493 !! wikitext
16494 __FORCETOC__
16495 ==<span id="old-anchor"></span>New title==
16496 !! html/php
16497 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16498 <ul>
16499 <li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
16500 </ul>
16501 </div>
16502
16503 <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>
16504
16505 !! end
16506
16507 !! test
16508 TOC with wgMaxTocLevel=3 (T8204)
16509 !! options
16510 wgMaxTocLevel=3
16511 !! wikitext
16512 == title 1 ==
16513 === title 1.1 ===
16514 ==== title 1.1.1 ====
16515 === title 1.2 ===
16516 == title 2 ==
16517 === title 2.1 ===
16518 !! html
16519 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16520 <ul>
16521 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16522 <ul>
16523 <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>
16524 <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>
16525 </ul>
16526 </li>
16527 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16528 <ul>
16529 <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>
16530 </ul>
16531 </li>
16532 </ul>
16533 </div>
16534
16535 <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>
16536 <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>
16537 <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>
16538 <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>
16539 <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>
16540 <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>
16541
16542 !! end
16543
16544 !! test
16545 TOC with wgMaxTocLevel=3 and two level four headings (T8204)
16546 !! options
16547 wgMaxTocLevel=3
16548 !! wikitext
16549 ==Section 1==
16550 ===Section 1.1===
16551 ====Section 1.1.1====
16552 ====Section 1.1.1.1====
16553 ==Section 2==
16554 !! html
16555 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16556 <ul>
16557 <li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
16558 <ul>
16559 <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>
16560 </ul>
16561 </li>
16562 <li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li>
16563 </ul>
16564 </div>
16565
16566 <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>
16567 <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>
16568 <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>
16569 <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>
16570 <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>
16571
16572 !! end
16573
16574
16575 !! test
16576 Resolving duplicate section names
16577 !! wikitext
16578 == Foo bar ==
16579 == Foo bar ==
16580 !! html
16581 <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>
16582 <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>
16583
16584 !! end
16585
16586 !! test
16587 Resolving duplicate section names with differing case (T12721)
16588 !! wikitext
16589 == Foo bar ==
16590 == Foo Bar ==
16591 !! html
16592 <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>
16593 <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>
16594
16595 !! end
16596
16597 !! article
16598 Template:sections
16599 !! text
16600 ===Section 1===
16601 ==Section 2==
16602 !! endarticle
16603
16604 !! test
16605 Template with sections, __NOTOC__
16606 !! wikitext
16607 __NOTOC__
16608 ==Section 0==
16609 {{sections}}
16610 ==Section 4==
16611 !! html
16612 <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>
16613 <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>
16614 <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>
16615 <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>
16616
16617 !! end
16618
16619 !! test
16620 __NOEDITSECTION__ keyword
16621 !! wikitext
16622 __NOEDITSECTION__
16623 ==Section 1==
16624 ==Section 2==
16625 !! html
16626 <h2><span class="mw-headline" id="Section_1">Section 1</span></h2>
16627 <h2><span class="mw-headline" id="Section_2">Section 2</span></h2>
16628
16629 !! end
16630
16631 !! test
16632 Link inside a section heading
16633 !! wikitext
16634 ==Section with a [[Main Page|link]] in it==
16635 !! html
16636 <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>
16637
16638 !! end
16639
16640 !! test
16641 TOC regression (T14077)
16642 !! wikitext
16643 __TOC__
16644 == title 1 ==
16645 === title 1.1 ===
16646 == title 2 ==
16647 !! html
16648 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16649 <ul>
16650 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16651 <ul>
16652 <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>
16653 </ul>
16654 </li>
16655 <li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li>
16656 </ul>
16657 </div>
16658
16659 <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>
16660 <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>
16661 <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>
16662
16663 !! end
16664
16665 !! test
16666 T3219 URL next to image (good)
16667 !! wikitext
16668 http://example.com [[File:Foobar.jpg]]
16669 !! html/php
16670 <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>
16671 </p>
16672 !! html/parsoid
16673 <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>
16674 !!end
16675
16676 # Parsoid doesn't wt2wt this cleanly because it adds <nowiki>s.
16677 !! test
16678 Short headings with trailing space should match behavior of Parser::doHeadings (T21910)
16679 !! options
16680 parsoid=wt2html,html2html
16681 !! wikitext
16682 ===
16683 The line above must have a trailing space!
16684 === <!--
16685 --> <!-- -->
16686 But just in case it doesn't...
16687 !! html/php
16688 <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>
16689 <p>The line above must have a trailing space!
16690 </p>
16691 <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>
16692 <p>But just in case it doesn't...
16693 </p>
16694 !! html/parsoid
16695 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
16696 <p>The line above must have a trailing space!</p>
16697 <h1 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h1> <!--
16698 --> <!-- -->
16699 <p>But just in case it doesn't...</p>
16700 !! end
16701
16702 !! test
16703 Header with special characters (T27462)
16704 !! wikitext
16705 The tooltips shall not show entities to the user (ie. be double escaped)
16706
16707 == text > text ==
16708 section 1
16709
16710 == text < text ==
16711 section 2
16712
16713 == text & text ==
16714 section 3
16715
16716 == text ' text ==
16717 section 4
16718
16719 == text " text ==
16720 section 5
16721 !! html/php
16722 <p>The tooltips shall not show entities to the user (ie. be double escaped)
16723 </p>
16724 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16725 <ul>
16726 <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>
16727 <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>
16728 <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>
16729 <li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li>
16730 <li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li>
16731 </ul>
16732 </div>
16733
16734 <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>
16735 <p>section 1
16736 </p>
16737 <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>
16738 <p>section 2
16739 </p>
16740 <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>
16741 <p>section 3
16742 </p>
16743 <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>
16744 <p>section 4
16745 </p>
16746 <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>
16747 <p>section 5
16748 </p>
16749 !! html/parsoid
16750 <p>The tooltips shall not show entities to the user (ie. be double escaped)</p>
16751
16752 <h2 id="text_>_text"><span id="text_.3E_text" typeof="mw:FallbackId"></span> text > text </h2>
16753 <p>section 1</p>
16754
16755 <h2 id="text_&lt;_text"><span id="text_.3C_text" typeof="mw:FallbackId"></span> text &lt; text </h2>
16756 <p>section 2</p>
16757
16758 <h2 id="text_&amp;_text"><span id="text_.26_text" typeof="mw:FallbackId"></span> text &amp; text </h2>
16759 <p>section 3</p>
16760
16761 <h2 id="text_'_text"><span id="text_.27_text" typeof="mw:FallbackId"></span> text ' text </h2>
16762 <p>section 4</p>
16763
16764 <h2 id='text_"_text'><span id="text_.22_text" typeof="mw:FallbackId"></span> text " text </h2>
16765 <p>section 5</p>
16766 !! end
16767
16768 !! test
16769 Header with space, plus and underscore as entity
16770 !! wikitext
16771 Id should not contain + for spaces
16772
16773 == Space between Text ==
16774 section 1
16775
16776 == Space-Entity&#32;between&#32;Text ==
16777 section 2
16778
16779 == Plus+between+Text ==
16780 section 3
16781
16782 == Plus-Entity&#43;between&#43;Text ==
16783 section 4
16784
16785 == Underscore_between_Text ==
16786 section 5
16787
16788 == Underscore-Entity&#95;between&#95;Text ==
16789 section 6
16790
16791 [[#Space between Text]]
16792 [[#Space-Entity&#32;between&#32;Text]]
16793 [[#Plus+between+Text]]
16794 [[#Plus-Entity&#43;between&#43;Text]]
16795 [[#Underscore_between_Text]]
16796 [[#Underscore-Entity&#95;between&#95;Text]]
16797 !! html/php
16798 <p>Id should not contain + for spaces
16799 </p>
16800 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16801 <ul>
16802 <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>
16803 <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>
16804 <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>
16805 <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>
16806 <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>
16807 <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>
16808 </ul>
16809 </div>
16810
16811 <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>
16812 <p>section 1
16813 </p>
16814 <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>
16815 <p>section 2
16816 </p>
16817 <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>
16818 <p>section 3
16819 </p>
16820 <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>
16821 <p>section 4
16822 </p>
16823 <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>
16824 <p>section 5
16825 </p>
16826 <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>
16827 <p>section 6
16828 </p><p><a href="#Space_between_Text">#Space between Text</a>
16829 <a href="#Space-Entity_between_Text">#Space-Entity&#32;between&#32;Text</a>
16830 <a href="#Plus.2Bbetween.2BText">#Plus+between+Text</a>
16831 <a href="#Plus-Entity.2Bbetween.2BText">#Plus-Entity&#43;between&#43;Text</a>
16832 <a href="#Underscore_between_Text">#Underscore_between_Text</a>
16833 <a href="#Underscore-Entity_between_Text">#Underscore-Entity&#95;between&#95;Text</a>
16834 </p>
16835 !! html/parsoid
16836 <p>Id should not contain + for spaces</p>
16837
16838 <h2 id="Space_between_Text"> Space between Text </h2>
16839 <p>section 1</p>
16840
16841 <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>
16842 <p>section 2</p>
16843
16844 <h2 id="Plus+between+Text"><span id="Plus.2Bbetween.2BText" typeof="mw:FallbackId"></span> Plus+between+Text </h2>
16845 <p>section 3</p>
16846
16847 <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>
16848 <p>section 4</p>
16849
16850 <h2 id="Underscore_between_Text"> Underscore_between_Text </h2>
16851 <p>section 5</p>
16852
16853 <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>
16854 <p>section 6</p>
16855
16856 <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>
16857 <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>
16858 <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>
16859 <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>
16860 <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>
16861 <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>
16862 !! end
16863
16864 # Parsoid html2wt disabled because it adds padding spaces around =
16865 !! test
16866 Headers with excess '=' characters
16867 (Are similar tests necessary beyond the 1st level?)
16868 !! options
16869 parsoid=wt2html,wt2wt,html2html
16870 !! wikitext
16871 =foo==
16872 ==foo=
16873 =''italic'' heading==
16874 ==''italic'' heading=
16875 !! html/php
16876 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16877 <ul>
16878 <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
16879 <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
16880 <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>
16881 <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>
16882 </ul>
16883 </div>
16884
16885 <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>
16886 <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>
16887 <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>
16888 <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>
16889
16890 !! html/parsoid
16891 <h1 id="foo="><span id="foo.3D" typeof="mw:FallbackId"></span>foo=</h1>
16892 <h1 id="=foo"><span id=".3Dfoo" typeof="mw:FallbackId"></span>=foo</h1>
16893 <h1 id="italic_heading="><span id="italic_heading.3D" typeof="mw:FallbackId"></span><i>italic</i> heading=</h1>
16894 <h1 id="=italic_heading"><span id=".3Ditalic_heading" typeof="mw:FallbackId"></span>=<i>italic</i> heading</h1>
16895 !! end
16896
16897 !! test
16898 HTML headers vs TOC (T25393)
16899 (__NOEDITSECTION__ for clearer output, doesn't matter here)
16900 !! wikitext
16901 <h1>Header 1</h1>
16902 == Header 1.1 ==
16903 == Header 1.2 ==
16904
16905 <h1>Header 2
16906 </h1>
16907 == Header 2.1 ==
16908 == Header 2.2 ==
16909 __NOEDITSECTION__
16910 !! html/php
16911 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16912 <ul>
16913 <li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
16914 <ul>
16915 <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>
16916 <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>
16917 </ul>
16918 </li>
16919 <li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a>
16920 <ul>
16921 <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>
16922 <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>
16923 </ul>
16924 </li>
16925 </ul>
16926 </div>
16927
16928 <h1><span class="mw-headline" id="Header_1">Header 1</span></h1>
16929 <h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2>
16930 <h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2>
16931 <h1><span class="mw-headline" id="Header_2">Header 2</span></h1>
16932 <h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2>
16933 <h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2>
16934
16935 !! html/parsoid
16936 <h1 id="Header_1" data-parsoid='{"stx":"html"}'>Header 1</h1>
16937 <h2 id="Header_1.1" data-parsoid='{}'> Header 1.1 </h2>
16938 <h2 id="Header_1.2" data-parsoid='{}'> Header 1.2 </h2>
16939
16940 <h1 id="Header_2" data-parsoid='{"stx":"html"}'>Header 2
16941 </h1>
16942 <h2 id="Header_2.1" data-parsoid='{}'> Header 2.1 </h2>
16943 <h2 id="Header_2.2" data-parsoid='{}'> Header 2.2 </h2>
16944 <meta property="mw:PageProp/noeditsection"/>
16945 !! end
16946
16947 !! test
16948 Single-line or multiline-comments can follow headings
16949 !! options
16950 parsoid=wt2html,wt2wt
16951 !! wikitext
16952 ==foo==<!---->
16953 ==bar==<!--c1-->
16954 ==baz==<!--
16955 c2
16956 c3-->
16957 !! html/php
16958 <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>
16959 <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>
16960 <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>
16961
16962 !! html/parsoid
16963 <h2 id="foo">foo</h2><!---->
16964 <h2 id="bar">bar</h2><!--c1-->
16965 <h2 id="baz">baz</h2><!--
16966 c2
16967 c3-->
16968 !! end
16969
16970 !! test
16971 T3219 URL next to image (broken)
16972 !! wikitext
16973 http://example.com[[File:Foobar.jpg]]
16974 !! html/php
16975 <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>
16976 </p>
16977 !! html/parsoid
16978 <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>
16979 !!end
16980
16981 !! test
16982 T3186 news: in the middle of text
16983 !! wikitext
16984 http://en.wikinews.org/wiki/Wikinews:Workplace
16985 !! html
16986 <p><a rel="nofollow" class="external free" href="http://en.wikinews.org/wiki/Wikinews:Workplace">http://en.wikinews.org/wiki/Wikinews:Workplace</a>
16987 </p>
16988 !!end
16989
16990
16991 !! test
16992 Namespaced link must have a title
16993 !! wikitext
16994 [[Project:]]
16995 !! html
16996 <p>[[Project:]]
16997 </p>
16998 !!end
16999
17000 !! test
17001 Namespaced link must have a title (bad fragment version)
17002 !! wikitext
17003 [[Project:#fragment]]
17004 !! html
17005 <p>[[Project:#fragment]]
17006 </p>
17007 !!end
17008
17009
17010 ###
17011 ### HTML tags and HTML attributes
17012 ###
17013
17014 !! test
17015 div with no attributes
17016 !! wikitext
17017 <div>HTML rocks</div>
17018 !! html
17019 <div>HTML rocks</div>
17020
17021 !! end
17022
17023 !! test
17024 div with double-quoted attribute
17025 !! wikitext
17026 <div id="rock">HTML rocks</div>
17027 !! html
17028 <div id="rock">HTML rocks</div>
17029
17030 !! end
17031
17032 !! test
17033 div with single-quoted attribute
17034 !! wikitext
17035 <div id='rock'>HTML rocks</div>
17036 !! html
17037 <div id="rock">HTML rocks</div>
17038
17039 !! end
17040
17041 !! test
17042 div with unquoted attribute
17043 !! wikitext
17044 <div id=rock>HTML rocks</div>
17045 !! html
17046 <div id="rock">HTML rocks</div>
17047
17048 !! end
17049
17050 !! test
17051 div with illegal double attributes
17052 !! wikitext
17053 <div id="a" id="b">HTML rocks</div>
17054 !! html
17055 <div id="b">HTML rocks</div>
17056
17057 !!end
17058
17059 !! test
17060 div with empty attribute value, space before equals
17061 !! options
17062 parsoid=wt2html,html2html
17063 !! wikitext
17064 <div class =>HTML rocks</div>
17065 !! html/php
17066 <div class="">HTML rocks</div>
17067
17068 !! html/parsoid
17069 <div class="" data-parsoid='{"stx":"html"}'>HTML rocks</div>
17070 !! end
17071
17072 !! test
17073 div with multiple empty attribute values
17074 !! config
17075 wgFragmentMode=[ 'html5', 'legacy' ]
17076 !! options
17077 parsoid=wt2html,html2html
17078 !! wikitext
17079 <div id= title=>HTML rocks</div>
17080 !! html/php
17081 <div id="title=">HTML rocks</div>
17082
17083 !! html/parsoid
17084 <div id="title=" data-parsoid='{"stx":"html"}'>HTML rocks</div>
17085 !! end
17086
17087 # FIXME Parsoid doesn't actually match PHP here.
17088 # Probably we should use the synthetic <foo /> or <indicator>
17089 # extensions for this test, which are enabled when running parser tests.
17090 !! test
17091 Extension tag in attribute value
17092 !! wikitext
17093 <span title="<translate>123</translate>">ok</span>
17094 !! html/php+disabled
17095 <p>&lt;span title="&lt;translate&gt;123&lt;/translate&gt;"&gt;ok&lt;/span&gt;
17096 </p>
17097 !! html/parsoid
17098 <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>
17099 !! end
17100
17101 !! test
17102 table with multiple empty attribute values
17103 !! options
17104 parsoid=wt2html,html2html
17105 !! wikitext
17106 {| title= id=
17107 | hi
17108 |}
17109 !! html/php
17110 <table title="id=">
17111 <tr>
17112 <td> hi
17113 </td></tr></table>
17114
17115 !! html/parsoid
17116 <table title="id=">
17117 <tbody><tr><td> hi</td></tr>
17118 </tbody></table>
17119 !! end
17120
17121 !! test
17122 div with braces in attribute value
17123 !! wikitext
17124 <div title="{}">Foo</div>
17125 !! html/php
17126 <div title="&#123;&#125;">Foo</div>
17127
17128 !! html/parsoid
17129 <div title="{}">Foo</div>
17130 !! end
17131
17132 !! test
17133 div with empty attribute value, no space before equals
17134 !! options
17135 parsoid=wt2html,html2html
17136 !! wikitext
17137 <div class=>HTML rocks</div>
17138 !! html/php
17139 <div class="">HTML rocks</div>
17140
17141 !! html/parsoid
17142 <div class="">HTML rocks</div>
17143 !! end
17144
17145 !! test
17146 HTML multiple attributes correction
17147 !! wikitext
17148 <p class="error" class="awesome">Awesome!</p>
17149 !! html
17150 <p class="awesome">Awesome!</p>
17151
17152 !!end
17153
17154 !! test
17155 Table multiple attributes correction
17156 !! wikitext
17157 {|
17158 !+ class="error" class="awesome"| status
17159 |}
17160 !! html
17161 <table>
17162 <tr>
17163 <th class="awesome"> status
17164 </th></tr></table>
17165
17166 !!end
17167
17168 !! test
17169 DIV IN UPPERCASE
17170 !! wikitext
17171 <DIV ID="x">HTML ROCKS</DIV>
17172 !! html
17173 <div id="x">HTML ROCKS</div>
17174
17175 !!end
17176
17177 !! test
17178 Non-ASCII pseudo-tags are rendered as text
17179 !! wikitext
17180 <khyô>
17181 !! html
17182 <p>&lt;khyô&gt;
17183 </p>
17184 !! end
17185
17186 !! test
17187 Pseudo-tag with URL 'name' renders as url link
17188 !! wikitext
17189 <http://example.com/>
17190 !! html
17191 <p>&lt;<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&gt;
17192 </p>
17193 !! end
17194
17195 !! test
17196 text with amp in the middle of nowhere
17197 !! wikitext
17198 Remember AT&T?
17199 !! html
17200 <p>Remember AT&amp;T?
17201 </p>
17202 !! end
17203
17204 !! test
17205 text with character entity: eacute
17206 !! wikitext
17207 I always thought &eacute; was a cute letter.
17208 !! html+tidy
17209 <p>I always thought &#233; was a cute letter.
17210 </p>
17211 !! end
17212
17213 !! test
17214 text with entity-escaped character entity-like string: eacute
17215 !! wikitext
17216 I always thought &amp;eacute; was a cute letter.
17217 !! html
17218 <p>I always thought &amp;eacute; was a cute letter.
17219 </p>
17220 !! end
17221
17222 !! test
17223 text with undefined character entity: xacute
17224 !! wikitext
17225 I always thought &xacute; was a cute letter.
17226 !! html
17227 <p>I always thought &amp;xacute; was a cute letter.
17228 </p>
17229 !! end
17230
17231 !! test
17232 HTML5 tags
17233 !! wikitext
17234 <data value="5">five</data>
17235 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
17236 <mark>This highlighted text</mark>
17237 !! html
17238 <p><data value="5">five</data>
17239 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
17240 <mark>This highlighted text</mark>
17241 </p>
17242 !! end
17243
17244 !! test
17245 HTML tag with leading space is parsed as text
17246 !! wikitext
17247 < div>foo< /div>
17248 !! html
17249 <p>&lt; div&gt;foo&lt; /div&gt;
17250 </p>
17251 !! end
17252
17253 ## Don't expect Parsoid and PHP to match, since PHP isn't exactly following
17254 ## the HTML5 parsing spec.
17255 !! test
17256 Element with broken attribute syntax
17257 !! options
17258 parsoid=wt2html
17259 !! wikitext
17260 <div style=" style="123">hi</div>
17261 <div =>ho</div>
17262 !! html/php
17263 <div style="123">hi</div>
17264 <div>ho</div>
17265
17266 !! html/parsoid
17267 <div style=" style=" data-parsoid='{"stx":"html","a":{"123\"":null},"sa":{"123\"":""}}'>hi</div>
17268 <div data-parsoid='{"stx":"html","a":{"=":null},"sa":{"=":""}}'>ho</div>
17269 !! end
17270
17271 ###
17272 ### Nesting tests (see T43545, T52604, T53081)
17273 ###
17274
17275 # This test case is fixed in Parsoid by domino 1.0.12. (T52604)
17276 # Note that html2wt is considerably more difficult if we use <b> in
17277 # the test case, instead of <small>
17278 !! test
17279 Ensure that HTML adoption agency algorithm is properly implemented.
17280 !! wikitext
17281 <small>X<small>Y</small>Z</small>
17282 !! html
17283 <p><small>X<small>Y</small>Z</small>
17284 </p>
17285 !! end
17286
17287 # This was T43545 in the PHP parser.
17288 !! test
17289 Nesting of <kbd>
17290 !! wikitext
17291 <kbd>X<kbd>Y</kbd>Z</kbd>
17292 !! html+tidy
17293 <p><kbd>X<kbd>Y</kbd>Z</kbd>
17294 </p>
17295 !! end
17296
17297 # The following cases were T53081 in the PHP parser.
17298 # Note that there are some other nestable tags (b, i, etc) which are
17299 # not covered; see T53081 for discussion.
17300
17301 !! test
17302 Nesting of <em>
17303 !! wikitext
17304 <em>X<em>Y</em>Z</em>
17305 !! html+tidy
17306 <p><em>X<em>Y</em>Z</em>
17307 </p>
17308 !! end
17309
17310 !! test
17311 Nesting of <strong>
17312 !! wikitext
17313 <strong>X<strong>Y</strong>Z</strong>
17314 !! html+tidy
17315 <p><strong>X<strong>Y</strong>Z</strong>
17316 </p>
17317 !! end
17318
17319 !! test
17320 Nesting of <q>
17321 !! wikitext
17322 <q>X<q>Y</q>Z</q>
17323 !! html+tidy
17324 <p><q>X<q>Y</q>Z</q>
17325 </p>
17326 !! end
17327
17328 !! test
17329 Nesting of <ruby>
17330 !! wikitext
17331 <ruby>X<ruby>Y</ruby>Z</ruby>
17332 !! html
17333 <p><ruby>X<ruby>Y</ruby>Z</ruby>
17334 </p>
17335 !! end
17336
17337 !! test
17338 Nesting of <bdo>
17339 !! wikitext
17340 <bdo>X<bdo>Y</bdo>Z</bdo>
17341 !! html
17342 <p><bdo>X<bdo>Y</bdo>Z</bdo>
17343 </p>
17344 !! end
17345
17346
17347 ###
17348 ### Media links
17349 ###
17350
17351 !! test
17352 Media link
17353 !! wikitext
17354 [[Media:Foobar.jpg]]
17355 [[Media:Video.ogv]]
17356 [[:Media:Video.ogv]]
17357 !! html/php
17358 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a>
17359 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
17360 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
17361 </p>
17362 !! html/parsoid
17363 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a>
17364 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" title="Video.ogv">Media:Video.ogv</a>
17365 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" title="Video.ogv" data-parsoid='{"a":{"namespace":"Media"},"sa":{"namespace":":Media"}}'>Media:Video.ogv</a></p>
17366 !! end
17367
17368 !! test
17369 Media link with text
17370 !! wikitext
17371 [[Media:Foobar.jpg|A neat file to look at]]
17372 !! html/php
17373 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">A neat file to look at</a>
17374 </p>
17375 !! html/parsoid
17376 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
17377 !! end
17378
17379 # FIXME: this is still bad HTML tag nesting
17380 # FIXME: doBlockLevels won't wrap this in a paragraph because it contains a div
17381 # Parsoid & Remex fix the p-wrapping since they operate on the DOM.
17382 !! test
17383 Media link with nasty text
17384 !! wikitext
17385 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
17386 !! html/php
17387 <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>
17388
17389 !! html+php/tidy
17390 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Safe Link</a></p>
17391 <div style="display:none">" onmouseover="alert(document.cookie)" onfoo="</div>
17392 !! html/parsoid
17393 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg" data-parsoid='{"autoInsertedEnd":true}'>Safe Link</a></p><div style="display:none" data-parsoid='{"stx":"html"}'><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg" data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'>" onmouseover="alert(document.cookie)" onfoo="</a></div>
17394
17395 !! end
17396
17397 !! test
17398 Media link to nonexistent file (T3702)
17399 !! wikitext
17400 [[Media:No such.jpg]]
17401 [[Media:No_such file.jpg]]
17402 !! html/php
17403 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a>
17404 <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>
17405 </p>
17406 !! html/parsoid
17407 <p><a rel="mw:MediaLink" href="./Special:FilePath/No_such.jpg" title="No such.jpg" typeof="mw:Error" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}' data-parsoid='{"a":{"fileName":"No_such.jpg"},"sa":{"fileName":"No such.jpg"}}'>Media:No such.jpg</a>
17408 <a rel="mw:MediaLink" href="./Special:FilePath/No_such_file.jpg" title="No such file.jpg" typeof="mw:Error" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}' data-parsoid='{"a":{"fileName":"No_such_file.jpg"},"sa":{"fileName":"No_such file.jpg"}}'>Media:No_such file.jpg</a></p>
17409 !! end
17410
17411 !! test
17412 Image link to nonexistent file (T3850 - good)
17413 !! wikitext
17414 [[File:No_such.jpg]]
17415 !! html/php
17416 <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>
17417 </p>
17418 !! html/parsoid
17419 <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>
17420 !! end
17421
17422 !! test
17423 :Image link to nonexistent file (T3850 - bad)
17424 !! wikitext
17425 [[:Image:No such.jpg]]
17426 !! html/php
17427 <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>
17428 </p>
17429 !! html/parsoid
17430 <p><a rel="mw:WikiLink" href="./File:No_such.jpg" title="File:No such.jpg">Image:No such.jpg</a></p>
17431 !! end
17432
17433 !! test
17434 Character reference normalization in link text (T3938)
17435 !! wikitext
17436 [[Main Page|this&that]]
17437 !! html
17438 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
17439 </p>
17440 !!end
17441
17442 !! article
17443 אַ
17444 !! text
17445 Test for unicode normalization
17446
17447 The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
17448 !! endarticle
17449
17450 !! test
17451 (T21451) Links should refer to the normalized form.
17452 !! wikitext
17453 [[&#xFB2E;]]
17454 [[&#x5d0;&#x5b7;]]
17455 [[&#x5d0;ַ]]
17456 [[א&#x5b7;]]
17457 [[אַ]]
17458 !! html
17459 <p><a href="/wiki/%D7%90%D6%B7" title="אַ">&#xfb2e;</a>
17460 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;&#x5b7;</a>
17461 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;ַ</a>
17462 <a href="/wiki/%D7%90%D6%B7" title="אַ">א&#x5b7;</a>
17463 <a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a>
17464 </p>
17465 !! end
17466
17467 !! test
17468 Empty attribute crash test (T4067)
17469 !! wikitext
17470 <font color="">foo</font>
17471 !! html
17472 <p><font color="">foo</font>
17473 </p>
17474 !! end
17475
17476 !! test
17477 Empty attribute crash test single-quotes (T4067)
17478 !! wikitext
17479 <font color=''>foo</font>
17480 !! html
17481 <p><font color="">foo</font>
17482 </p>
17483 !! end
17484
17485 !! test
17486 Attribute test: equals, then nothing
17487 !! options
17488 parsoid=wt2html,html2html
17489 !! wikitext
17490 <font color=>foo</font>
17491 !! html/php
17492 <p><font color="">foo</font>
17493 </p>
17494 !! html/parsoid
17495 <p><font color="" data-parsoid='{"stx":"html"}'>foo</font></p>
17496 !! end
17497
17498 !! test
17499 Attribute test: unquoted value
17500 !! options
17501 parsoid=wt2html,html2html
17502 !! wikitext
17503 <font color=x>foo</font>
17504 !! html/php
17505 <p><font color="x">foo</font>
17506 </p>
17507 !! html/parsoid
17508 <p><font color="x" data-parsoid='{"stx":"html"}'>foo</font></p>
17509 !! end
17510
17511 !! test
17512 Attribute test: unquoted but illegal value (hash)
17513 !! wikitext
17514 <font color=#x>foo</font>
17515 !! html
17516 <p><font color="#x">foo</font>
17517 </p>
17518 !! end
17519
17520 # Parsoid does not serialize to empty attribute syntax,
17521 # so wt2wt and html2wt cases are skipped
17522 !! test
17523 Attribute test: no value (T54330)
17524 !! options
17525 parsoid=wt2html,html2html
17526 !! wikitext
17527 <font color>foo</font>
17528 !! html/php
17529 <p><font color="">foo</font>
17530 </p>
17531 !! html/parsoid
17532 <p><font color="">foo</font></p>
17533 !! end
17534
17535 !! test
17536 T4095: link with three closing brackets
17537 !! wikitext
17538 [[Main Page]]]
17539 !! html/php
17540 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
17541 </p>
17542 !! html/parsoid
17543 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>]</p>
17544 !! end
17545
17546 !! test
17547 T4095: link with pipe and three closing brackets
17548 !! wikitext
17549 [[Main Page|link]]]
17550 !! html/php
17551 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
17552 </p>
17553 !! html/parsoid
17554 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">link</a>]</p>
17555 !! end
17556
17557 !! test
17558 T4095: link with pipe and three closing brackets, version 2
17559 !! wikitext
17560 [[Main Page|[http://example.com/]]]
17561 !! html/php
17562 <p><a href="/wiki/Main_Page" title="Main Page">[http://example.com/]</a>
17563 </p>
17564 !! html/parsoid
17565 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">[http://example.com/]</a></p>
17566 !! end
17567
17568
17569 ###
17570 ### Safety
17571 ###
17572
17573 !! article
17574 Template:Dangerous attribute
17575 !! text
17576 " onmouseover="alert(document.cookie)
17577 !! endarticle
17578
17579 !! article
17580 Template:Dangerous style attribute
17581 !! text
17582 border-size: expression(alert(document.cookie))
17583 !! endarticle
17584
17585 !! article
17586 Template:Div style
17587 !! text
17588 <div style="float: right; {{{1}}}">Magic div</div>
17589 !! endarticle
17590
17591 !! test
17592 T4304: HTML attribute safety (safe template; regression T4309)
17593 !! wikitext
17594 <div title="{{test}}"></div>
17595 !! html/php
17596 <div title="This is a test template"></div>
17597
17598 !! html/parsoid
17599 <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>
17600 !! end
17601
17602 # Parsoid has enough context to handle this case
17603 !! test
17604 T4304: HTML attribute safety (dangerous template; 2309)
17605 !! wikitext
17606 <div title="{{dangerous attribute}}"></div>
17607 !! html/php
17608 <div title=""></div>
17609
17610 !! html/parsoid
17611 <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>
17612 !! end
17613
17614 !! test
17615 T4304: HTML attribute safety (dangerous style template; 2309)
17616 !! wikitext
17617 <div style="{{dangerous style attribute}}"></div>
17618 !! html/php
17619 <div style="/* insecure input */"></div>
17620
17621 !! html/parsoid
17622 <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>
17623 !! end
17624
17625 !! test
17626 T4304: HTML attribute safety (safe parameter; 2309)
17627 !! wikitext
17628 {{div style|width: 200px}}
17629 !! html/php
17630 <div style="float: right; width: 200px">Magic div</div>
17631
17632 !! html/parsoid
17633 <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>
17634 !! end
17635
17636 !! test
17637 T4304: HTML attribute safety (unsafe parameter; 2309)
17638 !! wikitext
17639 {{div style|width: expression(alert(document.cookie))}}
17640 !! html/php
17641 <div style="/* insecure input */">Magic div</div>
17642
17643 !! html/parsoid
17644 <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>
17645 !! end
17646
17647 ## Parsoid output here differs; needs investigation.
17648 !! test
17649 T4304: HTML attribute safety (unsafe breakout parameter; 2309)
17650 !! wikitext
17651 {{div style|"><script>alert(document.cookie)</script>}}
17652 !! html
17653 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17654
17655 !! end
17656
17657 ## Parsoid output here differs; needs investigation.
17658 !! test
17659 T4304: HTML attribute safety (unsafe breakout parameter 2; 2309)
17660 !! wikitext
17661 {{div style|" ><script>alert(document.cookie)</script>}}
17662 !! html
17663 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17664
17665 !! end
17666
17667 !! test
17668 T4304: HTML attribute safety (link)
17669 !! wikitext
17670 <div title="[[Main Page]]"></div>
17671 !! html/php
17672 <div title="&#91;&#91;Main Page&#93;&#93;"></div>
17673
17674 !! html/parsoid
17675 <div title="[[Main Page]]"></div>
17676 !! end
17677
17678 !! test
17679 T4304: HTML attribute safety (italics)
17680 !! wikitext
17681 <div title="''foobar''"></div>
17682 !! html
17683 <div title="&#39;&#39;foobar&#39;&#39;"></div>
17684
17685 !! end
17686
17687 !! test
17688 T4304: HTML attribute safety (bold)
17689 !! wikitext
17690 <div title="'''foobar'''"></div>
17691 !! html
17692 <div title="&#39;&#39;&#39;foobar&#39;&#39;&#39;"></div>
17693
17694 !! end
17695
17696 !! test
17697 T4304: HTML attribute safety (ISBN)
17698 !! wikitext
17699 <div title="ISBN 1234567890"></div>
17700 !! html
17701 <div title="&#73;SBN 1234567890"></div>
17702
17703 !! end
17704
17705 !! test
17706 T4304: HTML attribute safety (RFC)
17707 !! wikitext
17708 <div title="RFC 1234"></div>
17709 !! html
17710 <div title="&#82;FC 1234"></div>
17711
17712 !! end
17713
17714 !! test
17715 T4304: HTML attribute safety (PMID)
17716 !! wikitext
17717 <div title="PMID 1234567890"></div>
17718 !! html
17719 <div title="&#80;MID 1234567890"></div>
17720
17721 !! end
17722
17723 !! test
17724 T4304: HTML attribute safety (web link)
17725 !! wikitext
17726 <div title="http://example.com/"></div>
17727 !! html
17728 <div title="http&#58;//example.com/"></div>
17729
17730 !! end
17731
17732 !! test
17733 T4304: HTML attribute safety (named web link)
17734 !! wikitext
17735 <div title="[http://example.com/ link]"></div>
17736 !! html/php
17737 <div title="&#91;http&#58;//example.com/ link&#93;"></div>
17738
17739 !! html/parsoid
17740 <div title="[http://example.com/ link]"></div>
17741 !! end
17742
17743 !! test
17744 T5244: HTML attribute safety (extension; safe)
17745 !! wikitext
17746 <div style="<nowiki>background:blue</nowiki>"></div>
17747 !! html/php
17748 <div style="background:blue"></div>
17749
17750 !! html/parsoid
17751 <div style="background:blue" data-parsoid='{"stx":"html","a":{"style":"background:blue"},"sa":{"style":"&lt;nowiki>background:blue&lt;/nowiki>"}}'></div>
17752 !! end
17753
17754 !! test
17755 T5244: HTML attribute safety (extension; unsafe)
17756 !! wikitext
17757 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
17758 !! html/php
17759 <div style="/* insecure input */"></div>
17760
17761 !! html/parsoid
17762 <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>
17763 !! end
17764
17765 # More MSIE fun discovered by Tom Gilder
17766
17767 !! test
17768 MSIE CSS safety test: spurious slash
17769 !! wikitext
17770 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
17771 !! html/php
17772 <div style="/* insecure input */">evil</div>
17773
17774 !! html/parsoid
17775 <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>
17776 !! end
17777
17778 !! test
17779 MSIE CSS safety test: hex code
17780 !! wikitext
17781 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
17782 !! html/php
17783 <div style="/* insecure input */">evil</div>
17784
17785 !! html/parsoid
17786 <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>
17787 !! end
17788
17789 !! test
17790 MSIE CSS safety test: comment in url
17791 !! wikitext
17792 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
17793 !! html/php
17794 <div style="background-image:u rl(javascript:alert(&#39;boo&#39;))">evil</div>
17795
17796 !! html/parsoid
17797 <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>
17798 !! end
17799
17800 !! test
17801 MSIE CSS safety test: comment in expression
17802 !! wikitext
17803 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
17804 !! html/php
17805 <div style="background-image:expres sion(alert(&#39;boo4&#39;))">evil4</div>
17806
17807 !! html/parsoid
17808 <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>
17809 !! end
17810
17811 !! test
17812 CSS safety test (all browsers): vertical tab (T57332 / CVE-2013-4567)
17813 !! wikitext
17814 <p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p>
17815 !! html/php
17816 <p style="/* invalid control char */">A</p>
17817
17818 !! html/parsoid
17819 <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>
17820 !! end
17821
17822 !! test
17823 MSIE 6 CSS safety test: Fullwidth (T57332)
17824 !! wikitext
17825 <p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p>
17826 <div style="top:EXPRESSION(alert())">B</div>
17827 !! html/php
17828 <p style="/* insecure input */">A</p>
17829 <div style="/* insecure input */">B</div>
17830
17831 !! html/parsoid
17832 <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>
17833 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"top:EXPRESSION(alert())"}}'>B</div>
17834 !! end
17835
17836 !! test
17837 MSIE 6 CSS safety test: IPA extensions (T57332)
17838 !! wikitext
17839 <div style="background-image:uʀʟ(javascript:alert())">A</div>
17840 <p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p>
17841 !! html/php
17842 <div style="/* insecure input */">A</div>
17843 <p style="/* insecure input */">B</p>
17844
17845 !! html/parsoid
17846 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:uʀʟ(javascript:alert())"}}'>A</div>
17847 <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>
17848 !! end
17849
17850 !! test
17851 MSIE 6 CSS safety test: sup/sub script (T57332)
17852 !! wikitext
17853 <div style="background-image:url⁽javascript:alert())">A</div>
17854 <div style="background-image:url₍javascript:alert())">B</div>
17855 <p style="font-size: 100px; color: expressioⁿ((title='XSSed'),'red')">C</p>
17856 !! html/php
17857 <div style="/* insecure input */">A</div>
17858 <div style="/* insecure input */">B</div>
17859 <p style="/* insecure input */">C</p>
17860
17861 !! html/parsoid
17862 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url⁽javascript:alert())"}}'>A</div>
17863 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url₍javascript:alert())"}}'>B</div>
17864 <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>
17865 !! end
17866
17867 !! test
17868 Opera -o-link CSS
17869 !! options
17870 parsoid=wt2html,html2html
17871 !! wikitext
17872 <div
17873 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;"
17874 style="-o-link:attr(title);-o-link-source:current">X</div>
17875 !! html/php
17876 <div title="data:text/html,&lt;img src=1 onerror=alert(1)&gt;" style="/* insecure input */">X</div>
17877
17878 !! html/parsoid
17879 <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>
17880 !! end
17881
17882 !! test
17883 MSIE 6 CSS safety test: Repetition markers (T57332)
17884 !! wikitext
17885 <p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p>
17886 <p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p>
17887 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">C</p>
17888 <p style="font-size: 100px; color: expresヽion((title='XSSed'),'red')">D</p>
17889 <p style="font-size: 100px; color: expresﹽion((title='XSSed'),'red')">E</p>
17890 <p style="font-size: 100px; color: expresﹼion((title='XSSed'),'red')">F</p>
17891 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">G</p>
17892 !! html/php
17893 <p style="/* insecure input */">A</p>
17894 <p style="/* insecure input */">B</p>
17895 <p style="/* insecure input */">C</p>
17896 <p style="/* insecure input */">D</p>
17897 <p style="/* insecure input */">E</p>
17898 <p style="/* insecure input */">F</p>
17899 <p style="/* insecure input */">G</p>
17900
17901 !! html/parsoid
17902 <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>
17903 <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>
17904 <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>
17905 <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>
17906 <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>
17907 <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>
17908 <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>
17909 !! end
17910
17911 !! test
17912 Table attribute legitimate extension
17913 !! wikitext
17914 {|
17915 !+ style="<nowiki>color:blue</nowiki>"| status
17916 |}
17917 !! html
17918 <table>
17919 <tr>
17920 <th style="color:blue"> status
17921 </th></tr></table>
17922
17923 !!end
17924
17925 !! test
17926 Table attribute safety
17927 !! wikitext
17928 {|
17929 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"| status
17930 |}
17931 !! html
17932 <table>
17933 <tr>
17934 <th style="/* insecure input */"> status
17935 </th></tr></table>
17936
17937 !! end
17938
17939 !! test
17940 CSS line continuation 1
17941 !! wikitext
17942 <div style="background-image: u\&#10;rl(test.jpg);"></div>
17943 !! html
17944 <div style="/* insecure input */"></div>
17945
17946 !! end
17947
17948 !! test
17949 CSS line continuation 2
17950 !! wikitext
17951 <div style="background-image: u\&#13;rl(test.jpg); "></div>
17952 !! html
17953 <div style="/* invalid control char */"></div>
17954
17955 !! end
17956
17957 !! article
17958 Template:Identity
17959 !! text
17960 {{{1}}}
17961 !! endarticle
17962
17963 !! test
17964 Expansion of multi-line templates in attribute values (T8255)
17965 !! wikitext
17966 <div style="background: {{identity|#00FF00}}">-</div>
17967 !! html
17968 <div style="background: #00FF00">-</div>
17969
17970 !! end
17971
17972 !! test
17973 Expansion of multi-line templates in attribute values (T8255 sanity check)
17974 !! wikitext
17975 <div style="background:
17976 #00FF00">-</div>
17977 !! html/php
17978 <div style="background: #00FF00">-</div>
17979
17980 !! html/parsoid
17981 <div style="background:
17982 #00FF00">-</div>
17983 !! end
17984
17985 !! test
17986 Expansion of multi-line templates in attribute values (T8255 sanity check 2)
17987 !! wikitext
17988 <div style="background: &#10;#00FF00">-</div>
17989 !! html
17990 <div style="background: &#10;#00FF00">-</div>
17991
17992 !! end
17993
17994 !! test
17995 Tags which are hidden from tidiers cannot pass through the Sanitizer
17996 !! wikitext
17997 <mw:toc><script>alert();</script></mw:toc>
17998 !! html+tidy
17999 <p>&lt;mw:toc&gt;&lt;script&gt;alert();&lt;/script&gt;&lt;/mw:toc&gt;
18000 </p>
18001 !! end
18002
18003 ###
18004 ### Parser hooks (see tests/parser/parserTestsParserHook.php for the <tag> extension)
18005 ###
18006
18007 !! test
18008 Parser hook: empty input
18009 !! wikitext
18010 <tag></tag>
18011 !! html/php
18012 <pre>
18013 ''
18014 array (
18015 )
18016 </pre>
18017
18018 !! html/parsoid
18019 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18020 !! end
18021
18022 ## Don't expect parsoid to rt this form.
18023 !! test
18024 Parser hook: empty input using terminated empty elements
18025 !! options
18026 parsoid=wt2html,html2html
18027 !! wikitext
18028 <tag/>
18029 !! html/php
18030 <pre>
18031 NULL
18032 array (
18033 )
18034 </pre>
18035
18036 !! html/parsoid
18037 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
18038 !! end
18039
18040 !! test
18041 Parser hook: empty input using terminated empty elements (space before)
18042 !! wikitext
18043 <tag />
18044 !! html/php
18045 <pre>
18046 NULL
18047 array (
18048 )
18049 </pre>
18050
18051 !! html/parsoid
18052 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
18053 !! end
18054
18055 !! test
18056 Parser hook: basic input
18057 !! wikitext
18058 <tag>input</tag>
18059 !! html/php
18060 <pre>
18061 'input'
18062 array (
18063 )
18064 </pre>
18065
18066 !! html/parsoid
18067 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18068 !! end
18069
18070 ## Don't expect parsoid to rt this form.
18071 !! test
18072 Parser hook: case insensitive
18073 !! options
18074 parsoid=wt2html,html2html
18075 !! wikitext
18076 <TAG>input</TAG>
18077 !! html/php
18078 <pre>
18079 'input'
18080 array (
18081 )
18082 </pre>
18083
18084 !! html/parsoid
18085 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18086 !! end
18087
18088 ## Don't expect parsoid to rt this form.
18089 !! test
18090 Parser hook: case insensitive, redux
18091 !! options
18092 parsoid=wt2html,html2html
18093 !! wikitext
18094 <TaG>input</TAg>
18095 !! html/php
18096 <pre>
18097 'input'
18098 array (
18099 )
18100 </pre>
18101
18102 !! html/parsoid
18103 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18104 !! end
18105
18106 !! test
18107 Parser hook: nested tags
18108 !! wikitext
18109 <tag><tag></tag></tag>
18110 !! html/php
18111 <pre>
18112 '<tag>'
18113 array (
18114 )
18115 </pre>&lt;/tag&gt;
18116
18117 !! html/parsoid
18118 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"&lt;tag>"}}' data-parsoid='{}' about="#mwt2"></pre>&lt;/tag>
18119 !! end
18120
18121 !! test
18122 Parser hook: basic arguments
18123 !! wikitext
18124 <tag width="200" height="100" depth="50" square=""></tag>
18125 !! html/php
18126 <pre>
18127 ''
18128 array (
18129 'width' => '200',
18130 'height' => '100',
18131 'depth' => '50',
18132 'square' => '',
18133 )
18134 </pre>
18135
18136 !! html/parsoid
18137 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18138 !! end
18139
18140 ## Don't expect parsoid to rt this form.
18141 !! test
18142 Parser hook: basic arguments, variations
18143 !! options
18144 parsoid=wt2html,html2html
18145 !! wikitext
18146 <tag width=200 height = "100" depth = '50' square></tag>
18147 !! html/php
18148 <pre>
18149 ''
18150 array (
18151 'width' => '200',
18152 'height' => '100',
18153 'depth' => '50',
18154 'square' => '',
18155 )
18156 </pre>
18157
18158 !! html/parsoid
18159 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18160 !! end
18161
18162 !! test
18163 Parser hook: argument containing a forward slash (T7344)
18164 !! wikitext
18165 <tag filename="/tmp/bla"></tag>
18166 !! html/php
18167 <pre>
18168 ''
18169 array (
18170 'filename' => '/tmp/bla',
18171 )
18172 </pre>
18173
18174 !! html/parsoid
18175 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"filename":"/tmp/bla"},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18176 !! end
18177
18178 ## Don't expect parsoid to rt this form.
18179 !! test
18180 Parser hook: empty input using terminated empty elements (T4374)
18181 !! options
18182 parsoid=wt2html,html2html
18183 !! wikitext
18184 <tag foo=bar/>text
18185 !! html/php
18186 <pre>
18187 NULL
18188 array (
18189 'foo' => 'bar',
18190 )
18191 </pre>text
18192
18193 !! html/parsoid
18194 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"foo":"bar"},"body":null}' data-parsoid='{}' about="#mwt2"></pre>text
18195 !! end
18196
18197 ## </tag> should be output literally since there is no matching tag that begins it
18198 ## Don't expect parsoid to rt this form.
18199 !! test
18200 Parser hook: basic arguments using terminated empty elements (T4374)
18201 !! options
18202 parsoid=wt2html
18203 !! wikitext
18204 <tag width=200 height = "100" depth = '50' square/>
18205 other stuff
18206 </tag>
18207 !! html/php
18208 <pre>
18209 NULL
18210 array (
18211 'width' => '200',
18212 'height' => '100',
18213 'depth' => '50',
18214 'square' => '',
18215 )
18216 </pre>
18217 <p>other stuff
18218 &lt;/tag&gt;
18219 </p>
18220 !! html/parsoid
18221 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":null}' about="#mwt2"></pre><p>other stuff
18222 &lt;/tag></p>
18223 !! end
18224
18225 ## Don't expect parsoid to rt this form.
18226 !! test
18227 Parser hook: Don't allow unclosed extension tags
18228 !! options
18229 parsoid=wt2html
18230 !! wikitext
18231 test <tag>123
18232
18233 this is a '''test'''
18234 !! html/php
18235 <p>test &lt;tag&gt;123
18236 </p><p>this is a <b>test</b>
18237 </p>
18238 !! html/parsoid
18239 <p>test &lt;tag>123</p>
18240
18241 <p>this is a <b>test</b></p>
18242 !! end
18243
18244 !! test
18245 Parser hook: horizontal rule inside extension tag that outputs <pre>
18246 !! wikitext
18247 <tag>
18248 Hello
18249 <hr/>
18250 Goodbye
18251 </tag>
18252 !! html/php
18253 <pre>
18254 '
18255 Hello
18256 <hr/>
18257 Goodbye
18258 '
18259 array (
18260 )
18261 </pre>
18262
18263 !! end
18264
18265 ###
18266 ### (see tests/parser/parserTestsParserHook.php for the <statictag> extension)
18267 ###
18268
18269 !! test
18270 Parser hook: static parser hook not inside a comment
18271 !! wikitext
18272 <statictag>hello, world</statictag>
18273
18274 <statictag action="flush" />
18275 !! html/php
18276 <p><br />
18277 hello, world
18278 </p>
18279 !! html/parsoid
18280 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{},"body":{"extsrc":"hello, world"}}' data-parsoid='{}' about="#mwt2"></span></p>
18281 <p typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about="#mwt4">hello, world</p>
18282 !! end
18283
18284 !! test
18285 Parser hook: static parser hook inside a comment
18286 !! wikitext
18287 <!-- <statictag>hello, world</statictag> -->
18288 <statictag action="flush" />
18289 !! html/php
18290 <p><br />
18291 </p>
18292 !! html/parsoid
18293 <!-- <statictag&#x3E;hello, world</statictag&#x3E; -->
18294 <p typeof='mw:Extension/statictag' data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about='#mwt2'></p>
18295 !! end
18296
18297 # Nested template calls; this case was broken by Parser.php rev 1.506,
18298 # since reverted.
18299
18300 !! article
18301 Template:One-parameter
18302 !! text
18303 (My parameter is: {{{1}}})
18304 !! endarticle
18305
18306 !! article
18307 Template:Map-one-parameter
18308 !! text
18309 {{{{{1}}}|{{{2}}}}}
18310 !! endarticle
18311
18312 !! test
18313 Nested template calls
18314 !! wikitext
18315 {{Map-one-parameter|One-parameter|param}}
18316 !! html
18317 <p>(My parameter is: param)
18318 </p>
18319 !! end
18320
18321
18322 ###
18323 ### Sanitizer
18324 ###
18325
18326 # Remex wraps empty tag runs with p-tags.
18327 # Parsoid strips them out during p-wrapping.
18328 !! test
18329 Sanitizer: Closing of open tags
18330 !! wikitext
18331 <s></s><table></table>
18332 !! html/php+tidy
18333 <p><s></s></p><table></table>
18334 !! html/parsoid
18335 <s></s><table></table>
18336 !! end
18337
18338 !! test
18339 Sanitizer: Closing of open but not closed tags
18340 !! wikitext
18341 <s>foo
18342 !! html
18343 <p><s>foo</s>
18344 </p>
18345 !! end
18346
18347 !! test
18348 Sanitizer: Closing of closed but not open tags
18349 !! options
18350 parsoid=wt2html
18351 !! wikitext
18352 </s>
18353 !! html/php+tidy
18354 <p class="mw-empty-elt">
18355 </p>
18356 !! html/parsoid
18357 !! end
18358
18359 !! test
18360 Sanitizer: Closing of closed but not open table tags
18361 !! options
18362 parsoid=wt2html
18363 !! wikitext
18364 Table not started</td></tr></table>
18365 !! html+tidy
18366 <p>Table not started
18367 </p>
18368 !! end
18369
18370 !! test
18371 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
18372 !! config
18373 wgFragmentMode=[ 'html5', 'legacy' ]
18374 !! wikitext
18375 <span id="æ: v">byte</span>[[#æ: v|backlink]]
18376 !! html/php
18377 <p><span id="æ:_v">byte</span><a href="#æ:_v">backlink</a>
18378 </p>
18379 !! html/parsoid
18380 <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>
18381 !! end
18382
18383 !! test
18384 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id="" (legacy)
18385 !! config
18386 wgFragmentMode=[ 'legacy' ]
18387 !! wikitext
18388 <span id="æ: v">byte</span>[[#æ: v|backlink]]
18389 !! html/php
18390 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v">backlink</a>
18391 </p>
18392 !! end
18393
18394 # In HTML5, the restrictions are that id must contain at least one character,
18395 # and must not contain any space characters.
18396 !! test
18397 Sanitizer: Validating the contents of the id attribute (T6515)
18398 !! options
18399 disabled
18400 !! wikitext
18401 <br id="" /><br id="a space" />
18402 !! html
18403 Something ...
18404 !! end
18405
18406 # In HTML5, id must be unique amongst all the ids in the element's home subtree.
18407 !! test
18408 Sanitizer: Validating id attribute uniqueness (T6515, T8301)
18409 !! options
18410 disabled
18411 !! wikitext
18412 <br id="foo" /><br id="foo" />
18413 !! html
18414 Something need to be done. foo-2 ?
18415 !! end
18416
18417 !! test
18418 Sanitizer: Validating that <meta> and <link> work, but only for Microdata
18419 !! wikitext
18420 <div itemscope>
18421 <meta itemprop="hello" content="world">
18422 <meta http-equiv="refresh" content="5">
18423 <meta itemprop="hello" http-equiv="refresh" content="5">
18424 <link itemprop="hello" href="{{SERVER}}">
18425 <link rel="stylesheet" href="{{SERVER}}">
18426 <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
18427 </div>
18428 !! html
18429 <div itemscope="">
18430 <p> <meta itemprop="hello" content="world" />
18431 &lt;meta http-equiv="refresh" content="5"&gt;
18432 <meta itemprop="hello" content="5" />
18433 <link itemprop="hello" href="http&#58;//example.org" />
18434 &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"&gt;
18435 <link itemprop="hello" href="http&#58;//example.org" />
18436 </p>
18437 </div>
18438
18439 !! end
18440
18441 !! test
18442 Sanitizer: Strip comments from CSS attributes
18443 !! options
18444 parsoid=wt2html,wt2wt
18445 !! wikitext
18446 <span style="margin:/*negate mbox-text padding */-0.125em -0.45em; /*rainbow*/rgba(255, 0, 0, 0.3)">2013</span>
18447 !! html/php
18448 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span>
18449 </p>
18450 !! html/parsoid
18451 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span></p>
18452 !! end
18453
18454 !! test
18455 Sanitizer: Avoid unnecessary percent encoded characters in interwiki links
18456 !! wikitext
18457 [[meatball:Soft"Security]]
18458 !! html/php
18459 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Soft%22Security" class="extiw" title="meatball:Soft&quot;Security">meatball:Soft"Security</a>
18460 </p>
18461 !! html/parsoid
18462 <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>
18463 !! end
18464
18465 !! test
18466 Sanitizer: angle brackets are invalid, even in interwiki links (T182338)
18467 !! wikitext
18468 [[meatball:Foo<Bar]]
18469 [[meatball:Foo>Bar]]
18470 [[meatball:Foo&lt;bar]]
18471 [[meatball:Foo&gt;bar]]
18472 !! html/php
18473 <p>[[meatball:Foo&lt;Bar]]
18474 [[meatball:Foo&gt;Bar]]
18475 [[meatball:Foo&lt;bar]]
18476 [[meatball:Foo&gt;bar]]
18477 </p>
18478 !! html/parsoid
18479 <p>[[meatball:Foo&lt;Bar]]
18480 [[meatball:Foo>Bar]]
18481 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span>bar]]
18482 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;gt;","srcContent":">"}'>></span>bar]]</p>
18483 !! end
18484
18485 !! test
18486 Language converter: output gets cut off unexpectedly (T7757)
18487 !! options
18488 language=zh
18489 !! wikitext
18490 this bit is safe: }-
18491
18492 but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}-
18493
18494 then we get cut off here: }-
18495
18496 all additional text is vanished
18497 !! html/php
18498 <p>this bit is safe: }-
18499 </p><p>but if we add a conversion instance: xxx
18500 </p><p>then we get cut off here: }-
18501 </p><p>all additional text is vanished
18502 </p>
18503 !! html/parsoid
18504 <p>this bit is safe: }-</p>
18505 <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>
18506 <p>then we get cut off here: }-</p>
18507 <p>all additional text is vanished</p>
18508 !! end
18509
18510 !! test
18511 Language converter glossary rules inside attributes (T119158)
18512 !! options
18513 language=sr variant=sr-el
18514 !! wikitext
18515 -{H|foAjrjvi=>sr-el:" onload="alert(1)" data-foo="}-
18516
18517 [[File:Foobar.jpg|alt=-{}-foAjrjvi-{}-]]
18518 !! html/php
18519 <p>
18520 </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>
18521 </p>
18522 !! html/parsoid
18523 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"foAjrjvi","l":"sr-el","t":"\" onload=\"alert(1)\" data-foo=\""}]}'/></p>
18524
18525 <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>
18526 !! end
18527
18528 !! test
18529 Self closed html pairs (T7487)
18530 !! wikitext
18531 <center><font id="bug" />Centered text</center>
18532 <div><font id="bug2" />In div text</div>
18533 !! html+tidy
18534 <center><font id="bug"></font>Centered text</center>
18535 <div><font id="bug2"></font>In div text</div>
18536 !! end
18537
18538 !! test
18539 Punctuation: nbsp before exclamation
18540 !! wikitext
18541 C'est grave !
18542 !! html
18543 <p>C'est grave&#160;!
18544 </p>
18545 !! end
18546
18547 !! test
18548 Punctuation: CSS !important (T13874)
18549 !! wikitext
18550 <div style="width:50% !important">important</div>
18551 !! html
18552 <div style="width:50% !important">important</div>
18553
18554 !!end
18555
18556 !! test
18557 Punctuation: CSS ! important (T13874; with space after)
18558 !! wikitext
18559 <div style="width:50% ! important">important</div>
18560 !! html
18561 <div style="width:50% ! important">important</div>
18562
18563 !!end
18564
18565 !! test
18566 HTML bullet list, closed tags (T7497)
18567 !! wikitext
18568 <ul>
18569 <li>One</li>
18570 <li>Two</li>
18571 </ul>
18572 !! html/php
18573 <ul>
18574 <li>One</li>
18575 <li>Two</li>
18576 </ul>
18577
18578 !! html/parsoid
18579 <ul data-parsoid='{"stx":"html"}'>
18580 <li data-parsoid='{"stx":"html"}'>One</li>
18581 <li data-parsoid='{"stx":"html"}'>Two</li>
18582 </ul>
18583
18584 !! end
18585
18586 !! test
18587 HTML bullet list, unclosed tags (T7497)
18588 !! wikitext
18589 <ul>
18590 <li>One
18591 <li>Two
18592 </ul>
18593 !! html/php+tidy
18594 <ul>
18595 <li>One
18596 </li><li>Two
18597 </li></ul>
18598 !! html/parsoid
18599 <ul data-parsoid='{"stx":"html"}'>
18600 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18601 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18602 </ul>
18603
18604 !! end
18605
18606 !! test
18607 HTML ordered list, closed tags (T7497)
18608 !! wikitext
18609 <ol>
18610 <li>One</li>
18611 <li>Two</li>
18612 </ol>
18613 !! html/php
18614 <ol>
18615 <li>One</li>
18616 <li>Two</li>
18617 </ol>
18618
18619 !! html/parsoid
18620 <ol data-parsoid='{"stx":"html"}'>
18621 <li data-parsoid='{"stx":"html"}'>One</li>
18622 <li data-parsoid='{"stx":"html"}'>Two</li>
18623 </ol>
18624
18625 !! end
18626
18627 !! test
18628 HTML ordered list, unclosed tags (T7497)
18629 !! options
18630 !! wikitext
18631 <ol>
18632 <li>One
18633 <li>Two
18634 </ol>
18635 !! html/php+tidy
18636 <ol>
18637 <li>One
18638 </li><li>Two
18639 </li></ol>
18640 !! html/parsoid
18641 <ol data-parsoid='{"stx":"html"}'>
18642 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18643 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18644 </ol>
18645
18646 !! end
18647
18648 !! test
18649 HTML nested bullet list, closed tags (T7497)
18650 !! wikitext
18651 <ul>
18652 <li>One</li>
18653 <li>Two:
18654 <ul>
18655 <li>Sub-one</li>
18656 <li>Sub-two</li>
18657 </ul>
18658 </li>
18659 </ul>
18660 !! html/php
18661 <ul>
18662 <li>One</li>
18663 <li>Two:
18664 <ul>
18665 <li>Sub-one</li>
18666 <li>Sub-two</li>
18667 </ul>
18668 </li>
18669 </ul>
18670
18671 !! html/parsoid
18672 <ul data-parsoid='{"stx":"html"}'>
18673 <li data-parsoid='{"stx":"html"}'>One</li>
18674 <li data-parsoid='{"stx":"html"}'>Two:
18675 <ul data-parsoid='{"stx":"html"}'>
18676 <li data-parsoid='{"stx":"html"}'>Sub-one</li>
18677 <li data-parsoid='{"stx":"html"}'>Sub-two</li>
18678 </ul>
18679 </li>
18680 </ul>
18681 !! end
18682
18683 !! test
18684 HTML nested bullet list, open tags (T7497)
18685 !! wikitext
18686 <ul>
18687 <li>One
18688 <li>Two:
18689 <ul>
18690 <li>Sub-one
18691 <li>Sub-two
18692 </ul>
18693 </ul>
18694 !! html+tidy
18695 <ul>
18696 <li>One
18697 </li><li>Two:
18698 <ul>
18699 <li>Sub-one
18700 </li><li>Sub-two
18701 </li></ul>
18702 </li></ul>
18703 !! end
18704
18705 !! test
18706 HTML nested ordered list, closed tags (T7497)
18707 !! wikitext
18708 <ol>
18709 <li>One</li>
18710 <li>Two:
18711 <ol>
18712 <li>Sub-one</li>
18713 <li>Sub-two</li>
18714 </ol>
18715 </li>
18716 </ol>
18717 !! html
18718 <ol>
18719 <li>One</li>
18720 <li>Two:
18721 <ol>
18722 <li>Sub-one</li>
18723 <li>Sub-two</li>
18724 </ol>
18725 </li>
18726 </ol>
18727
18728 !! end
18729
18730 !! test
18731 HTML nested ordered list, open tags (T7497)
18732 !! wikitext
18733 <ol>
18734 <li>One
18735 <li>Two:
18736 <ol>
18737 <li>Sub-one
18738 <li>Sub-two
18739 </ol>
18740 </ol>
18741 !! html/php
18742 <ol>
18743 <li>One
18744 <li>Two:
18745 <ol>
18746 <li>Sub-one
18747 <li>Sub-two
18748 </ol>
18749 </ol>
18750
18751 !! html/parsoid
18752 <ol>
18753 <li>One
18754 </li>
18755 <li>Two:
18756 <ol>
18757 <li>Sub-one
18758 </li>
18759 <li>Sub-two
18760 </li>
18761 </ol>
18762 </li>
18763 </ol>
18764
18765 !! end
18766
18767 !! test
18768 HTML ordered list item with parameters oddity
18769 !! wikitext
18770 <ol><li id="fragment">One</li>
18771 </ol>
18772 !! html
18773 <ol><li id="fragment">One</li>
18774 </ol>
18775
18776 !! end
18777
18778 # parsoid doesn't explicitly mark autonumbered links, see T55505
18779 !!test
18780 T7918: autonumbering
18781 !! wikitext
18782 [http://first/] [http://second] [ftp://ftp]
18783
18784 ftp://inlineftp
18785
18786 [mailto:enclosed@mail.tld With target]
18787
18788 [mailto:enclosed@mail.tld]
18789
18790 mailto:inline@mail.tld
18791 !! html/php
18792 <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>
18793 </p><p><a rel="nofollow" class="external free" href="ftp://inlineftp">ftp://inlineftp</a>
18794 </p><p><a rel="nofollow" class="external text" href="mailto:enclosed@mail.tld">With target</a>
18795 </p><p><a rel="nofollow" class="external autonumber" href="mailto:enclosed@mail.tld">[4]</a>
18796 </p><p><a rel="nofollow" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a>
18797 </p>
18798 !! html/parsoid
18799 <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>
18800 <p><a rel="mw:ExtLink" class="external free" href="ftp://inlineftp">ftp://inlineftp</a></p>
18801 <p><a rel="mw:ExtLink" class="external text" href="mailto:enclosed@mail.tld">With target</a></p>
18802 <p><a rel="mw:ExtLink" class="external autonumber" href="mailto:enclosed@mail.tld"></a></p>
18803 <p><a rel="mw:ExtLink" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a></p>
18804 !! end
18805
18806
18807 #
18808 # Security and HTML correctness
18809 # From Nick Jenkins' fuzz testing
18810 #
18811
18812 !! test
18813 Fuzz testing: Parser13
18814 !! wikitext
18815 {|
18816 | http://a|
18817 !! html
18818 <table>
18819 <tr>
18820 <td>
18821 </td>
18822 </tr>
18823 </table>
18824
18825 !! end
18826
18827 # Note that Parsoid output differs from the PHP parser here: the PHP
18828 # parser breaks the URL for the magic word, while in Parsoid the URL
18829 # production takes precedence.
18830 !! test
18831 Fuzz testing: Parser14
18832 !! wikitext
18833 == onmouseover= ==
18834 http://__TOC__
18835 !! html/php
18836 <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>
18837 http://<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
18838 <ul>
18839 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
18840 </ul>
18841 </div>
18842
18843
18844 !! html/php+tidy
18845 <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>
18846 http://</p><div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
18847 <ul>
18848 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
18849 </ul>
18850 </div>
18851 !! html/parsoid
18852 <h2 id="onmouseover="><span id="onmouseover.3D" typeof="mw:FallbackId"></span> onmouseover= </h2>
18853 <p><a rel="mw:ExtLink" class="external free" href="http://__TOC__" data-parsoid='{"stx":"url"}'>http://__TOC__</a></p>
18854 !! end
18855
18856 !! test
18857 Fuzz testing: Parser14-table
18858 !! options
18859 parsoid=wt2html,html2html
18860 !! wikitext
18861 ==a==
18862 {| STYLE=__TOC__
18863 !! html
18864 <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>
18865 <table style="&#95;_TOC&#95;_">
18866 <tr><td></td></tr>
18867 </table>
18868
18869 !! html+tidy
18870 <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>
18871 <table style="__TOC__">
18872 <tr>
18873 <td></td>
18874 </tr>
18875 </table>
18876 !! html/parsoid
18877 <h2 id="a">a</h2>
18878 <table style="__TOC__"></table>
18879 !! end
18880
18881 # Known to produce bogus xml (extra </td>)
18882 # Don't add the html/php section since it generates broken HTML
18883 !! test
18884 Fuzz testing: Parser16
18885 !! wikitext
18886 {|
18887 !https://||||||
18888 !! html+tidy
18889 <table>
18890 <tbody><tr>
18891 <th>https://</th>
18892 <th></th>
18893 <th></th>
18894 <th>
18895
18896 </th></tr>
18897 </tbody></table>
18898 !! end
18899
18900 !! test
18901 Fuzz testing: Parser21
18902 !! wikitext
18903 {|
18904 ! irc://{{ftp://a" onmouseover="alert('hello world');"
18905 |
18906 !! html
18907 <table>
18908 <tr>
18909 <th> <a rel="nofollow" class="external free" href="irc://{{ftp://a">irc://{{ftp://a</a>" onmouseover="alert('hello world');"
18910 </th>
18911 <td>
18912 </td>
18913 </tr>
18914 </table>
18915
18916 !! end
18917
18918 !! test
18919 Fuzz testing: Parser22
18920 !! wikitext
18921 http://===r:::https://b
18922
18923 {|
18924 !! html
18925 <p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a>
18926 </p>
18927 <table>
18928 <tr><td></td></tr>
18929 </table>
18930
18931 !! end
18932
18933 # Known to produce bad XML for now
18934 !! test
18935 Fuzz testing: Parser24
18936 !! options
18937 parsoid=wt2html
18938 !! wikitext
18939 {|
18940 {{{|
18941 <u CLASS=
18942 | {{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}} >
18943 <br style="onmouseover='alert(document.cookie);' " />
18944
18945 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
18946 |
18947 !! html/php
18948 <table>
18949 {{{|
18950 <u class="&#124;">}}}} &gt;
18951 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
18952
18953 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
18954 <tr>
18955 <td></u>
18956 </td>
18957 </tr>
18958 </table>
18959
18960 !! html/parsoid
18961 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>{{{|
18962 <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>"}'/>}}}} >
18963 <br style="onmouseover='alert(document.cookie);' " data-parsoid='{"stx":"html","selfClose":true}'/></u></p><p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><u class="|" data-parsoid='{"stx":"html","a":{"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--":null},"sa":{"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--":""},"autoInsertedEnd":true,"autoInsertedStart":true}'>MOVE YOUR MOUSE CURSOR OVER THIS TEXT</u></p><table data-parsoid='{"autoInsertedEnd":true}'>
18964
18965
18966
18967 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'></td></tr></tbody></table>
18968 !! end
18969
18970 # Note: the current result listed for this is not what the original one was,
18971 # but the original bug was JavaScript injection, which is fixed in any case.
18972 # It's not clear that the original result listed was any more correct than the
18973 # current one. Original result:
18974 # <p>{{{|
18975 # </p>
18976 # <li class="&#124;&#124;">
18977 # }}}blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
18978 !!test
18979 Fuzz testing: Parser25 (T8055)
18980 !! wikitext
18981 {{{
18982 |
18983 <LI CLASS=||
18984 >
18985 }}}blah" onmouseover="alert('hello world');" align="left"'''MOVE MOUSE CURSOR OVER HERE
18986 !! html/php
18987 <p>&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
18988 </p>
18989 !! html/parsoid
18990 <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"]}'>
18991 </span><p about="#mwt1">&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b></p>
18992 !! end
18993
18994 !!test
18995 Fuzz testing: URL adjacent extension (with space, clean)
18996 !! wikitext
18997 http://example.com <nowiki>junk</nowiki>
18998 !! html/php
18999 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> junk
19000 </p>
19001 !! html/parsoid
19002 <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>
19003 !! end
19004
19005 !!test
19006 Fuzz testing: URL adjacent extension (no space, dirty; nowiki)
19007 !! wikitext
19008 http://example.com<nowiki>junk</nowiki>
19009 !! html/php
19010 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>junk
19011 </p>
19012 !! html/parsoid
19013 <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>
19014 !! end
19015
19016 !! test
19017 Fuzz testing: URL adjacent extension (no space, dirty; pre)
19018 !! wikitext
19019 http://example.com<pre>junk</pre>
19020 !! html/php
19021 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre>
19022
19023 !! html/php+tidy
19024 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p><pre>junk</pre>
19025 !! html/parsoid
19026 <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>
19027 !! end
19028
19029 !! test
19030 Fuzz testing: image with bogus manual thumbnail
19031 !! wikitext
19032 [[Image:foobar.jpg|thumbnail= ]]
19033 !! html/php
19034 <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div>
19035
19036 !! html/parsoid
19037 <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>
19038 !! end
19039
19040 # Parsoid will emit the newline literally in wt2wt; see next test case.
19041 !! test
19042 Fuzz testing: encoded newline in generated HTML replacements (T8577)
19043 !! options
19044 parsoid=wt2html
19045 !! wikitext
19046 <pre dir="&#10;"></pre>
19047 !! html/php
19048 <pre dir="&#10;"></pre>
19049
19050 !! html/parsoid
19051 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
19052 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
19053 !! end
19054
19055 !! test
19056 Fuzz testing: encoded newline in generated HTML replacements, html2wt (T8577)
19057 !! options
19058 parsoid=html2wt
19059 !! html/parsoid
19060 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
19061 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
19062 !! wikitext
19063 <pre dir="
19064 "></pre>
19065 !! html/php
19066 <pre dir=""></pre>
19067
19068 !! end
19069
19070 !! test
19071 Templates in extension attributes are not expanded
19072 !! wikitext
19073 <pre dir="{{echo|ltr}}"></pre>
19074 !! html/php
19075 <pre dir="{{echo|ltr}}"></pre>
19076
19077 !! html/parsoid
19078 <pre typeof="mw:Extension/pre" about="#mwt2" dir="{{echo|ltr}}" data-mw='{"name":"pre","attrs":{"dir":"{{echo|ltr}}"},"body":{"extsrc":""}}'></pre>
19079 !! end
19080
19081 !! test
19082 Parsing optional HTML elements (T8171)
19083 !! options
19084 !! wikitext
19085 <table>
19086 <tr>
19087 <td> Some tabular data</td>
19088 <td> More tabular data ...
19089 <td> And yet som tabular data</td>
19090 </tr>
19091 </table>
19092 !! html
19093 <table>
19094 <tr>
19095 <td> Some tabular data</td>
19096 <td> More tabular data ...
19097 </td><td> And yet som tabular data</td>
19098 </tr>
19099 </table>
19100
19101 !! end
19102
19103 !! test
19104 Correct handling of <td>, <tr> (T8171)
19105 !! options
19106 !! wikitext
19107 <table>
19108 <tr>
19109 <td> Some tabular data</td>
19110 <td> More tabular data ...</td>
19111 <td> And yet som tabular data</td>
19112 </tr>
19113 </table>
19114 !! html
19115 <table>
19116 <tr>
19117 <td> Some tabular data</td>
19118 <td> More tabular data ...</td>
19119 <td> And yet som tabular data</td>
19120 </tr>
19121 </table>
19122
19123 !! end
19124
19125
19126 !! test
19127 Parsing crashing regression (fr:JavaScript)
19128 !! wikitext
19129 </body></x>
19130 !! html
19131 <p>&lt;/body&gt;&lt;/x&gt;
19132 </p>
19133 !! end
19134
19135 !! test
19136 Inline wiki vs wiki block nesting
19137 !! wikitext
19138 '''Bold paragraph
19139
19140 New wiki paragraph
19141 !! html
19142 <p><b>Bold paragraph</b>
19143 </p><p>New wiki paragraph
19144 </p>
19145 !! end
19146
19147 # FIXME: The current php output is documented
19148 # and desired output is the parsoid target.
19149 !! test
19150 Inline HTML vs wiki block nesting
19151 !! wikitext
19152 <b>Bold paragraph
19153
19154 New wiki paragraph
19155 !! html/php
19156 <p><b>Bold paragraph
19157 </p><p>New wiki paragraph</b>
19158 </p>
19159 !! html/parsoid
19160 <p><b>Bold paragraph</b>
19161 </p><p>New wiki paragraph
19162 </p>
19163 !! end
19164
19165 # Original result was this:
19166 # <p><b>bold</b><b>bold<i>bolditalics</i></b>
19167 # </p>
19168 # While that might be marginally more intuitive, maybe, the six-apostrophe
19169 # construct is clearly pathological and the result stated here (which is what
19170 # the parser actually does) is about as reasonable as anything.
19171 !!test
19172 Mixing markup for italics and bold
19173 !! options
19174 !! wikitext
19175 '''bold''''''bold''bolditalics'''''
19176 !! html
19177 <p>'<i>bold'</i><b>bold<i>bolditalics</i></b>
19178 </p>
19179 !! end
19180
19181
19182 !! article
19183 Xyzzyx
19184 !! text
19185 Article for special page transclusion test
19186 !! endarticle
19187
19188 !! test
19189 Special page transclusion
19190 !! options
19191 !! wikitext
19192 {{Special:Prefixindex/Xyzzyx}}
19193 !! html
19194 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19195 </ul>
19196
19197 !! end
19198
19199 !! test
19200 Special page transclusion twice (T7021)
19201 !! options
19202 !! wikitext
19203 {{Special:Prefixindex/Xyzzyx}}
19204 {{Special:Prefixindex/Xyzzyx}}
19205 !! html
19206 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19207 </ul>
19208 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19209 </ul>
19210
19211 !! end
19212
19213 !! test
19214 Transclusion of default MediaWiki message
19215 !! wikitext
19216 {{MediaWiki:Mainpage}}
19217 !! html
19218 <p>Main Page
19219 </p>
19220 !! end
19221
19222 !! test
19223 Transclusion of nonexistent MediaWiki message
19224 !! wikitext
19225 {{MediaWiki:Mainpagexxx}}
19226 !! html
19227 <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>
19228 </p>
19229 !! end
19230
19231 !! test
19232 Transclusion of MediaWiki message with underscore
19233 !! wikitext
19234 {{MediaWiki:history_short}}
19235 !! html
19236 <p>History
19237 </p>
19238 !! end
19239
19240 !! test
19241 Transclusion of MediaWiki message with space
19242 !! wikitext
19243 {{MediaWiki:history short}}
19244 !! html
19245 <p>History
19246 </p>
19247 !! end
19248
19249 !! test
19250 Invalid header with following text
19251 !! wikitext
19252 = x = y
19253 !! html
19254 <p>= x = y
19255 </p>
19256 !! end
19257
19258
19259 !! test
19260 Section extraction test (section 0)
19261 !! options
19262 section=0
19263 !! wikitext
19264 start
19265 ==a==
19266 ===aa===
19267 ====aaa====
19268 ==b==
19269 ===ba===
19270 ===bb===
19271 ====bba====
19272 ===bc===
19273 ==c==
19274 ===ca===
19275 !! html/php
19276 start
19277 !! end
19278
19279 !! test
19280 Section extraction test (section 1)
19281 !! options
19282 section=1
19283 !! wikitext
19284 start
19285 ==a==
19286 ===aa===
19287 ====aaa====
19288 ==b==
19289 ===ba===
19290 ===bb===
19291 ====bba====
19292 ===bc===
19293 ==c==
19294 ===ca===
19295 !! html/php
19296 ==a==
19297 ===aa===
19298 ====aaa====
19299 !! end
19300
19301 !! test
19302 Section extraction test (section 2)
19303 !! options
19304 section=2
19305 !! wikitext
19306 start
19307 ==a==
19308 ===aa===
19309 ====aaa====
19310 ==b==
19311 ===ba===
19312 ===bb===
19313 ====bba====
19314 ===bc===
19315 ==c==
19316 ===ca===
19317 !! html/php
19318 ===aa===
19319 ====aaa====
19320 !! end
19321
19322 !! test
19323 Section extraction test (section 3)
19324 !! options
19325 section=3
19326 !! wikitext
19327 start
19328 ==a==
19329 ===aa===
19330 ====aaa====
19331 ==b==
19332 ===ba===
19333 ===bb===
19334 ====bba====
19335 ===bc===
19336 ==c==
19337 ===ca===
19338 !! html/php
19339 ====aaa====
19340 !! end
19341
19342 !! test
19343 Section extraction test (section 4)
19344 !! options
19345 section=4
19346 !! wikitext
19347 start
19348 ==a==
19349 ===aa===
19350 ====aaa====
19351 ==b==
19352 ===ba===
19353 ===bb===
19354 ====bba====
19355 ===bc===
19356 ==c==
19357 ===ca===
19358 !! html/php
19359 ==b==
19360 ===ba===
19361 ===bb===
19362 ====bba====
19363 ===bc===
19364 !! end
19365
19366 !! test
19367 Section extraction test (section 5)
19368 !! options
19369 section=5
19370 !! wikitext
19371 start
19372 ==a==
19373 ===aa===
19374 ====aaa====
19375 ==b==
19376 ===ba===
19377 ===bb===
19378 ====bba====
19379 ===bc===
19380 ==c==
19381 ===ca===
19382 !! html/php
19383 ===ba===
19384 !! end
19385
19386 !! test
19387 Section extraction test (section 6)
19388 !! options
19389 section=6
19390 !! wikitext
19391 start
19392 ==a==
19393 ===aa===
19394 ====aaa====
19395 ==b==
19396 ===ba===
19397 ===bb===
19398 ====bba====
19399 ===bc===
19400 ==c==
19401 ===ca===
19402 !! html/php
19403 ===bb===
19404 ====bba====
19405 !! end
19406
19407 !! test
19408 Section extraction test (section 7)
19409 !! options
19410 section=7
19411 !! wikitext
19412 start
19413 ==a==
19414 ===aa===
19415 ====aaa====
19416 ==b==
19417 ===ba===
19418 ===bb===
19419 ====bba====
19420 ===bc===
19421 ==c==
19422 ===ca===
19423 !! html/php
19424 ====bba====
19425 !! end
19426
19427 !! test
19428 Section extraction test (section 8)
19429 !! options
19430 section=8
19431 !! wikitext
19432 start
19433 ==a==
19434 ===aa===
19435 ====aaa====
19436 ==b==
19437 ===ba===
19438 ===bb===
19439 ====bba====
19440 ===bc===
19441 ==c==
19442 ===ca===
19443 !! html/php
19444 ===bc===
19445 !! end
19446
19447 !! test
19448 Section extraction test (section 9)
19449 !! options
19450 section=9
19451 !! wikitext
19452 start
19453 ==a==
19454 ===aa===
19455 ====aaa====
19456 ==b==
19457 ===ba===
19458 ===bb===
19459 ====bba====
19460 ===bc===
19461 ==c==
19462 ===ca===
19463 !! html/php
19464 ==c==
19465 ===ca===
19466 !! end
19467
19468 !! test
19469 Section extraction test (section 10)
19470 !! options
19471 section=10
19472 !! wikitext
19473 start
19474 ==a==
19475 ===aa===
19476 ====aaa====
19477 ==b==
19478 ===ba===
19479 ===bb===
19480 ====bba====
19481 ===bc===
19482 ==c==
19483 ===ca===
19484 !! html/php
19485 ===ca===
19486 !! end
19487
19488 !! test
19489 Section extraction test (nonexistent section 11)
19490 !! options
19491 section=11
19492 !! wikitext
19493 start
19494 ==a==
19495 ===aa===
19496 ====aaa====
19497 ==b==
19498 ===ba===
19499 ===bb===
19500 ====bba====
19501 ===bc===
19502 ==c==
19503 ===ca===
19504 !! html/php
19505 !! end
19506
19507 !! test
19508 Section extraction test with bogus heading (section 1)
19509 !! options
19510 section=1
19511 !! wikitext
19512 ==a==
19513 ==bogus== not a legal section
19514 ==b==
19515 !! html/php
19516 ==a==
19517 ==bogus== not a legal section
19518 !! end
19519
19520 !! test
19521 Section extraction test with bogus heading (section 2)
19522 !! options
19523 section=2
19524 !! wikitext
19525 ==a==
19526 ==bogus== not a legal section
19527 ==b==
19528 !! html/php
19529 ==b==
19530 !! end
19531
19532 !! test
19533 Section extraction test with comment after heading (section 1)
19534 !! options
19535 section=1
19536 !! wikitext
19537 ==a==
19538 ==b== <!-- -->
19539 ==c==
19540 !! html/php
19541 ==a==
19542 !! end
19543
19544 !! test
19545 Section extraction test with comment after heading (section 2)
19546 !! options
19547 section=2
19548 !! wikitext
19549 ==a==
19550 ==b== <!-- -->
19551 ==c==
19552 !! html/php
19553 ==b== <!-- -->
19554 !! end
19555
19556 !! test
19557 Section extraction test with bogus <nowiki> heading (section 1)
19558 !! options
19559 section=1
19560 !! wikitext
19561 ==a==
19562 ==bogus== <nowiki>not a legal section</nowiki>
19563 ==b==
19564 !! html/php
19565 ==a==
19566 ==bogus== <nowiki>not a legal section</nowiki>
19567 !! end
19568
19569 !! test
19570 Section extraction test with bogus <nowiki> heading (section 2)
19571 !! options
19572 section=2
19573 !! wikitext
19574 ==a==
19575 ==bogus== <nowiki>not a legal section</nowiki>
19576 ==b==
19577 !! html/php
19578 ==b==
19579 !! end
19580
19581 # Formerly testing for T4587, now resolved by the use of unmarked sections
19582 # instead of respecting commented sections
19583 !! test
19584 Section extraction prefixed by comment (section 1)
19585 !! options
19586 section=1
19587 !! wikitext
19588 <!-- -->==sec1==
19589 ==sec2==
19590 !! html/php
19591 ==sec2==
19592 !!end
19593
19594 !! test
19595 Section extraction prefixed by comment (section 2)
19596 !! options
19597 section=2
19598 !! wikitext
19599 <!-- -->==sec1==
19600 ==sec2==
19601 !! html/php
19602
19603 !!end
19604
19605 # Formerly testing for T4607, now resolved by the use of unmarked sections
19606 # instead of respecting HTML-style headings
19607 !! test
19608 Section extraction, mixed wiki and html (section 1)
19609 !! options
19610 section=1
19611 !! wikitext
19612 <h2>unmarked</h2>
19613 unmarked
19614 ==1==
19615 one
19616 ==2==
19617 two
19618 !! html/php
19619 ==1==
19620 one
19621 !! end
19622
19623 !! test
19624 Section extraction, mixed wiki and html (section 2)
19625 !! options
19626 section=2
19627 !! wikitext
19628 <h2>unmarked</h2>
19629 unmarked
19630 ==1==
19631 one
19632 ==2==
19633 two
19634 !! html/php
19635 ==2==
19636 two
19637 !! end
19638
19639
19640 # Formerly testing for T5342
19641 !! test
19642 Section extraction, heading surrounded by <noinclude>
19643 !! options
19644 section=1
19645 !! wikitext
19646 <noinclude>==unmarked==</noinclude>
19647 ==marked==
19648 !! html/php
19649 ==marked==
19650 !!end
19651
19652 # Test behavior of T21910
19653 !! test
19654 Sectiion with all-equals
19655 !! options
19656 section=2
19657 !! wikitext
19658 ===
19659 The line above must have a trailing space
19660 === <!--
19661 --> <!-- -->
19662 But just in case it doesn't...
19663 !! html/php
19664 === <!--
19665 --> <!-- -->
19666 But just in case it doesn't...
19667 !! end
19668
19669 !! test
19670 Section replacement test (section 0)
19671 !! options
19672 replace=0,"xxx"
19673 !! wikitext
19674 start
19675 ==a==
19676 ===aa===
19677 ====aaa====
19678 ==b==
19679 ===ba===
19680 ===bb===
19681 ====bba====
19682 ===bc===
19683 ==c==
19684 ===ca===
19685 !! html/php
19686 xxx
19687
19688 ==a==
19689 ===aa===
19690 ====aaa====
19691 ==b==
19692 ===ba===
19693 ===bb===
19694 ====bba====
19695 ===bc===
19696 ==c==
19697 ===ca===
19698 !! end
19699
19700 !! test
19701 Section replacement test (section 1)
19702 !! options
19703 replace=1,"xxx"
19704 !! wikitext
19705 start
19706 ==a==
19707 ===aa===
19708 ====aaa====
19709 ==b==
19710 ===ba===
19711 ===bb===
19712 ====bba====
19713 ===bc===
19714 ==c==
19715 ===ca===
19716 !! html/php
19717 start
19718 xxx
19719
19720 ==b==
19721 ===ba===
19722 ===bb===
19723 ====bba====
19724 ===bc===
19725 ==c==
19726 ===ca===
19727 !! end
19728
19729 !! test
19730 Section replacement test (section 2)
19731 !! options
19732 replace=2,"xxx"
19733 !! wikitext
19734 start
19735 ==a==
19736 ===aa===
19737 ====aaa====
19738 ==b==
19739 ===ba===
19740 ===bb===
19741 ====bba====
19742 ===bc===
19743 ==c==
19744 ===ca===
19745 !! html/php
19746 start
19747 ==a==
19748 xxx
19749
19750 ==b==
19751 ===ba===
19752 ===bb===
19753 ====bba====
19754 ===bc===
19755 ==c==
19756 ===ca===
19757 !! end
19758
19759 !! test
19760 Section replacement test (section 3)
19761 !! options
19762 replace=3,"xxx"
19763 !! wikitext
19764 start
19765 ==a==
19766 ===aa===
19767 ====aaa====
19768 ==b==
19769 ===ba===
19770 ===bb===
19771 ====bba====
19772 ===bc===
19773 ==c==
19774 ===ca===
19775 !! html/php
19776 start
19777 ==a==
19778 ===aa===
19779 xxx
19780
19781 ==b==
19782 ===ba===
19783 ===bb===
19784 ====bba====
19785 ===bc===
19786 ==c==
19787 ===ca===
19788 !! end
19789
19790 !! test
19791 Section replacement test (section 4)
19792 !! options
19793 replace=4,"xxx"
19794 !! wikitext
19795 start
19796 ==a==
19797 ===aa===
19798 ====aaa====
19799 ==b==
19800 ===ba===
19801 ===bb===
19802 ====bba====
19803 ===bc===
19804 ==c==
19805 ===ca===
19806 !! html/php
19807 start
19808 ==a==
19809 ===aa===
19810 ====aaa====
19811 xxx
19812
19813 ==c==
19814 ===ca===
19815 !! end
19816
19817 !! test
19818 Section replacement test (section 5)
19819 !! options
19820 replace=5,"xxx"
19821 !! wikitext
19822 start
19823 ==a==
19824 ===aa===
19825 ====aaa====
19826 ==b==
19827 ===ba===
19828 ===bb===
19829 ====bba====
19830 ===bc===
19831 ==c==
19832 ===ca===
19833 !! html/php
19834 start
19835 ==a==
19836 ===aa===
19837 ====aaa====
19838 ==b==
19839 xxx
19840
19841 ===bb===
19842 ====bba====
19843 ===bc===
19844 ==c==
19845 ===ca===
19846 !! end
19847
19848 !! test
19849 Section replacement test (section 6)
19850 !! options
19851 replace=6,"xxx"
19852 !! wikitext
19853 start
19854 ==a==
19855 ===aa===
19856 ====aaa====
19857 ==b==
19858 ===ba===
19859 ===bb===
19860 ====bba====
19861 ===bc===
19862 ==c==
19863 ===ca===
19864 !! html/php
19865 start
19866 ==a==
19867 ===aa===
19868 ====aaa====
19869 ==b==
19870 ===ba===
19871 xxx
19872
19873 ===bc===
19874 ==c==
19875 ===ca===
19876 !! end
19877
19878 !! test
19879 Section replacement test (section 7)
19880 !! options
19881 replace=7,"xxx"
19882 !! wikitext
19883 start
19884 ==a==
19885 ===aa===
19886 ====aaa====
19887 ==b==
19888 ===ba===
19889 ===bb===
19890 ====bba====
19891 ===bc===
19892 ==c==
19893 ===ca===
19894 !! html/php
19895 start
19896 ==a==
19897 ===aa===
19898 ====aaa====
19899 ==b==
19900 ===ba===
19901 ===bb===
19902 xxx
19903
19904 ===bc===
19905 ==c==
19906 ===ca===
19907 !! end
19908
19909 !! test
19910 Section replacement test (section 8)
19911 !! options
19912 replace=8,"xxx"
19913 !! wikitext
19914 start
19915 ==a==
19916 ===aa===
19917 ====aaa====
19918 ==b==
19919 ===ba===
19920 ===bb===
19921 ====bba====
19922 ===bc===
19923 ==c==
19924 ===ca===
19925 !! html/php
19926 start
19927 ==a==
19928 ===aa===
19929 ====aaa====
19930 ==b==
19931 ===ba===
19932 ===bb===
19933 ====bba====
19934 xxx
19935
19936 ==c==
19937 ===ca===
19938 !!end
19939
19940 !! test
19941 Section replacement test (section 9)
19942 !! options
19943 replace=9,"xxx"
19944 !! wikitext
19945 start
19946 ==a==
19947 ===aa===
19948 ====aaa====
19949 ==b==
19950 ===ba===
19951 ===bb===
19952 ====bba====
19953 ===bc===
19954 ==c==
19955 ===ca===
19956 !! html/php
19957 start
19958 ==a==
19959 ===aa===
19960 ====aaa====
19961 ==b==
19962 ===ba===
19963 ===bb===
19964 ====bba====
19965 ===bc===
19966 xxx
19967 !! end
19968
19969 !! test
19970 Section replacement test (section 10)
19971 !! options
19972 replace=10,"xxx"
19973 !! wikitext
19974 start
19975 ==a==
19976 ===aa===
19977 ====aaa====
19978 ==b==
19979 ===ba===
19980 ===bb===
19981 ====bba====
19982 ===bc===
19983 ==c==
19984 ===ca===
19985 !! html/php
19986 start
19987 ==a==
19988 ===aa===
19989 ====aaa====
19990 ==b==
19991 ===ba===
19992 ===bb===
19993 ====bba====
19994 ===bc===
19995 ==c==
19996 xxx
19997 !! end
19998
19999 !! test
20000 Section replacement test with initial whitespace (T15728)
20001 !! options
20002 replace=2,"xxx"
20003 !! wikitext
20004 Preformatted initial line
20005 ==a==
20006 ===a===
20007 !! html/php
20008 Preformatted initial line
20009 ==a==
20010 xxx
20011 !! end
20012
20013
20014 !! test
20015 Section extraction, heading followed by pre with 20 spaces (T8398)
20016 !! options
20017 section=1
20018 !! wikitext
20019 ==a==
20020 a
20021 !! html/php
20022 ==a==
20023 a
20024 !! end
20025
20026 !! test
20027 Section extraction, heading followed by pre with 19 spaces (T8398 sanity check)
20028 !! options
20029 section=1
20030 !! wikitext
20031 ==a==
20032 a
20033 !! html/php
20034 ==a==
20035 a
20036 !! end
20037
20038
20039 !! test
20040 Section extraction, <pre> around bogus header (T12309)
20041 !! options
20042 section=2
20043 !! wikitext
20044 == Section One ==
20045 <pre>
20046 =======
20047 </pre>
20048
20049 == Section Two ==
20050 stuff
20051 !! html/php
20052 == Section Two ==
20053 stuff
20054 !! end
20055
20056 !! test
20057 Section replacement, <pre> around bogus header (T12309)
20058 !! options
20059 replace=2,"xxx"
20060 !! wikitext
20061 == Section One ==
20062 <pre>
20063 =======
20064 </pre>
20065
20066 == Section Two ==
20067 stuff
20068 !! html/php
20069 == Section One ==
20070 <pre>
20071 =======
20072 </pre>
20073
20074 xxx
20075 !! end
20076
20077 !! test
20078 Handling of &#x0A; in URLs
20079 !! wikitext
20080 ** irc://&#x0A;a
20081 !! html/php
20082 <ul><li><ul><li> <a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
20083
20084 !! html/parsoid
20085 <ul><li><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></li></ul>
20086 !! end
20087
20088 !! test
20089 Handling of %0A in URLs
20090 !! wikitext
20091 ** irc://%0Aa
20092 !! html/php
20093 <ul><li><ul><li> <a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
20094
20095 !! html/parsoid
20096 <ul><li><ul><li> <a rel="mw:ExtLink" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
20097 !! end
20098
20099 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
20100 !! test
20101 5 quotes, code coverage +1 line
20102 !! options
20103 parsoid=wt2html
20104 !! wikitext
20105 '''''
20106 !! html/php
20107 !! html/parsoid
20108 <b><i></i></b>
20109 !! end
20110
20111 # same html as previous, but wikitext adjusted to match parsoid html2wt
20112 # note that wt2html and html2html will put the <i> before the <b>
20113 !! test
20114 5 quotes, code coverage +1 line w/ nowiki (1)
20115 !! options
20116 parsoid=wt2wt,html2wt
20117 !! wikitext
20118 '''''<nowiki/>'''''
20119 !! html/php
20120 <p><i></i>
20121 </p>
20122 !! html/parsoid
20123 <p><b><i></i></b></p>
20124 !! end
20125
20126 # same as previous, just swapping the <i> and <b>
20127 !! test
20128 5 quotes, code coverage +1 line w/ nowiki (2)
20129 !! wikitext
20130 '''''<nowiki/>'''''
20131 !! html/php
20132 <p><i></i>
20133 </p>
20134 !! html/parsoid
20135 <p><i><b></b></i></p>
20136 !! end
20137
20138 !! test
20139 Special:Search page linking.
20140 !! wikitext
20141 {{Special:search}}
20142 !! html
20143 <p><a href="/wiki/Special:Search" title="Special:Search">Special:Search</a>
20144 </p>
20145 !! end
20146
20147 !! test
20148 {{!}} is a magic word
20149 !! wikitext
20150 {{!}} is a magic word there and {{!}} is still a magic word here
20151 | is not a magic word here but {{!}} is still a magic word here
20152 !! html/php
20153 <p>| is a magic word there and | is still a magic word here
20154 | is not a magic word here but | is still a magic word here
20155 </p>
20156 !! html/parsoid
20157 <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
20158 | 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>
20159 !! end
20160
20161 !! test
20162 Say the magic word
20163 !! options
20164 title=[[Parser test]]
20165 !! wikitext
20166 * {{PAGENAME}}
20167 * {{PAGENAMEE}}
20168 * {{FULLPAGENAME}}
20169 * {{FULLPAGENAMEE}}
20170 * {{BASEPAGENAME}}
20171 * {{BASEPAGENAMEE}}
20172 * {{SUBPAGENAME}}
20173 * {{SUBPAGENAMEE}}
20174 * {{ROOTPAGENAME}}
20175 * {{ROOTPAGENAMEE}}
20176 * {{TALKPAGENAME}}
20177 * {{TALKPAGENAMEE}}
20178 * {{SUBJECTPAGENAME}}
20179 * {{SUBJECTPAGENAMEE}}
20180 * {{NAMESPACEE}}
20181 * {{NAMESPACE}}
20182 * {{NAMESPACENUMBER}}
20183 * {{TALKSPACE}}
20184 * {{TALKSPACEE}}
20185 * {{SUBJECTSPACE}}
20186 * {{SUBJECTSPACEE}}
20187 * {{Dynamic|{{NUMBEROFUSERS}}|{{NUMBEROFPAGES}}|{{CURRENTVERSION}}|{{CONTENTLANGUAGE}}|{{DIRECTIONMARK}}|{{CURRENTTIMESTAMP}}|{{NUMBEROFARTICLES}}}}
20188 !! html
20189 <ul><li> Parser test</li>
20190 <li> Parser_test</li>
20191 <li> Parser test</li>
20192 <li> Parser_test</li>
20193 <li> Parser test</li>
20194 <li> Parser_test</li>
20195 <li> Parser test</li>
20196 <li> Parser_test</li>
20197 <li> Parser test</li>
20198 <li> Parser_test</li>
20199 <li> Talk:Parser test</li>
20200 <li> Talk:Parser_test</li>
20201 <li> Parser test</li>
20202 <li> Parser_test</li>
20203 <li> </li>
20204 <li> </li>
20205 <li> 0</li>
20206 <li> Talk</li>
20207 <li> Talk</li>
20208 <li> </li>
20209 <li> </li>
20210 <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>
20211
20212 !! end
20213 ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included.
20214
20215 !! test
20216 Gallery with valid attributes
20217 !! wikitext
20218 <gallery type="123" summary="345">
20219 File:File:Foobar.jpg
20220 </gallery>
20221 !! html/php
20222 <ul class="gallery mw-gallery-traditional" type="123">
20223 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20224 <div class="thumb" style="height: 150px;">File:Foobar.jpg</div>
20225 <div class="gallerytext">
20226 </div>
20227 </div></li>
20228 </ul>
20229
20230 !! html/parsoid
20231 <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"}}'>
20232 <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>
20233 </ul>
20234 !! end
20235
20236 ## Parsoid thinks the "centre" here is a property, not a caption.
20237 !! test
20238 Gallery
20239 !! options
20240 parsoid={
20241 "modes": ["wt2html"],
20242 "nativeGallery": true
20243 }
20244 !! wikitext
20245 <gallery>
20246 image1.png |
20247 image2.gif|||||
20248
20249 image3|
20250 image4 |300px| centre
20251 image5.svg| http://///////
20252 [[x|xx]]]]
20253 * image6
20254 </gallery>
20255 !! html/php
20256 <ul class="gallery mw-gallery-traditional">
20257 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20258 <div class="thumb" style="height: 150px;">Image1.png</div>
20259 <div class="gallerytext">
20260 </div>
20261 </div></li>
20262 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20263 <div class="thumb" style="height: 150px;">Image2.gif</div>
20264 <div class="gallerytext">
20265 </div>
20266 </div></li>
20267 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20268 <div class="thumb" style="height: 150px;">Image3</div>
20269 <div class="gallerytext">
20270 </div>
20271 </div></li>
20272 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20273 <div class="thumb" style="height: 150px;">Image4</div>
20274 <div class="gallerytext">
20275 <pre>centre
20276 </pre>
20277 </div>
20278 </div></li>
20279 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20280 <div class="thumb" style="height: 150px;">Image5.svg</div>
20281 <div class="gallerytext">
20282 <p><a rel="nofollow" class="external free" href="http://///////">http://///////</a>
20283 </p>
20284 </div>
20285 </div></li>
20286 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20287 <div class="thumb" style="height: 150px;">* image6</div>
20288 <div class="gallerytext">
20289 </div>
20290 </div></li>
20291 </ul>
20292
20293 !! html/parsoid
20294 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20295 <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>
20296 <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>
20297 <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>
20298 <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>
20299 <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>
20300 <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>
20301 </ul>
20302 !! end
20303
20304 !! test
20305 Gallery (with options, html)
20306 !! options
20307 parsoid={
20308 "modes": ["wt2html", "html2html"],
20309 "nativeGallery": true
20310 }
20311 !! wikitext
20312 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
20313 File:Nonexistent.jpg|caption
20314 File:Nonexistent.jpg
20315 image:foobar.jpg|some '''caption''' [[Main Page]]
20316 image:foobar.jpg
20317 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
20318 </gallery>
20319 !! html/php
20320 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
20321 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
20322 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20323 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20324 <div class="gallerytext">
20325 <p>caption
20326 </p>
20327 </div>
20328 </div></li>
20329 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20330 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20331 <div class="gallerytext">
20332 </div>
20333 </div></li>
20334 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20335 <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>
20336 <div class="gallerytext">
20337 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20338 </p>
20339 </div>
20340 </div></li>
20341 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20342 <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>
20343 <div class="gallerytext">
20344 </div>
20345 </div></li>
20346 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20347 <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>
20348 <div class="gallerytext">
20349 <p>blabla.
20350 </p>
20351 </div>
20352 </div></li>
20353 </ul>
20354
20355 !! html/parsoid
20356 <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":{}}'>
20357 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
20358 <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>
20359 <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>
20360 <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>
20361 <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>
20362 <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>
20363 </ul>
20364 !! end
20365
20366 !! test
20367 Gallery (with options, extsrc)
20368 !! options
20369 parsoid={
20370 "nativeGallery": false
20371 }
20372 !! wikitext
20373 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
20374 File:Nonexistent.jpg|caption
20375 File:Nonexistent.jpg
20376 image:foobar.jpg|some '''caption''' [[Main Page]]
20377 image:foobar.jpg
20378 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
20379 </gallery>
20380 !! html/php
20381 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
20382 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
20383 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20384 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20385 <div class="gallerytext">
20386 <p>caption
20387 </p>
20388 </div>
20389 </div></li>
20390 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20391 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20392 <div class="gallerytext">
20393 </div>
20394 </div></li>
20395 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20396 <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>
20397 <div class="gallerytext">
20398 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20399 </p>
20400 </div>
20401 </div></li>
20402 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20403 <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>
20404 <div class="gallerytext">
20405 </div>
20406 </div></li>
20407 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20408 <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>
20409 <div class="gallerytext">
20410 <p>blabla.
20411 </p>
20412 </div>
20413 </div></li>
20414 </ul>
20415
20416 !! html/parsoid
20417 <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"}}'>
20418 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
20419 <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>
20420 <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>
20421 <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>
20422 <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>
20423 <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>
20424 </ul>
20425 !! end
20426
20427 !! test
20428 Gallery (without px units)
20429 !! wikitext
20430 <gallery widths="70" heights="40">
20431 File:Foobar.jpg
20432 </gallery>
20433 !! html/php
20434 <ul class="gallery mw-gallery-traditional">
20435 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20436 <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>
20437 <div class="gallerytext">
20438 </div>
20439 </div></li>
20440 </ul>
20441
20442 !! html/parsoid
20443 <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"}}'>
20444 <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>
20445 </ul>
20446 !! end
20447
20448 !! test
20449 Gallery (with invalid units)
20450 !! wikitext
20451 <gallery widths="70em" heights="40em">
20452 File:Foobar.jpg
20453 </gallery>
20454 !! html/php
20455 <ul class="gallery mw-gallery-traditional">
20456 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20457 <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>
20458 <div class="gallerytext">
20459 </div>
20460 </div></li>
20461 </ul>
20462
20463 !! html/parsoid
20464 <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"}}'>
20465 <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>
20466 </ul>
20467 !! end
20468
20469 !! test
20470 Gallery with link that has fragment
20471 !! options
20472 parsoid={
20473 "modes": ["wt2html", "html2html"],
20474 "nativeGallery": true
20475 }
20476 !! wikitext
20477 <gallery>
20478 image:foobar.jpg|link=Main_Page
20479 image:foobar.jpg|link=Main_Page#section
20480 image:foobar.jpg|link=Main Page#section|caption
20481 </gallery>
20482 !! html/php
20483 <ul class="gallery mw-gallery-traditional">
20484 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20485 <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>
20486 <div class="gallerytext">
20487 </div>
20488 </div></li>
20489 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20490 <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>
20491 <div class="gallerytext">
20492 </div>
20493 </div></li>
20494 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20495 <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>
20496 <div class="gallerytext">
20497 <p>caption
20498 </p>
20499 </div>
20500 </div></li>
20501 </ul>
20502
20503 !! html/parsoid
20504 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20505 <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>
20506 <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>
20507 <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>
20508 </ul>
20509 !! end
20510
20511 ## Whoops, Parsoid shouldn't be parsing templates in the attribute caption!
20512 !! test
20513 Gallery with template inside caption
20514 !! options
20515 parsoid={
20516 "nativeGallery": true
20517 }
20518 !! wikitext
20519 <gallery caption="{{echo|hi}}">
20520 File:Foobar.jpg|{{echo|ho}}
20521 </gallery>
20522 !! html/php
20523 <ul class="gallery mw-gallery-traditional">
20524 <li class='gallerycaption'>{{echo|hi}}</li>
20525 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20526 <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>
20527 <div class="gallerytext">
20528 <p>ho
20529 </p>
20530 </div>
20531 </div></li>
20532 </ul>
20533
20534 !! html/parsoid
20535 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20536 <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>
20537 <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>
20538 </ul>
20539 !! end
20540
20541 !! test
20542 Gallery with wikitext inside caption
20543 !! options
20544 parsoid={
20545 "nativeGallery": true
20546 }
20547 !! wikitext
20548 <gallery>
20549 File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]]
20550 File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}}
20551 </gallery>
20552 !! html/php
20553 <ul class="gallery mw-gallery-traditional">
20554 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20555 <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>
20556 <div class="gallerytext">
20557 <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>
20558 </p>
20559 </div>
20560 </div></li>
20561 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20562 <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>
20563 <div class="gallerytext">
20564 <p>This is a test template
20565 </p>
20566 </div>
20567 </div></li>
20568 </ul>
20569
20570 !! html/parsoid
20571 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20572 <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>
20573 <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>
20574 </ul>
20575 !! end
20576
20577 !! test
20578 Gallery (with showfilename option)
20579 !! options
20580 parsoid={
20581 "nativeGallery": true
20582 }
20583 !! wikitext
20584 <gallery showfilename="">
20585 File:Nonexistent.jpg|caption
20586 File:Nonexistent.jpg
20587 File:Foobar.jpg|some '''caption''' [[Main Page]]
20588 File:Foobar.jpg
20589 </gallery>
20590 !! html/php
20591 <ul class="gallery mw-gallery-traditional">
20592 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20593 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20594 <div class="gallerytext">
20595 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
20596 caption
20597 </p>
20598 </div>
20599 </div></li>
20600 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20601 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20602 <div class="gallerytext">
20603 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
20604 </p>
20605 </div>
20606 </div></li>
20607 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20608 <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>
20609 <div class="gallerytext">
20610 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
20611 some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20612 </p>
20613 </div>
20614 </div></li>
20615 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20616 <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>
20617 <div class="gallerytext">
20618 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
20619 </p>
20620 </div>
20621 </div></li>
20622 </ul>
20623
20624 !! html/parsoid
20625 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
20626 <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>
20627 <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>
20628 <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>
20629 <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>
20630 </ul>
20631 !! end
20632
20633 ## Should Parsoid be preserving these variations? See T151367
20634 !! test
20635 Gallery (with namespace-less filenames)
20636 !! options
20637 parsoid={
20638 "modes": ["wt2html", "html2html"],
20639 "nativeGallery": true
20640 }
20641 !! wikitext
20642 <gallery>
20643 File:Nonexistent.jpg
20644 Nonexistent.jpg
20645 image:foobar.jpg
20646 foobar.jpg
20647 </gallery>
20648 !! html/php
20649 <ul class="gallery mw-gallery-traditional">
20650 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20651 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20652 <div class="gallerytext">
20653 </div>
20654 </div></li>
20655 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20656 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20657 <div class="gallerytext">
20658 </div>
20659 </div></li>
20660 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20661 <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>
20662 <div class="gallerytext">
20663 </div>
20664 </div></li>
20665 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20666 <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>
20667 <div class="gallerytext">
20668 </div>
20669 </div></li>
20670 </ul>
20671
20672 !! html/parsoid
20673 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20674 <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>
20675 <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>
20676 <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>
20677 <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>
20678 </ul>
20679 !! end
20680
20681 !! test
20682 Gallery override link with wikilink (T36852)
20683 !! options
20684 parsoid={
20685 "nativeGallery": true
20686 }
20687 !! wikitext
20688 <gallery>
20689 File:Foobar.jpg|alt=galleryalt|link=Wikilink
20690 </gallery>
20691 !! html/php
20692 <ul class="gallery mw-gallery-traditional">
20693 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20694 <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>
20695 <div class="gallerytext">
20696 </div>
20697 </div></li>
20698 </ul>
20699
20700 !! html/parsoid
20701 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20702 <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>
20703 </ul>
20704 !! end
20705
20706 !! test
20707 Gallery override link with absolute external link (T36852)
20708 !! options
20709 parsoid={
20710 "nativeGallery": true
20711 }
20712 !! wikitext
20713 <gallery>
20714 File:Foobar.jpg|alt=galleryalt|link=http://www.example.org
20715 </gallery>
20716 !! html/php
20717 <ul class="gallery mw-gallery-traditional">
20718 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20719 <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>
20720 <div class="gallerytext">
20721 </div>
20722 </div></li>
20723 </ul>
20724
20725 !! html/parsoid
20726 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20727 <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>
20728 </ul>
20729 !! end
20730
20731 !! test
20732 Gallery override link with absolute external link with LanguageConverter
20733 !! options
20734 language=zh
20735 !! wikitext
20736 <gallery>
20737 File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org
20738 </gallery>
20739 !! html/php
20740 <ul class="gallery mw-gallery-traditional">
20741 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20742 <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>
20743 <div class="gallerytext">
20744 <p>caption
20745 </p>
20746 </div>
20747 </div></li>
20748 </ul>
20749
20750 !! html/parsoid
20751 <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"}}'>
20752 <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>
20753 </ul>
20754 !! end
20755
20756 !! test
20757 Gallery override link with malicious javascript (T36852)
20758 !! options
20759 parsoid={
20760 "modes": ["wt2html", "html2html"],
20761 "nativeGallery": true
20762 }
20763 !! wikitext
20764 <gallery>
20765 File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!');
20766 </gallery>
20767 !! html/php
20768 <ul class="gallery mw-gallery-traditional">
20769 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20770 <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>
20771 <div class="gallerytext">
20772 </div>
20773 </div></li>
20774 </ul>
20775
20776 !! html/parsoid
20777 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20778 <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>
20779 </ul>
20780 !! end
20781
20782 # Note that parsoid uses the invalid link as a caption, PHP does not.
20783 !! test
20784 Gallery with invalid title as link (T45964)
20785 !! options
20786 parsoid={
20787 "modes": ["wt2html", "html2html"],
20788 "nativeGallery": true
20789 }
20790 !! wikitext
20791 <gallery>
20792 File:Foobar.jpg|link=<
20793 </gallery>
20794 !! html/php
20795 <ul class="gallery mw-gallery-traditional">
20796 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20797 <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>
20798 <div class="gallerytext">
20799 </div>
20800 </div></li>
20801 </ul>
20802
20803 !! html/parsoid
20804 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20805 <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>
20806 </ul>
20807 !! end
20808
20809 !! test
20810 Serialize gallery without attrs in data-mw
20811 !! options
20812 parsoid={
20813 "modes": ["html2wt"],
20814 "nativeGallery": true
20815 }
20816 !! html/parsoid
20817 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'>
20818 <li class="gallerycaption">123</li>
20819 <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>
20820 </ul>
20821 !! wikitext
20822 <gallery caption="123">
20823 File:Test.png
20824 </gallery>
20825 !! end
20826
20827 !! test
20828 Gallery with class and style attributes
20829 !! options
20830 parsoid={
20831 "nativeGallery": true
20832 }
20833 !! wikitext
20834 <gallery class="center" style="text-align: center;">
20835 File:Foobar.jpg
20836 </gallery>
20837 !! html/php
20838 <ul class="gallery mw-gallery-traditional center" style="text-align: center;">
20839 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20840 <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>
20841 <div class="gallerytext">
20842 </div>
20843 </div></li>
20844 </ul>
20845
20846 !! html/parsoid
20847 <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":{}}'>
20848 <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>
20849 </ul>
20850 !! end
20851
20852 !! test
20853 Gallery in slideshow mode
20854 !! options
20855 parsoid={
20856 "nativeGallery": true
20857 }
20858 !! wikitext
20859 <gallery mode="slideshow" showthumbnails="">
20860 File:Foobar.jpg
20861 </gallery>
20862 !! html/php
20863 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1">
20864 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20865 <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>
20866 <div class="gallerytext">
20867 </div>
20868 </div></li>
20869 </ul>
20870
20871 !! html/parsoid
20872 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'>
20873 <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>
20874 </ul>
20875 !! end
20876
20877 !! test
20878 HTML Hex character encoding (spells the word "JavaScript")
20879 !! options
20880 parsoid=wt2html,wt2wt,html2html
20881 !! wikitext
20882 &#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
20883 !! html/php
20884 <p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
20885 </p>
20886 !! html/parsoid
20887 <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>
20888 !! end
20889
20890 !! test
20891 HTML Hex character encoding bogus encoding (T28437 regression check)
20892 !! wikitext
20893 &#xsee;&#XSEE;
20894 !! html
20895 <p>&amp;#xsee;&amp;#XSEE;
20896 </p>
20897 !! end
20898
20899 !! test
20900 HTML Hex character encoding mixed case
20901 !! options
20902 parsoid=wt2html,wt2wt,html2html
20903 !! wikitext
20904 &#xEE;&#Xee;
20905 !! html/php
20906 <p>&#xee;&#xee;
20907 </p>
20908 !! html/parsoid
20909 <p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
20910 !! end
20911
20912 # See: https://www.w3.org/TR/html5/syntax.html#character-references
20913 # Note that U+000C (form feed) is not a valid XML character, so
20914 # it is banned even though allowed in HTML5.
20915 !! test
20916 Illegal character references (T106578)
20917 !! wikitext
20918 ; Null: &#00;
20919 ; FF: &#xC;
20920 ; CR: &#xD;
20921 ; Control (low): &#8;
20922 ; Control (high): &#x7F; &#x9F;
20923 ; Surrogate: &#xD83D;&#xDCA9;
20924 ; This is an okay astral character: &#x1F4A9;
20925 !! html+tidy
20926 <dl><dt> Null</dt>
20927 <dd> &amp;#00;</dd>
20928 <dt> FF</dt>
20929 <dd> &amp;#xC;</dd>
20930 <dt> CR</dt>
20931 <dd> &amp;#xD;</dd>
20932 <dt> Control (low)</dt>
20933 <dd> &amp;#8;</dd>
20934 <dt> Control (high)</dt>
20935 <dd> &amp;#x7F; &amp;#x9F;</dd>
20936 <dt> Surrogate</dt>
20937 <dd> &amp;#xD83D;&amp;#xDCA9;</dd>
20938 <dt> This is an okay astral character</dt>
20939 <dd> &#x1f4a9;</dd></dl>
20940 !! end
20941
20942 !! test
20943 __FORCETOC__ override
20944 !! wikitext
20945 __NEWSECTIONLINK__
20946 __FORCETOC__
20947 !! html/php
20948 <p><br />
20949 </p>
20950 !! end
20951
20952 !! test
20953 ISBN code coverage
20954 !! wikitext
20955 ISBN 978-0-1234-56&#x20;789
20956 !! html/php
20957 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a>&#x20;789
20958 </p>
20959 !! html/parsoid
20960 <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>
20961 !! end
20962
20963 !! test
20964 ISBN followed by 5 spaces
20965 !! wikitext
20966 ISBN
20967 !! html
20968 <p>ISBN
20969 </p>
20970 !! end
20971
20972 !! test
20973 Double ISBN
20974 !! wikitext
20975 ISBN ISBN 1234567890
20976 !! html/php
20977 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
20978 </p>
20979 !! html/parsoid
20980 <p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
20981 !! end
20982
20983 # Uppercase X and lowercase x as well
20984 !! test
20985 ISBN with an X
20986 !! wikitext
20987 ISBN 3-462-04561-X
20988 ISBN 3-462-04561-x
20989 ISBN 080442957X
20990 ISBN 080442957x
20991 ISBN 978080442957X
20992 ISBN 978080442957x
20993 !! html/php
20994 <p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a>
20995 <a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a>
20996 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a>
20997 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a>
20998 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a>
20999 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
21000 </p>
21001 !! html/parsoid
21002 <p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
21003 <a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
21004 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
21005 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
21006 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
21007 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
21008 !! end
21009
21010 !! test
21011 ISBN with empty prefix (parsoid test)
21012 !! wikitext
21013 ISBN 1234567890
21014 !! html/php
21015 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21016 </p>
21017 !! html/parsoid
21018 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p>
21019 !! end
21020
21021 !! test
21022 T24905: <abbr> followed by ISBN followed by </a>
21023 !! wikitext
21024 <abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
21025 !! html/php
21026 <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>
21027 </p>
21028 !! html/parsoid
21029 <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>
21030 !! end
21031
21032 !! test
21033 Double RFC
21034 !! wikitext
21035 RFC RFC 1234
21036 !! html
21037 <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a>
21038 </p>
21039 !! end
21040
21041 !! test
21042 Double RFC with a wiki link
21043 !! wikitext
21044 RFC [[RFC 1234]]
21045 !! html
21046 <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>
21047 </p>
21048 !! end
21049
21050 !! test
21051 RFC code coverage
21052 !! wikitext
21053 RFC 983&#x20;987
21054 !! html/php
21055 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
21056 </p>
21057 !! html/parsoid
21058 <p><a href="https://tools.ietf.org/html/rfc983" rel="mw:ExtLink" class="external text" data-parsoid='{"stx":"magiclink"}'>RFC 983</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#x20;","srcContent":" "}'> </span>987</p>
21059 !! end
21060
21061 !! test
21062 Centre-aligned image
21063 !! wikitext
21064 [[Image:foobar.jpg|centre]]
21065 !! html/php
21066 <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>
21067
21068 !! html/parsoid
21069 <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>
21070 !! end
21071
21072 !! test
21073 None-aligned image
21074 !! wikitext
21075 [[Image:foobar.jpg|none]]
21076 !! html/php
21077 <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>
21078
21079 !! html/parsoid
21080 <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>
21081 !! end
21082
21083 !! test
21084 Width + Height sized image (using px) (height is ignored)
21085 !! wikitext
21086 [[Image:foobar.jpg|640x480px]]
21087 !! html/php
21088 <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>
21089 </p>
21090 !! html/parsoid
21091 <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>
21092 !! end
21093
21094 !! test
21095 Width-sized image (using px, no following whitespace)
21096 !! wikitext
21097 [[Image:foobar.jpg|640px]]
21098 !! html/php
21099 <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>
21100 </p>
21101 !! html/parsoid
21102 <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>
21103 !! end
21104
21105 !! test
21106 Width-sized image (using px, with following whitespace - test regression from r39467)
21107 !! wikitext
21108 [[Image:foobar.jpg|640px ]]
21109 !! html/php
21110 <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>
21111 </p>
21112 !! html/parsoid
21113 <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>
21114 !!end
21115
21116 !! test
21117 Width-sized image (using px, with preceding whitespace - test regression from r39467)
21118 !! wikitext
21119 [[Image:foobar.jpg| 640px]]
21120 !! html/php
21121 <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>
21122 </p>
21123 !! html/parsoid
21124 <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>
21125 !! end
21126
21127 !! test
21128 Image with page parameter
21129 !! options
21130 djvu
21131 !! wikitext
21132 [[File:LoremIpsum.djvu|page=2]]
21133 !! html/php
21134 <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>
21135 </p>
21136 !! html/parsoid
21137 <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>
21138 !! end
21139
21140 !! test
21141 Another italics / bold test
21142 !! wikitext
21143 ''' ''x'
21144 !! html
21145 <pre>'<i> </i>x'
21146 </pre>
21147 !!end
21148
21149 # FIXME: The php output seems broken. It's interleaving some open/close tags.
21150 !! test
21151 dt/dd/dl test
21152 !! wikitext
21153 :;;;::
21154 !! html/php
21155 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dt></dl></dd></dl></dd></dl></dd></dl></dd></dl></dd></dl>
21156
21157 !! html/parsoid
21158 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dd></dl></dd></dl></dt></dl></dt></dl></dt></dl></dd></dl>
21159
21160 !!end
21161
21162 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
21163 !! test
21164 Images with the "|" character in the comment
21165 !! wikitext
21166 [[File:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
21167 !! html/php
21168 <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>
21169
21170 !! html/parsoid
21171 <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>
21172 !! end
21173
21174 !! test
21175 [Before] HTML without raw HTML enabled ($wgRawHtml==false)
21176 !! wikitext
21177 <html><script>alert(1);</script></html>
21178 !! html
21179 <p>&lt;html&gt;&lt;script&gt;alert(1);&lt;/script&gt;&lt;/html&gt;
21180 </p>
21181 !! end
21182
21183 !! test
21184 HTML with raw HTML ($wgRawHtml==true)
21185 !! options
21186 wgRawHtml=1
21187 !! wikitext
21188 <html><script>alert(1);</script></html>
21189 !! html/php
21190 <p><script>alert(1);</script>
21191 </p>
21192 !! end
21193
21194 !! test
21195 Parents of subpages, one level up
21196 !! options
21197 subpage title=[[Subpage test/L1/L2/L3]]
21198 !! wikitext
21199 [[../|L2]]
21200 !! html
21201 <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>
21202 </p>
21203 !! end
21204
21205
21206 !! test
21207 Parents of subpages, one level up, not named
21208 !! options
21209 subpage title=[[Subpage test/L1/L2/L3]]
21210 !! wikitext
21211 [[../]]
21212 !! html
21213 <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>
21214 </p>
21215 !! end
21216
21217
21218
21219 !! test
21220 Parents of subpages, two levels up
21221 !! options
21222 subpage title=[[Subpage test/L1/L2/L3]]
21223 !! wikitext
21224 [[../../|L1]]2
21225
21226 [[../../|L1]]l
21227 !! html
21228 <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
21229 </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>
21230 </p>
21231 !! end
21232
21233 !! test
21234 Parents of subpages, two levels up, without trailing slash or name.
21235 !! options
21236 subpage title=[[Subpage test/L1/L2/L3]]
21237 !! wikitext
21238 [[../..]]
21239 !! html
21240 <p>[[../..]]
21241 </p>
21242 !! end
21243
21244 !! test
21245 Parents of subpages, two levels up, with lots of extra trailing slashes.
21246 !! options
21247 subpage title=[[Subpage test/L1/L2/L3]]
21248 !! wikitext
21249 [[../../////]]
21250 !! html
21251 <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>
21252 </p>
21253 !! end
21254
21255 !! article
21256 Subpage test/L1/L2/L3Sibling
21257 !! text
21258 Sibling article
21259 !! endarticle
21260
21261 !! test
21262 Transclusion of a sibling page (one level up)
21263 !! options
21264 subpage title=[[Subpage test/L1/L2/L3]]
21265 !! wikitext
21266 {{../L3Sibling}}
21267 !! html
21268 <p>Sibling article
21269 </p>
21270 !! end
21271
21272 !! test
21273 Transclusion of a child page
21274 !! options
21275 subpage title=[[Subpage test/L1/L2]]
21276 !! wikitext
21277 {{/L3Sibling}}
21278 !! html
21279 <p>Sibling article
21280 </p>
21281 !! end
21282
21283 # This is wt2html only in Parsoid because we add <nowiki>
21284 # because of {{..}} and we don't expect to fix that to
21285 # eliminate the nowikis selective for {{..}} markup.
21286 !! test
21287 Non-transclusion because of too many up levels
21288 !! options
21289 subpage title=[[Subpage test/L1/L2/L3]]
21290 parsoid=wt2html
21291 !! wikitext
21292 {{../../../../More than parent}}
21293 !! html/php
21294 <p>{{../../../../More than parent}}
21295 </p>
21296 !! html/parsoid
21297 <p>{{../../../../More than parent}}</p>
21298 !! end
21299
21300 !! test
21301 Definition list code coverage
21302 !! wikitext
21303 ; title : def
21304 ; title : def
21305 ;title: def
21306 !! html/php
21307 <dl><dt> title &#160;</dt>
21308 <dd> def</dd>
21309 <dt> title&#160;</dt>
21310 <dd> def</dd>
21311 <dt>title</dt>
21312 <dd> def</dd></dl>
21313
21314 !! html/parsoid
21315 <dl><dt> title <span typeof="mw:Placeholder"> </span></dt><dd> def</dd>
21316 <dt> title<span typeof="mw:Placeholder"> </span></dt><dd> def</dd>
21317 <dt>title</dt><dd> def</dd></dl>
21318 !! end
21319
21320 !! test
21321 Don't fall for the self-closing div
21322 !! wikitext
21323 <div>hello world</div/>
21324 !! html
21325 <div>hello world</div>
21326
21327 !! end
21328
21329 !! test
21330 MSGNW magic word
21331 !! wikitext
21332 {{MSGNW:msg}}
21333 !! html/php
21334 <p>&#91;&#91;:Template:Msg&#93;&#93;
21335 </p>
21336 !! end
21337
21338 !! test
21339 RAW magic word
21340 !! wikitext
21341 {{RAW:QUERTY}}
21342 !! html
21343 <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>
21344 </p>
21345 !! end
21346
21347 # This isn't needed for XHTML conformance, but would be handy as a fallback security measure
21348 !! test
21349 Always escape literal '>' in output, not just after '<'
21350 !! wikitext
21351 ><>
21352 !! html
21353 <p>&gt;&lt;&gt;
21354 </p>
21355 !! end
21356
21357 !! test
21358 Template caching
21359 !! wikitext
21360 {{Test}}
21361 {{Test}}
21362 !! html
21363 <p>This is a test template
21364 This is a test template
21365 </p>
21366 !! end
21367
21368
21369 !! article
21370 MediaWiki:Fake
21371 !! text
21372 ==header==
21373 !! endarticle
21374
21375 !! test
21376 Inclusion of !userCanEdit() content
21377 !! wikitext
21378 {{MediaWiki:Fake}}
21379 !! html
21380 <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>
21381
21382 !! end
21383
21384
21385 !! test
21386 Out-of-order TOC heading levels
21387 !! wikitext
21388 ==2==
21389 ======6======
21390 ===3===
21391 =1=
21392 =====5=====
21393 ==2==
21394 !! html
21395 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
21396 <ul>
21397 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
21398 <ul>
21399 <li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
21400 <li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
21401 </ul>
21402 </li>
21403 <li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
21404 <ul>
21405 <li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
21406 <li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
21407 </ul>
21408 </li>
21409 </ul>
21410 </div>
21411
21412 <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>
21413 <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>
21414 <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>
21415 <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>
21416 <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>
21417 <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>
21418
21419 !! end
21420
21421
21422 !! test
21423 ISBN with a dummy number
21424 !! wikitext
21425 ISBN ---
21426 !! html
21427 <p>ISBN ---
21428 </p>
21429 !! end
21430
21431
21432 !! test
21433 ISBN with space-delimited number
21434 !! wikitext
21435 ISBN 92 9017 032 8
21436 !! html/php
21437 <p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a>
21438 </p>
21439 !! html/parsoid
21440 <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>
21441 !! end
21442
21443
21444 !! test
21445 ISBN with multiple spaces, no number
21446 !! wikitext
21447 ISBN foo
21448 !! html
21449 <p>ISBN foo
21450 </p>
21451 !! end
21452
21453
21454 !! test
21455 ISBN length
21456 !! wikitext
21457 ISBN 123456789
21458
21459 ISBN 1234567890
21460
21461 ISBN 12345678901
21462 !! html/php
21463 <p>ISBN 123456789
21464 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21465 </p><p>ISBN 12345678901
21466 </p>
21467 !! html/parsoid
21468 <p>ISBN 123456789</p>
21469
21470 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
21471
21472 <p>ISBN 12345678901</p>
21473 !! end
21474
21475
21476 !! test
21477 ISBN with trailing year (T9110)
21478 !! wikitext
21479 ISBN 1-234-56789-0 - 2006
21480
21481 ISBN 1 234 56789 0 - 2006
21482 !! html/php
21483 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006
21484 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006
21485 </p>
21486 !! html/parsoid
21487 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p>
21488
21489 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p>
21490 !! end
21491
21492
21493 !! test
21494 anchorencode
21495 !! config
21496 wgFragmentMode=[ 'html5', 'legacy' ]
21497 !! wikitext
21498 {{anchorencode:foo bar©#%n}}
21499 !! html/php
21500 <p>foo_bar©#%n
21501 </p>
21502 !! html/parsoid
21503 <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>
21504 !! end
21505
21506 !! test
21507 anchorencode (legacy)
21508 !! config
21509 wgFragmentMode=[ 'legacy' ]
21510 !! wikitext
21511 {{anchorencode:foo bar©#%n}}
21512 !! html/php
21513 <p>foo_bar.C2.A9.23.25n
21514 </p>
21515 !! end
21516
21517 !! test
21518 anchorencode trims spaces
21519 !! config
21520 wgFragmentMode=[ 'html5', 'legacy' ]
21521 !! wikitext
21522 {{anchorencode: __pretty__please__}}
21523 !! html/php
21524 <p>pretty_please
21525 </p>
21526 !! html/parsoid
21527 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: __pretty__please__","function":"anchorencode"},"params":{},"i":0}}]}'>pretty_please</p>
21528 !! end
21529
21530 !! test
21531 anchorencode deals with links
21532 !! config
21533 wgFragmentMode=[ 'html5', 'legacy' ]
21534 !! wikitext
21535 {{anchorencode: [[hello|world]] [[hi]]}}
21536 !! html/php
21537 <p>world_hi
21538 </p>
21539 !! html/parsoid
21540 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: [[hello|world]] [[hi]]","function":"anchorencode"},"params":{},"i":0}}]}'>world_hi</p>
21541 !! end
21542
21543 !! test
21544 anchorencode deals with templates
21545 !! config
21546 wgFragmentMode=[ 'html5', 'legacy' ]
21547 !! wikitext
21548 {{anchorencode: {{Foo}} x}}
21549 !! html/php
21550 <p>FOO_x
21551 </p>
21552 !! html/parsoid
21553 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: {{Foo}} x","function":"anchorencode"},"params":{},"i":0}}]}'>FOO_x</p>
21554 !! end
21555
21556 !! test
21557 anchorencode encodes like the TOC generator: (T20431)
21558 !! config
21559 wgFragmentMode=[ 'html5', 'legacy' ]
21560 !! wikitext
21561 === _ +:.3A%3A _ &&amp;]] x ===
21562 {{anchorencode: _ +:.3A%3A _ &&amp;]] x}}
21563 __NOEDITSECTION__
21564 !! html/php
21565 <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>
21566 <p>+:.3A%3A_&amp;&amp;&#93;&#93;_x
21567 </p>
21568 !! html/parsoid
21569 <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>
21570 <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>
21571 <meta property="mw:PageProp/noeditsection"/>
21572 !! end
21573
21574 !! test
21575 anchorencode encodes like the TOC generator: (T20431) (legacy)
21576 !! config
21577 wgFragmentMode=[ 'legacy' ]
21578 !! wikitext
21579 === _ +:.3A%3A&&amp;]] ===
21580 {{anchorencode: _ +:.3A%3A&&amp;]] }}
21581 __NOEDITSECTION__
21582 !! html/php
21583 <h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&amp;&amp;]]</span></h3>
21584 <p>.2B:.3A.253A.26.26.5D.5D
21585 </p>
21586 !! end
21587
21588 !! test
21589 T8200: blockquotes and paragraph formatting
21590 !! wikitext
21591 <blockquote>
21592 foo
21593 </blockquote>
21594
21595 bar
21596
21597 baz
21598 !! html
21599 <blockquote>
21600 <p>foo
21601 </p>
21602 </blockquote>
21603 <p>bar
21604 </p>
21605 <pre>baz
21606 </pre>
21607 !! end
21608
21609 !! test
21610 T10293: Use of center tag ruins paragraph formatting
21611 !! wikitext
21612 <center>
21613 foo
21614 </center>
21615
21616 bar
21617
21618 baz
21619 !! html
21620 <center>
21621 <p>foo
21622 </p>
21623 </center>
21624 <p>bar
21625 </p>
21626 <pre>baz
21627 </pre>
21628 !! end
21629
21630 !!test
21631 Parsing of overlapping (improperly nested) inline html tags
21632 !! wikitext
21633 <span><s>x</span></s>
21634 !! html/php
21635 <p><span><s>x&lt;/span&gt;</s></span>
21636 </p>
21637 !! html/parsoid
21638 <p><span><s>x</s></span>
21639 </p>
21640 !!end
21641
21642 ###
21643 ### Language variants related tests
21644 ###
21645
21646 # Parsoid does not mark self-links.
21647 # Parsoid does not convert links; PHP will do any necessary redirects.
21648
21649 !! test
21650 Self-link in language variants
21651 !! options
21652 title=[[Dunav]] language=sr
21653 !! wikitext
21654 Both [[Dunav]] and [[Дунав]] are names for this river.
21655 !! html/php
21656 <p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
21657 </p>
21658 !! html/parsoid
21659 <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>
21660 !! end
21661
21662 !! article
21663 Дуна
21664 !! text
21665 content
21666 !! endarticle
21667
21668 !! test
21669 Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
21670 !! options
21671 title=[[Duna]] language=sr
21672 !! wikitext
21673 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
21674 !! html/php
21675 <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.
21676 </p>
21677 !! html/parsoid
21678 <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>
21679 !! end
21680
21681 !! test
21682 Link to a section of a variant of this title shouldn't be parsed as self-link
21683 !! options
21684 title=[[Duna]] language=sr
21685 !! wikitext
21686 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
21687 !! html/php
21688 <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.
21689 </p>
21690 !! html/parsoid
21691 <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>
21692 !! end
21693
21694 !! test
21695 Link to pages in language variants
21696 !! options
21697 language=sr
21698 !! wikitext
21699 Main Page can be written as [[Маин Паге]]
21700 !! html/php
21701 <p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>
21702 </p>
21703 !! html/parsoid
21704 <p>Main Page can be written as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a></p>
21705 !! end
21706
21707
21708 !! test
21709 Multiple links to pages in language variants
21710 !! options
21711 language=sr
21712 !! wikitext
21713 [[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
21714 !! html/php
21715 <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>.
21716 </p>
21717 !! html/parsoid
21718 <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>
21719 !! end
21720
21721
21722 !! test
21723 Simple template in language variants
21724 !! options
21725 language=sr
21726 !! wikitext
21727 {{тест}}
21728 !! html/php
21729 <p>This is a test template
21730 </p>
21731 !! end
21732
21733
21734 !! test
21735 Template with explicit namespace in language variants
21736 !! options
21737 language=sr
21738 !! wikitext
21739 {{Template:тест}}
21740 !! html/php
21741 <p>This is a test template
21742 </p>
21743 !! end
21744
21745
21746 !! test
21747 Basic test for template parameter in language variants
21748 !! options
21749 language=sr
21750 !! wikitext
21751 {{парамтест|param=foo}}
21752 !! html/php
21753 <p>This is a test template with parameter foo
21754 </p>
21755 !! end
21756
21757 !! test
21758 Simple category in language variants
21759 !! options
21760 language=sr cat
21761 !! wikitext
21762 [[Category:МедиаWики Усер'с Гуиде]]
21763 !! html/php
21764 cat=МедиаWики_Усер'с_Гуиде sort=
21765 !! html/parsoid
21766 <link rel="mw:PageProp/Category" href="./Категорија:МедиаWики_Усер'с_Гуиде" data-parsoid='{"stx":"simple","a":{"href":"./Категорија:МедиаWики_Усер&#39;с_Гуиде"},"sa":{"href":"Category:МедиаWики Усер&#39;с Гуиде"}}'/>
21767 !! end
21768
21769 !! article
21770 Category:分类
21771 !! text
21772 blah
21773 !! endarticle
21774
21775 !! article
21776 Category:分類
21777 !! text
21778 blah
21779 !! endarticle
21780
21781 ## We used to, but no longer wt2wt this test since the default serializer
21782 ## will normalize all categories to serialize on their own line.
21783 ## This wikitext usage is going to be fairly uncommon in production and
21784 ## selser will take care of preserving formatting in those scenarios.
21785 !! test
21786 Don't convert blue categorylinks to another variant (T35210)
21787 !! options
21788 cat
21789 language=zh
21790 parsoid=wt2html
21791 !! wikitext
21792 [[A]][[Category:分类]]
21793 !! html/php
21794 cat=分类 sort=
21795 !! html/parsoid
21796 <p><a rel="mw:WikiLink" href="./A" title="A">A</a></p>
21797 <link rel="mw:PageProp/Category" href="./Category:分类"/>
21798 !! end
21799
21800 !! test
21801 Stripping -{}- tags (language variants)
21802 !! options
21803 language=sr
21804 !! wikitext
21805 Latin proverb: -{Ne nuntium necare}-
21806 !! html/php
21807 <p>Latin proverb: Ne nuntium necare
21808 </p>
21809 !! html/parsoid
21810 <p>Latin proverb: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
21811 !! end
21812
21813
21814 !! test
21815 Prevent conversion with -{}- tags (language variants)
21816 !! options
21817 language=sr variant=sr-ec
21818 !! wikitext
21819 Latinski: -{Ne nuntium necare}-
21820 !! html/php
21821 <p>Латински: Ne nuntium necare
21822 </p>
21823 !! html/parsoid
21824 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
21825 !! end
21826
21827
21828 !! test
21829 Prevent conversion of text with -{}- tags (language variants)
21830 !! options
21831 language=sr variant=sr-ec
21832 !! wikitext
21833 Latinski: -{Ne nuntium necare}-
21834 !! html/php
21835 <p>Латински: Ne nuntium necare
21836 </p>
21837 !! html/parsoid
21838 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
21839 !! end
21840
21841
21842 !! test
21843 Prevent conversion of links with -{}- tags (language variants)
21844 !! options
21845 language=sr variant=sr-ec
21846 !! wikitext
21847 -{[[Main Page]]}-
21848 !! html/php
21849 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21850 </p>
21851 !! html/parsoid
21852 <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>
21853 !! end
21854
21855
21856 !! test
21857 -{}- tags within headlines (within html for parserConvert())
21858 !! config
21859 wgFragmentMode=[ 'html5', 'legacy' ]
21860 !! options
21861 language=sr variant=sr-ec
21862 !! wikitext
21863 == -{Naslov}- ==
21864
21865 Note that even an unprotected headline ID is not affected by language
21866 conversion:
21867
21868 == Latinski ==
21869 !! html/php
21870 <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>
21871 <p>Ноте тхат евен ан унпротецтед хеадлине ИД ис нот аффецтед бy лангуаге
21872 цонверсион:
21873 </p>
21874 <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>
21875
21876 !! html/parsoid
21877 <h2 id="-{Naslov}-"><span id="-.7BNaslov.7D-" typeof="mw:FallbackId"></span> <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Naslov"}}'></span> </h2>
21878
21879 <p>Note that even an unprotected headline ID is not affected by language
21880 conversion:</p>
21881
21882 <h2 id="Latinski">Latinski</h2>
21883 !! end
21884
21885 !! test
21886 Explicit definition of language variant alternatives
21887 !! options
21888 language=zh variant=zh-tw
21889 !! wikitext
21890 -{zh:China;zh-tw:Taiwan}-, not China
21891 !! html/php
21892 <p>Taiwan, not China
21893 </p>
21894 !! html/parsoid
21895 <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>
21896 !! end
21897
21898 !! test
21899 Filter syntax for language variants
21900 !! options
21901 language=zh variant=zh-tw
21902 !! wikitext
21903 foo-{zh;zh-hans;zh-hant|blog, WEBJOURNAL, WEBLOG}-quux
21904 !! html/php
21905 <p>fooblog, WEBJOURNAL, WEBLOGquux
21906 </p>
21907 !! html/parsoid
21908 <p>foo<span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"blog, WEBJOURNAL, WEBLOG"}}'></span>quux</p>
21909 !! end
21910
21911 # Note that Parsoid post-processing for language variants needs to
21912 # update the `title` attribute here, based on the mw:ExpandedAttrs property
21913 !! test
21914 Conversion around HTML tags
21915 !! options
21916 language=sr variant=sr-ec
21917 !! wikitext
21918 -{H|span=>sr-ec:script;title=>sr-ec:src}-
21919 <span title="La-{sr-el:L;sr-ec:C}-tin">ski</span>
21920 !! html/php
21921 <p>
21922 <span title="ЛаCтин">ски</span>
21923 </p>
21924 !! html/parsoid
21925 <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"}]}'/>
21926 <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>
21927 !! end
21928
21929 !! test
21930 Explicit session-wise two-way language variant mapping (A flag and - flag)
21931 !! options
21932 language=zh variant=zh-tw
21933 !! wikitext
21934 This is -{zh:China; zh-tw:Taiwan}-, but we'll forget that now.
21935
21936 Taiwan is not China.
21937
21938 But -{A|zh:China; zh-tw:Taiwan}- is China,
21939
21940 (This-{-|zh:China; zh-tw:Taiwan}- should be stripped!)
21941
21942 and -{China}- is China.
21943 !! html/php
21944 <p>This is Taiwan, but we'll forget that now.
21945 </p><p>Taiwan is not China.
21946 </p><p>But Taiwan is Taiwan,
21947 </p><p>(This should be stripped!)
21948 </p><p>and China is China.
21949 </p>
21950 !! html/parsoid
21951 <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>
21952 <p>Taiwan is not China.</p>
21953 <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>
21954 <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>
21955 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"China"}}'></span> is China.</p>
21956 !! end
21957
21958 !! test
21959 Explicit session-wise one-way language variant mapping (A flag and - flag)
21960 !! options
21961 language=zh variant=zh-tw
21962 !! wikitext
21963 This is -{COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}-, but we'll forget that now.
21964
21965 COUNTRY is China or Taiwan.
21966
21967 But -{A|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- is COUNTRY,
21968
21969 (This-{-|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
21970
21971 and -{COUNTRY}- is COUNTRY.
21972 !! html/php
21973 <p>This is Taiwan, but we'll forget that now.
21974 </p><p>COUNTRY is China or Taiwan.
21975 </p><p>But Taiwan is Taiwan,
21976 </p><p>(This should be stripped!)
21977 </p><p>and COUNTRY is COUNTRY.
21978 </p>
21979 !! html/parsoid
21980 <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>
21981 <p>COUNTRY is China or Taiwan.</p>
21982 <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>
21983 <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>
21984 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"COUNTRY"}}'></span> is COUNTRY.</p>
21985 !! end
21986
21987 !! test
21988 Explicit session-wise two-way language variant mapping (H flag for hide)
21989 !! options
21990 language=zh variant=zh-tw
21991 !! wikitext
21992 (This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
21993
21994 Taiwan is China.
21995 !! html/php
21996 <p>(This should be stripped!)
21997 </p><p>Taiwan is Taiwan.
21998 </p>
21999 !! html/parsoid
22000 <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>
22001 <p>Taiwan is China.</p>
22002 !! end
22003
22004 !! test
22005 Explicit session-wise one-way language variant mapping (H flag for hide)
22006 !! options
22007 language=zh variant=zh-tw
22008 !! wikitext
22009 (This-{H|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
22010
22011 COUNTRY is Taiwan or China.
22012 !! html/php
22013 <p>(This should be stripped!)
22014 </p><p>Taiwan is Taiwan or China.
22015 </p>
22016 !! html/parsoid
22017 <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>
22018 <p>COUNTRY is Taiwan or China.</p>
22019 !! end
22020
22021 ## Note that parsoid test runner does not support 'showtitle' option.
22022 !! test
22023 Adding explicit conversion rule for title (T flag)
22024 !! options
22025 language=zh variant=zh-tw showtitle
22026 !! wikitext
22027 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
22028
22029 Taiwan is China.
22030 !! html/php
22031 Taiwan
22032 <p>Should be stripped!
22033 </p><p>Taiwan is China.
22034 </p>
22035 !! html/parsoid
22036 <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>
22037 <p>Taiwan is China.</p>
22038 !! end
22039
22040 !! test
22041 Code coverage: T combined with H flag
22042 !! options
22043 language=zh variant=zh-tw showtitle
22044 !! wikitext
22045 Should be stripped-{T;H|zh:China; zh-tw:Taiwan}-!
22046
22047 Taiwan is China.
22048 !! html/php
22049 Taiwan
22050 <p>Should be stripped!
22051 </p><p>Taiwan is Taiwan.
22052 </p>
22053 !! html/parsoid
22054 <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>
22055 <p>Taiwan is China.</p>
22056 !! end
22057
22058 !! test
22059 Code coverage: T with no variants
22060 !! options
22061 language=zh variant=zh-tw showtitle
22062 !! wikitext
22063 -{H|zh:China; zh-tw:Taiwan}-
22064 Taiwan is China.-{T|Taiwan is China}-
22065 !! html/php
22066 Taiwan is China
22067 <p>
22068 Taiwan is Taiwan.
22069 </p>
22070 !! html/parsoid
22071 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
22072 Taiwan is China.<meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Taiwan is China"},"title":true}'/></p>
22073 !! end
22074
22075 !! test
22076 Code coverage: rules with no variants
22077 !! options
22078 language=zh variant=zh-tw
22079 !! wikitext
22080 -{H|zh:China; zh-tw:Taiwan}-
22081 Taiwan is China.
22082 -{H|China}-
22083 Taiwan is China.
22084 !! html/php
22085 <p>
22086 Taiwan is Taiwan.
22087
22088 Taiwan is China.
22089 </p>
22090 !! html/parsoid
22091 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
22092 Taiwan is China.
22093 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":"China"}]}'/>
22094 Taiwan is China.</p>
22095 !! end
22096
22097
22098 !! test
22099 Code coverage: D flag for conversion rule
22100 !! options
22101 language=zh variant=zh-tw
22102 !! wikitext
22103 -{D|zh-cn:XA; zh-tw:YA}-
22104 -{A;D|zh-cn:XB; zh-tw:YB}-
22105 -{D;H|zh-cn:XC; zh-tw:YC}-
22106
22107 -{D;H|FOO=>zh-tw:BAR;FOO=>zh-cn:BAT}-
22108
22109 -{D|0=>zh-tw:1}-
22110 -{A;D|2=>zh-tw:3}-
22111 -{D;H|4=>zh-tw:5}-
22112
22113 XA XB XC YA YB YC FOO BAR BAT 012345
22114 !! html/php
22115 <p>大陆:XA;台灣:YA;
22116
22117 大陆:XC;台灣:YC;
22118 </p><p>FOO⇒台灣:BAR;FOO⇒大陆:BAT;
22119 </p><p>0⇒台灣:1;
22120
22121 4⇒台灣:5;
22122 </p><p>XA YB YC YA YB YC BAR BAR BAT 013355
22123 </p>
22124 !! html/parsoid
22125 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"twoway":[{"l":"zh-cn","t":"XA"},{"l":"zh-tw","t":"YA"}]}'></span>
22126 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XB"},{"l":"zh-tw","t":"YB"}]}'/>
22127 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XC"},{"l":"zh-tw","t":"YC"}]}'></span></p>
22128 <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>
22129 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"oneway":[{"f":"0","l":"zh-tw","t":"1"}]}'></span>
22130 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"2","l":"zh-tw","t":"3"}]}'/>
22131 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"4","l":"zh-tw","t":"5"}]}'></span></p>
22132 <p>XA XB XC YA YB YC FOO BAR BAT 012345</p>
22133 !! end
22134
22135 !! test
22136 Code coverage: N flag for conversion rule
22137 !! options
22138 language=zh variant=zh-cn
22139 !! wikitext
22140 -{N|zh-cn}-
22141
22142 -{N|zh-tw}-
22143
22144 -{N|sr-ec}-
22145 !! html/php
22146 <p>大陆
22147 </p><p>台灣
22148 </p><p>српски (ћирилица)‎
22149 </p>
22150 !! html/parsoid
22151 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-cn"}}'></span></p>
22152 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-tw"}}'></span></p>
22153 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"sr-ec"}}'></span></p>
22154 !! end
22155
22156 # html2wt suppresses the bogus 'D' flag, so this is wt2html only
22157 !! test
22158 Code coverage: N flag for conversion rule (wt2html only)
22159 !! options
22160 language=zh variant=zh-cn
22161 parsoid=wt2html,html2html
22162 !! wikitext
22163 -{D;N|en}-
22164 !! html/php
22165 <p>English
22166 </p>
22167 !! html/parsoid
22168 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"en"}}' data-parsoid='{"fl":["D","N"]}'></span></p>
22169 !! end
22170
22171 !! test
22172 Testing that changing the language variant here in the tests actually works
22173 !! options
22174 language=zh variant=zh showtitle
22175 !! wikitext
22176 Should be stripped-{T|zh:China; zh-tw:Taiwan}-!
22177 !! html/php
22178 China
22179 <p>Should be stripped!
22180 </p>
22181 !! html/parsoid
22182 <p>Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
22183 !! end
22184
22185 !! test
22186 Recursive conversion of alt and title attrs shouldn't clear converter state
22187 !! options
22188 language=zh variant=zh-cn
22189 showtitle
22190 !! wikitext
22191 -{H|zh-cn:Exclamation; zh-tw:exclamation}-
22192 Should be stripped-{T|zh-cn:China; zh-tw:Taiwan}-<span title="exclamation">!</span>
22193 !! html/php
22194 China
22195 <p>
22196 Should be stripped<span title="Exclamation">!</span>
22197 </p>
22198 !! html/parsoid
22199 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh-cn","t":"Exclamation"},{"l":"zh-tw","t":"exclamation"}]}'/>
22200 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>
22201 !! end
22202
22203 !! test
22204 T26072: more test on conversion rule for title
22205 !! options
22206 language=zh variant=zh-tw showtitle
22207 !! wikitext
22208 This should be stripped-{T|zh:China; zh-tw:Taiwan}-!
22209
22210 This won't take interferes with the title rule-{H|zh:Beijing; zh-tw:Taipei}-.
22211 !! html/php
22212 Taiwan
22213 <p>This should be stripped!
22214 </p><p>This won't take interferes with the title rule.
22215 </p>
22216 !! html/parsoid
22217 <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>
22218 <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>
22219 !! end
22220
22221 !! test
22222 Partly disable title conversion if variant == main language code
22223 !! options
22224 language=zh variant=zh title=[[ZH]] showtitle
22225 !! wikitext
22226 -{T|zh-cn:CN;zh-tw:TW}-
22227 !! html/php
22228 ZH
22229 <p>
22230 </p>
22231 !! html/parsoid
22232 <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>
22233 !! end
22234
22235 !! test
22236 Partly disable title conversion if variant == main language code, more
22237 !! options
22238 language=zh variant=zh title=[[ZH]] showtitle
22239 !! wikitext
22240 -{T|TW}-
22241 !! html/php
22242 ZH
22243 <p>
22244 </p>
22245 !! html/parsoid
22246 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"TW"},"title":true}'/></p>
22247 !! end
22248
22249 !! test
22250 Raw output of variant escape tags (R flag)
22251 !! options
22252 language=zh variant=zh-tw
22253 !! wikitext
22254 Raw: -{R|zh:China;zh-tw:Taiwan}-
22255 !! html/php
22256 <p>Raw: zh:China;zh-tw:Taiwan
22257 </p>
22258 !! html/parsoid
22259 <p>Raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"zh:China;zh-tw:Taiwan"}}'></span></p>
22260 !! end
22261
22262 # html2wt suppresses the bogus 'D' flags, so this is wt2html only
22263 !! test
22264 Raw output of variant escape tags (R flag) (wt2html only)
22265 !! options
22266 language=zh variant=zh-tw
22267 parsoid=wt2html,html2html
22268 !! wikitext
22269 -{Variant}- -{D|syntax}- -{D;R|options}-
22270 !! html/php
22271 <p>Variant syntax options
22272 </p>
22273 !! html/parsoid
22274 <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>
22275 !! end
22276
22277 !! test
22278 Nested markup inside raw output of variant escape tags (R flag)
22279 !! options
22280 language=zh variant=zh-tw
22281 !! wikitext
22282 Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
22283 !! html/php
22284 <p>Nested raw: nested Taiwan nested
22285 </p>
22286 !! html/parsoid
22287 <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>
22288 !! end
22289
22290 !! test
22291 Nested markup and spaces inside raw output of variant escape tags (R flag)
22292 !! options
22293 language=zh variant=zh-tw
22294 !! wikitext
22295 X-{ outer -{ inner }- outer }-X
22296 !! html/php
22297 <p>X outer inner outer X
22298 </p>
22299 !! html/parsoid
22300 <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>
22301 !! end
22302
22303 !! test
22304 Templates inside raw output of variant escape tags (R flag)
22305 !! options
22306 language=zh variant=zh-tw
22307 !! wikitext
22308 Nested raw: -{R|nested {{echo|hi}} templates}-
22309 !! html/php
22310 <p>Nested raw: nested hi templates
22311 </p>
22312 !! html/parsoid
22313 <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>
22314 !! end
22315
22316 !! test
22317 Strings evaluating false shouldn't be ignored by Language converter (T51072)
22318 !! options
22319 language=zh variant=zh-cn
22320 !! wikitext
22321 -{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
22322 !! html/php
22323 <p>0
22324 </p>
22325 !! html/parsoid
22326 <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>
22327 !! end
22328
22329 !! test
22330 Conversion rules from [numeric-only string] to [something else] (T48634)
22331 !! options
22332 language=zh variant=zh-cn
22333 !! wikitext
22334 -{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
22335 !! html/php
22336 <p>D12345EE12345
22337 </p>
22338 !! html/parsoid
22339 <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>
22340 !! end
22341
22342 !! test
22343 Two-way converter rule entries with an empty value should be ignored (T53551)
22344 !! options
22345 language=zh variant=zh-cn
22346 !! wikitext
22347 -{H|zh-cn:foo;zh-tw:;}-foobar
22348 !! html/php
22349 <p>foobar
22350 </p>
22351 !! html/parsoid
22352 <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>
22353 !! end
22354
22355 !! test
22356 One-way converter rule entries with an empty "from" string should be ignored (T53551)
22357 !! options
22358 language=zh variant=zh-cn
22359 !! wikitext
22360 -{H|=>zh-cn:foo;}-foobar
22361 !! html/php
22362 <p>foobar
22363 </p>
22364 !! html/parsoid
22365 <p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[5]}' data-mw-variant='{"add":true,"oneway":[{"f":"","l":"zh-cn","t":"foo"}]}'/>foobar</p>
22366 !! end
22367
22368 !! test
22369 Empty converter rule entries shouldn't be inserted into the conversion table (T53551)
22370 !! options
22371 language=zh variant=zh-cn
22372 !! wikitext
22373 -{H|}-foobar
22374 !! html/php
22375 <p>foobar
22376 </p>
22377 !! html/parsoid
22378 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":""}]}'/>foobar</p>
22379 !! end
22380
22381 !! test
22382 Nested using of manual convert syntax
22383 !! options
22384 language=zh variant=zh-hk
22385 !! wikitext
22386 Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
22387 !! html/php
22388 <p>Nested: Hello Hong Kong!
22389 </p>
22390 !! html/parsoid
22391 <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>
22392 !! end
22393
22394 !! test
22395 HTML markups with conversion syntax in attribs, nested in other conversion blocks
22396 !! options
22397 language=zh variant=zh-cn
22398 !! wikitext
22399 -{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}-
22400 !! html/php
22401 <p><span title="X">A</span>
22402 </p>
22403 !! html/parsoid
22404 <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>
22405 !! end
22406
22407 !! test
22408 HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet in PHP parser)
22409 !! options
22410 language=zh variant=zh-cn
22411 !! wikitext
22412 -{<span title="-{X}-">A</span>}-
22413 !! html/php+disabled
22414 <p><span title="X">A</span>
22415 </p>
22416 !! html/parsoid
22417 <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>
22418 !! end
22419
22420 # Parsoid and PHP disagree on how to parse this example: Parsoid
22421 # insists that the content of a language converter element be a valid
22422 # DOM fragment or attribute string
22423 !! test
22424 Language converter markup with block content
22425 !! options
22426 language=zh variant=zh-cn
22427 !! wikitext
22428 <span>a-{b<div>c}-d
22429
22430 <span>a-{zh;zh-hans;zh-hant|b<div>c}-d
22431
22432 <span>a-{H|0=>zh-cn:x<span>y;0=>zh-tw:b<div>c}-d
22433 !! html/php+tidy
22434 <span>ab<div>cd
22435 <span>ab<div>cd
22436 <span>ad
22437 </span></div></span></div></span>
22438 !! html/parsoid
22439 <p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</span></p><div typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"b&lt;div data-parsoid=&#39;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[10,16,5,0]}&#39;>c&lt;/div>"}}'></div><p>d</p>
22440
22441 <p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</span></p><div typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"b&lt;div data-parsoid=&#39;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[50,56,5,0]}&#39;>c&lt;/div>"}}'></div><p>d</p>
22442
22443 <p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a<meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"0","l":"zh-cn","t":"x&lt;span data-parsoid=&#39;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[82,89,6,0]}&#39;>y&lt;/span>"},{"f":"0","l":"zh-tw","t":"b&lt;div data-parsoid=&#39;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[100,106,5,0]}&#39;>c&lt;/div>"}]}'/>d</span></p>
22444 !! end
22445
22446 !! test
22447 LanguageConverter selser (1)
22448 !! options
22449 language=zh variant=zh-cn
22450 parsoid={
22451 "modes": ["wt2wt", "selser"],
22452 "changes": [
22453 ["span[typeof]", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
22454 ]
22455 }
22456 !! wikitext
22457 -{raw}-
22458 !! wikitext/edited
22459 -{edited}-
22460 !! end
22461
22462 !! test
22463 LanguageConverter selser (2)
22464 !! options
22465 language=zh variant=zh-cn
22466 parsoid={
22467 "modes": ["wt2wt", "selser"],
22468 "changes": [
22469 ["span[class='x']", "contents", "text", "-{foo}-"],
22470 ["a", "contents", "text", "-{"],
22471 ["span[typeof]", "attr", "data-mw", "{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"-{\"}},\"i\":0}}]}"]
22472 ]
22473 }
22474 !! wikitext
22475 <span class="x">TEXT1</span>
22476 [http://example.com TEXT2]
22477 [[Foo|TEXT3]]
22478 {{echo|TEXT4}}
22479 !! wikitext/edited
22480 <span class="x"><nowiki>-{foo}-</nowiki></span>
22481 [http://example.com -{]
22482 [[Foo|<nowiki>-{</nowiki>]]
22483 {{1x|<nowiki>-{</nowiki>}}
22484 !! end
22485
22486 # Tests LanguageVariantText in ConstrainedText
22487 !! test
22488 LanguageConverter selser (3)
22489 !! options
22490 language=zh variant=zh-cn
22491 parsoid={
22492 "modes": ["wt2wt", "selser"],
22493 "changes": [
22494 ["td > span", "attr", "typeof", "mw:LanguageVariant"],
22495 ["td > span", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
22496 ]
22497 }
22498 !! wikitext
22499 {|
22500 |-
22501 |<span>Foo</span>
22502 |}
22503 !! wikitext/edited
22504 {|
22505 |-
22506 |<nowiki/>-{edited}-
22507 |}
22508 !! end
22509
22510 # Tests LanguageVariantText._fromSelSer
22511 !! test
22512 LanguageConverter selser (4)
22513 !! options
22514 language=zh variant=zh-cn
22515 parsoid={
22516 "modes": ["wt2wt", "selser"],
22517 "changes": [
22518 ["td > span.x", "remove"]
22519 ]
22520 }
22521 !! wikitext
22522 {|
22523 |-
22524 |<span class="x">Foo</span>-{Bar}-
22525 ||<span class="x">Foo</span>-{Bar}-
22526 |}
22527 !! wikitext/edited
22528 {|
22529 |-
22530 |<nowiki/>-{Bar}-
22531 ||-{Bar}-
22532 |}
22533 !! end
22534
22535 # Since Parsoid is starting to emit canonical wikitext for links,
22536 # [http://example.com http://example.com] will not RT back to that
22537 # form anymore.
22538 # Parsoid does not language-convert links (it is done in a
22539 # post-processing step)
22540 !! test
22541 Proper conversion of text in external links
22542 !! options
22543 language=sr variant=sr-ec
22544 parsoid=wt2html
22545 !! wikitext
22546 http://www.google.com
22547 gopher://www.google.com
22548 [http://www.google.com http://www.google.com]
22549 [gopher://www.google.com gopher://www.google.com]
22550 [https://www.google.com irc://www.google.com]
22551 [ftp://www.google.com www.google.com/ftp://dir]
22552 [//www.google.com www.google.com]
22553 !! html/php
22554 <p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
22555 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
22556 <a rel="nofollow" class="external text" href="http://www.google.com">http://www.google.com</a>
22557 <a rel="nofollow" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
22558 <a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
22559 <a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
22560 <a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
22561 </p>
22562 !! html/parsoid
22563 <p><a rel="mw:ExtLink" class="external free" href="http://www.google.com">http://www.google.com</a>
22564 <a rel="mw:ExtLink" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
22565 <a rel="mw:ExtLink" class="external free" href="http://www.google.com">http://www.google.com</a>
22566 <a rel="mw:ExtLink" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
22567 <a rel="mw:ExtLink" class="external text" href="https://www.google.com">irc://www.google.com</a>
22568 <a rel="mw:ExtLink" class="external text" href="ftp://www.google.com">www.google.com/ftp://dir</a>
22569 <a rel="mw:ExtLink" class="external text" href="//www.google.com">www.google.com</a></p>
22570 !! end
22571
22572 !! test
22573 Do not convert roman numbers to language variants
22574 !! options
22575 language=sr variant=sr-ec
22576 !! wikitext
22577 Fridrih IV je car.
22578 !! html/php
22579 <p>Фридрих IV је цар.
22580 </p>
22581 !! html/parsoid
22582 <p>Fridrih IV je car.</p>
22583 !! end
22584
22585 !! test
22586 Unclosed language converter markup "-{"
22587 !! options
22588 language=sr
22589 !! wikitext
22590 -{T|hello
22591 !! html
22592 <p>-{T|hello
22593 </p>
22594 !! end
22595
22596 !! test
22597 Don't convert raw rule "-{R|=&gt;}-" to "=>"
22598 !! options
22599 language=sr
22600 !! wikitext
22601 -{R|=&gt;}-
22602 !! html/php
22603 <p>=&gt;
22604 </p>
22605 !! html/parsoid
22606 <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>
22607 !!end
22608
22609 !! test
22610 Don't break link parsing if language converter markup is in the caption.
22611 !! options
22612 language=sr variant=sr-ec
22613 !! wikitext
22614 [[Main Page|-{R|main page}-]]
22615 !! html/php
22616 <p><a href="/wiki/Main_Page" title="Маин Паге">main page</a>
22617 </p>
22618 !! html/parsoid
22619 <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>
22620 !! end
22621
22622 !! test
22623 T146304: Don't break template parsing if language converter markup is in the parameter.
22624 !! options
22625 language=sr variant=sr-ec
22626 !! wikitext
22627 {{echo|-{R|foo}-}}
22628 !! html/php
22629 <p>foo
22630 </p>
22631 !! html/parsoid
22632 <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>
22633 !! end
22634
22635 !! test
22636 T146305: Don't break image parsing if language converter markup is in the caption.
22637 !! options
22638 language=sr
22639 !! wikitext
22640 [[Датотека:Foobar.jpg|thumb|-{R|caption:}-]]
22641 !! html/php
22642 <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>
22643
22644 !! html/parsoid
22645 <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>
22646 !! end
22647
22648 !! test
22649 T146305: Don't break image parsing if nested language converter markup is in the caption.
22650 !! options
22651 language=zh variant=zh-cn
22652 !! wikitext
22653 [[File:Foobar.jpg|thumb|-{|zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
22654 !! html/php
22655 <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>
22656
22657 !! html/parsoid
22658 <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>
22659 !! end
22660
22661 # XXX html2wt disabled because rich markup in alt is not preserved.
22662 !! test
22663 Don't break gallery if language converter markup is inside.
22664 !! options
22665 language=zh
22666 !! wikitext
22667 <gallery>
22668 File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-
22669 File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt
22670 </gallery>
22671 !! html/php
22672 <ul class="gallery mw-gallery-traditional">
22673 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
22674 <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>
22675 <div class="gallerytext">
22676 <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>
22677 </p>
22678 </div>
22679 </div></li>
22680 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
22681 <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>
22682 <div class="gallerytext">
22683 <p>This is a test template
22684 </p>
22685 </div>
22686 </div></li>
22687 </ul>
22688
22689 !! html/parsoid
22690 <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"}}'>
22691 <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>
22692 <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>
22693 </ul>
22694 !! end
22695
22696 !! test
22697 T153135: Don't break list handling if language converter markup is in the item.
22698 !! options
22699 language=zh variant=zh-cn
22700 !! wikitext
22701 ;-{zh-cn:AAA;zh-tw:BBB}-
22702 ;-{R|foo:bar}-
22703 !! html/php
22704 <dl><dt>AAA</dt>
22705 <dt>foo:bar</dt></dl>
22706
22707 !! html/parsoid
22708 <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>
22709 <dt data-parsoid='{"dsr":[25,39,1,0]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"foo:bar"}}'></span></dt>
22710 </dl>
22711 !! end
22712
22713 // Note that parsoid does not protect colons unless language converter
22714 // markup is properly nested, because it is a backtracking parser.
22715 !! test
22716 T153135: Unclosed markup in definition list (code coverage)
22717 !! options
22718 language=zh variant=zh-cn
22719 !! wikitext
22720 ;<b>foo:bar
22721 ;-{zh-cn:AAA
22722 !! html/php+tidy
22723 <dl><dt><b>foo:bar</b></dt><b>
22724 <dt>-{zh-cn:AAA</dt></b></dl><p><b>
22725 </b></p>
22726 !! html/parsoid
22727 <dl><dt data-parsoid='{"dsr":[0,11,1,0]}'><b data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo:bar</b></dt><b data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
22728 <dt data-parsoid='{"dsr":[12,20,1,0]}'>-{zh-cn</dt>
22729 <dd data-parsoid='{"stx":"row","dsr":[20,24,1,0]}'>AAA</dd>
22730 </b></dl>
22731 !! end
22732
22733 !! test
22734 T153135: Nested language converter markup in definition list (code coverage)
22735 !! options
22736 language=zh variant=zh-cn
22737 !! wikitext
22738 ;-{|zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
22739 !! html/php
22740 <dl><dt>AAA foo:bar bat:baz</dt>
22741 <dd>def</dd></dl>
22742
22743 !! html/parsoid
22744 <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>
22745 <dd data-parsoid='{"stx":"row","dsr":[49,53,1,0]}'>def</dd>
22746 </dl>
22747 !! end
22748
22749 # html2wt mode disabled due to <nowiki> insertion.
22750 !! test
22751 T153140: Don't break table handling if language converter markup is in the cell.
22752 !! options
22753 language=sr variant=sr-ec
22754 parsoid=wt2html,wt2wt,html2html
22755 !! wikitext
22756 {|
22757 |-
22758 | -{R|B}-
22759 |}
22760 !! html/php
22761 <table>
22762
22763 <tr>
22764 <td> B
22765 </td></tr></table>
22766
22767 !! html/parsoid
22768 <table>
22769 <tbody>
22770 <tr>
22771 <td><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"B"}}'></span></td>
22772 </tr>
22773 </tbody>
22774 </table>
22775 !! end
22776
22777 !! test
22778 Language converter tricky html2wt cases (1)
22779 !! options
22780 language=sr
22781 parsoid=html2wt,wt2wt
22782 !! html/parsoid
22783 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"}-"}}'></span></p>
22784 !! wikitext
22785 -{<nowiki>}-</nowiki>}-
22786 !! html/php
22787 <p>&#125;-
22788 </p>
22789 !! end
22790
22791 !! test
22792 Language converter tricky html2wt cases (2)
22793 !! options
22794 language=sr
22795 parsoid=html2wt,wt2wt
22796 !! html/parsoid
22797 <p>-{foo}-</p>
22798 !! wikitext
22799 <nowiki>-{foo}-</nowiki>
22800 !! html/php
22801 <p>-&#123;foo&#125;-
22802 </p>
22803 !! end
22804
22805 !! test
22806 Language converter tricky html2wt cases (3)
22807 !! options
22808 language=sr
22809 parsoid=html2wt,wt2wt
22810 !! html/parsoid
22811 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"|"}}'></span></p>
22812 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"R|raw"}}'></span></p>
22813 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"-{foo}-"}}'></span></p>
22814 !! wikitext
22815 -{R||}-
22816
22817 -{R|R|raw}-
22818
22819 -{<nowiki>-{foo}-</nowiki>}-
22820 !! html/php
22821 <p>|
22822 </p><p>R|raw
22823 </p><p>-&#123;foo&#125;-
22824 </p>
22825 !! end
22826
22827 !! test
22828 Language converter tricky html2wt cases (4)
22829 !! options
22830 language=sr
22831 parsoid=html2wt,wt2wt
22832 !! html/parsoid
22833 <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>
22834 !! wikitext
22835 -{R|{{echo|hey}}}-
22836 !! html/php
22837 <p>hey
22838 </p>
22839 !! end
22840
22841 # Note that the <nowiki> escaping added by parsoid for source text,
22842 # destination text, and language names only works on the PHP side
22843 # for *destination text*. (HTML entity escaping wouldn't work
22844 # any better.) This is probably a bug, at least for source texts.
22845 # (For language names PHP uses a precise regexp based on the languages
22846 # it currently knows have variants, which is fragile since this set
22847 # can grow/shrink over time.)
22848 !! test
22849 Language converter tricky html2wt cases (5)
22850 !! options
22851 language=zh variant=zh-cn
22852 !! html/parsoid
22853 <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>
22854 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"A","l":"bo:g;us","t":"B"}]}'/></p>
22855 <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>
22856 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"bo:g;us","t":"xyz"},{"l":"zh-cn","t":"abc"}]}'></span></p>
22857 <p>a:b=>c xyz</p>
22858 !! wikitext
22859 -{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
22860
22861 -{H|A=><nowiki>bo:g;us</nowiki>:B}-
22862
22863 -{A|zh-tw:xyz; zh-cn:<nowiki>0;zh-tw:bar</nowiki>}-
22864
22865 -{<nowiki>bo:g;us</nowiki>:xyz; zh-cn:abc}-
22866
22867 a:b=>c xyz
22868 !! html/php+disabled
22869 <p>foobat;xyz=&gt;zh-cn:abc
22870 </p><p>A
22871 </p><p>0;zh-tw:bar
22872 </p><p>abc
22873 </p><p>a:b=&gt;c 0;zh-tw:bar
22874 </p>
22875 !! end
22876
22877 !! test
22878 T179579: Nowiki and lc interaction
22879 !! options
22880 parsoid=wt2html
22881 language=sr
22882 !! wikitext
22883 -{</nowiki>123}-
22884
22885 -{123<nowiki>|</nowiki>456}-
22886 !! html/parsoid
22887 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&amp;lt;/nowiki>123"}}' data-parsoid='{"fl":[],"src":"-{&lt;/nowiki>123}-"}'></span></p>
22888
22889 <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>
22890 !! end
22891
22892 !! test
22893 T2529: Uncovered bullet
22894 !! wikitext
22895 * Foo {{bullet}}
22896 !! html
22897 <ul><li> Foo </li>
22898 <li> Bar</li></ul>
22899
22900 !! end
22901
22902 !! test
22903 T2529: Uncovered bullet in a deeply nested list
22904 !! wikitext
22905 ******* Foo {{bullet}}
22906 !! html
22907 <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>
22908 <li> Bar</li></ul>
22909
22910 !! end
22911
22912 !! test
22913 T2529: Uncovered table already at line-start
22914 !! wikitext
22915 x
22916
22917 {{table}}
22918 y
22919 !! html
22920 <p>x
22921 </p>
22922 <table>
22923 <tr>
22924 <td> 1 </td>
22925 <td> 2
22926 </td></tr>
22927 <tr>
22928 <td> 3 </td>
22929 <td> 4
22930 </td></tr></table>
22931 <p>y
22932 </p>
22933 !! end
22934
22935 !! test
22936 T2529: Uncovered bullet in parser function result
22937 !! wikitext
22938 * Foo {{lc:{{bullet}} }}
22939 !! html
22940 <ul><li> Foo </li>
22941 <li> bar</li></ul>
22942
22943 !! end
22944
22945 !! test
22946 T7678: Double-parsed template argument
22947 !! wikitext
22948 {{lc:{{{1}}}|hello}}
22949 !! html
22950 <p>{{{1}}}
22951 </p>
22952 !! end
22953
22954 !! test
22955 T7678: Double-parsed template invocation
22956 !! wikitext
22957 {{lc:{{paramtest {{!}} param = hello }} }}
22958 !! html
22959 <p>{{paramtest | param = hello }}
22960 </p>
22961 !! end
22962
22963 !! test
22964 Case insensitivity of parser functions for non-ASCII characters (T10143)
22965 !! options
22966 language=cs
22967 title=[[Main Page]]
22968 !! wikitext
22969 {{PRVNÍVELKÉ:ěščř}}
22970 {{prvnívelké:ěščř}}
22971 {{PRVNÍMALÉ:ěščř}}
22972 {{prvnímalé:ěščř}}
22973 {{MALÁ:ěščř}}
22974 {{malá:ěščř}}
22975 {{VELKÁ:ěščř}}
22976 {{velká:ěščř}}
22977 !! html
22978 <p>Ěščř
22979 Ěščř
22980 ěščř
22981 ěščř
22982 ěščř
22983 ěščř
22984 ĚŠČŘ
22985 ĚŠČŘ
22986 </p>
22987 !! end
22988
22989 !! test
22990 Morwen/13: Unclosed link followed by heading
22991 !! wikitext
22992 [[link
22993 ==heading==
22994 !! html
22995 <p>[[link
22996 </p>
22997 <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>
22998
22999 !! end
23000
23001 !! test
23002 HHP2.1: Heuristics for headings in preprocessor parenthetical structures
23003 !! wikitext
23004 {{foo|
23005 =heading=
23006 !! html
23007 <p>{{foo|
23008 </p>
23009 <h1><span class="mw-headline" id="heading">heading</span></h1>
23010
23011 !! end
23012
23013 !! test
23014 HHP2.2: Heuristics for headings in preprocessor parenthetical structures
23015 !! wikitext
23016 {{foo|
23017 ==heading==
23018 !! html
23019 <p>{{foo|
23020 </p>
23021 <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>
23022
23023 !! end
23024
23025 !! test
23026 Tildes in comments
23027 !! options
23028 pst
23029 !! wikitext
23030 <!-- ~~~~ -->
23031 !! html/php
23032 <!-- ~~~~ -->
23033 !! end
23034
23035 !! test
23036 Paragraphs inside divs (no extra line breaks)
23037 !! wikitext
23038 <div>Line one
23039
23040 Line two</div>
23041 !! html
23042 <div>Line one
23043 Line two</div>
23044
23045 !! end
23046
23047 !! test
23048 Paragraphs inside divs (extra line break on open)
23049 !! wikitext
23050 <div>
23051 Line one
23052
23053 Line two</div>
23054 !! html
23055 <div>
23056 <p>Line one
23057 </p>
23058 Line two</div>
23059
23060 !! end
23061
23062 !! test
23063 Paragraphs inside divs (extra line break on close)
23064 !! wikitext
23065 <div>Line one
23066
23067 Line two
23068 </div>
23069 !! html
23070 <div>Line one
23071 <p>Line two
23072 </p>
23073 </div>
23074
23075 !! end
23076
23077 !! test
23078 Paragraphs inside divs (extra line break on open and close)
23079 !! wikitext
23080 <div>
23081 Line one
23082
23083 Line two
23084 </div>
23085 !! html
23086 <div>
23087 <p>Line one
23088 </p><p>Line two
23089 </p>
23090 </div>
23091
23092 !! end
23093
23094 # doBlockLevels screws up this output and Remex cleans up as much as it can.
23095 # Parsoid seems to do a better job here since its p-wrapper is probably smarter.
23096 !! test
23097 Nesting tags, paragraphs on lines which begin with <div>
23098 !! wikitext
23099 <div></div><strong>A
23100 B</strong>
23101 !! html/php+tidy
23102 <div></div><p><strong>A
23103 </strong></p><strong></strong><p><strong>B</strong>
23104 </p>
23105 !! html/parsoid
23106 <div></div>
23107 <p><strong>A
23108 B</strong>
23109 </p>
23110 !! end
23111
23112 # T8200: <blockquote> should behave like <div> with respect to line breaks
23113 !! test
23114 T8200: paragraphs inside blockquotes (no extra line breaks)
23115 !! wikitext
23116 <blockquote>Line one
23117
23118 Line two</blockquote>
23119 !! html
23120 <blockquote>Line one
23121 Line two</blockquote>
23122
23123 !! html+tidy
23124 <blockquote><p>Line one
23125 Line two</p></blockquote>
23126 !! end
23127
23128 !! test
23129 T8200: paragraphs inside blockquotes (extra line break on open)
23130 !! wikitext
23131 <blockquote>
23132 Line one
23133
23134 Line two</blockquote>
23135 !! html
23136 <blockquote>
23137 <p>Line one
23138 </p>
23139 Line two</blockquote>
23140
23141 !! html+tidy
23142 <blockquote>
23143 <p>Line one
23144 </p><p>
23145 Line two</p></blockquote>
23146 !! end
23147
23148 !! test
23149 T8200: paragraphs inside blockquotes (extra line break on close)
23150 !! wikitext
23151 <blockquote>Line one
23152
23153 Line two
23154 </blockquote>
23155 !! html
23156 <blockquote>Line one
23157 <p>Line two
23158 </p>
23159 </blockquote>
23160
23161 !! html+tidy
23162 <blockquote><p>Line one
23163 </p><p>Line two
23164 </p>
23165 </blockquote>
23166 !! end
23167
23168 !! test
23169 T8200: paragraphs inside blockquotes (extra line break on open and close)
23170 !! wikitext
23171 <blockquote>
23172 Line one
23173
23174 Line two
23175 </blockquote>
23176 !! html
23177 <blockquote>
23178 <p>Line one
23179 </p><p>Line two
23180 </p>
23181 </blockquote>
23182
23183 !! end
23184
23185 # FIXME: Why does/should the blockquote+div combo suppress p-wrapping here?
23186 !! test
23187 Paragraphs inside blockquotes/divs (no extra line breaks)
23188 !! wikitext
23189 <blockquote><div>Line one
23190
23191 Line two</div></blockquote>
23192 !! html
23193 <blockquote><div>Line one
23194 Line two</div></blockquote>
23195
23196 !! end
23197
23198 !! test
23199 Paragraphs inside blockquotes/divs (extra line break on open)
23200 !! wikitext
23201 <blockquote><div>
23202 Line one
23203
23204 Line two</div></blockquote>
23205 !! html
23206 <blockquote><div>
23207 <p>Line one
23208 </p>
23209 Line two</div></blockquote>
23210
23211 !! end
23212
23213 !! test
23214 Paragraphs inside blockquotes/divs (extra line break on close)
23215 !! wikitext
23216 <blockquote><div>Line one
23217
23218 Line two
23219 </div></blockquote>
23220 !! html
23221 <blockquote><div>Line one
23222 <p>Line two
23223 </p>
23224 </div></blockquote>
23225
23226 !! end
23227
23228 !! test
23229 Paragraphs inside blockquotes/divs (extra line break on open and close)
23230 !! wikitext
23231 <blockquote><div>
23232 Line one
23233
23234 Line two
23235 </div></blockquote>
23236 !! html
23237 <blockquote><div>
23238 <p>Line one
23239 </p><p>Line two
23240 </p>
23241 </div></blockquote>
23242
23243 !! end
23244
23245 !! test
23246 Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion
23247 !! options
23248 wgLinkHolderBatchSize=0
23249 !! wikitext
23250 [[meatball:1]]
23251 [[meatball:2]]
23252 [[meatball:3]]
23253 !! html
23254 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?1" class="extiw" title="meatball:1">meatball:1</a>
23255 <a href="http://www.usemod.com/cgi-bin/mb.pl?2" class="extiw" title="meatball:2">meatball:2</a>
23256 <a href="http://www.usemod.com/cgi-bin/mb.pl?3" class="extiw" title="meatball:3">meatball:3</a>
23257 </p>
23258 !! end
23259
23260 !! test
23261 Free external link invading image caption
23262 !! wikitext
23263 [[Image:Foobar.jpg|thumb|http://x|hello]]
23264 !! html/php
23265 <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>
23266
23267 !! html/parsoid
23268 <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>
23269 !! end
23270
23271 !! test
23272 T17196: localised external link numbers
23273 !! options
23274 language=fa
23275 !! wikitext
23276 [http://en.wikipedia.org/]
23277 !! html/php
23278 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/">[۱]</a>
23279 </p>
23280 !! html/parsoid
23281 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/"></a></p>
23282 !! end
23283
23284 !! test
23285 Multibyte character in padleft
23286 !! wikitext
23287 {{padleft:-Hello|7|Æ}}
23288 !! html/php
23289 <p>Æ-Hello
23290 </p>
23291 !! html/parsoid
23292 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:-Hello","function":"padleft"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Æ-Hello</p>
23293 !! end
23294
23295 !! test
23296 Multibyte character in padright
23297 !! wikitext
23298 {{padright:Hello-|7|Æ}}
23299 !! html/php
23300 <p>Hello-Æ
23301 </p>
23302 !! html/parsoid
23303 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:Hello-","function":"padright"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Hello-Æ</p>
23304 !! end
23305
23306 !!test
23307 formatdate parser function
23308 !! wikitext
23309 {{#formatdate:2009-03-24}}
23310 !! html
23311 <p><span class="mw-formatted-date" title="2009-03-24">2009-03-24</span>
23312 </p>
23313 !! end
23314
23315 !!test
23316 formatdate parser function, with default format
23317 !! wikitext
23318 {{#formatdate:2009-03-24|mdy}}
23319 !! html
23320 <p><span class="mw-formatted-date" title="2009-03-24">March 24, 2009</span>
23321 </p>
23322 !! end
23323
23324 !! test
23325 Spacing of numbers in formatted dates
23326 !! wikitext
23327 {{#formatdate:January 15}}
23328 !! html
23329 <p><span class="mw-formatted-date" title="01-15">January 15</span>
23330 </p>
23331 !! end
23332
23333 !! test
23334 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
23335 !! options
23336 language=nl title=[[MediaWiki:Common.css]]
23337 !! wikitext
23338 {{#formatdate:2009-03-24|dmy}}
23339 !! html
23340 <p><span class="mw-formatted-date" title="2009-03-24">24 March 2009</span>
23341 </p>
23342 !! end
23343
23344 #
23345 #
23346 #
23347
23348 #
23349 # Edit comments
23350 #
23351
23352 !! test
23353 Edit comment with link
23354 !! options
23355 comment
23356 !! wikitext
23357 I like the [[Main Page]] a lot
23358 !! html/php
23359 I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot
23360 !!end
23361
23362 !! test
23363 Edit comment with link and link text
23364 !! options
23365 comment
23366 !! wikitext
23367 I like the [[Main Page|best pages]] a lot
23368 !! html/php
23369 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
23370 !!end
23371
23372 !! test
23373 Edit comment with link and link text with suffix
23374 !! options
23375 comment
23376 !! wikitext
23377 I like the [[Main Page|best page]]s a lot
23378 !! html/php
23379 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
23380 !!end
23381
23382 !! test
23383 Edit comment with section link (non-local, eg in history list)
23384 !! options
23385 comment title=[[Main Page]]
23386 !! wikitext
23387 /* External links */ removed bogus entries
23388 !! html/php
23389 <a href="/wiki/Main_Page#External_links" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
23390 !!end
23391
23392 !! test
23393 Edit comment with section link and text before it (non-local, eg in history list)
23394 !! options
23395 comment title=[[Main Page]]
23396 !! wikitext
23397 pre-comment text /* External links */ removed bogus entries
23398 !! html/php
23399 pre-comment text <a href="/wiki/Main_Page#External_links" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
23400 !!end
23401
23402 !! test
23403 Edit comment with section link (local, eg in diff view)
23404 !! options
23405 comment local title=[[Main Page]]
23406 !! wikitext
23407 /* External links */ removed bogus entries
23408 !! html/php
23409 <a href="#External_links">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
23410 !!end
23411
23412 !! test
23413 Edit comment with subpage link (T16080)
23414 !! options
23415 comment
23416 subpage
23417 title=[[Subpage test]]
23418 !! wikitext
23419 Poked at a [[/subpage]] here...
23420 !! html/php
23421 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> here...
23422 !!end
23423
23424 !! test
23425 Edit comment with subpage link and link text (T16080)
23426 !! options
23427 comment
23428 subpage
23429 title=[[Subpage test]]
23430 !! wikitext
23431 Poked at a [[/subpage|neat little page]] here...
23432 !! html/php
23433 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">neat little page</a> here...
23434 !!end
23435
23436 !! test
23437 Edit comment with bogus subpage link in non-subpage NS (T16080)
23438 !! options
23439 comment
23440 title=[[Subpage test]]
23441 !! wikitext
23442 Poked at a [[/subpage]] here...
23443 !! html/php
23444 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...
23445 !!end
23446
23447 !! test
23448 Edit comment with bare anchor link (local, as on diff)
23449 !! options
23450 comment
23451 local
23452 title=[[Main Page]]
23453 !! wikitext
23454 [[#section]]
23455 !! html/php
23456 <a href="#section">#section</a>
23457 !! end
23458
23459 !! test
23460 Edit comment with bare anchor link (non-local, as on history)
23461 !! options
23462 comment
23463 title=[[Main Page]]
23464 !! wikitext
23465 [[#section]]
23466 !! html/php
23467 <a href="/wiki/Main_Page#section" title="Main Page">#section</a>
23468 !! end
23469
23470 !! test
23471 Anchor starting with underscore
23472 !! options
23473 title=[[Foo]]
23474 !! wikitext
23475 [[#_ref|One]]
23476 !! html/php
23477 <p><a href="#_ref">One</a>
23478 </p>
23479 !! html/parsoid
23480 <p><a rel="mw:WikiLink" href="./Foo#_ref" data-parsoid='{"stx":"piped","a":{"href":"./Foo#_ref"},"sa":{"href":"#_ref"}}'>One</a></p>
23481 !! end
23482
23483 !! test
23484 Id starting with underscore
23485 !! wikitext
23486 <div id="_ref"></div>
23487 !! html/*
23488 <div id="_ref"></div>
23489
23490 !! end
23491
23492 !! test
23493 Edit comment with link with more than one pipe (T99346)
23494 !! options
23495 comment
23496 !! wikitext
23497 [[Main Page|Many|pipes]]
23498 !! html/php
23499 <a href="/wiki/Main_Page" title="Main Page">Many|pipes</a>
23500 !! end
23501
23502 !! test
23503 Complex edit comment with link with more than one pipe (T99346)
23504 !! options
23505 comment
23506 !! wikitext
23507 Created page with "<noinclude>[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]]</noinclude> === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..."
23508 !! html/php
23509 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;
23510 !! end
23511
23512 !! test
23513 Space normalisation on autocomment (T24784)
23514 !! options
23515 comment
23516 title=[[Main Page]]
23517 !! wikitext
23518 /* __hello__world__ */
23519 !! html/php
23520 <a href="/wiki/Main_Page#hello_world" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">__hello__world__</span></span>
23521 !! end
23522
23523 !! test
23524 percent-encoding and + signs in comments (T28410)
23525 !! options
23526 comment
23527 !! wikitext
23528 [[ABC%33D% ++]] [[ABC%33D% ++|+%20]]
23529 !! html/php
23530 <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>
23531 !! end
23532
23533 # Parsoid doesn't support this yet: see T75581
23534 # but it *should* omit the 'src' attribute if the image is bad.
23535 # PHP side of tests was disabled in
23536 # mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
23537 # because of issues in the PHP parserTests infrastructure
23538 # (but the output below is indeed what the PHP side emits)
23539 !! test
23540 Bad images - basic functionality
23541 !! wikitext
23542 [[File:Bad.jpg]]
23543 !! DISABLED/html/php
23544 !! html/parsoid
23545 <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>
23546 !! end
23547
23548 !! test
23549 Bad images - T18039: text after bad image disappears
23550 !! wikitext
23551 Foo bar
23552 [[File:Bad.jpg]]
23553 Bar foo
23554 !! DISABLED/html/php
23555 <p>Foo bar
23556 </p><p>Bar foo
23557 </p>
23558 !! html/parsoid
23559 <p>Foo bar
23560 <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>
23561 Bar foo</p>
23562 !! end
23563
23564 !! test
23565 Verify that displaytitle works (T24501) no displaytitle
23566 !! options
23567 showtitle
23568 !! config
23569 wgAllowDisplayTitle=true
23570 wgRestrictDisplayTitle=false
23571 !! wikitext
23572 this is not the the title
23573 !! html/php
23574 Parser test
23575 <p>this is not the the title
23576 </p>
23577 !! end
23578
23579 !! test
23580 Verify that displaytitle works (T24501) RestrictDisplayTitle=false
23581 !! options
23582 showtitle
23583 title=[[Screen]]
23584 !! config
23585 wgAllowDisplayTitle=true
23586 wgRestrictDisplayTitle=false
23587 !! wikitext
23588 this is not the the title
23589 {{DISPLAYTITLE:whatever}}
23590 !! html/php
23591 whatever
23592 <p>this is not the the title
23593 </p>
23594 !! end
23595
23596 !! test
23597 Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch
23598 !! options
23599 showtitle
23600 title=[[Screen]]
23601 !! config
23602 wgAllowDisplayTitle=true
23603 wgRestrictDisplayTitle=true
23604 !! wikitext
23605 this is not the the title
23606 {{DISPLAYTITLE:whatever}}
23607 !! html/php
23608 Screen
23609 <p>this is not the the title
23610 </p>
23611 !! end
23612
23613 !! test
23614 Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching
23615 !! options
23616 showtitle
23617 title=[[Screen]]
23618 !! config
23619 wgAllowDisplayTitle=true
23620 wgRestrictDisplayTitle=true
23621 !! wikitext
23622 this is not the the title
23623 {{DISPLAYTITLE:screen}}
23624 !! html/php
23625 screen
23626 <p>this is not the the title
23627 </p>
23628 !! end
23629
23630 !! test
23631 Verify that displaytitle works (T24501) AllowDisplayTitle=false
23632 !! options
23633 showtitle
23634 title=[[Screen]]
23635 !! config
23636 wgAllowDisplayTitle=false
23637 !! wikitext
23638 this is not the the title
23639 {{DISPLAYTITLE:screen}}
23640 !! html/php
23641 Screen
23642 <p>this is not the the title
23643 <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>
23644 </p>
23645 !! end
23646
23647 !! test
23648 Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE
23649 !! options
23650 showtitle
23651 title=[[Screen]]
23652 !! config
23653 wgAllowDisplayTitle=false
23654 !! wikitext
23655 this is not the the title
23656 !! html/php
23657 Screen
23658 <p>this is not the the title
23659 </p>
23660 !! end
23661
23662 !! test
23663 Verify that displaytitle handles inline CSS styles (T28547) - rejected value
23664 !! options
23665 showtitle
23666 title=[[Screen]]
23667 !! config
23668 wgAllowDisplayTitle=true
23669 wgRestrictDisplayTitle=true
23670 !! wikitext
23671 this is not the the title
23672 {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
23673 !! html/php
23674 <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
23675 <p>this is not the the title
23676 </p>
23677 !! end
23678
23679 !! test
23680 Verify that displaytitle handles inline CSS styles (T28547) - accepted value
23681 !! options
23682 showtitle
23683 title=[[Screen]]
23684 !! config
23685 wgAllowDisplayTitle=true
23686 wgRestrictDisplayTitle=true
23687 !! wikitext
23688 this is not the the title
23689 {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
23690 !! html/php
23691 <span style="color: red;">s</span>creen
23692 <p>this is not the the title
23693 </p>
23694 !! end
23695
23696 !! test
23697 Page status indicators: Empty name is invalid
23698 !! options
23699 showindicators
23700 !! wikitext
23701 <indicator name=" "></indicator>
23702 <indicator></indicator>
23703 !! html/php
23704 <p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
23705 <span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
23706 </p>
23707 !! end
23708
23709 !! test
23710 Page status indicators: Weird syntaxes that are okay
23711 !! options
23712 showindicators
23713 !! wikitext
23714 <indicator name="empty" />
23715 <indicator name="name"></indicator>
23716 !! html/php
23717 empty=
23718 name=
23719 <p><br />
23720 </p>
23721 !! end
23722
23723 !! test
23724 Page status indicators: Torture test
23725 !! options
23726 showindicators
23727 !! wikitext
23728 <indicator name="01">hello world</indicator>
23729 <indicator name="02">[[Main Page]]</indicator>
23730 <indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator>
23731 <indicator name="04">[[File:Foobar.jpg|25px]]</indicator>
23732 <indicator name="05">* foo
23733 * bar</indicator>
23734 <indicator name="06"><nowiki>foo</nowiki></indicator>
23735 <indicator name="07"> Preformatted</indicator>
23736 <indicator name="08"><div>Broken tag</indicator>
23737 <indicator name="09">{| class=wikitable
23738 | cell
23739 |}</indicator>
23740 <indicator name="10">Two
23741
23742 paragraphs</indicator>
23743 !! html/php
23744 01=hello world
23745 02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
23746 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" />
23747 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>
23748 05=<ul><li> foo</li>
23749 <li> bar</li></ul>
23750
23751 06=foo
23752 07=<pre>Preformatted
23753 </pre>
23754 08=<div>Broken tag</div>
23755
23756 09=<table class="wikitable">
23757 <tr>
23758 <td> cell
23759 </td></tr></table>
23760
23761 10=<p>Two
23762 </p><p>paragraphs
23763 </p>
23764 <p><br />
23765 </p><p><br />
23766 </p><p><br />
23767 </p><p><br />
23768 </p><p><br />
23769 </p>
23770 !! end
23771
23772 !! test
23773 preload: check <noinclude> and <includeonly>
23774 !! options
23775 preload
23776 !! wikitext
23777 Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
23778 !! html/php
23779 Hello kind world.
23780 !! end
23781
23782 !! test
23783 preload: check <onlyinclude>
23784 !! options
23785 preload
23786 !! wikitext
23787 Goodbye <onlyinclude>Hello world</onlyinclude>
23788 !! html/php
23789 Hello world
23790 !! end
23791
23792 !! test
23793 preload: can pass tags through if we want to
23794 !! options
23795 preload
23796 !! wikitext
23797 <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
23798 !! html/php
23799 <includeonly>Hello world</includeonly>
23800 !! end
23801
23802 !! test
23803 preload: check that it doesn't try to do tricks
23804 !! options
23805 preload
23806 !! wikitext
23807 * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
23808 !! html/php
23809 * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
23810 !! end
23811
23812 !! test
23813 Play a bit with r67090 and T5158
23814 !! wikitext
23815 <div style="width:50% !important">&nbsp;</div>
23816 <div style="width:50%&nbsp;!important">&nbsp;</div>
23817 <div style="width:50%&#160;!important">&nbsp;</div>
23818 <div style="border : solid;">&nbsp;</div>
23819 !! html/php
23820 <div style="width:50% !important">&#160;</div>
23821 <div style="width:50% !important">&#160;</div>
23822 <div style="width:50% !important">&#160;</div>
23823 <div style="border&#160;: solid;">&#160;</div>
23824
23825 !! html/parsoid
23826 <div style="width:50% !important" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
23827 <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>
23828 <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>
23829 <div style="border : solid;" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
23830
23831 !! end
23832
23833 !! test
23834 HTML5 data attributes
23835 !! wikitext
23836 <span data-foo="bar">Baz</span>
23837 <p data-abc-def_hij="">Quuz</p>
23838 !! html/php
23839 <p><span data-foo="bar">Baz</span>
23840 </p>
23841 <p data-abc-def_hij="">Quuz</p>
23842
23843 !! html/parsoid
23844 <p><span data-foo="bar" data-parsoid='{"stx":"html"}'>Baz</span></p>
23845 <p data-abc-def_hij="" data-parsoid='{"stx":"html"}'>Quuz</p>
23846 !! end
23847
23848 !! test
23849 Strip reserved data attributes
23850 !! wikitext
23851 <div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
23852 !! html/php
23853 <div data-ok="fred">d</div>
23854
23855 !! html/parsoid
23856 <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>
23857 !! end
23858
23859 !! test
23860 percent-encoding and + signs in internal links (T28410)
23861 !! wikitext
23862 [[User:+%]] [[Page+title%]]
23863 [[%+]] [[%+|%20]] [[%+ ]] [[%+r]]
23864 [[%]] [[+]] [[File:%+abc%39|foo|[[bar]]]]
23865 [[%33%45]] [[%33%45+]]
23866 !! html/php
23867 <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>
23868 <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>
23869 <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>
23870 <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>
23871 </p>
23872 !! html/parsoid
23873 <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>
23874 <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>
23875 <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>
23876 <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>
23877 !! end
23878
23879 !! test
23880 Special characters in embedded file links (T29679)
23881 !! wikitext
23882 [[File:Contains & ampersand.jpg]]
23883 [[File:Does not exist.jpg|Title with & ampersand]]
23884 !! html/php
23885 <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>
23886 <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>
23887 </p>
23888 !! html/parsoid
23889 <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>
23890 <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>
23891 !! end
23892
23893 !! test
23894 Confirm that 'apos' named character reference doesn't make it to output (not legal in HTML 4)
23895 !! wikitext
23896 Text&apos;s been normalized?
23897 !! html
23898 <p>Text&#39;s been normalized?
23899 </p>
23900 !! end
23901
23902 !! test
23903 T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
23904 !! wikitext
23905 http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
23906 !! html
23907 <p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> &lt;-- U+3000 (vim: ^Vu3000)
23908 </p>
23909 !! end
23910
23911 !! test
23912 T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
23913 !! wikitext
23914 [http://www.example.org/ ideograms]
23915 !! html
23916 <p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a>
23917 </p>
23918 !! end
23919
23920 !! test
23921 T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
23922 !! wikitext
23923 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
23924 !! html
23925 <p><img src="http://www.example.org/pic.png" alt="pic.png"/> &lt;-- U+3000 (vim: ^Vu3000)
23926 </p>
23927 !! end
23928
23929 !! article
23930 Mediawiki:loop1
23931 !! text
23932 {{Identical|A}}
23933 !! endarticle
23934
23935 !! article
23936 Mediawiki:loop2
23937 !! text
23938 {{Identical|B}}
23939 !! endarticle
23940
23941 !! article
23942 Template:Identical
23943 !! text
23944 {{int:loop1}}
23945 {{int:loop2}}
23946 !! endarticle
23947
23948 !! test
23949 T33098 Template which includes system messages which includes the template
23950 !! wikitext
23951 {{Identical}}
23952 !! html
23953 <p><span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
23954 <span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
23955 </p>
23956 !! end
23957
23958 !! test
23959 T33490 Turkish: ucfirst 'blah'
23960 !! options
23961 language=tr
23962 !! wikitext
23963 {{ucfirst:blah}}
23964 !! html
23965 <p>Blah
23966 </p>
23967 !! end
23968
23969 !! test
23970 T33490 Turkish: ucfirst 'ix'
23971 !! options
23972 language=tr
23973 !! wikitext
23974 {{ucfirst:ix}}
23975 !! html
23976 <p>İx
23977 </p>
23978 !! end
23979
23980 !! test
23981 T33490 Turkish: lcfirst 'BLAH'
23982 !! options
23983 language=tr
23984 !! wikitext
23985 {{lcfirst:BLAH}}
23986 !! html
23987 <p>bLAH
23988 </p>
23989 !! end
23990
23991 !! test
23992 T33490 Turkish: ucfırst (with a dotless i)
23993 !! options
23994 language=tr
23995 !! wikitext
23996 {{ucfırst:blah}}
23997 !! html
23998 <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>
23999 </p>
24000 !! end
24001
24002 !! test
24003 T33490 ucfırst (with a dotless i) with English language
24004 !! options
24005 language=en
24006 !! wikitext
24007 {{ucfırst:blah}}
24008 !! html
24009 <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>
24010 </p>
24011 !! end
24012
24013 # Note that Parsoid doesn't emit an explicit TOC.
24014 # Note also that the html2wt direction tends to emit an extra newline
24015 # between the __TOC__ magicword and the first heading unless *both*
24016 # the <meta> and the <h2> have a data-parsoid attribute set (even if
24017 # it's "{}").
24018
24019 !! test
24020 T28375: TOC with italics
24021 !! options
24022 title=[[Main Page]]
24023 !! wikitext
24024 __TOC__
24025 == ''Lost'' episodes ==
24026 !! html/php
24027 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24028 <ul>
24029 <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>
24030 </ul>
24031 </div>
24032
24033 <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>
24034
24035 !! html/parsoid
24036 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24037 <h2 id="Lost_episodes" data-parsoid='{}'> <i>Lost</i> episodes </h2>
24038 !! end
24039
24040 !! test
24041 T28375: TOC with bold
24042 !! options
24043 title=[[Main Page]]
24044 !! wikitext
24045 __TOC__
24046 == '''should be bold''' then normal text ==
24047 !! html/php
24048 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24049 <ul>
24050 <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>
24051 </ul>
24052 </div>
24053
24054 <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>
24055
24056 !! html/parsoid
24057 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24058 <h2 id="should_be_bold_then_normal_text" data-parsoid='{}'> <b>should be bold</b> then normal text </h2>
24059 !! end
24060
24061 !! test
24062 T35845: Headings become cursive in TOC when they contain an image
24063 !! options
24064 title=[[Main Page]]
24065 !! wikitext
24066 __TOC__
24067 == Image [[Image:foobar.jpg]] ==
24068 !! html/php
24069 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24070 <ul>
24071 <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
24072 </ul>
24073 </div>
24074
24075 <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>
24076
24077 !! html/parsoid
24078 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24079 <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>
24080 !! end
24081
24082 !! test
24083 T35845 (2): Headings become bold in TOC when they contain a blockquote
24084 !! options
24085 title=[[Main Page]]
24086 !! wikitext
24087 __TOC__
24088 == <blockquote>Quote</blockquote> ==
24089 !! html/php
24090 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24091 <ul>
24092 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
24093 </ul>
24094 </div>
24095
24096 <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>
24097
24098 !! html/php+tidy
24099 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24100 <ul>
24101 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
24102 </ul>
24103 </div>
24104
24105 <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>
24106 !! html/parsoid
24107 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24108 <h2 id="Quote" data-parsoid='{}'> <blockquote>Quote</blockquote> </h2>
24109 !! end
24110
24111 !! test
24112 Unclosed tags in TOC
24113 !! config
24114 wgFragmentMode=[ 'html5', 'legacy' ]
24115 !! options
24116 title=[[Main Page]]
24117 !! wikitext
24118 __TOC__
24119 == Proof: 2 < 3 ==
24120 <small>Hanc marginis exiguitas non caperet.</small>
24121 QED
24122 !! html/php
24123 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24124 <ul>
24125 <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>
24126 </ul>
24127 </div>
24128
24129 <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>
24130 <p><small>Hanc marginis exiguitas non caperet.</small>
24131 QED
24132 </p>
24133 !! html/parsoid
24134 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24135 <h2 id="Proof:_2_&lt;_3" data-parsoid='{}'><span id="Proof:_2_.3C_3" typeof="mw:FallbackId"></span> Proof: 2 &lt; 3 </h2>
24136 <p><small>Hanc marginis exiguitas non caperet.</small>
24137 QED</p>
24138 !! end
24139
24140 !! test
24141 Multiple tags in TOC
24142 !! wikitext
24143 __TOC__
24144 == <i>Foo</i> <b>Bar</b> ==
24145
24146 == <i>Foo</i> <blockquote>Bar</blockquote> ==
24147 !! html/php
24148 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24149 <ul>
24150 <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>
24151 <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>
24152 </ul>
24153 </div>
24154
24155 <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>
24156 <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>
24157
24158 !! html/php+tidy
24159 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24160 <ul>
24161 <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>
24162 <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>
24163 </ul>
24164 </div>
24165
24166 <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>
24167 <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>
24168 !! html/parsoid
24169 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24170 <h2 id="Foo_Bar" data-parsoid='{}'> <i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b> </h2>
24171
24172 <h2 id="Foo_Bar_2" data-parsoid='{}'> <i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote>Bar</blockquote> </h2>
24173 !! end
24174
24175 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
24176 # html5 tag parsing.
24177 !! test
24178 Tags with parameters in TOC
24179 !! options
24180 parsoid=wt2html
24181 !! wikitext
24182 __TOC__
24183 == <sup class="in-h2">Hello</sup> ==
24184
24185 == <sup class="a > b">Evilbye</sup> ==
24186 !! html/php
24187 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24188 <ul>
24189 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
24190 <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>
24191 </ul>
24192 </div>
24193
24194 <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>
24195 <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>
24196
24197 !! html/parsoid
24198 <meta property="mw:PageProp/toc" />
24199 <h2 id="Hello"> <sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup> </h2>
24200
24201 <h2 id='b">Evilbye'><span id="b.22.3EEvilbye" typeof="mw:FallbackId"></span> <sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup> </h2>
24202 !! end
24203
24204 !! test
24205 span tags with directionality in TOC
24206 !! wikitext
24207 __TOC__
24208 == <span dir="ltr">C++</span> ==
24209
24210 == <span dir="rtl">זבנג!</span> ==
24211
24212 == <span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span> ==
24213
24214 == <span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span> ==
24215
24216 == <span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span> ==
24217 !! html/php
24218 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24219 <ul>
24220 <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>
24221 <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>
24222 <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>
24223 <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>
24224 <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>
24225 </ul>
24226 </div>
24227
24228 <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>
24229 <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>
24230 <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>
24231 <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>
24232 <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>
24233
24234 !! html/parsoid
24235 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24236 <h2 id="C++" data-parsoid='{}'><span id="C.2B.2B" typeof="mw:FallbackId"></span> <span dir="ltr">C++</span> </h2>
24237 <h2 id="זבנג!"><span id=".D7.96.D7.91.D7.A0.D7.92.21" typeof="mw:FallbackId"></span> <span dir="rtl">זבנג!</span> </h2>
24238 <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>
24239 <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>
24240 <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>
24241 !! end
24242
24243 !! test
24244 T74884: bdi element in ToC
24245 !! wikitext
24246 __TOC__
24247 == <bdi>test</bdi> ==
24248 !! html/php
24249 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24250 <ul>
24251 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
24252 </ul>
24253 </div>
24254
24255 <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>
24256
24257 !! html/parsoid
24258 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24259 <h2 id="test" data-parsoid='{}'> <bdi>test</bdi> </h2>
24260 !! end
24261
24262 !! test
24263 T35715: s/strike element in ToC
24264 !! wikitext
24265 __TOC__
24266 == <s>test</s> test <strike>test</strike> ==
24267 !! html/php
24268 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24269 <ul>
24270 <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>
24271 </ul>
24272 </div>
24273
24274 <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>
24275
24276 !! html/parsoid
24277 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24278 <h2 id="test_test_test" data-parsoid='{}'> <s>test</s> test <strike>test</strike> </h2>
24279 !! end
24280
24281 !! test
24282 Empty <p> tag in TOC, removed by Sanitizer (T92892)
24283 !! wikitext
24284 __TOC__
24285 == x ==
24286 !! html/php
24287 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24288 <ul>
24289 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
24290 </ul>
24291 </div>
24292
24293 <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>
24294
24295 !! html/parsoid
24296 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24297 <h2 id="x" data-parsoid='{}'> x </h2>
24298 !! end
24299
24300 !! article
24301 MediaWiki:T34057
24302 !! text
24303 == {{int:headline_sample}} ==
24304 !! endarticle
24305
24306 !! test
24307 T34057: Title needed when expanding <h> nodes.
24308 !! options
24309 title=[[Main Page]]
24310 !! wikitext
24311 {{int:T34057}}
24312 !! html
24313 <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>
24314
24315 !! end
24316
24317 !! test
24318 Strip marker in urlencode
24319 !! wikitext
24320 {{urlencode:x<nowiki/>y}}
24321 {{urlencode:x<nowiki/>y|wiki}}
24322 {{urlencode:x<nowiki/>y|path}}
24323 {{urlencode:x<pre id="one">two</pre>y}}
24324 !! html/php
24325 <p>xy
24326 xy
24327 xy
24328 xy
24329 </p>
24330 !! end
24331
24332 !! test
24333 Strip marker in lc
24334 !! wikitext
24335 {{lc:x<nowiki/>y}}
24336 !! html
24337 <p>xy
24338 </p>
24339 !! end
24340
24341 !! test
24342 Strip marker in uc
24343 !! wikitext
24344 {{uc:x<nowiki/>y}}
24345 !! html
24346 <p>XY
24347 </p>
24348 !! end
24349
24350 !! test
24351 Strip marker in formatNum
24352 !! wikitext
24353 {{formatnum:1<nowiki/>2}}
24354 {{formatnum:1<nowiki/>2|R}}
24355 !! html
24356 <p>12
24357 12
24358 </p>
24359 !! end
24360
24361 !! test
24362 Check noCommafy in formatNum
24363 !! options
24364 language=be-tarask
24365 !! wikitext
24366 {{formatnum:123456.78}}
24367 {{formatnum:123456.78|NOSEP}}
24368 !! html
24369 <p>123 456,78
24370 123456.78
24371 </p>
24372 !! end
24373
24374 !! test
24375 Wrong option for formatNum (T58199)
24376 !! wikitext
24377 {{formatnum:1,234.56|Random}}
24378 {{formatnum:1,234.56|EVERYTHING}}
24379 {{formatnum:1234.56|any argument that has the string 'NOSEP'}}
24380 !! html
24381 <p>1,234.56
24382 1,234.56
24383 1,234.56
24384 </p>
24385 !! end
24386
24387 !! test
24388 Strip marker in grammar
24389 !! options
24390 language=fi
24391 !! wikitext
24392 {{grammar:elative|foo<nowiki/>bar}}
24393 !! html
24394 <p>foobarista
24395 </p>
24396 !! end
24397
24398 !! test
24399 Strip marker in padleft
24400 !! wikitext
24401 {{padleft:|2|x<nowiki/>y}}
24402 !! html
24403 <p>xy
24404 </p>
24405 !! end
24406
24407 !! test
24408 Strip marker in padright
24409 !! wikitext
24410 {{padright:|2|x<nowiki/>y}}
24411 !! html
24412 <p>xy
24413 </p>
24414 !! end
24415
24416 !! test
24417 Strip marker in anchorencode
24418 !! wikitext
24419 {{anchorencode:x<nowiki/>y}}
24420 !! html/php
24421 <p>xy
24422 </p>
24423 !! html/parsoid
24424 <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>
24425 !! end
24426
24427 !! test
24428 nowiki inside link inside heading (T20295)
24429 !! wikitext
24430 ==[[foo|x<nowiki>y</nowiki>z]]==
24431 !! html
24432 <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>
24433
24434 !! end
24435
24436 !! test
24437 new support for bdi element (T33817)
24438 !! wikitext
24439 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
24440 !! html
24441 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
24442
24443 !!end
24444
24445 !! test
24446 Ignore pipe between table row attributes
24447 !! wikitext
24448 {|
24449 | quux
24450 |- id=foo | style='color: red'
24451 | bar
24452 |}
24453 !! html
24454 <table>
24455 <tr>
24456 <td> quux
24457 </td></tr>
24458 <tr id="foo" style="color: red">
24459 <td> bar
24460 </td></tr></table>
24461
24462 !! end
24463
24464 !!test
24465 Language parser function
24466 !! wikitext
24467 {{#language:ar}}
24468 !! html
24469 <p>العربية
24470 </p>
24471 !! end
24472
24473 !!test
24474 Padleft and padright (default 0-padding)
24475 !! wikitext
24476 {{padleft:xyz|5}}
24477 {{padright:xyz|5}}
24478 !! html/php
24479 <p>00xyz
24480 xyz00
24481 </p>
24482 !! html/parsoid
24483 <p><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:xyz","function":"padleft"},"params":{"1":{"wt":"5"}},"i":0}}]}'>00xyz</span>
24484 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:xyz","function":"padright"},"params":{"1":{"wt":"5"}},"i":0}}]}'>xyz00</span></p>
24485 !! end
24486
24487 !!test
24488 Padleft and padright (partial fill)
24489 !! wikitext
24490 {{padleft:xyz|6|ab}}
24491 {{padright:xyz|6|ab}}
24492 !! html/php
24493 <p>abaxyz
24494 xyzaba
24495 </p>
24496 !! html/parsoid
24497 <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>
24498 <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>
24499 !! end
24500
24501 !!test
24502 Padleft and padright as substr
24503 !! wikitext
24504 {{padleft:|3|abcde}}
24505 {{padright:|3|abcde}}
24506 !! html/php
24507 <p>abc
24508 abc
24509 </p>
24510 !! html/parsoid
24511 <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>
24512 <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>
24513 !! end
24514
24515 !!test
24516 Special parser function
24517 !! wikitext
24518 {{#special:RandomPage}}
24519 {{#special:BaDtItLe}}
24520 {{#special:Foobar}}
24521 !! html
24522 <p>Special:Random
24523 Special:Badtitle
24524 Special:Foobar
24525 </p>
24526 !! end
24527
24528 !!test
24529 T36939 - Case insensitive link parsing ([HttP://])
24530 !! wikitext
24531 [HttP://MediaWiki.Org/]
24532 !! html/php
24533 <p><a rel="nofollow" class="external autonumber" href="HttP://MediaWiki.Org/">[1]</a>
24534 </p>
24535 !! html/parsoid
24536 <p><a rel="mw:ExtLink" class="external autonumber" href="HttP://MediaWiki.Org/"></a></p>
24537 !! end
24538
24539 !!test
24540 T36939 - Case insensitive link parsing ([HttP:// title])
24541 !! wikitext
24542 [HttP://MediaWiki.Org/ MediaWiki]
24543 !! html
24544 <p><a rel="nofollow" class="external text" href="HttP://MediaWiki.Org/">MediaWiki</a>
24545 </p>
24546 !! end
24547
24548 !!test
24549 T36939 - Case insensitive link parsing (HttP://)
24550 !! wikitext
24551 HttP://MediaWiki.Org/
24552 !! html/php
24553 <p><a rel="nofollow" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a>
24554 </p>
24555 !! html/parsoid
24556 <p><a rel="mw:ExtLink" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a></p>
24557 !! end
24558
24559 !!test
24560 Disable TOC
24561 !! options
24562 notoc
24563 !! wikitext
24564 Lead
24565 == Section 1 ==
24566 == Section 2 ==
24567 == Section 3 ==
24568 == Section 4 ==
24569 == Section 5 ==
24570 !! html
24571 <p>Lead
24572 </p>
24573
24574 <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>
24575 <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>
24576 <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>
24577 <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>
24578 <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>
24579
24580 !! end
24581
24582
24583 ###
24584 ### Parsoid-specific tests
24585 ### Parsoid-PHP parser incompatibilities
24586 ###
24587 !!test
24588 1. SOL-sensitive wikitext tokens as template-args
24589 !!options
24590 parsoid=wt2html,wt2wt
24591 !! wikitext
24592 {{echo|*a}}
24593 {{echo|#a}}
24594 {{echo|:a}}
24595 !! html
24596 <span about="#mwt1" typeof="mw:Transclusion">
24597 </span><ul about="#mwt1"><li>a</li>
24598 </ul>
24599 <span about="#mwt2" typeof="mw:Transclusion">
24600 </span><ol about="#mwt2"><li>a</li>
24601 </ol>
24602 <span about="#mwt3" typeof="mw:Transclusion">
24603 </span><dl about="#mwt3"><dd>a</dd>
24604 </dl>
24605 !!end
24606
24607 #### -----------------------------------------------------------------
24608 #### Parsoid-specific functionality tests
24609 #### -----------------------------------------------------------------
24610
24611 # T65642/T68749: Formatting elt fixup around images is cleaned up.
24612 # We know wt2wt will fail, but we expect selser to pass.
24613 # Due to the nature of our testing, wt2wt and selser tests will enter the
24614 # blacklist and we'll catch selser regressions based on changes to the
24615 # blacklist entries for selser tests.
24616 !! test
24617 1. Bad treebuilder fixup of formatting elt is cleaned up
24618 !! options
24619 parsoid=wt2html,wt2wt
24620 !! wikitext
24621 {|
24622 |
24623 <small>
24624 [[Image:Foobar.jpg|right|Test]]
24625 </small>
24626 |}
24627 !! html/parsoid
24628 <table>
24629 <tbody><tr><td>
24630 <small>
24631 <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>
24632 </small>
24633 </td></tr>
24634 </tbody></table>
24635 !! end
24636
24637 !! test
24638 2. Bad treebuilder fixup of formatting elt is cleaned up
24639 !! options
24640 parsoid=wt2html,wt2wt
24641 !! wikitext
24642 '''foo[[File:Foobar.jpg|thumb|caption]]bar'''
24643
24644 <small>[[Image:Foobar.jpg|right|300px]]</small>
24645 !! html/parsoid
24646
24647 <p><b>foo</b></p>
24648 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><b>caption</b></figcaption></figure>
24649 <p><b>bar</b></p>
24650 <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>
24651 !! end
24652
24653 !! test
24654 3. Bad treebuilder fixup of formatting elt is cleaned up
24655 !! options
24656 parsoid=wt2html,wt2wt
24657 !! wikitext
24658 <small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
24659 !! html/parsoid
24660 <p><small><b>foo</b></small></p>
24661 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><small><b>caption</b></small></figcaption></figure>
24662 <p><small><b>bar</b></small></p>
24663 !! end
24664
24665 !! test
24666 4. Bad treebuilder fixup of formatting elt is cleaned up: formatting tags around captionless images are ignored
24667 !! options
24668 parsoid=wt2html,wt2wt
24669 !! wikitext
24670 '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
24671 !! html/parsoid
24672 <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>
24673 !! end
24674
24675 #### ----------------------------------------------------------------
24676 #### Parsoid-only testing of Parsoid's impl of LST
24677 #### Not implemented yet, see
24678 #### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
24679 #### ----------------------------------------------------------------
24680
24681 ## We still need to support serializing the older format while content is stored.
24682 !! test
24683 LST Sections: Backwards compatibility
24684 !! options
24685 parsoid={
24686 "suppressErrors": true,
24687 "modes": ["html2wt"]
24688 }
24689 !! wikitext
24690 <section begin="2011-05-16" />
24691 <section end="2014-04-10 (MW 1.23wmf22)" />
24692 !! html/parsoid
24693 <p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/>
24694 <meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p>
24695 !! end
24696
24697 !! test
24698 LST Sections: Newfangled approach
24699 !! wikitext
24700 <section begin="2011-05-16" />
24701 <section end="2014-04-10 (MW 1.23wmf22)" />
24702 !! html/parsoid
24703 <p><span typeof="mw:Extension/section" about="#mwt4" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"},"body":null}'>
24704 </span>
24705 <span typeof="mw:Extension/section" about="#mwt6" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"},"body":null}'>
24706 </span></p>
24707 !! end
24708
24709 #--------- Test stripping of empty nodes in template content ----------
24710
24711 !! test
24712 Empty LI and TR nodes should be stripped from template content
24713 !! wikitext
24714 {{EmptyLITest}}
24715 {{EmptyTRTest}}
24716 !! html/parsoid
24717 <ul about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyLITest","href":"./Template:EmptyLITest"},"params":{},"i":0}}]}'>
24718 <li>a</li>
24719 <li>b</li>
24720 </ul>
24721 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRTest","href":"./Template:EmptyTRTest"},"params":{},"i":0}}]}'>
24722 <tbody>
24723 <tr>
24724 <td>foo</td>
24725 </tr>
24726 <tr>
24727 <td>bar</td>
24728 </tr>
24729 </tbody>
24730 </table>
24731 !! end
24732
24733 !! test
24734 Empty LI and TR nodes should not be stripped from top-level content
24735 !! wikitext
24736 * a
24737 *
24738 * b
24739 {|
24740 |-
24741 |-
24742 |foo
24743 |}
24744 !! html/parsoid
24745 <ul>
24746 <li> a</li>
24747 <li class='mw-empty-elt'></li>
24748 <li> b</li>
24749 </ul>
24750 <table>
24751 <tbody>
24752 <tr class='mw-empty-elt'></tr>
24753 <tr>
24754 <td>foo</td>
24755 </tr>
24756 </tbody>
24757 </table>
24758 !! end
24759
24760 !! test
24761 Empty TR nodes should not be stripped if they have any attributes set
24762 !! wikitext
24763 {{EmptyTRWithHTMLAttrTest}}
24764 !! html/parsoid
24765 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'>
24766 <tr align='center'></tr>
24767 <tr><td>foo</td></tr>
24768 <tr align='center'></tr>
24769 <tr><td>bar</td></tr>
24770 </table>
24771 !! end
24772
24773 #### ----------------------------------------------------------------
24774 #### The following section of tests are primarily to test
24775 #### wikitext escaping capabilities of Parsoid. Given that
24776 #### escaping can be done any number of ways, the wikitext (input)
24777 #### is always adjusted to reflect how Parsoid adds nowiki
24778 #### escape tags.
24779 ####
24780 #### We are marking several tests as parsoid-only since the
24781 #### HTML in the result section is different from what the
24782 #### PHP parser generates for it.
24783 #### ----------------------------------------------------------------
24784
24785
24786 #### --------------- Headings ---------------
24787 #### 0. Unnested
24788 #### 1. Nested inside html <h1>=foo=</h1>
24789 #### 2. Outside heading nest on a single line <h1>foo</h1>*bar
24790 #### 3. Nested inside html with wikitext split by html tags
24791 #### 4. No escape needed
24792 #### 5. Empty headings <h1></h1>
24793 #### 6. Heading chars in SOL context
24794 #### ----------------------------------------
24795 !! test
24796 Headings: 0. Unnested
24797 !! options
24798 parsoid=html2wt
24799 !! html/parsoid
24800 <p>=foo=</p>
24801
24802 <p> =foo=
24803 <!--cmt-->
24804 =foo=</p>
24805
24806 <p>=foo<i>a</i>=</p>
24807 !! wikitext
24808 <nowiki>=foo=</nowiki>
24809
24810 <nowiki> </nowiki>=foo=
24811 <!--cmt-->
24812 <nowiki>=foo=</nowiki>
24813
24814 =foo''a''<nowiki>=</nowiki>
24815 !!end
24816
24817 # New headings and existing headings are handled differently
24818 !! test
24819 Headings: 1. Nested inside html
24820 !! options
24821 parsoid=html2wt
24822 !! html/parsoid
24823 <h1>=foo=</h1>
24824 <h2>=foo=</h2>
24825 <h3>=foo=</h3>
24826
24827 <h1 data-parsoid=''>=foo=</h1>
24828 <h2 data-parsoid=''>=foo=</h2>
24829 <h3 data-parsoid=''>=foo=</h3>
24830 <h4 data-parsoid=''>=foo=</h4>
24831 <h5 data-parsoid=''>=foo=</h5>
24832 <h6 data-parsoid=''>=foo=</h6>
24833 !! wikitext
24834 = =foo= =
24835
24836 == =foo= ==
24837
24838 === =foo= ===
24839
24840 =<nowiki>=foo=</nowiki>=
24841 ==<nowiki>=foo=</nowiki>==
24842 ===<nowiki>=foo=</nowiki>===
24843 ====<nowiki>=foo=</nowiki>====
24844 =====<nowiki>=foo=</nowiki>=====
24845 ======<nowiki>=foo=</nowiki>======
24846
24847 !!end
24848
24849 !! test
24850 Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
24851 !! options
24852 parsoid=html2wt
24853 !! html/parsoid
24854 <h1>foo</h1>*bar
24855 <h1>foo</h1>=bar
24856 <h1>foo</h1>=bar=
24857 !! wikitext
24858 = foo =
24859 <nowiki>*</nowiki>bar
24860
24861 = foo =
24862 =bar
24863
24864 = foo =
24865 <nowiki>=bar=</nowiki>
24866 !!end
24867
24868 !! test
24869 Headings: 3. Nested inside html with wikitext split by html tags
24870 !! options
24871 parsoid=html2wt
24872 !! html/parsoid
24873 <h1>=<b>bold</b>foo=</h1>
24874 !! wikitext
24875 = ='''bold'''foo= =
24876 !!end
24877
24878 !! test
24879 Headings: 4a. No escaping needed (testing just h1 and h2)
24880 !! options
24881 parsoid=html2wt
24882 !! html/parsoid
24883 <h1>=foo</h1>
24884 <h1>foo=</h1>
24885 <h1> =foo= </h1>
24886 <h1>=foo= bar</h1>
24887 <h2>=foo</h2>
24888 <h2>foo=</h2>
24889 <h1>=</h1>
24890 <h1><i>=</i>foo=</h1>
24891 !! wikitext
24892 = =foo =
24893
24894 = foo= =
24895
24896 = =foo= =
24897
24898 = =foo= bar =
24899
24900 == =foo ==
24901
24902 == foo= ==
24903
24904 = = =
24905
24906 = ''=''foo= =
24907 !!end
24908
24909 !! test
24910 Headings: 4b. No escaping needed (inside p-tags)
24911 !! options
24912 parsoid=html2wt
24913 !! html/parsoid
24914 <p>=foo= x
24915 =foo= <s></s>
24916 </p>
24917 !! wikitext
24918 =foo= x
24919 =foo= <s></s>
24920 !! html/php
24921 <p>=foo= x
24922 =foo= <s></s>
24923 </p>
24924 !!end
24925
24926 !! test
24927 Headings: 4c. Short headings (1)
24928 !! options
24929 parsoid=html2wt
24930 !! html/parsoid
24931 <p>===
24932 </p>
24933 !! wikitext
24934 <nowiki>===</nowiki>
24935 !! html/php
24936 <p>===
24937 </p>
24938 !! end
24939
24940 # in the html2wt direction we emit '= = =' or '=<nowiki>=</nowiki>='
24941 !! test
24942 Headings: 4d. Short headings (2)
24943 !! options
24944 parsoid=wt2html,html2html
24945 !! wikitext
24946 =
24947 ==
24948 ===
24949 ====
24950 =====
24951 !! html/php
24952 <p>=
24953 ==
24954 </p>
24955 <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>
24956 <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>
24957 <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>
24958
24959 !! html/parsoid
24960 <p>=
24961 ==</p>
24962 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
24963 <h1 id="=="><span id=".3D.3D" typeof="mw:FallbackId"></span>==</h1>
24964 <h2 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h2>
24965 !! end
24966
24967 !! test
24968 Headings: 5. Empty headings
24969 !! options
24970 parsoid=html2wt
24971 !! html/parsoid
24972 <h1 data-parsoid='{}'></h1>
24973
24974 <h2 data-parsoid='{}'></h2>
24975
24976 <h3 data-parsoid='{}'></h3>
24977
24978 <h4 data-parsoid='{}'></h4>
24979
24980 <h5 data-parsoid='{}'></h5>
24981
24982 <h6 data-parsoid='{}'></h6>
24983 !! wikitext
24984 =<nowiki/>=
24985
24986 ==<nowiki/>==
24987
24988 ===<nowiki/>===
24989
24990 ====<nowiki/>====
24991
24992 =====<nowiki/>=====
24993
24994 ======<nowiki/>======
24995 !!end
24996
24997 !! test
24998 Headings: 6a. Heading chars in SOL context (with trailing spaces)
24999 !! options
25000 parsoid=html2wt
25001 !! html/parsoid
25002 <p>=a=</p>
25003
25004 <p>=a=</p>
25005
25006 <p>=a=</p>
25007 !! wikitext
25008 <nowiki>=a=</nowiki>
25009
25010 <nowiki>=a=</nowiki>
25011
25012 <nowiki>=a=</nowiki>
25013 !!end
25014
25015 !! test
25016 Headings: 6b. Heading chars in SOL context (with trailing newlines)
25017 !! options
25018 parsoid=html2wt
25019 !! html/parsoid
25020 <p>=a=
25021 b</p>
25022
25023 <p>=a=
25024 b</p>
25025
25026 <p>=a=
25027 b</p>
25028 !! wikitext
25029 <nowiki>=a=</nowiki>
25030 b
25031
25032 <nowiki>=a=</nowiki>
25033 b
25034
25035 <nowiki>=a=</nowiki>
25036 b
25037 !!end
25038
25039 !! test
25040 Headings: 6c. Heading chars in SOL context (leading newline break)
25041 !! options
25042 parsoid=html2wt
25043 !! html/parsoid
25044 <p>a
25045 =b=</p>
25046 !! wikitext
25047 a
25048 <nowiki>=b=</nowiki>
25049 !!end
25050
25051 !! test
25052 Headings: 6d. Heading chars in SOL context (with interspersed comments)
25053 !! options
25054 parsoid=html2wt
25055 !! html/parsoid
25056 <!--c0--><p>=a=</p>
25057
25058 <!--c1--><p>=a=</p> <!--c2--> <!--c3-->
25059 !! wikitext
25060 <!--c0--><nowiki>=a=</nowiki>
25061
25062 <!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3-->
25063 !!end
25064
25065 !! test
25066 Headings: 6d. Heading chars in SOL context (No escaping needed)
25067 !! options
25068 parsoid=html2wt
25069 !! html/parsoid
25070 =a=<div>b</div>
25071 !! wikitext
25072 =a=<div>b</div>
25073 !!end
25074
25075 !! test
25076 Headings: 7. Insert a newline between new content and headings
25077 !! options
25078 parsoid=html2wt
25079 !! html/parsoid
25080 <h2>NEW</h2>
25081 <p>new</p>
25082 <h2 data-parsoid='{}'>A</h2>
25083 <p data-parsoid='{}'>a</p>
25084 !! wikitext
25085 == NEW ==
25086 new
25087
25088 ==A==
25089 a
25090
25091 !! end
25092
25093 !! test
25094 Headings: Used as horizontal rule
25095 !! config
25096 wgFragmentMode=[ 'html5', 'legacy' ]
25097 !! options
25098 parsoid=wt2html
25099 !! wikitext
25100 ===============
25101 !! html/php
25102 <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>
25103
25104 !! html/parsoid
25105 <h6 id="==="><span id=".3D.3D.3D" typeof="mw:FallbackId"></span>===</h6>
25106 !! end
25107
25108 #### --------------- Lists ---------------
25109 #### 0. Outside nests (*foo, etc.)
25110 #### 1. Nested inside html <ul><li>*foo</li></ul>
25111 #### 2. Inside definition lists
25112 #### 3. Only bullets at start should be escaped
25113 #### 4. No escapes needed
25114 #### 5. No unnecessary escapes
25115 #### 6. Escape bullets in SOL position
25116 #### 7. Escape bullets in a multi-line context
25117 #### ----------------------------------------
25118
25119 !! test
25120 Lists: 0. Outside nests
25121 !! options
25122 parsoid=html2wt
25123 !! html/parsoid
25124 <p>*foo</p>
25125
25126 <p>#foo</p>
25127
25128 <p>;Foo:bar</p>
25129 !! wikitext
25130 <nowiki>*</nowiki>foo
25131
25132 <nowiki>#</nowiki>foo
25133
25134 <nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar
25135 !!end
25136
25137 ## Making these next 3 tests Parsoid-only since they are html2wt tests
25138 ## to test wikitext escaping, and insignificant whitespace diffs
25139 ## cause PHP parser tests to barf
25140 !! test
25141 Lists: 1. Nested inside html (No unnecessary escapes)
25142 !! options
25143 parsoid=html2wt
25144 !! html/parsoid
25145 <ul>
25146 <li>*foo</li>
25147 <li>#foo</li>
25148 <li>:foo</li>
25149 <li>;foo</li>
25150 <li data-parsoid='{}'>*foo</li>
25151 <li data-parsoid='{}'>#foo</li>
25152 <li data-parsoid='{}'>:foo</li>
25153 <li data-parsoid='{}'>;foo</li>
25154 </ul>
25155
25156 <ol>
25157 <li>*foo</li>
25158 <li>#foo</li>
25159 <li>:foo</li>
25160 <li>;foo</li>
25161 <li data-parsoid='{}'>*foo</li>
25162 <li data-parsoid='{}'>#foo</li>
25163 <li data-parsoid='{}'>:foo</li>
25164 <li data-parsoid='{}'>;foo</li>
25165 </ol>
25166 !! wikitext
25167 * *foo
25168 * #foo
25169 * :foo
25170 * ;foo
25171 *<nowiki>*foo</nowiki>
25172 *<nowiki>#foo</nowiki>
25173 *<nowiki>:foo</nowiki>
25174 *<nowiki>;foo</nowiki>
25175
25176 # *foo
25177 # #foo
25178 # :foo
25179 # ;foo
25180 #<nowiki>*foo</nowiki>
25181 #<nowiki>#foo</nowiki>
25182 #<nowiki>:foo</nowiki>
25183 #<nowiki>;foo</nowiki>
25184 !!end
25185
25186 !! test
25187 Lists: 2. Inside definition lists
25188 !! options
25189 parsoid=html2wt
25190 !! html/parsoid
25191 <dl><dt>;foo</dt></dl>
25192 <dl><dt>:foo</dt></dl>
25193 <dl><dt>:foo</dt>
25194 <dd>bar</dd></dl>
25195 <dl><dd>:foo</dd></dl>
25196 !! wikitext
25197 ; ;foo
25198
25199 ; <nowiki>:foo</nowiki>
25200
25201 ; <nowiki>:foo</nowiki>
25202 : bar
25203
25204 : :foo
25205 !!end
25206
25207 !! test
25208 Lists: 3. Only bullets at start of text in wikitext-generated HTML should be escaped
25209 !! options
25210 parsoid=html2wt
25211 !! html/parsoid
25212 <ul>
25213 <li>*foo*bar</li>
25214 <li data-parsoid='{}'>*foo<i>it</i>*bar</li>
25215 </ul>
25216 !! wikitext
25217 * *foo*bar
25218 *<nowiki>*foo</nowiki>''it''*bar
25219 !!end
25220
25221 !! test
25222 Lists: 4. No escapes needed
25223 !! options
25224 parsoid=html2wt
25225 !! html/parsoid
25226 <ul>
25227 <li>foo*bar
25228 </li>
25229 </ul>
25230 <ul>
25231 <li><i>foo</i>*bar
25232 </li>
25233 </ul>
25234 <ul>
25235 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>: bar
25236 </li>
25237 </ul>
25238 <ul>
25239 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar
25240 </li>
25241 </ul>
25242 !! wikitext
25243 *foo*bar
25244
25245 *''foo''*bar
25246
25247 *[[Foo]]: bar
25248
25249 *[[Foo]]*bar
25250 !!end
25251
25252 !! test
25253 Lists: 5. No unnecessary escapes
25254 !! options
25255 parsoid=html2wt
25256 !! html/parsoid
25257 <ul><li> bar <span>[[foo]]</span></li></ul>
25258 <ul><li> =bar <span>[[foo]]</span></li></ul>
25259 <ul><li> [[bar <span>[[foo]]</span></li></ul>
25260 <ul><li> ]]bar <span>[[foo]]</span></li></ul>
25261 <ul><li> =bar <span>foo]]</span>=</li></ul>
25262 <ul><li> <s></s>: a</li></ul>
25263 <ul><li> <i>* foo</i></li></ul>
25264
25265 !! wikitext
25266 * bar <span><nowiki>[[foo]]</nowiki></span>
25267
25268 * =bar <span><nowiki>[[foo]]</nowiki></span>
25269
25270 * [[bar <span><nowiki>[[foo]]</nowiki></span>
25271
25272 * ]]bar <span><nowiki>[[foo]]</nowiki></span>
25273
25274 * =bar <span>foo]]</span>=
25275
25276 * <s></s>: a
25277
25278 * ''* foo''
25279 !!end
25280
25281 !! test
25282 Lists: 6. Escape bullets in SOL position
25283 !! options
25284 parsoid=html2wt
25285 !! html/parsoid
25286 <p><!--cmt-->*foo</p>
25287 !! wikitext
25288 <!--cmt--><nowiki>*</nowiki>foo
25289 !!end
25290
25291 !! test
25292 Lists: 7. Escape bullets in a multi-line context
25293 !! options
25294 parsoid=html2wt
25295 !! html/parsoid
25296 <p>a
25297 *b
25298 </p>
25299 !! wikitext
25300 a
25301 <nowiki>*</nowiki>b
25302 !!end
25303
25304 !! test
25305 Lists: 8. Escape colons only if not present in tags
25306 !! options
25307 parsoid=html2wt
25308 !! html/parsoid
25309 <dl><dt>a:b<i>c:d</i></dt></dl>
25310 !! wikitext
25311 ; <nowiki>a:b</nowiki>''c:d''
25312 !! end
25313
25314 #### --------------- HRs ---------------
25315 #### 1. Single line
25316 #### -----------------------------------
25317
25318 !! test
25319 HRs: 1. Single line
25320 !! options
25321 parsoid=html2wt
25322 !! html/parsoid
25323 <hr />----
25324 <hr />=foo=
25325 <hr />*foo
25326 !! wikitext
25327 ----<nowiki>----</nowiki>
25328 ----=foo=
25329 ----*foo
25330 !! end
25331
25332 #### --------------- Tables ---------------
25333 #### 1a. Simple example
25334 #### 1b. No escaping needed (!foo)
25335 #### 1c. No escaping needed (|foo)
25336 #### 1d. No escaping needed (|}foo)
25337 ####
25338 #### 2a. Nested in td (<td>foo|bar</td>)
25339 #### 2b. Nested in td (<td>foo||bar</td>)
25340 #### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
25341 ####
25342 #### 3a. Nested in th (<th>foo!bar</th>)
25343 #### 3b. Nested in th (<th>foo!!bar</th>)
25344 #### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
25345 ####
25346 #### 4a. Escape -
25347 #### 4b. Escape +
25348 #### 4c. No escaping needed
25349 #### --------------------------------------
25350
25351 !! test
25352 Tables: 1a. Simple example
25353 !! options
25354 parsoid=html2wt
25355 !! html/parsoid
25356 <p>{|
25357 |}
25358 </p>
25359 !! wikitext
25360 <nowiki>{|</nowiki>
25361 |}
25362 !! end
25363
25364 !! test
25365 Tables: 1b. No escaping needed
25366 !! options
25367 parsoid=html2wt
25368 !! html/parsoid
25369 <p>!foo
25370 </p>
25371 !! wikitext
25372 !foo
25373 !! end
25374
25375 !! test
25376 Tables: 1c. No escaping needed
25377 !! options
25378 parsoid=html2wt
25379 !! html/parsoid
25380 <p>|foo
25381 </p>
25382 !! wikitext
25383 |foo
25384 !! end
25385
25386 !! test
25387 Tables: 1d. No escaping needed
25388 !! options
25389 parsoid=html2wt
25390 !! html/parsoid
25391 <p>|}foo
25392 </p>
25393 !! wikitext
25394 |}foo
25395 !! end
25396
25397 !! test
25398 Tables: 2a. Nested in td
25399 !! options
25400 parsoid=html2wt
25401 !! html/parsoid
25402 <table><tbody><tr>
25403 <td>foo|bar</td></tr>
25404 <tr><td>x<div>a|b</div></td>
25405 </tbody></table>
25406 !! wikitext
25407 {|
25408 |<nowiki>foo|bar</nowiki>
25409 |-
25410 |x<div><nowiki>a|b</nowiki></div>
25411 |}
25412 !! html/php+tidy
25413 <table>
25414 <tbody><tr>
25415 <td>foo|bar
25416 </td></tr>
25417 <tr>
25418 <td>x<div>a|b</div>
25419 </td></tr></tbody></table>
25420 !! end
25421
25422 !! test
25423 Tables: 2b. Nested in td
25424 !! options
25425 parsoid=html2wt
25426 !! html/parsoid
25427 <table><tbody><tr>
25428 <td>foo||bar</td>
25429 <td>a<i>b||c</i></td>
25430 <td>a<i><div>b||c</div></i></td>
25431 </tr></tbody></table>
25432 !! wikitext
25433 {|
25434 |<nowiki>foo||bar</nowiki>
25435 |a''<nowiki>b||c</nowiki>''
25436 |a''<div><nowiki>b||c</nowiki></div>''
25437 |}
25438 !! html/php
25439 <table>
25440 <tr>
25441 <td>foo||bar
25442 </td>
25443 <td>a<i>b||c</i>
25444 </td>
25445 <td>a<i><div>b||c</div></i>
25446 </td></tr></table>
25447
25448 !! end
25449
25450 !! test
25451 Tables: 2c. Nested in td -- no escaping needed
25452 !! options
25453 parsoid=html2wt
25454 !! html/*
25455 <table>
25456 <tr>
25457 <td>foo!!bar
25458 </td></tr></table>
25459
25460 !! wikitext
25461 {|
25462 |foo!!bar
25463 |}
25464 !! end
25465
25466 !! test
25467 Tables: 3a. Nested in th
25468 !! options
25469 parsoid=html2wt
25470 !! html/*
25471 <table>
25472 <tr>
25473 <th>foo!bar
25474 </th></tr></table>
25475
25476 !! wikitext
25477 {|
25478 !foo!bar
25479 |}
25480 !! end
25481
25482 !! test
25483 Tables: 3b. Nested in th
25484 !! options
25485 parsoid=html2wt
25486 !! html/parsoid
25487 <table><tbody>
25488 <tr><th>foo!!bar</th>
25489 <th><i>foo|bar</i></th>
25490 <th><i>foo!!bar</i></th>
25491 <th><i><span>foo!!bar</span></i></th>
25492 </tr></tbody></table>
25493 !! wikitext
25494 {|
25495 !<nowiki>foo!!bar</nowiki>
25496 !''<nowiki>foo|bar</nowiki>''
25497 !''<nowiki>foo!!bar</nowiki>''
25498 !''<span><nowiki>foo!!bar</nowiki></span>''
25499 |}
25500 !! html/php
25501 <table>
25502 <tr>
25503 <th>foo!!bar
25504 </th>
25505 <th><i>foo|bar</i>
25506 </th>
25507 <th><i>foo!!bar</i>
25508 </th>
25509 <th><i><span>foo!!bar</span></i>
25510 </th></tr></table>
25511
25512 !! end
25513
25514 !! test
25515 Tables: 3c. Nested in th
25516 !! options
25517 parsoid=html2wt
25518 !! html/parsoid
25519 <table><tbody>
25520 <tr><th>foo||bar</th>
25521 <th><span typeof="mw:Nowiki">foo||bar</span></th>
25522 </tr></tbody></table>
25523 !! wikitext
25524 {|
25525 !<nowiki>foo||bar</nowiki>
25526 !<nowiki>foo||bar</nowiki>
25527 |}
25528 !! html/php
25529 <table>
25530 <tr>
25531 <th>foo||bar
25532 </th>
25533 <th>foo||bar
25534 </th></tr></table>
25535
25536 !! end
25537
25538 !! test
25539 Tables: 4a. Escape -
25540 !! options
25541 parsoid=html2wt
25542 !! html/*
25543 <table>
25544 <tr>
25545 <th>-bar
25546 </th></tr>
25547 <tr>
25548 <td>-bar
25549 </td></tr></table>
25550
25551 !! wikitext
25552 {|
25553 !-bar
25554 |-
25555 |<nowiki>-bar</nowiki>
25556 |}
25557 !! end
25558
25559 !! test
25560 Tables: 4b. Escape +
25561 !! options
25562 parsoid=html2wt
25563 !! html/*
25564 <table>
25565 <tr>
25566 <th>+bar
25567 </th></tr>
25568 <tr>
25569 <td>+bar
25570 </td></tr></table>
25571
25572 !! wikitext
25573 {|
25574 !+bar
25575 |-
25576 |<nowiki>+bar</nowiki>
25577 |}
25578 !! end
25579
25580 !! test
25581 Tables: 4c. No escaping needed
25582 !! options
25583 parsoid=html2wt
25584 !! html/parsoid
25585 <table><tbody>
25586 <tr><td>foo-bar</td><td>foo+bar</td></tr>
25587 <tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
25588 <tr><td>foo
25589 <p>bar|baz
25590 +bar
25591 -bar</p></td></tr>
25592 <tr><td>x
25593 <div>a|b</div></td>
25594 </tbody></table>
25595 !! wikitext
25596 {|
25597 |foo-bar
25598 |foo+bar
25599 |-
25600 |''foo''-bar
25601 |''foo''+bar
25602 |-
25603 |foo
25604 bar|baz
25605 +bar
25606 -bar
25607 |-
25608 |x
25609 <div>a|b</div>
25610 |}
25611 !! html/php
25612 <table>
25613 <tr>
25614 <td>foo-bar
25615 </td>
25616 <td>foo+bar
25617 </td></tr>
25618 <tr>
25619 <td><i>foo</i>-bar
25620 </td>
25621 <td><i>foo</i>+bar
25622 </td></tr>
25623 <tr>
25624 <td>foo
25625 <p>bar|baz
25626 +bar
25627 -bar
25628 </p>
25629 </td></tr>
25630 <tr>
25631 <td>x
25632 <div>a|b</div>
25633 </td></tr></table>
25634
25635 !! end
25636
25637 !! test
25638 Tables: 4d. No escaping needed
25639 !! options
25640 parsoid=html2wt
25641 !! html/parsoid
25642 <table>
25643 <tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
25644 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
25645 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
25646 </tbody></table>
25647 !! wikitext
25648 {|
25649 |[[Foo]]-bar
25650 ||+1
25651 ||-2
25652 |}
25653 !! html/php
25654 <table>
25655 <tr>
25656 <td><a href="/wiki/Foo" title="Foo">Foo</a>-bar
25657 </td>
25658 <td>+1
25659 </td>
25660 <td>-2
25661 </td></tr></table>
25662
25663 !! end
25664
25665 !! test
25666 T97430: Don't emit empty nowiki pairs around marker meta tags
25667 !! options
25668 parsoid=html2wt
25669 !! html/parsoid
25670 <p>*This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
25671 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
25672 !! wikitext
25673 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
25674 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
25675 !! end
25676
25677 !! test
25678 Unclosed xmlish element in table line shouldn't eat end delimiters
25679 !! options
25680 parsoid=html2wt
25681 !! html/parsoid
25682 <table>
25683 <tbody><tr><td> &lt;foo</td>
25684 <td> bar></td></tr>
25685 </tbody></table>
25686 !! wikitext
25687 {|
25688 | <foo
25689 | bar>
25690 |}
25691 !! html/php
25692 <table>
25693 <tr>
25694 <td> &lt;foo
25695 </td>
25696 <td> bar&gt;
25697 </td></tr></table>
25698
25699 !! end
25700
25701 #### --------------- Links ----------------
25702 #### 1. Quote marks in link text
25703 #### 2. Wikilinks: Escapes needed
25704 #### 3. Wikilinks: No escapes needed
25705 #### 4. Extlinks: Escapes needed
25706 #### 5. Extlinks: No escapes needed
25707 #### --------------------------------------
25708 !! test
25709 Links 1. WikiLinks: No escapes needed
25710 !! options
25711 parsoid=html2wt
25712 !! html/parsoid
25713 <p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
25714 <a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
25715 <a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
25716 !! wikitext
25717 [[Foo|Foo''boo'']]
25718 [[Foo|[Foobar]]]
25719 [[Foo|x [Foobar] x]]
25720 !! html/php
25721 <p><a href="/wiki/Foo" title="Foo">Foo<i>boo</i></a>
25722 <a href="/wiki/Foo" title="Foo">[Foobar]</a>
25723 <a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
25724 </p>
25725 !! end
25726
25727 !! test
25728 Links 2. WikiLinks: Escapes needed
25729 !! options
25730 parsoid=html2wt
25731 !! html/parsoid
25732 <a href="Foo" rel="mw:WikiLink">Foobar]</a>
25733 <a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
25734 <a href="Foo" rel="mw:WikiLink">[[Bar]]</a>
25735 <a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a>
25736 <a href="Foo" rel="mw:WikiLink">|Bar</a>
25737 <a href="Foo" rel="mw:WikiLink">]]bar</a>
25738 <a href="Foo" rel="mw:WikiLink">[[bar</a>
25739 <a href="Foo" rel="mw:WikiLink">x [[ y</a>
25740 <a href="Foo" rel="mw:WikiLink">x ]] y</a>
25741 <a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a>
25742 !! wikitext
25743 [[Foo|<nowiki>Foobar]</nowiki>]]
25744 [[Foo|x <nowiki>[http://google.com g]</nowiki> x]]
25745 [[Foo|<nowiki>[[Bar]]</nowiki>]]
25746 [[Foo|<nowiki>x [[Bar]] x</nowiki>]]
25747 [[Foo|<nowiki>|Bar</nowiki>]]
25748 [[Foo|<nowiki>]]bar</nowiki>]]
25749 [[Foo|<nowiki>[[bar</nowiki>]]
25750 [[Foo|<nowiki>x [[ y</nowiki>]]
25751 [[Foo|<nowiki>x ]] y</nowiki>]]
25752 [[Foo|<nowiki>x ]] y [[ z</nowiki>]]
25753 !! html/php
25754 <p><a href="/wiki/Foo" title="Foo">Foobar]</a>
25755 <a href="/wiki/Foo" title="Foo">x [http://google.com g] x</a>
25756 <a href="/wiki/Foo" title="Foo">[[Bar]]</a>
25757 <a href="/wiki/Foo" title="Foo">x [[Bar]] x</a>
25758 <a href="/wiki/Foo" title="Foo">|Bar</a>
25759 <a href="/wiki/Foo" title="Foo">]]bar</a>
25760 <a href="/wiki/Foo" title="Foo">[[bar</a>
25761 <a href="/wiki/Foo" title="Foo">x [[ y</a>
25762 <a href="/wiki/Foo" title="Foo">x ]] y</a>
25763 <a href="/wiki/Foo" title="Foo">x ]] y [[ z</a>
25764 </p>
25765 !! end
25766
25767 !! test
25768 Links 3. WikiLinks: No escapes needed
25769 !! options
25770 parsoid=html2wt
25771 !! html/parsoid
25772 <p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
25773 <a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
25774 !! wikitext
25775 [[Foo|[Foobar]]
25776 [[Foo|foo|bar]]
25777 !! html/php
25778 <p><a href="/wiki/Foo" title="Foo">[Foobar</a>
25779 <a href="/wiki/Foo" title="Foo">foo|bar</a>
25780 </p>
25781 !! end
25782
25783 !! test
25784 Links 4. ExtLinks: Escapes needed
25785 !! options
25786 parsoid=html2wt
25787 !! html/parsoid
25788 <p><a rel="mw:ExtLink" href="http://google.com">[google]</a>
25789 <a rel="mw:ExtLink" href="http://google.com">google]</a>
25790 <a rel="mw:ExtLink" href="http://google.com">goog] le</a></p>
25791 <p>[http://google.com]</p>
25792 <p>[http://google.com google]</p>
25793 <p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p>
25794 <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>
25795 !! wikitext
25796 [http://google.com <nowiki>[google]</nowiki>]
25797 [http://google.com <nowiki>google]</nowiki>]
25798 [http://google.com <nowiki>goog] le</nowiki>]
25799
25800 <nowiki>[http://google.com]</nowiki>
25801
25802 <nowiki>[http://google.com google]</nowiki>
25803
25804 [http://google.com<nowiki>]</nowiki>
25805
25806 [{{echo|http://google.com}}<nowiki>]</nowiki>
25807 !! html/php
25808 <p><a rel="nofollow" class="external text" href="http://google.com">[google]</a>
25809 <a rel="nofollow" class="external text" href="http://google.com">google]</a>
25810 <a rel="nofollow" class="external text" href="http://google.com">goog] le</a>
25811 </p><p>[http://google.com]
25812 </p><p>[http://google.com google]
25813 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
25814 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
25815 </p>
25816 !! end
25817
25818 !! test
25819 Links 5. ExtLinks: No escapes needed
25820 !! options
25821 parsoid=html2wt
25822 !! html/parsoid
25823 <p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
25824 <p>[<a ref="mw:ExtLink" href="http://google.com"></a>]</p>
25825 !! wikitext
25826 [http://google.com [google]
25827
25828 [[http://google.com]]
25829 !! html/php
25830 <p><a rel="nofollow" class="external text" href="http://google.com">[google</a>
25831 </p><p>[<a rel="nofollow" class="external autonumber" href="http://google.com">[1]</a>]
25832 </p>
25833 !! end
25834
25835 !! test
25836 Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300)
25837 !! options
25838 parsoid=html2wt
25839 !! html/parsoid
25840 <p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y
25841 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>?x
25842 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>&amp;x
25843 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>'x
25844 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,x
25845 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.x
25846 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
25847 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>:x
25848 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
25849 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>!x
25850 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>=x
25851 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>(x)
25852 <a rel="mw:ExtLink" href="http://example.com(x" data-parsoid='{"stx":"url"}'>http://example.com(x</a>)
25853 </p>
25854 !! wikitext
25855 x<nowiki/>http://example.com<nowiki/>y
25856 http://example.com<nowiki/>?x
25857 http://example.com<nowiki/>&x
25858 http://example.com<nowiki/>'x
25859 http://example.com<nowiki/>,x
25860 http://example.com<nowiki/>.x
25861 http://example.com<nowiki/>;x
25862 http://example.com<nowiki/>:x
25863 http://example.com<nowiki/>;x
25864 http://example.com<nowiki/>!x
25865 http://example.com<nowiki/>=x
25866 http://example.com<nowiki/>(x)
25867 http://example.com(x<nowiki/>)
25868 !! end
25869
25870 !! test
25871 Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
25872 !! options
25873 parsoid=html2wt
25874 !! html/parsoid
25875 <p>x
25876 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>
25877 y
25878 "<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>"
25879 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>)
25880 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>) foo
25881 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,
25882 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, foo
25883 </p>
25884 !! wikitext
25885 x
25886 http://example.com
25887 y
25888 "http://example.com"
25889 (http://example.com)
25890 (http://example.com) foo
25891 http://example.com,
25892 http://example.com, foo
25893 !! html/php
25894 <p>x
25895 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
25896 y
25897 "<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>"
25898 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
25899 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) foo
25900 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
25901 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, foo
25902 </p>
25903 !! end
25904
25905 !! test
25906 Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
25907 !! options
25908 parsoid=html2wt
25909 !! html/parsoid
25910 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\
25911 -<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p>
25912 !! wikitext
25913 http://example.com.,;:!?\
25914 -http://example.com:
25915 !! html/php
25916 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.,;:!?\
25917 -<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
25918 </p>
25919 !! end
25920
25921 !! test
25922 Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
25923 !! options
25924 parsoid=html2wt
25925 !! html/parsoid
25926 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
25927 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
25928 X<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
25929 !! wikitext
25930 RFC 123<nowiki/>4
25931 RFC 123<nowiki/>y
25932 X<nowiki/>RFC 123<nowiki/>y
25933 !! end
25934
25935 !! test
25936 Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
25937 !! options
25938 parsoid=html2wt
25939 !! html/parsoid
25940 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
25941 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
25942 -<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
25943 </p>
25944 !! wikitext
25945 RFC 123?foo
25946 RFC 123&foo
25947 -RFC 123-
25948 !! html/php
25949 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>?foo
25950 <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
25951 -<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>-
25952 </p>
25953 !! end
25954
25955 !! test
25956 Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300)
25957 !! options
25958 parsoid=html2wt
25959 !! html/parsoid
25960 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4
25961 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
25962 X<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
25963 !! wikitext
25964 PMID 123<nowiki/>4
25965 PMID 123<nowiki/>y
25966 X<nowiki/>PMID 123<nowiki/>y
25967 !! end
25968
25969 !! test
25970 Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300)
25971 !! options
25972 parsoid=html2wt
25973 !! html/parsoid
25974 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo
25975 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo
25976 -<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>-
25977 </p>
25978 !! wikitext
25979 PMID 123?foo
25980 PMID 123&foo
25981 -PMID 123-
25982 !! html/php
25983 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>?foo
25984 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>&amp;foo
25985 -<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>-
25986 </p>
25987 !! end
25988
25989 !! test
25990 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300)
25991 !! options
25992 parsoid=html2wt
25993 !! html/parsoid
25994 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
25995 <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
25996 a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
25997 </p>
25998 !! wikitext
25999 ISBN 1234567890<nowiki/>1
26000 ISBN 1234567890<nowiki/>x
26001 a<nowiki/>ISBN 1234567890<nowiki/>b
26002 !! end
26003
26004 !! test
26005 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (T66300)
26006 !! options
26007 parsoid=html2wt
26008 !! html/parsoid
26009 <p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
26010 !! wikitext
26011 -ISBN 1234567890's
26012 !! html/php
26013 <p>-<a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>'s
26014 </p>
26015 !! end
26016
26017 !! test
26018 Links 14. Protect link-like plain text. (Parsoid bug T78425)
26019 !! options
26020 parsoid=html2wt
26021 !! html/*
26022 <p>this is not a link: http://example.com
26023 </p>
26024 !! wikitext
26025 this is not a link: <nowiki>http://example.com</nowiki>
26026 !! end
26027
26028 !! test
26029 Links 15. Link trails can't become link prefixes.
26030 !! options
26031 language=is
26032 parsoid=html2wt
26033 !! html/parsoid
26034 <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>
26035 !! wikitext
26036 [[Söfnuður]]-[[00]]
26037 !! html/php
26038 <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>
26039 </p>
26040 !! end
26041
26042 #### --------------- Quotes ---------------
26043 #### 1. Quotes inside <b> and <i>
26044 #### 2. Link fragments separated by <i> and <b> tags
26045 #### 3. Link fragments inside <i> and <b>
26046 #### 4. No escaping needed
26047 #### --------------------------------------
26048 !! test
26049 1a. Quotes inside <b> and <i>
26050 !! options
26051 parsoid=html2wt
26052 !! html/*
26053 <p><i>'foo'</i>
26054 <i>''foo''</i>
26055 <i>'''foo'''</i>
26056 <i>foo</i>'s
26057 <b>'foo'</b>
26058 <b>''foo''</b>
26059 <b>'''foo'''</b>
26060 <b>foo'<i>bar'</i>baz</b>
26061 <b>foo</b>'s
26062 '<i>foo</i>
26063 <i>foo</i>'
26064 <i>foo'</i>'
26065 '<i>foo</i>'
26066 '<b>foo</b>
26067 <b>foo</b>'
26068 '<b>foo</b>'
26069 <i>fools'<span> errand</span></i>
26070 <i><span>fool</span>'s errand</i>
26071 '<i>foo</i> bar '<i>baz</i>
26072 a|!*#-:;+-~[]{}b'<i>x</i>
26073 </p>
26074 !! wikitext
26075 ''<nowiki/>'foo'''
26076 ''<nowiki>''foo''</nowiki>''
26077 ''<nowiki>'''foo'''</nowiki>''
26078 ''foo''<nowiki/>'s
26079 '''<nowiki/>'foo''''
26080 '''<nowiki>''foo''</nowiki>'''
26081 '''<nowiki>'''foo'''</nowiki>'''
26082 '''foo'<nowiki/>''bar'<nowiki/>''baz'''
26083 '''foo'''<nowiki/>'s
26084 '''foo''
26085 ''foo''<nowiki/>'
26086 ''foo'''<nowiki/>'
26087 '''foo''<nowiki/>'
26088 ''''foo'''
26089 '''foo'''<nowiki/>'
26090 ''''foo'''<nowiki/>'
26091 ''fools'<span> errand</span>''
26092 ''<span>fool</span>'s errand''
26093 '<nowiki/>''foo'' bar '''baz''
26094 a|!*#-:;+-~[]{}b'''x''
26095 !! end
26096
26097 !! test
26098 1b. Quotes inside <b> and <i> with other tags on same line
26099 !! options
26100 parsoid=html2wt
26101 !! html/parsoid
26102 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
26103 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
26104 <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>
26105 <a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" rel="mw:WikiLink" title="Bar">bar</a></i>
26106 '<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>
26107 '<i>foo</i> <div title="name">test</div>
26108 '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
26109 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
26110 <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>
26111 </ol>
26112 !! wikitext
26113 '''a'' foo ''[[bar]]''
26114 ''a''' foo ''[[bar]]''
26115 ''a''' foo '''{{echo|[[bar]]}}'''
26116 [[foo]] x'''[[bar]]''
26117 '''foo'' <ref>test</ref>
26118 '''foo'' <div title="name">test</div>
26119 '''foo'' and <br> bar
26120 <references />
26121 !! end
26122
26123 !! test
26124 2. Link fragments separated by <i> and <b> tags
26125 !! options
26126 parsoid=html2wt
26127 !! html/parsoid
26128 <p>[[<i>foo</i>hello]]</p>
26129 <p>[[<b>foo</b>hello]]</p>
26130 !! wikitext
26131 [[''foo''<nowiki>hello]]</nowiki>
26132
26133 [['''foo'''<nowiki>hello]]</nowiki>
26134 !! end
26135
26136 # FIXME: Escaping one or both of [[ and ]] is also acceptable --
26137 # this is one of the shortcomings of this format
26138 !! test
26139 3. Link fragments inside <i> and <b>
26140 !! options
26141 parsoid=html2wt
26142 !! html/parsoid
26143 <p><i>[[foo</i>]]</p>
26144 <p><b>[[foo</b>]]</p>
26145 !! wikitext
26146 ''[[foo''<nowiki>]]</nowiki>
26147
26148 '''[[foo'''<nowiki>]]</nowiki>
26149 !! end
26150
26151 !! test
26152 4. No escaping needed
26153 !! options
26154 parsoid=html2wt
26155 !! html/parsoid
26156 <p>'<span><i>bar</i></span>'
26157 '<span><b>bar</b></span>'
26158 'a:b'foo
26159 </p>
26160 !! wikitext
26161 '<span>''bar''</span>'
26162 '<span>'''bar'''</span>'
26163 'a:b'foo
26164 !! end
26165
26166 #### ----------- Paragraphs ---------------
26167 #### 1. No unnecessary escapes
26168 #### --------------------------------------
26169
26170 !! test
26171 1. No unnecessary escapes
26172 !! options
26173 parsoid=html2wt
26174 !! html/parsoid
26175 <p>bar <span>[[foo]]</span>
26176 </p><p>=bar <span>[[foo]]</span>
26177 </p><p>[[bar <span>[[foo]]</span>
26178 </p><p>]]bar <span>[[foo]]</span>
26179 </p><p>=bar <span>foo]]</span>=
26180 </p>
26181 !! wikitext
26182 bar <span><nowiki>[[foo]]</nowiki></span>
26183
26184 =bar <span><nowiki>[[foo]]</nowiki></span>
26185
26186 [[bar <span><nowiki>[[foo]]</nowiki></span>
26187
26188 ]]bar <span><nowiki>[[foo]]</nowiki></span>
26189
26190 =bar <span>foo]]</span><nowiki>=</nowiki>
26191 !!end
26192
26193 #### ----------------------- PRE --------------------------
26194 #### 1. Leading whitespace in SOL context should be escaped
26195 #### ------------------------------------------------------
26196 !! test
26197 1. Leading whitespace in SOL context should be escaped
26198 !! options
26199 parsoid=html2wt
26200 !! html/parsoid
26201 <p> a</p>
26202
26203 <p> a</p>
26204
26205 <p> a(tab)</p>
26206
26207 <p> a
26208 <!--cmt-->
26209 a</p>
26210
26211 <p>a
26212 b</p>
26213
26214 <p>a
26215 b</p>
26216
26217 <p>a
26218 b</p>
26219 !! wikitext
26220 <nowiki> </nowiki>a
26221
26222 <nowiki> </nowiki> a
26223
26224 a(tab)
26225
26226 <nowiki> </nowiki> a
26227 <!--cmt-->
26228 <nowiki> </nowiki>a
26229
26230 a
26231 <nowiki> </nowiki>b
26232
26233 a
26234 b
26235
26236 a
26237 b
26238 !! html/php
26239 <p> a
26240 </p><p> a
26241 </p><p> a(tab)
26242 </p><p> a
26243 a
26244 </p><p>a
26245 b
26246 </p><p>a
26247 b
26248 </p><p>a
26249 b
26250 </p>
26251 !! end
26252
26253 !! test
26254 2. Leading whitespace in non-indent-pre contexts should not be escaped
26255 !! options
26256 parsoid=html2wt
26257 !! html/parsoid
26258 <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>
26259 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
26260 <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>
26261 b</span></li>
26262 </ol>
26263 !! wikitext
26264 foo <ref>''a''
26265 b</ref>
26266 <references />
26267 !! end
26268
26269 !! test
26270 3. Leading whitespace in indent-pre suppressing contexts should not be escaped
26271 !! options
26272 parsoid=html2wt
26273 !! html/parsoid
26274 <blockquote>
26275 <p>
26276 a
26277 <span>b</span>
26278 c</p>
26279 </blockquote>
26280 !! wikitext
26281 <blockquote>
26282 a
26283 <span>b</span>
26284 c
26285 </blockquote>
26286 !! end
26287
26288 !! test
26289 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
26290 !! options
26291 parsoid=html2wt
26292 !! html/parsoid
26293 <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>
26294 !! wikitext
26295 [[File:Foobar.jpg|thumb|caption]]
26296 !! end
26297
26298 !! test
26299 5. Nowiki escaping should account for indent-pres
26300 !! options
26301 parsoid=html2wt
26302 !! html/parsoid
26303 <pre>==foo==</pre>
26304 !! wikitext
26305 ==foo==
26306 !! end
26307
26308 !!test
26309 T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
26310 !! options
26311 parsoid=html2wt
26312 !! html/parsoid
26313 <pre>
26314 * foo
26315 * bar
26316 </pre>
26317 !! wikitext
26318 * foo
26319 * bar
26320 !! end
26321
26322 #### --------------- Behavior Switches --------------------
26323
26324 !! test
26325 1. Valid behavior switches should be escaped
26326 !! options
26327 parsoid=html2wt
26328 !! html/parsoid
26329 __TOC__
26330 <i>__TOC__</i>
26331 !! wikitext
26332 <nowiki>__TOC__</nowiki>
26333 ''<nowiki>__TOC__</nowiki>''
26334 !! end
26335
26336 !! test
26337 2. Invalid behavior switches should not be escaped
26338 !! options
26339 parsoid=html2wt
26340 !! html/parsoid
26341 __TOO__
26342 __|__
26343 !! wikitext
26344 __TOO__
26345 __|__
26346 !! end
26347
26348 # We use indent-pre as an indirect way to test for sol-transparent behavior.
26349 !! test
26350 Behavior switches should be SOL-transparent
26351 !! options
26352 parsoid=html2wt
26353 !! html/parsoid
26354 <meta property="mw:PageProp/toc" />
26355
26356 <!-- this one's bogus -->
26357 <pre>__TOO__</pre>
26358
26359 <pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre>
26360
26361 <meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre>
26362 !! wikitext
26363 __TOC__
26364
26365 <!-- this one's bogus -->
26366 __TOO__
26367
26368 __TOC__ foo
26369
26370 __TOC__
26371 bar
26372 !! end
26373
26374 #### --------------- HTML tags ---------------
26375 #### 1. a tags
26376 #### 2. other tags
26377 #### 3. multi-line html tag
26378 #### 4. extension tags
26379 #### -----------------------------------------
26380 !! test
26381 1. a tags
26382 !! options
26383 parsoid=html2wt
26384 !! html/parsoid
26385 &lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
26386 !! wikitext
26387 <a href="http://google.com">google</a>
26388 !! end
26389
26390 !! test
26391 2. other tags
26392 !! options
26393 parsoid=html2wt
26394 !! html/parsoid
26395 <ul><li> &lt;div&gt;foo&lt;/div&gt;</li>
26396 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
26397 <li> &lt;td&gt;</li></ul>
26398
26399 !! wikitext
26400 * <nowiki><div>foo</div></nowiki>
26401 * <nowiki><div style="color:red">foo</div></nowiki>
26402 * <nowiki><td></nowiki>
26403 !! end
26404
26405 !! test
26406 3. multi-line html tag
26407 !! options
26408 parsoid=html2wt
26409 !! html/parsoid
26410 <p>&lt;div
26411 &gt;foo&lt;/div
26412 &gt;
26413 </p>
26414 !! wikitext
26415 <nowiki><div
26416 >foo</div
26417 ></nowiki>
26418 !! end
26419
26420 !! test
26421 4. extension tags
26422 !! options
26423 parsoid=html2wt
26424 !! html/parsoid
26425 <p>&lt;ref&gt;foo&lt;/ref&gt;
26426 </p><p>&lt;ref&gt;bar
26427 </p><p>baz&lt;/ref&gt;
26428 </p>
26429 !! wikitext
26430 <nowiki><ref>foo</ref></nowiki>
26431
26432 <nowiki><ref>bar</nowiki>
26433
26434 baz<nowiki></ref></nowiki>
26435 !! end
26436
26437 #### --------------- Others ---------------
26438 !! test
26439 Escaping nowikis
26440 !! options
26441 parsoid=html2wt
26442 !! html/parsoid
26443 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
26444 </p>
26445 !! wikitext
26446 &lt;nowiki&gt;foo&lt;/nowiki&gt;
26447 !! end
26448
26449 ## The quote-char in the input is necessary for triggering the bug
26450 !! test
26451 (T54035) Nowiki-escaping should not get tripped by " :" in text
26452 !! options
26453 parsoid=html2wt
26454 !! html/parsoid
26455 <p>foo's bar :</p>
26456 !! wikitext
26457 foo's bar :
26458 !! end
26459
26460 #----------- End of wikitext escaping tests --------------
26461
26462 !! test
26463
26464 Tag-like HTML structures are passed through as text
26465 !! wikitext
26466 <x y>
26467
26468 <x.y>
26469
26470 <x-y>
26471
26472 1>2
26473
26474 x<y
26475
26476 a>b
26477
26478 1<d e>f
26479 !! html
26480 <p>&lt;x y&gt;
26481 </p><p>&lt;x.y&gt;
26482 </p><p>&lt;x-y&gt;
26483 </p><p>1&gt;2
26484 </p><p>x&lt;y
26485 </p><p>a&gt;b
26486 </p><p>1&lt;d e&gt;f
26487 </p>
26488 !! end
26489
26490 !! test
26491 HTML tag with necessary entities in attributes
26492 !! wikitext
26493 <span title="&amp;amp;">foo</span>
26494 !! html
26495 <p><span title="&amp;amp;">foo</span>
26496 </p>
26497 !! end
26498
26499 !! test
26500 HTML tag with 'unnecessary' entity encoding in attributes
26501 !! wikitext
26502 <span title="&amp;">foo</span>
26503 !! html
26504 <p><span title="&amp;">foo</span>
26505 </p>
26506 !! end
26507
26508 !! test
26509 HTML tag with broken attribute value quoting
26510 !! options
26511 parsoid=wt2html,html2html
26512 !! wikitext
26513 <span title="Hello world>Foo</span>
26514 !! html/php
26515 <p><span title="Hello world">Foo</span>
26516 </p>
26517 !! html/parsoid
26518 <p><span title="Hello world">Foo</span></p>
26519 !! end
26520
26521 !! test
26522 Self-closed tag with broken attribute value quoting
26523 !! options
26524 parsoid=wt2html,html2html
26525 !! wikitext
26526 <div title="Hello world />Foo
26527 !! html/php+tidy
26528 <div title="Hello world"></div><p>Foo
26529 </p>
26530 !! html/parsoid
26531 <div title="Hello world " data-parsoid='{"stx":"html","selfClose":true}'></div><p>Foo</p>
26532 !! end
26533
26534 !! test
26535 Table with broken attribute value quoting
26536 !! options
26537 parsoid=wt2html,html2html
26538 !! wikitext
26539 {|
26540 | title="Hello world|Foo
26541 |}
26542 !! html/php
26543 <table>
26544 <tr>
26545 <td title="Hello world">Foo
26546 </td></tr></table>
26547
26548 !! html/parsoid
26549 <table>
26550 <tr>
26551 <td title="Hello world">Foo
26552 </td></tr></table>
26553
26554 !! end
26555
26556 !! test
26557 Table with broken attribute value quoting on consecutive lines
26558 !! options
26559 parsoid=wt2html,html2html
26560 !! wikitext
26561 {|
26562 | title="Hello world|Foo
26563 | style="color:red|Bar
26564 |}
26565 !! html/php
26566 <table>
26567 <tr>
26568 <td title="Hello world">Foo
26569 </td>
26570 <td style="color:red">Bar
26571 </td></tr></table>
26572
26573 !! html/parsoid
26574 <table><tbody>
26575 <tr>
26576 <td title="Hello world">Foo
26577 </td><td style="color: red">Bar
26578 </td></tr></tbody></table>
26579
26580 !! end
26581
26582 !!test
26583 Accept empty td cell attribute
26584 !! wikitext
26585 {|
26586 | align="center" | foo || |
26587 |}
26588 !! html
26589 <table>
26590 <tr>
26591 <td align="center"> foo </td>
26592 <td>
26593 </td></tr></table>
26594
26595 !!end
26596
26597 !!test
26598 Non-empty attributes in th-cells
26599 !! wikitext
26600 {|
26601 ! Foo !! style="color: red" | Bar
26602 |}
26603 !! html
26604 <table>
26605 <tr>
26606 <th> Foo </th>
26607 <th style="color: red"> Bar
26608 </th></tr></table>
26609
26610 !!end
26611
26612 !!test
26613 Accept empty attributes in th-cells
26614 !! wikitext
26615 {|
26616 !| foo !!| bar
26617 |}
26618 !! html
26619 <table>
26620 <tr>
26621 <th> foo </th>
26622 <th> bar
26623 </th></tr></table>
26624
26625 !!end
26626
26627 !!test
26628 Empty table rows go away
26629 !! wikitext
26630 {|
26631 | Hello
26632 | there
26633 |- class="foo"
26634 |-
26635 |}
26636 !! html
26637 <table>
26638 <tr>
26639 <td> Hello
26640 </td>
26641 <td> there
26642 </td></tr>
26643
26644 </table>
26645
26646 !! end
26647
26648 ###
26649 ### Parsoid-centric tests for testing RTing of inter-element separators
26650 ### Edge cases not tested by existing parser tests and specific to
26651 ### Parsoid-specific serialization strategies.
26652 ###
26653
26654 !!test
26655 RT-ed inter-element separators should be valid separators
26656 !! wikitext
26657 {|
26658 |- [[foo]]
26659 |}
26660 !! html/php
26661 <table>
26662
26663 </table>
26664
26665 !! html/parsoid
26666 <table>
26667 <tbody><tr class='mw-empty-elt' data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
26668 </tbody></table>
26669 !!end
26670
26671 # Parsoid-only test of a DOM pass
26672 !!test
26673 Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out
26674 !! wikitext
26675 {|
26676 |<small>foo
26677 bar
26678 |}
26679
26680 {|
26681 |<small>foo<small>
26682 |}
26683 !! html/parsoid
26684 <table>
26685 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo
26686 <p>bar</p></small></td></tr>
26687 </tbody></table>
26688
26689 <table>
26690 <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>
26691 </tbody></table>
26692 !!end
26693
26694 # Note that the "style" attribute is really a template parameter here.
26695 # The = would have to be {{=}} if you wanted the literal.
26696 !!test
26697 Empty TD followed by TD with tpl-generated attribute
26698 !! wikitext
26699 {|
26700 |-
26701 |
26702 |{{echo|style='color:red'}}|foo
26703 |}
26704 !! html
26705 <table>
26706
26707 <tr>
26708 <td>
26709 </td>
26710 <td>foo
26711 </td></tr></table>
26712
26713 !!end
26714
26715 !!test
26716 Indented table with an empty td
26717 !! wikitext
26718 {|
26719 |-
26720 |
26721 |foo
26722 |}
26723 !! html
26724 <table>
26725
26726 <tr>
26727 <td>
26728 </td>
26729 <td>foo
26730 </td></tr></table>
26731
26732 !!end
26733
26734 ## We have some newline diffs RT-ing this edge case
26735 ## and it is not important enough -- we seem to be emitting
26736 ## at most 2 newlines after a </tr> and this is unrelated to
26737 ## the issue from T85627 that this is testing.
26738 !!test
26739 Indented table with blank lines in between (T85627)
26740 !! options
26741 parsoid=wt2html
26742 !! wikitext
26743 {|
26744 |foo
26745
26746
26747 |}
26748 !! html
26749 <table>
26750
26751 <tr>
26752 <td>foo
26753 </td></tr></table>
26754
26755 !!end
26756
26757 !!test
26758 Indented block & table
26759 !! wikitext
26760 <div>foo</div>
26761 {|
26762 |foo
26763 |}
26764 !! html/php
26765 <div>foo</div>
26766 <table>
26767 <tr>
26768 <td>foo
26769 </td></tr></table>
26770
26771 !! html/parsoid
26772 <div data-parsoid='{"stx":"html"}'>foo</div>
26773 <table><tbody>
26774 <tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>foo</td></tr>
26775 </tbody></table>
26776 !!end
26777
26778 !! test
26779 Indent and comment before table row
26780 !! wikitext
26781 {|
26782 <!--hi-->|-
26783 | there
26784 |}
26785 !! html/php
26786 <table>
26787
26788 <tr>
26789 <td> there
26790 </td></tr></table>
26791
26792 !! html/parsoid
26793 <table>
26794 <!--hi--><tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
26795 <td data-parsoid='{"autoInsertedEnd":true}'> there</td></tr>
26796 </tbody></table>
26797 !! end
26798
26799 # Parsoid-specific since PHP parser doesn't handle this mixed tbl-wikitext
26800 !!test
26801 Empty TR followed by a template-generated TR
26802 !!options
26803 parsoid
26804 !! wikitext
26805 {|
26806 |-
26807 {{echo|<tr><td>foo</td></tr>}}
26808 |}
26809 !! html
26810 <table>
26811 <tbody>
26812 <tr class='mw-empty-elt'></tr>
26813 <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}}]}'>
26814 <td>foo</td></tr>
26815 </tbody></table>
26816 !!end
26817
26818 ## PHP and parsoid output differ for this, and since this is primarily
26819 ## for testing Parsoid's serializer, marking this Parsoid only
26820 !!test
26821 Empty TR followed by mixed-ws-comment line should RT correctly
26822 !!options
26823 parsoid
26824 !! wikitext
26825 {|
26826 |-
26827 <!--c-->
26828 |-
26829 <!--c--> <!--d-->
26830 |}
26831 !! html
26832 <table>
26833 <tbody>
26834 <tr class='mw-empty-elt'></tr>
26835 <!--c-->
26836 <tr>
26837 <!--c--> </tr><!--d-->
26838 </tbody></table>
26839
26840 !!end
26841
26842 !!test
26843 Multi-line image caption generated by templates with/without trailing newlines
26844 !! wikitext
26845 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]]
26846 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]]
26847 !! html/parsoid
26848 <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>
26849 <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>
26850 !!end
26851
26852 !! test
26853 New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly
26854 !! options
26855 parsoid=html2wt
26856 !! html/parsoid
26857 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>foo&lt;/includeonly>"}'/><meta typeof="mw:Includes/IncludeOnly/End" data-parsoid='{"src":""}'/><p>new para</p>
26858
26859 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{}'/><h1>new heading</h1>
26860 !! wikitext
26861 <includeonly>foo</includeonly>
26862 new para
26863
26864 [[Category:Foo]]
26865
26866 = new heading =
26867 !! end
26868
26869 ## PHP emits broken html for this, and since this is primarily
26870 ## a Parsoid serializer test, marking this Parsoid only
26871 !!test
26872 Improperly nested inline or quotes tags with whitespace in between
26873 !! wikitext
26874 <span> <s>x</span> </s>
26875 ''' ''x''' ''
26876 !! html/parsoid
26877 <p><span> <s>x</s></span><s> </s>
26878 <b> <i>x</i></b><i> </i>
26879 </p>
26880 !!end
26881
26882 !!test
26883 Encapsulate protected attributes from wt
26884 !! wikitext
26885 <div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
26886
26887 {| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true"
26888 | ok
26889 |}
26890 !! html/parsoid
26891 <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>
26892
26893 <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">
26894 <tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'> ok</td></tr>
26895 </tbody></table>
26896 !!end
26897
26898 ## Currently the p-wrapper is fragile in how it adds / removes transformations.
26899 ## Having nested or stray pre tags results in the attempt to add duplicates,
26900 ## causing an assertion fail. This test tries to prevent that situation.
26901 !!test
26902 Ensure ParagraphWrapper can deal with stray closing pre tags
26903 !!options
26904 parsoid=wt2html
26905 !! wikitext
26906 plain text</pre>
26907 !! html/parsoid
26908 plain text
26909 !!end
26910
26911 !!test
26912 1. Ensure fostered text content is wrapped in element nodes
26913 !!options
26914 parsoid=wt2html
26915 !! wikitext
26916 <table>hi</table><table>ho</table>
26917 !! html/parsoid
26918 <p>hi</p>
26919 <table></table>
26920 <p>ho</p>
26921 <table></table>
26922 !!end
26923
26924 !!test
26925 2. Ensure fostered text content is wrapped in element nodes (traps regressions around fostered marker on the element getting lost)
26926 !!options
26927 parsoid=wt2html,wt2wt
26928 !! wikitext
26929 <table>
26930 <tr> || ||
26931 <td> a
26932 </table>
26933 !! html/parsoid
26934 <p> || ||
26935 </p><table>
26936 <tbody><tr><td> a</td></tr>
26937 </tbody></table>
26938 !!end
26939
26940 !!test
26941 Encapsulation properly handles null DSR information from foster box
26942 !!options
26943 parsoid=wt2html,wt2wt
26944 !! wikitext
26945 {{echo|<table>foo<tr><td>bar</td></tr></table>}}
26946 !! html/parsoid
26947 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;<table>foo<tr><td>bar</td></tr></table>&quot;}},&quot;i&quot;:0}}]}">foo</span><table><tbody><tr><td>bar</td></tr></tbody></table>
26948 !!end
26949
26950 !!test
26951 1. Encapsulate foster-parented transclusion content
26952 !!options
26953 parsoid=wt2wt,wt2html
26954 !! wikitext
26955 <table>{{echo|foo<tr><td>bar</td></tr>}}</table>
26956 !! html/parsoid
26957 <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;foo<tr><td>bar</td></tr>&quot;}},&quot;i&quot;:0}},&quot;</table>&quot;]}">foo</p><table>
26958 <tbody>
26959 <tr>
26960 <td>bar</td>
26961 </tr>
26962 </tbody>
26963 </table>
26964 !!end
26965
26966 !!test
26967 2. Encapsulate foster-parented transclusion content
26968 !!options
26969 parsoid=wt2wt,wt2html
26970 !! wikitext
26971 <table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table>
26972 !! html/parsoid
26973 <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>
26974 <table>
26975 <tbody>
26976 <tr>
26977 <td>bar</td>
26978 </tr>
26979 </tbody>
26980 </table>
26981 !!end
26982
26983 !!test
26984 3. Encapsulate foster-parented transclusion content
26985 !!options
26986 parsoid=wt2wt,wt2html
26987 !! wikitext
26988 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
26989 !! html/parsoid
26990 <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;]}">
26991 <p>foo</p>
26992 </div>
26993 <table>
26994 <tbody>
26995 <tr>
26996 <td>bar</td>
26997 </tr>
26998 </tbody>
26999 </table>
27000 !!end
27001
27002 !!test
27003 4. Encapsulate foster-parented transclusion content
27004 !!options
27005 parsoid=wt2wt,wt2html
27006 !! wikitext
27007 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
27008 !! html/parsoid
27009 <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;]}">
27010 <p>foo</p>
27011 </div>
27012 <table>
27013 <tbody>
27014 <tr>
27015 <td>bar</td>
27016 </tr>
27017 </tbody>
27018 </table>
27019 !!end
27020
27021 !!test
27022 5. Encapsulate foster-parented transclusion content
27023 !!options
27024 parsoid=wt2wt,wt2html
27025 !! wikitext
27026 <table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table>
27027 !! html/parsoid
27028 <p typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[&quot;<table><tr><td><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></td>foo&quot;}},&quot;i&quot;:0}},&quot;</tr></table>&quot;]}">foo</p>
27029 <table>
27030 <tbody>
27031 <tr>
27032 <td>
27033 <div>
27034 <p>foo</p>
27035 </div>
27036 </td>
27037 </tr>
27038 </tbody>
27039 </table>
27040 !!end
27041
27042 !!test
27043 6. Encapsulate foster-parented transclusion content
27044 !!options
27045 parsoid=wt2wt,wt2html
27046 !! wikitext
27047 <table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p>
27048 !! html/parsoid
27049 <p typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[&quot;<table><tr><td><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></td>foo</tr></table>&quot;}},&quot;i&quot;:0}}]}">foo</p>
27050 <table>
27051 <tbody>
27052 <tr>
27053 <td>
27054 <div>
27055 <p>foo</p>
27056 </div>
27057 </td>
27058 </tr>
27059 </tbody>
27060 </table>
27061 <p>ok</p>
27062 !!end
27063
27064 !!test
27065 7. Encapsulate foster-parented transclusion content
27066 !!options
27067 parsoid=wt2wt,wt2html
27068 !! wikitext
27069 <table>{{echo|<p>foo</p>}}<td>bar</td></table>
27070 !! html/parsoid
27071 <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>
27072 <table>
27073 <tbody>
27074 <tr>
27075 <td>bar</td>
27076 </tr>
27077 </tbody>
27078 </table>
27079 !!end
27080
27081 # Note that the wt is broken on purpose: the = should be {{=}} if you
27082 # don't want it to be a template parameter key.
27083 !!test
27084 8. Encapsulate foster-parented transclusion content
27085 !!options
27086 parsoid=wt2wt,wt2html
27087 !! wikitext
27088 {{echo|a
27089 }}{|{{echo|style='color:red'}}
27090 |-
27091 |b
27092 |}
27093 !! html/parsoid
27094 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n"}},"i":0}}]}'>a</p>
27095 <span> </span>
27096 <p typeof="mw:Transclusion" data-mw='{"parts":["{|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"style":{"wt":"&#39;color:red&#39;"}},"i":0}},"\n|-\n|b\n|}"]}'>{{{1}}}</p>
27097 <table>
27098 <tbody>
27099 <tr>
27100 <td>b</td>
27101 </tr>
27102 </tbody>
27103 </table>
27104 !!end
27105
27106 !!test
27107 9. Encapsulate foster-parented transclusion content
27108 !!options
27109 parsoid=wt2wt,wt2html
27110 !! wikitext
27111 <table>{{echo|hi</table>hello}}
27112 !! html/parsoid
27113 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":["&lt;table>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi&lt;/table>hello"}},"i":0}}]}' data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"pi":[[{"k":"1"}]]}'>hi</p><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><p about="#mwt2">hello</p>
27114 !!end
27115
27116 !!test
27117 Table in fosterable position
27118 !!options
27119 parsoid=wt2html
27120 !! wikitext
27121 {{OpenTable}}
27122 <div>
27123 {|
27124 |}
27125 </div>
27126 |}
27127 !! html/parsoid
27128 <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">
27129 </span>
27130 <table about="#mwt1" data-parsoid='{"autoInsertedEnd":true}'></table>
27131
27132 <table>
27133 </table>
27134 !!end
27135
27136 # Parsoid only for T66747
27137 !! test
27138 Properly encapsulate empty-content transclusions in fosterable positions
27139 !! wikitext
27140 <table>
27141 {{#if:|
27142 <td>foo</td>
27143 }}
27144 </table>
27145 !! html/parsoid
27146 <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"}]]}'>
27147
27148 </table>
27149 !! end
27150
27151 !! test
27152 Always encapsulate foster box when template range is expanded to table
27153 !! options
27154 parsoid=wt2wt
27155 !! wikitext
27156 {|
27157 hello
27158 {{OpenTable}}
27159 |}
27160 !! html/parsoid
27161
27162 !! end
27163
27164 !! test
27165 T115289: Unclosed table
27166 !! wikitext
27167 {{echo|<table>}}<!--c-->[[Category:Two]]
27168 !! html/parsoid
27169 <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>
27170 !! end
27171
27172 !! test
27173 T115289: Don't migrate newlines out of tables with fostered content
27174 !! wikitext
27175 <table><td></td>{{echo|<tr>[[Category:One]]}}<!--c-->[[Category:Two]]
27176 !! html/parsoid
27177 <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>
27178 !! end
27179
27180 !! test
27181 T73074: More fostering fun
27182 !! wikitext
27183 <table><td></td>{{echo|<tr>}}<!--c-->[[Category:Two]]
27184 !! html/parsoid
27185 <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>
27186 !! end
27187
27188 !!test
27189 Support <object> element with .data attribute
27190 !!options
27191 parsoid=html2wt
27192 !! html/parsoid
27193 <object data="test.swf"></object>
27194 !! wikitext
27195 <object data="test.swf"></object>
27196 !!end
27197
27198 !! test
27199 Don't block XML namespace declaration
27200 !! wikitext
27201 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span>
27202 !! html/php
27203 <p><span xmlns:dct="http&#58;//purl.org/dc/terms/" property="dct:title">MediaWiki</span>
27204 </p>
27205 !! html/parsoid
27206 <p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p>
27207 !! end
27208
27209 # -----------------------------------------------------------------
27210 # The following section of tests are primarily to spec requirements
27211 # around Parsoid's serialization (old, new, edited content)
27212 #
27213 # All these tests are marked Parsoid html2wt and html2html only
27214 # ----------------------------------------------------------------
27215
27216 !! test
27217 Ignore rel attribute in a-tags during serialization to url-links
27218 !! options
27219 parsoid=html2wt
27220 !! html/parsoid
27221 <a href='http://en.wikipedia.org/wiki/Foobar'>http://en.wikipedia.org/wiki/Foobar</a>
27222 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:ExtLink'>http://en.wikipedia.org/wiki/Foobar</a>
27223 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:WikiLink'>http://en.wikipedia.org/wiki/Foobar</a>
27224 !! wikitext
27225 http://en.wikipedia.org/wiki/Foobar
27226 http://en.wikipedia.org/wiki/Foobar
27227 http://en.wikipedia.org/wiki/Foobar
27228 !! end
27229
27230 # 'mi' is a localinterwiki prefix as well as a language
27231 !! test
27232 Serialize interwiki links pointing to the current wiki as plain wiki links (T67869)
27233 !! options
27234 parsoid=html2wt
27235 !! html/parsoid
27236 <p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p>
27237 !! wikitext
27238 [[Foo]]
27239 !! end
27240
27241 !! test
27242 Parsoid should accept interwiki shortcuts
27243 !! options
27244 parsoid=html2wt
27245 !! html/parsoid
27246 <p><a rel='mw:WikiLink' href='./fr:Foo'>Foo</a>
27247 <a rel='mw:ExtLink' href='./fr:Foo'>Foo</a>
27248 <a href='./fr:Foo'>Foo</a></p>
27249 <p><a rel='mw:WikiLink' href='fr%3AFoo'>Foo</a>
27250 <a rel='mw:ExtLink' href='fr%3AFoo'>Foo</a>
27251 <a href='fr%3AFoo'>Foo</a></p>
27252 <p><a href='FR%3AFoo'>Foo</a>
27253 <a href='./FR:Foo'>Foo</a></p>
27254 !! wikitext
27255 [[:fr:Foo|Foo]]
27256 [[:fr:Foo|Foo]]
27257 [[:fr:Foo|Foo]]
27258
27259 [[:fr:Foo|Foo]]
27260 [[:fr:Foo|Foo]]
27261 [[:fr:Foo|Foo]]
27262
27263 [[:fr:Foo|Foo]]
27264 [[:fr:Foo|Foo]]
27265 !! end
27266
27267 !! test
27268 Parsoid should not accept invalid interwiki shortcuts
27269 !! options
27270 parsoid=html2wt
27271 !! html/parsoid
27272 <p><a rel='mw:WikiLink' href='news:Foo'>Foo</a>
27273 <a rel='mw:ExtLink' href='news:Foo'>Foo</a>
27274 <a href='news:Foo'>Foo</a></p>
27275 !! wikitext
27276 [news:Foo Foo]
27277 [news:Foo Foo]
27278 [news:Foo Foo]
27279 !! end
27280
27281 # See T93839
27282 !! test
27283 New wikilinks should be serialized properly
27284 !! options
27285 parsoid=html2wt
27286 !! html/parsoid
27287 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
27288 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
27289 <a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a>
27290 <a href="http://en.wikipedia.org/wiki/Foo">http://en.wikipedia.org/wiki/Foo</a>
27291 <a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a>
27292 !! wikitext
27293 [[Foo]]
27294 [[Foo]]
27295 [[:en:Foo|//en.wikipedia.org/wiki/Foo]]
27296 http://en.wikipedia.org/wiki/Foo
27297 [[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]]
27298 !! end
27299
27300 !! test
27301 New wiki links (href variations)
27302 !! options
27303 parsoid=html2wt
27304 !! html/parsoid
27305 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
27306 <a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a>
27307 <a rel="mw:WikiLink" href="Foo bar">Foo_bar</a>
27308 <a rel="mw:WikiLink" href="./Toxine_bact%C3%A9rienne">Toxine bactérienne</a>
27309 !! wikitext
27310 [[Foo_bar]]
27311 [[Foo_bar]]
27312 [[Foo_bar]]
27313 [[Toxine bactérienne]]
27314 !! end
27315
27316 !! test
27317 New wiki links (content string variations)
27318 !! options
27319 parsoid=html2wt
27320 !! html/parsoid
27321 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
27322 <a rel="mw:WikiLink" href="./Foo_bar">Foo bar</a>
27323 <a rel="mw:WikiLink" href="./Foo_bar">./Foo_bar</a>
27324 !! wikitext
27325 [[Foo_bar]]
27326 [[Foo bar]]
27327 [[Foo_bar|./Foo_bar]]
27328 !! end
27329
27330 !! test
27331 New category links (href variations)
27332 !! options
27333 parsoid=html2wt
27334 !! html/parsoid
27335 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" />
27336 <link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" />
27337 <link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" />
27338 !! wikitext
27339 [[Category:Toxine bactérienne]]
27340 [[Category:Toxine bactérienne]]
27341 [[Category:Toxine bactérienne]]
27342 !! end
27343
27344 !! test
27345 New sol transparent links don't need indent-pre nowiki protection
27346 !! options
27347 parsoid=html2wt
27348 language=de
27349 !! html/parsoid
27350 <link rel="mw:PageProp/redirect" href="./Main_Page">
27351 <!-- this is good --> <link rel="mw:PageProp/Category" href="./Category:Good" />
27352 <!-- this is great --> <link rel="mw:PageProp/Category" href="./Kategorie:Great" />
27353 !! wikitext
27354 #WEITERLEITUNG [[Main Page]]
27355 <!-- this is good --> [[Category:Good]]
27356 <!-- this is great --> [[Kategorie:Great]]
27357 !! end
27358
27359 !! test
27360 New interlanguage links (href variations)
27361 !! options
27362 parsoid=html2wt
27363 !! html/parsoid
27364 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" />
27365 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" />
27366 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" />
27367 !! wikitext
27368 [[es:Toxine bactérienne]]
27369 [[es:Toxine_bactérienne]]
27370 [[es:Toxine_bactérienne]]
27371 !! end
27372
27373 !! test
27374 Image: Modifying size of an image (1)
27375 !! options
27376 parsoid={
27377 "modes": ["wt2wt"],
27378 "changes": [
27379 ["img[height]", "attr", "height", "22"],
27380 ["img[width]", "attr", "width", "200"]
27381 ]
27382 }
27383 !! wikitext
27384 [[Image:Foobar.jpg|230x230px]]
27385 !! wikitext/edited
27386 [[Image:Foobar.jpg|200x200px]]
27387 !!end
27388
27389 !! test
27390 Image: Modifying size of an image (2)
27391 !! options
27392 parsoid={
27393 "modes": ["wt2wt"],
27394 "changes": [
27395 ["img[height]", "attr", "height", "100"],
27396 ["img[width]", "attr", "width", "500"]
27397 ]
27398 }
27399 !! wikitext
27400 [[Image:Foobar.jpg|230x230px]]
27401 !! wikitext/edited
27402 [[Image:Foobar.jpg|500x500px]]
27403 !!end
27404
27405 # Change in size is ignored so long as class='mw-default-size'
27406 !! test
27407 Image: Modifying size of an image (3)
27408 !! options
27409 parsoid={
27410 "modes": ["wt2wt"],
27411 "changes": [
27412 ["figure[class]", "removeClass", "mw-default-size"],
27413 ["figure img", "attr", "height", "19"],
27414 ["figure img", "attr", "width", "170"]
27415 ]
27416 }
27417 !! wikitext
27418 [[Image:Foobar.jpg|thumb]]
27419 !! wikitext/edited
27420 [[Image:Foobar.jpg|thumb|170x170px]]
27421 !!end
27422
27423 !! test
27424 Image: Modifying alignment of an image (T50665)
27425 !! options
27426 parsoid={
27427 "modes": ["wt2wt"],
27428 "changes": [
27429 ["figure[class]", "removeClass", "mw-halign-right"],
27430 ["figure[class]", "addClass", "mw-halign-left"]
27431 ]
27432 }
27433 !! wikitext
27434 [[Image:Foobar.jpg|thumb|caption|right]]
27435 !! wikitext/edited
27436 [[Image:Foobar.jpg|thumb|caption|left]]
27437 !! end
27438
27439 !! test
27440 Image: Modifying mw-default-size of an frameless image (T64805)
27441 !! options
27442 parsoid={
27443 "modes": ["wt2wt"],
27444 "changes": [
27445 ["figure.mw-default-size", "removeClass", "mw-default-size"]
27446 ]
27447 }
27448 !! wikitext
27449 [[Image:Foobar.jpg|frameless|right]]
27450 !! wikitext/edited
27451 [[Image:Foobar.jpg|frameless|right|220x220px]]
27452 !! end
27453
27454 !! test
27455 Image: Modifying valign of an image (T51221)
27456 !! options
27457 parsoid={
27458 "modes": ["wt2wt"],
27459 "changes": [
27460 ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
27461 ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
27462 ]
27463 }
27464 !! wikitext
27465 [[File:Foobar.jpg|20px|middle]]
27466 !! wikitext/edited
27467 [[File:Foobar.jpg|20px|text-top]]
27468 !! end
27469
27470 !! test
27471 Image: Modifying alt attribute of an image (T58400)
27472 !! options
27473 parsoid={
27474 "modes": ["wt2wt"],
27475 "changes": [
27476 ["img[alt]", "attr", "alt", "some alternate edited text"]
27477 ]
27478 }
27479 !! wikitext
27480 [[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
27481 !! wikitext/edited
27482 [[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
27483 !!end
27484
27485 !! test
27486 Image: Modifying caption of an image
27487 !! options
27488 parsoid={
27489 "modes": ["wt2wt"],
27490 "changes": [
27491 ["figcaption", "text", "new caption"]
27492 ]
27493 }
27494 !! wikitext
27495 [[Image:Foobar.jpg|thumb|original caption]]
27496 !! wikitext/edited
27497 [[Image:Foobar.jpg|thumb|new caption]]
27498 !!end
27499
27500 !! test
27501 Image: empty alt attribute (T50924)
27502 !! options
27503 parsoid
27504 !! wikitext
27505 [[File:Foobar.jpg|thumb|alt=|bar]]
27506 !! html
27507 <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>
27508 !! end
27509
27510 !! test
27511 Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
27512 !! options
27513 parsoid=html2wt
27514 language=ar
27515 disabled
27516 !! html/parsoid
27517 <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>
27518 !! wikitext
27519 [[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
27520 !! end
27521
27522 !! test
27523 Image: Block level image should have \n before and after
27524 !! wikitext
27525 123
27526 [[File:Foobar.jpg|right|thumb|150x150px]]
27527 456
27528 !! html/parsoid
27529 <p>123</p>
27530 <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>
27531 <p>456</p>
27532 !! end
27533
27534 !! test
27535 Image: New block level image should have \n before and after (existing content)
27536 !! wikitext
27537 123
27538 [[File:Foobar.jpg|right|thumb|150x150px]]
27539 456
27540 !! html/parsoid
27541 <p>123</p>
27542 <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>
27543 <p>456</p>
27544 !! end
27545
27546 !! test
27547 Image: upright option (parsoid)
27548 !! wikitext
27549 [[File:Foobar.jpg|thumb|upright|caption]]
27550 [[File:Foobar.jpg|thumb|upright=0.5|caption]]
27551 [[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]]
27552 !! html/parsoid
27553 <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>
27554 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/110px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="12" width="110"/></a><figcaption>caption</figcaption></figure>
27555 <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>
27556 !! end
27557
27558 !! test
27559 Image: upright option is ignored on inline and frame images (parsoid)
27560 !! wikitext
27561 [[File:Foobar.jpg|500x500px|upright=0.5|caption]]
27562 !! html/parsoid
27563 <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>
27564 !! end
27565
27566 !! test
27567 Image: in template parameter with empty parameter
27568 !! wikitext
27569 {{echo|[[File:Foobar.jpg|link=]]}}
27570 !! html/parsoid
27571 <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>
27572 !! end
27573
27574 !! test
27575 Image: from basic HTML (1)
27576 !! options
27577 parsoid=html2wt
27578 !! html/parsoid
27579 <span typeof="mw:Image">
27580 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
27581 </span>
27582 !! wikitext
27583 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
27584 !! end
27585
27586 !! test
27587 Image: from basic HTML (2)
27588 !! options
27589 parsoid=html2wt
27590 !! html/parsoid
27591 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
27592 !! wikitext
27593 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
27594 !! end
27595
27596 !! test
27597 Image: from basic HTML (3)
27598 !! options
27599 parsoid=html2wt
27600 !! html/parsoid
27601 <a href="Main"><img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"></a>
27602 !! wikitext
27603 [[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
27604 !! end
27605
27606 !! test
27607 Image: from basic HTML (4)
27608 !! options
27609 parsoid=html2wt
27610 !! html/parsoid
27611 <img src="./File:Foobar.jpg">
27612 !! wikitext
27613 [[File:Foobar.jpg|link=]]
27614 !! end
27615
27616 !! test
27617 Image: Invalid title as link
27618 !! wikitext
27619 [[File:Foobar.jpg|link=<]]
27620 !! html/php
27621 <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>
27622 </p>
27623 !! html/parsoid
27624 <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>
27625 !! end
27626
27627 !! test
27628 Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
27629 !! options
27630 parsoid=html2wt
27631 !! html/parsoid
27632 <ul>
27633 <li><p>foo</p></li>
27634 </ul>
27635 !! wikitext
27636 * foo
27637 !! end
27638
27639 !! test
27640 Lists: Serialize correctly even when list tags has unneeded whitespace between tags
27641 !! options
27642 parsoid=html2wt
27643 !! html/parsoid
27644 <ul> <li>foo</li></ul>
27645 !! wikitext
27646 * foo
27647 !! end
27648
27649 !! test
27650 Don't strip leading whitespace when handling indent-pre suppressing tags
27651 !! options
27652 parsoid=html2wt
27653 !! html/parsoid
27654 <table>
27655 <tr><td> indented row</td></tr>
27656 </table>
27657 <blockquote><p>
27658 <b>This is very bold of you!</b>
27659 </p>
27660 <table><tr><td>
27661 indented cell (no pre-wrapping!)
27662 </td></tr></table>
27663 </blockquote>
27664 <p>foo</p>
27665 <div>bar</div>
27666 !! wikitext
27667 {|
27668 | indented row
27669 |}
27670 <blockquote>
27671 '''This is very bold of you!'''
27672
27673 {|
27674 |
27675 indented cell (no pre-wrapping!)
27676 |}
27677 </blockquote>
27678 foo
27679 <div>bar</div>
27680 !! end
27681
27682 !! test
27683 Nowiki-wrap leading whitespace when handling indent-pre inducing tags
27684 !! options
27685 parsoid=html2wt
27686 !! html/parsoid
27687 <p>foo</p>
27688 <span>bar</span>
27689
27690 <span>foo2
27691 </span>bar2
27692
27693 <div>foo</div>
27694 <span>bar</span>
27695
27696 <div>
27697 <span>foo</span>
27698 </div>
27699 !! wikitext
27700 foo
27701
27702 <span>bar</span>
27703
27704 <span>foo2
27705 <nowiki> </nowiki></span>bar2
27706
27707 <div>foo</div>
27708 <nowiki> </nowiki><span>bar</span>
27709
27710 <div>
27711 <nowiki> </nowiki><span>foo</span>
27712 </div>
27713 !! end
27714
27715 !! test
27716 Lists: Dont insert newlines in a serialized list item.
27717 !! options
27718 parsoid=html2wt
27719 !! html/parsoid
27720 <ul><li>a<br>b</li><li>c</li></ul>
27721 !! wikitext
27722 * a<br>b
27723 * c
27724 !! end
27725
27726 !! test
27727 1. Headings: Force sol-transparent links and behavior switches to serialize before/after
27728 !! options
27729 parsoid={
27730 "modes": ["html2wt"],
27731 "scrubWikitext": false
27732 }
27733 !! html/parsoid
27734 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
27735 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
27736
27737 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
27738 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
27739
27740 <h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2>
27741
27742 <h2><meta property="mw:PageProp/toc" /> ok</h2>
27743 !! wikitext
27744 == hello there [[Category:A1]] ==
27745
27746 == [[Category:A2]] hi pal ==
27747
27748 == <!--foo--> [[Category:A3]] how goes it ==
27749
27750 == it goes well [[Category:A4]] <!--bar--> ==
27751
27752 ==howdy [[Category:A5]]==
27753
27754 == __TOC__ ok ==
27755 !! end
27756
27757 !! test
27758 2. Headings: Force sol-transparent links and behavior switches to serialize before/after
27759 !! options
27760 parsoid={
27761 "modes": ["html2wt"],
27762 "scrubWikitext": true
27763 }
27764 !! html/parsoid
27765 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
27766 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
27767
27768 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
27769 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
27770
27771 <h2><meta property="mw:PageProp/toc" /> ok</h2>
27772 !! wikitext
27773 == hello there ==
27774 [[Category:A1]]
27775 [[Category:A2]]
27776
27777 == hi pal ==
27778
27779 <!--foo--> [[Category:A3]]
27780
27781 == how goes it ==
27782
27783 == it goes well ==
27784 [[Category:A4]] <!--bar-->
27785
27786 __TOC__
27787
27788 == ok ==
27789 !! end
27790
27791 !! test
27792 Headings: Don't hoist metas that come from templates
27793 !! options
27794 parsoid={
27795 "modes": ["html2wt"],
27796 "scrubWikitext": true
27797 }
27798 !! html/parsoid
27799 <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>
27800 !! wikitext
27801 == {{echo|foo [[Category:Foo]]}} ==
27802 !! end
27803
27804 !! test
27805 Headings: Category in ref isn't hoisted
27806 !! options
27807 parsoid={
27808 "modes": ["html2wt"],
27809 "scrubWikitext": true
27810 }
27811 !! html/parsoid
27812 <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>
27813
27814 <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>
27815 !! wikitext
27816 == foo <ref>bar
27817 [[Category:Baz]] </ref> ==
27818
27819 <references />
27820 !! end
27821
27822 !! test
27823 Parsoid: Serialize positional parameters with = in them as named parameter
27824 !! options
27825 parsoid=html2wt
27826 !! html/parsoid
27827 <p about="#mwt1" typeof="mw:Transclusion"
27828 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p>
27829
27830 <p about="#mwt1" typeof="mw:Transclusion"
27831 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p>
27832
27833 <!--Orig params with data-parsoid has heuristics for handling = chars-->
27834 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
27835 <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>
27836 !! wikitext
27837 {{echo|1=f=oo}}
27838
27839 {{echo|1=f=oo|2=bar}}
27840
27841 <!--Orig params with data-parsoid has heuristics for handling = chars-->
27842 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
27843 {{echo|<nowiki>f=oo</nowiki>|bar}}
27844 !! end
27845
27846 !! test
27847 Parsoid: Serialize positional parameters with = in extlink as named parameter
27848 !! options
27849 parsoid=html2wt
27850 !! html/parsoid
27851 <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>
27852 !! wikitext
27853 {{echo|1=http://stuff?is=ok}}
27854 !! end
27855
27856 !! test
27857 Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes
27858 !! options
27859 parsoid=html2wt
27860 !! html/parsoid
27861 <div>a<p>b</p></div>
27862 <div>a
27863 <p>b</p></div>
27864 <div>
27865 a
27866 <p>b</p></div>
27867 !! wikitext
27868 <div>a
27869 b
27870 </div>
27871 <div>a
27872 b
27873 </div>
27874 <div>
27875 a
27876
27877 b
27878 </div>
27879 !! end
27880
27881 !! test
27882 Substrings resembling wikitext in hrefs should not get nowiki escapes
27883 !! options
27884 parsoid=html2wt
27885 !! html/parsoid
27886 <a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a>
27887 !! wikitext
27888 [[Foo''bar''baz]]
27889 !! end
27890
27891 !! test
27892 Enforce single-line context in the serializer
27893 !! options
27894 parsoid=html2wt
27895 !! html/parsoid
27896 <h2>testing
27897 123</h2>
27898
27899 <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">
27900 </span><span about="#mwt1">you</span> </h2>
27901
27902 <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>
27903
27904 <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
27905 there</span></li></ol>
27906
27907 <ul><li>asd
27908 sdf</li></ul>
27909
27910 <ul><li>foo
27911 bar
27912 baz</li>
27913 <li>foo <b>bar</b>
27914 baz</li></ul>
27915
27916 <dl><dt>hi
27917 ho </dt><dd data-parsoid='{"stx":"row"}'> hi
27918 ho</dd></dl>
27919
27920 <dl><dd> <table>
27921 <tbody><tr><td> ha
27922 ha
27923 ha</td></tr>
27924 </tbody></table></dd></dl>
27925 !! wikitext
27926 == testing 123 ==
27927
27928 == hi {{bogus|there
27929 you}} ==
27930
27931 == foo <ref>hello
27932 there</ref> ==
27933
27934 <references />
27935
27936 * asd sdf
27937
27938 * foo bar baz
27939 * foo '''bar''' baz
27940
27941 ; hi ho : hi ho
27942
27943 : {|
27944 | ha
27945 ha
27946 ha
27947 |}
27948 !! end
27949
27950 !! test
27951 Serialize new placeholder space without spans
27952 !! options
27953 parsoid=html2wt
27954 !! html/parsoid
27955 <p>foo<span typeof="mw:Placeholder"> </span>: bar</p>
27956
27957 <p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p>
27958
27959 <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>
27960 !! wikitext
27961 foo : bar
27962
27963 foo : bar
27964
27965 <ref>foo : bar</ref>ok
27966 !! end
27967
27968
27969 #-----------------------
27970 # Tag minimization tests
27971 #-----------------------
27972
27973 !! test
27974 1. I/B quote minimization: wikitext-only tags should be combined
27975 !! options
27976 parsoid=html2wt
27977 !! html/parsoid
27978 <p><i>A</i><i>B</i></p>
27979 <p><b>A</b><b>B</b></p>
27980 <p><i>A</i><b><i>B</i></b></p>
27981 <p><b>A</b><i><b>B</b></i></p>
27982 <p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p>
27983 <p><i><b>A</b></i><i><b>B</b></i></p>
27984 <p><i><b>A</b></i><b><i>B</i></b></p>
27985 <p><b><i>A</i></b><i><b>B</b></i></p>
27986 !! wikitext
27987 ''AB''
27988
27989 '''AB'''
27990
27991 ''A'''B'''''
27992
27993 '''A''B'''''
27994
27995 '''A''BC''D'''
27996
27997 '''''AB'''''
27998
27999 '''''AB'''''
28000
28001 '''''AB'''''
28002 !! end
28003
28004 !! test
28005 2. I/B quote minimization: wikitext and html tags should not be combined
28006 !! options
28007 parsoid=html2wt
28008 !! html/parsoid
28009 <p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
28010 <p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
28011 !! wikitext
28012 ''A''<i>B</i>
28013
28014 ''A''<nowiki/>'''<i>B</i>'''
28015 !! end
28016
28017 !! test
28018 3. I/B quote minimization: templated content stops minimization
28019 !! options
28020 parsoid=html2wt
28021 !! html/parsoid
28022 <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>
28023 <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>
28024 !! wikitext
28025 ''A''{{echo|''B''}}
28026
28027 ''A''{{echo|'''''B'''''}}
28028 !! end
28029
28030 !! test
28031 4. I/B quote minimization: new content should be mimimized with adjacent old content
28032 !! options
28033 parsoid=html2wt
28034 !! html/parsoid
28035 <p><i>A</i><i>B</i></p>
28036 <p><b>A</b><b>B</b></p>
28037 <p><i>A</i><b><i>B</i></b></p>
28038 !! wikitext
28039 ''AB''
28040
28041 '''AB'''
28042
28043 ''A'''B'''''
28044 !! end
28045
28046 !! test
28047 5a. Merge adjacent quote nodes if they've been edited
28048 !! options
28049 parsoid={
28050 "modes": ["wt2wt", "selser"],
28051 "changes": [
28052 ["p", "contents", "remove", ":contains('b')"]
28053 ]
28054 }
28055 !! wikitext
28056 ''a''b''c''
28057 !! wikitext/edited
28058 ''ac''
28059 !! end
28060
28061 !! test
28062 5b. Merge adjacent quote nodes if they've been edited
28063 !! options
28064 parsoid={
28065 "modes": ["wt2wt", "selser"],
28066 "changes": [
28067 ["#x", "remove"]
28068 ]
28069 }
28070 !! wikitext
28071 ''a''<span id="x">b</span>''c''
28072 !! wikitext/edited
28073 ''ac''
28074 !! end
28075
28076 !! test
28077 1. Merge adjacent link nodes as long as at least one element is new
28078 !! options
28079 parsoid={
28080 "modes": ["html2wt"],
28081 "scrubWikitext": true
28082 }
28083 !! html/parsoid
28084 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28085 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28086 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a>
28087 !! wikitext
28088 [[Football]]
28089 [[Football]]
28090 [[Football|Foot]][[Football|ball]]
28091 !! end
28092
28093 !! test
28094 2. Merge adjacent link nodes and enable additional normalizations
28095 !! options
28096 parsoid={
28097 "modes": ["html2wt"],
28098 "scrubWikitext": true
28099 }
28100 !! html/parsoid
28101 <a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a>
28102 !! wikitext
28103 [[Football|''Football'']]
28104 !! end
28105
28106 !! test
28107 3. Don't merge adjacent link nodes if scrubWikitext is false
28108 !! options
28109 parsoid={
28110 "modes": ["html2wt"],
28111 "scrubWikitext": false
28112 }
28113 !! html/parsoid
28114 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28115 !! wikitext
28116 [[Football|Foot]][[Football|ball]]
28117 !! end
28118
28119 #------------------------------
28120 # End of tag minimization tests
28121 #------------------------------
28122
28123 !!test
28124 T56262: New entities
28125 !! options
28126 parsoid=html2wt
28127 !! html/parsoid
28128 <span typeof="mw:Entity">&nbsp;</span>
28129 !! wikitext
28130 &nbsp;
28131 !! end
28132
28133 ## Note that there is no wikitext output for 'unknownproperty' ##
28134 ## Unknown magic words are silently dropped ##
28135
28136 !! test
28137 Magic words
28138 !! options
28139 parsoid=html2wt
28140 !! html/parsoid
28141 <meta property='mw:PageProp/toc' />
28142 <meta property='mw:PageProp/notoc' />
28143 <meta property='mw:PageProp/forcetoc' />
28144 <meta property='mw:PageProp/index' />
28145 <meta property='mw:PageProp/noindex' />
28146 <meta property='mw:PageProp/nogallery' />
28147 <meta property='mw:PageProp/noeditsection' />
28148 <meta property='mw:PageProp/notitleconvert' />
28149 <meta property='mw:PageProp/nocontentconvert' />
28150 <meta property='mw:PageProp/unknownproperty' />
28151 !! wikitext
28152 __TOC__
28153 __NOTOC__
28154 __FORCETOC__
28155 __INDEX__
28156 __NOINDEX__
28157 __NOGALLERY__
28158 __NOEDITSECTION__
28159 __NOTITLECONVERT__
28160 __NOCONTENTCONVERT__
28161 !! end
28162
28163 !! test
28164 Consecutive <pre>s should not get merged
28165 !! options
28166 parsoid=html2wt,html2html
28167 !! html/parsoid
28168 <pre>a</pre><pre>b</pre>
28169
28170 <pre>c
28171 </pre><pre>
28172 d</pre>
28173
28174 <pre>e
28175
28176 </pre><pre>
28177
28178 f</pre>
28179 !! wikitext
28180 a
28181
28182 b
28183
28184 c
28185
28186 d
28187
28188 e
28189
28190
28191
28192 f
28193 !! end
28194
28195 !! test
28196 Edited ISBN links not serializable as ISBN links should serialize as wikilinks
28197 !! options
28198 parsoid=html2wt
28199 !! html/parsoid
28200 <a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a>
28201 !! wikitext
28202 [[Special:BookSources/1234567890|ISBN 1234567895]]
28203 !! end
28204
28205 !! test
28206 Edited RFC links not serializable as RFC links should serialize as extlinks
28207 !! options
28208 parsoid=html2wt
28209 !! html/parsoid
28210 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
28211 !! wikitext
28212 [https://tools.ietf.org/html/rfc123 New RFC]
28213 !! end
28214
28215 !! test
28216 Edited PMID links not serializable as PMID links should serialize as extlinks
28217 !! options
28218 parsoid=html2wt
28219 !! html/parsoid
28220 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a>
28221 !! wikitext
28222 [//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID]
28223 !! end
28224
28225 !! test
28226 WTS of autolinks with trailing/surrounding context
28227 !! options
28228 parsoid=html2wt
28229 !! html/parsoid
28230 <p><a href="http://cscott.net">http://cscott.net</a><b>foo</b></p>
28231 <p><a href="http://cscott.net">http://cscott.net</a><b data-parsoid='{"stx":"html"}'>foo</b></p>
28232 <p><b><a href="http://cscott.net">http://cscott.net</a></b></p>
28233 <p><b><a href="http://cscott.net">http://cscott.net</a> </b></p>
28234 <p><b><a href="http://cscott.net">http://cscott.net</a>x</b></p>
28235 <p><a href="http://cscott.net">http://cscott.net</a>x</p>
28236 !! wikitext
28237 http://cscott.net'''foo'''
28238
28239 http://cscott.net<b>foo</b>
28240
28241 '''http://cscott.net'''
28242
28243 '''http://cscott.net '''
28244
28245 '''http://cscott.net<nowiki/>x'''
28246
28247 http://cscott.net<nowiki/>x
28248 !! end
28249
28250 !! test
28251 WTS of autolinks with nowikis (round-trip)
28252 !! wikitext
28253 x<nowiki/>http://cscott.net<nowiki/>x
28254 !! html/parsoid
28255 <p>x<a rel="mw:ExtLink" class="external free" href="http://cscott.net">http://cscott.net</a>x</p>
28256 !! end
28257
28258 # this is the "easy" test because it leaves in place all the
28259 # data-parsoid information indicating this is an autolink
28260 !! test
28261 WTS of autolinks with escapes (editing)
28262 !! options
28263 parsoid={
28264 "modes": ["wt2wt"],
28265 "changes": [
28266 [ "span", "remove" ]
28267 ]
28268 }
28269 !! wikitext
28270 x<nowiki/>http://cscott.net<nowiki/>x
28271 !! wikitext/edited
28272 x<nowiki/>http://cscott.net<nowiki/>x
28273 !! end
28274
28275 !! test
28276 WTS of edited autolink-like text (T103364)
28277 !! options
28278 parsoid={
28279 "modes": ["wt2wt"],
28280 "changes": [
28281 [ "span[typeof]", "removeAttr", "typeof" ]
28282 ]
28283 }
28284 !! wikitext
28285 Not a link: <nowiki>http://example.com</nowiki>.
28286 !! wikitext/edited
28287 Not a link: <span><nowiki>http://example.com</nowiki></span>.
28288 !! end
28289
28290 !! test
28291 WTS of newly-authored autolink-like text (T103364)
28292 !! options
28293 parsoid=html2wt
28294 !! html/parsoid
28295 <p>http://example.com is not a link.</p>
28296 !! wikitext
28297 <nowiki>http://example.com</nowiki> is not a link.
28298 !! end
28299
28300 !! test
28301 WTS of autolink-like text after an autolink (T108563)
28302 !! options
28303 parsoid=html2wt
28304 !! html/parsoid
28305 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p>
28306 !! wikitext
28307 http://example.com <nowiki>http://example.com</nowiki> is not a link.
28308 !! end
28309
28310 !! test
28311 Magic links inside links (not autolinked)
28312 !! wikitext
28313 [[Foo|http://example.com]]
28314 [[Foo|RFC 1234]]
28315 [[Foo|PMID 1234]]
28316 [[Foo|ISBN 123456789x]]
28317
28318 [http://foo.com http://example.com]
28319 [http://foo.com RFC 1234]
28320 [http://foo.com PMID 1234]
28321 [http://foo.com ISBN 123456789x]
28322 !! html+tidy
28323 <p><a href="/wiki/Foo" title="Foo">http://example.com</a>
28324 <a href="/wiki/Foo" title="Foo">RFC 1234</a>
28325 <a href="/wiki/Foo" title="Foo">PMID 1234</a>
28326 <a href="/wiki/Foo" title="Foo">ISBN 123456789x</a>
28327 </p><p><a rel="nofollow" class="external text" href="http://foo.com">http://example.com</a>
28328 <a rel="nofollow" class="external text" href="http://foo.com">RFC 1234</a>
28329 <a rel="nofollow" class="external text" href="http://foo.com">PMID 1234</a>
28330 <a rel="nofollow" class="external text" href="http://foo.com">ISBN 123456789x</a>
28331 </p>
28332 !! html/parsoid
28333 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a>
28334 <a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a>
28335 <a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a>
28336 <a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p>
28337
28338 <p><a rel="mw:ExtLink" class="external text" href="http://foo.com">http://example.com</a>
28339 <a rel="mw:ExtLink" class="external text" href="http://foo.com">RFC 1234</a>
28340 <a rel="mw:ExtLink" class="external text" href="http://foo.com">PMID 1234</a>
28341 <a rel="mw:ExtLink" class="external text" href="http://foo.com">ISBN 123456789x</a></p>
28342 !! end
28343
28344 !! test
28345 Magic links inside image captions (autolinked)
28346 !! wikitext
28347 [[File:Foobar.jpg|thumb|http://example.com]]
28348 [[File:Foobar.jpg|thumb|RFC 1234]]
28349 [[File:Foobar.jpg|thumb|PMID 1234]]
28350 [[File:Foobar.jpg|thumb|ISBN 123456789x]]
28351 !! html+tidy
28352 <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>
28353 <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>
28354 <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>
28355 <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>
28356 !! html/parsoid
28357 <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>
28358 <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 text">RFC 1234</a></figcaption></figure>
28359 <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 text">PMID 1234</a></figcaption></figure>
28360 <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>
28361 !! end
28362
28363 !! test
28364 WTS of magic word text (T109371)
28365 !! options
28366 parsoid=html2wt
28367 !! html/parsoid
28368 <p>RFC 1234</p>
28369 <p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p>
28370 <p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p>
28371 !! wikitext
28372 <nowiki>RFC 1234</nowiki>
28373
28374 [http://foo.com RFC 1234]
28375
28376 [[Foo|RFC 1234]]
28377 !! end
28378
28379 !! test
28380 Edited Redirect link should emit a non-piped wikitext link
28381 !! options
28382 parsoid=html2wt
28383 !! html/parsoid
28384 <link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>
28385 !! wikitext
28386 #REDIRECT [[Bar]]
28387 !! end
28388
28389 !! test
28390 T75121: Infer extension name from typeOf if data-mw is not present
28391 !! options
28392 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28393 !! html/parsoid
28394 <div typeOf="mw:Extension/foo"></div>
28395 !! wikitext
28396 <foo />
28397 !! end
28398
28399 # Note that the <p> wrapping isn't present in PHP parser output
28400 # The important thing for this test is that P-wrapping doesn't
28401 # interfere with the <nowiki> protection for leading - in <td>
28402 # (which isn't necessary for <th>).
28403 !! test
28404 T88318: p-wrapped dash in table.
28405 !! options
28406 parsoid=html2wt,wt2wt
28407 !! html/parsoid
28408 <table><tbody>
28409 <tr><th><p>-</p></th><th><p>- </p></th></tr>
28410 <tr><td><p>-</p></td><td><p>- </p></td></tr>
28411 <tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr>
28412 </tbody></table>
28413 !! wikitext
28414 {|
28415 !-
28416 !-
28417 |-
28418 |<nowiki>-</nowiki>
28419 |<nowiki>- </nowiki>
28420 |-
28421 |<small>-</small>
28422 |<br>
28423 -
28424 |<br>
28425 -
28426 |}
28427 !! html/php+tidy
28428 <table>
28429 <tbody><tr>
28430 <th>-
28431 </th>
28432 <th>-
28433 </th></tr>
28434 <tr>
28435 <td>-
28436 </td>
28437 <td>-
28438 </td></tr>
28439 <tr>
28440 <td><small>-</small>
28441 </td>
28442 <td><br />
28443 <p>-
28444 </p>
28445 </td>
28446 <td><br />
28447 <p>-
28448 </p>
28449 </td></tr></tbody></table>
28450 !! end
28451
28452 !! test
28453 T149209: WTS: Handle newlines in table cells properly
28454 !! options
28455 parsoid=html2wt
28456 !! html/parsoid
28457 <table>
28458 <tbody>
28459 <tr><td>a
28460 b
28461 </td><td data-parsoid='{"stx":"row"}'>c</td></tr>
28462 <tr><td><p>x</p>
28463 </td><td data-parsoid='{"stx":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr>
28464 </tbody></table>
28465 <table>
28466 <tbody>
28467 <tr><th>a
28468 b
28469 </th><th data-parsoid='{"stx":"row"}'>c</th></tr>
28470 <tr><th><p>x</h>
28471 </th><th data-parsoid='{"stx":"row"}'>y</th></tr>
28472 </tbody></table>
28473 !! wikitext
28474 {|
28475 |a
28476 b
28477 |c
28478 |-
28479 |x
28480 {{!}}y
28481 |}
28482 {|
28483 !a
28484 b
28485 !c
28486 |-
28487 !x
28488 !y
28489 |}
28490 !! end
28491
28492 !! test
28493 T149209: Selser: Handle newlines in table cells properly
28494 !! options
28495 parsoid={
28496 "modes": ["selser"],
28497 "changes": [
28498 [ "#h1", "html", "a\nb\n" ],
28499 [ "#h2", "html", "a\nb\n" ],
28500 [ "#c1", "html", "a\nb\n" ],
28501 [ "#c2", "html", "<p>a</p>" ],
28502 [ "#c3", "html", "<p>a</p>" ],
28503 [ "#c4", "html", "edit-me<p>a</p>" ]
28504 ]
28505 }
28506 !! wikitext
28507 {|
28508 ! id="h1" |edit-me!!1
28509 |-
28510 ! id="h2" |edit-me||2
28511 |-
28512 | id="c1" |edit-me||3
28513 |-
28514 | id="c2" |edit-me||4
28515 |-
28516 | id="c3" |edit-me||p||q||r
28517 |-
28518 | id="c4" |edit-me||p||q||r
28519 |}
28520 !! wikitext/edited
28521 {|
28522 ! id="h1" |a
28523 b
28524 !1
28525 |-
28526 ! id="h2" |a
28527 b
28528 !2
28529 |-
28530 | id="c1" |a
28531 b
28532 |3
28533 |-
28534 | id="c2" |a
28535 |4
28536 |-
28537 | id="c3" |a
28538 |p||q||r
28539 |-
28540 | id="c4" |edit-me
28541 a
28542 |p||q||r
28543 |}
28544 !! end
28545
28546 !! test
28547 HTML id attribute with Parsoid-like element ids should not be serialized to wikitext
28548 !! options
28549 parsoid=html2wt
28550 !! html/parsoid
28551 <table id='mwAb'>
28552 <td id='mwAc'>foo</td>
28553 <td id='serialize-this'>bar</td>
28554 </table>
28555 !! wikitext
28556 {|
28557 |foo
28558 | id="serialize-this" |bar
28559 |}
28560 !! end
28561
28562 !! test
28563 Parsoid-like element ids should not be serialized to wikitext unless shadowed
28564 !! options
28565 parsoid=html2wt
28566 !! html/parsoid
28567 <div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div>
28568 !! wikitext
28569 <div id="hello">ok</div>
28570 !! end
28571
28572 !! test
28573 WTS change modes
28574 !! options
28575 parsoid={
28576 "modes": ["wt2wt"],
28577 "changes": [
28578 [ "#xyz", "before", "<b>before</b> stuff " ],
28579 [ "#xyz", "after", " stuff <i>after</i>" ],
28580 [ "#xyz", "html", "x <b>y</b> z" ]
28581 ]
28582 }
28583 !! wikitext
28584 <span id="xyz">hello</span>
28585 !! wikitext/edited
28586 '''before''' stuff <span id="xyz">x '''y''' z</span> stuff ''after''
28587 !! end
28588
28589 !! test
28590 Never serialize a-tag as html, regardless of what data-parsoid has to say
28591 !! options
28592 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28593 !! html/parsoid
28594 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a>
28595 !! wikitext
28596 [[Foo]]
28597 !! end
28598
28599 ## SSS FIXME: This is broken output nevertheless.
28600 ## What might be a reasonable non-broken output for this?
28601 ## This is an edge case unlikely to be seen in production
28602 ## that I am not wasting more time on this right now.
28603 !! test
28604 Never serialize a-tag as html, no matter what attributes it has
28605 !! options
28606 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28607 !! html/parsoid
28608 <a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a>
28609 !! wikitext
28610 [http://boo.org http://boohoo.org]
28611 !! end
28612
28613 # Misnested is an indication that selser can reuse the source but these have
28614 # shown to sneak through on occasion. See T101768.
28615 # The original wikitext here is: [http://test.com [[one]] two three]
28616 !! test
28617 Strip span tags added to mark misnested links
28618 !! options
28619 parsoid=html2wt
28620 !! html/parsoid
28621 <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>
28622 !! wikitext
28623 [http://test.com][[one]] two three
28624 !! end
28625
28626 !! test
28627 Catch regression when unpacking misnested links
28628 !! options
28629 parsoid=wt2html
28630 !! wikitext
28631 {{echo|hi}}[http://example.com [[ho]]]
28632 !! html/parsoid
28633 <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>
28634 !! end
28635
28636 !! test
28637 Catch regression when unpacking with trailing content
28638 !! wikitext
28639 {{echo|Foo <references/> bar}}
28640 !! html/parsoid
28641 <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>
28642 !! end
28643
28644 !! test
28645 Use data-parsoid.firstWikitextNode to compute newline constraints for template content
28646 !! options
28647 parsoid=html2wt
28648 !! html/parsoid
28649 <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|}"]}'>
28650 <tbody><tr><td>d
28651 </td></tr>
28652 </tbody></table>
28653 !! wikitext
28654 {{echo|a}}
28655 {|{{echo|c
28656 {{!}}d
28657 }}
28658 |}
28659 !! end
28660
28661 ## This test verifies the presence and computation of this attribute indirectly
28662 ## by making an edit and ensuring that the serialization is correct (which it would be
28663 ## only if firstWikitextNode is properly set).
28664 !! test
28665 data-parsoid.firstWikitextNode should be computed properly in the presence of fostered content
28666 !! options
28667 parsoid= {
28668 "modes": ["wt2wt"],
28669 "changes": [
28670 [ "div#x", "remove" ],
28671 [ "div", "before", "<div>new</div>" ]
28672 ]
28673 }
28674 !! wikitext
28675 <div id="x">foo</div>
28676 {|
28677 {{echo|<div>boo</div>
28678 {{!}}b}}
28679 |c
28680 |}
28681 !! wikitext/edited
28682
28683 <div>new</div>
28684 {|
28685 {{echo|<div>boo</div>
28686 {{!}}b}}
28687 |c
28688 |}
28689 !! end
28690
28691 # --------------------------------------------
28692 # Tests spec'ing wikitext serialization norms |
28693 # --------------------------------------------
28694
28695 !! test
28696 Serialize multi-line indent-pre starting with wikitext syntax
28697 !! options
28698 parsoid=html2wt
28699 !! html/parsoid
28700 <pre>* 1
28701 ** 2
28702 * 3</pre>
28703 !! wikitext
28704 * 1
28705 ** 2
28706 * 3
28707 !! end
28708
28709 !! test
28710 1. Categories should always be serialized on their own line
28711 !! options
28712 parsoid=html2wt
28713 !! html/parsoid
28714 foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar
28715 !! wikitext
28716 foo
28717 [[Category:Foo]]
28718 bar
28719 !! end
28720
28721 !! test
28722 2. Categories that are part of templates should not introduce a line break
28723 !! wikitext
28724 foo {{echo|<span>bar</span> [[Category:baz]]}} bar
28725 !! html/parsoid
28726 <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>
28727 !! end
28728
28729 # Careful while editing these next 2 tests. There are \u200f characters
28730 # before and after the <link> tags in the HTML and following some
28731 # of the categories in wikitext
28732 # Do not remove these characters in edits.
28733 #
28734 # As part of the serialization, these bidi characters will get stripped.
28735 !! test
28736 RTL (\u200f) and LTR (\u200e) markers around category tags should be stripped
28737 !! options
28738 parsoid={
28739 "modes": ["html2wt"],
28740 "scrubWikitext": true
28741 }
28742 !! html/parsoid
28743 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏
28744 ‏<link rel="mw:PageProp/Category" href="./קטגוריה:_שיטות_משפט" />‏</p>
28745 !! wikitext
28746 [[קטגוריה:טקסים]]
28747 [[קטגוריה: שיטות משפט]]
28748 !! end
28749
28750 !! test
28751 RTL (\u200f) and LTR (\u200e) markers should not be stripped if followed by a text node
28752 !! options
28753 parsoid={
28754 "modes": ["html2wt"],
28755 "scrubWikitext": true
28756 }
28757 !! html/parsoid
28758 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏y</p>
28759 !! wikitext
28760 [[קטגוריה:טקסים]]
28761 ‏y
28762 !! end
28763
28764 !! test
28765 Lists: Add space after bullets
28766 !! options
28767 parsoid=html2wt
28768 !! html/parsoid
28769 <ul>
28770 <li>foo</li>
28771 <li> bar</li>
28772 <li><span> baz</span></li>
28773 </ul>
28774 !! wikitext
28775 * foo
28776 * bar
28777 * <span> baz</span>
28778 !! end
28779
28780 !! test
28781 1. Headings: Add space before/after == (T53744)
28782 !! options
28783 parsoid=html2wt
28784 !! html/parsoid
28785 <h2>foo</h2>
28786 <h2> bar</h2>
28787 <h2>baz </h2>
28788 <h2><span> baz</span></h2>
28789 !! wikitext
28790 == foo ==
28791
28792 == bar ==
28793
28794 == baz ==
28795
28796 == <span> baz</span> ==
28797 !! end
28798
28799 !! test
28800 2. Headings: Add space before/after == even after hoisted content
28801 !! options
28802 parsoid={
28803 "modes": ["html2wt"],
28804 "scrubWikitext": true
28805 }
28806 !! html/parsoid
28807 <h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2>
28808 !! wikitext
28809 [[Category:A2]]
28810
28811 == ok ==
28812 !! end
28813
28814 !! test
28815 1. Headings: suppress newly created empty headings
28816 !! options
28817 parsoid={
28818 "modes": ["html2wt"],
28819 "scrubWikitext": true
28820 }
28821 !! html/parsoid
28822 <h2></h2>
28823 !! wikitext
28824 !! end
28825
28826 !! test
28827 2. Headings: don't suppress empty headings if scrubWikitext is false
28828 !! options
28829 parsoid=html2wt
28830 !! html/parsoid
28831 <h2></h2>
28832 !! wikitext
28833 ==<nowiki/>==
28834 !! end
28835
28836 !! test
28837 3. Headings: suppress empty headings on edits
28838 !! options
28839 parsoid={
28840 "modes": ["selser"],
28841 "scrubWikitext": true,
28842 "changes": [
28843 [ "#x", "remove"]
28844 ]
28845 }
28846 !! wikitext
28847 ==<span id="x">foo</span>==
28848 !! wikitext/edited
28849 !! end
28850
28851 !! test
28852 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = true)
28853 !! options
28854 parsoid={
28855 "modes": ["html2wt"],
28856 "scrubWikitext": true
28857 }
28858 !! html/parsoid
28859 <h2>foo<br/>bar</h2>
28860 <h2>foo <span><br/>bar</span> baz</h2>
28861 !! wikitext
28862 == foo bar ==
28863
28864 == foo <span> bar</span> baz ==
28865 !! end
28866
28867 !! test
28868 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = false)
28869 !! options
28870 parsoid={
28871 "modes": ["html2wt"],
28872 "scrubWikitext": false
28873 }
28874 !! html/parsoid
28875 <h2>foo<br/>bar</h2>
28876 !! wikitext
28877 == foo<br> bar ==
28878 !! end
28879
28880 !! test
28881 1. WT Quote Tags: suppress newly created empty style tags
28882 !! options
28883 parsoid={
28884 "modes": ["html2wt"],
28885 "scrubWikitext": true
28886 }
28887 !! html/parsoid
28888 <i></i><b></b>
28889 !! wikitext
28890 !! end
28891
28892 !! test
28893 2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false
28894 !! options
28895 parsoid=html2wt
28896 !! html/parsoid
28897 <i></i><b></b>
28898 !! wikitext
28899 ''<nowiki/>'''''<nowiki/>'''
28900 !! end
28901
28902 !! test
28903 3. WT Quote Tags: suppress empty style tags on edits
28904 !! options
28905 parsoid={
28906 "modes": ["selser"],
28907 "scrubWikitext": true,
28908 "changes": [
28909 [ "#x", "remove"]
28910 ]
28911 }
28912 !! wikitext
28913 '''<span id="x">foo</span>'''
28914 !! wikitext/edited
28915 !! end
28916
28917 !! test
28918 1. Anchors: suppress newly created empty anchors
28919 !! options
28920 parsoid={
28921 "modes": ["html2wt"],
28922 "scrubWikitext": true
28923 }
28924 !! html/parsoid
28925 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
28926 !! wikitext
28927 !! end
28928
28929 !! test
28930 2. Anchors: don't suppress empty anchors if scrubWikitext is false
28931 !! options
28932 parsoid={
28933 "modes": ["html2wt"],
28934 "scrubWikitext": false
28935 }
28936 !! html/parsoid
28937 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
28938 !! wikitext
28939 [[Test|<nowiki/>]]
28940 !! end
28941
28942 !! test
28943 3. Anchors: suppress empty anchors on edits
28944 !! options
28945 parsoid={
28946 "modes": ["selser"],
28947 "scrubWikitext": true,
28948 "changes": [
28949 [ "#x", "remove"]
28950 ]
28951 }
28952 !! wikitext
28953 [[Test|<span id="x">foo</span>]]
28954 !! wikitext/edited
28955 !! end
28956
28957 !! test
28958 3a. Anchors: do not suppress numbered extlinks
28959 !! options
28960 parsoid={
28961 "modes": ["wt2wt"],
28962 "scrubWikitext": true
28963 }
28964 !! wikitext
28965 [http://foo.com]
28966 !! html/parsoid
28967 <a rel="mw:ExtLink" href="http://foo.com"></a>
28968 !! end
28969
28970 !! test
28971 3b. Anchors: do not suppress numbered extlinks
28972 !! options
28973 parsoid={
28974 "modes": ["wt2wt"],
28975 "scrubWikitext": true,
28976 "changes": [
28977 [ "#x", "remove"]
28978 ]
28979 }
28980 !! wikitext
28981 [http://foo.com <span id="x">foo</span>]
28982 !! wikitext/edited
28983 [http://foo.com]
28984 !! end
28985
28986 !!test
28987 Normalizations should be restricted to edited content
28988 !!options
28989 parsoid={
28990 "modes": ["selser"],
28991 "scrubWikitext": true,
28992 "changes": [
28993 [ "h1", "before", "<i></i>"]
28994 ]
28995 }
28996 !!wikitext
28997 a
28998 = =
28999 b
29000 !!wikitext/edited
29001 a
29002 = =
29003 b
29004 !!end
29005
29006 !! test
29007 1. Multiple normalizations (html2wt)
29008 !! options
29009 parsoid={
29010 "modes": ["html2wt"],
29011 "scrubWikitext": true
29012 }
29013 !! html
29014 <h2><i></i></h2>
29015 <p><a href='Foo' rel='mw:WikiLink'>foo<i></i>
29016 </a><b><i></i></b>x</p>
29017 !! wikitext
29018
29019 [[foo]]
29020 x
29021
29022 !! end
29023
29024 !! test
29025 2. Multiple normalizations (selser)
29026 !! options
29027 parsoid={
29028 "modes": ["selser"],
29029 "scrubWikitext": true,
29030 "changes": [
29031 [ "#x", "after", "<h1><i></i></h1>\n<p> x<b></b></p>"]
29032 ]
29033 }
29034 !! wikitext
29035 <span id="x">foo</span>
29036 !! wikitext/edited
29037 <span id="x">foo</span>
29038
29039 x
29040 !! end
29041
29042 !! test
29043 1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
29044 !! options
29045 parsoid={
29046 "modes": ["html2wt"],
29047 "scrubWikitext": true
29048 }
29049 !! html/parsoid
29050 <p> hi</p>
29051 <p> hello</p>
29052 !! wikitext
29053 hi
29054
29055 hello
29056 !! end
29057
29058 !! test
29059 2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false
29060 !! options
29061 parsoid=html2wt
29062 !! html/parsoid
29063 <p> hi</p>
29064 <p> hello</p>
29065 !! wikitext
29066 <nowiki> </nowiki>hi
29067
29068 <nowiki> </nowiki> hello
29069 !! end
29070
29071 !! test
29072 3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
29073 !! options
29074 parsoid={
29075 "modes": ["html2wt"],
29076 "scrubWikitext": true
29077 }
29078 !! html/parsoid
29079 <p>Foo
29080 bar
29081 baz</p>
29082
29083 <table><tr><td>Foo
29084 bar
29085 baz bang</td></tr></table>
29086
29087 <p><!--boo--> foo
29088 bar</p>
29089
29090 <p> foo
29091 bar<span>boo</span></p>
29092 !! wikitext
29093 Foo
29094 bar
29095 baz
29096
29097 {|
29098 |Foo
29099 bar
29100 baz bang
29101 |}
29102
29103 <!--boo-->foo
29104 bar
29105
29106 foo
29107 bar<span>boo</span>
29108 !! end
29109
29110 !! test
29111 4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs
29112 !! options
29113 parsoid={
29114 "modes": ["selser"],
29115 "scrubWikitext": true,
29116 "changes": [
29117 [ "p", "html", " a\n b" ]
29118 ]
29119 }
29120 !! wikitext
29121 xyz
29122 !! wikitext/edited
29123 a
29124 b
29125 !! end
29126
29127 !! test
29128 1. New links that end in spaces
29129 !! options
29130 parsoid={
29131 "modes": ["html2wt"],
29132 "scrubWikitext": false
29133 }
29134 !! html/parsoid
29135 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
29136 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
29137 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
29138 !! wikitext
29139 [[Berlin ]]<nowiki/>is the capital of Germany.
29140
29141 [[Foo ]]'''bar'''
29142
29143 [[Boston ]] is a city.
29144 !! end
29145
29146 !! test
29147 2. New links that end in spaces
29148 !! options
29149 parsoid={
29150 "modes": ["html2wt"],
29151 "scrubWikitext": true
29152 }
29153 !! html/parsoid
29154 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
29155 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
29156 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
29157 !! wikitext
29158 [[Berlin]] is the capital of Germany.
29159
29160 [[Foo]] '''bar'''
29161
29162 [[Boston]] is a city.
29163 !! end
29164
29165 !! test
29166 1. Table cells with escapable prefixes
29167 !! options
29168 parsoid={
29169 "modes": ["html2wt"],
29170 "scrubWikitext": false
29171 }
29172 !! html
29173 <table>
29174 <tr><td>a</td></tr>
29175 <tr><td>-</td></tr>
29176 <tr><td>+</td></tr>
29177 </table>
29178 !! wikitext
29179 {|
29180 |a
29181 |-
29182 |<nowiki>-</nowiki>
29183 |-
29184 |<nowiki>+</nowiki>
29185 |}
29186 !! end
29187
29188 !! test
29189 2. Table cells with escapable prefixes
29190 !! options
29191 parsoid={
29192 "modes": ["html2wt"],
29193 "scrubWikitext": true
29194 }
29195 !! html
29196 <table>
29197 <tr><td>a</td></tr>
29198 <tr><td>-</td></tr>
29199 <tr><td>+</td></tr>
29200 </table>
29201 !! wikitext
29202 {|
29203 |a
29204 |-
29205 | -
29206 |-
29207 | +
29208 |}
29209 !! end
29210
29211 !! test
29212 3a. Table cells with escapable prefixes after edits
29213 !! options
29214 parsoid={
29215 "modes": ["selser"],
29216 "scrubWikitext": true,
29217 "changes": [
29218 [ "table tbody tr:first-child td:first-child", "remove"]
29219 ]
29220 }
29221 !! wikitext
29222 {|
29223 |a||-
29224 |}
29225 !! wikitext/edited
29226 {|
29227 | -
29228 |}
29229 !! end
29230
29231 !! test
29232 3b. Table cells with escapable prefixes after edits
29233 !! options
29234 parsoid={
29235 "modes": ["selser"],
29236 "scrubWikitext": true,
29237 "changes": [
29238 [ "table tbody tr:first-child td:first-child", "html", "-" ],
29239 [ "#x", "remove" ]
29240 ]
29241 }
29242 !! wikitext
29243 {|
29244 |pqr
29245 |<span id="x">foo</span>+
29246 |}
29247 !! wikitext/edited
29248 {|
29249 | -
29250 | +
29251 |}
29252 !! end
29253
29254 # FIXME: This test will fail because
29255 # normalization doesn't realize that the id attribute
29256 # will eliminate the escapable scenario
29257 !! test
29258 4a. Table cells without escapable prefixes after edits
29259 !! options
29260 parsoid={
29261 "modes": ["selser"],
29262 "scrubWikitext": true,
29263 "changes": [
29264 [ "#x", "html", "-" ]
29265 ]
29266 }
29267 !! wikitext
29268 {|
29269 | id="x" |abcd
29270 |}
29271 !! wikitext/edited
29272 {|
29273 | id="x" |-
29274 |}
29275 !! end
29276
29277 ## This tests normalizer's ability to discriminate between
29278 ## cells having identical content.
29279 !! test
29280 4b. Table cells without escapable prefixes after edits
29281 !! options
29282 parsoid={
29283 "modes": ["selser"],
29284 "scrubWikitext": true,
29285 "changes": [
29286 [ "td", "html", "-" ]
29287 ]
29288 }
29289 !! wikitext
29290 {|
29291 |a||b
29292 |}
29293 !! wikitext/edited
29294 {|
29295 | -||-
29296 |}
29297 !! end
29298
29299 ## This tests normalizer's ability to not be tripped by
29300 ## comments (and whitespace)
29301 !! test
29302 4c. Table cells without escapable prefixes after edits
29303 !! options
29304 parsoid={
29305 "modes": ["selser"],
29306 "scrubWikitext": true,
29307 "changes": [
29308 [ "table tbody tr td:first-child", "remove" ]
29309 ]
29310 }
29311 !! wikitext
29312 {|
29313 |-
29314 <!--foo--> |a||-
29315 |}
29316 !! wikitext/edited
29317 {|
29318 |-
29319 <!--foo--> | -
29320 |}
29321 !! end
29322
29323 ## This tests normalizer's ability to handle HTML cells
29324 !! test
29325 4d. Table cells without escapable prefixes after edits
29326 !! options
29327 parsoid={
29328 "modes": ["selser"],
29329 "scrubWikitext": true,
29330 "changes": [
29331 [ "td", "html", "-" ]
29332 ]
29333 }
29334 !! wikitext
29335 <table>
29336 <tr><td>a</td></tr>
29337 </table>
29338 !! wikitext/edited
29339 <table>
29340 <tr><td>-</td></tr>
29341 </table>
29342 !! end
29343
29344 ## T111151 Remove font elements without attributes
29345 !! test
29346 5a. font tags without attributes should be dropped in scrubWikitext mode
29347 !! options
29348 parsoid={
29349 "modes": ["html2wt"],
29350 "scrubWikitext": true
29351 }
29352 !! html
29353 <font>foo</font>
29354 <font><font>bar</font></font>
29355 <font class="x">boo</font>
29356 !! wikitext
29357 foo
29358 bar
29359 <font class="x">boo</font>
29360 !! end
29361
29362 !! test
29363 5b. font tags should not be dropped without scrubWikitext being enabled
29364 !! options
29365 parsoid={
29366 "modes": ["html2wt"],
29367 "scrubWikitext": false
29368 }
29369 !! html
29370 <font>foo</font>
29371 !! wikitext
29372 <font>foo</font>
29373 !! end
29374
29375 !! test
29376 Escape nowiki DOM elements
29377 !! options
29378 parsoid=html2wt
29379 !! html/parsoid
29380 <nowiki><i>foo</i></nowiki>
29381 !! wikitext
29382 &lt;nowiki&gt;''foo''&lt;/nowiki&gt;
29383 !! end
29384
29385 # This is meant to be an interim fix while we go about figuring out
29386 # how to not introduce these trailing <nowiki/>s in the first place.
29387 !! test
29388 T115717: Strip trailing <nowiki/>s (without affecting valid uses)
29389 !! options
29390 parsoid=html2wt
29391 !! html/parsoid
29392 <p>x<meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/>
29393 y</p>
29394 <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>
29395 <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>
29396 !! wikitext
29397 x
29398 y
29399
29400 {{echo|
29401 1 = <nowiki/>}}
29402
29403 {{echo|
29404 1 = <nowiki/>
29405 }}
29406 !! end
29407
29408 # ---------------------------------------------------
29409 # End of tests spec'ing wikitext serialization norms |
29410 # ---------------------------------------------------
29411
29412 # T104032
29413 !! test
29414 Bare inline nodes not wrapped inside p-tags should be treated as p-wrapped
29415 !! options
29416 parsoid=html2wt
29417 !! html/parsoid
29418 a<p>b</p>
29419 <b>c</b><p>d</p>
29420 <table><tr>
29421 <td>a<p>b</p></td>
29422 <td><b>c</b><p>d</p></td>
29423 </tr></table>
29424 !! wikitext
29425 a
29426
29427 b
29428
29429 '''c'''
29430
29431 d
29432 {|
29433 |a
29434 b
29435 |'''c'''
29436 d
29437 |}
29438 !! end
29439
29440 !! test
29441 Anchor without href scenarios
29442 !! options
29443 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
29444 !! html/parsoid
29445 <a class="bc"></a>
29446 <a class="no">dice</a>
29447 <a name="foo"></a>
29448 !! wikitext
29449
29450 dice
29451 <span name="foo"></span>
29452 !! end
29453
29454 !! test
29455 New transclusion added after a list should be serialized after the list
29456 !! options
29457 parsoid=html2wt
29458 !! html/parsoid
29459 <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>
29460 !! wikitext
29461 * a
29462 {{echo|foo}}
29463 !! end
29464
29465 # -----------------------------------------------------------------
29466 # End of section for Parsoid-only html2wt tests for serialization
29467 # of new content
29468 # -----------------------------------------------------------------
29469
29470 # -----------------------------------------------------------------
29471 # The following section of tests are primarily to spec behavior of
29472 # the selective serializer. All these tests have manual selser
29473 # changes. The automated selser changes for all tests handle the
29474 # wide variation of changes, but these tests here capture specs
29475 # deterministically.
29476 # ----------------------------------------------------------------
29477
29478 ## T90517
29479 !! test
29480 Selser: New comments should not be lost
29481 !! options
29482 parsoid={
29483 "modes": ["selser"],
29484 "changes": [
29485 [ "#a", "after", "<!--c1-->" ],
29486 [ "#b", "before", "<!--c2-->" ]
29487 ]
29488 }
29489 !! wikitext
29490 <span id="a">a</span>
29491
29492 <span id="b">b</span>
29493 !! wikitext/edited
29494 <span id="a">a</span><!--c1-->
29495
29496 <!--c2--><span id="b">b</span>
29497 !! end
29498
29499 ## T89383
29500 !! test
29501 Selser: Check for validity of DSR before using it
29502 !! options
29503 parsoid={
29504 "modes": ["selser"],
29505 "changes": [
29506 [ "#a", "before", "<meta property='mw:PageProp/displaytitle' content='foo'>" ]
29507 ]
29508 }
29509 !! wikitext
29510 <span id="a">a</span>
29511 !! wikitext/edited
29512 {{DISPLAYTITLE:foo}}
29513 <span id="a">a</span>
29514 !! end
29515
29516 !! test
29517 1. DOMDiff: Changes to <ref> content should be looked up using id
29518 !! options
29519 parsoid={
29520 "modes": ["selser"],
29521 "changes": [
29522 ["#X", "after", "bar"],
29523 ["#Y", "after", "baz"]
29524 ]
29525 }
29526 !! wikitext
29527 X <ref><span id="X">foo</span></ref>
29528 Y <ref name="a" />
29529 <references>
29530 <ref name="a"><span id="Y">foo</span></ref>
29531 </references>
29532 !! wikitext/edited
29533 X <ref><span id="X">foo</span>bar</ref>
29534 Y <ref name="a" />
29535 <references>
29536 <ref name="a"><span id="Y">foo</span>baz</ref>
29537 </references>
29538 !! end
29539
29540 !! test
29541 2. DOMDiff: Changes to <ref> content should be looked up using id
29542 !! options
29543 parsoid={
29544 "modes": ["selser"],
29545 "changes": [
29546 ["#Z", "after", "bar"]
29547 ]
29548 }
29549 !! wikitext
29550 A <ref>foo bar for a</ref>
29551 B <ref group="X" name="b" />
29552
29553 <references />
29554
29555 <references group="X">
29556 <ref name="b"><span id="Z">foo</span></ref>
29557 </references>
29558 !! wikitext/edited
29559 A <ref>foo bar for a</ref>
29560 B <ref group="X" name="b" />
29561
29562 <references />
29563
29564 <references group="X">
29565 <ref name="b"><span id="Z">foo</span>bar</ref>
29566 </references>
29567 !! end
29568
29569 !! test
29570 DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388)
29571 !! options
29572 parsoid={
29573 "modes": ["selser"],
29574 "changes": [
29575 [ "div:first-child", "text", "bar" ]
29576 ]
29577 }
29578 !! wikitext
29579 <div style="{{1x|color:red;}}%">foo</div>
29580 !! wikitext/edited
29581 <div style="{{1x|color:red;}}%">bar</div>
29582 !! end
29583
29584 !! test
29585 Empty LI (T49673)
29586 !! wikitext
29587 * a
29588 *
29589 *
29590 * b
29591 !! html+tidy
29592 <ul><li> a</li>
29593 <li class="mw-empty-elt"> </li>
29594 <li class="mw-empty-elt"></li>
29595 <li> b</li></ul>
29596 !! end
29597
29598 !! test
29599 Thumbnail output
29600 !! wikitext
29601 [[File:Thumb.png|thumb]]
29602 !! html/php+tidy
29603 <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>
29604 !! html/parsoid
29605 <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>
29606 !! end
29607
29608 !! test
29609 unclosed internal link XSS (T137264)
29610 !! wikitext
29611 [[#%3Cscript%3Ealert(1)%3C/script%3E|
29612 !! html/php
29613 <p>[[#&lt;script&gt;alert(1)&lt;/script&gt;|
29614 </p>
29615 !! html/parsoid
29616 <p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p>
29617 !! end
29618
29619 !! test
29620 Validating that <style> isn't eaten by tidy (T167349)
29621 !! options
29622 styletag=1
29623 !! wikitext
29624 <div class="foo">
29625 <style>.foo::before { content: "<foo>"; }</style>
29626 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
29627 </div>
29628 !! html/php+tidy
29629 <div class="foo">
29630 <style>.foo::before { content: "<foo>"; }</style>
29631 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
29632 </div>
29633 !! end
29634
29635 !! test
29636 Validating that <style> isn't wrapped in a paragraph (T186965)
29637 !! options
29638 styletag=1
29639 !! wikitext
29640 A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
29641
29642 <style>.foo::before { content: "<foo>"; }</style>
29643
29644 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
29645
29646 But if it's on a line with other content, let it be wrapped.
29647
29648 <style>.foo::before { content: "<foo>"; }</style> bar
29649
29650 foo <style>.foo::before { content: "<foo>"; }</style>
29651
29652 foo <style>.foo::before { content: "<foo>"; }</style> bar
29653
29654 And the same if we have non-paragraph-breaking whitespace
29655
29656 foo
29657 <style>.foo::before { content: "<foo>"; }</style>
29658 bar
29659 !! html/php
29660 <p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
29661 </p>
29662 <style>.foo::before { content: "<foo>"; }</style>
29663 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
29664 <p>But if it's on a line with other content, let it be wrapped.
29665 </p><p><style>.foo::before { content: "<foo>"; }</style> bar
29666 </p><p>foo <style>.foo::before { content: "<foo>"; }</style>
29667 </p><p>foo <style>.foo::before { content: "<foo>"; }</style> bar
29668 </p><p>And the same if we have non-paragraph-breaking whitespace
29669 </p><p>foo
29670 <style>.foo::before { content: "<foo>"; }</style>
29671 bar
29672 </p>
29673 !! end
29674
29675 !! test
29676 Validating that <link> isn't wrapped in a paragraph (T186965)
29677 !! options
29678 styletag=1
29679 !! wikitext
29680 A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
29681
29682 <link rel="foo" href="bar"/>
29683
29684 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
29685
29686 But if it's on a line with other content, let it be wrapped.
29687
29688 <link rel="foo" href="bar"/> bar
29689
29690 foo <link rel="foo" href="bar"/>
29691
29692 foo <link rel="foo" href="bar"/> bar
29693
29694 And the same if we have non-paragraph-breaking whitespace
29695
29696 foo
29697 <link rel="foo" href="bar"/>
29698 bar
29699 !! html/php
29700 <p>A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
29701 </p>
29702 <link rel="foo" href="bar"/>
29703 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
29704 <p>But if it's on a line with other content, let it be wrapped.
29705 </p><p><link rel="foo" href="bar"/> bar
29706 </p><p>foo <link rel="foo" href="bar"/>
29707 </p><p>foo <link rel="foo" href="bar"/> bar
29708 </p><p>And the same if we have non-paragraph-breaking whitespace
29709 </p><p>foo
29710 <link rel="foo" href="bar"/>
29711 bar
29712 </p>
29713 !! end
29714
29715 !! test
29716 Decoding of HTML entities in headings and links for IDs and link fragments (T103714)
29717 !! config
29718 wgFragmentMode=[ 'html5', 'legacy' ]
29719 !! wikitext
29720 == A&B&amp;C&amp;amp;D&amp;amp;amp;E ==
29721 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
29722 !! html/php
29723 <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>
29724 <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>
29725 </p>
29726 !! html/parsoid
29727 <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>
29728 <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>
29729 !! end
29730
29731 !! test
29732 Decoding of HTML entities in headings and links for IDs and link fragments (T103714) (legacy)
29733 !! config
29734 wgFragmentMode=[ 'legacy' ]
29735 !! wikitext
29736 == A&B&amp;C&amp;amp;D&amp;amp;amp;E ==
29737 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
29738 !! html/php
29739 <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>
29740 <p><a href="#A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a>
29741 </p>
29742 !! end
29743
29744 !! test
29745 Decoding of HTML entities in embedded HTML tags
29746 !! wikitext
29747 <table class="1&2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
29748 !! html/php
29749 <table class="1&amp;2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
29750
29751 !! html/parsoid
29752 <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>
29753 !! end
29754
29755 !! test
29756 Decoding of HTML entities in indicator names for IDs (T104196)
29757 !! options
29758 parsoid=wt2html,html2html
29759 showindicators
29760 !! wikitext
29761 <indicator name="1&2&amp;3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
29762 !! html/php
29763 1&2&3&amp;4&amp;amp;5=Indicator
29764
29765 !! html/parsoid
29766 <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>
29767 !! end
29768
29769 # this version of the test strips out the ambiguity so Parsoid rts cleanly
29770 !! test
29771 Decoding of HTML entities in indicator names for IDs (unambiguous) (T104196)
29772 !! options
29773 showindicators
29774 !! wikitext
29775 <indicator name="1&2&3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
29776 !! html/php
29777 1&2&3&amp;4&amp;amp;5=Indicator
29778
29779 !! html/parsoid
29780 <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>
29781 !! end
29782
29783 # This fragment mode is what Parsoid supports.
29784 !! test
29785 HTML5 ids: fallback to legacy
29786 !! config
29787 wgFragmentMode=[ 'html5', 'legacy' ]
29788 !! wikitext
29789 == Foo bar ==
29790
29791 == foo Bar ==
29792
29793 == Тест ==
29794
29795 == Тест ==
29796
29797 == тест ==
29798
29799 == Hey < # " > % : ' ==
29800 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
29801
29802 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
29803
29804 <!-- These two links should produce identical HTML -->
29805 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
29806
29807 !! html/php
29808 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
29809 <ul>
29810 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
29811 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
29812 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
29813 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
29814 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
29815 <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>
29816 </ul>
29817 </div>
29818
29819 <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>
29820 <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>
29821 <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>
29822 <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>
29823 <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>
29824 <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>
29825 <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>
29826 </p><p>💩 <span id="💩"></span>
29827 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
29828 </p>
29829 !! html/parsoid
29830 <h2 id="Foo_bar"> Foo bar </h2>
29831
29832 <h2 id="foo_Bar_2"> foo Bar </h2>
29833
29834 <h2 id="Тест"><span id=".D0.A2.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span> Тест </h2>
29835
29836 <h2 id="Тест_2"><span id=".D0.A2.D0.B5.D1.81.D1.82_2" typeof="mw:FallbackId"></span> Тест </h2>
29837
29838 <h2 id="тест"><span id=".D1.82.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span> тест </h2>
29839
29840 <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>
29841 <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>
29842
29843 <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\":[190,209,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"anchorencode:💩\",\"function\":\"anchorencode\"},\"params\":{},\"i\":0}}]}&#39;>💩&lt;/span>"}]]}'></span></p>
29844
29845 <!-- These two links should produce identical HTML -->
29846 <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>
29847 !! end
29848
29849 # Parsoid doesn't support this mode
29850 !! test
29851 HTML5 ids: legacy with a fallback to modern
29852 !! config
29853 wgFragmentMode=[ 'legacy', 'html5' ]
29854 !! wikitext
29855 == Foo bar ==
29856
29857 == foo Bar ==
29858
29859 == Тест ==
29860
29861 == Тест ==
29862
29863 == тест ==
29864
29865 == Hey < # " > % : ' ==
29866 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
29867
29868 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
29869
29870 <!-- These two links should produce identical HTML -->
29871 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
29872
29873 !! html/php
29874 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
29875 <ul>
29876 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
29877 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
29878 <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>
29879 <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>
29880 <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>
29881 <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>
29882 </ul>
29883 </div>
29884
29885 <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>
29886 <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>
29887 <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>
29888 <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>
29889 <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>
29890 <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>
29891 <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>
29892 </p><p>.F0.9F.92.A9 <span id=".F0.9F.92.A9"></span>
29893 </p><p><a href="#.E5.95.A4.E9.85.92">#啤酒</a> <a href="#.E5.95.A4.E9.85.92">#啤酒</a>
29894 </p>
29895 !! end
29896
29897 # Parsoid doesn't support this mode.
29898 !! test
29899 HTML5 ids: no legacy
29900 !! config
29901 wgFragmentMode=[ 'html5' ]
29902 !! wikitext
29903 == Foo bar ==
29904
29905 == foo Bar ==
29906
29907 == Тест ==
29908
29909 == Тест ==
29910
29911 == тест ==
29912
29913 == Hey < # " > % : ' ==
29914 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
29915
29916 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
29917
29918 <!-- These two links should produce identical HTML -->
29919 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
29920
29921 !! html/php
29922 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
29923 <ul>
29924 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
29925 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
29926 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
29927 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
29928 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
29929 <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>
29930 </ul>
29931 </div>
29932
29933 <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>
29934 <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>
29935 <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>
29936 <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>
29937 <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>
29938 <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>
29939 <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>
29940 </p><p>💩 <span id="💩"></span>
29941 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
29942 </p>
29943 !! end
29944
29945 !! test
29946 T90902: Normalize weird characters in section IDs
29947 !! config
29948 wgFragmentMode=[ 'html5', 'legacy' ]
29949 !! wikitext
29950 == Foo&nbsp;bar ==
29951 [[#Foo&nbsp;bar]]
29952
29953 !! html/php
29954 <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>
29955 <p><a href="#Foo_bar">#Foo&#160;bar</a>
29956 </p>
29957 !! end
29958
29959 !! test
29960 T51672: Test for brackets in attributes of elements in external link texts
29961 !! wikitext
29962 [http://example.com/ link <span title="title with [brackets]">span</span>]
29963 [http://example.com/ link <span title="title with &#91;brackets&#93;">span</span>]
29964
29965 !! html/php
29966 <p><a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
29967 <a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
29968 </p>
29969 !! html/parsoid
29970 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/">link <span title="title with [brackets]">span</span></a>
29971 <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>
29972 !! end
29973
29974 !! test
29975 T72875: Test for brackets in attributes of elements in internal link texts
29976 !! wikitext
29977 [[Foo|link <span title="title with [[double brackets]]">span</span>]]
29978 [[Foo|link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span>]]
29979
29980 !! html/php
29981 <p><a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
29982 <a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
29983 </p>
29984 !! html/parsoid
29985 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">link <span title="title with [[double brackets]]">span</span></a>
29986 <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>
29987 !! end
29988
29989 !! test
29990 T179544: {{anchorencode:}} output should be always usable in links
29991 !! config
29992 wgFragmentMode=[ 'html5' ]
29993 !! wikitext
29994 <span id="{{anchorencode:[foo]}}"></span>[[#{{anchorencode:[foo]}}]]
29995 !! html/php
29996 <p><span id="&#91;foo&#93;"></span><a href="#[foo]">#&#91;foo&#93;</a>
29997 </p>
29998 !! html/parsoid
29999 <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>
30000 !! end
30001
30002 ## ------------------------------
30003 ## Parsoid section-wrapping tests
30004 ## ------------------------------
30005 !! test
30006 Section wrapping for well-nested sections (no leading content)
30007 !! options
30008 parsoid={
30009 "wrapSections": true
30010 }
30011 !! wikitext
30012 = 1 =
30013 a
30014
30015 = 2 =
30016 b
30017
30018 == 2.1 ==
30019 c
30020
30021 == 2.2 ==
30022 d
30023
30024 === 2.2.1 ===
30025 e
30026
30027 = 3 =
30028 f
30029 !! html/parsoid
30030 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1"> 1 </h1>
30031 <p>a</p>
30032
30033 </section><section data-mw-section-id="2"><h1 id="2"> 2 </h1>
30034 <p>b</p>
30035
30036 <section data-mw-section-id="3"><h2 id="2.1"> 2.1 </h2>
30037 <p>c</p>
30038
30039 </section><section data-mw-section-id="4"><h2 id="2.2"> 2.2 </h2>
30040 <p>d</p>
30041
30042 <section data-mw-section-id="5"><h3 id="2.2.1"> 2.2.1 </h3>
30043 <p>e</p>
30044
30045 </section></section></section><section data-mw-section-id="6"><h1 id="3"> 3 </h1>
30046 <p>f</p>
30047
30048 </section>
30049 !! end
30050
30051 !! test
30052 Section wrapping for well-nested sections (with leading content)
30053 !! options
30054 parsoid={
30055 "wrapSections": true
30056 }
30057 !! wikitext
30058 Para 1.
30059
30060 Para 2 with a <div>nested in it</div>
30061
30062 Para 3.
30063
30064 = 1 =
30065 a
30066
30067 = 2 =
30068 b
30069
30070 == 2.1 ==
30071 c
30072 !! html/parsoid
30073 <section data-mw-section-id="0"><p>Para 1.</p>
30074
30075 <p>Para 2 with a </p><div>nested in it</div>
30076
30077 <p>Para 3.</p>
30078
30079 </section><section data-mw-section-id="1"><h1 id="1"> 1 </h1>
30080 <p>a</p>
30081
30082 </section><section data-mw-section-id="2"><h1 id="2"> 2 </h1>
30083 <p>b</p>
30084
30085 <section data-mw-section-id="3"><h2 id="2.1"> 2.1 </h2>
30086 <p>c</p>
30087
30088 </section></section>
30089 !! end
30090
30091 !! test
30092 Section wrapping with template-generated sections (good nesting 1)
30093 !! options
30094 parsoid={
30095 "wrapSections": true
30096 }
30097 !! wikitext
30098 = 1 =
30099 a
30100
30101 {{echo|1=
30102 == 1.1 ==
30103 b
30104 }}
30105
30106 == 1.2 ==
30107 c
30108
30109 = 2 =
30110 d
30111 !! html/parsoid
30112 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1"> 1 </h1>
30113 <p>a</p>
30114
30115 <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">
30116 </span><p about="#mwt1">b</p>
30117 </section><section data-mw-section-id="3"><h2 id="1.2"> 1.2 </h2>
30118 <p>c</p>
30119
30120 </section></section><section data-mw-section-id="4"><h1 id="2"> 2 </h1>
30121 <p>d</p></section>
30122 !! end
30123
30124 # In this example, the template scope is mildly expanded to incorporate the
30125 # trailing newline after the transclusion since that is part of section 1.1.1
30126 !! test
30127 Section wrapping with template-generated sections (good nesting 2)
30128 !! options
30129 parsoid={
30130 "wrapSections": true,
30131 "modes": ["wt2html", "wt2wt"]
30132 }
30133 !! wikitext
30134 = 1 =
30135 a
30136
30137 {{echo|1=
30138 == 1.1 ==
30139 b
30140 === 1.1.1 ===
30141 d
30142 }}
30143 = 2 =
30144 e
30145 !! html/parsoid
30146 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1"> 1 </h1>
30147 <p>a</p>
30148
30149 <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">
30150 </span><p about="#mwt1">b</p><span about="#mwt1">
30151 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.1.1"> 1.1.1 </h3><span about="#mwt1">
30152 </span><p about="#mwt1">d</p><span about="#mwt1">
30153 </span></section></section></section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="2"> 2 </h1>
30154 <p>e</p></section>
30155 !! end
30156
30157 # In this example, the template scope is mildly expanded to incorporate the
30158 # trailing newline after the transclusion since that is part of section 1.2.1
30159 !! test
30160 Section wrapping with template-generated sections (good nesting 3)
30161 !! options
30162 parsoid={
30163 "wrapSections": true,
30164 "modes": ["wt2html", "wt2wt"]
30165 }
30166 !! wikitext
30167 = 1 =
30168 a
30169
30170 {{echo|1=
30171 x
30172 == 1.1 ==
30173 b
30174 ==1.2==
30175 c
30176 ===1.2.1===
30177 d
30178 }}
30179 = 2 =
30180 e
30181 !! html/parsoid
30182 <section data-mw-section-id="0"></section><section data-mw-section-id="1" data-parsoid="{}"><h1 id="1"> 1 </h1>
30183 <p>a</p>
30184
30185 <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">
30186 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.1"> 1.1 </h2><span about="#mwt1">
30187 </span><p about="#mwt1">b</p><span about="#mwt1">
30188 </span></section><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.2">1.2</h2><span about="#mwt1">
30189 </span><p about="#mwt1">c</p><span about="#mwt1">
30190 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.2.1">1.2.1</h3><span about="#mwt1">
30191 </span><p about="#mwt1">d</p><span about="#mwt1">
30192 </span></section></section></section><section data-mw-section-id="5"><h1 id="2"> 2 </h1>
30193 <p>e</p></section>
30194 !! end
30195
30196 # Because of section-wrapping and template-wrapping interactions,
30197 # the scope of the template is expanded so that the template markup
30198 # is valid in the presence of <section> tags.
30199 # This exercises the s1 is null scenario in the wrapSections code
30200 !! test
30201 Section wrapping with template-generated sections (bad nesting 1)
30202 !! options
30203 parsoid={
30204 "wrapSections": true
30205 }
30206 !! wikitext
30207 <div>
30208 a
30209
30210 {{echo|
30211 = 1 =
30212 b
30213 }}
30214
30215 c
30216 </div>
30217 !! html/parsoid
30218 <section data-mw-section-id="-1"></section><section data-mw-section-id="-2"><div data-parsoid='{"stx":"html"}'>
30219 <p>a</p>
30220
30221 <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"]}'>
30222 </span><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="1"> 1 </h1><span about="#mwt1">
30223 </span><p about="#mwt1">b
30224 </p><span about="#mwt1">
30225
30226 </span><p about="#mwt1">c</p><span about="#mwt1">
30227 </span></section></div></section>
30228 !! end
30229
30230 # Because of section-wrapping and template-wrapping interactions,
30231 # the scope of the template is expanded so that the template markup
30232 # is valid in the presence of <section> tags.
30233 # This exercises the s1 is ancestor of s2 scenario in the wrapSections code
30234 !! test
30235 Section wrapping with template-generated sections (bad nesting 2)
30236 !! options
30237 parsoid={
30238 "wrapSections": true
30239 }
30240 !! wikitext
30241 = 1 =
30242 a
30243
30244 {{echo|1=
30245 = 2 =
30246 b
30247 == 2.1 ==
30248 c
30249 }}
30250
30251 d
30252
30253 = 3 =
30254 e
30255 !! html/parsoid
30256 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1"> 1 </h1>
30257 <p>a</p>
30258
30259 </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">
30260 </span><p about="#mwt1">b</p><span about="#mwt1">
30261 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="2.1"> 2.1 </h2><span about="#mwt1">
30262 </span><p about="#mwt1">c</p><span about="#mwt1">
30263
30264 </span><p about="#mwt1">d</p><span about="#mwt1">
30265
30266 </span></section></section><section data-mw-section-id="4"><h1 id="3"> 3 </h1>
30267 <p>e</p></section>
30268 !! end
30269
30270 # Because of section-wrapping and template-wrapping interactions,
30271 # additional template wrappers are added to <section> tags
30272 # so that template wrapping semantics are valid whether section
30273 # tags are retained or stripped. But, the template scope can expand
30274 # greatly when accounting for section tags.
30275 # This exercises the s1 and s2 are in different subtrees scenario
30276 !! test
30277 Section wrapping with template-generated sections (bad nesting 3)
30278 !! options
30279 parsoid={
30280 "wrapSections": true,
30281 "modes": ["wt2html", "wt2wt"]
30282 }
30283 !! wikitext
30284 = 1 =
30285 a
30286
30287 {{echo|1=
30288 == 1.2 ==
30289 b
30290 = 2 =
30291 c
30292 }}
30293
30294 d
30295
30296 = 3 =
30297 e
30298 !! html/parsoid
30299 <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>
30300 <p>a</p>
30301
30302 <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">
30303 </span><p about="#mwt1">b</p><span about="#mwt1">
30304 </span></section></section><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="2"> 2 </h1><span about="#mwt1">
30305 </span><p about="#mwt1">c</p>
30306
30307 <p>d</p>
30308 </section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="3"> 3 </h1>
30309 <p>e</p></section>
30310 !! end
30311
30312 !! test
30313 Section wrapping with uneditable lead section + div wrapping multiple sections
30314 !! options
30315 parsoid={
30316 "wrapSections": true
30317 }
30318 !! wikitext
30319 foo
30320
30321 <div style="border:1px solid red;">
30322 = 1 =
30323 a
30324
30325 == 1.1 ==
30326 b
30327
30328 = 2 =
30329 c
30330 </div>
30331
30332 = 3 =
30333 d
30334
30335 == 3.1 ==
30336 e
30337 !! html/parsoid
30338 <section data-mw-section-id="-1"><p>foo</p>
30339
30340 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
30341 <section data-mw-section-id="1"><h1 id="1"> 1 </h1>
30342 <p>a</p>
30343
30344 <section data-mw-section-id="2"><h2 id="1.1"> 1.1 </h2>
30345 <p>b</p>
30346
30347 </section></section><section data-mw-section-id="-1"><h1 id="2"> 2 </h1>
30348 <p>c</p>
30349 </section></div>
30350
30351 </section><section data-mw-section-id="4"><h1 id="3"> 3 </h1>
30352 <p>d</p>
30353
30354 <section data-mw-section-id="5"><h2 id="3.1"> 3.1 </h2>
30355 <p>e</p>
30356 </section></section>
30357 !! end
30358
30359 !! test
30360 Section wrapping with editable lead section + div overlapping multiple sections
30361 !! options
30362 parsoid={
30363 "wrapSections": true
30364 }
30365 !! wikitext
30366 foo
30367
30368 = 1 =
30369 a
30370 <div style="border:1px solid red;">
30371 b
30372
30373 == 1.1 ==
30374 c
30375
30376 = 2 =
30377 d
30378 </div>
30379 e
30380
30381 = 3 =
30382 f
30383
30384 == 3.1 ==
30385 g
30386 !! html/parsoid
30387 <section data-mw-section-id="0"><p>foo</p>
30388
30389 </section><section data-mw-section-id="-1"><h1 id="1"> 1 </h1>
30390 <p>a</p>
30391 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
30392 <p>b</p>
30393
30394 <section data-mw-section-id="2"><h2 id="1.1"> 1.1 </h2>
30395 <p>c</p>
30396
30397 </section><section data-mw-section-id="-1"><h1 id="2"> 2 </h1>
30398 <p>d</p>
30399 </section></div>
30400 <p>e</p>
30401
30402 </section><section data-mw-section-id="4"><h1 id="3"> 3 </h1>
30403 <p>f</p>
30404
30405 <section data-mw-section-id="5"><h2 id="3.1"> 3.1 </h2>
30406 <p>g</p>
30407 </section></section>
30408 !! end
30409
30410 !! test
30411 HTML header tags should not be wrapped in section tags
30412 !! options
30413 parsoid={
30414 "wrapSections": true
30415 }
30416 !! wikitext
30417 foo
30418
30419 <h1>a</h1>
30420
30421 = b =
30422
30423 <h1>c</h1>
30424
30425 = d =
30426 !! html/parsoid
30427 <section data-mw-section-id="0"><p>foo</p>
30428
30429 <h1 id="a" data-parsoid='{"stx":"html"}'>a</h1>
30430
30431 </section><section data-mw-section-id="1"><h1 id="b"> b </h1>
30432
30433 <h1 id="c" data-parsoid='{"stx":"html"}'>c</h1>
30434
30435 </section><section data-mw-section-id="2"><h1 id="d"> d </h1></section>
30436 !! end
30437
30438 !! test
30439 Lead section containing only whitespace and comments.
30440 !! options
30441 parsoid={
30442 "wrapSections": true
30443 }
30444 !! wikitext
30445
30446 <!-- this is a comment, presumably significant to editors -->
30447 = 1 =
30448 a
30449
30450 = 2 =
30451 b
30452 !! html/parsoid
30453 <section data-mw-section-id="0" data-parsoid="{}">
30454 <!-- this is a comment, presumably significant to editors -->
30455 </section><section data-mw-section-id="1"><h1 id="1"> 1 </h1>
30456 <p>a</p>
30457
30458 </section><section data-mw-section-id="2"><h1 id="2"> 2 </h1>
30459 <p>b</p></section>
30460 !! end
30461
30462 !! test
30463 Pseudo-sections emitted by templates should have id -2
30464 !! options
30465 parsoid={
30466 "wrapSections": true
30467 }
30468 !! wikitext
30469 foo
30470 {{echo|<div>
30471 == a ==
30472 == b ==
30473 </div>
30474 }}
30475 !! html/parsoid
30476 <section data-mw-section-id="-1"><p>foo</p>
30477 </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}}]}'>
30478 <section data-mw-section-id="-1"><h2 id="a"> a </h2>
30479 </section><section data-mw-section-id="-1"><h2 id="b"> b </h2>
30480 </section></div><span about="#mwt1">
30481 </span></section>
30482 !! end