Complete coverage of Parser::getTemplateDom()
[lhc/web/wiklou.git] / tests / parser / parserTests.txt
1 # MediaWiki Parser test cases
2 # Some taken from https://meta.wikimedia.org/wiki/Parser_testing
3 # All (C) their respective authors and released under the GPL
4 #
5 # The syntax should be fairly self-explanatory.
6 #
7 # Currently supported test options:
8 # One of the following three:
9 #
10 # (default) generate HTML output
11 # pst apply pre-save transform
12 # msg apply message transform
13 #
14 # Plus any combination of these:
15 #
16 # cat add category links
17 # (ignored by Parsoid, since it emits <link>s)
18 # ill add inter-language links
19 # (ignored by Parsoid, since it emits <link>s)
20 # subpage enable subpages (disabled by default)
21 # title=[[XXX]] run test using article title XXX
22 # language=XXX set content language to XXX for this test
23 # variant=XXX set the variant of language for this test (eg zh-tw)
24 # disabled do not run test
25 # parsoid parsoid-specific options (not run by PHP parser unless
26 # the test includes an html/php section)
27 # php php-only test (not run by the parsoid parser unless
28 # the test includes an html/parsoid section)
29 # showtitle make the first line the title
30 # showindicators make the first lines the page status indicators
31 # comment run through Linker::formatComment() instead of main parser
32 # local format section links in edit comment text as local links
33 # notoc disable table of contents
34 # thumbsize=NNN set the default thumb size to NNNpx for this test
35 # wrap include the normal wrapper <div class="mw-parser-output"> (since 1.30)
36 #
37 # You can also set the following parser properties via test options:
38 # wgEnableUploads, wgAllowExternalImages, wgMaxTocLevel,
39 # wgLinkHolderBatchSize, wgRawHtml, wgInterwikiMagic,
40 # wgEnableMagicLinks
41 #
42 # For testing purposes, temporary articles can created:
43 # !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
44 # where '/' denotes a newline.
45
46 # This is the standard article assumed to exist.
47 !! article
48 Main Page
49 !! text
50 blah blah
51 !! endarticle
52
53 !!article
54 Foo
55 !!text
56 FOO
57 !!endarticle
58
59 !!article
60 Template:Foo
61 !!text
62 FOO
63 !!endarticle
64
65 !! article
66 Template:redirect to foo
67 !! text
68 #REDIRECT [[Template:Foo]]
69 !! endarticle
70
71 !! article
72 Template:Blank
73 !! text
74 !! endarticle
75
76 !! article
77 Template:pipe
78 !! text
79 |
80 !! endarticle
81
82 !! article
83 Template:=
84 !! text
85 <nowiki>=</nowiki>
86 !! endarticle
87
88 !!article
89 MediaWiki:bad image list
90 !!text
91 * [[File:Bad.jpg]] except [[Nasty page]]
92 !!endarticle
93
94 !! article
95 Template:inner list
96 !! text
97 * item 1
98 !! endarticle
99
100 !! article
101 Template:tbl-start
102 !! text
103 {|
104 !! endarticle
105
106 !! article
107 Template:tbl-end
108 !! text
109 |}
110 !! endarticle
111
112 !! article
113 Template:echo
114 !! text
115 {{{1}}}
116 !! endarticle
117
118 !! article
119 Template:echo3
120 !! text
121 {{{1}}}
122 {{{1}}}
123 {{{1}}}
124 !! endarticle
125
126 // For Serbian; localize Template namespace
127 !! article
128 Шаблон:Echo
129 !! text
130 {{{1}}}
131 !! endarticle
132
133 !! article
134 Template:echo_with_span
135 !! text
136 <span>{{{1}}}</span>
137 !! endarticle
138
139 !! article
140 Template:echo_with_div
141 !! text
142 <div>{{{1}}}</div>
143 !! endarticle
144
145 !! article
146 Template:echo with depth
147 !! text
148 {{echo|{{{1}}}}}
149 !! endarticle
150
151 !! article
152 Template:blank_param
153 !! text
154 {{{1}}}
155 {{{}}}
156 !! endarticle
157
158 !! article
159 Template:table_attribs
160 !! text
161 <noinclude>
162 |</noinclude>style="color:red;"|Foo
163 !! endarticle
164
165 !! article
166 Template:table_attribs_2
167 !! text
168 <noinclude>
169 |</noinclude>style="color:red;"|Foo
170 |Bar||Baz
171 !! endarticle
172
173 !! article
174 Template:table_attribs_3
175 !! text
176 <noinclude>
177 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo
178 !! endarticle
179
180 !! article
181 Template:table_attribs_4
182 !! text
183 | style="background-color:#DC241f;" width="10px" |
184 !! endarticle
185
186 !! article
187 Template:table_attribs_5
188 !! text
189 <noinclude>
190 |</noinclude>style="color:red;"||Bar
191 !! endarticle
192
193 !! article
194 Template:table_attribs_6
195 !! text
196 style="background: <nowiki>
197
198
199 red;</nowiki>" |
200 !! endarticle
201
202 !! article
203 Template:table_attribs_7
204 !! text
205 <noinclude>
206 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo<ref>foo</ref>
207 !! endarticle
208
209 !! article
210 Template:table_header_cells
211 !! text
212 {{table_attribs}}!!style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
213 !! endarticle
214
215 !! article
216 Template:table_cells
217 !! text
218 {{table_attribs}}||style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
219 !! endarticle
220
221 !! article
222 Template:PartialTable
223 !! text
224 {|
225 |-
226 !! endarticle
227
228 !! article
229 Template:image_attribs
230 !! text
231 <noinclude>
232 [[File:foobar.jpg|</noinclude>right|Caption text<noinclude>]]</noinclude>
233 !! endarticle
234
235 ## See T48811 for details
236 !! article
237 Template:mixed_attr_content_template
238 !! text
239 style="color:red;" title="T48811"
240 |-
241 |foo
242 !! endarticle
243
244 !! article
245 Template:definition_list
246 !! text
247 one
248 ::two
249 !! endarticle
250
251 !! article
252 A?b
253 !! text
254 Weirdo titles!
255 !! endarticle
256
257 !!article
258 Template:Bullet
259 !!text
260 * Bar
261 !!endarticle
262
263 !!article
264 Template:OpenTable
265 !!text
266 {|
267 !!endarticle
268
269 !!article
270 Template:EmptyLITest
271 !!text
272 *a
273 *
274 *
275 *b
276 !!endarticle
277
278 !!article
279 Template:EmptyTRTest
280 !!text
281 {|
282 |-
283 |-
284 |foo
285 |-
286 |-
287 |bar
288 |}
289 !!endarticle
290
291 !!article
292 Template:EmptyTRWithHTMLAttrTest
293 !!text
294 <table>
295 <tr align="center"></tr>
296 <tr><td>foo</td></tr>
297 <tr align="center"></tr>
298 <tr><td>bar</td></tr>
299 </table>
300 !!endarticle
301
302 !! article
303 Template:With: Colon
304 !! text
305 Template with colon
306 !! endarticle
307
308 ###
309 ### Basic tests
310 ###
311
312 !! test
313 Blank input
314 !! wikitext
315 !! html
316 !! end
317
318 !! test
319 Simple paragraph
320 !! wikitext
321 This is a simple paragraph.
322 !! html
323 <p>This is a simple paragraph.
324 </p>
325 !! end
326
327 !! test
328 Paragraphs with extra newline spacing
329 !! wikitext
330 foo
331
332 bar
333
334
335 baz
336
337
338
339 booz
340 !! html
341 <p>foo
342 </p><p>bar
343 </p><p><br />
344 baz
345 </p><p><br />
346 </p><p>booz
347 </p>
348 !! end
349
350 !! test
351 Paragraphs with newline spacing with comment lines in between
352 !! wikitext
353 ----
354 a
355 <!--foo-->
356 b
357 ----
358 a
359 <!--foo--><!--More than 1 comment, still stripped-->
360 b
361 ----
362 a
363 <!--foo--> <!----> <!-- bar -->
364 b
365 ----
366 a
367 <!--foo-->
368
369 b
370 ----
371 a
372
373 <!--foo-->
374 b
375 ----
376 a
377 <!--foo-->
378
379
380 b
381 ----
382 a
383
384
385 <!--foo-->
386 b
387 ----
388 !! html
389 <hr />
390 <p>a
391 b
392 </p>
393 <hr />
394 <p>a
395 b
396 </p>
397 <hr />
398 <p>a
399 b
400 </p>
401 <hr />
402 <p>a
403 </p><p>b
404 </p>
405 <hr />
406 <p>a
407 </p><p>b
408 </p>
409 <hr />
410 <p>a
411 </p><p><br />
412 b
413 </p>
414 <hr />
415 <p>a
416 </p><p><br />
417 b
418 </p>
419 <hr />
420
421 !! end
422
423 !! test
424 Paragraphs with newline spacing with non-empty white-space lines in between
425 !! wikitext
426 ----
427 a
428
429 b
430 ----
431 a
432
433
434 b
435 ----
436 !! html
437 <hr />
438 <p>a
439 </p><p>b
440 </p>
441 <hr />
442 <p>a
443 </p><p><br />
444 b
445 </p>
446 <hr />
447
448 !! end
449
450 !! test
451 Paragraphs with newline spacing with non-empty mixed comment and white-space lines in between
452 !! wikitext
453 ----
454 a
455 <!--foo-->
456 b
457 ----
458 a
459 <!--foo--><!--More than 1 comment doesn't disable stripping of this line!-->
460 b
461 ----
462 a
463
464 <!--foo-->
465 <!--bar-->
466 b
467 ----
468 a
469
470 <!--foo-->
471 <!--bar-->
472
473 b
474 ----
475 !! html
476 <hr />
477 <p>a
478 b
479 </p>
480 <hr />
481 <p>a
482 b
483 </p>
484 <hr />
485 <p>a
486 </p><p>b
487 </p>
488 <hr />
489 <p>a
490 </p><p><br />
491 b
492 </p>
493 <hr />
494
495 !! end
496
497 !! test
498 Extra newlines: More paragraphs with indented comment
499 !! wikitext
500 a
501
502 <!--boo-->
503
504 b
505 !! html
506 <p>a
507 </p><p><br />
508 b
509 </p>
510 !!end
511
512 !! test
513 Extra newlines followed by heading
514 !! wikitext
515 a
516
517
518
519 =b=
520 [[a]]
521
522
523 =b=
524 !! html
525 <p>a
526 </p><p><br />
527 </p>
528 <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>
529 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
530 </p><p><br />
531 </p>
532 <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>
533
534 !! end
535
536 !! test
537 Extra newlines between heading and content are swallowed
538 !! wikitext
539 =b=
540
541
542
543 [[a]]
544 !! html
545 <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>
546 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
547 </p>
548 !! end
549
550 !! test
551 Heading with line break in nowiki
552 !! options
553 parsoid=wt2html
554 !! config
555 wgFragmentMode=[ 'html5', 'legacy' ]
556 !! wikitext
557 ==A <nowiki>B
558 C</nowiki>==
559 !! html/php
560 <h2><span id="A_B.0AC"></span><span class="mw-headline" id="A_B
561 C">A B
562 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>
563
564 !! html/parsoid
565 <h2 id="A_B
566 C"><span id="A_B.0AC" typeof="mw:FallbackId"></span>A <span typeof="mw:Nowiki">B
567 C</span></h2>
568 !! end
569
570 !! test
571 Parsing an URL
572 !! wikitext
573 http://fr.wikipedia.org/wiki/🍺
574 <!-- EasterEgg we love beer, better be able be able to link to it -->
575 !! html
576 <p><a rel="nofollow" class="external free" href="http://fr.wikipedia.org/wiki/🍺">http://fr.wikipedia.org/wiki/🍺</a>
577 </p>
578 !! end
579
580 !! test
581 Simple list
582 !! wikitext
583 *Item 1
584 *Item 2
585 !! html
586 <ul><li>Item 1</li>
587 <li>Item 2</li></ul>
588
589 !! end
590
591 !! test
592 Italics and bold
593 !! wikitext
594 *plain
595 *plain''italic''plain
596 *plain''italic''plain''italic''plain
597 *plain'''bold'''plain
598 *plain'''bold'''plain'''bold'''plain
599 *plain''italic''plain'''bold'''plain
600 *plain'''bold'''plain''italic''plain
601 *plain''italic'''bold-italic'''italic''plain
602 *plain'''bold''bold-italic''bold'''plain
603 *plain'''''bold-italic'''italic''plain
604 *plain'''''bold-italic''bold'''plain
605 *plain''italic'''bold-italic'''''plain
606 *plain'''bold''bold-italic'''''plain
607 *plain l'''italic''plain
608 *plain l''''bold''' plain
609 !! html
610 <ul><li>plain</li>
611 <li>plain<i>italic</i>plain</li>
612 <li>plain<i>italic</i>plain<i>italic</i>plain</li>
613 <li>plain<b>bold</b>plain</li>
614 <li>plain<b>bold</b>plain<b>bold</b>plain</li>
615 <li>plain<i>italic</i>plain<b>bold</b>plain</li>
616 <li>plain<b>bold</b>plain<i>italic</i>plain</li>
617 <li>plain<i>italic<b>bold-italic</b>italic</i>plain</li>
618 <li>plain<b>bold<i>bold-italic</i>bold</b>plain</li>
619 <li>plain<i><b>bold-italic</b>italic</i>plain</li>
620 <li>plain<b><i>bold-italic</i>bold</b>plain</li>
621 <li>plain<i>italic<b>bold-italic</b></i>plain</li>
622 <li>plain<b>bold<i>bold-italic</i></b>plain</li>
623 <li>plain l'<i>italic</i>plain</li>
624 <li>plain l'<b>bold</b> plain</li></ul>
625
626 !! end
627
628 # this example taken from the [[simple:Moon]] article (T49326)
629 !! test
630 Italics and possessives (1)
631 !! wikitext
632 obtained by ''[[Lunar Prospector]]'''s gamma-ray spectrometer
633 !! html
634 <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
635 </p>
636 !! end
637
638 # this example taken from [[en:Flaming Pie]] (T51926)
639 !! test
640 Italics and possessives (2)
641 !! wikitext
642 '''''Flaming Pie''''' is ... released in 1997. In ''Flaming Pie'''s liner notes
643 !! html
644 <p><i><b>Flaming Pie</b></i> is ... released in 1997. In <i>Flaming Pie'</i>s liner notes
645 </p>
646 !! end
647
648 # this example taken from [[en:Dictionary]] (T51926)
649 !! test
650 Italics and possessives (3)
651 !! wikitext
652 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''.
653 !! html
654 <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>.
655 </p>
656 !! end
657
658
659 ###
660 ### 2-quote opening sequence tests
661 ###
662 !! test
663 Italics and bold: 2-quote opening sequence: (2,2)
664 !! wikitext
665 ''foo''
666 !! html
667 <p><i>foo</i>
668 </p>
669 !!end
670
671 !! test
672 Italics and bold: 2-quote opening sequence: (2,3)
673 !! wikitext
674 ''foo'''
675 !! html/*
676 <p><i>foo'</i>
677 </p>
678 !!end
679
680 !! test
681 Italics and bold: 2-quote opening sequence: (2,4)
682 !! options
683 parsoid=wt2html
684 !! wikitext
685 ''foo''''
686 !! html/*
687 <p><i>foo''</i>
688 </p>
689 !!end
690
691 # same html as previous, but wikitext adjusted to match parsoid html2wt
692 !! test
693 Italics and bold: 2-quote opening sequence: (2,4) w/ nowiki
694 !! wikitext
695 ''foo<nowiki>''</nowiki>''
696 !! html
697 <p><i>foo''</i>
698 </p>
699 !! end
700
701 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
702 !! test
703 Italics and bold: 2-quote opening sequence: (2,5)
704 !! options
705 parsoid=wt2html
706 !! wikitext
707 ''foo'''''
708 !! html/php
709 <p><i>foo</i>
710 </p>
711 !! html/parsoid
712 <p><i>foo</i><b></b>
713 </p>
714 !!end
715
716 # same html as previous, but wikitext adjusted to match parsoid html2wt
717 !! test
718 Italics and bold: 2-quote opening sequence: (2,5+3) w/ nowiki
719 !! wikitext
720 ''foo'''''<nowiki/>'''
721 !! html/php
722 <p><i>foo</i>
723 </p>
724 !! html/parsoid
725 <p><i>foo</i><b></b>
726 </p>
727 !! end
728
729
730 ###
731 ### 3-quote opening sequence tests
732 ###
733
734 !! test
735 Italics and bold: 3-quote opening sequence: (3,2)
736 !! wikitext
737 '''foo''
738 !! html/*
739 <p>'<i>foo</i>
740 </p>
741 !!end
742
743 !! test
744 Italics and bold: 3-quote opening sequence: (3,3)
745 !! wikitext
746 '''foo'''
747 !! html
748 <p><b>foo</b>
749 </p>
750 !!end
751
752 !! test
753 Italics and bold: 3-quote opening sequence: (3,4)
754 !! wikitext
755 '''foo''''
756 !! html/*
757 <p><b>foo'</b>
758 </p>
759 !!end
760
761 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
762 !! test
763 Italics and bold: 3-quote opening sequence: (3,5)
764 !! options
765 parsoid=wt2html
766 !! wikitext
767 '''foo'''''
768 !! html/php
769 <p><b>foo</b>
770 </p>
771 !! html/parsoid
772 <p><b>foo</b><i></i>
773 </p>
774 !!end
775
776 # same html as previous, but wikitext adjusted to match parsoid html2wt
777 !! test
778 Italics and bold: 3-quote opening sequence: (3,5+2) w/ nowiki
779 !! wikitext
780 '''foo'''''<nowiki/>''
781 !! html/php
782 <p><b>foo</b>
783 </p>
784 !! html/parsoid
785 <p><b>foo</b><i></i>
786 </p>
787 !! end
788
789
790 ###
791 ### 4-quote opening sequence tests
792 ###
793
794 !! test
795 Italics and bold: 4-quote opening sequence: (4,2)
796 !! options
797 parsoid=wt2html
798 !! wikitext
799 ''''foo''
800 !! html/*
801 <p>''<i>foo</i>
802 </p>
803 !!end
804
805 # same html as previous, but wikitext adjusted to match parsoid html2wt
806 !! test
807 Italics and bold: 4-quote opening sequence: (4,2) w/ nowiki
808 !! wikitext
809 <nowiki>''</nowiki>''foo''
810 !! html
811 <p>''<i>foo</i>
812 </p>
813 !! end
814
815 !! test
816 Italics and bold: 4-quote opening sequence: (4,3)
817 !! wikitext
818 ''''foo'''
819 !! html/*
820 <p>'<b>foo</b>
821 </p>
822 !!end
823
824 !! test
825 Italics and bold: 4-quote opening sequence: (4,4)
826 !! options
827 parsoid=wt2html
828 !! wikitext
829 ''''foo''''
830 !! html/*
831 <p>'<b>foo'</b>
832 </p>
833 !!end
834
835 # same html as previous, but wikitext adjusted to match parsoid html2wt
836 !! test
837 Italics and bold: 4-quote opening sequence: (4,4) w/ nowiki
838 !! wikitext
839 '<nowiki/>'''foo''''
840 !! html
841 <p>'<b>foo'</b>
842 </p>
843 !! end
844
845 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
846 !! test
847 Italics and bold: 4-quote opening sequence: (4,5)
848 !! options
849 parsoid=wt2html
850 !! wikitext
851 ''''foo'''''
852 !! html/php
853 <p>'<b>foo</b>
854 </p>
855 !! html/parsoid
856 <p>'<b>foo</b><i></i>
857 </p>
858 !!end
859
860 # same html as previous, but wikitext adjusted to match parsoid html2wt
861 !! test
862 Italics and bold: 4-quote opening sequence: (4,5+2) w/ nowiki
863 !! wikitext
864 '<nowiki/>'''foo'''''<nowiki/>''
865 !! html/php
866 <p>'<b>foo</b>
867 </p>
868 !! html/parsoid
869 <p>'<b>foo</b><i></i>
870 </p>
871 !! end
872
873
874 ###
875 ### 5-quote opening sequence tests
876 ###
877
878 !! test
879 Italics and bold: 5-quote opening sequence: (5,2)
880 !! options
881 parsoid=wt2html
882 !! wikitext
883 '''''foo''
884 !! html/*
885 <p><b><i>foo</i></b>
886 </p>
887 !!end
888
889 # same html as previous, but wikitext adjusted to match parsoid html2wt
890 !! test
891 Italics and bold: 5-quote opening sequence: (5,2+3)
892 !! wikitext
893 '''''foo'''''
894 !! html/*
895 <p><i><b>foo</b></i>
896 </p>
897 !! end
898
899 !! test
900 Italics and bold: 5-quote opening sequence: (5,3)
901 !! options
902 parsoid=wt2html
903 !! wikitext
904 '''''foo'''
905 !! html/*
906 <p><i><b>foo</b></i>
907 </p>
908 !!end
909
910 # same html as previous, but wikitext adjusted to match parsoid html2wt
911 !! test
912 Italics and bold: 5-quote opening sequence: (5,3+2)
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,4)
922 !! options
923 parsoid=wt2html
924 !! wikitext
925 '''''foo''''
926 !! html/*
927 <p><i><b>foo'</b></i>
928 </p>
929 !!end
930
931 !! test
932 Italics and bold: 5-quote opening sequence: (5,5)
933 !! wikitext
934 '''''foo'''''
935 !! html
936 <p><i><b>foo</b></i>
937 </p>
938 !!end
939
940 !! test
941 Italics and bold: 5-quote opening sequence: (5,6)
942 !! wikitext
943 '''''foo''''''
944 !! html/*
945 <p><i><b>foo'</b></i>
946 </p>
947 !! end
948
949 ###
950 ### multiple quote sequences in a line
951 ###
952
953 !! test
954 Italics and bold: multiple quote sequences: (2,4,2)
955 !! options
956 parsoid=wt2html
957 !! wikitext
958 ''foo''''bar''
959 !! html/*
960 <p><i>foo'<b>bar</b></i>
961 </p>
962 !! end
963
964 # same html as previous, but wikitext adjusted to match parsoid html2wt
965 !! test
966 Italics and bold: multiple quote sequences: (2,4,2+3) w/ nowiki
967 !! wikitext
968 ''foo'<nowiki/>'''bar'''''
969 !! html
970 <p><i>foo'<b>bar</b></i>
971 </p>
972 !! end
973
974 !! test
975 Italics and bold: multiple quote sequences: (2,4,3)
976 !! options
977 parsoid=wt2html
978 !! wikitext
979 ''foo''''bar'''
980 !! html/*
981 <p><i>foo'<b>bar</b></i>
982 </p>
983 !! end
984
985 # same html as previous, but wikitext adjusted to match parsoid html2wt
986 !! test
987 Italics and bold: multiple quote sequences: (2,4,3+2) w/ nowiki
988 !! wikitext
989 ''foo'<nowiki/>'''bar'''''
990 !! html
991 <p><i>foo'<b>bar</b></i>
992 </p>
993 !! end
994
995 !! test
996 Italics and bold: multiple quote sequences: (2,4,4)
997 !! options
998 parsoid=wt2html
999 !! wikitext
1000 ''foo''''bar''''
1001 !! html/*
1002 <p><i>foo'<b>bar'</b></i>
1003 </p>
1004 !! end
1005
1006 # same html as previous, but wikitext adjusted to match parsoid html2wt
1007 !! test
1008 Italics and bold: multiple quote sequences: (2,4,4+2) w/ nowiki
1009 !! wikitext
1010 ''foo'<nowiki/>'''bar'<nowiki/>'''''
1011 !! html
1012 <p><i>foo'<b>bar'</b></i>
1013 </p>
1014 !! end
1015
1016 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1017 !! test
1018 Italics and bold: multiple quote sequences: (3,4,2)
1019 !! options
1020 parsoid=wt2html
1021 !! wikitext
1022 '''foo''''bar''
1023 !! html/php
1024 <p><b>foo'</b>bar
1025 </p>
1026 !! html/parsoid
1027 <p><b>foo'</b>bar<i></i>
1028 </p>
1029 !! end
1030
1031 # same html as previous, but wikitext adjusted to match parsoid html2wt
1032 !! test
1033 Italics and bold: multiple quote sequences: (3,4,2+2) w/ nowiki
1034 !! wikitext
1035 '''foo''''bar''<nowiki/>''
1036 !! html/php
1037 <p><b>foo'</b>bar
1038 </p>
1039 !! html/parsoid
1040 <p><b>foo'</b>bar<i></i>
1041 </p>
1042 !! end
1043
1044 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1045 !! test
1046 Italics and bold: multiple quote sequences: (3,4,3)
1047 !! options
1048 parsoid=wt2html
1049 !! wikitext
1050 '''foo''''bar'''
1051 !! html/php
1052 <p><b>foo'</b>bar
1053 </p>
1054 !! html/parsoid
1055 <p><b>foo'</b>bar<b></b>
1056 </p>
1057 !! end
1058
1059 # same html as previous, but wikitext adjusted to match parsoid html2wt
1060 !! test
1061 Italics and bold: multiple quote sequences: (3,4,3+3) w/ nowiki
1062 !! wikitext
1063 '''foo''''bar'''<nowiki/>'''
1064 !! html/php
1065 <p><b>foo'</b>bar
1066 </p>
1067 !! html/parsoid
1068 <p><b>foo'</b>bar<b></b>
1069 </p>
1070 !! end
1071
1072 ###
1073 ### other quote tests
1074 ###
1075 !! test
1076 Italics and bold: other quote tests: (2,3,5)
1077 !! wikitext
1078 ''this is about '''foo's family'''''
1079 !! html
1080 <p><i>this is about <b>foo's family</b></i>
1081 </p>
1082 !!end
1083
1084
1085 !! test
1086 Italics and bold: other quote tests: (2,(3,3),2)
1087 !! wikitext
1088 ''this is about '''foo's''' family''
1089 !! html
1090 <p><i>this is about <b>foo's</b> family</i>
1091 </p>
1092 !!end
1093
1094
1095 !! test
1096 Italics and bold: other quote tests: (3,2,3,2)
1097 !! options
1098 parsoid=wt2html
1099 !! wikitext
1100 '''this is about ''foo'''s family''
1101 !! html/*
1102 <p><b>this is about <i>foo</i></b><i>s family</i>
1103 </p>
1104 !!end
1105
1106
1107 # same html as previous, but wikitext adjusted to match parsoid html2wt
1108 !! test
1109 Italics and bold: other quote tests: (3,2,3+2+2,2)
1110 !! wikitext
1111 '''this is about ''foo'''''<nowiki/>''s family''
1112 !! html
1113 <p><b>this is about <i>foo</i></b><i>s family</i>
1114 </p>
1115 !! end
1116
1117
1118 !! test
1119 Italics and bold: other quote tests: (3,2,3,3)
1120 !! wikitext
1121 '''this is about ''foo'''s family'''
1122 !! html/*
1123 <p>'<i>this is about </i>foo<b>s family</b>
1124 </p>
1125 !!end
1126
1127
1128 !! test
1129 Italics and bold: other quote tests: (3,(2,2),3)
1130 !! wikitext
1131 '''this is about ''foo's'' family'''
1132 !! html
1133 <p><b>this is about <i>foo's</i> family</b>
1134 </p>
1135 !!end
1136
1137
1138 !! test
1139 Italicized possessive
1140 !! wikitext
1141 The ''[[Main Page]]'''s talk page.
1142 !! html/php
1143 <p>The <i><a href="/wiki/Main_Page" title="Main Page">Main Page</a>'</i>s talk page.
1144 </p>
1145 !! html/parsoid
1146 <p>The <i><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>'</i>s talk page.</p>
1147 !! end
1148
1149 !! test
1150 Quote balancing context should be restricted to td/th cells on the same wikitext line
1151 !! options
1152 parsoid=wt2html,wt2wt
1153 !! wikitext
1154 {|
1155 !''a!!''b
1156 |''a||''b
1157 |}
1158 !! html+tidy
1159 <table>
1160 <tbody><tr>
1161 <th><i>a</i></th>
1162 <th><i>b</i>
1163 </th>
1164 <td><i>a</i></td>
1165 <td><i>b</i>
1166 </td></tr></tbody></table>
1167 !! end
1168
1169 ###
1170 ### Non-html5 tags
1171 ###
1172
1173 !! test
1174 Non-html5 tags should be accepted
1175 !! wikitext
1176 <center>''foo''</center>
1177 <big>''foo''</big>
1178 <font>''foo''</font>
1179 <strike>''foo''</strike>
1180 <tt>''foo''</tt>
1181 !! html
1182 <center><i>foo</i></center>
1183 <p><big><i>foo</i></big>
1184 <font><i>foo</i></font>
1185 <strike><i>foo</i></strike>
1186 <tt><i>foo</i></tt>
1187 </p>
1188 !! end
1189
1190 !! test
1191 <wbr> is valid wikitext (T54468)
1192 !! wikitext
1193 <wbr>
1194 !! html
1195 <p><wbr />
1196 </p>
1197 !! end
1198
1199 # <strike> is HTML4, <s> is HTML4/5.
1200 !! test
1201 <s> or <strike> for strikethrough
1202 !! wikitext
1203 <strike>strike</strike>
1204
1205 <s>s</s>
1206 !! html
1207 <p><strike>strike</strike>
1208 </p><p><s>s</s>
1209 </p>
1210 !! end
1211
1212 ## a not permitted
1213 ## i,b,br omitted
1214 !! test
1215 Text-level semantic html elements in wikitext
1216 !! wikitext
1217 <em>text</em>
1218 <strong>text</strong>
1219 <small>text</small>
1220 <s>text</s>
1221 <cite>text</cite>
1222 <q>text</q>
1223 <dfn>text</dfn>
1224 <abbr>text</abbr>
1225 <data>text</data>
1226 <time>text</time>
1227 <code>text</code>
1228 <var>text</var>
1229 <samp>text</samp>
1230 <kbd>text</kbd>
1231 <sub>text</sub>
1232 <u>text</u>
1233 <mark>text</mark>
1234 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1235 <bdi>text</bdi>
1236 <bdo>text</bdo>
1237 <span>text</span>
1238 <wbr />
1239 !! html
1240 <p><em>text</em>
1241 <strong>text</strong>
1242 <small>text</small>
1243 <s>text</s>
1244 <cite>text</cite>
1245 <q>text</q>
1246 <dfn>text</dfn>
1247 <abbr>text</abbr>
1248 <data>text</data>
1249 <time>text</time>
1250 <code>text</code>
1251 <var>text</var>
1252 <samp>text</samp>
1253 <kbd>text</kbd>
1254 <sub>text</sub>
1255 <u>text</u>
1256 <mark>text</mark>
1257 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1258 <bdi>text</bdi>
1259 <bdo>text</bdo>
1260 <span>text</span>
1261 <wbr />
1262 </p>
1263 !! end
1264
1265 # test cases taken from
1266 # https://www.w3.org/TR/html5/text-level-semantics.html#the-ruby-element
1267 !! test
1268 Ruby markup (W3C-style)
1269 !! wikitext
1270 ;Mono-ruby for individual base characters
1271 :<ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby>
1272 ;Group ruby
1273 :<ruby>今日<rt>きょう</rt></ruby>
1274 ;Jukugo ruby
1275 :<ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby>
1276 ;Inline ruby
1277 :<ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby>
1278 ;Double-sided ruby
1279 :<ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby>
1280
1281 <ruby>
1282 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1283 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1284 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1285 </ruby>
1286 !! html
1287 <dl><dt>Mono-ruby for individual base characters</dt>
1288 <dd><ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby></dd>
1289 <dt>Group ruby</dt>
1290 <dd><ruby>今日<rt>きょう</rt></ruby></dd>
1291 <dt>Jukugo ruby</dt>
1292 <dd><ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby></dd>
1293 <dt>Inline ruby</dt>
1294 <dd><ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby></dd>
1295 <dt>Double-sided ruby</dt>
1296 <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>
1297 <p><ruby>
1298 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1299 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1300 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1301 </ruby>
1302 </p>
1303 !! end
1304
1305 # The next two test different paths in the sanitizer.
1306 !! test
1307 Non-word characters don't terminate tag names (T19663, T42670, T54022)
1308 !! wikitext
1309 <blockquote|>a</blockquote>
1310
1311 <b→> doesn't terminate </b→>
1312
1313 <bä> doesn't terminate </bä>
1314
1315 <boo> doesn't terminate </boo>
1316
1317 <s.foo> doesn't terminate </s.foo>
1318
1319 <sub-ID#1>
1320 !! html
1321 <p>&lt;blockquote|&gt;a&lt;/blockquote&gt;
1322 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1323 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1324 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1325 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1326 </p><p>&lt;sub-ID#1&gt;
1327 </p>
1328 !! end
1329
1330 !! test
1331 Non-word characters don't terminate tag names
1332 !! wikitext
1333 <blockquote|>a</blockquote>
1334
1335 <b→> doesn't terminate </b→>
1336
1337 <bä> doesn't terminate </bä>
1338
1339 <boo> doesn't terminate </boo>
1340
1341 <s.foo> doesn't terminate </s.foo>
1342
1343 <sub-ID#1>
1344 !! html+tidy
1345 <p>&lt;blockquote|&gt;a
1346 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1347 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1348 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1349 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1350 </p><p>&lt;sub-ID#1&gt;
1351 </p>
1352 !! end
1353
1354 ###
1355 ### See tests/parser/parserTestsParserHook.php for the <tåg> extension)
1356 ### This checks that HTML5 tags (with non-word characters in the tag
1357 ### name) make it safely through the parser -- the Sanitizer will
1358 ### munge them later, as it should.
1359 ###
1360 !! test
1361 Non-word characters are valid in extension tags (T19663)
1362 !! wikitext
1363 <tåg>tåg</tåg>
1364 !! html/php
1365 <pre>
1366 'tåg'
1367 array (
1368 )
1369 </pre>
1370
1371 !! html/parsoid
1372 <pre typeof="mw:Extension/tåg" data-mw='{"name":"tåg","attrs":{},"body":{"extsrc":"tåg"}}' data-parsoid='{}' about="#mwt2"></pre>
1373 !! end
1374
1375 !! test
1376 Isolated close tags should be treated as literal text (T54760)
1377 !! options
1378 parsoid=wt2html
1379 !! wikitext
1380 </b>
1381
1382 <s.foo>s</s>
1383 !! html/php+tidy
1384 <p class="mw-empty-elt">
1385 </p><p>&lt;s.foo&gt;s
1386 </p>
1387 !! html/parsoid
1388 <p>&lt;s.foo&gt;s</p>
1389 !! end
1390
1391 ###
1392 ### Special characters
1393 ###
1394
1395 !! test
1396 Bare pipe character (T54363)
1397 !! wikitext
1398 |
1399 !! html
1400 <p>|
1401 </p>
1402 !! end
1403
1404 !! test
1405 Bare pipe character from a template (T54363)
1406 !! wikitext
1407 {{pipe}}
1408 !! html
1409 <p>|
1410 </p>
1411 !! end
1412
1413 ###
1414 ### <nowiki> test cases
1415 ###
1416
1417 !! test
1418 <nowiki> unordered list
1419 !! wikitext
1420 <nowiki>* This is not an unordered list item.</nowiki>
1421 !! html/php
1422 <p>* This is not an unordered list item.
1423 </p>
1424 !! html/parsoid
1425 <p><span typeof="mw:Nowiki">* This is not an unordered list item.</span></p>
1426 !! end
1427
1428 !! test
1429 <nowiki> spacing
1430 !! wikitext
1431 <nowiki>Lorem ipsum dolor
1432
1433 sed abit.
1434 sed nullum.
1435
1436 :and a colon
1437 </nowiki>
1438 !! html/php
1439 <p>Lorem ipsum dolor
1440
1441 sed abit.
1442 sed nullum.
1443
1444 :and a colon
1445
1446 </p>
1447 !! html/parsoid
1448 <p><span typeof="mw:Nowiki">Lorem ipsum dolor
1449
1450 sed abit.
1451 sed nullum.
1452
1453 :and a colon
1454 </span></p>
1455 !! end
1456
1457 !! test
1458 Don't parse <nowiki><span class="error"></nowiki> (T149622)
1459 !! wikitext
1460 <nowiki><span class="error"></nowiki>
1461 !! html/php
1462 <p>&lt;span class="error"&gt;
1463 </p>
1464 !! html/parsoid
1465 <p><span typeof="mw:Nowiki">&lt;span class="error"></span></p>
1466 !! end
1467
1468 !! test
1469 nowiki 3
1470 !! wikitext
1471 :There is not nowiki.
1472 :There is <nowiki>nowiki</nowiki>.
1473
1474 #There is not nowiki.
1475 #There is <nowiki>nowiki</nowiki>.
1476
1477 *There is not nowiki.
1478 *There is <nowiki>nowiki</nowiki>.
1479 !! html/php
1480 <dl><dd>There is not nowiki.</dd>
1481 <dd>There is nowiki.</dd></dl>
1482 <ol><li>There is not nowiki.</li>
1483 <li>There is nowiki.</li></ol>
1484 <ul><li>There is not nowiki.</li>
1485 <li>There is nowiki.</li></ul>
1486
1487 !! html/parsoid
1488 <dl><dd data-parsoid='{}'>There is not nowiki.</dd>
1489 <dd data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</dd></dl>
1490
1491 <ol><li data-parsoid='{}'>There is not nowiki.</li>
1492 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ol>
1493
1494 <ul><li data-parsoid='{}'>There is not nowiki.</li>
1495 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ul>
1496 !! end
1497
1498 !! test
1499 Entities inside <nowiki>
1500 !! wikitext
1501 <nowiki>&lt;</nowiki>
1502 !! html/php
1503 <p>&lt;
1504 </p>
1505 !! html/parsoid
1506 <p><span typeof="mw:Nowiki"><span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span></span></p>
1507 !! end
1508
1509 !! test
1510 Entities inside template parameters
1511 !! wikitext
1512 {{echo|&ndash;}}
1513 !! html/php+tidy
1514 <p>&#8211;
1515 </p>
1516 !! html/parsoid
1517 <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>
1518 !! end
1519
1520 !! test
1521 Properly escape nowiki when combined with other wiki markup
1522 !! options
1523 parsoid=html2wt
1524 !! html/parsoid
1525 <p>* &lt;/nowiki&gt; tag</p>
1526 !! wikitext
1527 <nowiki>*</nowiki> <nowiki>&lt;/nowiki&gt;</nowiki> tag
1528 !! end
1529
1530 !! test
1531 T93824: Put escaped HTML tags inside nowiki
1532 !! options
1533 parsoid=html2wt
1534 !! html/parsoid
1535 <p>&lt;h2&gt;foo&lt;/h2&gt;</p>
1536 !! wikitext
1537 <nowiki><h2>foo</h2></nowiki>
1538 !! end
1539
1540 !! test
1541 T71950: 1. Put nowiki as close to cause as possible, even with non-quote escapable chars
1542 !! options
1543 parsoid=html2wt
1544 !! html/parsoid
1545 <p>This text: L'<a rel="mw:WikiLink" href="./Foo">Foo</a>
1546 This text: L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1547 This text: L'''<a rel="mw:WikiLink" href="./Foo">Foo</a>''</p>
1548 !! wikitext
1549 This text: L'[[Foo]]
1550 This text: L<nowiki>''</nowiki>[[Foo]]
1551 This text: L<nowiki>'''</nowiki>[[Foo]]<nowiki>''</nowiki>
1552 !! end
1553
1554 # This test fails because wikitext whitespace is not normalized before comparing.
1555 !! test
1556 T71950: 2. Put nowiki as close to cause as possible, after ' :'
1557 !! options
1558 parsoid=html2wt
1559 !! html/parsoid
1560 <p>This text : L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1561 </p>
1562 !! wikitext
1563 This text : L<nowiki>''</nowiki>[[Foo]]
1564 !! end
1565
1566 # This test and the next one are html2wt only as they test that incorrect wikitext
1567 # passed in template arguments gets escaped or wrapped in nowikis where required.
1568 !! test
1569 T71482: Use {{!}} instead of nowiki for single pipe in template argument
1570 !! options
1571 parsoid=html2wt
1572 !! html/parsoid
1573 <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>
1574 <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>
1575 !! wikitext
1576 {{echo|foo{{!}}bar}}
1577 {{echo|<nowiki>foo|bar |[[</nowiki>}}
1578 !! end
1579
1580 !! test
1581 T53961: Output correct nowikis in template arguments
1582 !! options
1583 parsoid=html2wt
1584 !! html/parsoid
1585 <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>
1586 <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>
1587 <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>
1588 <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>
1589 <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>
1590 !! wikitext
1591 {{echo|a [ b}}
1592 {{echo|<nowiki>a }} b</nowiki>}}
1593 {{echo|<nowiki>a [[ b</nowiki>}}
1594 {{echo|<nowiki>a | {{ ]]</nowiki>}}
1595 {{echo|a <nowiki>}</nowiki>}}
1596 !! end
1597
1598 !! test
1599 Cases where "!!" needs nowiki protection
1600 !! options
1601 parsoid=html2wt
1602 !! html/parsoid
1603 <table>
1604 <tr><th>this needs protection !! here</th></tr>
1605 </table>
1606
1607 <table>
1608 <tr><th>this does not need
1609 protection !! here</th></tr>
1610 </table>
1611 !! wikitext
1612 {|
1613 !<nowiki>this needs protection !! here</nowiki>
1614 |}
1615
1616 {|
1617 !this does not need
1618 protection !! here
1619 |}
1620 !! end
1621
1622 ###
1623 ### Comments
1624 ###
1625 !! test
1626 Comments and Indent-Pre
1627 !! wikitext
1628 <!-- comment 1 --> asdf
1629
1630 <!-- comment 1 --> asdf
1631 <!-- comment 2 -->
1632
1633 <!-- comment 1 --> asdf
1634 <!-- comment 2 -->xyz
1635
1636 <!-- comment 1 --> asdf
1637 <!-- comment 2 --> xyz
1638 !! html
1639 <pre>asdf
1640 </pre>
1641 <pre>asdf
1642 </pre>
1643 <pre>asdf
1644 </pre>
1645 <p>xyz
1646 </p>
1647 <pre>asdf
1648 xyz
1649 </pre>
1650 !! end
1651
1652 !! test
1653 Comment test 2a
1654 !! wikitext
1655 asdf
1656 <!-- comment 1 -->
1657 jkl
1658 !! html
1659 <p>asdf
1660 jkl
1661 </p>
1662 !! end
1663
1664 !! test
1665 Comment test 2b
1666 !! wikitext
1667 asdf
1668 <!-- comment 1 -->
1669
1670 jkl
1671 !! html
1672 <p>asdf
1673 </p><p>jkl
1674 </p>
1675 !! end
1676
1677 !! test
1678 Comment test 3
1679 !! wikitext
1680 asdf
1681 <!-- comment 1 -->
1682 <!-- comment 2 -->
1683 jkl
1684 !! html
1685 <p>asdf
1686 jkl
1687 </p>
1688 !! end
1689
1690 !! test
1691 Comment test 4
1692 !! wikitext
1693 asdf<!-- comment 1 -->jkl
1694 !! html
1695 <p>asdfjkl
1696 </p>
1697 !! end
1698
1699 !! test
1700 Comment spacing
1701 !! wikitext
1702 a
1703 <!-- foo --> b <!-- bar -->
1704 c
1705 !! html
1706 <p>a
1707 </p>
1708 <pre> b
1709 </pre>
1710 <p>c
1711 </p>
1712 !! end
1713
1714 !! test
1715 Comment whitespace
1716 !! wikitext
1717 <!-- returns a single newline, not nothing, since the newline after > is not stripped -->
1718 !! html
1719
1720 !! end
1721
1722 !! test
1723 Comment semantics and delimiters
1724 !! wikitext
1725 <!-- --><!----><!-----><!------>
1726 !! html/php
1727
1728 !! html/parsoid
1729 <!-- --><!----><!--&#x2D;--><!--&#x2D;&#x2D;-->
1730 !! end
1731
1732 !! test
1733 Comment semantics and delimiters, redux
1734 !! wikitext
1735 <!-- In SGML every "foo" here would actually show up in the text -- foo -- bar
1736 -- foo -- funky huh? ... -->
1737 !! html/php
1738
1739 !! html/parsoid
1740 <!-- In SGML every "foo" here would actually show up in the text &#x2D;&#x2D; foo &#x2D;&#x2D; bar
1741 &#x2D;&#x2D; foo &#x2D;&#x2D; funky huh? ... -->
1742 !! end
1743
1744 !! test
1745 Comment semantics and delimiters: directors cut
1746 !! wikitext
1747 <!-- ... However we like to keep things simple and somewhat XML-ish so we eat
1748 everything starting with < followed by !-- until the first -- and > we see,
1749 that wouldn't be valid XML however, since in XML -- has to terminate a comment
1750 -->-->
1751 !! html/php
1752 <p>--&gt;
1753 </p>
1754 !! html/parsoid
1755 <!-- ... However we like to keep things simple and somewhat XML&#x2D;ish so we eat
1756 everything starting with < followed by !&#x2D;&#x2D; until the first &#x2D;&#x2D; and &#x3E; we see,
1757 that wouldn't be valid XML however, since in XML &#x2D;&#x2D; has to terminate a comment
1758 --><p>--></p>
1759 !! end
1760
1761 !! test
1762 Comment semantics: nesting
1763 !! wikitext
1764 <!--<!-- no, we're not going to do anything fancy here -->-->
1765 !! html/php
1766 <p>--&gt;
1767 </p>
1768 !! html/parsoid
1769 <!--<!&#x2D;&#x2D; no, we're not going to do anything fancy here --><p>--></p>
1770 !! end
1771
1772 # Parsoid closes the unclosed comment, even if it means a slight
1773 # round-trip diff.
1774 !! test
1775 Comment semantics: unclosed comment at end
1776 !! options
1777 parsoid=wt2html,html2html
1778 !! wikitext
1779 <!--This comment will run out to the end of the document
1780 !! html/php
1781
1782 !! html/parsoid
1783 <!--This comment will run out to the end of the document-->
1784 !! end
1785
1786 !! test
1787 Comment semantics: normalize comments to play nice with XML and browsers
1788 !! wikitext
1789 <!-- Browsers --!> think this is closed -->
1790 <!--> This would normally be text -->
1791 <!---> As would this -->
1792 <!-- XML doesn't like trailing dashes -------->
1793 <!-- Nor doubled hyphens -- anywhere in the data -->
1794 But this is not a comment.
1795 !! html/php
1796 <p>But this is not a comment.
1797 </p>
1798 !! html/parsoid
1799 <!-- Browsers &#x2D;&#x2D;!&#x3E; think this is closed -->
1800 <!--&#x3E; This would normally be text -->
1801 <!--&#x2D;&#x3E; As would this -->
1802 <!-- XML doesn't like trailing dashes &#x2D;&#x2D;&#x2D;&#x2D;&#x2D;&#x2D;-->
1803 <!-- Nor doubled hyphens &#x2D;&#x2D; anywhere in the data -->
1804 <p>But this is not a comment.</p>
1805 !! end
1806
1807 !! test
1808 Comment semantics: round-trip even text which contains encoded -->
1809 !! wikitext
1810 <!-- hello & goodbye - > --&gt; --&amp;gt; --&xx -->
1811 !! html/parsoid
1812 <!-- hello &#x26; goodbye &#x2D; &#x3E; &#x2D;&#x2D;&#x3E; &#x2D;&#x2D;&#x26;gt; &#x2D;&#x2D;&#x26;xx -->
1813 !! end
1814
1815 !! test
1816 Comment in template title
1817 !! wikitext
1818 {{f<!---->oo}}
1819 !! html
1820 <p>FOO
1821 </p>
1822 !! end
1823
1824 !! test
1825 Comment on its own line post-expand
1826 !! wikitext
1827 a
1828 {{blank}}<!---->
1829 b
1830 !! html
1831 <p>a
1832 </p><p>b
1833 </p>
1834 !! end
1835
1836 !! test
1837 Comment on its own line post-expand with non-significant whitespace
1838 !! wikitext
1839 a
1840 {{blank}} <!---->
1841 b
1842 !! html
1843 <p>a
1844 </p><p>b
1845 </p>
1846 !! end
1847
1848 !! test
1849 post-expand include size being exceeded
1850 !! options
1851 maxincludesize=20
1852 !! wikitext
1853 {{echo3|1234567890}}
1854 !! html
1855 <p><a href="/wiki/Template:Echo3" title="Template:Echo3">Template:Echo3</a><!-- WARNING: template omitted, post-expand include size too large -->
1856 </p>
1857 !! end
1858
1859 !! test
1860 max template depth being reached
1861 !! options
1862 maxtemplatedepth=1
1863 !! wikitext
1864 {{echo with depth|too deep!}}
1865 !! html
1866 <p><span class="error">Template recursion depth limit exceeded (1)</span>
1867 </p>
1868 !! end
1869
1870 !! test
1871 multiple templates that are redirects
1872 !! wikitext
1873 {{redirect to foo}}
1874 {{redirect to foo}}
1875 !! html
1876 <p>FOO
1877 FOO
1878 </p>
1879 !! end
1880
1881 !! test
1882 Multiple comments should still parse as SOL-transparent
1883 !! options
1884 parsoid=wt2html,wt2wt
1885 !! wikitext
1886 <!--c1-->*a
1887 <!--c2--><!--c3--><!--c4-->*b
1888 !! html/php
1889 <ul><li>a</li>
1890 <li>b</li></ul>
1891
1892 !! html/parsoid
1893 <!--c1--><ul>
1894 <li>a
1895 </li>
1896 <!--c2--><!--c3--><!--c4-->
1897 <li>b
1898 </li>
1899 </ul>
1900 !! end
1901
1902 ## Make sure ">" gets escaped in comments to avoid XSS
1903 !! test
1904 IE conditional comments
1905 !! wikitext
1906 <!--[if lt IE 9]>
1907 <script>alert('hi');</script>
1908 <![endif]-->
1909 !! html/parsoid
1910 <!--[if lt IE 9]&#x3E;
1911 <script&#x3E;alert('hi');</script&#x3E;
1912 <![endif]-->
1913 !! end
1914
1915 ###
1916 ### paragraph wrapping tests
1917 ###
1918
1919 !! test
1920 No block tags
1921 !! wikitext
1922 a
1923
1924 b
1925 !! html
1926 <p>a
1927 </p><p>b
1928 </p>
1929 !! end
1930
1931 !! test
1932 Block tag on one line (<div>)
1933 !! wikitext
1934 a <div>foo</div>
1935
1936 b
1937 !! html
1938 a <div>foo</div>
1939 <p>b
1940 </p>
1941 !! html+tidy
1942 <p>a </p><div>foo</div>
1943 <p>b
1944 </p>
1945 !! end
1946
1947 # Remex wraps empty tag runs with p-tags.
1948 # Parsoid strips them out during p-wrapping.
1949 !! test
1950 No p-wrappable content
1951 !! wikitext
1952 <span><div>x</div></span>
1953 <span><s><div>x</div></s></span>
1954 <small><em></em></small><span><s><div>x</div></s></span>
1955 !! html/php+tidy
1956 <span><div>x</div></span>
1957 <span><s><div>x</div></s></span>
1958 <p><small><em></em></small></p><span><s><div>x</div></s></span>
1959 !! html/parsoid
1960 <span><div>x</div></span>
1961 <span><s><div>x</div></s></span>
1962 <small><em></em></small><span><s><div>x</div></s></span>
1963 !! end
1964
1965 # T177612: Parsoid-only test
1966 !! test
1967 Transclusion meta tags shouldn't trip Parsoid's useless p-wrapper stripping code
1968 !! wikitext
1969 {{echo|<span><div>x</div></span>}}
1970 x
1971 !! html/parsoid
1972 <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>
1973 <p>x</p>
1974 !! end
1975
1976 !! test
1977 Block tag on one line (<blockquote>)
1978 !! wikitext
1979 a <blockquote>foo</blockquote>
1980
1981 b
1982 !! html
1983 a <blockquote>foo</blockquote>
1984 <p>b
1985 </p>
1986 !! html+tidy
1987 <p>a </p><blockquote><p>foo</p></blockquote>
1988 <p>b
1989 </p>
1990 !! end
1991
1992 !! test
1993 Block tag on both lines (<div>)
1994 !! wikitext
1995 a <div>foo</div>
1996
1997 b <div>foo</div>
1998 !! html
1999 a <div>foo</div>
2000 b <div>foo</div>
2001
2002 !! html+tidy
2003 <p>a </p><div>foo</div><p>
2004 b </p><div>foo</div>
2005 !! end
2006
2007 !! test
2008 Block tag on both lines (<blockquote>)
2009 !! wikitext
2010 a <blockquote>foo</blockquote>
2011
2012 b <blockquote>foo</blockquote>
2013 !! html
2014 a <blockquote>foo</blockquote>
2015 b <blockquote>foo</blockquote>
2016
2017 !! html+tidy
2018 <p>a </p><blockquote><p>foo</p></blockquote><p>
2019 b </p><blockquote><p>foo</p></blockquote>
2020 !! end
2021
2022 !! test
2023 Multiple lines without block tags
2024 !! wikitext
2025 <div>foo</div> a
2026 b
2027 c
2028 d<!--foo--> e
2029 x <div>foo</div> z
2030 !! html
2031 <div>foo</div> a
2032 <p>b
2033 c
2034 d e
2035 </p>
2036 x <div>foo</div> z
2037
2038 !! html+tidy
2039 <div>foo</div><p> a
2040 </p><p>b
2041 c
2042 d e
2043 </p><p>
2044 x </p><div>foo</div><p> z
2045 </p>
2046 !! end
2047
2048 # The difference between Parsoid & Remex here
2049 # is because of Parsoid's Tidy-emulation code
2050 # for p-wrapping. We'll start work to remove this
2051 # emulation code in Parsoid sooner than later.
2052 # Remex wraps empty tag runs with p-tags.
2053 # Parsoid strips them out in a separate pass.
2054 !! test
2055 Empty lines between lines with block tags
2056 !! wikitext
2057 <div></div>
2058
2059
2060 <div></div>a
2061
2062 b
2063 <div>a</div>b
2064
2065 <div>b</div>d
2066
2067
2068 <div>e</div>
2069 !! html
2070 <div></div>
2071 <p><br />
2072 </p>
2073 <div></div>a
2074 <p>b
2075 </p>
2076 <div>a</div>b
2077 <div>b</div>d
2078 <p><br />
2079 </p>
2080 <div>e</div>
2081
2082 !! html+tidy
2083 <div></div>
2084 <p><br />
2085 </p>
2086 <div></div><p>a
2087 </p><p>b
2088 </p>
2089 <div>a</div><p>b
2090 </p><div>b</div><p>d
2091 </p><p><br />
2092 </p>
2093 <div>e</div>
2094 !! html/parsoid
2095 <div data-parsoid='{"stx":"html"}'></div>
2096
2097 <p><br /></p>
2098 <div data-parsoid='{"stx":"html"}'></div><p>a</p>
2099
2100 <p>b</p>
2101 <div data-parsoid='{"stx":"html"}'>a</div><p>b</p>
2102
2103 <div data-parsoid='{"stx":"html"}'>b</div><p>d</p>
2104
2105 <p><br /></p>
2106 <div data-parsoid='{"stx":"html"}'>e</div>
2107 !! end
2108
2109 !! test
2110 Unclosed HTML p-tags should be handled properly
2111 !! wikitext
2112 <div><p>foo</div>
2113 a
2114
2115 b
2116 !! html/php+tidy
2117 <div><p>foo</p></div>
2118 <p>a
2119 </p><p>b
2120 </p>
2121 !! html/parsoid
2122 <div data-parsoid='{"stx":"html"}'><p data-parsoid='{"stx":"html", "autoInsertedEnd":true}'>foo</p></div>
2123 <p>a</p>
2124 <p>b</p>
2125 !! end
2126
2127 ## SSS FIXME: I can come up with other scenarios where this doesn't work because
2128 ## of eager output of buffered tokens in the p-wrapper. But, I'm going to ignore
2129 ## them for now.
2130 !! test
2131 1. P-wrapping should leave sol-transparent tags outside p-tags where possible
2132 !! options
2133 parsoid=wt2html
2134 !! wikitext
2135 a [[Category:A1]] [[Category:A2]]
2136 [[Category:A3]]
2137 [[Category:A4]]
2138 !! html/parsoid
2139 <p>a</p>
2140 <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"/>
2141 !! end
2142
2143 !! test
2144 2. P-wrapping should leave sol-transparent tags outside p-tags where possible
2145 !! options
2146 parsoid=wt2html
2147 !! wikitext
2148 [[Category:A1]]a
2149 !! html/parsoid
2150 <link rel="mw:PageProp/Category" href="./Category:A1"/><p>a</p>
2151 !! end
2152
2153 !! test
2154 No paragraph necessary for SOL transparent template
2155 !! wikitext
2156 <span><div>foo</div></span>
2157 [[Category:Foo]]
2158
2159 <span><div>foo</div></span>
2160 {{echo|[[Category:Foo]]}}
2161 !! html/php
2162 <span><div>foo</div></span>
2163 <span><div>foo</div></span>
2164
2165 !! html/parsoid
2166 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2167 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
2168
2169 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2170 <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}}]}'/>
2171 !! end
2172
2173 !! test
2174 Avoid expanding multiline sol transparent template ranges unnecessarily
2175 !! wikitext
2176 hi
2177
2178
2179 {{echo|<br/>
2180 }}
2181
2182 [[Category:Ho]]
2183 !! html/php
2184 <p>hi
2185 </p><p><br />
2186 <br />
2187 </p>
2188 !! html/parsoid
2189 <p>hi</p>
2190
2191 <p><br />
2192 <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">
2193 </span></p>
2194
2195 <link rel="mw:PageProp/Category" href="./Category:Ho" />
2196 !! end
2197
2198 ###
2199 ### Preformatted text
2200 ###
2201
2202 !! test
2203 Preformatted text
2204 !! wikitext
2205 This is some
2206 Preformatted text
2207 With ''italic''
2208 And '''bold'''
2209 And a [[Main Page|link]]
2210 !! html
2211 <pre>This is some
2212 Preformatted text
2213 With <i>italic</i>
2214 And <b>bold</b>
2215 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
2216 </pre>
2217 !! end
2218
2219 !! test
2220 Tabs don't trigger preformatted text
2221 !! wikitext
2222 This is not
2223 preformatted text.
2224 This is preformatted text.
2225 So is this.
2226 !! html/php
2227 <p> This is not
2228 preformatted text.
2229 </p>
2230 <pre>This is preformatted text.
2231 So is this.
2232 </pre>
2233 !! html/parsoid
2234 <p> This is not
2235 preformatted text.</p>
2236 <pre>This is preformatted text.
2237 So is this.</pre>
2238 !! end
2239
2240 !! test
2241 Space before tab needs nowiki pre protection
2242 !! options
2243 parsoid=html2wt
2244 !! html/parsoid
2245 <p> a</p>
2246 !! wikitext
2247 <nowiki> </nowiki> a
2248 !! end
2249
2250 !! test
2251 Ident preformatting with inline content
2252 !! wikitext
2253 a
2254 ''b''
2255 !! html
2256 <pre>a
2257 <i>b</i>
2258 </pre>
2259 !! end
2260
2261 !! test
2262 <pre> with <nowiki> inside (compatibility with 1.6 and earlier)
2263 !! wikitext
2264 <pre><nowiki>
2265 <b>
2266 <cite>
2267 <em>
2268 </nowiki></pre>
2269 !! html
2270 <pre>
2271 &lt;b&gt;
2272 &lt;cite&gt;
2273 &lt;em&gt;
2274 </pre>
2275
2276 !! end
2277
2278 !! test
2279 Regression with preformatted in <center>
2280 !! wikitext
2281 <center>
2282 Blah
2283 </center>
2284 !! html
2285 <center>
2286 <pre>Blah
2287 </pre>
2288 </center>
2289
2290 !! end
2291
2292 !! test
2293 T54763: Preformatted in <blockquote>
2294 !! wikitext
2295 <blockquote>
2296 Blah
2297 {|
2298 |
2299 indented cell (no pre-wrapping!)
2300 |}
2301 </blockquote>
2302 !! html
2303 <blockquote>
2304 <p> Blah
2305 </p>
2306 <table>
2307 <tr>
2308 <td>
2309 <p> indented cell (no pre-wrapping!)
2310 </p>
2311 </td></tr></table>
2312 </blockquote>
2313
2314 !! end
2315
2316 !! test
2317 T53086: Double newlines in blockquotes should be turned into paragraphs
2318 !! wikitext
2319 <blockquote>
2320 Foo
2321
2322 Bar
2323 </blockquote>
2324 !! html
2325 <blockquote>
2326 <p>Foo
2327 </p><p>Bar
2328 </p>
2329 </blockquote>
2330
2331 !! end
2332
2333 !! test
2334 T17491: <ins>/<del> in blockquote
2335 !! wikitext
2336 <blockquote>
2337 Foo <del>bar</del> <ins>baz</ins> quux
2338 </blockquote>
2339 !! html
2340 <blockquote>
2341 <p>Foo <del>bar</del> <ins>baz</ins> quux
2342 </p>
2343 </blockquote>
2344
2345 !! end
2346
2347 !! test
2348 T17491: <ins>/<del> in blockquote (2)
2349 !! wikitext
2350 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2351 </blockquote>
2352 !! html
2353 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2354 </blockquote>
2355
2356 !! html+tidy
2357 <blockquote><p>Foo </p><del>bar</del> <ins>baz</ins><p> quux
2358 </p></blockquote>
2359 !! end
2360
2361 !! test
2362 <pre> with attributes (T5202)
2363 !! wikitext
2364 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2365 !! html
2366 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2367
2368 !! end
2369
2370 !! test
2371 <pre> with width attribute (T5202)
2372 !! wikitext
2373 <pre width="8">Narrow screen goodies</pre>
2374 !! html
2375 <pre width="8">Narrow screen goodies</pre>
2376
2377 !! end
2378
2379 !! test
2380 <pre> with forbidden attribute (T5202)
2381 !! wikitext
2382 <pre width="8" onmouseover="alert(document.cookie)">Narrow screen goodies</pre>
2383 !! html
2384 <pre width="8">Narrow screen goodies</pre>
2385
2386 !! end
2387
2388 !! test
2389 Entities inside <pre>
2390 !! wikitext
2391 <pre>&lt;</pre>
2392 !! html
2393 <pre>&lt;</pre>
2394
2395 !! end
2396
2397 !! test
2398 <pre> with forbidden attribute values (T5202)
2399 !! wikitext
2400 <pre width="8" style="border-width: expression(alert(document.cookie))">Narrow screen goodies</pre>
2401 !! html
2402 <pre width="8" style="/* insecure input */">Narrow screen goodies</pre>
2403
2404 !! end
2405
2406 !! test
2407 <nowiki> inside <pre> (T15238)
2408 !! wikitext
2409 <pre>
2410 <nowiki>
2411 </pre>
2412 <pre>
2413 <nowiki></nowiki>
2414 </pre>
2415 <pre><nowiki><nowiki></nowiki>Foo<nowiki></nowiki></nowiki></pre>
2416 !! html
2417 <pre>
2418 &lt;nowiki&gt;
2419 </pre>
2420 <pre>
2421
2422 </pre>
2423 <pre>&lt;nowiki&gt;Foo&lt;/nowiki&gt;</pre>
2424
2425 !! end
2426
2427 !! test
2428 <nowiki> inside of #tag:pre
2429 !! wikitext
2430 {{#tag:pre|Foo <nowiki>&rarr;bar</nowiki>}}
2431 !! html/php
2432 <pre>Foo &#8594;bar</pre>
2433
2434 !! html/parsoid
2435 <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>
2436 !! end
2437
2438 ## Don't expect this to rt, Parsoid drops the unmatched closing pre tags that
2439 ## aren't enclosed in nowikis.
2440 !! test
2441 <nowiki> and <pre> preference (first one wins)
2442 !! options
2443 parsoid=wt2html
2444 !! wikitext
2445 <pre>
2446 <nowiki>
2447 </pre>
2448 </nowiki>
2449 </pre>
2450
2451 <nowiki>
2452 <pre>
2453 <nowiki>
2454 </pre>
2455 </nowiki>
2456 </pre>
2457
2458 !! html/php
2459 <pre>
2460 &lt;nowiki&gt;
2461 </pre>
2462 <p>&lt;/nowiki&gt;
2463 &lt;/pre&gt;
2464 </p><p>
2465 &lt;pre&gt;
2466 &lt;nowiki&gt;
2467 &lt;/pre&gt;
2468
2469 &lt;/pre&gt;
2470 </p>
2471 !! html/parsoid
2472 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n&lt;nowiki>\n"}}'>&lt;nowiki>
2473 </pre>
2474 <p>&lt;/nowiki></p>
2475
2476
2477 <p><span typeof="mw:Nowiki">
2478 &lt;pre>
2479 &lt;nowiki>
2480 &lt;/pre>
2481 </span></p>
2482 !! end
2483
2484 !! test
2485 </pre> inside nowiki
2486 !! wikitext
2487 <nowiki></pre></nowiki>
2488 !! html
2489 <p>&lt;/pre&gt;
2490 </p>
2491 !! end
2492
2493 !! test
2494 Empty pre; pre inside other HTML tags (T56946)
2495 !! wikitext
2496 a
2497
2498 <div><pre>
2499 foo
2500 </pre></div>
2501 <pre></pre>
2502 !! html/php+tidy
2503 <p>a
2504 </p>
2505 <div><pre>foo
2506 </pre></div>
2507 <pre></pre>
2508 !! html/parsoid
2509 <p>a</p>
2510
2511 <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
2512 </pre></div>
2513 <pre typeof="mw:Extension/pre" about="#mwt4" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":""}}'></pre>
2514 !! end
2515
2516 !! test
2517 HTML pre followed by indent-pre
2518 !! wikitext
2519 <pre>foo</pre>
2520 bar
2521 !! html
2522 <pre>foo</pre>
2523 <pre>bar
2524 </pre>
2525 !! end
2526
2527 !! test
2528 Block tag pre
2529 !! wikitext
2530 <p><pre>foo</pre></p>
2531 !! html/php+tidy
2532 <p class="mw-empty-elt"></p><pre>foo</pre><p class="mw-empty-elt"></p>
2533 !! html/parsoid
2534 <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>
2535 !! end
2536
2537 !!test
2538 Templates: Indent-Pre: 1a. Templates that break a line should suppress <pre>
2539 !! wikitext
2540 {{echo|}}
2541 !! html
2542
2543 !!end
2544
2545 !!test
2546 Templates: Indent-Pre: 1b. Templates that break a line should suppress <pre>
2547 !! wikitext
2548 {{echo|
2549 foo}}
2550 !! html
2551 <p>foo
2552 </p>
2553 !!end
2554
2555 !! test
2556 Templates: Indent-Pre: 1c: Wrapping should be based on expanded content
2557 !! wikitext
2558 {{echo|a
2559 b}}
2560 !! html
2561 <pre>a
2562 </pre>
2563 <p>b
2564 </p>
2565 !!end
2566
2567 !! test
2568 Templates: Indent-Pre: 1d: Wrapping should be based on expanded content
2569 !! wikitext
2570 {{echo|a
2571 b
2572 c
2573 d
2574 e
2575 }}
2576 !! html
2577 <pre>a
2578 </pre>
2579 <p>b
2580 c
2581 </p>
2582 <pre>d
2583 </pre>
2584 <p>e
2585 </p>
2586 !!end
2587
2588 !!test
2589 Templates: Indent-Pre: 1e. Wrapping should be based on expanded content
2590 !! wikitext
2591 {{echo| foo}}
2592
2593 {{echo| foo}}{{echo| bar}}
2594
2595 {{echo| foo}}
2596 {{echo| bar}}
2597
2598 {{echo|<!--cmt--> foo}}
2599
2600 <!--cmt-->{{echo| foo}}
2601
2602 {{echo|{{echo| }}bar}}
2603 !! html
2604 <pre>foo
2605 </pre>
2606 <pre>foo bar
2607 </pre>
2608 <pre>foo
2609 bar
2610 </pre>
2611 <pre>foo
2612 </pre>
2613 <pre>foo
2614 </pre>
2615 <pre>bar
2616 </pre>
2617 !!end
2618
2619 !! test
2620 Templates: Indent-Pre: 1f: Wrapping should be based on expanded content
2621 !! wikitext
2622 {{echo| }}a
2623
2624 {{echo|
2625 }}a
2626
2627 {{echo|
2628 b}}
2629
2630 {{echo|a
2631 }}b
2632
2633 {{echo|a
2634 }} b
2635 !! html
2636 <pre>a
2637 </pre>
2638 <p><br />
2639 </p>
2640 <pre>a
2641 </pre>
2642 <p><br />
2643 </p>
2644 <pre>b
2645 </pre>
2646 <p>a
2647 </p>
2648 <pre>b
2649 </pre>
2650 <p>a
2651 </p>
2652 <pre>b
2653 </pre>
2654 !!end
2655
2656 ## Hmm, should Parsoid rt this?
2657 !! test
2658 Pres with newline attributes
2659 !! options
2660 parsoid=wt2html,html2html
2661 !! wikitext
2662 <pre class="one
2663 two">hi</pre>
2664 !! html/php
2665 <pre class="one two">hi</pre>
2666
2667 !! html/parsoid
2668 <pre typeof="mw:Extension/pre" about="#mwt2" class="one two" data-mw='{"name":"pre","attrs":{"class":"one two"},"body":{"extsrc":"hi"}}'>hi</pre>
2669 !! end
2670
2671 !! test
2672 Things that look like <pre> tags aren't treated as such
2673 !! wikitext
2674 Barack Obama <President> of the United States
2675 <President></President>
2676 !! html
2677 <p>Barack Obama &lt;President&gt; of the United States
2678 &lt;President&gt;&lt;/President&gt;
2679 </p>
2680 !! end
2681
2682 !! test
2683 Handle broken pre-like tags (T66025)
2684 !! options
2685 parsoid=wt2html
2686 !! wikitext
2687 {{echo|<pre <pre>x</pre>}}
2688
2689 <table><pre </table>
2690 !! html/php
2691 <pre>x</pre>
2692 <table>&lt;pre </table>
2693
2694 !! html/php+tidy
2695 <pre>x</pre>
2696 &lt;pre <table></table>
2697 !! html/parsoid
2698 <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>
2699
2700
2701 <p>&lt;pre </p>
2702
2703 <table></table>
2704 !! end
2705
2706 !! test
2707 Parsoid: handle pre with space after attribute
2708 !! options
2709 parsoid=wt2html
2710 !! wikitext
2711 <pre style="width:50%;" >{{echo|foo}}</pre>
2712 !! html/php
2713 <pre style="width:50%;">{{echo|foo}}</pre>
2714
2715 !! html/parsoid
2716 <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>
2717 !! end
2718
2719 # TODO / maybe: fix wt2wt for this
2720 !! test
2721 Parsoid: Don't paragraph-wrap fosterable content
2722 !! options
2723 parsoid=wt2html
2724 !! wikitext
2725 {|
2726 <td></td>
2727 <td></td>
2728
2729
2730
2731 |}
2732 !! html
2733 <table>
2734
2735 <tbody>
2736 <tr>
2737 <td></td>
2738
2739 <td></td></tr>
2740
2741
2742
2743 </tbody></table>
2744 !! end
2745
2746 !! test
2747 Self-closed pre
2748 !! wikitext
2749 <pre />
2750 !! html/php
2751 <pre></pre>
2752
2753 !! html/parsoid
2754 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":null}'></pre>
2755 !! end
2756
2757 !! test
2758 Parsoid: Don't paragraph-wrap fosterable content even if table syntax is unbalanced
2759 !! options
2760 parsoid=wt2html
2761 !! wikitext
2762 {|
2763 <td>
2764 <td>
2765 </td>
2766
2767
2768
2769 |}
2770 !! html
2771 <table>
2772
2773 <tbody>
2774 <tr>
2775 <td></td>
2776
2777 <td>
2778 </td></tr>
2779
2780
2781
2782 </tbody></table>
2783 !! end
2784
2785
2786 #--------------------------------------------------------------------
2787 # Transclusion parameter whitespace stripping tests
2788 # Behavior is different for positional and named parameters
2789 #--------------------------------------------------------------------
2790 !! test
2791 Templates: Strip leading and trailing whitespace from named-param values
2792 !! wikitext
2793 {{echo|1= a }}
2794
2795 {{echo|1= {{echo|b}} }}
2796
2797 {{echo| 1 =
2798 c }}
2799
2800 {{echo| 1 =
2801 * d
2802 }}
2803 !! html
2804 <p>a
2805 </p><p>b
2806 </p><p>c
2807 </p>
2808 <ul><li>d</li></ul>
2809
2810 !! end
2811
2812 !! test
2813 Templates: Don't strip whitespace from positional-param values
2814 !! wikitext
2815 {{echo|a }}
2816
2817 {{echo|{{echo|b}} }}
2818
2819 {{echo| c
2820 }}
2821
2822 {{echo| {{echo|d}}
2823 }}
2824
2825 {{echo|
2826 e}}
2827
2828 {{echo|
2829 *f}}
2830
2831 {{echo|
2832 }}g
2833 !! html
2834 <p>a
2835 </p><p>b
2836 </p>
2837 <pre>c
2838 </pre>
2839 <p><br />
2840 </p>
2841 <pre>d
2842 </pre>
2843 <p><br />
2844 </p>
2845 <pre>e
2846 </pre>
2847 <p><br />
2848 </p>
2849 <ul><li>f</li></ul>
2850 <p><br />
2851 </p>
2852 <pre>g
2853 </pre>
2854 !! end
2855
2856 !! test
2857 Templates: Don't recognize targets split by newlines
2858 !! options
2859 parsoid=wt2html
2860 !! wikitext
2861 {{ech
2862 o|foo}}
2863 !! html/php
2864 <p>{{ech
2865 o|foo}}
2866 </p>
2867 !! html/parsoid
2868 <p>{{ech
2869 o|foo}}</p>
2870 !! end
2871
2872 !! test
2873 Templates: Recognize targets when newlines and comments don't split the target
2874 !! options
2875 parsoid=wt2html
2876 !! wikitext
2877 {{
2878 <!--X--> ech<!--X-->o<!--X-->
2879 <!--X--> <!--X-->
2880
2881 |foo}}
2882 !! html/php
2883 <p>foo
2884 </p>
2885 !! html/parsoid
2886 <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>
2887 !! end
2888
2889 !! test
2890 Templates: Handle empty comment-and-ws-only lines correctly
2891 !! wikitext
2892 {{echo|foo
2893 <!--should be ignored-->
2894 <!--should be ignored as well-->
2895 bar}}
2896 !! html/php
2897 <p>foo
2898 bar
2899 </p>
2900 !! html/parsoid
2901 <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>
2902 !! end
2903
2904 !! test
2905 Templates: Handle comments in the target
2906 !! wikitext
2907 {{echo
2908 <!-- should be ignored -->
2909 |foo}}
2910
2911 {{echo
2912 <!-- should be ignored and spaces on next line should not trip us up (T147742) -->
2913 |foo}}
2914
2915 {{echo<!-- should be ignored -->
2916 |foo}}
2917
2918 {{echo<!-- should be ignored -->|foo}}
2919
2920 {{<!-- should be ignored -->echo|foo}}
2921 !! html/php
2922 <p>foo
2923 </p><p>foo
2924 </p><p>foo
2925 </p><p>foo
2926 </p><p>foo
2927 </p>
2928 !! html/parsoid
2929 <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>
2930
2931 <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>
2932
2933 <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>
2934
2935 <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>
2936
2937 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
2938 !! end
2939
2940 !! test
2941 Templates: Handle comments in parameter names (T69657)
2942 !! wikitext
2943 {{echo|1
2944 <!-- should be ignored -->
2945 =foo}}
2946
2947 {{echo|
2948 <!-- should be ignored -->
2949 1 = foo}}
2950
2951 {{echo|1<!-- should be ignored -->=foo}}
2952
2953 {{echo|<!-- should be ignored -->1=foo}}
2954 !! html/php
2955 <p>foo
2956 </p><p>foo
2957 </p><p>foo
2958 </p><p>foo
2959 </p>
2960 !! html/parsoid
2961 <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>
2962
2963 <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>
2964
2965 <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>
2966
2967 <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>
2968 !! end
2969
2970 !! test
2971 Templates: Other wikitext in parameter names (T69657)
2972 !! wikitext
2973 {{echo|''1''=foo}}
2974 !! html/php
2975 <p>{{{1}}}
2976 </p>
2977 !! html/parsoid
2978 <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>
2979 !! end
2980
2981 !! test
2982 Templates: With colons
2983 !! wikitext
2984 {{With: Colon}}
2985 !! html/php
2986 <p>Template with colon
2987 </p>
2988 !! html/parsoid
2989 <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>
2990 !! end
2991
2992 #--------------------------------------------------------------------
2993 # Transclusion parameter escaping tests
2994 #--------------------------------------------------------------------
2995
2996 !! test
2997 Templates: Parsoid parameter escaping test 1
2998 !! wikitext
2999 {{echo|[foo]|{{echo|[bar]}}}}
3000 !! html/php+tidy
3001 <p>[foo]
3002 </p>
3003 !! html/parsoid
3004 <p about="#mwt1" typeof="mw:Transclusion"
3005 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[foo]"},"2":{"wt":"{{echo|[bar]}}"}},"i":0}}]}'>[foo]</p>
3006 !! end
3007
3008 !! test
3009 Parsoid: Pipes in external links in template parameter
3010 !! wikitext
3011 {{echo|[{{echo|http://example.com}} link]}}
3012 !! html/php+tidy
3013 <p><a rel="nofollow" class="external text" href="http://example.com">link</a>
3014 </p>
3015 !! html/parsoid
3016 <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>
3017 !! end
3018
3019 !! test
3020 Parsoid: pipe in transclusion parameter
3021 !! wikitext
3022 {{echo|http://foo.com/a&#124;b}}
3023 !! html/php+tidy
3024 <p><a rel="nofollow" class="external free" href="http://foo.com/a%7Cb">http://foo.com/a%7Cb</a>
3025 </p>
3026 !! html/parsoid
3027 <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>
3028 !! end
3029
3030 !! test
3031 Parsoid: Pipe in external link target and content in template parameter
3032 !! options
3033 parsoid=html2wt,wt2wt
3034 !! wikitext
3035 {{echo|[http://foo.com/a&#124;b a&#124;b]}}
3036 !! html/php+tidy
3037 <p><a rel="nofollow" class="external text" href="http://foo.com/a%7Cb">a&#124;b</a>
3038 </p>
3039 !! html/parsoid
3040 <p><a rel="mw:ExtLink" href="http://foo.com/a|b" about="#mwt1"
3041 typeof="mw:Transclusion"
3042 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},
3043 "params":{"1":{"wt":"[http://foo.com/a|b a|b]"}},"i":0}}]}'>a|b</a></p>
3044 !! end
3045
3046 !! test
3047 Parsoid: Pipe in template with nested template in external link target in template parameter (seriously)
3048 !! options
3049 parsoid
3050 !! wikitext
3051 {{echo|[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]}}
3052 !! html
3053 <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>
3054 !! end
3055
3056 !! test
3057 Templates: Don't escape already nowiki-escaped text in template parameters
3058 !! options
3059 parsoid=html2wt,wt2wt
3060 !! wikitext
3061 {{echo|foo<nowiki>|</nowiki>bar}}
3062 {{echo|<nowiki>&lt;div&gt;</nowiki>}}
3063 {{echo|<nowiki></nowiki>}}
3064 !! html/php+tidy
3065 <p>foo|bar
3066 &lt;div&gt;
3067
3068 </p>
3069 !! html/parsoid
3070 <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>
3071 <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>
3072 <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>
3073 </p>
3074 !! end
3075
3076 ## T54824
3077 !! test
3078 Templates: '=' char in nested transclusions should not trigger nowiki escapes or conversion to named param
3079 !! options
3080 parsoid=html2wt,wt2wt
3081 !! wikitext
3082 {{echo|{{echo|1=bar}}}}
3083 !! html/php+tidy
3084 <p>bar
3085 </p>
3086 !! html/parsoid
3087 <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>
3088 !! end
3089
3090 ## T58733
3091 !! test
3092 Templates parameters with special tokenizing behavior dont get modified because of arg escaping
3093 !! wikitext
3094 {{echo|a : b}}
3095 !! html/php+tidy
3096 <p>a&#160;: b
3097 </p>
3098 !! html/parsoid
3099 <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>
3100 !! end
3101
3102 ## T73412
3103 !! test
3104 Templates: Preserve blank parameter names
3105 !! wikitext
3106 {{echo|=foo}}
3107 !! html/php+tidy
3108 <p>{{{1}}}
3109 </p>
3110 !! html/parsoid
3111 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"":{"wt":"foo"}},"i":0}}]}'>{{{1}}}</p>
3112 !! end
3113
3114 !! test
3115 Templates: Preserve blank parameter names in other positions
3116 !! wikitext
3117 {{blank_param|bar|=foo}}
3118 !! html/php+tidy
3119 <p>bar
3120 foo
3121 </p>
3122 !! html/parsoid
3123 <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
3124 foo</p>
3125 !! end
3126
3127 ###
3128 ### Parsoid-centric tests for testing RT edge cases for pre
3129 ###
3130
3131 !!test
3132 1a. Indent-Pre and Comments
3133 !! wikitext
3134 a
3135 <!--a-->
3136 c
3137 !! html
3138 <pre>a
3139 </pre>
3140 <p>c
3141 </p>
3142 !!end
3143
3144 !!test
3145 1b. Indent-Pre and Comments
3146 !! wikitext
3147 a
3148 <!--a-->
3149 c
3150 !! html
3151 <pre>a
3152 </pre>
3153 <p>c
3154 </p>
3155 !!end
3156
3157 !!test
3158 1c. Indent-Pre and Comments
3159 !! wikitext
3160 <!--a--> a
3161
3162 <!--a--> a
3163 !! html
3164 <pre> a
3165 </pre>
3166 <pre> a
3167 </pre>
3168 !!end
3169
3170 !!test
3171 1d. Indent-Pre and Comments
3172 (Pre-handler currently cannot distinguish between comment/ws order and normalizes them to [comment,ws] order)
3173 !! wikitext
3174 <!--a--> a
3175
3176 <!--b-->b
3177 !! html
3178 <pre>a
3179 </pre>
3180 <pre>b
3181 </pre>
3182 !!end
3183
3184 !!test
3185 2a. Indent-Pre and tables
3186 !! wikitext
3187 {|
3188 |-
3189 !h1!!h2
3190 |foo||bar
3191 |}
3192 !! html
3193 <table>
3194
3195 <tr>
3196 <th>h1</th>
3197 <th>h2
3198 </th>
3199 <td>foo</td>
3200 <td>bar
3201 </td></tr></table>
3202
3203 !!end
3204
3205 !!test
3206 2b. Indent-Pre and tables
3207 !! wikitext
3208 {|
3209 |-
3210 |foo
3211 |}
3212 !! html
3213 <table>
3214
3215 <tr>
3216 <td>foo
3217 </td></tr></table>
3218
3219 !!end
3220
3221 !!test
3222 2c. Indent-Pre and tables (T44252)
3223 !! wikitext
3224 {|
3225 |+foo
3226 ! |bar
3227 |}
3228 !! html
3229 <table>
3230 <caption>foo
3231 </caption>
3232 <tr>
3233 <th>bar
3234 </th></tr></table>
3235
3236 !!end
3237
3238 !!test
3239 2d. Indent-Pre and tables
3240 !! wikitext
3241 a
3242 {|
3243 |b
3244 |}
3245 !! html/php
3246 <pre>a
3247 </pre>
3248 <table>
3249 <tr>
3250 <td>b
3251 </td></tr></table>
3252
3253 !! html/parsoid
3254 <pre>a</pre>
3255 <table>
3256 <tbody><tr><td> b</td></tr>
3257 </tbody></table>
3258 !!end
3259
3260 !!test
3261 2e. Indent-Pre and table-line syntax
3262 !! wikitext
3263 a
3264 | b
3265 | c
3266 !! html/php
3267 <pre>a
3268 | b
3269 | c
3270 </pre>
3271 !!end
3272
3273 !!test
3274 2f. Indent-pre started by table-line syntax
3275 !! wikitext
3276 a
3277 | b
3278 | c
3279 !! html/php
3280 <p>a
3281 </p>
3282 <pre>| b
3283 | c
3284 </pre>
3285 !! html/parsoid
3286 <p>a</p>
3287 <pre>
3288 | b
3289 | c</pre>
3290 !!end
3291
3292 !! test
3293 2g. Indented table markup mixed with indented pre content (proposed in T8200)
3294 !! wikitext
3295 <table>
3296 <tr>
3297 <td>
3298 Text that should be rendered preformatted
3299 </td>
3300 </tr>
3301 </table>
3302 !! html
3303 <table>
3304 <tr>
3305 <td>
3306 <pre>Text that should be rendered preformatted
3307 </pre>
3308 </td>
3309 </tr>
3310 </table>
3311
3312 !! end
3313
3314 !!test
3315 3a. Indent-Pre and block tags (single-line html)
3316 !! wikitext
3317 a <p> foo </p>
3318 b <div> foo </div>
3319 c <blockquote> foo </blockquote>
3320 <span> foo </span>
3321 !! html
3322 a <p> foo </p>
3323 b <div> foo </div>
3324 c <blockquote> foo </blockquote>
3325 <pre><span> foo </span>
3326 </pre>
3327 !! html/parsoid
3328 <p>a </p><p data-parsoid='{"stx":"html"}'> foo </p>
3329 <p>b </p><div data-parsoid='{"stx":"html"}'> foo </div>
3330 <p>c </p><blockquote data-parsoid='{"stx":"html"}'> foo </blockquote>
3331 <pre><span> foo </span>
3332 </pre>
3333 !! html/php+tidy
3334 <p> a </p><p> foo </p><p>
3335 b </p><div> foo </div><p>
3336 c </p><blockquote><p> foo </p></blockquote>
3337 <pre><span> foo </span>
3338 </pre>
3339 !! end
3340
3341 !!test
3342 3b. Indent-Pre and block tags (multi-line html)
3343 !! wikitext
3344 a <span>foo</span>
3345 b <div> foo </div>
3346 !! html
3347 <pre>a <span>foo</span>
3348 </pre>
3349 b <div> foo </div>
3350
3351 !! html/parsoid
3352 <pre>a <span data-parsoid='{"stx":"html"}'>foo</span></pre>
3353 b <div data-parsoid='{"stx":"html"}'> foo </div>
3354 !! html/php+tidy
3355 <pre>a <span>foo</span>
3356 </pre><p>
3357 b </p><div> foo </div>
3358 !!end
3359
3360 !!test
3361 3c. Indent-Pre and block tags (pre-content on separate line)
3362 !! wikitext
3363 <p>
3364 foo
3365 </p>
3366
3367 <div>
3368 foo
3369 </div>
3370
3371 <center>
3372 foo
3373 </center>
3374
3375 <blockquote>
3376 foo
3377 </blockquote>
3378
3379 <blockquote>
3380 <pre>
3381 foo
3382 </pre>
3383 </blockquote>
3384
3385 <table><tr><td>
3386 foo
3387 </td></tr></table>
3388
3389 <ul><li>
3390 foo
3391 </li></ul>
3392
3393 !! html
3394 <p>
3395 foo
3396 </p>
3397 <div>
3398 <pre>foo
3399 </pre>
3400 </div>
3401 <center>
3402 <pre>foo
3403 </pre>
3404 </center>
3405 <blockquote>
3406 <p> foo
3407 </p>
3408 </blockquote>
3409 <blockquote>
3410 <pre>
3411 foo
3412 </pre>
3413 </blockquote>
3414 <table><tr><td>
3415 <pre>foo
3416 </pre>
3417 </td></tr></table>
3418 <ul><li>
3419 foo
3420 </li></ul>
3421
3422 !!end
3423
3424 !! test
3425 4. Indent-Pre and extension tags
3426 !! wikitext
3427 a <tag />
3428 !! html/php
3429 a <pre>
3430 NULL
3431 array (
3432 )
3433 </pre>
3434
3435 !! html/parsoid
3436 a <pre typeof="mw:Extension/tag" about="#mwt2" data-parsoid='{}' data-mw='{"name":"tag","attrs":{},"body":null}'></pre>
3437 !! end
3438
3439 !! test
3440 5. Indent-Pre and html pre
3441 !! wikitext
3442 <pre class="123">hi</pre>
3443 !! html/php
3444 <pre class="123">hi</pre>
3445
3446 !! html/parsoid
3447 <pre typeof="mw:Extension/pre" about="#mwt2" class="123" data-mw='{"name":"pre","attrs":{"class":"123"},"body":{"extsrc":"hi"}}'>hi</pre>
3448 !! end
3449
3450 !!test
3451 Render paragraphs when indent-pre is suppressed in blocklevels
3452 !! wikitext
3453 <blockquote>
3454 foo
3455
3456 bar
3457 </blockquote>
3458 !! html
3459 <blockquote>
3460 <p> foo
3461 </p><p> bar
3462 </p>
3463 </blockquote>
3464
3465 !!end
3466
3467 !!test
3468 4. Multiple spaces at start-of-line
3469 !! wikitext
3470 <p> foo </p>
3471 foo
3472 {|
3473 |foo
3474 |}
3475 !! html
3476 <p> foo </p>
3477 <pre> foo
3478 </pre>
3479 <table>
3480 <tr>
3481 <td>foo
3482 </td></tr></table>
3483
3484 !!end
3485
3486 ## NOTE: the leading white-space chars on empty line are significant
3487 !! test
3488 5a. White-space in indent-pre
3489 !! wikitext
3490 a<br />
3491
3492 b
3493 !! html
3494 <pre>a<br />
3495
3496 b
3497 </pre>
3498 !! end
3499
3500 ## NOTE: the leading white-space chars on empty line are significant
3501 !! test
3502 5b. White-space in indent-pre
3503 !! wikitext
3504 a
3505
3506 b
3507
3508
3509 c
3510 !! html
3511 <pre>a
3512
3513 b
3514
3515
3516 c
3517 </pre>
3518 !! end
3519
3520 !! test
3521 5c. White-space in indent-pre
3522 !! wikitext
3523 ''a''
3524 ''b''
3525 ''c''
3526 !! html
3527 <pre><i>a</i>
3528 <i>b</i>
3529 <i>c</i>
3530 </pre>
3531 !! end
3532
3533 !! test
3534 6. Pre-blocks should extend across lines with leading WS even when there is no wrappable content
3535 !! wikitext
3536 a
3537
3538 <!-- continue -->
3539 b
3540
3541 c
3542
3543 d
3544 !! html
3545 <pre>a
3546
3547 b
3548 </pre>
3549 <pre>c
3550
3551 </pre>
3552 <p>d
3553 </p>
3554 !! end
3555
3556 !! test
3557 7a. Indent-pre and category links
3558 !! options
3559 parsoid=wt2html,wt2wt
3560 !! wikitext
3561 [[Category:foo]] <!-- No pre-wrapping -->
3562 {{echo| [[Category:foo]]}} <!-- No pre-wrapping -->
3563 !! html/php+tidy
3564 !! html/parsoid
3565 <link rel="mw:PageProp/Category" href="./Category:Foo"> <!-- No pre&#x2D;wrapping -->
3566 <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 -->
3567 !! end
3568
3569 ## We used to, but no longer wt2wt this test since the default serializer
3570 ## will normalize all categories to serialize on their own line.
3571 ## This wikitext usage is going to be fairly uncommon in production and
3572 ## selser will take care of preserving formatting in those scenarios.
3573 !! test
3574 7b. Indent-pre and category links
3575 !! options
3576 parsoid=wt2html
3577 !! wikitext
3578 [[Category:foo]] a
3579 [[Category:foo]] {{echo|b}}
3580 !! html/parsoid
3581 <pre><link rel="mw:PageProp/Category" href="./Category:Foo"> a
3582 <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>
3583 !! end
3584
3585 !! test
3586 Indent-Pre: Newlines in comments shouldn't affect sol state
3587 !! wikitext
3588 a <!--
3589 foo
3590 --> b
3591 !! html/php+tidy
3592 <p>a b
3593 </p>
3594 !! html/parsoid
3595 <p>a <!--
3596 foo
3597 --> b</p>
3598 !! end
3599
3600 ###
3601 ### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric)
3602 ###
3603
3604 !!test
3605 HTML-pre: 1. embedded newlines
3606 !! wikitext
3607 <pre>foo</pre>
3608
3609 <pre>
3610 foo
3611 </pre>
3612
3613 <pre>
3614
3615 foo
3616 </pre>
3617
3618 <pre>
3619
3620
3621 foo
3622 </pre>
3623 !! html/php+tidy
3624 <pre>foo</pre>
3625 <pre>foo
3626 </pre>
3627 <pre>
3628
3629 foo
3630 </pre>
3631 <pre>
3632
3633
3634 foo
3635 </pre>
3636 !! html/parsoid
3637 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre>
3638
3639 <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
3640 </pre>
3641
3642 <pre typeof="mw:Extension/pre" about="#mwt6" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\nfoo\n"}}'>
3643
3644 foo
3645 </pre>
3646
3647 <pre typeof="mw:Extension/pre" about="#mwt8" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\nfoo\n"}}'>
3648
3649
3650 foo
3651 </pre>
3652 !!end
3653
3654 !! test
3655 HTML-pre: big spaces
3656 !! wikitext
3657 <pre>
3658
3659
3660
3661
3662 haha
3663
3664
3665
3666
3667 haha
3668
3669
3670
3671
3672 </pre>
3673 !! html/php+tidy
3674 <pre>
3675
3676
3677
3678
3679 haha
3680
3681
3682
3683
3684 haha
3685
3686
3687
3688
3689 </pre>
3690 !! html/parsoid
3691 <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"}}'>
3692
3693
3694
3695
3696 haha
3697
3698
3699
3700
3701 haha
3702
3703
3704
3705
3706 </pre>
3707 !! end
3708
3709 !!test
3710 HTML-pre: 2: indented text
3711 !! wikitext
3712 <pre>
3713 foo
3714 </pre>
3715 !! html
3716 <pre>
3717 foo
3718 </pre>
3719
3720 !!end
3721
3722 !!test
3723 HTML-pre: 3: other wikitext
3724 !! wikitext
3725 <pre>
3726 * foo
3727 # bar
3728 = no-h =
3729 '' no-italic ''
3730 [[ NoLink ]]
3731 </pre>
3732 !! html/php
3733 <pre>
3734 * foo
3735 # bar
3736 = no-h =
3737 '' no-italic ''
3738 [[ NoLink ]]
3739 </pre>
3740
3741 !! html/parsoid
3742 <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
3743 # bar
3744 = no-h =
3745 '' no-italic ''
3746 [[ NoLink ]]
3747 </pre>
3748 !!end
3749
3750 ###
3751 ### Definition lists
3752 ###
3753 !! test
3754 Simple definition
3755 !! wikitext
3756 ;name :Definition
3757 !! html
3758 <dl><dt>name&#160;</dt>
3759 <dd>Definition</dd></dl>
3760
3761 !! end
3762
3763 !! test
3764 Definition list for indentation only
3765 !! wikitext
3766 :Indented text
3767 !! html
3768 <dl><dd>Indented text</dd></dl>
3769
3770 !! end
3771
3772 !! test
3773 Definition list with no space
3774 !! wikitext
3775 ;name:Definition
3776 !! html
3777 <dl><dt>name</dt>
3778 <dd>Definition</dd></dl>
3779
3780 !!end
3781
3782 !! test
3783 Definition list with URL link
3784 !! wikitext
3785 ;http://example.com/ :definition
3786 !! html
3787 <dl><dt><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&#160;</dt>
3788 <dd>definition</dd></dl>
3789
3790 !! end
3791
3792 !! test
3793 Definition list with bracketed URL link
3794 !! wikitext
3795 ;[http://www.example.com/ Example]:Something about it
3796 !! html
3797 <dl><dt><a rel="nofollow" class="external text" href="http://www.example.com/">Example</a></dt>
3798 <dd>Something about it</dd></dl>
3799
3800 !! end
3801
3802 !! test
3803 Definition list with wikilink containing colon
3804 !! wikitext
3805 ; [[Help:FAQ]]:The least-read page on Wikipedia
3806 !! html
3807 <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>
3808 <dd>The least-read page on Wikipedia</dd></dl>
3809
3810 !! end
3811
3812 # At Brion's and JeLuF's insistence... :)
3813 !! test
3814 Definition list with news link containing colon
3815 !! wikitext
3816 ;news:alt.wikipedia.rox: This isn't even a real newsgroup!
3817 !! html/php
3818 <dl><dt><a rel="nofollow" class="external free" href="news:alt.wikipedia.rox">news:alt.wikipedia.rox</a></dt>
3819 <dd>This isn't even a real newsgroup!</dd></dl>
3820
3821 !! html/parsoid
3822 <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>
3823 !! end
3824
3825 !! test
3826 Malformed definition list with colon
3827 !! wikitext
3828 ; news:alt.wikipedia.rox -- don't crash or enter an infinite loop
3829 !! html
3830 <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>
3831
3832 !! end
3833
3834 !! test
3835 Definition lists: colon in external link text
3836 !! wikitext
3837 ;[http://www.wikipedia2.org/ Wikipedia :The Next Generation] :OK, I made that up
3838 !! html
3839 <dl><dt><a rel="nofollow" class="external text" href="http://www.wikipedia2.org/">Wikipedia&#160;:The Next Generation</a>&#160;</dt>
3840 <dd>OK, I made that up</dd></dl>
3841
3842 !! end
3843
3844 !! test
3845 Definition lists: colon in HTML attribute
3846 !! wikitext
3847 ;<b style="display: inline">bold</b>
3848 !! html
3849 <dl><dt><b style="display: inline">bold</b></dt></dl>
3850
3851 !! end
3852
3853 !! test
3854 Definition lists: self-closed tag
3855 !! wikitext
3856 ;one<br/>two :two-line fun
3857 !! html
3858 <dl><dt>one<br />two&#160;</dt>
3859 <dd>two-line fun</dd></dl>
3860
3861 !! end
3862
3863 !! test
3864 Definition lists: ignore colons inside tags
3865 !! wikitext
3866 ;one <b>two : tag <i>fun:</i>:</b>:def
3867 !! html
3868 <dl><dt>one <b>two&#160;: tag <i>fun:</i>:</b></dt>
3869 <dd>def</dd></dl>
3870
3871 !! end
3872
3873 !! test
3874 Definition lists: excess closed tags
3875 !! wikitext
3876 ;one</b>two :bad tag fun
3877 !! html/php+tidy
3878 <dl><dt>onetwo&#160;</dt>
3879 <dd>bad tag fun</dd></dl>
3880 !! html/parsoid
3881 <dl>
3882 <dt>onetwo</dt>
3883 <dd>bad tag fun</dd>
3884 </dl>
3885 !! end
3886
3887 !! test
3888 T13748: Literal closing tags
3889 !! wikitext
3890 <dl>
3891 <dt>test 1</dt>
3892 <dd>test test test test test</dd>
3893 <dt>test 2</dt>
3894 <dd>test test test test test</dd>
3895 </dl>
3896 !! html
3897 <dl>
3898 <dt>test 1</dt>
3899 <dd>test test test test test</dd>
3900 <dt>test 2</dt>
3901 <dd>test test test test test</dd>
3902 </dl>
3903
3904 !! end
3905
3906 !! test
3907 Definition and unordered list using wiki syntax nested in unordered list using html tags.
3908 !! wikitext
3909 <ul><li>
3910 ;term :description
3911 *unordered
3912 </li></ul>
3913 !! html
3914 <ul><li>
3915 <dl><dt>term&#160;</dt>
3916 <dd>description</dd></dl>
3917 <ul><li>unordered</li></ul>
3918 </li></ul>
3919
3920 !! end
3921
3922 !! test
3923 Definition list with empty definition and following paragraph
3924 !! wikitext
3925 ;term:
3926
3927 Paragraph text
3928 !! html
3929 <dl><dt>term</dt>
3930 <dd></dd></dl>
3931 <p>Paragraph text
3932 </p>
3933 !! end
3934
3935 !! test
3936 Nested definition lists using html syntax
3937 !! wikitext
3938 <dl><dt>x</dt>
3939 <dd>a</dd>
3940 <dd>b</dd></dl>
3941 !! html
3942 <dl><dt>x</dt>
3943 <dd>a</dd>
3944 <dd>b</dd></dl>
3945
3946 !! end
3947
3948 !! test
3949 Definition Lists: No nesting: Multiple dd's
3950 !! wikitext
3951 ;x
3952 :a
3953 :b
3954 !! html
3955 <dl><dt>x</dt>
3956 <dd>a</dd>
3957 <dd>b</dd></dl>
3958
3959 !! end
3960
3961 !! test
3962 Definition Lists: Indentation: Regular
3963 !! wikitext
3964 :i1
3965 ::i2
3966 :::i3
3967 !! html
3968 <dl><dd>i1
3969 <dl><dd>i2
3970 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
3971
3972 !! end
3973
3974 !! test
3975 Definition Lists: Indentation: Missing 1st level
3976 !! wikitext
3977 ::i2
3978 :::i3
3979 !! html
3980 <dl><dd><dl><dd>i2
3981 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
3982
3983 !! end
3984
3985 !! test
3986 Definition Lists: Indentation: Multi-level indent
3987 !! wikitext
3988 :::i3
3989 !! html
3990 <dl><dd><dl><dd><dl><dd>i3</dd></dl></dd></dl></dd></dl>
3991
3992 !! end
3993
3994 !! test
3995 Definition Lists: Hacky use to indent tables
3996 !! wikitext
3997 ::{|
3998 |foo
3999 |bar
4000 |}
4001 this text
4002 should be left alone
4003 !! html
4004 <dl><dd><dl><dd><table>
4005 <tr>
4006 <td>foo
4007 </td>
4008 <td>bar
4009 </td></tr></table></dd></dl></dd></dl>
4010 <p>this text
4011 should be left alone
4012 </p>
4013 !! end
4014
4015 !! test
4016 Definition Lists: Hacky use to indent tables (with content following table)
4017 !! wikitext
4018 :{|
4019 |foo
4020 |bar
4021 |} <!--c1--> this text should be part of the dl
4022 !! html/php+tidy
4023 <dl><dd><table>
4024 <tbody><tr>
4025 <td>foo
4026 </td>
4027 <td>bar
4028 </td></tr></tbody></table> this text should be part of the dl</dd></dl>
4029 !! html/parsoid
4030 <dl><dd><table>
4031 <tbody><tr>
4032 <td>foo
4033 </td>
4034 <td>bar
4035 </td></tr></tbody></table> <!--c1--> this text should be part of the dl</dd></dl>
4036 !! end
4037
4038 !! test
4039 Definition Lists: Hacky use to indent tables, with comments (T65979)
4040 !! wikitext
4041 <!-- foo -->
4042 ::{|
4043 |foo
4044 |bar
4045 |}<!-- bar -->
4046 this text
4047 should be left alone
4048 !! html/parsoid
4049 <!-- foo -->
4050 <dl><dd><dl><dd><table><tr>
4051 <td>foo</td>
4052 <td>bar</td>
4053 </tr></table><!-- bar --></dd></dl></dd></dl>
4054 <p>this text
4055 should be left alone</p>
4056 !! end
4057
4058 !! test
4059 Definition Lists: Hacky use to indent tables, with comment before table
4060 !! wikitext
4061 ::<!-- foo -->{|
4062 |foo
4063 |}
4064 !! html/parsoid
4065 <dl><dd><dl><dd><!-- foo --><table><tr>
4066 <td>foo</td>
4067 </tr></table></dd></dl></dd></dl>
4068 !! end
4069
4070 # The trailing whitespace in this test is to catch a regression in
4071 # Parsoid after T54473.
4072 !! test
4073 Definition Lists: Hacky use to indent tables (WS-insensitive)
4074 !! wikitext
4075 : {|
4076 |a
4077 |}
4078 !! html/php
4079 <dl><dd><table>
4080 <tr>
4081 <td>a
4082 </td></tr></table></dd></dl>
4083
4084 !! html/parsoid
4085 <dl><dd> <table>
4086 <tbody><tr><td>a</td></tr>
4087 </tbody></table> </dd></dl>
4088 !! end
4089
4090 ## The PHP parser treats : items (dd) without a corresponding ; item (dt)
4091 ## as an empty dt item. It also ignores all but the last ";" when followed
4092 ## by ":" later on. So, ";" are not ignored in ";;;t3" but are ignored in
4093 ## ";;;t3 :d1". So, PHP parser behavior is a little inconsistent wrt multiple
4094 ## ";"s.
4095 ##
4096 ## Ex: ";;t2 ::d2" is transformed into:
4097 ##
4098 ## <dl>
4099 ## <dt>t2 </dt>
4100 ## <dd>
4101 ## <dl>
4102 ## <dt></dt>
4103 ## <dd>d2</dd>
4104 ## </dl>
4105 ## </dd>
4106 ## </dl>
4107 ##
4108 ## But, Parsoid treats "; :" as a tight atomic unit and excess ":" as plain text
4109 ## So, the same wikitext above (;;t2 ::d2) is transformed into:
4110 ##
4111 ## <dl>
4112 ## <dt>
4113 ## <dl>
4114 ## <dt>t2 </dt>
4115 ## <dd>:d2</dd>
4116 ## </dl>
4117 ## </dt>
4118 ## </dl>
4119 ##
4120 ## All Parsoid only definition list tests have this difference.
4121 ##
4122 ## See also: https://phabricator.wikimedia.org/T8569
4123 ## and https://lists.wikimedia.org/pipermail/wikitext-l/2011-November/000483.html
4124
4125 !! test
4126 Table / list interaction: indented table with lists in table contents
4127 !! wikitext
4128 :{|
4129 |-
4130 |a
4131
4132 *b
4133 |-
4134 |c
4135
4136 *d
4137 |}
4138 !! html
4139 <dl><dd><table>
4140
4141 <tr>
4142 <td>a
4143 <ul><li>b</li></ul>
4144 </td></tr>
4145 <tr>
4146 <td>c
4147 <ul><li>d</li></ul>
4148 </td></tr></table></dd></dl>
4149
4150 !! end
4151
4152 !!test
4153 Table / list interaction: lists nested in tables nested in indented lists
4154 !! wikitext
4155 :{|
4156 |
4157 :a
4158 :b
4159 |
4160 *c
4161 *d
4162 |}
4163
4164 *e
4165 *f
4166 !! html
4167 <dl><dd><table>
4168 <tr>
4169 <td>
4170 <dl><dd>a</dd>
4171 <dd>b</dd></dl>
4172 </td>
4173 <td>
4174 <ul><li>c</li>
4175 <li>d</li></ul>
4176 </td></tr></table></dd></dl>
4177 <ul><li>e</li>
4178 <li>f</li></ul>
4179
4180 !!end
4181
4182 !! test
4183 Definition Lists: Nesting: Multi-level (Parsoid only)
4184 !! wikitext
4185 ;t1 :d1
4186 ;;t2 ::d2
4187 ;;;t3 :::d3
4188 !! html/parsoid
4189 <dl>
4190 <dt>t1 </dt>
4191 <dd>d1</dd>
4192 <dt>
4193 <dl>
4194 <dt>t2 </dt>
4195 <dd>:d2</dd>
4196 <dt>
4197 <dl>
4198 <dt>t3 </dt>
4199 <dd>::d3</dd>
4200 </dl>
4201 </dt>
4202 </dl>
4203 </dt>
4204 </dl>
4205
4206
4207 !! end
4208
4209
4210 !! test
4211 Definition Lists: Nesting: Test 2
4212 !! wikitext
4213 ;t1
4214 ::d2
4215 !! html+tidy
4216 <dl><dt>t1</dt>
4217 <dd>
4218 <dl><dd>d2</dd></dl></dd></dl>
4219 !! end
4220
4221
4222 !! test
4223 Definition Lists: Nesting: Test 3
4224 !! wikitext
4225 :;t1
4226 ::::d2
4227 !! html+tidy
4228 <dl><dd><dl><dt>t1</dt>
4229 <dd>
4230 <dl><dd><dl><dd>d2</dd></dl></dd></dl></dd></dl></dd></dl>
4231 !! end
4232
4233
4234 !! test
4235 Definition Lists: Nesting: Test 4
4236 !! wikitext
4237 ::;t3
4238 :::d3
4239 !! html
4240 <dl><dd><dl><dd><dl><dt>t3</dt>
4241 <dd>d3</dd></dl></dd></dl></dd></dl>
4242
4243 !! end
4244
4245
4246 ## The Parsoid team believes the following three test exposes a
4247 ## bug in the PHP parser. (Parsoid team thinks the PHP parser is
4248 ## wrong to close the <dl> after the <dt> containing the <ul>.)
4249 ## It also exposes a "misfeature" in tidy, which doesn't like
4250 ## <dl> tags with a single <dt> child; it converts the <dt> into
4251 ## a <dd> in that case. (Parsoid leaves the <dt> alone!)
4252 !! test
4253 Definition Lists: Mixed Lists: Test 1
4254 !! wikitext
4255 :;*foo
4256 ::*bar
4257 :;baz
4258 !! html/php
4259 <dl><dd><dl><dt><ul><li>foo</li>
4260 <li>bar</li></ul></dt></dl>
4261 <dl><dt>baz</dt></dl></dd></dl>
4262
4263 !! html/php+tidy
4264 <dl><dd><dl><dt><ul><li>foo</li>
4265 <li>bar</li></ul></dt></dl>
4266 <dl><dt>baz</dt></dl></dd></dl>
4267 !! html/parsoid
4268 <dl>
4269 <dd><dl>
4270 <dt><ul>
4271 <li>foo
4272 </li>
4273 </ul></dt>
4274 <dd><ul>
4275 <li>bar
4276 </li>
4277 </ul></dd>
4278 <dt>baz</dt>
4279 </dl></dd>
4280 </dl>
4281 !! end
4282
4283 !! test
4284 Definition Lists: Mixed Lists: Test 2
4285 !! wikitext
4286 *:d1
4287 *:d2
4288 !! html
4289 <ul><li><dl><dd>d1</dd>
4290 <dd>d2</dd></dl></li></ul>
4291
4292 !! end
4293
4294
4295 !! test
4296 Definition Lists: Mixed Lists: Test 3
4297 !! wikitext
4298 *:::d1
4299 *:::d2
4300 !! html
4301 <ul><li><dl><dd><dl><dd><dl><dd>d1</dd>
4302 <dd>d2</dd></dl></dd></dl></dd></dl></li></ul>
4303
4304 !! end
4305
4306
4307 !! test
4308 Definition Lists: Mixed Lists: Test 4
4309 !! wikitext
4310 *;d1 :d2
4311 *;d3 :d4
4312 !! html
4313 <ul><li><dl><dt>d1&#160;</dt>
4314 <dd>d2</dd>
4315 <dt>d3&#160;</dt>
4316 <dd>d4</dd></dl></li></ul>
4317
4318 !! end
4319
4320
4321 !! test
4322 Definition Lists: Mixed Lists: Test 5
4323 !! wikitext
4324 *:d1
4325 *::d2
4326 !! html
4327 <ul><li><dl><dd>d1
4328 <dl><dd>d2</dd></dl></dd></dl></li></ul>
4329
4330 !! end
4331
4332
4333 !! test
4334 Definition Lists: Mixed Lists: Test 6
4335 !! wikitext
4336 #*:d1
4337 #*:::d3
4338 !! html
4339 <ol><li><ul><li><dl><dd>d1
4340 <dl><dd><dl><dd>d3</dd></dl></dd></dl></dd></dl></li></ul></li></ol>
4341
4342 !! end
4343
4344
4345 !! test
4346 Definition Lists: Mixed Lists: Test 7
4347 !! wikitext
4348 :*d1
4349 :*d2
4350 !! html
4351 <dl><dd><ul><li>d1</li>
4352 <li>d2</li></ul></dd></dl>
4353
4354 !! end
4355
4356
4357 !! test
4358 Definition Lists: Mixed Lists: Test 8
4359 !! wikitext
4360 :*d1
4361 ::*d2
4362 !! html
4363 <dl><dd><ul><li>d1</li></ul>
4364 <dl><dd><ul><li>d2</li></ul></dd></dl></dd></dl>
4365
4366 !! end
4367
4368
4369 !! test
4370 Definition Lists: Mixed Lists: Test 9
4371 !! wikitext
4372 *;foo :bar
4373 !! html
4374 <ul><li><dl><dt>foo&#160;</dt>
4375 <dd>bar</dd></dl></li></ul>
4376
4377 !! end
4378
4379
4380 !! test
4381 Definition Lists: Mixed Lists: Test 10
4382 !! wikitext
4383 *#;foo :bar
4384 !! html
4385 <ul><li><ol><li><dl><dt>foo&#160;</dt>
4386 <dd>bar</dd></dl></li></ol></li></ul>
4387
4388 !! end
4389
4390 # The Parsoid team disagrees with the PHP parser's seemingly-random
4391 # rules regarding dd/dt on the next few tests. Parsoid is more
4392 # consistent, and recognizes the shared nesting and keeps the
4393 # still-open tags around until the nesting is complete.
4394
4395 # This is a regression test for T175099
4396 !! test
4397 Definition Lists: Mixed Lists: Test 11
4398 !! wikitext
4399 ;a
4400 :*b
4401 !! html/php
4402 <dl><dt>a</dt>
4403 <dd>
4404 <ul><li>b</li></ul></dd></dl>
4405
4406 !! html/parsoid
4407 <dl><dt>a
4408 <dd><ul><li>b</li></ul></dd></dl>
4409 !! end
4410
4411 # FIXME: Maybe get rid of this test?
4412 !! test
4413 Definition Lists: Mixed Lists: Test 12
4414 !! wikitext
4415 *#*#;*;;foo :bar
4416 *#*#;boo :baz
4417 !! html/php
4418 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</dt>
4419 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dd></dl></li></ul></dd></dl>
4420 <dl><dt>boo&#160;</dt>
4421 <dd>baz</dd></dl></li></ol></li></ul></li></ol></li></ul>
4422
4423 !! html/php+tidy
4424 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</dt>
4425 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dt></dl></li></ul></dd></dl></li></ol></li></ul>
4426 <dl><dt>boo&#160;</dt>
4427 <dd>baz</dd></dl></li></ol></li></ul>
4428 !! html/parsoid
4429 <ul>
4430 <li>
4431 <ol>
4432 <li>
4433 <ul>
4434 <li>
4435 <ol>
4436 <li>
4437 <dl>
4438 <dt>
4439 <ul>
4440 <li>
4441 <dl>
4442 <dt>
4443 <dl>
4444 <dt>foo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
4445 <dd data-parsoid='{"stx":"row"}'>bar</dd>
4446 </dl></dt>
4447 </dl></li>
4448 </ul></dt>
4449 <dt>boo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
4450 <dd data-parsoid='{"stx":"row"}'>baz</dd>
4451 </dl></li>
4452 </ol></li>
4453 </ul></li>
4454 </ol></li>
4455 </ul>
4456 !! end
4457
4458 # FIXME: Maybe get rid of this test?
4459 # From whitelist:
4460 # * The test is wrong, there are two colons where there should be :;
4461 # * The PHP parser is wrong to close the <dl> after the <dt> containing the <ul>.
4462 !! test
4463 Definition Lists: Weird Ones: Test 1
4464 !! wikitext
4465 *#;*::;;foo :bar (who uses this?)
4466 !! html/php+tidy
4467 <ul><li><ol><li><dl><dt>foo&#160;</dt>
4468 <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>
4469 !! html/parsoid
4470 <ul>
4471 <li>
4472 <ol>
4473 <li>
4474 <dl>
4475 <dt>
4476 <ul>
4477 <li>
4478 <dl>
4479 <dd>
4480 <dl>
4481 <dd>
4482 <dl>
4483 <dt>
4484 <dl>
4485 <dt>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span></dt>
4486 <dd data-parsoid='{"stx":"row"}'>bar (who uses this?)</dd>
4487 </dl></dt>
4488 </dl></dd>
4489 </dl></dd>
4490 </dl></li>
4491 </ul></dt>
4492 </dl></li>
4493 </ol></li>
4494 </ul>
4495 !! end
4496
4497 !! test
4498 Definition Lists: colons occurring in tags
4499 !! wikitext
4500 ;a:b
4501 ;'''a:b'''
4502 ;<i>a:b</i>
4503 ;<span>a:b</span>
4504 ;<div>a:b</div>
4505 ;<div>a
4506 :b</div>
4507 ;{{echo|a:b}}
4508 ;{{echo|''a:b''}}
4509 ;;;''a:b''
4510 !! html+tidy
4511 <dl><dt>a</dt>
4512 <dd>b</dd>
4513 <dt><b>a:b</b></dt>
4514 <dt><i>a:b</i></dt>
4515 <dt><span>a:b</span></dt>
4516 <dt><div>a:b</div></dt>
4517 <dt><div>a</div></dt>
4518 <dd>b</dd>
4519 <dt>a</dt>
4520 <dd>b</dd>
4521 <dt><i>a:b</i></dt></dl>
4522 <dl><dt><dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4523 !! html/parsoid
4524 <dl><dt>a</dt><dd data-parsoid='{"stx":"row"}'>b</dd>
4525 <dt><b>a:b</b></dt>
4526 <dt><i data-parsoid='{"stx":"html"}'>a:b</i></dt>
4527 <dt><span data-parsoid='{"stx":"html"}'>a:b</span></dt>
4528 <dt><div data-parsoid='{"stx":"html"}'>a:b</div></dt>
4529 <dt><div data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</div></dt>
4530 <dd>b</dd>
4531 <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>
4532 <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>
4533 <dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4534 !! end
4535
4536 # Parsoid's output differs here again because it shares
4537 # nesting between the two lists unlike the PHP parser.
4538 # Unsure which is more desirable.
4539 !! test
4540 Definition Lists: colons and tables 1
4541 !! wikitext
4542 :{|
4543 |x
4544 |}
4545 :{|
4546 |y
4547 |}
4548 !! html/php
4549 <dl><dd><table>
4550 <tr>
4551 <td>x
4552 </td></tr></table></dd></dl>
4553 <dl><dd><table>
4554 <tr>
4555 <td>y
4556 </td></tr></table></dd></dl>
4557
4558 !! html/parsoid
4559 <dl><dd><table>
4560 <tr>
4561 <td>x
4562 </td></tr></table></dd>
4563 <dd><table>
4564 <tr>
4565 <td>y
4566 </td></tr></table></dd></dl>
4567 !! end
4568
4569 # FIXME: Does this need a html/php section?
4570 !! test
4571 Definition Lists: template interaction
4572 !! wikitext
4573 ::{{definition_list}}
4574
4575 :one
4576 ::{{definition_list}}
4577 :::two
4578 :::three
4579 ::four
4580 !! html/parsoid
4581 <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">
4582 </span><dd about="#mwt1">two</dd></dl></dd></dl>
4583
4584 <dl><dd data-parsoid='{}'>one
4585 <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">
4586 </span><dd about="#mwt2">two
4587 <dl><dd>two</dd>
4588 <dd>three</dd></dl></dd>
4589 <dd data-parsoid='{}'>four</dd></dl></dd></dl>
4590 !! end
4591
4592
4593 ###
4594 ### External links
4595 ###
4596 !! test
4597 External links: non-bracketed
4598 !! wikitext
4599 Non-bracketed: http://example.com
4600 !! html
4601 <p>Non-bracketed: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4602 </p>
4603 !! end
4604
4605 # parsoid doesn't explicitly mark autonumbered links, see T55505
4606 !! test
4607 External links: numbered
4608 !! wikitext
4609 Numbered: [http://example.com]
4610 Numbered: [http://example.net]
4611 Numbered: [http://example.com]
4612 !! html/php
4613 <p>Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>
4614 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.net">[2]</a>
4615 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[3]</a>
4616 </p>
4617 !! html/parsoid
4618 <p>Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>
4619 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.net"></a>
4620 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a></p>
4621 !!end
4622
4623 !! test
4624 External links: specified text
4625 !! wikitext
4626 Specified text: [http://example.com link]
4627 !! html
4628 <p>Specified text: <a rel="nofollow" class="external text" href="http://example.com">link</a>
4629 </p>
4630 !!end
4631
4632 !! test
4633 External links: trail
4634 !! wikitext
4635 Linktrails should not work for external links: [http://example.com link]s
4636 !! html
4637 <p>Linktrails should not work for external links: <a rel="nofollow" class="external text" href="http://example.com">link</a>s
4638 </p>
4639 !! end
4640
4641 !! test
4642 External links: dollar sign in URL
4643 !! wikitext
4644 http://example.com/1$2345
4645 !! html
4646 <p><a rel="nofollow" class="external free" href="http://example.com/1$2345">http://example.com/1$2345</a>
4647 </p>
4648 !! end
4649
4650 # parsoid doesn't explicitly mark autonumbered links, see T55505
4651 !! test
4652 External links: dollar sign in URL (autonumber)
4653 !! wikitext
4654 [http://example.com/1$2345]
4655 !! html/php
4656 <p><a rel="nofollow" class="external autonumber" href="http://example.com/1$2345">[1]</a>
4657 </p>
4658 !! html/parsoid
4659 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/1$2345"></a></p>
4660 !!end
4661
4662 !! test
4663 External links: open square bracket forbidden in URL (T6377)
4664 !! options
4665 parsoid=wt2html,wt2wt,html2html
4666 !! wikitext
4667 http://example.com/1[2345
4668 !! html/php
4669 <p><a rel="nofollow" class="external free" href="http://example.com/1">http://example.com/1</a>[2345
4670 </p>
4671 !! html/parsoid
4672 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/1">http://example.com/1</a>[2345</p>
4673 !! end
4674
4675 !! test
4676 External links: open square bracket forbidden in URL (named) (T6377)
4677 !! options
4678 parsoid=wt2html,html2html
4679 !! wikitext
4680 [http://example.com/1[2345]
4681 !! html/php
4682 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4683 </p>
4684 !! html/parsoid
4685 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/1">[2345</a></p>
4686 !!end
4687
4688 # parsoid adds a space before the link name
4689 !! test
4690 External links: open square bracket forbidden in URL (named) (T6377)
4691 Parsoid variant.
4692 !! wikitext
4693 [http://example.com/1 [2345]
4694 !! html
4695 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4696 </p>
4697 !!end
4698
4699 !! test
4700 External links: nowiki in URL link text (T8230)
4701 !! wikitext
4702 [http://example.com/ <nowiki>''example site''</nowiki>]
4703 !! html
4704 <p><a rel="nofollow" class="external text" href="http://example.com/">''example site''</a>
4705 </p>
4706 !! end
4707
4708 !! test
4709 External links: newline forbidden in text (T8230 regression check)
4710 !! wikitext
4711 [http://example.com/ first
4712 second]
4713 !! html
4714 <p>[<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a> first
4715 second]
4716 </p>
4717 !!end
4718
4719 !! test
4720 External links: Pipe char between url and text
4721 !! wikitext
4722 [http://example.com | link]
4723 !! html
4724 <p><a rel="nofollow" class="external text" href="http://example.com">| link</a>
4725 </p>
4726 !!end
4727
4728 !! test
4729 External links: protocol-relative URL in brackets
4730 !! wikitext
4731 [//example.com/ Test]
4732 !! html
4733 <p><a rel="nofollow" class="external text" href="//example.com/">Test</a>
4734 </p>
4735 !! end
4736
4737 # parsoid doesn't explicitly mark autonumbered links, see T55505
4738 !! test
4739 External links: protocol-relative URL in brackets without text
4740 !! wikitext
4741 [//example.com]
4742 !! html/php
4743 <p><a rel="nofollow" class="external autonumber" href="//example.com">[1]</a>
4744 </p>
4745 !! html/parsoid
4746 <p><a rel="mw:ExtLink" class="external autonumber" href="//example.com"></a></p>
4747 !! end
4748
4749 !! test
4750 External links: protocol-relative URL in free text is left alone
4751 !! wikitext
4752 //example.com/Foo
4753 !! html
4754 <p>//example.com/Foo
4755 </p>
4756 !!end
4757
4758 !! test
4759 External links: protocol-relative URL in the middle of a word is left alone (T32269)
4760 !! wikitext
4761 foo//example.com/Foo
4762 !! html
4763 <p>foo//example.com/Foo
4764 </p>
4765 !! end
4766
4767 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
4768 !! test
4769 External links: with no contents
4770 !! options
4771 parsoid=wt2html,wt2wt
4772 !! wikitext
4773 [http://en.wikipedia.org/wiki/Foo]
4774
4775 [[wikipedia:Foo|Bar]]
4776
4777 [[wikipedia:Foo|<span>Bar</span>]]
4778 !! html/php
4779 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo">[1]</a>
4780 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
4781 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo"><span>Bar</span></a>
4782 </p>
4783 !! html/parsoid
4784 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo"></a></p>
4785 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo">Bar</a></p>
4786 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo"><span>Bar</span></a></p>
4787 !! end
4788
4789 !! test
4790 External links: Free with trailing punctuation
4791 !! wikitext
4792 http://example.com,
4793 http://example.com;
4794 http://example.com\
4795 http://example.com.
4796 http://example.com:
4797 http://example.com!
4798 http://example.com?
4799 http://example.com)
4800 http://example.com/url_with_(brackets)
4801 (http://example.com/url_without_brackets)
4802 http://example.com/url_with_entity&amp;
4803 http://example.com/url_with_entity&#x26;
4804 http://example.com/url_with_entity&#038;
4805 http://example.com/url_with_entity&nbsp;
4806 http://example.com/url_with_entity&#xA0;
4807 http://example.com/url_with_entity&#160;
4808 http://example.com/url_with_entity&lt;
4809 http://example.com/url_with_entity&#x3C;
4810 http://example.com/url_with_entity&#60;
4811 !! html/php
4812 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
4813 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>;
4814 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>\
4815 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.
4816 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
4817 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>!
4818 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>?
4819 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
4820 <a rel="nofollow" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
4821 (<a rel="nofollow" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
4822 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4823 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4824 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4825 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
4826 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#xa0;
4827 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
4828 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&lt;
4829 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#x3c;
4830 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#60;
4831 </p>
4832 !! html/parsoid
4833 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>,
4834 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>;
4835 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>\
4836 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>.
4837 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>:
4838 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>!
4839 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>?
4840 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>)
4841 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
4842 (<a rel="mw:ExtLink" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
4843 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4844 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4845 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4846 <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>
4847 <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>
4848 <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>
4849 <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>
4850 <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>
4851 <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>
4852 !! end
4853
4854 !! test
4855 External links: tricky Parsoid html2html case
4856 !! options
4857 parsoid=wt2html,wt2wt,html2html
4858 !! wikitext
4859 http://example.com/url_with_entity&amp;amp;
4860 !! html/php
4861 <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>;
4862 </p>
4863 !! html/parsoid
4864 <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>
4865 !! end
4866
4867 !! test
4868 External links: Free with trailing quotes (T113666)
4869 !! wikitext
4870 '''News:''' Stuff here
4871
4872 news:'a'b''c''d e
4873 !! html/php
4874 <p><b>News:</b> Stuff here
4875 </p><p><a rel="nofollow" class="external free" href="news:&#39;a&#39;b">news:'a'b</a><i>c</i>d e
4876 </p>
4877 !! html/parsoid
4878 <p><b>News:</b> Stuff here</p>
4879 <p><a rel="mw:ExtLink" class="external free" href="news:'a'b">news:'a'b</a><i>c</i>d e</p>
4880 !! end
4881
4882 !! test
4883 External links: with entity
4884 !! wikitext
4885 [http://&#x20;www.librarieswithoutborders.org Libraries without borders]
4886 !! html/php
4887 <p><a rel="nofollow" class="external text" href="http://+www.librarieswithoutborders.org">Libraries without borders</a>
4888 </p>
4889 !! html/parsoid
4890 <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>
4891 !! end
4892
4893 !! test
4894 External links: Lone protocols are never linked (T105697)
4895 !! wikitext
4896 http://
4897 http://;
4898 (http://)
4899 bitcoin:
4900 bitcoin:;
4901 (bitcoin:)
4902 !! html
4903 <p>http://
4904 http://;
4905 (http://)
4906 bitcoin:
4907 bitcoin:;
4908 (bitcoin:)
4909 </p>
4910 !! end
4911
4912 !! test
4913 External links: No preceding word characters allowed (T67278)
4914 !! wikitext
4915 NOPEhttp://example.com
4916 N0http://example.com
4917 ok:http://example.com
4918 ok-http://example.com
4919 !! html
4920 <p>NOPEhttp://example.com
4921 N0http://example.com
4922 ok:<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4923 ok-<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4924 </p>
4925 !! end
4926
4927 !! test
4928 External links: nofollow domain exception
4929 !! wikitext
4930 A [https://no-nofollow.org/foobar link], and another [https://example.org link].
4931 !! html
4932 <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>.
4933 </p>
4934 !!end
4935
4936 !! test
4937 External image
4938 !! wikitext
4939 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
4940 !! html
4941 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
4942 </p>
4943 !! end
4944
4945 !! test
4946 External image from https
4947 !! wikitext
4948 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
4949 !! html
4950 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
4951 </p>
4952 !! end
4953
4954 !! test
4955 External image (when not allowed)
4956 !! options
4957 wgAllowExternalImages=0
4958 !! wikitext
4959 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
4960 !! html
4961 <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>
4962 </p>
4963 !! end
4964
4965 !! test
4966 Link to non-http image, no img tag
4967 !! wikitext
4968 Link to non-http image, no img tag: ftp://example.com/test.jpg
4969 !! html
4970 <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>
4971 </p>
4972 !! end
4973
4974 !! test
4975 External links: terminating separator
4976 !! wikitext
4977 Terminating separator: http://example.com/thing,
4978 !! html
4979 <p>Terminating separator: <a rel="nofollow" class="external free" href="http://example.com/thing">http://example.com/thing</a>,
4980 </p>
4981 !! end
4982
4983 !! test
4984 External links: intervening separator
4985 !! wikitext
4986 Intervening separator: http://example.com/1,2,3
4987 !! html
4988 <p>Intervening separator: <a rel="nofollow" class="external free" href="http://example.com/1,2,3">http://example.com/1,2,3</a>
4989 </p>
4990 !! end
4991
4992 !! test
4993 External links: old bug with URL in query
4994 !! wikitext
4995 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
4996 !! html
4997 <p>Old bug with URL in query: <a rel="nofollow" class="external text" href="http://example.com/thing?url=http://example.com">link</a>
4998 </p>
4999 !! end
5000
5001 !! test
5002 External links: old URL-in-URL bug, mixed protocols
5003 !! wikitext
5004 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
5005 !! html
5006 <p>And again with mixed protocols: <a rel="nofollow" class="external text" href="ftp://example.com?url=http://example.com">link</a>
5007 </p>
5008 !!end
5009
5010 # Since Parsoid is starting to emit canonical wikitext for links,
5011 # [http://example.com http://example.com] will not RT back to that
5012 # form anymore.
5013 !! test
5014 External links: URL in text
5015 !! options
5016 parsoid=wt2html
5017 !! wikitext
5018 URL in text: [http://example.com http://example.com]
5019 !! html/php
5020 <p>URL in text: <a rel="nofollow" class="external text" href="http://example.com">http://example.com</a>
5021 </p>
5022 !! html/parsoid
5023 <p>URL in text: <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a></p>
5024 !! end
5025
5026 !! test
5027 External links: Clickable images
5028 !! wikitext
5029 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
5030 !! html/php
5031 <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>
5032 </p>
5033 !! html/parsoid
5034 <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>
5035 !! end
5036
5037 !! test
5038 External links: raw ampersand
5039 !! wikitext
5040 Old &amp; use: http://x&y
5041 !! html
5042 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5043 </p>
5044 !! end
5045
5046 !! test
5047 External links: encoded ampersand
5048 !! wikitext
5049 Old &amp; use: http://x&amp;y
5050 !! html/php
5051 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5052 </p>
5053 !! html/parsoid
5054 <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>
5055 !! end
5056
5057 !! test
5058 External links: encoded equals (T8102)
5059 !! wikitext
5060 http://example.com/?foo&#61;bar
5061 !! html/php
5062 <p><a rel="nofollow" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a>
5063 </p>
5064 !! html/parsoid
5065 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a></p>
5066 !! end
5067
5068 ##
5069 ## Note that parsoid doesn't explicit mark autonumbered links, nor
5070 ## does it number them. As discussed in T55505, we can identify
5071 ## autonumbered links via CSS.
5072 ##
5073
5074 !! test
5075 External links: [raw ampersand]
5076 !! wikitext
5077 Old &amp; use: [http://x&y]
5078 !! html/php
5079 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5080 </p>
5081 !! html/parsoid
5082 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&amp;y"></a></p>
5083 !! end
5084
5085 # note that parsoid html is identical to [raw ampersand] case; so html2wt
5086 # mode will return the [raw ampersand] wikitext
5087 !! test
5088 External links: [encoded ampersand]
5089 !! options
5090 parsoid=wt2html,wt2wt,html2html
5091 !! wikitext
5092 Old &amp; use: [http://x&amp;y]
5093 !! html/php
5094 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5095 </p>
5096 !! html/parsoid
5097 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&amp;y"></a></p>
5098 !! end
5099
5100 !! test
5101 External links: [raw equals]
5102 !! wikitext
5103 [http://example.com/?foo=bar]
5104 !! html/php
5105 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5106 </p>
5107 !! html/parsoid
5108 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/?foo=bar"></a></p>
5109 !! end
5110
5111 # note that parsoid html is identical to [raw equals] case; so html2wt
5112 # mode will return the [raw equals] wikitext
5113 !! test
5114 External links: [encoded equals] (T8102)
5115 !! options
5116 parsoid=wt2html,wt2wt,html2html
5117 !! wikitext
5118 [http://example.com/?foo&#61;bar]
5119 !! html/php
5120 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5121 </p>
5122 !! html/parsoid
5123 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/?foo=bar"></a></p>
5124 !! end
5125
5126 # xxx parsoid strips the IDN character, so the round-trip tests will
5127 # obviously fail and are disabled. --cscott
5128 !! test
5129 External links: [IDN ignored character reference in hostname; strip it right off]
5130 !! options
5131 parsoid=wt2html,wt2wt,html2html
5132 !! wikitext
5133 [http://e&zwnj;xample.com/]
5134 !! html/php
5135 <p><a rel="nofollow" class="external autonumber" href="http://example.com/">[1]</a>
5136 </p>
5137 !! html/parsoid
5138 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/"></a></p>
5139 !! end
5140
5141 # FIXME: This test (the IDN characters in the text of a link) is an inconsistency.
5142 # Where an external link could easily circumvent the sanitization of the text of
5143 # a link like this (where an IDN-ignore character is in the URL somewhere), this
5144 # test demands a higher standard. That's a bit strange.
5145 #
5146 # Example:
5147 #
5148 # http://e‌xample.com -> [http://example.com|http://example.com]
5149 # [http://example.com|http://e‌xample.com] -> [http://example.com|http://e‌xample.com]
5150 #
5151 # The first example is sanitized, but the second is not. Any security benefits
5152 # from this production are trivial to circumvent. Either remove this test and
5153 # let the parser(s) do their thing unaccosted, or fix the inconsistency and change
5154 # the test accordingly.
5155 #
5156 # All our love,
5157 # The Parsoid team.
5158 # xxx parsoid strips the IDN character, so the round-trip tests will
5159 # obviously fail and are disabled. --cscott
5160 !! test
5161 External links: IDN ignored character reference in hostname; strip it right off
5162 !! options
5163 parsoid=wt2html,html2html
5164 !! wikitext
5165 http://e&zwnj;xample.com/
5166 !! html/php
5167 <p><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>
5168 </p>
5169 !! html/parsoid
5170 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/">http://example.com/</a></p>
5171 !! end
5172
5173 !! test
5174 External links: www.jpeg.org (T2554)
5175 !! wikitext
5176 http://www.jpeg.org
5177 !! html
5178 <p><a rel="nofollow" class="external free" href="http://www.jpeg.org">http://www.jpeg.org</a>
5179 </p>
5180 !! end
5181
5182 # parsoid doesn't explicitly mark autonumbered links, see T55505
5183 !! test
5184 External links: URL within URL (T2002)
5185 !! wikitext
5186 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
5187 !! html/php
5188 <p><a rel="nofollow" class="external autonumber" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp">[1]</a>
5189 </p>
5190 !! html/parsoid
5191 <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>
5192 !! end
5193
5194 !! test
5195 T2361: URL inside bracketed URL
5196 !! wikitext
5197 [http://www.example.com/foo http://www.example.com/bar]
5198 !! html
5199 <p><a rel="nofollow" class="external text" href="http://www.example.com/foo">http://www.example.com/bar</a>
5200 </p>
5201 !! end
5202
5203 !! test
5204 T2361: URL within URL, not bracketed
5205 !! wikitext
5206 http://www.example.com/foo?=http://www.example.com/bar
5207 !! html
5208 <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>
5209 </p>
5210 !! end
5211
5212 !! test
5213 T2289: ">"-token in URL-tail
5214 !! wikitext
5215 http://www.example.com/<hello>
5216 !! html
5217 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>&lt;hello&gt;
5218 </p>
5219 !!end
5220
5221 !! test
5222 T2289: literal ">"-token in URL-tail
5223 !! wikitext
5224 http://www.example.com/<b>html</b>
5225 !! html/php
5226 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a><b>html</b>
5227 </p>
5228 !! html/parsoid
5229 <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>
5230 !! end
5231
5232 !! test
5233 T2289: ">"-token in bracketed URL
5234 !! wikitext
5235 [http://www.example.com/<hello> stuff]
5236 !! html
5237 <p><a rel="nofollow" class="external text" href="http://www.example.com/">&lt;hello&gt; stuff</a>
5238 </p>
5239 !!end
5240
5241 !! test
5242 T2289: literal ">"-token in bracketed URL
5243 !! wikitext
5244 [http://www.example.com/<b>html</b> stuff]
5245 !! html
5246 <p><a rel="nofollow" class="external text" href="http://www.example.com/"><b>html</b> stuff</a>
5247 </p>
5248 !!end
5249
5250 !! test
5251 T2289: literal double quote at end of URL
5252 !! wikitext
5253 http://www.example.com/"hello"
5254 !! html
5255 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>"hello"
5256 </p>
5257 !!end
5258
5259 !! test
5260 T2289: literal double quote in bracketed URL
5261 !! wikitext
5262 [http://www.example.com/"hello" stuff]
5263 !! html
5264 <p><a rel="nofollow" class="external text" href="http://www.example.com/">"hello" stuff</a>
5265 </p>
5266 !!end
5267
5268 !! test
5269 External links: multiple legal whitespace is fine, Magnus. Don't break it please. (T7081)
5270 !! wikitext
5271 [http://www.example.com test]
5272 !! html
5273 <p><a rel="nofollow" class="external text" href="http://www.example.com">test</a>
5274 </p>
5275 !! end
5276
5277 !! test
5278 External links: link text with spaces
5279 !! wikitext
5280 [http://www.example.com a b c]
5281 [http://www.example.com ''a'' ''b'']
5282 !! html
5283 <p><a rel="nofollow" class="external text" href="http://www.example.com">a b c</a>
5284 <a rel="nofollow" class="external text" href="http://www.example.com"><i>a</i> <i>b</i></a>
5285 </p>
5286 !! end
5287
5288 # Note edge case difference between PHP and Parsoid here.
5289 !! test
5290 External links: wiki links within external link (T5695)
5291 !! options
5292 parsoid=wt2html,html2html
5293 !! wikitext
5294 [http://example.com [[wikilink]] embedded in ext link]
5295
5296 [http://example.com test [[wikilink]] embedded in ext link]
5297 !! html/php
5298 <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>
5299 </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>
5300 </p>
5301 !! html/parsoid
5302 <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>
5303 <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>
5304 !! end
5305
5306 !! test
5307 T2787: Links with one slash after the url protocol are invalid
5308 !! wikitext
5309 http:/example.com
5310
5311 [http:/example.com title]
5312 !! html
5313 <p>http:/example.com
5314 </p><p>[http:/example.com title]
5315 </p>
5316 !! end
5317
5318 !! test
5319 Bracketed external links with template-generated invalid target
5320 !! wikitext
5321 [{{echo|http:/example.com}} title]
5322 !! html
5323 <p>[http:/example.com title]
5324 </p>
5325 !! end
5326
5327 # wt2html only because Parsoid would want to add <nowiki>s coming from html
5328 !! test
5329 Broken wikilinks (but not external links) prevent templates from closing
5330 !! options
5331 parsoid=wt2html
5332 !! wikitext
5333 [http://example.com x
5334
5335 {{echo|[http://example.com x}}
5336
5337 [[Foo
5338
5339 {{echo|[[Foo}}
5340 !! html/php
5341 <p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5342 </p><p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5343 </p><p>[[Foo
5344 </p><p>{{echo|[[Foo}}
5345 </p>
5346 !! html/parsoid
5347 <p>[<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a> x</p>
5348 <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>
5349 <p>[[Foo</p>
5350 <p>{{echo|[[Foo}}</p>
5351 !! end
5352
5353 !! test
5354 Wikilinks with embedded newlines are not broken
5355 !! wikitext
5356 {{echo|[[ Foo
5357 B
5358 C]]}}
5359 !! html/php
5360 <p>[[ Foo
5361 B
5362 C]]
5363 </p>
5364 !! html/parsoid
5365 <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>
5366 !! end
5367
5368 !! test
5369 Broken templates
5370 !! options
5371 parsoid=wt2html
5372 !! wikitext
5373 {{echo|[[Foo|}}]]
5374
5375 [[Foo|{{echo|]]}}
5376 !! html/php
5377 <p>{{echo|<a href="/wiki/Foo" title="Foo">}}</a>
5378 </p><p>[[Foo|]]
5379 </p>
5380 !! html/parsoid
5381 <p>{{echo|<a rel="mw:WikiLink" href="./Foo" title="Foo">}}</a></p>
5382 <p>[[Foo|<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"]]"}},"i":0}}]}'>]]</span></p>
5383 !! end
5384
5385 !! test
5386 T4702: Mismatched <i>, <b> and <a> tags are invalid
5387 !! wikitext
5388 ''[http://example.com text'']
5389 [http://example.com '''text]'''
5390 ''Something [http://example.com in italic'']
5391 ''Something [http://example.com mixed''''', even bold]'''
5392 '''''Now [http://example.com both''''']
5393 !! html
5394 <p><a rel="nofollow" class="external text" href="http://example.com"><i>text</i></a>
5395 <a rel="nofollow" class="external text" href="http://example.com"><b>text</b></a>
5396 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>in italic</i></a>
5397 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>mixed</i><b>, even bold</b></a>
5398 <i><b>Now </b></i><a rel="nofollow" class="external text" href="http://example.com"><i><b>both</b></i></a>
5399 </p>
5400 !! end
5401
5402
5403 !! test
5404 T6781: %26 in URL
5405 !! wikitext
5406 http://www.example.com/?title=AT%26T
5407 !! html/php
5408 <p><a rel="nofollow" class="external free" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a>
5409 </p>
5410 !! html/parsoid
5411 <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>
5412 !! end
5413
5414 # According to https://www.w3.org/TR/2011/WD-html5-20110525/Overview.html#parsing-urls a plain
5415 # % is actually legal in HTML5. Any change in output would need testing though.
5416 !! test
5417 T6781, T7267: %25 in URL
5418 !! wikitext
5419 http://www.example.com/?title=100%25_Bran
5420 !! html/php
5421 <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>
5422 </p>
5423 !! html/parsoid
5424 <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>
5425 !! end
5426
5427 !! test
5428 T6781, T7267: %28, %29 in URL
5429 !! wikitext
5430 http://www.example.com/?title=Ben-Hur_%281959_film%29
5431 !! html/php
5432 <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>
5433 </p>
5434 !! html/parsoid
5435 <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>
5436 !! end
5437
5438
5439 !! test
5440 T6781: %26 in autonumber URL
5441 !! wikitext
5442 [http://www.example.com/?title=AT%26T]
5443 !! html/php
5444 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=AT%26T">[1]</a>
5445 </p>
5446 !! html/parsoid
5447 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=AT%26T"></a></p>
5448 !! end
5449
5450 !! test
5451 T6781, T7267: %26 in autonumber URL
5452 !! wikitext
5453 [http://www.example.com/?title=100%25_Bran]
5454 !! html/php
5455 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=100%25_Bran">[1]</a>
5456 </p>
5457 !! html/parsoid
5458 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=100%25_Bran"></a></p>
5459 !! end
5460
5461 !! test
5462 T6781, T7267: %28, %29 in autonumber URL
5463 !! wikitext
5464 [http://www.example.com/?title=Ben-Hur_%281959_film%29]
5465 !! html/php
5466 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">[1]</a>
5467 </p>
5468 !! html/parsoid
5469 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29"></a></p>
5470 !! end
5471
5472
5473 !! test
5474 T6781: %26 in bracketed URL
5475 !! wikitext
5476 [http://www.example.com/?title=AT%26T link]
5477 !! html/php
5478 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=AT%26T">link</a>
5479 </p>
5480 !! html/parsoid
5481 <p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=AT%26T">link</a></p>
5482 !! end
5483
5484 !! test
5485 T6781, T7267: %25 in bracketed URL
5486 !! wikitext
5487 [http://www.example.com/?title=100%25_Bran link]
5488 !! html
5489 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=100%25_Bran">link</a>
5490 </p>
5491 !! end
5492
5493 !! test
5494 T6781, T7267: %28, %29 in bracketed URL
5495 !! wikitext
5496 [http://www.example.com/?title=Ben-Hur_%281959_film%29 link]
5497 !! html/php
5498 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a>
5499 </p>
5500 !! html/parsoid
5501 <p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a></p>
5502 !! end
5503
5504 !! test
5505 External link containing a period in the anchor. (T65947)
5506 !! wikitext
5507 [//foo.org/bar#baz. bang]
5508
5509 [//foo.org/bar. bang]
5510 !! html/php
5511 <p><a rel="nofollow" class="external text" href="//foo.org/bar#baz.">bang</a>
5512 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar.">bang</a>
5513 </p>
5514 !! html/parsoid
5515 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar#baz.">bang</a></p>
5516 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar.">bang</a></p>
5517 !! end
5518
5519 !! test
5520 External link containing a single quote. (T65947)
5521 !! wikitext
5522 [//foo.org/bar'baz]
5523
5524 [//foo.org/bar'baz bang]
5525 !! html/php
5526 <p><a rel="nofollow" class="external autonumber" href="//foo.org/bar&#39;baz">[1]</a>
5527 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar&#39;baz">bang</a>
5528 </p>
5529 !! html/parsoid
5530 <p><a rel="mw:ExtLink" class="external autonumber" href="//foo.org/bar'baz"></a></p>
5531 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar'baz">bang</a></p>
5532 !! end
5533
5534 !! test
5535 External link containing double-single-quotes in text '' (T6598 sanity check)
5536 !! wikitext
5537 Some [http://example.com/ pretty ''italics'' and stuff]!
5538 !! html
5539 <p>Some <a rel="nofollow" class="external text" href="http://example.com/">pretty <i>italics</i> and stuff</a>!
5540 </p>
5541 !! end
5542
5543 !! test
5544 External link containing double-single-quotes in text embedded in italics (T6598 sanity check)
5545 !! wikitext
5546 ''Some [http://example.com/ pretty ''italics'' and stuff]!''
5547 !! html
5548 <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>
5549 </p>
5550 !! end
5551
5552 # Don't add the html/php section since the output is broken and there isn't any reason to spec it
5553 !! test
5554 External link containing double-single-quotes with no space separating the url from text in italics
5555 !! wikitext
5556 [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]].]
5557 !! html/php+tidy
5558 <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>.
5559 </p>
5560 !! html/parsoid
5561 <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>
5562 !! end
5563
5564 !! test
5565 External link with comments in link text
5566 !! wikitext
5567 [http://www.google.com Google <!-- comment -->]
5568 !! html/php
5569 <p><a rel="nofollow" class="external text" href="http://www.google.com">Google </a>
5570 </p>
5571 !! html/parsoid
5572 <p><a rel="mw:ExtLink" class="external text" href="http://www.google.com">Google <!-- comment --></a></p>
5573 !! end
5574
5575 !! test
5576 External link to bare IPv4 address
5577 !! wikitext
5578 [http://192.168.0.1 Link]
5579 !! html/php
5580 <p><a rel="nofollow" class="external text" href="http://192.168.0.1">Link</a>
5581 </p>
5582 !! html/parsoid
5583 <p><a rel="mw:ExtLink" class="external text" href="http://192.168.0.1">Link</a></p>
5584 !! end
5585
5586 !! test
5587 URL-encoding in URL functions (single parameter)
5588 !! wikitext
5589 {{localurl:Some page|amp=&}}
5590 !! html
5591 <p>/index.php?title=Some_page&amp;amp=&amp;
5592 </p>
5593 !! end
5594
5595 !! test
5596 URL-encoding in URL functions (multiple parameters)
5597 !! wikitext
5598 {{localurl:Some page|q=?&amp=&}}
5599 !! html
5600 <p>/index.php?title=Some_page&amp;q=?&amp;amp=&amp;
5601 </p>
5602 !! end
5603
5604 !! test
5605 Brackets in urls
5606 !! wikitext
5607 http://example.com/index.php?foozoid%5B%5D=bar
5608
5609 http://example.com/index.php?foozoid&#x5B;&#x5D;=bar
5610 !! html/php
5611 <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>
5612 </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>
5613 </p>
5614 !! html/parsoid
5615 <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>
5616
5617 <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>
5618 !! end
5619
5620 !! test
5621 IPv6 urls, autolink format (T23261)
5622 !! wikitext
5623 http://[2404:130:0:1000::187:2]/index.php
5624
5625 Examples from RFC 2373, section 2.2:
5626
5627 *http://[1080::8:800:200C:417A]/unicast
5628 *http://[FF01::101]/multicast
5629 *http://[::1]/loopback
5630 *http://[::]/unspecified
5631 *http://[::13.1.68.3]/ipv4compat
5632 *http://[::FFFF:129.144.52.38]/ipv4compat
5633
5634 Examples from RFC 2732, section 2:
5635
5636 *http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
5637 *http://[1080:0:0:0:8:800:200C:417A]/index.html
5638 *http://[3ffe:2a00:100:7031::1]
5639 *http://[1080::8:800:200C:417A]/foo
5640 *http://[::192.9.5.5]/ipng
5641 *http://[::FFFF:129.144.52.38]:80/index.html
5642 *http://[2010:836B:4179::836B:4179]
5643 !! html/php
5644 <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>
5645 </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:
5646 </p>
5647 <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>
5648 <li><a rel="nofollow" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5649 <li><a rel="nofollow" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5650 <li><a rel="nofollow" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5651 <li><a rel="nofollow" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5652 <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>
5653 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5654 </p>
5655 <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>
5656 <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>
5657 <li><a rel="nofollow" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5658 <li><a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
5659 <li><a rel="nofollow" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5660 <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>
5661 <li><a rel="nofollow" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5662
5663 !! html/parsoid
5664 <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>
5665
5666 <p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink" class="external text">RFC 2373</a>, section 2.2:</p>
5667 <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>
5668 <li><a rel="mw:ExtLink" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5669 <li><a rel="mw:ExtLink" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5670 <li><a rel="mw:ExtLink" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5671 <li><a rel="mw:ExtLink" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5672 <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>
5673
5674 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external text">RFC 2732</a>, section 2:</p>
5675 <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>
5676 <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>
5677 <li><a rel="mw:ExtLink" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5678 <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>
5679 <li><a rel="mw:ExtLink" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5680 <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>
5681 <li><a rel="mw:ExtLink" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5682 !! end
5683
5684 !! test
5685 IPv6 urls, bracketed format (T23261)
5686 !! wikitext
5687 [http://[2404:130:0:1000::187:2]/index.php test]
5688
5689 Examples from RFC 2373, section 2.2:
5690
5691 *[http://[1080::8:800:200C:417A] unicast]
5692 *[http://[FF01::101] multicast]
5693 *[http://[::1]/ loopback]
5694 *[http://[::] unspecified]
5695 *[http://[::13.1.68.3] ipv4compat]
5696 *[http://[::FFFF:129.144.52.38] ipv4compat]
5697
5698 Examples from RFC 2732, section 2:
5699
5700 *[http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html 1]
5701 *[http://[1080:0:0:0:8:800:200C:417A]/index.html 2]
5702 *[http://[3ffe:2a00:100:7031::1] 3]
5703 *[http://[1080::8:800:200C:417A]/foo 4]
5704 *[http://[::192.9.5.5]/ipng 5]
5705 *[http://[::FFFF:129.144.52.38]:80/index.html 6]
5706 *[http://[2010:836B:4179::836B:4179] 7]
5707 !! html/php
5708 <p><a rel="nofollow" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a>
5709 </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:
5710 </p>
5711 <ul><li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5712 <li><a rel="nofollow" class="external text" href="http://[FF01::101]">multicast</a></li>
5713 <li><a rel="nofollow" class="external text" href="http://[::1]/">loopback</a></li>
5714 <li><a rel="nofollow" class="external text" href="http://[::]">unspecified</a></li>
5715 <li><a rel="nofollow" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5716 <li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5717 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5718 </p>
5719 <ul><li><a rel="nofollow" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
5720 <li><a rel="nofollow" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5721 <li><a rel="nofollow" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5722 <li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5723 <li><a rel="nofollow" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
5724 <li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5725 <li><a rel="nofollow" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5726
5727 !! html/parsoid
5728 <p><a rel="mw:ExtLink" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a></p>
5729
5730 <p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink" class="external text">RFC 2373</a>, section 2.2:</p>
5731 <ul><li><a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5732 <li><a rel="mw:ExtLink" class="external text" href="http://[FF01::101]">multicast</a></li>
5733 <li><a rel="mw:ExtLink" class="external text" href="http://[::1]/">loopback</a></li>
5734 <li><a rel="mw:ExtLink" class="external text" href="http://[::]">unspecified</a></li>
5735 <li><a rel="mw:ExtLink" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5736 <li><a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5737
5738 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external text">RFC 2732</a>, section 2:</p>
5739 <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>
5740 <li><a rel="mw:ExtLink" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5741 <li><a rel="mw:ExtLink" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5742 <li><a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5743 <li><a rel="mw:ExtLink" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
5744 <li><a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5745 <li><a rel="mw:ExtLink" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5746 !! end
5747
5748 !! test
5749 Non-extlinks in brackets
5750 !! wikitext
5751 [foo]
5752 [foo bar]
5753 [foo ''bar'']
5754 [fool's] errand
5755 [fool's errand]
5756 [{{echo|foo}}]
5757 [{{echo|foo}} bar]
5758 [{{echo|foo}} ''bar'']
5759 [{{echo|foo}}l's] errand
5760 [{{echo|foo}}l's errand]
5761 [url={{echo|foo}}]
5762 [url=http://example.com]
5763 [http:// bare protocols don't count]
5764 !! html/php
5765 <p>[foo]
5766 [foo bar]
5767 [foo <i>bar</i>]
5768 [fool's] errand
5769 [fool's errand]
5770 [foo]
5771 [foo bar]
5772 [foo <i>bar</i>]
5773 [fool's] errand
5774 [fool's errand]
5775 [url=foo]
5776 [url=<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>]
5777 [http:// bare protocols don't count]
5778 </p>
5779 !! html/parsoid
5780 <p>[foo]
5781 [foo bar]
5782 [foo <i>bar</i>]
5783 [fool's] errand
5784 [fool's errand]
5785 [<span about="#mwt19" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>]
5786 [<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]
5787 [<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>]
5788 [<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
5789 [<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]
5790 [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>]
5791 [url=<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>]
5792 [http:// bare protocols don't count]</p>
5793 !! end
5794
5795 !! test
5796 Percent encoding in external links
5797 !! wikitext
5798 [https://github.com/search?l=&q=ResourceLoader+%40wikimedia Search]
5799 !! html/php
5800 <p><a rel="nofollow" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a>
5801 </p>
5802 !! html/parsoid
5803 <p><a rel="mw:ExtLink" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a></p>
5804 !! end
5805
5806 !! test
5807 Use url link syntax for links where the content is equal the link target
5808 !! wikitext
5809 http://example.com
5810 !! html/php
5811 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5812 </p>
5813 !! html/parsoid
5814 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a></p>
5815 !! end
5816
5817 !! test
5818 Parenthesis in external links, especially URL links
5819 !! wikitext
5820 http://example.com)
5821
5822 http://example.com/test)
5823
5824 http://example.com/(test)
5825
5826 http://example.com/((test)
5827
5828 (http://example.com/(test))
5829
5830 (http://example.com/(test)))))
5831
5832 http://example.com/a)b
5833
5834 [http://example.com) foo]
5835 !! html/php
5836 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
5837 </p><p><a rel="nofollow" class="external free" href="http://example.com/test">http://example.com/test</a>)
5838 </p><p><a rel="nofollow" class="external free" href="http://example.com/(test)">http://example.com/(test)</a>
5839 </p><p><a rel="nofollow" class="external free" href="http://example.com/((test)">http://example.com/((test)</a>
5840 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test))">http://example.com/(test))</a>
5841 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a>
5842 </p><p><a rel="nofollow" class="external free" href="http://example.com/a)b">http://example.com/a)b</a>
5843 </p><p><a rel="nofollow" class="external text" href="http://example.com)">foo</a>
5844 </p>
5845 !! html/parsoid
5846 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>)</p>
5847 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/test">http://example.com/test</a>)</p>
5848 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/(test)">http://example.com/(test)</a></p>
5849 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/((test)">http://example.com/((test)</a></p>
5850 <p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test))">http://example.com/(test))</a></p>
5851 <p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a></p>
5852 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/a)b">http://example.com/a)b</a></p>
5853 <p><a rel="mw:ExtLink" class="external text" href="http://example.com)">foo</a></p>
5854 !! end
5855
5856 !! test
5857 Parenthesis in external links, w/ transclusion or comment
5858 !! wikitext
5859 (http://example.com/{{echo|hi}})
5860
5861 (http://example.com<!-- hi -->)
5862 !! html/php
5863 <p>(<a rel="nofollow" class="external free" href="http://example.com/hi">http://example.com/hi</a>)
5864 </p><p>(<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
5865 </p>
5866 !! html/parsoid
5867 <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>
5868
5869 <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>
5870 !! end
5871
5872 !! test
5873 Serialize <a> tags with invalid link targets as plain text
5874 !! options
5875 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
5876 !! html/parsoid
5877 <a rel="mw:WikiLink" href="[[foo]]">text</a>
5878 <a rel="mw:WikiLink" href="[[foo]]">*text</a>
5879 <a rel="mw:WikiLink" href="[[foo]]">[[foo]]</a>
5880 <a rel="mw:WikiLink" href="[[foo]]">*a [[foo]]</a>
5881 !! wikitext
5882 text
5883 <nowiki>*</nowiki>text
5884 <nowiki>[[foo]]</nowiki>
5885 <nowiki>*</nowiki>a <nowiki>[[foo]]</nowiki>
5886 !! end
5887
5888 !! test
5889 mw:ExtLink -vs- mw:WikiLink (T94723)
5890 !! options
5891 parsoid=html2wt
5892 !! html/parsoid
5893 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"piped","a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>Bar</a>
5894 <a rel="mw:WikiLink" href="./Foo" title="Foo">Bar</a>
5895 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
5896 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
5897 <p>
5898 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
5899 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
5900 </p>
5901 !! wikitext
5902 [[Foo|Bar]]
5903 [[Foo|Bar]]
5904 [[:en:Foo|Bar]]
5905 [[:en:Foo|Bar]]
5906
5907 [[:en:European_Robin|European Robin]]
5908 [[:en:European_Robin|European Robin]]
5909 !! end
5910
5911 !! test
5912 mw:ExtLink linking to a interwiki URL can be round-tripped losslessly (T94723)
5913 !! options
5914 parsoid=wt2wt
5915 !! wikitext
5916 [http://en.wikipedia.org/wiki/European_Robin European Robin]
5917 !! html/parsoid
5918 THIS SECTION IS NOT USED (but Parsoid won't run the test without it)
5919 !! end
5920
5921
5922 ###
5923 ### Quotes
5924 ###
5925
5926 !! test
5927 Quotes
5928 !! wikitext
5929 Normal text. '''Bold text.''' Normal text. ''Italic text.''
5930
5931 Normal text. '''''Bold italic text.''''' Normal text.
5932 !! html
5933 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
5934 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
5935 </p>
5936 !! end
5937
5938
5939 # Parsoid inserts an empty bold tag pair at the end of the line, that the PHP
5940 # parser strips. The wikitext contains just the first half of the bold
5941 # quote pair.
5942 !! test
5943 Unclosed and unmatched quotes
5944 !! wikitext
5945 '''''Bold italic text '''with bold deactivated''' in between.'''''
5946
5947 '''''Bold italic text ''with italic deactivated'' in between.'''''
5948
5949 '''Bold text..
5950
5951 ..spanning two paragraphs (should not work).'''
5952
5953 '''Bold tag left open
5954
5955 ''Italic tag left open
5956
5957 Normal text.
5958
5959 <!-- Unmatching number of opening, closing tags: -->
5960 '''This year''''s election ''should'' beat '''last year''''s.
5961
5962 ''Tom'''s car is bigger than ''Susan'''s.
5963
5964 Plain ''italic'''s plain
5965 !! html/php
5966 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
5967 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
5968 </p><p><b>Bold text..</b>
5969 </p><p>..spanning two paragraphs (should not work).
5970 </p><p><b>Bold tag left open</b>
5971 </p><p><i>Italic tag left open</i>
5972 </p><p>Normal text.
5973 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
5974 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
5975 </p><p>Plain <i>italic'</i>s plain
5976 </p>
5977 !! html/parsoid
5978 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
5979 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
5980 </p><p><b>Bold text..</b>
5981 </p><p>..spanning two paragraphs (should not work).<b></b>
5982 </p><p><b>Bold tag left open</b>
5983 </p><p><i>Italic tag left open</i>
5984 </p><p>Normal text.
5985 </p>
5986 <!-- Unmatching number of opening, closing tags: -->
5987 <p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
5988 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
5989 </p><p>Plain <i>italic'</i>s plain
5990 </p>
5991 !! end
5992
5993 ###
5994 ### Tables
5995 ###
5996 ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
5997 ###
5998
5999 # This should not produce <table></table> as <table><tr><td></td></tr></table>
6000 # is the bare minimum required by the spec, see:
6001 # https://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
6002 # Parsoid team replies: empty table tags are legal in HTML5
6003 !! test
6004 A table with no data.
6005 !! options
6006 parsoid=wt2html
6007 !! wikitext
6008 {||}
6009 !! html/php
6010
6011 !! html/parsoid
6012 <table></table>
6013
6014 !! end
6015
6016 !! test
6017 A table with stray table end tags on start tag line (wt2html)
6018 !! options
6019 parsoid=wt2html
6020 !! wikitext
6021 {|style="color: red;"|}
6022
6023 {|style="color: red;" |}
6024 |foo
6025 |}
6026
6027 {|style="color: red;"|} id="foo"
6028 |foo
6029 |}
6030
6031 {|style="color: red;" |} id="foo"
6032 |foo
6033 |}
6034 !! html
6035 <table style="color: red;"></table>
6036
6037 <table style="color: red;">
6038 <tbody><tr>
6039 <td>foo</td>
6040 </tr></tbody>
6041 </table>
6042
6043 <table style="color: red;" id="foo">
6044 <tbody><tr>
6045 <td>foo</td>
6046 </tr></tbody>
6047 </table>
6048
6049 <table style="color: red;" id="foo">
6050 <tbody><tr>
6051 <td>foo</td>
6052 </tr></tbody>
6053 </table>
6054
6055 !! end
6056
6057 !! test
6058 A table with no data (take 2)
6059 !! wikitext
6060 {|
6061 |}
6062 !! html/parsoid
6063 <table></table>
6064 !! end
6065
6066 # A table with nothing but a caption is invalid XHTML, we might want to render
6067 # this as <p>caption</p>
6068 # Parsoid team replies: table with only a caption is legal in HTML5
6069 !! test
6070 A table with nothing but a caption
6071 !! wikitext
6072 {|
6073 |+caption
6074 |}
6075 !! html/php
6076 <table>
6077 <caption>caption
6078 </caption><tr><td></td></tr></table>
6079
6080 !! html/parsoid
6081 <table><caption>caption</caption></table>
6082 !! end
6083
6084 !! test
6085 A table with caption with default-spaced attributes and a table row
6086 !! wikitext
6087 {|
6088 |+ style="color: red;" | caption1
6089 |-
6090 |foo
6091 |}
6092 !! html
6093 <table>
6094 <caption style="color: red;">caption1
6095 </caption>
6096 <tr>
6097 <td>foo
6098 </td></tr></table>
6099
6100 !! end
6101
6102 !! test
6103 A table with captions with non-default spaced attributes and a table row
6104 !! wikitext
6105 {|
6106 |+style="color: red;"|caption2
6107 |+ style="color: red;"|caption3
6108 |-
6109 |foo
6110 |}
6111 !! html
6112 <table>
6113 <caption style="color: red;">caption2
6114 </caption>
6115 <caption style="color: red;">caption3
6116 </caption>
6117 <tr>
6118 <td>foo
6119 </td></tr></table>
6120
6121 !! end
6122
6123 !! test
6124 Table td-cell syntax variations
6125 !! wikitext
6126 {|
6127 |foo bar foo|baz
6128 |foo bar foo||baz
6129 |style='color:red;'|baz
6130 |style='color:red;'||baz
6131 |}
6132 !! html
6133 <table>
6134 <tr>
6135 <td>baz
6136 </td>
6137 <td>foo bar foo</td>
6138 <td>baz
6139 </td>
6140 <td style="color:red;">baz
6141 </td>
6142 <td>style='color:red;'</td>
6143 <td>baz
6144 </td></tr></table>
6145
6146 !! end
6147
6148 !! test
6149 Simple table
6150 !! wikitext
6151 {|
6152 |1||2
6153 |-
6154 |3||4
6155 |}
6156 !! html
6157 <table>
6158 <tr>
6159 <td>1</td>
6160 <td>2
6161 </td></tr>
6162 <tr>
6163 <td>3</td>
6164 <td>4
6165 </td></tr></table>
6166
6167 !! end
6168
6169 !! test
6170 Simple table but with multiple dashes for row wikitext
6171 !! wikitext
6172 {|
6173 |foo
6174 |-----
6175 |bar
6176 |}
6177 !! html
6178 <table>
6179 <tr>
6180 <td>foo
6181 </td></tr>
6182 <tr>
6183 <td>bar
6184 </td></tr></table>
6185
6186 !! end
6187
6188 !! test
6189 Multiplication table
6190 !! wikitext
6191 {| border="1" cellpadding="2"
6192 |+Multiplication table
6193 |-
6194 !&times;!!1!!2!!3
6195 |-
6196 !1
6197 |1||2||3
6198 |-
6199 !2
6200 |2||4||6
6201 |-
6202 !3
6203 |3||6||9
6204 |-
6205 !4
6206 |4||8||12
6207 |-
6208 !5
6209 |5||10||15
6210 |}
6211 !! html
6212 <table border="1" cellpadding="2">
6213 <caption>Multiplication table
6214 </caption>
6215 <tr>
6216 <th>&#215;</th>
6217 <th>1</th>
6218 <th>2</th>
6219 <th>3
6220 </th></tr>
6221 <tr>
6222 <th>1
6223 </th>
6224 <td>1</td>
6225 <td>2</td>
6226 <td>3
6227 </td></tr>
6228 <tr>
6229 <th>2
6230 </th>
6231 <td>2</td>
6232 <td>4</td>
6233 <td>6
6234 </td></tr>
6235 <tr>
6236 <th>3
6237 </th>
6238 <td>3</td>
6239 <td>6</td>
6240 <td>9
6241 </td></tr>
6242 <tr>
6243 <th>4
6244 </th>
6245 <td>4</td>
6246 <td>8</td>
6247 <td>12
6248 </td></tr>
6249 <tr>
6250 <th>5
6251 </th>
6252 <td>5</td>
6253 <td>10</td>
6254 <td>15
6255 </td></tr></table>
6256
6257 !! end
6258
6259 !! test
6260 Accept "||" in table headings
6261 !! wikitext
6262 {|
6263 !h1||h2
6264 |}
6265 !! html
6266 <table>
6267 <tr>
6268 <th>h1</th>
6269 <th>h2
6270 </th></tr></table>
6271
6272 !! end
6273
6274 !! test
6275 Accept "!!" in table data
6276 !! wikitext
6277 {|
6278 |Foo!!||
6279 |}
6280 !! html
6281 <table>
6282 <tr>
6283 <td>Foo!!</td>
6284 <td>
6285 </td></tr></table>
6286
6287 !! html/parsoid
6288 <table>
6289 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'> Foo!! </td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'></td></tr>
6290 </tbody></table>
6291 !! end
6292
6293 !! test
6294 Accept "||" in indented table headings
6295 !! wikitext
6296 :{|
6297 !h1||h2
6298 |}
6299 !! html
6300 <dl><dd><table>
6301 <tr>
6302 <th>h1</th>
6303 <th>h2
6304 </th></tr></table></dd></dl>
6305
6306 !! end
6307
6308 !! test
6309 Accept "!!" in templates
6310 !! wikitext
6311 {|
6312 !a {{echo|b!!c}}
6313 |}
6314 !! html/php
6315 <table>
6316 <tr>
6317 <th>a b</th>
6318 <th>c
6319 </th></tr></table>
6320
6321 !! html/parsoid
6322 <table>
6323 <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>
6324 !! end
6325
6326 !! test
6327 Accept "!!" in table headings after newline
6328 !! wikitext
6329 {|
6330 !a
6331 b!!c
6332 |}
6333 !! html/php
6334 <table>
6335 <tr>
6336 <th>a
6337 <p>b!!c
6338 </p>
6339 </th></tr></table>
6340
6341 !! html/parsoid
6342 <table>
6343 <tbody><tr><th>a
6344 <p>b!!c</p></th></tr>
6345 </tbody></table>
6346 !! end
6347
6348 !! test
6349 Accept "!!" in table data of mixed wikitext / html syntax
6350 !! wikitext
6351 {|
6352 !a
6353 <tr><td>b!!c</td></tr>
6354 |}
6355 !! html/php+tidy
6356 <table>
6357 <tbody><tr>
6358 <th>a
6359 </th></tr><tr><td>b!!c</td></tr>
6360 </tbody></table>
6361 !! html/parsoid
6362 <table>
6363 <tbody><tr><th>a</th></tr>
6364 <tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>b!!c</td></tr>
6365 </tbody></table>
6366 !! end
6367
6368 !! test
6369 Accept empty attributes in td/th cells (td/th cells starting with leading ||)
6370 !! wikitext
6371 {|
6372 !| h1
6373 || a
6374 |}
6375 !! html
6376 <table>
6377 <tr>
6378 <th>h1
6379 </th>
6380 <td>a
6381 </td></tr></table>
6382
6383 !! end
6384
6385 !!test
6386 Accept "| !" at start of line in tables (ignore !-attribute)
6387 !! wikitext
6388 {|
6389 |-
6390 |!style="color:red"|bar
6391 |}
6392 !! html
6393 <table>
6394
6395 <tr>
6396 <td>bar
6397 </td></tr></table>
6398
6399 !!end
6400
6401 !!test
6402 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 +/-
6403 !! wikitext
6404 {|
6405 |-
6406 |style='color:red;'|+1
6407 |style='color:blue;'|-1
6408 |-
6409 |1||2||3
6410 |1||+2||-3
6411 |-
6412 | +1
6413 | -1
6414 |}
6415 !! html
6416 <table>
6417
6418 <tr>
6419 <td style="color:red;">+1
6420 </td>
6421 <td style="color:blue;">-1
6422 </td></tr>
6423 <tr>
6424 <td>1</td>
6425 <td>2</td>
6426 <td>3
6427 </td>
6428 <td>1</td>
6429 <td>+2</td>
6430 <td>-3
6431 </td></tr>
6432 <tr>
6433 <td>+1
6434 </td>
6435 <td>-1
6436 </td></tr></table>
6437
6438 !!end
6439
6440 !! test
6441 Table rowspan
6442 !! wikitext
6443 {| border=1
6444 |Cell 1, row 1
6445 |rowspan=2|Cell 2, row 1 (and 2)
6446 |Cell 3, row 1
6447 |-
6448 |Cell 1, row 2
6449 |Cell 3, row 2
6450 |}
6451 !! html
6452 <table border="1">
6453 <tr>
6454 <td>Cell 1, row 1
6455 </td>
6456 <td rowspan="2">Cell 2, row 1 (and 2)
6457 </td>
6458 <td>Cell 3, row 1
6459 </td></tr>
6460 <tr>
6461 <td>Cell 1, row 2
6462 </td>
6463 <td>Cell 3, row 2
6464 </td></tr></table>
6465
6466 !! end
6467
6468 !! test
6469 Nested table
6470 !! wikitext
6471 {| border=1
6472 | &alpha;
6473 |
6474 {| bgcolor=#ABCDEF border=2
6475 |nested
6476 |-
6477 |table
6478 |}
6479 |the original table again
6480 |}
6481 !! html
6482 <table border="1">
6483 <tr>
6484 <td>&#945;
6485 </td>
6486 <td>
6487 <table bgcolor="#ABCDEF" border="2">
6488 <tr>
6489 <td>nested
6490 </td></tr>
6491 <tr>
6492 <td>table
6493 </td></tr></table>
6494 </td>
6495 <td>the original table again
6496 </td></tr></table>
6497
6498 !! end
6499
6500 !! test
6501 Invalid attributes in table cell (T3830)
6502 !! wikitext
6503 {|
6504 |Cell:|broken
6505 |}
6506 !! html
6507 <table>
6508 <tr>
6509 <td>broken
6510 </td></tr></table>
6511
6512 !! end
6513
6514 !! test
6515 Table cell attributes: Pipes protected by nowikis should be treated as a plain character
6516 !! wikitext
6517 {|
6518 | title="foo" |bar
6519 | title="foo<nowiki>|</nowiki>" |bar
6520 | title="foo<nowiki>|</nowiki>" bar
6521 |}
6522 !! html/php
6523 <table>
6524 <tr>
6525 <td title="foo">bar
6526 </td>
6527 <td title="foo&#124;">bar
6528 </td>
6529 <td>title="foo|" bar
6530 </td></tr></table>
6531
6532 !! html/parsoid
6533 <table>
6534 <tbody><tr><td title="foo">bar</td>
6535 <td title="foo|" data-parsoid='{"a":{"title":"foo|"},"sa":{"title":"foo&lt;nowiki>|&lt;/nowiki>"},"autoInsertedEnd":true}'>bar</td>
6536 <td> title="foo<span typeof="mw:Nowiki">|</span>" bar</td></tr>
6537 </tbody></table>
6538 !! end
6539
6540 # See: http://lists.wikimedia.org/mailman/htdig/wikitech-l/2006-April/022293.html
6541 # N.B. The "|}" to close the table is missing from the input, so parsoid's
6542 # *2wt modes will fail.
6543 !! test
6544 Table security: embedded pipes
6545 !! options
6546 parsoid=wt2html,html2html
6547 !! wikitext
6548 {|
6549 | |[ftp://|x||]" onmouseover="alert(document.cookie)">test
6550 !! html/php
6551 <table>
6552 <tr>
6553 <td>[<a rel="nofollow" class="external free" href="ftp://%7Cx">ftp://%7Cx</a></td>
6554 <td>]" onmouseover="alert(document.cookie)"&gt;test
6555 </td>
6556 </tr>
6557 </table>
6558
6559 !! html/parsoid
6560 <table><tbody>
6561 <tr>
6562 <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>
6563 !! end
6564
6565 !! test
6566 Element attributes with double ! should not be broken up by <th>
6567 !! wikitext
6568 {|
6569 !hi <div class="!!">ha</div> ho
6570 |}
6571 !! html/php
6572 <table>
6573 <tr>
6574 <th>hi <div class="!!">ha</div> ho
6575 </th></tr></table>
6576
6577 !! html/parsoid
6578 <table>
6579 <tbody><tr><th>hi <div class="!!" data-parsoid='{"stx":"html"}'>ha</div> ho</th></tr>
6580 </tbody></table>
6581 !! end
6582
6583 !! test
6584 ! and || in element attributes should not be parsed as <th>/<td>
6585 !! wikitext
6586 {|
6587 |<div style="color: red !important;" data-contrived="put this here ||">hi</div>
6588 |}
6589 !! html/php
6590 <table>
6591 <tr>
6592 <td><div style="color: red !important;" data-contrived="put this here &#124;&#124;">hi</div>
6593 </td></tr></table>
6594
6595 !! html/parsoid
6596 <table>
6597 <tbody><tr><td><div style="color: red !important;" data-contrived="put this here ||" data-parsoid='{"stx":"html"}'>hi</div></td></tr>
6598 </tbody></table>
6599 !! end
6600
6601 # FIXME: The output seems broken. Filed as T110268.
6602 !! test
6603 ! and || in td attributes should not be parsed as <th>/<td>
6604 !! options
6605 parsoid=wt2html
6606 !! wikitext
6607 {|
6608 |style="color: red !important;" data-contrived="put this here ||"|foo
6609 |}
6610 !! html/php
6611 <table>
6612 <tr>
6613 <td>style="color: red !important;" data-contrived="put this here</td>
6614 <td>foo
6615 </td></tr></table>
6616
6617 !! html/parsoid
6618 <table>
6619 <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>
6620 </tbody></table>
6621 !! end
6622
6623 !! test
6624 Break on | in element attribute in template
6625 !! options
6626 parsoid=wt2html,html2html
6627 !! wikitext
6628 {{echo|1=<div class="hi|ho">ha</div>}}
6629 !! html/php
6630 <p>ho"&gt;ha&lt;/div&gt;
6631 </p>
6632 !! html/parsoid
6633 <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>
6634 !! end
6635
6636 !! test
6637 Break on | in element attribute name in template
6638 !! wikitext
6639 {{echo|<div cla|ss="hiho">ha</div>}}
6640 !! html/parsoid
6641 <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>
6642 !! end
6643
6644 !! test
6645 Don't break on | in extension attribute in template
6646 !! wikitext
6647 {{echo|<ref name="hi|ho">ha</ref>}}
6648
6649 <references />
6650 !! html/parsoid
6651 <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>
6652
6653 <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>
6654 !! end
6655
6656 ## We don't support roundtripping of these attributes in Parsoid.
6657 ## Selective serialization takes care of preventing dirty diffs.
6658 ## But, on edits, we dirty-diff the invalid attribute text.
6659 !! test
6660 Invalid text in table attributes should be discarded
6661 !! options
6662 parsoid=wt2html
6663 !! wikitext
6664 {| <span>boo</span> style='border:1px solid black'
6665 | <span>boo</span> style='color:blue' |1
6666 |<span>boo</span> style='color:blue'|2
6667 |}
6668 !! html/php
6669 <table style="border:1px solid black">
6670 <tr>
6671 <td style="color:blue">1
6672 </td>
6673 <td style="color:blue">2
6674 </td></tr></table>
6675
6676 !! html/parsoid
6677 <table style="border:1px solid black">
6678 <tr>
6679 <td style="color:blue">1</td>
6680 <td style="color:blue">2</td>
6681 </tr>
6682 </table>
6683 !! end
6684
6685 !! test
6686 Invalid text in table attributes should be preserved by selective serializer
6687 !! options
6688 parsoid={
6689 "modes": ["selser"],
6690 "changes": [
6691 ["td:first-child", "text", "abc"],
6692 ["td + td", "text", "xyz"]
6693 ]
6694 }
6695 !! wikitext
6696 {| <span>boo</span> style='border:1px solid black'
6697 | <span>boo</span> style='color:blue' | 1
6698 |<span>boo</span> style='color:blue'| 2
6699 |}
6700 !! wikitext/edited
6701 {| <span>boo</span> style='border:1px solid black'
6702 | <span>boo</span> style='color:blue' |abc
6703 |<span>boo</span> style='color:blue'|xyz
6704 |}
6705 !! end
6706
6707 !! test
6708 1. Template-generated table cell attributes and cell content
6709 !! wikitext
6710 {|
6711 |{{table_attribs}}
6712 | {{table_attribs}}
6713 || {{table_attribs_5}}
6714 | <!--foo--> <!--bar--> <!--baz--> {{table_attribs}}
6715 |align=center {{table_attribs}}
6716 | <!--foo--> align=center <!--bar--> {{table_attribs}}
6717 |}
6718 !! html
6719 <table>
6720 <tr>
6721 <td style="color:red;">Foo
6722 </td>
6723 <td style="color:red;">Foo
6724 </td>
6725 <td>style="color:red;"</td>
6726 <td>Bar
6727 </td>
6728 <td style="color:red;">Foo
6729 </td>
6730 <td align="center" style="color:red;">Foo
6731 </td>
6732 <td align="center" style="color:red;">Foo
6733 </td></tr></table>
6734
6735 !! end
6736
6737 !! test
6738 2. Template-generated table cell attributes and cell content
6739 !! wikitext
6740 {|
6741 |{{table_attribs_2}}
6742 |}
6743 !! html/php
6744 <table>
6745 <tr>
6746 <td style="color:red;">Foo
6747 </td>
6748 <td>Bar</td>
6749 <td>Baz
6750 </td></tr></table>
6751
6752 !! html/parsoid
6753 <table>
6754 <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>
6755 <td about="#mwt1">Bar</td><td about="#mwt1">Baz</td></tr>
6756 </tbody></table>
6757 !! end
6758
6759 !! test
6760 3. Template-generated table cell attributes and cell content
6761 !! wikitext
6762 {|
6763 !align=center {{table_header_cells}}
6764 |-
6765 |align=center {{table_cells}}
6766 |}
6767 !! html/php
6768 <table>
6769 <tr>
6770 <th align="center" style="color:red;">Foo</th>
6771 <th style="color:red;"><i>Bar</i></th>
6772 <th style="color:brown;"><i>Foo</i> and Baz
6773 </th></tr>
6774 <tr>
6775 <td align="center" style="color:red;">Foo</td>
6776 <td style="color:red;"><i>Bar</i></td>
6777 <td style="color:brown;"><i>Foo</i> and Baz
6778 </td></tr></table>
6779
6780 !! html/parsoid
6781 <table>
6782 <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>
6783 <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>
6784 </tbody></table>
6785 !! end
6786
6787 !! test
6788 4. Template-generated table cell attributes and cell content inside a templated table
6789 !! wikitext
6790 {{tbl-start}}
6791 !align=center {{table_header_cells}}
6792 |-
6793 |align=center {{table_cells}}
6794 {{tbl-end}}
6795 !! html/php
6796 <table>
6797 <tr>
6798 <th align="center" style="color:red;">Foo</th>
6799 <th style="color:red;"><i>Bar</i></th>
6800 <th style="color:brown;"><i>Foo</i> and Baz
6801 </th></tr>
6802 <tr>
6803 <td align="center" style="color:red;">Foo</td>
6804 <td style="color:red;"><i>Bar</i></td>
6805 <td style="color:brown;"><i>Foo</i> and Baz
6806 </td></tr></table>
6807
6808 !! html/parsoid
6809 <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}}]}'>
6810 <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>
6811 <tr>
6812 <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>
6813 </tbody></table>
6814 !! end
6815
6816 ## Edge case fix to prevent future regressions
6817 !! test
6818 T107652: <ref>s in templates that also generate table cell attributes should be rendered properly
6819 !! wikitext
6820 {|
6821 |{{table_attribs_7}}
6822 |}
6823 <references />
6824 !! html/parsoid
6825 <table>
6826 <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>
6827 </tbody></table>
6828 <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>
6829 !! end
6830
6831 !! test
6832 Table with row followed by newlines and table heading
6833 !! options
6834 parsoid=wt2html,html2html
6835 !! wikitext
6836 {|
6837 |-
6838
6839 !foo
6840 |}
6841 !! html/*
6842 <table>
6843
6844
6845 <tr>
6846 <th>foo
6847 </th></tr></table>
6848
6849 !! end
6850
6851 !! test
6852 Table with empty line following the start tag
6853 !! options
6854 parsoid=wt2html,html2html
6855 !! wikitext
6856 {|
6857
6858 |-
6859 |foo
6860 |}
6861 !! html/*
6862 <table>
6863
6864
6865 <tr>
6866 <td>foo
6867 </td></tr></table>
6868
6869 !! end
6870
6871 !! test
6872 Table attributes with empty value
6873 !! options
6874 parsoid=wt2html,html2html
6875 !! wikitext
6876 {|
6877 | style=|hello
6878 |}
6879 !! html/php
6880 <table>
6881 <tr>
6882 <td style="">hello
6883 </td></tr></table>
6884
6885 !! html/parsoid
6886 <table>
6887 <tbody><tr><td style="">hello</td></tr>
6888 </tbody></table>
6889 !! end
6890
6891 !! test
6892 Wikitext table with a lot of comments
6893 !! wikitext
6894 {|
6895 <!-- c0 -->
6896 |foo
6897 <!-- c1 -->
6898 |-<!-- c2 -->
6899 <!-- c3 -->
6900 |<!-- c4 -->
6901 <!-- c5 -->
6902 |}
6903 !! html
6904 <table>
6905 <tr>
6906 <td>foo
6907 </td></tr>
6908 <tr>
6909 <td>
6910 </td></tr></table>
6911
6912 !! end
6913
6914 !! test
6915 Wikitext table comments represented in parsoid dom
6916 !! wikitext
6917 {|<!--c1--><!--c2-->
6918 |-<!--c3-->
6919 |x
6920 |}
6921 !! html/php+tidy
6922 <table>
6923
6924 <tbody><tr>
6925 <td>x
6926 </td></tr></tbody></table>
6927 !! html/parsoid
6928 <table><!--c1--><!--c2-->
6929 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'><!--c3-->
6930 <td data-parsoid='{"autoInsertedEnd":true}'>x</td></tr>
6931 </tbody></table>
6932 !! end
6933
6934 !! test
6935 Wikitext table with double-line table cell
6936 !! wikitext
6937 {|
6938 |a
6939 b
6940 |}
6941 !! html
6942 <table>
6943 <tr>
6944 <td>a
6945 <p>b
6946 </p>
6947 </td></tr></table>
6948
6949 !! end
6950
6951 !! test
6952 Table cell with a single comment
6953 !! wikitext
6954 {|
6955 | <!-- c1 -->
6956 |a
6957 |}
6958 !! html
6959 <table>
6960 <tr>
6961 <td>
6962 </td>
6963 <td>a
6964 </td></tr></table>
6965
6966 !! end
6967
6968 !! test
6969 Table-cell after a comment-only-empty-line
6970 !! wikitext
6971 {|
6972 |a
6973 <!--c1-->
6974 <!--c2-->|b
6975 |}
6976 !! html
6977 <table>
6978 <tr>
6979 <td>a
6980 </td>
6981 <td>b
6982 </td></tr></table>
6983
6984 !! html/parsoid
6985 <table>
6986 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>a</td>
6987 <!--c1-->
6988 <!--c2--><td data-parsoid='{"autoInsertedEnd":true}'>b</td></tr>
6989 </tbody></table>
6990
6991 !! end
6992
6993 !! test
6994 Build table with {{!}}
6995 !! wikitext
6996 {{{!}} class="wikitable"
6997 !header
6998 !second header
6999 {{!}}- style="color:red;"
7000 {{!}}data{{!}}{{!}} style="color:red;" {{!}}second data
7001 {{!}}}
7002 !! html
7003 <table class="wikitable">
7004 <tr>
7005 <th>header
7006 </th>
7007 <th>second header
7008 </th></tr>
7009 <tr style="color:red;">
7010 <td>data</td>
7011 <td style="color:red;">second data
7012 </td></tr></table>
7013
7014 !! end
7015
7016 !! test
7017 Build table with pipe as data
7018 !! wikitext
7019 {| class="wikitable"
7020 !header
7021 !second header
7022 |- style="color:red;"
7023 |data|| style="color:red;" |second data
7024 |-
7025 | style="color:red;" |data with | || style="color:red;" | second data with |
7026 |-
7027 ||data with | |||second data with |
7028 |}
7029 !! html
7030 <table class="wikitable">
7031 <tr>
7032 <th>header
7033 </th>
7034 <th>second header
7035 </th></tr>
7036 <tr style="color:red;">
7037 <td>data</td>
7038 <td style="color:red;">second data
7039 </td></tr>
7040 <tr>
7041 <td style="color:red;">data with |</td>
7042 <td style="color:red;">second data with |
7043 </td></tr>
7044 <tr>
7045 <td>data with |</td>
7046 <td>second data with |
7047 </td></tr></table>
7048
7049 !! end
7050
7051 !! test
7052 Build table with wikilink
7053 !! wikitext
7054 {| class="wikitable"
7055 !header||second header
7056 |- style="color:red;"
7057 |data [[Main Page|linktext]]||second data [[Main Page|linktext]]
7058 |-
7059 |data||second data [[Main Page|link|text with pipe]]
7060 |}
7061 !! html
7062 <table class="wikitable">
7063 <tr>
7064 <th>header</th>
7065 <th>second header
7066 </th></tr>
7067 <tr style="color:red;">
7068 <td>data <a href="/wiki/Main_Page" title="Main Page">linktext</a></td>
7069 <td>second data <a href="/wiki/Main_Page" title="Main Page">linktext</a>
7070 </td></tr>
7071 <tr>
7072 <td>data</td>
7073 <td>second data <a href="/wiki/Main_Page" title="Main Page">link|text with pipe</a>
7074 </td></tr></table>
7075
7076 !! end
7077
7078 # The expected HTML structure in this test is debatable. The PHP parser does
7079 # not parse this kind of table at all. The main focus for Parsoid is on
7080 # round-tripping, so this output is ok for now. TODO: revisit!
7081 !! test
7082 Wikitext table with html-syntax row
7083 !! wikitext
7084 {|
7085 |-
7086 <td>foo</td>
7087 |}
7088 !! html/parsoid
7089 <table>
7090 <tbody>
7091 <tr>
7092 <td>foo</td></tr></tbody></table>
7093 !! end
7094
7095 !! test
7096 Fostered content in tables: Plain text
7097 !! options
7098 parsoid=wt2html,html2html
7099 !! wikitext
7100 {|
7101 |-
7102 a
7103 |}
7104 !! html/php
7105 <table>
7106
7107 a
7108 </table>
7109
7110 !! html/php+tidy
7111
7112
7113 a
7114 <table></table>
7115 !! html/parsoid
7116 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>a</p><table>
7117 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7118
7119 </tr></tbody></table>
7120 !! end
7121
7122 !! test
7123 Fostered content in tables: Lists
7124 !! options
7125 parsoid=wt2html,html2html
7126 !! wikitext
7127 {|
7128 |-
7129 *a
7130 |}
7131 !! html/php
7132 <table>
7133
7134 <ul><li>a</li></ul>
7135 </table>
7136
7137 !! html/php+tidy
7138 <ul><li>a</li></ul><table>
7139
7140
7141 </table>
7142 !! html/parsoid
7143 <ul data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><li>a</li></ul><table>
7144 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7145
7146 </tr></tbody></table>
7147 !! end
7148
7149 !! test
7150 Template generated table cell with attributes
7151 !! wikitext
7152 {|
7153 |-
7154 {{table_attribs_4}} ||a||b
7155 |}
7156 !! html/php+tidy
7157 <table>
7158
7159 <tbody><tr>
7160 <td style="background-color:#DC241f;" width="10px"></td>
7161 <td>a</td>
7162 <td>b
7163 </td></tr></tbody></table>
7164 !! html/parsoid
7165 <table>
7166 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7167 <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>
7168 !! end
7169
7170 !! test
7171 Parsoid: Round-trip tables directly followed by content (T53219)
7172 !! options
7173 parsoid=wt2html,wt2wt
7174 !! wikitext
7175 {|
7176 |foo
7177 |} bar
7178
7179 {|
7180 |baz
7181 |}<b>quux</b>
7182 !! html+tidy
7183 <table>
7184 <tbody><tr>
7185 <td>foo
7186 </td></tr></tbody></table><p> bar
7187 </p><table>
7188 <tbody><tr>
7189 <td>baz
7190 </td></tr></tbody></table><p><b>quux</b>
7191 </p>
7192 !! end
7193
7194 !! test
7195 Parsoid: Default to a newline after tables in new content (T53219)
7196 !! options
7197 parsoid=html2wt
7198 !! html/parsoid
7199 <table><tbody>
7200 <tr><td>foo</td></tr></tbody></table> bar
7201 <table><tbody>
7202 <tr><td>baz</td></tr></tbody></table><b>quux</b>
7203 !! wikitext
7204 {|
7205 |foo
7206 |}
7207 <nowiki> </nowiki>bar
7208 {|
7209 |baz
7210 |}
7211 '''quux'''
7212 !! end
7213
7214 !! test
7215 Parsoid: newline inducing block nodes don't suppress <nowiki>
7216 !! options
7217 parsoid=html2wt
7218 !! html/parsoid
7219 a<h1>foo</h1>
7220 !! wikitext
7221 <nowiki> </nowiki>a
7222
7223 = foo =
7224 !! end
7225
7226 !! test
7227 Parsoid: Row-syntax table headings followed by comment & table cells
7228 !! options
7229 parsoid=wt2html,wt2wt
7230 !! wikitext
7231 {|
7232 !foo||bar
7233 <!-- foo --> ||baz||quux
7234 |}
7235 !! html/php
7236 <table>
7237 <tr>
7238 <th>foo</th>
7239 <th>bar
7240 </th>
7241 <td>baz</td>
7242 <td>quux
7243 </td></tr></table>
7244
7245 !! html/parsoid
7246 <table>
7247 <tbody><tr><th> foo </th><th> bar
7248 <!-- foo --> </th><td> baz </td><td> quux</td></tr>
7249 </tbody></table>
7250 !! end
7251
7252 !!test
7253 Parsoid: Recover better from broken table attributes
7254 !!options
7255 parsoid=wt2html
7256 !!wikitext
7257 {| class="foo
7258 | class="bar" |
7259 foo
7260 |}
7261 !!html/php+tidy
7262 <table class="foo">
7263 <tbody><tr>
7264 <td class="bar">
7265 <p>foo
7266 </p>
7267 </td></tr></tbody></table>
7268 !!html/parsoid
7269 <table class="foo">
7270 <tr>
7271 <td class="bar">
7272 <p>foo</p></td></tr>
7273 </tbody></table>
7274 !!end
7275
7276 !! test
7277 Tables: Digest broken attributes on table and tr tag
7278 !! options
7279 parsoid=wt2html
7280 !! wikitext
7281 {| || |} ++
7282 |- || || ++ --
7283 |- > [
7284 |}
7285 !! html
7286 <table>
7287 <tbody>
7288 <tr class='mw-empty-elt'></tr>
7289 <tr class='mw-empty-elt'></tr>
7290 </tbody></table>
7291 !! end
7292
7293 # T137406: Whitespace in the HTML
7294 !! test
7295 1. Generate correct wikitext for tables with thead/tbody/tfoot
7296 !! options
7297 parsoid=html2wt
7298 !! html/parsoid
7299 <table>
7300 <caption>Test</caption>
7301 <thead>
7302 <tr>
7303 <th>Month</th>
7304 <th>Savings</th>
7305 </tr>
7306 </thead>
7307 <tbody>
7308 <tr>
7309 <td>January</td>
7310 <td>$100</td>
7311 </tr>
7312 <tr>
7313 <td>February</td>
7314 <td>$80</td>
7315 </tr>
7316 </tbody>
7317 <tfoot>
7318 <tr>
7319 <td>Sum</td>
7320 <td>$180</td>
7321 </tr>
7322 </tfoot>
7323 </table>
7324 !! wikitext
7325 {|
7326 |+Test
7327 !Month
7328 !Savings
7329 |-
7330 |January
7331 |$100
7332 |-
7333 |February
7334 |$80
7335 |-
7336 |Sum
7337 |$180
7338 |}
7339 !! html/php+tidy
7340 <table>
7341 <caption>Test
7342 </caption>
7343 <tbody><tr>
7344 <th>Month
7345 </th>
7346 <th>Savings
7347 </th></tr>
7348 <tr>
7349 <td>January
7350 </td>
7351 <td>$100
7352 </td></tr>
7353 <tr>
7354 <td>February
7355 </td>
7356 <td>$80
7357 </td></tr>
7358 <tr>
7359 <td>Sum
7360 </td>
7361 <td>$180
7362 </td></tr></tbody></table>
7363 !! end
7364
7365 # T137406: No whitespace in the HTML
7366 !! test
7367 2. Generate correct wikitext for tables with thead/tbody/tfoot
7368 !! options
7369 parsoid=html2wt
7370 !! html/parsoid
7371 <table><thead><tr><th>heading</th></tr></thead><tbody><tr><td>foo</td></tr></tbody></table>
7372 !! wikitext
7373 {|
7374 !heading
7375 |-
7376 |foo
7377 |}
7378 !! end
7379
7380 !! test
7381 Testing serialization after deletion in references
7382 !! options
7383 parsoid={
7384 "modes": ["wt2wt"],
7385 "changes": [
7386 ["#x", "remove"]
7387 ]
7388 }
7389 !! wikitext
7390 hi <ref><div id="x">ho</div></ref>
7391
7392 <references />
7393 !! wikitext/edited
7394 hi <ref></ref>
7395
7396 <references />
7397 !! end
7398
7399 !!test
7400 Testing serialization after deletion of table cells
7401 !!options
7402 parsoid={
7403 "modes": ["wt2wt", "selser"],
7404 "changes": [
7405 ["#x", "remove"]
7406 ]
7407 }
7408 !!wikitext
7409 {|
7410 !h1 !!h2 !!h3
7411 | id="x" |c1 {{!}}{{!}}{{!}}c2 |||c3
7412 |}
7413 !! wikitext/edited
7414 {|
7415 !h1 !!h2 !!h3
7416 |c2 |||c3
7417 |}
7418 !!end
7419
7420 !! test
7421 Testing selser after addition of new row before first row (T125419)
7422 !! options
7423 parsoid={
7424 "modes": ["wt2wt", "selser"],
7425 "changes": [
7426 [ "tr", "before", "<tr><td>X</td></tr>" ]
7427 ]
7428 }
7429 !! wikitext
7430 {|
7431 |a
7432 |}
7433 !! wikitext/edited
7434 {|
7435 |X
7436 |-
7437 |a
7438 |}
7439 !! end
7440
7441 !! test
7442 Serialize new table rows in a HTML table using HTML tags
7443 !! options
7444 parsoid={
7445 "modes": ["wt2wt", "selser"],
7446 "changes": [
7447 [ "tr", "before", "<tr><td>X</td></tr>" ]
7448 ]
7449 }
7450 !! wikitext
7451 <table><tr><td>a</td></tr></table>
7452 !! wikitext/edited
7453 <table><tr><td>X</td></tr><tr><td>a</td></tr></table>
7454 !! end
7455
7456 !! test
7457 Serialize new table cells in a HTML row using HTML tags
7458 !! options
7459 parsoid={
7460 "modes": ["wt2wt", "selser"],
7461 "changes": [
7462 [ "td", "before", "<td>X</td>" ]
7463 ]
7464 }
7465 !! wikitext
7466 <table><tr><td>a</td></tr></table>
7467 !! wikitext/edited
7468 <table><tr><td>X</td><td>a</td></tr></table>
7469 !! end
7470
7471 !! test
7472 Wikitext tables can be nested inside HTML tables
7473 !! options
7474 parsoid=html2wt
7475 !! html
7476 <table data-parsoid='{"stx":"html"}'>
7477 <tr><td>
7478 <table>
7479 <tr><td>foo</td></tr>
7480 </table>
7481 </td></tr>
7482 </table>
7483 !! wikitext
7484 <table>
7485 <tr><td>
7486 {|
7487 |foo
7488 |}
7489 </td></tr>
7490 </table>
7491 !! end
7492
7493 !! test
7494 Serialize wikitext list items as HTML list items when embedded in a HTML list
7495 !! options
7496 parsoid=html2wt
7497 !! html
7498 <ul data-parsoid='{"stx": "html"}'>
7499 <li data-parsoid='{}'>a</li>
7500 <li>b</li>
7501 </ul>
7502 !! wikitext
7503 <ul>
7504 <li>a</li>
7505 <li>b</li>
7506 </ul>
7507 !! end
7508
7509 # SSS FIXME: Is this actually a good thing given the
7510 # odd nested list output that is generated by MW?
7511 # <ul><li>foo<ul>..</ul></li></ul> instead of
7512 # <ul><li>foo</li><ul>..</ul></ul>
7513 !! test
7514 Wikitext lists can be nested inside HTML lists
7515 !! options
7516 parsoid=html2wt
7517 !! html
7518 <ul data-parsoid='{"stx": "html"}'>
7519 <li data-parsoid='{"stx": "html"}'>a
7520 <ul><li>b</li></ul>
7521 </li>
7522 </ul>
7523
7524 <ul data-parsoid='{"stx": "html"}'>
7525 <li>x
7526 <ul><li>y</li></ul>
7527 </li>
7528 </ul>
7529 !! wikitext
7530 <ul>
7531 <li>a
7532 * b
7533 </li>
7534 </ul>
7535
7536 <ul>
7537 <li>x
7538 * y
7539 </li>
7540 </ul>
7541 !! end
7542
7543 ###
7544 ### Internal links
7545 ###
7546 !! test
7547 Plain link, capitalized
7548 !! wikitext
7549 [[Main Page]]
7550 !! html
7551 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
7552 </p>
7553 !! end
7554
7555 !! test
7556 Plain link, uncapitalized
7557 !! wikitext
7558 [[main Page]]
7559 !! html
7560 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
7561 </p>
7562 !! end
7563
7564 !! test
7565 Piped link
7566 !! wikitext
7567 [[Main Page|The Main Page]]
7568 !! html
7569 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7570 </p>
7571 !! end
7572
7573 !! test
7574 Piped link with comment in link text
7575 !! wikitext
7576 [[Main Page|The Main<!--front--> Page]]
7577 !! html
7578 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7579 </p>
7580 !! end
7581
7582 !! test
7583 Piped link with multiple pipe characters in link text
7584 !! wikitext
7585 [[Main Page||The|Main|Page|]]
7586 !! html/php
7587 <p><a href="/wiki/Main_Page" title="Main Page">|The|Main|Page|</a>
7588 </p>
7589 !! html/parsoid
7590 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">|The|Main|Page|</a></p>
7591 !! end
7592
7593 !! test
7594 Piped link with no link text
7595 !! wikitext
7596 [[Thomas Bek (bishop of St David's)|]]
7597 !! html/php
7598 <p>[[Thomas Bek (bishop of St David's)|]]
7599 </p>
7600 !! html/parsoid
7601 <p>[[Thomas Bek (bishop of St David's)|]]</p>
7602 !! end
7603
7604 !! test
7605 Piped link with empty link text
7606 !! wikitext
7607 [[Main Page|<nowiki/>]] - empty nowiki
7608 [[Main Page| ]] - empty space
7609 [[Main Page|&nbsp;]] - empty non breaking space
7610 !! html/php
7611 <p><a href="/wiki/Main_Page" title="Main Page"></a> - empty nowiki
7612 <a href="/wiki/Main_Page" title="Main Page"> </a> - empty space
7613 <a href="/wiki/Main_Page" title="Main Page">&#160;</a> - empty non breaking space
7614 </p>
7615 !! html/parsoid
7616 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:Nowiki"></span></a> - empty nowiki
7617 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page"> </a> - empty space
7618 <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>
7619 !! end
7620
7621 !! test
7622 Broken link
7623 !! wikitext
7624 [[Zigzagzogzagzig]]
7625 !! html
7626 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig</a>
7627 </p>
7628 !! end
7629
7630 !! test
7631 Broken link with fragment
7632 !! wikitext
7633 [[Zigzagzogzagzig#zug]]
7634 !! html
7635 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig#zug</a>
7636 </p>
7637 !! end
7638
7639 !! test
7640 Special page link with fragment
7641 !! wikitext
7642 [[Special:Version#anchor]]
7643 !! html
7644 <p><a href="/wiki/Special:Version#anchor" title="Special:Version">Special:Version#anchor</a>
7645 </p>
7646 !! end
7647
7648 !! test
7649 Nonexistent special page link with fragment
7650 !! wikitext
7651 [[Special:ThisNameWillHopefullyNeverBeUsed#anchor]]
7652 !! html
7653 <p><a href="/wiki/Special:ThisNameWillHopefullyNeverBeUsed" class="new" title="Special:ThisNameWillHopefullyNeverBeUsed (page does not exist)">Special:ThisNameWillHopefullyNeverBeUsed#anchor</a>
7654 </p>
7655 !! end
7656
7657 !! test
7658 Link with prefix
7659 !! wikitext
7660 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
7661 !! html
7662 <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>
7663 </p>
7664 !! end
7665
7666 !! test
7667 Link with suffix
7668 !! wikitext
7669 [[Main Page]]xxx, [[Main Page]]XXX, [[Main Page]]!!!
7670 !! html
7671 <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>!!!
7672 </p>
7673 !! end
7674
7675 !! article
7676 prefixed article
7677 !! text
7678 Some text
7679 !! endarticle
7680
7681 !! test
7682 T45661: Piped links with identical prefixes
7683 !! wikitext
7684 [[prefixed article|prefixed articles with spaces]]
7685
7686 [[prefixed article|prefixed articlesaoeu]]
7687
7688 [[Main Page|Main Page test]]
7689 !! html
7690 <p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articles with spaces</a>
7691 </p><p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articlesaoeu</a>
7692 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page test</a>
7693 </p>
7694 !! end
7695
7696
7697 !! test
7698 Link with HTML entity in suffix / tail
7699 !! wikitext
7700 [[Main Page]]&quot;, [[Main Page]]&#97;
7701 !! html/php
7702 <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;
7703 </p>
7704 !! html/parsoid
7705 <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>
7706 !! end
7707
7708 !! test
7709 Link with 3 brackets
7710 !! wikitext
7711 [[[Main Page]]]
7712 Foo [[[Main Page]]]
7713 !! html
7714 <p>[[[Main Page]]]
7715 Foo [[[Main Page]]]
7716 </p>
7717 !! end
7718
7719 !! test
7720 Link with 4 brackets
7721 !! wikitext
7722 [[[[Main Page]]]]
7723 !! html
7724 <p>[[<a href="/wiki/Main_Page" title="Main Page">Main Page</a>]]
7725 </p>
7726 !! end
7727
7728 !! test
7729 Piped link with 3 brackets
7730 !! wikitext
7731 [[[main page|the main page]]]
7732 !! html
7733 <p>[[[main page|the main page]]]
7734 </p>
7735 !! end
7736
7737 !! test
7738 Piped link with extlink-like text
7739 !! wikitext
7740 [[Main Page|[bar]]]
7741 [[Main Page|This is a [bar]]]
7742 [[Main Page|[bar]]
7743 !! html/php
7744 <p><a href="/wiki/Main_Page" title="Main Page">[bar]</a>
7745 <a href="/wiki/Main_Page" title="Main Page">This is a [bar]</a>
7746 <a href="/wiki/Main_Page" title="Main Page">[bar</a>
7747 </p>
7748 !! html/parsoid
7749 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar]</a>
7750 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>This is a [bar]</a>
7751 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar</a></p>
7752 !! end
7753
7754 !! test
7755 Link with multiple pipes
7756 !! wikitext
7757 [[Main Page|The|Main|Page]]
7758 !! html
7759 <p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a>
7760 </p>
7761 !! end
7762
7763 !! test
7764 Anchor containing a #. (T65430)
7765 !! config
7766 wgFragmentMode=[ 'html5', 'legacy' ]
7767 !! wikitext
7768 [[Main Page#And#Link]]
7769 !! html/php
7770 <p><a href="/wiki/Main_Page#And#Link" title="Main Page">Main Page#And#Link</a>
7771 </p>
7772 !! html/parsoid
7773 <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>
7774 !! end
7775
7776 !! test
7777 Link to namespaces
7778 !! wikitext
7779 [[Talk:Parser testing]], [[Meta:Disclaimers]]
7780 !! html
7781 <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>
7782 </p>
7783 !! end
7784
7785 !! test
7786 Link with space in namespace
7787 !! wikitext
7788 [[User talk:Foo bar]]
7789 !! html
7790 <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>
7791 </p>
7792 !! end
7793
7794 !! article
7795 MemoryAlpha:AlphaTest
7796 !! text
7797 This is an article in the MemoryAlpha namespace
7798 (which shadows the memoryalpha interwiki link).
7799 !! endarticle
7800
7801 !! test
7802 Namespace takes precedence over interwiki link (T53680)
7803 !! wikitext
7804 [[MemoryAlpha:AlphaTest]]
7805 !! html
7806 <p><a href="/wiki/MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a>
7807 </p>
7808 !! end
7809
7810 # The previous test doesn't work correctly in html2*, due to not recognizing the
7811 # link as an internal one. This one checks for the correct behavior.
7812 !! test
7813 Link to namespace preferred over interwiki with correct rel attribute
7814 !! options
7815 parsoid=html2wt,html2html
7816 !! html/parsoid
7817 <p><a rel="mw:WikiLink" href="./MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a></p>
7818 !! wikitext
7819 [[MemoryAlpha:AlphaTest]]
7820 !! end
7821
7822 !! test
7823 Piped link to namespace
7824 !! wikitext
7825 [[Meta:Disclaimers|The disclaimers]]
7826 !! html
7827 <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>
7828 </p>
7829 !! end
7830
7831 !! test
7832 Link containing }
7833 !! wikitext
7834 [[Usually caused by a typo (oops}]]
7835 !! html
7836 <p>[[Usually caused by a typo (oops}]]
7837 </p>
7838 !! end
7839
7840 !! article
7841 7% Solution
7842 !! text
7843 Just a test of an article title containing a percent.
7844 !! endarticle
7845
7846 !! test
7847 Link containing % (not as a hex sequence)
7848 !! wikitext
7849 [[7% Solution]]
7850 [[7% Solution|7%25 Solution]]
7851 !! html/php
7852 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
7853 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
7854 </p>
7855 !! html/parsoid
7856 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
7857 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
7858 !! end
7859
7860 # note that the parsoid HTML is identical to the previous test output,
7861 # so the previous test ensures that the html2wt mode will generate the
7862 # "not as a hex sequence" wikitext.
7863 !! test
7864 Link containing % as a single hex sequence interpreted to char
7865 !! options
7866 parsoid=wt2wt,wt2html,html2html
7867 !! wikitext
7868 [[7%25 Solution]]
7869 [[7%25 Solution|7%25 Solution]]
7870 !! html/php
7871 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
7872 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
7873 </p>
7874 !! html/parsoid
7875 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
7876 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
7877 !!end
7878
7879 !! test
7880 Link containing % as a double hex sequence interpreted to hex sequence
7881 !! wikitext
7882 [[7%2525 Solution]]
7883 !! html
7884 <p>[[7%2525 Solution]]
7885 </p>
7886 !!end
7887
7888 ## Example for such a section: == < ==
7889 !! test
7890 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors
7891 !! config
7892 wgFragmentMode=[ 'html5', 'legacy' ]
7893 !! wikitext
7894 [[%23%3c]][[%23%3e]]
7895 !! html/php
7896 <p><a href="#&lt;">#&lt;</a><a href="#&gt;">#&gt;</a>
7897 </p>
7898 !! html/parsoid
7899 <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>
7900 !! end
7901
7902 ## Example for such a section: == < ==
7903 !! test
7904 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors (legacy)
7905 !! config
7906 wgFragmentMode=[ 'legacy' ]
7907 !! wikitext
7908 [[%23%3c]][[%23%3e]]
7909 !! html/php
7910 <p><a href="#.3C">#&lt;</a><a href="#.3E">#&gt;</a>
7911 </p>
7912 !! end
7913
7914 !! test
7915 Link containing "<#" and ">#" as a hex sequences
7916 !! wikitext
7917 [[%3c%23]][[%3e%23]]
7918 !! html
7919 <p>[[%3c%23]][[%3e%23]]
7920 </p>
7921 !! end
7922
7923 !! test
7924 Link containing an equals sign
7925 !! wikitext
7926 [[Special:BookSources/isbn=4-00-026157-6]]
7927 !! html/php
7928 <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>
7929 </p>
7930 !! html/parsoid
7931 <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>
7932 !! end
7933
7934 !! article
7935 Foo~bar
7936 !! text
7937 Just a test of an article title containing a tilde.
7938 !! endarticle
7939
7940 # note that links containing signatures, like [[Foo~~~~]], are
7941 # massaged by the pre-save transform (PST) and so the tildes are never
7942 # seen by the parser.
7943 !! test
7944 Link containing a tilde
7945 !! wikitext
7946 [[Foo~bar]]
7947 !! html/php
7948 <p><a href="/wiki/Foo~bar" title="Foo~bar">Foo~bar</a>
7949 </p>
7950 !! html/parsoid
7951 <p><a rel="mw:WikiLink" href="./Foo~bar" title="Foo~bar">Foo~bar</a></p>
7952 !! end
7953
7954 !! test
7955 Link containing double-single-quotes '' (T6598)
7956 !! wikitext
7957 [[Lista d''e paise d''o munno]]
7958 !! html/php
7959 <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>
7960 </p>
7961 !! html/parsoid
7962 <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>
7963 !! end
7964
7965 !! test
7966 Link containing double quotes and spaces
7967 !! wikitext
7968 [[Cool "Gator"]]
7969 !! html/php
7970 <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>
7971 </p>
7972 !! html/parsoid
7973 <p><a rel="mw:WikiLink" href='./Cool_"Gator"' title='Cool "Gator"'>Cool "Gator"</a></p>
7974 !! end
7975
7976 !! test
7977 File containing double quotes and spaces
7978 !! wikitext
7979 [[File:Cool "Gator".png]]
7980 !! html/parsoid
7981 <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>
7982 !! end
7983
7984 !! test
7985 Redirect containing double quotes and spaces
7986 !! wikitext
7987 #REDIRECT [[Cool "Gator"]]
7988 !! html/parsoid
7989 <link rel="mw:PageProp/redirect" href="./Cool_%22Gator%22" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Cool_%22Gator%22"},"sa":{"href":"Cool \"Gator\""}}'/>
7990 !! end
7991
7992 !! test
7993 Link containing double-single-quotes '' in text (T6598 sanity check)
7994 !! wikitext
7995 Some [[Link|pretty ''italics'' and stuff]]!
7996 !! html/php
7997 <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>!
7998 </p>
7999 !! html/parsoid
8000 <p>Some <a rel="mw:WikiLink" href="./Link" title="Link">pretty <i>italics</i> and stuff</a>!</p>
8001 !! end
8002
8003 !! test
8004 Link containing double-single-quotes '' in text embedded in italics (T6598 sanity check)
8005 !! wikitext
8006 ''Some [[Link|pretty ''italics'' and stuff]]!''
8007 !! html
8008 <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>
8009 </p>
8010 !! end
8011
8012 !! test
8013 Link with double quotes in title part (literal) and alternate part (interpreted)
8014 !! wikitext
8015 [[File:Denys_Savchenko_''Pentecoste''.jpg]]
8016
8017 [[''Pentecoste'']]
8018
8019 [[''Pentecoste''|Pentecoste]]
8020
8021 [[''Pentecoste''|''Pentecoste'']]
8022 !! html/php
8023 <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>
8024 </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>
8025 </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>
8026 </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>
8027 </p>
8028 !! html/parsoid
8029 <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>
8030 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">''Pentecoste''</a></p>
8031 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">Pentecoste</a></p>
8032 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''"><i>Pentecoste</i></a></p>
8033 !! end
8034
8035 !! test
8036 Broken image links with HTML captions (T41700)
8037 !! wikitext
8038 [[File:Nonexistent|<script></script>]]
8039 [[File:Nonexistent|100x100px|<script></script>]]
8040 [[File:Nonexistent|&lt;]]
8041 [[File:Nonexistent|a<i>b</i>c]]
8042 !! html/php
8043 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8044 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8045 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;</a>
8046 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">abc</a>
8047 </p>
8048 !! html/parsoid
8049 <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>
8050 <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>
8051 <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>
8052 <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>
8053 !! end
8054
8055 !! test
8056 Plain link to URL
8057 !! wikitext
8058 [[http://www.example.com]]
8059 !! html/php
8060 <p>[<a rel="nofollow" class="external autonumber" href="http://www.example.com">[1]</a>]
8061 </p>
8062 !! html/parsoid
8063 <p>[<a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com"></a>]</p>
8064 !! end
8065
8066 !! test
8067 Plain link to URL with link text
8068 !! wikitext
8069 [[http://www.example.com Link text]]
8070 !! html
8071 <p>[<a rel="nofollow" class="external text" href="http://www.example.com">Link text</a>]
8072 </p>
8073 !! end
8074
8075 !! test
8076 Plain link to protocol-relative URL
8077 !! wikitext
8078 [[//www.example.com]]
8079 !! html/php
8080 <p>[<a rel="nofollow" class="external autonumber" href="//www.example.com">[1]</a>]
8081 </p>
8082 !! html/parsoid
8083 <p>[<a rel="mw:ExtLink" class="external autonumber" href="//www.example.com"></a>]</p>
8084 !! end
8085
8086 !! test
8087 Plain link to protocol-relative URL with link text
8088 !! wikitext
8089 [[//www.example.com Link text]]
8090 !! html
8091 <p>[<a rel="nofollow" class="external text" href="//www.example.com">Link text</a>]
8092 </p>
8093 !! end
8094
8095 !! test
8096 Plain link to page with question mark in title
8097 !! wikitext
8098 [[A?b]]
8099
8100 [[A?b|Baz]]
8101 !! html
8102 <p><a href="/wiki/A%3Fb" title="A?b">A?b</a>
8103 </p><p><a href="/wiki/A%3Fb" title="A?b">Baz</a>
8104 </p>
8105 !! end
8106
8107 # I'm fairly sure the expected result here is wrong.
8108 # We want these to be URL links, not pseudo-pages with URLs for titles....
8109 # However the current output is also pretty screwy.
8110 #
8111 # ----
8112 # I'm changing it to match the current output--it arguably makes more
8113 # sense in the light of the test above. Old expected result was:
8114 #<p>Piped link to URL: <a href="/index.php?title=Http://www.example.com&amp;action=edit" class="new">an example URL</a>
8115 #</p>
8116 # But I think this test is bordering on "garbage in, garbage out" anyway.
8117 # -- wtm
8118 !! test
8119 Piped link to URL
8120 !! wikitext
8121 Piped link to URL: [[http://www.example.com|an example URL]]
8122 !! html/php
8123 <p>Piped link to URL: [<a rel="nofollow" class="external text" href="http://www.example.com%7Can">example URL</a>]
8124 </p>
8125 !! html/parsoid
8126 <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>
8127 !! end
8128
8129 !! test
8130 Plain link in template argument
8131 !! options
8132 parsoid=wt2html
8133 !! wikitext
8134 {{echo|[http://www.example.com |123]}}
8135
8136 {{echo|[[http://www.example.com |123]]}}
8137
8138 {{echo|[[http://www.example.com |123]}}
8139
8140 {{echo|[http://www.example.com |123]]}}
8141 !! html/php
8142 <p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8143 </p><p>[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>]
8144 </p><p>{{echo|[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>}}
8145 </p><p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8146 </p>
8147 !! html/parsoid
8148 <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>
8149
8150 <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>
8151
8152 <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>
8153
8154 <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>
8155 !! end
8156
8157 !! test
8158 T2002: [[page|http://url/]] should link to page, not http://url/
8159 !! wikitext
8160 [[Main Page|http://url/]]
8161 !! html/php
8162 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
8163 </p>
8164 !! html/parsoid
8165 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">http://url/</a></p>
8166 !! end
8167
8168 # Parsoid does not mark self-links, by design.
8169 !! test
8170 T2337: Escaped self-links should be bold
8171 !! options
8172 title=[[Bug462]]
8173 !! wikitext
8174 [[Bu&#103;462]] [[Bug462]]
8175 !! html/php+tidy
8176 <p><a class="mw-selflink selflink">Bu&#103;462</a> <a class="mw-selflink selflink">Bug462</a>
8177 </p>
8178 !! html/parsoid
8179 <p><a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a> <a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a></p>
8180 !! end
8181
8182 !! test
8183 Self-link to section should not be bold
8184 !! options
8185 title=[[Main Page]]
8186 !! wikitext
8187 [[Main Page#section]]
8188 !! html
8189 <p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
8190 </p>
8191 !! end
8192
8193 !! article
8194 00
8195 !! text
8196 This is 00.
8197 !! endarticle
8198
8199 !!test
8200 Self-link to numeric title
8201 !!options
8202 title=[[0]]
8203 !! wikitext
8204 [[0]]
8205 !! html
8206 <p><a class="mw-selflink selflink">0</a>
8207 </p>
8208 !!end
8209
8210 !!test
8211 Link to numeric-equivalent title
8212 !!options
8213 title=[[0]]
8214 !! wikitext
8215 [[00]]
8216 !! html
8217 <p><a href="/wiki/00" title="00">00</a>
8218 </p>
8219 !!end
8220
8221 !! test
8222 <nowiki> inside a link
8223 !! wikitext
8224 [[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
8225 !! html
8226 <p>[[Main Page]] <a href="/wiki/Main_Page" title="Main Page">the main page [it's not very good]</a>
8227 </p>
8228 !! end
8229
8230 !! test
8231 Non-breaking spaces in title
8232 !! wikitext
8233 [[&nbsp; Main &nbsp; Page &nbsp;]]
8234 !! html
8235 <p><a href="/wiki/Main_Page" title="Main Page">&#160; Main &#160; Page &#160;</a>
8236 </p>
8237 !!end
8238
8239 # Add new article for the test below so that it doesn't red-link
8240 !! article
8241 Foo bar baz
8242 !! text
8243 boo
8244 !! endarticle
8245
8246 !! test
8247 Multiple spaces in titles should normalize to a single underscore
8248 !! options
8249 parsoid=wt2html,wt2wt
8250 !! wikitext
8251 [[Foo bar baz|x]]
8252 [[Foo bar baz|x]]
8253 [[Foo bar baz|x]]
8254 !! html/php
8255 <p><a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8256 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8257 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8258 </p>
8259 !! html/parsoid
8260 <p><a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8261 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8262 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8263 </p>
8264 !! end
8265
8266 !! test
8267 Internal link with ca linktrail, surrounded by bold apostrophes (T29473 primary issue)
8268 !! options
8269 language=ca
8270 !! wikitext
8271 '''[[Main Page]]'''
8272 !! html
8273 <p><b><a href="/wiki/Main_Page" title="Main Page">Main Page</a></b>
8274 </p>
8275 !! end
8276
8277 !! test
8278 Internal link with ca linktrail, surrounded by italic apostrophes (T29473 primary issue)
8279 !! options
8280 language=ca
8281 !! wikitext
8282 ''[[Main Page]]''
8283 !! html
8284 <p><i><a href="/wiki/Main_Page" title="Main Page">Main Page</a></i>
8285 </p>
8286 !! end
8287
8288 !! test
8289 Internal link with en linktrail: no apostrophes (T29473)
8290 !! options
8291 language=en
8292 !! wikitext
8293 [[Something]]'nice
8294 !! html
8295 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (page does not exist)">Something</a>'nice
8296 </p>
8297 !! end
8298
8299 !! test
8300 Internal link with ca linktrail with apostrophes (T29473)
8301 !! options
8302 language=ca
8303 !! wikitext
8304 [[Something]]'nice
8305 !! html
8306 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (encara no existeix)">Something'nice</a>
8307 </p>
8308 !! end
8309
8310 !! test
8311 Internal link with kaa linktrail with apostrophes (T29473)
8312 !! options
8313 language=kaa
8314 !! wikitext
8315 [[Something]]'nice
8316 !! html
8317 <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>
8318 </p>
8319 !! end
8320
8321 !! test
8322 Link with multiple ":" in a subpage-supporting namespace (T65636)
8323 !! wikitext
8324 [[User:Foo/Test/63636:Bar|Test]]
8325 !! html/php
8326 <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>
8327 </p>
8328 !! html/parsoid
8329 <p><a rel="mw:WikiLink" href="./User:Foo/Test/63636:Bar" title="User:Foo/Test/63636:Bar">Test</a></p>
8330 !! end
8331
8332 ## Mainly a sanity check for Parsoid
8333 !! test
8334 Handle title parsing for subpages
8335 !! options
8336 title=[[/123123]]
8337 subpage
8338 !! wikitext
8339 123
8340 !! html/php
8341 <p>123
8342 </p>
8343 !! html/parsoid
8344 <p>123</p>
8345 !! end
8346
8347 !! article
8348 User:Test/123
8349 !! text
8350 test 123
8351 !! endarticle
8352
8353 !! test
8354 Link to a subpage from a namespace other than main
8355 !! options
8356 title=[[User:Test]]
8357 subpage
8358 !! wikitext
8359 [[/123]]
8360 !! html/php
8361 <p><a href="/wiki/User:Test/123" title="User:Test/123">/123</a>
8362 </p>
8363 !! html/parsoid
8364 <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>
8365 !! end
8366
8367 !! test
8368 Ensure that transclusion titles are not url-decoded
8369 !! options
8370 subpage title=[[Test]]
8371 parsoid=wt2html
8372 !! wikitext
8373 {{Bar%C3%A9}} {{/Bar%C3%A9}}
8374 !! html/php
8375 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}
8376 </p>
8377 !! html/parsoid
8378 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}</p>
8379 !! end
8380
8381 !! test
8382 Purely hash wikilink
8383 !! options
8384 title=[[User:Test/123]]
8385 subpage
8386 !! wikitext
8387 [[#a|b]]
8388 !! html/php
8389 <p><a href="#a">b</a>
8390 </p>
8391 !! html/parsoid
8392 <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>
8393 !! end
8394
8395 !! test
8396 Serialization of purely hash wikilink
8397 !! options
8398 title=[[User:Test/123]]
8399 subpage
8400 parsoid=html2wt
8401 !! html/parsoid
8402 <p><a href="#a">[[</a></p>
8403 !! wikitext
8404 [[#a|<nowiki>[[</nowiki>]]
8405 !! html/php
8406 <p><a href="#a">[[</a>
8407 </p>
8408 !! end
8409
8410 !! test
8411 1. Interaction of linktrail and template encapsulation
8412 !! wikitext
8413 {{echo|[[Foo]]}}l
8414 !! html/parsoid
8415 <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>
8416 !! end
8417
8418 !! test
8419 2. Interaction of linktrail and template encapsulation
8420 !! options
8421 parsoid
8422 !! wikitext
8423 {{echo|Some [[Fool]]}}s
8424 !! html
8425 <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>
8426 !! end
8427
8428 !! test
8429 3. Interaction of linktrail and template encapsulation
8430 !! options
8431 parsoid
8432 !! wikitext
8433 {{echo|Some [[Fool]]s are '''bold and foolish'''}}
8434 !! html
8435 <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>
8436 !! end
8437
8438 !! article
8439 Söfnuður
8440 !! text
8441 Test.
8442 !! endarticle
8443
8444 !! test
8445 Internal link with is link prefix
8446 !! options
8447 language=is
8448 !! wikitext
8449 Aðrir mótmælenda[[söfnuður|söfnuðir]] og
8450 !! html
8451 <p>Aðrir <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a> og
8452 </p>
8453 !! end
8454
8455 !! article
8456 Mótmælendatrú
8457 !! text
8458 Test.
8459 !! endarticle
8460
8461 !! test
8462 Internal link with is link trail and link prefix
8463 !! options
8464 language=is
8465 !! wikitext
8466 [[mótmælendatrú|xxx]]ar
8467 [[mótmælendatrú]]ar
8468 mótmælenda[[söfnuður]]
8469 mótmælenda[[söfnuður|söfnuðir]]
8470 mótmælenda[[söfnuður|söfnuðir]]xxx
8471 !! html
8472 <p><a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">xxxar</a>
8473 <a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">mótmælendatrúar</a>
8474 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuður</a>
8475 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a>
8476 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðirxxx</a>
8477 </p>
8478 !! end
8479
8480 !! test
8481 Parsoid link trail escaping
8482 !! options
8483 parsoid=html2wt,html2html
8484 !! html/parsoid
8485 <p><a rel="mw:WikiLink" href="./Apple" title="Apple">apple</a>s</p>
8486 !! wikitext
8487 [[apple]]<nowiki/>s
8488 !! end
8489
8490 !! test
8491 Parsoid link prefix escaping
8492 !! options
8493 language=is
8494 parsoid=html2wt,html2html
8495 !! html/parsoid
8496 <p>Aðrir mótmælenda<a rel="mw:WikiLink" href="./Söfnuður" title="Söfnuður">söfnuður</a></p>
8497 !! wikitext
8498 Aðrir mótmælenda<nowiki/>[[söfnuður]]
8499 !! end
8500
8501 !! test
8502 Parsoid link bracket escaping
8503 !! options
8504 parsoid=html2wt,html2html
8505 !! html/parsoid
8506 <p><a rel="mw:WikiLink" href="./Test" title="Test">Test</a></p>
8507 <p>[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]</p>
8508 <p>[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]</p>
8509 <p>[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]</p>
8510 <p>[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]</p>
8511 <p>[[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]]</p>
8512 !! wikitext
8513 [[Test]]
8514
8515 [<nowiki/>[[Test]]]
8516
8517 [[[[Test]]]]
8518
8519 [[[<nowiki/>[[Test]]]]]
8520
8521 [[[[[[Test]]]]]]
8522
8523 [[[[[<nowiki/>[[Test]]]]]]]
8524 !! end
8525
8526 !! test
8527 Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved
8528 !! wikitext
8529 [[Foo| bar]]
8530
8531 [[Foo| ''bar'']]
8532
8533 [http://wp.org foo]
8534
8535 [http://wp.org ''foo'']
8536 !! html
8537 <p><a href="/wiki/Foo" title="Foo"> bar</a>
8538 </p><p><a href="/wiki/Foo" title="Foo"> <i>bar</i></a>
8539 </p><p><a rel="nofollow" class="external text" href="http://wp.org">foo</a>
8540 </p><p><a rel="nofollow" class="external text" href="http://wp.org"><i>foo</i></a>
8541 </p>
8542 !! end
8543
8544 !! test
8545 Parsoid: Scoped parsing should handle mixed transclusions and plain text
8546 !! wikitext
8547 [[Foo|{{echo|a}} b {{echo|c}}]]
8548 !! html/parsoid
8549 <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>
8550 !! end
8551
8552 !! test
8553 Link with angle bracket after anchor
8554 !! config
8555 wgFragmentMode=[ 'html5', 'legacy' ]
8556 !! wikitext
8557 [[Foo#<bar>]]
8558 !! html/php
8559 <p><a href="/wiki/Foo#&lt;bar&gt;" title="Foo">Foo#&lt;bar&gt;</a>
8560 </p>
8561 !! html/parsoid
8562 <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>
8563 !! end
8564
8565 !! test
8566 Link with angle bracket after anchor (legacy)
8567 !! config
8568 wgFragmentMode=[ 'legacy' ]
8569 !! wikitext
8570 [[Foo#<bar>]]
8571 !! html/php
8572 <p><a href="/wiki/Foo#.3Cbar.3E" title="Foo">Foo#&lt;bar&gt;</a>
8573 </p>
8574 !! end
8575
8576 ###
8577 ### Interwiki links (see maintenance/interwiki.sql)
8578 ###
8579
8580 !! test
8581 Inline interwiki link
8582 !! options
8583 parsoid=wt2html,wt2wt,html2html
8584 !! wikitext
8585 [[MeatBall:SoftSecurity]]
8586 !! html/php
8587 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
8588 </p>
8589 !! html/parsoid
8590 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a></p>
8591 !! end
8592
8593 !! test
8594 Inline interwiki link with empty title (T4372)
8595 !! options
8596 parsoid=wt2html,wt2wt,html2html
8597 !! wikitext
8598 [[MeatBall:]]
8599 !! html/php
8600 <p><a href="http://www.usemod.com/cgi-bin/mb.pl" class="extiw" title="meatball:">MeatBall:</a>
8601 </p>
8602 !! html/parsoid
8603 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?" title="meatball:">MeatBall:</a></p>
8604 !! end
8605
8606 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
8607 !! test
8608 Interwiki link encoding conversion (T3636)
8609 !! options
8610 parsoid=wt2html,wt2wt
8611 !! wikitext
8612 *[[Wikipedia:ro:Olteni&#0355;a]]
8613 *[[Wikipedia:ro:Olteni&#355;a]]
8614 !! html
8615 <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>
8616 <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>
8617
8618 !! html/php+tidy
8619 <ul>
8620 <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>
8621 <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>
8622 </ul>
8623 !! html/parsoid
8624 <ul>
8625 <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>
8626 <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>
8627 </ul>
8628 !! end
8629
8630 !! test
8631 Interwiki link with fragment (T4130)
8632 !! wikitext
8633 [[MeatBall:SoftSecurity#foo]]
8634 !! html
8635 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity#foo</a>
8636 </p>
8637 !! end
8638
8639 !! test
8640 Link scenarios with escaped fragments
8641 !! config
8642 wgFragmentMode=[ 'html5', 'legacy' ]
8643 !! wikitext
8644 [[#Is this great?]]
8645 [[Foo#Is this great?]]
8646 [[meatball:Foo#Is this great?]]
8647 !! html/php
8648 <p><a href="#Is_this_great?">#Is this great?</a>
8649 <a href="/wiki/Foo#Is_this_great?" title="Foo">Foo#Is this great?</a>
8650 <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>
8651 </p>
8652 !! html/parsoid
8653 <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>
8654 <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>
8655 <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>
8656 !! end
8657
8658 !! test
8659 Link scenarios with escaped fragments (legacy)
8660 !! config
8661 wgFragmentMode=[ 'legacy' ]
8662 !! wikitext
8663 [[#Is this great?]]
8664 [[Foo#Is this great?]]
8665 [[meatball:Foo#Is this great?]]
8666 !! html/php
8667 <p><a href="#Is_this_great.3F">#Is this great?</a>
8668 <a href="/wiki/Foo#Is_this_great.3F" title="Foo">Foo#Is this great?</a>
8669 <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>
8670 </p>
8671 !! end
8672
8673 # Ideally the wikipedia: prefix here should be proto-relative too
8674 # [CSA]: this is kind of a bogus test, as the PHP parser test doesn't
8675 # define the 'en' prefix, and originally the test used 'wikipedia',
8676 # which isn't a localinterwiki prefix hence the links to the 'en:Foo'
8677 # article.
8678 !! test
8679 Different interwiki prefixes mapping to the same URL
8680 !! wikitext
8681 [[:en:Foo]]
8682
8683 [[:en:Foo|Foo]]
8684
8685 [[wikipedia:Foo]]
8686
8687 [[:wikipedia:Foo|Foo]]
8688
8689 [[wikipedia:en:Foo]]
8690
8691 [[:wikipedia:en:Foo]]
8692
8693 [[ wikiPEdia :Foo]]
8694 !! html/parsoid
8695 <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>
8696
8697 <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>
8698
8699 <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>
8700
8701 <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>
8702
8703 <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>
8704
8705 <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>
8706
8707 <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>
8708 !! end
8709
8710 !! test
8711 Interwiki links that cannot be represented in wiki syntax
8712 !! wikitext
8713 [[meatball:ok]]
8714 [[meatball:ok#foo|ok with fragment]]
8715 [[meatball:ok_as_well?|ok ending with ? mark]]
8716 [http://de.wikipedia.org/wiki/Foo?action=history has query]
8717 [http://de.wikipedia.org/wiki/#foo is just fragment]
8718
8719 !! html/php
8720 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?ok" class="extiw" title="meatball:ok">meatball:ok</a>
8721 <a href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" class="extiw" title="meatball:ok">ok with fragment</a>
8722 <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>
8723 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8724 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a>
8725 </p>
8726 !! html/parsoid
8727 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok" title="meatball:ok">meatball:ok</a>
8728 <a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" title="meatball:ok">ok with fragment</a>
8729 <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>
8730 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8731 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a></p>
8732 !! end
8733
8734 !! test
8735 Interwiki links: trail
8736 !! wikitext
8737 [[wikipedia:Foo|Ba]]r
8738 !! html/php
8739 <p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
8740 </p>
8741 !! html/parsoid
8742 <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>
8743 !! end
8744
8745 !! test
8746 Local interwiki link
8747 !! options
8748 parsoid=wt2html,wt2wt,html2html
8749 !! wikitext
8750 [[local:Template:Foo]]
8751 !! html/php
8752 <p><a href="/wiki/Template:Foo" title="Template:Foo">local:Template:Foo</a>
8753 </p>
8754 !! html/parsoid
8755 <p><a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">local:Template:Foo</a></p>
8756 !! end
8757
8758 # Parsoid does not mark self-links, by design.
8759 !! test
8760 Local interwiki link: self-link to current page
8761 !! options
8762 title=[[Main Page]]
8763 parsoid=wt2html,wt2wt,html2html
8764 !! wikitext
8765 [[local:Main Page]]
8766 !! html/php
8767 <p><a class="mw-selflink selflink">local:Main Page</a>
8768 </p>
8769 !! html/parsoid
8770 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:Main Page</a></p>
8771 !! end
8772
8773 !! test
8774 Local interwiki link: prefix only (T66167)
8775 !! options
8776 parsoid=wt2html,wt2wt,html2html
8777 !! wikitext
8778 [[local:]]
8779 !! html/php
8780 <p><a href="/wiki/Main_Page" title="Main Page">local:</a>
8781 </p>
8782 !! html/parsoid
8783 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:</a></p>
8784 !! end
8785
8786 !! test
8787 Local interwiki link: with additional interwiki prefix (T63357)
8788 !! options
8789 parsoid=wt2html,wt2wt,html2html
8790 !! wikitext
8791 [[local:meatball:Hello]]
8792 !! html/php
8793 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Hello" class="extiw" title="meatball:Hello">local:meatball:Hello</a>
8794 </p>
8795 !! html/parsoid
8796 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?Hello" title="meatball:Hello">local:meatball:Hello</a></p>
8797 !! end
8798
8799 !! test
8800 Multiple local interwiki link prefixes
8801 !! wikitext
8802 [[local:local:local:local:mi:local:Foo]]
8803 !! options
8804 parsoid=wt2html,wt2wt,html2html
8805 !! html/php
8806 <p><a href="/wiki/Foo" title="Foo">local:local:local:local:mi:local:Foo</a>
8807 </p>
8808 !! html/parsoid
8809 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">local:local:local:local:mi:local:Foo</a></p>
8810 !! end
8811
8812 ###
8813 ### Interlanguage links
8814 ### Language links (so that searching for '### language' matches..)
8815 ###
8816
8817 !! test
8818 Interlanguage link
8819 !! wikitext
8820 Blah blah blah
8821 [[zh:Chinese]]
8822 !! html/php
8823 <p>Blah blah blah
8824 </p>
8825 !! html/parsoid
8826 <p>Blah blah blah</p>
8827 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8828 !! end
8829
8830 ## parsoid html2wt will lose the space variations
8831 !! test
8832 Interlanguage link with spacing
8833 !! options
8834 parsoid=wt2html,wt2wt,html2html
8835 !! wikitext
8836 Blah blah blah
8837 [[ zh : Chinese ]]
8838 !! html/php
8839 <p>Blah blah blah
8840 </p>
8841 !! html/parsoid
8842 <p>Blah blah blah</p>
8843 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8844 !! end
8845
8846 !! test
8847 Double interlanguage link
8848 !! wikitext
8849 Blah blah blah
8850 [[es:Spanish]]
8851 [[zh:Chinese]]
8852 !! html/php
8853 <p>Blah blah blah
8854 </p>
8855 !! html/parsoid
8856 <p>Blah blah blah</p>
8857 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
8858 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8859 !! end
8860
8861 ## parsoid html2wt will lose the space variations
8862 !! test
8863 Interlanguage link variations
8864 !! options
8865 parsoid=wt2html,wt2wt,html2html
8866 !! wikitext
8867 Blah blah blah
8868 [[ es :Spanish]]
8869 [[ ZH :Chinese]]
8870 [[es:Foo_bar]]
8871 !! html/php
8872 <p>Blah blah blah
8873 </p>
8874 !! html/parsoid
8875 <p>Blah blah blah</p>
8876 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish" />
8877 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese" />
8878 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar" />
8879 !! end
8880
8881 !! test
8882 Escaping of interlanguage links (T129218, T156308)
8883 !! wikitext
8884 Blah blah blah
8885 [[:es:Spanish]]
8886 [[ : zh : Chinese ]]
8887 !! html/php
8888 <p>Blah blah blah
8889 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
8890 <a href="http://zh.wikipedia.org/wiki/Chinese" class="extiw" title="zh:Chinese"> zh : Chinese </a>
8891 </p>
8892 !! html/parsoid
8893 <p>Blah blah blah
8894 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
8895 <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh : Chinese </a></p>
8896 !! end
8897
8898 !! test
8899 Multiple colons escaping interlanguage links
8900 !! options
8901 parsoid=wt2html
8902 !! wikitext
8903 [[:es:Spanish]]
8904 [[::es:Spanish]]
8905 [[:::es:Spanish]]
8906 !! html/php
8907 <p><a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
8908 [[::es:Spanish]]
8909 [[:::es:Spanish]]
8910 </p>
8911 !! html/parsoid
8912 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
8913 [[::es:Spanish]]
8914 [[:::es:Spanish]]</p>
8915 !! end
8916
8917 ## parsoid html2wt will normalize the space to _
8918 !! test
8919 Space and question mark encoding in interlanguage links (T95473)
8920 !! options
8921 parsoid=wt2html,wt2wt,html2html
8922 !! wikitext
8923 Blah blah blah
8924 [[es:Foo bar?]]
8925 !! html/php
8926 <p>Blah blah blah
8927 </p>
8928 !! html/parsoid
8929 <p>Blah blah blah</p>
8930 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar%3F" />
8931 !! end
8932
8933 !! test
8934 Interlanguage link, with prefix links
8935 !! options
8936 language=ln
8937 !! wikitext
8938 Blah blah blah
8939 [[zh:Chinese]]
8940 !! html/php
8941 <p>Blah blah blah
8942 </p>
8943 !! html/parsoid
8944 <p>Blah blah blah</p>
8945 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8946 !! end
8947
8948 !! test
8949 Double interlanguage link, with prefix links (T10897)
8950 !! options
8951 language=ln
8952 !! wikitext
8953 Blah blah blah
8954 [[es:Spanish]]
8955 [[zh:Chinese]]
8956 !! html/php
8957 <p>Blah blah blah
8958 </p>
8959 !! html/parsoid
8960 <p>Blah blah blah</p>
8961 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
8962 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8963 !! end
8964
8965 !! test
8966 "Extra" interlanguage links (T34189 / gerrit 111390)
8967 !! wikitext
8968 Blah blah blah
8969 [[mul:Article]]
8970 !! html/php
8971 <p>Blah blah blah
8972 </p>
8973 !! html/parsoid
8974 <p>Blah blah blah</p>
8975 <link rel="mw:PageProp/Language" title="Multilingual" href="http://wikisource.org/wiki/Article"/>
8976 !! end
8977
8978 ## PHP parser tests script needs an update
8979 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
8980 !! test
8981 Language links render as inline links if $wgInterwikiMagic=false
8982 !! options
8983 wgInterwikiMagic=false
8984 parsoid=wt2html,wt2wt,html2html
8985 !! wikitext
8986 Blah blah blah
8987 [[zh:Chinese]]
8988 !! html/parsoid
8989 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
8990 !! end
8991
8992 ## PHP parser tests script needs an update
8993 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
8994 !! test
8995 Language links render as inline links in the Talk namespace
8996 !! options
8997 title=Talk:Foo
8998 parsoid=wt2html,wt2wt,html2html
8999 !! wikitext
9000 Blah blah blah
9001 [[zh:Chinese]]
9002 !! html/parsoid
9003 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
9004 !! end
9005
9006 !! test
9007 Parsoid-specific test: Wikilinks with &nbsp; should RT properly
9008 !! options
9009 language=ln
9010 !! wikitext
9011 [[WW&nbsp;II]]
9012 !! html
9013 <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>
9014 </p>
9015 !! end
9016
9017 !! test
9018 Parsoid T55221: Wikilinks should be properly entity-escaped
9019 !! options
9020 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
9021 !! html/parsoid
9022 <p>He&amp;nbsp;llo <a href="./Foo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9023 <p>He&amp;nbsp;llo <a href="./He&amp;nbsp;llo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9024 !! wikitext
9025 He&amp;nbsp;llo [[Foo|He&amp;nbsp;llo]]
9026
9027 He&amp;nbsp;llo He&amp;nbsp;llo
9028 !! html/php
9029 <p>He&amp;nbsp;llo <a href="/wiki/Foo" title="Foo">He&amp;nbsp;llo</a>
9030 </p><p>He&amp;nbsp;llo He&amp;nbsp;llo
9031 </p>
9032 !! end
9033
9034 # html2wt will fail because of title normalization without data-parsoid
9035 !! test
9036 Parsoid: handle constructor well
9037 !! options
9038 parsoid=wt2html,wt2wt
9039 !! wikitext
9040 [[constructor]]
9041
9042 [[constructor:foo]]
9043 !! html/php
9044 <p><a href="/index.php?title=Constructor&amp;action=edit&amp;redlink=1" class="new" title="Constructor (page does not exist)">constructor</a>
9045 </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>
9046 </p>
9047 !! html/parsoid
9048 <p><a rel="mw:WikiLink" href="./Constructor" title="Constructor" data-parsoid='{"stx":"simple","a":{"href":"./Constructor"},"sa":{"href":"constructor"}}'>constructor</a></p>
9049
9050 <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>
9051 !! end
9052
9053 !! article
9054 ko:
9055 !! text
9056 Test.
9057 !! endarticle
9058
9059 # Note that `ko` isn't a known interlanguage prefix
9060 !! test
9061 Parsoid: recognize interlanguage links without a target page
9062 !! options
9063 ill
9064 !! wikitext
9065 [[es:]]
9066
9067 [[ko:]]
9068 !! html/php
9069 es:
9070 !! html/parsoid
9071 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/"/>
9072
9073 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9074 !! end
9075
9076 # Note that `ko` isn't a known interwiki prefix
9077 !! test
9078 Parsoid: recognize interwiki links without a target page
9079 !! options
9080 parsoid=wt2html,wt2wt,html2html
9081 !! wikitext
9082 [[:es:]]
9083
9084 [[:ko:]]
9085 !! html/php
9086 <p><a href="http://es.wikipedia.org/wiki/" class="extiw" title="es:">es:</a>
9087 </p><p><a href="/wiki/Ko:" title="Ko:">ko:</a>
9088 </p>
9089 !! html/parsoid
9090 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/" title="es:">es:</a></p>
9091 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9092 !! end
9093
9094 !! test
9095 Handle interwiki links pointing to the current wiki as plain wiki links (T47209)
9096 !! wikitext
9097 [[mi:Foo]]
9098 !! html/php
9099 <p><a href="/wiki/Foo" title="Foo">mi:Foo</a>
9100 </p>
9101 !! html/parsoid
9102 <p><a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo"},"sa":{"href":"mi:Foo"}}'>mi:Foo</a></p>
9103 !! end
9104
9105 !! test
9106 Interlanguage link with preceding local interwiki link (T70085)
9107 !! options
9108 parsoid=wt2html,wt2wt,html2html
9109 !! wikitext
9110 Blah blah blah
9111 [[local:es:Spanish]]
9112 !! html/php
9113 <p>Blah blah blah
9114 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">local:es:Spanish</a>
9115 </p>
9116 !! html/parsoid
9117 <p>Blah blah blah
9118 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">local:es:Spanish</a></p>
9119 !! end
9120
9121 !! test
9122 Looks like an interlanguage link, but is actually a local interwiki
9123 !! options
9124 parsoid=wt2html,wt2wt,html2html
9125 !! wikitext
9126 Blah blah blah
9127 [[mi:Template:Foo]]
9128 !! html/php
9129 <p>Blah blah blah
9130 <a href="/wiki/Template:Foo" title="Template:Foo">mi:Template:Foo</a>
9131 </p>
9132 !! html/parsoid
9133 <p>Blah blah blah
9134 <a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">mi:Template:Foo</a></p>
9135 !! end
9136
9137 ###
9138 ### Redirects, Parsoid-only
9139 ###
9140
9141 !! test
9142 1. Simple redirect to page
9143 !! wikitext
9144 #REDIRECT [[Main Page]]
9145 !! html/parsoid
9146 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9147 !! end
9148
9149 !! test
9150 2. Other redirect variants
9151 !! wikitext
9152 #REDIRECT [[Main_Page]]
9153 !! html/parsoid
9154 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Main_Page"},"sa":{"href":"Main_Page"}}'/>
9155 !! end
9156
9157 # Not a valid redirect in PHP (although perhaps it was, once upon a time)
9158 # This tests the Parsoid bail-out code.
9159 !! test
9160 3. Other redirect variants
9161 !! options
9162 parsoid=wt2html
9163 !! wikitext
9164 #REDIRECT [[<nowiki>[[Bar]]</nowiki>]]
9165 !! html/parsoid
9166 <ol><li>REDIRECT [[<span typeof="mw:Nowiki">[[Bar]]</span>]]</li></ol>
9167 !! end
9168
9169 !! test
9170 4. Redirect to a templated destination
9171 !! wikitext
9172 #REDIRECT [[{{echo|Foo}}bar]]
9173 !! html/parsoid
9174 <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"}]]}'/>
9175 !! end
9176
9177 !! test
9178 Empty redirect
9179 !! options
9180 parsoid=wt2html,wt2wt
9181 !! wikitext
9182 #REDIRECT [[]]
9183 !! html/parsoid
9184 <ol>
9185 <li>REDIRECT [[]]</li></ol>
9186 !! end
9187
9188 !! test
9189 Optional colon in #REDIRECT
9190 !! options
9191 # the colon is archaic syntax. we support it for wt2html, but we
9192 # don't care that it roundtrips back to the modern syntax.
9193 parsoid=wt2html,html2html
9194 !! wikitext
9195 #REDIRECT:[[Main Page]]
9196 !! html/parsoid
9197 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9198 !! end
9199
9200 !! test
9201 Whitespace in #REDIRECT with optional colon
9202 !! options
9203 # the colon and gratuitous whitespace is archaic syntax. we support
9204 # it for wt2html, but we don't care that it roundtrips back to the
9205 # modern syntax (without extra whitespace)
9206 parsoid=wt2html,html2html
9207 !! wikitext
9208
9209 #REDIRECT
9210 :
9211 [[Main Page]]
9212 !! html/parsoid
9213 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9214 !! end
9215
9216 !! test
9217 Piped link in #REDIRECT
9218 !! options
9219 # content after piped link is ignored. we support this syntax,
9220 # but don't care that the piped link is lost when we roundtrip this.
9221 parsoid=wt2html
9222 !! wikitext
9223 #REDIRECT [[Main Page|bar]]
9224 !! html/parsoid
9225 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9226 !! end
9227
9228 !! test
9229 Redirect to category (T104502)
9230 !! options
9231 parsoid=wt2html,wt2wt
9232 !! wikitext
9233 #REDIRECT [[Category:Foo]]
9234 !! html/parsoid
9235 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9236 !! end
9237
9238 !! test
9239 Redirect to category with URL encoding (T104502)
9240 !! options
9241 parsoid=wt2html
9242 !! wikitext
9243 #REDIRECT [[Category%3AFoo]]
9244 !! html/parsoid
9245 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9246 !! end
9247
9248 !! test
9249 Redirect to category page
9250 !! wikitext
9251 #REDIRECT [[:Category:Foo]]
9252 !! html/parsoid
9253 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9254 !! end
9255
9256 !! test
9257 Redirect to image page (1)
9258 !! wikitext
9259 #REDIRECT [[File:Wiki.png]]
9260 !! html/parsoid
9261 <link rel="mw:PageProp/redirect" href="./File:Wiki.png"/>
9262 !! end
9263
9264 !! test
9265 Redirect to image page (2)
9266 !! wikitext
9267 #REDIRECT [[Image:Wiki.png]]
9268 !! html/parsoid
9269 <link rel="mw:PageProp/redirect" href="./File:Wiki.png" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./File:Wiki.png"},"sa":{"href":"Image:Wiki.png"}}'/>
9270 !! end
9271
9272 # html2wt disabled because wts serializes as "#REDIRECT [[:en:File:Wiki.png]]"
9273 # Next test confirms this.
9274 !! test
9275 Redirect to language (1) (T104918)
9276 !! options
9277 parsoid=wt2html,wt2wt,html2html
9278 !! wikitext
9279 #REDIRECT [[en:File:Wiki.png]]
9280 !! html/parsoid
9281 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9282 !! end
9283
9284 !! test
9285 Redirect to language (2) (T104918)
9286 !! wikitext
9287 #REDIRECT [[:en:File:Wiki.png]]
9288 !! html/parsoid
9289 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9290 !! end
9291
9292 !! test
9293 Redirect to interwiki (T104918)
9294 !! wikitext
9295 #REDIRECT [[meatball:File:Wiki.png]]
9296 !! html/parsoid
9297 <link rel="mw:PageProp/redirect" href="http://www.usemod.com/cgi-bin/mb.pl?File:Wiki.png"/>
9298 !! end
9299
9300 !! test
9301 Non-English #REDIRECT
9302 !! options
9303 language=is
9304 !! wikitext
9305 #TILVÍSUN [[Main Page]]
9306 !! html/parsoid
9307 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#TILVÍSUN ","a":{"href":"./Main_Page"},"sa":{"href":"Main Page"}}'/>
9308 !! end
9309
9310 !! test
9311 Redirect syntax under text isn't considered a redirect
9312 !! wikitext
9313 some text
9314
9315 #redirect [[Main Page]]
9316 !! html/parsoid
9317 <p>some text</p>
9318 <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>
9319 !! end
9320
9321 !! test
9322 New redirect
9323 !! options
9324 parsoid=html2wt
9325 !! html/parsoid
9326 <p>Foo<link rel="mw:PageProp/redirect" href="./Foo"/></p>
9327 !! wikitext
9328 #REDIRECT [[Foo]]
9329 Foo
9330 !! end
9331
9332 !! test
9333 Redirect followed by block on the same line
9334 !! options
9335 parsoid=wt2html
9336 !! wikitext
9337 #REDIRECT [[Main Page]]<!-- haha -->==hi==
9338 !! html/parsoid
9339 <link rel="mw:PageProp/redirect" href="./Main_Page"/><!-- haha --><h2 id="hi">hi</h2>
9340 !! end
9341
9342 !! test
9343 Redirect followed by a newline
9344 !! wikitext
9345 #REDIRECT [[Main Page]]
9346 A newline
9347 !! html/parsoid
9348 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9349 <p>A newline</p>
9350 !! end
9351
9352 !! test
9353 Redirect followed by multiple newlines
9354 !! wikitext
9355 #REDIRECT [[Main Page]]
9356
9357
9358 A newline
9359 !! html/parsoid
9360 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9361
9362 <p><br/>
9363 A newline</p>
9364 !! end
9365
9366 !! test
9367 Drop duplicate redirects
9368 !! options
9369 parsoid=html2wt
9370 !! html/parsoid
9371 <link rel="mw:PageProp/redirect" href="./Foo"/>
9372 <link rel="mw:PageProp/redirect" href="./Bar"/>
9373 <link rel="mw:PageProp/redirect" href="./Baz"/>
9374 !! wikitext
9375 #REDIRECT [[Foo]]
9376 !! end
9377
9378 ##
9379 ## XHTML tidiness
9380 ###
9381
9382 !! test
9383 <br> to <br />
9384 !! wikitext
9385 1<br>2<br />3
9386 !! html
9387 <p>1<br />2<br />3
9388 </p>
9389 !! end
9390
9391 !! test
9392 Broken br tag sanitization
9393 !! wikitext
9394 </br>
9395 !! html/php
9396 <p>&lt;/br&gt;
9397 </p>
9398 !! end
9399
9400 # TODO: Fix html2html mode (T53055)!
9401 !! test
9402 Parsoid: Broken br tag recognition
9403 !! options
9404 parsoid=wt2html
9405 !! wikitext
9406 </br>
9407
9408 <br/ >
9409 !! html+tidy
9410 <p><br />
9411 </p><p><br />
9412 </p>
9413 !! end
9414
9415 !! test
9416 Incorrecly removing closing slashes from correctly formed XHTML
9417 !! wikitext
9418 <br style="clear:both;" />
9419 !! html
9420 <p><br style="clear:both;" />
9421 </p>
9422 !! end
9423
9424 !! test
9425 Failing to transform badly formed HTML into correct XHTML
9426 !! wikitext
9427 <br style="clear: left;">
9428 <br style="clear: right;">
9429 <br style="clear: both;">
9430 !! html
9431 <p><br style="clear: left;" />
9432 <br style="clear: right;" />
9433 <br style="clear: both;" />
9434 </p>
9435 !!end
9436
9437 ## FIXME: Is Parsoid's acceptance of self-closing html-tags
9438 ## a feature or a bug? See https://phabricator.wikimedia.org/T76962
9439 !! test
9440 Handling html with a div self-closing tag
9441 !! wikitext
9442 <div title />
9443 <div title/>
9444 <div title/ >
9445 <div title=bar />
9446 <div title=bar/>
9447 <div title=bar/ >
9448 !! html/php
9449 <p>&lt;div title /&gt;
9450 &lt;div title/&gt;
9451 </p>
9452 <div>
9453 <p>&lt;div title=bar /&gt;
9454 &lt;div title=bar/&gt;
9455 </p>
9456 <div title="bar/"></div>
9457 </div>
9458
9459 !! html/parsoid
9460 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9461 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9462 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9463 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9464 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9465 <div title="bar/" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></div>
9466 !! end
9467
9468 !! test
9469 Handling html with a br self-closing tag
9470 !! wikitext
9471 <br title />
9472 <br title/>
9473 <br title/ >
9474 <br title=bar />
9475 <br title=bar/>
9476 <br title=bar/ >
9477 !! html/php
9478 <p><br title="" />
9479 <br title="" />
9480 <br />
9481 <br title="bar" />
9482 <br title="bar" />
9483 <br title="bar/" />
9484 </p>
9485 !! html/parsoid
9486 <p><br title="" />
9487 <br title="" />
9488 <br title="" />
9489 <br title="bar" />
9490 <br title="bar" />
9491 <br title="bar/" />
9492 </p>
9493 !! end
9494
9495 !! test
9496 Horizontal ruler (should it add that extra space?)
9497 !! wikitext
9498 <hr>
9499 <hr >
9500 foo <hr
9501 > bar
9502 !! html+tidy
9503 <hr />
9504 <hr /><p>
9505 foo </p><hr /><p> bar
9506 </p>
9507 !! end
9508
9509 !! test
9510 Horizontal ruler -- 4+ dashes render hr
9511 !! wikitext
9512 ----
9513 !! html
9514 <hr />
9515
9516 !! end
9517
9518 !! test
9519 Horizontal ruler -- eats additional dashes on the same line
9520 !! wikitext
9521 ---------
9522 !! html
9523 <hr />
9524
9525 !! end
9526
9527 !! test
9528 Horizontal ruler -- does not collapse dashes on consecutive lines
9529 !! wikitext
9530 ----
9531 ----
9532 !! html
9533 <hr />
9534 <hr />
9535
9536 !! end
9537
9538 !! test
9539 Horizontal ruler -- <4 dashes render as plain text
9540 !! wikitext
9541 ---
9542 !! html
9543 <p>---
9544 </p>
9545 !! end
9546
9547 !! test
9548 Horizontal ruler -- Supports content following dashes on same line
9549 !! wikitext
9550 ---- Foo
9551 !! html
9552 <hr /> Foo
9553
9554 !! html+tidy
9555 <hr /><p> Foo
9556 </p>
9557 !! end
9558
9559 ###
9560 ### Block-level elements
9561 ###
9562 !! test
9563 Common list
9564 !! wikitext
9565 *Common list
9566 *item 2
9567 *item 3
9568 !! html
9569 <ul><li>Common list</li>
9570 <li>item 2</li>
9571 <li>item 3</li></ul>
9572
9573 !! end
9574
9575 !! test
9576 Numbered list
9577 !! wikitext
9578 #Numbered list
9579 #item 2
9580 #item 3
9581 !! html
9582 <ol><li>Numbered list</li>
9583 <li>item 2</li>
9584 <li>item 3</li></ol>
9585
9586 !! end
9587
9588 # the switch from level 3 to ordered should not introduce a newline between
9589 !! test
9590 Mixed list
9591 !! wikitext
9592 *Mixed list
9593 *#with numbers
9594 **and bullets
9595 *#and numbers
9596 *bullets again
9597 **bullet level 2
9598 ***bullet level 3
9599 ***#Number on level 4
9600 **bullet level 2
9601 **#Number on level 3
9602 **#Number on level 3
9603 *#number level 2
9604 *Level 1
9605 ***Level 3
9606 #**Level 3, but ordered
9607 !! html
9608 <ul><li>Mixed list
9609 <ol><li>with numbers</li></ol>
9610 <ul><li>and bullets</li></ul>
9611 <ol><li>and numbers</li></ol></li>
9612 <li>bullets again
9613 <ul><li>bullet level 2
9614 <ul><li>bullet level 3
9615 <ol><li>Number on level 4</li></ol></li></ul></li>
9616 <li>bullet level 2
9617 <ol><li>Number on level 3</li>
9618 <li>Number on level 3</li></ol></li></ul>
9619 <ol><li>number level 2</li></ol></li>
9620 <li>Level 1
9621 <ul><li><ul><li>Level 3</li></ul></li></ul></li></ul>
9622 <ol><li><ul><li><ul><li>Level 3, but ordered</li></ul></li></ul></li></ol>
9623
9624 !! end
9625
9626 !! test
9627 1. Nested mixed wikitext and html list
9628 !! wikitext
9629 *hi
9630 *<ul><li>ho</li></ul>
9631 *hi
9632 **ho
9633 !! html/php
9634 <ul><li>hi</li>
9635 <li><ul><li>ho</li></ul></li>
9636 <li>hi
9637 <ul><li>ho</li></ul></li></ul>
9638
9639 !! html/parsoid
9640 <ul><li>hi</li>
9641 <li><ul data-parsoid='{"stx":"html"}'><li data-parsoid='{"stx":"html"}'>ho</li></ul></li>
9642 <li>hi
9643 <ul><li>ho</li></ul></li></ul>
9644 !! end
9645
9646 !! test
9647 2. Nested mixed wikitext and html list (incompatible)
9648 !! wikitext
9649 ;hi
9650 :{{echo|<li>ho</li>}}
9651 !! html/php
9652 <dl><dt>hi</dt>
9653 <dd><li>ho</li></dd></dl>
9654
9655 !! html/parsoid
9656 <dl><dt>hi</dt>
9657 <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>
9658 !! end
9659
9660 !! test
9661 Nested lists 1
9662 !! wikitext
9663 *foo
9664 **bar
9665 !! html
9666 <ul><li>foo
9667 <ul><li>bar</li></ul></li></ul>
9668
9669 !! end
9670
9671 !! test
9672 Nested lists 2
9673 !! wikitext
9674 **foo
9675 *bar
9676 !! html
9677 <ul><li><ul><li>foo</li></ul></li>
9678 <li>bar</li></ul>
9679
9680 !! end
9681
9682 !! test
9683 Nested lists 3 (first element empty)
9684 !! wikitext
9685 *
9686 **bar
9687 !! html
9688 <ul><li>
9689 <ul><li>bar</li></ul></li></ul>
9690
9691 !! end
9692
9693 !! test
9694 Nested lists 4 (first element empty)
9695 !! wikitext
9696 **
9697 *bar
9698 !! html
9699 <ul><li><ul><li></li></ul></li>
9700 <li>bar</li></ul>
9701
9702 !! end
9703
9704 !! test
9705 Nested lists 5 (both elements empty)
9706 !! wikitext
9707 **
9708 *
9709 !! html
9710 <ul><li><ul><li></li></ul></li>
9711 <li></li></ul>
9712
9713 !! end
9714
9715 !! test
9716 Nested lists 6 (both elements empty)
9717 !! wikitext
9718 *
9719 **
9720 !! html
9721 <ul><li>
9722 <ul><li></li></ul></li></ul>
9723
9724 !! end
9725
9726 !! test
9727 Nested lists 7 (skip initial nesting levels)
9728 !! wikitext
9729 ***foo
9730 !! html
9731 <ul><li><ul><li><ul><li>foo</li></ul></li></ul></li></ul>
9732
9733 !! end
9734
9735 !! test
9736 Nested lists 8 (multiple nesting transitions)
9737 !! wikitext
9738 *foo
9739 ***bar
9740 **baz
9741 *boo
9742 !! html
9743 <ul><li>foo
9744 <ul><li><ul><li>bar</li></ul></li>
9745 <li>baz</li></ul></li>
9746 <li>boo</li></ul>
9747
9748 !! end
9749
9750 !! test
9751 Nested lists 9 (extension interaction)
9752 !! options
9753 parsoid
9754 !! wikitext
9755 *<references />
9756 !! html/parsoid
9757 <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>
9758 !! end
9759
9760 !! test
9761 1. Lists with start-of-line-transparent tokens before bullets: Comments
9762 !! wikitext
9763 *foo
9764 *<!--cmt-->bar
9765 <!--cmt-->*baz
9766 !! html
9767 <ul><li>foo</li>
9768 <li>bar</li>
9769 <li>baz</li></ul>
9770
9771 !! end
9772
9773 !! test
9774 2. Lists with start-of-line-transparent tokens before bullets: Template close
9775 !! wikitext
9776 *foo {{echo|bar
9777 }}*baz
9778 !! html
9779 <ul><li>foo bar</li>
9780 <li>baz</li></ul>
9781
9782 !! end
9783
9784 !! test
9785 List items are not parsed correctly following a <pre> block (T2785)
9786 !! wikitext
9787 *<pre>foo</pre>
9788 *<pre>bar</pre>
9789 *zar
9790 !! html/php
9791 <ul><li><pre>foo</pre></li>
9792 <li><pre>bar</pre></li>
9793 <li>zar</li></ul>
9794
9795 !! html/parsoid
9796 <ul><li><pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre></li>
9797 <li><pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"bar"}}'>bar</pre></li>
9798 <li>zar</li></ul>
9799 !! end
9800
9801 # FIXME: Might benefit from a html/parsoid since this has a template
9802 !! test
9803 List items from template
9804 !! wikitext
9805
9806 {{inner list}}
9807 *item 2
9808
9809 *item 0
9810 {{inner list}}
9811 *item 2
9812
9813 *item 0
9814 *notSOL{{inner list}}
9815 *item 2
9816 !! html
9817 <ul><li>item 1</li>
9818 <li>item 2</li></ul>
9819 <ul><li>item 0</li>
9820 <li>item 1</li>
9821 <li>item 2</li></ul>
9822 <ul><li>item 0</li>
9823 <li>notSOL</li>
9824 <li>item 1</li>
9825 <li>item 2</li></ul>
9826
9827 !! end
9828
9829 !! test
9830 List interrupted by empty line or heading
9831 !! wikitext
9832 *foo
9833
9834 **bar
9835 ==A heading==
9836 *Another list item
9837 !! html
9838 <ul><li>foo</li></ul>
9839 <ul><li><ul><li>bar</li></ul></li></ul>
9840 <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>
9841 <ul><li>Another list item</li></ul>
9842
9843 !!end
9844
9845 !!test
9846 Multiple list tags generated by templates
9847 !! wikitext
9848 {{echo|<li>}}a
9849 {{echo|<li>}}b
9850 {{echo|<li>}}c
9851 !! html
9852 <li>a
9853 <li>b
9854 <li>c</li>
9855 </li>
9856 </li>
9857
9858 !! html+tidy
9859 <li>a
9860 </li><li>b
9861 </li><li>c
9862 </li>
9863 !! html/parsoid
9864 <li about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","autoInsertedEnd":true,"dsr":[0,44,null,null],"pi":[[{"k":"1"}],[{"k":"1"}],[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;li>"}},"i":0}},"a\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;li>"}},"i":1}},"b\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;li>"}},"i":2}},"c"]}'>a
9865 </li><li about="#mwt1">b
9866 </li><li about="#mwt1" data-parsoid='{"stx":"html","autoInsertedEnd":true,"dsr":[null,44,null,0]}'>c</li>
9867 !!end
9868
9869 !!test
9870 Single-comment whitespace lines dont break lists, and neither do multi-comment whitespace lines
9871 !! wikitext
9872 *a
9873 <!--This line will NOT split the list-->
9874 *b
9875 <!--This line will NOT split the list either-->
9876 *c
9877 <!--foo--> <!----> <!--This line NOT split the list either-->
9878 *d
9879 !! html
9880 <ul><li>a</li>
9881 <li>b</li>
9882 <li>c</li>
9883 <li>d</li></ul>
9884
9885 !!end
9886
9887 !!test
9888 Replacing whitespace with tabs still doesn't break the list (gerrit 78327)
9889 !! wikitext
9890 *a
9891 <!--This line will NOT split the list-->
9892 *b
9893 <!--This line will NOT split the list either-->
9894 *c
9895 <!--foo--> <!----> <!--This line NOT split the list
9896 either-->
9897 *d
9898 !! html
9899 <ul><li>a</li>
9900 <li>b</li>
9901 <li>c</li>
9902 <li>d</li></ul>
9903
9904 !!end
9905
9906 # FIXME: Parsoid has a dedicated DOM pass to mimic this Tidy-specific li-hack
9907 # That pass could possibly be removed.
9908 !!test
9909 Test the li-hack (a hack from Tidy days, but doesn't work as advertised with Remex)
9910 !!options
9911 parsoid=wt2html,wt2wt
9912 !! wikitext
9913 *foo
9914 *<li>li-hack
9915 *{{echo|<li>templated li-hack}}
9916 *<!--foo--><li> unsupported li-hack with preceding comments
9917
9918 <ul>
9919 <li><li>not a li-hack
9920 </li>
9921 </ul>
9922 !! html+tidy
9923 <ul><li>foo</li>
9924 <li class="mw-empty-elt"></li><li>li-hack</li>
9925 <li class="mw-empty-elt"></li><li>templated li-hack</li>
9926 <li class="mw-empty-elt"></li><li> unsupported li-hack with preceding comments</li></ul>
9927 <ul>
9928 <li class="mw-empty-elt"></li><li>not a li-hack
9929 </li>
9930 </ul>
9931 !! html/parsoid
9932 <ul><li> foo</li>
9933 <li data-parsoid='{"stx":"html","autoInsertedEnd":true,"liHackSrc":"*"}'>li-hack</li>
9934 <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>
9935 <li data-parsoid='{"autoInsertedEnd":true}'><!--foo--></li><li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>unsupported li-hack with preceding comments</li></ul>
9936
9937 <ul data-parsoid='{"stx":"html"}'>
9938 <li class="mw-empty-elt" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></li><li data-parsoid='{"stx":"html"}'>not a li-hack
9939 </li>
9940 </ul>
9941
9942 !!end
9943
9944 !! test
9945 Parsoid: Make sure nested lists are serialized on their own line even if HTML contains no newlines
9946 !! options
9947 parsoid
9948 !! wikitext
9949 #foo
9950 ##bar
9951
9952 *foo
9953 **bar
9954
9955 :foo
9956 ::bar
9957 !! html
9958 <ol>
9959 <li>foo<ol>
9960 <li>bar</li>
9961 </ol></li>
9962 </ol><ul>
9963 <li>foo<ul>
9964 <li>bar</li>
9965 </ul></li>
9966 </ul><dl>
9967 <dd>foo<dl>
9968 <dd>bar</dd>
9969 </dl></dd>
9970 </dl>
9971 !! end
9972
9973 !! test
9974 Parsoid: Test of whitespace serialization with Templated bullets
9975 !! options
9976 parsoid
9977 !! wikitext
9978 * {{bullet}}
9979 !! html/parsoid
9980 <ul>
9981 <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>
9982 </ul>
9983 !! end
9984
9985 # ------------------------------------------------------------------------
9986 # The next set of tests are about Parsoid's ability to handle badly nested
9987 # tags (parse, minimize scope of fixup, and roundtrip back)
9988 # ------------------------------------------------------------------------
9989
9990 # Remex and Parsoid output stems from list handling diffs because Parsoid & PHP parser.
9991 # Parsoid's list handling is more aware of block structure.
9992 !! test
9993 Unbalanced closing block tags break a list
9994 !! wikitext
9995 <div>
9996 *a</div><div>
9997 *b</div>
9998 !! html+tidy
9999 <div>
10000 <ul><li>a</li></ul></div><div>
10001 <li>b</li></div>
10002 !! html/parsoid
10003 <div><ul>
10004 <li>a</li>
10005 </ul></div>
10006 <div><ul>
10007 <li>b</li>
10008 </ul></div>
10009 !! end
10010
10011 !! test
10012 Unbalanced closing non-block tags don't break a list
10013 !! wikitext
10014 <span>
10015 *a</span><span>
10016 *b</span>
10017 !! html/php+tidy
10018 <p><span>
10019 </span></p>
10020 <ul><li>a<span></span></li>
10021 <li>b</li></ul>
10022 !! html/parsoid
10023 <span>
10024 <ul>
10025 <li>a<span></span></li>
10026 <li>b</li>
10027 </ul>
10028 </span>
10029 !! end
10030
10031 # Parsoid does some post-dom-building cleanup
10032 # which is why its output differs from Remex.
10033 !! test
10034 Unclosed formatting tags that straddle lists are closed and reopened
10035 !! options
10036 parsoid=wt2html,wt2wt,html2html
10037 !! wikitext
10038 #<s> a
10039 #b </s>
10040 !! html/php+tidy
10041 <ol><li><s> a</s></li><s>
10042 </s><li><s>b </s></li></ol>
10043 !! html/parsoid
10044 <ol><li><s> a</s></li>
10045 <li><s>b </s></li></ol>
10046 !! end
10047
10048 # Output is ugly because of all the misnested tag fixups.
10049 # Remex is wrapping p-tags around empty elements.
10050 # Parsoid has special-case handling of this pattern of
10051 # wrapping lists in formatting tags.
10052 # FIXME: Should we remove this code from Parsoid? Or add
10053 # special support in Remex? If the latter, maybe just wait
10054 # for Parsoid to become the default parser.
10055 # See T70395.
10056 !!test
10057 1. List embedded in a formatting tag
10058 !! wikitext
10059 <small>
10060 *foo
10061 </small>
10062 !! html/php+tidy
10063 <p><small>
10064 </small></p><small><ul><li>foo</li></ul></small><small></small><p><small></small>
10065 </p>
10066 !! html/parsoid
10067 <small>
10068 <ul>
10069 <li>foo</li>
10070 </ul>
10071 </small>
10072 !!end
10073
10074 # Output is ugly because of all the misnested tag fixups
10075 # Remex is wrapping p-tags around empty elements.
10076 # Parsoid has code that strips useless p-tags.
10077 !!test
10078 2. List embedded in a formatting tag in a misnested way
10079 !! wikitext
10080 <small>
10081 *a
10082 *b</small>
10083 !! html/php+tidy
10084 <p><small>
10085 </small></p><small></small><ul><small><li>a</li>
10086 </small><li><small>b</small></li></ul>
10087 !! html/parsoid
10088 <small></small>
10089 <ul><small>
10090 <li>a</li>
10091 </small>
10092 <li><small>b</small></li>
10093 </ul>
10094 !!end
10095
10096 !! test
10097 Table with missing opening <tr> tag
10098 !! options
10099 parsoid=wt2html,wt2wt
10100 !! wikitext
10101 <table>
10102 <td>foo</td>
10103 </tr>
10104 </table>
10105 !! html+tidy
10106 <table>
10107 <tbody><tr><td>foo</td>
10108 </tr>
10109 </tbody></table>
10110 !! end
10111
10112 ###
10113 ### Magic Words
10114 ###
10115
10116 # Note that the current date is hard-coded as
10117 # 1970-01-01T00:02:03Z (a Thursday)
10118 # when running parser tests. The timezone is also fixed to GMT, so
10119 # local date will be identical to current date.
10120
10121 !! test
10122 Magic Word: {{CURRENTDAY}}
10123 !! wikitext
10124 {{CURRENTDAY}}
10125 !! html
10126 <p>1
10127 </p>
10128 !! end
10129
10130 !! test
10131 Magic Word: {{CURRENTDAY2}}
10132 !! wikitext
10133 {{CURRENTDAY2}}
10134 !! html
10135 <p>01
10136 </p>
10137 !! end
10138
10139 !! test
10140 Magic Word: {{CURRENTDAYNAME}}
10141 !! wikitext
10142 {{CURRENTDAYNAME}}
10143 !! html
10144 <p>Thursday
10145 </p>
10146 !! end
10147
10148 !! test
10149 Magic Word: {{CURRENTDOW}}
10150 !! wikitext
10151 {{CURRENTDOW}}
10152 !! html
10153 <p>4
10154 </p>
10155 !! end
10156
10157 !! test
10158 Magic Word: {{CURRENTMONTH}}
10159 !! wikitext
10160 {{CURRENTMONTH}}
10161 !! html
10162 <p>01
10163 </p>
10164 !! end
10165
10166 !! test
10167 Magic Word: {{CURRENTMONTH1}}
10168 !! wikitext
10169 {{CURRENTMONTH1}}
10170 !! html
10171 <p>1
10172 </p>
10173 !! end
10174
10175 !! test
10176 Magic Word: {{CURRENTMONTHABBREV}}
10177 !! wikitext
10178 {{CURRENTMONTHABBREV}}
10179 !! html
10180 <p>Jan
10181 </p>
10182 !! end
10183
10184 !! test
10185 Magic Word: {{CURRENTMONTHNAME}}
10186 !! wikitext
10187 {{CURRENTMONTHNAME}}
10188 !! html
10189 <p>January
10190 </p>
10191 !! end
10192
10193 !! test
10194 Magic Word: {{CURRENTMONTHNAMEGEN}}
10195 !! wikitext
10196 {{CURRENTMONTHNAMEGEN}}
10197 !! html
10198 <p>January
10199 </p>
10200 !! end
10201
10202 !! test
10203 Magic Word: {{CURRENTTIME}}
10204 !! wikitext
10205 {{CURRENTTIME}}
10206 !! html
10207 <p>00:02
10208 </p>
10209 !! end
10210
10211 !! test
10212 Magic Word: {{CURRENTHOUR}}
10213 !! wikitext
10214 {{CURRENTHOUR}}
10215 !! html
10216 <p>00
10217 </p>
10218 !! end
10219
10220 !! test
10221 Magic Word: {{CURRENTWEEK}} (T6594)
10222 !! wikitext
10223 {{CURRENTWEEK}}
10224 !! html
10225 <p>1
10226 </p>
10227 !! end
10228
10229 !! test
10230 Magic Word: {{CURRENTYEAR}}
10231 !! wikitext
10232 {{CURRENTYEAR}}
10233 !! html
10234 <p>1970
10235 </p>
10236 !! end
10237
10238 !! test
10239 Magic Word: {{CURRENTTIMESTAMP}}
10240 !! wikitext
10241 {{CURRENTTIMESTAMP}}
10242 !! html
10243 <p>19700101000203
10244 </p>
10245 !! end
10246
10247 !! test
10248 Magic Words LOCAL (UTC)
10249 !! wikitext
10250 *{{LOCALMONTH}}
10251 *{{LOCALMONTH1}}
10252 *{{LOCALMONTHNAME}}
10253 *{{LOCALMONTHNAMEGEN}}
10254 *{{LOCALMONTHABBREV}}
10255 *{{LOCALDAY}}
10256 *{{LOCALDAY2}}
10257 *{{LOCALDAYNAME}}
10258 *{{LOCALYEAR}}
10259 *{{LOCALTIME}}
10260 *{{LOCALHOUR}}
10261 *{{LOCALWEEK}}
10262 *{{LOCALDOW}}
10263 *{{LOCALTIMESTAMP}}
10264 !! html
10265 <ul><li>01</li>
10266 <li>1</li>
10267 <li>January</li>
10268 <li>January</li>
10269 <li>Jan</li>
10270 <li>1</li>
10271 <li>01</li>
10272 <li>Thursday</li>
10273 <li>1970</li>
10274 <li>00:02</li>
10275 <li>00</li>
10276 <li>1</li>
10277 <li>4</li>
10278 <li>19700101000203</li></ul>
10279
10280 !! end
10281
10282 !! test
10283 Magic Word: {{FULLPAGENAME}}
10284 !! options
10285 title=[[User:Ævar Arnfjörð Bjarmason]]
10286 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10287 !! wikitext
10288 {{FULLPAGENAME}}
10289 !! html/*
10290 <p>User:Ævar Arnfjörð Bjarmason
10291 </p>
10292 !! end
10293
10294 !! test
10295 Magic Word: {{FULLPAGENAMEE}}
10296 !! options
10297 title=[[User:Ævar Arnfjörð Bjarmason]]
10298 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10299 !! wikitext
10300 {{FULLPAGENAMEE}}
10301 !! html/*
10302 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10303 </p>
10304 !! end
10305
10306 !! test
10307 Magic Word: {{TALKSPACE}}
10308 !! options
10309 title=[[User:Ævar Arnfjörð Bjarmason]]
10310 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10311 !! wikitext
10312 {{TALKSPACE}}
10313 !! html/*
10314 <p>User talk
10315 </p>
10316 !! end
10317
10318 !! test
10319 Magic Word: {{TALKSPACE}}, same namespace
10320 !! options
10321 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10322 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10323 !! wikitext
10324 {{TALKSPACE}}
10325 !! html/*
10326 <p>User talk
10327 </p>
10328 !! end
10329
10330 !! test
10331 Magic Word: {{TALKSPACE}}, main namespace
10332 !! options
10333 title=[[Parser Test]]
10334 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10335 !! wikitext
10336 {{TALKSPACE}}
10337 !! html/*
10338 <p>Talk
10339 </p>
10340 !! end
10341
10342 !! test
10343 Magic Word: {{TALKSPACEE}}
10344 !! options
10345 title=[[User:Ævar Arnfjörð Bjarmason]]
10346 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10347 !! wikitext
10348 {{TALKSPACEE}}
10349 !! html/*
10350 <p>User_talk
10351 </p>
10352 !! end
10353
10354 !! test
10355 Magic Word: {{SUBJECTSPACE}}
10356 !! options
10357 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10358 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10359 !! wikitext
10360 {{SUBJECTSPACE}}
10361 !! html/*
10362 <p>User
10363 </p>
10364 !! end
10365
10366 !! test
10367 Magic Word: {{SUBJECTSPACE}}, same namespace
10368 !! options
10369 title=[[User:Ævar Arnfjörð Bjarmason]]
10370 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10371 !! wikitext
10372 {{SUBJECTSPACE}}
10373 !! html/*
10374 <p>User
10375 </p>
10376 !! end
10377
10378 !! test
10379 Magic Word: {{SUBJECTSPACE}}, main namespace
10380 !! options
10381 title=[[Parser Test]]
10382 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10383 !! wikitext
10384 {{SUBJECTSPACE}}
10385 !! html/*
10386
10387 !! end
10388
10389 !! test
10390 Magic Word: {{SUBJECTSPACEE}}
10391 !! options
10392 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10393 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10394 !! wikitext
10395 {{SUBJECTSPACEE}}
10396 !! html/*
10397 <p>User
10398 </p>
10399 !! end
10400
10401 !! test
10402 Magic Word: {{NAMESPACE}}
10403 !! options
10404 title=[[User:Ævar Arnfjörð Bjarmason]]
10405 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10406 !! wikitext
10407 {{NAMESPACE}}
10408 !! html/*
10409 <p>User
10410 </p>
10411 !! end
10412
10413 !! test
10414 Magic Word: {{NAMESPACEE}}
10415 !! options
10416 title=[[User:Ævar Arnfjörð Bjarmason]]
10417 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10418 !! wikitext
10419 {{NAMESPACEE}}
10420 !! html/*
10421 <p>User
10422 </p>
10423 !! end
10424
10425 !! test
10426 Magic Word: {{NAMESPACENUMBER}}
10427 !! options
10428 title=[[User:Ævar Arnfjörð Bjarmason]]
10429 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10430 !! wikitext
10431 {{NAMESPACENUMBER}}
10432 !! html/*
10433 <p>2
10434 </p>
10435 !! end
10436
10437 !! test
10438 Magic Word: {{SUBPAGENAME}}
10439 !! options
10440 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10441 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10442 !! wikitext
10443 {{SUBPAGENAME}}
10444 !! html/*
10445 <p>sub ö
10446 </p>
10447 !! end
10448
10449 !! test
10450 Magic Word: {{SUBPAGENAMEE}}
10451 !! options
10452 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10453 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10454 !! wikitext
10455 {{SUBPAGENAMEE}}
10456 !! html/*
10457 <p>sub_%C3%B6
10458 </p>
10459 !! end
10460
10461 !! test
10462 Magic Word: {{ROOTPAGENAME}}
10463 !! options
10464 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10465 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10466 !! wikitext
10467 {{ROOTPAGENAME}}
10468 !! html/*
10469 <p>Ævar Arnfjörð Bjarmason
10470 </p>
10471 !! end
10472
10473 !! test
10474 Magic Word: {{ROOTPAGENAMEE}}
10475 !! options
10476 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10477 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10478 !! wikitext
10479 {{ROOTPAGENAMEE}}
10480 !! html/*
10481 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10482 </p>
10483 !! end
10484
10485 !! test
10486 Magic Word: {{BASEPAGENAME}}
10487 !! options
10488 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10489 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10490 !! wikitext
10491 {{BASEPAGENAME}}
10492 !! html/*
10493 <p>Ævar Arnfjörð Bjarmason
10494 </p>
10495 !! end
10496
10497 !! test
10498 Magic Word: {{BASEPAGENAMEE}}
10499 !! options
10500 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10501 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10502 !! wikitext
10503 {{BASEPAGENAMEE}}
10504 !! html/*
10505 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10506 </p>
10507 !! end
10508
10509 !! test
10510 Magic Word: {{TALKPAGENAME}}
10511 !! options
10512 title=[[User:Ævar Arnfjörð Bjarmason]]
10513 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10514 !! wikitext
10515 {{TALKPAGENAME}}
10516 !! html/*
10517 <p>User talk:Ævar Arnfjörð Bjarmason
10518 </p>
10519 !! end
10520
10521 !! test
10522 Magic Word: {{TALKPAGENAMEE}}
10523 !! options
10524 title=[[User:Ævar Arnfjörð Bjarmason]]
10525 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10526 !! wikitext
10527 {{TALKPAGENAMEE}}
10528 !! html/*
10529 <p>User_talk:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10530 </p>
10531 !! end
10532
10533 !! test
10534 Magic Word: {{SUBJECTPAGENAME}}
10535 !! options
10536 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10537 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10538 !! wikitext
10539 {{SUBJECTPAGENAME}}
10540 !! html/*
10541 <p>User:Ævar Arnfjörð Bjarmason
10542 </p>
10543 !! end
10544
10545 !! test
10546 Magic Word: {{SUBJECTPAGENAMEE}}
10547 !! options
10548 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10549 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10550 !! wikitext
10551 {{SUBJECTPAGENAMEE}}
10552 !! html/*
10553 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10554 </p>
10555 !! end
10556
10557 !! test
10558 Magic Word: {{NUMBEROFFILES}}
10559 !! options
10560 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10561 !! wikitext
10562 {{NUMBEROFFILES}}
10563 !! html/*
10564 <p>7
10565 </p>
10566 !! end
10567
10568 !! test
10569 Magic Word: {{PAGENAME}}
10570 !! options
10571 title=[[User:Ævar Arnfjörð Bjarmason]]
10572 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10573 !! wikitext
10574 {{PAGENAME}}
10575 !! html/*
10576 <p>Ævar Arnfjörð Bjarmason
10577 </p>
10578 !! end
10579
10580 !! test
10581 Magic Word: {{PAGENAME}} with metacharacters
10582 !! options
10583 title=[['foo & bar = baz']]
10584 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10585 !! wikitext
10586 ''{{PAGENAME}}''
10587 !! html+tidy
10588 <p><i>&#39;foo &#38; bar &#61; baz&#39;</i>
10589 </p>
10590 !! end
10591
10592 !! test
10593 Magic Word: {{PAGENAME}} with metacharacters (T28781)
10594 !! options
10595 title=[[*RFC 1234 http://example.com/]]
10596 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10597 !! wikitext
10598 {{PAGENAME}}
10599 !! html+tidy
10600 <p>&#42;RFC&#32;1234 http&#58;//example.com/
10601 </p>
10602 !! end
10603
10604 !! test
10605 Magic Word: {{PAGENAMEE}}
10606 !! options
10607 title=[[User:Ævar Arnfjörð Bjarmason]]
10608 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10609 !! wikitext
10610 {{PAGENAMEE}}
10611 !! html/*
10612 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10613 </p>
10614 !! end
10615
10616 !! test
10617 Magic Word: {{PAGENAMEE}} with metacharacters (T28781)
10618 !! options
10619 title=[[*RFC 1234 http://example.com/]]
10620 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10621 !! wikitext
10622 {{PAGENAMEE}}
10623 !! html+tidy
10624 <p>&#42;RFC_1234_http&#58;//example.com/
10625 </p>
10626 !! end
10627
10628 !! test
10629 Magic Word: {{REVISIONID}}
10630 !! options
10631 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10632 showflags
10633 !! wikitext
10634 {{REVISIONID}}
10635 !! html/*
10636 <p>1337
10637 </p>
10638 flags=vary-revision-id
10639 !! end
10640
10641 !! test
10642 Magic Word: {{SCRIPTPATH}}
10643 !! options
10644 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10645 !! wikitext
10646 {{SCRIPTPATH}}
10647 !! html/*
10648
10649 !! end
10650
10651 !! test
10652 Magic Word: {{STYLEPATH}}
10653 !! options
10654 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10655 !! wikitext
10656 {{STYLEPATH}}
10657 !! html/*
10658 <p>/skins
10659 </p>
10660 !! end
10661
10662 !! test
10663 Magic Word: {{SERVER}}
10664 !! options
10665 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10666 !! wikitext
10667 {{SERVER}}
10668 !! html/*
10669 <p><a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10670 </p>
10671 !! end
10672
10673 !! test
10674 Magic Word: {{SERVERNAME}}
10675 !! options
10676 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10677 !! wikitext
10678 {{SERVERNAME}}
10679 !! html/*
10680 <p>example.org
10681 </p>
10682 !! end
10683
10684 !! test
10685 Magic Word: {{SITENAME}}
10686 !! options
10687 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10688 !! wikitext
10689 {{SITENAME}}
10690 !! html/*
10691 <p>MediaWiki
10692 </p>
10693 !! end
10694
10695 !! test
10696 Magic Word: {{PAGELANGUAGE}}
10697 !! options
10698 language=fr
10699 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10700 !! wikitext
10701 {{PAGELANGUAGE}}
10702 !! html/*
10703 <p>fr
10704 </p>
10705 !! end
10706
10707 !! test
10708 Magic Word: {{PAGELANGUAGE}} on a page with no explicitly set language
10709 !! options
10710 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10711 !! wikitext
10712 {{PAGELANGUAGE}}
10713 !! html/*
10714 <p>en
10715 </p>
10716 !! end
10717
10718 !! test
10719 Case-sensitive magic words, when cased differently, should just be template transclusions
10720 !! wikitext
10721 {{CurrentMonth}}
10722 {{currentday}}
10723 {{cURreNTweEK}}
10724 {{currentHour}}
10725 !! html
10726 <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>
10727 <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>
10728 <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>
10729 <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>
10730 </p>
10731 !! end
10732
10733 !! test
10734 Case-insensitive magic words should still work with weird casing.
10735 !! wikitext
10736 {{sErVeRNaMe}}
10737 {{LCFirst:AOEU}}
10738 {{ucFIRST:aoeu}}
10739 {{SERver}}
10740 !! html
10741 <p>example.org
10742 aOEU
10743 Aoeu
10744 <a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10745 </p>
10746 !! end
10747
10748 # From plwiki:PLOS_ONE
10749 !! test
10750 Parsoid: Page property magic word with magic word contents
10751 !! wikitext
10752 {{DISPLAYTITLE:''{{PAGENAME}}''}}
10753 !! html/parsoid
10754 <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>"}]]}'/>
10755 !! end
10756
10757 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
10758 # But, this is a limitation of our representation and is documented in
10759 # TemplateHandler.js in processSpecialMagicWord
10760 !! test
10761 Parsoid: Template-generated DISPLAYTITLE
10762 !! wikitext
10763 {{{{echo|DISPLAYTITLE}}:Foo}}
10764 !! options
10765 showtitle
10766 !! config
10767 wgAllowDisplayTitle=true
10768 wgRestrictDisplayTitle=false
10769 !! html/php
10770 Foo
10771
10772 !! html/parsoid
10773 <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"}]]}'/>
10774 !! end
10775
10776 !! test
10777 Namespace 1 {{ns:1}}
10778 !! wikitext
10779 {{ns:1}}
10780 !! html
10781 <p>Talk
10782 </p>
10783 !! end
10784
10785 !! test
10786 Namespace 1 {{ns:01}}
10787 !! wikitext
10788 {{ns:01}}
10789 !! html
10790 <p>Talk
10791 </p>
10792 !! end
10793
10794 !! test
10795 Namespace 0 {{ns:0}} (T6783)
10796 !! wikitext
10797 {{ns:0}}
10798 !! html
10799
10800 !! end
10801
10802 !! test
10803 Namespace 0 {{ns:00}} (T6783)
10804 !! wikitext
10805 {{ns:00}}
10806 !! html
10807
10808 !! end
10809
10810 !! test
10811 Namespace -1 {{ns:-1}}
10812 !! wikitext
10813 {{ns:-1}}
10814 !! html
10815 <p>Special
10816 </p>
10817 !! end
10818
10819 !! test
10820 Namespace User {{ns:User}}
10821 !! wikitext
10822 {{ns:User}}
10823 !! html
10824 <p>User
10825 </p>
10826 !! end
10827
10828 !! test
10829 Namespace User talk {{ns:User_talk}}
10830 !! wikitext
10831 {{ns:User_talk}}
10832 !! html
10833 <p>User talk
10834 </p>
10835 !! end
10836
10837 !! test
10838 Namespace User talk {{ns:uSeR tAlK}}
10839 !! wikitext
10840 {{ns:uSeR tAlK}}
10841 !! html
10842 <p>User talk
10843 </p>
10844 !! end
10845
10846 !! test
10847 Namespace File {{ns:File}}
10848 !! wikitext
10849 {{ns:File}}
10850 !! html
10851 <p>File
10852 </p>
10853 !! end
10854
10855 !! test
10856 Namespace File {{ns:Image}}
10857 !! wikitext
10858 {{ns:Image}}
10859 !! html
10860 <p>File
10861 </p>
10862 !! end
10863
10864 !! test
10865 Namespace (lang=de) Benutzer {{ns:User}}
10866 !! options
10867 language=de
10868 !! wikitext
10869 {{ns:User}}
10870 !! html
10871 <p>Benutzer
10872 </p>
10873 !! end
10874
10875 !! test
10876 Namespace (lang=de) Benutzer Diskussion {{ns:3}}
10877 !! options
10878 language=de
10879 !! wikitext
10880 {{ns:3}}
10881 !! html
10882 <p>Benutzer Diskussion
10883 </p>
10884 !! end
10885
10886 !! test
10887 Urlencode
10888 !! wikitext
10889 {{urlencode:hi world?!}}
10890 {{urlencode:hi world?!|WIKI}}
10891 {{urlencode:hi world?!|PATH}}
10892 {{urlencode:hi world?!|QUERY}}
10893 !! html/php
10894 <p>hi+world%3F%21
10895 hi_world%3F!
10896 hi%20world%3F%21
10897 hi+world%3F%21
10898 </p>
10899 !! end
10900
10901 !! test
10902 Magic Word: prioritize type info over data-parsoid
10903 !! options
10904 parsoid=html2wt
10905 !! html/parsoid
10906 <meta property="mw:PageProp/forcetoc" data-parsoid='{"magicSrc":"__NOTOC__"}'/>
10907 !! wikitext
10908 __FORCETOC__
10909 !! end
10910
10911 !! test
10912 Magic Word: serialize on separate line (parsoid)
10913 !! options
10914 parsoid=wt2wt,html2wt
10915 !! wikitext
10916 foo
10917 __NOTOC__
10918 bar
10919 !! html/parsoid
10920 foo<meta property="mw:PageProp/notoc"/>bar
10921 !! end
10922
10923 !! test
10924 Magic Word: rt non-english wikis
10925 !! options
10926 parsoid=wt2wt
10927 language=de
10928 !! wikitext
10929 __NOEDITSECTION__
10930 !! html/parsoid
10931 <meta property="mw:PageProp/noeditsection" data-parsoid='{"magicSrc":"__NOEDITSECTION__"}'/>
10932 !! end
10933
10934 !!test
10935 __proto__ is treated as normal wikitext (T105997)
10936 !!wikitext
10937 __proto__
10938 !!html
10939 <p>__proto__
10940 </p>
10941 !!end
10942
10943 ###
10944 ### Magic links
10945 ###
10946 !! test
10947 Magic links: internal link to RFC (T2479)
10948 !! wikitext
10949 [[RFC 123]]
10950 !! html/php
10951 <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>
10952 </p>
10953 !! html/parsoid
10954 <p><a rel="mw:WikiLink" href="./RFC_123" title="RFC 123">RFC 123</a></p>
10955 !! end
10956
10957 !! test
10958 Magic links: RFC (T2479)
10959 !! wikitext
10960 RFC 822
10961 !! html/php
10962 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
10963 </p>
10964 !! html/parsoid
10965 <p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external text">RFC 822</a></p>
10966 !! end
10967
10968 !! test
10969 Magic links: RFC (T67278)
10970 !! wikitext
10971 This is RFC 822 but thisRFC 822 is not RFC 822linked.
10972 !! html/php
10973 <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.
10974 </p>
10975 !! html/parsoid
10976 <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>
10977 !! end
10978
10979 !! test
10980 Magic links: RFC (w/ non-newline whitespace, T30950/T31025)
10981 !! wikitext
10982 RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 822
10983 RFC
10984 822
10985 !! html/php
10986 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
10987 RFC
10988 822
10989 </p>
10990 !! html/parsoid
10991 <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>
10992 RFC
10993 822</p>
10994 !! end
10995
10996 !! test
10997 Magic links: ISBN (T3937)
10998 !! wikitext
10999 ISBN 0-306-40615-2
11000 !! html/php
11001 <p><a href="/wiki/Special:BookSources/0306406152" class="internal mw-magiclink-isbn">ISBN 0-306-40615-2</a>
11002 </p>
11003 !! html/parsoid
11004 <p><a href="./Special:BookSources/0306406152" rel="mw:WikiLink">ISBN 0-306-40615-2</a></p>
11005 !! end
11006
11007 !! test
11008 Magic links: ISBN (T67278)
11009 !! wikitext
11010 This is ISBN 978-0-316-09811-3 but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.
11011 !! html/php
11012 <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.
11013 </p>
11014 !! html/parsoid
11015 <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>
11016 !! end
11017
11018 !! test
11019 Magic links: ISBN (w/ non-newline whitespace, T30950/T31025)
11020 !! wikitext
11021 ISBN &nbsp;&#160;&#0160;&#xA0;&#Xa0; 978&nbsp;0&#160;316&#0160;09811&#xA0;3
11022 ISBN
11023 9780316098113
11024 ISBN 978
11025 0316098113
11026 !! html/php
11027 <p><a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978 0 316 09811 3</a>
11028 ISBN
11029 9780316098113
11030 ISBN 978
11031 0316098113
11032 </p>
11033 !! html/parsoid
11034 <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>
11035 ISBN
11036 9780316098113
11037 ISBN 978
11038 0316098113</p>
11039 !! end
11040
11041 !! test
11042 Magic links: PMID incorrectly converts space to underscore
11043 !! wikitext
11044 PMID 1234
11045 !! html/php
11046 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11047 </p>
11048 !! html/parsoid
11049 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external text">PMID 1234</a></p>
11050 !! end
11051
11052 !! test
11053 Magic links: PMID (T67278)
11054 !! wikitext
11055 This is PMID 1234 but thisPMID 1234 is not PMID 1234linked.
11056 !! html/php
11057 <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.
11058 </p>
11059 !! html/parsoid
11060 <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>
11061 !! end
11062
11063 !! test
11064 Magic links: PMID (w/ non-newline whitespace, T30950/T31025)
11065 !! wikitext
11066 PMID &nbsp;&#160;&#0160;&#xA0;&#Xa0; 1234
11067 PMID
11068 1234
11069 !! html/php
11070 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11071 PMID
11072 1234
11073 </p>
11074 !! html/parsoid
11075 <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>
11076 PMID
11077 1234</p>
11078 !! end
11079
11080 # <nowiki> nodes shouldn't be inserted during html2wt by Parsoid,
11081 # since these are ExtLinkText, not MagicLinkText
11082 !! test
11083 Magic links: use appropriate serialization for "almost" magic links.
11084 !! wikitext
11085 X[[Special:BookSources/0978739256|foo]]
11086
11087 X[https://tools.ietf.org/html/rfc1234 foo]
11088 !! html/php
11089 <p>X<a href="/wiki/Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a>
11090 </p><p>X<a rel="nofollow" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a>
11091 </p>
11092 !! html/parsoid
11093 <p>X<a rel="mw:WikiLink" href="./Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a></p>
11094 <p>X<a rel="mw:ExtLink" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a></p>
11095 !! end
11096
11097 !! test
11098 Magic links: All disabled (T47942)
11099 !! options
11100 wgEnableMagicLinks={"ISBN":false, "PMID":false, "RFC":false}
11101 !! wikitext
11102 ISBN 0-306-40615-2
11103 PMID 1234
11104 RFC 4321
11105 !! html/php
11106 <p>ISBN 0-306-40615-2
11107 PMID 1234
11108 RFC 4321
11109 </p>
11110 !! end
11111
11112 ###
11113 ### Templates
11114 ####
11115
11116 !! test
11117 Nonexistent template
11118 !! wikitext
11119 {{thistemplatedoesnotexist}}
11120 !! html
11121 <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>
11122 </p>
11123 !! end
11124
11125 !! test
11126 Template with invalid target containing tags
11127 !! wikitext
11128 {{a<b>b</b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11129 !! html
11130 <p>{{a<b>b</b>|foo|a=b|a = b}}
11131 </p>
11132 !! end
11133
11134 !! test
11135 Template with invalid target containing unclosed tag
11136 !! wikitext
11137 {{a<b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11138 !! html
11139 <p>{{a<b>|foo|a=b|a = b}}</b>
11140 </p>
11141 !! end
11142
11143 !! test
11144 Template with invalid target containing wikilink
11145 !! wikitext
11146 {{[[Main Page]]}}
11147 !! html/php
11148 <p>{{<a href="/wiki/Main_Page" title="Main Page">Main Page</a>}}
11149 </p>
11150 !! html/parsoid
11151 <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>
11152 !! end
11153
11154 !! test
11155 Template with just whitespace in it, T70421
11156 !! wikitext
11157 {{echo|{{ }}}}
11158 !! html/parsoid
11159 <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>
11160 !! end
11161
11162 !! article
11163 Template:test
11164 !! text
11165 This is a test template
11166 !! endarticle
11167
11168 !! test
11169 Simple template
11170 !! wikitext
11171 {{test}}
11172 !! html
11173 <p>This is a test template
11174 </p>
11175 !! end
11176
11177 !! test
11178 Template with explicit namespace
11179 !! wikitext
11180 {{Template:test}}
11181 !! html
11182 <p>This is a test template
11183 </p>
11184 !! end
11185
11186
11187 !! article
11188 Template:paramtest
11189 !! text
11190 This is a test template with parameter {{{param}}}
11191 !! endarticle
11192
11193 !! test
11194 Template parameter
11195 !! wikitext
11196 {{paramtest|param=foo}}
11197 !! html
11198 <p>This is a test template with parameter foo
11199 </p>
11200 !! end
11201
11202 !! article
11203 Template:paramtestnum
11204 !! text
11205 [[{{{1}}}|{{{2}}}]]
11206 !! endarticle
11207
11208 !! test
11209 Template unnamed parameter
11210 !! wikitext
11211 {{paramtestnum|Main Page|the main page}}
11212 !! html
11213 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
11214 </p>
11215 !! end
11216
11217 !! article
11218 Template:templatesimple
11219 !! text
11220 (test)
11221 !! endarticle
11222
11223 !! article
11224 Template:templateredirect
11225 !! text
11226 #redirect [[Template:templatesimple]]
11227 !! endarticle
11228
11229 !! article
11230 Template:templateasargtestnum
11231 !! text
11232 {{{{{1}}}}}
11233 !! endarticle
11234
11235 !! article
11236 Template:templateasargtest
11237 !! text
11238 {{template{{{templ}}}}}
11239 !! endarticle
11240
11241 !! article
11242 Template:templateasargtest2
11243 !! text
11244 {{{{{templ}}}}}
11245 !! endarticle
11246
11247 !! test
11248 Template with template name as unnamed argument
11249 !! wikitext
11250 {{templateasargtestnum|templatesimple}}
11251 !! html
11252 <p>(test)
11253 </p>
11254 !! end
11255
11256 !! test
11257 Template with template name as argument
11258 !! wikitext
11259 {{templateasargtest|templ=simple}}
11260 !! html
11261 <p>(test)
11262 </p>
11263 !! end
11264
11265 !! test
11266 Template with template name as argument (2)
11267 !! wikitext
11268 {{templateasargtest2|templ=templatesimple}}
11269 !! html
11270 <p>(test)
11271 </p>
11272 !! end
11273
11274 !! article
11275 Template:templateasargtestdefault
11276 !! text
11277 {{{{{templ|templatesimple}}}}}
11278 !! endarticle
11279
11280 !! article
11281 Template:templa
11282 !! text
11283 '''templ'''
11284 !! endarticle
11285
11286 !! test
11287 Template with default value
11288 !! wikitext
11289 {{templateasargtestdefault}}
11290 !! html
11291 <p>(test)
11292 </p>
11293 !! end
11294
11295 !! test
11296 Template with default value (value set)
11297 !! wikitext
11298 {{templateasargtestdefault|templ=templa}}
11299 !! html
11300 <p><b>templ</b>
11301 </p>
11302 !! end
11303
11304 !! test
11305 Template redirect
11306 !! wikitext
11307 {{templateredirect}}
11308 !! html/php
11309 <p>(test)
11310 </p>
11311 !! html/parsoid
11312 <link rel="mw:PageProp/redirect" href="./Template:Templatesimple" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"templateredirect","href":"./Template:Templateredirect"},"params":{},"i":0}}]}'/>
11313 !! end
11314
11315 !! test
11316 Template with argument in separate line
11317 !! wikitext
11318 {{ templateasargtest |
11319 templ = simple }}
11320 !! html
11321 <p>(test)
11322 </p>
11323 !! end
11324
11325 !! test
11326 Template with complex template as argument
11327 !! wikitext
11328 {{paramtest|
11329 param ={{ templateasargtest |
11330 templ = simple }}}}
11331 !! html
11332 <p>This is a test template with parameter (test)
11333 </p>
11334 !! end
11335
11336 !! test
11337 Templates with templated name
11338 !! wikitext
11339 {{{{echo|echo}}|foo}}
11340 {{{{echo|inner list}} }}
11341 !! html
11342 <p>foo
11343 </p>
11344 <ul><li>item 1</li></ul>
11345
11346 !! html/parsoid
11347 <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>
11348 <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>
11349 !! end
11350
11351 ## Regression test; the output here isn't really that interesting.
11352 !! test
11353 Templates with templated name and top level template args
11354 !! wikitext
11355 {{1{{2{{{3}}}|4=5}}}}
11356 !! html/parsoid
11357 <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>
11358 !! end
11359
11360 # Parsoid markup is deliberate "broken". This is an edge case.
11361 # See long comment in TemplateHandler.js:convertAttribsToString.
11362 !! test
11363 Templates with invalid templated targets
11364 !! wikitext
11365 {{echo
11366 {{echo|foo}}
11367 }}
11368 !! html/php
11369 <p>{{echo
11370 foo
11371 }}
11372 </p>
11373 !! html/parsoid
11374 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n{{echo|foo}}\n"},"params":{},"i":0}}]}'>{{echo
11375 foo }}</p>
11376 !! end
11377
11378 !! test
11379 Template with thumb image (with link in description)
11380 !! wikitext
11381 {{paramtest|param=[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
11382 !! html/php
11383 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>
11384
11385 !! html+tidy
11386 <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>
11387 !! html/parsoid
11388 <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>
11389 !! end
11390
11391 !! article
11392 Template:complextemplate
11393 !! text
11394 {{{1}}} {{paramtest|
11395 param ={{{param}}}}}
11396 !! endarticle
11397
11398 !! test
11399 Template with complex arguments
11400 !! wikitext
11401 {{complextemplate|
11402 param ={{ templateasargtest |
11403 templ = simple }}|[[Template:complextemplate|link]]}}
11404 !! html
11405 <p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test)
11406 </p>
11407 !! end
11408
11409 !! test
11410 T2553: link with two variables in a piped link
11411 !! wikitext
11412 {|
11413 |[[{{{1}}}|{{{2}}}]]
11414 |}
11415 !! html/php
11416 <table>
11417 <tr>
11418 <td>[[{{{1}}}|{{{2}}}]]
11419 </td></tr></table>
11420
11421 !! html/parsoid
11422 <table>
11423 <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>
11424 </tbody></table>
11425 !! end
11426
11427 # See: T2553
11428 !! test
11429 Abort table cell attribute parsing on wikilink
11430 !! wikitext
11431 {|
11432 |testing [[one|two]] |three||four
11433 |testing one two |three||four
11434 |testing="[[one|two]]" |three||four
11435 |}
11436 !! html/php
11437 <table>
11438 <tr>
11439 <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>
11440 <td>four
11441 </td>
11442 <td>three</td>
11443 <td>four
11444 </td>
11445 <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>
11446 <td>four
11447 </td></tr></table>
11448
11449 !! html/parsoid
11450 <table>
11451 <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>
11452 <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>
11453 <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>
11454 </tbody></table>
11455 !! end
11456
11457 !! test
11458 Don't abort table cell attribute parsing if wikilink is found in template arg
11459 !! wikitext
11460 {|
11461 |Test {{#tag:ref|One two "[[three]]" four}}
11462 |}
11463 !! html/parsoid
11464 <table>
11465 <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>
11466 </tbody></table>
11467 !! end
11468
11469 !! test
11470 Magic variable as template parameter
11471 !! wikitext
11472 {{paramtest|param={{SITENAME}}}}
11473 !! html
11474 <p>This is a test template with parameter MediaWiki
11475 </p>
11476 !! end
11477
11478 !! article
11479 Template:linktest
11480 !! text
11481 [[{{{param}}}|link]]
11482 !! endarticle
11483
11484 !! test
11485 Template parameter as link source
11486 !! wikitext
11487 {{linktest|param=Main Page}}
11488 !! html
11489 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
11490 </p>
11491 !! end
11492
11493 !!article
11494 Template:paramtest2
11495 !! text
11496 including another template, {{paramtest|param={{{arg}}}}}
11497 !! endarticle
11498
11499 !! test
11500 Template passing argument to another template
11501 !! wikitext
11502 {{paramtest2|arg='hmm'}}
11503 !! html
11504 <p>including another template, This is a test template with parameter 'hmm'
11505 </p>
11506 !! end
11507
11508 !! article
11509 Template:Linktest2
11510 !! text
11511 Main Page
11512 !! endarticle
11513
11514 !! test
11515 Template as link source
11516 !! wikitext
11517 [[{{linktest2}}]]
11518
11519 [[{{linktest2}}|Main Page]]
11520
11521 [[{{linktest2}}]]Page
11522 !! html
11523 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11524 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11525 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>Page
11526 </p>
11527 !! end
11528
11529
11530 !! article
11531 Template:loop1
11532 !! text
11533 {{loop2}}
11534 !! endarticle
11535
11536 !! article
11537 Template:loop2
11538 !! text
11539 {{loop1}}
11540 !! endarticle
11541
11542 !! test
11543 Template infinite loop
11544 !! wikitext
11545 {{loop1}}
11546 !! html
11547 <p><span class="error">Template loop detected: <a href="/wiki/Template:Loop1" title="Template:Loop1">Template:Loop1</a></span>
11548 </p>
11549 !! end
11550
11551 !! test
11552 Template from main namespace
11553 !! wikitext
11554 {{:Main Page}}
11555 !! html
11556 <p>blah blah
11557 </p>
11558 !! end
11559
11560 !! test
11561 Template from non-includable namespace
11562 !! options
11563 wgNonincludableNamespaces=10
11564 !! wikitext
11565 {{echo|uh oh!}}
11566 !! html
11567 <p><a href="/wiki/Template:Echo" title="Template:Echo">Template:Echo</a>
11568 </p>
11569 !! end
11570
11571 !! article
11572 Template:table
11573 !! text
11574 {|
11575 | 1 || 2
11576 |-
11577 | 3 || 4
11578 |}
11579 !! endarticle
11580
11581 !! test
11582 T2529: Template with table, not included at beginning of line
11583 !! wikitext
11584 foo {{table}}
11585 !! html
11586 <p>foo
11587 </p>
11588 <table>
11589 <tr>
11590 <td>1</td>
11591 <td>2
11592 </td></tr>
11593 <tr>
11594 <td>3</td>
11595 <td>4
11596 </td></tr></table>
11597
11598 !! end
11599
11600 !! test
11601 T2523: Template shouldn't eat newline (or add an extra one before table)
11602 !! wikitext
11603 foo
11604 {{table}}
11605 !! html
11606 <p>foo
11607 </p>
11608 <table>
11609 <tr>
11610 <td>1</td>
11611 <td>2
11612 </td></tr>
11613 <tr>
11614 <td>3</td>
11615 <td>4
11616 </td></tr></table>
11617
11618 !! end
11619
11620 !! test
11621 T2041: Template parameters shown as broken links
11622 !! wikitext
11623 {{{parameter}}}
11624 !! html
11625 <p>{{{parameter}}}
11626 </p>
11627 !! end
11628
11629 !! test
11630 Template with targets containing wikilinks
11631 !! options
11632 parsoid=wt2html
11633 !! wikitext
11634 {{[[foo]]}}
11635
11636 {{[[{{echo|foo}}]]}}
11637
11638 {{{{echo|[[foo}}]]}}
11639 !! html/php
11640 <p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11641 </p><p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11642 </p><p>{{[[foo}}]]
11643 </p>
11644 !! html/parsoid
11645 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">foo</a>}}</p>
11646 <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>
11647 <p>{{<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[foo}}]]"}},"i":0}}]}'>[[foo}}]]</span></p>
11648 !! end
11649
11650 !! article
11651 Template:''
11652 !! text
11653 bar
11654 !! endarticle
11655
11656 !! test
11657 Templates: Double quotes as template target
11658 !! wikitext
11659 foo {{''}} baz
11660 !! html/php
11661 <p>foo bar baz
11662 </p>
11663 !! html/parsoid
11664 <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
11665 </p>
11666 !! end
11667
11668 ## This test is about making sure Parsoid's data-mw is well formed in the
11669 ## face of multiple templates with intersecting and overlapping ranges. The
11670 ## wikitext itself is wretched.
11671 !! test
11672 Templates with intersecting and overlapping ranges
11673 !! wikitext
11674 {|{{echo|
11675 <p>ha</p>}}
11676 {|{{echo|
11677 <p>ho</p>}}
11678 {{echo|{{!}}hi}}
11679 |}
11680 !! html/php+tidy
11681 <p>ha</p><table>
11682
11683 </table><p>ho</p><table>
11684
11685 <tbody><tr>
11686 <td>hi
11687 </td></tr></tbody></table>
11688 !! html/parsoid
11689 <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":""}]]}'>
11690
11691 </table><p about="#mwt1">ho</p><table about="#mwt1" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"","html":""},{"html":""}]]}'>
11692
11693 <tbody><tr><td>hi</td></tr>
11694 </tbody></table>
11695 !! end
11696
11697 !! article
11698 Template:MSGNW test
11699 !! text
11700 ''None'' of '''this''' should be
11701 * interpreted
11702 but rather passed unmodified
11703 {{test}}
11704 <gallery>
11705 File:Foobar.jpg
11706 </gallery>
11707 <!-- comment -->
11708 !! endarticle
11709
11710 # hmm, fix this or just deprecate msgnw and document its behavior?
11711 !! test
11712 msgnw keyword
11713 !! wikitext
11714 {{msgnw:MSGNW test}}
11715 !! html/php
11716 <p>&#39;&#39;None&#39;&#39; of &#39;&#39;&#39;this&#39;&#39;&#39; should be
11717 &#42; interpreted
11718 &#32;but rather passed unmodified
11719 &#123;&#123;test&#125;&#125;
11720 &#60;gallery&#62;
11721 File:Foobar.jpg
11722 &#60;/gallery&#62;
11723 &#60;!-- comment --&#62;
11724 </p>
11725 !! end
11726
11727 !! test
11728 int keyword
11729 !! wikitext
11730 {{int:youhavenewmessages|lots of money|not!}}
11731 !! html
11732 <p>You have lots of money (not!).
11733 </p>
11734 !! end
11735
11736 !! test
11737 int keyword - non-existing message
11738 !! wikitext
11739 {{int:var}}
11740 !! html
11741 <p>⧼var⧽
11742 </p>
11743 !! end
11744
11745 !! article
11746 Template:Includes
11747 !! text
11748 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11749 !! endarticle
11750
11751 !! test
11752 <includeonly> and <noinclude> being included
11753 !! wikitext
11754 {{Includes}}
11755 !! html
11756 <p>Foobar
11757 </p>
11758 !! end
11759
11760 !! article
11761 Template:Includes2
11762 !! text
11763 <onlyinclude>Foo</onlyinclude>bar
11764 !! endarticle
11765
11766 !! test
11767 <onlyinclude> being included
11768 !! wikitext
11769 {{Includes2}}
11770 !! html
11771 <p>Foo
11772 </p>
11773 !! end
11774
11775
11776 !! article
11777 Template:Includes3
11778 !! text
11779 <onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly>
11780 !! endarticle
11781
11782 !! test
11783 <onlyinclude> and <includeonly> being included
11784 !! wikitext
11785 {{Includes3}}
11786 !! html
11787 <p>Foo
11788 </p>
11789 !! end
11790
11791 !! test
11792 <includeonly> and <noinclude> on a page
11793 !! wikitext
11794 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11795 !! html
11796 <p>Foozar
11797 </p>
11798 !! end
11799
11800 !! test
11801 Un-closed <noinclude>
11802 !! wikitext
11803 <noinclude>
11804 !! html
11805 !! end
11806
11807 !! test
11808 <onlyinclude> on a page
11809 !! wikitext
11810 <onlyinclude>Foo</onlyinclude>bar
11811 !! html
11812 <p>Foobar
11813 </p>
11814 !! end
11815
11816 !! test
11817 Un-closed <onlyinclude>
11818 !! wikitext
11819 <onlyinclude>
11820 !! html
11821 !! end
11822
11823 !!test
11824 Self-closed noinclude, includeonly, onlyinclude tags
11825 !! wikitext
11826 <noinclude />
11827 <includeonly />
11828 <onlyinclude />
11829 !! html
11830 <p><br />
11831 </p>
11832 !!end
11833
11834 !!test
11835 Unbalanced includeonly and noinclude tags
11836 !! wikitext
11837 {|
11838 |a</noinclude>
11839 |b</noinclude></noinclude>
11840 |c</noinclude></includeonly>
11841 |d</includeonly></includeonly>
11842 |}
11843 !! html
11844 <table>
11845 <tr>
11846 <td>a
11847 </td>
11848 <td>b
11849 </td>
11850 <td>c&lt;/includeonly&gt;
11851 </td>
11852 <td>d&lt;/includeonly&gt;&lt;/includeonly&gt;
11853 </td></tr></table>
11854
11855 !!end
11856
11857 !! article
11858 Template:Includeonly section
11859 !! text
11860 <includeonly>
11861 ==Includeonly section==
11862 </includeonly>
11863 ==Section T-1==
11864 !!endarticle
11865
11866 !! test
11867 T8563: Edit link generation for section shown by <includeonly>
11868 !! wikitext
11869 {{includeonly section}}
11870 !! html
11871 <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>
11872 <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>
11873
11874 !! end
11875
11876 # Uses same input as the contents of [[Template:Includeonly section]]
11877 !! test
11878 T8563: Section extraction for section shown by <includeonly>
11879 !! options
11880 section=T-2
11881 !! wikitext
11882 <includeonly>
11883 ==Includeonly section==
11884 </includeonly>
11885 ==Section T-2==
11886 !! html
11887 ==Section T-2==
11888 !! end
11889
11890 !! test
11891 T8563: Edit link generation for section suppressed by <includeonly>
11892 !! wikitext
11893 <includeonly>
11894 ==Includeonly section==
11895 </includeonly>
11896 ==Section 1==
11897 !! html
11898 <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>
11899
11900 !! end
11901
11902 !! test
11903 T8563: Section extraction for section suppressed by <includeonly>
11904 !! options
11905 section=1
11906 !! wikitext
11907 <includeonly>
11908 ==Includeonly section==
11909 </includeonly>
11910 ==Section 1==
11911 !! html
11912 ==Section 1==
11913 !! end
11914
11915 !! test
11916 Un-closed <includeonly>
11917 !! wikitext
11918 <includeonly>
11919 !! html/php
11920 !! html/parsoid
11921 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>"}'/>
11922 !! end
11923
11924 ## We used to, but no longer wt2wt this test since the default serializer
11925 ## will normalize the include directives to serialize on their own line.
11926 ## Selser will take care of preserving formatting in scenarios where they
11927 ## intermingled with other wikitext.
11928 !! test
11929 Includes and comments at SOL
11930 !! options
11931 parsoid=wt2html,html2html
11932 !! wikitext
11933 <!-- comment --><noinclude><!-- comment --></noinclude><!-- comment -->==hu==
11934
11935 <noinclude>
11936 some
11937 </noinclude>*stuff
11938 *here
11939
11940 <includeonly>can have stuff</includeonly>===here===
11941
11942 !! html/php
11943 <h2><span class="mw-headline" id="hu">hu</span></h2>
11944 <p>some
11945 </p>
11946 <ul><li>stuff</li>
11947 <li>here</li></ul>
11948 <h3><span class="mw-headline" id="here">here</span></h3>
11949
11950 !! html/parsoid
11951 <!-- 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>
11952
11953 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
11954 <p>some</p>
11955 <meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/><ul><li>stuff</li>
11956 <li>here</li></ul>
11957
11958 <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>
11959
11960 !! end
11961
11962 # TODO: test with DOM fragment reuse!
11963 !! test
11964 Parsoid: DOM fragment reuse
11965 !! options
11966 parsoid=wt2wt,wt2html
11967 !! wikitext
11968 a{{echo|b<table></table>c}}d
11969
11970 a{{echo|b
11971 <table></table>
11972 c}}d
11973
11974 {{echo|a
11975
11976 <table></table>
11977
11978 b}}
11979 !! html
11980 <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>
11981
11982 <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">
11983 </span><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><span about="#mwt2">
11984 </span><p about="#mwt2">cd</p>
11985
11986 <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">
11987
11988 </span><table about="#mwt3" data-parsoid='{"stx":"html"}'></table><span about="#mwt3">
11989
11990 </span><p about="#mwt3">b</p>
11991 !! end
11992
11993 !! test
11994 Parsoid: Merge double tds (T52603)
11995 !! options
11996 parsoid
11997 !! wikitext
11998 {|
11999 |{{echo|{{!}} foo}}
12000 |}
12001 !! html
12002 <table><tbody>
12003 <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>
12004 </tbody></table>
12005 !! end
12006
12007 !! test
12008 Parsoid: Merge double tds in nested transclusion content (T52603)
12009 !! options
12010 parsoid
12011 !! wikitext
12012 {{echo|<div>}}
12013 {|
12014 |{{echo|{{!}} foo}}
12015 |}
12016 {{echo|</div>}}
12017 !! html
12018 <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}}]}'>
12019 <table><tbody>
12020 <tr><td data-mw='{"parts":["|"]}'> foo</td></tr>
12021 </tbody></table>
12022 </div>
12023 !! end
12024
12025 ###
12026 ### <includeonly> and <noinclude> in attributes
12027 ###
12028 !!test
12029 0. includeonly around the entire attribute
12030 !! wikitext
12031 <span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
12032 !! html
12033 <p><span id="v2">bar</span>
12034 </p>
12035 !!end
12036
12037 !!test
12038 1. includeonly in html attr key
12039 !! wikitext
12040 <span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
12041 !! html
12042 <p><span id="foo">bar</span>
12043 </p>
12044 !!end
12045
12046 !!test
12047 2. includeonly in html attr value
12048 !! wikitext
12049 <span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
12050 <span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
12051 !! html
12052 <p><span id="v1">bar</span>
12053 <span id="v1">bar</span>
12054 </p>
12055 !!end
12056
12057 !!test
12058 3. includeonly in part of an attr value
12059 !! wikitext
12060 <span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
12061 !! html
12062 <p><span style="color:red;">bar</span>
12063 </p>
12064 !!end
12065
12066 !!test
12067 4. includeonly in table attributes
12068 !! wikitext
12069 {|
12070 |- <noinclude>
12071 |-
12072 |a
12073 </noinclude>
12074 |- <includeonly>
12075 |-
12076 |b
12077 </includeonly>
12078 |}
12079 !! html
12080 <table>
12081
12082
12083 <tr>
12084 <td>a
12085 </td></tr>
12086 </table>
12087
12088 !!end
12089
12090 ###
12091 ### Preprocessor precedence tests
12092 ### See: https://www.mediawiki.org/wiki/Preprocessor_ABNF
12093 ###
12094 ##{{[[-{{{{{{[[Foo|bar}}]]}-}}}}}]]
12095 !! test
12096 Preprocessor precedence 1: link is rightmost opening
12097 !! options
12098 parsoid=wt2html
12099 !! wikitext
12100 {{[[Foo|bar}}]]
12101
12102 But close-brace is not a valid character in a link title:
12103 {{[[Foo}}|bar]]
12104
12105 However, we can still tell this was handled as a link in the preprocessor:
12106 {{echo|[[Foo}}|bar]]|bat}}
12107 !! html/php
12108 <p>{{<a href="/wiki/Foo" title="Foo">bar}}</a>
12109 </p><p>But close-brace is not a valid character in a link title:
12110 {{[[Foo}}|bar]]
12111 </p><p>However, we can still tell this was handled as a link in the preprocessor:
12112 [[Foo}}|bar]]
12113 </p>
12114 !! html/parsoid
12115 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">bar}}</a></p>
12116 <p>But close-brace is not a valid character in a link title: {{[[Foo}}|bar]]</p>
12117 <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>
12118 !! end
12119
12120 !! test
12121 Preprocessor precedence 2: template is rightmost opening
12122 !! options
12123 language=zh
12124 !! wikitext
12125 -{{echo|foo}-}}-
12126 !! html/php
12127 <p>-foo}--
12128 </p>
12129 !! html/parsoid
12130 <p>-<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}-"}},"i":0}}]}'>foo}-</span>-</p>
12131 !! end
12132
12133 !! test
12134 Preprocessor precedence 3: language converter is rightmost opening
12135 !! options
12136 language=zh
12137 parsoid=wt2html
12138 !! wikitext
12139 {{echo|hi}}
12140
12141 {{-{R|echo|hi}}}-
12142
12143 [[-{R|raw]]}-
12144 !! html/php
12145 <p>hi
12146 </p><p>{{echo|hi}}
12147 </p><p>[[raw]]
12148 </p>
12149 !! html/parsoid
12150 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"}},"i":0}}]}'>hi</p>
12151 <p>{{<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"echo|hi}}"}}'></span></p>
12152 <p>[[<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw]]"}}'></span></p>
12153 !! end
12154
12155 !! test
12156 Preprocessor precedence 4: left-most angle bracket
12157 !! options
12158 language=zh
12159 !! wikitext
12160 <!--{raw}-->
12161 !! html/php
12162 !! html/parsoid
12163 <!--{raw}-->
12164 !! end
12165
12166 !! article
12167 Template:Precedence5
12168 !! text
12169 {{{{{1}}}}}
12170 !! endarticle
12171
12172 !! test
12173 Preprocessor precedence 5: tplarg takes precedence over template
12174 !! wikitext
12175 {{Precedence5|Bullet}}
12176 !! html/php
12177 <ul><li>Bar</li></ul>
12178
12179 !! html/parsoid
12180 <ul typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Precedence5","href":"./Template:Precedence5"},"params":{"1":{"wt":"Bullet"}},"i":0}}]}'><li>Bar</li></ul>
12181 !! end
12182
12183 !! test
12184 Preprocessor precedence 6: broken link is rightmost opening
12185 !! options
12186 parsoid=wt2html
12187 !! wikitext
12188 {{echo|[[Foo}}
12189
12190 {{echo|[[Foo|bar|bat=baz}}
12191 !! html/php
12192 <p>{{echo|[[Foo}}
12193 </p><p>{{echo|[[Foo|bar|bat=baz}}
12194 </p>
12195 !! html/parsoid
12196 <p>{{echo|[[Foo}}</p>
12197 <p>{{echo|[[Foo|bar|bat=baz}}</p>
12198 !! end
12199
12200 # This next test exposes a difference between PHP and Parsoid:
12201 # Given [[Foo|{{echo|Bar]]x}}y]]z:
12202 # 1) Both PHP and Parsoid ignore the `]]` inside the `echo` in the
12203 # "preprocessor" stage. The `{{echo` extends until the `x}}`, and the
12204 # outer `[[Foo` extends until the `y]]`
12205 # 2a) But then the PHP preprocessor emits `[[Foo|Bar]]xy]]z` as an
12206 # intermediate result (after template expansion), and link processing
12207 # happens on this intermediate result, which moves the wikilink
12208 # boundary leftward to `[[Foo|Bar]]`
12209 # 2b) Parsoid works in a single step, so it's going to keep the
12210 # wikilink as extending to the `y]]`
12211 # 3a) Then PHP does linktrail processing which slurps up the trailing
12212 # `xy` inside the link.
12213 # 3b) Parsoid will do linktrail processing to slurp up the trailing
12214 # `z` inside the link.
12215 # This is "correct" behavior. Parsoid's basic worldview is that the
12216 # `]]` inside the template shouldn't be allowed to leak out to affect
12217 # the surrounding wikilink. PHP may match Parsoid (in the future)
12218 # if you use {{#balance}} (T114445).
12219
12220 !! test
12221 Preprocessor precedence 7: broken template is rightmost opening
12222 !! options
12223 parsoid=wt2html
12224 !! wikitext
12225 [[Foo|{{echo|Bar]]
12226
12227 [[Foo|{{echo|Bar]]-x}}-y]]-z
12228
12229 Careful: linktrails can move the end of the wikilink:
12230 [[Foo|{{echo|y']]a}}l]]l
12231 !! html/php
12232 <p><a href="/wiki/Foo" title="Foo">{{echo|Bar</a>
12233 </p><p><a href="/wiki/Foo" title="Foo">Bar</a>-x-y]]-z
12234 </p><p>Careful: linktrails can move the end of the wikilink:
12235 <a href="/wiki/Foo" title="Foo">y'al</a>]]l
12236 </p>
12237 !! html/parsoid
12238 <p>[[Foo|{{echo|Bar]]</p>
12239 <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>
12240 <p>Careful: linktrails can move the end of the wikilink:
12241 <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>
12242 !! end
12243
12244 !! test
12245 Preprocessor precedence 8: broken language converter is rightmost opening
12246 !! options
12247 language=zh
12248 !! wikitext
12249 [[Foo-{R|raw]]
12250 !! html
12251 <p>[[Foo-{R|raw]]
12252 </p>
12253 !! end
12254
12255 !! article
12256 Template:Preprocessor_precedence_9
12257 !! text
12258 ;4: {{{{1}}}}
12259 ;5: {{{{{2}}}}}
12260 ;6: {{{{{{3}}}}}}
12261 ;7: {{{{{{{4}}}}}}}
12262 !! endarticle
12263
12264 !! test
12265 Preprocessor precedence 9: groups of braces
12266 !! wikitext
12267 {{Preprocessor precedence 9|Four|Bullet|1|2}}
12268 !! html/php
12269 <dl><dt>4</dt>
12270 <dd>{Four}</dd>
12271 <dt>5</dt>
12272 <dd></dd></dl>
12273 <ul><li>Bar</li></ul>
12274 <dl><dt>6</dt>
12275 <dd>Four</dd>
12276 <dt>7</dt>
12277 <dd>{Bullet}</dd></dl>
12278
12279 !! html/parsoid
12280 <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}}]}'>
12281 <dt>4</dt>
12282 <dd>{Four}</dd>
12283 <dt>5</dt>
12284 <dd></dd>
12285 </dl><ul about="#mwt1">
12286 <li>Bar</li>
12287 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12288 <dt>6</dt>
12289 <dd>Four</dd>
12290 <dt>7</dt>
12291 <dd>{Bullet}</dd>
12292 </dl>
12293 !! end
12294
12295 !! article
12296 Template:Preprocessor_precedence_10
12297 !! text
12298 ;1: -{R|raw}-
12299 ;2: -{{Bullet}}-
12300 ;3: -{{{1}}}-
12301 ;4: -{{{{2}}}}-
12302 ;5: -{{{{{3}}}}}-
12303 ;6: -{{{{{{4}}}}}}-
12304 ;7: -{{{{{{{5}}}}}}}-
12305 !! endarticle
12306
12307 !! test
12308 Preprocessor precedence 10: groups of braces with leading dash
12309 !! options
12310 language=zh
12311 !! wikitext
12312 {{Preprocessor precedence 10|Three|raw2|Bullet|1|2}}
12313 !! html/php
12314 <dl><dt>1</dt>
12315 <dd>raw</dd>
12316 <dt>2</dt>
12317 <dd>-</dd></dl>
12318 <ul><li>Bar-</li></ul>
12319 <dl><dt>3</dt>
12320 <dd>-Three-</dd>
12321 <dt>4</dt>
12322 <dd>raw2</dd>
12323 <dt>5</dt>
12324 <dd>-</dd></dl>
12325 <ul><li>Bar-</li></ul>
12326 <dl><dt>6</dt>
12327 <dd>-Three-</dd>
12328 <dt>7</dt>
12329 <dd>raw2</dd></dl>
12330
12331 !! html/parsoid
12332 <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}}]}'>
12333 <dt>1</dt>
12334 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw"}}'></span></dd>
12335 <dt>2</dt>
12336 <dd>-</dd>
12337 </dl><ul about="#mwt1">
12338 <li>Bar-</li>
12339 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12340 <dt>3</dt>
12341 <dd>-Three-</dd>
12342 <dt>4</dt>
12343 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12344 <dt>5</dt>
12345 <dd>-</dd>
12346 </dl><ul about="#mwt1">
12347 <li>Bar-</li>
12348 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12349 <dt>6</dt>
12350 <dd>-Three-</dd>
12351 <dt>7</dt>
12352 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12353 </dl>
12354 !! end
12355
12356 !! test
12357 Preprocessor precedence 11: found during visual diff testing
12358 !! wikitext
12359 {{#tag:span|-{{#tag:span|-{{echo|x}}}}}}
12360
12361 {{echo|-{{echo|-{{echo|x}}}}}}
12362
12363 {{echo|-{{echo|x}}}}
12364 !! html/php
12365 <p><span>-<span>-x</span></span>
12366 </p><p>--x
12367 </p><p>-x
12368 </p>
12369 !! html/parsoid
12370 <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>
12371
12372 <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>
12373
12374 <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>
12375 !! end
12376
12377 !! test
12378 Preprocessor precedence 12: broken language converter closed by brace.
12379 !! options
12380 parsoid=wt2html
12381 !! wikitext
12382 This form breaks the template, which is unfortunate:
12383 *{{echo|foo-{bar}bat}}
12384
12385 But if the broken language converter markup is inside an extension
12386 tag, nothing bad happens:
12387 *<nowiki>foo-{bar}bat</nowiki>
12388 *{{echo|<nowiki>foo-{bar}bat</nowiki>}}
12389 *<pre>foo-{bar}bat</pre>
12390 *{{echo|<pre>foo-{bar}bat</pre>}}
12391
12392 <tag>foo-{bar}bat</tag>
12393 {{echo|<tag>foo-{bar}bat</tag>}}
12394
12395 !! html/php+tidy
12396 <p>This form breaks the template, which is unfortunate:
12397 </p>
12398 <ul><li>{{echo|foo-{bar}bat}}</li></ul>
12399 <p>But if the broken language converter markup is inside an extension
12400 tag, nothing bad happens:
12401 </p>
12402 <ul><li>foo-&#123;bar}bat</li>
12403 <li>foo-&#123;bar}bat</li>
12404 <li><pre>foo-{bar}bat</pre></li>
12405 <li><pre>foo-{bar}bat</pre></li></ul>
12406 <pre>'foo-{bar}bat'
12407 array (
12408 )
12409 </pre>
12410 <pre>'foo-{bar}bat'
12411 array (
12412 )
12413 </pre>
12414 !! html/parsoid
12415 <p>This form breaks the template, which is unfortunate:</p>
12416 <ul>
12417 <li>{{echo|foo-{bar}bat}}</li>
12418 </ul>
12419 <p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p>
12420 <ul>
12421 <li><span typeof="mw:Nowiki">foo-{bar}bat</span></li>
12422 <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>
12423 <li><pre typeof="mw:Extension/pre" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo-{bar}bat"}}'>foo-{bar}bat</pre></li>
12424 <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>
12425 </ul>
12426 <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>
12427 !! end
12428
12429 !! test
12430 Preprocessor precedence 13: broken language converter in external link
12431 !! options
12432 parsoid=wt2html
12433 !! wikitext
12434 *[http://example.com/-{foo Example in URL]
12435 *[http://example.com Example in -{link} description]
12436 *{{echo|[http://example.com/-{foo Breaks template, however]}}
12437 !! html/php+tidy
12438 <ul><li><a rel="nofollow" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12439 <li><a rel="nofollow" class="external text" href="http://example.com">Example in -{link} description</a></li>
12440 <li>{{echo|<a rel="nofollow" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li></ul>
12441 !! html/parsoid
12442 <ul>
12443 <li><a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12444 <li><a rel="mw:ExtLink" class="external text" href="http://example.com">Example in -{link} description</a></li>
12445 <li>{{echo|<a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
12446 </ul>
12447 !! end
12448
12449 !! test
12450 Preprocessor precedence 14: broken language converter in comment
12451 !! wikitext
12452 *<!--{{foo}}-->...should be ok
12453 *<!---{{foo}}-->...extra dashes
12454 *{{echo|foo<!-- -{bar} -->bat}}...should be ok
12455 !! html/php+tidy
12456 <ul><li>...should be ok</li>
12457 <li>...extra dashes</li>
12458 <li>foobat...should be ok</li></ul>
12459 !! html/parsoid
12460 <ul>
12461 <li><!--{{foo}}-->...should be ok</li>
12462 <li><!--&#x2D;{{foo}}-->...extra dashes</li>
12463 <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>
12464 </ul>
12465 !! end
12466
12467 !! test
12468 Preprocessor precedence 15: broken brace markup in headings
12469 !! config
12470 wgFragmentMode=[ 'html5', 'legacy' ]
12471 !! options
12472 parsoid=wt2html
12473 !! wikitext
12474 __NOTOC__ __NOEDITSECTION__
12475 ===1 foo[bar 1===
12476 1
12477 ===2 foo[[bar 2===
12478 2
12479 ===3 foo{bar 3===
12480 3
12481 ===4 foo{{bar 4===
12482 4
12483 ===5 foo{{{bar 5===
12484 5
12485 ===6 foo-{bar 6===
12486 6
12487 !! html/php+tidy
12488 <h3><span id="1_foo.5Bbar_1"></span><span class="mw-headline" id="1_foo[bar_1">1 foo[bar 1</span></h3>
12489 <p>1
12490 </p>
12491 <h3><span id="2_foo.5B.5Bbar_2"></span><span class="mw-headline" id="2_foo[[bar_2">2 foo[[bar 2</span></h3>
12492 <p>2
12493 </p>
12494 <h3><span id="3_foo.7Bbar_3"></span><span class="mw-headline" id="3_foo{bar_3">3 foo{bar 3</span></h3>
12495 <p>3
12496 </p>
12497 <h3><span id="4_foo.7B.7Bbar_4"></span><span class="mw-headline" id="4_foo{{bar_4">4 foo{{bar 4</span></h3>
12498 <p>4
12499 </p>
12500 <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>
12501 <p>5
12502 </p>
12503 <h3><span id="6_foo-.7Bbar_6"></span><span class="mw-headline" id="6_foo-{bar_6">6 foo-{bar 6</span></h3>
12504 <p>6
12505 </p>
12506 !! html/parsoid
12507 <meta property="mw:PageProp/notoc"/> <meta property="mw:PageProp/noeditsection"/>
12508 <h3 id="1_foo[bar_1"><span id="1_foo.5Bbar_1" typeof="mw:FallbackId"></span>1 foo[bar 1</h3>
12509 <p>1</p>
12510 <h3 id="2_foo[[bar_2"><span id="2_foo.5B.5Bbar_2" typeof="mw:FallbackId"></span>2 foo[[bar 2</h3>
12511 <p>2</p>
12512 <h3 id="3_foo{bar_3"><span id="3_foo.7Bbar_3" typeof="mw:FallbackId"></span>3 foo{bar 3</h3>
12513 <p>3</p>
12514 <h3 id="4_foo{{bar_4"><span id="4_foo.7B.7Bbar_4" typeof="mw:FallbackId"></span>4 foo{{bar 4</h3>
12515 <p>4</p>
12516 <h3 id="5_foo{{{bar_5"><span id="5_foo.7B.7B.7Bbar_5" typeof="mw:FallbackId"></span>5 foo{{{bar 5</h3>
12517 <p>5</p>
12518 <h3 id="6_foo-{bar_6"><span id="6_foo-.7Bbar_6" typeof="mw:FallbackId"></span>6 foo-{bar 6</h3>
12519 <p>6</p>
12520 !! end
12521
12522 !! test
12523 Preprocessor precedence 16: matching closing braces to opening braces
12524 !! options
12525 language=zh
12526 parsoid=wt2html
12527 !! wikitext
12528 -{{{echo|foo}}bar}-
12529 !! html/php
12530 <p>foobar
12531 </p>
12532 !! html/parsoid
12533 <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>
12534 !! end
12535
12536 !! test
12537 Preprocessor precedence 17: template w/o target shouldn't prevent closing
12538 !! options
12539 parsoid=wt2html
12540 !! wikitext
12541 {{echo|hi {{}}}}
12542 !! html/php
12543 <p>hi {{}}
12544 </p>
12545 !! html/parsoid
12546 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi {{}}"}},"i":0}}]}'>hi {{}}</p>
12547 !! end
12548
12549 !! test
12550 Preprocessor precedence 18: another rightmost wins scenario
12551 !! options
12552 parsoid=wt2html
12553 !! wikitext
12554 {{ -{{{{1|tplarg}}} }} }-
12555 !! html/php
12556 <p>{{ -{tplarg }} }-
12557 </p>
12558 !! html/parsoid
12559 <p>{{ -{<span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"1"},"params":{"1":{"wt":"tplarg"}},"i":0}}]}'>tplarg</span> }} }-</p>
12560 !! end
12561
12562 !! test
12563 Preprocessor precedence 19: break syntax
12564 !! options
12565 parsoid=wt2html
12566 !! wikitext
12567 -{{
12568 !! html/php
12569 <p>-{{
12570 </p>
12571 !! html/parsoid
12572 <p>-{{</p>
12573 !! end
12574
12575 ###
12576 ### Token Stream Patcher tests
12577 ###
12578 ### These tests won't always pass wt2wt and other modes because
12579 ### on serialization, the table will be output on a new line.
12580 ### For now, we are blacklisting them, and using this to test selser.
12581 ###
12582
12583 !!test
12584 1. Table tag in SOL posn. should get reparsed correctly with valid TSR
12585 !!options
12586 parsoid=wt2html,wt2wt
12587 !!wikitext
12588 {{echo|}}{| width = '100%'
12589 |foo
12590 |}
12591 !!html/parsoid
12592 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":""}},"i":0}}]}'></span><table width="100%">
12593 <tbody><tr><td>foo</td></tr>
12594 </tbody></table>
12595 !!end
12596
12597 ## We used to, but no longer wt2wt this test since the default serializer
12598 ## will normalize the include directives to serialize on their own line.
12599 ## Selser will take care of preserving formatting in scenarios where they
12600 ## intermingled with other wikitext.
12601 !!test
12602 2. Table tag in SOL posn. should get reparsed correctly with valid TSR
12603 !!options
12604 parsoid=wt2html
12605 !!wikitext
12606 <includeonly>a</includeonly>{| {{{b}}}
12607 |c
12608 |}
12609 !!html/parsoid
12610 <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":""}]]}'>
12611 <tbody><tr><td>c</td></tr>
12612 </tbody></table>
12613 !!end
12614
12615 !! test
12616 Table wikitext syntax outside wiki-tables
12617 !! wikitext
12618 a
12619 |+ not a caption
12620 ! not a table heading
12621 |- not a table row
12622 | not a table cell
12623 | class="foo bar" | baz
12624 b
12625 |}
12626 |-
12627 c
12628 !! html
12629 <p>a
12630 |+ not a caption
12631 ! not a table heading
12632 |- not a table row
12633 | not a table cell
12634 | class="foo bar" | baz
12635 b
12636 |}
12637 |-
12638 c
12639 </p>
12640 !! end
12641
12642 ###
12643 ### Testing parsing of templates where a template arg
12644 ### has the same name as the template itself.
12645 ###
12646
12647 !! article
12648 Template:quote
12649 !! text
12650 {{{quote|{{{1}}}}}}
12651 !! endarticle
12652
12653 !!test
12654 Templates: Template Name/Arg clash: 1. Use of positional param
12655 !! wikitext
12656 {{quote|foo}}
12657 !! html
12658 <p>foo
12659 </p>
12660 !!end
12661
12662 !!test
12663 Templates: Template Name/Arg clash: 2. Use of named param
12664 !! wikitext
12665 {{quote|quote=foo}}
12666 !! html
12667 <p>foo
12668 </p>
12669 !!end
12670
12671 !!test
12672 Templates: Template Name/Arg clash: 3. Use of named param with empty input
12673 !! wikitext
12674 {{quote|quote}}
12675 !! html
12676 <p>quote
12677 </p>
12678 !!end
12679
12680 ###
12681 ### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
12682 ###
12683
12684 !!test
12685 Templates: 1. Simple use
12686 !! wikitext
12687 {{echo|Foo}}
12688 !! html
12689 <p>Foo
12690 </p>
12691 !!end
12692
12693 !!test
12694 Templates: 2. Inside a block tag
12695 !! wikitext
12696 <div>{{echo|Foo}}</div>
12697 <blockquote>{{echo|Foo}}</blockquote>
12698 !! html
12699 <div>Foo</div>
12700 <blockquote>Foo</blockquote>
12701
12702 !! html+tidy
12703 <div>Foo</div>
12704 <blockquote><p>Foo</p></blockquote>
12705 !!end
12706
12707 !!test
12708 Templates: P-wrapping: 1a. Templates on consecutive lines
12709 !! wikitext
12710 {{echo|Foo}}
12711 {{echo|bar}}
12712 !! html
12713 <p>Foo
12714 bar
12715 </p>
12716 !!end
12717
12718 !!test
12719 Templates: P-wrapping: 1b. Templates on consecutive lines
12720 !! wikitext
12721 Foo
12722
12723 {{echo|bar}}
12724 {{echo|baz}}
12725 !! html
12726 <p>Foo
12727 </p><p>bar
12728 baz
12729 </p>
12730 !!end
12731
12732 !!test
12733 Templates: P-wrapping: 1c. Templates on consecutive lines
12734 !! wikitext
12735 {{echo|Foo}}
12736 {{echo|bar}} <div>baz</div>
12737 !! html
12738 <p>Foo
12739 </p>
12740 bar <div>baz</div>
12741
12742 !! html+tidy
12743 <p>Foo
12744 </p><p>
12745 bar </p><div>baz</div>
12746 !! end
12747
12748 !!test
12749 Templates: P-wrapping: 1d. Template preceded by comment-only line
12750 !!options
12751 parsoid
12752 !! wikitext
12753 <!-- foo -->
12754 {{echo|Bar}}
12755 !! html
12756 <!-- foo -->
12757
12758 <p about="#mwt223" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar"}},"i":0}}]}'>Bar</p>
12759 !!end
12760
12761 !!test
12762 Templates: Inline Text: 1. Multiple template uses
12763 !! wikitext
12764 {{echo|Foo}}bar{{echo|baz}}
12765 !! html
12766 <p>Foobarbaz
12767 </p>
12768 !!end
12769
12770 !!test
12771 Templates: Inline Text: 2. Back-to-back template uses
12772 !! wikitext
12773 {{echo|Foo}}{{echo|bar}}
12774 !! html
12775 <p>Foobar
12776 </p>
12777 !!end
12778
12779 !!test
12780 Templates: Block Tags: 1. Multiple template uses
12781 !! wikitext
12782 {{echo|<div>Foo</div>}}<div>bar</div>{{echo|<div>baz</div>}}
12783 !! html
12784 <div>Foo</div><div>bar</div><div>baz</div>
12785
12786 !!end
12787
12788 !!test
12789 Templates: Block Tags: 2. Back-to-back template uses
12790 !! wikitext
12791 {{echo|<div>Foo</div>}}{{echo|<div>bar</div>}}
12792 !! html
12793 <div>Foo</div><div>bar</div>
12794
12795 !!end
12796
12797 # This is an edge case relating to paragraph wrapping.
12798 !!test
12799 Templates: Correctly encapsulate templates producing </p> tag without a corresponding <p> tag
12800 !! wikitext
12801 {{echo|a
12802 b</p>}}
12803 !! html/parsoid
12804 <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
12805 b</p>
12806 !!end
12807
12808 !!test
12809 Templates: Links: 1. Simple example
12810 !! wikitext
12811 {{echo|[[Foo|bar]]}}
12812 !! html
12813 <p><a href="/wiki/Foo" title="Foo">bar</a>
12814 </p>
12815 !!end
12816
12817 !!test
12818 Templates: Links: 2. Generation of link href
12819 !! wikitext
12820 [[{{echo|Foo}}|bar]]
12821 !! html
12822 <p><a href="/wiki/Foo" title="Foo">bar</a>
12823 </p>
12824 !!end
12825
12826 !!test
12827 Templates: Links: 3. Generation of part of a link href
12828 !! wikitext
12829 [[Fo{{echo|o}}|bar]]
12830
12831 [[Foo{{echo|bar}}]]
12832
12833 [[Foo{{echo|bar}}baz]]
12834
12835 [[Foo{{echo|bar}}|bar]]
12836
12837 [[:Foo{{echo|bar}}]]
12838
12839 [[:Foo{{echo|bar}}|bar]]
12840 !! html
12841 <p><a href="/wiki/Foo" title="Foo">bar</a>
12842 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12843 </p><p><a href="/index.php?title=Foobarbaz&amp;action=edit&amp;redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a>
12844 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12845 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12846 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12847 </p>
12848 !!end
12849
12850 !!test
12851 Templates: Links: 4. Multiple templates generating link href
12852 !! wikitext
12853 [[{{echo|F}}{{echo|o}}ob{{echo|ar}}]]
12854 !! html
12855 <p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12856 </p>
12857 !!end
12858
12859 !!test
12860 Templates: Links: 5. Generation of link text
12861 !! wikitext
12862 [[Foo|{{echo|bar}}]]
12863 !! html
12864 <p><a href="/wiki/Foo" title="Foo">bar</a>
12865 </p>
12866 !!end
12867
12868 !!test
12869 Templates: Links: 5. Nested templates (only outermost template should be marked)
12870 !! wikitext
12871 {{echo|[[{{echo|Foo}}|bar]]}}
12872 !! html
12873 <p><a href="/wiki/Foo" title="Foo">bar</a>
12874 </p>
12875 !!end
12876
12877 !!test
12878 Templates: HTML Tag: 1. Generation of HTML attr. key
12879 !! wikitext
12880 <div {{echo|style}}="color:red;">foo</div>
12881 !! html
12882 <div style="color:red;">foo</div>
12883
12884 !!end
12885
12886 !!test
12887 Templates: HTML Tag: 2. Generation of HTML attr. value
12888 !! wikitext
12889 <div style={{echo|'color:red;'}}>foo</div>
12890 !! html
12891 <div style="color:red;">foo</div>
12892
12893 !!end
12894
12895 !!test
12896 Templates: HTML Tag: 3. Generation of HTML attr key and value
12897 !! wikitext
12898 <div {{echo|style}}={{echo|'color:red;'}}>foo</div>
12899 !! html
12900 <div style="color:red;">foo</div>
12901
12902 !!end
12903
12904 !!test
12905 Templates: HTML Tag: 4. Generation of starting piece of HTML attr value
12906 !! wikitext
12907 <div title="{{echo|This is a long title}} with just one piece templated">foo</div>
12908 !! html
12909 <div title="This is a long title with just one piece templated">foo</div>
12910
12911 !!end
12912
12913 !!test
12914 Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
12915 !! wikitext
12916 <div title="This is a long title with just {{echo|one piece}} templated">foo</div>
12917 !! html
12918 <div title="This is a long title with just one piece templated">foo</div>
12919
12920 !!end
12921
12922 !!test
12923 Templates: HTML Tag: 6. Generation of end piece of HTML attr value
12924 !! wikitext
12925 <div title="This is a long title with just one piece {{echo|templated}}">foo</div>
12926 !! html
12927 <div title="This is a long title with just one piece templated">foo</div>
12928
12929 !!end
12930
12931 # SSS FIXME: While it is great we added support for all this,
12932 # do we want to make this part of the spec? Maybe we want to
12933 # deprecate this kind of usage in the future?
12934 !!test
12935 Templates: HTML Tag: 7. Generation of partial attribute key string
12936 !! wikitext
12937 <div st{{echo|yle}}="color:red;">foo</div>
12938 !! html
12939 <div style="color:red;">foo</div>
12940
12941 !!end
12942
12943 !! test
12944 Templates: HTML Tag: 8. Template-generated attribute (k=v)
12945 !! wikitext
12946 <div {{echo|1=id="v1"}}>bar</div>
12947 !! html
12948 <div id="v1">bar</div>
12949
12950 !!end
12951
12952 !! test
12953 Templates: HTML Tag: 9. Multiple template-generated attributes
12954 !! wikitext
12955 <div {{echo|1=id="v1" title="foo"}}>bar</div>
12956 !! html
12957 <div id="v1" title="foo">bar</div>
12958
12959 !!end
12960
12961 !! test
12962 Templates: Support for templates generating attributes and content
12963 !! wikitext
12964 {| {{mixed_attr_content_template}}
12965 |-
12966 |bar
12967 |}
12968 !! html/php
12969 <table style="color:red;" title="T48811">
12970
12971 <tr>
12972 <td>foo
12973 </td></tr>
12974 <tr>
12975 <td>bar
12976 </td></tr></table>
12977
12978 !! html/parsoid
12979 <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|}"]}'>
12980 <tbody><tr>
12981 <td>foo</td></tr>
12982 <tr>
12983 <td>bar</td></tr>
12984 </tbody></table>
12985 !!end
12986
12987 !! test
12988 1. Entities and nowikis inside templated attributes should be handled correctly
12989 !! wikitext
12990 <div {{echo|style{{=}}"background:&#35;f9f9f9;"}}>foo</div>
12991 !! html/php
12992 <div style="background:#f9f9f9;">foo</div>
12993
12994 !! html/parsoid
12995 <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>
12996 !! end
12997
12998 !! test
12999 2. Entities and nowikis inside templated attributes should be handled correctly
13000 !! wikitext
13001 {|
13002 |{{table_attribs_3}}
13003 |}
13004 !! html/php
13005 <table>
13006 <tr>
13007 <td style="background:#f9f9f9;">Foo
13008 </td></tr></table>
13009
13010 !! html/parsoid
13011 <table>
13012 <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>
13013 </tbody></table>
13014 !! end
13015
13016 !! test
13017 3. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13018 !! wikitext
13019 {{tbl-start}}
13020 |{{table_attribs_3}}
13021 {{tbl-end}}
13022 !! html/php
13023 <table>
13024 <tr>
13025 <td style="background:#f9f9f9;">Foo
13026 </td></tr></table>
13027
13028 !! html/parsoid
13029 <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}}]}'>
13030 <tbody><tr><td style="background:#f9f9f9;">Foo</td></tr>
13031 </tbody></table>
13032 !! end
13033
13034 # T107622
13035 !! test
13036 4. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13037 !! wikitext
13038 {|
13039 |{{table_attribs_6}} hi
13040 |}
13041 !! html/php
13042 <table>
13043 <tr>
13044 <td style="background: red;">hi
13045 </td></tr></table>
13046
13047 !! html/parsoid
13048 <table>
13049 <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>
13050 </tbody></table>
13051 !! end
13052
13053 !!test
13054 Templates: HTML Tables: 1. Generating start of a HTML table
13055 !! wikitext
13056 {{echo|<table><tr><td>foo</td>}}</tr></table>
13057 !! html
13058 <table><tr><td>foo</td></tr></table>
13059
13060 !!end
13061
13062 !!test
13063 Templates: HTML Tables: 2a. Generating middle of a HTML table
13064 !! wikitext
13065 <table><tr>{{echo|<td>foo</td>}}</tr></table>
13066 !! html
13067 <table><tr><td>foo</td></tr></table>
13068
13069 !!end
13070
13071 !!test
13072 Templates: HTML Tables: 2b. Generating middle of a HTML table
13073 !! wikitext
13074 <table>{{echo|<tr><td>foo</td></tr>}}</table>
13075 !! html
13076 <table><tr><td>foo</td></tr></table>
13077
13078 !!end
13079
13080 !!test
13081 Templates: HTML Tables: 3. Generating end of a HTML table
13082 !! wikitext
13083 <table><tr>{{echo|<td>foo</td></tr></table>}}
13084 !! html
13085 <table><tr><td>foo</td></tr></table>
13086
13087 !!end
13088
13089 !!test
13090 Templates: HTML Tables: 4a. Generating a single tag of a HTML table
13091 !! wikitext
13092 {{echo|<table>}}<tr><td>foo</td></tr></table>
13093 !! html
13094 <table><tr><td>foo</td></tr></table>
13095
13096 !!end
13097
13098 !!test
13099 Templates: HTML Tables: 4b. Generating a single tag of a HTML table
13100 !! wikitext
13101 <table>{{echo|<tr>}}<td>foo</td></tr></table>
13102 !! html
13103 <table><tr><td>foo</td></tr></table>
13104
13105 !!end
13106
13107 !!test
13108 Templates: HTML Tables: 4c. Generating a single tag of a HTML table
13109 !! wikitext
13110 <table><tr>{{echo|<td>}}foo</td></tr></table>
13111 !! html
13112 <table><tr><td>foo</td></tr></table>
13113
13114 !!end
13115
13116 !!test
13117 Templates: HTML Tables: 4d. Generating a single tag of a HTML table
13118 !! wikitext
13119 <table><tr><td>foo{{echo|</td>}}</tr></table>
13120 !! html
13121 <table><tr><td>foo</td></tr></table>
13122
13123 !!end
13124
13125 !!test
13126 Templates: HTML Tables: 4e. Generating a single tag of a HTML table
13127 !! wikitext
13128 <table><tr><td>foo</td>{{echo|</tr>}}</table>
13129 !! html
13130 <table><tr><td>foo</td></tr></table>
13131
13132 !!end
13133
13134 !!test
13135 Templates: HTML Tables: 4f. Generating a single tag of a HTML table
13136 !! wikitext
13137 <table><tr><td>foo</td></tr>{{echo|</table>}}
13138 !! html
13139 <table><tr><td>foo</td></tr></table>
13140
13141 !!end
13142
13143 !!test
13144 Templates: HTML Tables: 5. Proper fostering of categories from inside
13145 !!options
13146 parsoid=wt2html,wt2wt
13147 !! wikitext
13148 <table>[[Category:foo1]]<tr><td>foo</td></tr></table>
13149 <!--Two categories (T52330)-->
13150 <table>[[Category:bar1]][[Category:bar2]]<tr><td>foo</td></tr></table>
13151 !! html
13152 <link rel="mw:PageProp/Category" href="./Category:Foo1"><table><tbody><tr><td>foo</td></tr></tbody></table>
13153 <!--Two categories (T52330)-->
13154 <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>
13155 !!end
13156
13157 !!test
13158 Templates: Wiki Tables: 1a. Fostering of entire template content
13159 !! wikitext
13160 {|
13161 {{echo|a}}
13162 |}
13163 !! html
13164 <table>
13165 a
13166 <tr><td></td></tr></table>
13167
13168 !! html/php+tidy
13169
13170 a
13171 <table><tbody><tr><td></td></tr></tbody></table>
13172 !! html/parsoid
13173 <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"}},"i":0}},"\n|}"]}'>a</p><table about="#mwt2">
13174
13175 </table>
13176 !! end
13177
13178 !!test
13179 Templates: Wiki Tables: 1b. Fostering of entire template content
13180 !! wikitext
13181 {|
13182 {{echo|<div>}}
13183 foo
13184 {{echo|</div>}}
13185 |}
13186 !! html
13187 <table>
13188 <div>
13189 <p>foo
13190 </p>
13191 </div>
13192 <tr><td></td></tr></table>
13193
13194 !! html/php+tidy
13195 <div>
13196 <p>foo
13197 </p>
13198 </div><table>
13199
13200 <tbody><tr><td></td></tr></tbody></table>
13201 !! html/parsoid
13202 <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|}"]}'>
13203 <p>foo</p>
13204 </div><table about="#mwt3">
13205
13206 </table>
13207 !! end
13208
13209 !!test
13210 Templates: Wiki Tables: 2. Fostering of partial template content
13211 !! wikitext
13212 {|
13213 {{echo|a
13214 <div>b</div>}}
13215 |}
13216 !! html
13217 <table>
13218 a
13219 <div>b</div>
13220 <tr><td></td></tr></table>
13221
13222 !! html/php+tidy
13223
13224 a
13225 <div>b</div><table>
13226 <tbody><tr><td></td></tr></tbody></table>
13227 !! html/parsoid
13228 <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">
13229
13230
13231 </table>
13232 !! end
13233
13234 !!test
13235 Templates: Wiki Tables: 3. td-content via multiple templates
13236 !! wikitext
13237 {|
13238 {{echo|{{pipe}}a}}{{echo|b}}
13239 |}
13240 !! html
13241 <table>
13242 <tr>
13243 <td>ab
13244 </td></tr></table>
13245
13246 !!end
13247
13248 !!test
13249 Templates: Wiki Tables: 4. Templated tags, no content
13250 !! wikitext
13251 {{tbl-start}}
13252 {{tbl-end}}
13253 !! html
13254 <table>
13255 <tr><td></td></tr></table>
13256
13257 !!end
13258
13259 !!test
13260 Templates: Wiki Tables: 5. Templated tags, regular td-tags
13261 !! wikitext
13262 {{tbl-start}}
13263 |foo
13264 {{tbl-end}}
13265 !! html
13266 <table>
13267 <tr>
13268 <td>foo
13269 </td></tr></table>
13270
13271 !!end
13272
13273 !!test
13274 Templates: Wiki Tables: 6. Templated tags, templated td-tags
13275 !! wikitext
13276 {{tbl-start}}
13277 {{!}}foo
13278 {{tbl-end}}
13279 !! html
13280 <table>
13281 <tr>
13282 <td>foo
13283 </td></tr></table>
13284
13285 !!end
13286
13287 ## This test case is very specific to Parsoid's internals
13288 ## and is hence only tested for Parsoid's code. Parsoid uses
13289 ## a <meta> marker tag for <ref> tags and they are expanded
13290 ## much later. We are verifying that this <meta> tag usage
13291 ## doesn't prevent foster parenting.
13292 !!test
13293 Templates: Wiki Tables: 7. Fosterable <ref>s should get fostered
13294 !!wikitext
13295 {{PartialTable}}<ref>foo</ref>
13296 |}
13297
13298 <references />
13299 !!html/parsoid
13300 <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">
13301 <tbody>
13302 </tbody></table>
13303
13304 <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>
13305 !!end
13306
13307 !! test
13308 Templates: Wiki Tables: 8. Fosterable meta-tags should get fostered
13309 !! wikitext
13310 {{echo|
13311 {{{!}}
13312 {{!}}-}}
13313 <onlyinclude>
13314 |foo
13315 </onlyinclude>
13316 {{!}}}
13317 !! html/parsoid
13318 <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{{!}}}"]}'>
13319 </span><meta typeof="mw:Includes/OnlyInclude" about="#mwt1"/><table about="#mwt1">
13320 <tbody><tr>
13321
13322 <td>foo
13323 <meta typeof="mw:Includes/OnlyInclude/End"/></td></tr>
13324 </tbody></table>
13325 !! end
13326
13327 !!test
13328 Templates: Lists: Multi-line list-items via templates
13329 !! wikitext
13330 *{{echo|a {{nonexistent|
13331 unused}}}}
13332 *{{echo|b {{nonexistent|
13333 unused}}}}
13334 !! html
13335 <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>
13336 <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>
13337
13338 !!end
13339
13340 !!test
13341 Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo)
13342 !! wikitext
13343 {{echo|''a}}{{echo|b''c''d}}{{echo|''e}}
13344 !! html
13345 <p><i>ab</i>c<i>d</i>e
13346 </p>
13347 !!end
13348
13349 !!test
13350 Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span)
13351 (PHP parser generates misnested html)
13352 !! wikitext
13353 {{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}}
13354 !! html/parsoid
13355 <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>
13356 !!end
13357
13358 !!test
13359 Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div)
13360 (PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s)
13361 !! options
13362 parsoid=wt2html,wt2wt
13363 !! wikitext
13364 {{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}}
13365 !! html
13366 <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>
13367 <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>
13368 <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>
13369 !!end
13370
13371 !!test
13372 Templates: Ugly nesting: 4. Divs opened/closed across templates
13373 !! wikitext
13374 a<div>b{{echo|c</div>d}}e
13375 !! html
13376 a<div>bc</div>de
13377
13378 !! html+tidy
13379 <p>a</p><div>bc</div><p>de
13380 </p>
13381 !! end
13382
13383 !! test
13384 Templates: Ugly templates: 3. newline-only template parameter
13385 !! wikitext
13386 foo {{echo|
13387 }}
13388 !! html
13389 <p>foo
13390 </p>
13391 !! end
13392
13393 # This looks like a bug: a single newline triggers p/br for some reason.
13394 !! test
13395 Templates: Ugly templates: 4. newline-only template parameter inconsistency
13396 !! wikitext
13397 {{echo|
13398 }}
13399 !! html
13400 <p><br />
13401 </p>
13402 !! end
13403
13404 # T66017 -- ugly wikitext with fostered content generates two template ranges that
13405 # have a true overlap (T1-start - T2-start - T1-end - T2-end).
13406 !! test
13407 Templates: Ugly templates: 5. Template encapsulation test: Non-trivial overlap of template ranges is properly handled
13408 !! wikitext
13409 {{echo|<table>}}
13410 {{echo|<div>foo}}
13411 {{echo|</table>}}
13412 !! html/parsoid
13413 <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
13414 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13415 </table>
13416 !! end
13417
13418 # T66017 -- ugly wikitext with fostered content generates two template ranges
13419 # that are "identical" and generate nesting cycles in the algorithm
13420 !! test
13421 Templates: Ugly templates: 6. Template encapsulation test: Cyclical nesting of template ranges is properly handled
13422 !! wikitext
13423 {{echo|<table><tr><td><table>}}
13424 {{echo|<div>}}
13425 {{echo|</div>}}
13426 !! html/parsoid
13427 <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"}'>
13428 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13429 </table></td></tr></tbody></table>
13430 !! end
13431
13432 !! test
13433 Templates: Parameters substituted at the top-level
13434 !! wikitext
13435 {{{foo|''who'' {{echo|me}}? '''never!'''}}}
13436
13437 {{{foo|bar|baz}}}
13438 !! html/php
13439 <p><i>who</i> me? <b>never!</b>
13440 </p><p>bar
13441 </p>
13442 !! html/parsoid
13443 <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>
13444
13445 <p about="#mwt3" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"foo"},"params":{"1":{"wt":"bar"},"2":{"wt":"baz"}},"i":0}}]}'>bar</p>
13446 !! end
13447
13448 !! test
13449 Templates: Param with empty arg in the final position
13450 !! wikitext
13451 {{{hi|}}}
13452 !! html/parsoid
13453 <span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"hi"},"params":{"1":{"wt":""}},"i":0}}]}'></span>
13454 !! end
13455
13456 !!test
13457 Parser Functions: 1. Simple example
13458 !! wikitext
13459 {{uc:foo}}
13460 !! html
13461 <p>FOO
13462 </p>
13463 !!end
13464
13465 !!test
13466 Parser Functions: 2. Nested use (only outermost should be marked up)
13467 !! wikitext
13468 {{uc:{{lc:FOO}}}}
13469 !! html
13470 <p>FOO
13471 </p>
13472 !!end
13473
13474 ###
13475 ### Pre-save transform tests
13476 ###
13477 !! test
13478 pre-save transform: subst:
13479 !! options
13480 pst
13481 !! wikitext
13482 {{subst:test}}
13483 !! html/php
13484 This is a test template
13485 !! end
13486
13487 !! test
13488 pre-save transform: normal template
13489 !! options
13490 pst
13491 !! wikitext
13492 {{test}}
13493 !! html/php
13494 {{test}}
13495 !! end
13496
13497 !! test
13498 pre-save transform: nonexistent template
13499 !! options
13500 pst
13501 !! wikitext
13502 {{thistemplatedoesnotexist}}
13503 !! html/php
13504 {{thistemplatedoesnotexist}}
13505 !! end
13506
13507 !! test
13508 pre-save transform: subst magic variables
13509 !! options
13510 pst
13511 !! wikitext
13512 {{subst:SITENAME}}
13513 !! html/php
13514 MediaWiki
13515 !! end
13516
13517 # This is T2089, which I fixed. -- wtm
13518 !! test
13519 pre-save transform: subst: templates with parameters
13520 !! options
13521 pst
13522 !! wikitext
13523 {{subst:paramtest|param="something else"}}
13524 !! html/php
13525 This is a test template with parameter "something else"
13526 !! end
13527
13528 !! article
13529 Template:nowikitest
13530 !! text
13531 <nowiki>'''not wiki'''</nowiki>
13532 !! endarticle
13533
13534 !! test
13535 pre-save transform: nowiki in subst (T3188)
13536 !! options
13537 pst
13538 !! wikitext
13539 {{subst:nowikitest}}
13540 !! html/php
13541 <nowiki>'''not wiki'''</nowiki>
13542 !! end
13543
13544 !! article
13545 Template:commenttest
13546 !! text
13547 This template has <!-- a comment --> in it.
13548 !! endarticle
13549
13550 !! test
13551 pre-save transform: comment in subst (T3936)
13552 !! options
13553 pst
13554 !! wikitext
13555 {{subst:commenttest}}
13556 !! html/php
13557 This template has <!-- a comment --> in it.
13558 !! end
13559
13560 !! test
13561 pre-save transform: unclosed tag
13562 !! options
13563 pst
13564 !! wikitext
13565 <nowiki>'''not wiki'''
13566 !! html/php
13567 <nowiki>'''not wiki'''
13568 !! end
13569
13570 !! test
13571 pre-save transform: mixed tag case
13572 !! options
13573 pst
13574 !! wikitext
13575 <NOwiki>'''not wiki'''</noWIKI>
13576 !! html/php
13577 <NOwiki>'''not wiki'''</noWIKI>
13578 !! end
13579
13580 !! test
13581 pre-save transform: unclosed comment in <nowiki>
13582 !! options
13583 pst
13584 !! wikitext
13585 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13586 !! html/php
13587 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13588 !!end
13589
13590 # Leading @ in this template definition works around a limitation
13591 # in parsoid's parserTests which otherwise strips the <span> from the
13592 # result (confusing it for a template wrapper)
13593 !! article
13594 Template:dangerous
13595 !!text
13596 @<span onmouseover="alert('crap')">Oh no</span>
13597 !!endarticle
13598
13599 !!test
13600 (confirming safety of fix for subst T3936)
13601 !! wikitext
13602 {{Template:dangerous}}
13603 !! html
13604 <p>@<span>Oh no</span>
13605 </p>
13606 !! end
13607
13608 !! test
13609 pre-save transform: comment containing gallery (T7024)
13610 !! options
13611 pst
13612 !! wikitext
13613 <!-- <gallery>data</gallery> -->
13614 !! html/php
13615 <!-- <gallery>data</gallery> -->
13616 !!end
13617
13618 !! test
13619 pre-save transform: comment containing extension
13620 !! options
13621 pst
13622 !! wikitext
13623 <!-- <tag>data</tag> -->
13624 !! html/php
13625 <!-- <tag>data</tag> -->
13626 !!end
13627
13628 !! test
13629 pre-save transform: comment containing nowiki
13630 !! options
13631 pst
13632 !! wikitext
13633 <!-- <nowiki>data</nowiki> -->
13634 !! html/php
13635 <!-- <nowiki>data</nowiki> -->
13636 !!end
13637
13638 !! test
13639 pre-save transform: <noinclude> in subst (T5298)
13640 !! options
13641 pst
13642 !! wikitext
13643 {{subst:Includes}}
13644 !! html/php
13645 Foobar
13646 !! end
13647
13648 !! test
13649 pre-save transform: <onlyinclude> in subst (T5298)
13650 !! options
13651 pst
13652 !! wikitext
13653 {{subst:Includes2}}
13654 !! html/php
13655 Foo
13656 !! end
13657
13658 !! article
13659 Template:SubstTest
13660 !!text
13661 {{<includeonly>subst:</includeonly>Includes}}
13662 !! endarticle
13663
13664 !! article
13665 Template:SafeSubstTest
13666 !! text
13667 {{<includeonly>safesubst:</includeonly>Includes}}
13668 !! endarticle
13669
13670 !! test
13671 T24297: safesubst: works during PST
13672 !! options
13673 pst
13674 !! wikitext
13675 {{subst:SafeSubstTest}}{{safesubst:SubstTest}}
13676 !! html/php
13677 FoobarFoobar
13678 !! end
13679
13680 !! test
13681 T24297: safesubst: works during normal parse
13682 !! wikitext
13683 {{SafeSubstTest}}
13684 !! html
13685 <p>Foobar
13686 </p>
13687 !! end
13688
13689 !! test
13690 subst: does not work during normal parse
13691 !! wikitext
13692 {{SubstTest}}
13693 !! html
13694 <p>{{subst:Includes}}
13695 </p>
13696 !! end
13697
13698 !! test
13699 pre-save transform: context links ("pipe trick")
13700 !! options
13701 pst
13702 !! wikitext
13703 [[Article (context)|]]
13704 [[Bar:Article|]]
13705 [[:Bar:Article|]]
13706 [[Bar:Article (context)|]]
13707 [[:Bar:Article (context)|]]
13708 [[|Article]]
13709 [[|Article (context)]]
13710 [[Bar:X (Y) Z|]]
13711 [[:Bar:X (Y) Z|]]
13712 !! html/php
13713 [[Article (context)|Article]]
13714 [[Bar:Article|Article]]
13715 [[:Bar:Article|Article]]
13716 [[Bar:Article (context)|Article]]
13717 [[:Bar:Article (context)|Article]]
13718 [[Article]]
13719 [[Article (context)]]
13720 [[Bar:X (Y) Z|X (Y) Z]]
13721 [[:Bar:X (Y) Z|X (Y) Z]]
13722 !! end
13723
13724 !! test
13725 pre-save transform: context links ("pipe trick") with interwiki prefix
13726 !! options
13727 pst
13728 !! wikitext
13729 [[interwiki:Article|]]
13730 [[:interwiki:Article|]]
13731 [[interwiki:Bar:Article|]]
13732 [[:interwiki:Bar:Article|]]
13733 !! html/php
13734 [[interwiki:Article|Article]]
13735 [[:interwiki:Article|Article]]
13736 [[interwiki:Bar:Article|Bar:Article]]
13737 [[:interwiki:Bar:Article|Bar:Article]]
13738 !! end
13739
13740 !! test
13741 pre-save transform: context links ("pipe trick") with parens in title
13742 !! options
13743 pst title=[[Somearticle (context)]]
13744 !! wikitext
13745 [[|Article]]
13746 !! html/php
13747 [[Article (context)|Article]]
13748 !! end
13749
13750 !! test
13751 pre-save transform: context links ("pipe trick") with comma in title
13752 !! options
13753 pst title=[[Someplace, Somewhere]]
13754 !! wikitext
13755 [[|Otherplace]]
13756 [[Otherplace, Elsewhere|]]
13757 [[Otherplace, Elsewhere, Anywhere|]]
13758 !! html/php
13759 [[Otherplace, Somewhere|Otherplace]]
13760 [[Otherplace, Elsewhere|Otherplace]]
13761 [[Otherplace, Elsewhere, Anywhere|Otherplace]]
13762 !! end
13763
13764 !! test
13765 pre-save transform: context links ("pipe trick") with parens and comma
13766 !! options
13767 pst title=[[Someplace (IGNORED), Somewhere]]
13768 !! wikitext
13769 [[|Otherplace]]
13770 [[Otherplace (place), Elsewhere|]]
13771 !! html/php
13772 [[Otherplace, Somewhere|Otherplace]]
13773 [[Otherplace (place), Elsewhere|Otherplace]]
13774 !! end
13775
13776 !! test
13777 pre-save transform: context links ("pipe trick") with comma and parens
13778 !! options
13779 pst title=[[Who, me? (context)]]
13780 !! wikitext
13781 [[|Yes, you.]]
13782 [[Me, Myself, and I (1937 song)|]]
13783 !! html/php
13784 [[Yes, you. (context)|Yes, you.]]
13785 [[Me, Myself, and I (1937 song)|Me, Myself, and I]]
13786 !! end
13787
13788 !! test
13789 pre-save transform: context links ("pipe trick") with namespace
13790 !! options
13791 pst title=[[Ns:Somearticle]]
13792 !! wikitext
13793 [[|Article]]
13794 !! html/php
13795 [[Ns:Article|Article]]
13796 !! end
13797
13798 !! test
13799 pre-save transform: context links ("pipe trick") with namespace and parens
13800 !! options
13801 pst title=[[Ns:Somearticle (context)]]
13802 !! wikitext
13803 [[|Article]]
13804 !! html/php
13805 [[Ns:Article (context)|Article]]
13806 !! end
13807
13808 !! test
13809 pre-save transform: context links ("pipe trick") with namespace and comma
13810 !! options
13811 pst title=[[Ns:Somearticle, Context, Whatever]]
13812 !! wikitext
13813 [[|Article]]
13814 !! html/php
13815 [[Ns:Article, Context, Whatever|Article]]
13816 !! end
13817
13818 !! test
13819 pre-save transform: context links ("pipe trick") with namespace, comma and parens
13820 !! options
13821 pst title=[[Ns:Somearticle, Context (context)]]
13822 !! wikitext
13823 [[|Article]]
13824 !! html/php
13825 [[Ns:Article (context)|Article]]
13826 !! end
13827
13828 !! test
13829 pre-save transform: context links ("pipe trick") with namespace, parens and comma
13830 !! options
13831 pst title=[[Ns:Somearticle (IGNORED), Context]]
13832 !! wikitext
13833 [[|Article]]
13834 !! html/php
13835 [[Ns:Article, Context|Article]]
13836 !! end
13837
13838 !! test
13839 pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, T32149)
13840 !! options
13841 pst
13842 !! wikitext
13843 [[Article(context)|]]
13844 [[Bar:Article(context)|]]
13845 [[:Bar:Article(context)|]]
13846 [[|Article(context)]]
13847 [[Bar:X(Y)Z|]]
13848 [[:Bar:X(Y)Z|]]
13849 !! html/php
13850 [[Article(context)|Article]]
13851 [[Bar:Article(context)|Article]]
13852 [[:Bar:Article(context)|Article]]
13853 [[Article(context)]]
13854 [[Bar:X(Y)Z|X(Y)Z]]
13855 [[:Bar:X(Y)Z|X(Y)Z]]
13856 !! end
13857
13858 !! test
13859 pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, T32149)
13860 !! options
13861 pst
13862 !! wikitext
13863 [[Article (context)|]]
13864 [[Bar:Article (context)|]]
13865 [[:Bar:Article (context)|]]
13866 [[|Article (context)]]
13867 [[Bar:X (Y) Z|]]
13868 [[:Bar:X (Y) Z|]]
13869 !! html/php
13870 [[Article (context)|Article]]
13871 [[Bar:Article (context)|Article]]
13872 [[:Bar:Article (context)|Article]]
13873 [[Article (context)]]
13874 [[Bar:X (Y) Z|X (Y) Z]]
13875 [[:Bar:X (Y) Z|X (Y) Z]]
13876 !! end
13877
13878 !! test
13879 pre-save transform: context links ("pipe trick") with parens and no space (Korean style, T32149)
13880 !! options
13881 pst
13882 !! wikitext
13883 [[Article(context)|]]
13884 [[Bar:Article(context)|]]
13885 [[:Bar:Article(context)|]]
13886 [[|Article(context)]]
13887 [[Bar:X(Y)Z|]]
13888 [[:Bar:X(Y)Z|]]
13889 !! html/php
13890 [[Article(context)|Article]]
13891 [[Bar:Article(context)|Article]]
13892 [[:Bar:Article(context)|Article]]
13893 [[Article(context)]]
13894 [[Bar:X(Y)Z|X(Y)Z]]
13895 [[:Bar:X(Y)Z|X(Y)Z]]
13896 !! end
13897
13898 !! test
13899 pre-save transform: context links ("pipe trick") with commas (T23660)
13900 !! options
13901 pst
13902 !! wikitext
13903 [[Article (context), context|]]
13904 [[Article (context),context|]]
13905 [[Bar:Article (context), context|]]
13906 [[Bar:Article (context),context|]]
13907 [[:Bar:Article (context), context|]]
13908 [[:Bar:Article (context),context|]]
13909 !! html/php
13910 [[Article (context), context|Article]]
13911 [[Article (context),context|Article]]
13912 [[Bar:Article (context), context|Article]]
13913 [[Bar:Article (context),context|Article]]
13914 [[:Bar:Article (context), context|Article]]
13915 [[:Bar:Article (context),context|Article]]
13916 !! end
13917
13918 !! test
13919 Parsoid: backwards pipe trick
13920 !! wikitext
13921 [[|'''bar''']]
13922 !! html/php
13923 <p>[[|<b>bar</b>]]
13924 </p>
13925 !! html/parsoid
13926 <p>[[|<b>bar</b>]]</p>
13927 !! end
13928
13929 !! test
13930 pre-save transform: trim trailing empty lines
13931 !! options
13932 pst
13933 !! wikitext
13934 Empty lines are trimmed
13935
13936
13937
13938
13939 !! html/php
13940 Empty lines are trimmed
13941 !! end
13942
13943 !! test
13944 pre-save transform: Signature expansion
13945 !! options
13946 pst
13947 !! wikitext
13948 * ~~~
13949 * ~~~~
13950 * ~~~~~
13951 * <noinclude>~~~</noinclude>
13952 * <includeonly>~~~</includeonly>
13953 * <onlyinclude>~~~</onlyinclude>
13954 !! html/php
13955 * [[Special:Contributions/127.0.0.1|127.0.0.1]]
13956 * [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
13957 * 00:02, 1 January 1970 (UTC)
13958 * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
13959 * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
13960 * <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>
13961 !! end
13962
13963
13964 !! test
13965 ParserOutput flags from signature expansion (T84843)
13966 !! options
13967 pst
13968 showflags
13969 !! wikitext
13970 ~~~~
13971 !! html/php
13972 [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
13973 flags=user-signature
13974 !! end
13975
13976
13977 !! test
13978 pre-save transform: Signature expansion in nowiki tags (T2093)
13979 !! options
13980 pst disabled
13981 !! wikitext
13982 Shall not expand:
13983
13984 <nowiki>~~~~</nowiki>
13985
13986 <includeonly><nowiki>~~~~</nowiki></includeonly>
13987
13988 <noinclude><nowiki>~~~~</nowiki></noinclude>
13989
13990 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
13991
13992 {{subst:Foo}} shall be converted to FOO
13993
13994 As well as inside noinclude/onlyinclude
13995 <noinclude>{{subst:Foo}}</noinclude>
13996 <onlyinclude>{{subst:Foo}}</onlyinclude>
13997
13998 But not inside includeonly
13999 <includeonly>{{subst:Foo}}</includeonly>
14000 !! html/php
14001 Shall not expand:
14002
14003 <nowiki>~~~~</nowiki>
14004
14005 <includeonly><nowiki>~~~~</nowiki></includeonly>
14006
14007 <noinclude><nowiki>~~~~</nowiki></noinclude>
14008
14009 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14010
14011 FOO shall be converted to FOO
14012
14013 As well as inside noinclude/onlyinclude
14014 <noinclude>FOO</noinclude>
14015 <onlyinclude>FOO</onlyinclude>
14016
14017 But not inside includeonly
14018 <includeonly>{{subst:Foo}}</includeonly>
14019 !! end
14020
14021 !! test
14022 Parsoid: Recognize nowiki with trailing space in tags
14023 !! options
14024 parsoid=wt2html
14025 !! wikitext
14026 <nowiki ><div>[[foo]]</nowiki >
14027
14028 a<nowiki / >b
14029
14030 c<nowiki />d
14031
14032 e<nowiki/ >f
14033 !! html
14034 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
14035 <p>ab</p>
14036 <p>cd</p>
14037 <p>ef</p>
14038 !! end
14039
14040 !! test
14041 Parsoid: Recognize nowiki with odd capitalization
14042 !! options
14043 parsoid=wt2html
14044 !! wikitext
14045 <noWikI ><div>[[foo]]</Nowiki >
14046 !! html
14047 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
14048 !! end
14049
14050
14051 !! test
14052 Parsoid: Escape nowiki with trailing space in tags
14053 !! options
14054 parsoid=html2wt
14055 !! html/parsoid
14056 <p>&lt;nowiki &gt; foo &lt/nowiki ></p>
14057 <p>a&lt;nowiki /&gt;b</p>
14058 <p>c&lt;nowiki/ &gt;d</p>
14059 !! wikitext
14060 &lt;nowiki &gt; foo &lt;/nowiki &gt;
14061
14062 a&lt;nowiki /&gt;b
14063
14064 c&lt;nowiki/ &gt;d
14065 !! end
14066
14067 !! test
14068 Parsoid: Escape weird noWikI capitalizations
14069 !! options
14070 parsoid=html2wt
14071 !! html/parsoid
14072 <p>&lt;noWikI &gt; foo &lt/NoWikI ></p>
14073 !! wikitext
14074 &lt;noWikI &gt; foo &lt;/NoWikI &gt;
14075 !! end
14076
14077 ###
14078 ### Message transform tests
14079 ###
14080 !! test
14081 message transform: magic variables
14082 !! options
14083 msg
14084 !! wikitext
14085 {{SITENAME}}
14086 !! html
14087 MediaWiki
14088 !! end
14089
14090 !! test
14091 message transform: should not transform wiki markup
14092 !! options
14093 msg
14094 !! wikitext
14095 ''test''
14096 !! html
14097 ''test''
14098 !! end
14099
14100 !! test
14101 message transform: <noinclude> in transcluded template (T6926)
14102 !! options
14103 msg
14104 !! wikitext
14105 {{Includes}}
14106 !! html
14107 Foobar
14108 !! end
14109
14110 !! test
14111 message transform: <onlyinclude> in transcluded template (T6926)
14112 !! options
14113 msg
14114 !! wikitext
14115 {{Includes2}}
14116 !! html
14117 Foo
14118 !! end
14119
14120 !! test
14121 {{#special:}} page name, known
14122 !! options
14123 msg
14124 !! wikitext
14125 {{#special:Recentchanges}}
14126 !! html
14127 Special:RecentChanges
14128 !! end
14129
14130 !! test
14131 {{#special:}} page name with subpage, known
14132 !! options
14133 msg
14134 !! wikitext
14135 {{#special:Recentchanges/param}}
14136 !! html
14137 Special:RecentChanges/param
14138 !! end
14139
14140 !! test
14141 {{#special:}} page name, unknown
14142 !! options
14143 msg
14144 !! wikitext
14145 {{#special:foobar nonexistent}}
14146 !! html
14147 Special:Foobar nonexistent
14148 !! end
14149
14150 !! test
14151 {{#speciale:}} page name, known
14152 !! options
14153 msg
14154 !! wikitext
14155 {{#speciale:Recentchanges}}
14156 !! html
14157 Special:RecentChanges
14158 !! end
14159
14160 !! test
14161 {{#speciale:}} page name with subpage, known
14162 !! options
14163 msg
14164 !! wikitext
14165 {{#speciale:Recentchanges/param}}
14166 !! html
14167 Special:RecentChanges/param
14168 !! end
14169
14170 !! test
14171 {{#speciale:}} page name, unknown
14172 !! options
14173 msg
14174 !! wikitext
14175 {{#speciale:foobar nonexistent}}
14176 !! html
14177 Special:Foobar_nonexistent
14178 !! end
14179
14180 ###
14181 ### Images
14182 ###
14183 ### For Parsoid-specific tests, see
14184 #### https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
14185
14186 !! test
14187 Simple image
14188 !! options
14189 parsoid=wt2html,wt2wt,html2html
14190 !! wikitext
14191 [[Image:foobar.jpg]]
14192 !! html/php
14193 <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>
14194 </p>
14195 !! html/parsoid
14196 <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>
14197 !! end
14198
14199 !! test
14200 Serialize simple image with span wrapper
14201 !! options
14202 parsoid=html2wt
14203 !! html/parsoid
14204 <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>
14205 !! wikitext
14206 [[File:Foobar.jpg]]
14207 !! end
14208
14209 !! test
14210 Simple image (using File: namespace, now canonical)
14211 !! wikitext
14212 [[File:Foobar.jpg]]
14213 !! html/php
14214 <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>
14215 </p>
14216 !! html/parsoid
14217 <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>
14218 !! end
14219
14220 !! test
14221 Right-aligned image
14222 !! wikitext
14223 [[File:Foobar.jpg|right]]
14224 !! html/php
14225 <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>
14226
14227 !! html/parsoid
14228 <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>
14229 !! end
14230
14231 !! test
14232 Image with caption
14233 !! wikitext
14234 [[File:Foobar.jpg|right|Caption text]]
14235 !! html/php
14236 <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>
14237
14238 !! html/parsoid
14239 <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>
14240 !! end
14241
14242 !! test
14243 Image with caption, T55312 #1
14244 !! wikitext
14245 [[File:Foobar.jpg|right|Caption page stuff]]
14246 !! html/php
14247 <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>
14248
14249 !! html/parsoid
14250 <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>
14251 !! end
14252
14253 !! test
14254 Image with caption, T55312 #2
14255 !! wikitext
14256 [[File:Foobar.jpg|right|Caption page=]]
14257 !! html/php
14258 <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>
14259
14260 !! html/parsoid
14261 <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>
14262 !! end
14263
14264 !! test
14265 Image with caption, T55312 #3
14266 !! wikitext
14267 [[File:Foobar.jpg|right|Caption page=stuff]]
14268 !! html/php
14269 <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>
14270
14271 !! html/parsoid
14272 <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>
14273 !! end
14274
14275 !! test
14276 Image caption with pipe entity
14277 !! wikitext
14278 [[File:Foobar.jpg|thumb|one &#x7C; two]]
14279 [[File:Foobar.jpg|thumb|one ''two'' &#x7C; three]]
14280 !! html/php
14281 <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>
14282 <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>
14283
14284 !! html/parsoid
14285 <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>
14286 <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>
14287 !! end
14288
14289 !! test
14290 Allow empty links in image captions (T62753)
14291 !! options
14292 thumbsize=220
14293 !! wikitext
14294 [[File:Foobar.jpg|thumb|Caption [[Link1]]
14295 [[]]
14296 [[Link2]]
14297 ]]
14298 !! html/php
14299 <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>
14300
14301 !! html/parsoid
14302 <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>
14303 [[]]
14304 <a rel="mw:WikiLink" href="./Link2" title="Link2" data-parsoid='{"stx":"simple","a":{"href":"./Link2"},"sa":{"href":"Link2"}}'>Link2</a>
14305 </figcaption></figure>
14306 !! end
14307
14308 !! test
14309 Titles in unlinked images (T23454)
14310 !! wikitext
14311 [[File:Foobar.jpg|link=|stuff]]
14312 !! html/php
14313 <p><img alt="stuff" src="http://example.com/images/3/3a/Foobar.jpg" title="stuff" width="1941" height="220" />
14314 </p>
14315 !! html/parsoid
14316 <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>
14317 !! end
14318
14319 !! test
14320 Link with empty target
14321 !! wikitext
14322 [[]]
14323 !! html
14324 <p>[[]]
14325 </p>
14326 !! end
14327
14328 !! test
14329 Image with link trail
14330 !! wikitext
14331 Linktrails should not work for images: [[File:Foobar.jpg]]s
14332 !! html/php
14333 <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
14334 </p>
14335 !! html/parsoid
14336 <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>
14337 !! end
14338
14339 !! test
14340 Image with empty attribute
14341 !! options
14342 parsoid=wt2html,wt2wt,html2html
14343 !! wikitext
14344 [[File:Foobar.jpg|right||Caption text]]
14345 !! html/php
14346 <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>
14347
14348 !! html/parsoid
14349 <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>
14350 !! end
14351
14352 !! test
14353 1. Block image with individual attributes from templates
14354 !! wikitext
14355 [[File:Foobar.jpg|thumb|{{echo|137px}}|This is a caption]]
14356 !! html/php
14357 <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>
14358
14359 !! html/parsoid
14360 <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>
14361 !! end
14362
14363 !! test
14364 2. Block Image with individual attributes from templates
14365 !! wikitext
14366 [[File:Foobar.jpg|{{echo|thumb}}|{{echo|137px}}|This is a caption]]
14367 !! html/php
14368 <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>
14369
14370 !! html/parsoid
14371 <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>
14372 !! end
14373
14374 !! test
14375 3. Inline image with individual attributes from templates
14376 !! wikitext
14377 [[File:Foobar.jpg|{{echo|50px}}]]
14378 !! html/php
14379 <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>
14380 </p>
14381 !! html/parsoid
14382 <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>
14383 !! end
14384
14385 ## Parsoid does not provide editing support for images where templates produce multiple image attributes.
14386 ## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
14387 !! test
14388 Image with multiple attributes from the same template
14389 !! wikitext
14390 [[File:Foobar.jpg|{{image_attribs}}]]
14391 !! html/php
14392 <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>
14393
14394 !! html/parsoid
14395 <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>
14396 !! end
14397
14398 !! test
14399 Image with link tails
14400 !! options
14401 thumbsize=220
14402 !! wikitext
14403 123[[File:Foobar.jpg]]456
14404 123[[File:Foobar.jpg|right]]456
14405 123[[File:Foobar.jpg|thumb]]456
14406 !! html/php
14407 <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
14408 </p>
14409 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
14410 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
14411
14412 !! html/php+tidy
14413 <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
14414 </p><p>
14415 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
14416 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
14417 </p>
14418 !! html/parsoid
14419 <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>
14420 <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>
14421 <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>
14422 !! end
14423
14424 !! test
14425 Image with multiple captions -- only last one is accepted
14426 !! wikitext
14427 [[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]]
14428 !! html/php
14429 <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>
14430
14431 !! html/parsoid
14432 <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>
14433 !! end
14434
14435 !! test
14436 Image with multiple widths -- use last
14437 !! wikitext
14438 [[File:Foobar.jpg|200px|300px|caption]]
14439 !! html/php
14440 <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>
14441 </p>
14442 !! html/parsoid
14443 <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>
14444 !! end
14445
14446 !! test
14447 Image with multiple alignments -- use first (T50664)
14448 !! options
14449 thumbsize=220
14450 !! wikitext
14451 [[File:Foobar.jpg|thumb|left|right|center|caption]]
14452
14453 [[File:Foobar.jpg|middle|text-top|caption]]
14454 !! html/php
14455 <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>
14456 <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>
14457 </p>
14458 !! html/parsoid
14459 <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>
14460 <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>
14461 !! end
14462
14463 !! test
14464 Image with width attribute at different positions
14465 !! wikitext
14466 [[File:Foobar.jpg|200px|right|Caption]]
14467 [[File:Foobar.jpg|right|200px|Caption]]
14468 [[File:Foobar.jpg|right|Caption|200px]]
14469 !! html/php
14470 <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>
14471 <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>
14472 <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>
14473
14474 !! html/parsoid
14475 <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>
14476 <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>
14477 <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>
14478 !! end
14479
14480 # a sad bit of backward-compatibility
14481 !! test
14482 Image with size specified with pxpx (T15500, T53628)
14483 !! options
14484 parsoid=wt2html,wt2wt,html2html
14485 !! wikitext
14486 [[File:Foobar.jpg|20pxpx]]
14487 [[File:Foobar.jpg|200x20pxpx]]
14488 !! html/php
14489 <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>
14490 <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>
14491 </p>
14492 !! html/parsoid
14493 <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>
14494 !! end
14495
14496 !! test
14497 Image with link parameter, wiki target
14498 !! wikitext
14499 [[File:Foobar.jpg|link=Main Page]]
14500 !! html/php
14501 <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>
14502 </p>
14503 !! html/parsoid
14504 <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>
14505 !! end
14506
14507 # parsoid T51293 (part 1)
14508 !! test
14509 Image with link parameter, URL target
14510 !! wikitext
14511 [[File:Foobar.jpg|link=http://example.com/]]
14512 !! html/php
14513 <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>
14514 </p>
14515 !! html/parsoid
14516 <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>
14517 !! end
14518
14519 # parsoid T51293 (part 2)
14520 !! test
14521 Image with link parameter, protocol-less URL target
14522 !! wikitext
14523 [[File:Foobar.jpg|link=//example.com/]]
14524 !! html/php
14525 <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>
14526 </p>
14527 !! html/parsoid
14528 <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>
14529 !! end
14530
14531 !! test
14532 Escaping non-block captions (T107435)
14533 !! options
14534 parsoid={
14535 "modes": ["wt2wt"],
14536 "changes": [
14537 ["[typeof~='mw:Image']", "attr", "data-mw", "{\"caption\": \"|\"}"]
14538 ]
14539 }
14540 !! wikitext
14541 [[Image:Foobar.jpg|caption]]
14542 !! wikitext/edited
14543 [[Image:Foobar.jpg|<nowiki>|</nowiki>]]
14544 !! end
14545
14546 # wgExternalLinkTarget not supported by Parsoid
14547 !! test
14548 Image with link parameter, wgExternalLinkTarget
14549 !! wikitext
14550 [[Image:foobar.jpg|link=http://example.com/]]
14551 !! config
14552 wgExternalLinkTarget='foobar'
14553 !! html/php
14554 <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>
14555 </p>
14556 !! end
14557
14558 !! test
14559 Image with link parameter, wgNoFollowLinks set to false
14560 !! wikitext
14561 [[Image:foobar.jpg|link=http://example.com/]]
14562 !! config
14563 wgNoFollowLinks=false
14564 !! html/php
14565 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14566 </p>
14567 !! end
14568
14569 !! test
14570 Image with link parameter, wgNoFollowDomainExceptions
14571 !! wikitext
14572 [[Image:foobar.jpg|link=http://example.com/]]
14573 !! config
14574 wgNoFollowDomainExceptions='example.com'
14575 !! html/php
14576 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14577 </p>
14578 !! end
14579
14580 # wgExternalLinkTarget not supported by Parsoid
14581 !! test
14582 Image with link parameter, wgExternalLinkTarget, unnamed parameter
14583 !! wikitext
14584 [[Image:foobar.jpg|link=http://example.com/|Title]]
14585 !! config
14586 wgExternalLinkTarget='foobar'
14587 !! html/php
14588 <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>
14589 </p>
14590 !! end
14591
14592 !! test
14593 Image with empty link parameter
14594 !! wikitext
14595 [[File:Foobar.jpg|link=]]
14596 !! html/php
14597 <p><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" />
14598 </p>
14599 !! html/parsoid
14600 <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>
14601 !! end
14602
14603 !! test
14604 Image with link parameter (wiki target) and unnamed parameter
14605 !! wikitext
14606 [[File:Foobar.jpg|link=Main_Page|Title]]
14607 !! html/php
14608 <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>
14609 </p>
14610 !! html/parsoid
14611 <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>
14612 !! end
14613
14614 !! test
14615 Image with link parameter (URL target) and unnamed parameter
14616 !! wikitext
14617 [[File:Foobar.jpg|link=http://example.com/|Title]]
14618 !! html/php
14619 <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>
14620 </p>
14621 !! html/parsoid
14622 <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>
14623 !! end
14624
14625 !! test
14626 Thumbnail image with link parameter
14627 !! options
14628 thumbsize=220
14629 parsoid=wt2html,wt2wt,html2html
14630 !! wikitext
14631 [[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
14632 !! html/php
14633 <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>
14634
14635 !! html/parsoid
14636 <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>
14637 !! end
14638
14639 !! test
14640 Manually-specified thumbnail image
14641 !! options
14642 thumbsize=220
14643 !! wikitext
14644 [[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
14645 !! html/php
14646 <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>
14647
14648 !! html/parsoid
14649 <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>
14650 !! end
14651
14652 !! test
14653 Manually-specified thumbnail image with explicit link to wiki page
14654 !! options
14655 thumbsize=220
14656 parsoid=wt2html,wt2wt,html2html
14657 !! wikitext
14658 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
14659 !! html/php
14660 <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>
14661
14662 !! html/parsoid
14663 <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>
14664 !! end
14665
14666 !! test
14667 Manually-specified thumbnail image with explicit link to url
14668 !! options
14669 thumbsize=220
14670 parsoid=wt2html,wt2wt,html2html
14671 !! wikitext
14672 [[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
14673 !! html/php
14674 <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>
14675
14676 !! html/parsoid
14677 <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>
14678 !! end
14679
14680 !! test
14681 Manually-specified thumbnail image with explicit no link
14682 !! options
14683 thumbsize=220
14684 parsoid=wt2html,wt2wt,html2html
14685 !! wikitext
14686 [[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
14687 !! html/php
14688 <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>
14689
14690 !! html/parsoid
14691 <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>
14692 !! end
14693
14694 !! test
14695 Manually-specified thumbnail image with explicit link and alt text
14696 !! options
14697 thumbsize=220
14698 parsoid=wt2html,wt2wt,html2html
14699 !! wikitext
14700 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
14701 !! html/php
14702 <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>
14703
14704 !! html/parsoid
14705 <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>
14706 !! end
14707
14708 !! test
14709 Image with frame and link
14710 !! options
14711 parsoid=wt2html,wt2wt,html2html
14712 !! wikitext
14713 [[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
14714 !! html/php
14715 <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>
14716
14717 !! html/parsoid
14718 <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>
14719 !! end
14720
14721 !! test
14722 Image with frame and link and explicit alt
14723 !! options
14724 parsoid=wt2html,wt2wt,html2html
14725 !! wikitext
14726 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]]
14727 !! html/php
14728 <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>
14729
14730 !! html/parsoid
14731 <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>
14732 !! end
14733
14734 !! test
14735 Image with wiki markup in implicit alt
14736 !! wikitext
14737 [[Image:Foobar.jpg|testing '''bold''' in alt]]
14738
14739 [[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
14740 !! html/php
14741 <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>
14742 </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>
14743 </p>
14744 !! html/parsoid
14745 <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>
14746
14747 <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>
14748 !! end
14749
14750 !! test
14751 Alt image option should handle most kinds of wikitext without barfing
14752 !! wikitext
14753 [[Image:Foobar.jpg|thumb|This is the image caption|alt=This is a [[link]] and a {{echo|''bold template''}}.]]
14754 !! html/php
14755 <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>
14756
14757 !! html/parsoid
14758 <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>
14759 !! end
14760
14761 !! test
14762 Image with table with attributes in caption
14763 !! options
14764 parsoid=wt2html,html2html
14765 !! wikitext
14766 [[File:Foobar.jpg|thumb|
14767 {| class="123" |
14768 |- class="456" |
14769 | ha
14770 |}
14771 ]]
14772 !! html/parsoid
14773 <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>
14774 <table class="123">
14775 <tbody><tr class="456" data-parsoid='{"startTagSrc":"|-"}'>
14776 <td> ha</td></tr>
14777 </tbody></table>
14778 </figcaption></figure>
14779 !! end
14780
14781 !! test
14782 Image with table with rows from templates in caption
14783 !! wikitext
14784 [[File:Foobar.jpg|thumb|
14785 {|
14786 {{echo|{{!}} hi}}
14787 |}
14788 ]]
14789 !! html/parsoid
14790 <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>
14791 <table>
14792 <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>
14793 </tbody></table>
14794 </figcaption></figure>
14795 !! end
14796
14797 !! test
14798 Image with nested tables in caption
14799 !! wikitext
14800 [[File:Foobar.jpg|thumb|Foo<br />
14801 {|
14802 |
14803 {|
14804 |z
14805 |}
14806 |}
14807 ]]
14808 !! html/parsoid
14809 <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}'/>
14810 <table>
14811 <tbody><tr><td>
14812 <table>
14813 <tbody><tr><td>z</td></tr>
14814 </tbody></table></td></tr>
14815 </tbody></table>
14816 </figcaption></figure>
14817 !! end
14818
14819 ###################
14820 # Conflicting image format options.
14821 # First option specified should 'win'.
14822 # All three cases in each test should be identical.
14823
14824 !! test
14825 Image with 'frameless' first.
14826 !! options
14827 parsoid=wt2html,wt2wt,html2html
14828 !! wikitext
14829 [[File:Foobar.jpg|frameless|caption]]
14830
14831 [[File:Foobar.jpg|frameless|frame|caption]]
14832
14833 [[File:Foobar.jpg|frameless|thumb|caption]]
14834 !! html/php
14835 <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>
14836 </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>
14837 </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>
14838 </p>
14839 !! html/parsoid
14840 <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>
14841 <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>
14842 <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>
14843 !! end
14844
14845 !! test
14846 Image with 'frame' first.
14847 !! options
14848 parsoid=wt2html,wt2wt,html2html
14849 !! wikitext
14850 [[File:Foobar.jpg|frame|caption]]
14851 [[File:Foobar.jpg|frame|frameless|caption]]
14852 [[File:Foobar.jpg|frame|thumb|caption]]
14853 !! html/php
14854 <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>
14855 <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>
14856 <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>
14857
14858 !! html/parsoid
14859 <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>
14860 <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>
14861 <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>
14862 !! end
14863
14864 !! test
14865 Image with 'thumb' first.
14866 !! options
14867 parsoid=wt2html,wt2wt,html2html
14868 !! wikitext
14869 [[File:Foobar.jpg|thumb|caption]]
14870 [[File:Foobar.jpg|thumb|frameless|caption]]
14871 [[File:Foobar.jpg|thumb|frame|caption]]
14872 !! html/php
14873 <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>
14874 <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>
14875 <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>
14876
14877 !! html/parsoid
14878 <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>
14879 <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>
14880 <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>
14881 !! end
14882
14883 ###################
14884 # Image sizing.
14885 # See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
14886 # and https://phabricator.wikimedia.org/T64258
14887 # Foobar has actual size of 1941x220
14888 # 1. Thumbs & frameless always reduce, can't be enlarged unless it's
14889 # a scalable format.
14890 # 2. Framed images always ignore size options; always render at default size.
14891 # 3. "Unspecified format" and border are the only types which can be
14892 # enlarged.
14893
14894 !! test
14895 Image: unspecified format and border enlarge
14896 !! options
14897 parsoid=wt2html,wt2wt,html2html
14898 !! wikitext
14899 [[File:Foobar.jpg|2000px]]
14900
14901 [[File:Foobar.jpg|border|2000px]]
14902 !! html/php
14903 <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>
14904 </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>
14905 </p>
14906 !! html/parsoid
14907 <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>
14908 <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>
14909 !! end
14910
14911 !! test
14912 Image: "unspecified format" and border reduce
14913 !! options
14914 parsoid=wt2html,wt2wt,html2html
14915 !! wikitext
14916 [[File:Foobar.jpg|1000px]]
14917
14918 [[File:Foobar.jpg|border|1000px]]
14919 !! html/php
14920 <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>
14921 </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>
14922 </p>
14923 !! html/parsoid
14924 <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>
14925 <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>
14926 !! end
14927
14928 !! test
14929 Image: thumbs reduce
14930 !! options
14931 parsoid=wt2html,wt2wt,html2html
14932 !! wikitext
14933 [[File:Foobar.jpg|thumb|50px]]
14934 !! html/php
14935 <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>
14936
14937 !! html/parsoid
14938 <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>
14939 !! end
14940
14941 !! test
14942 Image: bitmap thumbs can't be enlarged past original size, but vector can.
14943 !! options
14944 parsoid=wt2html,wt2wt,html2html
14945 !! wikitext
14946 [[File:Foobar.jpg|thumb|2000px]]
14947
14948 [[File:Foobar.svg|thumb|2000px]]
14949 !! html/php
14950 <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>
14951 <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>
14952
14953 !! html/parsoid
14954 <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>
14955 <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>
14956 !! end
14957
14958 !! test
14959 Image: frameless can reduce in size
14960 !! options
14961 parsoid=wt2html,wt2wt,html2html
14962 !! wikitext
14963 [[File:Foobar.jpg|frameless|50px]]
14964 !! html/php
14965 <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>
14966 </p>
14967 !! html/parsoid
14968 <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>
14969 !! end
14970
14971 !! test
14972 Image: bitmap frameless can't be enlarged past original size, but vector can
14973 !! options
14974 parsoid=wt2html,wt2wt,html2html
14975 !! wikitext
14976 [[File:Foobar.jpg|frameless|2000px]]
14977
14978 [[File:Foobar.svg|frameless|2000px]]
14979 !! html/php
14980 <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>
14981 </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>
14982 </p>
14983 !! html/parsoid
14984 <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>
14985 <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>
14986 !! end
14987
14988 !! test
14989 Image: framed images are always unscaled.
14990 !! options
14991 parsoid=wt2html,wt2wt,html2html
14992 !! wikitext
14993 [[File:Foobar.jpg|frame]]
14994
14995 [[File:Foobar.jpg|frame|50px]]
14996
14997 [[File:Foobar.jpg|frame|50x50px]]
14998
14999 [[File:Foobar.jpg|frame|2000px]]
15000 !! html/php
15001 <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>
15002 <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>
15003 <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>
15004 <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>
15005
15006 !! html/parsoid
15007 <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>
15008 <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>
15009 <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>
15010 <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>
15011 !! end
15012
15013 ###################
15014
15015 !! test
15016 Link to image page- image page normally doesn't exists, hence edit link
15017 Add test with existing image page
15018 #<p><a href="/wiki/File:Test" title="Image:Test">Image:test</a>
15019 !! wikitext
15020 [[:Image:test]]
15021 !! html
15022 <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>
15023 </p>
15024 !! end
15025
15026 !! test
15027 T20784 Link to non-existent image page with caption should use caption as link text
15028 !! wikitext
15029 [[:Image:test|caption]]
15030 !! html
15031 <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>
15032 </p>
15033 !! end
15034
15035 !! test
15036 Frameless image caption with a free URL
15037 !! wikitext
15038 [[File:Foobar.jpg|http://example.com]]
15039 !! html/php
15040 <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>
15041 </p>
15042 !! html/parsoid
15043 <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>
15044 !! end
15045
15046 !! test
15047 Thumbnail image caption with a free URL
15048 !! options
15049 thumbsize=220
15050 !! wikitext
15051 [[File:Foobar.jpg|thumb|http://example.com]]
15052 !! html/php
15053 <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>
15054
15055 !! html/parsoid
15056 <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>
15057 !! end
15058
15059 !! test
15060 Thumbnail image caption with a free URL and explicit alt
15061 !! options
15062 thumbsize=220
15063 parsoid=wt2html,wt2wt,html2html
15064 !! wikitext
15065 [[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]]
15066 !! html/php
15067 <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>
15068
15069 !! html/parsoid
15070 <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>
15071 !! end
15072
15073 !! test
15074 SVG thumbnails with no language set
15075 !! options
15076 !! wikitext
15077 [[File:Foobar.svg|thumb|caption]]
15078 !! html/php
15079 <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>
15080
15081 !! html/parsoid
15082 <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>
15083 !! end
15084
15085 !! test
15086 SVG thumbnails with language de
15087 !! options
15088 parsoid=wt2html,wt2wt,html2html
15089 !! wikitext
15090 [[File:Foobar.svg|thumb|caption|lang=de]]
15091 !! html/php
15092 <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>
15093
15094 !! html/parsoid
15095 <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>
15096 !! end
15097
15098 !! test
15099 SVG thumbnails with invalid language code
15100 !! options
15101 parsoid=wt2html,wt2wt,html2html
15102 !! wikitext
15103 [[File:Foobar.svg|thumb|caption|lang=invalid:language:code]]
15104 !! html/php
15105 <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>
15106
15107 !! html/parsoid
15108 <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>
15109 !! end
15110
15111 !! test
15112 T3887: A ISBN with a thumbnail
15113 !! wikitext
15114 [[File:Foobar.jpg|thumb|ISBN 1235467890]]
15115 !! html/php
15116 <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>
15117
15118 !! html/parsoid
15119 <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>
15120 !! end
15121
15122 !! test
15123 T3887: A RFC with a thumbnail
15124 !! wikitext
15125 [[File:Foobar.jpg|thumb|This is RFC 12354]]
15126 !! html/php
15127 <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>
15128
15129 !! html/parsoid
15130 <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>
15131 !! end
15132
15133 !! test
15134 T3887: A mailto link with a thumbnail
15135 !! wikitext
15136 [[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
15137 !! html/php
15138 <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>
15139
15140 !! html/parsoid
15141 <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>
15142 !! end
15143
15144 # Pending resolution to T2368
15145 !! test
15146 T2648: Frameless image caption with a link
15147 !! wikitext
15148 [[File:Foobar.jpg|text with a [[link]] in it]]
15149 !! html/php
15150 <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>
15151 </p>
15152 !! html/parsoid
15153 <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>
15154 !! end
15155
15156 !! test
15157 T2648: Frameless image caption with a link (suffix)
15158 !! wikitext
15159 [[File:Foobar.jpg|text with a [[link]]foo in it]]
15160 !! html/php
15161 <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>
15162 </p>
15163 !! html/parsoid
15164 <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>
15165 !! end
15166
15167 !! test
15168 T2648: Frameless image caption with an interwiki link
15169 !! wikitext
15170 [[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
15171 !! html/php
15172 <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>
15173 </p>
15174 !! html/parsoid
15175 <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>
15176 !! end
15177
15178 !! test
15179 T2648: Frameless image caption with a piped interwiki link
15180 !! wikitext
15181 [[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
15182 !! html/php
15183 <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>
15184 </p>
15185 !! html/parsoid
15186 <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>
15187 !! end
15188
15189 !! test
15190 T107474: Frameless image caption with <nowiki>
15191 !! wikitext
15192 [[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]]
15193 !! html/parsoid
15194 <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>
15195 !! end
15196
15197 !! test
15198 Escape HTML special chars in image alt text
15199 !! wikitext
15200 [[File:Foobar.jpg|& < > "]]
15201 !! html/php
15202 <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>
15203 </p>
15204 !! html/parsoid
15205 <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>
15206 !! end
15207
15208 !! test
15209 Escape HTML special chars in image alt text with LanguageConverter
15210 !! options
15211 language=zh
15212 !! wikitext
15213 [[File:Foobar.jpg|& < > "]]
15214 !! html/php
15215 <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>
15216 </p>
15217 !! html/parsoid
15218 <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>
15219 !! end
15220
15221 !! test
15222 Entities in file name and attributes
15223 !! wikitext
15224 [[File:7%25 solution.gif|manualthumb=7%25 solution.gif|link=7%25 solution|[[7%25 solution]]]]
15225 !! html/php
15226 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=7%25_solution.gif" class="new" title="File:7% solution.gif">7% solution</a>
15227 </p>
15228 !! html/parsoid
15229 <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>
15230 !! end
15231
15232 !! test
15233 T2499: Alt text should have &#1234;, not &amp;1234;
15234 !! wikitext
15235 [[File:Foobar.jpg|&#9792;]]
15236 !! html/php
15237 <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>
15238 </p>
15239 !! html/parsoid
15240 <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>
15241 !! end
15242
15243 !! test
15244 Broken image caption with link
15245 !! options
15246 parsoid=wt2html,wt2wt,html2html
15247 !! wikitext
15248 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
15249 !! html/php
15250 <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.
15251 </p>
15252 !! html/parsoid
15253 <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>
15254 !! end
15255
15256 !! test
15257 Image caption containing another image
15258 !! wikitext
15259 [[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
15260 !! html/php
15261 <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>
15262
15263 !! html/parsoid
15264 <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>
15265 !! end
15266
15267 !! test
15268 Image: caption containing a newline
15269 !! wikitext
15270 [[File:Foobar.jpg|This
15271 *is some text]]
15272 !! html/php
15273 <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>
15274 </p>
15275 !! html/parsoid
15276 <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>
15277 !!end
15278
15279 !!test
15280 Image: caption containing leading space
15281 (The leading space should not trigger nowiki escaping in wt2wt mode)
15282 !! wikitext
15283 [[File:Foobar.jpg|thumb| bar]]
15284 !! html/php
15285 <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>
15286
15287 !! html/parsoid
15288 <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>
15289 !!end
15290
15291 # html/php output not have newlines after table, td, th, etc. because
15292 # Linker::makeThumbLink2() replaces the newlines with spaces since
15293 # the table is inside a caption.
15294 # FIXME: Verify if that circa 2004 fix is still required.
15295 !! test
15296 Image: caption containing a table
15297 !! options
15298 parsoid=wt2html,wt2wt,html2html
15299 !! wikitext
15300 [[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
15301 {|
15302 !Foo!!Bar
15303 |-
15304 |Foo1||Bar1
15305 |}
15306 and some more text.]]
15307 !! html/php
15308 <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>
15309
15310 !! html/parsoid
15311 <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
15312 <table>
15313 <tbody>
15314 <tr><th>Foo</th><th>Bar</th></tr>
15315 <tr>
15316 <td>Foo1</td>
15317 <td>Bar1</td></tr></tbody></table>and some more text.</figcaption></figure>
15318 !! end
15319
15320 !! test
15321 T5090: External links other than http: in image captions
15322 !! wikitext
15323 [[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
15324 !! html/php
15325 <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>
15326
15327 !! html/parsoid
15328 <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>
15329 !! end
15330
15331 !! test
15332 Custom class
15333 !! options
15334 parsoid=wt2html,wt2wt,html2html
15335 !! wikitext
15336 [[Image:foobar.jpg|a|class=b]]
15337 !! html/php
15338 <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>
15339 </p>
15340 !! html/parsoid
15341 <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>
15342 !! end
15343
15344 !! test
15345 Localized image handling (1).
15346 !! options
15347 parsoid=wt2html,wt2wt,html2html
15348 language=es
15349 !! wikitext
15350 [[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]]
15351 !! html/php
15352 <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>
15353
15354 !! html/parsoid
15355 <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>
15356 !! end
15357
15358 !! test
15359 Localized image handling (2).
15360 !! options
15361 thumbsize=220
15362 parsoid=wt2html,wt2wt,html2html
15363 language=es
15364 !! wikitext
15365 [[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
15366 !! html/php
15367 <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>
15368
15369 !! html/parsoid
15370 <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>
15371 !! end
15372
15373 !! test
15374 Localized image handling (3).
15375 !! options
15376 language=fa
15377 parsoid=html2wt
15378 !! html/parsoid
15379 <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>
15380 !! wikitext
15381 [[File:Foobar.jpg|بندانگشتی]]
15382 !! end
15383
15384 !! test
15385 "border", "frameless" and "class" attributes on an image.
15386 !! options
15387 thumbsize=220
15388 parsoid=wt2html,wt2wt,html2html
15389 !! wikitext
15390 [[File:Foobar.jpg|frameless|border|class=extra|caption]]
15391 !! html/php
15392 <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>
15393 </p>
15394 !! html/parsoid
15395 <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>
15396 !! end
15397
15398 # Note that 'right' is the default alignment, despite the misspelled 'righ' below
15399 !! test
15400 Invalid image attributes (T64500)
15401 !! options
15402 thumbsize=220
15403 parsoid=wt2html,wt2wt,html2html
15404 !! wikitext
15405 [[File:Foobar.jpg|thumb|float|left|caption]]
15406
15407 [[File:Foobar.jpg|thumb|righ|caption]]
15408
15409 [[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]]
15410 !! html/php
15411 <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>
15412 <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>
15413 <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>
15414
15415 !! html/parsoid
15416 <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>
15417 <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>
15418 <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>
15419 !! end
15420
15421 !! article
15422 File:Barfoo.jpg
15423 !! text
15424 #REDIRECT [[File:Barfoo.jpg]]
15425 !! endarticle
15426
15427 # FIXME: Parsoid should run this test -- but we'd need to teach the
15428 # mockAPI about the redirected Barfoo.jpg image.
15429 !! test
15430 Redirected image
15431 !! wikitext
15432 [[Image:Barfoo.jpg]]
15433 !! html/php
15434 <p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
15435 </p>
15436 !! end
15437
15438 !! test
15439 Missing image with uploads disabled
15440 !! options
15441 wgEnableUploads=0
15442 !! wikitext
15443 [[File:Foobaz.jpg]]
15444 !! html/php
15445 <p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a>
15446 </p>
15447 !! html/parsoid
15448 <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>
15449 !! end
15450
15451 # Parsoid-specific testing for images
15452 # https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
15453 # Currently imperfect due to a flaw in the Parsoid testrunner
15454 # Work in progress
15455 # THESE TESTS SHOULD BE MOVED UP and merged with the php-specific
15456 # image tests.
15457
15458 !! test
15459 Parsoid-specific image handling - simple image with size and middle alignment
15460 !! wikitext
15461 [[File:Foobar.jpg|middle|50px]]
15462 !! html/parsoid
15463 <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>
15464 !! end
15465
15466 !! test
15467 Parsoid-specific image handling - simple image with size, middle alignment,
15468 non-standard namespace alias
15469 !! options
15470 parsoid=wt2wt,wt2html,html2html
15471 !! wikitext
15472 [[Image:Foobar.jpg|middle|50px]]
15473 !! html/parsoid
15474 <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>
15475 !! end
15476
15477 !! test
15478 Parsoid-specific image handling - simple image with size and middle alignment
15479 (existing content)
15480 !! wikitext
15481 [[File:Foobar.jpg|50px|middle]]
15482 !! html/parsoid
15483 <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>
15484 !! end
15485
15486 !! test
15487 Parsoid-specific image handling - simple image with size and middle alignment
15488 and non-standard namespace name
15489 !! options
15490 parsoid=wt2html,wt2wt,html2html
15491 !! wikitext
15492 [[Image:Foobar.jpg|50px|middle]]
15493 !! html/parsoid
15494 <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>
15495 !! end
15496
15497 !! test
15498 Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
15499 !! wikitext
15500 [[File:Foobar.jpg|500x10px|baseline|caption]]
15501 !! html/parsoid
15502 <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>
15503 !! end
15504
15505 !! test
15506 Parsoid-specific image handling - simple image with border and size spec
15507 !! wikitext
15508 [[File:Foobar.jpg|50px|border|caption]]
15509 !! html/parsoid
15510 <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>
15511 !! end
15512
15513 !! test
15514 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15515 !! wikitext
15516 [[File:Foobar.jpg|left|baseline|thumb|caption content]]
15517 !! html/parsoid
15518 <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>
15519 !! end
15520
15521 !! test
15522 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15523 (existing content)
15524 !! wikitext
15525 [[File:Foobar.jpg|thumb|left|baseline|caption content]]
15526 !! html/parsoid
15527 <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>
15528 !! end
15529
15530 !! test
15531 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption
15532 !! wikitext
15533 [[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
15534 !! html/parsoid
15535 <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>
15536 !! end
15537
15538 !! test
15539 Parsoid-specific image handling - thumbnail with specific size, halign,
15540 valign, and caption (existing content)
15541 !! wikitext
15542 [[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
15543 !! html/parsoid
15544 <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>
15545 !! end
15546
15547 !! test
15548 Parsoid-specific image handling - framed image with specific size and caption
15549 (size is ignored)
15550 !! options
15551 parsoid=wt2html,wt2wt,html2html
15552 !! wikitext
15553 [[File:Foobar.jpg|frame|500x50px|caption]]
15554 !! html/parsoid
15555 <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>
15556 !! end
15557
15558 !! test
15559 Parsoid-specific image handling - framed image with specific size, halign, valign, and caption
15560 (size is ignored)
15561 !! options
15562 parsoid=wt2html,wt2wt,html2html
15563 !! wikitext
15564 [[File:Foobar.jpg|left|baseline|frame|500x50px|caption]]
15565 !! html/parsoid
15566 <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>
15567 !! end
15568
15569 !! test
15570 Parsoid-specific image handling - frameless image with specific size, border, and caption
15571 !! wikitext
15572 [[File:Foobar.jpg|frameless|442x50px|border|caption]]
15573 !! html/parsoid
15574 <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>
15575 !! end
15576
15577 !! test
15578 Parsoid-specific image handling - simple image with a formatted caption
15579 !! wikitext
15580 [[File:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]]
15581 !! html/parsoid
15582 <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>
15583 !! end
15584
15585 !! test
15586 Parsoid-specific image handling - caption with a template in it
15587 !! wikitext
15588 [[File:Foobar.jpg|thumb|200x23px|This caption has a {{echo|transclusion}} in it.]]
15589 !! html/parsoid
15590 <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>
15591 !! end
15592
15593 !! test
15594 Parsoid-specific image handling - caption with unbalanced tags in it
15595 !! options
15596 parsoid=wt2html,wt2wt,html2html
15597 !! wikitext
15598 foo
15599 [[File:Foobar.jpg|thumb|200x200px|This caption has a <center>unbalanced tag in it.]]
15600 bar
15601 !! html/parsoid
15602 <p>foo</p>
15603 <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>
15604 <p>bar</p>
15605 !! end
15606
15607 !! test
15608 Parsoid-specific image handling - empty caption (1)
15609 !! options
15610 parsoid=wt2html,wt2wt
15611 !! wikitext
15612 [[File:Foobar.jpg|thumb|]]
15613 !! html/parsoid
15614 <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>
15615 !! end
15616
15617 # empty captions don't get serialized unless we're in the "round trip" case
15618 !! test
15619 Parsoid-specific image handling - empty caption (2)
15620 !! options
15621 parsoid=html2wt
15622 !! html/parsoid
15623 <figure class="mw-default-size" typeof="mw:Image/Thumb">
15624 <a href="./File:Foobar.jpg">
15625 <img resource="./File:Foobar.jpg"
15626 src="//example.com/images/3/3a/Foobar.jpg"
15627 data-file-width="1941" data-file-height="220" data-file-type="bitmap"
15628 height="25" width="220"/>
15629 </a>
15630 <figcaption></figcaption>
15631 </figure>
15632 !! wikitext
15633 [[File:Foobar.jpg|thumb]]
15634 !! end
15635
15636 !! test
15637 Parsoid-specific image handling - whitespace caption
15638 !! wikitext
15639 [[File:Foobar.jpg|thumb| ]]
15640 !! html/parsoid
15641 <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>
15642 !! end
15643
15644 !! test
15645 Parsoid-specific image handling - lang option
15646 !! wikitext
15647 foo
15648 [[File:Foobar.svg|lang=de|caption]]
15649 bar
15650 !! html/parsoid
15651 <p>foo
15652 <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>
15653 bar</p>
15654 !! end
15655
15656 ## Edge case bugs in Parsoid from T93580
15657 !! test
15658 T93580: 1. Templated <ref> inside block images
15659 !! wikitext
15660 [[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]]
15661
15662 <references />
15663 !! html/parsoid
15664 <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>
15665
15666 <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>
15667 !! end
15668
15669 !! test
15670 T93580: 2. <ref> inside inline images
15671 !! wikitext
15672 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: <ref>foo</ref>]]
15673
15674 <references />
15675 !! html/parsoid
15676 <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>
15677
15678 <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>
15679 !! end
15680
15681 !! test
15682 T93580: 3. Templated <ref> inside inline images
15683 !! wikitext
15684 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}]]
15685
15686 <references />
15687 !! html/parsoid
15688 <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>
15689
15690 <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>
15691 !! end
15692
15693 ###
15694 ### Subpages
15695 ###
15696 !! article
15697 Subpage test/subpage
15698 !! text
15699 foo
15700 !! endarticle
15701
15702 !! test
15703 Subpage link
15704 !! options
15705 subpage title=[[Subpage test]]
15706 !! wikitext
15707 [[/subpage]]
15708 !! html
15709 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
15710 </p>
15711 !! end
15712
15713 !! test
15714 Subpage noslash link
15715 !! options
15716 subpage title=[[Subpage test]]
15717 !! wikitext
15718 [[/subpage/]]
15719 !! html
15720 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
15721 </p>
15722 !! end
15723
15724 !! article
15725 Subpage test/1/2/subpage
15726 !! text
15727 blah
15728 !! endarticle
15729
15730 !! test
15731 Relative subpage noslash link
15732 !! options
15733 parsoid=wt2wt,wt2html,html2html
15734 subpage title=[[Subpage test/1/2/3/4]]
15735 !! wikitext
15736 [[../../subpage/]]
15737
15738 [[../../subpage]]
15739 !! html/php
15740 <p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a>
15741 </p><p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage test/1/2/subpage</a>
15742 </p>
15743 !! html/parsoid
15744 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a></p>
15745 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage_test/1/2/subpage</a></p>
15746 !! end
15747
15748 !! test
15749 Parsoid: dot-slash prefixed wikilinks
15750 !! wikitext
15751 [[./foo]]
15752
15753 [[././bar]]
15754
15755 [[././baz/]]
15756 !! html/php
15757 <p>[[./foo]]
15758 </p><p>[[././bar]]
15759 </p><p>[[././baz/]]
15760 </p>
15761 !! html/parsoid
15762 <p>[[./foo]]
15763 </p><p>[[././bar]]
15764 </p><p>[[././baz/]]
15765 </p>
15766 !! end
15767
15768 !! test
15769 Render invalid page names as plain text (T53090)
15770 !! wikitext
15771 [[./../foo|bar]]
15772 [[foo�|bar]]
15773 [[foo/.|bar]]
15774 [[foo/..|bar]]
15775 [[foo~~~bar]]
15776 [[foo>bar]]
15777 [[foo[bar]]
15778 [[.]]
15779 [[..]]
15780 [[foo././bar]]
15781 [[foo[http://example.com]xyz]]
15782
15783 [[{{echo|./../foo}}|bar]]
15784 [[{{echo|foo/.}}|bar]]
15785 [[{{echo|foo/..}}|bar]]
15786 [[{{echo|foo~~~~bar}}]]
15787 [[{{echo|foo>bar}}]]
15788 [[{{echo|foo././bar}}]]
15789 [[{{echo|foo{bar}}]]
15790 [[{{echo|foo}bar}}]]
15791 [[{{echo|foo[bar}}]]
15792 [[{{echo|foo]bar}}]]
15793 [[{{echo|foo<bar}}]]
15794 !!html/php
15795 <p>[[./../foo|bar]]
15796 [[foo�|bar]]
15797 [[foo/.|bar]]
15798 [[foo/..|bar]]
15799 [[foo~~~bar]]
15800 [[foo&gt;bar]]
15801 [[foo[bar]]
15802 [[.]]
15803 [[..]]
15804 [[foo././bar]]
15805 [[foo<a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>xyz]]
15806 </p><p>[[./../foo|bar]]
15807 [[foo/.|bar]]
15808 [[foo/..|bar]]
15809 [[foo~~~~bar]]
15810 [[foo&gt;bar]]
15811 [[foo././bar]]
15812 [[foo{bar]]
15813 [[foo}bar]]
15814 [[foo[bar]]
15815 [[foo]bar]]
15816 [[foo&lt;bar]]
15817 </p>
15818 !!html/parsoid
15819 <p>[[./../foo|bar]]
15820 [[foo�|bar]]
15821 [[foo/.|bar]]
15822 [[foo/..|bar]]
15823 [[foo~~~bar]]
15824 [[foo>bar]]
15825 [[foo[bar]]
15826 [[.]]
15827 [[..]]
15828 [[foo././bar]]
15829 [[foo<a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>xyz]]</p>
15830
15831 <p>[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"./../foo"}},"i":0}}]}'>./../foo</span>|bar]]
15832 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/."}},"i":0}}]}'>foo/.</span>|bar]]
15833 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/.."}},"i":0}}]}'>foo/..</span>|bar]]
15834 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo~~~~bar"}},"i":0}}]}'>foo~~~~bar</span>]]
15835 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo>bar"}},"i":0}}]}'>foo>bar</span>]]
15836 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo././bar"}},"i":0}}]}'>foo././bar</span>]]
15837 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo{bar"}},"i":0}}]}'>foo{bar</span>]]
15838 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}bar"}},"i":0}}]}'>foo}bar</span>]]
15839 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo[bar"}},"i":0}}]}'>foo[bar</span>]]
15840 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo]bar"}},"i":0}}]}'>foo]bar</span>]]
15841 [[<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>
15842 !!end
15843
15844 !! test
15845 Disabled subpages
15846 !! wikitext
15847 [[/subpage]]
15848 !! html
15849 <p><a href="/index.php?title=/subpage&amp;action=edit&amp;redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a>
15850 </p>
15851 !! end
15852
15853 !! test
15854 T2561: {{/Subpage}}
15855 !! options
15856 subpage title=[[Page]]
15857 !! wikitext
15858 {{/Subpage}}
15859 !! html
15860 <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>
15861 </p>
15862 !! end
15863
15864 ###
15865 ### Categories
15866 ###
15867 !! article
15868 Category:MediaWiki User's Guide
15869 !! text
15870 blah
15871 !! endarticle
15872
15873 !! test
15874 Link to category
15875 !! wikitext
15876 [[:Category:MediaWiki User's Guide]]
15877 !! html
15878 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User&#39;s Guide">Category:MediaWiki User's Guide</a>
15879 </p>
15880 !! end
15881
15882 !! test
15883 Simple category
15884 !! options
15885 cat
15886 !! wikitext
15887 [[Category:MediaWiki User's Guide]]
15888 !! html/php
15889 cat=MediaWiki_User's_Guide sort=
15890 !! html/parsoid
15891 <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"}}'/>
15892 !! end
15893
15894 !! test
15895 PAGESINCATEGORY invalid title fatal (r33546 fix)
15896 !! wikitext
15897 {{PAGESINCATEGORY:<bogus>}}
15898 !! html
15899 <p>0
15900 </p>
15901 !! end
15902
15903 !! test
15904 Category with different sort key
15905 !! options
15906 cat
15907 !! wikitext
15908 [[Category:MediaWiki User's Guide|Foo]]
15909 !! html/php
15910 cat=MediaWiki_User's_Guide sort=Foo
15911 !! html/parsoid
15912 <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"}}'/>
15913 !! end
15914
15915 !! test
15916 Category with identical sort key
15917 !! options
15918 cat
15919 !! wikitext
15920 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
15921 !! html/php
15922 cat=MediaWiki_User's_Guide sort=MediaWiki User's Guide
15923 !! html/parsoid
15924 <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"}}'/>
15925 !! end
15926
15927 !! test
15928 Category with empty sort key
15929 !! options
15930 cat
15931 pst
15932 !! wikitext
15933 [[Category:MediaWiki User's Guide|]]
15934 !! html/php
15935 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
15936 !! end
15937
15938 !! test
15939 Category with empty sort key and parentheses
15940 !! options
15941 cat
15942 pst
15943 !! wikitext
15944 [[Category:Foo (bar)|]]
15945 !! html/php
15946 [[Category:Foo (bar)|Foo]]
15947 !! end
15948
15949 !! test
15950 Category with link tail
15951 !! options
15952 cat
15953 pst
15954 !! wikitext
15955 123[[Category:Foo]]456
15956 !! html/php
15957 123[[Category:Foo]]456
15958 !! end
15959
15960 !! test
15961 Category with template
15962 !! options
15963 cat
15964 pst
15965 !! wikitext
15966 [[Category:{{echo|Foo}}]]
15967 !! html/php
15968 [[Category:{{echo|Foo}}]]
15969 !! end
15970
15971 !! test
15972 Category with template in sort key
15973 !! options
15974 cat
15975 pst
15976 !! wikitext
15977 [[Category:Foo|{{echo|Bar}}]]
15978 !! html/php
15979 [[Category:Foo|{{echo|Bar}}]]
15980 !! end
15981
15982 !! test
15983 Category with template in sort key and title
15984 !! options
15985 cat
15986 pst
15987 !! wikitext
15988 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
15989 !! html/php
15990 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
15991 !! end
15992
15993 ## We used to, but no longer wt2wt this test since the default serializer
15994 ## will normalize all categories to serialize on their own line.
15995 ## This wikitext usage is going to be fairly uncommon in production and
15996 ## selser will take care of preserving formatting in those scenarios.
15997 !! test
15998 Category / paragraph interactions
15999 !! options
16000 parsoid=wt2html
16001 !! wikitext
16002 Foo [[Category:Baz]] Bar
16003
16004 Foo [[Category:Baz]]
16005 Bar
16006
16007 Foo
16008 [[Category:Baz]]
16009 Bar
16010
16011 Foo
16012 [[Category:Baz]] Bar
16013
16014 Foo
16015 [[Category:Baz]]
16016 [[Category:Baz]]
16017 [[Category:Baz]]
16018 Bar
16019
16020 [[Category:Baz]]
16021 [[Category:Baz]]
16022 [[Category:Baz]]
16023
16024 [[Category:Baz]]
16025 {{echo|[[Category:Baz]]}}
16026 [[Category:Baz]]
16027 !! html/php
16028 <p>Foo Bar
16029 </p><p>Foo
16030 Bar
16031 </p><p>Foo
16032 Bar
16033 </p><p>Foo Bar
16034 </p><p>Foo
16035 Bar
16036 </p>
16037 !! html/parsoid
16038 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16039 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16040 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16041 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16042 <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>
16043 <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}}]}'/>
16044 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
16045 !! end
16046
16047 ## We used to, but no longer wt2wt this test since the default serializer
16048 ## will normalize all categories to serialize on their own line.
16049 ## This wikitext usage is going to be fairly uncommon in production and
16050 ## selser will take care of preserving formatting in those scenarios.
16051 ##
16052 ## The whitespace on the empty line is part of the test. Please do not delete
16053 !! test
16054 1. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16055 !! options
16056 parsoid=wt2html
16057 !! wikitext
16058 This
16059
16060 [[Category:Foo]] and this should be part of same paragraph (not an indent-pre)
16061
16062 {{echo|[[Category:Foo]] and so should this!}}
16063 !! html/php
16064 <p>This and this should be part of same paragraph (not an indent-pre) and so should this!
16065 </p>
16066 !! html/parsoid
16067 <p>This
16068
16069 <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of same paragraph (not an indent-pre)
16070
16071 <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>
16072 !! end
16073
16074 ## Parsoid will not try to wt2wt this while preserving newlines because
16075 ## it suppresses excess newlines within list items -- and we don't want to
16076 ## introduce a special case just for categories, which is, in reality somewhat
16077 ## odd behavior -- categories are unlikely to be used in list items like this
16078 ## in top-level pages and are only likely to show up in template-generated
16079 ## list items where this RT-ing is a non-issue.
16080 ##
16081 ## The whitespace on the empty line is part of the test. Please do not delete
16082 !! test
16083 2. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16084 !! options
16085 parsoid=wt2html
16086 !! wikitext
16087 * This
16088
16089 [[Category:Foo]] and this should be part of the same list item
16090 * So should this
16091
16092 {{echo|[[Category:Foo]] and this should be part of the same list item}}
16093 !! html
16094 <ul><li>This and this should be part of the same list item</li>
16095 <li>So should this and this should be part of the same list item</li></ul>
16096 !! html/parsoid
16097 <ul>
16098 <li>This <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of the same list item</li>
16099 <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>
16100 </ul>
16101 !! end
16102
16103 ## Newlines and categories that follow the last item of a list
16104 ## are treated differently because this (list followed by categories)
16105 ## is an extremely common pattern on wikis.
16106 !! test
16107 3. Categories and newlines: newline suppression for last list item should RT properly
16108 !! wikitext
16109 * a
16110 * b
16111
16112 [[Category:Foo]]
16113
16114 [[Category:Bar]]
16115 [[Category:Baz]]
16116 !! html/parsoid
16117 <ul><li> a</li>
16118 <li> b</li></ul>
16119
16120 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16121
16122 <link rel="mw:PageProp/Category" href="./Category:Bar" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
16123 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
16124 !! end
16125
16126 !! test
16127 4. Categories and newlines: newline suppression for last list item should RT properly
16128 !! wikitext
16129 * a
16130 **** b
16131
16132 [[Category:Foo]]
16133 !! html/parsoid
16134 <ul><li> a
16135 <ul><li><ul><li><ul><li> b</li></ul></li></ul></li></ul></li></ul>
16136
16137 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16138 !! end
16139
16140 ## only wt2html for this to make sure the algo only applies to the rightmost path
16141 !! test
16142 5. Categories and newlines: migrateTrailingCategories dom pass should only run on the rightmost path of nested lists
16143 !! options
16144 parsoid=wt2html
16145 !! wikitext
16146 * a
16147 ** b
16148 [[Category:Foo]]
16149 * c
16150 ** d
16151 [[Category:Foo]]
16152 !! html/parsoid
16153 <ul><li> a
16154 <ul><li> b
16155 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul></li>
16156 <li> c
16157 <ul><li> d</li></ul></li></ul>
16158 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16159 !! end
16160
16161 ## We used to, but no longer wt2wt this test since the default serializer
16162 ## will normalize all categories to serialize on their own line.
16163 ## This wikitext usage is going to be fairly uncommon in production and
16164 ## selser will take care of preserving formatting in those scenarios.
16165 !! test
16166 6. Categories and newlines: migrateTrailingCategories dom pass should not migrate categories not preceded by newlines
16167 !! options
16168 parsoid=wt2html
16169 !! wikitext
16170 * a [[Category:Foo]]
16171 !! html/parsoid
16172 <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>
16173 !! end
16174
16175 # This test also demonstrates because of newline+category tunneling
16176 # through the list hander, template wrapping doesn't expand to the
16177 # containing list when the list item swallows the category.
16178 !! test
16179 7. Categories and newlines: migrateTrailingCategories dom pass should leave template content alone
16180 !! wikitext
16181 * {{echo|a
16182 [[Category:Foo]]}}
16183 !! html/parsoid
16184 <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
16185 </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>
16186 !! end
16187
16188 !! test
16189 8. Categories and newlines: migrateTrailingCategories dom pass should not get tripped by intervening templates
16190 !! wikitext
16191 * a
16192
16193 {{echo|[[Category:Foo]]
16194 [[Category:Bar]]}}
16195 [[Category:Baz]]
16196 !! html/parsoid
16197 <ul><li> a</li></ul>
16198
16199 <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">
16200 </span><link rel="mw:PageProp/Category" href="./Category:Bar" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
16201 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
16202 !! end
16203
16204 !! test
16205 9. Categories and newlines: should behave properly with linkprefix (T87753)
16206 !! options
16207 language=ar
16208 !! wikitext
16209 foo bar
16210 foo bar
16211 [[تصنيف:Foo]]
16212 [[تصنيف:Bar]]
16213 !! html/php
16214 <p>foo bar
16215 foo bar
16216 </p>
16217 !! html/parsoid
16218 <p>foo bar
16219 foo bar</p>
16220 <link rel="mw:PageProp/Category" href="./تصنيف:Foo"/>
16221 <link rel="mw:PageProp/Category" href="./تصنيف:Bar"/>
16222 !! end
16223
16224 !! test
16225 10. No regressions on internal links following category (T174639)
16226 !! options
16227 parsoid=wt2html,html2html
16228 !! wikitext
16229 [[Category:Foo]]<div>a
16230
16231 [[Foo]]</div>
16232 !! html/php
16233 <div>a
16234 <a href="/wiki/Foo" title="Foo">Foo</a></div>
16235
16236 !! html/parsoid
16237 <link rel="mw:PageProp/Category" href="./Category:Foo"/><div>a
16238
16239 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></div>
16240 !! end
16241
16242 # Note that Parsoid differs slightly from PHP due to T175421
16243 !! test
16244 11. Special case where only newlines separate links (T175416)
16245 !! options
16246 parsoid=wt2html,html2html
16247 !! wikitext
16248 [[Category:Foo]]
16249
16250 [[Foo]][[es:Alimento]]
16251
16252 [[Foo]]
16253 !! html/php
16254 <p><br />
16255 <a href="/wiki/Foo" title="Foo">Foo</a>
16256 </p><p><a href="/wiki/Foo" title="Foo">Foo</a>
16257 </p>
16258 !! html/parsoid
16259 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
16260
16261 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p><link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
16262
16263 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p>
16264 !! end
16265
16266 !! test
16267 Category links with multiple namespaces
16268 !! wikitext
16269 [[Category:Project:Foo]]
16270 !! html/parsoid
16271 <link rel="mw:PageProp/Category" href="./Category:Project:Foo" />
16272 !! end
16273
16274 !! test
16275 Parsoid: Serialize link to category page with colon escape
16276 !! options
16277 parsoid
16278 !! wikitext
16279
16280 [[:Category:Foo]]
16281 [[:Category:Foo|Bar]]
16282 !! html
16283 <p>
16284 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Category:Foo</a>
16285 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Bar</a>
16286 </p>
16287 !! end
16288
16289 # We used to, but no longer wt2wt this test since the default serializer
16290 # will normalize all categories to serialize on their own line.
16291 # This wikitext usage is going to be fairly uncommon in production and
16292 # selser will take care of preventing whitespace insertion if this
16293 # occurs in an article.
16294 #
16295 # html2html disabled for the same reason (whitespace insertion between
16296 # x and y).
16297 #
16298 # html2wt disabled because it localizes the "Category" namespace.
16299 !! test
16300 Link prefix/suffixes aren't applied to category links
16301 !! options
16302 parsoid=wt2html
16303 language=is
16304 !! wikitext
16305 x[[Category:Foo]]y
16306 !! html/php
16307 <p>xy
16308 </p>
16309 !! html/parsoid
16310 <p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p>
16311 !! end
16312
16313 !! test
16314 Link prefix/suffixes aren't applied to language links
16315 !! options
16316 parsoid=wt2html
16317 language=is
16318 !! wikitext
16319 x[[es:Foo]]y
16320 !! html/php
16321 <p>xy
16322 </p>
16323 !! html/parsoid
16324 <p>x<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo" data-parsoid=""/>y</p>
16325 !! end
16326
16327 !! test
16328 Parsoid: Serialize link to file page with colon escape
16329 !! options
16330 parsoid
16331 !! wikitext
16332
16333 [[:File:Foo.png]]
16334 [[:File:Foo.png|Bar]]
16335 !! html
16336 <p>
16337 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">File:Foo.png</a>
16338 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">Bar</a>
16339 </p>
16340 !! end
16341
16342 !! test
16343 Parsoid: Serialize a genuine category link without colon escape
16344 !! options
16345 parsoid
16346 !! wikitext
16347 [[Category:Foo]]
16348 [[Category:Foo|Bar]]
16349 !! html
16350 <link rel="mw:PageProp/Category" href="./Category:Foo">
16351 <link rel="mw:PageProp/Category" href="./Category:Foo#Bar">
16352 !! end
16353
16354 !! test
16355 Normalize hrefs properly before testing for invalid link targets (T72894)
16356 !! options
16357 parsoid=html2wt
16358 !! html/parsoid
16359 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/>
16360 !! wikitext
16361 [[Category:Toxine bactérienne]]
16362 !! end
16363
16364 !! test
16365 Parsoid: Defaultsort
16366 !! wikitext
16367 {{DEFAULTSORT:Foo}}
16368 !! html/parsoid
16369 <meta property="mw:PageProp/categorydefaultsort" content="Foo"/>
16370 !! end
16371
16372 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
16373 # But, this is a limitation of our representation and is documented in
16374 # TemplateHandler.js in processSpecialMagicWord
16375 !! test
16376 Parsoid: Defaultsort (template-generated)
16377 !! wikitext
16378 {{{{echo|DEFAULTSORT}}:Foo}}
16379 !! html/parsoid
16380 <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"}]]}'/>
16381 !! end
16382
16383 ###
16384 ### Inter-language links
16385 ###
16386 !! test
16387 Interlanguage links
16388 !! options
16389 ill
16390 !! wikitext
16391 [[es:Alimento]]
16392 [[fr:Nourriture]]
16393 [[zh:食品]]
16394 !! html/php
16395 es:Alimento fr:Nourriture zh:食品
16396 !! html/parsoid
16397 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
16398 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Nourriture"/>
16399 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/食品"/>
16400 !! end
16401
16402 !! test
16403 Duplicate interlanguage links (T26502)
16404 !! options
16405 ill
16406 !! wikitext
16407 [[es:1]]
16408 [[es:2]]
16409 [[fr:1]]
16410 [[fr:2]]
16411 !! html/php
16412 es:1 fr:1
16413 !! html/parsoid
16414 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/1"/>
16415 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/2"/>
16416 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/1"/>
16417 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/2"/>
16418 !! end
16419
16420 ###
16421 ### Sections
16422 ###
16423 !! test
16424 Basic section headings
16425 !! wikitext
16426 ==Headline 1==
16427 Some text
16428
16429 ==Headline 2==
16430 More
16431 ===Smaller headline===
16432 Blah blah
16433 !! html
16434 <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>
16435 <p>Some text
16436 </p>
16437 <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>
16438 <p>More
16439 </p>
16440 <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>
16441 <p>Blah blah
16442 </p>
16443 !! end
16444
16445 !! test
16446 Section headings with TOC
16447 !! wikitext
16448 ==Headline 1==
16449 ===Subheadline 1===
16450 =====Skipping a level=====
16451 ======Skipping a level======
16452
16453 ==Headline 2==
16454 Some text
16455 ===Another headline===
16456 !! html
16457 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16458 <ul>
16459 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
16460 <ul>
16461 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
16462 <ul>
16463 <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>
16464 <ul>
16465 <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>
16466 </ul>
16467 </li>
16468 </ul>
16469 </li>
16470 </ul>
16471 </li>
16472 <li class="toclevel-1 tocsection-5"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
16473 <ul>
16474 <li class="toclevel-2 tocsection-6"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
16475 </ul>
16476 </li>
16477 </ul>
16478 </div>
16479
16480 <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>
16481 <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>
16482 <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>
16483 <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>
16484 <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>
16485 <p>Some text
16486 </p>
16487 <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>
16488
16489 !! end
16490
16491 !! test
16492 TOC anchors don't collide
16493 !! wikitext
16494 __FORCETOC__
16495 ==Headline 2==
16496 ==Headline==
16497 ==Headline 2==
16498 ==Headline==
16499 !! html/php
16500 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16501 <ul>
16502 <li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
16503 <li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
16504 <li class="toclevel-1 tocsection-3"><a href="#Headline_2_2"><span class="tocnumber">3</span> <span class="toctext">Headline 2</span></a></li>
16505 <li class="toclevel-1 tocsection-4"><a href="#Headline_3"><span class="tocnumber">4</span> <span class="toctext">Headline</span></a></li>
16506 </ul>
16507 </div>
16508
16509 <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>
16510 <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>
16511 <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>
16512 <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>
16513
16514 !! end
16515
16516 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
16517 # Parsoid html2wt direction adds <nowiki> for level 7 and up.
16518 !! test
16519 Handling of sections up to level 6 and beyond
16520 !! options
16521 parsoid=wt2html
16522 !! wikitext
16523 =Level 1 Heading=
16524 ==Level 2 Heading==
16525 ===Level 3 Heading===
16526 ====Level 4 Heading====
16527 =====Level 5 Heading=====
16528 ======Level 6 Heading======
16529 =======Level 7 Heading=======
16530 ========Level 8 Heading========
16531 =========Level 9 Heading=========
16532 ==========Level 10 Heading==========
16533 !! html/php
16534 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16535 <ul>
16536 <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
16537 <ul>
16538 <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>
16539 <ul>
16540 <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>
16541 <ul>
16542 <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>
16543 <ul>
16544 <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>
16545 <ul>
16546 <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>
16547 <li class="toclevel-6 tocsection-7"><a href="#.3DLevel_7_Heading.3D"><span class="tocnumber">1.1.1.1.1.2</span> <span class="toctext">=Level 7 Heading=</span></a></li>
16548 <li class="toclevel-6 tocsection-8"><a href="#.3D.3DLevel_8_Heading.3D.3D"><span class="tocnumber">1.1.1.1.1.3</span> <span class="toctext">==Level 8 Heading==</span></a></li>
16549 <li class="toclevel-6 tocsection-9"><a href="#.3D.3D.3DLevel_9_Heading.3D.3D.3D"><span class="tocnumber">1.1.1.1.1.4</span> <span class="toctext">===Level 9 Heading===</span></a></li>
16550 <li class="toclevel-6 tocsection-10"><a href="#.3D.3D.3D.3DLevel_10_Heading.3D.3D.3D.3D"><span class="tocnumber">1.1.1.1.1.5</span> <span class="toctext">====Level 10 Heading====</span></a></li>
16551 </ul>
16552 </li>
16553 </ul>
16554 </li>
16555 </ul>
16556 </li>
16557 </ul>
16558 </li>
16559 </ul>
16560 </li>
16561 </ul>
16562 </div>
16563
16564 <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>
16565 <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>
16566 <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>
16567 <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>
16568 <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>
16569 <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>
16570 <h6><span class="mw-headline" id=".3DLevel_7_Heading.3D">=Level 7 Heading=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=7" title="Edit section: =Level 7 Heading=">edit</a><span class="mw-editsection-bracket">]</span></span></h6>
16571 <h6><span class="mw-headline" id=".3D.3DLevel_8_Heading.3D.3D">==Level 8 Heading==</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=8" title="Edit section: ==Level 8 Heading==">edit</a><span class="mw-editsection-bracket">]</span></span></h6>
16572 <h6><span class="mw-headline" id=".3D.3D.3DLevel_9_Heading.3D.3D.3D">===Level 9 Heading===</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=9" title="Edit section: ===Level 9 Heading===">edit</a><span class="mw-editsection-bracket">]</span></span></h6>
16573 <h6><span class="mw-headline" id=".3D.3D.3D.3DLevel_10_Heading.3D.3D.3D.3D">====Level 10 Heading====</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=10" title="Edit section: ====Level 10 Heading====">edit</a><span class="mw-editsection-bracket">]</span></span></h6>
16574
16575 !! html/parsoid
16576 <h1 id="Level_1_Heading" data-parsoid='{}'>Level 1 Heading</h1>
16577 <h2 id="Level_2_Heading" data-parsoid='{}'>Level 2 Heading</h2>
16578 <h3 id="Level_3_Heading" data-parsoid='{}'>Level 3 Heading</h3>
16579 <h4 id="Level_4_Heading" data-parsoid='{}'>Level 4 Heading</h4>
16580 <h5 id="Level_5_Heading" data-parsoid='{}'>Level 5 Heading</h5>
16581 <h6 id="Level_6_Heading" data-parsoid='{}'>Level 6 Heading</h6>
16582 <h6 id="=Level_7_Heading=" data-parsoid='{}'><span id=".3DLevel_7_Heading.3D" typeof="mw:FallbackId"></span>=Level 7 Heading=</h6>
16583 <h6 id="==Level_8_Heading==" data-parsoid='{}'><span id=".3D.3DLevel_8_Heading.3D.3D" typeof="mw:FallbackId"></span>==Level 8 Heading==</h6>
16584 <h6 id="===Level_9_Heading===" data-parsoid='{}'><span id=".3D.3D.3DLevel_9_Heading.3D.3D.3D" typeof="mw:FallbackId"></span>===Level 9 Heading===</h6>
16585 <h6 id="====Level_10_Heading====" data-parsoid='{}'><span id=".3D.3D.3D.3DLevel_10_Heading.3D.3D.3D.3D" typeof="mw:FallbackId"></span>====Level 10 Heading====</h6>
16586 !! end
16587
16588 !! test
16589 TOC regression (T11764)
16590 !! wikitext
16591 ==title 1==
16592 ===title 1.1===
16593 ====title 1.1.1====
16594 ===title 1.2===
16595 ==title 2==
16596 ===title 2.1===
16597 !! html
16598 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16599 <ul>
16600 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16601 <ul>
16602 <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>
16603 <ul>
16604 <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>
16605 </ul>
16606 </li>
16607 <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>
16608 </ul>
16609 </li>
16610 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16611 <ul>
16612 <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>
16613 </ul>
16614 </li>
16615 </ul>
16616 </div>
16617
16618 <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>
16619 <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>
16620 <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>
16621 <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>
16622 <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>
16623 <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>
16624
16625 !! end
16626
16627 !! test
16628 TOC for heading containing <span id="..."></span> (T96153)
16629 !! wikitext
16630 __FORCETOC__
16631 ==<span id="old-anchor"></span>New title==
16632 !! html/php
16633 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16634 <ul>
16635 <li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
16636 </ul>
16637 </div>
16638
16639 <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>
16640
16641 !! end
16642
16643 !! test
16644 TOC with wgMaxTocLevel=3 (T8204)
16645 !! options
16646 wgMaxTocLevel=3
16647 !! wikitext
16648 ==title 1==
16649 ===title 1.1===
16650 ====title 1.1.1====
16651 ===title 1.2===
16652 ==title 2==
16653 ===title 2.1===
16654 !! html
16655 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16656 <ul>
16657 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16658 <ul>
16659 <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>
16660 <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>
16661 </ul>
16662 </li>
16663 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16664 <ul>
16665 <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>
16666 </ul>
16667 </li>
16668 </ul>
16669 </div>
16670
16671 <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>
16672 <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>
16673 <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>
16674 <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>
16675 <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>
16676 <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>
16677
16678 !! end
16679
16680 !! test
16681 TOC with wgMaxTocLevel=3 and two level four headings (T8204)
16682 !! options
16683 wgMaxTocLevel=3
16684 !! wikitext
16685 ==Section 1==
16686 ===Section 1.1===
16687 ====Section 1.1.1====
16688 ====Section 1.1.1.1====
16689 ==Section 2==
16690 !! html
16691 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16692 <ul>
16693 <li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
16694 <ul>
16695 <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>
16696 </ul>
16697 </li>
16698 <li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li>
16699 </ul>
16700 </div>
16701
16702 <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>
16703 <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>
16704 <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>
16705 <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>
16706 <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>
16707
16708 !! end
16709
16710
16711 !! test
16712 Resolving duplicate section names
16713 !! wikitext
16714 ==Foo bar==
16715 ==Foo bar==
16716 !! html
16717 <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>
16718 <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>
16719
16720 !! end
16721
16722 !! test
16723 Resolving duplicate section names with differing case (T12721)
16724 !! wikitext
16725 ==Foo bar==
16726 ==Foo Bar==
16727 !! html
16728 <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>
16729 <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>
16730
16731 !! end
16732
16733 !! article
16734 Template:sections
16735 !! text
16736 ===Section 1===
16737 ==Section 2==
16738 !! endarticle
16739
16740 !! test
16741 Template with sections, __NOTOC__
16742 !! wikitext
16743 __NOTOC__
16744 ==Section 0==
16745 {{sections}}
16746 ==Section 4==
16747 !! html
16748 <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>
16749 <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>
16750 <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>
16751 <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>
16752
16753 !! end
16754
16755 !! test
16756 __NOEDITSECTION__ keyword
16757 !! wikitext
16758 __NOEDITSECTION__
16759 ==Section 1==
16760 ==Section 2==
16761 !! html
16762 <h2><span class="mw-headline" id="Section_1">Section 1</span></h2>
16763 <h2><span class="mw-headline" id="Section_2">Section 2</span></h2>
16764
16765 !! end
16766
16767 !! test
16768 Link inside a section heading
16769 !! wikitext
16770 ==Section with a [[Main Page|link]] in it==
16771 !! html
16772 <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>
16773
16774 !! end
16775
16776 !! test
16777 TOC regression (T14077)
16778 !! wikitext
16779 __TOC__
16780 ==title 1==
16781 ===title 1.1===
16782 ==title 2==
16783 !! html
16784 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16785 <ul>
16786 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16787 <ul>
16788 <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>
16789 </ul>
16790 </li>
16791 <li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li>
16792 </ul>
16793 </div>
16794
16795 <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>
16796 <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>
16797 <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>
16798
16799 !! end
16800
16801 !! test
16802 T3219 URL next to image (good)
16803 !! wikitext
16804 http://example.com [[File:Foobar.jpg]]
16805 !! html/php
16806 <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>
16807 </p>
16808 !! html/parsoid
16809 <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>
16810 !!end
16811
16812 # Parsoid doesn't wt2wt this cleanly because it adds <nowiki>s.
16813 !! test
16814 Short headings with trailing space should match behavior of Parser::doHeadings (T21910)
16815 !! options
16816 parsoid=wt2html,html2html
16817 !! wikitext
16818 ===
16819 The line above must have a trailing space!
16820 === <!--
16821 --> <!-- -->
16822 But just in case it doesn't...
16823 !! html/php
16824 <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>
16825 <p>The line above must have a trailing space!
16826 </p>
16827 <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>
16828 <p>But just in case it doesn't...
16829 </p>
16830 !! html/parsoid
16831 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
16832 <p>The line above must have a trailing space!</p>
16833 <h1 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h1> <!--
16834 --> <!-- -->
16835 <p>But just in case it doesn't...</p>
16836 !! end
16837
16838 !! test
16839 Header with special characters (T27462)
16840 !! wikitext
16841 The tooltips shall not show entities to the user (ie. be double escaped)
16842
16843 ==text > text==
16844 section 1
16845
16846 ==text < text==
16847 section 2
16848
16849 ==text & text==
16850 section 3
16851
16852 ==text ' text==
16853 section 4
16854
16855 ==text " text==
16856 section 5
16857 !! html/php
16858 <p>The tooltips shall not show entities to the user (ie. be double escaped)
16859 </p>
16860 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16861 <ul>
16862 <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>
16863 <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>
16864 <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>
16865 <li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li>
16866 <li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li>
16867 </ul>
16868 </div>
16869
16870 <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>
16871 <p>section 1
16872 </p>
16873 <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>
16874 <p>section 2
16875 </p>
16876 <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>
16877 <p>section 3
16878 </p>
16879 <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>
16880 <p>section 4
16881 </p>
16882 <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>
16883 <p>section 5
16884 </p>
16885 !! html/parsoid
16886 <p>The tooltips shall not show entities to the user (ie. be double escaped)</p>
16887
16888 <h2 id="text_>_text"><span id="text_.3E_text" typeof="mw:FallbackId"></span>text > text</h2>
16889 <p>section 1</p>
16890
16891 <h2 id="text_&lt;_text"><span id="text_.3C_text" typeof="mw:FallbackId"></span>text &lt; text</h2>
16892 <p>section 2</p>
16893
16894 <h2 id="text_&amp;_text"><span id="text_.26_text" typeof="mw:FallbackId"></span>text &amp; text</h2>
16895 <p>section 3</p>
16896
16897 <h2 id="text_'_text"><span id="text_.27_text" typeof="mw:FallbackId"></span>text ' text</h2>
16898 <p>section 4</p>
16899
16900 <h2 id='text_"_text'><span id="text_.22_text" typeof="mw:FallbackId"></span>text " text</h2>
16901 <p>section 5</p>
16902 !! end
16903
16904 !! test
16905 Header with space, plus and underscore as entity
16906 !! wikitext
16907 Id should not contain + for spaces
16908
16909 ==Space between Text==
16910 section 1
16911
16912 ==Space-Entity&#32;between&#32;Text==
16913 section 2
16914
16915 ==Plus+between+Text==
16916 section 3
16917
16918 ==Plus-Entity&#43;between&#43;Text==
16919 section 4
16920
16921 ==Underscore_between_Text==
16922 section 5
16923
16924 ==Underscore-Entity&#95;between&#95;Text==
16925 section 6
16926
16927 [[#Space between Text]]
16928 [[#Space-Entity&#32;between&#32;Text]]
16929 [[#Plus+between+Text]]
16930 [[#Plus-Entity&#43;between&#43;Text]]
16931 [[#Underscore_between_Text]]
16932 [[#Underscore-Entity&#95;between&#95;Text]]
16933 !! html/php
16934 <p>Id should not contain + for spaces
16935 </p>
16936 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16937 <ul>
16938 <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>
16939 <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>
16940 <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>
16941 <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>
16942 <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>
16943 <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>
16944 </ul>
16945 </div>
16946
16947 <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>
16948 <p>section 1
16949 </p>
16950 <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>
16951 <p>section 2
16952 </p>
16953 <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>
16954 <p>section 3
16955 </p>
16956 <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>
16957 <p>section 4
16958 </p>
16959 <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>
16960 <p>section 5
16961 </p>
16962 <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>
16963 <p>section 6
16964 </p><p><a href="#Space_between_Text">#Space between Text</a>
16965 <a href="#Space-Entity_between_Text">#Space-Entity&#32;between&#32;Text</a>
16966 <a href="#Plus.2Bbetween.2BText">#Plus+between+Text</a>
16967 <a href="#Plus-Entity.2Bbetween.2BText">#Plus-Entity&#43;between&#43;Text</a>
16968 <a href="#Underscore_between_Text">#Underscore_between_Text</a>
16969 <a href="#Underscore-Entity_between_Text">#Underscore-Entity&#95;between&#95;Text</a>
16970 </p>
16971 !! html/parsoid
16972 <p>Id should not contain + for spaces</p>
16973
16974 <h2 id="Space_between_Text">Space between Text</h2>
16975 <p>section 1</p>
16976
16977 <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>
16978 <p>section 2</p>
16979
16980 <h2 id="Plus+between+Text"><span id="Plus.2Bbetween.2BText" typeof="mw:FallbackId"></span>Plus+between+Text</h2>
16981 <p>section 3</p>
16982
16983 <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>
16984 <p>section 4</p>
16985
16986 <h2 id="Underscore_between_Text">Underscore_between_Text</h2>
16987 <p>section 5</p>
16988
16989 <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>
16990 <p>section 6</p>
16991
16992 <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>
16993 <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>
16994 <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>
16995 <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>
16996 <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>
16997 <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>
16998 !! end
16999
17000 # Parsoid html2wt disabled because it adds padding spaces around =
17001 !! test
17002 Headers with excess '=' characters
17003 (Are similar tests necessary beyond the 1st level?)
17004 !! options
17005 parsoid=wt2html,wt2wt,html2html
17006 !! wikitext
17007 =foo==
17008 ==foo=
17009 =''italic'' heading==
17010 ==''italic'' heading=
17011 !! html/php
17012 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
17013 <ul>
17014 <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
17015 <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
17016 <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>
17017 <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>
17018 </ul>
17019 </div>
17020
17021 <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>
17022 <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>
17023 <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>
17024 <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>
17025
17026 !! html/parsoid
17027 <h1 id="foo="><span id="foo.3D" typeof="mw:FallbackId"></span>foo=</h1>
17028 <h1 id="=foo"><span id=".3Dfoo" typeof="mw:FallbackId"></span>=foo</h1>
17029 <h1 id="italic_heading="><span id="italic_heading.3D" typeof="mw:FallbackId"></span><i>italic</i> heading=</h1>
17030 <h1 id="=italic_heading"><span id=".3Ditalic_heading" typeof="mw:FallbackId"></span>=<i>italic</i> heading</h1>
17031 !! end
17032
17033 !! test
17034 HTML headers vs TOC (T25393)
17035 (__NOEDITSECTION__ for clearer output, doesn't matter here)
17036 !! wikitext
17037 <h1>Header 1</h1>
17038 ==Header 1.1==
17039 ==Header 1.2==
17040
17041 <h1>Header 2
17042 </h1>
17043 ==Header 2.1==
17044 ==Header 2.2==
17045 __NOEDITSECTION__
17046 !! html/php
17047 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
17048 <ul>
17049 <li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
17050 <ul>
17051 <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>
17052 <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>
17053 </ul>
17054 </li>
17055 <li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a>
17056 <ul>
17057 <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>
17058 <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>
17059 </ul>
17060 </li>
17061 </ul>
17062 </div>
17063
17064 <h1><span class="mw-headline" id="Header_1">Header 1</span></h1>
17065 <h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2>
17066 <h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2>
17067 <h1><span class="mw-headline" id="Header_2">Header 2
17068 </span></h1>
17069 <h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2>
17070 <h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2>
17071
17072 !! html/parsoid
17073 <h1 id="Header_1" data-parsoid='{"stx":"html"}'>Header 1</h1>
17074 <h2 id="Header_1.1" data-parsoid='{}'>Header 1.1</h2>
17075 <h2 id="Header_1.2" data-parsoid='{}'>Header 1.2</h2>
17076
17077 <h1 id="Header_2" data-parsoid='{"stx":"html"}'>Header 2
17078 </h1>
17079 <h2 id="Header_2.1" data-parsoid='{}'>Header 2.1</h2>
17080 <h2 id="Header_2.2" data-parsoid='{}'>Header 2.2</h2>
17081 <meta property="mw:PageProp/noeditsection"/>
17082 !! end
17083
17084 !! test
17085 Single-line or multiline-comments can follow headings
17086 !! options
17087 parsoid=wt2html,wt2wt
17088 !! wikitext
17089 ==foo==<!---->
17090 ==bar==<!--c1-->
17091 ==baz==<!--
17092 c2
17093 c3-->
17094 !! html/php
17095 <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>
17096 <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>
17097 <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>
17098
17099 !! html/parsoid
17100 <h2 id="foo">foo</h2><!---->
17101 <h2 id="bar">bar</h2><!--c1-->
17102 <h2 id="baz">baz</h2><!--
17103 c2
17104 c3-->
17105 !! end
17106
17107 !! test
17108 T3219 URL next to image (broken)
17109 !! wikitext
17110 http://example.com[[File:Foobar.jpg]]
17111 !! html/php
17112 <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>
17113 </p>
17114 !! html/parsoid
17115 <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>
17116 !!end
17117
17118 !! test
17119 T3186 news: in the middle of text
17120 !! wikitext
17121 http://en.wikinews.org/wiki/Wikinews:Workplace
17122 !! html
17123 <p><a rel="nofollow" class="external free" href="http://en.wikinews.org/wiki/Wikinews:Workplace">http://en.wikinews.org/wiki/Wikinews:Workplace</a>
17124 </p>
17125 !!end
17126
17127
17128 !! test
17129 Namespaced link must have a title
17130 !! wikitext
17131 [[Project:]]
17132 !! html
17133 <p>[[Project:]]
17134 </p>
17135 !!end
17136
17137 !! test
17138 Namespaced link must have a title (bad fragment version)
17139 !! wikitext
17140 [[Project:#fragment]]
17141 !! html
17142 <p>[[Project:#fragment]]
17143 </p>
17144 !!end
17145
17146
17147 ###
17148 ### HTML tags and HTML attributes
17149 ###
17150
17151 !! test
17152 div with no attributes
17153 !! wikitext
17154 <div>HTML rocks</div>
17155 !! html
17156 <div>HTML rocks</div>
17157
17158 !! end
17159
17160 !! test
17161 div with double-quoted attribute
17162 !! wikitext
17163 <div id="rock">HTML rocks</div>
17164 !! html
17165 <div id="rock">HTML rocks</div>
17166
17167 !! end
17168
17169 !! test
17170 div with single-quoted attribute
17171 !! wikitext
17172 <div id='rock'>HTML rocks</div>
17173 !! html
17174 <div id="rock">HTML rocks</div>
17175
17176 !! end
17177
17178 !! test
17179 div with unquoted attribute
17180 !! wikitext
17181 <div id=rock>HTML rocks</div>
17182 !! html
17183 <div id="rock">HTML rocks</div>
17184
17185 !! end
17186
17187 !! test
17188 div with illegal double attributes
17189 !! wikitext
17190 <div id="a" id="b">HTML rocks</div>
17191 !! html
17192 <div id="b">HTML rocks</div>
17193
17194 !!end
17195
17196 !! test
17197 div with empty attribute value, space before equals
17198 !! options
17199 parsoid=wt2html,html2html
17200 !! wikitext
17201 <div class =>HTML rocks</div>
17202 !! html/php
17203 <div class="">HTML rocks</div>
17204
17205 !! html/parsoid
17206 <div class="" data-parsoid='{"stx":"html"}'>HTML rocks</div>
17207 !! end
17208
17209 !! test
17210 div with multiple empty attribute values
17211 !! config
17212 wgFragmentMode=[ 'html5', 'legacy' ]
17213 !! options
17214 parsoid=wt2html,html2html
17215 !! wikitext
17216 <div id= title=>HTML rocks</div>
17217 !! html/php
17218 <div id="title=">HTML rocks</div>
17219
17220 !! html/parsoid
17221 <div id="title=" data-parsoid='{"stx":"html"}'>HTML rocks</div>
17222 !! end
17223
17224 # FIXME Parsoid doesn't actually match PHP here.
17225 # Probably we should use the synthetic <foo /> or <indicator>
17226 # extensions for this test, which are enabled when running parser tests.
17227 !! test
17228 Extension tag in attribute value
17229 !! wikitext
17230 <span title="<translate>123</translate>">ok</span>
17231 !! html/php+disabled
17232 <p>&lt;span title="&lt;translate&gt;123&lt;/translate&gt;"&gt;ok&lt;/span&gt;
17233 </p>
17234 !! html/parsoid
17235 <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>
17236 !! end
17237
17238 !! test
17239 table with multiple empty attribute values
17240 !! options
17241 parsoid=wt2html,html2html
17242 !! wikitext
17243 {| title= id=
17244 |hi
17245 |}
17246 !! html/php
17247 <table title="id=">
17248 <tr>
17249 <td>hi
17250 </td></tr></table>
17251
17252 !! html/parsoid
17253 <table title="id=">
17254 <tbody><tr><td>hi</td></tr>
17255 </tbody></table>
17256 !! end
17257
17258 !! test
17259 div with braces in attribute value
17260 !! wikitext
17261 <div title="{}">Foo</div>
17262 !! html/php
17263 <div title="&#123;&#125;">Foo</div>
17264
17265 !! html/parsoid
17266 <div title="{}">Foo</div>
17267 !! end
17268
17269 !! test
17270 div with empty attribute value, no space before equals
17271 !! options
17272 parsoid=wt2html,html2html
17273 !! wikitext
17274 <div class=>HTML rocks</div>
17275 !! html/php
17276 <div class="">HTML rocks</div>
17277
17278 !! html/parsoid
17279 <div class="">HTML rocks</div>
17280 !! end
17281
17282 !! test
17283 HTML multiple attributes correction
17284 !! wikitext
17285 <p class="error" class="awesome">Awesome!</p>
17286 !! html
17287 <p class="awesome">Awesome!</p>
17288
17289 !!end
17290
17291 !! test
17292 Table multiple attributes correction
17293 !! wikitext
17294 {|
17295 !+ class="error" class="awesome"|status
17296 |}
17297 !! html
17298 <table>
17299 <tr>
17300 <th class="awesome">status
17301 </th></tr></table>
17302
17303 !!end
17304
17305 !! test
17306 DIV IN UPPERCASE
17307 !! wikitext
17308 <DIV ID="x">HTML ROCKS</DIV>
17309 !! html
17310 <div id="x">HTML ROCKS</div>
17311
17312 !!end
17313
17314 !! test
17315 Non-ASCII pseudo-tags are rendered as text
17316 !! wikitext
17317 <khyô>
17318 !! html
17319 <p>&lt;khyô&gt;
17320 </p>
17321 !! end
17322
17323 !! test
17324 Pseudo-tag with URL 'name' renders as url link
17325 !! wikitext
17326 <http://example.com/>
17327 !! html
17328 <p>&lt;<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&gt;
17329 </p>
17330 !! end
17331
17332 !! test
17333 text with amp in the middle of nowhere
17334 !! wikitext
17335 Remember AT&T?
17336 !! html
17337 <p>Remember AT&amp;T?
17338 </p>
17339 !! end
17340
17341 !! test
17342 text with character entity: eacute
17343 !! wikitext
17344 I always thought &eacute; was a cute letter.
17345 !! html+tidy
17346 <p>I always thought &#233; was a cute letter.
17347 </p>
17348 !! end
17349
17350 !! test
17351 text with entity-escaped character entity-like string: eacute
17352 !! wikitext
17353 I always thought &amp;eacute; was a cute letter.
17354 !! html
17355 <p>I always thought &amp;eacute; was a cute letter.
17356 </p>
17357 !! end
17358
17359 !! test
17360 text with undefined character entity: xacute
17361 !! wikitext
17362 I always thought &xacute; was a cute letter.
17363 !! html
17364 <p>I always thought &amp;xacute; was a cute letter.
17365 </p>
17366 !! end
17367
17368 !! test
17369 HTML5 tags
17370 !! wikitext
17371 <data value="5">five</data>
17372 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
17373 <mark>This highlighted text</mark>
17374 !! html
17375 <p><data value="5">five</data>
17376 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
17377 <mark>This highlighted text</mark>
17378 </p>
17379 !! end
17380
17381 !! test
17382 HTML tag with leading space is parsed as text
17383 !! wikitext
17384 < div>foo< /div>
17385 !! html
17386 <p>&lt; div&gt;foo&lt; /div&gt;
17387 </p>
17388 !! end
17389
17390 ## Don't expect Parsoid and PHP to match, since PHP isn't exactly following
17391 ## the HTML5 parsing spec.
17392 !! test
17393 Element with broken attribute syntax
17394 !! options
17395 parsoid=wt2html
17396 !! wikitext
17397 <div style=" style="123">hi</div>
17398 <div =>ho</div>
17399 !! html/php
17400 <div style="123">hi</div>
17401 <div>ho</div>
17402
17403 !! html/parsoid
17404 <div style=" style=" data-parsoid='{"stx":"html","a":{"123\"":null},"sa":{"123\"":""}}'>hi</div>
17405 <div data-parsoid='{"stx":"html","a":{"=":null},"sa":{"=":""}}'>ho</div>
17406 !! end
17407
17408 ###
17409 ### Nesting tests (see T43545, T52604, T53081)
17410 ###
17411
17412 # This test case is fixed in Parsoid by domino 1.0.12. (T52604)
17413 # Note that html2wt is considerably more difficult if we use <b> in
17414 # the test case, instead of <small>
17415 !! test
17416 Ensure that HTML adoption agency algorithm is properly implemented.
17417 !! wikitext
17418 <small>X<small>Y</small>Z</small>
17419 !! html
17420 <p><small>X<small>Y</small>Z</small>
17421 </p>
17422 !! end
17423
17424 # This was T43545 in the PHP parser.
17425 !! test
17426 Nesting of <kbd>
17427 !! wikitext
17428 <kbd>X<kbd>Y</kbd>Z</kbd>
17429 !! html+tidy
17430 <p><kbd>X<kbd>Y</kbd>Z</kbd>
17431 </p>
17432 !! end
17433
17434 # The following cases were T53081 in the PHP parser.
17435 # Note that there are some other nestable tags (b, i, etc) which are
17436 # not covered; see T53081 for discussion.
17437
17438 !! test
17439 Nesting of <em>
17440 !! wikitext
17441 <em>X<em>Y</em>Z</em>
17442 !! html+tidy
17443 <p><em>X<em>Y</em>Z</em>
17444 </p>
17445 !! end
17446
17447 !! test
17448 Nesting of <strong>
17449 !! wikitext
17450 <strong>X<strong>Y</strong>Z</strong>
17451 !! html+tidy
17452 <p><strong>X<strong>Y</strong>Z</strong>
17453 </p>
17454 !! end
17455
17456 !! test
17457 Nesting of <q>
17458 !! wikitext
17459 <q>X<q>Y</q>Z</q>
17460 !! html+tidy
17461 <p><q>X<q>Y</q>Z</q>
17462 </p>
17463 !! end
17464
17465 !! test
17466 Nesting of <ruby>
17467 !! wikitext
17468 <ruby>X<ruby>Y</ruby>Z</ruby>
17469 !! html
17470 <p><ruby>X<ruby>Y</ruby>Z</ruby>
17471 </p>
17472 !! end
17473
17474 !! test
17475 Nesting of <bdo>
17476 !! wikitext
17477 <bdo>X<bdo>Y</bdo>Z</bdo>
17478 !! html
17479 <p><bdo>X<bdo>Y</bdo>Z</bdo>
17480 </p>
17481 !! end
17482
17483
17484 ###
17485 ### Media links
17486 ###
17487
17488 !! test
17489 Media link
17490 !! wikitext
17491 [[Media:Foobar.jpg]]
17492 [[Media:Video.ogv]]
17493 [[:Media:Video.ogv]]
17494 !! html/php
17495 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a>
17496 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
17497 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
17498 </p>
17499 !! html/parsoid
17500 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a>
17501 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" title="Video.ogv">Media:Video.ogv</a>
17502 <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>
17503 !! end
17504
17505 !! test
17506 Media link with text
17507 !! wikitext
17508 [[Media:Foobar.jpg|A neat file to look at]]
17509 !! html/php
17510 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">A neat file to look at</a>
17511 </p>
17512 !! html/parsoid
17513 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
17514 !! end
17515
17516 # FIXME: this is still bad HTML tag nesting
17517 # FIXME: doBlockLevels won't wrap this in a paragraph because it contains a div
17518 # Parsoid & Remex fix the p-wrapping since they operate on the DOM.
17519 !! test
17520 Media link with nasty text
17521 !! wikitext
17522 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
17523 !! html/php
17524 <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>
17525
17526 !! html/php+tidy
17527 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Safe Link</a></p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg"><div style="display:none">" onmouseover="alert(document.cookie)" onfoo="</div></a>
17528 !! html/parsoid
17529 <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>
17530
17531 !! end
17532
17533 !! test
17534 Media link to nonexistent file (T3702)
17535 !! wikitext
17536 [[Media:No such.jpg]]
17537 [[Media:No_such file.jpg]]
17538 !! html/php
17539 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a>
17540 <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>
17541 </p>
17542 !! html/parsoid
17543 <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>
17544 <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>
17545 !! end
17546
17547 !! test
17548 Image link to nonexistent file (T3850 - good)
17549 !! wikitext
17550 [[File:No_such.jpg]]
17551 !! html/php
17552 <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>
17553 </p>
17554 !! html/parsoid
17555 <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>
17556 !! end
17557
17558 !! test
17559 :Image link to nonexistent file (T3850 - bad)
17560 !! wikitext
17561 [[:Image:No such.jpg]]
17562 !! html/php
17563 <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>
17564 </p>
17565 !! html/parsoid
17566 <p><a rel="mw:WikiLink" href="./File:No_such.jpg" title="File:No such.jpg">Image:No such.jpg</a></p>
17567 !! end
17568
17569 !! test
17570 Character reference normalization in link text (T3938)
17571 !! wikitext
17572 [[Main Page|this&that]]
17573 !! html
17574 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
17575 </p>
17576 !!end
17577
17578 !! article
17579 אַ
17580 !! text
17581 Test for unicode normalization
17582
17583 The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
17584 !! endarticle
17585
17586 !! test
17587 (T21451) Links should refer to the normalized form.
17588 !! wikitext
17589 [[&#xFB2E;]]
17590 [[&#x5d0;&#x5b7;]]
17591 [[&#x5d0;ַ]]
17592 [[א&#x5b7;]]
17593 [[אַ]]
17594 !! html
17595 <p><a href="/wiki/%D7%90%D6%B7" title="אַ">&#xfb2e;</a>
17596 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;&#x5b7;</a>
17597 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;ַ</a>
17598 <a href="/wiki/%D7%90%D6%B7" title="אַ">א&#x5b7;</a>
17599 <a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a>
17600 </p>
17601 !! end
17602
17603 !! test
17604 Empty attribute crash test (T4067)
17605 !! wikitext
17606 <font color="">foo</font>
17607 !! html
17608 <p><font color="">foo</font>
17609 </p>
17610 !! end
17611
17612 !! test
17613 Empty attribute crash test single-quotes (T4067)
17614 !! wikitext
17615 <font color=''>foo</font>
17616 !! html
17617 <p><font color="">foo</font>
17618 </p>
17619 !! end
17620
17621 !! test
17622 Attribute test: equals, then nothing
17623 !! options
17624 parsoid=wt2html,html2html
17625 !! wikitext
17626 <font color=>foo</font>
17627 !! html/php
17628 <p><font color="">foo</font>
17629 </p>
17630 !! html/parsoid
17631 <p><font color="" data-parsoid='{"stx":"html"}'>foo</font></p>
17632 !! end
17633
17634 !! test
17635 Attribute test: unquoted value
17636 !! options
17637 parsoid=wt2html,html2html
17638 !! wikitext
17639 <font color=x>foo</font>
17640 !! html/php
17641 <p><font color="x">foo</font>
17642 </p>
17643 !! html/parsoid
17644 <p><font color="x" data-parsoid='{"stx":"html"}'>foo</font></p>
17645 !! end
17646
17647 !! test
17648 Attribute test: unquoted but illegal value (hash)
17649 !! wikitext
17650 <font color=#x>foo</font>
17651 !! html
17652 <p><font color="#x">foo</font>
17653 </p>
17654 !! end
17655
17656 # Parsoid does not serialize to empty attribute syntax,
17657 # so wt2wt and html2wt cases are skipped
17658 !! test
17659 Attribute test: no value (T54330)
17660 !! options
17661 parsoid=wt2html,html2html
17662 !! wikitext
17663 <font color>foo</font>
17664 !! html/php
17665 <p><font color="">foo</font>
17666 </p>
17667 !! html/parsoid
17668 <p><font color="">foo</font></p>
17669 !! end
17670
17671 !! test
17672 T4095: link with three closing brackets
17673 !! wikitext
17674 [[Main Page]]]
17675 !! html/php
17676 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
17677 </p>
17678 !! html/parsoid
17679 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>]</p>
17680 !! end
17681
17682 !! test
17683 T4095: link with pipe and three closing brackets
17684 !! wikitext
17685 [[Main Page|link]]]
17686 !! html/php
17687 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
17688 </p>
17689 !! html/parsoid
17690 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">link</a>]</p>
17691 !! end
17692
17693 !! test
17694 T4095: link with pipe and three closing brackets, version 2
17695 !! wikitext
17696 [[Main Page|[http://example.com/]]]
17697 !! html/php
17698 <p><a href="/wiki/Main_Page" title="Main Page">[http://example.com/]</a>
17699 </p>
17700 !! html/parsoid
17701 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">[http://example.com/]</a></p>
17702 !! end
17703
17704
17705 ###
17706 ### Safety
17707 ###
17708
17709 !! article
17710 Template:Dangerous attribute
17711 !! text
17712 " onmouseover="alert(document.cookie)
17713 !! endarticle
17714
17715 !! article
17716 Template:Dangerous style attribute
17717 !! text
17718 border-size: expression(alert(document.cookie))
17719 !! endarticle
17720
17721 !! article
17722 Template:Div style
17723 !! text
17724 <div style="float: right; {{{1}}}">Magic div</div>
17725 !! endarticle
17726
17727 !! test
17728 T4304: HTML attribute safety (safe template; regression T4309)
17729 !! wikitext
17730 <div title="{{test}}"></div>
17731 !! html/php
17732 <div title="This is a test template"></div>
17733
17734 !! html/parsoid
17735 <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>
17736 !! end
17737
17738 # Parsoid has enough context to handle this case
17739 !! test
17740 T4304: HTML attribute safety (dangerous template; 2309)
17741 !! wikitext
17742 <div title="{{dangerous attribute}}"></div>
17743 !! html/php
17744 <div title=""></div>
17745
17746 !! html/parsoid
17747 <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>
17748 !! end
17749
17750 !! test
17751 T4304: HTML attribute safety (dangerous style template; 2309)
17752 !! wikitext
17753 <div style="{{dangerous style attribute}}"></div>
17754 !! html/php
17755 <div style="/* insecure input */"></div>
17756
17757 !! html/parsoid
17758 <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>
17759 !! end
17760
17761 !! test
17762 T4304: HTML attribute safety (safe parameter; 2309)
17763 !! wikitext
17764 {{div style|width: 200px}}
17765 !! html/php
17766 <div style="float: right; width: 200px">Magic div</div>
17767
17768 !! html/parsoid
17769 <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>
17770 !! end
17771
17772 !! test
17773 T4304: HTML attribute safety (unsafe parameter; 2309)
17774 !! wikitext
17775 {{div style|width: expression(alert(document.cookie))}}
17776 !! html/php
17777 <div style="/* insecure input */">Magic div</div>
17778
17779 !! html/parsoid
17780 <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>
17781 !! end
17782
17783 ## Parsoid output here differs; needs investigation.
17784 !! test
17785 T4304: HTML attribute safety (unsafe breakout parameter; 2309)
17786 !! wikitext
17787 {{div style|"><script>alert(document.cookie)</script>}}
17788 !! html
17789 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17790
17791 !! end
17792
17793 ## Parsoid output here differs; needs investigation.
17794 !! test
17795 T4304: HTML attribute safety (unsafe breakout parameter 2; 2309)
17796 !! wikitext
17797 {{div style|" ><script>alert(document.cookie)</script>}}
17798 !! html
17799 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17800
17801 !! end
17802
17803 !! test
17804 T4304: HTML attribute safety (link)
17805 !! wikitext
17806 <div title="[[Main Page]]"></div>
17807 !! html/php
17808 <div title="&#91;&#91;Main Page&#93;&#93;"></div>
17809
17810 !! html/parsoid
17811 <div title="[[Main Page]]"></div>
17812 !! end
17813
17814 !! test
17815 T4304: HTML attribute safety (italics)
17816 !! wikitext
17817 <div title="''foobar''"></div>
17818 !! html
17819 <div title="&#39;&#39;foobar&#39;&#39;"></div>
17820
17821 !! end
17822
17823 !! test
17824 T4304: HTML attribute safety (bold)
17825 !! wikitext
17826 <div title="'''foobar'''"></div>
17827 !! html
17828 <div title="&#39;&#39;&#39;foobar&#39;&#39;&#39;"></div>
17829
17830 !! end
17831
17832 !! test
17833 T4304: HTML attribute safety (ISBN)
17834 !! wikitext
17835 <div title="ISBN 1234567890"></div>
17836 !! html
17837 <div title="&#73;SBN 1234567890"></div>
17838
17839 !! end
17840
17841 !! test
17842 T4304: HTML attribute safety (RFC)
17843 !! wikitext
17844 <div title="RFC 1234"></div>
17845 !! html
17846 <div title="&#82;FC 1234"></div>
17847
17848 !! end
17849
17850 !! test
17851 T4304: HTML attribute safety (PMID)
17852 !! wikitext
17853 <div title="PMID 1234567890"></div>
17854 !! html
17855 <div title="&#80;MID 1234567890"></div>
17856
17857 !! end
17858
17859 !! test
17860 T4304: HTML attribute safety (web link)
17861 !! wikitext
17862 <div title="http://example.com/"></div>
17863 !! html
17864 <div title="http&#58;//example.com/"></div>
17865
17866 !! end
17867
17868 !! test
17869 T4304: HTML attribute safety (named web link)
17870 !! wikitext
17871 <div title="[http://example.com/ link]"></div>
17872 !! html/php
17873 <div title="&#91;http&#58;//example.com/ link&#93;"></div>
17874
17875 !! html/parsoid
17876 <div title="[http://example.com/ link]"></div>
17877 !! end
17878
17879 !! test
17880 T5244: HTML attribute safety (extension; safe)
17881 !! wikitext
17882 <div style="<nowiki>background:blue</nowiki>"></div>
17883 !! html/php
17884 <div style="background:blue"></div>
17885
17886 !! html/parsoid
17887 <div style="background:blue" data-parsoid='{"stx":"html","a":{"style":"background:blue"},"sa":{"style":"&lt;nowiki>background:blue&lt;/nowiki>"}}'></div>
17888 !! end
17889
17890 !! test
17891 T5244: HTML attribute safety (extension; unsafe)
17892 !! wikitext
17893 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
17894 !! html/php
17895 <div style="/* insecure input */"></div>
17896
17897 !! html/parsoid
17898 <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>
17899 !! end
17900
17901 # More MSIE fun discovered by Tom Gilder
17902
17903 !! test
17904 MSIE CSS safety test: spurious slash
17905 !! wikitext
17906 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
17907 !! html/php
17908 <div style="/* insecure input */">evil</div>
17909
17910 !! html/parsoid
17911 <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>
17912 !! end
17913
17914 !! test
17915 MSIE CSS safety test: hex code
17916 !! wikitext
17917 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
17918 !! html/php
17919 <div style="/* insecure input */">evil</div>
17920
17921 !! html/parsoid
17922 <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>
17923 !! end
17924
17925 !! test
17926 MSIE CSS safety test: comment in url
17927 !! wikitext
17928 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
17929 !! html/php
17930 <div style="background-image:u rl(javascript:alert(&#39;boo&#39;))">evil</div>
17931
17932 !! html/parsoid
17933 <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>
17934 !! end
17935
17936 !! test
17937 MSIE CSS safety test: comment in expression
17938 !! wikitext
17939 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
17940 !! html/php
17941 <div style="background-image:expres sion(alert(&#39;boo4&#39;))">evil4</div>
17942
17943 !! html/parsoid
17944 <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>
17945 !! end
17946
17947 !! test
17948 CSS safety test (all browsers): vertical tab (T57332 / CVE-2013-4567)
17949 !! wikitext
17950 <p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p>
17951 !! html/php
17952 <p style="/* invalid control char */">A</p>
17953
17954 !! html/parsoid
17955 <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>
17956 !! end
17957
17958 !! test
17959 MSIE 6 CSS safety test: Fullwidth (T57332)
17960 !! wikitext
17961 <p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p>
17962 <div style="top:EXPRESSION(alert())">B</div>
17963 !! html/php
17964 <p style="/* insecure input */">A</p>
17965 <div style="/* insecure input */">B</div>
17966
17967 !! html/parsoid
17968 <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>
17969 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"top:EXPRESSION(alert())"}}'>B</div>
17970 !! end
17971
17972 !! test
17973 MSIE 6 CSS safety test: IPA extensions (T57332)
17974 !! wikitext
17975 <div style="background-image:uʀʟ(javascript:alert())">A</div>
17976 <p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p>
17977 !! html/php
17978 <div style="/* insecure input */">A</div>
17979 <p style="/* insecure input */">B</p>
17980
17981 !! html/parsoid
17982 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:uʀʟ(javascript:alert())"}}'>A</div>
17983 <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>
17984 !! end
17985
17986 !! test
17987 MSIE 6 CSS safety test: sup/sub script (T57332)
17988 !! wikitext
17989 <div style="background-image:url⁽javascript:alert())">A</div>
17990 <div style="background-image:url₍javascript:alert())">B</div>
17991 <p style="font-size: 100px; color: expressioⁿ((title='XSSed'),'red')">C</p>
17992 !! html/php
17993 <div style="/* insecure input */">A</div>
17994 <div style="/* insecure input */">B</div>
17995 <p style="/* insecure input */">C</p>
17996
17997 !! html/parsoid
17998 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url⁽javascript:alert())"}}'>A</div>
17999 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url₍javascript:alert())"}}'>B</div>
18000 <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>
18001 !! end
18002
18003 !! test
18004 Opera -o-link CSS
18005 !! options
18006 parsoid=wt2html,html2html
18007 !! wikitext
18008 <div
18009 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;"
18010 style="-o-link:attr(title);-o-link-source:current">X</div>
18011 !! html/php
18012 <div title="data:text/html,&lt;img src=1 onerror=alert(1)&gt;" style="/* insecure input */">X</div>
18013
18014 !! html/parsoid
18015 <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>
18016 !! end
18017
18018 !! test
18019 MSIE 6 CSS safety test: Repetition markers (T57332)
18020 !! wikitext
18021 <p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p>
18022 <p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p>
18023 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">C</p>
18024 <p style="font-size: 100px; color: expresヽion((title='XSSed'),'red')">D</p>
18025 <p style="font-size: 100px; color: expresﹽion((title='XSSed'),'red')">E</p>
18026 <p style="font-size: 100px; color: expresﹼion((title='XSSed'),'red')">F</p>
18027 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">G</p>
18028 !! html/php
18029 <p style="/* insecure input */">A</p>
18030 <p style="/* insecure input */">B</p>
18031 <p style="/* insecure input */">C</p>
18032 <p style="/* insecure input */">D</p>
18033 <p style="/* insecure input */">E</p>
18034 <p style="/* insecure input */">F</p>
18035 <p style="/* insecure input */">G</p>
18036
18037 !! html/parsoid
18038 <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>
18039 <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>
18040 <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>
18041 <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>
18042 <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>
18043 <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>
18044 <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>
18045 !! end
18046
18047 !! test
18048 Table attribute legitimate extension
18049 !! wikitext
18050 {|
18051 !+ style="<nowiki>color:blue</nowiki>"|status
18052 |}
18053 !! html
18054 <table>
18055 <tr>
18056 <th style="color:blue">status
18057 </th></tr></table>
18058
18059 !!end
18060
18061 !! test
18062 Table attribute safety
18063 !! wikitext
18064 {|
18065 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"|status
18066 |}
18067 !! html
18068 <table>
18069 <tr>
18070 <th style="/* insecure input */">status
18071 </th></tr></table>
18072
18073 !! end
18074
18075 !! test
18076 CSS line continuation 1
18077 !! wikitext
18078 <div style="background-image: u\&#10;rl(test.jpg);"></div>
18079 !! html
18080 <div style="/* insecure input */"></div>
18081
18082 !! end
18083
18084 !! test
18085 CSS line continuation 2
18086 !! wikitext
18087 <div style="background-image: u\&#13;rl(test.jpg); "></div>
18088 !! html
18089 <div style="/* invalid control char */"></div>
18090
18091 !! end
18092
18093 !! article
18094 Template:Identity
18095 !! text
18096 {{{1}}}
18097 !! endarticle
18098
18099 !! test
18100 Expansion of multi-line templates in attribute values (T8255)
18101 !! wikitext
18102 <div style="background: {{identity|#00FF00}}">-</div>
18103 !! html
18104 <div style="background: #00FF00">-</div>
18105
18106 !! end
18107
18108 !! test
18109 Expansion of multi-line templates in attribute values (T8255 sanity check)
18110 !! wikitext
18111 <div style="background:
18112 #00FF00">-</div>
18113 !! html/php
18114 <div style="background: #00FF00">-</div>
18115
18116 !! html/parsoid
18117 <div style="background:
18118 #00FF00">-</div>
18119 !! end
18120
18121 !! test
18122 Expansion of multi-line templates in attribute values (T8255 sanity check 2)
18123 !! wikitext
18124 <div style="background: &#10;#00FF00">-</div>
18125 !! html
18126 <div style="background: &#10;#00FF00">-</div>
18127
18128 !! end
18129
18130 !! test
18131 Tags which are hidden from tidiers cannot pass through the Sanitizer
18132 !! wikitext
18133 <mw:toc><script>alert();</script></mw:toc>
18134 !! html+tidy
18135 <p>&lt;mw:toc&gt;&lt;script&gt;alert();&lt;/script&gt;&lt;/mw:toc&gt;
18136 </p>
18137 !! end
18138
18139 ###
18140 ### Parser hooks (see tests/parser/parserTestsParserHook.php for the <tag> extension)
18141 ###
18142
18143 !! test
18144 Parser hook: empty input
18145 !! wikitext
18146 <tag></tag>
18147 !! html/php
18148 <pre>
18149 ''
18150 array (
18151 )
18152 </pre>
18153
18154 !! html/parsoid
18155 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18156 !! end
18157
18158 ## Don't expect parsoid to rt this form.
18159 !! test
18160 Parser hook: empty input using terminated empty elements
18161 !! options
18162 parsoid=wt2html,html2html
18163 !! wikitext
18164 <tag/>
18165 !! html/php
18166 <pre>
18167 NULL
18168 array (
18169 )
18170 </pre>
18171
18172 !! html/parsoid
18173 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
18174 !! end
18175
18176 !! test
18177 Parser hook: empty input using terminated empty elements (space before)
18178 !! wikitext
18179 <tag />
18180 !! html/php
18181 <pre>
18182 NULL
18183 array (
18184 )
18185 </pre>
18186
18187 !! html/parsoid
18188 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
18189 !! end
18190
18191 !! test
18192 Parser hook: basic input
18193 !! wikitext
18194 <tag>input</tag>
18195 !! html/php
18196 <pre>
18197 'input'
18198 array (
18199 )
18200 </pre>
18201
18202 !! html/parsoid
18203 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18204 !! end
18205
18206 ## Don't expect parsoid to rt this form.
18207 !! test
18208 Parser hook: case insensitive
18209 !! options
18210 parsoid=wt2html,html2html
18211 !! wikitext
18212 <TAG>input</TAG>
18213 !! html/php
18214 <pre>
18215 'input'
18216 array (
18217 )
18218 </pre>
18219
18220 !! html/parsoid
18221 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18222 !! end
18223
18224 ## Don't expect parsoid to rt this form.
18225 !! test
18226 Parser hook: case insensitive, redux
18227 !! options
18228 parsoid=wt2html,html2html
18229 !! wikitext
18230 <TaG>input</TAg>
18231 !! html/php
18232 <pre>
18233 'input'
18234 array (
18235 )
18236 </pre>
18237
18238 !! html/parsoid
18239 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18240 !! end
18241
18242 !! test
18243 Parser hook: nested tags
18244 !! wikitext
18245 <tag><tag></tag></tag>
18246 !! html/php
18247 <pre>
18248 '<tag>'
18249 array (
18250 )
18251 </pre>&lt;/tag&gt;
18252
18253 !! html/parsoid
18254 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"&lt;tag>"}}' data-parsoid='{}' about="#mwt2"></pre>&lt;/tag>
18255 !! end
18256
18257 !! test
18258 Parser hook: basic arguments
18259 !! wikitext
18260 <tag width="200" height="100" depth="50" square=""></tag>
18261 !! html/php
18262 <pre>
18263 ''
18264 array (
18265 'width' => '200',
18266 'height' => '100',
18267 'depth' => '50',
18268 'square' => '',
18269 )
18270 </pre>
18271
18272 !! html/parsoid
18273 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18274 !! end
18275
18276 ## Don't expect parsoid to rt this form.
18277 !! test
18278 Parser hook: basic arguments, variations
18279 !! options
18280 parsoid=wt2html,html2html
18281 !! wikitext
18282 <tag width=200 height = "100" depth = '50' square></tag>
18283 !! html/php
18284 <pre>
18285 ''
18286 array (
18287 'width' => '200',
18288 'height' => '100',
18289 'depth' => '50',
18290 'square' => '',
18291 )
18292 </pre>
18293
18294 !! html/parsoid
18295 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18296 !! end
18297
18298 !! test
18299 Parser hook: argument containing a forward slash (T7344)
18300 !! wikitext
18301 <tag filename="/tmp/bla"></tag>
18302 !! html/php
18303 <pre>
18304 ''
18305 array (
18306 'filename' => '/tmp/bla',
18307 )
18308 </pre>
18309
18310 !! html/parsoid
18311 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"filename":"/tmp/bla"},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18312 !! end
18313
18314 ## Don't expect parsoid to rt this form.
18315 !! test
18316 Parser hook: empty input using terminated empty elements (T4374)
18317 !! options
18318 parsoid=wt2html,html2html
18319 !! wikitext
18320 <tag foo=bar/>text
18321 !! html/php
18322 <pre>
18323 NULL
18324 array (
18325 'foo' => 'bar',
18326 )
18327 </pre>text
18328
18329 !! html/parsoid
18330 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"foo":"bar"},"body":null}' data-parsoid='{}' about="#mwt2"></pre>text
18331 !! end
18332
18333 ## </tag> should be output literally since there is no matching tag that begins it
18334 ## Don't expect parsoid to rt this form.
18335 !! test
18336 Parser hook: basic arguments using terminated empty elements (T4374)
18337 !! options
18338 parsoid=wt2html
18339 !! wikitext
18340 <tag width=200 height = "100" depth = '50' square/>
18341 other stuff
18342 </tag>
18343 !! html/php
18344 <pre>
18345 NULL
18346 array (
18347 'width' => '200',
18348 'height' => '100',
18349 'depth' => '50',
18350 'square' => '',
18351 )
18352 </pre>
18353 <p>other stuff
18354 &lt;/tag&gt;
18355 </p>
18356 !! html/parsoid
18357 <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
18358 &lt;/tag></p>
18359 !! end
18360
18361 ## Don't expect parsoid to rt this form.
18362 !! test
18363 Parser hook: Don't allow unclosed extension tags
18364 !! options
18365 parsoid=wt2html
18366 !! wikitext
18367 test <tag>123
18368
18369 this is a '''test'''
18370 !! html/php
18371 <p>test &lt;tag&gt;123
18372 </p><p>this is a <b>test</b>
18373 </p>
18374 !! html/parsoid
18375 <p>test &lt;tag>123</p>
18376
18377 <p>this is a <b>test</b></p>
18378 !! end
18379
18380 !! test
18381 Parser hook: horizontal rule inside extension tag that outputs <pre>
18382 !! wikitext
18383 <tag>
18384 Hello
18385 <hr/>
18386 Goodbye
18387 </tag>
18388 !! html/php
18389 <pre>
18390 '
18391 Hello
18392 <hr/>
18393 Goodbye
18394 '
18395 array (
18396 )
18397 </pre>
18398
18399 !! end
18400
18401 ###
18402 ### (see tests/parser/parserTestsParserHook.php for the <statictag> extension)
18403 ###
18404
18405 !! test
18406 Parser hook: static parser hook not inside a comment
18407 !! wikitext
18408 <statictag>hello, world</statictag>
18409
18410 <statictag action="flush" />
18411 !! html/php
18412 <p><br />
18413 hello, world
18414 </p>
18415 !! html/parsoid
18416 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{},"body":{"extsrc":"hello, world"}}' data-parsoid='{}' about="#mwt2"></span></p>
18417 <p typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about="#mwt4">hello, world</p>
18418 !! end
18419
18420 !! test
18421 Parser hook: static parser hook inside a comment
18422 !! wikitext
18423 <!-- <statictag>hello, world</statictag> -->
18424 <statictag action="flush" />
18425 !! html/php
18426 <p><br />
18427 </p>
18428 !! html/parsoid
18429 <!-- <statictag&#x3E;hello, world</statictag&#x3E; -->
18430 <p typeof='mw:Extension/statictag' data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about='#mwt2'></p>
18431 !! end
18432
18433 # Nested template calls; this case was broken by Parser.php rev 1.506,
18434 # since reverted.
18435
18436 !! article
18437 Template:One-parameter
18438 !! text
18439 (My parameter is: {{{1}}})
18440 !! endarticle
18441
18442 !! article
18443 Template:Map-one-parameter
18444 !! text
18445 {{{{{1}}}|{{{2}}}}}
18446 !! endarticle
18447
18448 !! test
18449 Nested template calls
18450 !! wikitext
18451 {{Map-one-parameter|One-parameter|param}}
18452 !! html
18453 <p>(My parameter is: param)
18454 </p>
18455 !! end
18456
18457
18458 ###
18459 ### Sanitizer
18460 ###
18461
18462 # Remex wraps empty tag runs with p-tags.
18463 # Parsoid strips them out during p-wrapping.
18464 !! test
18465 Sanitizer: Closing of open tags
18466 !! wikitext
18467 <s></s><table></table>
18468 !! html/php+tidy
18469 <p><s></s></p><table></table>
18470 !! html/parsoid
18471 <s></s><table></table>
18472 !! end
18473
18474 !! test
18475 Sanitizer: Closing of open but not closed tags
18476 !! wikitext
18477 <s>foo
18478 !! html
18479 <p><s>foo</s>
18480 </p>
18481 !! end
18482
18483 !! test
18484 Sanitizer: Closing of closed but not open tags
18485 !! options
18486 parsoid=wt2html
18487 !! wikitext
18488 </s>
18489 !! html/php+tidy
18490 <p class="mw-empty-elt">
18491 </p>
18492 !! html/parsoid
18493 !! end
18494
18495 !! test
18496 Sanitizer: Closing of closed but not open table tags
18497 !! options
18498 parsoid=wt2html
18499 !! wikitext
18500 Table not started</td></tr></table>
18501 !! html+tidy
18502 <p>Table not started
18503 </p>
18504 !! end
18505
18506 !! test
18507 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
18508 !! config
18509 wgFragmentMode=[ 'html5', 'legacy' ]
18510 !! wikitext
18511 <span id="æ: v">byte</span>[[#æ: v|backlink]]
18512 !! html/php
18513 <p><span id="æ:_v">byte</span><a href="#æ:_v">backlink</a>
18514 </p>
18515 !! html/parsoid
18516 <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>
18517 !! end
18518
18519 !! test
18520 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id="" (legacy)
18521 !! config
18522 wgFragmentMode=[ 'legacy' ]
18523 !! wikitext
18524 <span id="æ: v">byte</span>[[#æ: v|backlink]]
18525 !! html/php
18526 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v">backlink</a>
18527 </p>
18528 !! end
18529
18530 # In HTML5, the restrictions are that id must contain at least one character,
18531 # and must not contain any space characters.
18532 !! test
18533 Sanitizer: Validating the contents of the id attribute (T6515)
18534 !! options
18535 disabled
18536 !! wikitext
18537 <br id="" /><br id="a space" />
18538 !! html
18539 Something ...
18540 !! end
18541
18542 # In HTML5, id must be unique amongst all the ids in the element's home subtree.
18543 !! test
18544 Sanitizer: Validating id attribute uniqueness (T6515, T8301)
18545 !! options
18546 disabled
18547 !! wikitext
18548 <br id="foo" /><br id="foo" />
18549 !! html
18550 Something need to be done. foo-2 ?
18551 !! end
18552
18553 !! test
18554 Sanitizer: Validating that <meta> and <link> work, but only for Microdata
18555 !! wikitext
18556 <div itemscope>
18557 <meta itemprop="hello" content="world">
18558 <meta http-equiv="refresh" content="5">
18559 <meta itemprop="hello" http-equiv="refresh" content="5">
18560 <link itemprop="hello" href="{{SERVER}}">
18561 <link rel="stylesheet" href="{{SERVER}}">
18562 <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
18563 </div>
18564 !! html
18565 <div itemscope="">
18566 <p> <meta itemprop="hello" content="world" />
18567 &lt;meta http-equiv="refresh" content="5"&gt;
18568 <meta itemprop="hello" content="5" />
18569 <link itemprop="hello" href="http&#58;//example.org" />
18570 &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"&gt;
18571 <link itemprop="hello" href="http&#58;//example.org" />
18572 </p>
18573 </div>
18574
18575 !! end
18576
18577 !! test
18578 Sanitizer: Strip comments from CSS attributes
18579 !! options
18580 parsoid=wt2html,wt2wt
18581 !! wikitext
18582 <span style="margin:/*negate mbox-text padding */-0.125em -0.45em; /*rainbow*/rgba(255, 0, 0, 0.3)">2013</span>
18583 !! html/php
18584 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span>
18585 </p>
18586 !! html/parsoid
18587 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span></p>
18588 !! end
18589
18590 !! test
18591 Sanitizer: Avoid unnecessary percent encoded characters in interwiki links
18592 !! wikitext
18593 [[meatball:Soft"Security]]
18594 !! html/php
18595 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Soft%22Security" class="extiw" title="meatball:Soft&quot;Security">meatball:Soft"Security</a>
18596 </p>
18597 !! html/parsoid
18598 <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>
18599 !! end
18600
18601 !! test
18602 Sanitizer: angle brackets are invalid, even in interwiki links (T182338)
18603 !! wikitext
18604 [[meatball:Foo<Bar]]
18605 [[meatball:Foo>Bar]]
18606 [[meatball:Foo&lt;bar]]
18607 [[meatball:Foo&gt;bar]]
18608 !! html/php
18609 <p>[[meatball:Foo&lt;Bar]]
18610 [[meatball:Foo&gt;Bar]]
18611 [[meatball:Foo&lt;bar]]
18612 [[meatball:Foo&gt;bar]]
18613 </p>
18614 !! html/parsoid
18615 <p>[[meatball:Foo&lt;Bar]]
18616 [[meatball:Foo>Bar]]
18617 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span>bar]]
18618 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;gt;","srcContent":">"}'>></span>bar]]</p>
18619 !! end
18620
18621 !! test
18622 Language converter: output gets cut off unexpectedly (T7757)
18623 !! options
18624 language=zh
18625 !! wikitext
18626 this bit is safe: }-
18627
18628 but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}-
18629
18630 then we get cut off here: }-
18631
18632 all additional text is vanished
18633 !! html/php
18634 <p>this bit is safe: }-
18635 </p><p>but if we add a conversion instance: xxx
18636 </p><p>then we get cut off here: }-
18637 </p><p>all additional text is vanished
18638 </p>
18639 !! html/parsoid
18640 <p>this bit is safe: }-</p>
18641 <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>
18642 <p>then we get cut off here: }-</p>
18643 <p>all additional text is vanished</p>
18644 !! end
18645
18646 !! test
18647 Language converter glossary rules inside attributes (T119158)
18648 !! options
18649 language=sr variant=sr-el
18650 !! wikitext
18651 -{H|foAjrjvi=>sr-el:" onload="alert(1)" data-foo="}-
18652
18653 [[File:Foobar.jpg|alt=-{}-foAjrjvi-{}-]]
18654 !! html/php
18655 <p>
18656 </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>
18657 </p>
18658 !! html/parsoid
18659 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"foAjrjvi","l":"sr-el","t":"\" onload=\"alert(1)\" data-foo=\""}]}'/></p>
18660
18661 <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>
18662 !! end
18663
18664 !! test
18665 Self closed html pairs (T7487)
18666 !! wikitext
18667 <center><font id="bug" />Centered text</center>
18668 <div><font id="bug2" />In div text</div>
18669 !! html+tidy
18670 <center><font id="bug"></font>Centered text</center>
18671 <div><font id="bug2"></font>In div text</div>
18672 !! end
18673
18674 !! test
18675 Punctuation: nbsp before exclamation
18676 !! wikitext
18677 C'est grave !
18678 !! html
18679 <p>C'est grave&#160;!
18680 </p>
18681 !! end
18682
18683 !! test
18684 Punctuation: CSS !important (T13874)
18685 !! wikitext
18686 <div style="width:50% !important">important</div>
18687 !! html
18688 <div style="width:50% !important">important</div>
18689
18690 !!end
18691
18692 !! test
18693 Punctuation: CSS ! important (T13874; with space after)
18694 !! wikitext
18695 <div style="width:50% ! important">important</div>
18696 !! html
18697 <div style="width:50% ! important">important</div>
18698
18699 !!end
18700
18701 !! test
18702 HTML bullet list, closed tags (T7497)
18703 !! wikitext
18704 <ul>
18705 <li>One</li>
18706 <li>Two</li>
18707 </ul>
18708 !! html/php
18709 <ul>
18710 <li>One</li>
18711 <li>Two</li>
18712 </ul>
18713
18714 !! html/parsoid
18715 <ul data-parsoid='{"stx":"html"}'>
18716 <li data-parsoid='{"stx":"html"}'>One</li>
18717 <li data-parsoid='{"stx":"html"}'>Two</li>
18718 </ul>
18719
18720 !! end
18721
18722 !! test
18723 HTML bullet list, unclosed tags (T7497)
18724 !! wikitext
18725 <ul>
18726 <li>One
18727 <li>Two
18728 </ul>
18729 !! html/php+tidy
18730 <ul>
18731 <li>One
18732 </li><li>Two
18733 </li></ul>
18734 !! html/parsoid
18735 <ul data-parsoid='{"stx":"html"}'>
18736 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18737 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18738 </ul>
18739
18740 !! end
18741
18742 !! test
18743 HTML ordered list, closed tags (T7497)
18744 !! wikitext
18745 <ol>
18746 <li>One</li>
18747 <li>Two</li>
18748 </ol>
18749 !! html/php
18750 <ol>
18751 <li>One</li>
18752 <li>Two</li>
18753 </ol>
18754
18755 !! html/parsoid
18756 <ol data-parsoid='{"stx":"html"}'>
18757 <li data-parsoid='{"stx":"html"}'>One</li>
18758 <li data-parsoid='{"stx":"html"}'>Two</li>
18759 </ol>
18760
18761 !! end
18762
18763 !! test
18764 HTML ordered list, unclosed tags (T7497)
18765 !! options
18766 !! wikitext
18767 <ol>
18768 <li>One
18769 <li>Two
18770 </ol>
18771 !! html/php+tidy
18772 <ol>
18773 <li>One
18774 </li><li>Two
18775 </li></ol>
18776 !! html/parsoid
18777 <ol data-parsoid='{"stx":"html"}'>
18778 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18779 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18780 </ol>
18781
18782 !! end
18783
18784 !! test
18785 HTML nested bullet list, closed tags (T7497)
18786 !! wikitext
18787 <ul>
18788 <li>One</li>
18789 <li>Two:
18790 <ul>
18791 <li>Sub-one</li>
18792 <li>Sub-two</li>
18793 </ul>
18794 </li>
18795 </ul>
18796 !! html/php
18797 <ul>
18798 <li>One</li>
18799 <li>Two:
18800 <ul>
18801 <li>Sub-one</li>
18802 <li>Sub-two</li>
18803 </ul>
18804 </li>
18805 </ul>
18806
18807 !! html/parsoid
18808 <ul data-parsoid='{"stx":"html"}'>
18809 <li data-parsoid='{"stx":"html"}'>One</li>
18810 <li data-parsoid='{"stx":"html"}'>Two:
18811 <ul data-parsoid='{"stx":"html"}'>
18812 <li data-parsoid='{"stx":"html"}'>Sub-one</li>
18813 <li data-parsoid='{"stx":"html"}'>Sub-two</li>
18814 </ul>
18815 </li>
18816 </ul>
18817 !! end
18818
18819 !! test
18820 HTML nested bullet list, open tags (T7497)
18821 !! wikitext
18822 <ul>
18823 <li>One
18824 <li>Two:
18825 <ul>
18826 <li>Sub-one
18827 <li>Sub-two
18828 </ul>
18829 </ul>
18830 !! html+tidy
18831 <ul>
18832 <li>One
18833 </li><li>Two:
18834 <ul>
18835 <li>Sub-one
18836 </li><li>Sub-two
18837 </li></ul>
18838 </li></ul>
18839 !! end
18840
18841 !! test
18842 HTML nested ordered list, closed tags (T7497)
18843 !! wikitext
18844 <ol>
18845 <li>One</li>
18846 <li>Two:
18847 <ol>
18848 <li>Sub-one</li>
18849 <li>Sub-two</li>
18850 </ol>
18851 </li>
18852 </ol>
18853 !! html
18854 <ol>
18855 <li>One</li>
18856 <li>Two:
18857 <ol>
18858 <li>Sub-one</li>
18859 <li>Sub-two</li>
18860 </ol>
18861 </li>
18862 </ol>
18863
18864 !! end
18865
18866 !! test
18867 HTML nested ordered list, open tags (T7497)
18868 !! wikitext
18869 <ol>
18870 <li>One
18871 <li>Two:
18872 <ol>
18873 <li>Sub-one
18874 <li>Sub-two
18875 </ol>
18876 </ol>
18877 !! html/php
18878 <ol>
18879 <li>One
18880 <li>Two:
18881 <ol>
18882 <li>Sub-one
18883 <li>Sub-two
18884 </ol>
18885 </ol>
18886
18887 !! html/parsoid
18888 <ol>
18889 <li>One
18890 </li>
18891 <li>Two:
18892 <ol>
18893 <li>Sub-one
18894 </li>
18895 <li>Sub-two
18896 </li>
18897 </ol>
18898 </li>
18899 </ol>
18900
18901 !! end
18902
18903 !! test
18904 HTML ordered list item with parameters oddity
18905 !! wikitext
18906 <ol><li id="fragment">One</li>
18907 </ol>
18908 !! html
18909 <ol><li id="fragment">One</li>
18910 </ol>
18911
18912 !! end
18913
18914 # parsoid doesn't explicitly mark autonumbered links, see T55505
18915 !!test
18916 T7918: autonumbering
18917 !! wikitext
18918 [http://first/] [http://second] [ftp://ftp]
18919
18920 ftp://inlineftp
18921
18922 [mailto:enclosed@mail.tld With target]
18923
18924 [mailto:enclosed@mail.tld]
18925
18926 mailto:inline@mail.tld
18927 !! html/php
18928 <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>
18929 </p><p><a rel="nofollow" class="external free" href="ftp://inlineftp">ftp://inlineftp</a>
18930 </p><p><a rel="nofollow" class="external text" href="mailto:enclosed@mail.tld">With target</a>
18931 </p><p><a rel="nofollow" class="external autonumber" href="mailto:enclosed@mail.tld">[4]</a>
18932 </p><p><a rel="nofollow" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a>
18933 </p>
18934 !! html/parsoid
18935 <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>
18936 <p><a rel="mw:ExtLink" class="external free" href="ftp://inlineftp">ftp://inlineftp</a></p>
18937 <p><a rel="mw:ExtLink" class="external text" href="mailto:enclosed@mail.tld">With target</a></p>
18938 <p><a rel="mw:ExtLink" class="external autonumber" href="mailto:enclosed@mail.tld"></a></p>
18939 <p><a rel="mw:ExtLink" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a></p>
18940 !! end
18941
18942
18943 #
18944 # Security and HTML correctness
18945 # From Nick Jenkins' fuzz testing
18946 #
18947
18948 !! test
18949 Fuzz testing: Parser13
18950 !! wikitext
18951 {|
18952 | http://a|
18953 !! html
18954 <table>
18955 <tr>
18956 <td>
18957 </td>
18958 </tr>
18959 </table>
18960
18961 !! end
18962
18963 # Note that Parsoid output differs from the PHP parser here: the PHP
18964 # parser breaks the URL for the magic word, while in Parsoid the URL
18965 # production takes precedence.
18966 !! test
18967 Fuzz testing: Parser14
18968 !! wikitext
18969 ==onmouseover===
18970 http://__TOC__
18971 !! html/php
18972 <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>
18973 http://<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
18974 <ul>
18975 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
18976 </ul>
18977 </div>
18978
18979
18980 !! html/php+tidy
18981 <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>
18982 http://</p><div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
18983 <ul>
18984 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
18985 </ul>
18986 </div>
18987 !! html/parsoid
18988 <h2 id="onmouseover="><span id="onmouseover.3D" typeof="mw:FallbackId"></span>onmouseover=</h2>
18989 <p><a rel="mw:ExtLink" class="external free" href="http://__TOC__" data-parsoid='{"stx":"url"}'>http://__TOC__</a></p>
18990 !! end
18991
18992 !! test
18993 Fuzz testing: Parser14-table
18994 !! options
18995 parsoid=wt2html,html2html
18996 !! wikitext
18997 ==a==
18998 {| STYLE=__TOC__
18999 !! html
19000 <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>
19001 <table style="&#95;_TOC&#95;_">
19002 <tr><td></td></tr>
19003 </table>
19004
19005 !! html+tidy
19006 <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>
19007 <table style="__TOC__">
19008 <tr>
19009 <td></td>
19010 </tr>
19011 </table>
19012 !! html/parsoid
19013 <h2 id="a">a</h2>
19014 <table style="__TOC__"></table>
19015 !! end
19016
19017 # Known to produce bogus xml (extra </td>)
19018 # Don't add the html/php section since it generates broken HTML
19019 !! test
19020 Fuzz testing: Parser16
19021 !! wikitext
19022 {|
19023 !https://||||||
19024 !! html+tidy
19025 <table>
19026 <tbody><tr>
19027 <th>https://</th>
19028 <th></th>
19029 <th></th>
19030 <th>
19031
19032 </th></tr>
19033 </tbody></table>
19034 !! end
19035
19036 !! test
19037 Fuzz testing: Parser21
19038 !! wikitext
19039 {|
19040 !irc://{{ftp://a" onmouseover="alert('hello world');"
19041 |
19042 !! html
19043 <table>
19044 <tr>
19045 <th><a rel="nofollow" class="external free" href="irc://{{ftp://a">irc://{{ftp://a</a>" onmouseover="alert('hello world');"
19046 </th>
19047 <td>
19048 </td>
19049 </tr>
19050 </table>
19051
19052 !! end
19053
19054 !! test
19055 Fuzz testing: Parser22
19056 !! wikitext
19057 http://===r:::https://b
19058
19059 {|
19060 !! html
19061 <p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a>
19062 </p>
19063 <table>
19064 <tr><td></td></tr>
19065 </table>
19066
19067 !! end
19068
19069 # Known to produce bad XML for now
19070 !! test
19071 Fuzz testing: Parser24
19072 !! options
19073 parsoid=wt2html
19074 !! wikitext
19075 {|
19076 {{{|
19077 <u CLASS=
19078 | {{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}} >
19079 <br style="onmouseover='alert(document.cookie);' " />
19080
19081 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19082 |
19083 !! html/php
19084 <table>
19085 {{{|
19086 <u class="&#124;">}}}} &gt;
19087 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
19088
19089 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19090 <tr>
19091 <td></u>
19092 </td>
19093 </tr>
19094 </table>
19095
19096 !! html/parsoid
19097 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>{{{|
19098 <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>"}'/>}}}} >
19099 <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}'>
19100
19101
19102
19103 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'></td></tr></tbody></table>
19104 !! end
19105
19106 # Note: the current result listed for this is not what the original one was,
19107 # but the original bug was JavaScript injection, which is fixed in any case.
19108 # It's not clear that the original result listed was any more correct than the
19109 # current one. Original result:
19110 # <p>{{{|
19111 # </p>
19112 # <li class="&#124;&#124;">
19113 # }}}blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
19114 !!test
19115 Fuzz testing: Parser25 (T8055)
19116 !! wikitext
19117 {{{
19118 |
19119 <LI CLASS=||
19120 >
19121 }}}blah" onmouseover="alert('hello world');" align="left"'''MOVE MOUSE CURSOR OVER HERE
19122 !! html/php
19123 <p>&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
19124 </p>
19125 !! html/parsoid
19126 <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"]}'>
19127 </span><p about="#mwt1">&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b></p>
19128 !! end
19129
19130 !!test
19131 Fuzz testing: URL adjacent extension (with space, clean)
19132 !! wikitext
19133 http://example.com <nowiki>junk</nowiki>
19134 !! html/php
19135 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> junk
19136 </p>
19137 !! html/parsoid
19138 <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>
19139 !! end
19140
19141 !!test
19142 Fuzz testing: URL adjacent extension (no space, dirty; nowiki)
19143 !! wikitext
19144 http://example.com<nowiki>junk</nowiki>
19145 !! html/php
19146 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>junk
19147 </p>
19148 !! html/parsoid
19149 <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>
19150 !! end
19151
19152 !! test
19153 Fuzz testing: URL adjacent extension (no space, dirty; pre)
19154 !! wikitext
19155 http://example.com<pre>junk</pre>
19156 !! html/php
19157 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre>
19158
19159 !! html/php+tidy
19160 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p><pre>junk</pre>
19161 !! html/parsoid
19162 <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>
19163 !! end
19164
19165 !! test
19166 Fuzz testing: image with bogus manual thumbnail
19167 !! wikitext
19168 [[Image:foobar.jpg|thumbnail= ]]
19169 !! html/php
19170 <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div>
19171
19172 !! html/parsoid
19173 <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>
19174 !! end
19175
19176 # Parsoid will emit the newline literally in wt2wt; see next test case.
19177 !! test
19178 Fuzz testing: encoded newline in generated HTML replacements (T8577)
19179 !! options
19180 parsoid=wt2html
19181 !! wikitext
19182 <pre dir="&#10;"></pre>
19183 !! html/php
19184 <pre dir="&#10;"></pre>
19185
19186 !! html/parsoid
19187 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
19188 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
19189 !! end
19190
19191 !! test
19192 Fuzz testing: encoded newline in generated HTML replacements, html2wt (T8577)
19193 !! options
19194 parsoid=html2wt
19195 !! html/parsoid
19196 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
19197 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
19198 !! wikitext
19199 <pre dir="
19200 "></pre>
19201 !! html/php
19202 <pre dir=""></pre>
19203
19204 !! end
19205
19206 !! test
19207 Templates in extension attributes are not expanded
19208 !! wikitext
19209 <pre dir="{{echo|ltr}}"></pre>
19210 !! html/php
19211 <pre dir="{{echo|ltr}}"></pre>
19212
19213 !! html/parsoid
19214 <pre typeof="mw:Extension/pre" about="#mwt2" dir="{{echo|ltr}}" data-mw='{"name":"pre","attrs":{"dir":"{{echo|ltr}}"},"body":{"extsrc":""}}'></pre>
19215 !! end
19216
19217 !! test
19218 Parsing optional HTML elements (T8171)
19219 !! options
19220 !! wikitext
19221 <table>
19222 <tr>
19223 <td> Some tabular data</td>
19224 <td> More tabular data ...
19225 <td> And yet som tabular data</td>
19226 </tr>
19227 </table>
19228 !! html
19229 <table>
19230 <tr>
19231 <td> Some tabular data</td>
19232 <td> More tabular data ...
19233 </td><td> And yet som tabular data</td>
19234 </tr>
19235 </table>
19236
19237 !! end
19238
19239 !! test
19240 Correct handling of <td>, <tr> (T8171)
19241 !! options
19242 !! wikitext
19243 <table>
19244 <tr>
19245 <td> Some tabular data</td>
19246 <td> More tabular data ...</td>
19247 <td> And yet som tabular data</td>
19248 </tr>
19249 </table>
19250 !! html
19251 <table>
19252 <tr>
19253 <td> Some tabular data</td>
19254 <td> More tabular data ...</td>
19255 <td> And yet som tabular data</td>
19256 </tr>
19257 </table>
19258
19259 !! end
19260
19261
19262 !! test
19263 Parsing crashing regression (fr:JavaScript)
19264 !! wikitext
19265 </body></x>
19266 !! html
19267 <p>&lt;/body&gt;&lt;/x&gt;
19268 </p>
19269 !! end
19270
19271 !! test
19272 Inline wiki vs wiki block nesting
19273 !! wikitext
19274 '''Bold paragraph
19275
19276 New wiki paragraph
19277 !! html
19278 <p><b>Bold paragraph</b>
19279 </p><p>New wiki paragraph
19280 </p>
19281 !! end
19282
19283 # FIXME: The current php output is documented
19284 # and desired output is the parsoid target.
19285 !! test
19286 Inline HTML vs wiki block nesting
19287 !! wikitext
19288 <b>Bold paragraph
19289
19290 New wiki paragraph
19291 !! html/php
19292 <p><b>Bold paragraph
19293 </p><p>New wiki paragraph</b>
19294 </p>
19295 !! html/parsoid
19296 <p><b>Bold paragraph</b>
19297 </p><p>New wiki paragraph
19298 </p>
19299 !! end
19300
19301 # Original result was this:
19302 # <p><b>bold</b><b>bold<i>bolditalics</i></b>
19303 # </p>
19304 # While that might be marginally more intuitive, maybe, the six-apostrophe
19305 # construct is clearly pathological and the result stated here (which is what
19306 # the parser actually does) is about as reasonable as anything.
19307 !!test
19308 Mixing markup for italics and bold
19309 !! options
19310 !! wikitext
19311 '''bold''''''bold''bolditalics'''''
19312 !! html
19313 <p>'<i>bold'</i><b>bold<i>bolditalics</i></b>
19314 </p>
19315 !! end
19316
19317
19318 !! article
19319 Xyzzyx
19320 !! text
19321 Article for special page transclusion test
19322 !! endarticle
19323
19324 !! test
19325 Special page transclusion
19326 !! options
19327 !! wikitext
19328 {{Special:Prefixindex/Xyzzyx}}
19329 !! html
19330 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19331 </ul>
19332
19333 !! end
19334
19335 !! test
19336 Special page transclusion twice (T7021)
19337 !! options
19338 !! wikitext
19339 {{Special:Prefixindex/Xyzzyx}}
19340 {{Special:Prefixindex/Xyzzyx}}
19341 !! html
19342 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19343 </ul>
19344 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19345 </ul>
19346
19347 !! end
19348
19349 !! test
19350 Transclusion of default MediaWiki message
19351 !! wikitext
19352 {{MediaWiki:Mainpage}}
19353 !! html
19354 <p>Main Page
19355 </p>
19356 !! end
19357
19358 !! test
19359 Transclusion of nonexistent MediaWiki message
19360 !! wikitext
19361 {{MediaWiki:Mainpagexxx}}
19362 !! html
19363 <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>
19364 </p>
19365 !! end
19366
19367 !! test
19368 Transclusion of MediaWiki message with underscore
19369 !! wikitext
19370 {{MediaWiki:history_short}}
19371 !! html
19372 <p>History
19373 </p>
19374 !! end
19375
19376 !! test
19377 Transclusion of MediaWiki message with space
19378 !! wikitext
19379 {{MediaWiki:history short}}
19380 !! html
19381 <p>History
19382 </p>
19383 !! end
19384
19385 !! test
19386 Invalid header with following text
19387 !! wikitext
19388 = x = y
19389 !! html
19390 <p>= x = y
19391 </p>
19392 !! end
19393
19394
19395 !! test
19396 Section extraction test (section 0)
19397 !! options
19398 section=0
19399 !! wikitext
19400 start
19401 ==a==
19402 ===aa===
19403 ====aaa====
19404 ==b==
19405 ===ba===
19406 ===bb===
19407 ====bba====
19408 ===bc===
19409 ==c==
19410 ===ca===
19411 !! html/php
19412 start
19413 !! end
19414
19415 !! test
19416 Section extraction test (section 1)
19417 !! options
19418 section=1
19419 !! wikitext
19420 start
19421 ==a==
19422 ===aa===
19423 ====aaa====
19424 ==b==
19425 ===ba===
19426 ===bb===
19427 ====bba====
19428 ===bc===
19429 ==c==
19430 ===ca===
19431 !! html/php
19432 ==a==
19433 ===aa===
19434 ====aaa====
19435 !! end
19436
19437 !! test
19438 Section extraction test (section 2)
19439 !! options
19440 section=2
19441 !! wikitext
19442 start
19443 ==a==
19444 ===aa===
19445 ====aaa====
19446 ==b==
19447 ===ba===
19448 ===bb===
19449 ====bba====
19450 ===bc===
19451 ==c==
19452 ===ca===
19453 !! html/php
19454 ===aa===
19455 ====aaa====
19456 !! end
19457
19458 !! test
19459 Section extraction test (section 3)
19460 !! options
19461 section=3
19462 !! wikitext
19463 start
19464 ==a==
19465 ===aa===
19466 ====aaa====
19467 ==b==
19468 ===ba===
19469 ===bb===
19470 ====bba====
19471 ===bc===
19472 ==c==
19473 ===ca===
19474 !! html/php
19475 ====aaa====
19476 !! end
19477
19478 !! test
19479 Section extraction test (section 4)
19480 !! options
19481 section=4
19482 !! wikitext
19483 start
19484 ==a==
19485 ===aa===
19486 ====aaa====
19487 ==b==
19488 ===ba===
19489 ===bb===
19490 ====bba====
19491 ===bc===
19492 ==c==
19493 ===ca===
19494 !! html/php
19495 ==b==
19496 ===ba===
19497 ===bb===
19498 ====bba====
19499 ===bc===
19500 !! end
19501
19502 !! test
19503 Section extraction test (section 5)
19504 !! options
19505 section=5
19506 !! wikitext
19507 start
19508 ==a==
19509 ===aa===
19510 ====aaa====
19511 ==b==
19512 ===ba===
19513 ===bb===
19514 ====bba====
19515 ===bc===
19516 ==c==
19517 ===ca===
19518 !! html/php
19519 ===ba===
19520 !! end
19521
19522 !! test
19523 Section extraction test (section 6)
19524 !! options
19525 section=6
19526 !! wikitext
19527 start
19528 ==a==
19529 ===aa===
19530 ====aaa====
19531 ==b==
19532 ===ba===
19533 ===bb===
19534 ====bba====
19535 ===bc===
19536 ==c==
19537 ===ca===
19538 !! html/php
19539 ===bb===
19540 ====bba====
19541 !! end
19542
19543 !! test
19544 Section extraction test (section 7)
19545 !! options
19546 section=7
19547 !! wikitext
19548 start
19549 ==a==
19550 ===aa===
19551 ====aaa====
19552 ==b==
19553 ===ba===
19554 ===bb===
19555 ====bba====
19556 ===bc===
19557 ==c==
19558 ===ca===
19559 !! html/php
19560 ====bba====
19561 !! end
19562
19563 !! test
19564 Section extraction test (section 8)
19565 !! options
19566 section=8
19567 !! wikitext
19568 start
19569 ==a==
19570 ===aa===
19571 ====aaa====
19572 ==b==
19573 ===ba===
19574 ===bb===
19575 ====bba====
19576 ===bc===
19577 ==c==
19578 ===ca===
19579 !! html/php
19580 ===bc===
19581 !! end
19582
19583 !! test
19584 Section extraction test (section 9)
19585 !! options
19586 section=9
19587 !! wikitext
19588 start
19589 ==a==
19590 ===aa===
19591 ====aaa====
19592 ==b==
19593 ===ba===
19594 ===bb===
19595 ====bba====
19596 ===bc===
19597 ==c==
19598 ===ca===
19599 !! html/php
19600 ==c==
19601 ===ca===
19602 !! end
19603
19604 !! test
19605 Section extraction test (section 10)
19606 !! options
19607 section=10
19608 !! wikitext
19609 start
19610 ==a==
19611 ===aa===
19612 ====aaa====
19613 ==b==
19614 ===ba===
19615 ===bb===
19616 ====bba====
19617 ===bc===
19618 ==c==
19619 ===ca===
19620 !! html/php
19621 ===ca===
19622 !! end
19623
19624 !! test
19625 Section extraction test (nonexistent section 11)
19626 !! options
19627 section=11
19628 !! wikitext
19629 start
19630 ==a==
19631 ===aa===
19632 ====aaa====
19633 ==b==
19634 ===ba===
19635 ===bb===
19636 ====bba====
19637 ===bc===
19638 ==c==
19639 ===ca===
19640 !! html/php
19641 !! end
19642
19643 !! test
19644 Section extraction test with bogus heading (section 1)
19645 !! options
19646 section=1
19647 !! wikitext
19648 ==a==
19649 ==bogus== not a legal section
19650 ==b==
19651 !! html/php
19652 ==a==
19653 ==bogus== not a legal section
19654 !! end
19655
19656 !! test
19657 Section extraction test with bogus heading (section 2)
19658 !! options
19659 section=2
19660 !! wikitext
19661 ==a==
19662 ==bogus== not a legal section
19663 ==b==
19664 !! html/php
19665 ==b==
19666 !! end
19667
19668 !! test
19669 Section extraction test with comment after heading (section 1)
19670 !! options
19671 section=1
19672 !! wikitext
19673 ==a==
19674 ==b== <!-- -->
19675 ==c==
19676 !! html/php
19677 ==a==
19678 !! end
19679
19680 !! test
19681 Section extraction test with comment after heading (section 2)
19682 !! options
19683 section=2
19684 !! wikitext
19685 ==a==
19686 ==b== <!-- -->
19687 ==c==
19688 !! html/php
19689 ==b== <!-- -->
19690 !! end
19691
19692 !! test
19693 Section extraction test with bogus <nowiki> heading (section 1)
19694 !! options
19695 section=1
19696 !! wikitext
19697 ==a==
19698 ==bogus== <nowiki>not a legal section</nowiki>
19699 ==b==
19700 !! html/php
19701 ==a==
19702 ==bogus== <nowiki>not a legal section</nowiki>
19703 !! end
19704
19705 !! test
19706 Section extraction test with bogus <nowiki> heading (section 2)
19707 !! options
19708 section=2
19709 !! wikitext
19710 ==a==
19711 ==bogus== <nowiki>not a legal section</nowiki>
19712 ==b==
19713 !! html/php
19714 ==b==
19715 !! end
19716
19717 # Formerly testing for T4587, now resolved by the use of unmarked sections
19718 # instead of respecting commented sections
19719 !! test
19720 Section extraction prefixed by comment (section 1)
19721 !! options
19722 section=1
19723 !! wikitext
19724 <!-- -->==sec1==
19725 ==sec2==
19726 !! html/php
19727 ==sec2==
19728 !!end
19729
19730 !! test
19731 Section extraction prefixed by comment (section 2)
19732 !! options
19733 section=2
19734 !! wikitext
19735 <!-- -->==sec1==
19736 ==sec2==
19737 !! html/php
19738
19739 !!end
19740
19741 # Formerly testing for T4607, now resolved by the use of unmarked sections
19742 # instead of respecting HTML-style headings
19743 !! test
19744 Section extraction, mixed wiki and html (section 1)
19745 !! options
19746 section=1
19747 !! wikitext
19748 <h2>unmarked</h2>
19749 unmarked
19750 ==1==
19751 one
19752 ==2==
19753 two
19754 !! html/php
19755 ==1==
19756 one
19757 !! end
19758
19759 !! test
19760 Section extraction, mixed wiki and html (section 2)
19761 !! options
19762 section=2
19763 !! wikitext
19764 <h2>unmarked</h2>
19765 unmarked
19766 ==1==
19767 one
19768 ==2==
19769 two
19770 !! html/php
19771 ==2==
19772 two
19773 !! end
19774
19775
19776 # Formerly testing for T5342
19777 !! test
19778 Section extraction, heading surrounded by <noinclude>
19779 !! options
19780 section=1
19781 !! wikitext
19782 <noinclude>==unmarked==</noinclude>
19783 ==marked==
19784 !! html/php
19785 ==marked==
19786 !!end
19787
19788 # Test behavior of T21910
19789 !! test
19790 Sectiion with all-equals
19791 !! options
19792 section=2
19793 !! wikitext
19794 ===
19795 The line above must have a trailing space
19796 === <!--
19797 --> <!-- -->
19798 But just in case it doesn't...
19799 !! html/php
19800 === <!--
19801 --> <!-- -->
19802 But just in case it doesn't...
19803 !! end
19804
19805 !! test
19806 Section replacement test (section 0)
19807 !! options
19808 replace=0,"xxx"
19809 !! wikitext
19810 start
19811 ==a==
19812 ===aa===
19813 ====aaa====
19814 ==b==
19815 ===ba===
19816 ===bb===
19817 ====bba====
19818 ===bc===
19819 ==c==
19820 ===ca===
19821 !! html/php
19822 xxx
19823
19824 ==a==
19825 ===aa===
19826 ====aaa====
19827 ==b==
19828 ===ba===
19829 ===bb===
19830 ====bba====
19831 ===bc===
19832 ==c==
19833 ===ca===
19834 !! end
19835
19836 !! test
19837 Section replacement test (section 1)
19838 !! options
19839 replace=1,"xxx"
19840 !! wikitext
19841 start
19842 ==a==
19843 ===aa===
19844 ====aaa====
19845 ==b==
19846 ===ba===
19847 ===bb===
19848 ====bba====
19849 ===bc===
19850 ==c==
19851 ===ca===
19852 !! html/php
19853 start
19854 xxx
19855
19856 ==b==
19857 ===ba===
19858 ===bb===
19859 ====bba====
19860 ===bc===
19861 ==c==
19862 ===ca===
19863 !! end
19864
19865 !! test
19866 Section replacement test (section 2)
19867 !! options
19868 replace=2,"xxx"
19869 !! wikitext
19870 start
19871 ==a==
19872 ===aa===
19873 ====aaa====
19874 ==b==
19875 ===ba===
19876 ===bb===
19877 ====bba====
19878 ===bc===
19879 ==c==
19880 ===ca===
19881 !! html/php
19882 start
19883 ==a==
19884 xxx
19885
19886 ==b==
19887 ===ba===
19888 ===bb===
19889 ====bba====
19890 ===bc===
19891 ==c==
19892 ===ca===
19893 !! end
19894
19895 !! test
19896 Section replacement test (section 3)
19897 !! options
19898 replace=3,"xxx"
19899 !! wikitext
19900 start
19901 ==a==
19902 ===aa===
19903 ====aaa====
19904 ==b==
19905 ===ba===
19906 ===bb===
19907 ====bba====
19908 ===bc===
19909 ==c==
19910 ===ca===
19911 !! html/php
19912 start
19913 ==a==
19914 ===aa===
19915 xxx
19916
19917 ==b==
19918 ===ba===
19919 ===bb===
19920 ====bba====
19921 ===bc===
19922 ==c==
19923 ===ca===
19924 !! end
19925
19926 !! test
19927 Section replacement test (section 4)
19928 !! options
19929 replace=4,"xxx"
19930 !! wikitext
19931 start
19932 ==a==
19933 ===aa===
19934 ====aaa====
19935 ==b==
19936 ===ba===
19937 ===bb===
19938 ====bba====
19939 ===bc===
19940 ==c==
19941 ===ca===
19942 !! html/php
19943 start
19944 ==a==
19945 ===aa===
19946 ====aaa====
19947 xxx
19948
19949 ==c==
19950 ===ca===
19951 !! end
19952
19953 !! test
19954 Section replacement test (section 5)
19955 !! options
19956 replace=5,"xxx"
19957 !! wikitext
19958 start
19959 ==a==
19960 ===aa===
19961 ====aaa====
19962 ==b==
19963 ===ba===
19964 ===bb===
19965 ====bba====
19966 ===bc===
19967 ==c==
19968 ===ca===
19969 !! html/php
19970 start
19971 ==a==
19972 ===aa===
19973 ====aaa====
19974 ==b==
19975 xxx
19976
19977 ===bb===
19978 ====bba====
19979 ===bc===
19980 ==c==
19981 ===ca===
19982 !! end
19983
19984 !! test
19985 Section replacement test (section 6)
19986 !! options
19987 replace=6,"xxx"
19988 !! wikitext
19989 start
19990 ==a==
19991 ===aa===
19992 ====aaa====
19993 ==b==
19994 ===ba===
19995 ===bb===
19996 ====bba====
19997 ===bc===
19998 ==c==
19999 ===ca===
20000 !! html/php
20001 start
20002 ==a==
20003 ===aa===
20004 ====aaa====
20005 ==b==
20006 ===ba===
20007 xxx
20008
20009 ===bc===
20010 ==c==
20011 ===ca===
20012 !! end
20013
20014 !! test
20015 Section replacement test (section 7)
20016 !! options
20017 replace=7,"xxx"
20018 !! wikitext
20019 start
20020 ==a==
20021 ===aa===
20022 ====aaa====
20023 ==b==
20024 ===ba===
20025 ===bb===
20026 ====bba====
20027 ===bc===
20028 ==c==
20029 ===ca===
20030 !! html/php
20031 start
20032 ==a==
20033 ===aa===
20034 ====aaa====
20035 ==b==
20036 ===ba===
20037 ===bb===
20038 xxx
20039
20040 ===bc===
20041 ==c==
20042 ===ca===
20043 !! end
20044
20045 !! test
20046 Section replacement test (section 8)
20047 !! options
20048 replace=8,"xxx"
20049 !! wikitext
20050 start
20051 ==a==
20052 ===aa===
20053 ====aaa====
20054 ==b==
20055 ===ba===
20056 ===bb===
20057 ====bba====
20058 ===bc===
20059 ==c==
20060 ===ca===
20061 !! html/php
20062 start
20063 ==a==
20064 ===aa===
20065 ====aaa====
20066 ==b==
20067 ===ba===
20068 ===bb===
20069 ====bba====
20070 xxx
20071
20072 ==c==
20073 ===ca===
20074 !!end
20075
20076 !! test
20077 Section replacement test (section 9)
20078 !! options
20079 replace=9,"xxx"
20080 !! wikitext
20081 start
20082 ==a==
20083 ===aa===
20084 ====aaa====
20085 ==b==
20086 ===ba===
20087 ===bb===
20088 ====bba====
20089 ===bc===
20090 ==c==
20091 ===ca===
20092 !! html/php
20093 start
20094 ==a==
20095 ===aa===
20096 ====aaa====
20097 ==b==
20098 ===ba===
20099 ===bb===
20100 ====bba====
20101 ===bc===
20102 xxx
20103 !! end
20104
20105 !! test
20106 Section replacement test (section 10)
20107 !! options
20108 replace=10,"xxx"
20109 !! wikitext
20110 start
20111 ==a==
20112 ===aa===
20113 ====aaa====
20114 ==b==
20115 ===ba===
20116 ===bb===
20117 ====bba====
20118 ===bc===
20119 ==c==
20120 ===ca===
20121 !! html/php
20122 start
20123 ==a==
20124 ===aa===
20125 ====aaa====
20126 ==b==
20127 ===ba===
20128 ===bb===
20129 ====bba====
20130 ===bc===
20131 ==c==
20132 xxx
20133 !! end
20134
20135 !! test
20136 Section replacement test with initial whitespace (T15728)
20137 !! options
20138 replace=2,"xxx"
20139 !! wikitext
20140 Preformatted initial line
20141 ==a==
20142 ===a===
20143 !! html/php
20144 Preformatted initial line
20145 ==a==
20146 xxx
20147 !! end
20148
20149
20150 !! test
20151 Section extraction, heading followed by pre with 20 spaces (T8398)
20152 !! options
20153 section=1
20154 !! wikitext
20155 ==a==
20156 a
20157 !! html/php
20158 ==a==
20159 a
20160 !! end
20161
20162 !! test
20163 Section extraction, heading followed by pre with 19 spaces (T8398 sanity check)
20164 !! options
20165 section=1
20166 !! wikitext
20167 ==a==
20168 a
20169 !! html/php
20170 ==a==
20171 a
20172 !! end
20173
20174
20175 !! test
20176 Section extraction, <pre> around bogus header (T12309)
20177 !! options
20178 section=2
20179 !! wikitext
20180 == Section One ==
20181 <pre>
20182 =======
20183 </pre>
20184
20185 == Section Two ==
20186 stuff
20187 !! html/php
20188 == Section Two ==
20189 stuff
20190 !! end
20191
20192 !! test
20193 Section replacement, <pre> around bogus header (T12309)
20194 !! options
20195 replace=2,"xxx"
20196 !! wikitext
20197 == Section One ==
20198 <pre>
20199 =======
20200 </pre>
20201
20202 == Section Two ==
20203 stuff
20204 !! html/php
20205 == Section One ==
20206 <pre>
20207 =======
20208 </pre>
20209
20210 xxx
20211 !! end
20212
20213 !! test
20214 Handling of &#x0A; in URLs
20215 !! wikitext
20216 *irc://&#x0A;a
20217 !! html/php
20218 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
20219
20220 !! html/parsoid
20221 <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>
20222 !! end
20223
20224 !! test
20225 Handling of %0A in URLs
20226 !! wikitext
20227 *irc://%0Aa
20228 !! html/php
20229 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
20230
20231 !! html/parsoid
20232 <ul><li><a rel="mw:ExtLink" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
20233 !! end
20234
20235 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
20236 !! test
20237 5 quotes, code coverage +1 line
20238 !! options
20239 parsoid=wt2html
20240 !! wikitext
20241 '''''
20242 !! html/php
20243 !! html/parsoid
20244 <b><i></i></b>
20245 !! end
20246
20247 # same html as previous, but wikitext adjusted to match parsoid html2wt
20248 # note that wt2html and html2html will put the <i> before the <b>
20249 !! test
20250 5 quotes, code coverage +1 line w/ nowiki (1)
20251 !! options
20252 parsoid=wt2wt,html2wt
20253 !! wikitext
20254 '''''<nowiki/>'''''
20255 !! html/php
20256 <p><i></i>
20257 </p>
20258 !! html/parsoid
20259 <p><b><i></i></b></p>
20260 !! end
20261
20262 # same as previous, just swapping the <i> and <b>
20263 !! test
20264 5 quotes, code coverage +1 line w/ nowiki (2)
20265 !! wikitext
20266 '''''<nowiki/>'''''
20267 !! html/php
20268 <p><i></i>
20269 </p>
20270 !! html/parsoid
20271 <p><i><b></b></i></p>
20272 !! end
20273
20274 !! test
20275 Special:Search page linking.
20276 !! wikitext
20277 {{Special:search}}
20278 !! html
20279 <p><a href="/wiki/Special:Search" title="Special:Search">Special:Search</a>
20280 </p>
20281 !! end
20282
20283 !! test
20284 {{!}} is a magic word
20285 !! wikitext
20286 {{!}} is a magic word there and {{!}} is still a magic word here
20287 | is not a magic word here but {{!}} is still a magic word here
20288 !! html/php
20289 <p>| is a magic word there and | is still a magic word here
20290 | is not a magic word here but | is still a magic word here
20291 </p>
20292 !! html/parsoid
20293 <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
20294 | 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>
20295 !! end
20296
20297 !! test
20298 Say the magic word
20299 !! options
20300 title=[[Parser test]]
20301 !! wikitext
20302 *{{PAGENAME}}
20303 *{{PAGENAMEE}}
20304 *{{FULLPAGENAME}}
20305 *{{FULLPAGENAMEE}}
20306 *{{BASEPAGENAME}}
20307 *{{BASEPAGENAMEE}}
20308 *{{SUBPAGENAME}}
20309 *{{SUBPAGENAMEE}}
20310 *{{ROOTPAGENAME}}
20311 *{{ROOTPAGENAMEE}}
20312 *{{TALKPAGENAME}}
20313 *{{TALKPAGENAMEE}}
20314 *{{SUBJECTPAGENAME}}
20315 *{{SUBJECTPAGENAMEE}}
20316 *{{NAMESPACEE}}
20317 *{{NAMESPACE}}
20318 *{{NAMESPACENUMBER}}
20319 *{{TALKSPACE}}
20320 *{{TALKSPACEE}}
20321 *{{SUBJECTSPACE}}
20322 *{{SUBJECTSPACEE}}
20323 *{{Dynamic|{{NUMBEROFUSERS}}|{{NUMBEROFPAGES}}|{{CURRENTVERSION}}|{{CONTENTLANGUAGE}}|{{DIRECTIONMARK}}|{{CURRENTTIMESTAMP}}|{{NUMBEROFARTICLES}}}}
20324 !! html
20325 <ul><li>Parser test</li>
20326 <li>Parser_test</li>
20327 <li>Parser test</li>
20328 <li>Parser_test</li>
20329 <li>Parser test</li>
20330 <li>Parser_test</li>
20331 <li>Parser test</li>
20332 <li>Parser_test</li>
20333 <li>Parser test</li>
20334 <li>Parser_test</li>
20335 <li>Talk:Parser test</li>
20336 <li>Talk:Parser_test</li>
20337 <li>Parser test</li>
20338 <li>Parser_test</li>
20339 <li></li>
20340 <li></li>
20341 <li>0</li>
20342 <li>Talk</li>
20343 <li>Talk</li>
20344 <li></li>
20345 <li></li>
20346 <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>
20347
20348 !! end
20349 ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included.
20350
20351 !! test
20352 Gallery with valid attributes
20353 !! wikitext
20354 <gallery type="123" summary="345">
20355 File:File:Foobar.jpg
20356 </gallery>
20357 !! html/php
20358 <ul class="gallery mw-gallery-traditional" type="123">
20359 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20360 <div class="thumb" style="height: 150px;">File:Foobar.jpg</div>
20361 <div class="gallerytext">
20362 </div>
20363 </div></li>
20364 </ul>
20365
20366 !! html/parsoid
20367 <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"}}'>
20368 <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>
20369 </ul>
20370 !! end
20371
20372 ## Parsoid thinks the "centre" here is a property, not a caption.
20373 !! test
20374 Gallery
20375 !! options
20376 parsoid={
20377 "modes": ["wt2html"],
20378 "nativeGallery": true
20379 }
20380 !! wikitext
20381 <gallery>
20382 image1.png |
20383 image2.gif|||||
20384
20385 image3|
20386 image4 |300px| centre
20387 image5.svg| http://///////
20388 [[x|xx]]]]
20389 * image6
20390 </gallery>
20391 !! html/php
20392 <ul class="gallery mw-gallery-traditional">
20393 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20394 <div class="thumb" style="height: 150px;">Image1.png</div>
20395 <div class="gallerytext">
20396 </div>
20397 </div></li>
20398 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20399 <div class="thumb" style="height: 150px;">Image2.gif</div>
20400 <div class="gallerytext">
20401 </div>
20402 </div></li>
20403 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20404 <div class="thumb" style="height: 150px;">Image3</div>
20405 <div class="gallerytext">
20406 </div>
20407 </div></li>
20408 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20409 <div class="thumb" style="height: 150px;">Image4</div>
20410 <div class="gallerytext">
20411 <pre>centre
20412 </pre>
20413 </div>
20414 </div></li>
20415 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20416 <div class="thumb" style="height: 150px;">Image5.svg</div>
20417 <div class="gallerytext">
20418 <p><a rel="nofollow" class="external free" href="http://///////">http://///////</a>
20419 </p>
20420 </div>
20421 </div></li>
20422 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20423 <div class="thumb" style="height: 150px;">* image6</div>
20424 <div class="gallerytext">
20425 </div>
20426 </div></li>
20427 </ul>
20428
20429 !! html/parsoid
20430 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20431 <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>
20432 <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>
20433 <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>
20434 <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>
20435 <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>
20436 <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>
20437 </ul>
20438 !! end
20439
20440 !! test
20441 Gallery (with options, html)
20442 !! options
20443 parsoid={
20444 "modes": ["wt2html", "html2html"],
20445 "nativeGallery": true
20446 }
20447 !! wikitext
20448 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
20449 File:Nonexistent.jpg|caption
20450 File:Nonexistent.jpg
20451 image:foobar.jpg|some '''caption''' [[Main Page]]
20452 image:foobar.jpg
20453 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
20454 </gallery>
20455 !! html/php
20456 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
20457 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
20458 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20459 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20460 <div class="gallerytext">
20461 <p>caption
20462 </p>
20463 </div>
20464 </div></li>
20465 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20466 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20467 <div class="gallerytext">
20468 </div>
20469 </div></li>
20470 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20471 <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>
20472 <div class="gallerytext">
20473 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20474 </p>
20475 </div>
20476 </div></li>
20477 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20478 <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>
20479 <div class="gallerytext">
20480 </div>
20481 </div></li>
20482 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20483 <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>
20484 <div class="gallerytext">
20485 <p>blabla.
20486 </p>
20487 </div>
20488 </div></li>
20489 </ul>
20490
20491 !! html/parsoid
20492 <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":{}}'>
20493 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
20494 <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>
20495 <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>
20496 <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>
20497 <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>
20498 <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>
20499 </ul>
20500 !! end
20501
20502 !! test
20503 Gallery (with options, extsrc)
20504 !! options
20505 parsoid={
20506 "nativeGallery": false
20507 }
20508 !! wikitext
20509 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
20510 File:Nonexistent.jpg|caption
20511 File:Nonexistent.jpg
20512 image:foobar.jpg|some '''caption''' [[Main Page]]
20513 image:foobar.jpg
20514 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
20515 </gallery>
20516 !! html/php
20517 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
20518 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
20519 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20520 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20521 <div class="gallerytext">
20522 <p>caption
20523 </p>
20524 </div>
20525 </div></li>
20526 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20527 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20528 <div class="gallerytext">
20529 </div>
20530 </div></li>
20531 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20532 <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>
20533 <div class="gallerytext">
20534 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20535 </p>
20536 </div>
20537 </div></li>
20538 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20539 <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>
20540 <div class="gallerytext">
20541 </div>
20542 </div></li>
20543 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20544 <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>
20545 <div class="gallerytext">
20546 <p>blabla.
20547 </p>
20548 </div>
20549 </div></li>
20550 </ul>
20551
20552 !! html/parsoid
20553 <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"}}'>
20554 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
20555 <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>
20556 <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>
20557 <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>
20558 <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>
20559 <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>
20560 </ul>
20561 !! end
20562
20563 !! test
20564 Gallery (without px units)
20565 !! wikitext
20566 <gallery widths="70" heights="40">
20567 File:Foobar.jpg
20568 </gallery>
20569 !! html/php
20570 <ul class="gallery mw-gallery-traditional">
20571 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20572 <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>
20573 <div class="gallerytext">
20574 </div>
20575 </div></li>
20576 </ul>
20577
20578 !! html/parsoid
20579 <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"}}'>
20580 <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>
20581 </ul>
20582 !! end
20583
20584 !! test
20585 Gallery (with invalid units)
20586 !! wikitext
20587 <gallery widths="70em" heights="40em">
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="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>
20594 <div class="gallerytext">
20595 </div>
20596 </div></li>
20597 </ul>
20598
20599 !! html/parsoid
20600 <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"}}'>
20601 <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>
20602 </ul>
20603 !! end
20604
20605 !! test
20606 Gallery with link that has fragment
20607 !! options
20608 parsoid={
20609 "modes": ["wt2html", "html2html"],
20610 "nativeGallery": true
20611 }
20612 !! wikitext
20613 <gallery>
20614 image:foobar.jpg|link=Main_Page
20615 image:foobar.jpg|link=Main_Page#section
20616 image:foobar.jpg|link=Main Page#section|caption
20617 </gallery>
20618 !! html/php
20619 <ul class="gallery mw-gallery-traditional">
20620 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20621 <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>
20622 <div class="gallerytext">
20623 </div>
20624 </div></li>
20625 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20626 <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>
20627 <div class="gallerytext">
20628 </div>
20629 </div></li>
20630 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20631 <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>
20632 <div class="gallerytext">
20633 <p>caption
20634 </p>
20635 </div>
20636 </div></li>
20637 </ul>
20638
20639 !! html/parsoid
20640 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20641 <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>
20642 <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>
20643 <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>
20644 </ul>
20645 !! end
20646
20647 ## Whoops, Parsoid shouldn't be parsing templates in the attribute caption!
20648 !! test
20649 Gallery with template inside caption
20650 !! options
20651 parsoid={
20652 "nativeGallery": true
20653 }
20654 !! wikitext
20655 <gallery caption="{{echo|hi}}">
20656 File:Foobar.jpg|{{echo|ho}}
20657 </gallery>
20658 !! html/php
20659 <ul class="gallery mw-gallery-traditional">
20660 <li class='gallerycaption'>{{echo|hi}}</li>
20661 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20662 <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>
20663 <div class="gallerytext">
20664 <p>ho
20665 </p>
20666 </div>
20667 </div></li>
20668 </ul>
20669
20670 !! html/parsoid
20671 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20672 <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>
20673 <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>
20674 </ul>
20675 !! end
20676
20677 !! test
20678 Gallery with wikitext inside caption
20679 !! options
20680 parsoid={
20681 "nativeGallery": true
20682 }
20683 !! wikitext
20684 <gallery>
20685 File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]]
20686 File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}}
20687 </gallery>
20688 !! html/php
20689 <ul class="gallery mw-gallery-traditional">
20690 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20691 <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>
20692 <div class="gallerytext">
20693 <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>
20694 </p>
20695 </div>
20696 </div></li>
20697 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20698 <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>
20699 <div class="gallerytext">
20700 <p>This is a test template
20701 </p>
20702 </div>
20703 </div></li>
20704 </ul>
20705
20706 !! html/parsoid
20707 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20708 <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>
20709 <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>
20710 </ul>
20711 !! end
20712
20713 !! test
20714 Gallery (with showfilename option)
20715 !! options
20716 parsoid={
20717 "nativeGallery": true
20718 }
20719 !! wikitext
20720 <gallery showfilename="">
20721 File:Nonexistent.jpg|caption
20722 File:Nonexistent.jpg
20723 File:Foobar.jpg|some '''caption''' [[Main Page]]
20724 File:Foobar.jpg
20725 </gallery>
20726 !! html/php
20727 <ul class="gallery mw-gallery-traditional">
20728 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20729 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20730 <div class="gallerytext">
20731 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
20732 caption
20733 </p>
20734 </div>
20735 </div></li>
20736 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20737 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20738 <div class="gallerytext">
20739 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
20740 </p>
20741 </div>
20742 </div></li>
20743 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20744 <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>
20745 <div class="gallerytext">
20746 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
20747 some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20748 </p>
20749 </div>
20750 </div></li>
20751 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20752 <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>
20753 <div class="gallerytext">
20754 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
20755 </p>
20756 </div>
20757 </div></li>
20758 </ul>
20759
20760 !! html/parsoid
20761 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
20762 <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>
20763 <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>
20764 <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>
20765 <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>
20766 </ul>
20767 !! end
20768
20769 ## Should Parsoid be preserving these variations? See T151367
20770 !! test
20771 Gallery (with namespace-less filenames)
20772 !! options
20773 parsoid={
20774 "modes": ["wt2html", "html2html"],
20775 "nativeGallery": true
20776 }
20777 !! wikitext
20778 <gallery>
20779 File:Nonexistent.jpg
20780 Nonexistent.jpg
20781 image:foobar.jpg
20782 foobar.jpg
20783 </gallery>
20784 !! html/php
20785 <ul class="gallery mw-gallery-traditional">
20786 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20787 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20788 <div class="gallerytext">
20789 </div>
20790 </div></li>
20791 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20792 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20793 <div class="gallerytext">
20794 </div>
20795 </div></li>
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 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20802 <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>
20803 <div class="gallerytext">
20804 </div>
20805 </div></li>
20806 </ul>
20807
20808 !! html/parsoid
20809 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20810 <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>
20811 <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>
20812 <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>
20813 <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>
20814 </ul>
20815 !! end
20816
20817 !! test
20818 Gallery override link with wikilink (T36852)
20819 !! options
20820 parsoid={
20821 "nativeGallery": true
20822 }
20823 !! wikitext
20824 <gallery>
20825 File:Foobar.jpg|alt=galleryalt|link=Wikilink
20826 </gallery>
20827 !! html/php
20828 <ul class="gallery mw-gallery-traditional">
20829 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20830 <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>
20831 <div class="gallerytext">
20832 </div>
20833 </div></li>
20834 </ul>
20835
20836 !! html/parsoid
20837 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20838 <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>
20839 </ul>
20840 !! end
20841
20842 !! test
20843 Gallery override link with absolute external link (T36852)
20844 !! options
20845 parsoid={
20846 "nativeGallery": true
20847 }
20848 !! wikitext
20849 <gallery>
20850 File:Foobar.jpg|alt=galleryalt|link=http://www.example.org
20851 </gallery>
20852 !! html/php
20853 <ul class="gallery mw-gallery-traditional">
20854 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20855 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="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>
20856 <div class="gallerytext">
20857 </div>
20858 </div></li>
20859 </ul>
20860
20861 !! html/parsoid
20862 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20863 <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>
20864 </ul>
20865 !! end
20866
20867 !! test
20868 Gallery override link with absolute external link with LanguageConverter
20869 !! options
20870 language=zh
20871 !! wikitext
20872 <gallery>
20873 File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org
20874 </gallery>
20875 !! html/php
20876 <ul class="gallery mw-gallery-traditional">
20877 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20878 <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>
20879 <div class="gallerytext">
20880 <p>caption
20881 </p>
20882 </div>
20883 </div></li>
20884 </ul>
20885
20886 !! html/parsoid
20887 <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"}}'>
20888 <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>
20889 </ul>
20890 !! end
20891
20892 !! test
20893 Gallery override link with malicious javascript (T36852)
20894 !! options
20895 parsoid={
20896 "modes": ["wt2html", "html2html"],
20897 "nativeGallery": true
20898 }
20899 !! wikitext
20900 <gallery>
20901 File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!');
20902 </gallery>
20903 !! html/php
20904 <ul class="gallery mw-gallery-traditional">
20905 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20906 <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>
20907 <div class="gallerytext">
20908 </div>
20909 </div></li>
20910 </ul>
20911
20912 !! html/parsoid
20913 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20914 <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>
20915 </ul>
20916 !! end
20917
20918 # Note that parsoid uses the invalid link as a caption, PHP does not.
20919 !! test
20920 Gallery with invalid title as link (T45964)
20921 !! options
20922 parsoid={
20923 "modes": ["wt2html", "html2html"],
20924 "nativeGallery": true
20925 }
20926 !! wikitext
20927 <gallery>
20928 File:Foobar.jpg|link=<
20929 </gallery>
20930 !! html/php
20931 <ul class="gallery mw-gallery-traditional">
20932 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20933 <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>
20934 <div class="gallerytext">
20935 </div>
20936 </div></li>
20937 </ul>
20938
20939 !! html/parsoid
20940 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20941 <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>
20942 </ul>
20943 !! end
20944
20945 !! test
20946 Serialize gallery without attrs in data-mw
20947 !! options
20948 parsoid={
20949 "modes": ["html2wt"],
20950 "nativeGallery": true
20951 }
20952 !! html/parsoid
20953 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'>
20954 <li class="gallerycaption">123</li>
20955 <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>
20956 </ul>
20957 !! wikitext
20958 <gallery caption="123">
20959 File:Test.png
20960 </gallery>
20961 !! end
20962
20963 !! test
20964 Gallery with class and style attributes
20965 !! options
20966 parsoid={
20967 "nativeGallery": true
20968 }
20969 !! wikitext
20970 <gallery class="center" style="text-align: center;">
20971 File:Foobar.jpg
20972 </gallery>
20973 !! html/php
20974 <ul class="gallery mw-gallery-traditional center" style="text-align: center;">
20975 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20976 <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>
20977 <div class="gallerytext">
20978 </div>
20979 </div></li>
20980 </ul>
20981
20982 !! html/parsoid
20983 <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":{}}'>
20984 <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>
20985 </ul>
20986 !! end
20987
20988 !! test
20989 Gallery in slideshow mode
20990 !! options
20991 parsoid={
20992 "nativeGallery": true
20993 }
20994 !! wikitext
20995 <gallery mode="slideshow" showthumbnails="">
20996 File:Foobar.jpg
20997 </gallery>
20998 !! html/php
20999 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1">
21000 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21001 <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>
21002 <div class="gallerytext">
21003 </div>
21004 </div></li>
21005 </ul>
21006
21007 !! html/parsoid
21008 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'>
21009 <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>
21010 </ul>
21011 !! end
21012
21013 !! test
21014 HTML Hex character encoding (spells the word "JavaScript")
21015 !! options
21016 parsoid=wt2html,wt2wt,html2html
21017 !! wikitext
21018 &#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
21019 !! html/php
21020 <p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
21021 </p>
21022 !! html/parsoid
21023 <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>
21024 !! end
21025
21026 !! test
21027 HTML Hex character encoding bogus encoding (T28437 regression check)
21028 !! wikitext
21029 &#xsee;&#XSEE;
21030 !! html
21031 <p>&amp;#xsee;&amp;#XSEE;
21032 </p>
21033 !! end
21034
21035 !! test
21036 HTML Hex character encoding mixed case
21037 !! options
21038 parsoid=wt2html,wt2wt,html2html
21039 !! wikitext
21040 &#xEE;&#Xee;
21041 !! html/php
21042 <p>&#xee;&#xee;
21043 </p>
21044 !! html/parsoid
21045 <p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
21046 !! end
21047
21048 # See: https://www.w3.org/TR/html5/syntax.html#character-references
21049 # Note that U+000C (form feed) is not a valid XML character, so
21050 # it is banned even though allowed in HTML5.
21051 !! test
21052 Illegal character references (T106578)
21053 !! wikitext
21054 ; Null: &#00;
21055 ; FF: &#xC;
21056 ; CR: &#xD;
21057 ; Control (low): &#8;
21058 ; Control (high): &#x7F; &#x9F;
21059 ; Surrogate: &#xD83D;&#xDCA9;
21060 ; This is an okay astral character: &#x1F4A9;
21061 !! html+tidy
21062 <dl><dt>Null</dt>
21063 <dd>&amp;#00;</dd>
21064 <dt>FF</dt>
21065 <dd>&amp;#xC;</dd>
21066 <dt>CR</dt>
21067 <dd>&amp;#xD;</dd>
21068 <dt>Control (low)</dt>
21069 <dd>&amp;#8;</dd>
21070 <dt>Control (high)</dt>
21071 <dd>&amp;#x7F; &amp;#x9F;</dd>
21072 <dt>Surrogate</dt>
21073 <dd>&amp;#xD83D;&amp;#xDCA9;</dd>
21074 <dt>This is an okay astral character</dt>
21075 <dd>&#x1f4a9;</dd></dl>
21076 !! end
21077
21078 !! test
21079 __FORCETOC__ override
21080 !! wikitext
21081 __NEWSECTIONLINK__
21082 __FORCETOC__
21083 !! html/php
21084 <p><br />
21085 </p>
21086 !! end
21087
21088 !! test
21089 ISBN code coverage
21090 !! wikitext
21091 ISBN 978-0-1234-56&#x20;789
21092 !! html/php
21093 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a>&#x20;789
21094 </p>
21095 !! html/parsoid
21096 <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>
21097 !! end
21098
21099 !! test
21100 ISBN followed by 5 spaces
21101 !! wikitext
21102 ISBN
21103 !! html
21104 <p>ISBN
21105 </p>
21106 !! end
21107
21108 !! test
21109 Double ISBN
21110 !! wikitext
21111 ISBN ISBN 1234567890
21112 !! html/php
21113 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21114 </p>
21115 !! html/parsoid
21116 <p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
21117 !! end
21118
21119 # Uppercase X and lowercase x as well
21120 !! test
21121 ISBN with an X
21122 !! wikitext
21123 ISBN 3-462-04561-X
21124 ISBN 3-462-04561-x
21125 ISBN 080442957X
21126 ISBN 080442957x
21127 ISBN 978080442957X
21128 ISBN 978080442957x
21129 !! html/php
21130 <p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a>
21131 <a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a>
21132 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a>
21133 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a>
21134 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a>
21135 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
21136 </p>
21137 !! html/parsoid
21138 <p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
21139 <a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
21140 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
21141 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
21142 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
21143 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
21144 !! end
21145
21146 !! test
21147 ISBN with empty prefix (parsoid test)
21148 !! wikitext
21149 ISBN 1234567890
21150 !! html/php
21151 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21152 </p>
21153 !! html/parsoid
21154 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p>
21155 !! end
21156
21157 !! test
21158 T24905: <abbr> followed by ISBN followed by </a>
21159 !! wikitext
21160 <abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
21161 !! html/php
21162 <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>
21163 </p>
21164 !! html/parsoid
21165 <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>
21166 !! end
21167
21168 !! test
21169 Double RFC
21170 !! wikitext
21171 RFC RFC 1234
21172 !! html
21173 <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a>
21174 </p>
21175 !! end
21176
21177 !! test
21178 Double RFC with a wiki link
21179 !! wikitext
21180 RFC [[RFC 1234]]
21181 !! html
21182 <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>
21183 </p>
21184 !! end
21185
21186 !! test
21187 RFC code coverage
21188 !! wikitext
21189 RFC 983&#x20;987
21190 !! html/php
21191 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
21192 </p>
21193 !! html/parsoid
21194 <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>
21195 !! end
21196
21197 !! test
21198 Centre-aligned image
21199 !! wikitext
21200 [[Image:foobar.jpg|centre]]
21201 !! html/php
21202 <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>
21203
21204 !! html/parsoid
21205 <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>
21206 !! end
21207
21208 !! test
21209 None-aligned image
21210 !! wikitext
21211 [[Image:foobar.jpg|none]]
21212 !! html/php
21213 <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>
21214
21215 !! html/parsoid
21216 <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>
21217 !! end
21218
21219 !! test
21220 Width + Height sized image (using px) (height is ignored)
21221 !! wikitext
21222 [[Image:foobar.jpg|640x480px]]
21223 !! html/php
21224 <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>
21225 </p>
21226 !! html/parsoid
21227 <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>
21228 !! end
21229
21230 !! test
21231 Width-sized image (using px, no following whitespace)
21232 !! wikitext
21233 [[Image:foobar.jpg|640px]]
21234 !! html/php
21235 <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>
21236 </p>
21237 !! html/parsoid
21238 <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>
21239 !! end
21240
21241 !! test
21242 Width-sized image (using px, with following whitespace - test regression from r39467)
21243 !! wikitext
21244 [[Image:foobar.jpg|640px ]]
21245 !! html/php
21246 <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>
21247 </p>
21248 !! html/parsoid
21249 <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>
21250 !!end
21251
21252 !! test
21253 Width-sized image (using px, with preceding whitespace - test regression from r39467)
21254 !! wikitext
21255 [[Image:foobar.jpg| 640px]]
21256 !! html/php
21257 <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>
21258 </p>
21259 !! html/parsoid
21260 <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>
21261 !! end
21262
21263 !! test
21264 Image with page parameter
21265 !! options
21266 djvu
21267 !! wikitext
21268 [[File:LoremIpsum.djvu|page=2]]
21269 !! html/php
21270 <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>
21271 </p>
21272 !! html/parsoid
21273 <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>
21274 !! end
21275
21276 !! test
21277 Another italics / bold test
21278 !! wikitext
21279 ''' ''x'
21280 !! html
21281 <pre>'<i> </i>x'
21282 </pre>
21283 !!end
21284
21285 # FIXME: The php output seems broken. It's interleaving some open/close tags.
21286 !! test
21287 dt/dd/dl test
21288 !! wikitext
21289 :;;;::
21290 !! html/php
21291 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dt></dl></dd></dl></dd></dl></dd></dl></dd></dl></dd></dl>
21292
21293 !! html/parsoid
21294 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dd></dl></dd></dl></dt></dl></dt></dl></dt></dl></dd></dl>
21295
21296 !!end
21297
21298 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
21299 !! test
21300 Images with the "|" character in the comment
21301 !! wikitext
21302 [[File:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
21303 !! html/php
21304 <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>
21305
21306 !! html/parsoid
21307 <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>
21308 !! end
21309
21310 !! test
21311 [Before] HTML without raw HTML enabled ($wgRawHtml==false)
21312 !! wikitext
21313 <html><script>alert(1);</script></html>
21314 !! html
21315 <p>&lt;html&gt;&lt;script&gt;alert(1);&lt;/script&gt;&lt;/html&gt;
21316 </p>
21317 !! end
21318
21319 !! test
21320 HTML with raw HTML ($wgRawHtml==true)
21321 !! options
21322 wgRawHtml=1
21323 !! wikitext
21324 <html><script>alert(1);</script></html>
21325 !! html/php
21326 <p><script>alert(1);</script>
21327 </p>
21328 !! end
21329
21330 !! test
21331 Parents of subpages, one level up
21332 !! options
21333 subpage title=[[Subpage test/L1/L2/L3]]
21334 !! wikitext
21335 [[../|L2]]
21336 !! html
21337 <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>
21338 </p>
21339 !! end
21340
21341
21342 !! test
21343 Parents of subpages, one level up, not named
21344 !! options
21345 subpage title=[[Subpage test/L1/L2/L3]]
21346 !! wikitext
21347 [[../]]
21348 !! html
21349 <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>
21350 </p>
21351 !! end
21352
21353
21354
21355 !! test
21356 Parents of subpages, two levels up
21357 !! options
21358 subpage title=[[Subpage test/L1/L2/L3]]
21359 !! wikitext
21360 [[../../|L1]]2
21361
21362 [[../../|L1]]l
21363 !! html
21364 <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
21365 </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>
21366 </p>
21367 !! end
21368
21369 !! test
21370 Parents of subpages, two levels up, without trailing slash or name.
21371 !! options
21372 subpage title=[[Subpage test/L1/L2/L3]]
21373 !! wikitext
21374 [[../..]]
21375 !! html
21376 <p>[[../..]]
21377 </p>
21378 !! end
21379
21380 !! test
21381 Parents of subpages, two levels up, with lots of extra trailing slashes.
21382 !! options
21383 subpage title=[[Subpage test/L1/L2/L3]]
21384 !! wikitext
21385 [[../../////]]
21386 !! html
21387 <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>
21388 </p>
21389 !! end
21390
21391 !! article
21392 Subpage test/L1/L2/L3Sibling
21393 !! text
21394 Sibling article
21395 !! endarticle
21396
21397 !! test
21398 Transclusion of a sibling page (one level up)
21399 !! options
21400 subpage title=[[Subpage test/L1/L2/L3]]
21401 !! wikitext
21402 {{../L3Sibling}}
21403 !! html
21404 <p>Sibling article
21405 </p>
21406 !! end
21407
21408 !! test
21409 Transclusion of a child page
21410 !! options
21411 subpage title=[[Subpage test/L1/L2]]
21412 !! wikitext
21413 {{/L3Sibling}}
21414 !! html
21415 <p>Sibling article
21416 </p>
21417 !! end
21418
21419 # This is wt2html only in Parsoid because we add <nowiki>
21420 # because of {{..}} and we don't expect to fix that to
21421 # eliminate the nowikis selective for {{..}} markup.
21422 !! test
21423 Non-transclusion because of too many up levels
21424 !! options
21425 subpage title=[[Subpage test/L1/L2/L3]]
21426 parsoid=wt2html
21427 !! wikitext
21428 {{../../../../More than parent}}
21429 !! html/php
21430 <p>{{../../../../More than parent}}
21431 </p>
21432 !! html/parsoid
21433 <p>{{../../../../More than parent}}</p>
21434 !! end
21435
21436 !! test
21437 Definition list code coverage
21438 !! wikitext
21439 ;title : def
21440 ;title : def
21441 ;title: def
21442 !! html/php
21443 <dl><dt>title &#160;</dt>
21444 <dd>def</dd>
21445 <dt>title&#160;</dt>
21446 <dd>def</dd>
21447 <dt>title</dt>
21448 <dd>def</dd></dl>
21449
21450 !! html/parsoid
21451 <dl><dt>title <span typeof="mw:Placeholder"> </span></dt><dd> def</dd>
21452 <dt>title<span typeof="mw:Placeholder"> </span></dt><dd> def</dd>
21453 <dt>title</dt><dd> def</dd></dl>
21454 !! end
21455
21456 !! test
21457 Don't fall for the self-closing div
21458 !! wikitext
21459 <div>hello world</div/>
21460 !! html
21461 <div>hello world</div>
21462
21463 !! end
21464
21465 !! test
21466 MSGNW magic word
21467 !! wikitext
21468 {{MSGNW:msg}}
21469 !! html/php
21470 <p>&#91;&#91;:Template:Msg&#93;&#93;
21471 </p>
21472 !! end
21473
21474 !! test
21475 RAW magic word
21476 !! wikitext
21477 {{RAW:QUERTY}}
21478 !! html
21479 <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>
21480 </p>
21481 !! end
21482
21483 # This isn't needed for XHTML conformance, but would be handy as a fallback security measure
21484 !! test
21485 Always escape literal '>' in output, not just after '<'
21486 !! wikitext
21487 ><>
21488 !! html
21489 <p>&gt;&lt;&gt;
21490 </p>
21491 !! end
21492
21493 !! test
21494 Template caching
21495 !! wikitext
21496 {{Test}}
21497 {{Test}}
21498 !! html
21499 <p>This is a test template
21500 This is a test template
21501 </p>
21502 !! end
21503
21504
21505 !! article
21506 MediaWiki:Fake
21507 !! text
21508 ==header==
21509 !! endarticle
21510
21511 !! test
21512 Inclusion of !userCanEdit() content
21513 !! wikitext
21514 {{MediaWiki:Fake}}
21515 !! html
21516 <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>
21517
21518 !! end
21519
21520
21521 !! test
21522 Out-of-order TOC heading levels
21523 !! wikitext
21524 ==2==
21525 ======6======
21526 ===3===
21527 =1=
21528 =====5=====
21529 ==2==
21530 !! html
21531 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
21532 <ul>
21533 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
21534 <ul>
21535 <li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
21536 <li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
21537 </ul>
21538 </li>
21539 <li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
21540 <ul>
21541 <li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
21542 <li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
21543 </ul>
21544 </li>
21545 </ul>
21546 </div>
21547
21548 <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>
21549 <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>
21550 <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>
21551 <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>
21552 <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>
21553 <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>
21554
21555 !! end
21556
21557
21558 !! test
21559 ISBN with a dummy number
21560 !! wikitext
21561 ISBN ---
21562 !! html
21563 <p>ISBN ---
21564 </p>
21565 !! end
21566
21567
21568 !! test
21569 ISBN with space-delimited number
21570 !! wikitext
21571 ISBN 92 9017 032 8
21572 !! html/php
21573 <p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a>
21574 </p>
21575 !! html/parsoid
21576 <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>
21577 !! end
21578
21579
21580 !! test
21581 ISBN with multiple spaces, no number
21582 !! wikitext
21583 ISBN foo
21584 !! html
21585 <p>ISBN foo
21586 </p>
21587 !! end
21588
21589
21590 !! test
21591 ISBN length
21592 !! wikitext
21593 ISBN 123456789
21594
21595 ISBN 1234567890
21596
21597 ISBN 12345678901
21598 !! html/php
21599 <p>ISBN 123456789
21600 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21601 </p><p>ISBN 12345678901
21602 </p>
21603 !! html/parsoid
21604 <p>ISBN 123456789</p>
21605
21606 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
21607
21608 <p>ISBN 12345678901</p>
21609 !! end
21610
21611
21612 !! test
21613 ISBN with trailing year (T9110)
21614 !! wikitext
21615 ISBN 1-234-56789-0 - 2006
21616
21617 ISBN 1 234 56789 0 - 2006
21618 !! html/php
21619 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006
21620 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006
21621 </p>
21622 !! html/parsoid
21623 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p>
21624
21625 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p>
21626 !! end
21627
21628
21629 !! test
21630 anchorencode
21631 !! config
21632 wgFragmentMode=[ 'html5', 'legacy' ]
21633 !! wikitext
21634 {{anchorencode:foo bar©#%n}}
21635 !! html/php
21636 <p>foo_bar©#%n
21637 </p>
21638 !! html/parsoid
21639 <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>
21640 !! end
21641
21642 !! test
21643 anchorencode (legacy)
21644 !! config
21645 wgFragmentMode=[ 'legacy' ]
21646 !! wikitext
21647 {{anchorencode:foo bar©#%n}}
21648 !! html/php
21649 <p>foo_bar.C2.A9.23.25n
21650 </p>
21651 !! end
21652
21653 !! test
21654 anchorencode trims spaces
21655 !! config
21656 wgFragmentMode=[ 'html5', 'legacy' ]
21657 !! wikitext
21658 {{anchorencode: __pretty__please__}}
21659 !! html/php
21660 <p>pretty_please
21661 </p>
21662 !! html/parsoid
21663 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: __pretty__please__","function":"anchorencode"},"params":{},"i":0}}]}'>pretty_please</p>
21664 !! end
21665
21666 !! test
21667 anchorencode deals with links
21668 !! config
21669 wgFragmentMode=[ 'html5', 'legacy' ]
21670 !! wikitext
21671 {{anchorencode: [[hello|world]] [[hi]]}}
21672 !! html/php
21673 <p>world_hi
21674 </p>
21675 !! html/parsoid
21676 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: [[hello|world]] [[hi]]","function":"anchorencode"},"params":{},"i":0}}]}'>world_hi</p>
21677 !! end
21678
21679 !! test
21680 anchorencode deals with templates
21681 !! config
21682 wgFragmentMode=[ 'html5', 'legacy' ]
21683 !! wikitext
21684 {{anchorencode: {{Foo}} x}}
21685 !! html/php
21686 <p>FOO_x
21687 </p>
21688 !! html/parsoid
21689 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: {{Foo}} x","function":"anchorencode"},"params":{},"i":0}}]}'>FOO_x</p>
21690 !! end
21691
21692 !! test
21693 anchorencode encodes like the TOC generator: (T20431)
21694 !! config
21695 wgFragmentMode=[ 'html5', 'legacy' ]
21696 !! wikitext
21697 ===_ +:.3A%3A _ &&amp;]] x===
21698 {{anchorencode: _ +:.3A%3A _ &&amp;]] x}}
21699 __NOEDITSECTION__
21700 !! html/php
21701 <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>
21702 <p>+:.3A%3A_&amp;&amp;&#93;&#93;_x
21703 </p>
21704 !! html/parsoid
21705 <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>
21706 <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>
21707 <meta property="mw:PageProp/noeditsection"/>
21708 !! end
21709
21710 !! test
21711 anchorencode encodes like the TOC generator: (T20431) (legacy)
21712 !! config
21713 wgFragmentMode=[ 'legacy' ]
21714 !! wikitext
21715 ===_ +:.3A%3A&&amp;]]===
21716 {{anchorencode: _ +:.3A%3A&&amp;]] }}
21717 __NOEDITSECTION__
21718 !! html/php
21719 <h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&amp;&amp;]]</span></h3>
21720 <p>.2B:.3A.253A.26.26.5D.5D
21721 </p>
21722 !! end
21723
21724 !! test
21725 T8200: blockquotes and paragraph formatting
21726 !! wikitext
21727 <blockquote>
21728 foo
21729 </blockquote>
21730
21731 bar
21732
21733 baz
21734 !! html
21735 <blockquote>
21736 <p>foo
21737 </p>
21738 </blockquote>
21739 <p>bar
21740 </p>
21741 <pre>baz
21742 </pre>
21743 !! end
21744
21745 !! test
21746 T10293: Use of center tag ruins paragraph formatting
21747 !! wikitext
21748 <center>
21749 foo
21750 </center>
21751
21752 bar
21753
21754 baz
21755 !! html
21756 <center>
21757 <p>foo
21758 </p>
21759 </center>
21760 <p>bar
21761 </p>
21762 <pre>baz
21763 </pre>
21764 !! end
21765
21766 !!test
21767 Parsing of overlapping (improperly nested) inline html tags
21768 !! wikitext
21769 <span><s>x</span></s>
21770 !! html/php
21771 <p><span><s>x&lt;/span&gt;</s></span>
21772 </p>
21773 !! html/parsoid
21774 <p><span><s>x</s></span>
21775 </p>
21776 !!end
21777
21778 ###
21779 ### Language variants related tests
21780 ###
21781
21782 # Parsoid does not mark self-links.
21783 # Parsoid does not convert links; PHP will do any necessary redirects.
21784
21785 !! test
21786 Self-link in language variants
21787 !! options
21788 title=[[Dunav]] language=sr
21789 !! wikitext
21790 Both [[Dunav]] and [[Дунав]] are names for this river.
21791 !! html/php
21792 <p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
21793 </p>
21794 !! html/parsoid
21795 <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>
21796 !! end
21797
21798 !! article
21799 Дуна
21800 !! text
21801 content
21802 !! endarticle
21803
21804 !! test
21805 Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
21806 !! options
21807 title=[[Duna]] language=sr
21808 !! wikitext
21809 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
21810 !! html/php
21811 <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.
21812 </p>
21813 !! html/parsoid
21814 <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>
21815 !! end
21816
21817 !! test
21818 Link to a section of a variant of this title shouldn't be parsed as self-link
21819 !! options
21820 title=[[Duna]] language=sr
21821 !! wikitext
21822 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
21823 !! html/php
21824 <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.
21825 </p>
21826 !! html/parsoid
21827 <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>
21828 !! end
21829
21830 !! test
21831 Link to pages in language variants
21832 !! options
21833 language=sr
21834 !! wikitext
21835 Main Page can be written as [[Маин Паге]]
21836 !! html/php
21837 <p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>
21838 </p>
21839 !! html/parsoid
21840 <p>Main Page can be written as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a></p>
21841 !! end
21842
21843
21844 !! test
21845 Multiple links to pages in language variants
21846 !! options
21847 language=sr
21848 !! wikitext
21849 [[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
21850 !! html/php
21851 <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>.
21852 </p>
21853 !! html/parsoid
21854 <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>
21855 !! end
21856
21857
21858 !! test
21859 Simple template in language variants
21860 !! options
21861 language=sr
21862 !! wikitext
21863 {{тест}}
21864 !! html/php
21865 <p>This is a test template
21866 </p>
21867 !! end
21868
21869
21870 !! test
21871 Template with explicit namespace in language variants
21872 !! options
21873 language=sr
21874 !! wikitext
21875 {{Template:тест}}
21876 !! html/php
21877 <p>This is a test template
21878 </p>
21879 !! end
21880
21881
21882 !! test
21883 Basic test for template parameter in language variants
21884 !! options
21885 language=sr
21886 !! wikitext
21887 {{парамтест|param=foo}}
21888 !! html/php
21889 <p>This is a test template with parameter foo
21890 </p>
21891 !! end
21892
21893 !! test
21894 Simple category in language variants
21895 !! options
21896 language=sr cat
21897 !! wikitext
21898 [[Category:МедиаWики Усер'с Гуиде]]
21899 !! html/php
21900 cat=МедиаWики_Усер'с_Гуиде sort=
21901 !! html/parsoid
21902 <link rel="mw:PageProp/Category" href="./Категорија:МедиаWики_Усер'с_Гуиде" data-parsoid='{"stx":"simple","a":{"href":"./Категорија:МедиаWики_Усер&#39;с_Гуиде"},"sa":{"href":"Category:МедиаWики Усер&#39;с Гуиде"}}'/>
21903 !! end
21904
21905 !! article
21906 Category:分类
21907 !! text
21908 blah
21909 !! endarticle
21910
21911 !! article
21912 Category:分類
21913 !! text
21914 blah
21915 !! endarticle
21916
21917 ## We used to, but no longer wt2wt this test since the default serializer
21918 ## will normalize all categories to serialize on their own line.
21919 ## This wikitext usage is going to be fairly uncommon in production and
21920 ## selser will take care of preserving formatting in those scenarios.
21921 !! test
21922 Don't convert blue categorylinks to another variant (T35210)
21923 !! options
21924 cat
21925 language=zh
21926 parsoid=wt2html
21927 !! wikitext
21928 [[A]][[Category:分类]]
21929 !! html/php
21930 cat=分类 sort=
21931 !! html/parsoid
21932 <p><a rel="mw:WikiLink" href="./A" title="A">A</a></p>
21933 <link rel="mw:PageProp/Category" href="./Category:分类"/>
21934 !! end
21935
21936 !! test
21937 Stripping -{}- tags (language variants)
21938 !! options
21939 language=sr
21940 !! wikitext
21941 Latin proverb: -{Ne nuntium necare}-
21942 !! html/php
21943 <p>Latin proverb: Ne nuntium necare
21944 </p>
21945 !! html/parsoid
21946 <p>Latin proverb: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
21947 !! end
21948
21949
21950 !! test
21951 Prevent conversion with -{}- tags (language variants)
21952 !! options
21953 language=sr variant=sr-ec
21954 !! wikitext
21955 Latinski: -{Ne nuntium necare}-
21956 !! html/php
21957 <p>Латински: Ne nuntium necare
21958 </p>
21959 !! html/parsoid
21960 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
21961 !! end
21962
21963
21964 !! test
21965 Prevent conversion of text with -{}- tags (language variants)
21966 !! options
21967 language=sr variant=sr-ec
21968 !! wikitext
21969 Latinski: -{Ne nuntium necare}-
21970 !! html/php
21971 <p>Латински: Ne nuntium necare
21972 </p>
21973 !! html/parsoid
21974 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
21975 !! end
21976
21977
21978 !! test
21979 Prevent conversion of links with -{}- tags (language variants)
21980 !! options
21981 language=sr variant=sr-ec
21982 !! wikitext
21983 -{[[Main Page]]}-
21984 !! html/php
21985 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21986 </p>
21987 !! html/parsoid
21988 <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>
21989 !! end
21990
21991
21992 !! test
21993 -{}- tags within headlines (within html for parserConvert())
21994 !! config
21995 wgFragmentMode=[ 'html5', 'legacy' ]
21996 !! options
21997 language=sr variant=sr-ec
21998 !! wikitext
21999 ==-{Naslov}-==
22000
22001 Note that even an unprotected headline ID is not affected by language
22002 conversion:
22003
22004 ==Latinski==
22005 !! html/php
22006 <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>
22007 <p>Ноте тхат евен ан унпротецтед хеадлине ИД ис нот аффецтед бy лангуаге
22008 цонверсион:
22009 </p>
22010 <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>
22011
22012 !! html/parsoid
22013 <h2 id="-{Naslov}-"><span id="-.7BNaslov.7D-" typeof="mw:FallbackId"></span><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Naslov"}}'></span></h2>
22014
22015 <p>Note that even an unprotected headline ID is not affected by language
22016 conversion:</p>
22017
22018 <h2 id="Latinski">Latinski</h2>
22019 !! end
22020
22021 !! test
22022 Explicit definition of language variant alternatives
22023 !! options
22024 language=zh variant=zh-tw
22025 !! wikitext
22026 -{zh:China;zh-tw:Taiwan}-, not China
22027 !! html/php
22028 <p>Taiwan, not China
22029 </p>
22030 !! html/parsoid
22031 <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>
22032 !! end
22033
22034 !! test
22035 Filter syntax for language variants
22036 !! options
22037 language=zh variant=zh-tw
22038 !! wikitext
22039 foo-{zh;zh-hans;zh-hant|blog, WEBJOURNAL, WEBLOG}-quux
22040 !! html/php
22041 <p>fooblog, WEBJOURNAL, WEBLOGquux
22042 </p>
22043 !! html/parsoid
22044 <p>foo<span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"blog, WEBJOURNAL, WEBLOG"}}'></span>quux</p>
22045 !! end
22046
22047 # Note that Parsoid post-processing for language variants needs to
22048 # update the `title` attribute here, based on the mw:ExpandedAttrs property
22049 !! test
22050 Conversion around HTML tags
22051 !! options
22052 language=sr variant=sr-ec
22053 !! wikitext
22054 -{H|span=>sr-ec:script;title=>sr-ec:src}-
22055 <span title="La-{sr-el:L;sr-ec:C}-tin">ski</span>
22056 !! html/php
22057 <p>
22058 <span title="ЛаCтин">ски</span>
22059 </p>
22060 !! html/parsoid
22061 <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"}]}'/>
22062 <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>
22063 !! end
22064
22065 !! test
22066 Explicit session-wise two-way language variant mapping (A flag and - flag)
22067 !! options
22068 language=zh variant=zh-tw
22069 !! wikitext
22070 This is -{zh:China; zh-tw:Taiwan}-, but we'll forget that now.
22071
22072 Taiwan is not China.
22073
22074 But -{A|zh:China; zh-tw:Taiwan}- is China,
22075
22076 (This-{-|zh:China; zh-tw:Taiwan}- should be stripped!)
22077
22078 and -{China}- is China.
22079 !! html/php
22080 <p>This is Taiwan, but we'll forget that now.
22081 </p><p>Taiwan is not China.
22082 </p><p>But Taiwan is Taiwan,
22083 </p><p>(This should be stripped!)
22084 </p><p>and China is China.
22085 </p>
22086 !! html/parsoid
22087 <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>
22088 <p>Taiwan is not China.</p>
22089 <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>
22090 <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>
22091 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"China"}}'></span> is China.</p>
22092 !! end
22093
22094 !! test
22095 Explicit session-wise one-way language variant mapping (A flag and - flag)
22096 !! options
22097 language=zh variant=zh-tw
22098 !! wikitext
22099 This is -{COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}-, but we'll forget that now.
22100
22101 COUNTRY is China or Taiwan.
22102
22103 But -{A|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- is COUNTRY,
22104
22105 (This-{-|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
22106
22107 and -{COUNTRY}- is COUNTRY.
22108 !! html/php
22109 <p>This is Taiwan, but we'll forget that now.
22110 </p><p>COUNTRY is China or Taiwan.
22111 </p><p>But Taiwan is Taiwan,
22112 </p><p>(This should be stripped!)
22113 </p><p>and COUNTRY is COUNTRY.
22114 </p>
22115 !! html/parsoid
22116 <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>
22117 <p>COUNTRY is China or Taiwan.</p>
22118 <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>
22119 <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>
22120 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"COUNTRY"}}'></span> is COUNTRY.</p>
22121 !! end
22122
22123 !! test
22124 Explicit session-wise two-way language variant mapping (H flag for hide)
22125 !! options
22126 language=zh variant=zh-tw
22127 !! wikitext
22128 (This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
22129
22130 Taiwan is China.
22131 !! html/php
22132 <p>(This should be stripped!)
22133 </p><p>Taiwan is Taiwan.
22134 </p>
22135 !! html/parsoid
22136 <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>
22137 <p>Taiwan is China.</p>
22138 !! end
22139
22140 !! test
22141 Explicit session-wise one-way language variant mapping (H flag for hide)
22142 !! options
22143 language=zh variant=zh-tw
22144 !! wikitext
22145 (This-{H|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
22146
22147 COUNTRY is Taiwan or China.
22148 !! html/php
22149 <p>(This should be stripped!)
22150 </p><p>Taiwan is Taiwan or China.
22151 </p>
22152 !! html/parsoid
22153 <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>
22154 <p>COUNTRY is Taiwan or China.</p>
22155 !! end
22156
22157 ## Note that parsoid test runner does not support 'showtitle' option.
22158 !! test
22159 Adding explicit conversion rule for title (T flag)
22160 !! options
22161 language=zh variant=zh-tw showtitle
22162 !! wikitext
22163 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
22164
22165 Taiwan is China.
22166 !! html/php
22167 Taiwan
22168 <p>Should be stripped!
22169 </p><p>Taiwan is China.
22170 </p>
22171 !! html/parsoid
22172 <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>
22173 <p>Taiwan is China.</p>
22174 !! end
22175
22176 !! test
22177 Code coverage: T combined with H flag
22178 !! options
22179 language=zh variant=zh-tw showtitle
22180 !! wikitext
22181 Should be stripped-{T;H|zh:China; zh-tw:Taiwan}-!
22182
22183 Taiwan is China.
22184 !! html/php
22185 Taiwan
22186 <p>Should be stripped!
22187 </p><p>Taiwan is Taiwan.
22188 </p>
22189 !! html/parsoid
22190 <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>
22191 <p>Taiwan is China.</p>
22192 !! end
22193
22194 !! test
22195 Code coverage: T with no variants
22196 !! options
22197 language=zh variant=zh-tw showtitle
22198 !! wikitext
22199 -{H|zh:China; zh-tw:Taiwan}-
22200 Taiwan is China.-{T|Taiwan is China}-
22201 !! html/php
22202 Taiwan is China
22203 <p>
22204 Taiwan is Taiwan.
22205 </p>
22206 !! html/parsoid
22207 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
22208 Taiwan is China.<meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Taiwan is China"},"title":true}'/></p>
22209 !! end
22210
22211 !! test
22212 Code coverage: rules with no variants
22213 !! options
22214 language=zh variant=zh-tw
22215 !! wikitext
22216 -{H|zh:China; zh-tw:Taiwan}-
22217 Taiwan is China.
22218 -{H|China}-
22219 Taiwan is China.
22220 !! html/php
22221 <p>
22222 Taiwan is Taiwan.
22223
22224 Taiwan is China.
22225 </p>
22226 !! html/parsoid
22227 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
22228 Taiwan is China.
22229 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":"China"}]}'/>
22230 Taiwan is China.</p>
22231 !! end
22232
22233
22234 !! test
22235 Code coverage: D flag for conversion rule
22236 !! options
22237 language=zh variant=zh-tw
22238 !! wikitext
22239 -{D|zh-cn:XA; zh-tw:YA}-
22240 -{A;D|zh-cn:XB; zh-tw:YB}-
22241 -{D;H|zh-cn:XC; zh-tw:YC}-
22242
22243 -{D;H|FOO=>zh-tw:BAR;FOO=>zh-cn:BAT}-
22244
22245 -{D|0=>zh-tw:1}-
22246 -{A;D|2=>zh-tw:3}-
22247 -{D;H|4=>zh-tw:5}-
22248
22249 XA XB XC YA YB YC FOO BAR BAT 012345
22250 !! html/php
22251 <p>大陆:XA;台灣:YA;
22252
22253 大陆:XC;台灣:YC;
22254 </p><p>FOO⇒台灣:BAR;FOO⇒大陆:BAT;
22255 </p><p>0⇒台灣:1;
22256
22257 4⇒台灣:5;
22258 </p><p>XA YB YC YA YB YC BAR BAR BAT 013355
22259 </p>
22260 !! html/parsoid
22261 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"twoway":[{"l":"zh-cn","t":"XA"},{"l":"zh-tw","t":"YA"}]}'></span>
22262 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XB"},{"l":"zh-tw","t":"YB"}]}'/>
22263 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XC"},{"l":"zh-tw","t":"YC"}]}'></span></p>
22264 <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>
22265 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"oneway":[{"f":"0","l":"zh-tw","t":"1"}]}'></span>
22266 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"2","l":"zh-tw","t":"3"}]}'/>
22267 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"4","l":"zh-tw","t":"5"}]}'></span></p>
22268 <p>XA XB XC YA YB YC FOO BAR BAT 012345</p>
22269 !! end
22270
22271 !! test
22272 Code coverage: N flag for conversion rule
22273 !! options
22274 language=zh variant=zh-cn
22275 !! wikitext
22276 -{N|zh-cn}-
22277
22278 -{N|zh-tw}-
22279
22280 -{N|sr-ec}-
22281 !! html/php
22282 <p>大陆
22283 </p><p>台灣
22284 </p><p>српски (ћирилица)‎
22285 </p>
22286 !! html/parsoid
22287 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-cn"}}'></span></p>
22288 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-tw"}}'></span></p>
22289 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"sr-ec"}}'></span></p>
22290 !! end
22291
22292 # html2wt suppresses the bogus 'D' flag, so this is wt2html only
22293 !! test
22294 Code coverage: N flag for conversion rule (wt2html only)
22295 !! options
22296 language=zh variant=zh-cn
22297 parsoid=wt2html,html2html
22298 !! wikitext
22299 -{D;N|en}-
22300 !! html/php
22301 <p>English
22302 </p>
22303 !! html/parsoid
22304 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"en"}}' data-parsoid='{"fl":["D","N"]}'></span></p>
22305 !! end
22306
22307 !! test
22308 Testing that changing the language variant here in the tests actually works
22309 !! options
22310 language=zh variant=zh showtitle
22311 !! wikitext
22312 Should be stripped-{T|zh:China; zh-tw:Taiwan}-!
22313 !! html/php
22314 China
22315 <p>Should be stripped!
22316 </p>
22317 !! html/parsoid
22318 <p>Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
22319 !! end
22320
22321 !! test
22322 Recursive conversion of alt and title attrs shouldn't clear converter state
22323 !! options
22324 language=zh variant=zh-cn
22325 showtitle
22326 !! wikitext
22327 -{H|zh-cn:Exclamation; zh-tw:exclamation}-
22328 Should be stripped-{T|zh-cn:China; zh-tw:Taiwan}-<span title="exclamation">!</span>
22329 !! html/php
22330 China
22331 <p>
22332 Should be stripped<span title="Exclamation">!</span>
22333 </p>
22334 !! html/parsoid
22335 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh-cn","t":"Exclamation"},{"l":"zh-tw","t":"exclamation"}]}'/>
22336 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>
22337 !! end
22338
22339 !! test
22340 T26072: more test on conversion rule for title
22341 !! options
22342 language=zh variant=zh-tw showtitle
22343 !! wikitext
22344 This should be stripped-{T|zh:China; zh-tw:Taiwan}-!
22345
22346 This won't take interferes with the title rule-{H|zh:Beijing; zh-tw:Taipei}-.
22347 !! html/php
22348 Taiwan
22349 <p>This should be stripped!
22350 </p><p>This won't take interferes with the title rule.
22351 </p>
22352 !! html/parsoid
22353 <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>
22354 <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>
22355 !! end
22356
22357 !! test
22358 Partly disable title conversion if variant == main language code
22359 !! options
22360 language=zh variant=zh title=[[ZH]] showtitle
22361 !! wikitext
22362 -{T|zh-cn:CN;zh-tw:TW}-
22363 !! html/php
22364 ZH
22365 <p>
22366 </p>
22367 !! html/parsoid
22368 <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>
22369 !! end
22370
22371 !! test
22372 Partly disable title conversion if variant == main language code, more
22373 !! options
22374 language=zh variant=zh title=[[ZH]] showtitle
22375 !! wikitext
22376 -{T|TW}-
22377 !! html/php
22378 ZH
22379 <p>
22380 </p>
22381 !! html/parsoid
22382 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"TW"},"title":true}'/></p>
22383 !! end
22384
22385 !! test
22386 Raw output of variant escape tags (R flag)
22387 !! options
22388 language=zh variant=zh-tw
22389 !! wikitext
22390 Raw: -{R|zh:China;zh-tw:Taiwan}-
22391 !! html/php
22392 <p>Raw: zh:China;zh-tw:Taiwan
22393 </p>
22394 !! html/parsoid
22395 <p>Raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"zh:China;zh-tw:Taiwan"}}'></span></p>
22396 !! end
22397
22398 # html2wt suppresses the bogus 'D' flags, so this is wt2html only
22399 !! test
22400 Raw output of variant escape tags (R flag) (wt2html only)
22401 !! options
22402 language=zh variant=zh-tw
22403 parsoid=wt2html,html2html
22404 !! wikitext
22405 -{Variant}- -{D|syntax}- -{D;R|options}-
22406 !! html/php
22407 <p>Variant syntax options
22408 </p>
22409 !! html/parsoid
22410 <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>
22411 !! end
22412
22413 !! test
22414 Nested markup inside raw output of variant escape tags (R flag)
22415 !! options
22416 language=zh variant=zh-tw
22417 !! wikitext
22418 Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
22419 !! html/php
22420 <p>Nested raw: nested Taiwan nested
22421 </p>
22422 !! html/parsoid
22423 <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>
22424 !! end
22425
22426 !! test
22427 Nested markup and spaces inside raw output of variant escape tags (R flag)
22428 !! options
22429 language=zh variant=zh-tw
22430 !! wikitext
22431 X-{ outer -{ inner }- outer }-X
22432 !! html/php
22433 <p>X outer inner outer X
22434 </p>
22435 !! html/parsoid
22436 <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>
22437 !! end
22438
22439 !! test
22440 Templates inside raw output of variant escape tags (R flag)
22441 !! options
22442 language=zh variant=zh-tw
22443 !! wikitext
22444 Nested raw: -{R|nested {{echo|hi}} templates}-
22445 !! html/php
22446 <p>Nested raw: nested hi templates
22447 </p>
22448 !! html/parsoid
22449 <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>
22450 !! end
22451
22452 !! test
22453 Strings evaluating false shouldn't be ignored by Language converter (T51072)
22454 !! options
22455 language=zh variant=zh-cn
22456 !! wikitext
22457 -{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
22458 !! html/php
22459 <p>0
22460 </p>
22461 !! html/parsoid
22462 <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>
22463 !! end
22464
22465 !! test
22466 Conversion rules from [numeric-only string] to [something else] (T48634)
22467 !! options
22468 language=zh variant=zh-cn
22469 !! wikitext
22470 -{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
22471 !! html/php
22472 <p>D12345EE12345
22473 </p>
22474 !! html/parsoid
22475 <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>
22476 !! end
22477
22478 !! test
22479 Two-way converter rule entries with an empty value should be ignored (T53551)
22480 !! options
22481 language=zh variant=zh-cn
22482 !! wikitext
22483 -{H|zh-cn:foo;zh-tw:;}-foobar
22484 !! html/php
22485 <p>foobar
22486 </p>
22487 !! html/parsoid
22488 <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>
22489 !! end
22490
22491 !! test
22492 One-way converter rule entries with an empty "from" string should be ignored (T53551)
22493 !! options
22494 language=zh variant=zh-cn
22495 !! wikitext
22496 -{H|=>zh-cn:foo;}-foobar
22497 !! html/php
22498 <p>foobar
22499 </p>
22500 !! html/parsoid
22501 <p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[5]}' data-mw-variant='{"add":true,"oneway":[{"f":"","l":"zh-cn","t":"foo"}]}'/>foobar</p>
22502 !! end
22503
22504 !! test
22505 Empty converter rule entries shouldn't be inserted into the conversion table (T53551)
22506 !! options
22507 language=zh variant=zh-cn
22508 !! wikitext
22509 -{H|}-foobar
22510 !! html/php
22511 <p>foobar
22512 </p>
22513 !! html/parsoid
22514 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":""}]}'/>foobar</p>
22515 !! end
22516
22517 !! test
22518 Nested using of manual convert syntax
22519 !! options
22520 language=zh variant=zh-hk
22521 !! wikitext
22522 Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
22523 !! html/php
22524 <p>Nested: Hello Hong Kong!
22525 </p>
22526 !! html/parsoid
22527 <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>
22528 !! end
22529
22530 !! test
22531 HTML markups with conversion syntax in attribs, nested in other conversion blocks
22532 !! options
22533 language=zh variant=zh-cn
22534 !! wikitext
22535 -{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}-
22536 !! html/php
22537 <p><span title="X">A</span>
22538 </p>
22539 !! html/parsoid
22540 <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>
22541 !! end
22542
22543 !! test
22544 HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet in PHP parser)
22545 !! options
22546 language=zh variant=zh-cn
22547 !! wikitext
22548 -{<span title="-{X}-">A</span>}-
22549 !! html/php+disabled
22550 <p><span title="X">A</span>
22551 </p>
22552 !! html/parsoid
22553 <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>
22554 !! end
22555
22556 # Parsoid and PHP disagree on how to parse this example: Parsoid
22557 # insists that the content of a language converter element be a valid
22558 # DOM fragment or attribute string
22559 !! test
22560 Language converter markup with block content
22561 !! options
22562 language=zh variant=zh-cn
22563 !! wikitext
22564 <span>a-{b<div>c}-d
22565
22566 <span>a-{zh;zh-hans;zh-hant|b<div>c}-d
22567
22568 <span>a-{H|0=>zh-cn:x<span>y;0=>zh-tw:b<div>c}-d
22569 !! html/php+tidy
22570 <span>ab<div>cd
22571 <span>ab<div>cd
22572 <span>ad
22573 </span></div></span></div></span>
22574 !! html/parsoid
22575 <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>
22576
22577 <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>
22578
22579 <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>
22580 !! end
22581
22582 !! test
22583 LanguageConverter selser (1)
22584 !! options
22585 language=zh variant=zh-cn
22586 parsoid={
22587 "modes": ["wt2wt", "selser"],
22588 "changes": [
22589 ["span[typeof]", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
22590 ]
22591 }
22592 !! wikitext
22593 -{raw}-
22594 !! wikitext/edited
22595 -{edited}-
22596 !! end
22597
22598 !! test
22599 LanguageConverter selser (2)
22600 !! options
22601 language=zh variant=zh-cn
22602 parsoid={
22603 "modes": ["wt2wt", "selser"],
22604 "changes": [
22605 ["span[class='x']", "contents", "text", "-{foo}-"],
22606 ["a", "contents", "text", "-{"],
22607 ["span[typeof]", "attr", "data-mw", "{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"-{\"}},\"i\":0}}]}"]
22608 ]
22609 }
22610 !! wikitext
22611 <span class="x">TEXT1</span>
22612 [http://example.com TEXT2]
22613 [[Foo|TEXT3]]
22614 {{echo|TEXT4}}
22615 !! wikitext/edited
22616 <span class="x"><nowiki>-{foo}-</nowiki></span>
22617 [http://example.com -{]
22618 [[Foo|<nowiki>-{</nowiki>]]
22619 {{1x|<nowiki>-{</nowiki>}}
22620 !! end
22621
22622 # Tests LanguageVariantText in ConstrainedText
22623 !! test
22624 LanguageConverter selser (3)
22625 !! options
22626 language=zh variant=zh-cn
22627 parsoid={
22628 "modes": ["wt2wt", "selser"],
22629 "changes": [
22630 ["td > span", "attr", "typeof", "mw:LanguageVariant"],
22631 ["td > span", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
22632 ]
22633 }
22634 !! wikitext
22635 {|
22636 |-
22637 |<span>Foo</span>
22638 |}
22639 !! wikitext/edited
22640 {|
22641 |-
22642 |<nowiki/>-{edited}-
22643 |}
22644 !! end
22645
22646 # Tests LanguageVariantText._fromSelSer
22647 !! test
22648 LanguageConverter selser (4)
22649 !! options
22650 language=zh variant=zh-cn
22651 parsoid={
22652 "modes": ["wt2wt", "selser"],
22653 "changes": [
22654 ["td > span.x", "remove"]
22655 ]
22656 }
22657 !! wikitext
22658 {|
22659 |-
22660 |<span class="x">Foo</span>-{Bar}-
22661 ||<span class="x">Foo</span>-{Bar}-
22662 |}
22663 !! wikitext/edited
22664 {|
22665 |-
22666 |<nowiki/>-{Bar}-
22667 ||-{Bar}-
22668 |}
22669 !! end
22670
22671 # Since Parsoid is starting to emit canonical wikitext for links,
22672 # [http://example.com http://example.com] will not RT back to that
22673 # form anymore.
22674 # Parsoid does not language-convert links (it is done in a
22675 # post-processing step)
22676 !! test
22677 Proper conversion of text in external links
22678 !! options
22679 language=sr variant=sr-ec
22680 parsoid=wt2html
22681 !! wikitext
22682 http://www.google.com
22683 gopher://www.google.com
22684 [http://www.google.com http://www.google.com]
22685 [gopher://www.google.com gopher://www.google.com]
22686 [https://www.google.com irc://www.google.com]
22687 [ftp://www.google.com www.google.com/ftp://dir]
22688 [//www.google.com www.google.com]
22689 !! html/php
22690 <p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
22691 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
22692 <a rel="nofollow" class="external text" href="http://www.google.com">http://www.google.com</a>
22693 <a rel="nofollow" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
22694 <a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
22695 <a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
22696 <a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
22697 </p>
22698 !! html/parsoid
22699 <p><a rel="mw:ExtLink" class="external free" href="http://www.google.com">http://www.google.com</a>
22700 <a rel="mw:ExtLink" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
22701 <a rel="mw:ExtLink" class="external free" href="http://www.google.com">http://www.google.com</a>
22702 <a rel="mw:ExtLink" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
22703 <a rel="mw:ExtLink" class="external text" href="https://www.google.com">irc://www.google.com</a>
22704 <a rel="mw:ExtLink" class="external text" href="ftp://www.google.com">www.google.com/ftp://dir</a>
22705 <a rel="mw:ExtLink" class="external text" href="//www.google.com">www.google.com</a></p>
22706 !! end
22707
22708 !! test
22709 Do not convert roman numbers to language variants
22710 !! options
22711 language=sr variant=sr-ec
22712 !! wikitext
22713 Fridrih IV je car.
22714 !! html/php
22715 <p>Фридрих IV је цар.
22716 </p>
22717 !! html/parsoid
22718 <p>Fridrih IV je car.</p>
22719 !! end
22720
22721 !! test
22722 Unclosed language converter markup "-{"
22723 !! options
22724 language=sr
22725 !! wikitext
22726 -{T|hello
22727 !! html
22728 <p>-{T|hello
22729 </p>
22730 !! end
22731
22732 !! test
22733 Don't convert raw rule "-{R|=&gt;}-" to "=>"
22734 !! options
22735 language=sr
22736 !! wikitext
22737 -{R|=&gt;}-
22738 !! html/php
22739 <p>=&gt;
22740 </p>
22741 !! html/parsoid
22742 <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>
22743 !!end
22744
22745 !! test
22746 Don't break link parsing if language converter markup is in the caption.
22747 !! options
22748 language=sr variant=sr-ec
22749 !! wikitext
22750 [[Main Page|-{R|main page}-]]
22751 !! html/php
22752 <p><a href="/wiki/Main_Page" title="Маин Паге">main page</a>
22753 </p>
22754 !! html/parsoid
22755 <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>
22756 !! end
22757
22758 !! test
22759 T146304: Don't break template parsing if language converter markup is in the parameter.
22760 !! options
22761 language=sr variant=sr-ec
22762 !! wikitext
22763 {{echo|-{R|foo}-}}
22764 !! html/php
22765 <p>foo
22766 </p>
22767 !! html/parsoid
22768 <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>
22769 !! end
22770
22771 !! test
22772 T146305: Don't break image parsing if language converter markup is in the caption.
22773 !! options
22774 language=sr
22775 !! wikitext
22776 [[Датотека:Foobar.jpg|thumb|-{R|caption:}-]]
22777 !! html/php
22778 <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>
22779
22780 !! html/parsoid
22781 <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>
22782 !! end
22783
22784 !! test
22785 T146305: Don't break image parsing if nested language converter markup is in the caption.
22786 !! options
22787 language=zh variant=zh-cn
22788 !! wikitext
22789 [[File:Foobar.jpg|thumb|-{|zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
22790 !! html/php
22791 <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>
22792
22793 !! html/parsoid
22794 <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>
22795 !! end
22796
22797 # XXX html2wt disabled because rich markup in alt is not preserved.
22798 !! test
22799 Don't break gallery if language converter markup is inside.
22800 !! options
22801 language=zh
22802 !! wikitext
22803 <gallery>
22804 File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-
22805 File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt
22806 </gallery>
22807 !! html/php
22808 <ul class="gallery mw-gallery-traditional">
22809 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
22810 <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>
22811 <div class="gallerytext">
22812 <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>
22813 </p>
22814 </div>
22815 </div></li>
22816 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
22817 <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>
22818 <div class="gallerytext">
22819 <p>This is a test template
22820 </p>
22821 </div>
22822 </div></li>
22823 </ul>
22824
22825 !! html/parsoid
22826 <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"}}'>
22827 <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>
22828 <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>
22829 </ul>
22830 !! end
22831
22832 !! test
22833 T153135: Don't break list handling if language converter markup is in the item.
22834 !! options
22835 language=zh variant=zh-cn
22836 !! wikitext
22837 ;-{zh-cn:AAA;zh-tw:BBB}-
22838 ;-{R|foo:bar}-
22839 !! html/php
22840 <dl><dt>AAA</dt>
22841 <dt>foo:bar</dt></dl>
22842
22843 !! html/parsoid
22844 <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>
22845 <dt data-parsoid='{"dsr":[25,39,1,0]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"foo:bar"}}'></span></dt>
22846 </dl>
22847 !! end
22848
22849 // Note that parsoid does not protect colons unless language converter
22850 // markup is properly nested, because it is a backtracking parser.
22851 !! test
22852 T153135: Unclosed markup in definition list (code coverage)
22853 !! options
22854 language=zh variant=zh-cn
22855 !! wikitext
22856 ;<b>foo:bar
22857 ;-{zh-cn:AAA
22858 !! html/php+tidy
22859 <dl><dt><b>foo:bar</b></dt><b>
22860 <dt>-{zh-cn:AAA</dt></b></dl><p><b>
22861 </b></p>
22862 !! html/parsoid
22863 <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}'>
22864 <dt data-parsoid='{"dsr":[12,20,1,0]}'>-{zh-cn</dt>
22865 <dd data-parsoid='{"stx":"row","dsr":[20,24,1,0]}'>AAA</dd>
22866 </b></dl>
22867 !! end
22868
22869 !! test
22870 T153135: Nested language converter markup in definition list (code coverage)
22871 !! options
22872 language=zh variant=zh-cn
22873 !! wikitext
22874 ;-{|zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
22875 !! html/php
22876 <dl><dt>AAA foo:bar bat:baz</dt>
22877 <dd>def</dd></dl>
22878
22879 !! html/parsoid
22880 <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>
22881 <dd data-parsoid='{"stx":"row","dsr":[49,53,1,0]}'>def</dd>
22882 </dl>
22883 !! end
22884
22885 # html2wt mode disabled due to <nowiki> insertion.
22886 !! test
22887 T153140: Don't break table handling if language converter markup is in the cell.
22888 !! options
22889 language=sr variant=sr-ec
22890 parsoid=wt2html,wt2wt,html2html
22891 !! wikitext
22892 {|
22893 |-
22894 | -{R|B}-
22895 |}
22896 !! html/php
22897 <table>
22898
22899 <tr>
22900 <td>B
22901 </td></tr></table>
22902
22903 !! html/parsoid
22904 <table>
22905 <tbody>
22906 <tr>
22907 <td><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"B"}}'></span></td>
22908 </tr>
22909 </tbody>
22910 </table>
22911 !! end
22912
22913 !! test
22914 Language converter tricky html2wt cases (1)
22915 !! options
22916 language=sr
22917 parsoid=html2wt,wt2wt
22918 !! html/parsoid
22919 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"}-"}}'></span></p>
22920 !! wikitext
22921 -{<nowiki>}-</nowiki>}-
22922 !! html/php
22923 <p>&#125;-
22924 </p>
22925 !! end
22926
22927 !! test
22928 Language converter tricky html2wt cases (2)
22929 !! options
22930 language=sr
22931 parsoid=html2wt,wt2wt
22932 !! html/parsoid
22933 <p>-{foo}-</p>
22934 !! wikitext
22935 <nowiki>-{foo}-</nowiki>
22936 !! html/php
22937 <p>-&#123;foo&#125;-
22938 </p>
22939 !! end
22940
22941 !! test
22942 Language converter tricky html2wt cases (3)
22943 !! options
22944 language=sr
22945 parsoid=html2wt,wt2wt
22946 !! html/parsoid
22947 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"|"}}'></span></p>
22948 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"R|raw"}}'></span></p>
22949 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"-{foo}-"}}'></span></p>
22950 !! wikitext
22951 -{R||}-
22952
22953 -{R|R|raw}-
22954
22955 -{<nowiki>-{foo}-</nowiki>}-
22956 !! html/php
22957 <p>|
22958 </p><p>R|raw
22959 </p><p>-&#123;foo&#125;-
22960 </p>
22961 !! end
22962
22963 !! test
22964 Language converter tricky html2wt cases (4)
22965 !! options
22966 language=sr
22967 parsoid=html2wt,wt2wt
22968 !! html/parsoid
22969 <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>
22970 !! wikitext
22971 -{R|{{echo|hey}}}-
22972 !! html/php
22973 <p>hey
22974 </p>
22975 !! end
22976
22977 # Note that the <nowiki> escaping added by parsoid for source text,
22978 # destination text, and language names only works on the PHP side
22979 # for *destination text*. (HTML entity escaping wouldn't work
22980 # any better.) This is probably a bug, at least for source texts.
22981 # (For language names PHP uses a precise regexp based on the languages
22982 # it currently knows have variants, which is fragile since this set
22983 # can grow/shrink over time.)
22984 !! test
22985 Language converter tricky html2wt cases (5)
22986 !! options
22987 language=zh variant=zh-cn
22988 !! html/parsoid
22989 <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>
22990 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"A","l":"bo:g;us","t":"B"}]}'/></p>
22991 <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>
22992 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"bo:g;us","t":"xyz"},{"l":"zh-cn","t":"abc"}]}'></span></p>
22993 <p>a:b=>c xyz</p>
22994 !! wikitext
22995 -{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
22996
22997 -{H|A=><nowiki>bo:g;us</nowiki>:B}-
22998
22999 -{A|zh-tw:xyz; zh-cn:<nowiki>0;zh-tw:bar</nowiki>}-
23000
23001 -{<nowiki>bo:g;us</nowiki>:xyz; zh-cn:abc}-
23002
23003 a:b=>c xyz
23004 !! html/php+disabled
23005 <p>foobat;xyz=&gt;zh-cn:abc
23006 </p><p>A
23007 </p><p>0;zh-tw:bar
23008 </p><p>abc
23009 </p><p>a:b=&gt;c 0;zh-tw:bar
23010 </p>
23011 !! end
23012
23013 !! test
23014 T179579: Nowiki and lc interaction
23015 !! options
23016 parsoid=wt2html
23017 language=sr
23018 !! wikitext
23019 -{</nowiki>123}-
23020
23021 -{123<nowiki>|</nowiki>456}-
23022 !! html/parsoid
23023 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&amp;lt;/nowiki>123"}}' data-parsoid='{"fl":[],"src":"-{&lt;/nowiki>123}-"}'></span></p>
23024
23025 <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>
23026 !! end
23027
23028 !! test
23029 T2529: Uncovered bullet
23030 !! wikitext
23031 *Foo {{bullet}}
23032 !! html
23033 <ul><li>Foo</li>
23034 <li>Bar</li></ul>
23035
23036 !! end
23037
23038 !! test
23039 T2529: Uncovered bullet in a deeply nested list
23040 !! wikitext
23041 *******Foo {{bullet}}
23042 !! html
23043 <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>
23044 <li>Bar</li></ul>
23045
23046 !! end
23047
23048 !! test
23049 T2529: Uncovered table already at line-start
23050 !! wikitext
23051 x
23052
23053 {{table}}
23054 y
23055 !! html
23056 <p>x
23057 </p>
23058 <table>
23059 <tr>
23060 <td>1</td>
23061 <td>2
23062 </td></tr>
23063 <tr>
23064 <td>3</td>
23065 <td>4
23066 </td></tr></table>
23067 <p>y
23068 </p>
23069 !! end
23070
23071 !! test
23072 T2529: Uncovered bullet in parser function result
23073 !! wikitext
23074 *Foo {{lc:{{bullet}} }}
23075 !! html
23076 <ul><li>Foo</li>
23077 <li>bar</li></ul>
23078
23079 !! end
23080
23081 !! test
23082 T7678: Double-parsed template argument
23083 !! wikitext
23084 {{lc:{{{1}}}|hello}}
23085 !! html
23086 <p>{{{1}}}
23087 </p>
23088 !! end
23089
23090 !! test
23091 T7678: Double-parsed template invocation
23092 !! wikitext
23093 {{lc:{{paramtest {{!}} param = hello }} }}
23094 !! html
23095 <p>{{paramtest | param = hello }}
23096 </p>
23097 !! end
23098
23099 !! test
23100 Case insensitivity of parser functions for non-ASCII characters (T10143)
23101 !! options
23102 language=cs
23103 title=[[Main Page]]
23104 !! wikitext
23105 {{PRVNÍVELKÉ:ěščř}}
23106 {{prvnívelké:ěščř}}
23107 {{PRVNÍMALÉ:ěščř}}
23108 {{prvnímalé:ěščř}}
23109 {{MALÁ:ěščř}}
23110 {{malá:ěščř}}
23111 {{VELKÁ:ěščř}}
23112 {{velká:ěščř}}
23113 !! html
23114 <p>Ěščř
23115 Ěščř
23116 ěščř
23117 ěščř
23118 ěščř
23119 ěščř
23120 ĚŠČŘ
23121 ĚŠČŘ
23122 </p>
23123 !! end
23124
23125 !! test
23126 Morwen/13: Unclosed link followed by heading
23127 !! wikitext
23128 [[link
23129 ==heading==
23130 !! html
23131 <p>[[link
23132 </p>
23133 <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>
23134
23135 !! end
23136
23137 !! test
23138 HHP2.1: Heuristics for headings in preprocessor parenthetical structures
23139 !! wikitext
23140 {{foo|
23141 =heading=
23142 !! html
23143 <p>{{foo|
23144 </p>
23145 <h1><span class="mw-headline" id="heading">heading</span></h1>
23146
23147 !! end
23148
23149 !! test
23150 HHP2.2: Heuristics for headings in preprocessor parenthetical structures
23151 !! wikitext
23152 {{foo|
23153 ==heading==
23154 !! html
23155 <p>{{foo|
23156 </p>
23157 <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>
23158
23159 !! end
23160
23161 !! test
23162 Tildes in comments
23163 !! options
23164 pst
23165 !! wikitext
23166 <!-- ~~~~ -->
23167 !! html/php
23168 <!-- ~~~~ -->
23169 !! end
23170
23171 !! test
23172 Paragraphs inside divs (no extra line breaks)
23173 !! wikitext
23174 <div>Line one
23175
23176 Line two</div>
23177 !! html
23178 <div>Line one
23179 Line two</div>
23180
23181 !! end
23182
23183 !! test
23184 Paragraphs inside divs (extra line break on open)
23185 !! wikitext
23186 <div>
23187 Line one
23188
23189 Line two</div>
23190 !! html
23191 <div>
23192 <p>Line one
23193 </p>
23194 Line two</div>
23195
23196 !! end
23197
23198 !! test
23199 Paragraphs inside divs (extra line break on close)
23200 !! wikitext
23201 <div>Line one
23202
23203 Line two
23204 </div>
23205 !! html
23206 <div>Line one
23207 <p>Line two
23208 </p>
23209 </div>
23210
23211 !! end
23212
23213 !! test
23214 Paragraphs inside divs (extra line break on open and close)
23215 !! wikitext
23216 <div>
23217 Line one
23218
23219 Line two
23220 </div>
23221 !! html
23222 <div>
23223 <p>Line one
23224 </p><p>Line two
23225 </p>
23226 </div>
23227
23228 !! end
23229
23230 # doBlockLevels screws up this output and Remex cleans up as much as it can.
23231 # Parsoid seems to do a better job here since its p-wrapper is probably smarter.
23232 !! test
23233 Nesting tags, paragraphs on lines which begin with <div>
23234 !! wikitext
23235 <div></div><strong>A
23236 B</strong>
23237 !! html/php+tidy
23238 <div></div><p><strong>A
23239 </strong></p><strong></strong><p><strong>B</strong>
23240 </p>
23241 !! html/parsoid
23242 <div></div>
23243 <p><strong>A
23244 B</strong>
23245 </p>
23246 !! end
23247
23248 # T8200: <blockquote> should behave like <div> with respect to line breaks
23249 !! test
23250 T8200: paragraphs inside blockquotes (no extra line breaks)
23251 !! wikitext
23252 <blockquote>Line one
23253
23254 Line two</blockquote>
23255 !! html
23256 <blockquote>Line one
23257 Line two</blockquote>
23258
23259 !! html+tidy
23260 <blockquote><p>Line one
23261 Line two</p></blockquote>
23262 !! end
23263
23264 !! test
23265 T8200: paragraphs inside blockquotes (extra line break on open)
23266 !! wikitext
23267 <blockquote>
23268 Line one
23269
23270 Line two</blockquote>
23271 !! html
23272 <blockquote>
23273 <p>Line one
23274 </p>
23275 Line two</blockquote>
23276
23277 !! html+tidy
23278 <blockquote>
23279 <p>Line one
23280 </p><p>
23281 Line two</p></blockquote>
23282 !! end
23283
23284 # Parsoid's output is broken on this because of Tidy-compatibility cruft
23285 !! test
23286 T8200: paragraphs inside blockquotes (extra line break on close)
23287 !! wikitext
23288 <blockquote>Line one
23289
23290 Line two
23291 </blockquote>
23292 !! html
23293 <blockquote>Line one
23294 <p>Line two
23295 </p>
23296 </blockquote>
23297
23298 !! html+tidy
23299 <blockquote><p>Line one
23300 </p><p>Line two
23301 </p>
23302 </blockquote>
23303 !! end
23304
23305 !! test
23306 T8200: paragraphs inside blockquotes (extra line break on open and close)
23307 !! wikitext
23308 <blockquote>
23309 Line one
23310
23311 Line two
23312 </blockquote>
23313 !! html
23314 <blockquote>
23315 <p>Line one
23316 </p><p>Line two
23317 </p>
23318 </blockquote>
23319
23320 !! end
23321
23322 # FIXME: Why does/should the blockquote+div combo suppress p-wrapping here?
23323 !! test
23324 Paragraphs inside blockquotes/divs (no extra line breaks)
23325 !! wikitext
23326 <blockquote><div>Line one
23327
23328 Line two</div></blockquote>
23329 !! html
23330 <blockquote><div>Line one
23331 Line two</div></blockquote>
23332
23333 !! end
23334
23335 !! test
23336 Paragraphs inside blockquotes/divs (extra line break on open)
23337 !! wikitext
23338 <blockquote><div>
23339 Line one
23340
23341 Line two</div></blockquote>
23342 !! html
23343 <blockquote><div>
23344 <p>Line one
23345 </p>
23346 Line two</div></blockquote>
23347
23348 !! end
23349
23350 !! test
23351 Paragraphs inside blockquotes/divs (extra line break on close)
23352 !! wikitext
23353 <blockquote><div>Line one
23354
23355 Line two
23356 </div></blockquote>
23357 !! html
23358 <blockquote><div>Line one
23359 <p>Line two
23360 </p>
23361 </div></blockquote>
23362
23363 !! end
23364
23365 !! test
23366 Paragraphs inside blockquotes/divs (extra line break on open and close)
23367 !! wikitext
23368 <blockquote><div>
23369 Line one
23370
23371 Line two
23372 </div></blockquote>
23373 !! html
23374 <blockquote><div>
23375 <p>Line one
23376 </p><p>Line two
23377 </p>
23378 </div></blockquote>
23379
23380 !! end
23381
23382 !! test
23383 Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion
23384 !! options
23385 wgLinkHolderBatchSize=0
23386 !! wikitext
23387 [[meatball:1]]
23388 [[meatball:2]]
23389 [[meatball:3]]
23390 !! html
23391 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?1" class="extiw" title="meatball:1">meatball:1</a>
23392 <a href="http://www.usemod.com/cgi-bin/mb.pl?2" class="extiw" title="meatball:2">meatball:2</a>
23393 <a href="http://www.usemod.com/cgi-bin/mb.pl?3" class="extiw" title="meatball:3">meatball:3</a>
23394 </p>
23395 !! end
23396
23397 !! test
23398 Free external link invading image caption
23399 !! wikitext
23400 [[Image:Foobar.jpg|thumb|http://x|hello]]
23401 !! html/php
23402 <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>
23403
23404 !! html/parsoid
23405 <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>
23406 !! end
23407
23408 !! test
23409 T17196: localised external link numbers
23410 !! options
23411 language=fa
23412 !! wikitext
23413 [http://en.wikipedia.org/]
23414 !! html/php
23415 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/">[۱]</a>
23416 </p>
23417 !! html/parsoid
23418 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/"></a></p>
23419 !! end
23420
23421 !! test
23422 Multibyte character in padleft
23423 !! wikitext
23424 {{padleft:-Hello|7|Æ}}
23425 !! html/php
23426 <p>Æ-Hello
23427 </p>
23428 !! html/parsoid
23429 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:-Hello","function":"padleft"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Æ-Hello</p>
23430 !! end
23431
23432 !! test
23433 Multibyte character in padright
23434 !! wikitext
23435 {{padright:Hello-|7|Æ}}
23436 !! html/php
23437 <p>Hello-Æ
23438 </p>
23439 !! html/parsoid
23440 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:Hello-","function":"padright"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Hello-Æ</p>
23441 !! end
23442
23443 !!test
23444 formatdate parser function
23445 !! wikitext
23446 {{#formatdate:2009-03-24}}
23447 !! html
23448 <p><span class="mw-formatted-date" title="2009-03-24">2009-03-24</span>
23449 </p>
23450 !! end
23451
23452 !!test
23453 formatdate parser function, with default format
23454 !! wikitext
23455 {{#formatdate:2009-03-24|mdy}}
23456 !! html
23457 <p><span class="mw-formatted-date" title="2009-03-24">March 24, 2009</span>
23458 </p>
23459 !! end
23460
23461 !! test
23462 Spacing of numbers in formatted dates
23463 !! wikitext
23464 {{#formatdate:January 15}}
23465 !! html
23466 <p><span class="mw-formatted-date" title="01-15">January 15</span>
23467 </p>
23468 !! end
23469
23470 !! test
23471 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
23472 !! options
23473 language=nl title=[[MediaWiki:Common.css]]
23474 !! wikitext
23475 {{#formatdate:2009-03-24|dmy}}
23476 !! html
23477 <p><span class="mw-formatted-date" title="2009-03-24">24 March 2009</span>
23478 </p>
23479 !! end
23480
23481 #
23482 #
23483 #
23484
23485 #
23486 # Edit comments
23487 #
23488
23489 !! test
23490 Edit comment with link
23491 !! options
23492 comment
23493 !! wikitext
23494 I like the [[Main Page]] a lot
23495 !! html/php
23496 I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot
23497 !!end
23498
23499 !! test
23500 Edit comment with link and link text
23501 !! options
23502 comment
23503 !! wikitext
23504 I like the [[Main Page|best pages]] a lot
23505 !! html/php
23506 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
23507 !!end
23508
23509 !! test
23510 Edit comment with link and link text with suffix
23511 !! options
23512 comment
23513 !! wikitext
23514 I like the [[Main Page|best page]]s a lot
23515 !! html/php
23516 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
23517 !!end
23518
23519 !! test
23520 Edit comment with section link (non-local, eg in history list)
23521 !! options
23522 comment title=[[Main Page]]
23523 !! wikitext
23524 /* External links */ removed bogus entries
23525 !! html/php
23526 <a href="/wiki/Main_Page#External_links" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
23527 !!end
23528
23529 !! test
23530 Edit comment with section link and text before it (non-local, eg in history list)
23531 !! options
23532 comment title=[[Main Page]]
23533 !! wikitext
23534 pre-comment text /* External links */ removed bogus entries
23535 !! html/php
23536 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>
23537 !!end
23538
23539 !! test
23540 Edit comment with section link (local, eg in diff view)
23541 !! options
23542 comment local title=[[Main Page]]
23543 !! wikitext
23544 /* External links */ removed bogus entries
23545 !! html/php
23546 <a href="#External_links">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
23547 !!end
23548
23549 !! test
23550 Edit comment with subpage link (T16080)
23551 !! options
23552 comment
23553 subpage
23554 title=[[Subpage test]]
23555 !! wikitext
23556 Poked at a [[/subpage]] here...
23557 !! html/php
23558 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> here...
23559 !!end
23560
23561 !! test
23562 Edit comment with subpage link and link text (T16080)
23563 !! options
23564 comment
23565 subpage
23566 title=[[Subpage test]]
23567 !! wikitext
23568 Poked at a [[/subpage|neat little page]] here...
23569 !! html/php
23570 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">neat little page</a> here...
23571 !!end
23572
23573 !! test
23574 Edit comment with bogus subpage link in non-subpage NS (T16080)
23575 !! options
23576 comment
23577 title=[[Subpage test]]
23578 !! wikitext
23579 Poked at a [[/subpage]] here...
23580 !! html/php
23581 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...
23582 !!end
23583
23584 !! test
23585 Edit comment with bare anchor link (local, as on diff)
23586 !! options
23587 comment
23588 local
23589 title=[[Main Page]]
23590 !! wikitext
23591 [[#section]]
23592 !! html/php
23593 <a href="#section">#section</a>
23594 !! end
23595
23596 !! test
23597 Edit comment with bare anchor link (non-local, as on history)
23598 !! options
23599 comment
23600 title=[[Main Page]]
23601 !! wikitext
23602 [[#section]]
23603 !! html/php
23604 <a href="/wiki/Main_Page#section" title="Main Page">#section</a>
23605 !! end
23606
23607 !! test
23608 Anchor starting with underscore
23609 !! options
23610 title=[[Foo]]
23611 !! wikitext
23612 [[#_ref|One]]
23613 !! html/php
23614 <p><a href="#_ref">One</a>
23615 </p>
23616 !! html/parsoid
23617 <p><a rel="mw:WikiLink" href="./Foo#_ref" data-parsoid='{"stx":"piped","a":{"href":"./Foo#_ref"},"sa":{"href":"#_ref"}}'>One</a></p>
23618 !! end
23619
23620 !! test
23621 Id starting with underscore
23622 !! wikitext
23623 <div id="_ref"></div>
23624 !! html/*
23625 <div id="_ref"></div>
23626
23627 !! end
23628
23629 !! test
23630 Edit comment with link with more than one pipe (T99346)
23631 !! options
23632 comment
23633 !! wikitext
23634 [[Main Page|Many|pipes]]
23635 !! html/php
23636 <a href="/wiki/Main_Page" title="Main Page">Many|pipes</a>
23637 !! end
23638
23639 !! test
23640 Complex edit comment with link with more than one pipe (T99346)
23641 !! options
23642 comment
23643 !! wikitext
23644 Created page with "<noinclude>[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]]</noinclude> === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..."
23645 !! html/php
23646 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;
23647 !! end
23648
23649 !! test
23650 Space normalisation on autocomment (T24784)
23651 !! options
23652 comment
23653 title=[[Main Page]]
23654 !! wikitext
23655 /* __hello__world__ */
23656 !! html/php
23657 <a href="/wiki/Main_Page#hello_world" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">__hello__world__</span></span>
23658 !! end
23659
23660 !! test
23661 percent-encoding and + signs in comments (T28410)
23662 !! options
23663 comment
23664 !! wikitext
23665 [[ABC%33D% ++]] [[ABC%33D% ++|+%20]]
23666 !! html/php
23667 <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>
23668 !! end
23669
23670 # Parsoid doesn't support this yet: see T75581
23671 # but it *should* omit the 'src' attribute if the image is bad.
23672 # PHP side of tests was disabled in
23673 # mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
23674 # because of issues in the PHP parserTests infrastructure
23675 # (but the output below is indeed what the PHP side emits)
23676 !! test
23677 Bad images - basic functionality
23678 !! wikitext
23679 [[File:Bad.jpg]]
23680 !! html/php+disabled
23681 !! html/parsoid
23682 <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>
23683 !! end
23684
23685 !! test
23686 Bad images - T18039: text after bad image disappears
23687 !! wikitext
23688 Foo bar
23689 [[File:Bad.jpg]]
23690 Bar foo
23691 !! html/php+disabled
23692 <p>Foo bar
23693 </p><p>Bar foo
23694 </p>
23695 !! html/parsoid
23696 <p>Foo bar
23697 <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>
23698 Bar foo</p>
23699 !! end
23700
23701 !! test
23702 Verify that displaytitle works (T24501) no displaytitle
23703 !! options
23704 showtitle
23705 !! config
23706 wgAllowDisplayTitle=true
23707 wgRestrictDisplayTitle=false
23708 !! wikitext
23709 this is not the the title
23710 !! html/php
23711 Parser test
23712 <p>this is not the the title
23713 </p>
23714 !! end
23715
23716 !! test
23717 Verify that displaytitle works (T24501) RestrictDisplayTitle=false
23718 !! options
23719 showtitle
23720 title=[[Screen]]
23721 !! config
23722 wgAllowDisplayTitle=true
23723 wgRestrictDisplayTitle=false
23724 !! wikitext
23725 this is not the the title
23726 {{DISPLAYTITLE:whatever}}
23727 !! html/php
23728 whatever
23729 <p>this is not the the title
23730 </p>
23731 !! end
23732
23733 !! test
23734 Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch
23735 !! options
23736 showtitle
23737 title=[[Screen]]
23738 !! config
23739 wgAllowDisplayTitle=true
23740 wgRestrictDisplayTitle=true
23741 !! wikitext
23742 this is not the the title
23743 {{DISPLAYTITLE:whatever}}
23744 !! html/php
23745 Screen
23746 <p>this is not the the title
23747 </p>
23748 !! end
23749
23750 !! test
23751 Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching
23752 !! options
23753 showtitle
23754 title=[[Screen]]
23755 !! config
23756 wgAllowDisplayTitle=true
23757 wgRestrictDisplayTitle=true
23758 !! wikitext
23759 this is not the the title
23760 {{DISPLAYTITLE:screen}}
23761 !! html/php
23762 screen
23763 <p>this is not the the title
23764 </p>
23765 !! end
23766
23767 !! test
23768 Verify that displaytitle works (T24501) AllowDisplayTitle=false
23769 !! options
23770 showtitle
23771 title=[[Screen]]
23772 !! config
23773 wgAllowDisplayTitle=false
23774 !! wikitext
23775 this is not the the title
23776 {{DISPLAYTITLE:screen}}
23777 !! html/php
23778 Screen
23779 <p>this is not the the title
23780 <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>
23781 </p>
23782 !! end
23783
23784 !! test
23785 Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE
23786 !! options
23787 showtitle
23788 title=[[Screen]]
23789 !! config
23790 wgAllowDisplayTitle=false
23791 !! wikitext
23792 this is not the the title
23793 !! html/php
23794 Screen
23795 <p>this is not the the title
23796 </p>
23797 !! end
23798
23799 !! test
23800 Verify that displaytitle handles inline CSS styles (T28547) - rejected value
23801 !! options
23802 showtitle
23803 title=[[Screen]]
23804 !! config
23805 wgAllowDisplayTitle=true
23806 wgRestrictDisplayTitle=true
23807 !! wikitext
23808 this is not the the title
23809 {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
23810 !! html/php
23811 <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
23812 <p>this is not the the title
23813 </p>
23814 !! end
23815
23816 !! test
23817 Verify that displaytitle handles inline CSS styles (T28547) - accepted value
23818 !! options
23819 showtitle
23820 title=[[Screen]]
23821 !! config
23822 wgAllowDisplayTitle=true
23823 wgRestrictDisplayTitle=true
23824 !! wikitext
23825 this is not the the title
23826 {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
23827 !! html/php
23828 <span style="color: red;">s</span>creen
23829 <p>this is not the the title
23830 </p>
23831 !! end
23832
23833 !! test
23834 Page status indicators: Empty name is invalid
23835 !! options
23836 showindicators
23837 !! wikitext
23838 <indicator name=" "></indicator>
23839 <indicator></indicator>
23840 !! html/php
23841 <p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
23842 <span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
23843 </p>
23844 !! end
23845
23846 !! test
23847 Page status indicators: Weird syntaxes that are okay
23848 !! options
23849 showindicators
23850 !! wikitext
23851 <indicator name="empty" />
23852 <indicator name="name"></indicator>
23853 !! html/php
23854 empty=
23855 name=
23856 <p><br />
23857 </p>
23858 !! end
23859
23860 !! test
23861 Page status indicators: Torture test
23862 !! options
23863 showindicators
23864 !! wikitext
23865 <indicator name="01">hello world</indicator>
23866 <indicator name="02">[[Main Page]]</indicator>
23867 <indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator>
23868 <indicator name="04">[[File:Foobar.jpg|25px]]</indicator>
23869 <indicator name="05">*foo
23870 *bar</indicator>
23871 <indicator name="06"><nowiki>foo</nowiki></indicator>
23872 <indicator name="07"> Preformatted</indicator>
23873 <indicator name="08"><div>Broken tag</indicator>
23874 <indicator name="09">{| class=wikitable
23875 |cell
23876 |}</indicator>
23877 <indicator name="10">Two
23878
23879 paragraphs</indicator>
23880 !! html/php
23881 01=hello world
23882 02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
23883 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" />
23884 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>
23885 05=<ul><li>foo</li>
23886 <li>bar</li></ul>
23887
23888 06=foo
23889 07=<pre>Preformatted
23890 </pre>
23891 08=<div>Broken tag</div>
23892
23893 09=<table class="wikitable">
23894 <tr>
23895 <td>cell
23896 </td></tr></table>
23897
23898 10=<p>Two
23899 </p><p>paragraphs
23900 </p>
23901 <p><br />
23902 </p><p><br />
23903 </p><p><br />
23904 </p><p><br />
23905 </p><p><br />
23906 </p>
23907 !! end
23908
23909 !! test
23910 preload: check <noinclude> and <includeonly>
23911 !! options
23912 preload
23913 !! wikitext
23914 Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
23915 !! html/php
23916 Hello kind world.
23917 !! end
23918
23919 !! test
23920 preload: check <onlyinclude>
23921 !! options
23922 preload
23923 !! wikitext
23924 Goodbye <onlyinclude>Hello world</onlyinclude>
23925 !! html/php
23926 Hello world
23927 !! end
23928
23929 !! test
23930 preload: can pass tags through if we want to
23931 !! options
23932 preload
23933 !! wikitext
23934 <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
23935 !! html/php
23936 <includeonly>Hello world</includeonly>
23937 !! end
23938
23939 !! test
23940 preload: check that it doesn't try to do tricks
23941 !! options
23942 preload
23943 !! wikitext
23944 * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
23945 !! html/php
23946 * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
23947 !! end
23948
23949 !! test
23950 Play a bit with r67090 and T5158
23951 !! wikitext
23952 <div style="width:50% !important">&nbsp;</div>
23953 <div style="width:50%&nbsp;!important">&nbsp;</div>
23954 <div style="width:50%&#160;!important">&nbsp;</div>
23955 <div style="border : solid;">&nbsp;</div>
23956 !! html/php
23957 <div style="width:50% !important">&#160;</div>
23958 <div style="width:50% !important">&#160;</div>
23959 <div style="width:50% !important">&#160;</div>
23960 <div style="border&#160;: solid;">&#160;</div>
23961
23962 !! html/parsoid
23963 <div style="width:50% !important" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
23964 <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>
23965 <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>
23966 <div style="border : solid;" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
23967
23968 !! end
23969
23970 !! test
23971 HTML5 data attributes
23972 !! wikitext
23973 <span data-foo="bar">Baz</span>
23974 <p data-abc-def_hij="">Quuz</p>
23975 !! html/php
23976 <p><span data-foo="bar">Baz</span>
23977 </p>
23978 <p data-abc-def_hij="">Quuz</p>
23979
23980 !! html/parsoid
23981 <p><span data-foo="bar" data-parsoid='{"stx":"html"}'>Baz</span></p>
23982 <p data-abc-def_hij="" data-parsoid='{"stx":"html"}'>Quuz</p>
23983 !! end
23984
23985 !! test
23986 Strip reserved data attributes
23987 !! wikitext
23988 <div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
23989 !! html/php
23990 <div data-ok="fred">d</div>
23991
23992 !! html/parsoid
23993 <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>
23994 !! end
23995
23996 !! test
23997 percent-encoding and + signs in internal links (T28410)
23998 !! wikitext
23999 [[User:+%]] [[Page+title%]]
24000 [[%+]] [[%+|%20]] [[%+ ]] [[%+r]]
24001 [[%]] [[+]] [[File:%+abc%39|foo|[[bar]]]]
24002 [[%33%45]] [[%33%45+]]
24003 !! html/php
24004 <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>
24005 <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>
24006 <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>
24007 <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>
24008 </p>
24009 !! html/parsoid
24010 <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>
24011 <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>
24012 <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>
24013 <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>
24014 !! end
24015
24016 !! test
24017 Special characters in embedded file links (T29679)
24018 !! wikitext
24019 [[File:Contains & ampersand.jpg]]
24020 [[File:Does not exist.jpg|Title with & ampersand]]
24021 !! html/php
24022 <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>
24023 <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>
24024 </p>
24025 !! html/parsoid
24026 <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>
24027 <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>
24028 !! end
24029
24030 !! test
24031 Confirm that 'apos' named character reference doesn't make it to output (not legal in HTML 4)
24032 !! wikitext
24033 Text&apos;s been normalized?
24034 !! html
24035 <p>Text&#39;s been normalized?
24036 </p>
24037 !! end
24038
24039 !! test
24040 T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
24041 !! wikitext
24042 http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
24043 !! html
24044 <p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> &lt;-- U+3000 (vim: ^Vu3000)
24045 </p>
24046 !! end
24047
24048 !! test
24049 T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
24050 !! wikitext
24051 [http://www.example.org/ ideograms]
24052 !! html
24053 <p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a>
24054 </p>
24055 !! end
24056
24057 !! test
24058 T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
24059 !! wikitext
24060 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
24061 !! html
24062 <p><img src="http://www.example.org/pic.png" alt="pic.png"/> &lt;-- U+3000 (vim: ^Vu3000)
24063 </p>
24064 !! end
24065
24066 !! article
24067 Mediawiki:loop1
24068 !! text
24069 {{Identical|A}}
24070 !! endarticle
24071
24072 !! article
24073 Mediawiki:loop2
24074 !! text
24075 {{Identical|B}}
24076 !! endarticle
24077
24078 !! article
24079 Template:Identical
24080 !! text
24081 {{int:loop1}}
24082 {{int:loop2}}
24083 !! endarticle
24084
24085 !! test
24086 T33098 Template which includes system messages which includes the template
24087 !! wikitext
24088 {{Identical}}
24089 !! html
24090 <p><span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
24091 <span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
24092 </p>
24093 !! end
24094
24095 !! test
24096 T33490 Turkish: ucfirst 'blah'
24097 !! options
24098 language=tr
24099 !! wikitext
24100 {{ucfirst:blah}}
24101 !! html
24102 <p>Blah
24103 </p>
24104 !! end
24105
24106 !! test
24107 T33490 Turkish: ucfirst 'ix'
24108 !! options
24109 language=tr
24110 !! wikitext
24111 {{ucfirst:ix}}
24112 !! html
24113 <p>İx
24114 </p>
24115 !! end
24116
24117 !! test
24118 T33490 Turkish: lcfirst 'BLAH'
24119 !! options
24120 language=tr
24121 !! wikitext
24122 {{lcfirst:BLAH}}
24123 !! html
24124 <p>bLAH
24125 </p>
24126 !! end
24127
24128 !! test
24129 T33490 Turkish: ucfırst (with a dotless i)
24130 !! options
24131 language=tr
24132 !! wikitext
24133 {{ucfırst:blah}}
24134 !! html
24135 <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>
24136 </p>
24137 !! end
24138
24139 !! test
24140 T33490 ucfırst (with a dotless i) with English language
24141 !! options
24142 language=en
24143 !! wikitext
24144 {{ucfırst:blah}}
24145 !! html
24146 <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>
24147 </p>
24148 !! end
24149
24150 # Note that Parsoid doesn't emit an explicit TOC.
24151 # Note also that the html2wt direction tends to emit an extra newline
24152 # between the __TOC__ magicword and the first heading unless *both*
24153 # the <meta> and the <h2> have a data-parsoid attribute set (even if
24154 # it's "{}").
24155
24156 !! test
24157 T28375: TOC with italics
24158 !! options
24159 title=[[Main Page]]
24160 !! wikitext
24161 __TOC__
24162 ==''Lost'' episodes==
24163 !! html/php
24164 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24165 <ul>
24166 <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>
24167 </ul>
24168 </div>
24169
24170 <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>
24171
24172 !! html/parsoid
24173 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24174 <h2 id="Lost_episodes" data-parsoid='{}'><i>Lost</i> episodes</h2>
24175 !! end
24176
24177 !! test
24178 T28375: TOC with bold
24179 !! options
24180 title=[[Main Page]]
24181 !! wikitext
24182 __TOC__
24183 =='''should be bold''' then normal text==
24184 !! html/php
24185 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24186 <ul>
24187 <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>
24188 </ul>
24189 </div>
24190
24191 <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>
24192
24193 !! html/parsoid
24194 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24195 <h2 id="should_be_bold_then_normal_text" data-parsoid='{}'><b>should be bold</b> then normal text</h2>
24196 !! end
24197
24198 !! test
24199 T35845: Headings become cursive in TOC when they contain an image
24200 !! options
24201 title=[[Main Page]]
24202 !! wikitext
24203 __TOC__
24204 ==Image [[Image:foobar.jpg]]==
24205 !! html/php
24206 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24207 <ul>
24208 <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
24209 </ul>
24210 </div>
24211
24212 <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>
24213
24214 !! html/parsoid
24215 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24216 <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>
24217 !! end
24218
24219 !! test
24220 T35845 (2): Headings become bold in TOC when they contain a blockquote
24221 !! options
24222 title=[[Main Page]]
24223 !! wikitext
24224 __TOC__
24225 ==<blockquote>Quote</blockquote>==
24226 !! html/php
24227 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24228 <ul>
24229 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
24230 </ul>
24231 </div>
24232
24233 <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>
24234
24235 !! html/php+tidy
24236 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24237 <ul>
24238 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
24239 </ul>
24240 </div>
24241
24242 <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>
24243 !! html/parsoid
24244 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24245 <h2 id="Quote" data-parsoid='{}'><blockquote>Quote</blockquote></h2>
24246 !! end
24247
24248 !! test
24249 Unclosed tags in TOC
24250 !! config
24251 wgFragmentMode=[ 'html5', 'legacy' ]
24252 !! options
24253 title=[[Main Page]]
24254 !! wikitext
24255 __TOC__
24256 ==Proof: 2 < 3==
24257 <small>Hanc marginis exiguitas non caperet.</small>
24258 QED
24259 !! html/php
24260 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24261 <ul>
24262 <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>
24263 </ul>
24264 </div>
24265
24266 <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>
24267 <p><small>Hanc marginis exiguitas non caperet.</small>
24268 QED
24269 </p>
24270 !! html/parsoid
24271 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24272 <h2 id="Proof:_2_&lt;_3" data-parsoid='{}'><span id="Proof:_2_.3C_3" typeof="mw:FallbackId"></span>Proof: 2 &lt; 3</h2>
24273 <p><small>Hanc marginis exiguitas non caperet.</small>
24274 QED</p>
24275 !! end
24276
24277 !! test
24278 Multiple tags in TOC
24279 !! wikitext
24280 __TOC__
24281 ==<i>Foo</i> <b>Bar</b>==
24282
24283 ==<i>Foo</i> <blockquote>Bar</blockquote>==
24284 !! html/php
24285 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24286 <ul>
24287 <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>
24288 <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>
24289 </ul>
24290 </div>
24291
24292 <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>
24293 <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>
24294
24295 !! html/php+tidy
24296 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24297 <ul>
24298 <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>
24299 <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>
24300 </ul>
24301 </div>
24302
24303 <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>
24304 <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>
24305 !! html/parsoid
24306 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24307 <h2 id="Foo_Bar" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b></h2>
24308
24309 <h2 id="Foo_Bar_2" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote>Bar</blockquote></h2>
24310 !! end
24311
24312 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
24313 # html5 tag parsing.
24314 !! test
24315 Tags with parameters in TOC
24316 !! options
24317 parsoid=wt2html
24318 !! wikitext
24319 __TOC__
24320 ==<sup class="in-h2">Hello</sup>==
24321
24322 ==<sup class="a > b">Evilbye</sup>==
24323 !! html/php
24324 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24325 <ul>
24326 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
24327 <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>
24328 </ul>
24329 </div>
24330
24331 <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>
24332 <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>
24333
24334 !! html/parsoid
24335 <meta property="mw:PageProp/toc" />
24336 <h2 id="Hello"><sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup></h2>
24337
24338 <h2 id='b">Evilbye'><span id="b.22.3EEvilbye" typeof="mw:FallbackId"></span><sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup></h2>
24339 !! end
24340
24341 !! test
24342 span tags with directionality in TOC
24343 !! wikitext
24344 __TOC__
24345 ==<span dir="ltr">C++</span>==
24346
24347 ==<span dir="rtl">זבנג!</span>==
24348
24349 ==<span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span>==
24350
24351 ==<span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span>==
24352
24353 ==<span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span>==
24354 !! html/php
24355 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24356 <ul>
24357 <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>
24358 <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>
24359 <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>
24360 <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>
24361 <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>
24362 </ul>
24363 </div>
24364
24365 <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>
24366 <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>
24367 <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>
24368 <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>
24369 <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>
24370
24371 !! html/parsoid
24372 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24373 <h2 id="C++" data-parsoid='{}'><span id="C.2B.2B" typeof="mw:FallbackId"></span><span dir="ltr">C++</span></h2>
24374 <h2 id="זבנג!"><span id=".D7.96.D7.91.D7.A0.D7.92.21" typeof="mw:FallbackId"></span><span dir="rtl">זבנג!</span></h2>
24375 <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>
24376 <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>
24377 <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>
24378 !! end
24379
24380 !! test
24381 T74884: bdi element in ToC
24382 !! wikitext
24383 __TOC__
24384 ==<bdi>test</bdi>==
24385 !! html/php
24386 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24387 <ul>
24388 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
24389 </ul>
24390 </div>
24391
24392 <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>
24393
24394 !! html/parsoid
24395 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24396 <h2 id="test" data-parsoid='{}'><bdi>test</bdi></h2>
24397 !! end
24398
24399 !! test
24400 T35715: s/strike element in ToC
24401 !! wikitext
24402 __TOC__
24403 ==<s>test</s> test <strike>test</strike>==
24404 !! html/php
24405 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24406 <ul>
24407 <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>
24408 </ul>
24409 </div>
24410
24411 <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>
24412
24413 !! html/parsoid
24414 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24415 <h2 id="test_test_test" data-parsoid='{}'><s>test</s> test <strike>test</strike></h2>
24416 !! end
24417
24418 !! test
24419 Empty <p> tag in TOC, removed by Sanitizer (T92892)
24420 !! wikitext
24421 __TOC__
24422 ==x==
24423 !! html/php
24424 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24425 <ul>
24426 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
24427 </ul>
24428 </div>
24429
24430 <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>
24431
24432 !! html/parsoid
24433 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24434 <h2 id="x" data-parsoid='{}'>x</h2>
24435 !! end
24436
24437 !! article
24438 MediaWiki:T34057
24439 !! text
24440 == {{int:headline_sample}} ==
24441 !! endarticle
24442
24443 !! test
24444 T34057: Title needed when expanding <h> nodes.
24445 !! options
24446 title=[[Main Page]]
24447 !! wikitext
24448 {{int:T34057}}
24449 !! html
24450 <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>
24451
24452 !! end
24453
24454 !! test
24455 Strip marker in urlencode
24456 !! wikitext
24457 {{urlencode:x<nowiki/>y}}
24458 {{urlencode:x<nowiki/>y|wiki}}
24459 {{urlencode:x<nowiki/>y|path}}
24460 {{urlencode:x<pre id="one">two</pre>y}}
24461 !! html/php
24462 <p>xy
24463 xy
24464 xy
24465 xy
24466 </p>
24467 !! end
24468
24469 !! test
24470 Strip marker in lc
24471 !! wikitext
24472 {{lc:x<nowiki/>y}}
24473 !! html
24474 <p>xy
24475 </p>
24476 !! end
24477
24478 !! test
24479 Strip marker in uc
24480 !! wikitext
24481 {{uc:x<nowiki/>y}}
24482 !! html
24483 <p>XY
24484 </p>
24485 !! end
24486
24487 !! test
24488 Strip marker in formatNum
24489 !! wikitext
24490 {{formatnum:1<nowiki/>2}}
24491 {{formatnum:1<nowiki/>2|R}}
24492 !! html
24493 <p>12
24494 12
24495 </p>
24496 !! end
24497
24498 !! test
24499 Check noCommafy in formatNum
24500 !! options
24501 language=be-tarask
24502 !! wikitext
24503 {{formatnum:123456.78}}
24504 {{formatnum:123456.78|NOSEP}}
24505 !! html
24506 <p>123 456,78
24507 123456.78
24508 </p>
24509 !! end
24510
24511 !! test
24512 Wrong option for formatNum (T58199)
24513 !! wikitext
24514 {{formatnum:1,234.56|Random}}
24515 {{formatnum:1,234.56|EVERYTHING}}
24516 {{formatnum:1234.56|any argument that has the string 'NOSEP'}}
24517 !! html
24518 <p>1,234.56
24519 1,234.56
24520 1,234.56
24521 </p>
24522 !! end
24523
24524 !! test
24525 Strip marker in grammar
24526 !! options
24527 language=fi
24528 !! wikitext
24529 {{grammar:elative|foo<nowiki/>bar}}
24530 !! html
24531 <p>foobarista
24532 </p>
24533 !! end
24534
24535 !! test
24536 Strip marker in padleft
24537 !! wikitext
24538 {{padleft:|2|x<nowiki/>y}}
24539 !! html
24540 <p>xy
24541 </p>
24542 !! end
24543
24544 !! test
24545 Strip marker in padright
24546 !! wikitext
24547 {{padright:|2|x<nowiki/>y}}
24548 !! html
24549 <p>xy
24550 </p>
24551 !! end
24552
24553 !! test
24554 Strip marker in anchorencode
24555 !! wikitext
24556 {{anchorencode:x<nowiki/>y}}
24557 !! html/php
24558 <p>xy
24559 </p>
24560 !! html/parsoid
24561 <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>
24562 !! end
24563
24564 !! test
24565 nowiki inside link inside heading (T20295)
24566 !! wikitext
24567 ==[[foo|x<nowiki>y</nowiki>z]]==
24568 !! html
24569 <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>
24570
24571 !! end
24572
24573 !! test
24574 new support for bdi element (T33817)
24575 !! wikitext
24576 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
24577 !! html
24578 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
24579
24580 !!end
24581
24582 !! test
24583 Ignore pipe between table row attributes
24584 !! wikitext
24585 {|
24586 |quux
24587 |- id=foo | style='color: red'
24588 |bar
24589 |}
24590 !! html
24591 <table>
24592 <tr>
24593 <td>quux
24594 </td></tr>
24595 <tr id="foo" style="color: red">
24596 <td>bar
24597 </td></tr></table>
24598
24599 !! end
24600
24601 !!test
24602 Language parser function
24603 !! wikitext
24604 {{#language:ar}}
24605 !! html
24606 <p>العربية
24607 </p>
24608 !! end
24609
24610 !!test
24611 Padleft and padright (default 0-padding)
24612 !! wikitext
24613 {{padleft:xyz|5}}
24614 {{padright:xyz|5}}
24615 !! html/php
24616 <p>00xyz
24617 xyz00
24618 </p>
24619 !! html/parsoid
24620 <p><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:xyz","function":"padleft"},"params":{"1":{"wt":"5"}},"i":0}}]}'>00xyz</span>
24621 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:xyz","function":"padright"},"params":{"1":{"wt":"5"}},"i":0}}]}'>xyz00</span></p>
24622 !! end
24623
24624 !!test
24625 Padleft and padright (partial fill)
24626 !! wikitext
24627 {{padleft:xyz|6|ab}}
24628 {{padright:xyz|6|ab}}
24629 !! html/php
24630 <p>abaxyz
24631 xyzaba
24632 </p>
24633 !! html/parsoid
24634 <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>
24635 <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>
24636 !! end
24637
24638 !!test
24639 Padleft and padright as substr
24640 !! wikitext
24641 {{padleft:|3|abcde}}
24642 {{padright:|3|abcde}}
24643 !! html/php
24644 <p>abc
24645 abc
24646 </p>
24647 !! html/parsoid
24648 <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>
24649 <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>
24650 !! end
24651
24652 !!test
24653 Special parser function
24654 !! wikitext
24655 {{#special:RandomPage}}
24656 {{#special:BaDtItLe}}
24657 {{#special:Foobar}}
24658 !! html
24659 <p>Special:Random
24660 Special:Badtitle
24661 Special:Foobar
24662 </p>
24663 !! end
24664
24665 !!test
24666 T36939 - Case insensitive link parsing ([HttP://])
24667 !! wikitext
24668 [HttP://MediaWiki.Org/]
24669 !! html/php
24670 <p><a rel="nofollow" class="external autonumber" href="HttP://MediaWiki.Org/">[1]</a>
24671 </p>
24672 !! html/parsoid
24673 <p><a rel="mw:ExtLink" class="external autonumber" href="HttP://MediaWiki.Org/"></a></p>
24674 !! end
24675
24676 !!test
24677 T36939 - Case insensitive link parsing ([HttP:// title])
24678 !! wikitext
24679 [HttP://MediaWiki.Org/ MediaWiki]
24680 !! html
24681 <p><a rel="nofollow" class="external text" href="HttP://MediaWiki.Org/">MediaWiki</a>
24682 </p>
24683 !! end
24684
24685 !!test
24686 T36939 - Case insensitive link parsing (HttP://)
24687 !! wikitext
24688 HttP://MediaWiki.Org/
24689 !! html/php
24690 <p><a rel="nofollow" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a>
24691 </p>
24692 !! html/parsoid
24693 <p><a rel="mw:ExtLink" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a></p>
24694 !! end
24695
24696 !!test
24697 Disable TOC
24698 !! options
24699 notoc
24700 !! wikitext
24701 Lead
24702 ==Section 1==
24703 ==Section 2==
24704 ==Section 3==
24705 ==Section 4==
24706 ==Section 5==
24707 !! html
24708 <p>Lead
24709 </p>
24710
24711 <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>
24712 <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>
24713 <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>
24714 <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>
24715 <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>
24716
24717 !! end
24718
24719
24720 ###
24721 ### Parsoid-specific tests
24722 ### Parsoid-PHP parser incompatibilities
24723 ###
24724 !!test
24725 1. SOL-sensitive wikitext tokens as template-args
24726 !!options
24727 parsoid=wt2html,wt2wt
24728 !! wikitext
24729 {{echo|*a}}
24730 {{echo|#a}}
24731 {{echo|:a}}
24732 !! html
24733 <span about="#mwt1" typeof="mw:Transclusion">
24734 </span><ul about="#mwt1"><li>a</li>
24735 </ul>
24736 <span about="#mwt2" typeof="mw:Transclusion">
24737 </span><ol about="#mwt2"><li>a</li>
24738 </ol>
24739 <span about="#mwt3" typeof="mw:Transclusion">
24740 </span><dl about="#mwt3"><dd>a</dd>
24741 </dl>
24742 !!end
24743
24744 #### -----------------------------------------------------------------
24745 #### Parsoid-specific functionality tests
24746 #### -----------------------------------------------------------------
24747
24748 # T65642/T68749: Formatting elt fixup around images is cleaned up.
24749 # We know wt2wt will fail, but we expect selser to pass.
24750 # Due to the nature of our testing, wt2wt and selser tests will enter the
24751 # blacklist and we'll catch selser regressions based on changes to the
24752 # blacklist entries for selser tests.
24753 !! test
24754 1. Bad treebuilder fixup of formatting elt is cleaned up
24755 !! options
24756 parsoid=wt2html,wt2wt
24757 !! wikitext
24758 {|
24759 |
24760 <small>
24761 [[Image:Foobar.jpg|right|Test]]
24762 </small>
24763 |}
24764 !! html/parsoid
24765 <table>
24766 <tbody><tr><td>
24767 <small>
24768 <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>
24769 </small>
24770 </td></tr>
24771 </tbody></table>
24772 !! end
24773
24774 !! test
24775 2. Bad treebuilder fixup of formatting elt is cleaned up
24776 !! options
24777 parsoid=wt2html,wt2wt
24778 !! wikitext
24779 '''foo[[File:Foobar.jpg|thumb|caption]]bar'''
24780
24781 <small>[[Image:Foobar.jpg|right|300px]]</small>
24782 !! html/parsoid
24783
24784 <p><b>foo</b></p>
24785 <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>
24786 <p><b>bar</b></p>
24787 <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>
24788 !! end
24789
24790 !! test
24791 3. Bad treebuilder fixup of formatting elt is cleaned up
24792 !! options
24793 parsoid=wt2html,wt2wt
24794 !! wikitext
24795 <small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
24796 !! html/parsoid
24797 <p><small><b>foo</b></small></p>
24798 <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>
24799 <p><small><b>bar</b></small></p>
24800 !! end
24801
24802 !! test
24803 4. Bad treebuilder fixup of formatting elt is cleaned up: formatting tags around captionless images are ignored
24804 !! options
24805 parsoid=wt2html,wt2wt
24806 !! wikitext
24807 '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
24808 !! html/parsoid
24809 <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>
24810 !! end
24811
24812 #### ----------------------------------------------------------------
24813 #### Parsoid-only testing of Parsoid's impl of LST
24814 #### Not implemented yet, see
24815 #### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
24816 #### ----------------------------------------------------------------
24817
24818 ## We still need to support serializing the older format while content is stored.
24819 !! test
24820 LST Sections: Backwards compatibility
24821 !! options
24822 parsoid={
24823 "suppressErrors": true,
24824 "modes": ["html2wt"]
24825 }
24826 !! wikitext
24827 <section begin="2011-05-16" />
24828 <section end="2014-04-10 (MW 1.23wmf22)" />
24829 !! html/parsoid
24830 <p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/>
24831 <meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p>
24832 !! end
24833
24834 !! test
24835 LST Sections: Newfangled approach
24836 !! wikitext
24837 <section begin="2011-05-16" />
24838 <section end="2014-04-10 (MW 1.23wmf22)" />
24839 !! html/parsoid
24840 <p><span typeof="mw:Extension/section" about="#mwt4" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"},"body":null}'>
24841 </span>
24842 <span typeof="mw:Extension/section" about="#mwt6" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"},"body":null}'>
24843 </span></p>
24844 !! end
24845
24846 #--------- Test stripping of empty nodes in template content ----------
24847
24848 !! test
24849 Empty LI and TR nodes should be stripped from template content
24850 !! wikitext
24851 {{EmptyLITest}}
24852 {{EmptyTRTest}}
24853 !! html/parsoid
24854 <ul about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyLITest","href":"./Template:EmptyLITest"},"params":{},"i":0}}]}'>
24855 <li>a</li>
24856 <li>b</li>
24857 </ul>
24858 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRTest","href":"./Template:EmptyTRTest"},"params":{},"i":0}}]}'>
24859 <tbody>
24860 <tr>
24861 <td>foo</td>
24862 </tr>
24863 <tr>
24864 <td>bar</td>
24865 </tr>
24866 </tbody>
24867 </table>
24868 !! end
24869
24870 !! test
24871 Empty LI and TR nodes should not be stripped from top-level content
24872 !! wikitext
24873 * a
24874 *
24875 * b
24876
24877 {|
24878 |-
24879 |-
24880 |foo
24881 |}
24882 !! html/parsoid
24883 <ul>
24884 <li> a</li>
24885 <li class='mw-empty-elt'></li>
24886 <li> b</li>
24887 </ul>
24888 <table>
24889 <tbody>
24890 <tr class='mw-empty-elt'></tr>
24891 <tr>
24892 <td>foo</td>
24893 </tr>
24894 </tbody>
24895 </table>
24896 !! end
24897
24898 !! test
24899 Empty TR nodes should not be stripped if they have any attributes set
24900 !! wikitext
24901 {{EmptyTRWithHTMLAttrTest}}
24902 !! html/parsoid
24903 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'>
24904 <tr align='center'></tr>
24905 <tr><td>foo</td></tr>
24906 <tr align='center'></tr>
24907 <tr><td>bar</td></tr>
24908 </table>
24909 !! end
24910
24911 #### ----------------------------------------------------------------
24912 #### The following section of tests are primarily to test
24913 #### wikitext escaping capabilities of Parsoid. Given that
24914 #### escaping can be done any number of ways, the wikitext (input)
24915 #### is always adjusted to reflect how Parsoid adds nowiki
24916 #### escape tags.
24917 ####
24918 #### We are marking several tests as parsoid-only since the
24919 #### HTML in the result section is different from what the
24920 #### PHP parser generates for it.
24921 #### ----------------------------------------------------------------
24922
24923
24924 #### --------------- Headings ---------------
24925 #### 0. Unnested
24926 #### 1. Nested inside html <h1>=foo=</h1>
24927 #### 2. Outside heading nest on a single line <h1>foo</h1>*bar
24928 #### 3. Nested inside html with wikitext split by html tags
24929 #### 4. No escape needed
24930 #### 5. Empty headings <h1></h1>
24931 #### 6. Heading chars in SOL context
24932 #### ----------------------------------------
24933 !! test
24934 Headings: 0. Unnested
24935 !! options
24936 parsoid=html2wt
24937 !! html/parsoid
24938 <p>=foo=</p>
24939
24940 <p> =foo=
24941 <!--cmt-->
24942 =foo=</p>
24943
24944 <p>=foo<i>a</i>=</p>
24945 !! wikitext
24946 <nowiki>=foo=</nowiki>
24947
24948 <nowiki> </nowiki>=foo=
24949 <!--cmt-->
24950 <nowiki>=foo=</nowiki>
24951
24952 =foo''a''<nowiki>=</nowiki>
24953 !!end
24954
24955 # New headings and existing headings are handled differently
24956 !! test
24957 Headings: 1. Nested inside html
24958 !! options
24959 parsoid=html2wt
24960 !! html/parsoid
24961 <h1>=foo=</h1>
24962 <h2>=foo=</h2>
24963 <h3>=foo=</h3>
24964
24965 <h1 data-parsoid=''>=foo=</h1>
24966 <h2 data-parsoid=''>=foo=</h2>
24967 <h3 data-parsoid=''>=foo=</h3>
24968 <h4 data-parsoid=''>=foo=</h4>
24969 <h5 data-parsoid=''>=foo=</h5>
24970 <h6 data-parsoid=''>=foo=</h6>
24971 !! wikitext
24972 = =foo= =
24973
24974 == =foo= ==
24975
24976 === =foo= ===
24977
24978 =<nowiki>=foo=</nowiki>=
24979 ==<nowiki>=foo=</nowiki>==
24980 ===<nowiki>=foo=</nowiki>===
24981 ====<nowiki>=foo=</nowiki>====
24982 =====<nowiki>=foo=</nowiki>=====
24983 ======<nowiki>=foo=</nowiki>======
24984
24985 !!end
24986
24987 !! test
24988 Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
24989 !! options
24990 parsoid=html2wt
24991 !! html/parsoid
24992 <h1>foo</h1>*bar
24993 <h1>foo</h1>=bar
24994 <h1>foo</h1>=bar=
24995 !! wikitext
24996 = foo =
24997 <nowiki>*</nowiki>bar
24998
24999 = foo =
25000 =bar
25001
25002 = foo =
25003 <nowiki>=bar=</nowiki>
25004 !!end
25005
25006 !! test
25007 Headings: 3. Nested inside html with wikitext split by html tags
25008 !! options
25009 parsoid=html2wt
25010 !! html/parsoid
25011 <h1>=<b>bold</b>foo=</h1>
25012 !! wikitext
25013 = ='''bold'''foo= =
25014 !!end
25015
25016 !! test
25017 Headings: 4a. No escaping needed (testing just h1 and h2)
25018 !! options
25019 parsoid=html2wt
25020 !! html/parsoid
25021 <h1>=foo</h1>
25022 <h1>foo=</h1>
25023 <h1> =foo= </h1>
25024 <h1>=foo= bar</h1>
25025 <h2>=foo</h2>
25026 <h2>foo=</h2>
25027 <h1>=</h1>
25028 <h1><i>=</i>foo=</h1>
25029 !! wikitext
25030 = =foo =
25031
25032 = foo= =
25033
25034 = =foo= =
25035
25036 = =foo= bar =
25037
25038 == =foo ==
25039
25040 == foo= ==
25041
25042 = = =
25043
25044 = ''=''foo= =
25045 !!end
25046
25047 !! test
25048 Headings: 4b. No escaping needed (inside p-tags)
25049 !! options
25050 parsoid=html2wt
25051 !! html/parsoid
25052 <p>=foo= x
25053 =foo= <s></s>
25054 </p>
25055 !! wikitext
25056 =foo= x
25057 =foo= <s></s>
25058 !! html/php
25059 <p>=foo= x
25060 =foo= <s></s>
25061 </p>
25062 !!end
25063
25064 !! test
25065 Headings: 4c. Short headings (1)
25066 !! options
25067 parsoid=html2wt
25068 !! html/parsoid
25069 <p>===
25070 </p>
25071 !! wikitext
25072 <nowiki>===</nowiki>
25073 !! html/php
25074 <p>===
25075 </p>
25076 !! end
25077
25078 # in the html2wt direction we emit '= = =' or '=<nowiki>=</nowiki>='
25079 !! test
25080 Headings: 4d. Short headings (2)
25081 !! options
25082 parsoid=wt2html,html2html
25083 !! wikitext
25084 =
25085 ==
25086 ===
25087 ====
25088 =====
25089 !! html/php
25090 <p>=
25091 ==
25092 </p>
25093 <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>
25094 <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>
25095 <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>
25096
25097 !! html/parsoid
25098 <p>=
25099 ==</p>
25100 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
25101 <h1 id="=="><span id=".3D.3D" typeof="mw:FallbackId"></span>==</h1>
25102 <h2 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h2>
25103 !! end
25104
25105 !! test
25106 Headings: 5. Empty headings
25107 !! options
25108 parsoid=html2wt
25109 !! html/parsoid
25110 <h1 data-parsoid='{}'></h1>
25111
25112 <h2 data-parsoid='{}'></h2>
25113
25114 <h3 data-parsoid='{}'></h3>
25115
25116 <h4 data-parsoid='{}'></h4>
25117
25118 <h5 data-parsoid='{}'></h5>
25119
25120 <h6 data-parsoid='{}'></h6>
25121 !! wikitext
25122 =<nowiki/>=
25123
25124 ==<nowiki/>==
25125
25126 ===<nowiki/>===
25127
25128 ====<nowiki/>====
25129
25130 =====<nowiki/>=====
25131
25132 ======<nowiki/>======
25133 !!end
25134
25135 !! test
25136 Headings: 6a. Heading chars in SOL context (with trailing spaces)
25137 !! options
25138 parsoid=html2wt
25139 !! html/parsoid
25140 <p>=a=</p>
25141
25142 <p>=a=</p>
25143
25144 <p>=a=</p>
25145 !! wikitext
25146 <nowiki>=a=</nowiki>
25147
25148 <nowiki>=a=</nowiki>
25149
25150 <nowiki>=a=</nowiki>
25151 !!end
25152
25153 !! test
25154 Headings: 6b. Heading chars in SOL context (with trailing newlines)
25155 !! options
25156 parsoid=html2wt
25157 !! html/parsoid
25158 <p>=a=
25159 b</p>
25160
25161 <p>=a=
25162 b</p>
25163
25164 <p>=a=
25165 b</p>
25166 !! wikitext
25167 <nowiki>=a=</nowiki>
25168 b
25169
25170 <nowiki>=a=</nowiki>
25171 b
25172
25173 <nowiki>=a=</nowiki>
25174 b
25175 !!end
25176
25177 !! test
25178 Headings: 6c. Heading chars in SOL context (leading newline break)
25179 !! options
25180 parsoid=html2wt
25181 !! html/parsoid
25182 <p>a
25183 =b=</p>
25184 !! wikitext
25185 a
25186 <nowiki>=b=</nowiki>
25187 !!end
25188
25189 !! test
25190 Headings: 6d. Heading chars in SOL context (with interspersed comments)
25191 !! options
25192 parsoid=html2wt
25193 !! html/parsoid
25194 <!--c0--><p>=a=</p>
25195
25196 <!--c1--><p>=a=</p> <!--c2--> <!--c3-->
25197 !! wikitext
25198 <!--c0--><nowiki>=a=</nowiki>
25199
25200 <!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3-->
25201 !!end
25202
25203 !! test
25204 Headings: 6d. Heading chars in SOL context (No escaping needed)
25205 !! options
25206 parsoid=html2wt
25207 !! html/parsoid
25208 =a=<div>b</div>
25209 !! wikitext
25210 =a=<div>b</div>
25211 !!end
25212
25213 !! test
25214 Headings: 7. Insert a newline between new content and headings
25215 !! options
25216 parsoid=html2wt
25217 !! html/parsoid
25218 <h2>NEW</h2>
25219 <p>new</p>
25220 <h2 data-parsoid='{}'>A</h2>
25221 <p data-parsoid='{}'>a</p>
25222 !! wikitext
25223 == NEW ==
25224 new
25225
25226 ==A==
25227 a
25228
25229 !! end
25230
25231 !! test
25232 Headings: Used as horizontal rule
25233 !! config
25234 wgFragmentMode=[ 'html5', 'legacy' ]
25235 !! options
25236 parsoid=wt2html
25237 !! wikitext
25238 ===============
25239 !! html/php
25240 <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>
25241
25242 !! html/parsoid
25243 <h6 id="==="><span id=".3D.3D.3D" typeof="mw:FallbackId"></span>===</h6>
25244 !! end
25245
25246 #### --------------- Lists ---------------
25247 #### 0. Outside nests (*foo, etc.)
25248 #### 1. Nested inside html <ul><li>*foo</li></ul>
25249 #### 2. Inside definition lists
25250 #### 3. Only bullets at start should be escaped
25251 #### 4. No escapes needed
25252 #### 5. No unnecessary escapes
25253 #### 6. Escape bullets in SOL position
25254 #### 7. Escape bullets in a multi-line context
25255 #### ----------------------------------------
25256
25257 !! test
25258 Lists: 0. Outside nests
25259 !! options
25260 parsoid=html2wt
25261 !! html/parsoid
25262 <p>*foo</p>
25263
25264 <p>#foo</p>
25265
25266 <p>;Foo:bar</p>
25267 !! wikitext
25268 <nowiki>*</nowiki>foo
25269
25270 <nowiki>#</nowiki>foo
25271
25272 <nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar
25273 !!end
25274
25275 ## Making these next 3 tests Parsoid-only since they are html2wt tests
25276 ## to test wikitext escaping, and insignificant whitespace diffs
25277 ## cause PHP parser tests to barf
25278 !! test
25279 Lists: 1. Nested inside html (No unnecessary escapes)
25280 !! options
25281 parsoid=html2wt
25282 !! html/parsoid
25283 <ul>
25284 <li>*foo</li>
25285 <li>#foo</li>
25286 <li>:foo</li>
25287 <li>;foo</li>
25288 <li data-parsoid='{}'>*foo</li>
25289 <li data-parsoid='{}'>#foo</li>
25290 <li data-parsoid='{}'>:foo</li>
25291 <li data-parsoid='{}'>;foo</li>
25292 </ul>
25293
25294 <ol>
25295 <li>*foo</li>
25296 <li>#foo</li>
25297 <li>:foo</li>
25298 <li>;foo</li>
25299 <li data-parsoid='{}'>*foo</li>
25300 <li data-parsoid='{}'>#foo</li>
25301 <li data-parsoid='{}'>:foo</li>
25302 <li data-parsoid='{}'>;foo</li>
25303 </ol>
25304 !! wikitext
25305 * *foo
25306 * #foo
25307 * :foo
25308 * ;foo
25309 *<nowiki>*foo</nowiki>
25310 *<nowiki>#foo</nowiki>
25311 *<nowiki>:foo</nowiki>
25312 *<nowiki>;foo</nowiki>
25313
25314 # *foo
25315 # #foo
25316 # :foo
25317 # ;foo
25318 #<nowiki>*foo</nowiki>
25319 #<nowiki>#foo</nowiki>
25320 #<nowiki>:foo</nowiki>
25321 #<nowiki>;foo</nowiki>
25322 !!end
25323
25324 !! test
25325 Lists: 2. Inside definition lists
25326 !! options
25327 parsoid=html2wt
25328 !! html/parsoid
25329 <dl><dt>;foo</dt></dl>
25330 <dl><dt>:foo</dt></dl>
25331 <dl><dt>:foo</dt>
25332 <dd>bar</dd></dl>
25333 <dl><dd>:foo</dd></dl>
25334 !! wikitext
25335 ; ;foo
25336
25337 ; <nowiki>:foo</nowiki>
25338
25339 ; <nowiki>:foo</nowiki>
25340 : bar
25341
25342 : :foo
25343 !!end
25344
25345 !! test
25346 Lists: 3. Only bullets at start of text in wikitext-generated HTML should be escaped
25347 !! options
25348 parsoid=html2wt
25349 !! html/parsoid
25350 <ul>
25351 <li>*foo*bar</li>
25352 <li data-parsoid='{}'>*foo<i>it</i>*bar</li>
25353 </ul>
25354 !! wikitext
25355 * *foo*bar
25356 *<nowiki>*foo</nowiki>''it''*bar
25357 !!end
25358
25359 !! test
25360 Lists: 4. No escapes needed
25361 !! options
25362 parsoid=html2wt
25363 !! html/parsoid
25364 <ul>
25365 <li>foo*bar
25366 </li>
25367 </ul>
25368 <ul>
25369 <li><i>foo</i>*bar
25370 </li>
25371 </ul>
25372 <ul>
25373 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>: bar
25374 </li>
25375 </ul>
25376 <ul>
25377 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar
25378 </li>
25379 </ul>
25380 !! wikitext
25381 *foo*bar
25382
25383 *''foo''*bar
25384
25385 *[[Foo]]: bar
25386
25387 *[[Foo]]*bar
25388 !!end
25389
25390 !! test
25391 Lists: 5. No unnecessary escapes
25392 !! options
25393 parsoid=html2wt
25394 !! html/parsoid
25395 <ul><li> bar <span>[[foo]]</span></li></ul>
25396 <ul><li> =bar <span>[[foo]]</span></li></ul>
25397 <ul><li> [[bar <span>[[foo]]</span></li></ul>
25398 <ul><li> ]]bar <span>[[foo]]</span></li></ul>
25399 <ul><li> =bar <span>foo]]</span>=</li></ul>
25400 <ul><li> <s></s>: a</li></ul>
25401 <ul><li> <i>* foo</i></li></ul>
25402
25403 !! wikitext
25404 * bar <span><nowiki>[[foo]]</nowiki></span>
25405
25406 * =bar <span><nowiki>[[foo]]</nowiki></span>
25407
25408 * [[bar <span><nowiki>[[foo]]</nowiki></span>
25409
25410 * ]]bar <span><nowiki>[[foo]]</nowiki></span>
25411
25412 * =bar <span>foo]]</span>=
25413
25414 * <s></s>: a
25415
25416 * ''* foo''
25417 !!end
25418
25419 !! test
25420 Lists: 6. Escape bullets in SOL position
25421 !! options
25422 parsoid=html2wt
25423 !! html/parsoid
25424 <p><!--cmt-->*foo</p>
25425 !! wikitext
25426 <!--cmt--><nowiki>*</nowiki>foo
25427 !!end
25428
25429 !! test
25430 Lists: 7. Escape bullets in a multi-line context
25431 !! options
25432 parsoid=html2wt
25433 !! html/parsoid
25434 <p>a
25435 *b
25436 </p>
25437 !! wikitext
25438 a
25439 <nowiki>*</nowiki>b
25440 !!end
25441
25442 !! test
25443 Lists: 8. Escape colons only if not present in tags
25444 !! options
25445 parsoid=html2wt
25446 !! html/parsoid
25447 <dl><dt>a:b<i>c:d</i></dt></dl>
25448 !! wikitext
25449 ; <nowiki>a:b</nowiki>''c:d''
25450 !! end
25451
25452 #### --------------- HRs ---------------
25453 #### 1. Single line
25454 #### -----------------------------------
25455
25456 !! test
25457 HRs: 1. Single line
25458 !! options
25459 parsoid=html2wt
25460 !! html/parsoid
25461 <hr />----
25462 <hr />=foo=
25463 <hr />*foo
25464 !! wikitext
25465 ----<nowiki>----</nowiki>
25466 ----=foo=
25467 ----*foo
25468 !! end
25469
25470 #### --------------- Tables ---------------
25471 #### 1a. Simple example
25472 #### 1b. No escaping needed (!foo)
25473 #### 1c. No escaping needed (|foo)
25474 #### 1d. No escaping needed (|}foo)
25475 ####
25476 #### 2a. Nested in td (<td>foo|bar</td>)
25477 #### 2b. Nested in td (<td>foo||bar</td>)
25478 #### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
25479 ####
25480 #### 3a. Nested in th (<th>foo!bar</th>)
25481 #### 3b. Nested in th (<th>foo!!bar</th>)
25482 #### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
25483 ####
25484 #### 4a. Escape -
25485 #### 4b. Escape +
25486 #### 4c. No escaping needed
25487 #### --------------------------------------
25488
25489 !! test
25490 Tables: 1a. Simple example
25491 !! options
25492 parsoid=html2wt
25493 !! html/parsoid
25494 <p>{|
25495 |}
25496 </p>
25497 !! wikitext
25498 <nowiki>{|</nowiki>
25499 |}
25500 !! end
25501
25502 !! test
25503 Tables: 1b. No escaping needed
25504 !! options
25505 parsoid=html2wt
25506 !! html/parsoid
25507 <p>!foo
25508 </p>
25509 !! wikitext
25510 !foo
25511 !! end
25512
25513 !! test
25514 Tables: 1c. No escaping needed
25515 !! options
25516 parsoid=html2wt
25517 !! html/parsoid
25518 <p>|foo
25519 </p>
25520 !! wikitext
25521 |foo
25522 !! end
25523
25524 !! test
25525 Tables: 1d. No escaping needed
25526 !! options
25527 parsoid=html2wt
25528 !! html/parsoid
25529 <p>|}foo
25530 </p>
25531 !! wikitext
25532 |}foo
25533 !! end
25534
25535 !! test
25536 Tables: 2a. Nested in td
25537 !! options
25538 parsoid=html2wt
25539 !! html/parsoid
25540 <table><tbody><tr>
25541 <td>foo|bar</td></tr>
25542 <tr><td>x<div>a|b</div></td>
25543 </tbody></table>
25544 !! wikitext
25545 {|
25546 |<nowiki>foo|bar</nowiki>
25547 |-
25548 |x<div><nowiki>a|b</nowiki></div>
25549 |}
25550 !! html/php+tidy
25551 <table>
25552 <tbody><tr>
25553 <td>foo|bar
25554 </td></tr>
25555 <tr>
25556 <td>x<div>a|b</div>
25557 </td></tr></tbody></table>
25558 !! end
25559
25560 !! test
25561 Tables: 2b. Nested in td
25562 !! options
25563 parsoid=html2wt
25564 !! html/parsoid
25565 <table><tbody><tr>
25566 <td>foo||bar</td>
25567 <td>a<i>b||c</i></td>
25568 <td>a<i><div>b||c</div></i></td>
25569 </tr></tbody></table>
25570 !! wikitext
25571 {|
25572 |<nowiki>foo||bar</nowiki>
25573 |a''<nowiki>b||c</nowiki>''
25574 |a''<div><nowiki>b||c</nowiki></div>''
25575 |}
25576 !! html/php
25577 <table>
25578 <tr>
25579 <td>foo||bar
25580 </td>
25581 <td>a<i>b||c</i>
25582 </td>
25583 <td>a<i><div>b||c</div></i>
25584 </td></tr></table>
25585
25586 !! end
25587
25588 !! test
25589 Tables: 2c. Nested in td -- no escaping needed
25590 !! options
25591 parsoid=html2wt
25592 !! html/*
25593 <table>
25594 <tr>
25595 <td>foo!!bar
25596 </td></tr></table>
25597
25598 !! wikitext
25599 {|
25600 |foo!!bar
25601 |}
25602 !! end
25603
25604 !! test
25605 Tables: 3a. Nested in th
25606 !! options
25607 parsoid=html2wt
25608 !! html/*
25609 <table>
25610 <tr>
25611 <th>foo!bar
25612 </th></tr></table>
25613
25614 !! wikitext
25615 {|
25616 !foo!bar
25617 |}
25618 !! end
25619
25620 !! test
25621 Tables: 3b. Nested in th
25622 !! options
25623 parsoid=html2wt
25624 !! html/parsoid
25625 <table><tbody>
25626 <tr><th>foo!!bar</th>
25627 <th><i>foo|bar</i></th>
25628 <th><i>foo!!bar</i></th>
25629 <th><i><span>foo!!bar</span></i></th>
25630 </tr></tbody></table>
25631 !! wikitext
25632 {|
25633 !<nowiki>foo!!bar</nowiki>
25634 !''<nowiki>foo|bar</nowiki>''
25635 !''<nowiki>foo!!bar</nowiki>''
25636 !''<span><nowiki>foo!!bar</nowiki></span>''
25637 |}
25638 !! html/php
25639 <table>
25640 <tr>
25641 <th>foo!!bar
25642 </th>
25643 <th><i>foo|bar</i>
25644 </th>
25645 <th><i>foo!!bar</i>
25646 </th>
25647 <th><i><span>foo!!bar</span></i>
25648 </th></tr></table>
25649
25650 !! end
25651
25652 !! test
25653 Tables: 3c. Nested in th
25654 !! options
25655 parsoid=html2wt
25656 !! html/parsoid
25657 <table><tbody>
25658 <tr><th>foo||bar</th>
25659 <th><span typeof="mw:Nowiki">foo||bar</span></th>
25660 </tr></tbody></table>
25661 !! wikitext
25662 {|
25663 !<nowiki>foo||bar</nowiki>
25664 !<nowiki>foo||bar</nowiki>
25665 |}
25666 !! html/php
25667 <table>
25668 <tr>
25669 <th>foo||bar
25670 </th>
25671 <th>foo||bar
25672 </th></tr></table>
25673
25674 !! end
25675
25676 !! test
25677 Tables: 4a. Escape -
25678 !! options
25679 parsoid=html2wt
25680 !! html/*
25681 <table>
25682 <tr>
25683 <th>-bar
25684 </th></tr>
25685 <tr>
25686 <td>-bar
25687 </td></tr></table>
25688
25689 !! wikitext
25690 {|
25691 !-bar
25692 |-
25693 |<nowiki>-bar</nowiki>
25694 |}
25695 !! end
25696
25697 !! test
25698 Tables: 4b. Escape +
25699 !! options
25700 parsoid=html2wt
25701 !! html/*
25702 <table>
25703 <tr>
25704 <th>+bar
25705 </th></tr>
25706 <tr>
25707 <td>+bar
25708 </td></tr></table>
25709
25710 !! wikitext
25711 {|
25712 !+bar
25713 |-
25714 |<nowiki>+bar</nowiki>
25715 |}
25716 !! end
25717
25718 !! test
25719 Tables: 4c. No escaping needed
25720 !! options
25721 parsoid=html2wt
25722 !! html/parsoid
25723 <table><tbody>
25724 <tr><td>foo-bar</td><td>foo+bar</td></tr>
25725 <tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
25726 <tr><td>foo
25727 <p>bar|baz
25728 +bar
25729 -bar</p></td></tr>
25730 <tr><td>x
25731 <div>a|b</div></td>
25732 </tbody></table>
25733 !! wikitext
25734 {|
25735 |foo-bar
25736 |foo+bar
25737 |-
25738 |''foo''-bar
25739 |''foo''+bar
25740 |-
25741 |foo
25742 bar|baz
25743 +bar
25744 -bar
25745 |-
25746 |x
25747 <div>a|b</div>
25748 |}
25749 !! html/php
25750 <table>
25751 <tr>
25752 <td>foo-bar
25753 </td>
25754 <td>foo+bar
25755 </td></tr>
25756 <tr>
25757 <td><i>foo</i>-bar
25758 </td>
25759 <td><i>foo</i>+bar
25760 </td></tr>
25761 <tr>
25762 <td>foo
25763 <p>bar|baz
25764 +bar
25765 -bar
25766 </p>
25767 </td></tr>
25768 <tr>
25769 <td>x
25770 <div>a|b</div>
25771 </td></tr></table>
25772
25773 !! end
25774
25775 !! test
25776 Tables: 4d. No escaping needed
25777 !! options
25778 parsoid=html2wt
25779 !! html/parsoid
25780 <table>
25781 <tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
25782 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
25783 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
25784 </tbody></table>
25785 !! wikitext
25786 {|
25787 |[[Foo]]-bar
25788 ||+1
25789 ||-2
25790 |}
25791 !! html/php
25792 <table>
25793 <tr>
25794 <td><a href="/wiki/Foo" title="Foo">Foo</a>-bar
25795 </td>
25796 <td>+1
25797 </td>
25798 <td>-2
25799 </td></tr></table>
25800
25801 !! end
25802
25803 !! test
25804 T97430: Don't emit empty nowiki pairs around marker meta tags
25805 !! options
25806 parsoid=html2wt
25807 !! html/parsoid
25808 <p>*This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
25809 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
25810 !! wikitext
25811 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
25812 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
25813 !! end
25814
25815 !! test
25816 Unclosed xmlish element in table line shouldn't eat end delimiters
25817 !! options
25818 parsoid=html2wt
25819 !! html/parsoid
25820 <table>
25821 <tbody><tr><td> &lt;foo</td>
25822 <td> bar></td></tr>
25823 </tbody></table>
25824 !! wikitext
25825 {|
25826 | <foo
25827 | bar>
25828 |}
25829 !! html/php
25830 <table>
25831 <tr>
25832 <td>&lt;foo
25833 </td>
25834 <td>bar&gt;
25835 </td></tr></table>
25836
25837 !! end
25838
25839 #### --------------- Links ----------------
25840 #### 1. Quote marks in link text
25841 #### 2. Wikilinks: Escapes needed
25842 #### 3. Wikilinks: No escapes needed
25843 #### 4. Extlinks: Escapes needed
25844 #### 5. Extlinks: No escapes needed
25845 #### --------------------------------------
25846 !! test
25847 Links 1. WikiLinks: No escapes needed
25848 !! options
25849 parsoid=html2wt
25850 !! html/parsoid
25851 <p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
25852 <a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
25853 <a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
25854 !! wikitext
25855 [[Foo|Foo''boo'']]
25856 [[Foo|[Foobar]]]
25857 [[Foo|x [Foobar] x]]
25858 !! html/php
25859 <p><a href="/wiki/Foo" title="Foo">Foo<i>boo</i></a>
25860 <a href="/wiki/Foo" title="Foo">[Foobar]</a>
25861 <a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
25862 </p>
25863 !! end
25864
25865 !! test
25866 Links 2. WikiLinks: Escapes needed
25867 !! options
25868 parsoid=html2wt
25869 !! html/parsoid
25870 <a href="Foo" rel="mw:WikiLink">Foobar]</a>
25871 <a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
25872 <a href="Foo" rel="mw:WikiLink">[[Bar]]</a>
25873 <a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a>
25874 <a href="Foo" rel="mw:WikiLink">|Bar</a>
25875 <a href="Foo" rel="mw:WikiLink">]]bar</a>
25876 <a href="Foo" rel="mw:WikiLink">[[bar</a>
25877 <a href="Foo" rel="mw:WikiLink">x [[ y</a>
25878 <a href="Foo" rel="mw:WikiLink">x ]] y</a>
25879 <a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a>
25880 !! wikitext
25881 [[Foo|<nowiki>Foobar]</nowiki>]]
25882 [[Foo|x <nowiki>[http://google.com g]</nowiki> x]]
25883 [[Foo|<nowiki>[[Bar]]</nowiki>]]
25884 [[Foo|<nowiki>x [[Bar]] x</nowiki>]]
25885 [[Foo|<nowiki>|Bar</nowiki>]]
25886 [[Foo|<nowiki>]]bar</nowiki>]]
25887 [[Foo|<nowiki>[[bar</nowiki>]]
25888 [[Foo|<nowiki>x [[ y</nowiki>]]
25889 [[Foo|<nowiki>x ]] y</nowiki>]]
25890 [[Foo|<nowiki>x ]] y [[ z</nowiki>]]
25891 !! html/php
25892 <p><a href="/wiki/Foo" title="Foo">Foobar]</a>
25893 <a href="/wiki/Foo" title="Foo">x [http://google.com g] x</a>
25894 <a href="/wiki/Foo" title="Foo">[[Bar]]</a>
25895 <a href="/wiki/Foo" title="Foo">x [[Bar]] x</a>
25896 <a href="/wiki/Foo" title="Foo">|Bar</a>
25897 <a href="/wiki/Foo" title="Foo">]]bar</a>
25898 <a href="/wiki/Foo" title="Foo">[[bar</a>
25899 <a href="/wiki/Foo" title="Foo">x [[ y</a>
25900 <a href="/wiki/Foo" title="Foo">x ]] y</a>
25901 <a href="/wiki/Foo" title="Foo">x ]] y [[ z</a>
25902 </p>
25903 !! end
25904
25905 !! test
25906 Links 3. WikiLinks: No escapes needed
25907 !! options
25908 parsoid=html2wt
25909 !! html/parsoid
25910 <p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
25911 <a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
25912 !! wikitext
25913 [[Foo|[Foobar]]
25914 [[Foo|foo|bar]]
25915 !! html/php
25916 <p><a href="/wiki/Foo" title="Foo">[Foobar</a>
25917 <a href="/wiki/Foo" title="Foo">foo|bar</a>
25918 </p>
25919 !! end
25920
25921 !! test
25922 Links 4. ExtLinks: Escapes needed
25923 !! options
25924 parsoid=html2wt
25925 !! html/parsoid
25926 <p><a rel="mw:ExtLink" href="http://google.com">[google]</a>
25927 <a rel="mw:ExtLink" href="http://google.com">google]</a>
25928 <a rel="mw:ExtLink" href="http://google.com">goog] le</a></p>
25929 <p>[http://google.com]</p>
25930 <p>[http://google.com google]</p>
25931 <p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p>
25932 <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>
25933 !! wikitext
25934 [http://google.com <nowiki>[google]</nowiki>]
25935 [http://google.com <nowiki>google]</nowiki>]
25936 [http://google.com <nowiki>goog] le</nowiki>]
25937
25938 <nowiki>[http://google.com]</nowiki>
25939
25940 <nowiki>[http://google.com google]</nowiki>
25941
25942 [http://google.com<nowiki>]</nowiki>
25943
25944 [{{echo|http://google.com}}<nowiki>]</nowiki>
25945 !! html/php
25946 <p><a rel="nofollow" class="external text" href="http://google.com">[google]</a>
25947 <a rel="nofollow" class="external text" href="http://google.com">google]</a>
25948 <a rel="nofollow" class="external text" href="http://google.com">goog] le</a>
25949 </p><p>[http://google.com]
25950 </p><p>[http://google.com google]
25951 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
25952 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
25953 </p>
25954 !! end
25955
25956 !! test
25957 Links 5. ExtLinks: No escapes needed
25958 !! options
25959 parsoid=html2wt
25960 !! html/parsoid
25961 <p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
25962 <p>[<a ref="mw:ExtLink" href="http://google.com"></a>]</p>
25963 !! wikitext
25964 [http://google.com [google]
25965
25966 [[http://google.com]]
25967 !! html/php
25968 <p><a rel="nofollow" class="external text" href="http://google.com">[google</a>
25969 </p><p>[<a rel="nofollow" class="external autonumber" href="http://google.com">[1]</a>]
25970 </p>
25971 !! end
25972
25973 !! test
25974 Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300)
25975 !! options
25976 parsoid=html2wt
25977 !! html/parsoid
25978 <p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y
25979 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>?x
25980 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>&amp;x
25981 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>'x
25982 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,x
25983 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.x
25984 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
25985 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>:x
25986 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
25987 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>!x
25988 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>=x
25989 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>(x)
25990 <a rel="mw:ExtLink" href="http://example.com(x" data-parsoid='{"stx":"url"}'>http://example.com(x</a>)
25991 </p>
25992 !! wikitext
25993 x<nowiki/>http://example.com<nowiki/>y
25994 http://example.com<nowiki/>?x
25995 http://example.com<nowiki/>&x
25996 http://example.com<nowiki/>'x
25997 http://example.com<nowiki/>,x
25998 http://example.com<nowiki/>.x
25999 http://example.com<nowiki/>;x
26000 http://example.com<nowiki/>:x
26001 http://example.com<nowiki/>;x
26002 http://example.com<nowiki/>!x
26003 http://example.com<nowiki/>=x
26004 http://example.com<nowiki/>(x)
26005 http://example.com(x<nowiki/>)
26006 !! end
26007
26008 !! test
26009 Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
26010 !! options
26011 parsoid=html2wt
26012 !! html/parsoid
26013 <p>x
26014 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>
26015 y
26016 "<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>"
26017 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>)
26018 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>) foo
26019 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,
26020 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, foo
26021 </p>
26022 !! wikitext
26023 x
26024 http://example.com
26025 y
26026 "http://example.com"
26027 (http://example.com)
26028 (http://example.com) foo
26029 http://example.com,
26030 http://example.com, foo
26031 !! html/php
26032 <p>x
26033 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
26034 y
26035 "<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>"
26036 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
26037 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) foo
26038 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
26039 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, foo
26040 </p>
26041 !! end
26042
26043 !! test
26044 Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
26045 !! options
26046 parsoid=html2wt
26047 !! html/parsoid
26048 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\
26049 -<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p>
26050 !! wikitext
26051 http://example.com.,;:!?\
26052 -http://example.com:
26053 !! html/php
26054 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.,;:!?\
26055 -<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
26056 </p>
26057 !! end
26058
26059 !! test
26060 Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
26061 !! options
26062 parsoid=html2wt
26063 !! html/parsoid
26064 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
26065 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
26066 X<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
26067 !! wikitext
26068 RFC 123<nowiki/>4
26069 RFC 123<nowiki/>y
26070 X<nowiki/>RFC 123<nowiki/>y
26071 !! end
26072
26073 !! test
26074 Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
26075 !! options
26076 parsoid=html2wt
26077 !! html/parsoid
26078 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
26079 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
26080 -<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
26081 </p>
26082 !! wikitext
26083 RFC 123?foo
26084 RFC 123&foo
26085 -RFC 123-
26086 !! html/php
26087 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>?foo
26088 <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
26089 -<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>-
26090 </p>
26091 !! end
26092
26093 !! test
26094 Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300)
26095 !! options
26096 parsoid=html2wt
26097 !! html/parsoid
26098 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4
26099 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
26100 X<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
26101 !! wikitext
26102 PMID 123<nowiki/>4
26103 PMID 123<nowiki/>y
26104 X<nowiki/>PMID 123<nowiki/>y
26105 !! end
26106
26107 !! test
26108 Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300)
26109 !! options
26110 parsoid=html2wt
26111 !! html/parsoid
26112 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo
26113 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo
26114 -<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>-
26115 </p>
26116 !! wikitext
26117 PMID 123?foo
26118 PMID 123&foo
26119 -PMID 123-
26120 !! html/php
26121 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>?foo
26122 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>&amp;foo
26123 -<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>-
26124 </p>
26125 !! end
26126
26127 !! test
26128 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300)
26129 !! options
26130 parsoid=html2wt
26131 !! html/parsoid
26132 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
26133 <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
26134 a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
26135 </p>
26136 !! wikitext
26137 ISBN 1234567890<nowiki/>1
26138 ISBN 1234567890<nowiki/>x
26139 a<nowiki/>ISBN 1234567890<nowiki/>b
26140 !! end
26141
26142 !! test
26143 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (T66300)
26144 !! options
26145 parsoid=html2wt
26146 !! html/parsoid
26147 <p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
26148 !! wikitext
26149 -ISBN 1234567890's
26150 !! html/php
26151 <p>-<a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>'s
26152 </p>
26153 !! end
26154
26155 !! test
26156 Links 14. Protect link-like plain text. (Parsoid bug T78425)
26157 !! options
26158 parsoid=html2wt
26159 !! html/*
26160 <p>this is not a link: http://example.com
26161 </p>
26162 !! wikitext
26163 this is not a link: <nowiki>http://example.com</nowiki>
26164 !! end
26165
26166 !! test
26167 Links 15. Link trails can't become link prefixes.
26168 !! options
26169 language=is
26170 parsoid=html2wt
26171 !! html/parsoid
26172 <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>
26173 !! wikitext
26174 [[Söfnuður]]-[[00]]
26175 !! html/php
26176 <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>
26177 </p>
26178 !! end
26179
26180 #### --------------- Quotes ---------------
26181 #### 1. Quotes inside <b> and <i>
26182 #### 2. Link fragments separated by <i> and <b> tags
26183 #### 3. Link fragments inside <i> and <b>
26184 #### 4. No escaping needed
26185 #### --------------------------------------
26186 !! test
26187 1a. Quotes inside <b> and <i>
26188 !! options
26189 parsoid=html2wt
26190 !! html/*
26191 <p><i>'foo'</i>
26192 <i>''foo''</i>
26193 <i>'''foo'''</i>
26194 <i>foo</i>'s
26195 <b>'foo'</b>
26196 <b>''foo''</b>
26197 <b>'''foo'''</b>
26198 <b>foo'<i>bar'</i>baz</b>
26199 <b>foo</b>'s
26200 '<i>foo</i>
26201 <i>foo</i>'
26202 <i>foo'</i>'
26203 '<i>foo</i>'
26204 '<b>foo</b>
26205 <b>foo</b>'
26206 '<b>foo</b>'
26207 <i>fools'<span> errand</span></i>
26208 <i><span>fool</span>'s errand</i>
26209 '<i>foo</i> bar '<i>baz</i>
26210 a|!*#-:;+-~[]{}b'<i>x</i>
26211 </p>
26212 !! wikitext
26213 ''<nowiki/>'foo'''
26214 ''<nowiki>''foo''</nowiki>''
26215 ''<nowiki>'''foo'''</nowiki>''
26216 ''foo''<nowiki/>'s
26217 '''<nowiki/>'foo''''
26218 '''<nowiki>''foo''</nowiki>'''
26219 '''<nowiki>'''foo'''</nowiki>'''
26220 '''foo'<nowiki/>''bar'<nowiki/>''baz'''
26221 '''foo'''<nowiki/>'s
26222 '''foo''
26223 ''foo''<nowiki/>'
26224 ''foo'''<nowiki/>'
26225 '''foo''<nowiki/>'
26226 ''''foo'''
26227 '''foo'''<nowiki/>'
26228 ''''foo'''<nowiki/>'
26229 ''fools'<span> errand</span>''
26230 ''<span>fool</span>'s errand''
26231 '<nowiki/>''foo'' bar '''baz''
26232 a|!*#-:;+-~[]{}b'''x''
26233 !! end
26234
26235 !! test
26236 1b. Quotes inside <b> and <i> with other tags on same line
26237 !! options
26238 parsoid=html2wt
26239 !! html/parsoid
26240 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
26241 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
26242 <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>
26243 <a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" rel="mw:WikiLink" title="Bar">bar</a></i>
26244 '<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>
26245 '<i>foo</i> <div title="name">test</div>
26246 '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
26247 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
26248 <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>
26249 </ol>
26250 !! wikitext
26251 '''a'' foo ''[[bar]]''
26252 ''a''' foo ''[[bar]]''
26253 ''a''' foo '''{{echo|[[bar]]}}'''
26254 [[foo]] x'''[[bar]]''
26255 '''foo'' <ref>test</ref>
26256 '''foo'' <div title="name">test</div>
26257 '''foo'' and <br> bar
26258 <references />
26259 !! end
26260
26261 !! test
26262 2. Link fragments separated by <i> and <b> tags
26263 !! options
26264 parsoid=html2wt
26265 !! html/parsoid
26266 <p>[[<i>foo</i>hello]]</p>
26267 <p>[[<b>foo</b>hello]]</p>
26268 !! wikitext
26269 [[''foo''<nowiki>hello]]</nowiki>
26270
26271 [['''foo'''<nowiki>hello]]</nowiki>
26272 !! end
26273
26274 # FIXME: Escaping one or both of [[ and ]] is also acceptable --
26275 # this is one of the shortcomings of this format
26276 !! test
26277 3. Link fragments inside <i> and <b>
26278 !! options
26279 parsoid=html2wt
26280 !! html/parsoid
26281 <p><i>[[foo</i>]]</p>
26282 <p><b>[[foo</b>]]</p>
26283 !! wikitext
26284 ''[[foo''<nowiki>]]</nowiki>
26285
26286 '''[[foo'''<nowiki>]]</nowiki>
26287 !! end
26288
26289 !! test
26290 4. No escaping needed
26291 !! options
26292 parsoid=html2wt
26293 !! html/parsoid
26294 <p>'<span><i>bar</i></span>'
26295 '<span><b>bar</b></span>'
26296 'a:b'foo
26297 </p>
26298 !! wikitext
26299 '<span>''bar''</span>'
26300 '<span>'''bar'''</span>'
26301 'a:b'foo
26302 !! end
26303
26304 #### ----------- Paragraphs ---------------
26305 #### 1. No unnecessary escapes
26306 #### --------------------------------------
26307
26308 !! test
26309 1. No unnecessary escapes
26310 !! options
26311 parsoid=html2wt
26312 !! html/parsoid
26313 <p>bar <span>[[foo]]</span>
26314 </p><p>=bar <span>[[foo]]</span>
26315 </p><p>[[bar <span>[[foo]]</span>
26316 </p><p>]]bar <span>[[foo]]</span>
26317 </p><p>=bar <span>foo]]</span>=
26318 </p>
26319 !! wikitext
26320 bar <span><nowiki>[[foo]]</nowiki></span>
26321
26322 =bar <span><nowiki>[[foo]]</nowiki></span>
26323
26324 [[bar <span><nowiki>[[foo]]</nowiki></span>
26325
26326 ]]bar <span><nowiki>[[foo]]</nowiki></span>
26327
26328 =bar <span>foo]]</span><nowiki>=</nowiki>
26329 !!end
26330
26331 #### ----------------------- PRE --------------------------
26332 #### 1. Leading whitespace in SOL context should be escaped
26333 #### ------------------------------------------------------
26334 !! test
26335 1. Leading whitespace in SOL context should be escaped
26336 !! options
26337 parsoid=html2wt
26338 !! html/parsoid
26339 <p> a</p>
26340
26341 <p> a</p>
26342
26343 <p> a(tab)</p>
26344
26345 <p> a
26346 <!--cmt-->
26347 a</p>
26348
26349 <p>a
26350 b</p>
26351
26352 <p>a
26353 b</p>
26354
26355 <p>a
26356 b</p>
26357 !! wikitext
26358 <nowiki> </nowiki>a
26359
26360 <nowiki> </nowiki> a
26361
26362 a(tab)
26363
26364 <nowiki> </nowiki> a
26365 <!--cmt-->
26366 <nowiki> </nowiki>a
26367
26368 a
26369 <nowiki> </nowiki>b
26370
26371 a
26372 b
26373
26374 a
26375 b
26376 !! html/php
26377 <p> a
26378 </p><p> a
26379 </p><p> a(tab)
26380 </p><p> a
26381 a
26382 </p><p>a
26383 b
26384 </p><p>a
26385 b
26386 </p><p>a
26387 b
26388 </p>
26389 !! end
26390
26391 !! test
26392 2. Leading whitespace in non-indent-pre contexts should not be escaped
26393 !! options
26394 parsoid=html2wt
26395 !! html/parsoid
26396 <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>
26397 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
26398 <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>
26399 b</span></li>
26400 </ol>
26401 !! wikitext
26402 foo <ref>''a''
26403 b</ref>
26404 <references />
26405 !! end
26406
26407 !! test
26408 3. Leading whitespace in indent-pre suppressing contexts should not be escaped
26409 !! options
26410 parsoid=html2wt
26411 !! html/parsoid
26412 <blockquote>
26413 <p>
26414 a
26415 <span>b</span>
26416 c</p>
26417 </blockquote>
26418 !! wikitext
26419 <blockquote>
26420 a
26421 <span>b</span>
26422 c
26423 </blockquote>
26424 !! end
26425
26426 !! test
26427 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
26428 !! options
26429 parsoid=html2wt
26430 !! html/parsoid
26431 <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>
26432 !! wikitext
26433 [[File:Foobar.jpg|thumb|caption]]
26434 !! end
26435
26436 !! test
26437 5. Nowiki escaping should account for indent-pres
26438 !! options
26439 parsoid=html2wt
26440 !! html/parsoid
26441 <pre>==foo==</pre>
26442 !! wikitext
26443 ==foo==
26444 !! end
26445
26446 !!test
26447 T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
26448 !! options
26449 parsoid=html2wt
26450 !! html/parsoid
26451 <pre>
26452 * foo
26453 * bar
26454 </pre>
26455 !! wikitext
26456 * foo
26457 * bar
26458 !! end
26459
26460 #### --------------- Behavior Switches --------------------
26461
26462 !! test
26463 1. Valid behavior switches should be escaped
26464 !! options
26465 parsoid=html2wt
26466 !! html/parsoid
26467 __TOC__
26468 <i>__TOC__</i>
26469 !! wikitext
26470 <nowiki>__TOC__</nowiki>
26471 ''<nowiki>__TOC__</nowiki>''
26472 !! end
26473
26474 !! test
26475 2. Invalid behavior switches should not be escaped
26476 !! options
26477 parsoid=html2wt
26478 !! html/parsoid
26479 __TOO__
26480 __|__
26481 !! wikitext
26482 __TOO__
26483 __|__
26484 !! end
26485
26486 # We use indent-pre as an indirect way to test for sol-transparent behavior.
26487 !! test
26488 Behavior switches should be SOL-transparent
26489 !! options
26490 parsoid=html2wt
26491 !! html/parsoid
26492 <meta property="mw:PageProp/toc" />
26493
26494 <!-- this one's bogus -->
26495 <pre>__TOO__</pre>
26496
26497 <pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre>
26498
26499 <meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre>
26500 !! wikitext
26501 __TOC__
26502
26503 <!-- this one's bogus -->
26504 __TOO__
26505
26506 __TOC__ foo
26507
26508 __TOC__
26509 bar
26510 !! end
26511
26512 #### --------------- HTML tags ---------------
26513 #### 1. a tags
26514 #### 2. other tags
26515 #### 3. multi-line html tag
26516 #### 4. extension tags
26517 #### -----------------------------------------
26518 !! test
26519 1. a tags
26520 !! options
26521 parsoid=html2wt
26522 !! html/parsoid
26523 &lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
26524 !! wikitext
26525 <a href="http://google.com">google</a>
26526 !! end
26527
26528 !! test
26529 2. other tags
26530 !! options
26531 parsoid=html2wt
26532 !! html/parsoid
26533 <ul><li> &lt;div&gt;foo&lt;/div&gt;</li>
26534 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
26535 <li> &lt;td&gt;</li></ul>
26536
26537 !! wikitext
26538 * <nowiki><div>foo</div></nowiki>
26539 * <nowiki><div style="color:red">foo</div></nowiki>
26540 * <nowiki><td></nowiki>
26541 !! end
26542
26543 !! test
26544 3. multi-line html tag
26545 !! options
26546 parsoid=html2wt
26547 !! html/parsoid
26548 <p>&lt;div
26549 &gt;foo&lt;/div
26550 &gt;
26551 </p>
26552 !! wikitext
26553 <nowiki><div
26554 >foo</div
26555 ></nowiki>
26556 !! end
26557
26558 !! test
26559 4. extension tags
26560 !! options
26561 parsoid=html2wt
26562 !! html/parsoid
26563 <p>&lt;ref&gt;foo&lt;/ref&gt;
26564 </p><p>&lt;ref&gt;bar
26565 </p><p>baz&lt;/ref&gt;
26566 </p>
26567 !! wikitext
26568 <nowiki><ref>foo</ref></nowiki>
26569
26570 <nowiki><ref>bar</nowiki>
26571
26572 baz<nowiki></ref></nowiki>
26573 !! end
26574
26575 #### --------------- Others ---------------
26576 !! test
26577 Escaping nowikis
26578 !! options
26579 parsoid=html2wt
26580 !! html/parsoid
26581 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
26582 </p>
26583 !! wikitext
26584 &lt;nowiki&gt;foo&lt;/nowiki&gt;
26585 !! end
26586
26587 ## The quote-char in the input is necessary for triggering the bug
26588 !! test
26589 (T54035) Nowiki-escaping should not get tripped by " :" in text
26590 !! options
26591 parsoid=html2wt
26592 !! html/parsoid
26593 <p>foo's bar :</p>
26594 !! wikitext
26595 foo's bar :
26596 !! end
26597
26598 #----------- End of wikitext escaping tests --------------
26599
26600 !! test
26601
26602 Tag-like HTML structures are passed through as text
26603 !! wikitext
26604 <x y>
26605
26606 <x.y>
26607
26608 <x-y>
26609
26610 1>2
26611
26612 x<y
26613
26614 a>b
26615
26616 1<d e>f
26617 !! html
26618 <p>&lt;x y&gt;
26619 </p><p>&lt;x.y&gt;
26620 </p><p>&lt;x-y&gt;
26621 </p><p>1&gt;2
26622 </p><p>x&lt;y
26623 </p><p>a&gt;b
26624 </p><p>1&lt;d e&gt;f
26625 </p>
26626 !! end
26627
26628 !! test
26629 HTML tag with necessary entities in attributes
26630 !! wikitext
26631 <span title="&amp;amp;">foo</span>
26632 !! html
26633 <p><span title="&amp;amp;">foo</span>
26634 </p>
26635 !! end
26636
26637 !! test
26638 HTML tag with 'unnecessary' entity encoding in attributes
26639 !! wikitext
26640 <span title="&amp;">foo</span>
26641 !! html
26642 <p><span title="&amp;">foo</span>
26643 </p>
26644 !! end
26645
26646 !! test
26647 HTML tag with broken attribute value quoting
26648 !! options
26649 parsoid=wt2html,html2html
26650 !! wikitext
26651 <span title="Hello world>Foo</span>
26652 !! html/php
26653 <p><span title="Hello world">Foo</span>
26654 </p>
26655 !! html/parsoid
26656 <p><span title="Hello world">Foo</span></p>
26657 !! end
26658
26659 !! test
26660 Self-closed tag with broken attribute value quoting
26661 !! options
26662 parsoid=wt2html,html2html
26663 !! wikitext
26664 <div title="Hello world />Foo
26665 !! html/php+tidy
26666 <div title="Hello world"></div><p>Foo
26667 </p>
26668 !! html/parsoid
26669 <div title="Hello world " data-parsoid='{"stx":"html","selfClose":true}'></div><p>Foo</p>
26670 !! end
26671
26672 !! test
26673 Table with broken attribute value quoting
26674 !! options
26675 parsoid=wt2html,html2html
26676 !! wikitext
26677 {|
26678 | title="Hello world|Foo
26679 |}
26680 !! html/php
26681 <table>
26682 <tr>
26683 <td title="Hello world">Foo
26684 </td></tr></table>
26685
26686 !! html/parsoid
26687 <table>
26688 <tr>
26689 <td title="Hello world">Foo
26690 </td></tr></table>
26691
26692 !! end
26693
26694 !! test
26695 Table with broken attribute value quoting on consecutive lines
26696 !! options
26697 parsoid=wt2html,html2html
26698 !! wikitext
26699 {|
26700 | title="Hello world|Foo
26701 | style="color:red|Bar
26702 |}
26703 !! html/php
26704 <table>
26705 <tr>
26706 <td title="Hello world">Foo
26707 </td>
26708 <td style="color:red">Bar
26709 </td></tr></table>
26710
26711 !! html/parsoid
26712 <table><tbody>
26713 <tr>
26714 <td title="Hello world">Foo
26715 </td><td style="color: red">Bar
26716 </td></tr></tbody></table>
26717
26718 !! end
26719
26720 !!test
26721 Accept empty td cell attribute
26722 !! wikitext
26723 {|
26724 | align="center" |foo|| |
26725 |}
26726 !! html
26727 <table>
26728 <tr>
26729 <td align="center">foo</td>
26730 <td>
26731 </td></tr></table>
26732
26733 !!end
26734
26735 !!test
26736 Non-empty attributes in th-cells
26737 !! wikitext
26738 {|
26739 !Foo!! style="color: red" |Bar
26740 |}
26741 !! html
26742 <table>
26743 <tr>
26744 <th>Foo</th>
26745 <th style="color: red">Bar
26746 </th></tr></table>
26747
26748 !!end
26749
26750 !!test
26751 Accept empty attributes in th-cells
26752 !! wikitext
26753 {|
26754 !|foo!!|bar
26755 |}
26756 !! html
26757 <table>
26758 <tr>
26759 <th>foo</th>
26760 <th>bar
26761 </th></tr></table>
26762
26763 !!end
26764
26765 !!test
26766 Empty table rows go away
26767 !! wikitext
26768 {|
26769 |Hello
26770 |there
26771 |- class="foo"
26772 |-
26773 |}
26774 !! html
26775 <table>
26776 <tr>
26777 <td>Hello
26778 </td>
26779 <td>there
26780 </td></tr>
26781
26782 </table>
26783
26784 !! end
26785
26786 ###
26787 ### Parsoid-centric tests for testing RTing of inter-element separators
26788 ### Edge cases not tested by existing parser tests and specific to
26789 ### Parsoid-specific serialization strategies.
26790 ###
26791
26792 !!test
26793 RT-ed inter-element separators should be valid separators
26794 !! wikitext
26795 {|
26796 |- [[foo]]
26797 |}
26798 !! html/php
26799 <table>
26800
26801 </table>
26802
26803 !! html/parsoid
26804 <table>
26805 <tbody><tr class='mw-empty-elt' data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
26806 </tbody></table>
26807 !!end
26808
26809 # Parsoid-only test of a DOM pass
26810 !!test
26811 Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out
26812 !! wikitext
26813 {|
26814 |<small>foo
26815 bar
26816 |}
26817
26818 {|
26819 |<small>foo<small>
26820 |}
26821 !! html/parsoid
26822 <table>
26823 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo
26824 <p>bar</p></small></td></tr>
26825 </tbody></table>
26826
26827 <table>
26828 <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>
26829 </tbody></table>
26830 !!end
26831
26832 # Note that the "style" attribute is really a template parameter here.
26833 # The = would have to be {{=}} if you wanted the literal.
26834 !!test
26835 Empty TD followed by TD with tpl-generated attribute
26836 !! wikitext
26837 {|
26838 |-
26839 |
26840 |{{echo|style='color:red'}}|foo
26841 |}
26842 !! html
26843 <table>
26844
26845 <tr>
26846 <td>
26847 </td>
26848 <td>foo
26849 </td></tr></table>
26850
26851 !!end
26852
26853 !!test
26854 Indented table with an empty td
26855 !! wikitext
26856 {|
26857 |-
26858 |
26859 |foo
26860 |}
26861 !! html
26862 <table>
26863
26864 <tr>
26865 <td>
26866 </td>
26867 <td>foo
26868 </td></tr></table>
26869
26870 !!end
26871
26872 ## We have some newline diffs RT-ing this edge case
26873 ## and it is not important enough -- we seem to be emitting
26874 ## at most 2 newlines after a </tr> and this is unrelated to
26875 ## the issue from T85627 that this is testing.
26876 !!test
26877 Indented table with blank lines in between (T85627)
26878 !! options
26879 parsoid=wt2html
26880 !! wikitext
26881 {|
26882 |foo
26883
26884
26885 |}
26886 !! html
26887 <table>
26888
26889 <tr>
26890 <td>foo
26891 </td></tr></table>
26892
26893 !!end
26894
26895 !!test
26896 Indented block & table
26897 !! wikitext
26898 <div>foo</div>
26899 {|
26900 |foo
26901 |}
26902 !! html/php
26903 <div>foo</div>
26904 <table>
26905 <tr>
26906 <td>foo
26907 </td></tr></table>
26908
26909 !! html/parsoid
26910 <div data-parsoid='{"stx":"html"}'>foo</div>
26911 <table><tbody>
26912 <tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>foo</td></tr>
26913 </tbody></table>
26914 !!end
26915
26916 !! test
26917 Indent and comment before table row
26918 !! wikitext
26919 {|
26920 <!--hi-->|-
26921 |there
26922 |}
26923 !! html/php
26924 <table>
26925
26926 <tr>
26927 <td>there
26928 </td></tr></table>
26929
26930 !! html/parsoid
26931 <table>
26932 <!--hi--><tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
26933 <td data-parsoid='{"autoInsertedEnd":true}'> there</td></tr>
26934 </tbody></table>
26935 !! end
26936
26937 # Parsoid-specific since PHP parser doesn't handle this mixed tbl-wikitext
26938 !!test
26939 Empty TR followed by a template-generated TR
26940 !!options
26941 parsoid
26942 !! wikitext
26943 {|
26944 |-
26945 {{echo|<tr><td>foo</td></tr>}}
26946 |}
26947 !! html
26948 <table>
26949 <tbody>
26950 <tr class='mw-empty-elt'></tr>
26951 <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}}]}'>
26952 <td>foo</td></tr>
26953 </tbody></table>
26954 !!end
26955
26956 ## PHP and parsoid output differ for this, and since this is primarily
26957 ## for testing Parsoid's serializer, marking this Parsoid only
26958 !!test
26959 Empty TR followed by mixed-ws-comment line should RT correctly
26960 !!options
26961 parsoid
26962 !! wikitext
26963 {|
26964 |-
26965 <!--c-->
26966 |-
26967 <!--c--> <!--d-->
26968 |}
26969 !! html
26970 <table>
26971 <tbody>
26972 <tr class='mw-empty-elt'></tr>
26973 <!--c-->
26974 <tr>
26975 <!--c--> </tr><!--d-->
26976 </tbody></table>
26977
26978 !!end
26979
26980 !!test
26981 Multi-line image caption generated by templates with/without trailing newlines
26982 !! wikitext
26983 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]]
26984 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]]
26985 !! html/parsoid
26986 <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>
26987 <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>
26988 !!end
26989
26990 !! test
26991 New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly
26992 !! options
26993 parsoid=html2wt
26994 !! html/parsoid
26995 <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>
26996
26997 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{}'/><h1>new heading</h1>
26998 !! wikitext
26999 <includeonly>foo</includeonly>
27000 new para
27001
27002 [[Category:Foo]]
27003
27004 = new heading =
27005 !! end
27006
27007 ## PHP emits broken html for this, and since this is primarily
27008 ## a Parsoid serializer test, marking this Parsoid only
27009 !!test
27010 Improperly nested inline or quotes tags with whitespace in between
27011 !! wikitext
27012 <span> <s>x</span> </s>
27013 ''' ''x''' ''
27014 !! html/parsoid
27015 <p><span> <s>x</s></span><s> </s>
27016 <b> <i>x</i></b><i> </i>
27017 </p>
27018 !!end
27019
27020 !!test
27021 Encapsulate protected attributes from wt
27022 !! wikitext
27023 <div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
27024
27025 {| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true"
27026 | ok
27027 |}
27028 !! html/parsoid
27029 <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>
27030
27031 <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">
27032 <tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'> ok</td></tr>
27033 </tbody></table>
27034 !!end
27035
27036 ## Currently the p-wrapper is fragile in how it adds / removes transformations.
27037 ## Having nested or stray pre tags results in the attempt to add duplicates,
27038 ## causing an assertion fail. This test tries to prevent that situation.
27039 !!test
27040 Ensure ParagraphWrapper can deal with stray closing pre tags
27041 !!options
27042 parsoid=wt2html
27043 !! wikitext
27044 plain text</pre>
27045 !! html/parsoid
27046 plain text
27047 !!end
27048
27049 !!test
27050 1. Ensure fostered text content is wrapped in element nodes
27051 !!options
27052 parsoid=wt2html
27053 !! wikitext
27054 <table>hi</table><table>ho</table>
27055 !! html/parsoid
27056 <p>hi</p>
27057 <table></table>
27058 <p>ho</p>
27059 <table></table>
27060 !!end
27061
27062 !!test
27063 2. Ensure fostered text content is wrapped in element nodes (traps regressions around fostered marker on the element getting lost)
27064 !!options
27065 parsoid=wt2html,wt2wt
27066 !! wikitext
27067 <table>
27068 <tr> || ||
27069 <td> a
27070 </table>
27071 !! html/parsoid
27072 <p> || ||
27073 </p><table>
27074 <tbody><tr><td> a</td></tr>
27075 </tbody></table>
27076 !!end
27077
27078 !!test
27079 Encapsulation properly handles null DSR information from foster box
27080 !!options
27081 parsoid=wt2html,wt2wt
27082 !! wikitext
27083 {{echo|<table>foo<tr><td>bar</td></tr></table>}}
27084 !! html/parsoid
27085 <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>
27086 !!end
27087
27088 !!test
27089 1. Encapsulate foster-parented transclusion content
27090 !!options
27091 parsoid=wt2wt,wt2html
27092 !! wikitext
27093 <table>{{echo|foo<tr><td>bar</td></tr>}}</table>
27094 !! html/parsoid
27095 <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>
27096 <tbody>
27097 <tr>
27098 <td>bar</td>
27099 </tr>
27100 </tbody>
27101 </table>
27102 !!end
27103
27104 !!test
27105 2. Encapsulate foster-parented transclusion content
27106 !!options
27107 parsoid=wt2wt,wt2html
27108 !! wikitext
27109 <table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table>
27110 !! html/parsoid
27111 <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>
27112 <table>
27113 <tbody>
27114 <tr>
27115 <td>bar</td>
27116 </tr>
27117 </tbody>
27118 </table>
27119 !!end
27120
27121 !!test
27122 3. Encapsulate foster-parented transclusion content
27123 !!options
27124 parsoid=wt2wt,wt2html
27125 !! wikitext
27126 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
27127 !! html/parsoid
27128 <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;]}">
27129 <p>foo</p>
27130 </div>
27131 <table>
27132 <tbody>
27133 <tr>
27134 <td>bar</td>
27135 </tr>
27136 </tbody>
27137 </table>
27138 !!end
27139
27140 !!test
27141 4. Encapsulate foster-parented transclusion content
27142 !!options
27143 parsoid=wt2wt,wt2html
27144 !! wikitext
27145 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
27146 !! html/parsoid
27147 <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;]}">
27148 <p>foo</p>
27149 </div>
27150 <table>
27151 <tbody>
27152 <tr>
27153 <td>bar</td>
27154 </tr>
27155 </tbody>
27156 </table>
27157 !!end
27158
27159 !!test
27160 5. Encapsulate foster-parented transclusion content
27161 !!options
27162 parsoid=wt2wt,wt2html
27163 !! wikitext
27164 <table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table>
27165 !! html/parsoid
27166 <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>
27167 <table>
27168 <tbody>
27169 <tr>
27170 <td>
27171 <div>
27172 <p>foo</p>
27173 </div>
27174 </td>
27175 </tr>
27176 </tbody>
27177 </table>
27178 !!end
27179
27180 !!test
27181 6. Encapsulate foster-parented transclusion content
27182 !!options
27183 parsoid=wt2wt,wt2html
27184 !! wikitext
27185 <table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p>
27186 !! html/parsoid
27187 <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>
27188 <table>
27189 <tbody>
27190 <tr>
27191 <td>
27192 <div>
27193 <p>foo</p>
27194 </div>
27195 </td>
27196 </tr>
27197 </tbody>
27198 </table>
27199 <p>ok</p>
27200 !!end
27201
27202 !!test
27203 7. Encapsulate foster-parented transclusion content
27204 !!options
27205 parsoid=wt2wt,wt2html
27206 !! wikitext
27207 <table>{{echo|<p>foo</p>}}<td>bar</td></table>
27208 !! html/parsoid
27209 <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>
27210 <table>
27211 <tbody>
27212 <tr>
27213 <td>bar</td>
27214 </tr>
27215 </tbody>
27216 </table>
27217 !!end
27218
27219 # Note that the wt is broken on purpose: the = should be {{=}} if you
27220 # don't want it to be a template parameter key.
27221 !!test
27222 8. Encapsulate foster-parented transclusion content
27223 !!options
27224 parsoid=wt2wt,wt2html
27225 !! wikitext
27226 {{echo|a
27227 }}{|{{echo|style='color:red'}}
27228 |-
27229 |b
27230 |}
27231 !! html/parsoid
27232 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n"}},"i":0}}]}'>a</p>
27233 <span> </span>
27234 <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>
27235 <table>
27236 <tbody>
27237 <tr>
27238 <td>b</td>
27239 </tr>
27240 </tbody>
27241 </table>
27242 !!end
27243
27244 !!test
27245 9. Encapsulate foster-parented transclusion content
27246 !!options
27247 parsoid=wt2wt,wt2html
27248 !! wikitext
27249 <table>{{echo|hi</table>hello}}
27250 !! html/parsoid
27251 <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>
27252 !!end
27253
27254 !!test
27255 Table in fosterable position
27256 !!options
27257 parsoid=wt2html
27258 !! wikitext
27259 {{OpenTable}}
27260 <div>
27261 {|
27262 |}
27263 </div>
27264 |}
27265 !! html/parsoid
27266 <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">
27267 </span>
27268 <table about="#mwt1" data-parsoid='{"autoInsertedEnd":true}'></table>
27269
27270 <table>
27271 </table>
27272 !!end
27273
27274 # Parsoid only for T66747
27275 !! test
27276 Properly encapsulate empty-content transclusions in fosterable positions
27277 !! wikitext
27278 <table>
27279 {{#if:|
27280 <td>foo</td>
27281 }}
27282 </table>
27283 !! html/parsoid
27284 <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"}]]}'>
27285
27286 </table>
27287 !! end
27288
27289 !! test
27290 Always encapsulate foster box when template range is expanded to table
27291 !! options
27292 parsoid=wt2wt
27293 !! wikitext
27294 {|
27295 hello
27296 {{OpenTable}}
27297 |}
27298 !! html/parsoid
27299
27300 !! end
27301
27302 !! test
27303 T115289: Unclosed table
27304 !! wikitext
27305 {{echo|<table>}}<!--c-->[[Category:Two]]
27306 !! html/parsoid
27307 <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>
27308 !! end
27309
27310 !! test
27311 T115289: Don't migrate newlines out of tables with fostered content
27312 !! wikitext
27313 <table><td></td>{{echo|<tr>[[Category:One]]}}<!--c-->[[Category:Two]]
27314 !! html/parsoid
27315 <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>
27316 !! end
27317
27318 !! test
27319 T73074: More fostering fun
27320 !! wikitext
27321 <table><td></td>{{echo|<tr>}}<!--c-->[[Category:Two]]
27322 !! html/parsoid
27323 <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>
27324 !! end
27325
27326 !!test
27327 Support <object> element with .data attribute
27328 !!options
27329 parsoid=html2wt
27330 !! html/parsoid
27331 <object data="test.swf"></object>
27332 !! wikitext
27333 <object data="test.swf"></object>
27334 !!end
27335
27336 !! test
27337 Don't block XML namespace declaration
27338 !! wikitext
27339 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span>
27340 !! html/php
27341 <p><span xmlns:dct="http&#58;//purl.org/dc/terms/" property="dct:title">MediaWiki</span>
27342 </p>
27343 !! html/parsoid
27344 <p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p>
27345 !! end
27346
27347 # -----------------------------------------------------------------
27348 # The following section of tests are primarily to spec requirements
27349 # around Parsoid's serialization (old, new, edited content)
27350 #
27351 # All these tests are marked Parsoid html2wt and html2html only
27352 # ----------------------------------------------------------------
27353
27354 !! test
27355 Ignore rel attribute in a-tags during serialization to url-links
27356 !! options
27357 parsoid=html2wt
27358 !! html/parsoid
27359 <a href='http://en.wikipedia.org/wiki/Foobar'>http://en.wikipedia.org/wiki/Foobar</a>
27360 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:ExtLink'>http://en.wikipedia.org/wiki/Foobar</a>
27361 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:WikiLink'>http://en.wikipedia.org/wiki/Foobar</a>
27362 !! wikitext
27363 http://en.wikipedia.org/wiki/Foobar
27364 http://en.wikipedia.org/wiki/Foobar
27365 http://en.wikipedia.org/wiki/Foobar
27366 !! end
27367
27368 # 'mi' is a localinterwiki prefix as well as a language
27369 !! test
27370 Serialize interwiki links pointing to the current wiki as plain wiki links (T67869)
27371 !! options
27372 parsoid=html2wt
27373 !! html/parsoid
27374 <p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p>
27375 !! wikitext
27376 [[Foo]]
27377 !! end
27378
27379 !! test
27380 Parsoid should accept interwiki shortcuts
27381 !! options
27382 parsoid=html2wt
27383 !! html/parsoid
27384 <p><a rel='mw:WikiLink' href='./fr:Foo'>Foo</a>
27385 <a rel='mw:ExtLink' href='./fr:Foo'>Foo</a>
27386 <a href='./fr:Foo'>Foo</a></p>
27387 <p><a rel='mw:WikiLink' href='fr%3AFoo'>Foo</a>
27388 <a rel='mw:ExtLink' href='fr%3AFoo'>Foo</a>
27389 <a href='fr%3AFoo'>Foo</a></p>
27390 <p><a href='FR%3AFoo'>Foo</a>
27391 <a href='./FR:Foo'>Foo</a></p>
27392 !! wikitext
27393 [[:fr:Foo|Foo]]
27394 [[:fr:Foo|Foo]]
27395 [[:fr:Foo|Foo]]
27396
27397 [[:fr:Foo|Foo]]
27398 [[:fr:Foo|Foo]]
27399 [[:fr:Foo|Foo]]
27400
27401 [[:fr:Foo|Foo]]
27402 [[:fr:Foo|Foo]]
27403 !! end
27404
27405 !! test
27406 Parsoid should not accept invalid interwiki shortcuts
27407 !! options
27408 parsoid=html2wt
27409 !! html/parsoid
27410 <p><a rel='mw:WikiLink' href='news:Foo'>Foo</a>
27411 <a rel='mw:ExtLink' href='news:Foo'>Foo</a>
27412 <a href='news:Foo'>Foo</a></p>
27413 !! wikitext
27414 [news:Foo Foo]
27415 [news:Foo Foo]
27416 [news:Foo Foo]
27417 !! end
27418
27419 # See T93839
27420 !! test
27421 New wikilinks should be serialized properly
27422 !! options
27423 parsoid=html2wt
27424 !! html/parsoid
27425 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
27426 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
27427 <a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a>
27428 <a href="http://en.wikipedia.org/wiki/Foo">http://en.wikipedia.org/wiki/Foo</a>
27429 <a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a>
27430 !! wikitext
27431 [[Foo]]
27432 [[Foo]]
27433 [[:en:Foo|//en.wikipedia.org/wiki/Foo]]
27434 http://en.wikipedia.org/wiki/Foo
27435 [[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]]
27436 !! end
27437
27438 !! test
27439 New wiki links (href variations)
27440 !! options
27441 parsoid=html2wt
27442 !! html/parsoid
27443 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
27444 <a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a>
27445 <a rel="mw:WikiLink" href="Foo bar">Foo_bar</a>
27446 <a rel="mw:WikiLink" href="./Toxine_bact%C3%A9rienne">Toxine bactérienne</a>
27447 !! wikitext
27448 [[Foo_bar]]
27449 [[Foo_bar]]
27450 [[Foo_bar]]
27451 [[Toxine bactérienne]]
27452 !! end
27453
27454 !! test
27455 New wiki links (content string variations)
27456 !! options
27457 parsoid=html2wt
27458 !! html/parsoid
27459 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
27460 <a rel="mw:WikiLink" href="./Foo_bar">Foo bar</a>
27461 <a rel="mw:WikiLink" href="./Foo_bar">./Foo_bar</a>
27462 !! wikitext
27463 [[Foo_bar]]
27464 [[Foo bar]]
27465 [[Foo_bar|./Foo_bar]]
27466 !! end
27467
27468 !! test
27469 New category links (href variations)
27470 !! options
27471 parsoid=html2wt
27472 !! html/parsoid
27473 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" />
27474 <link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" />
27475 <link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" />
27476 !! wikitext
27477 [[Category:Toxine bactérienne]]
27478 [[Category:Toxine bactérienne]]
27479 [[Category:Toxine bactérienne]]
27480 !! end
27481
27482 !! test
27483 New sol transparent links don't need indent-pre nowiki protection
27484 !! options
27485 parsoid=html2wt
27486 language=de
27487 !! html/parsoid
27488 <link rel="mw:PageProp/redirect" href="./Main_Page">
27489 <!-- this is good --> <link rel="mw:PageProp/Category" href="./Category:Good" />
27490 <!-- this is great --> <link rel="mw:PageProp/Category" href="./Kategorie:Great" />
27491 !! wikitext
27492 #WEITERLEITUNG [[Main Page]]
27493 <!-- this is good --> [[Category:Good]]
27494 <!-- this is great --> [[Kategorie:Great]]
27495 !! end
27496
27497 !! test
27498 New interlanguage links (href variations)
27499 !! options
27500 parsoid=html2wt
27501 !! html/parsoid
27502 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" />
27503 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" />
27504 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" />
27505 !! wikitext
27506 [[es:Toxine bactérienne]]
27507 [[es:Toxine_bactérienne]]
27508 [[es:Toxine_bactérienne]]
27509 !! end
27510
27511 !! test
27512 Image: Modifying size of an image (1)
27513 !! options
27514 parsoid={
27515 "modes": ["wt2wt"],
27516 "changes": [
27517 ["img[height]", "attr", "height", "22"],
27518 ["img[width]", "attr", "width", "200"]
27519 ]
27520 }
27521 !! wikitext
27522 [[Image:Foobar.jpg|230x230px]]
27523 !! wikitext/edited
27524 [[Image:Foobar.jpg|200x200px]]
27525 !!end
27526
27527 !! test
27528 Image: Modifying size of an image (2)
27529 !! options
27530 parsoid={
27531 "modes": ["wt2wt"],
27532 "changes": [
27533 ["img[height]", "attr", "height", "100"],
27534 ["img[width]", "attr", "width", "500"]
27535 ]
27536 }
27537 !! wikitext
27538 [[Image:Foobar.jpg|230x230px]]
27539 !! wikitext/edited
27540 [[Image:Foobar.jpg|500x500px]]
27541 !!end
27542
27543 # Change in size is ignored so long as class='mw-default-size'
27544 !! test
27545 Image: Modifying size of an image (3)
27546 !! options
27547 parsoid={
27548 "modes": ["wt2wt"],
27549 "changes": [
27550 ["figure[class]", "removeClass", "mw-default-size"],
27551 ["figure img", "attr", "height", "19"],
27552 ["figure img", "attr", "width", "170"]
27553 ]
27554 }
27555 !! wikitext
27556 [[Image:Foobar.jpg|thumb]]
27557 !! wikitext/edited
27558 [[Image:Foobar.jpg|thumb|170x170px]]
27559 !!end
27560
27561 !! test
27562 Image: Modifying alignment of an image (T50665)
27563 !! options
27564 parsoid={
27565 "modes": ["wt2wt"],
27566 "changes": [
27567 ["figure[class]", "removeClass", "mw-halign-right"],
27568 ["figure[class]", "addClass", "mw-halign-left"]
27569 ]
27570 }
27571 !! wikitext
27572 [[Image:Foobar.jpg|thumb|caption|right]]
27573 !! wikitext/edited
27574 [[Image:Foobar.jpg|thumb|caption|left]]
27575 !! end
27576
27577 !! test
27578 Image: Modifying mw-default-size of an frameless image (T64805)
27579 !! options
27580 parsoid={
27581 "modes": ["wt2wt"],
27582 "changes": [
27583 ["figure.mw-default-size", "removeClass", "mw-default-size"]
27584 ]
27585 }
27586 !! wikitext
27587 [[Image:Foobar.jpg|frameless|right]]
27588 !! wikitext/edited
27589 [[Image:Foobar.jpg|frameless|right|220x220px]]
27590 !! end
27591
27592 !! test
27593 Image: Modifying valign of an image (T51221)
27594 !! options
27595 parsoid={
27596 "modes": ["wt2wt"],
27597 "changes": [
27598 ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
27599 ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
27600 ]
27601 }
27602 !! wikitext
27603 [[File:Foobar.jpg|20px|middle]]
27604 !! wikitext/edited
27605 [[File:Foobar.jpg|20px|text-top]]
27606 !! end
27607
27608 !! test
27609 Image: Modifying alt attribute of an image (T58400)
27610 !! options
27611 parsoid={
27612 "modes": ["wt2wt"],
27613 "changes": [
27614 ["img[alt]", "attr", "alt", "some alternate edited text"]
27615 ]
27616 }
27617 !! wikitext
27618 [[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
27619 !! wikitext/edited
27620 [[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
27621 !!end
27622
27623 !! test
27624 Image: Modifying caption of an image
27625 !! options
27626 parsoid={
27627 "modes": ["wt2wt"],
27628 "changes": [
27629 ["figcaption", "text", "new caption"]
27630 ]
27631 }
27632 !! wikitext
27633 [[Image:Foobar.jpg|thumb|original caption]]
27634 !! wikitext/edited
27635 [[Image:Foobar.jpg|thumb|new caption]]
27636 !!end
27637
27638 !! test
27639 Image: empty alt attribute (T50924)
27640 !! options
27641 parsoid
27642 !! wikitext
27643 [[File:Foobar.jpg|thumb|alt=|bar]]
27644 !! html
27645 <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>
27646 !! end
27647
27648 !! test
27649 Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
27650 !! options
27651 parsoid=html2wt
27652 language=ar
27653 disabled
27654 !! html/parsoid
27655 <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>
27656 !! wikitext
27657 [[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
27658 !! end
27659
27660 !! test
27661 Image: Block level image should have \n before and after
27662 !! wikitext
27663 123
27664 [[File:Foobar.jpg|right|thumb|150x150px]]
27665 456
27666 !! html/parsoid
27667 <p>123</p>
27668 <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>
27669 <p>456</p>
27670 !! end
27671
27672 !! test
27673 Image: New block level image should have \n before and after (existing content)
27674 !! wikitext
27675 123
27676 [[File:Foobar.jpg|right|thumb|150x150px]]
27677 456
27678 !! html/parsoid
27679 <p>123</p>
27680 <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>
27681 <p>456</p>
27682 !! end
27683
27684 !! test
27685 Image: upright option (parsoid)
27686 !! wikitext
27687 [[File:Foobar.jpg|thumb|upright|caption]]
27688 [[File:Foobar.jpg|thumb|upright=0.5|caption]]
27689 [[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]]
27690 !! html/parsoid
27691 <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>
27692 <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>
27693 <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>
27694 !! end
27695
27696 !! test
27697 Image: upright option is ignored on inline and frame images (parsoid)
27698 !! wikitext
27699 [[File:Foobar.jpg|500x500px|upright=0.5|caption]]
27700 !! html/parsoid
27701 <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>
27702 !! end
27703
27704 !! test
27705 Image: in template parameter with empty parameter
27706 !! wikitext
27707 {{echo|[[File:Foobar.jpg|link=]]}}
27708 !! html/parsoid
27709 <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>
27710 !! end
27711
27712 !! test
27713 Image: from basic HTML (1)
27714 !! options
27715 parsoid=html2wt
27716 !! html/parsoid
27717 <span typeof="mw:Image">
27718 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
27719 </span>
27720 !! wikitext
27721 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
27722 !! end
27723
27724 !! test
27725 Image: from basic HTML (2)
27726 !! options
27727 parsoid=html2wt
27728 !! html/parsoid
27729 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
27730 !! wikitext
27731 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
27732 !! end
27733
27734 !! test
27735 Image: from basic HTML (3)
27736 !! options
27737 parsoid=html2wt
27738 !! html/parsoid
27739 <a href="Main"><img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"></a>
27740 !! wikitext
27741 [[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
27742 !! end
27743
27744 !! test
27745 Image: from basic HTML (4)
27746 !! options
27747 parsoid=html2wt
27748 !! html/parsoid
27749 <img src="./File:Foobar.jpg">
27750 !! wikitext
27751 [[File:Foobar.jpg|link=]]
27752 !! end
27753
27754 !! test
27755 Image: Invalid title as link
27756 !! wikitext
27757 [[File:Foobar.jpg|link=<]]
27758 !! html/php
27759 <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>
27760 </p>
27761 !! html/parsoid
27762 <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>
27763 !! end
27764
27765 !! test
27766 Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
27767 !! options
27768 parsoid=html2wt
27769 !! html/parsoid
27770 <ul>
27771 <li><p>foo</p></li>
27772 </ul>
27773 !! wikitext
27774 * foo
27775 !! end
27776
27777 !! test
27778 Lists: Serialize correctly even when list tags has unneeded whitespace between tags
27779 !! options
27780 parsoid=html2wt
27781 !! html/parsoid
27782 <ul> <li>foo</li></ul>
27783 !! wikitext
27784 * foo
27785 !! end
27786
27787 !! test
27788 Don't strip leading whitespace when handling indent-pre suppressing tags
27789 !! options
27790 parsoid=html2wt
27791 !! html/parsoid
27792 <table>
27793 <tr><td> indented row</td></tr>
27794 </table>
27795 <blockquote><p>
27796 <b>This is very bold of you!</b>
27797 </p>
27798 <table><tr><td>
27799 indented cell (no pre-wrapping!)
27800 </td></tr></table>
27801 </blockquote>
27802 <p>foo</p>
27803 <div>bar</div>
27804 !! wikitext
27805 {|
27806 | indented row
27807 |}
27808 <blockquote>
27809 '''This is very bold of you!'''
27810
27811 {|
27812 |
27813 indented cell (no pre-wrapping!)
27814 |}
27815 </blockquote>
27816 foo
27817 <div>bar</div>
27818 !! end
27819
27820 !! test
27821 Nowiki-wrap leading whitespace when handling indent-pre inducing tags
27822 !! options
27823 parsoid=html2wt
27824 !! html/parsoid
27825 <p>foo</p>
27826 <span>bar</span>
27827
27828 <span>foo2
27829 </span>bar2
27830
27831 <div>foo</div>
27832 <span>bar</span>
27833
27834 <div>
27835 <span>foo</span>
27836 </div>
27837 !! wikitext
27838 foo
27839
27840 <span>bar</span>
27841
27842 <span>foo2
27843 <nowiki> </nowiki></span>bar2
27844
27845 <div>foo</div>
27846 <nowiki> </nowiki><span>bar</span>
27847
27848 <div>
27849 <nowiki> </nowiki><span>foo</span>
27850 </div>
27851 !! end
27852
27853 !! test
27854 Lists: Dont insert newlines in a serialized list item.
27855 !! options
27856 parsoid=html2wt
27857 !! html/parsoid
27858 <ul><li>a<br>b</li><li>c</li></ul>
27859 !! wikitext
27860 * a<br />b
27861 * c
27862 !! end
27863
27864 !! test
27865 1. Headings: Force sol-transparent links and behavior switches to serialize before/after
27866 !! options
27867 parsoid={
27868 "modes": ["html2wt"],
27869 "scrubWikitext": false
27870 }
27871 !! html/parsoid
27872 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
27873 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
27874
27875 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
27876 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
27877
27878 <h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2>
27879
27880 <h2><meta property="mw:PageProp/toc" /> ok</h2>
27881 !! wikitext
27882 == hello there [[Category:A1]] ==
27883
27884 == [[Category:A2]] hi pal ==
27885
27886 == <!--foo--> [[Category:A3]] how goes it ==
27887
27888 == it goes well [[Category:A4]] <!--bar--> ==
27889
27890 ==howdy [[Category:A5]]==
27891
27892 == __TOC__ ok ==
27893 !! end
27894
27895 !! test
27896 2. Headings: Force sol-transparent links and behavior switches to serialize before/after
27897 !! options
27898 parsoid={
27899 "modes": ["html2wt"],
27900 "scrubWikitext": true
27901 }
27902 !! html/parsoid
27903 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
27904 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
27905
27906 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
27907 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
27908
27909 <h2><meta property="mw:PageProp/toc" /> ok</h2>
27910 !! wikitext
27911 == hello there ==
27912 [[Category:A1]]
27913 [[Category:A2]]
27914
27915 == hi pal ==
27916
27917 <!--foo--> [[Category:A3]]
27918
27919 == how goes it ==
27920
27921 == it goes well ==
27922 [[Category:A4]] <!--bar-->
27923
27924 __TOC__
27925
27926 == ok ==
27927 !! end
27928
27929 !! test
27930 Headings: Don't hoist metas that come from templates
27931 !! options
27932 parsoid={
27933 "modes": ["html2wt"],
27934 "scrubWikitext": true
27935 }
27936 !! html/parsoid
27937 <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>
27938 !! wikitext
27939 == {{echo|foo [[Category:Foo]]}} ==
27940 !! end
27941
27942 !! test
27943 Headings: Category in ref isn't hoisted
27944 !! options
27945 parsoid={
27946 "modes": ["html2wt"],
27947 "scrubWikitext": true
27948 }
27949 !! html/parsoid
27950 <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>
27951
27952 <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>
27953 !! wikitext
27954 == foo <ref>bar
27955 [[Category:Baz]] </ref> ==
27956
27957 <references />
27958 !! end
27959
27960 !! test
27961 Parsoid: Serialize positional parameters with = in them as named parameter
27962 !! options
27963 parsoid=html2wt
27964 !! html/parsoid
27965 <p about="#mwt1" typeof="mw:Transclusion"
27966 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p>
27967
27968 <p about="#mwt1" typeof="mw:Transclusion"
27969 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p>
27970
27971 <!--Orig params with data-parsoid has heuristics for handling = chars-->
27972 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
27973 <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>
27974 !! wikitext
27975 {{echo|1=f=oo}}
27976
27977 {{echo|1=f=oo|2=bar}}
27978
27979 <!--Orig params with data-parsoid has heuristics for handling = chars-->
27980 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
27981 {{echo|<nowiki>f=oo</nowiki>|bar}}
27982 !! end
27983
27984 !! test
27985 Parsoid: Serialize positional parameters with = in extlink as named parameter
27986 !! options
27987 parsoid=html2wt
27988 !! html/parsoid
27989 <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>
27990 !! wikitext
27991 {{echo|1=http://stuff?is=ok}}
27992 !! end
27993
27994 !! test
27995 Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes
27996 !! options
27997 parsoid=html2wt
27998 !! html/parsoid
27999 <div>a<p>b</p></div>
28000 <div>a
28001 <p>b</p></div>
28002 <div>
28003 a
28004 <p>b</p></div>
28005 !! wikitext
28006 <div>a
28007 b
28008 </div>
28009 <div>a
28010 b
28011 </div>
28012 <div>
28013 a
28014
28015 b
28016 </div>
28017 !! end
28018
28019 !! test
28020 Substrings resembling wikitext in hrefs should not get nowiki escapes
28021 !! options
28022 parsoid=html2wt
28023 !! html/parsoid
28024 <a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a>
28025 !! wikitext
28026 [[Foo''bar''baz]]
28027 !! end
28028
28029 !! test
28030 Enforce single-line context in the serializer
28031 !! options
28032 parsoid=html2wt
28033 !! html/parsoid
28034 <h2>testing
28035 123</h2>
28036
28037 <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">
28038 </span><span about="#mwt1">you</span> </h2>
28039
28040 <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>
28041
28042 <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
28043 there</span></li></ol>
28044
28045 <ul><li>asd
28046 sdf</li></ul>
28047
28048 <ul><li>foo
28049 bar
28050 baz</li>
28051 <li>foo <b>bar</b>
28052 baz</li></ul>
28053
28054 <dl><dt>hi
28055 ho </dt><dd data-parsoid='{"stx":"row"}'> hi
28056 ho</dd></dl>
28057
28058 <dl><dd> <table>
28059 <tbody><tr><td> ha
28060 ha
28061 ha</td></tr>
28062 </tbody></table></dd></dl>
28063 !! wikitext
28064 == testing 123 ==
28065
28066 == hi {{bogus|there
28067 you}} ==
28068
28069 == foo <ref>hello
28070 there</ref> ==
28071
28072 <references />
28073
28074 * asd sdf
28075
28076 * foo bar baz
28077 * foo '''bar''' baz
28078
28079 ; hi ho : hi ho
28080
28081 : {|
28082 | ha
28083 ha
28084 ha
28085 |}
28086 !! end
28087
28088 !! test
28089 Serialize new placeholder space without spans
28090 !! options
28091 parsoid=html2wt
28092 !! html/parsoid
28093 <p>foo<span typeof="mw:Placeholder"> </span>: bar</p>
28094
28095 <p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p>
28096
28097 <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>
28098 !! wikitext
28099 foo : bar
28100
28101 foo : bar
28102
28103 <ref>foo : bar</ref>ok
28104 !! end
28105
28106
28107 #-----------------------
28108 # Tag minimization tests
28109 #-----------------------
28110
28111 !! test
28112 1. I/B quote minimization: wikitext-only tags should be combined
28113 !! options
28114 parsoid=html2wt
28115 !! html/parsoid
28116 <p><i>A</i><i>B</i></p>
28117 <p><b>A</b><b>B</b></p>
28118 <p><i>A</i><b><i>B</i></b></p>
28119 <p><b>A</b><i><b>B</b></i></p>
28120 <p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p>
28121 <p><i><b>A</b></i><i><b>B</b></i></p>
28122 <p><i><b>A</b></i><b><i>B</i></b></p>
28123 <p><b><i>A</i></b><i><b>B</b></i></p>
28124 !! wikitext
28125 ''AB''
28126
28127 '''AB'''
28128
28129 ''A'''B'''''
28130
28131 '''A''B'''''
28132
28133 '''A''BC''D'''
28134
28135 '''''AB'''''
28136
28137 '''''AB'''''
28138
28139 '''''AB'''''
28140 !! end
28141
28142 !! test
28143 2. I/B quote minimization: wikitext and html tags should not be combined
28144 !! options
28145 parsoid=html2wt
28146 !! html/parsoid
28147 <p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
28148 <p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
28149 !! wikitext
28150 ''A''<i>B</i>
28151
28152 ''A''<nowiki/>'''<i>B</i>'''
28153 !! end
28154
28155 !! test
28156 3. I/B quote minimization: templated content stops minimization
28157 !! options
28158 parsoid=html2wt
28159 !! html/parsoid
28160 <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>
28161 <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>
28162 !! wikitext
28163 ''A''{{echo|''B''}}
28164
28165 ''A''{{echo|'''''B'''''}}
28166 !! end
28167
28168 !! test
28169 4. I/B quote minimization: new content should be mimimized with adjacent old content
28170 !! options
28171 parsoid=html2wt
28172 !! html/parsoid
28173 <p><i>A</i><i>B</i></p>
28174 <p><b>A</b><b>B</b></p>
28175 <p><i>A</i><b><i>B</i></b></p>
28176 !! wikitext
28177 ''AB''
28178
28179 '''AB'''
28180
28181 ''A'''B'''''
28182 !! end
28183
28184 !! test
28185 5a. Merge adjacent quote nodes if they've been edited
28186 !! options
28187 parsoid={
28188 "modes": ["wt2wt", "selser"],
28189 "changes": [
28190 ["p", "contents", "remove", ":contains('b')"]
28191 ]
28192 }
28193 !! wikitext
28194 ''a''b''c''
28195 !! wikitext/edited
28196 ''ac''
28197 !! end
28198
28199 !! test
28200 5b. Merge adjacent quote nodes if they've been edited
28201 !! options
28202 parsoid={
28203 "modes": ["wt2wt", "selser"],
28204 "changes": [
28205 ["#x", "remove"]
28206 ]
28207 }
28208 !! wikitext
28209 ''a''<span id="x">b</span>''c''
28210 !! wikitext/edited
28211 ''ac''
28212 !! end
28213
28214 !! test
28215 1. Merge adjacent link nodes as long as at least one element is new
28216 !! options
28217 parsoid={
28218 "modes": ["html2wt"],
28219 "scrubWikitext": true
28220 }
28221 !! html/parsoid
28222 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28223 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28224 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a>
28225 !! wikitext
28226 [[Football]]
28227 [[Football]]
28228 [[Football|Foot]][[Football|ball]]
28229 !! end
28230
28231 !! test
28232 2. Merge adjacent link nodes and enable additional normalizations
28233 !! options
28234 parsoid={
28235 "modes": ["html2wt"],
28236 "scrubWikitext": true
28237 }
28238 !! html/parsoid
28239 <a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a>
28240 !! wikitext
28241 [[Football|''Football'']]
28242 !! end
28243
28244 !! test
28245 3. Don't merge adjacent link nodes if scrubWikitext is false
28246 !! options
28247 parsoid={
28248 "modes": ["html2wt"],
28249 "scrubWikitext": false
28250 }
28251 !! html/parsoid
28252 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28253 !! wikitext
28254 [[Football|Foot]][[Football|ball]]
28255 !! end
28256
28257 #------------------------------
28258 # End of tag minimization tests
28259 #------------------------------
28260
28261 !!test
28262 T56262: New entities
28263 !! options
28264 parsoid=html2wt
28265 !! html/parsoid
28266 <span typeof="mw:Entity">&nbsp;</span>
28267 !! wikitext
28268 &nbsp;
28269 !! end
28270
28271 ## Note that there is no wikitext output for 'unknownproperty' ##
28272 ## Unknown magic words are silently dropped ##
28273
28274 !! test
28275 Magic words
28276 !! options
28277 parsoid=html2wt
28278 !! html/parsoid
28279 <meta property='mw:PageProp/toc' />
28280 <meta property='mw:PageProp/notoc' />
28281 <meta property='mw:PageProp/forcetoc' />
28282 <meta property='mw:PageProp/index' />
28283 <meta property='mw:PageProp/noindex' />
28284 <meta property='mw:PageProp/nogallery' />
28285 <meta property='mw:PageProp/noeditsection' />
28286 <meta property='mw:PageProp/notitleconvert' />
28287 <meta property='mw:PageProp/nocontentconvert' />
28288 <meta property='mw:PageProp/unknownproperty' />
28289 !! wikitext
28290 __TOC__
28291 __NOTOC__
28292 __FORCETOC__
28293 __INDEX__
28294 __NOINDEX__
28295 __NOGALLERY__
28296 __NOEDITSECTION__
28297 __NOTITLECONVERT__
28298 __NOCONTENTCONVERT__
28299 !! end
28300
28301 !! test
28302 Consecutive <pre>s should not get merged
28303 !! options
28304 parsoid=html2wt,html2html
28305 !! html/parsoid
28306 <pre>a</pre><pre>b</pre>
28307
28308 <pre>c
28309 </pre><pre>
28310 d</pre>
28311
28312 <pre>e
28313
28314 </pre><pre>
28315
28316 f</pre>
28317 !! wikitext
28318 a
28319
28320 b
28321
28322 c
28323
28324 d
28325
28326 e
28327
28328
28329
28330 f
28331 !! end
28332
28333 !! test
28334 Edited ISBN links not serializable as ISBN links should serialize as wikilinks
28335 !! options
28336 parsoid=html2wt
28337 !! html/parsoid
28338 <a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a>
28339 !! wikitext
28340 [[Special:BookSources/1234567890|ISBN 1234567895]]
28341 !! end
28342
28343 !! test
28344 Edited RFC links not serializable as RFC links should serialize as extlinks
28345 !! options
28346 parsoid=html2wt
28347 !! html/parsoid
28348 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
28349 !! wikitext
28350 [https://tools.ietf.org/html/rfc123 New RFC]
28351 !! end
28352
28353 !! test
28354 Edited PMID links not serializable as PMID links should serialize as extlinks
28355 !! options
28356 parsoid=html2wt
28357 !! html/parsoid
28358 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a>
28359 !! wikitext
28360 [//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID]
28361 !! end
28362
28363 !! test
28364 WTS of autolinks with trailing/surrounding context
28365 !! options
28366 parsoid=html2wt
28367 !! html/parsoid
28368 <p><a href="http://cscott.net">http://cscott.net</a><b>foo</b></p>
28369 <p><a href="http://cscott.net">http://cscott.net</a><b data-parsoid='{"stx":"html"}'>foo</b></p>
28370 <p><b><a href="http://cscott.net">http://cscott.net</a></b></p>
28371 <p><b><a href="http://cscott.net">http://cscott.net</a> </b></p>
28372 <p><b><a href="http://cscott.net">http://cscott.net</a>x</b></p>
28373 <p><a href="http://cscott.net">http://cscott.net</a>x</p>
28374 !! wikitext
28375 http://cscott.net'''foo'''
28376
28377 http://cscott.net<b>foo</b>
28378
28379 '''http://cscott.net'''
28380
28381 '''http://cscott.net '''
28382
28383 '''http://cscott.net<nowiki/>x'''
28384
28385 http://cscott.net<nowiki/>x
28386 !! end
28387
28388 !! test
28389 WTS of autolinks with nowikis (round-trip)
28390 !! wikitext
28391 x<nowiki/>http://cscott.net<nowiki/>x
28392 !! html/parsoid
28393 <p>x<a rel="mw:ExtLink" class="external free" href="http://cscott.net">http://cscott.net</a>x</p>
28394 !! end
28395
28396 # this is the "easy" test because it leaves in place all the
28397 # data-parsoid information indicating this is an autolink
28398 !! test
28399 WTS of autolinks with escapes (editing)
28400 !! options
28401 parsoid={
28402 "modes": ["wt2wt"],
28403 "changes": [
28404 [ "span", "remove" ]
28405 ]
28406 }
28407 !! wikitext
28408 x<nowiki/>http://cscott.net<nowiki/>x
28409 !! wikitext/edited
28410 x<nowiki/>http://cscott.net<nowiki/>x
28411 !! end
28412
28413 !! test
28414 WTS of edited autolink-like text (T103364)
28415 !! options
28416 parsoid={
28417 "modes": ["wt2wt"],
28418 "changes": [
28419 [ "span[typeof]", "removeAttr", "typeof" ]
28420 ]
28421 }
28422 !! wikitext
28423 Not a link: <nowiki>http://example.com</nowiki>.
28424 !! wikitext/edited
28425 Not a link: <span><nowiki>http://example.com</nowiki></span>.
28426 !! end
28427
28428 !! test
28429 WTS of newly-authored autolink-like text (T103364)
28430 !! options
28431 parsoid=html2wt
28432 !! html/parsoid
28433 <p>http://example.com is not a link.</p>
28434 !! wikitext
28435 <nowiki>http://example.com</nowiki> is not a link.
28436 !! end
28437
28438 !! test
28439 WTS of autolink-like text after an autolink (T108563)
28440 !! options
28441 parsoid=html2wt
28442 !! html/parsoid
28443 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p>
28444 !! wikitext
28445 http://example.com <nowiki>http://example.com</nowiki> is not a link.
28446 !! end
28447
28448 !! test
28449 Magic links inside links (not autolinked)
28450 !! wikitext
28451 [[Foo|http://example.com]]
28452 [[Foo|RFC 1234]]
28453 [[Foo|PMID 1234]]
28454 [[Foo|ISBN 123456789x]]
28455
28456 [http://foo.com http://example.com]
28457 [http://foo.com RFC 1234]
28458 [http://foo.com PMID 1234]
28459 [http://foo.com ISBN 123456789x]
28460 !! html+tidy
28461 <p><a href="/wiki/Foo" title="Foo">http://example.com</a>
28462 <a href="/wiki/Foo" title="Foo">RFC 1234</a>
28463 <a href="/wiki/Foo" title="Foo">PMID 1234</a>
28464 <a href="/wiki/Foo" title="Foo">ISBN 123456789x</a>
28465 </p><p><a rel="nofollow" class="external text" href="http://foo.com">http://example.com</a>
28466 <a rel="nofollow" class="external text" href="http://foo.com">RFC 1234</a>
28467 <a rel="nofollow" class="external text" href="http://foo.com">PMID 1234</a>
28468 <a rel="nofollow" class="external text" href="http://foo.com">ISBN 123456789x</a>
28469 </p>
28470 !! html/parsoid
28471 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a>
28472 <a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a>
28473 <a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a>
28474 <a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p>
28475
28476 <p><a rel="mw:ExtLink" class="external text" href="http://foo.com">http://example.com</a>
28477 <a rel="mw:ExtLink" class="external text" href="http://foo.com">RFC 1234</a>
28478 <a rel="mw:ExtLink" class="external text" href="http://foo.com">PMID 1234</a>
28479 <a rel="mw:ExtLink" class="external text" href="http://foo.com">ISBN 123456789x</a></p>
28480 !! end
28481
28482 !! test
28483 Magic links inside image captions (autolinked)
28484 !! wikitext
28485 [[File:Foobar.jpg|thumb|http://example.com]]
28486 [[File:Foobar.jpg|thumb|RFC 1234]]
28487 [[File:Foobar.jpg|thumb|PMID 1234]]
28488 [[File:Foobar.jpg|thumb|ISBN 123456789x]]
28489 !! html+tidy
28490 <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>
28491 <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>
28492 <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>
28493 <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>
28494 !! html/parsoid
28495 <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>
28496 <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>
28497 <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>
28498 <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>
28499 !! end
28500
28501 !! test
28502 WTS of magic word text (T109371)
28503 !! options
28504 parsoid=html2wt
28505 !! html/parsoid
28506 <p>RFC 1234</p>
28507 <p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p>
28508 <p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p>
28509 !! wikitext
28510 <nowiki>RFC 1234</nowiki>
28511
28512 [http://foo.com RFC 1234]
28513
28514 [[Foo|RFC 1234]]
28515 !! end
28516
28517 !! test
28518 Edited Redirect link should emit a non-piped wikitext link
28519 !! options
28520 parsoid=html2wt
28521 !! html/parsoid
28522 <link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>
28523 !! wikitext
28524 #REDIRECT [[Bar]]
28525 !! end
28526
28527 !! test
28528 T75121: Infer extension name from typeOf if data-mw is not present
28529 !! options
28530 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28531 !! html/parsoid
28532 <div typeOf="mw:Extension/foo"></div>
28533 !! wikitext
28534 <foo />
28535 !! end
28536
28537 # Note that the <p> wrapping isn't present in PHP parser output
28538 # The important thing for this test is that P-wrapping doesn't
28539 # interfere with the <nowiki> protection for leading - in <td>
28540 # (which isn't necessary for <th>).
28541 !! test
28542 T88318: p-wrapped dash in table.
28543 !! options
28544 parsoid=html2wt,wt2wt
28545 !! html/parsoid
28546 <table><tbody>
28547 <tr><th><p>-</p></th><th><p>- </p></th></tr>
28548 <tr><td><p>-</p></td><td><p>- </p></td></tr>
28549 <tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr>
28550 </tbody></table>
28551 !! wikitext
28552 {|
28553 !-
28554 !-
28555 |-
28556 |<nowiki>-</nowiki>
28557 |<nowiki>- </nowiki>
28558 |-
28559 |<small>-</small>
28560 |<br />
28561 -
28562 |<br />
28563 -
28564 |}
28565 !! html/php+tidy
28566 <table>
28567 <tbody><tr>
28568 <th>-
28569 </th>
28570 <th>-
28571 </th></tr>
28572 <tr>
28573 <td>-
28574 </td>
28575 <td>-
28576 </td></tr>
28577 <tr>
28578 <td><small>-</small>
28579 </td>
28580 <td><br />
28581 <p>-
28582 </p>
28583 </td>
28584 <td><br />
28585 <p>-
28586 </p>
28587 </td></tr></tbody></table>
28588 !! end
28589
28590 !! test
28591 T149209: WTS: Handle newlines in table cells properly
28592 !! options
28593 parsoid=html2wt
28594 !! html/parsoid
28595 <table>
28596 <tbody>
28597 <tr><td>a
28598 b
28599 </td><td data-parsoid='{"stx":"row"}'>c</td></tr>
28600 <tr><td><p>x</p>
28601 </td><td data-parsoid='{"stx":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr>
28602 </tbody></table>
28603 <table>
28604 <tbody>
28605 <tr><th>a
28606 b
28607 </th><th data-parsoid='{"stx":"row"}'>c</th></tr>
28608 <tr><th><p>x</h>
28609 </th><th data-parsoid='{"stx":"row"}'>y</th></tr>
28610 </tbody></table>
28611 !! wikitext
28612 {|
28613 |a
28614 b
28615 |c
28616 |-
28617 |x
28618 {{!}}y
28619 |}
28620 {|
28621 !a
28622 b
28623 !c
28624 |-
28625 !x
28626 !y
28627 |}
28628 !! end
28629
28630 !! test
28631 T149209: Selser: Handle newlines in table cells properly
28632 !! options
28633 parsoid={
28634 "modes": ["selser"],
28635 "changes": [
28636 [ "#h1", "html", "a\nb\n" ],
28637 [ "#h2", "html", "a\nb\n" ],
28638 [ "#c1", "html", "a\nb\n" ],
28639 [ "#c2", "html", "<p>a</p>" ],
28640 [ "#c3", "html", "<p>a</p>" ],
28641 [ "#c4", "html", "edit-me<p>a</p>" ]
28642 ]
28643 }
28644 !! wikitext
28645 {|
28646 ! id="h1" |edit-me!!1
28647 |-
28648 ! id="h2" |edit-me||2
28649 |-
28650 | id="c1" |edit-me||3
28651 |-
28652 | id="c2" |edit-me||4
28653 |-
28654 | id="c3" |edit-me||p||q||r
28655 |-
28656 | id="c4" |edit-me||p||q||r
28657 |}
28658 !! wikitext/edited
28659 {|
28660 ! id="h1" |a
28661 b
28662 !1
28663 |-
28664 ! id="h2" |a
28665 b
28666 !2
28667 |-
28668 | id="c1" |a
28669 b
28670 |3
28671 |-
28672 | id="c2" |a
28673 |4
28674 |-
28675 | id="c3" |a
28676 |p||q||r
28677 |-
28678 | id="c4" |edit-me
28679 a
28680 |p||q||r
28681 |}
28682 !! end
28683
28684 !! test
28685 HTML id attribute with Parsoid-like element ids should not be serialized to wikitext
28686 !! options
28687 parsoid=html2wt
28688 !! html/parsoid
28689 <table id='mwAb'>
28690 <td id='mwAc'>foo</td>
28691 <td id='serialize-this'>bar</td>
28692 </table>
28693 !! wikitext
28694 {|
28695 |foo
28696 | id="serialize-this" |bar
28697 |}
28698 !! end
28699
28700 !! test
28701 Parsoid-like element ids should not be serialized to wikitext unless shadowed
28702 !! options
28703 parsoid=html2wt
28704 !! html/parsoid
28705 <div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div>
28706 !! wikitext
28707 <div id="hello">ok</div>
28708 !! end
28709
28710 !! test
28711 WTS change modes
28712 !! options
28713 parsoid={
28714 "modes": ["wt2wt"],
28715 "changes": [
28716 [ "#xyz", "before", "<b>before</b> stuff " ],
28717 [ "#xyz", "after", " stuff <i>after</i>" ],
28718 [ "#xyz", "html", "x <b>y</b> z" ]
28719 ]
28720 }
28721 !! wikitext
28722 <span id="xyz">hello</span>
28723 !! wikitext/edited
28724 '''before''' stuff <span id="xyz">x '''y''' z</span> stuff ''after''
28725 !! end
28726
28727 !! test
28728 Never serialize a-tag as html, regardless of what data-parsoid has to say
28729 !! options
28730 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28731 !! html/parsoid
28732 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a>
28733 !! wikitext
28734 [[Foo]]
28735 !! end
28736
28737 ## SSS FIXME: This is broken output nevertheless.
28738 ## What might be a reasonable non-broken output for this?
28739 ## This is an edge case unlikely to be seen in production
28740 ## that I am not wasting more time on this right now.
28741 !! test
28742 Never serialize a-tag as html, no matter what attributes it has
28743 !! options
28744 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28745 !! html/parsoid
28746 <a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a>
28747 !! wikitext
28748 [http://boo.org http://boohoo.org]
28749 !! end
28750
28751 # Misnested is an indication that selser can reuse the source but these have
28752 # shown to sneak through on occasion. See T101768.
28753 # The original wikitext here is: [http://test.com [[one]] two three]
28754 !! test
28755 Strip span tags added to mark misnested links
28756 !! options
28757 parsoid=html2wt
28758 !! html/parsoid
28759 <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>
28760 !! wikitext
28761 [http://test.com][[one]] two three
28762 !! end
28763
28764 !! test
28765 Catch regression when unpacking misnested links
28766 !! options
28767 parsoid=wt2html
28768 !! wikitext
28769 {{echo|hi}}[http://example.com [[ho]]]
28770 !! html/parsoid
28771 <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>
28772 !! end
28773
28774 !! test
28775 Catch regression when unpacking with trailing content
28776 !! wikitext
28777 {{echo|Foo <references/> bar}}
28778 !! html/parsoid
28779 <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>
28780 !! end
28781
28782 !! test
28783 Use data-parsoid.firstWikitextNode to compute newline constraints for template content
28784 !! options
28785 parsoid=html2wt
28786 !! html/parsoid
28787 <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|}"]}'>
28788 <tbody><tr><td>d
28789 </td></tr>
28790 </tbody></table>
28791 !! wikitext
28792 {{echo|a}}
28793 {|{{echo|c
28794 {{!}}d
28795 }}
28796 |}
28797 !! end
28798
28799 ## This test verifies the presence and computation of this attribute indirectly
28800 ## by making an edit and ensuring that the serialization is correct (which it would be
28801 ## only if firstWikitextNode is properly set).
28802 !! test
28803 data-parsoid.firstWikitextNode should be computed properly in the presence of fostered content
28804 !! options
28805 parsoid= {
28806 "modes": ["wt2wt"],
28807 "changes": [
28808 [ "div#x", "remove" ],
28809 [ "div", "before", "<div>new</div>" ]
28810 ]
28811 }
28812 !! wikitext
28813 <div id="x">foo</div>
28814 {|
28815 {{echo|<div>boo</div>
28816 {{!}}b}}
28817 |c
28818 |}
28819 !! wikitext/edited
28820
28821 <div>new</div>
28822 {|
28823 {{echo|<div>boo</div>
28824 {{!}}b}}
28825 |c
28826 |}
28827 !! end
28828
28829 # --------------------------------------------
28830 # Tests spec'ing wikitext serialization norms |
28831 # --------------------------------------------
28832
28833 !! test
28834 Serialize multi-line indent-pre starting with wikitext syntax
28835 !! options
28836 parsoid=html2wt
28837 !! html/parsoid
28838 <pre>* 1
28839 ** 2
28840 * 3</pre>
28841 !! wikitext
28842 * 1
28843 ** 2
28844 * 3
28845 !! end
28846
28847 !! test
28848 1. Categories should always be serialized on their own line
28849 !! options
28850 parsoid=html2wt
28851 !! html/parsoid
28852 foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar
28853 !! wikitext
28854 foo
28855 [[Category:Foo]]
28856 bar
28857 !! end
28858
28859 !! test
28860 2. Categories that are part of templates should not introduce a line break
28861 !! wikitext
28862 foo {{echo|<span>bar</span> [[Category:baz]]}} bar
28863 !! html/parsoid
28864 <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>
28865 !! end
28866
28867 # Careful while editing these next 2 tests. There are \u200f characters
28868 # before and after the <link> tags in the HTML and following some
28869 # of the categories in wikitext
28870 # Do not remove these characters in edits.
28871 #
28872 # As part of the serialization, these Unicode directional formatting characters will get stripped.
28873 !! test
28874 RTL (\u200f) and LTR (\u200e) markers around category tags should be stripped
28875 !! options
28876 parsoid={
28877 "modes": ["html2wt"],
28878 "scrubWikitext": true
28879 }
28880 !! html/parsoid
28881 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏
28882 ‏<link rel="mw:PageProp/Category" href="./קטגוריה:_שיטות_משפט" />‏</p>
28883 !! wikitext
28884 [[קטגוריה:טקסים]]
28885 [[קטגוריה: שיטות משפט]]
28886 !! end
28887
28888 !! test
28889 RTL (\u200f) and LTR (\u200e) markers should not be stripped if followed by a text node
28890 !! options
28891 parsoid={
28892 "modes": ["html2wt"],
28893 "scrubWikitext": true
28894 }
28895 !! html/parsoid
28896 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏y</p>
28897 !! wikitext
28898 [[קטגוריה:טקסים]]
28899 ‏y
28900 !! end
28901
28902 !! test
28903 Lists: Add space after bullets
28904 !! options
28905 parsoid=html2wt
28906 !! html/parsoid
28907 <ul>
28908 <li>foo</li>
28909 <li> bar</li>
28910 <li><span> baz</span></li>
28911 </ul>
28912 !! wikitext
28913 * foo
28914 * bar
28915 * <span> baz</span>
28916 !! end
28917
28918 !! test
28919 1. Headings: Add space before/after == (T53744)
28920 !! options
28921 parsoid=html2wt
28922 !! html/parsoid
28923 <h2>foo</h2>
28924 <h2> bar</h2>
28925 <h2>baz </h2>
28926 <h2><span> baz</span></h2>
28927 !! wikitext
28928 == foo ==
28929
28930 == bar ==
28931
28932 == baz ==
28933
28934 == <span> baz</span> ==
28935 !! end
28936
28937 !! test
28938 2. Headings: Add space before/after == even after hoisted content
28939 !! options
28940 parsoid={
28941 "modes": ["html2wt"],
28942 "scrubWikitext": true
28943 }
28944 !! html/parsoid
28945 <h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2>
28946 !! wikitext
28947 [[Category:A2]]
28948
28949 == ok ==
28950 !! end
28951
28952 !! test
28953 1. Headings: suppress newly created empty headings
28954 !! options
28955 parsoid={
28956 "modes": ["html2wt"],
28957 "scrubWikitext": true
28958 }
28959 !! html/parsoid
28960 <h2></h2>
28961 !! wikitext
28962 !! end
28963
28964 !! test
28965 2. Headings: don't suppress empty headings if scrubWikitext is false
28966 !! options
28967 parsoid=html2wt
28968 !! html/parsoid
28969 <h2></h2>
28970 !! wikitext
28971 ==<nowiki/>==
28972 !! end
28973
28974 !! test
28975 3. Headings: suppress empty headings on edits
28976 !! options
28977 parsoid={
28978 "modes": ["selser"],
28979 "scrubWikitext": true,
28980 "changes": [
28981 [ "#x", "remove"]
28982 ]
28983 }
28984 !! wikitext
28985 ==<span id="x">foo</span>==
28986 !! wikitext/edited
28987 !! end
28988
28989 !! test
28990 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = true)
28991 !! options
28992 parsoid={
28993 "modes": ["html2wt"],
28994 "scrubWikitext": true
28995 }
28996 !! html/parsoid
28997 <h2>foo<br/>bar</h2>
28998 <h2>foo <span><br/>bar</span> baz</h2>
28999 !! wikitext
29000 == foo bar ==
29001
29002 == foo <span> bar</span> baz ==
29003 !! end
29004
29005 !! test
29006 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = false)
29007 !! options
29008 parsoid={
29009 "modes": ["html2wt"],
29010 "scrubWikitext": false
29011 }
29012 !! html/parsoid
29013 <h2>foo<br/>bar</h2>
29014 !! wikitext
29015 == foo<br /> bar ==
29016 !! end
29017
29018 !! test
29019 1. WT Quote Tags: suppress newly created empty style tags
29020 !! options
29021 parsoid={
29022 "modes": ["html2wt"],
29023 "scrubWikitext": true
29024 }
29025 !! html/parsoid
29026 <i></i><b></b>
29027 !! wikitext
29028 !! end
29029
29030 !! test
29031 2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false
29032 !! options
29033 parsoid=html2wt
29034 !! html/parsoid
29035 <i></i><b></b>
29036 !! wikitext
29037 ''<nowiki/>'''''<nowiki/>'''
29038 !! end
29039
29040 !! test
29041 3. WT Quote Tags: suppress empty style tags on edits
29042 !! options
29043 parsoid={
29044 "modes": ["selser"],
29045 "scrubWikitext": true,
29046 "changes": [
29047 [ "#x", "remove"]
29048 ]
29049 }
29050 !! wikitext
29051 '''<span id="x">foo</span>'''
29052 !! wikitext/edited
29053 !! end
29054
29055 !! test
29056 1. Anchors: suppress newly created empty anchors
29057 !! options
29058 parsoid={
29059 "modes": ["html2wt"],
29060 "scrubWikitext": true
29061 }
29062 !! html/parsoid
29063 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
29064 !! wikitext
29065 !! end
29066
29067 !! test
29068 2. Anchors: don't suppress empty anchors if scrubWikitext is false
29069 !! options
29070 parsoid={
29071 "modes": ["html2wt"],
29072 "scrubWikitext": false
29073 }
29074 !! html/parsoid
29075 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
29076 !! wikitext
29077 [[Test|<nowiki/>]]
29078 !! end
29079
29080 !! test
29081 3. Anchors: suppress empty anchors on edits
29082 !! options
29083 parsoid={
29084 "modes": ["selser"],
29085 "scrubWikitext": true,
29086 "changes": [
29087 [ "#x", "remove"]
29088 ]
29089 }
29090 !! wikitext
29091 [[Test|<span id="x">foo</span>]]
29092 !! wikitext/edited
29093 !! end
29094
29095 !! test
29096 3a. Anchors: do not suppress numbered extlinks
29097 !! options
29098 parsoid={
29099 "modes": ["wt2wt"],
29100 "scrubWikitext": true
29101 }
29102 !! wikitext
29103 [http://foo.com]
29104 !! html/parsoid
29105 <a rel="mw:ExtLink" href="http://foo.com"></a>
29106 !! end
29107
29108 !! test
29109 3b. Anchors: do not suppress numbered extlinks
29110 !! options
29111 parsoid={
29112 "modes": ["wt2wt"],
29113 "scrubWikitext": true,
29114 "changes": [
29115 [ "#x", "remove"]
29116 ]
29117 }
29118 !! wikitext
29119 [http://foo.com <span id="x">foo</span>]
29120 !! wikitext/edited
29121 [http://foo.com]
29122 !! end
29123
29124 !!test
29125 Normalizations should be restricted to edited content
29126 !!options
29127 parsoid={
29128 "modes": ["selser"],
29129 "scrubWikitext": true,
29130 "changes": [
29131 [ "h1", "before", "<i></i>"]
29132 ]
29133 }
29134 !!wikitext
29135 a
29136 = =
29137 b
29138 !!wikitext/edited
29139 a
29140 = =
29141 b
29142 !!end
29143
29144 !! test
29145 1. Multiple normalizations (html2wt)
29146 !! options
29147 parsoid={
29148 "modes": ["html2wt"],
29149 "scrubWikitext": true
29150 }
29151 !! html
29152 <h2><i></i></h2>
29153 <p><a href='Foo' rel='mw:WikiLink'>foo<i></i>
29154 </a><b><i></i></b>x</p>
29155 !! wikitext
29156
29157 [[foo]]
29158 x
29159
29160 !! end
29161
29162 !! test
29163 2. Multiple normalizations (selser)
29164 !! options
29165 parsoid={
29166 "modes": ["selser"],
29167 "scrubWikitext": true,
29168 "changes": [
29169 [ "#x", "after", "<h1><i></i></h1>\n<p> x<b></b></p>"]
29170 ]
29171 }
29172 !! wikitext
29173 <span id="x">foo</span>
29174 !! wikitext/edited
29175 <span id="x">foo</span>
29176
29177 x
29178 !! end
29179
29180 !! test
29181 1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
29182 !! options
29183 parsoid={
29184 "modes": ["html2wt"],
29185 "scrubWikitext": true
29186 }
29187 !! html/parsoid
29188 <p> hi</p>
29189 <p> hello</p>
29190 !! wikitext
29191 hi
29192
29193 hello
29194 !! end
29195
29196 !! test
29197 2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false
29198 !! options
29199 parsoid=html2wt
29200 !! html/parsoid
29201 <p> hi</p>
29202 <p> hello</p>
29203 !! wikitext
29204 <nowiki> </nowiki>hi
29205
29206 <nowiki> </nowiki> hello
29207 !! end
29208
29209 !! test
29210 3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
29211 !! options
29212 parsoid={
29213 "modes": ["html2wt"],
29214 "scrubWikitext": true
29215 }
29216 !! html/parsoid
29217 <p>Foo
29218 bar
29219 baz</p>
29220
29221 <table><tr><td>Foo
29222 bar
29223 baz bang</td></tr></table>
29224
29225 <p><!--boo--> foo
29226 bar</p>
29227
29228 <p> foo
29229 bar<span>boo</span></p>
29230 !! wikitext
29231 Foo
29232 bar
29233 baz
29234
29235 {|
29236 |Foo
29237 bar
29238 baz bang
29239 |}
29240
29241 <!--boo-->foo
29242 bar
29243
29244 foo
29245 bar<span>boo</span>
29246 !! end
29247
29248 !! test
29249 4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs
29250 !! options
29251 parsoid={
29252 "modes": ["selser"],
29253 "scrubWikitext": true,
29254 "changes": [
29255 [ "p", "html", " a\n b" ]
29256 ]
29257 }
29258 !! wikitext
29259 xyz
29260 !! wikitext/edited
29261 a
29262 b
29263 !! end
29264
29265 !! test
29266 1. New links that end in spaces
29267 !! options
29268 parsoid={
29269 "modes": ["html2wt"],
29270 "scrubWikitext": false
29271 }
29272 !! html/parsoid
29273 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
29274 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
29275 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
29276 !! wikitext
29277 [[Berlin ]]<nowiki/>is the capital of Germany.
29278
29279 [[Foo ]]'''bar'''
29280
29281 [[Boston ]] is a city.
29282 !! end
29283
29284 !! test
29285 2. New links that end in spaces
29286 !! options
29287 parsoid={
29288 "modes": ["html2wt"],
29289 "scrubWikitext": true
29290 }
29291 !! html/parsoid
29292 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
29293 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
29294 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
29295 !! wikitext
29296 [[Berlin]] is the capital of Germany.
29297
29298 [[Foo]] '''bar'''
29299
29300 [[Boston]] is a city.
29301 !! end
29302
29303 !! test
29304 1. Table cells with escapable prefixes
29305 !! options
29306 parsoid={
29307 "modes": ["html2wt"],
29308 "scrubWikitext": false
29309 }
29310 !! html
29311 <table>
29312 <tr><td>a</td></tr>
29313 <tr><td>-</td></tr>
29314 <tr><td>+</td></tr>
29315 </table>
29316 !! wikitext
29317 {|
29318 |a
29319 |-
29320 |<nowiki>-</nowiki>
29321 |-
29322 |<nowiki>+</nowiki>
29323 |}
29324 !! end
29325
29326 !! test
29327 2. Table cells with escapable prefixes
29328 !! options
29329 parsoid={
29330 "modes": ["html2wt"],
29331 "scrubWikitext": true
29332 }
29333 !! html
29334 <table>
29335 <tr><td>a</td></tr>
29336 <tr><td>-</td></tr>
29337 <tr><td>+</td></tr>
29338 </table>
29339 !! wikitext
29340 {|
29341 |a
29342 |-
29343 | -
29344 |-
29345 | +
29346 |}
29347 !! end
29348
29349 !! test
29350 3a. Table cells with escapable prefixes after edits
29351 !! options
29352 parsoid={
29353 "modes": ["selser"],
29354 "scrubWikitext": true,
29355 "changes": [
29356 [ "table tbody tr:first-child td:first-child", "remove"]
29357 ]
29358 }
29359 !! wikitext
29360 {|
29361 |a||-
29362 |}
29363 !! wikitext/edited
29364 {|
29365 | -
29366 |}
29367 !! end
29368
29369 !! test
29370 3b. Table cells with escapable prefixes after edits
29371 !! options
29372 parsoid={
29373 "modes": ["selser"],
29374 "scrubWikitext": true,
29375 "changes": [
29376 [ "table tbody tr:first-child td:first-child", "html", "-" ],
29377 [ "#x", "remove" ]
29378 ]
29379 }
29380 !! wikitext
29381 {|
29382 |pqr
29383 |<span id="x">foo</span>+
29384 |}
29385 !! wikitext/edited
29386 {|
29387 | -
29388 | +
29389 |}
29390 !! end
29391
29392 # FIXME: This test will fail because
29393 # normalization doesn't realize that the id attribute
29394 # will eliminate the escapable scenario
29395 !! test
29396 4a. Table cells without escapable prefixes after edits
29397 !! options
29398 parsoid={
29399 "modes": ["selser"],
29400 "scrubWikitext": true,
29401 "changes": [
29402 [ "#x", "html", "-" ]
29403 ]
29404 }
29405 !! wikitext
29406 {|
29407 | id="x" |abcd
29408 |}
29409 !! wikitext/edited
29410 {|
29411 | id="x" |-
29412 |}
29413 !! end
29414
29415 ## This tests normalizer's ability to discriminate between
29416 ## cells having identical content.
29417 !! test
29418 4b. Table cells without escapable prefixes after edits
29419 !! options
29420 parsoid={
29421 "modes": ["selser"],
29422 "scrubWikitext": true,
29423 "changes": [
29424 [ "td", "html", "-" ]
29425 ]
29426 }
29427 !! wikitext
29428 {|
29429 |a||b
29430 |}
29431 !! wikitext/edited
29432 {|
29433 | -||-
29434 |}
29435 !! end
29436
29437 ## This tests normalizer's ability to not be tripped by
29438 ## comments (and whitespace)
29439 !! test
29440 4c. Table cells without escapable prefixes after edits
29441 !! options
29442 parsoid={
29443 "modes": ["selser"],
29444 "scrubWikitext": true,
29445 "changes": [
29446 [ "table tbody tr td:first-child", "remove" ]
29447 ]
29448 }
29449 !! wikitext
29450 {|
29451 |-
29452 <!--foo--> |a||-
29453 |}
29454 !! wikitext/edited
29455 {|
29456 |-
29457 <!--foo--> | -
29458 |}
29459 !! end
29460
29461 ## This tests normalizer's ability to handle HTML cells
29462 !! test
29463 4d. Table cells without escapable prefixes after edits
29464 !! options
29465 parsoid={
29466 "modes": ["selser"],
29467 "scrubWikitext": true,
29468 "changes": [
29469 [ "td", "html", "-" ]
29470 ]
29471 }
29472 !! wikitext
29473 <table>
29474 <tr><td>a</td></tr>
29475 </table>
29476 !! wikitext/edited
29477 <table>
29478 <tr><td>-</td></tr>
29479 </table>
29480 !! end
29481
29482 ## T111151 Remove font elements without attributes
29483 !! test
29484 5a. font tags without attributes should be dropped in scrubWikitext mode
29485 !! options
29486 parsoid={
29487 "modes": ["html2wt"],
29488 "scrubWikitext": true
29489 }
29490 !! html
29491 <font>foo</font>
29492 <font><font>bar</font></font>
29493 <font class="x">boo</font>
29494 !! wikitext
29495 foo
29496 bar
29497 <font class="x">boo</font>
29498 !! end
29499
29500 !! test
29501 5b. font tags should not be dropped without scrubWikitext being enabled
29502 !! options
29503 parsoid={
29504 "modes": ["html2wt"],
29505 "scrubWikitext": false
29506 }
29507 !! html
29508 <font>foo</font>
29509 !! wikitext
29510 <font>foo</font>
29511 !! end
29512
29513 !! test
29514 Escape nowiki DOM elements
29515 !! options
29516 parsoid=html2wt
29517 !! html/parsoid
29518 <nowiki><i>foo</i></nowiki>
29519 !! wikitext
29520 &lt;nowiki&gt;''foo''&lt;/nowiki&gt;
29521 !! end
29522
29523 # This is meant to be an interim fix while we go about figuring out
29524 # how to not introduce these trailing <nowiki/>s in the first place.
29525 !! test
29526 T115717: Strip trailing <nowiki/>s (without affecting valid uses)
29527 !! options
29528 parsoid=html2wt
29529 !! html/parsoid
29530 <p>x<meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/>
29531 y</p>
29532 <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>
29533 <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>
29534 !! wikitext
29535 x
29536 y
29537
29538 {{echo|
29539 1 = <nowiki/>}}
29540
29541 {{echo|
29542 1 = <nowiki/>
29543 }}
29544 !! end
29545
29546 !! test
29547 New list is serialized on newlines
29548 !! options
29549 parsoid=html2wt
29550 !! html/parsoid
29551 <p>The quick brown fox jumps over the lazy dog.</p><ul>
29552 <li>Yesterday</li>
29553 <li>Today</li>
29554 <li>Tomorrow</li>
29555 </ul><p>The quick onyx goblin jumps over the lazy dwarf.</p>
29556 !! wikitext
29557 The quick brown fox jumps over the lazy dog.
29558
29559 * Yesterday
29560 * Today
29561 * Tomorrow
29562
29563 The quick onyx goblin jumps over the lazy dwarf.
29564 !! end
29565
29566 !! test
29567 New lists in formatting elements serialized w/o newlines
29568 !! options
29569 parsoid=html2wt
29570 !! html/parsoid
29571 <small>
29572
29573 <ul>
29574 <li>123</li>
29575 </ul>
29576
29577 </small>
29578
29579 <small><ul><li>hi</li></ul></small>
29580 !! wikitext
29581 <small>
29582 * 123
29583 </small>
29584
29585 <small>
29586 * hi
29587 </small>
29588 !! end
29589
29590 !! test
29591 New list in table doesn't need newlines
29592 !! options
29593 parsoid=html2wt
29594 !! html/parsoid
29595 <table><tr><td><ul><li>test</li><li>123</li></td></tr></table>
29596 !! wikitext
29597 {|
29598 |
29599 * test
29600 * 123
29601 |}
29602 !! end
29603
29604 # ---------------------------------------------------
29605 # End of tests spec'ing wikitext serialization norms |
29606 # ---------------------------------------------------
29607
29608 # T104032
29609 !! test
29610 Bare inline nodes not wrapped inside p-tags should be treated as p-wrapped
29611 !! options
29612 parsoid=html2wt
29613 !! html/parsoid
29614 a<p>b</p>
29615 <b>c</b><p>d</p>
29616 <table><tr>
29617 <td>a<p>b</p></td>
29618 <td><b>c</b><p>d</p></td>
29619 </tr></table>
29620 !! wikitext
29621 a
29622
29623 b
29624
29625 '''c'''
29626
29627 d
29628 {|
29629 |a
29630 b
29631 |'''c'''
29632 d
29633 |}
29634 !! end
29635
29636 !! test
29637 Anchor without href scenarios
29638 !! options
29639 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
29640 !! html/parsoid
29641 <a class="bc"></a>
29642 <a class="no">dice</a>
29643 <a name="foo"></a>
29644 !! wikitext
29645
29646 dice
29647 <span name="foo"></span>
29648 !! end
29649
29650 !! test
29651 New transclusion added after a list should be serialized after the list
29652 !! options
29653 parsoid=html2wt
29654 !! html/parsoid
29655 <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>
29656 !! wikitext
29657 * a
29658 {{echo|foo}}
29659 !! end
29660
29661 # -----------------------------------------------------------------
29662 # End of section for Parsoid-only html2wt tests for serialization
29663 # of new content
29664 # -----------------------------------------------------------------
29665
29666 # -----------------------------------------------------------------
29667 # The following section of tests are primarily to spec behavior of
29668 # the selective serializer. All these tests have manual selser
29669 # changes. The automated selser changes for all tests handle the
29670 # wide variation of changes, but these tests here capture specs
29671 # deterministically.
29672 # ----------------------------------------------------------------
29673
29674 ## T90517
29675 !! test
29676 Selser: New comments should not be lost
29677 !! options
29678 parsoid={
29679 "modes": ["selser"],
29680 "changes": [
29681 [ "#a", "after", "<!--c1-->" ],
29682 [ "#b", "before", "<!--c2-->" ]
29683 ]
29684 }
29685 !! wikitext
29686 <span id="a">a</span>
29687
29688 <span id="b">b</span>
29689 !! wikitext/edited
29690 <span id="a">a</span><!--c1-->
29691
29692 <!--c2--><span id="b">b</span>
29693 !! end
29694
29695 ## T89383
29696 !! test
29697 Selser: Check for validity of DSR before using it
29698 !! options
29699 parsoid={
29700 "modes": ["selser"],
29701 "changes": [
29702 [ "#a", "before", "<meta property='mw:PageProp/displaytitle' content='foo'>" ]
29703 ]
29704 }
29705 !! wikitext
29706 <span id="a">a</span>
29707 !! wikitext/edited
29708 {{DISPLAYTITLE:foo}}
29709 <span id="a">a</span>
29710 !! end
29711
29712 !! test
29713 1. DOMDiff: Changes to <ref> content should be looked up using id
29714 !! options
29715 parsoid={
29716 "modes": ["selser"],
29717 "changes": [
29718 ["#X", "after", "bar"],
29719 ["#Y", "after", "baz"]
29720 ]
29721 }
29722 !! wikitext
29723 X <ref><span id="X">foo</span></ref>
29724 Y <ref name="a" />
29725 <references>
29726 <ref name="a"><span id="Y">foo</span></ref>
29727 </references>
29728 !! wikitext/edited
29729 X <ref><span id="X">foo</span>bar</ref>
29730 Y <ref name="a" />
29731 <references>
29732 <ref name="a"><span id="Y">foo</span>baz</ref>
29733 </references>
29734 !! end
29735
29736 !! test
29737 2. DOMDiff: Changes to <ref> content should be looked up using id
29738 !! options
29739 parsoid={
29740 "modes": ["selser"],
29741 "changes": [
29742 ["#Z", "after", "bar"]
29743 ]
29744 }
29745 !! wikitext
29746 A <ref>foo bar for a</ref>
29747 B <ref group="X" name="b" />
29748
29749 <references />
29750
29751 <references group="X">
29752 <ref name="b"><span id="Z">foo</span></ref>
29753 </references>
29754 !! wikitext/edited
29755 A <ref>foo bar for a</ref>
29756 B <ref group="X" name="b" />
29757
29758 <references />
29759
29760 <references group="X">
29761 <ref name="b"><span id="Z">foo</span>bar</ref>
29762 </references>
29763 !! end
29764
29765 !! test
29766 DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388)
29767 !! options
29768 parsoid={
29769 "modes": ["selser"],
29770 "changes": [
29771 [ "div:first-child", "text", "bar" ]
29772 ]
29773 }
29774 !! wikitext
29775 <div style="{{1x|color:red;}}%">foo</div>
29776 !! wikitext/edited
29777 <div style="{{1x|color:red;}}%">bar</div>
29778 !! end
29779
29780 !! test
29781 Empty LI (T49673)
29782 !! wikitext
29783 *a
29784 *
29785 *
29786 *b
29787 !! html+tidy
29788 <ul><li>a</li>
29789 <li class="mw-empty-elt"></li>
29790 <li class="mw-empty-elt"></li>
29791 <li>b</li></ul>
29792 !! end
29793
29794 !! test
29795 Thumbnail output
29796 !! wikitext
29797 [[File:Thumb.png|thumb]]
29798 !! html/php+tidy
29799 <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>
29800 !! html/parsoid
29801 <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>
29802 !! end
29803
29804 !! test
29805 unclosed internal link XSS (T137264)
29806 !! wikitext
29807 [[#%3Cscript%3Ealert(1)%3C/script%3E|
29808 !! html/php
29809 <p>[[#&lt;script&gt;alert(1)&lt;/script&gt;|
29810 </p>
29811 !! html/parsoid
29812 <p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p>
29813 !! end
29814
29815 !! test
29816 Validating that <style> isn't eaten by tidy (T167349)
29817 !! options
29818 styletag=1
29819 !! wikitext
29820 <div class="foo">
29821 <style>.foo::before { content: "<foo>"; }</style>
29822 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
29823 </div>
29824 !! html/php+tidy
29825 <div class="foo">
29826 <style>.foo::before { content: "<foo>"; }</style>
29827 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
29828 </div>
29829 !! end
29830
29831 !! test
29832 Validating that <style> isn't wrapped in a paragraph (T186965)
29833 !! options
29834 styletag=1
29835 !! wikitext
29836 A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
29837
29838 <style>.foo::before { content: "<foo>"; }</style>
29839
29840 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
29841
29842 But if it's on a line with other content, let it be wrapped.
29843
29844 <style>.foo::before { content: "<foo>"; }</style> bar
29845
29846 foo <style>.foo::before { content: "<foo>"; }</style>
29847
29848 foo <style>.foo::before { content: "<foo>"; }</style> bar
29849
29850 And the same if we have non-paragraph-breaking whitespace
29851
29852 foo
29853 <style>.foo::before { content: "<foo>"; }</style>
29854 bar
29855 !! html/php
29856 <p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
29857 </p>
29858 <style>.foo::before { content: "<foo>"; }</style>
29859 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
29860 <p>But if it's on a line with other content, let it be wrapped.
29861 </p><p><style>.foo::before { content: "<foo>"; }</style> bar
29862 </p><p>foo <style>.foo::before { content: "<foo>"; }</style>
29863 </p><p>foo <style>.foo::before { content: "<foo>"; }</style> bar
29864 </p><p>And the same if we have non-paragraph-breaking whitespace
29865 </p><p>foo
29866 <style>.foo::before { content: "<foo>"; }</style>
29867 bar
29868 </p>
29869 !! end
29870
29871 !! test
29872 Validating that <link> isn't wrapped in a paragraph (T186965)
29873 !! options
29874 styletag=1
29875 !! wikitext
29876 A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
29877
29878 <link rel="foo" href="bar"/>
29879
29880 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
29881
29882 But if it's on a line with other content, let it be wrapped.
29883
29884 <link rel="foo" href="bar"/> bar
29885
29886 foo <link rel="foo" href="bar"/>
29887
29888 foo <link rel="foo" href="bar"/> bar
29889
29890 And the same if we have non-paragraph-breaking whitespace
29891
29892 foo
29893 <link rel="foo" href="bar"/>
29894 bar
29895 !! html/php
29896 <p>A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
29897 </p>
29898 <link rel="foo" href="bar"/>
29899 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
29900 <p>But if it's on a line with other content, let it be wrapped.
29901 </p><p><link rel="foo" href="bar"/> bar
29902 </p><p>foo <link rel="foo" href="bar"/>
29903 </p><p>foo <link rel="foo" href="bar"/> bar
29904 </p><p>And the same if we have non-paragraph-breaking whitespace
29905 </p><p>foo
29906 <link rel="foo" href="bar"/>
29907 bar
29908 </p>
29909 !! end
29910
29911 !! test
29912 Decoding of HTML entities in headings and links for IDs and link fragments (T103714)
29913 !! config
29914 wgFragmentMode=[ 'html5', 'legacy' ]
29915 !! wikitext
29916 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
29917 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
29918 !! html/php
29919 <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>
29920 <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>
29921 </p>
29922 !! html/parsoid
29923 <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>
29924 <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>
29925 !! end
29926
29927 !! test
29928 Decoding of HTML entities in headings and links for IDs and link fragments (T103714) (legacy)
29929 !! config
29930 wgFragmentMode=[ 'legacy' ]
29931 !! wikitext
29932 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
29933 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
29934 !! html/php
29935 <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>
29936 <p><a href="#A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a>
29937 </p>
29938 !! end
29939
29940 !! test
29941 Decoding of HTML entities in embedded HTML tags
29942 !! wikitext
29943 <table class="1&2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
29944 !! html/php
29945 <table class="1&amp;2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
29946
29947 !! html/parsoid
29948 <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>
29949 !! end
29950
29951 !! test
29952 Decoding of HTML entities in indicator names for IDs (T104196)
29953 !! options
29954 parsoid=wt2html,html2html
29955 showindicators
29956 !! wikitext
29957 <indicator name="1&2&amp;3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
29958 !! html/php
29959 1&2&3&amp;4&amp;amp;5=Indicator
29960
29961 !! html/parsoid
29962 <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>
29963 !! end
29964
29965 # this version of the test strips out the ambiguity so Parsoid rts cleanly
29966 !! test
29967 Decoding of HTML entities in indicator names for IDs (unambiguous) (T104196)
29968 !! options
29969 showindicators
29970 !! wikitext
29971 <indicator name="1&2&3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
29972 !! html/php
29973 1&2&3&amp;4&amp;amp;5=Indicator
29974
29975 !! html/parsoid
29976 <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>
29977 !! end
29978
29979 # This fragment mode is what Parsoid supports.
29980 !! test
29981 HTML5 ids: fallback to legacy
29982 !! config
29983 wgFragmentMode=[ 'html5', 'legacy' ]
29984 !! wikitext
29985 ==Foo bar==
29986
29987 ==foo Bar==
29988
29989 ==Тест==
29990
29991 ==Тест==
29992
29993 ==тест==
29994
29995 ==Hey < # " > % : '==
29996 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
29997
29998 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
29999
30000 <!-- These two links should produce identical HTML -->
30001 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
30002
30003 !! html/php
30004 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
30005 <ul>
30006 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
30007 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
30008 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
30009 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
30010 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
30011 <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>
30012 </ul>
30013 </div>
30014
30015 <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>
30016 <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>
30017 <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>
30018 <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>
30019 <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>
30020 <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>
30021 <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>
30022 </p><p>💩 <span id="💩"></span>
30023 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
30024 </p>
30025 !! html/parsoid
30026 <h2 id="Foo_bar">Foo bar</h2>
30027
30028 <h2 id="foo_Bar_2">foo Bar</h2>
30029
30030 <h2 id="Тест"><span id=".D0.A2.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>Тест</h2>
30031
30032 <h2 id="Тест_2"><span id=".D0.A2.D0.B5.D1.81.D1.82_2" typeof="mw:FallbackId"></span>Тест</h2>
30033
30034 <h2 id="тест"><span id=".D1.82.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>тест</h2>
30035
30036 <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>
30037 <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>
30038
30039 <p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode:💩","function":"anchorencode"},"params":{},"i":0}}]}'>💩</span> <span id="💩" about="#mwt3" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"id"},{"html":"&lt;span about=\"#mwt2\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[]],\"dsr\":[178,197,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"anchorencode:💩\",\"function\":\"anchorencode\"},\"params\":{},\"i\":0}}]}&#39;>💩&lt;/span>"}]]}'></span></p>
30040
30041 <!-- These two links should produce identical HTML -->
30042 <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>
30043 !! end
30044
30045 # Parsoid doesn't support this mode
30046 !! test
30047 HTML5 ids: legacy with a fallback to modern
30048 !! config
30049 wgFragmentMode=[ 'legacy', 'html5' ]
30050 !! wikitext
30051 ==Foo bar==
30052
30053 ==foo Bar==
30054
30055 ==Тест==
30056
30057 ==Тест==
30058
30059 ==тест==
30060
30061 ==Hey < # " > % : '==
30062 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
30063
30064 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
30065
30066 <!-- These two links should produce identical HTML -->
30067 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
30068
30069 !! html/php
30070 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
30071 <ul>
30072 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
30073 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
30074 <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>
30075 <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>
30076 <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>
30077 <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>
30078 </ul>
30079 </div>
30080
30081 <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>
30082 <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>
30083 <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>
30084 <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>
30085 <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>
30086 <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>
30087 <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>
30088 </p><p>.F0.9F.92.A9 <span id=".F0.9F.92.A9"></span>
30089 </p><p><a href="#.E5.95.A4.E9.85.92">#啤酒</a> <a href="#.E5.95.A4.E9.85.92">#啤酒</a>
30090 </p>
30091 !! end
30092
30093 # Parsoid doesn't support this mode.
30094 !! test
30095 HTML5 ids: no legacy
30096 !! config
30097 wgFragmentMode=[ 'html5' ]
30098 !! wikitext
30099 ==Foo bar==
30100
30101 ==foo Bar==
30102
30103 ==Тест==
30104
30105 ==Тест==
30106
30107 ==тест==
30108
30109 ==Hey < # " > % : '==
30110 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
30111
30112 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
30113
30114 <!-- These two links should produce identical HTML -->
30115 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
30116
30117 !! html/php
30118 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
30119 <ul>
30120 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
30121 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
30122 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
30123 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
30124 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
30125 <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>
30126 </ul>
30127 </div>
30128
30129 <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>
30130 <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>
30131 <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>
30132 <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>
30133 <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>
30134 <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>
30135 <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>
30136 </p><p>💩 <span id="💩"></span>
30137 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
30138 </p>
30139 !! end
30140
30141 !! test
30142 T90902: Normalize weird characters in section IDs
30143 !! config
30144 wgFragmentMode=[ 'html5', 'legacy' ]
30145 !! wikitext
30146 ==Foo&nbsp;bar==
30147 [[#Foo&nbsp;bar]]
30148
30149 !! html/php
30150 <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>
30151 <p><a href="#Foo_bar">#Foo&#160;bar</a>
30152 </p>
30153 !! html/parsoid
30154 <h2 id="Foo_bar"> Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span>bar </h2>
30155 <p><a rel="mw:WikiLink" href="./Main_Page#Foo_bar" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Foo_bar"},"sa":{"href":"#Foo&amp;nbsp;bar"}}'>#Foo bar</a></p>
30156 !! end
30157
30158 !! test
30159 T51672: Test for brackets in attributes of elements in external link texts
30160 !! wikitext
30161 [http://example.com/ link <span title="title with [brackets]">span</span>]
30162 [http://example.com/ link <span title="title with &#91;brackets&#93;">span</span>]
30163
30164 !! html/php
30165 <p><a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
30166 <a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
30167 </p>
30168 !! html/parsoid
30169 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/">link <span title="title with [brackets]">span</span></a>
30170 <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>
30171 !! end
30172
30173 !! test
30174 T72875: Test for brackets in attributes of elements in internal link texts
30175 !! wikitext
30176 [[Foo|link <span title="title with [[double brackets]]">span</span>]]
30177 [[Foo|link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span>]]
30178
30179 !! html/php
30180 <p><a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
30181 <a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
30182 </p>
30183 !! html/parsoid
30184 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">link <span title="title with [[double brackets]]">span</span></a>
30185 <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>
30186 !! end
30187
30188 !! test
30189 T179544: {{anchorencode:}} output should be always usable in links
30190 !! config
30191 wgFragmentMode=[ 'html5' ]
30192 !! wikitext
30193 <span id="{{anchorencode:[foo]}}"></span>[[#{{anchorencode:[foo]}}]]
30194 !! html/php
30195 <p><span id="&#91;foo&#93;"></span><a href="#[foo]">#&#91;foo&#93;</a>
30196 </p>
30197 !! html/parsoid
30198 <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>
30199 !! end
30200
30201 ## ------------------------------
30202 ## Parsoid section-wrapping tests
30203 ## ------------------------------
30204 !! test
30205 Section wrapping for well-nested sections (no leading content)
30206 !! options
30207 parsoid={
30208 "wrapSections": true
30209 }
30210 !! wikitext
30211 =1=
30212 a
30213
30214 =2=
30215 b
30216
30217 ==2.1==
30218 c
30219
30220 ==2.2==
30221 d
30222
30223 ===2.2.1===
30224 e
30225
30226 =3=
30227 f
30228 !! html/parsoid
30229 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
30230 <p>a</p>
30231
30232 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
30233 <p>b</p>
30234
30235 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
30236 <p>c</p>
30237
30238 </section><section data-mw-section-id="4"><h2 id="2.2">2.2</h2>
30239 <p>d</p>
30240
30241 <section data-mw-section-id="5"><h3 id="2.2.1">2.2.1</h3>
30242 <p>e</p>
30243
30244 </section></section></section><section data-mw-section-id="6"><h1 id="3">3</h1>
30245 <p>f</p>
30246
30247 </section>
30248 !! end
30249
30250 !! test
30251 Section wrapping for well-nested sections (with leading content)
30252 !! options
30253 parsoid={
30254 "wrapSections": true
30255 }
30256 !! wikitext
30257 Para 1.
30258
30259 Para 2 with a <div>nested in it</div>
30260
30261 Para 3.
30262
30263 =1=
30264 a
30265
30266 =2=
30267 b
30268
30269 ==2.1==
30270 c
30271 !! html/parsoid
30272 <section data-mw-section-id="0"><p>Para 1.</p>
30273
30274 <p>Para 2 with a </p><div>nested in it</div>
30275
30276 <p>Para 3.</p>
30277
30278 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
30279 <p>a</p>
30280
30281 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
30282 <p>b</p>
30283
30284 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
30285 <p>c</p>
30286
30287 </section></section>
30288 !! end
30289
30290 !! test
30291 Section wrapping with template-generated sections (good nesting 1)
30292 !! options
30293 parsoid={
30294 "wrapSections": true
30295 }
30296 !! wikitext
30297 =1=
30298 a
30299
30300 {{echo|1=
30301 ==1.1==
30302 b
30303 }}
30304
30305 ==1.2==
30306 c
30307
30308 =2=
30309 d
30310 !! html/parsoid
30311 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
30312 <p>a</p>
30313
30314 <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">
30315 </span><p about="#mwt1">b</p>
30316 </section><section data-mw-section-id="3"><h2 id="1.2">1.2</h2>
30317 <p>c</p>
30318
30319 </section></section><section data-mw-section-id="4"><h1 id="2">2</h1>
30320 <p>d</p></section>
30321 !! end
30322
30323 # In this example, the template scope is mildly expanded to incorporate the
30324 # trailing newline after the transclusion since that is part of section 1.1.1
30325 !! test
30326 Section wrapping with template-generated sections (good nesting 2)
30327 !! options
30328 parsoid={
30329 "wrapSections": true,
30330 "modes": ["wt2html", "wt2wt"]
30331 }
30332 !! wikitext
30333 =1=
30334 a
30335
30336 {{echo|1=
30337 ==1.1==
30338 b
30339 ===1.1.1===
30340 d
30341 }}
30342 =2=
30343 e
30344 !! html/parsoid
30345 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
30346 <p>a</p>
30347
30348 <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">
30349 </span><p about="#mwt1">b</p><span about="#mwt1">
30350 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.1.1">1.1.1</h3><span about="#mwt1">
30351 </span><p about="#mwt1">d</p><span about="#mwt1">
30352 </span></section></section></section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="2">2</h1>
30353 <p>e</p></section>
30354 !! end
30355
30356 # In this example, the template scope is mildly expanded to incorporate the
30357 # trailing newline after the transclusion since that is part of section 1.2.1
30358 !! test
30359 Section wrapping with template-generated sections (good nesting 3)
30360 !! options
30361 parsoid={
30362 "wrapSections": true,
30363 "modes": ["wt2html", "wt2wt"]
30364 }
30365 !! wikitext
30366 =1=
30367 a
30368
30369 {{echo|1=
30370 x
30371 ==1.1==
30372 b
30373 ==1.2==
30374 c
30375 ===1.2.1===
30376 d
30377 }}
30378 =2=
30379 e
30380 !! html/parsoid
30381 <section data-mw-section-id="0"></section><section data-mw-section-id="1" data-parsoid="{}"><h1 id="1"> 1 </h1>
30382 <p>a</p>
30383
30384 <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">
30385 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.1">1.1</h2><span about="#mwt1">
30386 </span><p about="#mwt1">b</p><span about="#mwt1">
30387 </span></section><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.2">1.2</h2><span about="#mwt1">
30388 </span><p about="#mwt1">c</p><span about="#mwt1">
30389 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.2.1">1.2.1</h3><span about="#mwt1">
30390 </span><p about="#mwt1">d</p><span about="#mwt1">
30391 </span></section></section></section><section data-mw-section-id="5"><h1 id="2">2</h1>
30392 <p>e</p></section>
30393 !! end
30394
30395 # Because of section-wrapping and template-wrapping interactions,
30396 # the scope of the template is expanded so that the template markup
30397 # is valid in the presence of <section> tags.
30398 # This exercises the s1 is null scenario in the wrapSections code
30399 !! test
30400 Section wrapping with template-generated sections (bad nesting 1)
30401 !! options
30402 parsoid={
30403 "wrapSections": true
30404 }
30405 !! wikitext
30406 <div>
30407 a
30408
30409 {{echo|
30410 =1=
30411 b
30412 }}
30413
30414 c
30415 </div>
30416 !! html/parsoid
30417 <section data-mw-section-id="-1"></section><section data-mw-section-id="-2"><div data-parsoid='{"stx":"html"}'>
30418 <p>a</p>
30419
30420 <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"]}'>
30421 </span><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="1">1</h1><span about="#mwt1">
30422 </span><p about="#mwt1">b
30423 </p><span about="#mwt1">
30424
30425 </span><p about="#mwt1">c</p><span about="#mwt1">
30426 </span></section></div></section>
30427 !! end
30428
30429 # Because of section-wrapping and template-wrapping interactions,
30430 # the scope of the template is expanded so that the template markup
30431 # is valid in the presence of <section> tags.
30432 # This exercises the s1 is ancestor of s2 scenario in the wrapSections code
30433 !! test
30434 Section wrapping with template-generated sections (bad nesting 2)
30435 !! options
30436 parsoid={
30437 "wrapSections": true
30438 }
30439 !! wikitext
30440 =1=
30441 a
30442
30443 {{echo|1=
30444 =2=
30445 b
30446 ==2.1==
30447 c
30448 }}
30449
30450 d
30451
30452 =3=
30453 e
30454 !! html/parsoid
30455 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
30456 <p>a</p>
30457
30458 </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">
30459 </span><p about="#mwt1">b</p><span about="#mwt1">
30460 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="2.1">2.1</h2><span about="#mwt1">
30461 </span><p about="#mwt1">c</p><span about="#mwt1">
30462
30463 </span><p about="#mwt1">d</p><span about="#mwt1">
30464
30465 </span></section></section><section data-mw-section-id="4"><h1 id="3">3</h1>
30466 <p>e</p></section>
30467 !! end
30468
30469 # Because of section-wrapping and template-wrapping interactions,
30470 # additional template wrappers are added to <section> tags
30471 # so that template wrapping semantics are valid whether section
30472 # tags are retained or stripped. But, the template scope can expand
30473 # greatly when accounting for section tags.
30474 # This exercises the s1 and s2 are in different subtrees scenario
30475 !! test
30476 Section wrapping with template-generated sections (bad nesting 3)
30477 !! options
30478 parsoid={
30479 "wrapSections": true,
30480 "modes": ["wt2html", "wt2wt"]
30481 }
30482 !! wikitext
30483 =1=
30484 a
30485
30486 {{echo|1=
30487 ==1.2==
30488 b
30489 =2=
30490 c
30491 }}
30492
30493 d
30494
30495 =3=
30496 e
30497 !! html/parsoid
30498 <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>
30499 <p>a</p>
30500
30501 <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">
30502 </span><p about="#mwt1">b</p><span about="#mwt1">
30503 </span></section></section><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="2">2</h1><span about="#mwt1">
30504 </span><p about="#mwt1">c</p>
30505
30506 <p>d</p>
30507 </section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="3">3</h1>
30508 <p>e</p></section>
30509 !! end
30510
30511 !! test
30512 Section wrapping with uneditable lead section + div wrapping multiple sections
30513 !! options
30514 parsoid={
30515 "wrapSections": true
30516 }
30517 !! wikitext
30518 foo
30519
30520 <div style="border:1px solid red;">
30521 =1=
30522 a
30523
30524 ==1.1==
30525 b
30526
30527 =2=
30528 c
30529 </div>
30530
30531 =3=
30532 d
30533
30534 ==3.1==
30535 e
30536 !! html/parsoid
30537 <section data-mw-section-id="-1"><p>foo</p>
30538
30539 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
30540 <section data-mw-section-id="1"><h1 id="1">1</h1>
30541 <p>a</p>
30542
30543 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
30544 <p>b</p>
30545
30546 </section></section><section data-mw-section-id="-1"><h1 id="2">2</h1>
30547 <p>c</p>
30548 </section></div>
30549
30550 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
30551 <p>d</p>
30552
30553 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
30554 <p>e</p>
30555 </section></section>
30556 !! end
30557
30558 !! test
30559 Section wrapping with editable lead section + div overlapping multiple sections
30560 !! options
30561 parsoid={
30562 "wrapSections": true
30563 }
30564 !! wikitext
30565 foo
30566
30567 =1=
30568 a
30569 <div style="border:1px solid red;">
30570 b
30571
30572 ==1.1==
30573 c
30574
30575 =2=
30576 d
30577 </div>
30578 e
30579
30580 =3=
30581 f
30582
30583 ==3.1==
30584 g
30585 !! html/parsoid
30586 <section data-mw-section-id="0"><p>foo</p>
30587
30588 </section><section data-mw-section-id="-1"><h1 id="1">1</h1>
30589 <p>a</p>
30590 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
30591 <p>b</p>
30592
30593 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
30594 <p>c</p>
30595
30596 </section><section data-mw-section-id="-1"><h1 id="2">2</h1>
30597 <p>d</p>
30598 </section></div>
30599 <p>e</p>
30600
30601 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
30602 <p>f</p>
30603
30604 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
30605 <p>g</p>
30606 </section></section>
30607 !! end
30608
30609 !! test
30610 HTML header tags should not be wrapped in section tags
30611 !! options
30612 parsoid={
30613 "wrapSections": true
30614 }
30615 !! wikitext
30616 foo
30617
30618 <h1>a</h1>
30619
30620 =b=
30621
30622 <h1>c</h1>
30623
30624 =d=
30625 !! html/parsoid
30626 <section data-mw-section-id="0"><p>foo</p>
30627
30628 <h1 id="a" data-parsoid='{"stx":"html"}'>a</h1>
30629
30630 </section><section data-mw-section-id="1"><h1 id="b">b</h1>
30631
30632 <h1 id="c" data-parsoid='{"stx":"html"}'>c</h1>
30633
30634 </section><section data-mw-section-id="2"><h1 id="d">d</h1></section>
30635 !! end
30636
30637 !! test
30638 Lead section containing only whitespace and comments.
30639 !! options
30640 parsoid={
30641 "wrapSections": true
30642 }
30643 !! wikitext
30644
30645 <!-- this is a comment, presumably significant to editors -->
30646 =1=
30647 a
30648
30649 =2=
30650 b
30651 !! html/parsoid
30652 <section data-mw-section-id="0" data-parsoid="{}">
30653 <!-- this is a comment, presumably significant to editors -->
30654 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
30655 <p>a</p>
30656
30657 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
30658 <p>b</p></section>
30659 !! end
30660
30661 !! test
30662 Pseudo-sections emitted by templates should have id -2
30663 !! options
30664 parsoid={
30665 "wrapSections": true
30666 }
30667 !! wikitext
30668 foo
30669 {{echo|<div>
30670 ==a==
30671 ==b==
30672 </div>
30673 }}
30674 !! html/parsoid
30675 <section data-mw-section-id="-1"><p>foo</p>
30676 </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}}]}'>
30677 <section data-mw-section-id="-1"><h2 id="a">a</h2>
30678 </section><section data-mw-section-id="-1"><h2 id="b">b</h2>
30679 </section></div><span about="#mwt1">
30680 </span></section>
30681 !! end
30682
30683 ##########################################################################
30684 Tests demonstrating white-space insensitivity in input wikitext
30685 for wikitext headings, wikitext list items, and wikitext table captions,
30686 headings, and cells. HTML versions of the same should preserve whitespace.
30687 ##########################################################################
30688 !! test
30689 Trim whitespace in wikitext headings, list items, table captions, headings, and cells
30690 !! wikitext
30691 __NOTOC__
30692 == <!--c1--> <!--c2--> Spaces <!--c3--> <!--c4--> ==
30693 == <!--c2--> <!--c2--> Tabs <!--c3--><!--c4--> ==
30694 * <!--c1--> <!--c2--> List item <!--c3--> <!--c4-->
30695 ; <!--term to define--> term : <!--term's definition--> definition
30696 {|
30697 |+ <!--c1--> <!--c2--> Table Caption <!--c3--> <!--c4-->
30698 |-
30699 ! <!--c1--> <!--c2--> Table Heading 1 <!--c3--> <!--c4--> !! Table Heading 2 <!--c5-->
30700 |-
30701 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
30702 |-
30703 | class="foo" || <!--c1--> <!--c2--> Table Cell 3 <!--c3--> <!--c4-->
30704 |-
30705 | <!--c1--> testing [[one|two]] <!--c2--> | <!--c3--> some content
30706 |}
30707 : {|
30708 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
30709 |} foo <!--c1-->
30710 !! html/php+tidy
30711 <h2><span class="mw-headline" id="Spaces">Spaces</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Spaces">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
30712 <h2><span class="mw-headline" id="Tabs">Tabs</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Tabs">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
30713 <ul><li>List item</li></ul>
30714 <dl><dt>term&#160;</dt>
30715 <dd>definition</dd></dl>
30716 <table>
30717 <caption>Table Caption
30718 </caption>
30719 <tbody><tr>
30720 <th>Table Heading 1</th>
30721 <th>Table Heading 2
30722 </th></tr>
30723 <tr>
30724 <td>Table Cell 1</td>
30725 <td>Table Cell 2
30726 </td></tr>
30727 <tr>
30728 <td>class="foo"</td>
30729 <td>Table Cell 3
30730 </td></tr>
30731 <tr>
30732 <td>testing <a href="/index.php?title=One&amp;action=edit&amp;redlink=1" class="new" title="One (page does not exist)">two</a> | some content
30733 </td></tr></tbody></table>
30734 <dl><dd><table>
30735 <tbody><tr>
30736 <td>Table Cell 1</td>
30737 <td>Table Cell 2
30738 </td></tr></tbody></table> foo</dd></dl>
30739 !! end
30740
30741 # Looks like <caption> is not accepted in HTML
30742 !! test
30743 Do not trim whitespace in HTML headings, list items, table captions, headings, and cells
30744 !! wikitext
30745 __NOTOC__
30746 <h2> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
30747 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
30748 <table>
30749 <tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> <th></tr>
30750 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> <th></tr>
30751 </table>
30752 !! html/php+tidy
30753 <h2><span class="mw-headline" id="Heading"> Heading </span></h2>
30754 <ul><li> List item </li></ul>
30755 <table>
30756 <tbody><tr><th> Table Heading </th><th></th></tr>
30757 <tr><td> Table Cell </td><th></th></tr>
30758 </tbody></table>
30759 !! end
30760
30761 !! test
30762 Do not trim whitespace in links and quotes
30763 !! wikitext
30764 foo '' <!--c1--> italic <!--c2--> '' and ''' <!--c3--> bold <!--c4--> '''
30765 [[Foo| some text ]]
30766 !! html/php+tidy
30767 <p>foo <i> italic </i> and <b> bold </b>
30768 <a href="/wiki/Foo" title="Foo"> some text </a>
30769 </p>
30770 !! end
30771
30772 !! test
30773 Remove p tags surrounding a single element in a figcaption
30774 !! options
30775 parsoid=html2wt
30776 !! wikitext
30777 [[File:Foobar.jpg|right|200x200px|Caption]]
30778 !! html/parsoid
30779 <figure class="mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="23" width="200"/></a><figcaption><p>Caption</p></figcaption></figure>
30780 !! end
30781
30782 !! test
30783 Selser preserves lack of newline before list and allows newline after the list
30784 !! options
30785 parsoid={
30786 "modes": ["selser"],
30787 "scrubWikitext": true,
30788 "changes": [
30789 [ "ul", "after", "<p>footer</p>" ]
30790 ]
30791 }
30792 !! wikitext
30793 header
30794 *foo
30795 *bar
30796 !! wikitext/edited
30797 header
30798 *foo
30799 *bar
30800
30801 footer
30802 !! end
30803
30804
30805 !! test
30806 Selser does not introduce newlines between unedited paragraph preceding the list
30807 !! options
30808 parsoid={
30809 "modes": ["selser"],
30810 "changes": [
30811 [ "table tbody tr td p:last-child", "empty" ]
30812 ]
30813 }
30814 !! wikitext
30815 {|
30816 |
30817 header
30818 *foo
30819 *bar
30820 footer
30821 |}
30822 !! wikitext/edited
30823 {|
30824 |
30825 header
30826 *foo
30827 *bar
30828
30829 |}
30830 !! end
30831
30832 !! test
30833 Selser does not introduce newlines between unedited paragraph following the list
30834 !! options
30835 parsoid={
30836 "modes": ["selser"],
30837 "changes": [
30838 [ "table tbody tr td p:first-child", "empty" ]
30839 ]
30840 }
30841 !! wikitext
30842 {|
30843 |
30844 header
30845 *foo
30846 *bar
30847 footer
30848 |}
30849 !! wikitext/edited
30850 {|
30851 |
30852
30853 *foo
30854 *bar
30855 footer
30856 |}
30857 !! end
30858
30859 !! test
30860 Remove a list item but do not insert newline above list
30861 !! options
30862 parsoid={
30863 "modes": ["selser"],
30864 "changes": [
30865 [ "ul li:last-child", "remove" ]
30866 ]
30867 }
30868 !! wikitext
30869 header
30870 *foo
30871 *bar
30872 footer
30873 !! wikitext/edited
30874 header
30875 *foo
30876 footer
30877 !! end
30878
30879 !! test
30880 Check soft hyphens as entities (&shy;) in displaytitle (T66528)
30881 !! options
30882 showtitle
30883 title=[[Lopadotemachoselachogaleokranioleipsanodrimhypotrimmatosilphioparaomelitokatakechymenokichlepikossyphophattoperisteralektryonoptekephalliokigklopeleiolagoiosiraiobaphetraganopterygon]]
30884 !! wikitext
30885 {{DISPLAYTITLE:Lopado&shy;temacho&shy;selacho&shy;galeo&shy;kranio&shy;leipsano&shy;drim&shy;hypo&shy;trimmato&shy;silphio&shy;parao&shy;melito&shy;katakechy&shy;meno&shy;kichl&shy;epi&shy;kossypho&shy;phatto&shy;perister&shy;alektryon&shy;opte&shy;kephallio&shy;kigklo&shy;peleio&shy;lagoio&shy;siraio&shy;baphe&shy;tragano&shy;pterygon}}
30886 !! html/php
30887 Lopado&#173;temacho&#173;selacho&#173;galeo&#173;kranio&#173;leipsano&#173;drim&#173;hypo&#173;trimmato&#173;silphio&#173;parao&#173;melito&#173;katakechy&#173;meno&#173;kichl&#173;epi&#173;kossypho&#173;phatto&#173;perister&#173;alektryon&#173;opte&#173;kephallio&#173;kigklo&#173;peleio&#173;lagoio&#173;siraio&#173;baphe&#173;tragano&#173;pterygon
30888
30889 !! end
30890
30891 !! test
30892 Check soft hyphens as Unicode characters (U+00AD) in displaytitle (T66528)
30893 !! options
30894 showtitle
30895 title=[[Lopadotemachoselachogaleokranioleipsanodrimhypotrimmatosilphioparaomelitokatakechymenokichlepikossyphophattoperisteralektryonoptekephalliokigklopeleiolagoiosiraiobaphetraganopterygon]]
30896 !! wikitext
30897 {{DISPLAYTITLE:Lopado­temacho­selacho­galeo­kranio­leipsano­drim­hypo­trimmato­silphio­parao­melito­katakechy­meno­kichl­epi­kossypho­phatto­perister­alektryon­opte­kephallio­kigklo­peleio­lagoio­siraio­baphe­tragano­pterygon}}
30898 !! html/php
30899 Lopado­temacho­selacho­galeo­kranio­leipsano­drim­hypo­trimmato­silphio­parao­melito­katakechy­meno­kichl­epi­kossypho­phatto­perister­alektryon­opte­kephallio­kigklo­peleio­lagoio­siraio­baphe­tragano­pterygon
30900
30901 !! end