Don't armor french spaces before punctuation followed by word characters
[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 a
331
332 b (+2 nls)
333
334
335 c (+3 nls)
336
337
338
339 d (+4 nls)
340
341
342
343
344 e (+5 nls)
345 !! html
346 <p>a
347 </p><p>b (+2 nls)
348 </p><p><br />
349 c (+3 nls)
350 </p><p><br />
351 </p><p>d (+4 nls)
352 </p><p><br />
353 </p><p><br />
354 e (+5 nls)
355 </p>
356 !! end
357
358 !! test
359 Paragraphs with newline spacing with comment lines in between
360 !! wikitext
361 ----
362 a
363 <!--foo-->
364 b
365 ----
366 a
367 <!--foo--><!--More than 1 comment, still stripped-->
368 b
369 ----
370 a
371 <!--foo--> <!----> <!-- bar -->
372 b
373 ----
374 a
375 <!--foo-->
376
377 b
378 ----
379 a
380
381 <!--foo-->
382 b
383 ----
384 a
385 <!--foo-->
386
387
388 b
389 ----
390 a
391
392
393 <!--foo-->
394 b
395 ----
396 !! html
397 <hr />
398 <p>a
399 b
400 </p>
401 <hr />
402 <p>a
403 b
404 </p>
405 <hr />
406 <p>a
407 b
408 </p>
409 <hr />
410 <p>a
411 </p><p>b
412 </p>
413 <hr />
414 <p>a
415 </p><p>b
416 </p>
417 <hr />
418 <p>a
419 </p><p><br />
420 b
421 </p>
422 <hr />
423 <p>a
424 </p><p><br />
425 b
426 </p>
427 <hr />
428
429 !! end
430
431 !! test
432 Paragraphs with newline spacing with non-empty white-space lines in between
433 !! wikitext
434 ----
435 a
436
437 b
438 ----
439 a
440
441
442 b
443 ----
444 !! html
445 <hr />
446 <p>a
447 </p><p>b
448 </p>
449 <hr />
450 <p>a
451 </p><p><br />
452 b
453 </p>
454 <hr />
455
456 !! end
457
458 !! test
459 Paragraphs with newline spacing with non-empty mixed comment and white-space lines in between
460 !! wikitext
461 ----
462 a
463 <!--foo-->
464 b
465 ----
466 a
467 <!--foo--><!--More than 1 comment doesn't disable stripping of this line!-->
468 b
469 ----
470 a
471
472 <!--foo-->
473 <!--bar-->
474 b
475 ----
476 a
477
478 <!--foo-->
479 <!--bar-->
480
481 b
482 ----
483 !! html
484 <hr />
485 <p>a
486 b
487 </p>
488 <hr />
489 <p>a
490 b
491 </p>
492 <hr />
493 <p>a
494 </p><p>b
495 </p>
496 <hr />
497 <p>a
498 </p><p><br />
499 b
500 </p>
501 <hr />
502
503 !! end
504
505 !! test
506 Extra newlines: More paragraphs with indented comment
507 !! wikitext
508 a
509
510 <!--boo-->
511
512 b
513 !! html
514 <p>a
515 </p><p><br />
516 b
517 </p>
518 !!end
519
520 !! test
521 Extra newlines followed by heading
522 !! wikitext
523 a
524
525
526 =b=
527 [[a]]
528
529
530 =b=
531 !! html
532 <p>a
533 </p><p><br />
534 </p>
535 <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>
536 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
537 </p><p><br />
538 </p>
539 <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>
540
541 !! end
542
543 !! test
544 Extra newlines between heading and content are swallowed (Parsoid does not)
545 !! wikitext
546 =b=
547
548
549
550 [[a]]
551 !! html/php+tidy
552 <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>
553 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
554 </p>
555 !! html/parsoid
556 <h1 id="b">b</h1>
557 <p>
558 <br></p>
559
560 <p><a rel="mw:WikiLink" href="./A" title="A">a</a></p>
561 !! end
562
563 !! test
564 Extra new lines before and after lists are preserved
565 !! wikitext
566 a
567
568
569 *b
570
571
572 c
573 !! html/php+tidy
574 <p>a
575 </p><p><br />
576 </p>
577 <ul><li>b</li></ul>
578 <p><br />
579 c
580 </p>
581 !! html/parsoid
582 <p>a</p>
583 <p>
584 <br></p>
585 <ul><li>b</li></ul>
586 <p>
587 <br>
588 c</p>
589 !! end
590
591 # Parsoid regression test
592 !!test
593 Multiple newlines after tables are converted to p-br-p tags
594 !!options
595 parsoid=wt2html,wt2wt
596 !!wikitext
597 {|
598 |x
599 |}
600
601
602
603
604 =b=
605 !!html/php+tidy
606 <table>
607 <tbody><tr>
608 <td>x
609 </td></tr></tbody></table>
610 <p><br />
611 </p><p><br />
612 </p>
613 <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>
614 !!html/parsoid
615 <table>
616 <tbody>
617 <tr>
618 <td>x</td>
619 </tr>
620 </tbody>
621 </table>
622 <p><br/></p>
623 <p><br/></p>
624 <h1 id="b">b</h1>
625 !!end
626
627 !! test
628 Heading with line break in nowiki
629 !! options
630 parsoid=wt2html
631 !! config
632 wgFragmentMode=[ 'html5', 'legacy' ]
633 !! wikitext
634 ==A <nowiki>B
635 C</nowiki>==
636 !! html/php
637 <h2><span id="A_B.0AC"></span><span class="mw-headline" id="A_B
638 C">A B
639 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>
640
641 !! html/parsoid
642 <h2 id="A_B
643 C"><span id="A_B.0AC" typeof="mw:FallbackId"></span>A <span typeof="mw:Nowiki">B
644 C</span></h2>
645 !! end
646
647 !! test
648 Parsing an URL
649 !! wikitext
650 http://fr.wikipedia.org/wiki/🍺
651 <!-- EasterEgg we love beer, better be able be able to link to it -->
652 !! html
653 <p><a rel="nofollow" class="external free" href="http://fr.wikipedia.org/wiki/🍺">http://fr.wikipedia.org/wiki/🍺</a>
654 </p>
655 !! end
656
657 !! test
658 Simple list
659 !! wikitext
660 *Item 1
661 *Item 2
662 !! html
663 <ul><li>Item 1</li>
664 <li>Item 2</li></ul>
665
666 !! end
667
668 !! test
669 Italics and bold
670 !! wikitext
671 *plain
672 *plain''italic''plain
673 *plain''italic''plain''italic''plain
674 *plain'''bold'''plain
675 *plain'''bold'''plain'''bold'''plain
676 *plain''italic''plain'''bold'''plain
677 *plain'''bold'''plain''italic''plain
678 *plain''italic'''bold-italic'''italic''plain
679 *plain'''bold''bold-italic''bold'''plain
680 *plain'''''bold-italic'''italic''plain
681 *plain'''''bold-italic''bold'''plain
682 *plain''italic'''bold-italic'''''plain
683 *plain'''bold''bold-italic'''''plain
684 *plain l'''italic''plain
685 *plain l''''bold''' plain
686 !! html
687 <ul><li>plain</li>
688 <li>plain<i>italic</i>plain</li>
689 <li>plain<i>italic</i>plain<i>italic</i>plain</li>
690 <li>plain<b>bold</b>plain</li>
691 <li>plain<b>bold</b>plain<b>bold</b>plain</li>
692 <li>plain<i>italic</i>plain<b>bold</b>plain</li>
693 <li>plain<b>bold</b>plain<i>italic</i>plain</li>
694 <li>plain<i>italic<b>bold-italic</b>italic</i>plain</li>
695 <li>plain<b>bold<i>bold-italic</i>bold</b>plain</li>
696 <li>plain<i><b>bold-italic</b>italic</i>plain</li>
697 <li>plain<b><i>bold-italic</i>bold</b>plain</li>
698 <li>plain<i>italic<b>bold-italic</b></i>plain</li>
699 <li>plain<b>bold<i>bold-italic</i></b>plain</li>
700 <li>plain l'<i>italic</i>plain</li>
701 <li>plain l'<b>bold</b> plain</li></ul>
702
703 !! end
704
705 # this example taken from the [[simple:Moon]] article (T49326)
706 !! test
707 Italics and possessives (1)
708 !! wikitext
709 obtained by ''[[Lunar Prospector]]'''s gamma-ray spectrometer
710 !! html
711 <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
712 </p>
713 !! end
714
715 # this example taken from [[en:Flaming Pie]] (T51926)
716 !! test
717 Italics and possessives (2)
718 !! wikitext
719 '''''Flaming Pie''''' is ... released in 1997. In ''Flaming Pie'''s liner notes
720 !! html
721 <p><i><b>Flaming Pie</b></i> is ... released in 1997. In <i>Flaming Pie'</i>s liner notes
722 </p>
723 !! end
724
725 # this example taken from [[en:Dictionary]] (T51926)
726 !! test
727 Italics and possessives (3)
728 !! wikitext
729 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''.
730 !! html
731 <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>.
732 </p>
733 !! end
734
735
736 ###
737 ### 2-quote opening sequence tests
738 ###
739 !! test
740 Italics and bold: 2-quote opening sequence: (2,2)
741 !! wikitext
742 ''foo''
743 !! html
744 <p><i>foo</i>
745 </p>
746 !!end
747
748 !! test
749 Italics and bold: 2-quote opening sequence: (2,3)
750 !! wikitext
751 ''foo'''
752 !! html/*
753 <p><i>foo'</i>
754 </p>
755 !!end
756
757 !! test
758 Italics and bold: 2-quote opening sequence: (2,4)
759 !! options
760 parsoid=wt2html
761 !! wikitext
762 ''foo''''
763 !! html/*
764 <p><i>foo''</i>
765 </p>
766 !!end
767
768 # same html as previous, but wikitext adjusted to match parsoid html2wt
769 !! test
770 Italics and bold: 2-quote opening sequence: (2,4) w/ nowiki
771 !! wikitext
772 ''foo<nowiki>''</nowiki>''
773 !! html
774 <p><i>foo''</i>
775 </p>
776 !! end
777
778 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
779 !! test
780 Italics and bold: 2-quote opening sequence: (2,5)
781 !! options
782 parsoid=wt2html
783 !! wikitext
784 ''foo'''''
785 !! html/php
786 <p><i>foo</i>
787 </p>
788 !! html/parsoid
789 <p><i>foo</i><b></b>
790 </p>
791 !!end
792
793 # same html as previous, but wikitext adjusted to match parsoid html2wt
794 !! test
795 Italics and bold: 2-quote opening sequence: (2,5+3) w/ nowiki
796 !! wikitext
797 ''foo'''''<nowiki/>'''
798 !! html/php
799 <p><i>foo</i>
800 </p>
801 !! html/parsoid
802 <p><i>foo</i><b></b>
803 </p>
804 !! end
805
806
807 ###
808 ### 3-quote opening sequence tests
809 ###
810
811 !! test
812 Italics and bold: 3-quote opening sequence: (3,2)
813 !! wikitext
814 '''foo''
815 !! html/*
816 <p>'<i>foo</i>
817 </p>
818 !!end
819
820 !! test
821 Italics and bold: 3-quote opening sequence: (3,3)
822 !! wikitext
823 '''foo'''
824 !! html
825 <p><b>foo</b>
826 </p>
827 !!end
828
829 !! test
830 Italics and bold: 3-quote opening sequence: (3,4)
831 !! wikitext
832 '''foo''''
833 !! html/*
834 <p><b>foo'</b>
835 </p>
836 !!end
837
838 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
839 !! test
840 Italics and bold: 3-quote opening sequence: (3,5)
841 !! options
842 parsoid=wt2html
843 !! wikitext
844 '''foo'''''
845 !! html/php
846 <p><b>foo</b>
847 </p>
848 !! html/parsoid
849 <p><b>foo</b><i></i>
850 </p>
851 !!end
852
853 # same html as previous, but wikitext adjusted to match parsoid html2wt
854 !! test
855 Italics and bold: 3-quote opening sequence: (3,5+2) w/ nowiki
856 !! wikitext
857 '''foo'''''<nowiki/>''
858 !! html/php
859 <p><b>foo</b>
860 </p>
861 !! html/parsoid
862 <p><b>foo</b><i></i>
863 </p>
864 !! end
865
866
867 ###
868 ### 4-quote opening sequence tests
869 ###
870
871 !! test
872 Italics and bold: 4-quote opening sequence: (4,2)
873 !! options
874 parsoid=wt2html
875 !! wikitext
876 ''''foo''
877 !! html/*
878 <p>''<i>foo</i>
879 </p>
880 !!end
881
882 # same html as previous, but wikitext adjusted to match parsoid html2wt
883 !! test
884 Italics and bold: 4-quote opening sequence: (4,2) w/ nowiki
885 !! wikitext
886 <nowiki>''</nowiki>''foo''
887 !! html
888 <p>''<i>foo</i>
889 </p>
890 !! end
891
892 !! test
893 Italics and bold: 4-quote opening sequence: (4,3)
894 !! wikitext
895 ''''foo'''
896 !! html/*
897 <p>'<b>foo</b>
898 </p>
899 !!end
900
901 !! test
902 Italics and bold: 4-quote opening sequence: (4,4)
903 !! options
904 parsoid=wt2html
905 !! wikitext
906 ''''foo''''
907 !! html/*
908 <p>'<b>foo'</b>
909 </p>
910 !!end
911
912 # same html as previous, but wikitext adjusted to match parsoid html2wt
913 !! test
914 Italics and bold: 4-quote opening sequence: (4,4) w/ nowiki
915 !! wikitext
916 '<nowiki/>'''foo''''
917 !! html
918 <p>'<b>foo'</b>
919 </p>
920 !! end
921
922 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
923 !! test
924 Italics and bold: 4-quote opening sequence: (4,5)
925 !! options
926 parsoid=wt2html
927 !! wikitext
928 ''''foo'''''
929 !! html/php
930 <p>'<b>foo</b>
931 </p>
932 !! html/parsoid
933 <p>'<b>foo</b><i></i>
934 </p>
935 !!end
936
937 # same html as previous, but wikitext adjusted to match parsoid html2wt
938 !! test
939 Italics and bold: 4-quote opening sequence: (4,5+2) w/ nowiki
940 !! wikitext
941 '<nowiki/>'''foo'''''<nowiki/>''
942 !! html/php
943 <p>'<b>foo</b>
944 </p>
945 !! html/parsoid
946 <p>'<b>foo</b><i></i>
947 </p>
948 !! end
949
950
951 ###
952 ### 5-quote opening sequence tests
953 ###
954
955 !! test
956 Italics and bold: 5-quote opening sequence: (5,2)
957 !! options
958 parsoid=wt2html
959 !! wikitext
960 '''''foo''
961 !! html/*
962 <p><b><i>foo</i></b>
963 </p>
964 !!end
965
966 # same html as previous, but wikitext adjusted to match parsoid html2wt
967 !! test
968 Italics and bold: 5-quote opening sequence: (5,2+3)
969 !! wikitext
970 '''''foo'''''
971 !! html/*
972 <p><i><b>foo</b></i>
973 </p>
974 !! end
975
976 !! test
977 Italics and bold: 5-quote opening sequence: (5,3)
978 !! options
979 parsoid=wt2html
980 !! wikitext
981 '''''foo'''
982 !! html/*
983 <p><i><b>foo</b></i>
984 </p>
985 !!end
986
987 # same html as previous, but wikitext adjusted to match parsoid html2wt
988 !! test
989 Italics and bold: 5-quote opening sequence: (5,3+2)
990 !! wikitext
991 '''''foo'''''
992 !! html
993 <p><i><b>foo</b></i>
994 </p>
995 !! end
996
997 !! test
998 Italics and bold: 5-quote opening sequence: (5,4)
999 !! options
1000 parsoid=wt2html
1001 !! wikitext
1002 '''''foo''''
1003 !! html/*
1004 <p><i><b>foo'</b></i>
1005 </p>
1006 !!end
1007
1008 !! test
1009 Italics and bold: 5-quote opening sequence: (5,5)
1010 !! wikitext
1011 '''''foo'''''
1012 !! html
1013 <p><i><b>foo</b></i>
1014 </p>
1015 !!end
1016
1017 !! test
1018 Italics and bold: 5-quote opening sequence: (5,6)
1019 !! wikitext
1020 '''''foo''''''
1021 !! html/*
1022 <p><i><b>foo'</b></i>
1023 </p>
1024 !! end
1025
1026 ###
1027 ### multiple quote sequences in a line
1028 ###
1029
1030 !! test
1031 Italics and bold: multiple quote sequences: (2,4,2)
1032 !! options
1033 parsoid=wt2html
1034 !! wikitext
1035 ''foo''''bar''
1036 !! html/*
1037 <p><i>foo'<b>bar</b></i>
1038 </p>
1039 !! end
1040
1041 # same html as previous, but wikitext adjusted to match parsoid html2wt
1042 !! test
1043 Italics and bold: multiple quote sequences: (2,4,2+3) w/ nowiki
1044 !! wikitext
1045 ''foo'<nowiki/>'''bar'''''
1046 !! html
1047 <p><i>foo'<b>bar</b></i>
1048 </p>
1049 !! end
1050
1051 !! test
1052 Italics and bold: multiple quote sequences: (2,4,3)
1053 !! options
1054 parsoid=wt2html
1055 !! wikitext
1056 ''foo''''bar'''
1057 !! html/*
1058 <p><i>foo'<b>bar</b></i>
1059 </p>
1060 !! end
1061
1062 # same html as previous, but wikitext adjusted to match parsoid html2wt
1063 !! test
1064 Italics and bold: multiple quote sequences: (2,4,3+2) w/ nowiki
1065 !! wikitext
1066 ''foo'<nowiki/>'''bar'''''
1067 !! html
1068 <p><i>foo'<b>bar</b></i>
1069 </p>
1070 !! end
1071
1072 !! test
1073 Italics and bold: multiple quote sequences: (2,4,4)
1074 !! options
1075 parsoid=wt2html
1076 !! wikitext
1077 ''foo''''bar''''
1078 !! html/*
1079 <p><i>foo'<b>bar'</b></i>
1080 </p>
1081 !! end
1082
1083 # same html as previous, but wikitext adjusted to match parsoid html2wt
1084 !! test
1085 Italics and bold: multiple quote sequences: (2,4,4+2) w/ nowiki
1086 !! wikitext
1087 ''foo'<nowiki/>'''bar'<nowiki/>'''''
1088 !! html
1089 <p><i>foo'<b>bar'</b></i>
1090 </p>
1091 !! end
1092
1093 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1094 !! test
1095 Italics and bold: multiple quote sequences: (3,4,2)
1096 !! options
1097 parsoid=wt2html
1098 !! wikitext
1099 '''foo''''bar''
1100 !! html/php
1101 <p><b>foo'</b>bar
1102 </p>
1103 !! html/parsoid
1104 <p><b>foo'</b>bar<i></i>
1105 </p>
1106 !! end
1107
1108 # same html as previous, but wikitext adjusted to match parsoid html2wt
1109 !! test
1110 Italics and bold: multiple quote sequences: (3,4,2+2) w/ nowiki
1111 !! wikitext
1112 '''foo''''bar''<nowiki/>''
1113 !! html/php
1114 <p><b>foo'</b>bar
1115 </p>
1116 !! html/parsoid
1117 <p><b>foo'</b>bar<i></i>
1118 </p>
1119 !! end
1120
1121 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1122 !! test
1123 Italics and bold: multiple quote sequences: (3,4,3)
1124 !! options
1125 parsoid=wt2html
1126 !! wikitext
1127 '''foo''''bar'''
1128 !! html/php
1129 <p><b>foo'</b>bar
1130 </p>
1131 !! html/parsoid
1132 <p><b>foo'</b>bar<b></b>
1133 </p>
1134 !! end
1135
1136 # same html as previous, but wikitext adjusted to match parsoid html2wt
1137 !! test
1138 Italics and bold: multiple quote sequences: (3,4,3+3) w/ nowiki
1139 !! wikitext
1140 '''foo''''bar'''<nowiki/>'''
1141 !! html/php
1142 <p><b>foo'</b>bar
1143 </p>
1144 !! html/parsoid
1145 <p><b>foo'</b>bar<b></b>
1146 </p>
1147 !! end
1148
1149 ###
1150 ### other quote tests
1151 ###
1152 !! test
1153 Italics and bold: other quote tests: (2,3,5)
1154 !! wikitext
1155 ''this is about '''foo's family'''''
1156 !! html
1157 <p><i>this is about <b>foo's family</b></i>
1158 </p>
1159 !!end
1160
1161
1162 !! test
1163 Italics and bold: other quote tests: (2,(3,3),2)
1164 !! wikitext
1165 ''this is about '''foo's''' family''
1166 !! html
1167 <p><i>this is about <b>foo's</b> family</i>
1168 </p>
1169 !!end
1170
1171
1172 !! test
1173 Italics and bold: other quote tests: (3,2,3,2)
1174 !! options
1175 parsoid=wt2html
1176 !! wikitext
1177 '''this is about ''foo'''s family''
1178 !! html/*
1179 <p><b>this is about <i>foo</i></b><i>s family</i>
1180 </p>
1181 !!end
1182
1183
1184 # same html as previous, but wikitext adjusted to match parsoid html2wt
1185 !! test
1186 Italics and bold: other quote tests: (3,2,3+2+2,2)
1187 !! wikitext
1188 '''this is about ''foo'''''<nowiki/>''s family''
1189 !! html
1190 <p><b>this is about <i>foo</i></b><i>s family</i>
1191 </p>
1192 !! end
1193
1194
1195 !! test
1196 Italics and bold: other quote tests: (3,2,3,3)
1197 !! wikitext
1198 '''this is about ''foo'''s family'''
1199 !! html/*
1200 <p>'<i>this is about </i>foo<b>s family</b>
1201 </p>
1202 !!end
1203
1204
1205 !! test
1206 Italics and bold: other quote tests: (3,(2,2),3)
1207 !! wikitext
1208 '''this is about ''foo's'' family'''
1209 !! html
1210 <p><b>this is about <i>foo's</i> family</b>
1211 </p>
1212 !!end
1213
1214
1215 !! test
1216 Italicized possessive
1217 !! wikitext
1218 The ''[[Main Page]]'''s talk page.
1219 !! html/php
1220 <p>The <i><a href="/wiki/Main_Page" title="Main Page">Main Page</a>'</i>s talk page.
1221 </p>
1222 !! html/parsoid
1223 <p>The <i><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>'</i>s talk page.</p>
1224 !! end
1225
1226 !! test
1227 Quote balancing context should be restricted to td/th cells on the same wikitext line
1228 !! options
1229 parsoid=wt2html,wt2wt
1230 !! wikitext
1231 {|
1232 !''a!!''b
1233 |''a||''b
1234 |}
1235 !! html+tidy
1236 <table>
1237 <tbody><tr>
1238 <th><i>a</i></th>
1239 <th><i>b</i>
1240 </th>
1241 <td><i>a</i></td>
1242 <td><i>b</i>
1243 </td></tr></tbody></table>
1244 !! end
1245
1246 ###
1247 ### Non-html5 tags
1248 ###
1249
1250 !! test
1251 Non-html5 tags should be accepted
1252 !! wikitext
1253 <center>''foo''</center>
1254 <big>''foo''</big>
1255 <font>''foo''</font>
1256 <strike>''foo''</strike>
1257 <tt>''foo''</tt>
1258 !! html
1259 <center><i>foo</i></center>
1260 <p><big><i>foo</i></big>
1261 <font><i>foo</i></font>
1262 <strike><i>foo</i></strike>
1263 <tt><i>foo</i></tt>
1264 </p>
1265 !! end
1266
1267 !! test
1268 <wbr> is valid wikitext (T54468)
1269 !! wikitext
1270 <wbr>
1271 !! html
1272 <p><wbr />
1273 </p>
1274 !! end
1275
1276 # <strike> is HTML4, <s> is HTML4/5.
1277 !! test
1278 <s> or <strike> for strikethrough
1279 !! wikitext
1280 <strike>strike</strike>
1281
1282 <s>s</s>
1283 !! html
1284 <p><strike>strike</strike>
1285 </p><p><s>s</s>
1286 </p>
1287 !! end
1288
1289 ## a not permitted
1290 ## i,b,br omitted
1291 !! test
1292 Text-level semantic html elements in wikitext
1293 !! wikitext
1294 <em>text</em>
1295 <strong>text</strong>
1296 <small>text</small>
1297 <s>text</s>
1298 <cite>text</cite>
1299 <q>text</q>
1300 <dfn>text</dfn>
1301 <abbr>text</abbr>
1302 <data>text</data>
1303 <time>text</time>
1304 <code>text</code>
1305 <var>text</var>
1306 <samp>text</samp>
1307 <kbd>text</kbd>
1308 <sub>text</sub>
1309 <u>text</u>
1310 <mark>text</mark>
1311 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1312 <bdi>text</bdi>
1313 <bdo>text</bdo>
1314 <span>text</span>
1315 <wbr />
1316 !! html
1317 <p><em>text</em>
1318 <strong>text</strong>
1319 <small>text</small>
1320 <s>text</s>
1321 <cite>text</cite>
1322 <q>text</q>
1323 <dfn>text</dfn>
1324 <abbr>text</abbr>
1325 <data>text</data>
1326 <time>text</time>
1327 <code>text</code>
1328 <var>text</var>
1329 <samp>text</samp>
1330 <kbd>text</kbd>
1331 <sub>text</sub>
1332 <u>text</u>
1333 <mark>text</mark>
1334 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1335 <bdi>text</bdi>
1336 <bdo>text</bdo>
1337 <span>text</span>
1338 <wbr />
1339 </p>
1340 !! end
1341
1342 # test cases taken from
1343 # https://www.w3.org/TR/html5/text-level-semantics.html#the-ruby-element
1344 !! test
1345 Ruby markup (W3C-style)
1346 !! wikitext
1347 ;Mono-ruby for individual base characters
1348 :<ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby>
1349 ;Group ruby
1350 :<ruby>今日<rt>きょう</rt></ruby>
1351 ;Jukugo ruby
1352 :<ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby>
1353 ;Inline ruby
1354 :<ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby>
1355 ;Double-sided ruby
1356 :<ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby>
1357
1358 <ruby>
1359 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1360 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1361 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1362 </ruby>
1363 !! html
1364 <dl><dt>Mono-ruby for individual base characters</dt>
1365 <dd><ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby></dd>
1366 <dt>Group ruby</dt>
1367 <dd><ruby>今日<rt>きょう</rt></ruby></dd>
1368 <dt>Jukugo ruby</dt>
1369 <dd><ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby></dd>
1370 <dt>Inline ruby</dt>
1371 <dd><ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby></dd>
1372 <dt>Double-sided ruby</dt>
1373 <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>
1374 <p><ruby>
1375 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1376 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1377 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1378 </ruby>
1379 </p>
1380 !! end
1381
1382 # The next two test different paths in the sanitizer.
1383 !! test
1384 Non-word characters don't terminate tag names (T19663, T42670, T54022)
1385 !! wikitext
1386 <blockquote|>a</blockquote>
1387
1388 <b→> doesn't terminate </b→>
1389
1390 <bä> doesn't terminate </bä>
1391
1392 <boo> doesn't terminate </boo>
1393
1394 <s.foo> doesn't terminate </s.foo>
1395
1396 <sub-ID#1>
1397 !! html
1398 <p>&lt;blockquote|&gt;a&lt;/blockquote&gt;
1399 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1400 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1401 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1402 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1403 </p><p>&lt;sub-ID#1&gt;
1404 </p>
1405 !! end
1406
1407 !! test
1408 Non-word characters don't terminate tag names
1409 !! wikitext
1410 <blockquote|>a</blockquote>
1411
1412 <b→> doesn't terminate </b→>
1413
1414 <bä> doesn't terminate </bä>
1415
1416 <boo> doesn't terminate </boo>
1417
1418 <s.foo> doesn't terminate </s.foo>
1419
1420 <sub-ID#1>
1421 !! html+tidy
1422 <p>&lt;blockquote|&gt;a
1423 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1424 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1425 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1426 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1427 </p><p>&lt;sub-ID#1&gt;
1428 </p>
1429 !! end
1430
1431 ###
1432 ### See tests/parser/parserTestsParserHook.php for the <tåg> extension)
1433 ### This checks that HTML5 tags (with non-word characters in the tag
1434 ### name) make it safely through the parser -- the Sanitizer will
1435 ### munge them later, as it should.
1436 ###
1437 !! test
1438 Non-word characters are valid in extension tags (T19663)
1439 !! wikitext
1440 <tåg>tåg</tåg>
1441 !! html/php
1442 <pre>
1443 'tåg'
1444 array (
1445 )
1446 </pre>
1447
1448 !! html/parsoid
1449 <pre typeof="mw:Extension/tåg" data-mw='{"name":"tåg","attrs":{},"body":{"extsrc":"tåg"}}' data-parsoid='{}' about="#mwt2"></pre>
1450 !! end
1451
1452 !! test
1453 Isolated close tags should be treated as literal text (T54760)
1454 !! options
1455 parsoid=wt2html
1456 !! wikitext
1457 </b>
1458
1459 <s.foo>s</s>
1460 !! html/php+tidy
1461 <p class="mw-empty-elt">
1462 </p><p>&lt;s.foo&gt;s
1463 </p>
1464 !! html/parsoid
1465 <p>&lt;s.foo&gt;s</p>
1466 !! end
1467
1468 ###
1469 ### Special characters
1470 ###
1471
1472 !! test
1473 Bare pipe character (T54363)
1474 !! wikitext
1475 |
1476 !! html
1477 <p>|
1478 </p>
1479 !! end
1480
1481 !! test
1482 Bare pipe character from a template (T54363)
1483 !! wikitext
1484 {{pipe}}
1485 !! html
1486 <p>|
1487 </p>
1488 !! end
1489
1490 ###
1491 ### <nowiki> test cases
1492 ###
1493
1494 !! test
1495 <nowiki> unordered list
1496 !! wikitext
1497 <nowiki>* This is not an unordered list item.</nowiki>
1498 !! html/php
1499 <p>* This is not an unordered list item.
1500 </p>
1501 !! html/parsoid
1502 <p><span typeof="mw:Nowiki">* This is not an unordered list item.</span></p>
1503 !! end
1504
1505 !! test
1506 <nowiki> spacing
1507 !! wikitext
1508 <nowiki>Lorem ipsum dolor
1509
1510 sed abit.
1511 sed nullum.
1512
1513 :and a colon
1514 </nowiki>
1515 !! html/php
1516 <p>Lorem ipsum dolor
1517
1518 sed abit.
1519 sed nullum.
1520
1521 :and a colon
1522
1523 </p>
1524 !! html/parsoid
1525 <p><span typeof="mw:Nowiki">Lorem ipsum dolor
1526
1527 sed abit.
1528 sed nullum.
1529
1530 :and a colon
1531 </span></p>
1532 !! end
1533
1534 !! test
1535 Don't parse <nowiki><span class="error"></nowiki> (T149622)
1536 !! wikitext
1537 <nowiki><span class="error"></nowiki>
1538 !! html/php
1539 <p>&lt;span class="error"&gt;
1540 </p>
1541 !! html/parsoid
1542 <p><span typeof="mw:Nowiki">&lt;span class="error"></span></p>
1543 !! end
1544
1545 !! test
1546 nowiki 3
1547 !! wikitext
1548 :There is not nowiki.
1549 :There is <nowiki>nowiki</nowiki>.
1550
1551 #There is not nowiki.
1552 #There is <nowiki>nowiki</nowiki>.
1553
1554 *There is not nowiki.
1555 *There is <nowiki>nowiki</nowiki>.
1556 !! html/php
1557 <dl><dd>There is not nowiki.</dd>
1558 <dd>There is nowiki.</dd></dl>
1559 <ol><li>There is not nowiki.</li>
1560 <li>There is nowiki.</li></ol>
1561 <ul><li>There is not nowiki.</li>
1562 <li>There is nowiki.</li></ul>
1563
1564 !! html/parsoid
1565 <dl><dd data-parsoid='{}'>There is not nowiki.</dd>
1566 <dd data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</dd></dl>
1567
1568 <ol><li data-parsoid='{}'>There is not nowiki.</li>
1569 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ol>
1570
1571 <ul><li data-parsoid='{}'>There is not nowiki.</li>
1572 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ul>
1573 !! end
1574
1575 !! test
1576 Entities inside <nowiki>
1577 !! wikitext
1578 <nowiki>&lt;</nowiki>
1579 !! html/php
1580 <p>&lt;
1581 </p>
1582 !! html/parsoid
1583 <p><span typeof="mw:Nowiki"><span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span></span></p>
1584 !! end
1585
1586 !! test
1587 Entities inside template parameters
1588 !! wikitext
1589 {{echo|&ndash;}}
1590 !! html/php+tidy
1591 <p>&#8211;
1592 </p>
1593 !! html/parsoid
1594 <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>
1595 !! end
1596
1597 !! test
1598 Properly escape nowiki when combined with other wiki markup
1599 !! options
1600 parsoid=html2wt
1601 !! html/parsoid
1602 <p>* &lt;/nowiki&gt; tag</p>
1603 !! wikitext
1604 <nowiki>*</nowiki> <nowiki>&lt;/nowiki&gt;</nowiki> tag
1605 !! end
1606
1607 !! test
1608 T93824: Put escaped HTML tags inside nowiki
1609 !! options
1610 parsoid=html2wt
1611 !! html/parsoid
1612 <p>&lt;h2&gt;foo&lt;/h2&gt;</p>
1613 !! wikitext
1614 <nowiki><h2>foo</h2></nowiki>
1615 !! end
1616
1617 !! test
1618 T71950: 1. Put nowiki as close to cause as possible, even with non-quote escapable chars
1619 !! options
1620 parsoid=html2wt
1621 !! html/parsoid
1622 <p>This text: L'<a rel="mw:WikiLink" href="./Foo">Foo</a>
1623 This text: L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1624 This text: L'''<a rel="mw:WikiLink" href="./Foo">Foo</a>''</p>
1625 !! wikitext
1626 This text: L'[[Foo]]
1627 This text: L<nowiki>''</nowiki>[[Foo]]
1628 This text: L<nowiki>'''</nowiki>[[Foo]]<nowiki>''</nowiki>
1629 !! end
1630
1631 # This test fails because wikitext whitespace is not normalized before comparing.
1632 !! test
1633 T71950: 2. Put nowiki as close to cause as possible, after ' :'
1634 !! options
1635 parsoid=html2wt
1636 !! html/parsoid
1637 <p>This text : L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1638 </p>
1639 !! wikitext
1640 This text : L<nowiki>''</nowiki>[[Foo]]
1641 !! end
1642
1643 # This test and the next one are html2wt only as they test that incorrect wikitext
1644 # passed in template arguments gets escaped or wrapped in nowikis where required.
1645 !! test
1646 T71482: Use {{!}} instead of nowiki for single pipe in template argument
1647 !! options
1648 parsoid=html2wt
1649 !! html/parsoid
1650 <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>
1651 <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>
1652 !! wikitext
1653 {{echo|foo{{!}}bar}}
1654 {{echo|<nowiki>foo|bar |[[</nowiki>}}
1655 !! end
1656
1657 !! test
1658 T53961: Output correct nowikis in template arguments
1659 !! options
1660 parsoid=html2wt
1661 !! html/parsoid
1662 <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>
1663 <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>
1664 <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>
1665 <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>
1666 <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>
1667 !! wikitext
1668 {{echo|a [ b}}
1669 {{echo|<nowiki>a }} b</nowiki>}}
1670 {{echo|<nowiki>a [[ b</nowiki>}}
1671 {{echo|<nowiki>a | {{ ]]</nowiki>}}
1672 {{echo|a <nowiki>}</nowiki>}}
1673 !! end
1674
1675 !! test
1676 Cases where "!!" needs nowiki protection
1677 !! options
1678 parsoid=html2wt
1679 !! html/parsoid
1680 <table>
1681 <tr><th>this needs protection !! here</th></tr>
1682 </table>
1683
1684 <table>
1685 <tr><th>this does not need
1686 protection !! here</th></tr>
1687 </table>
1688 !! wikitext
1689 {|
1690 !<nowiki>this needs protection !! here</nowiki>
1691 |}
1692
1693 {|
1694 !this does not need
1695 protection !! here
1696 |}
1697 !! end
1698
1699 ###
1700 ### Comments
1701 ###
1702 !! test
1703 Comments and Indent-Pre
1704 !! wikitext
1705 <!-- comment 1 --> asdf
1706
1707 <!-- comment 1 --> asdf
1708 <!-- comment 2 -->
1709
1710 <!-- comment 1 --> asdf
1711 <!-- comment 2 -->xyz
1712
1713 <!-- comment 1 --> asdf
1714 <!-- comment 2 --> xyz
1715 !! html
1716 <pre>asdf
1717 </pre>
1718 <pre>asdf
1719 </pre>
1720 <pre>asdf
1721 </pre>
1722 <p>xyz
1723 </p>
1724 <pre>asdf
1725 xyz
1726 </pre>
1727 !! end
1728
1729 !! test
1730 Comment test 2a
1731 !! wikitext
1732 asdf
1733 <!-- comment 1 -->
1734 jkl
1735 !! html
1736 <p>asdf
1737 jkl
1738 </p>
1739 !! end
1740
1741 !! test
1742 Comment test 2b
1743 !! wikitext
1744 asdf
1745 <!-- comment 1 -->
1746
1747 jkl
1748 !! html
1749 <p>asdf
1750 </p><p>jkl
1751 </p>
1752 !! end
1753
1754 !! test
1755 Comment test 3
1756 !! wikitext
1757 asdf
1758 <!-- comment 1 -->
1759 <!-- comment 2 -->
1760 jkl
1761 !! html
1762 <p>asdf
1763 jkl
1764 </p>
1765 !! end
1766
1767 !! test
1768 Comment test 4
1769 !! wikitext
1770 asdf<!-- comment 1 -->jkl
1771 !! html
1772 <p>asdfjkl
1773 </p>
1774 !! end
1775
1776 !! test
1777 Comment spacing
1778 !! wikitext
1779 a
1780 <!-- foo --> b <!-- bar -->
1781 c
1782 !! html
1783 <p>a
1784 </p>
1785 <pre> b
1786 </pre>
1787 <p>c
1788 </p>
1789 !! end
1790
1791 !! test
1792 Comment whitespace
1793 !! wikitext
1794 <!-- returns a single newline, not nothing, since the newline after > is not stripped -->
1795 !! html
1796
1797 !! end
1798
1799 !! test
1800 Comment semantics and delimiters
1801 !! wikitext
1802 <!-- --><!----><!-----><!------>
1803 !! html/php
1804
1805 !! html/parsoid
1806 <!-- --><!----><!--&#x2D;--><!--&#x2D;&#x2D;-->
1807 !! end
1808
1809 !! test
1810 Comment semantics and delimiters, redux
1811 !! wikitext
1812 <!-- In SGML every "foo" here would actually show up in the text -- foo -- bar
1813 -- foo -- funky huh? ... -->
1814 !! html/php
1815
1816 !! html/parsoid
1817 <!-- In SGML every "foo" here would actually show up in the text &#x2D;&#x2D; foo &#x2D;&#x2D; bar
1818 &#x2D;&#x2D; foo &#x2D;&#x2D; funky huh? ... -->
1819 !! end
1820
1821 !! test
1822 Comment semantics and delimiters: directors cut
1823 !! wikitext
1824 <!-- ... However we like to keep things simple and somewhat XML-ish so we eat
1825 everything starting with < followed by !-- until the first -- and > we see,
1826 that wouldn't be valid XML however, since in XML -- has to terminate a comment
1827 -->-->
1828 !! html/php
1829 <p>--&gt;
1830 </p>
1831 !! html/parsoid
1832 <!-- ... However we like to keep things simple and somewhat XML&#x2D;ish so we eat
1833 everything starting with < followed by !&#x2D;&#x2D; until the first &#x2D;&#x2D; and &#x3E; we see,
1834 that wouldn't be valid XML however, since in XML &#x2D;&#x2D; has to terminate a comment
1835 --><p>--></p>
1836 !! end
1837
1838 !! test
1839 Comment semantics: nesting
1840 !! wikitext
1841 <!--<!-- no, we're not going to do anything fancy here -->-->
1842 !! html/php
1843 <p>--&gt;
1844 </p>
1845 !! html/parsoid
1846 <!--<!&#x2D;&#x2D; no, we're not going to do anything fancy here --><p>--></p>
1847 !! end
1848
1849 # Parsoid closes the unclosed comment, even if it means a slight
1850 # round-trip diff.
1851 !! test
1852 Comment semantics: unclosed comment at end
1853 !! options
1854 parsoid=wt2html,html2html
1855 !! wikitext
1856 <!--This comment will run out to the end of the document
1857 !! html/php
1858
1859 !! html/parsoid
1860 <!--This comment will run out to the end of the document-->
1861 !! end
1862
1863 !! test
1864 Comment semantics: normalize comments to play nice with XML and browsers
1865 !! wikitext
1866 <!-- Browsers --!> think this is closed -->
1867 <!--> This would normally be text -->
1868 <!---> As would this -->
1869 <!-- XML doesn't like trailing dashes -------->
1870 <!-- Nor doubled hyphens -- anywhere in the data -->
1871 But this is not a comment.
1872 !! html/php
1873 <p>But this is not a comment.
1874 </p>
1875 !! html/parsoid
1876 <!-- Browsers &#x2D;&#x2D;!&#x3E; think this is closed -->
1877 <!--&#x3E; This would normally be text -->
1878 <!--&#x2D;&#x3E; As would this -->
1879 <!-- XML doesn't like trailing dashes &#x2D;&#x2D;&#x2D;&#x2D;&#x2D;&#x2D;-->
1880 <!-- Nor doubled hyphens &#x2D;&#x2D; anywhere in the data -->
1881 <p>But this is not a comment.</p>
1882 !! end
1883
1884 !! test
1885 Comment semantics: round-trip even text which contains encoded -->
1886 !! wikitext
1887 <!-- hello & goodbye - > --&gt; --&amp;gt; --&xx -->
1888 !! html/parsoid
1889 <!-- hello &#x26; goodbye &#x2D; &#x3E; &#x2D;&#x2D;&#x3E; &#x2D;&#x2D;&#x26;gt; &#x2D;&#x2D;&#x26;xx -->
1890 !! end
1891
1892 !! test
1893 Comment in template title
1894 !! wikitext
1895 {{f<!---->oo}}
1896 !! html
1897 <p>FOO
1898 </p>
1899 !! end
1900
1901 !! test
1902 Comment on its own line post-expand
1903 !! wikitext
1904 a
1905 {{blank}}<!---->
1906 b
1907 !! html
1908 <p>a
1909 </p><p>b
1910 </p>
1911 !! end
1912
1913 !! test
1914 Comment on its own line post-expand with non-significant whitespace
1915 !! wikitext
1916 a
1917 {{blank}} <!---->
1918 b
1919 !! html
1920 <p>a
1921 </p><p>b
1922 </p>
1923 !! end
1924
1925 !! test
1926 post-expand include size being exceeded
1927 !! options
1928 maxincludesize=20
1929 !! wikitext
1930 {{echo3|1234567890}}
1931 !! html
1932 <p><a href="/wiki/Template:Echo3" title="Template:Echo3">Template:Echo3</a><!-- WARNING: template omitted, post-expand include size too large -->
1933 </p>
1934 !! end
1935
1936 !! test
1937 max template depth being reached
1938 !! options
1939 maxtemplatedepth=1
1940 !! wikitext
1941 {{echo with depth|too deep!}}
1942 !! html
1943 <p><span class="error">Template recursion depth limit exceeded (1)</span>
1944 </p>
1945 !! end
1946
1947 !! test
1948 multiple templates that are redirects
1949 !! wikitext
1950 {{redirect to foo}}
1951 {{redirect to foo}}
1952 !! html
1953 <p>FOO
1954 FOO
1955 </p>
1956 !! end
1957
1958 !! test
1959 Multiple comments should still parse as SOL-transparent
1960 !! options
1961 parsoid=wt2html,wt2wt
1962 !! wikitext
1963 <!--c1-->*a
1964 <!--c2--><!--c3--><!--c4-->*b
1965 !! html/php
1966 <ul><li>a</li>
1967 <li>b</li></ul>
1968
1969 !! html/parsoid
1970 <!--c1--><ul>
1971 <li>a
1972 </li>
1973 <!--c2--><!--c3--><!--c4-->
1974 <li>b
1975 </li>
1976 </ul>
1977 !! end
1978
1979 ## Make sure ">" gets escaped in comments to avoid XSS
1980 !! test
1981 IE conditional comments
1982 !! wikitext
1983 <!--[if lt IE 9]>
1984 <script>alert('hi');</script>
1985 <![endif]-->
1986 !! html/parsoid
1987 <!--[if lt IE 9]&#x3E;
1988 <script&#x3E;alert('hi');</script&#x3E;
1989 <![endif]-->
1990 !! end
1991
1992 ###
1993 ### paragraph wrapping tests
1994 ###
1995
1996 !! test
1997 No block tags
1998 !! wikitext
1999 a
2000
2001 b
2002 !! html
2003 <p>a
2004 </p><p>b
2005 </p>
2006 !! end
2007
2008 !! test
2009 Block tag on one line (<div>)
2010 !! wikitext
2011 a <div>foo</div>
2012
2013 b
2014 !! html
2015 a <div>foo</div>
2016 <p>b
2017 </p>
2018 !! html+tidy
2019 <p>a </p><div>foo</div>
2020 <p>b
2021 </p>
2022 !! end
2023
2024 # Remex wraps empty tag runs with p-tags.
2025 # Parsoid strips them out during p-wrapping.
2026 !! test
2027 No p-wrappable content
2028 !! wikitext
2029 <span><div>x</div></span>
2030 <span><s><div>x</div></s></span>
2031 <small><em></em></small><span><s><div>x</div></s></span>
2032 !! html/php+tidy
2033 <span><div>x</div></span>
2034 <span><s><div>x</div></s></span>
2035 <p><small><em></em></small></p><span><s><div>x</div></s></span>
2036 !! html/parsoid
2037 <span><div>x</div></span>
2038 <span><s><div>x</div></s></span>
2039 <small><em></em></small><span><s><div>x</div></s></span>
2040 !! end
2041
2042 # T177612: Parsoid-only test
2043 !! test
2044 Transclusion meta tags shouldn't trip Parsoid's useless p-wrapper stripping code
2045 !! wikitext
2046 {{echo|<span><div>x</div></span>}}
2047 x
2048 !! html/parsoid
2049 <span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;span>&lt;div>x&lt;/div>&lt;/span>"}},"i":0}}]}'><div>x</div></span>
2050 <p>x</p>
2051 !! end
2052
2053 !! test
2054 Block tag on one line (<blockquote>)
2055 !! wikitext
2056 a <blockquote>foo</blockquote>
2057
2058 b
2059 !! html
2060 a <blockquote>foo</blockquote>
2061 <p>b
2062 </p>
2063 !! html+tidy
2064 <p>a </p><blockquote><p>foo</p></blockquote>
2065 <p>b
2066 </p>
2067 !! end
2068
2069 !! test
2070 Block tag on both lines (<div>)
2071 !! wikitext
2072 a <div>foo</div>
2073
2074 b <div>foo</div>
2075 !! html
2076 a <div>foo</div>
2077 b <div>foo</div>
2078
2079 !! html+tidy
2080 <p>a </p><div>foo</div><p>
2081 b </p><div>foo</div>
2082 !! end
2083
2084 !! test
2085 Block tag on both lines (<blockquote>)
2086 !! wikitext
2087 a <blockquote>foo</blockquote>
2088
2089 b <blockquote>foo</blockquote>
2090 !! html
2091 a <blockquote>foo</blockquote>
2092 b <blockquote>foo</blockquote>
2093
2094 !! html+tidy
2095 <p>a </p><blockquote><p>foo</p></blockquote><p>
2096 b </p><blockquote><p>foo</p></blockquote>
2097 !! end
2098
2099 !! test
2100 Multiple lines without block tags
2101 !! wikitext
2102 <div>foo</div> a
2103 b
2104 c
2105 d<!--foo--> e
2106 x <div>foo</div> z
2107 !! html
2108 <div>foo</div> a
2109 <p>b
2110 c
2111 d e
2112 </p>
2113 x <div>foo</div> z
2114
2115 !! html+tidy
2116 <div>foo</div><p> a
2117 </p><p>b
2118 c
2119 d e
2120 </p><p>
2121 x </p><div>foo</div><p> z
2122 </p>
2123 !! end
2124
2125 # The difference between Parsoid & Remex here
2126 # is because of Parsoid's Tidy-emulation code
2127 # for p-wrapping. We'll start work to remove this
2128 # emulation code in Parsoid sooner than later.
2129 # Remex wraps empty tag runs with p-tags.
2130 # Parsoid strips them out in a separate pass.
2131 !! test
2132 Empty lines between lines with block tags
2133 !! wikitext
2134 <div></div>
2135
2136
2137 <div></div>a
2138
2139 b
2140 <div>a</div>b
2141
2142 <div>b</div>d
2143
2144
2145 <div>e</div>
2146 !! html
2147 <div></div>
2148 <p><br />
2149 </p>
2150 <div></div>a
2151 <p>b
2152 </p>
2153 <div>a</div>b
2154 <div>b</div>d
2155 <p><br />
2156 </p>
2157 <div>e</div>
2158
2159 !! html+tidy
2160 <div></div>
2161 <p><br />
2162 </p>
2163 <div></div><p>a
2164 </p><p>b
2165 </p>
2166 <div>a</div><p>b
2167 </p><div>b</div><p>d
2168 </p><p><br />
2169 </p>
2170 <div>e</div>
2171 !! html/parsoid
2172 <div data-parsoid='{"stx":"html"}'></div>
2173
2174 <p><br /></p>
2175 <div data-parsoid='{"stx":"html"}'></div><p>a</p>
2176
2177 <p>b</p>
2178 <div data-parsoid='{"stx":"html"}'>a</div><p>b</p>
2179
2180 <div data-parsoid='{"stx":"html"}'>b</div><p>d</p>
2181
2182 <p><br /></p>
2183 <div data-parsoid='{"stx":"html"}'>e</div>
2184 !! end
2185
2186 !! test
2187 Unclosed HTML p-tags should be handled properly
2188 !! wikitext
2189 <div><p>foo</div>
2190 a
2191
2192 b
2193 !! html/php+tidy
2194 <div><p>foo</p></div>
2195 <p>a
2196 </p><p>b
2197 </p>
2198 !! html/parsoid
2199 <div data-parsoid='{"stx":"html"}'><p data-parsoid='{"stx":"html", "autoInsertedEnd":true}'>foo</p></div>
2200 <p>a</p>
2201 <p>b</p>
2202 !! end
2203
2204 ## SSS FIXME: I can come up with other scenarios where this doesn't work because
2205 ## of eager output of buffered tokens in the p-wrapper. But, I'm going to ignore
2206 ## them for now.
2207 !! test
2208 1. P-wrapping should leave sol-transparent tags outside p-tags where possible
2209 !! options
2210 parsoid=wt2html
2211 !! wikitext
2212 a [[Category:A1]] [[Category:A2]]
2213 [[Category:A3]]
2214 [[Category:A4]]
2215 !! html/parsoid
2216 <p>a</p>
2217 <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"/>
2218 !! end
2219
2220 !! test
2221 2. P-wrapping should leave sol-transparent tags outside p-tags where possible
2222 !! options
2223 parsoid=wt2html
2224 !! wikitext
2225 [[Category:A1]]a
2226 !! html/parsoid
2227 <link rel="mw:PageProp/Category" href="./Category:A1"/><p>a</p>
2228 !! end
2229
2230 !! test
2231 No paragraph necessary for SOL transparent template
2232 !! wikitext
2233 <span><div>foo</div></span>
2234 [[Category:Foo]]
2235
2236 <span><div>foo</div></span>
2237 {{echo|[[Category:Foo]]}}
2238 !! html/php
2239 <span><div>foo</div></span>
2240 <span><div>foo</div></span>
2241
2242 !! html/parsoid
2243 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2244 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
2245
2246 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2247 <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}}]}'/>
2248 !! end
2249
2250 !! test
2251 Avoid expanding multiline sol transparent template ranges unnecessarily
2252 !! wikitext
2253 hi
2254
2255
2256 {{echo|<br/>
2257 }}
2258
2259 [[Category:Ho]]
2260 !! html/php
2261 <p>hi
2262 </p><p><br />
2263 <br />
2264 </p>
2265 !! html/parsoid
2266 <p>hi</p>
2267
2268 <p><br />
2269 <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">
2270 </span></p>
2271
2272 <link rel="mw:PageProp/Category" href="./Category:Ho" />
2273 !! end
2274
2275 ###
2276 ### Preformatted text
2277 ###
2278
2279 !! test
2280 Preformatted text
2281 !! wikitext
2282 This is some
2283 Preformatted text
2284 With ''italic''
2285 And '''bold'''
2286 And a [[Main Page|link]]
2287 !! html
2288 <pre>This is some
2289 Preformatted text
2290 With <i>italic</i>
2291 And <b>bold</b>
2292 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
2293 </pre>
2294 !! end
2295
2296 !! test
2297 Tabs don't trigger preformatted text
2298 !! wikitext
2299 This is not
2300 preformatted text.
2301 This is preformatted text.
2302 So is this.
2303 !! html/php
2304 <p> This is not
2305 preformatted text.
2306 </p>
2307 <pre>This is preformatted text.
2308 So is this.
2309 </pre>
2310 !! html/parsoid
2311 <p> This is not
2312 preformatted text.</p>
2313 <pre>This is preformatted text.
2314 So is this.</pre>
2315 !! end
2316
2317 !! test
2318 Space before tab needs nowiki pre protection
2319 !! options
2320 parsoid=html2wt
2321 !! html/parsoid
2322 <p> a</p>
2323 !! wikitext
2324 <nowiki> </nowiki> a
2325 !! end
2326
2327 !! test
2328 Ident preformatting with inline content
2329 !! wikitext
2330 a
2331 ''b''
2332 !! html
2333 <pre>a
2334 <i>b</i>
2335 </pre>
2336 !! end
2337
2338 !! test
2339 <pre> with <nowiki> inside (compatibility with 1.6 and earlier)
2340 !! wikitext
2341 <pre><nowiki>
2342 <b>
2343 <cite>
2344 <em>
2345 </nowiki></pre>
2346 !! html
2347 <pre>
2348 &lt;b&gt;
2349 &lt;cite&gt;
2350 &lt;em&gt;
2351 </pre>
2352
2353 !! end
2354
2355 !! test
2356 Regression with preformatted in <center>
2357 !! wikitext
2358 <center>
2359 Blah
2360 </center>
2361 !! html
2362 <center>
2363 <pre>Blah
2364 </pre>
2365 </center>
2366
2367 !! end
2368
2369 !! test
2370 T54763: Preformatted in <blockquote>
2371 !! wikitext
2372 <blockquote>
2373 Blah
2374 {|
2375 |
2376 indented cell (no pre-wrapping!)
2377 |}
2378 </blockquote>
2379 !! html
2380 <blockquote>
2381 <p> Blah
2382 </p>
2383 <table>
2384 <tr>
2385 <td>
2386 <p> indented cell (no pre-wrapping!)
2387 </p>
2388 </td></tr></table>
2389 </blockquote>
2390
2391 !! end
2392
2393 !! test
2394 T53086: Double newlines in blockquotes should be turned into paragraphs
2395 !! wikitext
2396 <blockquote>
2397 Foo
2398
2399 Bar
2400 </blockquote>
2401 !! html
2402 <blockquote>
2403 <p>Foo
2404 </p><p>Bar
2405 </p>
2406 </blockquote>
2407
2408 !! end
2409
2410 !! test
2411 T17491: <ins>/<del> in blockquote
2412 !! wikitext
2413 <blockquote>
2414 Foo <del>bar</del> <ins>baz</ins> quux
2415 </blockquote>
2416 !! html
2417 <blockquote>
2418 <p>Foo <del>bar</del> <ins>baz</ins> quux
2419 </p>
2420 </blockquote>
2421
2422 !! end
2423
2424 !! test
2425 T17491: <ins>/<del> in blockquote (2)
2426 !! wikitext
2427 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2428 </blockquote>
2429 !! html
2430 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2431 </blockquote>
2432
2433 !! html+tidy
2434 <blockquote><p>Foo </p><del>bar</del> <ins>baz</ins><p> quux
2435 </p></blockquote>
2436 !! end
2437
2438 !! test
2439 <pre> with attributes (T5202)
2440 !! wikitext
2441 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2442 !! html
2443 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2444
2445 !! end
2446
2447 !! test
2448 <pre> with width attribute (T5202)
2449 !! wikitext
2450 <pre width="8">Narrow screen goodies</pre>
2451 !! html
2452 <pre width="8">Narrow screen goodies</pre>
2453
2454 !! end
2455
2456 !! test
2457 <pre> with forbidden attribute (T5202)
2458 !! wikitext
2459 <pre width="8" onmouseover="alert(document.cookie)">Narrow screen goodies</pre>
2460 !! html
2461 <pre width="8">Narrow screen goodies</pre>
2462
2463 !! end
2464
2465 !! test
2466 Entities inside <pre>
2467 !! wikitext
2468 <pre>&lt;</pre>
2469 !! html
2470 <pre>&lt;</pre>
2471
2472 !! end
2473
2474 !! test
2475 <pre> with forbidden attribute values (T5202)
2476 !! wikitext
2477 <pre width="8" style="border-width: expression(alert(document.cookie))">Narrow screen goodies</pre>
2478 !! html
2479 <pre width="8" style="/* insecure input */">Narrow screen goodies</pre>
2480
2481 !! end
2482
2483 !! test
2484 <nowiki> inside <pre> (T15238)
2485 !! wikitext
2486 <pre>
2487 <nowiki>
2488 </pre>
2489 <pre>
2490 <nowiki></nowiki>
2491 </pre>
2492 <pre><nowiki><nowiki></nowiki>Foo<nowiki></nowiki></nowiki></pre>
2493 !! html
2494 <pre>
2495 &lt;nowiki&gt;
2496 </pre>
2497 <pre>
2498
2499 </pre>
2500 <pre>&lt;nowiki&gt;Foo&lt;/nowiki&gt;</pre>
2501
2502 !! end
2503
2504 !! test
2505 <nowiki> inside of #tag:pre
2506 !! wikitext
2507 {{#tag:pre|Foo <nowiki>&rarr;bar</nowiki>}}
2508 !! html/php
2509 <pre>Foo &#8594;bar</pre>
2510
2511 !! html/parsoid
2512 <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>
2513 !! end
2514
2515 ## Don't expect this to rt, Parsoid drops the unmatched closing pre tags that
2516 ## aren't enclosed in nowikis.
2517 !! test
2518 <nowiki> and <pre> preference (first one wins)
2519 !! options
2520 parsoid=wt2html
2521 !! wikitext
2522 <pre>
2523 <nowiki>
2524 </pre>
2525 </nowiki>
2526 </pre>
2527
2528 <nowiki>
2529 <pre>
2530 <nowiki>
2531 </pre>
2532 </nowiki>
2533 </pre>
2534
2535 !! html/php
2536 <pre>
2537 &lt;nowiki&gt;
2538 </pre>
2539 <p>&lt;/nowiki&gt;
2540 &lt;/pre&gt;
2541 </p><p>
2542 &lt;pre&gt;
2543 &lt;nowiki&gt;
2544 &lt;/pre&gt;
2545
2546 &lt;/pre&gt;
2547 </p>
2548 !! html/parsoid
2549 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n&lt;nowiki>\n"}}'>&lt;nowiki>
2550 </pre>
2551 <p>&lt;/nowiki></p>
2552
2553
2554 <p><span typeof="mw:Nowiki">
2555 &lt;pre>
2556 &lt;nowiki>
2557 &lt;/pre>
2558 </span></p>
2559 !! end
2560
2561 !! test
2562 </pre> inside nowiki
2563 !! wikitext
2564 <nowiki></pre></nowiki>
2565 !! html
2566 <p>&lt;/pre&gt;
2567 </p>
2568 !! end
2569
2570 !! test
2571 Empty pre; pre inside other HTML tags (T56946)
2572 !! wikitext
2573 a
2574
2575 <div><pre>
2576 foo
2577 </pre></div>
2578 <pre></pre>
2579 !! html/php+tidy
2580 <p>a
2581 </p>
2582 <div><pre>foo
2583 </pre></div>
2584 <pre></pre>
2585 !! html/parsoid
2586 <p>a</p>
2587
2588 <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
2589 </pre></div>
2590 <pre typeof="mw:Extension/pre" about="#mwt4" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":""}}'></pre>
2591 !! end
2592
2593 !! test
2594 HTML pre followed by indent-pre
2595 !! wikitext
2596 <pre>foo</pre>
2597 bar
2598 !! html
2599 <pre>foo</pre>
2600 <pre>bar
2601 </pre>
2602 !! end
2603
2604 !! test
2605 Block tag pre
2606 !! wikitext
2607 <p><pre>foo</pre></p>
2608 !! html/php+tidy
2609 <p class="mw-empty-elt"></p><pre>foo</pre><p class="mw-empty-elt"></p>
2610 !! html/parsoid
2611 <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>
2612 !! end
2613
2614 !!test
2615 Templates: Indent-Pre: 1a. Templates that break a line should suppress <pre>
2616 !! wikitext
2617 {{echo|}}
2618 !! html
2619
2620 !!end
2621
2622 !!test
2623 Templates: Indent-Pre: 1b. Templates that break a line should suppress <pre>
2624 !! wikitext
2625 {{echo|
2626 foo}}
2627 !! html
2628 <p>foo
2629 </p>
2630 !!end
2631
2632 !! test
2633 Templates: Indent-Pre: 1c: Wrapping should be based on expanded content
2634 !! wikitext
2635 {{echo|a
2636 b}}
2637 !! html
2638 <pre>a
2639 </pre>
2640 <p>b
2641 </p>
2642 !!end
2643
2644 !! test
2645 Templates: Indent-Pre: 1d: Wrapping should be based on expanded content
2646 !! wikitext
2647 {{echo|a
2648 b
2649 c
2650 d
2651 e
2652 }}
2653 !! html
2654 <pre>a
2655 </pre>
2656 <p>b
2657 c
2658 </p>
2659 <pre>d
2660 </pre>
2661 <p>e
2662 </p>
2663 !!end
2664
2665 !!test
2666 Templates: Indent-Pre: 1e. Wrapping should be based on expanded content
2667 !! wikitext
2668 {{echo| foo}}
2669
2670 {{echo| foo}}{{echo| bar}}
2671
2672 {{echo| foo}}
2673 {{echo| bar}}
2674
2675 {{echo|<!--cmt--> foo}}
2676
2677 <!--cmt-->{{echo| foo}}
2678
2679 {{echo|{{echo| }}bar}}
2680 !! html
2681 <pre>foo
2682 </pre>
2683 <pre>foo bar
2684 </pre>
2685 <pre>foo
2686 bar
2687 </pre>
2688 <pre>foo
2689 </pre>
2690 <pre>foo
2691 </pre>
2692 <pre>bar
2693 </pre>
2694 !!end
2695
2696 !! test
2697 Templates: Indent-Pre: 1f: Wrapping should be based on expanded content
2698 !! wikitext
2699 {{echo| }}a
2700
2701 {{echo|
2702 }}a
2703
2704 {{echo|
2705 b}}
2706
2707 {{echo|a
2708 }}b
2709
2710 {{echo|a
2711 }} b
2712 !! html
2713 <pre>a
2714 </pre>
2715 <p><br />
2716 </p>
2717 <pre>a
2718 </pre>
2719 <p><br />
2720 </p>
2721 <pre>b
2722 </pre>
2723 <p>a
2724 </p>
2725 <pre>b
2726 </pre>
2727 <p>a
2728 </p>
2729 <pre>b
2730 </pre>
2731 !!end
2732
2733 ## Hmm, should Parsoid rt this?
2734 !! test
2735 Pres with newline attributes
2736 !! options
2737 parsoid=wt2html,html2html
2738 !! wikitext
2739 <pre class="one
2740 two">hi</pre>
2741 !! html/php
2742 <pre class="one two">hi</pre>
2743
2744 !! html/parsoid
2745 <pre typeof="mw:Extension/pre" about="#mwt2" class="one two" data-mw='{"name":"pre","attrs":{"class":"one two"},"body":{"extsrc":"hi"}}'>hi</pre>
2746 !! end
2747
2748 !! test
2749 Things that look like <pre> tags aren't treated as such
2750 !! wikitext
2751 Barack Obama <President> of the United States
2752 <President></President>
2753 !! html
2754 <p>Barack Obama &lt;President&gt; of the United States
2755 &lt;President&gt;&lt;/President&gt;
2756 </p>
2757 !! end
2758
2759 !! test
2760 Handle broken pre-like tags (T66025)
2761 !! options
2762 parsoid=wt2html
2763 !! wikitext
2764 {{echo|<pre <pre>x</pre>}}
2765
2766 <table><pre </table>
2767 !! html/php
2768 <pre>x</pre>
2769 <table>&lt;pre </table>
2770
2771 !! html/php+tidy
2772 <pre>x</pre>
2773 &lt;pre <table></table>
2774 !! html/parsoid
2775 <pre typeof="mw:Transclusion mw:Extension/pre" about="#mwt2" data-parsoid='{"stx":"html","a":{"&lt;pre":null},"sa":{"&lt;pre":""},"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;pre &lt;pre>x&lt;/pre>"}},"i":0}}]}'>x</pre>
2776
2777 <span data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>&lt;pre </span><table data-parsoid='{"stx":"html"}'></table>
2778 !! end
2779
2780 !! test
2781 Parsoid: handle pre with space after attribute
2782 !! options
2783 parsoid=wt2html
2784 !! wikitext
2785 <pre style="width:50%;" >{{echo|foo}}</pre>
2786 !! html/php
2787 <pre style="width:50%;">{{echo|foo}}</pre>
2788
2789 !! html/parsoid
2790 <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>
2791 !! end
2792
2793 # TODO / maybe: fix wt2wt for this
2794 !! test
2795 Parsoid: Don't paragraph-wrap fosterable content
2796 !! options
2797 parsoid=wt2html
2798 !! wikitext
2799 {|
2800 <td></td>
2801 <td></td>
2802
2803
2804
2805 |}
2806 !! html
2807 <table>
2808
2809 <tbody>
2810 <tr>
2811 <td></td>
2812
2813 <td></td></tr>
2814
2815
2816
2817 </tbody></table>
2818 !! end
2819
2820 !! test
2821 Self-closed pre
2822 !! wikitext
2823 <pre />
2824 !! html/php
2825 <pre></pre>
2826
2827 !! html/parsoid
2828 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":null}'></pre>
2829 !! end
2830
2831 !! test
2832 Parsoid: Don't paragraph-wrap fosterable content even if table syntax is unbalanced
2833 !! options
2834 parsoid=wt2html
2835 !! wikitext
2836 {|
2837 <td>
2838 <td>
2839 </td>
2840
2841
2842
2843 |}
2844 !! html
2845 <table>
2846
2847 <tbody>
2848 <tr>
2849 <td></td>
2850
2851 <td>
2852 </td></tr>
2853
2854
2855
2856 </tbody></table>
2857 !! end
2858
2859
2860 #--------------------------------------------------------------------
2861 # Transclusion parameter whitespace stripping tests
2862 # Behavior is different for positional and named parameters
2863 #--------------------------------------------------------------------
2864 !! test
2865 Templates: Strip leading and trailing whitespace from named-param values
2866 !! wikitext
2867 {{echo|1= a }}
2868
2869 {{echo|1= {{echo|b}} }}
2870
2871 {{echo| 1 =
2872 c }}
2873
2874 {{echo| 1 =
2875 * d
2876 }}
2877 !! html
2878 <p>a
2879 </p><p>b
2880 </p><p>c
2881 </p>
2882 <ul><li>d</li></ul>
2883
2884 !! end
2885
2886 !! test
2887 Templates: Don't strip whitespace from positional-param values
2888 !! wikitext
2889 {{echo|a }}
2890
2891 {{echo|{{echo|b}} }}
2892
2893 {{echo| c
2894 }}
2895
2896 {{echo| {{echo|d}}
2897 }}
2898
2899 {{echo|
2900 e}}
2901
2902 {{echo|
2903 *f}}
2904
2905 {{echo|
2906 }}g
2907 !! html
2908 <p>a
2909 </p><p>b
2910 </p>
2911 <pre>c
2912 </pre>
2913 <p><br />
2914 </p>
2915 <pre>d
2916 </pre>
2917 <p><br />
2918 </p>
2919 <pre>e
2920 </pre>
2921 <p><br />
2922 </p>
2923 <ul><li>f</li></ul>
2924 <p><br />
2925 </p>
2926 <pre>g
2927 </pre>
2928 !! end
2929
2930 !! test
2931 Templates: Don't recognize targets split by newlines
2932 !! options
2933 parsoid=wt2html
2934 !! wikitext
2935 {{ech
2936 o|foo}}
2937 !! html/php
2938 <p>{{ech
2939 o|foo}}
2940 </p>
2941 !! html/parsoid
2942 <p>{{ech
2943 o|foo}}</p>
2944 !! end
2945
2946 !! test
2947 Templates: Recognize targets when newlines and comments don't split the target
2948 !! options
2949 parsoid=wt2html
2950 !! wikitext
2951 {{
2952 <!--X--> ech<!--X-->o<!--X-->
2953 <!--X--> <!--X-->
2954
2955 |foo}}
2956 !! html/php
2957 <p>foo
2958 </p>
2959 !! html/parsoid
2960 <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>
2961 !! end
2962
2963 !! test
2964 Templates: Handle empty comment-and-ws-only lines correctly
2965 !! wikitext
2966 {{echo|foo
2967 <!--should be ignored-->
2968 <!--should be ignored as well-->
2969 bar}}
2970 !! html/php
2971 <p>foo
2972 bar
2973 </p>
2974 !! html/parsoid
2975 <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>
2976 !! end
2977
2978 !! test
2979 Templates: Handle comments in the target
2980 !! wikitext
2981 {{echo
2982 <!-- should be ignored -->
2983 |foo}}
2984
2985 {{echo
2986 <!-- should be ignored and spaces on next line should not trip us up (T147742) -->
2987 |foo}}
2988
2989 {{echo<!-- should be ignored -->
2990 |foo}}
2991
2992 {{echo<!-- should be ignored -->|foo}}
2993
2994 {{<!-- should be ignored -->echo|foo}}
2995 !! html/php
2996 <p>foo
2997 </p><p>foo
2998 </p><p>foo
2999 </p><p>foo
3000 </p><p>foo
3001 </p>
3002 !! html/parsoid
3003 <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>
3004
3005 <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>
3006
3007 <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>
3008
3009 <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>
3010
3011 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
3012 !! end
3013
3014 !! test
3015 Templates: Handle comments in parameter names (T69657)
3016 !! wikitext
3017 {{echo|1
3018 <!-- should be ignored -->
3019 =foo}}
3020
3021 {{echo|
3022 <!-- should be ignored -->
3023 1 = foo}}
3024
3025 {{echo|1<!-- should be ignored -->=foo}}
3026
3027 {{echo|<!-- should be ignored -->1=foo}}
3028 !! html/php
3029 <p>foo
3030 </p><p>foo
3031 </p><p>foo
3032 </p><p>foo
3033 </p>
3034 !! html/parsoid
3035 <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>
3036
3037 <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>
3038
3039 <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>
3040
3041 <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>
3042 !! end
3043
3044 !! test
3045 Templates: Other wikitext in parameter names (T69657)
3046 !! wikitext
3047 {{echo|''1''=foo}}
3048 !! html/php
3049 <p>{{{1}}}
3050 </p>
3051 !! html/parsoid
3052 <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>
3053 !! end
3054
3055 !! test
3056 Templates: With colons
3057 !! wikitext
3058 {{With: Colon}}
3059 !! html/php
3060 <p>Template with colon
3061 </p>
3062 !! html/parsoid
3063 <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>
3064 !! end
3065
3066 #--------------------------------------------------------------------
3067 # Transclusion parameter escaping tests
3068 #--------------------------------------------------------------------
3069
3070 !! test
3071 Templates: Parsoid parameter escaping test 1
3072 !! wikitext
3073 {{echo|[foo]|{{echo|[bar]}}}}
3074 !! html/php+tidy
3075 <p>[foo]
3076 </p>
3077 !! html/parsoid
3078 <p about="#mwt1" typeof="mw:Transclusion"
3079 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[foo]"},"2":{"wt":"{{echo|[bar]}}"}},"i":0}}]}'>[foo]</p>
3080 !! end
3081
3082 !! test
3083 Parsoid: Pipes in external links in template parameter
3084 !! wikitext
3085 {{echo|[{{echo|http://example.com}} link]}}
3086 !! html/php+tidy
3087 <p><a rel="nofollow" class="external text" href="http://example.com">link</a>
3088 </p>
3089 !! html/parsoid
3090 <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>
3091 !! end
3092
3093 !! test
3094 Parsoid: pipe in transclusion parameter
3095 !! wikitext
3096 {{echo|http://foo.com/a&#124;b}}
3097 !! html/php+tidy
3098 <p><a rel="nofollow" class="external free" href="http://foo.com/a%7Cb">http://foo.com/a%7Cb</a>
3099 </p>
3100 !! html/parsoid
3101 <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>
3102 !! end
3103
3104 !! test
3105 Parsoid: Pipe in external link target and content in template parameter
3106 !! options
3107 parsoid=html2wt,wt2wt
3108 !! wikitext
3109 {{echo|[http://foo.com/a&#124;b a&#124;b]}}
3110 !! html/php+tidy
3111 <p><a rel="nofollow" class="external text" href="http://foo.com/a%7Cb">a&#124;b</a>
3112 </p>
3113 !! html/parsoid
3114 <p><a rel="mw:ExtLink" href="http://foo.com/a|b" about="#mwt1"
3115 typeof="mw:Transclusion"
3116 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},
3117 "params":{"1":{"wt":"[http://foo.com/a|b a|b]"}},"i":0}}]}'>a|b</a></p>
3118 !! end
3119
3120 !! test
3121 Parsoid: Pipe in template with nested template in external link target in template parameter (seriously)
3122 !! options
3123 parsoid
3124 !! wikitext
3125 {{echo|[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]}}
3126 !! html
3127 <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>
3128 !! end
3129
3130 !! test
3131 Templates: Don't escape already nowiki-escaped text in template parameters
3132 !! options
3133 parsoid=html2wt,wt2wt
3134 !! wikitext
3135 {{echo|foo<nowiki>|</nowiki>bar}}
3136 {{echo|<nowiki>&lt;div&gt;</nowiki>}}
3137 {{echo|<nowiki></nowiki>}}
3138 !! html/php+tidy
3139 <p>foo|bar
3140 &lt;div&gt;
3141
3142 </p>
3143 !! html/parsoid
3144 <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>
3145 <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>
3146 <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>
3147 </p>
3148 !! end
3149
3150 ## T54824
3151 !! test
3152 Templates: '=' char in nested transclusions should not trigger nowiki escapes or conversion to named param
3153 !! options
3154 parsoid=html2wt,wt2wt
3155 !! wikitext
3156 {{echo|{{echo|1=bar}}}}
3157 !! html/php+tidy
3158 <p>bar
3159 </p>
3160 !! html/parsoid
3161 <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>
3162 !! end
3163
3164 ## T58733
3165 !! test
3166 Templates parameters with special tokenizing behavior dont get modified because of arg escaping
3167 !! wikitext
3168 {{echo|a : b}}
3169 !! html/php+tidy
3170 <p>a&#160;: b
3171 </p>
3172 !! html/parsoid
3173 <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>
3174 !! end
3175
3176 ## T73412
3177 !! test
3178 Templates: Preserve blank parameter names
3179 !! wikitext
3180 {{echo|=foo}}
3181 !! html/php+tidy
3182 <p>{{{1}}}
3183 </p>
3184 !! html/parsoid
3185 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"":{"wt":"foo"}},"i":0}}]}'>{{{1}}}</p>
3186 !! end
3187
3188 !! test
3189 Templates: Preserve blank parameter names in other positions
3190 !! wikitext
3191 {{blank_param|bar|=foo}}
3192 !! html/php+tidy
3193 <p>bar
3194 foo
3195 </p>
3196 !! html/parsoid
3197 <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
3198 foo</p>
3199 !! end
3200
3201 ###
3202 ### Parsoid-centric tests for testing RT edge cases for pre
3203 ###
3204
3205 !!test
3206 1a. Indent-Pre and Comments
3207 !! wikitext
3208 a
3209 <!--a-->
3210 c
3211 !! html
3212 <pre>a
3213 </pre>
3214 <p>c
3215 </p>
3216 !!end
3217
3218 !!test
3219 1b. Indent-Pre and Comments
3220 !! wikitext
3221 a
3222 <!--a-->
3223 c
3224 !! html
3225 <pre>a
3226 </pre>
3227 <p>c
3228 </p>
3229 !!end
3230
3231 !!test
3232 1c. Indent-Pre and Comments
3233 !! wikitext
3234 <!--a--> a
3235
3236 <!--a--> a
3237 !! html
3238 <pre> a
3239 </pre>
3240 <pre> a
3241 </pre>
3242 !!end
3243
3244 !!test
3245 1d. Indent-Pre and Comments
3246 (Pre-handler currently cannot distinguish between comment/ws order and normalizes them to [comment,ws] order)
3247 !! wikitext
3248 <!--a--> a
3249
3250 <!--b-->b
3251 !! html
3252 <pre>a
3253 </pre>
3254 <pre>b
3255 </pre>
3256 !!end
3257
3258 !!test
3259 2a. Indent-Pre and tables
3260 !! wikitext
3261 {|
3262 |-
3263 !h1!!h2
3264 |foo||bar
3265 |}
3266 !! html
3267 <table>
3268
3269 <tr>
3270 <th>h1</th>
3271 <th>h2
3272 </th>
3273 <td>foo</td>
3274 <td>bar
3275 </td></tr></table>
3276
3277 !!end
3278
3279 !!test
3280 2b. Indent-Pre and tables
3281 !! wikitext
3282 {|
3283 |-
3284 |foo
3285 |}
3286 !! html
3287 <table>
3288
3289 <tr>
3290 <td>foo
3291 </td></tr></table>
3292
3293 !!end
3294
3295 !!test
3296 2c. Indent-Pre and tables (T44252)
3297 !! wikitext
3298 {|
3299 |+foo
3300 ! |bar
3301 |}
3302 !! html
3303 <table>
3304 <caption>foo
3305 </caption>
3306 <tr>
3307 <th>bar
3308 </th></tr></table>
3309
3310 !!end
3311
3312 !!test
3313 2d. Indent-Pre and tables
3314 !! wikitext
3315 a
3316 {|
3317 |b
3318 |}
3319 !! html/php
3320 <pre>a
3321 </pre>
3322 <table>
3323 <tr>
3324 <td>b
3325 </td></tr></table>
3326
3327 !! html/parsoid
3328 <pre>a</pre>
3329 <table>
3330 <tbody><tr><td> b</td></tr>
3331 </tbody></table>
3332 !!end
3333
3334 !!test
3335 2e. Indent-Pre and table-line syntax
3336 !! wikitext
3337 a
3338 | b
3339 | c
3340 !! html/php
3341 <pre>a
3342 | b
3343 | c
3344 </pre>
3345 !!end
3346
3347 !!test
3348 2f. Indent-pre started by table-line syntax
3349 !! wikitext
3350 a
3351 | b
3352 | c
3353 !! html/php
3354 <p>a
3355 </p>
3356 <pre>| b
3357 | c
3358 </pre>
3359 !! html/parsoid
3360 <p>a</p>
3361 <pre>
3362 | b
3363 | c</pre>
3364 !!end
3365
3366 !! test
3367 2g. Indented table markup mixed with indented pre content (proposed in T8200)
3368 !! wikitext
3369 <table>
3370 <tr>
3371 <td>
3372 Text that should be rendered preformatted
3373 </td>
3374 </tr>
3375 </table>
3376 !! html
3377 <table>
3378 <tr>
3379 <td>
3380 <pre>Text that should be rendered preformatted
3381 </pre>
3382 </td>
3383 </tr>
3384 </table>
3385
3386 !! end
3387
3388 !! test
3389 2h. Indent pre in tables
3390 !! options
3391 parsoid=wt2html,html2html
3392 !! wikitext
3393 {|
3394 !
3395 foo
3396 !
3397 bar
3398 |-
3399 |
3400 baz
3401 {{!}}
3402 bam
3403 |}
3404 !! html/php
3405 <table>
3406 <tr>
3407 <th>
3408 <pre>foo
3409 </pre>
3410 </th>
3411 <th>
3412 <pre>bar
3413 </pre>
3414 </th></tr>
3415 <tr>
3416 <td>
3417 <pre>baz
3418 </pre>
3419 </td>
3420 <td>
3421 <pre>bam
3422 </pre>
3423 </td></tr></table>
3424
3425 !! html/parsoid
3426 <table>
3427 <tbody><tr><th>
3428 <pre>foo</pre>
3429 </th><th>
3430 <pre>bar</pre>
3431 </th></tr><tr>
3432 <td>
3433 <pre>baz</pre>
3434 </td><td data-parsoid='{"startTagSrc":"{{!}}"}'>
3435 <pre>bam</pre>
3436 </td></tr></tbody></table>
3437 !! end
3438
3439 !!test
3440 3a. Indent-Pre and block tags (single-line html)
3441 !! wikitext
3442 a <p> foo </p>
3443 b <div> foo </div>
3444 c <blockquote> foo </blockquote>
3445 <span> foo </span>
3446 !! html
3447 a <p> foo </p>
3448 b <div> foo </div>
3449 c <blockquote> foo </blockquote>
3450 <pre><span> foo </span>
3451 </pre>
3452 !! html/parsoid
3453 <p>a </p><p data-parsoid='{"stx":"html"}'> foo </p>
3454 <p>b </p><div data-parsoid='{"stx":"html"}'> foo </div>
3455 <p>c </p><blockquote data-parsoid='{"stx":"html"}'> foo </blockquote>
3456 <pre><span> foo </span>
3457 </pre>
3458 !! html/php+tidy
3459 <p> a </p><p> foo </p><p>
3460 b </p><div> foo </div><p>
3461 c </p><blockquote><p> foo </p></blockquote>
3462 <pre><span> foo </span>
3463 </pre>
3464 !! end
3465
3466 !! test
3467 3b. Indent-Pre and block tags (multi-line html)
3468 !! wikitext
3469 a <span>foo</span>
3470 <!-- comment --> b <div> foo </div>
3471 !! html/php
3472 <pre>a <span>foo</span>
3473 </pre>
3474 b <div> foo </div>
3475
3476 !! html/parsoid
3477 <pre>a <span data-parsoid='{"stx":"html"}'>foo</span></pre>
3478 <!-- comment --> <p>b </p><div data-parsoid='{"stx":"html"}'> foo </div>
3479 !! html/php+tidy
3480 <pre>a <span>foo</span>
3481 </pre><p>
3482 b </p><div> foo </div>
3483 !! end
3484
3485 !!test
3486 3c. Indent-Pre and block tags (pre-content on separate line)
3487 !! wikitext
3488 <p>
3489 foo
3490 </p>
3491
3492 <div>
3493 foo
3494 </div>
3495
3496 <center>
3497 foo
3498 </center>
3499
3500 <blockquote>
3501 foo
3502 </blockquote>
3503
3504 <blockquote>
3505 <pre>
3506 foo
3507 </pre>
3508 </blockquote>
3509
3510 <table><tr><td>
3511 foo
3512 </td></tr></table>
3513
3514 <ul><li>
3515 foo
3516 </li></ul>
3517
3518 !! html
3519 <p>
3520 foo
3521 </p>
3522 <div>
3523 <pre>foo
3524 </pre>
3525 </div>
3526 <center>
3527 <pre>foo
3528 </pre>
3529 </center>
3530 <blockquote>
3531 <p> foo
3532 </p>
3533 </blockquote>
3534 <blockquote>
3535 <pre>
3536 foo
3537 </pre>
3538 </blockquote>
3539 <table><tr><td>
3540 <pre>foo
3541 </pre>
3542 </td></tr></table>
3543 <ul><li>
3544 foo
3545 </li></ul>
3546
3547 !!end
3548
3549 !! test
3550 4. Indent-Pre and extension tags
3551 !! wikitext
3552 a <tag />
3553 !! html/php
3554 a <pre>
3555 NULL
3556 array (
3557 )
3558 </pre>
3559
3560 !! html/parsoid
3561 a <pre typeof="mw:Extension/tag" about="#mwt2" data-parsoid='{}' data-mw='{"name":"tag","attrs":{},"body":null}'></pre>
3562 !! end
3563
3564 !! test
3565 5. Indent-Pre and html pre
3566 !! wikitext
3567 <pre class="123">hi</pre>
3568 !! html/php
3569 <pre class="123">hi</pre>
3570
3571 !! html/parsoid
3572 <pre typeof="mw:Extension/pre" about="#mwt2" class="123" data-mw='{"name":"pre","attrs":{"class":"123"},"body":{"extsrc":"hi"}}'>hi</pre>
3573 !! end
3574
3575 !!test
3576 Render paragraphs when indent-pre is suppressed in blocklevels
3577 !! wikitext
3578 <blockquote>
3579 foo
3580
3581 bar
3582 </blockquote>
3583 !! html
3584 <blockquote>
3585 <p> foo
3586 </p><p> bar
3587 </p>
3588 </blockquote>
3589
3590 !!end
3591
3592 !!test
3593 4. Multiple spaces at start-of-line
3594 !! wikitext
3595 <p> foo </p>
3596 foo
3597 {|
3598 |foo
3599 |}
3600 !! html
3601 <p> foo </p>
3602 <pre> foo
3603 </pre>
3604 <table>
3605 <tr>
3606 <td>foo
3607 </td></tr></table>
3608
3609 !!end
3610
3611 ## NOTE: the leading white-space chars on empty line are significant
3612 !! test
3613 5a. White-space in indent-pre
3614 !! wikitext
3615 a<br />
3616
3617 b
3618 !! html
3619 <pre>a<br />
3620
3621 b
3622 </pre>
3623 !! end
3624
3625 ## NOTE: the leading white-space chars on empty line are significant
3626 !! test
3627 5b. White-space in indent-pre
3628 !! wikitext
3629 a
3630
3631 b
3632
3633
3634 c
3635 !! html
3636 <pre>a
3637
3638 b
3639
3640
3641 c
3642 </pre>
3643 !! end
3644
3645 !! test
3646 5c. White-space in indent-pre
3647 !! wikitext
3648 ''a''
3649 ''b''
3650 ''c''
3651 !! html
3652 <pre><i>a</i>
3653 <i>b</i>
3654 <i>c</i>
3655 </pre>
3656 !! end
3657
3658 !! test
3659 6. Pre-blocks should extend across lines with leading WS even when there is no wrappable content
3660 !! wikitext
3661 a
3662
3663 <!-- continue -->
3664 b
3665
3666 c
3667
3668 d
3669 !! html
3670 <pre>a
3671
3672 b
3673 </pre>
3674 <pre>c
3675
3676 </pre>
3677 <p>d
3678 </p>
3679 !! end
3680
3681 !! test
3682 7a. Indent-pre and category links
3683 !! options
3684 parsoid=wt2html,wt2wt
3685 !! wikitext
3686 [[Category:foo]] <!-- No pre-wrapping -->
3687 {{echo| [[Category:foo]]}} <!-- No pre-wrapping -->
3688 !! html/php+tidy
3689 !! html/parsoid
3690 <link rel="mw:PageProp/Category" href="./Category:Foo"> <!-- No pre&#x2D;wrapping -->
3691 <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 -->
3692 !! end
3693
3694 ## We used to, but no longer wt2wt this test since the default serializer
3695 ## will normalize all categories to serialize on their own line.
3696 ## This wikitext usage is going to be fairly uncommon in production and
3697 ## selser will take care of preserving formatting in those scenarios.
3698 !! test
3699 7b. Indent-pre and category links
3700 !! options
3701 parsoid=wt2html
3702 !! wikitext
3703 [[Category:foo]] a
3704 [[Category:foo]] {{echo|b}}
3705 !! html/parsoid
3706 <pre><link rel="mw:PageProp/Category" href="./Category:Foo"> a
3707 <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>
3708 !! end
3709
3710 !! test
3711 Indent-Pre: Newlines in comments shouldn't affect sol state
3712 !! wikitext
3713 a <!--
3714 foo
3715 --> b
3716 !! html/php+tidy
3717 <p>a b
3718 </p>
3719 !! html/parsoid
3720 <p>a <!--
3721 foo
3722 --> b</p>
3723 !! end
3724
3725 ###
3726 ### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric)
3727 ###
3728
3729 !!test
3730 HTML-pre: 1. embedded newlines
3731 !! wikitext
3732 <pre>foo</pre>
3733
3734 <pre>
3735 foo
3736 </pre>
3737
3738 <pre>
3739
3740 foo
3741 </pre>
3742
3743 <pre>
3744
3745
3746 foo
3747 </pre>
3748 !! html/php+tidy
3749 <pre>foo</pre>
3750 <pre>foo
3751 </pre>
3752 <pre>
3753
3754 foo
3755 </pre>
3756 <pre>
3757
3758
3759 foo
3760 </pre>
3761 !! html/parsoid
3762 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre>
3763
3764 <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
3765 </pre>
3766
3767 <pre typeof="mw:Extension/pre" about="#mwt6" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\nfoo\n"}}'>
3768
3769 foo
3770 </pre>
3771
3772 <pre typeof="mw:Extension/pre" about="#mwt8" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\nfoo\n"}}'>
3773
3774
3775 foo
3776 </pre>
3777 !!end
3778
3779 !! test
3780 HTML-pre: big spaces
3781 !! wikitext
3782 <pre>
3783
3784
3785
3786
3787 haha
3788
3789
3790
3791
3792 haha
3793
3794
3795
3796
3797 </pre>
3798 !! html/php+tidy
3799 <pre>
3800
3801
3802
3803
3804 haha
3805
3806
3807
3808
3809 haha
3810
3811
3812
3813
3814 </pre>
3815 !! html/parsoid
3816 <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"}}'>
3817
3818
3819
3820
3821 haha
3822
3823
3824
3825
3826 haha
3827
3828
3829
3830
3831 </pre>
3832 !! end
3833
3834 !!test
3835 HTML-pre: 2: indented text
3836 !! wikitext
3837 <pre>
3838 foo
3839 </pre>
3840 !! html
3841 <pre>
3842 foo
3843 </pre>
3844
3845 !!end
3846
3847 !!test
3848 HTML-pre: 3: other wikitext
3849 !! wikitext
3850 <pre>
3851 * foo
3852 # bar
3853 = no-h =
3854 '' no-italic ''
3855 [[ NoLink ]]
3856 </pre>
3857 !! html/php
3858 <pre>
3859 * foo
3860 # bar
3861 = no-h =
3862 '' no-italic ''
3863 [[ NoLink ]]
3864 </pre>
3865
3866 !! html/parsoid
3867 <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
3868 # bar
3869 = no-h =
3870 '' no-italic ''
3871 [[ NoLink ]]
3872 </pre>
3873 !!end
3874
3875 ###
3876 ### Definition lists
3877 ###
3878 !! test
3879 Simple definition
3880 !! wikitext
3881 ;name :Definition
3882 !! html
3883 <dl><dt>name</dt>
3884 <dd>Definition</dd></dl>
3885
3886 !! end
3887
3888 !! test
3889 Definition list for indentation only
3890 !! wikitext
3891 :Indented text
3892 !! html
3893 <dl><dd>Indented text</dd></dl>
3894
3895 !! end
3896
3897 !! test
3898 Definition list with no space
3899 !! wikitext
3900 ;name:Definition
3901 !! html
3902 <dl><dt>name</dt>
3903 <dd>Definition</dd></dl>
3904
3905 !!end
3906
3907 !! test
3908 Definition list with URL link
3909 !! wikitext
3910 ;http://example.com/ :definition
3911 !! html
3912 <dl><dt><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a></dt>
3913 <dd>definition</dd></dl>
3914
3915 !! end
3916
3917 !! test
3918 Definition list with bracketed URL link
3919 !! wikitext
3920 ;[http://www.example.com/ Example]:Something about it
3921 !! html
3922 <dl><dt><a rel="nofollow" class="external text" href="http://www.example.com/">Example</a></dt>
3923 <dd>Something about it</dd></dl>
3924
3925 !! end
3926
3927 !! test
3928 Definition list with wikilink containing colon
3929 !! wikitext
3930 ;[[Help:FAQ]]:The least-read page on Wikipedia
3931 !! html
3932 <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>
3933 <dd>The least-read page on Wikipedia</dd></dl>
3934
3935 !! end
3936
3937 # At Brion's and JeLuF's insistence... :)
3938 !! test
3939 Definition list with news link containing colon
3940 !! wikitext
3941 ;news:alt.wikipedia.rox :This isn't even a real newsgroup!
3942 !! html/php
3943 <dl><dt><a rel="nofollow" class="external free" href="news:alt.wikipedia.rox">news:alt.wikipedia.rox</a></dt>
3944 <dd>This isn't even a real newsgroup!</dd></dl>
3945
3946 !! html/parsoid
3947 <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>
3948 !! end
3949
3950 !! test
3951 Malformed definition list with colon
3952 !! wikitext
3953 ;news:alt.wikipedia.rox -- don't crash or enter an infinite loop
3954 !! html
3955 <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>
3956
3957 !! end
3958
3959 !! test
3960 Definition lists: colon in external link text
3961 !! wikitext
3962 ;[http://www.wikipedia2.org/ Wikipedia :The Next Generation] :OK, I made that up
3963 !! html
3964 <dl><dt><a rel="nofollow" class="external text" href="http://www.wikipedia2.org/">Wikipedia :The Next Generation</a></dt>
3965 <dd>OK, I made that up</dd></dl>
3966
3967 !! end
3968
3969 !! test
3970 Definition lists: colon in HTML attribute
3971 !! wikitext
3972 ;<b style="display: inline">bold</b>
3973 !! html
3974 <dl><dt><b style="display: inline">bold</b></dt></dl>
3975
3976 !! end
3977
3978 !! test
3979 Definition lists: self-closed tag
3980 !! wikitext
3981 ;one<br/>two :two-line fun
3982 !! html
3983 <dl><dt>one<br />two</dt>
3984 <dd>two-line fun</dd></dl>
3985
3986 !! end
3987
3988 !! test
3989 Definition lists: ignore colons inside tags
3990 !! wikitext
3991 ;one <b>two : tag <i>fun:</i>:</b>:def
3992 !! html
3993 <dl><dt>one <b>two&#160;: tag <i>fun:</i>:</b></dt>
3994 <dd>def</dd></dl>
3995
3996 !! end
3997
3998 !! test
3999 Definition lists: excess closed tags
4000 !! wikitext
4001 ;one</b>two :bad tag fun
4002 !! html/php+tidy
4003 <dl><dt>onetwo</dt>
4004 <dd>bad tag fun</dd></dl>
4005 !! html/parsoid
4006 <dl>
4007 <dt>onetwo</dt>
4008 <dd>bad tag fun</dd>
4009 </dl>
4010 !! end
4011
4012 !! test
4013 T13748: Literal closing tags
4014 !! wikitext
4015 <dl>
4016 <dt>test 1</dt>
4017 <dd>test test test test test</dd>
4018 <dt>test 2</dt>
4019 <dd>test test test test test</dd>
4020 </dl>
4021 !! html
4022 <dl>
4023 <dt>test 1</dt>
4024 <dd>test test test test test</dd>
4025 <dt>test 2</dt>
4026 <dd>test test test test test</dd>
4027 </dl>
4028
4029 !! end
4030
4031 !! test
4032 Definition and unordered list using wiki syntax nested in unordered list using html tags.
4033 !! wikitext
4034 <ul><li>
4035 ;term :description
4036 *unordered
4037 </li></ul>
4038 !! html
4039 <ul><li>
4040 <dl><dt>term</dt>
4041 <dd>description</dd></dl>
4042 <ul><li>unordered</li></ul>
4043 </li></ul>
4044
4045 !! end
4046
4047 !! test
4048 Definition list with empty definition and following paragraph
4049 !! wikitext
4050 ;term:
4051
4052 Paragraph text
4053 !! html
4054 <dl><dt>term</dt>
4055 <dd></dd></dl>
4056 <p>Paragraph text
4057 </p>
4058 !! end
4059
4060 !! test
4061 Nested definition lists using html syntax
4062 !! wikitext
4063 <dl><dt>x</dt>
4064 <dd>a</dd>
4065 <dd>b</dd></dl>
4066 !! html
4067 <dl><dt>x</dt>
4068 <dd>a</dd>
4069 <dd>b</dd></dl>
4070
4071 !! end
4072
4073 !! test
4074 Definition Lists: No nesting: Multiple dd's
4075 !! wikitext
4076 ;x
4077 :a
4078 :b
4079 !! html
4080 <dl><dt>x</dt>
4081 <dd>a</dd>
4082 <dd>b</dd></dl>
4083
4084 !! end
4085
4086 !! test
4087 Definition Lists: Indentation: Regular
4088 !! wikitext
4089 :i1
4090 ::i2
4091 :::i3
4092 !! html
4093 <dl><dd>i1
4094 <dl><dd>i2
4095 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
4096
4097 !! end
4098
4099 !! test
4100 Definition Lists: Indentation: Missing 1st level
4101 !! wikitext
4102 ::i2
4103 :::i3
4104 !! html
4105 <dl><dd><dl><dd>i2
4106 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
4107
4108 !! end
4109
4110 !! test
4111 Definition Lists: Indentation: Multi-level indent
4112 !! wikitext
4113 :::i3
4114 !! html
4115 <dl><dd><dl><dd><dl><dd>i3</dd></dl></dd></dl></dd></dl>
4116
4117 !! end
4118
4119 !! test
4120 Definition Lists: Hacky use to indent tables
4121 !! wikitext
4122 ::{|
4123 |foo
4124 |bar
4125 |}
4126 this text
4127 should be left alone
4128 !! html
4129 <dl><dd><dl><dd><table>
4130 <tr>
4131 <td>foo
4132 </td>
4133 <td>bar
4134 </td></tr></table></dd></dl></dd></dl>
4135 <p>this text
4136 should be left alone
4137 </p>
4138 !! end
4139
4140 !! test
4141 Definition Lists: Hacky use to indent tables (with content following table)
4142 !! wikitext
4143 :{|
4144 |foo
4145 |bar
4146 |} <!--c1--> this text should be part of the dl
4147 !! html/php+tidy
4148 <dl><dd><table>
4149 <tbody><tr>
4150 <td>foo
4151 </td>
4152 <td>bar
4153 </td></tr></tbody></table> this text should be part of the dl</dd></dl>
4154 !! html/parsoid
4155 <dl><dd><table>
4156 <tbody><tr>
4157 <td>foo
4158 </td>
4159 <td>bar
4160 </td></tr></tbody></table> <!--c1--> this text should be part of the dl</dd></dl>
4161 !! end
4162
4163 !! test
4164 Definition Lists: Hacky use to indent tables, with comments (T65979)
4165 !! wikitext
4166 <!-- foo -->
4167 ::{|
4168 |foo
4169 |bar
4170 |}<!-- bar -->
4171 this text
4172 should be left alone
4173 !! html/parsoid
4174 <!-- foo -->
4175 <dl><dd><dl><dd><table><tr>
4176 <td>foo</td>
4177 <td>bar</td>
4178 </tr></table><!-- bar --></dd></dl></dd></dl>
4179 <p>this text
4180 should be left alone</p>
4181 !! end
4182
4183 !! test
4184 Definition Lists: Hacky use to indent tables, with comment before table
4185 !!options
4186 parsoid=wt2html
4187 !! wikitext
4188 ::<!-- foo -->{|
4189 |foo
4190 |}
4191 !! html/parsoid
4192 <dl><dd><dl><dd><!-- foo --><table><tr>
4193 <td>foo</td>
4194 </tr></table></dd></dl></dd></dl>
4195 !! end
4196
4197 # The trailing whitespace in this test is to catch a regression in
4198 # Parsoid after T54473.
4199 !! test
4200 Definition Lists: Hacky use to indent tables (WS-insensitive)
4201 !! wikitext
4202 :{|
4203 |a
4204 |}
4205 !! html/php
4206 <dl><dd><table>
4207 <tr>
4208 <td>a
4209 </td></tr></table></dd></dl>
4210
4211 !! html/parsoid
4212 <dl><dd><table>
4213 <tbody><tr><td>a</td></tr>
4214 </tbody></table></dd></dl>
4215 !! end
4216
4217 ## The PHP parser treats : items (dd) without a corresponding ; item (dt)
4218 ## as an empty dt item. It also ignores all but the last ";" when followed
4219 ## by ":" later on. So, ";" are not ignored in ";;;t3" but are ignored in
4220 ## ";;;t3 :d1". So, PHP parser behavior is a little inconsistent wrt multiple
4221 ## ";"s.
4222 ##
4223 ## Ex: ";;t2 ::d2" is transformed into:
4224 ##
4225 ## <dl>
4226 ## <dt>t2 </dt>
4227 ## <dd>
4228 ## <dl>
4229 ## <dt></dt>
4230 ## <dd>d2</dd>
4231 ## </dl>
4232 ## </dd>
4233 ## </dl>
4234 ##
4235 ## But, Parsoid treats "; :" as a tight atomic unit and excess ":" as plain text
4236 ## So, the same wikitext above (;;t2 ::d2) is transformed into:
4237 ##
4238 ## <dl>
4239 ## <dt>
4240 ## <dl>
4241 ## <dt>t2 </dt>
4242 ## <dd>:d2</dd>
4243 ## </dl>
4244 ## </dt>
4245 ## </dl>
4246 ##
4247 ## All Parsoid only definition list tests have this difference.
4248 ##
4249 ## See also: https://phabricator.wikimedia.org/T8569
4250 ## and https://lists.wikimedia.org/pipermail/wikitext-l/2011-November/000483.html
4251
4252 !! test
4253 Table / list interaction: indented table with lists in table contents
4254 !! wikitext
4255 :{|
4256 |-
4257 |a
4258
4259 *b
4260 |-
4261 |c
4262
4263 *d
4264 |}
4265 !! html
4266 <dl><dd><table>
4267
4268 <tr>
4269 <td>a
4270 <ul><li>b</li></ul>
4271 </td></tr>
4272 <tr>
4273 <td>c
4274 <ul><li>d</li></ul>
4275 </td></tr></table></dd></dl>
4276
4277 !! end
4278
4279 !!test
4280 Table / list interaction: lists nested in tables nested in indented lists
4281 !! wikitext
4282 :{|
4283 |
4284 :a
4285 :b
4286 |
4287 *c
4288 *d
4289 |}
4290
4291 *e
4292 *f
4293 !! html
4294 <dl><dd><table>
4295 <tr>
4296 <td>
4297 <dl><dd>a</dd>
4298 <dd>b</dd></dl>
4299 </td>
4300 <td>
4301 <ul><li>c</li>
4302 <li>d</li></ul>
4303 </td></tr></table></dd></dl>
4304 <ul><li>e</li>
4305 <li>f</li></ul>
4306
4307 !!end
4308
4309 !! test
4310 Definition Lists: Nesting: Multi-level (Parsoid only)
4311 !! wikitext
4312 ;t1 :d1
4313 ;;t2 ::d2
4314 ;;;t3 :::d3
4315 !! html/parsoid
4316 <dl>
4317 <dt>t1 </dt>
4318 <dd>d1</dd>
4319 <dt>
4320 <dl>
4321 <dt>t2 </dt>
4322 <dd>:d2</dd>
4323 <dt>
4324 <dl>
4325 <dt>t3 </dt>
4326 <dd>::d3</dd>
4327 </dl>
4328 </dt>
4329 </dl>
4330 </dt>
4331 </dl>
4332
4333
4334 !! end
4335
4336
4337 !! test
4338 Definition Lists: Nesting: Test 2
4339 !! wikitext
4340 ;t1
4341 ::d2
4342 !! html+tidy
4343 <dl><dt>t1</dt>
4344 <dd>
4345 <dl><dd>d2</dd></dl></dd></dl>
4346 !! end
4347
4348
4349 !! test
4350 Definition Lists: Nesting: Test 3
4351 !! wikitext
4352 :;t1
4353 ::::d2
4354 !! html+tidy
4355 <dl><dd><dl><dt>t1</dt>
4356 <dd>
4357 <dl><dd><dl><dd>d2</dd></dl></dd></dl></dd></dl></dd></dl>
4358 !! end
4359
4360
4361 !! test
4362 Definition Lists: Nesting: Test 4
4363 !! wikitext
4364 ::;t3
4365 :::d3
4366 !! html
4367 <dl><dd><dl><dd><dl><dt>t3</dt>
4368 <dd>d3</dd></dl></dd></dl></dd></dl>
4369
4370 !! end
4371
4372
4373 ## The Parsoid team believes the following three test exposes a
4374 ## bug in the PHP parser. (Parsoid team thinks the PHP parser is
4375 ## wrong to close the <dl> after the <dt> containing the <ul>.)
4376 ## It also exposes a "misfeature" in tidy, which doesn't like
4377 ## <dl> tags with a single <dt> child; it converts the <dt> into
4378 ## a <dd> in that case. (Parsoid leaves the <dt> alone!)
4379 !! test
4380 Definition Lists: Mixed Lists: Test 1
4381 !! wikitext
4382 :;*foo
4383 ::*bar
4384 :;baz
4385 !! html/php
4386 <dl><dd><dl><dt><ul><li>foo</li>
4387 <li>bar</li></ul></dt></dl>
4388 <dl><dt>baz</dt></dl></dd></dl>
4389
4390 !! html/php+tidy
4391 <dl><dd><dl><dt><ul><li>foo</li>
4392 <li>bar</li></ul></dt></dl>
4393 <dl><dt>baz</dt></dl></dd></dl>
4394 !! html/parsoid
4395 <dl>
4396 <dd><dl>
4397 <dt><ul>
4398 <li>foo
4399 </li>
4400 </ul></dt>
4401 <dd><ul>
4402 <li>bar
4403 </li>
4404 </ul></dd>
4405 <dt>baz</dt>
4406 </dl></dd>
4407 </dl>
4408 !! end
4409
4410 !! test
4411 Definition Lists: Mixed Lists: Test 2
4412 !! wikitext
4413 *:d1
4414 *:d2
4415 !! html
4416 <ul><li><dl><dd>d1</dd>
4417 <dd>d2</dd></dl></li></ul>
4418
4419 !! end
4420
4421
4422 !! test
4423 Definition Lists: Mixed Lists: Test 3
4424 !! wikitext
4425 *:::d1
4426 *:::d2
4427 !! html
4428 <ul><li><dl><dd><dl><dd><dl><dd>d1</dd>
4429 <dd>d2</dd></dl></dd></dl></dd></dl></li></ul>
4430
4431 !! end
4432
4433
4434 !! test
4435 Definition Lists: Mixed Lists: Test 4
4436 !! wikitext
4437 *;d1 :d2
4438 *;d3 :d4
4439 !! html
4440 <ul><li><dl><dt>d1</dt>
4441 <dd>d2</dd>
4442 <dt>d3</dt>
4443 <dd>d4</dd></dl></li></ul>
4444
4445 !! end
4446
4447
4448 !! test
4449 Definition Lists: Mixed Lists: Test 5
4450 !! wikitext
4451 *:d1
4452 *::d2
4453 !! html
4454 <ul><li><dl><dd>d1
4455 <dl><dd>d2</dd></dl></dd></dl></li></ul>
4456
4457 !! end
4458
4459
4460 !! test
4461 Definition Lists: Mixed Lists: Test 6
4462 !! wikitext
4463 #*:d1
4464 #*:::d3
4465 !! html
4466 <ol><li><ul><li><dl><dd>d1
4467 <dl><dd><dl><dd>d3</dd></dl></dd></dl></dd></dl></li></ul></li></ol>
4468
4469 !! end
4470
4471
4472 !! test
4473 Definition Lists: Mixed Lists: Test 7
4474 !! wikitext
4475 :*d1
4476 :*d2
4477 !! html
4478 <dl><dd><ul><li>d1</li>
4479 <li>d2</li></ul></dd></dl>
4480
4481 !! end
4482
4483
4484 !! test
4485 Definition Lists: Mixed Lists: Test 8
4486 !! wikitext
4487 :*d1
4488 ::*d2
4489 !! html
4490 <dl><dd><ul><li>d1</li></ul>
4491 <dl><dd><ul><li>d2</li></ul></dd></dl></dd></dl>
4492
4493 !! end
4494
4495
4496 !! test
4497 Definition Lists: Mixed Lists: Test 9
4498 !! wikitext
4499 *;foo :bar
4500 !! html
4501 <ul><li><dl><dt>foo</dt>
4502 <dd>bar</dd></dl></li></ul>
4503
4504 !! end
4505
4506
4507 !! test
4508 Definition Lists: Mixed Lists: Test 10
4509 !! wikitext
4510 *#;foo :bar
4511 !! html
4512 <ul><li><ol><li><dl><dt>foo</dt>
4513 <dd>bar</dd></dl></li></ol></li></ul>
4514
4515 !! end
4516
4517 # The Parsoid team disagrees with the PHP parser's seemingly-random
4518 # rules regarding dd/dt on the next few tests. Parsoid is more
4519 # consistent, and recognizes the shared nesting and keeps the
4520 # still-open tags around until the nesting is complete.
4521
4522 # This is a regression test for T175099
4523 !! test
4524 Definition Lists: Mixed Lists: Test 11
4525 !! wikitext
4526 ;a
4527 :*b
4528 !! html/php
4529 <dl><dt>a</dt>
4530 <dd>
4531 <ul><li>b</li></ul></dd></dl>
4532
4533 !! html/parsoid
4534 <dl><dt>a
4535 <dd><ul><li>b</li></ul></dd></dl>
4536 !! end
4537
4538 # FIXME: Maybe get rid of this test?
4539 !! test
4540 Definition Lists: Mixed Lists: Test 12
4541 !! wikitext
4542 *#*#;*;;foo :bar
4543 *#*#;boo :baz
4544 !! html/php
4545 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo</dt>
4546 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dd></dl></li></ul></dd></dl>
4547 <dl><dt>boo</dt>
4548 <dd>baz</dd></dl></li></ol></li></ul></li></ol></li></ul>
4549
4550 !! html/php+tidy
4551 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo</dt>
4552 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dt></dl></li></ul></dd></dl></li></ol></li></ul>
4553 <dl><dt>boo</dt>
4554 <dd>baz</dd></dl></li></ol></li></ul>
4555 !! html/parsoid
4556 <ul>
4557 <li>
4558 <ol>
4559 <li>
4560 <ul>
4561 <li>
4562 <ol>
4563 <li>
4564 <dl>
4565 <dt>
4566 <ul>
4567 <li>
4568 <dl>
4569 <dt>
4570 <dl>
4571 <dt>foo</dt>
4572 <dd data-parsoid='{"stx":"row"}'>bar</dd>
4573 </dl></dt>
4574 </dl></li>
4575 </ul></dt>
4576 <dt>boo</dt>
4577 <dd data-parsoid='{"stx":"row"}'>baz</dd>
4578 </dl></li>
4579 </ol></li>
4580 </ul></li>
4581 </ol></li>
4582 </ul>
4583 !! end
4584
4585 !! test
4586 Definition Lists: Mixed Lists: Test 13
4587 !! wikitext
4588 *#*#;*;;foo : bar
4589 *#*#;boo : baz
4590 !! html+tidy
4591 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</dt>
4592 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dt></dl></li></ul></dd></dl></li></ol></li></ul>
4593 <dl><dt>boo&#160;</dt>
4594 <dd>baz</dd></dl></li></ol></li></ul>
4595 !! end
4596
4597 # FIXME: Maybe get rid of this test?
4598 # From whitelist:
4599 # * The test is wrong, there are two colons where there should be :;
4600 # * The PHP parser is wrong to close the <dl> after the <dt> containing the <ul>.
4601 !! test
4602 Definition Lists: Weird Ones: Test 1
4603 !! wikitext
4604 *#;*::;;foo :bar (who uses this?)
4605 !! html/php+tidy
4606 <ul><li><ol><li><dl><dt>foo</dt>
4607 <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>
4608 !! html/parsoid
4609 <ul>
4610 <li>
4611 <ol>
4612 <li>
4613 <dl>
4614 <dt>
4615 <ul>
4616 <li>
4617 <dl>
4618 <dd>
4619 <dl>
4620 <dd>
4621 <dl>
4622 <dt>
4623 <dl>
4624 <dt>foo</dt>
4625 <dd data-parsoid='{"stx":"row"}'>bar (who uses this?)</dd>
4626 </dl></dt>
4627 </dl></dd>
4628 </dl></dd>
4629 </dl></li>
4630 </ul></dt>
4631 </dl></li>
4632 </ol></li>
4633 </ul>
4634 !! end
4635
4636 !! test
4637 Definition Lists: colons occurring in tags
4638 !! wikitext
4639 ;a:b
4640 ;'''a:b'''
4641 ;<i>a:b</i>
4642 ;<span>a:b</span>
4643 ;<div>a:b</div>
4644 ;<div>a
4645 :b</div>
4646 ;{{echo|a:b}}
4647 ;{{echo|''a:b''}}
4648 ;;;''a:b''
4649 !! html+tidy
4650 <dl><dt>a</dt>
4651 <dd>b</dd>
4652 <dt><b>a:b</b></dt>
4653 <dt><i>a:b</i></dt>
4654 <dt><span>a:b</span></dt>
4655 <dt><div>a:b</div></dt>
4656 <dt><div>a</div></dt>
4657 <dd>b</dd>
4658 <dt>a</dt>
4659 <dd>b</dd>
4660 <dt><i>a:b</i></dt></dl>
4661 <dl><dt><dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4662 !! html/parsoid
4663 <dl><dt>a</dt><dd data-parsoid='{"stx":"row"}'>b</dd>
4664 <dt><b>a:b</b></dt>
4665 <dt><i data-parsoid='{"stx":"html"}'>a:b</i></dt>
4666 <dt><span data-parsoid='{"stx":"html"}'>a:b</span></dt>
4667 <dt><div data-parsoid='{"stx":"html"}'>a:b</div></dt>
4668 <dt><div data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</div></dt>
4669 <dd>b</dd>
4670 <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>
4671 <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>
4672 <dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4673 !! end
4674
4675 # Parsoid's output differs here again because it shares
4676 # nesting between the two lists unlike the PHP parser.
4677 # Unsure which is more desirable.
4678 !! test
4679 Definition Lists: colons and tables 1
4680 !! wikitext
4681 :{|
4682 |x
4683 |}
4684 :{|
4685 |y
4686 |}
4687 !! html/php
4688 <dl><dd><table>
4689 <tr>
4690 <td>x
4691 </td></tr></table></dd></dl>
4692 <dl><dd><table>
4693 <tr>
4694 <td>y
4695 </td></tr></table></dd></dl>
4696
4697 !! html/parsoid
4698 <dl><dd><table>
4699 <tr>
4700 <td>x
4701 </td></tr></table></dd>
4702 <dd><table>
4703 <tr>
4704 <td>y
4705 </td></tr></table></dd></dl>
4706 !! end
4707
4708 # FIXME: Does this need a html/php section?
4709 !! test
4710 Definition Lists: template interaction
4711 !! wikitext
4712 ::{{definition_list}}
4713
4714 :one
4715 ::{{definition_list}}
4716 :::two
4717 :::three
4718 ::four
4719 !! html/parsoid
4720 <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">
4721 </span><dd about="#mwt1">two</dd></dl></dd></dl>
4722
4723 <dl><dd data-parsoid='{}'>one
4724 <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">
4725 </span><dd about="#mwt2">two
4726 <dl><dd>two</dd>
4727 <dd>three</dd></dl></dd>
4728 <dd data-parsoid='{}'>four</dd></dl></dd></dl>
4729 !! end
4730
4731
4732 ###
4733 ### External links
4734 ###
4735 !! test
4736 External links: non-bracketed
4737 !! wikitext
4738 Non-bracketed: http://example.com
4739 !! html
4740 <p>Non-bracketed: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4741 </p>
4742 !! end
4743
4744 # parsoid doesn't explicitly mark autonumbered links, see T55505
4745 !! test
4746 External links: numbered
4747 !! wikitext
4748 Numbered: [http://example.com]
4749 Numbered: [http://example.net]
4750 Numbered: [http://example.com]
4751 !! html/php
4752 <p>Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>
4753 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.net">[2]</a>
4754 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[3]</a>
4755 </p>
4756 !! html/parsoid
4757 <p>Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>
4758 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.net"></a>
4759 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a></p>
4760 !!end
4761
4762 !! test
4763 External links: specified text
4764 !! wikitext
4765 Specified text: [http://example.com link]
4766 !! html
4767 <p>Specified text: <a rel="nofollow" class="external text" href="http://example.com">link</a>
4768 </p>
4769 !!end
4770
4771 !! test
4772 External links: trail
4773 !! wikitext
4774 Linktrails should not work for external links: [http://example.com link]s
4775 !! html
4776 <p>Linktrails should not work for external links: <a rel="nofollow" class="external text" href="http://example.com">link</a>s
4777 </p>
4778 !! end
4779
4780 !! test
4781 External links: dollar sign in URL
4782 !! wikitext
4783 http://example.com/1$2345
4784 !! html
4785 <p><a rel="nofollow" class="external free" href="http://example.com/1$2345">http://example.com/1$2345</a>
4786 </p>
4787 !! end
4788
4789 # parsoid doesn't explicitly mark autonumbered links, see T55505
4790 !! test
4791 External links: dollar sign in URL (autonumber)
4792 !! wikitext
4793 [http://example.com/1$2345]
4794 !! html/php
4795 <p><a rel="nofollow" class="external autonumber" href="http://example.com/1$2345">[1]</a>
4796 </p>
4797 !! html/parsoid
4798 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/1$2345"></a></p>
4799 !!end
4800
4801 !! test
4802 External links: open square bracket forbidden in URL (T6377)
4803 !! options
4804 parsoid=wt2html,wt2wt,html2html
4805 !! wikitext
4806 http://example.com/1[2345
4807 !! html/php
4808 <p><a rel="nofollow" class="external free" href="http://example.com/1">http://example.com/1</a>[2345
4809 </p>
4810 !! html/parsoid
4811 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/1">http://example.com/1</a>[2345</p>
4812 !! end
4813
4814 !! test
4815 External links: open square bracket forbidden in URL (named) (T6377)
4816 !! options
4817 parsoid=wt2html,html2html
4818 !! wikitext
4819 [http://example.com/1[2345]
4820 !! html/php
4821 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4822 </p>
4823 !! html/parsoid
4824 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/1">[2345</a></p>
4825 !!end
4826
4827 # parsoid adds a space before the link name
4828 !! test
4829 External links: open square bracket forbidden in URL (named) (T6377)
4830 Parsoid variant.
4831 !! wikitext
4832 [http://example.com/1 [2345]
4833 !! html
4834 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4835 </p>
4836 !!end
4837
4838 !! test
4839 External links: nowiki in URL link text (T8230)
4840 !! wikitext
4841 [http://example.com/ <nowiki>''example site''</nowiki>]
4842 !! html
4843 <p><a rel="nofollow" class="external text" href="http://example.com/">''example site''</a>
4844 </p>
4845 !! end
4846
4847 !! test
4848 External links: newline forbidden in text (T8230 regression check)
4849 !! wikitext
4850 [http://example.com/ first
4851 second]
4852 !! html
4853 <p>[<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a> first
4854 second]
4855 </p>
4856 !!end
4857
4858 !! test
4859 External links: Pipe char between url and text
4860 !! wikitext
4861 [http://example.com | link]
4862 !! html
4863 <p><a rel="nofollow" class="external text" href="http://example.com">| link</a>
4864 </p>
4865 !!end
4866
4867 !! test
4868 External links: protocol-relative URL in brackets
4869 !! wikitext
4870 [//example.com/ Test]
4871 !! html
4872 <p><a rel="nofollow" class="external text" href="//example.com/">Test</a>
4873 </p>
4874 !! end
4875
4876 # parsoid doesn't explicitly mark autonumbered links, see T55505
4877 !! test
4878 External links: protocol-relative URL in brackets without text
4879 !! wikitext
4880 [//example.com]
4881 !! html/php
4882 <p><a rel="nofollow" class="external autonumber" href="//example.com">[1]</a>
4883 </p>
4884 !! html/parsoid
4885 <p><a rel="mw:ExtLink" class="external autonumber" href="//example.com"></a></p>
4886 !! end
4887
4888 !! test
4889 External links: protocol-relative URL in free text is left alone
4890 !! wikitext
4891 //example.com/Foo
4892 !! html
4893 <p>//example.com/Foo
4894 </p>
4895 !!end
4896
4897 !! test
4898 External links: protocol-relative URL in the middle of a word is left alone (T32269)
4899 !! wikitext
4900 foo//example.com/Foo
4901 !! html
4902 <p>foo//example.com/Foo
4903 </p>
4904 !! end
4905
4906 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
4907 !! test
4908 External links: with no contents
4909 !! options
4910 parsoid=wt2html,wt2wt
4911 !! wikitext
4912 [http://en.wikipedia.org/wiki/Foo]
4913
4914 [[wikipedia:Foo|Bar]]
4915
4916 [[wikipedia:Foo|<span>Bar</span>]]
4917 !! html/php
4918 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo">[1]</a>
4919 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
4920 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo"><span>Bar</span></a>
4921 </p>
4922 !! html/parsoid
4923 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo"></a></p>
4924 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo">Bar</a></p>
4925 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo"><span>Bar</span></a></p>
4926 !! end
4927
4928 !! test
4929 External links: Free with trailing punctuation
4930 !! wikitext
4931 http://example.com,
4932 http://example.com;
4933 http://example.com\
4934 http://example.com.
4935 http://example.com:
4936 http://example.com!
4937 http://example.com?
4938 http://example.com)
4939 http://example.com/url_with_(brackets)
4940 (http://example.com/url_without_brackets)
4941 http://example.com/url_with_entity&amp;
4942 http://example.com/url_with_entity&#x26;
4943 http://example.com/url_with_entity&#038;
4944 http://example.com/url_with_entity&nbsp;
4945 http://example.com/url_with_entity&#xA0;
4946 http://example.com/url_with_entity&#160;
4947 http://example.com/url_with_entity&lt;
4948 http://example.com/url_with_entity&#x3C;
4949 http://example.com/url_with_entity&#60;
4950 !! html/php
4951 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
4952 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>;
4953 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>\
4954 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.
4955 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
4956 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>!
4957 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>?
4958 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
4959 <a rel="nofollow" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
4960 (<a rel="nofollow" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
4961 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4962 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4963 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4964 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
4965 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#xa0;
4966 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
4967 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&lt;
4968 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#x3c;
4969 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#60;
4970 </p>
4971 !! html/parsoid
4972 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>,
4973 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>;
4974 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>\
4975 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>.
4976 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>:
4977 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>!
4978 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>?
4979 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>)
4980 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
4981 (<a rel="mw:ExtLink" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
4982 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4983 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4984 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4985 <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>
4986 <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>
4987 <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>
4988 <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>
4989 <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>
4990 <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>
4991 !! end
4992
4993 !! test
4994 External links: tricky Parsoid html2html case
4995 !! options
4996 parsoid=wt2html,wt2wt,html2html
4997 !! wikitext
4998 http://example.com/url_with_entity&amp;amp;
4999 !! html/php
5000 <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>;
5001 </p>
5002 !! html/parsoid
5003 <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>
5004 !! end
5005
5006 !! test
5007 External links: Free with trailing quotes (T113666)
5008 !! wikitext
5009 '''News:''' Stuff here
5010
5011 news:'a'b''c''d e
5012 !! html/php
5013 <p><b>News:</b> Stuff here
5014 </p><p><a rel="nofollow" class="external free" href="news:&#39;a&#39;b">news:'a'b</a><i>c</i>d e
5015 </p>
5016 !! html/parsoid
5017 <p><b>News:</b> Stuff here</p>
5018 <p><a rel="mw:ExtLink" class="external free" href="news:'a'b">news:'a'b</a><i>c</i>d e</p>
5019 !! end
5020
5021 !! test
5022 External links: with entity
5023 !! wikitext
5024 [http://&#x20;www.librarieswithoutborders.org Libraries without borders]
5025 !! html/php
5026 <p><a rel="nofollow" class="external text" href="http://+www.librarieswithoutborders.org">Libraries without borders</a>
5027 </p>
5028 !! html/parsoid
5029 <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>
5030 !! end
5031
5032 !! test
5033 External links: Lone protocols are never linked (T105697)
5034 !! wikitext
5035 http://
5036 http://;
5037 (http://)
5038 bitcoin:
5039 bitcoin:;
5040 (bitcoin:)
5041 !! html
5042 <p>http://
5043 http://;
5044 (http://)
5045 bitcoin:
5046 bitcoin:;
5047 (bitcoin:)
5048 </p>
5049 !! end
5050
5051 !! test
5052 External links: No preceding word characters allowed (T67278)
5053 !! wikitext
5054 NOPEhttp://example.com
5055 N0http://example.com
5056 ok:http://example.com
5057 ok-http://example.com
5058 !! html
5059 <p>NOPEhttp://example.com
5060 N0http://example.com
5061 ok:<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5062 ok-<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5063 </p>
5064 !! end
5065
5066 !! test
5067 External links: nofollow domain exception
5068 !! wikitext
5069 A [https://no-nofollow.org/foobar link], and another [https://example.org link].
5070 !! html
5071 <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>.
5072 </p>
5073 !!end
5074
5075 !! test
5076 External image
5077 !! wikitext
5078 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5079 !! html
5080 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
5081 </p>
5082 !! end
5083
5084 !! test
5085 External image from https
5086 !! wikitext
5087 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5088 !! html
5089 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
5090 </p>
5091 !! end
5092
5093 !! test
5094 External image (when not allowed)
5095 !! options
5096 wgAllowExternalImages=0
5097 !! wikitext
5098 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5099 !! html
5100 <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>
5101 </p>
5102 !! end
5103
5104 !! test
5105 Link to non-http image, no img tag
5106 !! wikitext
5107 Link to non-http image, no img tag: ftp://example.com/test.jpg
5108 !! html
5109 <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>
5110 </p>
5111 !! end
5112
5113 !! test
5114 External links: terminating separator
5115 !! wikitext
5116 Terminating separator: http://example.com/thing,
5117 !! html
5118 <p>Terminating separator: <a rel="nofollow" class="external free" href="http://example.com/thing">http://example.com/thing</a>,
5119 </p>
5120 !! end
5121
5122 !! test
5123 External links: intervening separator
5124 !! wikitext
5125 Intervening separator: http://example.com/1,2,3
5126 !! html
5127 <p>Intervening separator: <a rel="nofollow" class="external free" href="http://example.com/1,2,3">http://example.com/1,2,3</a>
5128 </p>
5129 !! end
5130
5131 !! test
5132 External links: old bug with URL in query
5133 !! wikitext
5134 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
5135 !! html
5136 <p>Old bug with URL in query: <a rel="nofollow" class="external text" href="http://example.com/thing?url=http://example.com">link</a>
5137 </p>
5138 !! end
5139
5140 !! test
5141 External links: old URL-in-URL bug, mixed protocols
5142 !! wikitext
5143 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
5144 !! html
5145 <p>And again with mixed protocols: <a rel="nofollow" class="external text" href="ftp://example.com?url=http://example.com">link</a>
5146 </p>
5147 !!end
5148
5149 # Since Parsoid is starting to emit canonical wikitext for links,
5150 # [http://example.com http://example.com] will not RT back to that
5151 # form anymore.
5152 !! test
5153 External links: URL in text
5154 !! options
5155 parsoid=wt2html
5156 !! wikitext
5157 URL in text: [http://example.com http://example.com]
5158 !! html/php
5159 <p>URL in text: <a rel="nofollow" class="external text" href="http://example.com">http://example.com</a>
5160 </p>
5161 !! html/parsoid
5162 <p>URL in text: <a rel="mw:ExtLink" class="external text" href="http://example.com">http://example.com</a></p>
5163 !! end
5164
5165 !! test
5166 External links: Clickable images
5167 !! wikitext
5168 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
5169 !! html/php
5170 <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>
5171 </p>
5172 !! html/parsoid
5173 <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>
5174 !! end
5175
5176 !! test
5177 External links: raw ampersand
5178 !! wikitext
5179 Old &amp; use: http://x&y
5180 !! html
5181 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5182 </p>
5183 !! end
5184
5185 !! test
5186 External links: encoded ampersand
5187 !! wikitext
5188 Old &amp; use: http://x&amp;y
5189 !! html/php
5190 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5191 </p>
5192 !! html/parsoid
5193 <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>
5194 !! end
5195
5196 !! test
5197 External links: encoded equals (T8102)
5198 !! wikitext
5199 http://example.com/?foo&#61;bar
5200 !! html/php
5201 <p><a rel="nofollow" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a>
5202 </p>
5203 !! html/parsoid
5204 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a></p>
5205 !! end
5206
5207 ##
5208 ## Note that parsoid doesn't explicit mark autonumbered links, nor
5209 ## does it number them. As discussed in T55505, we can identify
5210 ## autonumbered links via CSS.
5211 ##
5212
5213 !! test
5214 External links: [raw ampersand]
5215 !! wikitext
5216 Old &amp; use: [http://x&y]
5217 !! html/php
5218 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5219 </p>
5220 !! html/parsoid
5221 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&amp;y"></a></p>
5222 !! end
5223
5224 # note that parsoid html is identical to [raw ampersand] case; so html2wt
5225 # mode will return the [raw ampersand] wikitext
5226 !! test
5227 External links: [encoded ampersand]
5228 !! options
5229 parsoid=wt2html,wt2wt,html2html
5230 !! wikitext
5231 Old &amp; use: [http://x&amp;y]
5232 !! html/php
5233 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5234 </p>
5235 !! html/parsoid
5236 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&amp;y"></a></p>
5237 !! end
5238
5239 !! test
5240 External links: [raw equals]
5241 !! wikitext
5242 [http://example.com/?foo=bar]
5243 !! html/php
5244 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5245 </p>
5246 !! html/parsoid
5247 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/?foo=bar"></a></p>
5248 !! end
5249
5250 # note that parsoid html is identical to [raw equals] case; so html2wt
5251 # mode will return the [raw equals] wikitext
5252 !! test
5253 External links: [encoded equals] (T8102)
5254 !! options
5255 parsoid=wt2html,wt2wt,html2html
5256 !! wikitext
5257 [http://example.com/?foo&#61;bar]
5258 !! html/php
5259 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5260 </p>
5261 !! html/parsoid
5262 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/?foo=bar"></a></p>
5263 !! end
5264
5265 # xxx parsoid strips the IDN character, so the round-trip tests will
5266 # obviously fail and are disabled. --cscott
5267 !! test
5268 External links: [IDN ignored character reference in hostname; strip it right off]
5269 !! options
5270 parsoid=wt2html,wt2wt,html2html
5271 !! wikitext
5272 [http://e&zwnj;xample.com/]
5273 !! html/php
5274 <p><a rel="nofollow" class="external autonumber" href="http://example.com/">[1]</a>
5275 </p>
5276 !! html/parsoid
5277 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/"></a></p>
5278 !! end
5279
5280 # FIXME: This test (the IDN characters in the text of a link) is an inconsistency.
5281 # Where an external link could easily circumvent the sanitization of the text of
5282 # a link like this (where an IDN-ignore character is in the URL somewhere), this
5283 # test demands a higher standard. That's a bit strange.
5284 #
5285 # Example:
5286 #
5287 # http://e‌xample.com -> [http://example.com|http://example.com]
5288 # [http://example.com|http://e‌xample.com] -> [http://example.com|http://e‌xample.com]
5289 #
5290 # The first example is sanitized, but the second is not. Any security benefits
5291 # from this production are trivial to circumvent. Either remove this test and
5292 # let the parser(s) do their thing unaccosted, or fix the inconsistency and change
5293 # the test accordingly.
5294 #
5295 # All our love,
5296 # The Parsoid team.
5297 # xxx parsoid strips the IDN character, so the round-trip tests will
5298 # obviously fail and are disabled. --cscott
5299 !! test
5300 External links: IDN ignored character reference in hostname; strip it right off
5301 !! options
5302 parsoid=wt2html,html2html
5303 !! wikitext
5304 http://e&zwnj;xample.com/
5305 !! html/php
5306 <p><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>
5307 </p>
5308 !! html/parsoid
5309 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/">http://example.com/</a></p>
5310 !! end
5311
5312 !! test
5313 External links: www.jpeg.org (T2554)
5314 !! wikitext
5315 http://www.jpeg.org
5316 !! html
5317 <p><a rel="nofollow" class="external free" href="http://www.jpeg.org">http://www.jpeg.org</a>
5318 </p>
5319 !! end
5320
5321 # parsoid doesn't explicitly mark autonumbered links, see T55505
5322 !! test
5323 External links: URL within URL (T2002)
5324 !! wikitext
5325 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
5326 !! html/php
5327 <p><a rel="nofollow" class="external autonumber" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp">[1]</a>
5328 </p>
5329 !! html/parsoid
5330 <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>
5331 !! end
5332
5333 !! test
5334 T2361: URL inside bracketed URL
5335 !! wikitext
5336 [http://www.example.com/foo http://www.example.com/bar]
5337 !! html
5338 <p><a rel="nofollow" class="external text" href="http://www.example.com/foo">http://www.example.com/bar</a>
5339 </p>
5340 !! end
5341
5342 !! test
5343 T2361: URL within URL, not bracketed
5344 !! wikitext
5345 http://www.example.com/foo?=http://www.example.com/bar
5346 !! html
5347 <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>
5348 </p>
5349 !! end
5350
5351 !! test
5352 T2289: ">"-token in URL-tail
5353 !! wikitext
5354 http://www.example.com/<hello>
5355 !! html
5356 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>&lt;hello&gt;
5357 </p>
5358 !!end
5359
5360 !! test
5361 T2289: literal ">"-token in URL-tail
5362 !! wikitext
5363 http://www.example.com/<b>html</b>
5364 !! html/php
5365 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a><b>html</b>
5366 </p>
5367 !! html/parsoid
5368 <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>
5369 !! end
5370
5371 !! test
5372 T2289: ">"-token in bracketed URL
5373 !! wikitext
5374 [http://www.example.com/<hello> stuff]
5375 !! html
5376 <p><a rel="nofollow" class="external text" href="http://www.example.com/">&lt;hello&gt; stuff</a>
5377 </p>
5378 !!end
5379
5380 !! test
5381 T2289: literal ">"-token in bracketed URL
5382 !! wikitext
5383 [http://www.example.com/<b>html</b> stuff]
5384 !! html
5385 <p><a rel="nofollow" class="external text" href="http://www.example.com/"><b>html</b> stuff</a>
5386 </p>
5387 !!end
5388
5389 !! test
5390 T2289: literal double quote at end of URL
5391 !! wikitext
5392 http://www.example.com/"hello"
5393 !! html
5394 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>"hello"
5395 </p>
5396 !!end
5397
5398 !! test
5399 T2289: literal double quote in bracketed URL
5400 !! wikitext
5401 [http://www.example.com/"hello" stuff]
5402 !! html
5403 <p><a rel="nofollow" class="external text" href="http://www.example.com/">"hello" stuff</a>
5404 </p>
5405 !!end
5406
5407 !! test
5408 External links: multiple legal whitespace is fine, Magnus. Don't break it please. (T7081)
5409 !! wikitext
5410 [http://www.example.com test]
5411 !! html
5412 <p><a rel="nofollow" class="external text" href="http://www.example.com">test</a>
5413 </p>
5414 !! end
5415
5416 !! test
5417 External links: link text with spaces
5418 !! wikitext
5419 [http://www.example.com a b c]
5420 [http://www.example.com ''a'' ''b'']
5421 !! html
5422 <p><a rel="nofollow" class="external text" href="http://www.example.com">a b c</a>
5423 <a rel="nofollow" class="external text" href="http://www.example.com"><i>a</i> <i>b</i></a>
5424 </p>
5425 !! end
5426
5427 # Note edge case difference between PHP and Parsoid here.
5428 !! test
5429 External links: wiki links within external link (T5695)
5430 !! options
5431 parsoid=wt2html,html2html
5432 !! wikitext
5433 [http://example.com [[wikilink]] embedded in ext link]
5434
5435 [http://example.com test [[wikilink]] embedded in ext link]
5436 !! html/php
5437 <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>
5438 </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>
5439 </p>
5440 !! html/parsoid
5441 <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>
5442 <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>
5443 !! end
5444
5445 !! test
5446 T2787: Links with one slash after the url protocol are invalid
5447 !! wikitext
5448 http:/example.com
5449
5450 [http:/example.com title]
5451 !! html
5452 <p>http:/example.com
5453 </p><p>[http:/example.com title]
5454 </p>
5455 !! end
5456
5457 !! test
5458 Bracketed external links with template-generated invalid target
5459 !! wikitext
5460 [{{echo|http:/example.com}} title]
5461 !! html
5462 <p>[http:/example.com title]
5463 </p>
5464 !! end
5465
5466 # wt2html only because Parsoid would want to add <nowiki>s coming from html
5467 !! test
5468 Broken wikilinks (but not external links) prevent templates from closing
5469 !! options
5470 parsoid=wt2html
5471 !! wikitext
5472 [http://example.com x
5473
5474 {{echo|[http://example.com x}}
5475
5476 [[Foo
5477
5478 {{echo|[[Foo}}
5479 !! html/php
5480 <p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5481 </p><p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5482 </p><p>[[Foo
5483 </p><p>{{echo|[[Foo}}
5484 </p>
5485 !! html/parsoid
5486 <p>[<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a> x</p>
5487 <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>
5488 <p>[[Foo</p>
5489 <p>{{echo|[[Foo}}</p>
5490 !! end
5491
5492 !! test
5493 Wikilinks with embedded newlines are not broken
5494 !! wikitext
5495 {{echo|[[ Foo
5496 B
5497 C]]}}
5498 !! html/php
5499 <p>[[ Foo
5500 B
5501 C]]
5502 </p>
5503 !! html/parsoid
5504 <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>
5505 !! end
5506
5507 !! test
5508 Broken templates
5509 !! options
5510 parsoid=wt2html
5511 !! wikitext
5512 {{echo|[[Foo|}}]]
5513
5514 [[Foo|{{echo|]]}}
5515 !! html/php
5516 <p>{{echo|<a href="/wiki/Foo" title="Foo">}}</a>
5517 </p><p>[[Foo|]]
5518 </p>
5519 !! html/parsoid
5520 <p>{{echo|<a rel="mw:WikiLink" href="./Foo" title="Foo">}}</a></p>
5521 <p>[[Foo|<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"]]"}},"i":0}}]}'>]]</span></p>
5522 !! end
5523
5524 !! test
5525 T4702: Mismatched <i>, <b> and <a> tags are invalid
5526 !! wikitext
5527 ''[http://example.com text'']
5528 [http://example.com '''text]'''
5529 ''Something [http://example.com in italic'']
5530 ''Something [http://example.com mixed''''', even bold]'''
5531 '''''Now [http://example.com both''''']
5532 !! html
5533 <p><a rel="nofollow" class="external text" href="http://example.com"><i>text</i></a>
5534 <a rel="nofollow" class="external text" href="http://example.com"><b>text</b></a>
5535 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>in italic</i></a>
5536 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>mixed</i><b>, even bold</b></a>
5537 <i><b>Now </b></i><a rel="nofollow" class="external text" href="http://example.com"><i><b>both</b></i></a>
5538 </p>
5539 !! end
5540
5541
5542 !! test
5543 T6781: %26 in URL
5544 !! wikitext
5545 http://www.example.com/?title=AT%26T
5546 !! html/php
5547 <p><a rel="nofollow" class="external free" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a>
5548 </p>
5549 !! html/parsoid
5550 <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>
5551 !! end
5552
5553 # According to https://www.w3.org/TR/2011/WD-html5-20110525/Overview.html#parsing-urls a plain
5554 # % is actually legal in HTML5. Any change in output would need testing though.
5555 !! test
5556 T6781, T7267: %25 in URL
5557 !! wikitext
5558 http://www.example.com/?title=100%25_Bran
5559 !! html/php
5560 <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>
5561 </p>
5562 !! html/parsoid
5563 <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>
5564 !! end
5565
5566 !! test
5567 T6781, T7267: %28, %29 in URL
5568 !! wikitext
5569 http://www.example.com/?title=Ben-Hur_%281959_film%29
5570 !! html/php
5571 <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>
5572 </p>
5573 !! html/parsoid
5574 <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>
5575 !! end
5576
5577
5578 !! test
5579 T6781: %26 in autonumber URL
5580 !! wikitext
5581 [http://www.example.com/?title=AT%26T]
5582 !! html/php
5583 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=AT%26T">[1]</a>
5584 </p>
5585 !! html/parsoid
5586 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=AT%26T"></a></p>
5587 !! end
5588
5589 !! test
5590 T6781, T7267: %26 in autonumber URL
5591 !! wikitext
5592 [http://www.example.com/?title=100%25_Bran]
5593 !! html/php
5594 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=100%25_Bran">[1]</a>
5595 </p>
5596 !! html/parsoid
5597 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=100%25_Bran"></a></p>
5598 !! end
5599
5600 !! test
5601 T6781, T7267: %28, %29 in autonumber URL
5602 !! wikitext
5603 [http://www.example.com/?title=Ben-Hur_%281959_film%29]
5604 !! html/php
5605 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">[1]</a>
5606 </p>
5607 !! html/parsoid
5608 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29"></a></p>
5609 !! end
5610
5611
5612 !! test
5613 T6781: %26 in bracketed URL
5614 !! wikitext
5615 [http://www.example.com/?title=AT%26T link]
5616 !! html/php
5617 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=AT%26T">link</a>
5618 </p>
5619 !! html/parsoid
5620 <p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=AT%26T">link</a></p>
5621 !! end
5622
5623 !! test
5624 T6781, T7267: %25 in bracketed URL
5625 !! wikitext
5626 [http://www.example.com/?title=100%25_Bran link]
5627 !! html
5628 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=100%25_Bran">link</a>
5629 </p>
5630 !! end
5631
5632 !! test
5633 T6781, T7267: %28, %29 in bracketed URL
5634 !! wikitext
5635 [http://www.example.com/?title=Ben-Hur_%281959_film%29 link]
5636 !! html/php
5637 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a>
5638 </p>
5639 !! html/parsoid
5640 <p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a></p>
5641 !! end
5642
5643 !! test
5644 External link containing a period in the anchor. (T65947)
5645 !! wikitext
5646 [//foo.org/bar#baz. bang]
5647
5648 [//foo.org/bar. bang]
5649 !! html/php
5650 <p><a rel="nofollow" class="external text" href="//foo.org/bar#baz.">bang</a>
5651 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar.">bang</a>
5652 </p>
5653 !! html/parsoid
5654 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar#baz.">bang</a></p>
5655 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar.">bang</a></p>
5656 !! end
5657
5658 !! test
5659 External link containing a single quote. (T65947)
5660 !! wikitext
5661 [//foo.org/bar'baz]
5662
5663 [//foo.org/bar'baz bang]
5664 !! html/php
5665 <p><a rel="nofollow" class="external autonumber" href="//foo.org/bar&#39;baz">[1]</a>
5666 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar&#39;baz">bang</a>
5667 </p>
5668 !! html/parsoid
5669 <p><a rel="mw:ExtLink" class="external autonumber" href="//foo.org/bar'baz"></a></p>
5670 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar'baz">bang</a></p>
5671 !! end
5672
5673 !! test
5674 External link containing double-single-quotes in text '' (T6598 sanity check)
5675 !! wikitext
5676 Some [http://example.com/ pretty ''italics'' and stuff]!
5677 !! html
5678 <p>Some <a rel="nofollow" class="external text" href="http://example.com/">pretty <i>italics</i> and stuff</a>!
5679 </p>
5680 !! end
5681
5682 !! test
5683 External link containing double-single-quotes in text embedded in italics (T6598 sanity check)
5684 !! wikitext
5685 ''Some [http://example.com/ pretty ''italics'' and stuff]!''
5686 !! html
5687 <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>
5688 </p>
5689 !! end
5690
5691 # Don't add the html/php section since the output is broken and there isn't any reason to spec it
5692 !! test
5693 External link containing double-single-quotes with no space separating the url from text in italics
5694 !! wikitext
5695 [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]].]
5696 !! html/php+tidy
5697 <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>.
5698 </p>
5699 !! html/parsoid
5700 <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>
5701 !! end
5702
5703 !! test
5704 External link with comments in link text
5705 !! wikitext
5706 [http://www.google.com Google <!-- comment -->]
5707 !! html/php
5708 <p><a rel="nofollow" class="external text" href="http://www.google.com">Google </a>
5709 </p>
5710 !! html/parsoid
5711 <p><a rel="mw:ExtLink" class="external text" href="http://www.google.com">Google <!-- comment --></a></p>
5712 !! end
5713
5714 !! test
5715 External link to bare IPv4 address
5716 !! wikitext
5717 [http://192.168.0.1 Link]
5718 !! html/php
5719 <p><a rel="nofollow" class="external text" href="http://192.168.0.1">Link</a>
5720 </p>
5721 !! html/parsoid
5722 <p><a rel="mw:ExtLink" class="external text" href="http://192.168.0.1">Link</a></p>
5723 !! end
5724
5725 !! test
5726 URL-encoding in URL functions (single parameter)
5727 !! wikitext
5728 {{localurl:Some page|amp=&}}
5729 !! html
5730 <p>/index.php?title=Some_page&amp;amp=&amp;
5731 </p>
5732 !! end
5733
5734 !! test
5735 URL-encoding in URL functions (multiple parameters)
5736 !! wikitext
5737 {{localurl:Some page|q=?&amp=&}}
5738 !! html
5739 <p>/index.php?title=Some_page&amp;q=?&amp;amp=&amp;
5740 </p>
5741 !! end
5742
5743 !! test
5744 Brackets in urls
5745 !! wikitext
5746 http://example.com/index.php?foozoid%5B%5D=bar
5747
5748 http://example.com/index.php?foozoid&#x5B;&#x5D;=bar
5749 !! html/php
5750 <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>
5751 </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>
5752 </p>
5753 !! html/parsoid
5754 <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>
5755
5756 <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>
5757 !! end
5758
5759 !! test
5760 IPv6 urls, autolink format (T23261)
5761 !! wikitext
5762 http://[2404:130:0:1000::187:2]/index.php
5763
5764 Examples from RFC 2373, section 2.2:
5765
5766 *http://[1080::8:800:200C:417A]/unicast
5767 *http://[FF01::101]/multicast
5768 *http://[::1]/loopback
5769 *http://[::]/unspecified
5770 *http://[::13.1.68.3]/ipv4compat
5771 *http://[::FFFF:129.144.52.38]/ipv4compat
5772
5773 Examples from RFC 2732, section 2:
5774
5775 *http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
5776 *http://[1080:0:0:0:8:800:200C:417A]/index.html
5777 *http://[3ffe:2a00:100:7031::1]
5778 *http://[1080::8:800:200C:417A]/foo
5779 *http://[::192.9.5.5]/ipng
5780 *http://[::FFFF:129.144.52.38]:80/index.html
5781 *http://[2010:836B:4179::836B:4179]
5782 !! html/php
5783 <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>
5784 </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:
5785 </p>
5786 <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>
5787 <li><a rel="nofollow" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5788 <li><a rel="nofollow" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5789 <li><a rel="nofollow" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5790 <li><a rel="nofollow" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5791 <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>
5792 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5793 </p>
5794 <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>
5795 <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>
5796 <li><a rel="nofollow" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5797 <li><a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
5798 <li><a rel="nofollow" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5799 <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>
5800 <li><a rel="nofollow" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5801
5802 !! html/parsoid
5803 <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>
5804
5805 <p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink" class="external mw-magiclink">RFC 2373</a>, section 2.2:</p>
5806 <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>
5807 <li><a rel="mw:ExtLink" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5808 <li><a rel="mw:ExtLink" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5809 <li><a rel="mw:ExtLink" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5810 <li><a rel="mw:ExtLink" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5811 <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>
5812
5813 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external mw-magiclink">RFC 2732</a>, section 2:</p>
5814 <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>
5815 <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>
5816 <li><a rel="mw:ExtLink" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5817 <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>
5818 <li><a rel="mw:ExtLink" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5819 <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>
5820 <li><a rel="mw:ExtLink" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5821 !! end
5822
5823 !! test
5824 IPv6 urls, bracketed format (T23261)
5825 !! wikitext
5826 [http://[2404:130:0:1000::187:2]/index.php test]
5827
5828 Examples from RFC 2373, section 2.2:
5829
5830 *[http://[1080::8:800:200C:417A] unicast]
5831 *[http://[FF01::101] multicast]
5832 *[http://[::1]/ loopback]
5833 *[http://[::] unspecified]
5834 *[http://[::13.1.68.3] ipv4compat]
5835 *[http://[::FFFF:129.144.52.38] ipv4compat]
5836
5837 Examples from RFC 2732, section 2:
5838
5839 *[http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html 1]
5840 *[http://[1080:0:0:0:8:800:200C:417A]/index.html 2]
5841 *[http://[3ffe:2a00:100:7031::1] 3]
5842 *[http://[1080::8:800:200C:417A]/foo 4]
5843 *[http://[::192.9.5.5]/ipng 5]
5844 *[http://[::FFFF:129.144.52.38]:80/index.html 6]
5845 *[http://[2010:836B:4179::836B:4179] 7]
5846 !! html/php
5847 <p><a rel="nofollow" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a>
5848 </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:
5849 </p>
5850 <ul><li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5851 <li><a rel="nofollow" class="external text" href="http://[FF01::101]">multicast</a></li>
5852 <li><a rel="nofollow" class="external text" href="http://[::1]/">loopback</a></li>
5853 <li><a rel="nofollow" class="external text" href="http://[::]">unspecified</a></li>
5854 <li><a rel="nofollow" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5855 <li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5856 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5857 </p>
5858 <ul><li><a rel="nofollow" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
5859 <li><a rel="nofollow" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5860 <li><a rel="nofollow" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5861 <li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5862 <li><a rel="nofollow" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
5863 <li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5864 <li><a rel="nofollow" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5865
5866 !! html/parsoid
5867 <p><a rel="mw:ExtLink" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a></p>
5868
5869 <p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink" class="external mw-magiclink">RFC 2373</a>, section 2.2:</p>
5870 <ul><li><a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5871 <li><a rel="mw:ExtLink" class="external text" href="http://[FF01::101]">multicast</a></li>
5872 <li><a rel="mw:ExtLink" class="external text" href="http://[::1]/">loopback</a></li>
5873 <li><a rel="mw:ExtLink" class="external text" href="http://[::]">unspecified</a></li>
5874 <li><a rel="mw:ExtLink" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5875 <li><a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5876
5877 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external mw-magiclink">RFC 2732</a>, section 2:</p>
5878 <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>
5879 <li><a rel="mw:ExtLink" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5880 <li><a rel="mw:ExtLink" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5881 <li><a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5882 <li><a rel="mw:ExtLink" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
5883 <li><a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5884 <li><a rel="mw:ExtLink" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5885 !! end
5886
5887 !! test
5888 Non-extlinks in brackets
5889 !! wikitext
5890 [foo]
5891 [foo bar]
5892 [foo ''bar'']
5893 [fool's] errand
5894 [fool's errand]
5895 [{{echo|foo}}]
5896 [{{echo|foo}} bar]
5897 [{{echo|foo}} ''bar'']
5898 [{{echo|foo}}l's] errand
5899 [{{echo|foo}}l's errand]
5900 [url={{echo|foo}}]
5901 [url=http://example.com]
5902 [http:// bare protocols don't count]
5903 !! html/php
5904 <p>[foo]
5905 [foo bar]
5906 [foo <i>bar</i>]
5907 [fool's] errand
5908 [fool's errand]
5909 [foo]
5910 [foo bar]
5911 [foo <i>bar</i>]
5912 [fool's] errand
5913 [fool's errand]
5914 [url=foo]
5915 [url=<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>]
5916 [http:// bare protocols don't count]
5917 </p>
5918 !! html/parsoid
5919 <p>[foo]
5920 [foo bar]
5921 [foo <i>bar</i>]
5922 [fool's] errand
5923 [fool's errand]
5924 [<span about="#mwt19" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>]
5925 [<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]
5926 [<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>]
5927 [<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
5928 [<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]
5929 [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>]
5930 [url=<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>]
5931 [http:// bare protocols don't count]</p>
5932 !! end
5933
5934 !! test
5935 Percent encoding in external links
5936 !! wikitext
5937 [https://github.com/search?l=&q=ResourceLoader+%40wikimedia Search]
5938 !! html/php
5939 <p><a rel="nofollow" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a>
5940 </p>
5941 !! html/parsoid
5942 <p><a rel="mw:ExtLink" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a></p>
5943 !! end
5944
5945 !! test
5946 Use url link syntax for links where the content is equal the link target
5947 !! wikitext
5948 http://example.com
5949 !! html/php
5950 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5951 </p>
5952 !! html/parsoid
5953 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a></p>
5954 !! end
5955
5956 !! test
5957 Parenthesis in external links, especially URL links
5958 !! wikitext
5959 http://example.com)
5960
5961 http://example.com/test)
5962
5963 http://example.com/(test)
5964
5965 http://example.com/((test)
5966
5967 (http://example.com/(test))
5968
5969 (http://example.com/(test)))))
5970
5971 http://example.com/a)b
5972
5973 [http://example.com) foo]
5974 !! html/php
5975 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
5976 </p><p><a rel="nofollow" class="external free" href="http://example.com/test">http://example.com/test</a>)
5977 </p><p><a rel="nofollow" class="external free" href="http://example.com/(test)">http://example.com/(test)</a>
5978 </p><p><a rel="nofollow" class="external free" href="http://example.com/((test)">http://example.com/((test)</a>
5979 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test))">http://example.com/(test))</a>
5980 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a>
5981 </p><p><a rel="nofollow" class="external free" href="http://example.com/a)b">http://example.com/a)b</a>
5982 </p><p><a rel="nofollow" class="external text" href="http://example.com)">foo</a>
5983 </p>
5984 !! html/parsoid
5985 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>)</p>
5986 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/test">http://example.com/test</a>)</p>
5987 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/(test)">http://example.com/(test)</a></p>
5988 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/((test)">http://example.com/((test)</a></p>
5989 <p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test))">http://example.com/(test))</a></p>
5990 <p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a></p>
5991 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/a)b">http://example.com/a)b</a></p>
5992 <p><a rel="mw:ExtLink" class="external text" href="http://example.com)">foo</a></p>
5993 !! end
5994
5995 !! test
5996 Parenthesis in external links, w/ transclusion or comment
5997 !! wikitext
5998 (http://example.com/{{echo|hi}})
5999
6000 (http://example.com<!-- hi -->)
6001 !! html/php
6002 <p>(<a rel="nofollow" class="external free" href="http://example.com/hi">http://example.com/hi</a>)
6003 </p><p>(<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
6004 </p>
6005 !! html/parsoid
6006 <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>
6007
6008 <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>
6009 !! end
6010
6011 !! test
6012 Serialize <a> tags with invalid link targets as plain text
6013 !! options
6014 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
6015 !! html/parsoid
6016 <a rel="mw:WikiLink" href="[[foo]]">text</a>
6017 <a rel="mw:WikiLink" href="[[foo]]">*text</a>
6018 <a rel="mw:WikiLink" href="[[foo]]">[[foo]]</a>
6019 <a rel="mw:WikiLink" href="[[foo]]">*a [[foo]]</a>
6020 !! wikitext
6021 text
6022 <nowiki>*</nowiki>text
6023 <nowiki>[[foo]]</nowiki>
6024 <nowiki>*</nowiki>a <nowiki>[[foo]]</nowiki>
6025 !! end
6026
6027 !! test
6028 mw:ExtLink -vs- mw:WikiLink (T94723)
6029 !! options
6030 parsoid=html2wt
6031 !! html/parsoid
6032 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"piped","a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>Bar</a>
6033 <a rel="mw:WikiLink" href="./Foo" title="Foo">Bar</a>
6034 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
6035 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
6036 <p>
6037 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
6038 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
6039 </p>
6040 !! wikitext
6041 [[Foo|Bar]]
6042 [[Foo|Bar]]
6043 [[:en:Foo|Bar]]
6044 [[:en:Foo|Bar]]
6045
6046 [[:en:European_Robin|European Robin]]
6047 [[:en:European_Robin|European Robin]]
6048 !! end
6049
6050 !! test
6051 mw:ExtLink linking to a interwiki URL can be round-tripped losslessly (T94723)
6052 !! options
6053 parsoid=wt2wt
6054 !! wikitext
6055 [http://en.wikipedia.org/wiki/European_Robin European Robin]
6056 !! html/parsoid
6057 THIS SECTION IS NOT USED (but Parsoid won't run the test without it)
6058 !! end
6059
6060
6061 ###
6062 ### Quotes
6063 ###
6064
6065 !! test
6066 Quotes
6067 !! wikitext
6068 Normal text. '''Bold text.''' Normal text. ''Italic text.''
6069
6070 Normal text. '''''Bold italic text.''''' Normal text.
6071 !! html
6072 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
6073 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
6074 </p>
6075 !! end
6076
6077
6078 # Parsoid inserts an empty bold tag pair at the end of the line, that the PHP
6079 # parser strips. The wikitext contains just the first half of the bold
6080 # quote pair.
6081 !! test
6082 Unclosed and unmatched quotes
6083 !! wikitext
6084 '''''Bold italic text '''with bold deactivated''' in between.'''''
6085
6086 '''''Bold italic text ''with italic deactivated'' in between.'''''
6087
6088 '''Bold text..
6089
6090 ..spanning two paragraphs (should not work).'''
6091
6092 '''Bold tag left open
6093
6094 ''Italic tag left open
6095
6096 Normal text.
6097
6098 <!-- Unmatching number of opening, closing tags: -->
6099 '''This year''''s election ''should'' beat '''last year''''s.
6100
6101 ''Tom'''s car is bigger than ''Susan'''s.
6102
6103 Plain ''italic'''s plain
6104 !! html/php
6105 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
6106 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
6107 </p><p><b>Bold text..</b>
6108 </p><p>..spanning two paragraphs (should not work).
6109 </p><p><b>Bold tag left open</b>
6110 </p><p><i>Italic tag left open</i>
6111 </p><p>Normal text.
6112 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
6113 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
6114 </p><p>Plain <i>italic'</i>s plain
6115 </p>
6116 !! html/parsoid
6117 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
6118 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
6119 </p><p><b>Bold text..</b>
6120 </p><p>..spanning two paragraphs (should not work).<b></b>
6121 </p><p><b>Bold tag left open</b>
6122 </p><p><i>Italic tag left open</i>
6123 </p><p>Normal text.
6124 </p>
6125 <!-- Unmatching number of opening, closing tags: -->
6126 <p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
6127 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
6128 </p><p>Plain <i>italic'</i>s plain
6129 </p>
6130 !! end
6131
6132 ###
6133 ### Tables
6134 ###
6135 ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
6136 ###
6137
6138 # This should not produce <table></table> as <table><tr><td></td></tr></table>
6139 # is the bare minimum required by the spec, see:
6140 # https://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
6141 # Parsoid team replies: empty table tags are legal in HTML5
6142 !! test
6143 A table with no data.
6144 !! options
6145 parsoid=wt2html
6146 !! wikitext
6147 {||}
6148 !! html/php
6149
6150 !! html/parsoid
6151 <table></table>
6152
6153 !! end
6154
6155 !! test
6156 A table with stray table end tags on start tag line (wt2html)
6157 !! options
6158 parsoid=wt2html
6159 !! wikitext
6160 {|style="color: red;"|}
6161
6162 {|style="color: red;" |}
6163 |foo
6164 |}
6165
6166 {|style="color: red;"|} id="foo"
6167 |foo
6168 |}
6169
6170 {|style="color: red;" |} id="foo"
6171 |foo
6172 |}
6173 !! html
6174 <table style="color: red;"></table>
6175
6176 <table style="color: red;">
6177 <tbody><tr>
6178 <td>foo</td>
6179 </tr></tbody>
6180 </table>
6181
6182 <table style="color: red;" id="foo">
6183 <tbody><tr>
6184 <td>foo</td>
6185 </tr></tbody>
6186 </table>
6187
6188 <table style="color: red;" id="foo">
6189 <tbody><tr>
6190 <td>foo</td>
6191 </tr></tbody>
6192 </table>
6193
6194 !! end
6195
6196 !! test
6197 A table with no data (take 2)
6198 !! wikitext
6199 {|
6200 |}
6201 !! html/parsoid
6202 <table></table>
6203 !! end
6204
6205 # A table with nothing but a caption is invalid XHTML, we might want to render
6206 # this as <p>caption</p>
6207 # Parsoid team replies: table with only a caption is legal in HTML5
6208 !! test
6209 A table with nothing but a caption
6210 !! wikitext
6211 {|
6212 |+caption
6213 |}
6214 !! html/php
6215 <table>
6216 <caption>caption
6217 </caption><tr><td></td></tr></table>
6218
6219 !! html/parsoid
6220 <table><caption>caption</caption></table>
6221 !! end
6222
6223 !! test
6224 A table with caption with default-spaced attributes and a table row
6225 !! wikitext
6226 {|
6227 |+ style="color: red;" |caption1
6228 |-
6229 |foo
6230 |}
6231 !! html
6232 <table>
6233 <caption style="color: red;">caption1
6234 </caption>
6235 <tr>
6236 <td>foo
6237 </td></tr></table>
6238
6239 !! end
6240
6241 !! test
6242 A table with captions with non-default spaced attributes and a table row
6243 !! wikitext
6244 {|
6245 |+style="color: red;"|caption2
6246 |+ style="color: red;"|caption3
6247 |-
6248 |foo
6249 |}
6250 !! html
6251 <table>
6252 <caption style="color: red;">caption2
6253 </caption>
6254 <caption style="color: red;">caption3
6255 </caption>
6256 <tr>
6257 <td>foo
6258 </td></tr></table>
6259
6260 !! end
6261
6262 !! test
6263 Table td-cell syntax variations
6264 !! wikitext
6265 {|
6266 |foo bar foo|baz
6267 |foo bar foo||baz
6268 |style='color:red;'|baz
6269 |style='color:red;'||baz
6270 |}
6271 !! html
6272 <table>
6273 <tr>
6274 <td>baz
6275 </td>
6276 <td>foo bar foo</td>
6277 <td>baz
6278 </td>
6279 <td style="color:red;">baz
6280 </td>
6281 <td>style='color:red;'</td>
6282 <td>baz
6283 </td></tr></table>
6284
6285 !! end
6286
6287 !! test
6288 Simple table
6289 !! wikitext
6290 {|
6291 |1||2
6292 |-
6293 |3||4
6294 |}
6295 !! html
6296 <table>
6297 <tr>
6298 <td>1</td>
6299 <td>2
6300 </td></tr>
6301 <tr>
6302 <td>3</td>
6303 <td>4
6304 </td></tr></table>
6305
6306 !! end
6307
6308 !! test
6309 Simple table but with multiple dashes for row wikitext
6310 !! wikitext
6311 {|
6312 |foo
6313 |-----
6314 |bar
6315 |}
6316 !! html
6317 <table>
6318 <tr>
6319 <td>foo
6320 </td></tr>
6321 <tr>
6322 <td>bar
6323 </td></tr></table>
6324
6325 !! end
6326
6327 !! test
6328 Multiplication table
6329 !! wikitext
6330 {| border="1" cellpadding="2"
6331 |+Multiplication table
6332 |-
6333 !&times;!!1!!2!!3
6334 |-
6335 !1
6336 |1||2||3
6337 |-
6338 !2
6339 |2||4||6
6340 |-
6341 !3
6342 |3||6||9
6343 |-
6344 !4
6345 |4||8||12
6346 |-
6347 !5
6348 |5||10||15
6349 |}
6350 !! html
6351 <table border="1" cellpadding="2">
6352 <caption>Multiplication table
6353 </caption>
6354 <tr>
6355 <th>&#215;</th>
6356 <th>1</th>
6357 <th>2</th>
6358 <th>3
6359 </th></tr>
6360 <tr>
6361 <th>1
6362 </th>
6363 <td>1</td>
6364 <td>2</td>
6365 <td>3
6366 </td></tr>
6367 <tr>
6368 <th>2
6369 </th>
6370 <td>2</td>
6371 <td>4</td>
6372 <td>6
6373 </td></tr>
6374 <tr>
6375 <th>3
6376 </th>
6377 <td>3</td>
6378 <td>6</td>
6379 <td>9
6380 </td></tr>
6381 <tr>
6382 <th>4
6383 </th>
6384 <td>4</td>
6385 <td>8</td>
6386 <td>12
6387 </td></tr>
6388 <tr>
6389 <th>5
6390 </th>
6391 <td>5</td>
6392 <td>10</td>
6393 <td>15
6394 </td></tr></table>
6395
6396 !! end
6397
6398 !! test
6399 Accept "||" in table headings
6400 !! wikitext
6401 {|
6402 !h1||h2
6403 |}
6404 !! html
6405 <table>
6406 <tr>
6407 <th>h1</th>
6408 <th>h2
6409 </th></tr></table>
6410
6411 !! end
6412
6413 !! test
6414 Accept "!!" in table data
6415 !! wikitext
6416 {|
6417 |Foo!!||
6418 |}
6419 !! html
6420 <table>
6421 <tr>
6422 <td>Foo!!</td>
6423 <td>
6424 </td></tr></table>
6425
6426 !! html/parsoid
6427 <table>
6428 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'> Foo!! </td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'></td></tr>
6429 </tbody></table>
6430 !! end
6431
6432 !! test
6433 Accept "||" in indented table headings
6434 !! wikitext
6435 :{|
6436 !h1||h2
6437 |}
6438 !! html
6439 <dl><dd><table>
6440 <tr>
6441 <th>h1</th>
6442 <th>h2
6443 </th></tr></table></dd></dl>
6444
6445 !! end
6446
6447 !! test
6448 Accept "!!" in templates
6449 !! wikitext
6450 {|
6451 !a {{echo|b!!c}}
6452 |}
6453 !! html/php
6454 <table>
6455 <tr>
6456 <th>a b</th>
6457 <th>c
6458 </th></tr></table>
6459
6460 !! html/parsoid
6461 <table>
6462 <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>
6463 !! end
6464
6465 !! test
6466 Accept "!!" in table headings after newline
6467 !! wikitext
6468 {|
6469 !a
6470 b!!c
6471 |}
6472 !! html/php
6473 <table>
6474 <tr>
6475 <th>a
6476 <p>b!!c
6477 </p>
6478 </th></tr></table>
6479
6480 !! html/parsoid
6481 <table>
6482 <tbody><tr><th>a
6483 <p>b!!c</p></th></tr>
6484 </tbody></table>
6485 !! end
6486
6487 !! test
6488 Accept "!!" in table data of mixed wikitext / html syntax
6489 !! wikitext
6490 {|
6491 !a
6492 <tr><td>b!!c</td></tr>
6493 |}
6494 !! html/php+tidy
6495 <table>
6496 <tbody><tr>
6497 <th>a
6498 </th></tr><tr><td>b!!c</td></tr>
6499 </tbody></table>
6500 !! html/parsoid
6501 <table>
6502 <tbody><tr><th>a</th></tr>
6503 <tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>b!!c</td></tr>
6504 </tbody></table>
6505 !! end
6506
6507 !! test
6508 Accept empty attributes in td/th cells (td/th cells starting with leading ||)
6509 !! wikitext
6510 {|
6511 !|h1
6512 ||a
6513 |}
6514 !! html
6515 <table>
6516 <tr>
6517 <th>h1
6518 </th>
6519 <td>a
6520 </td></tr></table>
6521
6522 !! end
6523
6524 !!test
6525 Accept "| !" at start of line in tables (ignore !-attribute)
6526 !! wikitext
6527 {|
6528 |-
6529 |!style="color:red"|bar
6530 |}
6531 !! html
6532 <table>
6533
6534 <tr>
6535 <td>bar
6536 </td></tr></table>
6537
6538 !!end
6539
6540 !!test
6541 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 +/-
6542 !! wikitext
6543 {|
6544 |-
6545 |style='color:red;'|+1
6546 |style='color:blue;'|-1
6547 |-
6548 |1||2||3
6549 |1||+2||-3
6550 |-
6551 | +1
6552 | -1
6553 |}
6554 !! html
6555 <table>
6556
6557 <tr>
6558 <td style="color:red;">+1
6559 </td>
6560 <td style="color:blue;">-1
6561 </td></tr>
6562 <tr>
6563 <td>1</td>
6564 <td>2</td>
6565 <td>3
6566 </td>
6567 <td>1</td>
6568 <td>+2</td>
6569 <td>-3
6570 </td></tr>
6571 <tr>
6572 <td>+1
6573 </td>
6574 <td>-1
6575 </td></tr></table>
6576
6577 !!end
6578
6579 !! test
6580 Table rowspan
6581 !! wikitext
6582 {| border=1
6583 |Cell 1, row 1
6584 |rowspan=2|Cell 2, row 1 (and 2)
6585 |Cell 3, row 1
6586 |-
6587 |Cell 1, row 2
6588 |Cell 3, row 2
6589 |}
6590 !! html
6591 <table border="1">
6592 <tr>
6593 <td>Cell 1, row 1
6594 </td>
6595 <td rowspan="2">Cell 2, row 1 (and 2)
6596 </td>
6597 <td>Cell 3, row 1
6598 </td></tr>
6599 <tr>
6600 <td>Cell 1, row 2
6601 </td>
6602 <td>Cell 3, row 2
6603 </td></tr></table>
6604
6605 !! end
6606
6607 !! test
6608 Nested table
6609 !! wikitext
6610 {| border=1
6611 | &alpha;
6612 |
6613 {| bgcolor=#ABCDEF border=2
6614 |nested
6615 |-
6616 |table
6617 |}
6618 |the original table again
6619 |}
6620 !! html
6621 <table border="1">
6622 <tr>
6623 <td>&#945;
6624 </td>
6625 <td>
6626 <table bgcolor="#ABCDEF" border="2">
6627 <tr>
6628 <td>nested
6629 </td></tr>
6630 <tr>
6631 <td>table
6632 </td></tr></table>
6633 </td>
6634 <td>the original table again
6635 </td></tr></table>
6636
6637 !! end
6638
6639 !! test
6640 Invalid attributes in table cell (T3830)
6641 !! wikitext
6642 {|
6643 |Cell:|broken
6644 |}
6645 !! html
6646 <table>
6647 <tr>
6648 <td>broken
6649 </td></tr></table>
6650
6651 !! end
6652
6653 !! test
6654 Table cell attributes: Pipes protected by nowikis should be treated as a plain character
6655 !! wikitext
6656 {|
6657 |title="foo" |bar
6658 |title="foo<nowiki>|</nowiki>" |bar
6659 |title="foo<nowiki>|</nowiki>" bar
6660 |}
6661 !! html/php
6662 <table>
6663 <tr>
6664 <td title="foo">bar
6665 </td>
6666 <td title="foo&#124;">bar
6667 </td>
6668 <td>title="foo|" bar
6669 </td></tr></table>
6670
6671 !! html/parsoid
6672 <table>
6673 <tbody><tr><td title="foo">bar</td>
6674 <td title="foo|" data-parsoid='{"a":{"title":"foo|"},"sa":{"title":"foo&lt;nowiki>|&lt;/nowiki>"},"autoInsertedEnd":true}'>bar</td>
6675 <td> title="foo<span typeof="mw:Nowiki">|</span>" bar</td></tr>
6676 </tbody></table>
6677 !! end
6678
6679 # See: http://lists.wikimedia.org/mailman/htdig/wikitech-l/2006-April/022293.html
6680 # N.B. The "|}" to close the table is missing from the input, so parsoid's
6681 # *2wt modes will fail.
6682 !! test
6683 Table security: embedded pipes
6684 !! options
6685 parsoid=wt2html,html2html
6686 !! wikitext
6687 {|
6688 | |[ftp://|x||]" onmouseover="alert(document.cookie)">test
6689 !! html/php
6690 <table>
6691 <tr>
6692 <td>[<a rel="nofollow" class="external free" href="ftp://%7Cx">ftp://%7Cx</a></td>
6693 <td>]" onmouseover="alert(document.cookie)"&gt;test
6694 </td>
6695 </tr>
6696 </table>
6697
6698 !! html/parsoid
6699 <table><tbody>
6700 <tr>
6701 <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>
6702 !! end
6703
6704 !! test
6705 Element attributes with double ! should not be broken up by <th>
6706 !! wikitext
6707 {|
6708 !hi <div class="!!">ha</div> ho
6709 |}
6710 !! html/php
6711 <table>
6712 <tr>
6713 <th>hi <div class="!!">ha</div> ho
6714 </th></tr></table>
6715
6716 !! html/parsoid
6717 <table>
6718 <tbody><tr><th>hi <div class="!!" data-parsoid='{"stx":"html"}'>ha</div> ho</th></tr>
6719 </tbody></table>
6720 !! end
6721
6722 !! test
6723 ! and || in element attributes should not be parsed as <th>/<td>
6724 !! wikitext
6725 {|
6726 |<div style="color: red !important;" data-contrived="put this here ||">hi</div>
6727 |}
6728 !! html/php
6729 <table>
6730 <tr>
6731 <td><div style="color: red !important;" data-contrived="put this here &#124;&#124;">hi</div>
6732 </td></tr></table>
6733
6734 !! html/parsoid
6735 <table>
6736 <tbody><tr><td><div style="color: red !important;" data-contrived="put this here ||" data-parsoid='{"stx":"html"}'>hi</div></td></tr>
6737 </tbody></table>
6738 !! end
6739
6740 # FIXME: The output seems broken. Filed as T110268.
6741 !! test
6742 ! and || in td attributes should not be parsed as <th>/<td>
6743 !! options
6744 parsoid=wt2html
6745 !! wikitext
6746 {|
6747 |style="color: red !important;" data-contrived="put this here ||"|foo
6748 |}
6749 !! html/php
6750 <table>
6751 <tr>
6752 <td>style="color: red !important;" data-contrived="put this here</td>
6753 <td>foo
6754 </td></tr></table>
6755
6756 !! html/parsoid
6757 <table>
6758 <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>
6759 </tbody></table>
6760 !! end
6761
6762 !! test
6763 Break on | in element attribute in template
6764 !! options
6765 parsoid=wt2html,html2html
6766 !! wikitext
6767 {{echo|1=<div class="hi|ho">ha</div>}}
6768 !! html/php
6769 <p>ho"&gt;ha&lt;/div&gt;
6770 </p>
6771 !! html/parsoid
6772 <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>
6773 !! end
6774
6775 !! test
6776 Break on | in element attribute name in template
6777 !! wikitext
6778 {{echo|<div cla|ss="hiho">ha</div>}}
6779 !! html/parsoid
6780 <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>
6781 !! end
6782
6783 !! test
6784 Don't break on | in extension attribute in template
6785 !! wikitext
6786 {{echo|<ref name="hi|ho">ha</ref>}}
6787
6788 <references />
6789 !! html/parsoid
6790 <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>
6791
6792 <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>
6793 !! end
6794
6795 ## We don't support roundtripping of these attributes in Parsoid.
6796 ## Selective serialization takes care of preventing dirty diffs.
6797 ## But, on edits, we dirty-diff the invalid attribute text.
6798 !! test
6799 Invalid text in table attributes should be discarded
6800 !! options
6801 parsoid=wt2html
6802 !! wikitext
6803 {| <span>boo</span> style='border:1px solid black'
6804 | <span>boo</span> style='color:blue' |1
6805 |<span>boo</span> style='color:blue'|2
6806 |}
6807 !! html/php
6808 <table style="border:1px solid black">
6809 <tr>
6810 <td style="color:blue">1
6811 </td>
6812 <td style="color:blue">2
6813 </td></tr></table>
6814
6815 !! html/parsoid
6816 <table style="border:1px solid black">
6817 <tr>
6818 <td style="color:blue">1</td>
6819 <td style="color:blue">2</td>
6820 </tr>
6821 </table>
6822 !! end
6823
6824 !! test
6825 Invalid text in table attributes should be preserved by selective serializer
6826 !! options
6827 parsoid={
6828 "modes": ["selser"],
6829 "changes": [
6830 ["td:first-child", "text", "abc"],
6831 ["td + td", "text", "xyz"]
6832 ]
6833 }
6834 !! wikitext
6835 {| <span>boo</span> style='border:1px solid black'
6836 | <span>boo</span> style='color:blue' | 1
6837 |<span>boo</span> style='color:blue'| 2
6838 |}
6839 !! wikitext/edited
6840 {| <span>boo</span> style='border:1px solid black'
6841 | <span>boo</span> style='color:blue' | abc
6842 |<span>boo</span> style='color:blue'| xyz
6843 |}
6844 !! end
6845
6846 !! test
6847 1. Template-generated table cell attributes and cell content
6848 !! wikitext
6849 {|
6850 |{{table_attribs}}
6851 | {{table_attribs}}
6852 || {{table_attribs_5}}
6853 | <!--foo--> <!--bar--> <!--baz--> {{table_attribs}}
6854 |align=center {{table_attribs}}
6855 | <!--foo--> align=center <!--bar--> {{table_attribs}}
6856 |}
6857 !! html
6858 <table>
6859 <tr>
6860 <td style="color:red;">Foo
6861 </td>
6862 <td style="color:red;">Foo
6863 </td>
6864 <td>style="color:red;"</td>
6865 <td>Bar
6866 </td>
6867 <td style="color:red;">Foo
6868 </td>
6869 <td align="center" style="color:red;">Foo
6870 </td>
6871 <td align="center" style="color:red;">Foo
6872 </td></tr></table>
6873
6874 !! end
6875
6876 !! test
6877 2. Template-generated table cell attributes and cell content
6878 !! wikitext
6879 {|
6880 |{{table_attribs_2}}
6881 |}
6882 !! html/php
6883 <table>
6884 <tr>
6885 <td style="color:red;">Foo
6886 </td>
6887 <td>Bar</td>
6888 <td>Baz
6889 </td></tr></table>
6890
6891 !! html/parsoid
6892 <table>
6893 <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>
6894 <td about="#mwt1">Bar</td><td about="#mwt1">Baz</td></tr>
6895 </tbody></table>
6896 !! end
6897
6898 !! test
6899 3. Template-generated table cell attributes and cell content
6900 !! wikitext
6901 {|
6902 !align=center {{table_header_cells}}
6903 |-
6904 |align=center {{table_cells}}
6905 |}
6906 !! html/php
6907 <table>
6908 <tr>
6909 <th align="center" style="color:red;">Foo</th>
6910 <th style="color:red;"><i>Bar</i></th>
6911 <th style="color:brown;"><i>Foo</i> and Baz
6912 </th></tr>
6913 <tr>
6914 <td align="center" style="color:red;">Foo</td>
6915 <td style="color:red;"><i>Bar</i></td>
6916 <td style="color:brown;"><i>Foo</i> and Baz
6917 </td></tr></table>
6918
6919 !! html/parsoid
6920 <table>
6921 <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>
6922 <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>
6923 </tbody></table>
6924 !! end
6925
6926 !! test
6927 4. Template-generated table cell attributes and cell content inside a templated table
6928 !! wikitext
6929 {{tbl-start}}
6930 !align=center {{table_header_cells}}
6931 |-
6932 |align=center {{table_cells}}
6933 {{tbl-end}}
6934 !! html/php
6935 <table>
6936 <tr>
6937 <th align="center" style="color:red;">Foo</th>
6938 <th style="color:red;"><i>Bar</i></th>
6939 <th style="color:brown;"><i>Foo</i> and Baz
6940 </th></tr>
6941 <tr>
6942 <td align="center" style="color:red;">Foo</td>
6943 <td style="color:red;"><i>Bar</i></td>
6944 <td style="color:brown;"><i>Foo</i> and Baz
6945 </td></tr></table>
6946
6947 !! html/parsoid
6948 <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}}]}'>
6949 <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>
6950 <tr>
6951 <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>
6952 </tbody></table>
6953 !! end
6954
6955 ## Edge case fix to prevent future regressions
6956 !! test
6957 T107652: <ref>s in templates that also generate table cell attributes should be rendered properly
6958 !! wikitext
6959 {|
6960 |{{table_attribs_7}}
6961 |}
6962 <references />
6963 !! html/parsoid
6964 <table>
6965 <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>
6966 </tbody></table>
6967 <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>
6968 !! end
6969
6970 !! test
6971 Table with row followed by newlines and table heading
6972 !! options
6973 parsoid=wt2html,html2html
6974 !! wikitext
6975 {|
6976 |-
6977
6978 !foo
6979 |}
6980 !! html/*
6981 <table>
6982
6983
6984 <tr>
6985 <th>foo
6986 </th></tr></table>
6987
6988 !! end
6989
6990 !! test
6991 Table with empty line following the start tag
6992 !! options
6993 parsoid=wt2html,html2html
6994 !! wikitext
6995 {|
6996
6997 |-
6998 |foo
6999 |}
7000 !! html/*
7001 <table>
7002
7003
7004 <tr>
7005 <td>foo
7006 </td></tr></table>
7007
7008 !! end
7009
7010 !! test
7011 Table attributes with empty value
7012 !! options
7013 parsoid=wt2html,html2html
7014 !! wikitext
7015 {|
7016 | style=|hello
7017 |}
7018 !! html/php
7019 <table>
7020 <tr>
7021 <td style="">hello
7022 </td></tr></table>
7023
7024 !! html/parsoid
7025 <table>
7026 <tbody><tr><td style="">hello</td></tr>
7027 </tbody></table>
7028 !! end
7029
7030 !! test
7031 Wikitext table with a lot of comments
7032 !! wikitext
7033 {|
7034 <!-- c0 -->
7035 |foo
7036 <!-- c1 -->
7037 |-<!-- c2 -->
7038 <!-- c3 -->
7039 |<!-- c4 -->
7040 <!-- c5 -->
7041 |}
7042 !! html
7043 <table>
7044 <tr>
7045 <td>foo
7046 </td></tr>
7047 <tr>
7048 <td>
7049 </td></tr></table>
7050
7051 !! end
7052
7053 !! test
7054 Wikitext table comments represented in parsoid dom
7055 !! wikitext
7056 {|<!--c1--><!--c2-->
7057 |-<!--c3-->
7058 |x
7059 |}
7060 !! html/php+tidy
7061 <table>
7062
7063 <tbody><tr>
7064 <td>x
7065 </td></tr></tbody></table>
7066 !! html/parsoid
7067 <table><!--c1--><!--c2-->
7068 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'><!--c3-->
7069 <td data-parsoid='{"autoInsertedEnd":true}'>x</td></tr>
7070 </tbody></table>
7071 !! end
7072
7073 !! test
7074 Wikitext table with double-line table cell
7075 !! wikitext
7076 {|
7077 |a
7078 b
7079 |}
7080 !! html
7081 <table>
7082 <tr>
7083 <td>a
7084 <p>b
7085 </p>
7086 </td></tr></table>
7087
7088 !! end
7089
7090 !! test
7091 Table cell with a single comment
7092 !! wikitext
7093 {|
7094 |<!-- c1 -->
7095 |a
7096 |}
7097 !! html
7098 <table>
7099 <tr>
7100 <td>
7101 </td>
7102 <td>a
7103 </td></tr></table>
7104
7105 !! end
7106
7107 !! test
7108 Table-cell after a comment-only-empty-line
7109 !! wikitext
7110 {|
7111 |a
7112 <!--c1-->
7113 <!--c2-->|b
7114 |}
7115 !! html
7116 <table>
7117 <tr>
7118 <td>a
7119 </td>
7120 <td>b
7121 </td></tr></table>
7122
7123 !! html/parsoid
7124 <table>
7125 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>a</td>
7126 <!--c1-->
7127 <!--c2--><td data-parsoid='{"autoInsertedEnd":true}'>b</td></tr>
7128 </tbody></table>
7129
7130 !! end
7131
7132 !! test
7133 Build table with {{!}}
7134 !! wikitext
7135 {{{!}} class="wikitable"
7136 !header
7137 !second header
7138 {{!}}- style="color:red;"
7139 {{!}}data{{!}}{{!}} style="color:red;" {{!}}second data
7140 {{!}}}
7141 !! html
7142 <table class="wikitable">
7143 <tr>
7144 <th>header
7145 </th>
7146 <th>second header
7147 </th></tr>
7148 <tr style="color:red;">
7149 <td>data</td>
7150 <td style="color:red;">second data
7151 </td></tr></table>
7152
7153 !! end
7154
7155 !! test
7156 Build table with pipe as data
7157 !! wikitext
7158 {| class="wikitable"
7159 !header
7160 !second header
7161 |- style="color:red;"
7162 |data|| style="color:red;" |second data
7163 |-
7164 | style="color:red;" |data with | || style="color:red;" | second data with |
7165 |-
7166 ||data with | |||second data with |
7167 |}
7168 !! html
7169 <table class="wikitable">
7170 <tr>
7171 <th>header
7172 </th>
7173 <th>second header
7174 </th></tr>
7175 <tr style="color:red;">
7176 <td>data</td>
7177 <td style="color:red;">second data
7178 </td></tr>
7179 <tr>
7180 <td style="color:red;">data with |</td>
7181 <td style="color:red;">second data with |
7182 </td></tr>
7183 <tr>
7184 <td>data with |</td>
7185 <td>second data with |
7186 </td></tr></table>
7187
7188 !! end
7189
7190 !! test
7191 Build table with wikilink
7192 !! wikitext
7193 {| class="wikitable"
7194 !header||second header
7195 |- style="color:red;"
7196 |data [[Main Page|linktext]]||second data [[Main Page|linktext]]
7197 |-
7198 |data||second data [[Main Page|link|text with pipe]]
7199 |}
7200 !! html
7201 <table class="wikitable">
7202 <tr>
7203 <th>header</th>
7204 <th>second header
7205 </th></tr>
7206 <tr style="color:red;">
7207 <td>data <a href="/wiki/Main_Page" title="Main Page">linktext</a></td>
7208 <td>second data <a href="/wiki/Main_Page" title="Main Page">linktext</a>
7209 </td></tr>
7210 <tr>
7211 <td>data</td>
7212 <td>second data <a href="/wiki/Main_Page" title="Main Page">link|text with pipe</a>
7213 </td></tr></table>
7214
7215 !! end
7216
7217 # The expected HTML structure in this test is debatable. The PHP parser does
7218 # not parse this kind of table at all. The main focus for Parsoid is on
7219 # round-tripping, so this output is ok for now. TODO: revisit!
7220 !! test
7221 Wikitext table with html-syntax row
7222 !! wikitext
7223 {|
7224 |-
7225 <td>foo</td>
7226 |}
7227 !! html/parsoid
7228 <table>
7229 <tbody>
7230 <tr>
7231 <td>foo</td></tr></tbody></table>
7232 !! end
7233
7234 !! test
7235 Fostered content in tables: Plain text
7236 !! options
7237 parsoid=wt2html,html2html
7238 !! wikitext
7239 {|
7240 |-
7241 a
7242 |}
7243 !! html/php
7244 <table>
7245
7246 a
7247 </table>
7248
7249 !! html/php+tidy
7250
7251
7252 a
7253 <table></table>
7254 !! html/parsoid
7255 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>a</p><table>
7256 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7257
7258 </tr></tbody></table>
7259 !! end
7260
7261 !! test
7262 Fostered content in tables: Lists
7263 !! options
7264 parsoid=wt2html,html2html
7265 !! wikitext
7266 {|
7267 |-
7268 *a
7269 |}
7270 !! html/php
7271 <table>
7272
7273 <ul><li>a</li></ul>
7274 </table>
7275
7276 !! html/php+tidy
7277 <ul><li>a</li></ul><table>
7278
7279
7280 </table>
7281 !! html/parsoid
7282 <ul data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><li>a</li></ul><table>
7283 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7284
7285 </tr></tbody></table>
7286 !! end
7287
7288 !! test
7289 Template generated table cell with attributes
7290 !! wikitext
7291 {|
7292 |-
7293 {{table_attribs_4}} ||a||b
7294 |}
7295 !! html/php+tidy
7296 <table>
7297
7298 <tbody><tr>
7299 <td style="background-color:#DC241f;" width="10px"></td>
7300 <td>a</td>
7301 <td>b
7302 </td></tr></tbody></table>
7303 !! html/parsoid
7304 <table>
7305 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7306 <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>
7307 !! end
7308
7309 !! test
7310 Parsoid: Round-trip tables directly followed by content (T53219)
7311 !! options
7312 parsoid=wt2html,wt2wt
7313 !! wikitext
7314 {|
7315 |foo
7316 |} bar
7317
7318 {|
7319 |baz
7320 |}<b>quux</b>
7321 !! html+tidy
7322 <table>
7323 <tbody><tr>
7324 <td>foo
7325 </td></tr></tbody></table><p> bar
7326 </p><table>
7327 <tbody><tr>
7328 <td>baz
7329 </td></tr></tbody></table><p><b>quux</b>
7330 </p>
7331 !! end
7332
7333 !! test
7334 Parsoid: Default to a newline after tables in new content (T53219)
7335 !! options
7336 parsoid=html2wt
7337 !! html/parsoid
7338 <table><tbody>
7339 <tr><td>foo</td></tr></tbody></table> bar
7340 <table><tbody>
7341 <tr><td>baz</td></tr></tbody></table><b>quux</b>
7342 !! wikitext
7343 {|
7344 |foo
7345 |}
7346 <nowiki> </nowiki>bar
7347 {|
7348 |baz
7349 |}
7350 '''quux'''
7351 !! end
7352
7353 !! test
7354 Parsoid: Row-syntax table headings followed by comment & table cells
7355 !! options
7356 parsoid=wt2html,wt2wt
7357 !! wikitext
7358 {|
7359 !foo||bar
7360 <!-- foo --> ||baz||quux
7361 |}
7362 !! html/php
7363 <table>
7364 <tr>
7365 <th>foo</th>
7366 <th>bar
7367 </th>
7368 <td>baz</td>
7369 <td>quux
7370 </td></tr></table>
7371
7372 !! html/parsoid
7373 <table>
7374 <tbody><tr><th>foo</th><th>bar
7375 <!-- foo --></th><td> baz </td><td>quux</td></tr>
7376 </tbody></table>
7377 !! end
7378
7379 !!test
7380 Parsoid: Recover better from broken table attributes
7381 !!options
7382 parsoid=wt2html
7383 !!wikitext
7384 {| class="foo
7385 | class="bar" |
7386 foo
7387 |}
7388 !!html/php+tidy
7389 <table class="foo">
7390 <tbody><tr>
7391 <td class="bar">
7392 <p>foo
7393 </p>
7394 </td></tr></tbody></table>
7395 !!html/parsoid
7396 <table class="foo">
7397 <tr>
7398 <td class="bar">
7399 <p>foo</p></td></tr>
7400 </tbody></table>
7401 !!end
7402
7403 !! test
7404 Tables: Digest broken attributes on table and tr tag
7405 !! options
7406 parsoid=wt2html
7407 !! wikitext
7408 {| || |} ++
7409 |- || || ++ --
7410 |- > [
7411 |}
7412 !! html
7413 <table>
7414 <tbody>
7415 <tr class='mw-empty-elt'></tr>
7416 <tr class='mw-empty-elt'></tr>
7417 </tbody></table>
7418 !! end
7419
7420 !! test
7421 Table with missing opening <tr> tag
7422 !! options
7423 parsoid=wt2html,wt2wt
7424 !! wikitext
7425 <table>
7426 <td>foo</td>
7427 </tr>
7428 </table>
7429 !! html+tidy
7430 <table>
7431 <tbody><tr><td>foo</td>
7432 </tr>
7433 </tbody></table>
7434 !! end
7435
7436 # T137406: Whitespace in the HTML
7437 !! test
7438 1. Generate correct wikitext for tables with thead/tbody/tfoot
7439 !! options
7440 parsoid=html2wt
7441 !! html/parsoid
7442 <table>
7443 <caption>Test</caption>
7444 <thead>
7445 <tr>
7446 <th>Month</th>
7447 <th>Savings</th>
7448 </tr>
7449 </thead>
7450 <tbody>
7451 <tr>
7452 <td>January</td>
7453 <td>$100</td>
7454 </tr>
7455 <tr>
7456 <td>February</td>
7457 <td>$80</td>
7458 </tr>
7459 </tbody>
7460 <tfoot>
7461 <tr>
7462 <td>Sum</td>
7463 <td>$180</td>
7464 </tr>
7465 </tfoot>
7466 </table>
7467 !! wikitext
7468 {|
7469 |+Test
7470 !Month
7471 !Savings
7472 |-
7473 |January
7474 |$100
7475 |-
7476 |February
7477 |$80
7478 |-
7479 |Sum
7480 |$180
7481 |}
7482 !! html/php+tidy
7483 <table>
7484 <caption>Test
7485 </caption>
7486 <tbody><tr>
7487 <th>Month
7488 </th>
7489 <th>Savings
7490 </th></tr>
7491 <tr>
7492 <td>January
7493 </td>
7494 <td>$100
7495 </td></tr>
7496 <tr>
7497 <td>February
7498 </td>
7499 <td>$80
7500 </td></tr>
7501 <tr>
7502 <td>Sum
7503 </td>
7504 <td>$180
7505 </td></tr></tbody></table>
7506 !! end
7507
7508 # T137406: No whitespace in the HTML
7509 !! test
7510 2. Generate correct wikitext for tables with thead/tbody/tfoot
7511 !! options
7512 parsoid=html2wt
7513 !! html/parsoid
7514 <table><thead><tr><th>heading</th></tr></thead><tbody><tr><td>foo</td></tr></tbody></table>
7515 !! wikitext
7516 {|
7517 !heading
7518 |-
7519 |foo
7520 |}
7521 !! end
7522
7523 !! test
7524 Wikitext tables can be nested inside HTML tables
7525 !! options
7526 parsoid=html2wt
7527 !! html
7528 <table data-parsoid='{"stx":"html"}'>
7529 <tr><td>
7530 <table>
7531 <tr><td>foo</td></tr>
7532 </table>
7533 </td></tr>
7534 </table>
7535 !! wikitext
7536 <table>
7537 <tr><td>
7538 {|
7539 |foo
7540 |}
7541 </td></tr>
7542 </table>
7543 !! end
7544
7545 ###
7546 ### Internal links
7547 ###
7548 !! test
7549 Plain link, capitalized
7550 !! wikitext
7551 [[Main Page]]
7552 !! html
7553 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
7554 </p>
7555 !! end
7556
7557 !! test
7558 Plain link, uncapitalized
7559 !! wikitext
7560 [[main Page]]
7561 !! html
7562 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
7563 </p>
7564 !! end
7565
7566 !! test
7567 Piped link
7568 !! wikitext
7569 [[Main Page|The Main Page]]
7570 !! html
7571 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7572 </p>
7573 !! end
7574
7575 !! test
7576 Piped link with comment in link text
7577 !! wikitext
7578 [[Main Page|The Main<!--front--> Page]]
7579 !! html
7580 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7581 </p>
7582 !! end
7583
7584 !! test
7585 Piped link with multiple pipe characters in link text
7586 !! wikitext
7587 [[Main Page||The|Main|Page|]]
7588 !! html/php
7589 <p><a href="/wiki/Main_Page" title="Main Page">|The|Main|Page|</a>
7590 </p>
7591 !! html/parsoid
7592 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">|The|Main|Page|</a></p>
7593 !! end
7594
7595 !! test
7596 Piped link with no link text
7597 !! wikitext
7598 [[Thomas Bek (bishop of St David's)|]]
7599 !! html/php
7600 <p>[[Thomas Bek (bishop of St David's)|]]
7601 </p>
7602 !! html/parsoid
7603 <p>[[Thomas Bek (bishop of St David's)|]]</p>
7604 !! end
7605
7606 !! test
7607 Piped link with empty link text
7608 !! wikitext
7609 [[Main Page|<nowiki/>]] - empty nowiki
7610 [[Main Page| ]] - empty space
7611 [[Main Page|&nbsp;]] - empty non breaking space
7612 !! html/php
7613 <p><a href="/wiki/Main_Page" title="Main Page"></a> - empty nowiki
7614 <a href="/wiki/Main_Page" title="Main Page"> </a> - empty space
7615 <a href="/wiki/Main_Page" title="Main Page">&#160;</a> - empty non breaking space
7616 </p>
7617 !! html/parsoid
7618 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:Nowiki"></span></a> - empty nowiki
7619 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page"> </a> - empty space
7620 <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>
7621 !! end
7622
7623 !! test
7624 Broken link
7625 !! wikitext
7626 [[Zigzagzogzagzig]]
7627 !! html
7628 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig</a>
7629 </p>
7630 !! end
7631
7632 !! test
7633 Broken link with fragment
7634 !! wikitext
7635 [[Zigzagzogzagzig#zug]]
7636 !! html
7637 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig#zug</a>
7638 </p>
7639 !! end
7640
7641 !! test
7642 Special page link with fragment
7643 !! wikitext
7644 [[Special:Version#anchor]]
7645 !! html
7646 <p><a href="/wiki/Special:Version#anchor" title="Special:Version">Special:Version#anchor</a>
7647 </p>
7648 !! end
7649
7650 !! test
7651 Nonexistent special page link with fragment
7652 !! wikitext
7653 [[Special:ThisNameWillHopefullyNeverBeUsed#anchor]]
7654 !! html
7655 <p><a href="/wiki/Special:ThisNameWillHopefullyNeverBeUsed" class="new" title="Special:ThisNameWillHopefullyNeverBeUsed (page does not exist)">Special:ThisNameWillHopefullyNeverBeUsed#anchor</a>
7656 </p>
7657 !! end
7658
7659 !! test
7660 Link with prefix
7661 !! wikitext
7662 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
7663 !! html
7664 <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>
7665 </p>
7666 !! end
7667
7668 !! test
7669 Link with suffix
7670 !! wikitext
7671 [[Main Page]]xxx, [[Main Page]]XXX, [[Main Page]]!!!
7672 !! html
7673 <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>!!!
7674 </p>
7675 !! end
7676
7677 !! article
7678 prefixed article
7679 !! text
7680 Some text
7681 !! endarticle
7682
7683 !! test
7684 T45661: Piped links with identical prefixes
7685 !! wikitext
7686 [[prefixed article|prefixed articles with spaces]]
7687
7688 [[prefixed article|prefixed articlesaoeu]]
7689
7690 [[Main Page|Main Page test]]
7691 !! html
7692 <p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articles with spaces</a>
7693 </p><p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articlesaoeu</a>
7694 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page test</a>
7695 </p>
7696 !! end
7697
7698
7699 !! test
7700 Link with HTML entity in suffix / tail
7701 !! wikitext
7702 [[Main Page]]&quot;, [[Main Page]]&#97;
7703 !! html/php
7704 <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;
7705 </p>
7706 !! html/parsoid
7707 <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>
7708 !! end
7709
7710 !! test
7711 Link with 3 brackets
7712 !! wikitext
7713 [[[Main Page]]]
7714 Foo [[[Main Page]]]
7715 !! html
7716 <p>[[[Main Page]]]
7717 Foo [[[Main Page]]]
7718 </p>
7719 !! end
7720
7721 !! test
7722 Link with 4 brackets
7723 !! wikitext
7724 [[[[Main Page]]]]
7725 !! html
7726 <p>[[<a href="/wiki/Main_Page" title="Main Page">Main Page</a>]]
7727 </p>
7728 !! end
7729
7730 !! test
7731 Piped link with 3 brackets
7732 !! wikitext
7733 [[[main page|the main page]]]
7734 !! html
7735 <p>[[[main page|the main page]]]
7736 </p>
7737 !! end
7738
7739 !! test
7740 Piped link with extlink-like text
7741 !! wikitext
7742 [[Main Page|[bar]]]
7743 [[Main Page|This is a [bar]]]
7744 [[Main Page|[bar]]
7745 !! html/php
7746 <p><a href="/wiki/Main_Page" title="Main Page">[bar]</a>
7747 <a href="/wiki/Main_Page" title="Main Page">This is a [bar]</a>
7748 <a href="/wiki/Main_Page" title="Main Page">[bar</a>
7749 </p>
7750 !! html/parsoid
7751 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar]</a>
7752 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>This is a [bar]</a>
7753 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar</a></p>
7754 !! end
7755
7756 !! test
7757 Link with multiple pipes
7758 !! wikitext
7759 [[Main Page|The|Main|Page]]
7760 !! html
7761 <p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a>
7762 </p>
7763 !! end
7764
7765 !! test
7766 Anchor containing a #. (T65430)
7767 !! config
7768 wgFragmentMode=[ 'html5', 'legacy' ]
7769 !! wikitext
7770 [[Main Page#And#Link]]
7771 !! html/php
7772 <p><a href="/wiki/Main_Page#And#Link" title="Main Page">Main Page#And#Link</a>
7773 </p>
7774 !! html/parsoid
7775 <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>
7776 !! end
7777
7778 !! test
7779 Link to namespaces
7780 !! wikitext
7781 [[Talk:Parser testing]], [[Meta:Disclaimers]]
7782 !! html
7783 <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>
7784 </p>
7785 !! end
7786
7787 !! test
7788 Link with space in namespace
7789 !! wikitext
7790 [[User talk:Foo bar]]
7791 !! html
7792 <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>
7793 </p>
7794 !! end
7795
7796 !! article
7797 MemoryAlpha:AlphaTest
7798 !! text
7799 This is an article in the MemoryAlpha namespace
7800 (which shadows the memoryalpha interwiki link).
7801 !! endarticle
7802
7803 !! test
7804 Namespace takes precedence over interwiki link (T53680)
7805 !! wikitext
7806 [[MemoryAlpha:AlphaTest]]
7807 !! html
7808 <p><a href="/wiki/MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a>
7809 </p>
7810 !! end
7811
7812 # The previous test doesn't work correctly in html2*, due to not recognizing the
7813 # link as an internal one. This one checks for the correct behavior.
7814 !! test
7815 Link to namespace preferred over interwiki with correct rel attribute
7816 !! options
7817 parsoid=html2wt,html2html
7818 !! html/parsoid
7819 <p><a rel="mw:WikiLink" href="./MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a></p>
7820 !! wikitext
7821 [[MemoryAlpha:AlphaTest]]
7822 !! end
7823
7824 !! test
7825 Piped link to namespace
7826 !! wikitext
7827 [[Meta:Disclaimers|The disclaimers]]
7828 !! html
7829 <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>
7830 </p>
7831 !! end
7832
7833 !! test
7834 Link containing }
7835 !! wikitext
7836 [[Usually caused by a typo (oops}]]
7837 !! html
7838 <p>[[Usually caused by a typo (oops}]]
7839 </p>
7840 !! end
7841
7842 !! article
7843 7% Solution
7844 !! text
7845 Just a test of an article title containing a percent.
7846 !! endarticle
7847
7848 !! test
7849 Link containing % (not as a hex sequence)
7850 !! wikitext
7851 [[7% Solution]]
7852 [[7% Solution|7%25 Solution]]
7853 !! html/php
7854 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
7855 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
7856 </p>
7857 !! html/parsoid
7858 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
7859 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
7860 !! end
7861
7862 # note that the parsoid HTML is identical to the previous test output,
7863 # so the previous test ensures that the html2wt mode will generate the
7864 # "not as a hex sequence" wikitext.
7865 !! test
7866 Link containing % as a single hex sequence interpreted to char
7867 !! options
7868 parsoid=wt2wt,wt2html,html2html
7869 !! wikitext
7870 [[7%25 Solution]]
7871 [[7%25 Solution|7%25 Solution]]
7872 !! html/php
7873 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
7874 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
7875 </p>
7876 !! html/parsoid
7877 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
7878 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
7879 !!end
7880
7881 !! test
7882 Link containing % as a double hex sequence interpreted to hex sequence
7883 !! wikitext
7884 [[7%2525 Solution]]
7885 !! html
7886 <p>[[7%2525 Solution]]
7887 </p>
7888 !!end
7889
7890 ## Example for such a section: == < ==
7891 !! test
7892 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors
7893 !! config
7894 wgFragmentMode=[ 'html5', 'legacy' ]
7895 !! wikitext
7896 [[%23%3c]][[%23%3e]]
7897 !! html/php
7898 <p><a href="#&lt;">#&lt;</a><a href="#&gt;">#&gt;</a>
7899 </p>
7900 !! html/parsoid
7901 <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>
7902 !! end
7903
7904 ## Example for such a section: == < ==
7905 !! test
7906 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors (legacy)
7907 !! config
7908 wgFragmentMode=[ 'legacy' ]
7909 !! wikitext
7910 [[%23%3c]][[%23%3e]]
7911 !! html/php
7912 <p><a href="#.3C">#&lt;</a><a href="#.3E">#&gt;</a>
7913 </p>
7914 !! end
7915
7916 !! test
7917 Link containing "<#" and ">#" as a hex sequences
7918 !! wikitext
7919 [[%3c%23]][[%3e%23]]
7920 !! html
7921 <p>[[%3c%23]][[%3e%23]]
7922 </p>
7923 !! end
7924
7925 !! test
7926 Link containing an equals sign
7927 !! wikitext
7928 [[Special:BookSources/isbn=4-00-026157-6]]
7929 !! html/php
7930 <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>
7931 </p>
7932 !! html/parsoid
7933 <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>
7934 !! end
7935
7936 !! article
7937 Foo~bar
7938 !! text
7939 Just a test of an article title containing a tilde.
7940 !! endarticle
7941
7942 # note that links containing signatures, like [[Foo~~~~]], are
7943 # massaged by the pre-save transform (PST) and so the tildes are never
7944 # seen by the parser.
7945 !! test
7946 Link containing a tilde
7947 !! wikitext
7948 [[Foo~bar]]
7949 !! html/php
7950 <p><a href="/wiki/Foo~bar" title="Foo~bar">Foo~bar</a>
7951 </p>
7952 !! html/parsoid
7953 <p><a rel="mw:WikiLink" href="./Foo~bar" title="Foo~bar">Foo~bar</a></p>
7954 !! end
7955
7956 !! test
7957 Link containing double-single-quotes '' (T6598)
7958 !! wikitext
7959 [[Lista d''e paise d''o munno]]
7960 !! html/php
7961 <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>
7962 </p>
7963 !! html/parsoid
7964 <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>
7965 !! end
7966
7967 !! test
7968 Link containing double quotes and spaces
7969 !! wikitext
7970 [[Cool "Gator"]]
7971 !! html/php
7972 <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>
7973 </p>
7974 !! html/parsoid
7975 <p><a rel="mw:WikiLink" href='./Cool_"Gator"' title='Cool "Gator"'>Cool "Gator"</a></p>
7976 !! end
7977
7978 !! test
7979 File containing double quotes and spaces
7980 !! wikitext
7981 [[File:Cool "Gator".png]]
7982 !! html/parsoid
7983 <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>
7984 !! end
7985
7986 !! test
7987 Redirect containing double quotes and spaces
7988 !! wikitext
7989 #REDIRECT [[Cool "Gator"]]
7990 !! html/parsoid
7991 <link rel="mw:PageProp/redirect" href="./Cool_%22Gator%22" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Cool_%22Gator%22"},"sa":{"href":"Cool \"Gator\""}}'/>
7992 !! end
7993
7994 !! test
7995 Link containing double-single-quotes '' in text (T6598 sanity check)
7996 !! wikitext
7997 Some [[Link|pretty ''italics'' and stuff]]!
7998 !! html/php
7999 <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>!
8000 </p>
8001 !! html/parsoid
8002 <p>Some <a rel="mw:WikiLink" href="./Link" title="Link">pretty <i>italics</i> and stuff</a>!</p>
8003 !! end
8004
8005 !! test
8006 Link containing double-single-quotes '' in text embedded in italics (T6598 sanity check)
8007 !! wikitext
8008 ''Some [[Link|pretty ''italics'' and stuff]]!''
8009 !! html
8010 <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>
8011 </p>
8012 !! end
8013
8014 !! test
8015 Link with double quotes in title part (literal) and alternate part (interpreted)
8016 !! wikitext
8017 [[File:Denys_Savchenko_''Pentecoste''.jpg]]
8018
8019 [[''Pentecoste'']]
8020
8021 [[''Pentecoste''|Pentecoste]]
8022
8023 [[''Pentecoste''|''Pentecoste'']]
8024 !! html/php
8025 <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>
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)">''Pentecoste''</a>
8027 </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>
8028 </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>
8029 </p>
8030 !! html/parsoid
8031 <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>
8032 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">''Pentecoste''</a></p>
8033 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">Pentecoste</a></p>
8034 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''"><i>Pentecoste</i></a></p>
8035 !! end
8036
8037 !! test
8038 Broken image links with HTML captions (T41700)
8039 !! wikitext
8040 [[File:Nonexistent|<script></script>]]
8041 [[File:Nonexistent|100x100px|<script></script>]]
8042 [[File:Nonexistent|&lt;]]
8043 [[File:Nonexistent|a<i>b</i>c]]
8044 !! html/php
8045 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8046 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8047 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;</a>
8048 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">abc</a>
8049 </p>
8050 !! html/parsoid
8051 <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>
8052 <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>
8053 <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>
8054 <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>
8055 !! end
8056
8057 !! test
8058 Plain link to URL
8059 !! wikitext
8060 [[http://www.example.com]]
8061 !! html/php
8062 <p>[<a rel="nofollow" class="external autonumber" href="http://www.example.com">[1]</a>]
8063 </p>
8064 !! html/parsoid
8065 <p>[<a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com"></a>]</p>
8066 !! end
8067
8068 !! test
8069 Plain link to URL with link text
8070 !! wikitext
8071 [[http://www.example.com Link text]]
8072 !! html
8073 <p>[<a rel="nofollow" class="external text" href="http://www.example.com">Link text</a>]
8074 </p>
8075 !! end
8076
8077 !! test
8078 Plain link to protocol-relative URL
8079 !! wikitext
8080 [[//www.example.com]]
8081 !! html/php
8082 <p>[<a rel="nofollow" class="external autonumber" href="//www.example.com">[1]</a>]
8083 </p>
8084 !! html/parsoid
8085 <p>[<a rel="mw:ExtLink" class="external autonumber" href="//www.example.com"></a>]</p>
8086 !! end
8087
8088 !! test
8089 Plain link to protocol-relative URL with link text
8090 !! wikitext
8091 [[//www.example.com Link text]]
8092 !! html
8093 <p>[<a rel="nofollow" class="external text" href="//www.example.com">Link text</a>]
8094 </p>
8095 !! end
8096
8097 !! test
8098 Plain link to page with question mark in title
8099 !! wikitext
8100 [[A?b]]
8101
8102 [[A?b|Baz]]
8103 !! html
8104 <p><a href="/wiki/A%3Fb" title="A?b">A?b</a>
8105 </p><p><a href="/wiki/A%3Fb" title="A?b">Baz</a>
8106 </p>
8107 !! end
8108
8109 # I'm fairly sure the expected result here is wrong.
8110 # We want these to be URL links, not pseudo-pages with URLs for titles....
8111 # However the current output is also pretty screwy.
8112 #
8113 # ----
8114 # I'm changing it to match the current output--it arguably makes more
8115 # sense in the light of the test above. Old expected result was:
8116 #<p>Piped link to URL: <a href="/index.php?title=Http://www.example.com&amp;action=edit" class="new">an example URL</a>
8117 #</p>
8118 # But I think this test is bordering on "garbage in, garbage out" anyway.
8119 # -- wtm
8120 !! test
8121 Piped link to URL
8122 !! wikitext
8123 Piped link to URL: [[http://www.example.com|an example URL]]
8124 !! html/php
8125 <p>Piped link to URL: [<a rel="nofollow" class="external text" href="http://www.example.com%7Can">example URL</a>]
8126 </p>
8127 !! html/parsoid
8128 <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>
8129 !! end
8130
8131 !! test
8132 Plain link in template argument
8133 !! options
8134 parsoid=wt2html
8135 !! wikitext
8136 {{echo|[http://www.example.com |123]}}
8137
8138 {{echo|[[http://www.example.com |123]]}}
8139
8140 {{echo|[[http://www.example.com |123]}}
8141
8142 {{echo|[http://www.example.com |123]]}}
8143 !! html/php
8144 <p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8145 </p><p>[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>]
8146 </p><p>{{echo|[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>}}
8147 </p><p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8148 </p>
8149 !! html/parsoid
8150 <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>
8151
8152 <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>
8153
8154 <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>
8155
8156 <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>
8157 !! end
8158
8159 !! test
8160 T2002: [[page|http://url/]] should link to page, not http://url/
8161 !! wikitext
8162 [[Main Page|http://url/]]
8163 !! html/php
8164 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
8165 </p>
8166 !! html/parsoid
8167 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">http://url/</a></p>
8168 !! end
8169
8170 # Parsoid does not mark self-links, by design.
8171 !! test
8172 T2337: Escaped self-links should be bold
8173 !! options
8174 title=[[Bug462]]
8175 !! wikitext
8176 [[Bu&#103;462]] [[Bug462]]
8177 !! html/php+tidy
8178 <p><a class="mw-selflink selflink">Bu&#103;462</a> <a class="mw-selflink selflink">Bug462</a>
8179 </p>
8180 !! html/parsoid
8181 <p><a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a> <a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a></p>
8182 !! end
8183
8184 !! test
8185 Self-link to section should not be bold
8186 !! options
8187 title=[[Main Page]]
8188 !! wikitext
8189 [[Main Page#section]]
8190 !! html
8191 <p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
8192 </p>
8193 !! end
8194
8195 !! article
8196 00
8197 !! text
8198 This is 00.
8199 !! endarticle
8200
8201 !!test
8202 Self-link to numeric title
8203 !!options
8204 title=[[0]]
8205 !! wikitext
8206 [[0]]
8207 !! html
8208 <p><a class="mw-selflink selflink">0</a>
8209 </p>
8210 !!end
8211
8212 !!test
8213 Link to numeric-equivalent title
8214 !!options
8215 title=[[0]]
8216 !! wikitext
8217 [[00]]
8218 !! html
8219 <p><a href="/wiki/00" title="00">00</a>
8220 </p>
8221 !!end
8222
8223 !! test
8224 <nowiki> inside a link
8225 !! wikitext
8226 [[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
8227 !! html
8228 <p>[[Main Page]] <a href="/wiki/Main_Page" title="Main Page">the main page [it's not very good]</a>
8229 </p>
8230 !! end
8231
8232 !! test
8233 Non-breaking spaces in title
8234 !! wikitext
8235 [[&nbsp; Main &nbsp; Page &nbsp;]]
8236 !! html
8237 <p><a href="/wiki/Main_Page" title="Main Page">&#160; Main &#160; Page &#160;</a>
8238 </p>
8239 !!end
8240
8241 # Add new article for the test below so that it doesn't red-link
8242 !! article
8243 Foo bar baz
8244 !! text
8245 boo
8246 !! endarticle
8247
8248 !! test
8249 Multiple spaces in titles should normalize to a single underscore
8250 !! options
8251 parsoid=wt2html,wt2wt
8252 !! wikitext
8253 [[Foo bar baz|x]]
8254 [[Foo bar baz|x]]
8255 [[Foo bar baz|x]]
8256 !! html/php
8257 <p><a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8258 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8259 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8260 </p>
8261 !! html/parsoid
8262 <p><a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8263 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8264 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8265 </p>
8266 !! end
8267
8268 !! test
8269 Internal link with ca linktrail, surrounded by bold apostrophes (T29473 primary issue)
8270 !! options
8271 language=ca
8272 !! wikitext
8273 '''[[Main Page]]'''
8274 !! html
8275 <p><b><a href="/wiki/Main_Page" title="Main Page">Main Page</a></b>
8276 </p>
8277 !! end
8278
8279 !! test
8280 Internal link with ca linktrail, surrounded by italic apostrophes (T29473 primary issue)
8281 !! options
8282 language=ca
8283 !! wikitext
8284 ''[[Main Page]]''
8285 !! html
8286 <p><i><a href="/wiki/Main_Page" title="Main Page">Main Page</a></i>
8287 </p>
8288 !! end
8289
8290 !! test
8291 Internal link with en linktrail: no apostrophes (T29473)
8292 !! options
8293 language=en
8294 !! wikitext
8295 [[Something]]'nice
8296 !! html
8297 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (page does not exist)">Something</a>'nice
8298 </p>
8299 !! end
8300
8301 !! test
8302 Internal link with ca linktrail with apostrophes (T29473)
8303 !! options
8304 language=ca
8305 !! wikitext
8306 [[Something]]'nice
8307 !! html
8308 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (encara no existeix)">Something'nice</a>
8309 </p>
8310 !! end
8311
8312 !! test
8313 Internal link with kaa linktrail with apostrophes (T29473)
8314 !! options
8315 language=kaa
8316 !! wikitext
8317 [[Something]]'nice
8318 !! html
8319 <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>
8320 </p>
8321 !! end
8322
8323 !! test
8324 Link with multiple ":" in a subpage-supporting namespace (T65636)
8325 !! wikitext
8326 [[User:Foo/Test/63636:Bar|Test]]
8327 !! html/php
8328 <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>
8329 </p>
8330 !! html/parsoid
8331 <p><a rel="mw:WikiLink" href="./User:Foo/Test/63636:Bar" title="User:Foo/Test/63636:Bar">Test</a></p>
8332 !! end
8333
8334 ## Mainly a sanity check for Parsoid
8335 !! test
8336 Handle title parsing for subpages
8337 !! options
8338 title=[[/123123]]
8339 subpage
8340 !! wikitext
8341 123
8342 !! html/php
8343 <p>123
8344 </p>
8345 !! html/parsoid
8346 <p>123</p>
8347 !! end
8348
8349 !! article
8350 User:Test/123
8351 !! text
8352 test 123
8353 !! endarticle
8354
8355 !! test
8356 Link to a subpage from a namespace other than main
8357 !! options
8358 title=[[User:Test]]
8359 subpage
8360 !! wikitext
8361 [[/123]]
8362 !! html/php
8363 <p><a href="/wiki/User:Test/123" title="User:Test/123">/123</a>
8364 </p>
8365 !! html/parsoid
8366 <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>
8367 !! end
8368
8369 !! test
8370 Ensure that transclusion titles are not url-decoded
8371 !! options
8372 subpage title=[[Test]]
8373 parsoid=wt2html
8374 !! wikitext
8375 {{Bar%C3%A9}} {{/Bar%C3%A9}}
8376 !! html/php
8377 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}
8378 </p>
8379 !! html/parsoid
8380 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}</p>
8381 !! end
8382
8383 !! test
8384 Purely hash wikilink
8385 !! options
8386 title=[[User:Test/123]]
8387 subpage
8388 !! wikitext
8389 [[#a|b]]
8390 !! html/php
8391 <p><a href="#a">b</a>
8392 </p>
8393 !! html/parsoid
8394 <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>
8395 !! end
8396
8397 !! test
8398 Serialization of purely hash wikilink
8399 !! options
8400 title=[[User:Test/123]]
8401 subpage
8402 parsoid=html2wt
8403 !! html/parsoid
8404 <p><a href="#a">[[</a></p>
8405 !! wikitext
8406 [[#a|<nowiki>[[</nowiki>]]
8407 !! html/php
8408 <p><a href="#a">[[</a>
8409 </p>
8410 !! end
8411
8412 !! test
8413 1. Interaction of linktrail and template encapsulation
8414 !! wikitext
8415 {{echo|[[Foo]]}}l
8416 !! html/parsoid
8417 <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>
8418 !! end
8419
8420 !! test
8421 2. Interaction of linktrail and template encapsulation
8422 !! options
8423 parsoid
8424 !! wikitext
8425 {{echo|Some [[Fool]]}}s
8426 !! html
8427 <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>
8428 !! end
8429
8430 !! test
8431 3. Interaction of linktrail and template encapsulation
8432 !! options
8433 parsoid
8434 !! wikitext
8435 {{echo|Some [[Fool]]s are '''bold and foolish'''}}
8436 !! html
8437 <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>
8438 !! end
8439
8440 !! article
8441 Söfnuður
8442 !! text
8443 Test.
8444 !! endarticle
8445
8446 !! test
8447 Internal link with is link prefix
8448 !! options
8449 language=is
8450 !! wikitext
8451 Aðrir mótmælenda[[söfnuður|söfnuðir]] og
8452 !! html
8453 <p>Aðrir <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a> og
8454 </p>
8455 !! end
8456
8457 !! article
8458 Mótmælendatrú
8459 !! text
8460 Test.
8461 !! endarticle
8462
8463 !! test
8464 Internal link with is link trail and link prefix
8465 !! options
8466 language=is
8467 !! wikitext
8468 [[mótmælendatrú|xxx]]ar
8469 [[mótmælendatrú]]ar
8470 mótmælenda[[söfnuður]]
8471 mótmælenda[[söfnuður|söfnuðir]]
8472 mótmælenda[[söfnuður|söfnuðir]]xxx
8473 !! html
8474 <p><a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">xxxar</a>
8475 <a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">mótmælendatrúar</a>
8476 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuður</a>
8477 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a>
8478 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðirxxx</a>
8479 </p>
8480 !! end
8481
8482 !! test
8483 Parsoid link trail escaping
8484 !! options
8485 parsoid=html2wt,html2html
8486 !! html/parsoid
8487 <p><a rel="mw:WikiLink" href="./Apple" title="Apple">apple</a>s</p>
8488 !! wikitext
8489 [[apple]]<nowiki/>s
8490 !! end
8491
8492 !! test
8493 Parsoid link prefix escaping
8494 !! options
8495 language=is
8496 parsoid=html2wt,html2html
8497 !! html/parsoid
8498 <p>Aðrir mótmælenda<a rel="mw:WikiLink" href="./Söfnuður" title="Söfnuður">söfnuður</a></p>
8499 !! wikitext
8500 Aðrir mótmælenda<nowiki/>[[söfnuður]]
8501 !! end
8502
8503 !! test
8504 Parsoid link bracket escaping
8505 !! options
8506 parsoid=html2wt,html2html
8507 !! html/parsoid
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 <p>[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]</p>
8513 <p>[[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]]</p>
8514 !! wikitext
8515 [[Test]]
8516
8517 [<nowiki/>[[Test]]]
8518
8519 [[[[Test]]]]
8520
8521 [[[<nowiki/>[[Test]]]]]
8522
8523 [[[[[[Test]]]]]]
8524
8525 [[[[[<nowiki/>[[Test]]]]]]]
8526 !! end
8527
8528 !! test
8529 Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved
8530 !! wikitext
8531 [[Foo| bar]]
8532
8533 [[Foo| ''bar'']]
8534
8535 [http://wp.org foo]
8536
8537 [http://wp.org ''foo'']
8538 !! html
8539 <p><a href="/wiki/Foo" title="Foo"> bar</a>
8540 </p><p><a href="/wiki/Foo" title="Foo"> <i>bar</i></a>
8541 </p><p><a rel="nofollow" class="external text" href="http://wp.org">foo</a>
8542 </p><p><a rel="nofollow" class="external text" href="http://wp.org"><i>foo</i></a>
8543 </p>
8544 !! end
8545
8546 !! test
8547 Parsoid: Scoped parsing should handle mixed transclusions and plain text
8548 !! wikitext
8549 [[Foo|{{echo|a}} b {{echo|c}}]]
8550 !! html/parsoid
8551 <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>
8552 !! end
8553
8554 !! test
8555 Link with angle bracket after anchor
8556 !! config
8557 wgFragmentMode=[ 'html5', 'legacy' ]
8558 !! wikitext
8559 [[Foo#<bar>]]
8560 !! html/php
8561 <p><a href="/wiki/Foo#&lt;bar&gt;" title="Foo">Foo#&lt;bar&gt;</a>
8562 </p>
8563 !! html/parsoid
8564 <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>
8565 !! end
8566
8567 !! test
8568 Link with angle bracket after anchor (legacy)
8569 !! config
8570 wgFragmentMode=[ 'legacy' ]
8571 !! wikitext
8572 [[Foo#<bar>]]
8573 !! html/php
8574 <p><a href="/wiki/Foo#.3Cbar.3E" title="Foo">Foo#&lt;bar&gt;</a>
8575 </p>
8576 !! end
8577
8578 ###
8579 ### Interwiki links (see maintenance/interwiki.sql)
8580 ###
8581
8582 !! test
8583 Inline interwiki link
8584 !! options
8585 parsoid=wt2html,wt2wt,html2html
8586 !! wikitext
8587 [[MeatBall:SoftSecurity]]
8588 !! html/php
8589 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
8590 </p>
8591 !! html/parsoid
8592 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a></p>
8593 !! end
8594
8595 !! test
8596 Inline interwiki link with empty title (T4372)
8597 !! options
8598 parsoid=wt2html,wt2wt,html2html
8599 !! wikitext
8600 [[MeatBall:]]
8601 !! html/php
8602 <p><a href="http://www.usemod.com/cgi-bin/mb.pl" class="extiw" title="meatball:">MeatBall:</a>
8603 </p>
8604 !! html/parsoid
8605 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?" title="meatball:">MeatBall:</a></p>
8606 !! end
8607
8608 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
8609 !! test
8610 Interwiki link encoding conversion (T3636)
8611 !! options
8612 parsoid=wt2html,wt2wt
8613 !! wikitext
8614 *[[Wikipedia:ro:Olteni&#0355;a]]
8615 *[[Wikipedia:ro:Olteni&#355;a]]
8616 !! html
8617 <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>
8618 <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>
8619
8620 !! html/php+tidy
8621 <ul>
8622 <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>
8623 <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>
8624 </ul>
8625 !! html/parsoid
8626 <ul>
8627 <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>
8628 <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>
8629 </ul>
8630 !! end
8631
8632 !! test
8633 Interwiki link with fragment (T4130)
8634 !! wikitext
8635 [[MeatBall:SoftSecurity#foo]]
8636 !! html
8637 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity#foo</a>
8638 </p>
8639 !! end
8640
8641 !! test
8642 Link scenarios with escaped fragments
8643 !! config
8644 wgFragmentMode=[ 'html5', 'legacy' ]
8645 !! wikitext
8646 [[#Is this great?]]
8647 [[Foo#Is this great?]]
8648 [[meatball:Foo#Is this great?]]
8649 !! html/php
8650 <p><a href="#Is_this_great?">#Is this great?</a>
8651 <a href="/wiki/Foo#Is_this_great?" title="Foo">Foo#Is this great?</a>
8652 <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>
8653 </p>
8654 !! html/parsoid
8655 <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>
8656 <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>
8657 <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>
8658 !! end
8659
8660 !! test
8661 Link scenarios with escaped fragments (legacy)
8662 !! config
8663 wgFragmentMode=[ 'legacy' ]
8664 !! wikitext
8665 [[#Is this great?]]
8666 [[Foo#Is this great?]]
8667 [[meatball:Foo#Is this great?]]
8668 !! html/php
8669 <p><a href="#Is_this_great.3F">#Is this great?</a>
8670 <a href="/wiki/Foo#Is_this_great.3F" title="Foo">Foo#Is this great?</a>
8671 <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>
8672 </p>
8673 !! end
8674
8675 # Ideally the wikipedia: prefix here should be proto-relative too
8676 # [CSA]: this is kind of a bogus test, as the PHP parser test doesn't
8677 # define the 'en' prefix, and originally the test used 'wikipedia',
8678 # which isn't a localinterwiki prefix hence the links to the 'en:Foo'
8679 # article.
8680 !! test
8681 Different interwiki prefixes mapping to the same URL
8682 !! wikitext
8683 [[:en:Foo]]
8684
8685 [[:en:Foo|Foo]]
8686
8687 [[wikipedia:Foo]]
8688
8689 [[:wikipedia:Foo|Foo]]
8690
8691 [[wikipedia:en:Foo]]
8692
8693 [[:wikipedia:en:Foo]]
8694
8695 [[ wikiPEdia :Foo]]
8696 !! html/parsoid
8697 <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>
8698
8699 <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>
8700
8701 <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>
8702
8703 <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>
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/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>
8708
8709 <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>
8710 !! end
8711
8712 !! test
8713 Interwiki links that cannot be represented in wiki syntax
8714 !! wikitext
8715 [[meatball:ok]]
8716 [[meatball:ok#foo|ok with fragment]]
8717 [[meatball:ok_as_well?|ok ending with ? mark]]
8718 [http://de.wikipedia.org/wiki/Foo?action=history has query]
8719 [http://de.wikipedia.org/wiki/#foo is just fragment]
8720
8721 !! html/php
8722 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?ok" class="extiw" title="meatball:ok">meatball:ok</a>
8723 <a href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" class="extiw" title="meatball:ok">ok with fragment</a>
8724 <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>
8725 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8726 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a>
8727 </p>
8728 !! html/parsoid
8729 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok" title="meatball:ok">meatball:ok</a>
8730 <a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" title="meatball:ok">ok with fragment</a>
8731 <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>
8732 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8733 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a></p>
8734 !! end
8735
8736 !! test
8737 Interwiki links: trail
8738 !! wikitext
8739 [[wikipedia:Foo|Ba]]r
8740 !! html/php
8741 <p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
8742 </p>
8743 !! html/parsoid
8744 <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>
8745 !! end
8746
8747 !! test
8748 Local interwiki link
8749 !! options
8750 parsoid=wt2html,wt2wt,html2html
8751 !! wikitext
8752 [[local:Template:Foo]]
8753 !! html/php
8754 <p><a href="/wiki/Template:Foo" title="Template:Foo">local:Template:Foo</a>
8755 </p>
8756 !! html/parsoid
8757 <p><a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">local:Template:Foo</a></p>
8758 !! end
8759
8760 # Parsoid does not mark self-links, by design.
8761 !! test
8762 Local interwiki link: self-link to current page
8763 !! options
8764 title=[[Main Page]]
8765 parsoid=wt2html,wt2wt,html2html
8766 !! wikitext
8767 [[local:Main Page]]
8768 !! html/php
8769 <p><a class="mw-selflink selflink">local:Main Page</a>
8770 </p>
8771 !! html/parsoid
8772 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:Main Page</a></p>
8773 !! end
8774
8775 !! test
8776 Local interwiki link: prefix only (T66167)
8777 !! options
8778 parsoid=wt2html,wt2wt,html2html
8779 !! wikitext
8780 [[local:]]
8781 !! html/php
8782 <p><a href="/wiki/Main_Page" title="Main Page">local:</a>
8783 </p>
8784 !! html/parsoid
8785 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:</a></p>
8786 !! end
8787
8788 !! test
8789 Local interwiki link: with additional interwiki prefix (T63357)
8790 !! options
8791 parsoid=wt2html,wt2wt,html2html
8792 !! wikitext
8793 [[local:meatball:Hello]]
8794 !! html/php
8795 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Hello" class="extiw" title="meatball:Hello">local:meatball:Hello</a>
8796 </p>
8797 !! html/parsoid
8798 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?Hello" title="meatball:Hello">local:meatball:Hello</a></p>
8799 !! end
8800
8801 !! test
8802 Multiple local interwiki link prefixes
8803 !! wikitext
8804 [[local:local:local:local:mi:local:Foo]]
8805 !! options
8806 parsoid=wt2html,wt2wt,html2html
8807 !! html/php
8808 <p><a href="/wiki/Foo" title="Foo">local:local:local:local:mi:local:Foo</a>
8809 </p>
8810 !! html/parsoid
8811 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">local:local:local:local:mi:local:Foo</a></p>
8812 !! end
8813
8814 ###
8815 ### Interlanguage links
8816 ### Language links (so that searching for '### language' matches..)
8817 ###
8818
8819 !! test
8820 Interlanguage link
8821 !! wikitext
8822 Blah blah blah
8823 [[zh:Chinese]]
8824 !! html/php
8825 <p>Blah blah blah
8826 </p>
8827 !! html/parsoid
8828 <p>Blah blah blah</p>
8829 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8830 !! end
8831
8832 ## parsoid html2wt will lose the space variations
8833 !! test
8834 Interlanguage link with spacing
8835 !! options
8836 parsoid=wt2html,wt2wt,html2html
8837 !! wikitext
8838 Blah blah blah
8839 [[ zh : Chinese ]]
8840 !! html/php
8841 <p>Blah blah blah
8842 </p>
8843 !! html/parsoid
8844 <p>Blah blah blah</p>
8845 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8846 !! end
8847
8848 !! test
8849 Double interlanguage link
8850 !! wikitext
8851 Blah blah blah
8852 [[es:Spanish]]
8853 [[zh:Chinese]]
8854 !! html/php
8855 <p>Blah blah blah
8856 </p>
8857 !! html/parsoid
8858 <p>Blah blah blah</p>
8859 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
8860 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8861 !! end
8862
8863 ## parsoid html2wt will lose the space variations
8864 !! test
8865 Interlanguage link variations
8866 !! options
8867 parsoid=wt2html,wt2wt,html2html
8868 !! wikitext
8869 Blah blah blah
8870 [[ es :Spanish]]
8871 [[ ZH :Chinese]]
8872 [[es:Foo_bar]]
8873 !! html/php
8874 <p>Blah blah blah
8875 </p>
8876 !! html/parsoid
8877 <p>Blah blah blah</p>
8878 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish" />
8879 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese" />
8880 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar" />
8881 !! end
8882
8883 !! test
8884 Escaping of interlanguage links (T129218, T156308)
8885 !! wikitext
8886 Blah blah blah
8887 [[:es:Spanish]]
8888 [[ : zh : Chinese ]]
8889 !! html/php
8890 <p>Blah blah blah
8891 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
8892 <a href="http://zh.wikipedia.org/wiki/Chinese" class="extiw" title="zh:Chinese"> zh : Chinese </a>
8893 </p>
8894 !! html/parsoid
8895 <p>Blah blah blah
8896 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
8897 <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh : Chinese </a></p>
8898 !! end
8899
8900 !! test
8901 Multiple colons escaping interlanguage links
8902 !! options
8903 parsoid=wt2html
8904 !! wikitext
8905 [[:es:Spanish]]
8906 [[::es:Spanish]]
8907 [[:::es:Spanish]]
8908 !! html/php
8909 <p><a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
8910 [[::es:Spanish]]
8911 [[:::es:Spanish]]
8912 </p>
8913 !! html/parsoid
8914 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
8915 [[::es:Spanish]]
8916 [[:::es:Spanish]]</p>
8917 !! end
8918
8919 ## parsoid html2wt will normalize the space to _
8920 !! test
8921 Space and question mark encoding in interlanguage links (T95473)
8922 !! options
8923 parsoid=wt2html,wt2wt,html2html
8924 !! wikitext
8925 Blah blah blah
8926 [[es:Foo bar?]]
8927 !! html/php
8928 <p>Blah blah blah
8929 </p>
8930 !! html/parsoid
8931 <p>Blah blah blah</p>
8932 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar%3F" />
8933 !! end
8934
8935 !! test
8936 Interlanguage link, with prefix links
8937 !! options
8938 language=ln
8939 !! wikitext
8940 Blah blah blah
8941 [[zh:Chinese]]
8942 !! html/php
8943 <p>Blah blah blah
8944 </p>
8945 !! html/parsoid
8946 <p>Blah blah blah</p>
8947 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8948 !! end
8949
8950 !! test
8951 Double interlanguage link, with prefix links (T10897)
8952 !! options
8953 language=ln
8954 !! wikitext
8955 Blah blah blah
8956 [[es:Spanish]]
8957 [[zh:Chinese]]
8958 !! html/php
8959 <p>Blah blah blah
8960 </p>
8961 !! html/parsoid
8962 <p>Blah blah blah</p>
8963 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
8964 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8965 !! end
8966
8967 !! test
8968 "Extra" interlanguage links (T34189 / gerrit 111390)
8969 !! wikitext
8970 Blah blah blah
8971 [[mul:Article]]
8972 !! html/php
8973 <p>Blah blah blah
8974 </p>
8975 !! html/parsoid
8976 <p>Blah blah blah</p>
8977 <link rel="mw:PageProp/Language" title="Multilingual" href="http://wikisource.org/wiki/Article"/>
8978 !! end
8979
8980 ## PHP parser tests script needs an update
8981 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
8982 !! test
8983 Language links render as inline links if $wgInterwikiMagic=false
8984 !! options
8985 wgInterwikiMagic=false
8986 parsoid=wt2html,wt2wt,html2html
8987 !! wikitext
8988 Blah blah blah
8989 [[zh:Chinese]]
8990 !! html/parsoid
8991 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
8992 !! end
8993
8994 ## PHP parser tests script needs an update
8995 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
8996 !! test
8997 Language links render as inline links in the Talk namespace
8998 !! options
8999 title=Talk:Foo
9000 parsoid=wt2html,wt2wt,html2html
9001 !! wikitext
9002 Blah blah blah
9003 [[zh:Chinese]]
9004 !! html/parsoid
9005 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
9006 !! end
9007
9008 !! test
9009 Parsoid-specific test: Wikilinks with &nbsp; should RT properly
9010 !! options
9011 language=ln
9012 !! wikitext
9013 [[WW&nbsp;II]]
9014 !! html
9015 <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>
9016 </p>
9017 !! end
9018
9019 !! test
9020 Parsoid T55221: Wikilinks should be properly entity-escaped
9021 !! options
9022 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
9023 !! html/parsoid
9024 <p>He&amp;nbsp;llo <a href="./Foo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9025 <p>He&amp;nbsp;llo <a href="./He&amp;nbsp;llo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9026 !! wikitext
9027 He&amp;nbsp;llo [[Foo|He&amp;nbsp;llo]]
9028
9029 He&amp;nbsp;llo He&amp;nbsp;llo
9030 !! html/php
9031 <p>He&amp;nbsp;llo <a href="/wiki/Foo" title="Foo">He&amp;nbsp;llo</a>
9032 </p><p>He&amp;nbsp;llo He&amp;nbsp;llo
9033 </p>
9034 !! end
9035
9036 # html2wt will fail because of title normalization without data-parsoid
9037 !! test
9038 Parsoid: handle constructor well
9039 !! options
9040 parsoid=wt2html,wt2wt
9041 !! wikitext
9042 [[constructor]]
9043
9044 [[constructor:foo]]
9045 !! html/php
9046 <p><a href="/index.php?title=Constructor&amp;action=edit&amp;redlink=1" class="new" title="Constructor (page does not exist)">constructor</a>
9047 </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>
9048 </p>
9049 !! html/parsoid
9050 <p><a rel="mw:WikiLink" href="./Constructor" title="Constructor" data-parsoid='{"stx":"simple","a":{"href":"./Constructor"},"sa":{"href":"constructor"}}'>constructor</a></p>
9051
9052 <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>
9053 !! end
9054
9055 !! test
9056 Template parameter named "constructor"
9057 !! wikitext
9058 {{echo| constructor = |hi}}
9059 !! html/parsoid
9060 <p about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"constructor","named":true,"spc":[" "," ",""," "]},{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"},"constructor":{"wt":""}},"i":0}}]}'>hi</p>
9061 !! end
9062
9063 !! article
9064 ko:
9065 !! text
9066 Test.
9067 !! endarticle
9068
9069 # Note that `ko` isn't a known interlanguage prefix
9070 !! test
9071 Parsoid: recognize interlanguage links without a target page
9072 !! options
9073 ill
9074 !! wikitext
9075 [[es:]]
9076
9077 [[ko:]]
9078 !! html/php
9079 es:
9080 !! html/parsoid
9081 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/"/>
9082
9083 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9084 !! end
9085
9086 # Note that `ko` isn't a known interwiki prefix
9087 !! test
9088 Parsoid: recognize interwiki links without a target page
9089 !! options
9090 parsoid=wt2html,wt2wt,html2html
9091 !! wikitext
9092 [[:es:]]
9093
9094 [[:ko:]]
9095 !! html/php
9096 <p><a href="http://es.wikipedia.org/wiki/" class="extiw" title="es:">es:</a>
9097 </p><p><a href="/wiki/Ko:" title="Ko:">ko:</a>
9098 </p>
9099 !! html/parsoid
9100 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/" title="es:">es:</a></p>
9101 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9102 !! end
9103
9104 !! test
9105 Handle interwiki links pointing to the current wiki as plain wiki links (T47209)
9106 !! wikitext
9107 [[mi:Foo]]
9108 !! html/php
9109 <p><a href="/wiki/Foo" title="Foo">mi:Foo</a>
9110 </p>
9111 !! html/parsoid
9112 <p><a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo"},"sa":{"href":"mi:Foo"}}'>mi:Foo</a></p>
9113 !! end
9114
9115 !! test
9116 Interlanguage link with preceding local interwiki link (T70085)
9117 !! options
9118 parsoid=wt2html,wt2wt,html2html
9119 !! wikitext
9120 Blah blah blah
9121 [[local:es:Spanish]]
9122 !! html/php
9123 <p>Blah blah blah
9124 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">local:es:Spanish</a>
9125 </p>
9126 !! html/parsoid
9127 <p>Blah blah blah
9128 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">local:es:Spanish</a></p>
9129 !! end
9130
9131 !! test
9132 Looks like an interlanguage link, but is actually a local interwiki
9133 !! options
9134 parsoid=wt2html,wt2wt,html2html
9135 !! wikitext
9136 Blah blah blah
9137 [[mi:Template:Foo]]
9138 !! html/php
9139 <p>Blah blah blah
9140 <a href="/wiki/Template:Foo" title="Template:Foo">mi:Template:Foo</a>
9141 </p>
9142 !! html/parsoid
9143 <p>Blah blah blah
9144 <a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">mi:Template:Foo</a></p>
9145 !! end
9146
9147 ###
9148 ### Redirects, Parsoid-only
9149 ###
9150
9151 !! test
9152 1. Simple redirect to page
9153 !! wikitext
9154 #REDIRECT [[Main Page]]
9155 !! html/parsoid
9156 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9157 !! end
9158
9159 !! test
9160 2. Other redirect variants
9161 !! wikitext
9162 #REDIRECT [[Main_Page]]
9163 !! html/parsoid
9164 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Main_Page"},"sa":{"href":"Main_Page"}}'/>
9165 !! end
9166
9167 # Not a valid redirect in PHP (although perhaps it was, once upon a time)
9168 # This tests the Parsoid bail-out code.
9169 !! test
9170 3. Other redirect variants
9171 !! options
9172 parsoid=wt2html
9173 !! wikitext
9174 #REDIRECT [[<nowiki>[[Bar]]</nowiki>]]
9175 !! html/parsoid
9176 <ol><li>REDIRECT [[<span typeof="mw:Nowiki">[[Bar]]</span>]]</li></ol>
9177 !! end
9178
9179 !! test
9180 4. Redirect to a templated destination
9181 !! wikitext
9182 #REDIRECT [[{{echo|Foo}}bar]]
9183 !! html/parsoid
9184 <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"}]]}'/>
9185 !! end
9186
9187 !! test
9188 Empty redirect
9189 !! options
9190 parsoid=wt2html,wt2wt
9191 !! wikitext
9192 #REDIRECT [[]]
9193 !! html/parsoid
9194 <ol>
9195 <li>REDIRECT [[]]</li></ol>
9196 !! end
9197
9198 !! test
9199 Optional colon in #REDIRECT
9200 !! options
9201 # the colon is archaic syntax. we support it for wt2html, but we
9202 # don't care that it roundtrips back to the modern syntax.
9203 parsoid=wt2html,html2html
9204 !! wikitext
9205 #REDIRECT:[[Main Page]]
9206 !! html/parsoid
9207 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9208 !! end
9209
9210 !! test
9211 Whitespace in #REDIRECT with optional colon
9212 !! options
9213 # the colon and gratuitous whitespace is archaic syntax. we support
9214 # it for wt2html, but we don't care that it roundtrips back to the
9215 # modern syntax (without extra whitespace)
9216 parsoid=wt2html,html2html
9217 !! wikitext
9218
9219 #REDIRECT
9220 :
9221 [[Main Page]]
9222 !! html/parsoid
9223 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9224 !! end
9225
9226 !! test
9227 Piped link in #REDIRECT
9228 !! options
9229 # content after piped link is ignored. we support this syntax,
9230 # but don't care that the piped link is lost when we roundtrip this.
9231 parsoid=wt2html
9232 !! wikitext
9233 #REDIRECT [[Main Page|bar]]
9234 !! html/parsoid
9235 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9236 !! end
9237
9238 !! test
9239 Redirect to category (T104502)
9240 !! options
9241 parsoid=wt2html,wt2wt
9242 !! wikitext
9243 #REDIRECT [[Category:Foo]]
9244 !! html/parsoid
9245 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9246 !! end
9247
9248 !! test
9249 Redirect to category with URL encoding (T104502)
9250 !! options
9251 parsoid=wt2html
9252 !! wikitext
9253 #REDIRECT [[Category%3AFoo]]
9254 !! html/parsoid
9255 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9256 !! end
9257
9258 !! test
9259 Redirect to category page
9260 !! wikitext
9261 #REDIRECT [[:Category:Foo]]
9262 !! html/parsoid
9263 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9264 !! end
9265
9266 !! test
9267 Redirect to image page (1)
9268 !! wikitext
9269 #REDIRECT [[File:Wiki.png]]
9270 !! html/parsoid
9271 <link rel="mw:PageProp/redirect" href="./File:Wiki.png"/>
9272 !! end
9273
9274 !! test
9275 Redirect to image page (2)
9276 !! wikitext
9277 #REDIRECT [[Image:Wiki.png]]
9278 !! html/parsoid
9279 <link rel="mw:PageProp/redirect" href="./File:Wiki.png" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./File:Wiki.png"},"sa":{"href":"Image:Wiki.png"}}'/>
9280 !! end
9281
9282 # html2wt disabled because wts serializes as "#REDIRECT [[:en:File:Wiki.png]]"
9283 # Next test confirms this.
9284 !! test
9285 Redirect to language (1) (T104918)
9286 !! options
9287 parsoid=wt2html,wt2wt,html2html
9288 !! wikitext
9289 #REDIRECT [[en:File:Wiki.png]]
9290 !! html/parsoid
9291 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9292 !! end
9293
9294 !! test
9295 Redirect to language (2) (T104918)
9296 !! wikitext
9297 #REDIRECT [[:en:File:Wiki.png]]
9298 !! html/parsoid
9299 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9300 !! end
9301
9302 !! test
9303 Redirect to interwiki (T104918)
9304 !! wikitext
9305 #REDIRECT [[meatball:File:Wiki.png]]
9306 !! html/parsoid
9307 <link rel="mw:PageProp/redirect" href="http://www.usemod.com/cgi-bin/mb.pl?File:Wiki.png"/>
9308 !! end
9309
9310 !! test
9311 Non-English #REDIRECT
9312 !! options
9313 language=is
9314 !! wikitext
9315 #TILVÍSUN [[Main Page]]
9316 !! html/parsoid
9317 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#TILVÍSUN ","a":{"href":"./Main_Page"},"sa":{"href":"Main Page"}}'/>
9318 !! end
9319
9320 !! test
9321 Redirect syntax under text isn't considered a redirect
9322 !! wikitext
9323 some text
9324
9325 #redirect [[Main Page]]
9326 !! html/parsoid
9327 <p>some text</p>
9328 <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>
9329 !! end
9330
9331 !! test
9332 New redirect
9333 !! options
9334 parsoid=html2wt
9335 !! html/parsoid
9336 <p>Foo<link rel="mw:PageProp/redirect" href="./Foo"/></p>
9337 !! wikitext
9338 #REDIRECT [[Foo]]
9339 Foo
9340 !! end
9341
9342 !! test
9343 Redirect followed by block on the same line
9344 !! options
9345 parsoid=wt2html
9346 !! wikitext
9347 #REDIRECT [[Main Page]]<!-- haha -->==hi==
9348 !! html/parsoid
9349 <link rel="mw:PageProp/redirect" href="./Main_Page"/><!-- haha --><h2 id="hi">hi</h2>
9350 !! end
9351
9352 !! test
9353 Redirect followed by a newline
9354 !! wikitext
9355 #REDIRECT [[Main Page]]
9356 A newline
9357 !! html/parsoid
9358 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9359 <p>A newline</p>
9360 !! end
9361
9362 !! test
9363 Redirect followed by multiple newlines
9364 !! wikitext
9365 #REDIRECT [[Main Page]]
9366
9367
9368 A newline
9369 !! html/parsoid
9370 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9371
9372 <p><br/>
9373 A newline</p>
9374 !! end
9375
9376 !! test
9377 Drop duplicate redirects
9378 !! options
9379 parsoid=html2wt
9380 !! html/parsoid
9381 <link rel="mw:PageProp/redirect" href="./Foo"/>
9382 <link rel="mw:PageProp/redirect" href="./Bar"/>
9383 <link rel="mw:PageProp/redirect" href="./Baz"/>
9384 !! wikitext
9385 #REDIRECT [[Foo]]
9386 !! end
9387
9388 ##
9389 ## XHTML tidiness
9390 ###
9391
9392 !! test
9393 <br> to <br />
9394 !! wikitext
9395 1<br>2<br />3
9396 !! html
9397 <p>1<br />2<br />3
9398 </p>
9399 !! end
9400
9401 !! test
9402 Broken br tag sanitization
9403 !! wikitext
9404 </br>
9405 !! html/php
9406 <p>&lt;/br&gt;
9407 </p>
9408 !! end
9409
9410 # TODO: Fix html2html mode (T53055)!
9411 !! test
9412 Parsoid: Broken br tag recognition
9413 !! options
9414 parsoid=wt2html
9415 !! wikitext
9416 </br>
9417
9418 <br/ >
9419 !! html+tidy
9420 <p><br />
9421 </p><p><br />
9422 </p>
9423 !! end
9424
9425 !! test
9426 Incorrecly removing closing slashes from correctly formed XHTML
9427 !! wikitext
9428 <br style="clear:both;" />
9429 !! html
9430 <p><br style="clear:both;" />
9431 </p>
9432 !! end
9433
9434 !! test
9435 Failing to transform badly formed HTML into correct XHTML
9436 !! wikitext
9437 <br style="clear: left;">
9438 <br style="clear: right;">
9439 <br style="clear: both;">
9440 !! html
9441 <p><br style="clear: left;" />
9442 <br style="clear: right;" />
9443 <br style="clear: both;" />
9444 </p>
9445 !!end
9446
9447 ## FIXME: Is Parsoid's acceptance of self-closing html-tags
9448 ## a feature or a bug? See https://phabricator.wikimedia.org/T76962
9449 !! test
9450 Handling html with a div self-closing tag
9451 !! wikitext
9452 <div title />
9453 <div title/>
9454 <div title/ >
9455 <div title=bar />
9456 <div title=bar/>
9457 <div title=bar/ >
9458 !! html/php
9459 <p>&lt;div title /&gt;
9460 &lt;div title/&gt;
9461 </p>
9462 <div>
9463 <p>&lt;div title=bar /&gt;
9464 &lt;div title=bar/&gt;
9465 </p>
9466 <div title="bar/"></div>
9467 </div>
9468
9469 !! html/parsoid
9470 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9471 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9472 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9473 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9474 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9475 <div title="bar/" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></div>
9476 !! end
9477
9478 !! test
9479 Handling html with a br self-closing tag
9480 !! wikitext
9481 <br title />
9482 <br title/>
9483 <br title/ >
9484 <br title=bar />
9485 <br title=bar/>
9486 <br title=bar/ >
9487 !! html/php
9488 <p><br title="" />
9489 <br title="" />
9490 <br />
9491 <br title="bar" />
9492 <br title="bar" />
9493 <br title="bar/" />
9494 </p>
9495 !! html/parsoid
9496 <p><br title="" />
9497 <br title="" />
9498 <br title="" />
9499 <br title="bar" />
9500 <br title="bar" />
9501 <br title="bar/" />
9502 </p>
9503 !! end
9504
9505 !! test
9506 Horizontal ruler (should it add that extra space?)
9507 !! wikitext
9508 <hr>
9509 <hr >
9510 foo <hr
9511 > bar
9512 !! html+tidy
9513 <hr />
9514 <hr /><p>
9515 foo </p><hr /><p> bar
9516 </p>
9517 !! end
9518
9519 !! test
9520 Horizontal ruler -- 4+ dashes render hr
9521 !! wikitext
9522 ----
9523 !! html
9524 <hr />
9525
9526 !! end
9527
9528 !! test
9529 Horizontal ruler -- eats additional dashes on the same line
9530 !! wikitext
9531 ---------
9532 !! html
9533 <hr />
9534
9535 !! end
9536
9537 !! test
9538 Horizontal ruler -- does not collapse dashes on consecutive lines
9539 !! wikitext
9540 ----
9541 ----
9542 !! html
9543 <hr />
9544 <hr />
9545
9546 !! end
9547
9548 !! test
9549 Horizontal ruler -- <4 dashes render as plain text
9550 !! wikitext
9551 ---
9552 !! html
9553 <p>---
9554 </p>
9555 !! end
9556
9557 !! test
9558 Horizontal ruler -- Supports content following dashes on same line
9559 !! wikitext
9560 ---- Foo
9561 !! html
9562 <hr /> Foo
9563
9564 !! html+tidy
9565 <hr /><p> Foo
9566 </p>
9567 !! end
9568
9569 ###
9570 ### Block-level elements
9571 ###
9572 !! test
9573 Common list
9574 !! wikitext
9575 *Common list
9576 *item 2
9577 *item 3
9578 !! html
9579 <ul><li>Common list</li>
9580 <li>item 2</li>
9581 <li>item 3</li></ul>
9582
9583 !! end
9584
9585 !! test
9586 Numbered list
9587 !! wikitext
9588 #Numbered list
9589 #item 2
9590 #item 3
9591 !! html
9592 <ol><li>Numbered list</li>
9593 <li>item 2</li>
9594 <li>item 3</li></ol>
9595
9596 !! end
9597
9598 # the switch from level 3 to ordered should not introduce a newline between
9599 !! test
9600 Mixed list
9601 !! wikitext
9602 *Mixed list
9603 *#with numbers
9604 **and bullets
9605 *#and numbers
9606 *bullets again
9607 **bullet level 2
9608 ***bullet level 3
9609 ***#Number on level 4
9610 **bullet level 2
9611 **#Number on level 3
9612 **#Number on level 3
9613 *#number level 2
9614 *Level 1
9615 ***Level 3
9616 #**Level 3, but ordered
9617 !! html
9618 <ul><li>Mixed list
9619 <ol><li>with numbers</li></ol>
9620 <ul><li>and bullets</li></ul>
9621 <ol><li>and numbers</li></ol></li>
9622 <li>bullets again
9623 <ul><li>bullet level 2
9624 <ul><li>bullet level 3
9625 <ol><li>Number on level 4</li></ol></li></ul></li>
9626 <li>bullet level 2
9627 <ol><li>Number on level 3</li>
9628 <li>Number on level 3</li></ol></li></ul>
9629 <ol><li>number level 2</li></ol></li>
9630 <li>Level 1
9631 <ul><li><ul><li>Level 3</li></ul></li></ul></li></ul>
9632 <ol><li><ul><li><ul><li>Level 3, but ordered</li></ul></li></ul></li></ol>
9633
9634 !! end
9635
9636 !! test
9637 1. Nested mixed wikitext and html list
9638 !! wikitext
9639 *hi
9640 *<ul><li>ho</li></ul>
9641 *hi
9642 **ho
9643 !! html/php
9644 <ul><li>hi</li>
9645 <li><ul><li>ho</li></ul></li>
9646 <li>hi
9647 <ul><li>ho</li></ul></li></ul>
9648
9649 !! html/parsoid
9650 <ul><li>hi</li>
9651 <li><ul data-parsoid='{"stx":"html"}'><li data-parsoid='{"stx":"html"}'>ho</li></ul></li>
9652 <li>hi
9653 <ul><li>ho</li></ul></li></ul>
9654 !! end
9655
9656 !! test
9657 2. Nested mixed wikitext and html list (incompatible)
9658 !! wikitext
9659 ;hi
9660 :{{echo|<li>ho</li>}}
9661 !! html/php
9662 <dl><dt>hi</dt>
9663 <dd><li>ho</li></dd></dl>
9664
9665 !! html/parsoid
9666 <dl><dt>hi</dt>
9667 <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>
9668 !! end
9669
9670 !! test
9671 Nested lists 1
9672 !! wikitext
9673 *foo
9674 **bar
9675 !! html
9676 <ul><li>foo
9677 <ul><li>bar</li></ul></li></ul>
9678
9679 !! end
9680
9681 !! test
9682 Nested lists 2
9683 !! wikitext
9684 **foo
9685 *bar
9686 !! html
9687 <ul><li><ul><li>foo</li></ul></li>
9688 <li>bar</li></ul>
9689
9690 !! end
9691
9692 !! test
9693 Nested lists 3 (first element empty)
9694 !! wikitext
9695 *
9696 **bar
9697 !! html
9698 <ul><li>
9699 <ul><li>bar</li></ul></li></ul>
9700
9701 !! end
9702
9703 !! test
9704 Nested lists 4 (first element empty)
9705 !! wikitext
9706 **
9707 *bar
9708 !! html
9709 <ul><li><ul><li></li></ul></li>
9710 <li>bar</li></ul>
9711
9712 !! end
9713
9714 !! test
9715 Nested lists 5 (both elements empty)
9716 !! wikitext
9717 **
9718 *
9719 !! html
9720 <ul><li><ul><li></li></ul></li>
9721 <li></li></ul>
9722
9723 !! end
9724
9725 !! test
9726 Nested lists 6 (both elements empty)
9727 !! wikitext
9728 *
9729 **
9730 !! html
9731 <ul><li>
9732 <ul><li></li></ul></li></ul>
9733
9734 !! end
9735
9736 !! test
9737 Nested lists 7 (skip initial nesting levels)
9738 !! wikitext
9739 ***foo
9740 !! html
9741 <ul><li><ul><li><ul><li>foo</li></ul></li></ul></li></ul>
9742
9743 !! end
9744
9745 !! test
9746 Nested lists 8 (multiple nesting transitions)
9747 !! wikitext
9748 *foo
9749 ***bar
9750 **baz
9751 *boo
9752 !! html
9753 <ul><li>foo
9754 <ul><li><ul><li>bar</li></ul></li>
9755 <li>baz</li></ul></li>
9756 <li>boo</li></ul>
9757
9758 !! end
9759
9760 !! test
9761 Nested lists 9 (extension interaction)
9762 !! options
9763 parsoid
9764 !! wikitext
9765 *<references />
9766 !! html/parsoid
9767 <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>
9768 !! end
9769
9770 !! test
9771 1. Lists with start-of-line-transparent tokens before bullets: Comments
9772 !! wikitext
9773 *foo
9774 *<!--cmt-->bar
9775 <!--cmt-->*baz
9776 !! html
9777 <ul><li>foo</li>
9778 <li>bar</li>
9779 <li>baz</li></ul>
9780
9781 !! end
9782
9783 !! test
9784 Nested lists 10 (list and span siblings: wt2wt regression)
9785 !! wikitext
9786 *a <span>x</span>
9787 **b <span>y</span>
9788 !! html/parsoid
9789 <ul><li>a <span>x</span>
9790 <ul><li>b <span>y</span></li></ul></li></ul>
9791 !! end
9792
9793 !! test
9794 2. Lists with start-of-line-transparent tokens before bullets: Template close
9795 !! wikitext
9796 *foo {{echo|bar
9797 }}*baz
9798 !! html
9799 <ul><li>foo bar</li>
9800 <li>baz</li></ul>
9801
9802 !! end
9803
9804 !! test
9805 List items are not parsed correctly following a <pre> block (T2785)
9806 !! wikitext
9807 *<pre>foo</pre>
9808 *<pre>bar</pre>
9809 *zar
9810 !! html/php
9811 <ul><li><pre>foo</pre></li>
9812 <li><pre>bar</pre></li>
9813 <li>zar</li></ul>
9814
9815 !! html/parsoid
9816 <ul><li><pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre></li>
9817 <li><pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"bar"}}'>bar</pre></li>
9818 <li>zar</li></ul>
9819 !! end
9820
9821 # FIXME: Might benefit from a html/parsoid since this has a template
9822 !! test
9823 List items from template
9824 !! wikitext
9825
9826 {{inner list}}
9827 *item 2
9828
9829 *item 0
9830 {{inner list}}
9831 *item 2
9832
9833 *item 0
9834 *notSOL{{inner list}}
9835 *item 2
9836 !! html
9837 <ul><li>item 1</li>
9838 <li>item 2</li></ul>
9839 <ul><li>item 0</li>
9840 <li>item 1</li>
9841 <li>item 2</li></ul>
9842 <ul><li>item 0</li>
9843 <li>notSOL</li>
9844 <li>item 1</li>
9845 <li>item 2</li></ul>
9846
9847 !! end
9848
9849 !! test
9850 List interrupted by empty line or heading
9851 !! wikitext
9852 *foo
9853
9854 **bar
9855 ==A heading==
9856 *Another list item
9857 !! html
9858 <ul><li>foo</li></ul>
9859 <ul><li><ul><li>bar</li></ul></li></ul>
9860 <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>
9861 <ul><li>Another list item</li></ul>
9862
9863 !!end
9864
9865 !!test
9866 Multiple list tags generated by templates
9867 !! wikitext
9868 {{echo|<li>}}a
9869 {{echo|<li>}}b
9870 {{echo|<li>}}c
9871 !! html
9872 <li>a
9873 <li>b
9874 <li>c</li>
9875 </li>
9876 </li>
9877
9878 !! html+tidy
9879 <li>a
9880 </li><li>b
9881 </li><li>c
9882 </li>
9883 !! html/parsoid
9884 <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
9885 </li><li about="#mwt1">b
9886 </li><li about="#mwt1" data-parsoid='{"stx":"html","autoInsertedEnd":true,"dsr":[null,44,null,0]}'>c</li>
9887 !!end
9888
9889 !!test
9890 Single-comment whitespace lines dont break lists, and neither do multi-comment whitespace lines
9891 !! wikitext
9892 *a
9893 <!--This line will NOT split the list-->
9894 *b
9895 <!--This line will NOT split the list either-->
9896 *c
9897 <!--foo--> <!----> <!--This line NOT split the list either-->
9898 *d
9899 !! html
9900 <ul><li>a</li>
9901 <li>b</li>
9902 <li>c</li>
9903 <li>d</li></ul>
9904
9905 !!end
9906
9907 !!test
9908 Replacing whitespace with tabs still doesn't break the list (gerrit 78327)
9909 !! wikitext
9910 *a
9911 <!--This line will NOT split the list-->
9912 *b
9913 <!--This line will NOT split the list either-->
9914 *c
9915 <!--foo--> <!----> <!--This line NOT split the list
9916 either-->
9917 *d
9918 !! html
9919 <ul><li>a</li>
9920 <li>b</li>
9921 <li>c</li>
9922 <li>d</li></ul>
9923
9924 !!end
9925
9926 # FIXME: Parsoid has a dedicated DOM pass to mimic this Tidy-specific li-hack
9927 # That pass could possibly be removed.
9928 !!test
9929 Test the li-hack (a hack from Tidy days, but doesn't work as advertised with Remex)
9930 !!options
9931 parsoid=wt2html,wt2wt
9932 !! wikitext
9933 *foo
9934 *<li>li-hack
9935 *{{echo|<li>templated li-hack}}
9936 *<!--foo--><li> unsupported li-hack with preceding comments
9937
9938 <ul>
9939 <li><li>not a li-hack
9940 </li>
9941 </ul>
9942 !! html+tidy
9943 <ul><li>foo</li>
9944 <li class="mw-empty-elt"></li><li>li-hack</li>
9945 <li class="mw-empty-elt"></li><li>templated li-hack</li>
9946 <li class="mw-empty-elt"></li><li> unsupported li-hack with preceding comments</li></ul>
9947 <ul>
9948 <li class="mw-empty-elt"></li><li>not a li-hack
9949 </li>
9950 </ul>
9951 !! html/parsoid
9952 <ul><li> foo</li>
9953 <li data-parsoid='{"stx":"html","autoInsertedEnd":true,"liHackSrc":"*"}'>li-hack</li>
9954 <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>
9955 <li data-parsoid='{"autoInsertedEnd":true}'><!--foo--></li><li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>unsupported li-hack with preceding comments</li></ul>
9956
9957 <ul data-parsoid='{"stx":"html"}'>
9958 <li class="mw-empty-elt" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></li><li data-parsoid='{"stx":"html"}'>not a li-hack
9959 </li>
9960 </ul>
9961
9962 !!end
9963
9964 !! test
9965 Parsoid: Make sure nested lists are serialized on their own line even if HTML contains no newlines
9966 !! options
9967 parsoid
9968 !! wikitext
9969 #foo
9970 ##bar
9971
9972 *foo
9973 **bar
9974
9975 :foo
9976 ::bar
9977 !! html
9978 <ol>
9979 <li>foo<ol>
9980 <li>bar</li>
9981 </ol></li>
9982 </ol><ul>
9983 <li>foo<ul>
9984 <li>bar</li>
9985 </ul></li>
9986 </ul><dl>
9987 <dd>foo<dl>
9988 <dd>bar</dd>
9989 </dl></dd>
9990 </dl>
9991 !! end
9992
9993 !! test
9994 Parsoid: Test of whitespace serialization with Templated bullets
9995 !! options
9996 parsoid=wt2html
9997 !! wikitext
9998 * {{bullet}}
9999 !! html/parsoid
10000 <ul>
10001 <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>
10002 </ul>
10003 !! end
10004
10005 # ------------------------------------------------------------------------
10006 # The next set of tests are about Parsoid's ability to handle badly nested
10007 # tags (parse, minimize scope of fixup, and roundtrip back)
10008 # ------------------------------------------------------------------------
10009
10010 # Remex and Parsoid output stems from list handling diffs because Parsoid & PHP parser.
10011 # Parsoid's list handling is more aware of block structure.
10012 !! test
10013 Unbalanced closing block tags break a list
10014 !! wikitext
10015 <div>
10016 *a</div><div>
10017 *b</div>
10018 !! html+tidy
10019 <div>
10020 <ul><li>a</li></ul></div><div>
10021 <li>b</li></div>
10022 !! html/parsoid
10023 <div><ul>
10024 <li>a</li>
10025 </ul></div>
10026 <div><ul>
10027 <li>b</li>
10028 </ul></div>
10029 !! end
10030
10031 !! test
10032 Unbalanced closing non-block tags don't break a list
10033 !! wikitext
10034 <span>
10035 *a</span><span>
10036 *b</span>
10037 !! html/php+tidy
10038 <p><span>
10039 </span></p>
10040 <ul><li>a<span></span></li>
10041 <li>b</li></ul>
10042 !! html/parsoid
10043 <span>
10044 <ul>
10045 <li>a<span></span></li>
10046 <li>b</li>
10047 </ul>
10048 </span>
10049 !! end
10050
10051 # Parsoid does some post-dom-building cleanup
10052 # which is why its output differs from Remex.
10053 !! test
10054 Unclosed formatting tags that straddle lists are closed and reopened
10055 !! options
10056 parsoid=wt2html,wt2wt,html2html
10057 !! wikitext
10058 #<s> a
10059 #b </s>
10060 !! html/php+tidy
10061 <ol><li><s> a</s></li><s>
10062 </s><li><s>b </s></li></ol>
10063 !! html/parsoid
10064 <ol><li><s> a</s></li>
10065 <li><s>b </s></li></ol>
10066 !! end
10067
10068 # Output is ugly because of all the misnested tag fixups.
10069 # Remex is wrapping p-tags around empty elements.
10070 # Parsoid has special-case handling of this pattern of
10071 # wrapping lists in formatting tags.
10072 # FIXME: Should we remove this code from Parsoid? Or add
10073 # special support in Remex? If the latter, maybe just wait
10074 # for Parsoid to become the default parser.
10075 # See T70395.
10076 !!test
10077 1. List embedded in a formatting tag
10078 !! wikitext
10079 <small>
10080 *foo
10081 </small>
10082 !! html/php+tidy
10083 <p><small>
10084 </small></p><small><ul><li>foo</li></ul></small><small></small><p><small></small>
10085 </p>
10086 !! html/parsoid
10087 <small>
10088 <ul>
10089 <li>foo</li>
10090 </ul>
10091 </small>
10092 !!end
10093
10094 # Output is ugly because of all the misnested tag fixups
10095 # Remex is wrapping p-tags around empty elements.
10096 # Parsoid has code that strips useless p-tags.
10097 !!test
10098 2. List embedded in a formatting tag in a misnested way
10099 !! wikitext
10100 <small>
10101 *a
10102 *b</small>
10103 !! html/php+tidy
10104 <p><small>
10105 </small></p><small></small><ul><small><li>a</li>
10106 </small><li><small>b</small></li></ul>
10107 !! html/parsoid
10108 <small></small>
10109 <ul><small>
10110 <li>a</li>
10111 </small>
10112 <li><small>b</small></li>
10113 </ul>
10114 !!end
10115
10116 ###
10117 ### Magic Words
10118 ###
10119
10120 # Note that the current date is hard-coded as
10121 # 1970-01-01T00:02:03Z (a Thursday)
10122 # when running parser tests. The timezone is also fixed to GMT, so
10123 # local date will be identical to current date.
10124
10125 !! test
10126 Magic Word: {{CURRENTDAY}}
10127 !! wikitext
10128 {{CURRENTDAY}}
10129 !! html
10130 <p>1
10131 </p>
10132 !! end
10133
10134 !! test
10135 Magic Word: {{CURRENTDAY2}}
10136 !! wikitext
10137 {{CURRENTDAY2}}
10138 !! html
10139 <p>01
10140 </p>
10141 !! end
10142
10143 !! test
10144 Magic Word: {{CURRENTDAYNAME}}
10145 !! wikitext
10146 {{CURRENTDAYNAME}}
10147 !! html
10148 <p>Thursday
10149 </p>
10150 !! end
10151
10152 !! test
10153 Magic Word: {{CURRENTDOW}}
10154 !! wikitext
10155 {{CURRENTDOW}}
10156 !! html
10157 <p>4
10158 </p>
10159 !! end
10160
10161 !! test
10162 Magic Word: {{CURRENTMONTH}}
10163 !! wikitext
10164 {{CURRENTMONTH}}
10165 !! html
10166 <p>01
10167 </p>
10168 !! end
10169
10170 !! test
10171 Magic Word: {{CURRENTMONTH1}}
10172 !! wikitext
10173 {{CURRENTMONTH1}}
10174 !! html
10175 <p>1
10176 </p>
10177 !! end
10178
10179 !! test
10180 Magic Word: {{CURRENTMONTHABBREV}}
10181 !! wikitext
10182 {{CURRENTMONTHABBREV}}
10183 !! html
10184 <p>Jan
10185 </p>
10186 !! end
10187
10188 !! test
10189 Magic Word: {{CURRENTMONTHNAME}}
10190 !! wikitext
10191 {{CURRENTMONTHNAME}}
10192 !! html
10193 <p>January
10194 </p>
10195 !! end
10196
10197 !! test
10198 Magic Word: {{CURRENTMONTHNAMEGEN}}
10199 !! wikitext
10200 {{CURRENTMONTHNAMEGEN}}
10201 !! html
10202 <p>January
10203 </p>
10204 !! end
10205
10206 !! test
10207 Magic Word: {{CURRENTTIME}}
10208 !! wikitext
10209 {{CURRENTTIME}}
10210 !! html
10211 <p>00:02
10212 </p>
10213 !! end
10214
10215 !! test
10216 Magic Word: {{CURRENTHOUR}}
10217 !! wikitext
10218 {{CURRENTHOUR}}
10219 !! html
10220 <p>00
10221 </p>
10222 !! end
10223
10224 !! test
10225 Magic Word: {{CURRENTWEEK}} (T6594)
10226 !! wikitext
10227 {{CURRENTWEEK}}
10228 !! html
10229 <p>1
10230 </p>
10231 !! end
10232
10233 !! test
10234 Magic Word: {{CURRENTYEAR}}
10235 !! wikitext
10236 {{CURRENTYEAR}}
10237 !! html
10238 <p>1970
10239 </p>
10240 !! end
10241
10242 !! test
10243 Magic Word: {{CURRENTTIMESTAMP}}
10244 !! wikitext
10245 {{CURRENTTIMESTAMP}}
10246 !! html
10247 <p>19700101000203
10248 </p>
10249 !! end
10250
10251 !! test
10252 Magic Words LOCAL (UTC)
10253 !! wikitext
10254 *{{LOCALMONTH}}
10255 *{{LOCALMONTH1}}
10256 *{{LOCALMONTHNAME}}
10257 *{{LOCALMONTHNAMEGEN}}
10258 *{{LOCALMONTHABBREV}}
10259 *{{LOCALDAY}}
10260 *{{LOCALDAY2}}
10261 *{{LOCALDAYNAME}}
10262 *{{LOCALYEAR}}
10263 *{{LOCALTIME}}
10264 *{{LOCALHOUR}}
10265 *{{LOCALWEEK}}
10266 *{{LOCALDOW}}
10267 *{{LOCALTIMESTAMP}}
10268 !! html
10269 <ul><li>01</li>
10270 <li>1</li>
10271 <li>January</li>
10272 <li>January</li>
10273 <li>Jan</li>
10274 <li>1</li>
10275 <li>01</li>
10276 <li>Thursday</li>
10277 <li>1970</li>
10278 <li>00:02</li>
10279 <li>00</li>
10280 <li>1</li>
10281 <li>4</li>
10282 <li>19700101000203</li></ul>
10283
10284 !! end
10285
10286 !! test
10287 Magic Word: {{FULLPAGENAME}}
10288 !! options
10289 title=[[User:Ævar Arnfjörð Bjarmason]]
10290 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10291 !! wikitext
10292 {{FULLPAGENAME}}
10293 !! html/*
10294 <p>User:Ævar Arnfjörð Bjarmason
10295 </p>
10296 !! end
10297
10298 !! test
10299 Magic Word: {{FULLPAGENAMEE}}
10300 !! options
10301 title=[[User:Ævar Arnfjörð Bjarmason]]
10302 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10303 !! wikitext
10304 {{FULLPAGENAMEE}}
10305 !! html/*
10306 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10307 </p>
10308 !! end
10309
10310 !! test
10311 Magic Word: {{TALKSPACE}}
10312 !! options
10313 title=[[User:Ævar Arnfjörð Bjarmason]]
10314 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10315 !! wikitext
10316 {{TALKSPACE}}
10317 !! html/*
10318 <p>User talk
10319 </p>
10320 !! end
10321
10322 !! test
10323 Magic Word: {{TALKSPACE}}, same namespace
10324 !! options
10325 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10326 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10327 !! wikitext
10328 {{TALKSPACE}}
10329 !! html/*
10330 <p>User talk
10331 </p>
10332 !! end
10333
10334 !! test
10335 Magic Word: {{TALKSPACE}}, main namespace
10336 !! options
10337 title=[[Parser Test]]
10338 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10339 !! wikitext
10340 {{TALKSPACE}}
10341 !! html/*
10342 <p>Talk
10343 </p>
10344 !! end
10345
10346 !! test
10347 Magic Word: {{TALKSPACEE}}
10348 !! options
10349 title=[[User:Ævar Arnfjörð Bjarmason]]
10350 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10351 !! wikitext
10352 {{TALKSPACEE}}
10353 !! html/*
10354 <p>User_talk
10355 </p>
10356 !! end
10357
10358 !! test
10359 Magic Word: {{SUBJECTSPACE}}
10360 !! options
10361 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10362 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10363 !! wikitext
10364 {{SUBJECTSPACE}}
10365 !! html/*
10366 <p>User
10367 </p>
10368 !! end
10369
10370 !! test
10371 Magic Word: {{SUBJECTSPACE}}, same namespace
10372 !! options
10373 title=[[User:Ævar Arnfjörð Bjarmason]]
10374 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10375 !! wikitext
10376 {{SUBJECTSPACE}}
10377 !! html/*
10378 <p>User
10379 </p>
10380 !! end
10381
10382 !! test
10383 Magic Word: {{SUBJECTSPACE}}, main namespace
10384 !! options
10385 title=[[Parser Test]]
10386 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10387 !! wikitext
10388 {{SUBJECTSPACE}}
10389 !! html/*
10390
10391 !! end
10392
10393 !! test
10394 Magic Word: {{SUBJECTSPACEE}}
10395 !! options
10396 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10397 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10398 !! wikitext
10399 {{SUBJECTSPACEE}}
10400 !! html/*
10401 <p>User
10402 </p>
10403 !! end
10404
10405 !! test
10406 Magic Word: {{NAMESPACE}}
10407 !! options
10408 title=[[User:Ævar Arnfjörð Bjarmason]]
10409 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10410 !! wikitext
10411 {{NAMESPACE}}
10412 !! html/*
10413 <p>User
10414 </p>
10415 !! end
10416
10417 !! test
10418 Magic Word: {{NAMESPACEE}}
10419 !! options
10420 title=[[User:Ævar Arnfjörð Bjarmason]]
10421 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10422 !! wikitext
10423 {{NAMESPACEE}}
10424 !! html/*
10425 <p>User
10426 </p>
10427 !! end
10428
10429 !! test
10430 Magic Word: {{NAMESPACENUMBER}}
10431 !! options
10432 title=[[User:Ævar Arnfjörð Bjarmason]]
10433 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10434 !! wikitext
10435 {{NAMESPACENUMBER}}
10436 !! html/*
10437 <p>2
10438 </p>
10439 !! end
10440
10441 !! test
10442 Magic Word: {{SUBPAGENAME}}
10443 !! options
10444 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10445 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10446 !! wikitext
10447 {{SUBPAGENAME}}
10448 !! html/*
10449 <p>sub ö
10450 </p>
10451 !! end
10452
10453 !! test
10454 Magic Word: {{SUBPAGENAMEE}}
10455 !! options
10456 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10457 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10458 !! wikitext
10459 {{SUBPAGENAMEE}}
10460 !! html/*
10461 <p>sub_%C3%B6
10462 </p>
10463 !! end
10464
10465 !! test
10466 Magic Word: {{ROOTPAGENAME}}
10467 !! options
10468 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10469 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10470 !! wikitext
10471 {{ROOTPAGENAME}}
10472 !! html/*
10473 <p>Ævar Arnfjörð Bjarmason
10474 </p>
10475 !! end
10476
10477 !! test
10478 Magic Word: {{ROOTPAGENAMEE}}
10479 !! options
10480 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10481 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10482 !! wikitext
10483 {{ROOTPAGENAMEE}}
10484 !! html/*
10485 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10486 </p>
10487 !! end
10488
10489 !! test
10490 Magic Word: {{BASEPAGENAME}}
10491 !! options
10492 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10493 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10494 !! wikitext
10495 {{BASEPAGENAME}}
10496 !! html/*
10497 <p>Ævar Arnfjörð Bjarmason
10498 </p>
10499 !! end
10500
10501 !! test
10502 Magic Word: {{BASEPAGENAMEE}}
10503 !! options
10504 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10505 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10506 !! wikitext
10507 {{BASEPAGENAMEE}}
10508 !! html/*
10509 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10510 </p>
10511 !! end
10512
10513 !! test
10514 Magic Word: {{TALKPAGENAME}}
10515 !! options
10516 title=[[User:Ævar Arnfjörð Bjarmason]]
10517 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10518 !! wikitext
10519 {{TALKPAGENAME}}
10520 !! html/*
10521 <p>User talk:Ævar Arnfjörð Bjarmason
10522 </p>
10523 !! end
10524
10525 !! test
10526 Magic Word: {{TALKPAGENAMEE}}
10527 !! options
10528 title=[[User:Ævar Arnfjörð Bjarmason]]
10529 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10530 !! wikitext
10531 {{TALKPAGENAMEE}}
10532 !! html/*
10533 <p>User_talk:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10534 </p>
10535 !! end
10536
10537 !! test
10538 Magic Word: {{SUBJECTPAGENAME}}
10539 !! options
10540 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10541 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10542 !! wikitext
10543 {{SUBJECTPAGENAME}}
10544 !! html/*
10545 <p>User:Ævar Arnfjörð Bjarmason
10546 </p>
10547 !! end
10548
10549 !! test
10550 Magic Word: {{SUBJECTPAGENAMEE}}
10551 !! options
10552 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10553 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10554 !! wikitext
10555 {{SUBJECTPAGENAMEE}}
10556 !! html/*
10557 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10558 </p>
10559 !! end
10560
10561 !! test
10562 Magic Word: {{NUMBEROFFILES}}
10563 !! options
10564 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10565 !! wikitext
10566 {{NUMBEROFFILES}}
10567 !! html/*
10568 <p>7
10569 </p>
10570 !! end
10571
10572 !! test
10573 Magic Word: {{PAGENAME}}
10574 !! options
10575 title=[[User:Ævar Arnfjörð Bjarmason]]
10576 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10577 !! wikitext
10578 {{PAGENAME}}
10579 !! html/*
10580 <p>Ævar Arnfjörð Bjarmason
10581 </p>
10582 !! end
10583
10584 !! test
10585 Magic Word: {{PAGENAME}} with metacharacters
10586 !! options
10587 title=[['foo & bar = baz']]
10588 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10589 !! wikitext
10590 ''{{PAGENAME}}''
10591 !! html+tidy
10592 <p><i>&#39;foo &#38; bar &#61; baz&#39;</i>
10593 </p>
10594 !! end
10595
10596 !! test
10597 Magic Word: {{PAGENAME}} with metacharacters (T28781)
10598 !! options
10599 title=[[*RFC 1234 http://example.com/]]
10600 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10601 !! wikitext
10602 {{PAGENAME}}
10603 !! html+tidy
10604 <p>&#42;RFC&#32;1234 http&#58;//example.com/
10605 </p>
10606 !! end
10607
10608 !! test
10609 Magic Word: {{PAGENAMEE}}
10610 !! options
10611 title=[[User:Ævar Arnfjörð Bjarmason]]
10612 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10613 !! wikitext
10614 {{PAGENAMEE}}
10615 !! html/*
10616 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10617 </p>
10618 !! end
10619
10620 !! test
10621 Magic Word: {{PAGENAMEE}} with metacharacters (T28781)
10622 !! options
10623 title=[[*RFC 1234 http://example.com/]]
10624 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10625 !! wikitext
10626 {{PAGENAMEE}}
10627 !! html+tidy
10628 <p>&#42;RFC_1234_http&#58;//example.com/
10629 </p>
10630 !! end
10631
10632 !! test
10633 Magic Word: {{REVISIONID}}
10634 !! options
10635 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10636 showflags
10637 !! wikitext
10638 {{REVISIONID}}
10639 !! html/*
10640 <p>1337
10641 </p>
10642 flags=vary-revision-id
10643 !! end
10644
10645 !! test
10646 Magic Word: {{SCRIPTPATH}}
10647 !! options
10648 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10649 !! wikitext
10650 {{SCRIPTPATH}}
10651 !! html/*
10652
10653 !! end
10654
10655 !! test
10656 Magic Word: {{STYLEPATH}}
10657 !! options
10658 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10659 !! wikitext
10660 {{STYLEPATH}}
10661 !! html/*
10662 <p>/skins
10663 </p>
10664 !! end
10665
10666 !! test
10667 Magic Word: {{SERVER}}
10668 !! options
10669 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10670 !! wikitext
10671 {{SERVER}}
10672 !! html/*
10673 <p><a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10674 </p>
10675 !! end
10676
10677 !! test
10678 Magic Word: {{SERVERNAME}}
10679 !! options
10680 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10681 !! wikitext
10682 {{SERVERNAME}}
10683 !! html/*
10684 <p>example.org
10685 </p>
10686 !! end
10687
10688 !! test
10689 Magic Word: {{SITENAME}}
10690 !! options
10691 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10692 !! wikitext
10693 {{SITENAME}}
10694 !! html/*
10695 <p>MediaWiki
10696 </p>
10697 !! end
10698
10699 !! test
10700 Magic Word: {{PAGELANGUAGE}}
10701 !! options
10702 language=fr
10703 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10704 !! wikitext
10705 {{PAGELANGUAGE}}
10706 !! html/*
10707 <p>fr
10708 </p>
10709 !! end
10710
10711 !! test
10712 Magic Word: {{PAGELANGUAGE}} on a page with no explicitly set language
10713 !! options
10714 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10715 !! wikitext
10716 {{PAGELANGUAGE}}
10717 !! html/*
10718 <p>en
10719 </p>
10720 !! end
10721
10722 !! test
10723 Case-sensitive magic words, when cased differently, should just be template transclusions
10724 !! wikitext
10725 {{CurrentMonth}}
10726 {{currentday}}
10727 {{cURreNTweEK}}
10728 {{currentHour}}
10729 !! html
10730 <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>
10731 <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>
10732 <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>
10733 <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>
10734 </p>
10735 !! end
10736
10737 !! test
10738 Case-insensitive magic words should still work with weird casing.
10739 !! wikitext
10740 {{sErVeRNaMe}}
10741 {{LCFirst:AOEU}}
10742 {{ucFIRST:aoeu}}
10743 {{SERver}}
10744 !! html
10745 <p>example.org
10746 aOEU
10747 Aoeu
10748 <a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10749 </p>
10750 !! end
10751
10752 # From plwiki:PLOS_ONE
10753 !! test
10754 Parsoid: Page property magic word with magic word contents
10755 !! wikitext
10756 {{DISPLAYTITLE:''{{PAGENAME}}''}}
10757 !! html/parsoid
10758 <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>"}]]}'/>
10759 !! end
10760
10761 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
10762 # But, this is a limitation of our representation and is documented in
10763 # TemplateHandler.js in processSpecialMagicWord
10764 !! test
10765 Parsoid: Template-generated DISPLAYTITLE
10766 !! wikitext
10767 {{{{echo|DISPLAYTITLE}}:Foo}}
10768 !! options
10769 showtitle
10770 !! config
10771 wgAllowDisplayTitle=true
10772 wgRestrictDisplayTitle=false
10773 !! html/php
10774 Foo
10775
10776 !! html/parsoid
10777 <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"}]]}'/>
10778 !! end
10779
10780 !! test
10781 Namespace 1 {{ns:1}}
10782 !! wikitext
10783 {{ns:1}}
10784 !! html
10785 <p>Talk
10786 </p>
10787 !! end
10788
10789 !! test
10790 Namespace 1 {{ns:01}}
10791 !! wikitext
10792 {{ns:01}}
10793 !! html
10794 <p>Talk
10795 </p>
10796 !! end
10797
10798 !! test
10799 Namespace 0 {{ns:0}} (T6783)
10800 !! wikitext
10801 {{ns:0}}
10802 !! html
10803
10804 !! end
10805
10806 !! test
10807 Namespace 0 {{ns:00}} (T6783)
10808 !! wikitext
10809 {{ns:00}}
10810 !! html
10811
10812 !! end
10813
10814 !! test
10815 Namespace -1 {{ns:-1}}
10816 !! wikitext
10817 {{ns:-1}}
10818 !! html
10819 <p>Special
10820 </p>
10821 !! end
10822
10823 !! test
10824 Namespace User {{ns:User}}
10825 !! wikitext
10826 {{ns:User}}
10827 !! html
10828 <p>User
10829 </p>
10830 !! end
10831
10832 !! test
10833 Namespace User talk {{ns:User_talk}}
10834 !! wikitext
10835 {{ns:User_talk}}
10836 !! html
10837 <p>User talk
10838 </p>
10839 !! end
10840
10841 !! test
10842 Namespace User talk {{ns:uSeR tAlK}}
10843 !! wikitext
10844 {{ns:uSeR tAlK}}
10845 !! html
10846 <p>User talk
10847 </p>
10848 !! end
10849
10850 !! test
10851 Namespace File {{ns:File}}
10852 !! wikitext
10853 {{ns:File}}
10854 !! html
10855 <p>File
10856 </p>
10857 !! end
10858
10859 !! test
10860 Namespace File {{ns:Image}}
10861 !! wikitext
10862 {{ns:Image}}
10863 !! html
10864 <p>File
10865 </p>
10866 !! end
10867
10868 !! test
10869 Namespace (lang=de) Benutzer {{ns:User}}
10870 !! options
10871 language=de
10872 !! wikitext
10873 {{ns:User}}
10874 !! html
10875 <p>Benutzer
10876 </p>
10877 !! end
10878
10879 !! test
10880 Namespace (lang=de) Benutzer Diskussion {{ns:3}}
10881 !! options
10882 language=de
10883 !! wikitext
10884 {{ns:3}}
10885 !! html
10886 <p>Benutzer Diskussion
10887 </p>
10888 !! end
10889
10890 !! test
10891 Urlencode
10892 !! wikitext
10893 {{urlencode:hi world?!}}
10894 {{urlencode:hi world?!|WIKI}}
10895 {{urlencode:hi world?!|PATH}}
10896 {{urlencode:hi world?!|QUERY}}
10897 !! html/php
10898 <p>hi+world%3F%21
10899 hi_world%3F!
10900 hi%20world%3F%21
10901 hi+world%3F%21
10902 </p>
10903 !! end
10904
10905 !! test
10906 Magic Word: prioritize type info over data-parsoid
10907 !! options
10908 parsoid=html2wt
10909 !! html/parsoid
10910 <meta property="mw:PageProp/forcetoc" data-parsoid='{"magicSrc":"__NOTOC__"}'/>
10911 !! wikitext
10912 __FORCETOC__
10913 !! end
10914
10915 !! test
10916 Magic Word: serialize on separate line (parsoid)
10917 !! options
10918 parsoid=wt2wt,html2wt
10919 !! wikitext
10920 foo
10921 __NOTOC__
10922 bar
10923 !! html/parsoid
10924 foo<meta property="mw:PageProp/notoc"/>bar
10925 !! end
10926
10927 !! test
10928 Magic Word: rt non-english wikis
10929 !! options
10930 parsoid=wt2wt
10931 language=de
10932 !! wikitext
10933 __NOEDITSECTION__
10934 !! html/parsoid
10935 <meta property="mw:PageProp/noeditsection" data-parsoid='{"magicSrc":"__NOEDITSECTION__"}'/>
10936 !! end
10937
10938 !!test
10939 __proto__ is treated as normal wikitext (T105997)
10940 !!wikitext
10941 __proto__
10942 !!html
10943 <p>__proto__
10944 </p>
10945 !!end
10946
10947 ###
10948 ### Magic links
10949 ###
10950 !! test
10951 Magic links: internal link to RFC (T2479)
10952 !! wikitext
10953 [[RFC 123]]
10954 !! html/php
10955 <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>
10956 </p>
10957 !! html/parsoid
10958 <p><a rel="mw:WikiLink" href="./RFC_123" title="RFC 123">RFC 123</a></p>
10959 !! end
10960
10961 !! test
10962 Magic links: RFC (T2479)
10963 !! wikitext
10964 RFC 822
10965 !! html/php
10966 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
10967 </p>
10968 !! html/parsoid
10969 <p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external mw-magiclink">RFC 822</a></p>
10970 !! end
10971
10972 !! test
10973 Magic links: RFC (T67278)
10974 !! wikitext
10975 This is RFC 822 but thisRFC 822 is not RFC 822linked.
10976 !! html/php
10977 <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.
10978 </p>
10979 !! html/parsoid
10980 <p>This is <a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external mw-magiclink">RFC 822</a> but thisRFC 822 is not RFC 822linked.</p>
10981 !! end
10982
10983 !! test
10984 Magic links: RFC (w/ non-newline whitespace, T30950/T31025)
10985 !! wikitext
10986 RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 822
10987 RFC
10988 822
10989 !! html/php
10990 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
10991 RFC
10992 822
10993 </p>
10994 !! html/parsoid
10995 <p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external mw-magiclink">RFC <span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#0160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#xA0;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#Xa0;","srcContent":" "}'> </span> 822</a>
10996 RFC
10997 822</p>
10998 !! end
10999
11000 !! test
11001 Magic links: ISBN (T3937)
11002 !! wikitext
11003 ISBN 0-306-40615-2
11004 !! html/php
11005 <p><a href="/wiki/Special:BookSources/0306406152" class="internal mw-magiclink-isbn">ISBN 0-306-40615-2</a>
11006 </p>
11007 !! html/parsoid
11008 <p><a href="./Special:BookSources/0306406152" rel="mw:WikiLink">ISBN 0-306-40615-2</a></p>
11009 !! end
11010
11011 !! test
11012 Magic links: ISBN (T67278)
11013 !! wikitext
11014 This is ISBN 978-0-316-09811-3 but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.
11015 !! html/php
11016 <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.
11017 </p>
11018 !! html/parsoid
11019 <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>
11020 !! end
11021
11022 !! test
11023 Magic links: ISBN (w/ non-newline whitespace, T30950/T31025)
11024 !! wikitext
11025 ISBN &nbsp;&#160;&#0160;&#xA0;&#Xa0; 978&nbsp;0&#160;316&#0160;09811&#xA0;3
11026 ISBN
11027 9780316098113
11028 ISBN 978
11029 0316098113
11030 !! html/php
11031 <p><a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978 0 316 09811 3</a>
11032 ISBN
11033 9780316098113
11034 ISBN 978
11035 0316098113
11036 </p>
11037 !! html/parsoid
11038 <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>
11039 ISBN
11040 9780316098113
11041 ISBN 978
11042 0316098113</p>
11043 !! end
11044
11045 !! test
11046 Magic links: PMID incorrectly converts space to underscore
11047 !! wikitext
11048 PMID 1234
11049 !! html/php
11050 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11051 </p>
11052 !! html/parsoid
11053 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external mw-magiclink">PMID 1234</a></p>
11054 !! end
11055
11056 !! test
11057 Magic links: PMID (T67278)
11058 !! wikitext
11059 This is PMID 1234 but thisPMID 1234 is not PMID 1234linked.
11060 !! html/php
11061 <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.
11062 </p>
11063 !! html/parsoid
11064 <p>This is <a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external mw-magiclink">PMID 1234</a> but thisPMID 1234 is not PMID 1234linked.</p>
11065 !! end
11066
11067 !! test
11068 Magic links: PMID (w/ non-newline whitespace, T30950/T31025)
11069 !! wikitext
11070 PMID &nbsp;&#160;&#0160;&#xA0;&#Xa0; 1234
11071 PMID
11072 1234
11073 !! html/php
11074 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11075 PMID
11076 1234
11077 </p>
11078 !! html/parsoid
11079 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external mw-magiclink">PMID <span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#0160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#xA0;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#Xa0;","srcContent":" "}'> </span> 1234</a>
11080 PMID
11081 1234</p>
11082 !! end
11083
11084 # <nowiki> nodes shouldn't be inserted during html2wt by Parsoid,
11085 # since these are ExtLinkText, not MagicLinkText
11086 !! test
11087 Magic links: use appropriate serialization for "almost" magic links.
11088 !! wikitext
11089 X[[Special:BookSources/0978739256|foo]]
11090
11091 X[https://tools.ietf.org/html/rfc1234 foo]
11092 !! html/php
11093 <p>X<a href="/wiki/Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a>
11094 </p><p>X<a rel="nofollow" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a>
11095 </p>
11096 !! html/parsoid
11097 <p>X<a rel="mw:WikiLink" href="./Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a></p>
11098 <p>X<a rel="mw:ExtLink" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a></p>
11099 !! end
11100
11101 !! test
11102 Magic links: All disabled (T47942)
11103 !! options
11104 wgEnableMagicLinks={"ISBN":false, "PMID":false, "RFC":false}
11105 !! wikitext
11106 ISBN 0-306-40615-2
11107 PMID 1234
11108 RFC 4321
11109 !! html/php
11110 <p>ISBN 0-306-40615-2
11111 PMID 1234
11112 RFC 4321
11113 </p>
11114 !! end
11115
11116 ###
11117 ### Templates
11118 ####
11119
11120 !! test
11121 Nonexistent template
11122 !! wikitext
11123 {{thistemplatedoesnotexist}}
11124 !! html
11125 <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>
11126 </p>
11127 !! end
11128
11129 !! test
11130 Template with invalid target containing tags
11131 !! wikitext
11132 {{a<b>b</b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11133 !! html
11134 <p>{{a<b>b</b>|foo|a=b|a = b}}
11135 </p>
11136 !! end
11137
11138 !! test
11139 Template with invalid target containing unclosed tag
11140 !! wikitext
11141 {{a<b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11142 !! html
11143 <p>{{a<b>|foo|a=b|a = b}}</b>
11144 </p>
11145 !! end
11146
11147 !! test
11148 Template with invalid target containing wikilink
11149 !! wikitext
11150 {{[[Main Page]]}}
11151 !! html/php
11152 <p>{{<a href="/wiki/Main_Page" title="Main Page">Main Page</a>}}
11153 </p>
11154 !! html/parsoid
11155 <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>
11156 !! end
11157
11158 !! test
11159 Template with just whitespace in it, T70421
11160 !! wikitext
11161 {{echo|{{ }}}}
11162 !! html/parsoid
11163 <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>
11164 !! end
11165
11166 !! article
11167 Template:test
11168 !! text
11169 This is a test template
11170 !! endarticle
11171
11172 !! test
11173 Simple template
11174 !! wikitext
11175 {{test}}
11176 !! html
11177 <p>This is a test template
11178 </p>
11179 !! end
11180
11181 !! test
11182 Template with explicit namespace
11183 !! wikitext
11184 {{Template:test}}
11185 !! html
11186 <p>This is a test template
11187 </p>
11188 !! end
11189
11190
11191 !! article
11192 Template:paramtest
11193 !! text
11194 This is a test template with parameter {{{param}}}
11195 !! endarticle
11196
11197 !! test
11198 Template parameter
11199 !! wikitext
11200 {{paramtest|param=foo}}
11201 !! html
11202 <p>This is a test template with parameter foo
11203 </p>
11204 !! end
11205
11206 !! article
11207 Template:paramtestnum
11208 !! text
11209 [[{{{1}}}|{{{2}}}]]
11210 !! endarticle
11211
11212 !! test
11213 Template unnamed parameter
11214 !! wikitext
11215 {{paramtestnum|Main Page|the main page}}
11216 !! html
11217 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
11218 </p>
11219 !! end
11220
11221 !! article
11222 Template:templatesimple
11223 !! text
11224 (test)
11225 !! endarticle
11226
11227 !! article
11228 Template:templateredirect
11229 !! text
11230 #redirect [[Template:templatesimple]]
11231 !! endarticle
11232
11233 !! article
11234 Template:templateasargtestnum
11235 !! text
11236 {{{{{1}}}}}
11237 !! endarticle
11238
11239 !! article
11240 Template:templateasargtest
11241 !! text
11242 {{template{{{templ}}}}}
11243 !! endarticle
11244
11245 !! article
11246 Template:templateasargtest2
11247 !! text
11248 {{{{{templ}}}}}
11249 !! endarticle
11250
11251 !! test
11252 Template with template name as unnamed argument
11253 !! wikitext
11254 {{templateasargtestnum|templatesimple}}
11255 !! html
11256 <p>(test)
11257 </p>
11258 !! end
11259
11260 !! test
11261 Template with template name as argument
11262 !! wikitext
11263 {{templateasargtest|templ=simple}}
11264 !! html
11265 <p>(test)
11266 </p>
11267 !! end
11268
11269 !! test
11270 Template with template name as argument (2)
11271 !! wikitext
11272 {{templateasargtest2|templ=templatesimple}}
11273 !! html
11274 <p>(test)
11275 </p>
11276 !! end
11277
11278 !! article
11279 Template:templateasargtestdefault
11280 !! text
11281 {{{{{templ|templatesimple}}}}}
11282 !! endarticle
11283
11284 !! article
11285 Template:templa
11286 !! text
11287 '''templ'''
11288 !! endarticle
11289
11290 !! test
11291 Template with default value
11292 !! wikitext
11293 {{templateasargtestdefault}}
11294 !! html
11295 <p>(test)
11296 </p>
11297 !! end
11298
11299 !! test
11300 Template with default value (value set)
11301 !! wikitext
11302 {{templateasargtestdefault|templ=templa}}
11303 !! html
11304 <p><b>templ</b>
11305 </p>
11306 !! end
11307
11308 !! test
11309 Template redirect
11310 !! wikitext
11311 {{templateredirect}}
11312 !! html/php
11313 <p>(test)
11314 </p>
11315 !! html/parsoid
11316 <link rel="mw:PageProp/redirect" href="./Template:Templatesimple" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"templateredirect","href":"./Template:Templateredirect"},"params":{},"i":0}}]}'/>
11317 !! end
11318
11319 !! test
11320 Template with argument in separate line
11321 !! wikitext
11322 {{ templateasargtest |
11323 templ = simple }}
11324 !! html
11325 <p>(test)
11326 </p>
11327 !! end
11328
11329 !! test
11330 Template with complex template as argument
11331 !! wikitext
11332 {{paramtest|
11333 param ={{ templateasargtest |
11334 templ = simple }}}}
11335 !! html
11336 <p>This is a test template with parameter (test)
11337 </p>
11338 !! end
11339
11340 !! test
11341 Templates with templated name
11342 !! wikitext
11343 {{{{echo|echo}}|foo}}
11344 {{{{echo|inner list}} }}
11345 !! html
11346 <p>foo
11347 </p>
11348 <ul><li>item 1</li></ul>
11349
11350 !! html/parsoid
11351 <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>
11352 <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>
11353 !! end
11354
11355 ## Regression test; the output here isn't really that interesting.
11356 !! test
11357 Templates with templated name and top level template args
11358 !! wikitext
11359 {{1{{2{{{3}}}|4=5}}}}
11360 !! html/parsoid
11361 <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>
11362 !! end
11363
11364 # Parsoid markup is deliberate "broken". This is an edge case.
11365 # See long comment in TemplateHandler.js:convertAttribsToString.
11366 !! test
11367 Templates with invalid templated targets
11368 !! wikitext
11369 {{echo
11370 {{echo|foo}}
11371 }}
11372 !! html/php
11373 <p>{{echo
11374 foo
11375 }}
11376 </p>
11377 !! html/parsoid
11378 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n{{echo|foo}}\n"},"params":{},"i":0}}]}'>{{echo
11379 foo }}</p>
11380 !! end
11381
11382 !! test
11383 Template with thumb image (with link in description)
11384 !! wikitext
11385 {{paramtest|param=[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
11386 !! html/php
11387 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>
11388
11389 !! html+tidy
11390 <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>
11391 !! html/parsoid
11392 <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>
11393 !! end
11394
11395 !! article
11396 Template:complextemplate
11397 !! text
11398 {{{1}}} {{paramtest|
11399 param ={{{param}}}}}
11400 !! endarticle
11401
11402 !! test
11403 Template with complex arguments
11404 !! wikitext
11405 {{complextemplate|
11406 param ={{ templateasargtest |
11407 templ = simple }}|[[Template:complextemplate|link]]}}
11408 !! html
11409 <p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test)
11410 </p>
11411 !! end
11412
11413 !! test
11414 T2553: link with two variables in a piped link
11415 !! wikitext
11416 {|
11417 |[[{{{1}}}|{{{2}}}]]
11418 |}
11419 !! html/php
11420 <table>
11421 <tr>
11422 <td>[[{{{1}}}|{{{2}}}]]
11423 </td></tr></table>
11424
11425 !! html/parsoid
11426 <table>
11427 <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>
11428 </tbody></table>
11429 !! end
11430
11431 # See: T2553
11432 !! test
11433 Abort table cell attribute parsing on wikilink
11434 !! wikitext
11435 {|
11436 |testing [[one|two]] |three||four
11437 |testing one two |three||four
11438 |testing="[[one|two]]" |three||four
11439 |}
11440 !! html/php
11441 <table>
11442 <tr>
11443 <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>
11444 <td>four
11445 </td>
11446 <td>three</td>
11447 <td>four
11448 </td>
11449 <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>
11450 <td>four
11451 </td></tr></table>
11452
11453 !! html/parsoid
11454 <table>
11455 <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>
11456 <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>
11457 <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>
11458 </tbody></table>
11459 !! end
11460
11461 !! test
11462 Don't abort table cell attribute parsing if wikilink is found in template arg
11463 !! wikitext
11464 {|
11465 |Test {{#tag:ref|One two "[[three]]" four}}
11466 |}
11467 !! html/parsoid
11468 <table>
11469 <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>
11470 </tbody></table>
11471 !! end
11472
11473 !! test
11474 Magic variable as template parameter
11475 !! wikitext
11476 {{paramtest|param={{SITENAME}}}}
11477 !! html
11478 <p>This is a test template with parameter MediaWiki
11479 </p>
11480 !! end
11481
11482 !! article
11483 Template:linktest
11484 !! text
11485 [[{{{param}}}|link]]
11486 !! endarticle
11487
11488 !! test
11489 Template parameter as link source
11490 !! wikitext
11491 {{linktest|param=Main Page}}
11492 !! html
11493 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
11494 </p>
11495 !! end
11496
11497 !!article
11498 Template:paramtest2
11499 !! text
11500 including another template, {{paramtest|param={{{arg}}}}}
11501 !! endarticle
11502
11503 !! test
11504 Template passing argument to another template
11505 !! wikitext
11506 {{paramtest2|arg='hmm'}}
11507 !! html
11508 <p>including another template, This is a test template with parameter 'hmm'
11509 </p>
11510 !! end
11511
11512 !! article
11513 Template:Linktest2
11514 !! text
11515 Main Page
11516 !! endarticle
11517
11518 !! test
11519 Template as link source
11520 !! wikitext
11521 [[{{linktest2}}]]
11522
11523 [[{{linktest2}}|Main Page]]
11524
11525 [[{{linktest2}}]]Page
11526 !! html
11527 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11528 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11529 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>Page
11530 </p>
11531 !! end
11532
11533
11534 !! article
11535 Template:loop1
11536 !! text
11537 {{loop2}}
11538 !! endarticle
11539
11540 !! article
11541 Template:loop2
11542 !! text
11543 {{loop1}}
11544 !! endarticle
11545
11546 !! test
11547 Template infinite loop
11548 !! wikitext
11549 {{loop1}}
11550 !! html
11551 <p><span class="error">Template loop detected: <a href="/wiki/Template:Loop1" title="Template:Loop1">Template:Loop1</a></span>
11552 </p>
11553 !! end
11554
11555 !! test
11556 Template from main namespace
11557 !! wikitext
11558 {{:Main Page}}
11559 !! html
11560 <p>blah blah
11561 </p>
11562 !! end
11563
11564 !! test
11565 Template from non-includable namespace
11566 !! options
11567 wgNonincludableNamespaces=10
11568 !! wikitext
11569 {{echo|uh oh!}}
11570 !! html
11571 <p><a href="/wiki/Template:Echo" title="Template:Echo">Template:Echo</a>
11572 </p>
11573 !! end
11574
11575 !! article
11576 Template:table
11577 !! text
11578 {|
11579 | 1 || 2
11580 |-
11581 | 3 || 4
11582 |}
11583 !! endarticle
11584
11585 !! test
11586 T2529: Template with table, not included at beginning of line
11587 !! wikitext
11588 foo {{table}}
11589 !! html
11590 <p>foo
11591 </p>
11592 <table>
11593 <tr>
11594 <td>1</td>
11595 <td>2
11596 </td></tr>
11597 <tr>
11598 <td>3</td>
11599 <td>4
11600 </td></tr></table>
11601
11602 !! end
11603
11604 !! test
11605 T2523: Template shouldn't eat newline (or add an extra one before table)
11606 !! wikitext
11607 foo
11608 {{table}}
11609 !! html
11610 <p>foo
11611 </p>
11612 <table>
11613 <tr>
11614 <td>1</td>
11615 <td>2
11616 </td></tr>
11617 <tr>
11618 <td>3</td>
11619 <td>4
11620 </td></tr></table>
11621
11622 !! end
11623
11624 !! test
11625 T2041: Template parameters shown as broken links
11626 !! wikitext
11627 {{{parameter}}}
11628 !! html
11629 <p>{{{parameter}}}
11630 </p>
11631 !! end
11632
11633 !! test
11634 Template with targets containing wikilinks
11635 !! options
11636 parsoid=wt2html
11637 !! wikitext
11638 {{[[foo]]}}
11639
11640 {{[[{{echo|foo}}]]}}
11641
11642 {{{{echo|[[foo}}]]}}
11643 !! html/php
11644 <p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11645 </p><p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11646 </p><p>{{[[foo}}]]
11647 </p>
11648 !! html/parsoid
11649 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">foo</a>}}</p>
11650 <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>
11651 <p>{{<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[foo}}]]"}},"i":0}}]}'>[[foo}}]]</span></p>
11652 !! end
11653
11654 !! article
11655 Template:''
11656 !! text
11657 bar
11658 !! endarticle
11659
11660 !! test
11661 Templates: Double quotes as template target
11662 !! wikitext
11663 foo {{''}} baz
11664 !! html/php
11665 <p>foo bar baz
11666 </p>
11667 !! html/parsoid
11668 <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
11669 </p>
11670 !! end
11671
11672 ## This test is about making sure Parsoid's data-mw is well formed in the
11673 ## face of multiple templates with intersecting and overlapping ranges. The
11674 ## wikitext itself is wretched.
11675 !! test
11676 Templates with intersecting and overlapping ranges
11677 !! wikitext
11678 {|{{echo|
11679 <p>ha</p>}}
11680 {|{{echo|
11681 <p>ho</p>}}
11682 {{echo|{{!}}hi}}
11683 |}
11684 !! html/php+tidy
11685 <p>ha</p><table>
11686
11687 </table><p>ho</p><table>
11688
11689 <tbody><tr>
11690 <td>hi
11691 </td></tr></tbody></table>
11692 !! html/parsoid
11693 <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":""}]]}'>
11694
11695 </table><p about="#mwt1">ho</p><table about="#mwt1" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"","html":""},{"html":""}]]}'>
11696
11697 <tbody><tr><td>hi</td></tr>
11698 </tbody></table>
11699 !! end
11700
11701 !! article
11702 Template:MSGNW test
11703 !! text
11704 ''None'' of '''this''' should be
11705 * interpreted
11706 but rather passed unmodified
11707 {{test}}
11708 <gallery>
11709 File:Foobar.jpg
11710 </gallery>
11711 <!-- comment -->
11712 !! endarticle
11713
11714 # hmm, fix this or just deprecate msgnw and document its behavior?
11715 !! test
11716 msgnw keyword
11717 !! wikitext
11718 {{msgnw:MSGNW test}}
11719 !! html/php
11720 <p>&#39;&#39;None&#39;&#39; of &#39;&#39;&#39;this&#39;&#39;&#39; should be
11721 &#42; interpreted
11722 &#32;but rather passed unmodified
11723 &#123;&#123;test&#125;&#125;
11724 &#60;gallery&#62;
11725 File:Foobar.jpg
11726 &#60;/gallery&#62;
11727 &#60;!-- comment --&#62;
11728 </p>
11729 !! end
11730
11731 !! test
11732 int keyword
11733 !! wikitext
11734 {{int:youhavenewmessages|lots of money|not!}}
11735 !! html
11736 <p>You have lots of money (not!).
11737 </p>
11738 !! end
11739
11740 !! test
11741 int keyword - non-existing message
11742 !! wikitext
11743 {{int:var}}
11744 !! html
11745 <p>⧼var⧽
11746 </p>
11747 !! end
11748
11749 !! article
11750 Template:Includes
11751 !! text
11752 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11753 !! endarticle
11754
11755 !! test
11756 <includeonly> and <noinclude> being included
11757 !! wikitext
11758 {{Includes}}
11759 !! html
11760 <p>Foobar
11761 </p>
11762 !! end
11763
11764 !! article
11765 Template:Includes2
11766 !! text
11767 <onlyinclude>Foo</onlyinclude>bar
11768 !! endarticle
11769
11770 !! test
11771 <onlyinclude> being included
11772 !! wikitext
11773 {{Includes2}}
11774 !! html
11775 <p>Foo
11776 </p>
11777 !! end
11778
11779
11780 !! article
11781 Template:Includes3
11782 !! text
11783 <onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly>
11784 !! endarticle
11785
11786 !! test
11787 <onlyinclude> and <includeonly> being included
11788 !! wikitext
11789 {{Includes3}}
11790 !! html
11791 <p>Foo
11792 </p>
11793 !! end
11794
11795 !! test
11796 <includeonly> and <noinclude> on a page
11797 !! wikitext
11798 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11799 !! html
11800 <p>Foozar
11801 </p>
11802 !! end
11803
11804 !! test
11805 Un-closed <noinclude>
11806 !! wikitext
11807 <noinclude>
11808 !! html
11809 !! end
11810
11811 !! test
11812 <onlyinclude> on a page
11813 !! wikitext
11814 <onlyinclude>Foo</onlyinclude>bar
11815 !! html
11816 <p>Foobar
11817 </p>
11818 !! end
11819
11820 !! test
11821 Un-closed <onlyinclude>
11822 !! wikitext
11823 <onlyinclude>
11824 !! html
11825 !! end
11826
11827 !!test
11828 Self-closed noinclude, includeonly, onlyinclude tags
11829 !! wikitext
11830 <noinclude />
11831 <includeonly />
11832 <onlyinclude />
11833 !! html
11834 <p><br />
11835 </p>
11836 !!end
11837
11838 !!test
11839 Unbalanced includeonly and noinclude tags
11840 !! wikitext
11841 {|
11842 |a</noinclude>
11843 |b</noinclude></noinclude>
11844 |c</noinclude></includeonly>
11845 |d</includeonly></includeonly>
11846 |}
11847 !! html
11848 <table>
11849 <tr>
11850 <td>a
11851 </td>
11852 <td>b
11853 </td>
11854 <td>c&lt;/includeonly&gt;
11855 </td>
11856 <td>d&lt;/includeonly&gt;&lt;/includeonly&gt;
11857 </td></tr></table>
11858
11859 !!end
11860
11861 !! article
11862 Template:Includeonly section
11863 !! text
11864 <includeonly>
11865 ==Includeonly section==
11866 </includeonly>
11867 ==Section T-1==
11868 !!endarticle
11869
11870 !! test
11871 T8563: Edit link generation for section shown by <includeonly>
11872 !! wikitext
11873 {{includeonly section}}
11874 !! html
11875 <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>
11876 <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>
11877
11878 !! end
11879
11880 # Uses same input as the contents of [[Template:Includeonly section]]
11881 !! test
11882 T8563: Section extraction for section shown by <includeonly>
11883 !! options
11884 section=T-2
11885 !! wikitext
11886 <includeonly>
11887 ==Includeonly section==
11888 </includeonly>
11889 ==Section T-2==
11890 !! html
11891 ==Section T-2==
11892 !! end
11893
11894 !! test
11895 T8563: Edit link generation for section suppressed by <includeonly>
11896 !! wikitext
11897 <includeonly>
11898 ==Includeonly section==
11899 </includeonly>
11900 ==Section 1==
11901 !! html
11902 <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>
11903
11904 !! end
11905
11906 !! test
11907 T8563: Section extraction for section suppressed by <includeonly>
11908 !! options
11909 section=1
11910 !! wikitext
11911 <includeonly>
11912 ==Includeonly section==
11913 </includeonly>
11914 ==Section 1==
11915 !! html
11916 ==Section 1==
11917 !! end
11918
11919 !! test
11920 Un-closed <includeonly>
11921 !! wikitext
11922 <includeonly>
11923 !! html/php
11924 !! html/parsoid
11925 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>"}'/>
11926 !! end
11927
11928 ## We used to, but no longer wt2wt this test since the default serializer
11929 ## will normalize the include directives to serialize on their own line.
11930 ## Selser will take care of preserving formatting in scenarios where they
11931 ## intermingled with other wikitext.
11932 !! test
11933 Includes and comments at SOL
11934 !! options
11935 parsoid=wt2html,html2html
11936 !! wikitext
11937 <!-- comment --><noinclude><!-- comment --></noinclude><!-- comment -->==hu==
11938
11939 <noinclude>
11940 some
11941 </noinclude>*stuff
11942 *here
11943
11944 <includeonly>can have stuff</includeonly>===here===
11945
11946 !! html/php
11947 <h2><span class="mw-headline" id="hu">hu</span></h2>
11948 <p>some
11949 </p>
11950 <ul><li>stuff</li>
11951 <li>here</li></ul>
11952 <h3><span class="mw-headline" id="here">here</span></h3>
11953
11954 !! html/parsoid
11955 <!-- 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>
11956
11957 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
11958 <p>some</p>
11959 <meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/><ul><li>stuff</li>
11960 <li>here</li></ul>
11961
11962 <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>
11963
11964 !! end
11965
11966 # TODO: test with DOM fragment reuse!
11967 !! test
11968 Parsoid: DOM fragment reuse
11969 !! options
11970 parsoid=wt2wt,wt2html
11971 !! wikitext
11972 a{{echo|b<table></table>c}}d
11973
11974 a{{echo|b
11975 <table></table>
11976 c}}d
11977
11978 {{echo|a
11979
11980 <table></table>
11981
11982 b}}
11983 !! html
11984 <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>
11985
11986 <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">
11987 </span><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><span about="#mwt2">
11988 </span><p about="#mwt2">cd</p>
11989
11990 <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">
11991
11992 </span><table about="#mwt3" data-parsoid='{"stx":"html"}'></table><span about="#mwt3">
11993
11994 </span><p about="#mwt3">b</p>
11995 !! end
11996
11997 !! test
11998 Parsoid: Merge double tds (T52603)
11999 !! options
12000 parsoid
12001 !! wikitext
12002 {|
12003 |{{echo|{{!}} foo}}
12004 |}
12005 !! html
12006 <table><tbody>
12007 <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>
12008 </tbody></table>
12009 !! end
12010
12011 !! test
12012 Parsoid: Merge double tds in nested transclusion content (T52603)
12013 !! options
12014 parsoid
12015 !! wikitext
12016 {{echo|<div>}}
12017 {|
12018 |{{echo|{{!}} foo}}
12019 |}
12020 {{echo|</div>}}
12021 !! html
12022 <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}}]}'>
12023 <table><tbody>
12024 <tr><td data-mw='{"parts":["|"]}'> foo</td></tr>
12025 </tbody></table>
12026 </div>
12027 !! end
12028
12029 ###
12030 ### <includeonly> and <noinclude> in attributes
12031 ###
12032 !!test
12033 0. includeonly around the entire attribute
12034 !! wikitext
12035 <span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
12036 !! html
12037 <p><span id="v2">bar</span>
12038 </p>
12039 !!end
12040
12041 !!test
12042 1. includeonly in html attr key
12043 !! wikitext
12044 <span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
12045 !! html
12046 <p><span id="foo">bar</span>
12047 </p>
12048 !!end
12049
12050 !!test
12051 2. includeonly in html attr value
12052 !! wikitext
12053 <span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
12054 <span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
12055 !! html
12056 <p><span id="v1">bar</span>
12057 <span id="v1">bar</span>
12058 </p>
12059 !!end
12060
12061 !!test
12062 3. includeonly in part of an attr value
12063 !! wikitext
12064 <span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
12065 !! html
12066 <p><span style="color:red;">bar</span>
12067 </p>
12068 !!end
12069
12070 !!test
12071 4. includeonly in table attributes
12072 !! wikitext
12073 {|
12074 |- <noinclude>
12075 |-
12076 |a
12077 </noinclude>
12078 |- <includeonly>
12079 |-
12080 |b
12081 </includeonly>
12082 |}
12083 !! html
12084 <table>
12085
12086
12087 <tr>
12088 <td>a
12089 </td></tr>
12090 </table>
12091
12092 !!end
12093
12094 ###
12095 ### Preprocessor precedence tests
12096 ### See: https://www.mediawiki.org/wiki/Preprocessor_ABNF
12097 ###
12098 ##{{[[-{{{{{{[[Foo|bar}}]]}-}}}}}]]
12099 !! test
12100 Preprocessor precedence 1: link is rightmost opening
12101 !! options
12102 parsoid=wt2html
12103 !! wikitext
12104 {{[[Foo|bar}}]]
12105
12106 But close-brace is not a valid character in a link title:
12107 {{[[Foo}}|bar]]
12108
12109 However, we can still tell this was handled as a link in the preprocessor:
12110 {{echo|[[Foo}}|bar]]|bat}}
12111 !! html/php
12112 <p>{{<a href="/wiki/Foo" title="Foo">bar}}</a>
12113 </p><p>But close-brace is not a valid character in a link title:
12114 {{[[Foo}}|bar]]
12115 </p><p>However, we can still tell this was handled as a link in the preprocessor:
12116 [[Foo}}|bar]]
12117 </p>
12118 !! html/parsoid
12119 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">bar}}</a></p>
12120 <p>But close-brace is not a valid character in a link title: {{[[Foo}}|bar]]</p>
12121 <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>
12122 !! end
12123
12124 !! test
12125 Preprocessor precedence 2: template is rightmost opening
12126 !! options
12127 language=zh
12128 !! wikitext
12129 -{{echo|foo}-}}-
12130 !! html/php
12131 <p>-foo}--
12132 </p>
12133 !! html/parsoid
12134 <p>-<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}-"}},"i":0}}]}'>foo}-</span>-</p>
12135 !! end
12136
12137 !! test
12138 Preprocessor precedence 3: language converter is rightmost opening
12139 !! options
12140 language=zh
12141 parsoid=wt2html
12142 !! wikitext
12143 {{echo|hi}}
12144
12145 {{-{R|echo|hi}}}-
12146
12147 [[-{R|raw]]}-
12148 !! html/php
12149 <p>hi
12150 </p><p>{{echo|hi}}
12151 </p><p>[[raw]]
12152 </p>
12153 !! html/parsoid
12154 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"}},"i":0}}]}'>hi</p>
12155 <p>{{<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"echo|hi}}"}}'></span></p>
12156 <p>[[<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw]]"}}'></span></p>
12157 !! end
12158
12159 !! test
12160 Preprocessor precedence 4: left-most angle bracket
12161 !! options
12162 language=zh
12163 !! wikitext
12164 <!--{raw}-->
12165 !! html/php
12166 !! html/parsoid
12167 <!--{raw}-->
12168 !! end
12169
12170 !! article
12171 Template:Precedence5
12172 !! text
12173 {{{{{1}}}}}
12174 !! endarticle
12175
12176 !! test
12177 Preprocessor precedence 5: tplarg takes precedence over template
12178 !! wikitext
12179 {{Precedence5|Bullet}}
12180 !! html/php
12181 <ul><li>Bar</li></ul>
12182
12183 !! html/parsoid
12184 <ul typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Precedence5","href":"./Template:Precedence5"},"params":{"1":{"wt":"Bullet"}},"i":0}}]}'><li>Bar</li></ul>
12185 !! end
12186
12187 !! test
12188 Preprocessor precedence 6: broken link is rightmost opening
12189 !! options
12190 parsoid=wt2html
12191 !! wikitext
12192 {{echo|[[Foo}}
12193
12194 {{echo|[[Foo|bar|bat=baz}}
12195 !! html/php
12196 <p>{{echo|[[Foo}}
12197 </p><p>{{echo|[[Foo|bar|bat=baz}}
12198 </p>
12199 !! html/parsoid
12200 <p>{{echo|[[Foo}}</p>
12201 <p>{{echo|[[Foo|bar|bat=baz}}</p>
12202 !! end
12203
12204 # This next test exposes a difference between PHP and Parsoid:
12205 # Given [[Foo|{{echo|Bar]]x}}y]]z:
12206 # 1) Both PHP and Parsoid ignore the `]]` inside the `echo` in the
12207 # "preprocessor" stage. The `{{echo` extends until the `x}}`, and the
12208 # outer `[[Foo` extends until the `y]]`
12209 # 2a) But then the PHP preprocessor emits `[[Foo|Bar]]xy]]z` as an
12210 # intermediate result (after template expansion), and link processing
12211 # happens on this intermediate result, which moves the wikilink
12212 # boundary leftward to `[[Foo|Bar]]`
12213 # 2b) Parsoid works in a single step, so it's going to keep the
12214 # wikilink as extending to the `y]]`
12215 # 3a) Then PHP does linktrail processing which slurps up the trailing
12216 # `xy` inside the link.
12217 # 3b) Parsoid will do linktrail processing to slurp up the trailing
12218 # `z` inside the link.
12219 # This is "correct" behavior. Parsoid's basic worldview is that the
12220 # `]]` inside the template shouldn't be allowed to leak out to affect
12221 # the surrounding wikilink. PHP may match Parsoid (in the future)
12222 # if you use {{#balance}} (T114445).
12223
12224 !! test
12225 Preprocessor precedence 7: broken template is rightmost opening
12226 !! options
12227 parsoid=wt2html
12228 !! wikitext
12229 [[Foo|{{echo|Bar]]
12230
12231 [[Foo|{{echo|Bar]]-x}}-y]]-z
12232
12233 Careful: linktrails can move the end of the wikilink:
12234 [[Foo|{{echo|y']]a}}l]]l
12235 !! html/php
12236 <p><a href="/wiki/Foo" title="Foo">{{echo|Bar</a>
12237 </p><p><a href="/wiki/Foo" title="Foo">Bar</a>-x-y]]-z
12238 </p><p>Careful: linktrails can move the end of the wikilink:
12239 <a href="/wiki/Foo" title="Foo">y'al</a>]]l
12240 </p>
12241 !! html/parsoid
12242 <p>[[Foo|{{echo|Bar]]</p>
12243 <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>
12244 <p>Careful: linktrails can move the end of the wikilink:
12245 <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>
12246 !! end
12247
12248 !! test
12249 Preprocessor precedence 8: broken language converter is rightmost opening
12250 !! options
12251 language=zh
12252 !! wikitext
12253 [[Foo-{R|raw]]
12254 !! html
12255 <p>[[Foo-{R|raw]]
12256 </p>
12257 !! end
12258
12259 !! article
12260 Template:Preprocessor_precedence_9
12261 !! text
12262 ;4: {{{{1}}}}
12263 ;5: {{{{{2}}}}}
12264 ;6: {{{{{{3}}}}}}
12265 ;7: {{{{{{{4}}}}}}}
12266 !! endarticle
12267
12268 !! test
12269 Preprocessor precedence 9: groups of braces
12270 !! wikitext
12271 {{Preprocessor precedence 9|Four|Bullet|1|2}}
12272 !! html/php
12273 <dl><dt>4</dt>
12274 <dd>{Four}</dd>
12275 <dt>5</dt>
12276 <dd></dd></dl>
12277 <ul><li>Bar</li></ul>
12278 <dl><dt>6</dt>
12279 <dd>Four</dd>
12280 <dt>7</dt>
12281 <dd>{Bullet}</dd></dl>
12282
12283 !! html/parsoid
12284 <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}}]}'>
12285 <dt>4</dt>
12286 <dd>{Four}</dd>
12287 <dt>5</dt>
12288 <dd></dd>
12289 </dl><ul about="#mwt1">
12290 <li>Bar</li>
12291 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12292 <dt>6</dt>
12293 <dd>Four</dd>
12294 <dt>7</dt>
12295 <dd>{Bullet}</dd>
12296 </dl>
12297 !! end
12298
12299 !! article
12300 Template:Preprocessor_precedence_10
12301 !! text
12302 ;1: -{R|raw}-
12303 ;2: -{{Bullet}}-
12304 ;3: -{{{1}}}-
12305 ;4: -{{{{2}}}}-
12306 ;5: -{{{{{3}}}}}-
12307 ;6: -{{{{{{4}}}}}}-
12308 ;7: -{{{{{{{5}}}}}}}-
12309 !! endarticle
12310
12311 !! test
12312 Preprocessor precedence 10: groups of braces with leading dash
12313 !! options
12314 language=zh
12315 !! wikitext
12316 {{Preprocessor precedence 10|Three|raw2|Bullet|1|2}}
12317 !! html/php
12318 <dl><dt>1</dt>
12319 <dd>raw</dd>
12320 <dt>2</dt>
12321 <dd>-</dd></dl>
12322 <ul><li>Bar-</li></ul>
12323 <dl><dt>3</dt>
12324 <dd>-Three-</dd>
12325 <dt>4</dt>
12326 <dd>raw2</dd>
12327 <dt>5</dt>
12328 <dd>-</dd></dl>
12329 <ul><li>Bar-</li></ul>
12330 <dl><dt>6</dt>
12331 <dd>-Three-</dd>
12332 <dt>7</dt>
12333 <dd>raw2</dd></dl>
12334
12335 !! html/parsoid
12336 <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}}]}'>
12337 <dt>1</dt>
12338 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw"}}'></span></dd>
12339 <dt>2</dt>
12340 <dd>-</dd>
12341 </dl><ul about="#mwt1">
12342 <li>Bar-</li>
12343 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12344 <dt>3</dt>
12345 <dd>-Three-</dd>
12346 <dt>4</dt>
12347 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12348 <dt>5</dt>
12349 <dd>-</dd>
12350 </dl><ul about="#mwt1">
12351 <li>Bar-</li>
12352 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12353 <dt>6</dt>
12354 <dd>-Three-</dd>
12355 <dt>7</dt>
12356 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12357 </dl>
12358 !! end
12359
12360 !! test
12361 Preprocessor precedence 11: found during visual diff testing
12362 !! wikitext
12363 {{#tag:span|-{{#tag:span|-{{echo|x}}}}}}
12364
12365 {{echo|-{{echo|-{{echo|x}}}}}}
12366
12367 {{echo|-{{echo|x}}}}
12368 !! html/php
12369 <p><span>-<span>-x</span></span>
12370 </p><p>--x
12371 </p><p>-x
12372 </p>
12373 !! html/parsoid
12374 <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>
12375
12376 <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>
12377
12378 <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>
12379 !! end
12380
12381 !! test
12382 Preprocessor precedence 12: broken language converter closed by brace.
12383 !! options
12384 parsoid=wt2html
12385 !! wikitext
12386 This form breaks the template, which is unfortunate:
12387 *{{echo|foo-{bar}bat}}
12388
12389 But if the broken language converter markup is inside an extension
12390 tag, nothing bad happens:
12391 *<nowiki>foo-{bar}bat</nowiki>
12392 *{{echo|<nowiki>foo-{bar}bat</nowiki>}}
12393 *<pre>foo-{bar}bat</pre>
12394 *{{echo|<pre>foo-{bar}bat</pre>}}
12395
12396 <tag>foo-{bar}bat</tag>
12397 {{echo|<tag>foo-{bar}bat</tag>}}
12398
12399 !! html/php+tidy
12400 <p>This form breaks the template, which is unfortunate:
12401 </p>
12402 <ul><li>{{echo|foo-{bar}bat}}</li></ul>
12403 <p>But if the broken language converter markup is inside an extension
12404 tag, nothing bad happens:
12405 </p>
12406 <ul><li>foo-&#123;bar}bat</li>
12407 <li>foo-&#123;bar}bat</li>
12408 <li><pre>foo-{bar}bat</pre></li>
12409 <li><pre>foo-{bar}bat</pre></li></ul>
12410 <pre>'foo-{bar}bat'
12411 array (
12412 )
12413 </pre>
12414 <pre>'foo-{bar}bat'
12415 array (
12416 )
12417 </pre>
12418 !! html/parsoid
12419 <p>This form breaks the template, which is unfortunate:</p>
12420 <ul>
12421 <li>{{echo|foo-{bar}bat}}</li>
12422 </ul>
12423 <p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p>
12424 <ul>
12425 <li><span typeof="mw:Nowiki">foo-{bar}bat</span></li>
12426 <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>
12427 <li><pre typeof="mw:Extension/pre" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo-{bar}bat"}}'>foo-{bar}bat</pre></li>
12428 <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>
12429 </ul>
12430 <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>
12431 !! end
12432
12433 !! test
12434 Preprocessor precedence 13: broken language converter in external link
12435 !! options
12436 parsoid=wt2html
12437 !! wikitext
12438 *[http://example.com/-{foo Example in URL]
12439 *[http://example.com Example in -{link} description]
12440 *{{echo|[http://example.com/-{foo Breaks template, however]}}
12441 !! html/php+tidy
12442 <ul><li><a rel="nofollow" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12443 <li><a rel="nofollow" class="external text" href="http://example.com">Example in -{link} description</a></li>
12444 <li>{{echo|<a rel="nofollow" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li></ul>
12445 !! html/parsoid
12446 <ul>
12447 <li><a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12448 <li><a rel="mw:ExtLink" class="external text" href="http://example.com">Example in -{link} description</a></li>
12449 <li>{{echo|<a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
12450 </ul>
12451 !! end
12452
12453 !! test
12454 Preprocessor precedence 14: broken language converter in comment
12455 !! wikitext
12456 *<!--{{foo}}-->...should be ok
12457 *<!---{{foo}}-->...extra dashes
12458 *{{echo|foo<!-- -{bar} -->bat}}...should be ok
12459 !! html/php+tidy
12460 <ul><li>...should be ok</li>
12461 <li>...extra dashes</li>
12462 <li>foobat...should be ok</li></ul>
12463 !! html/parsoid
12464 <ul>
12465 <li><!--{{foo}}-->...should be ok</li>
12466 <li><!--&#x2D;{{foo}}-->...extra dashes</li>
12467 <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>
12468 </ul>
12469 !! end
12470
12471 !! test
12472 Preprocessor precedence 15: broken brace markup in headings
12473 !! config
12474 wgFragmentMode=[ 'html5', 'legacy' ]
12475 !! options
12476 parsoid=wt2html
12477 !! wikitext
12478 __NOTOC__ __NOEDITSECTION__
12479 ===1 foo[bar 1===
12480 1
12481 ===2 foo[[bar 2===
12482 2
12483 ===3 foo{bar 3===
12484 3
12485 ===4 foo{{bar 4===
12486 4
12487 ===5 foo{{{bar 5===
12488 5
12489 ===6 foo-{bar 6===
12490 6
12491 !! html/php+tidy
12492 <h3><span id="1_foo.5Bbar_1"></span><span class="mw-headline" id="1_foo[bar_1">1 foo[bar 1</span></h3>
12493 <p>1
12494 </p>
12495 <h3><span id="2_foo.5B.5Bbar_2"></span><span class="mw-headline" id="2_foo[[bar_2">2 foo[[bar 2</span></h3>
12496 <p>2
12497 </p>
12498 <h3><span id="3_foo.7Bbar_3"></span><span class="mw-headline" id="3_foo{bar_3">3 foo{bar 3</span></h3>
12499 <p>3
12500 </p>
12501 <h3><span id="4_foo.7B.7Bbar_4"></span><span class="mw-headline" id="4_foo{{bar_4">4 foo{{bar 4</span></h3>
12502 <p>4
12503 </p>
12504 <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>
12505 <p>5
12506 </p>
12507 <h3><span id="6_foo-.7Bbar_6"></span><span class="mw-headline" id="6_foo-{bar_6">6 foo-{bar 6</span></h3>
12508 <p>6
12509 </p>
12510 !! html/parsoid
12511 <meta property="mw:PageProp/notoc"/> <meta property="mw:PageProp/noeditsection"/>
12512 <h3 id="1_foo[bar_1"><span id="1_foo.5Bbar_1" typeof="mw:FallbackId"></span>1 foo[bar 1</h3>
12513 <p>1</p>
12514 <h3 id="2_foo[[bar_2"><span id="2_foo.5B.5Bbar_2" typeof="mw:FallbackId"></span>2 foo[[bar 2</h3>
12515 <p>2</p>
12516 <h3 id="3_foo{bar_3"><span id="3_foo.7Bbar_3" typeof="mw:FallbackId"></span>3 foo{bar 3</h3>
12517 <p>3</p>
12518 <h3 id="4_foo{{bar_4"><span id="4_foo.7B.7Bbar_4" typeof="mw:FallbackId"></span>4 foo{{bar 4</h3>
12519 <p>4</p>
12520 <h3 id="5_foo{{{bar_5"><span id="5_foo.7B.7B.7Bbar_5" typeof="mw:FallbackId"></span>5 foo{{{bar 5</h3>
12521 <p>5</p>
12522 <h3 id="6_foo-{bar_6"><span id="6_foo-.7Bbar_6" typeof="mw:FallbackId"></span>6 foo-{bar 6</h3>
12523 <p>6</p>
12524 !! end
12525
12526 !! test
12527 Preprocessor precedence 16: matching closing braces to opening braces
12528 !! options
12529 language=zh
12530 parsoid=wt2html
12531 !! wikitext
12532 -{{{echo|foo}}bar}-
12533 !! html/php
12534 <p>foobar
12535 </p>
12536 !! html/parsoid
12537 <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>
12538 !! end
12539
12540 !! test
12541 Preprocessor precedence 17: template w/o target shouldn't prevent closing
12542 !! options
12543 parsoid=wt2html
12544 !! wikitext
12545 {{echo|hi {{}}}}
12546 !! html/php
12547 <p>hi {{}}
12548 </p>
12549 !! html/parsoid
12550 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi {{}}"}},"i":0}}]}'>hi {{}}</p>
12551 !! end
12552
12553 !! test
12554 Preprocessor precedence 18: another rightmost wins scenario
12555 !! options
12556 parsoid=wt2html
12557 !! wikitext
12558 {{ -{{{{1|tplarg}}} }} }-
12559 !! html/php
12560 <p>{{ -{tplarg }} }-
12561 </p>
12562 !! html/parsoid
12563 <p>{{ -{<span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"1"},"params":{"1":{"wt":"tplarg"}},"i":0}}]}'>tplarg</span> }} }-</p>
12564 !! end
12565
12566 !! test
12567 Preprocessor precedence 19: break syntax
12568 !! options
12569 parsoid=wt2html
12570 !! wikitext
12571 -{{
12572 !! html/php
12573 <p>-{{
12574 </p>
12575 !! html/parsoid
12576 <p>-{{</p>
12577 !! end
12578
12579 ###
12580 ### Token Stream Patcher tests
12581 ###
12582 ### These tests won't always pass wt2wt and other modes because
12583 ### on serialization, the table will be output on a new line.
12584 ### For now, we are blacklisting them, and using this to test selser.
12585 ###
12586
12587 !!test
12588 1. Table tag in SOL posn. should get reparsed correctly with valid TSR
12589 !!options
12590 parsoid=wt2html,wt2wt
12591 !!wikitext
12592 {{echo|}}{| width = '100%'
12593 |foo
12594 |}
12595 !!html/parsoid
12596 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":""}},"i":0}}]}'></span><table width="100%">
12597 <tbody><tr><td>foo</td></tr>
12598 </tbody></table>
12599 !!end
12600
12601 ## We used to, but no longer wt2wt this test since the default serializer
12602 ## will normalize the include directives to serialize on their own line.
12603 ## Selser will take care of preserving formatting in scenarios where they
12604 ## intermingled with other wikitext.
12605 !!test
12606 2. Table tag in SOL posn. should get reparsed correctly with valid TSR
12607 !!options
12608 parsoid=wt2html
12609 !!wikitext
12610 <includeonly>a</includeonly>{| {{{b}}}
12611 |c
12612 |}
12613 !!html/parsoid
12614 <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":""}]]}'>
12615 <tbody><tr><td>c</td></tr>
12616 </tbody></table>
12617 !!end
12618
12619 !! test
12620 Table wikitext syntax outside wiki-tables
12621 !! wikitext
12622 a
12623 |+ not a caption
12624 ! not a table heading
12625 |- not a table row
12626 | not a table cell
12627 | class="foo bar" | baz
12628 b
12629 |}
12630 |-
12631 c
12632 !! html
12633 <p>a
12634 |+ not a caption
12635 ! not a table heading
12636 |- not a table row
12637 | not a table cell
12638 | class="foo bar" | baz
12639 b
12640 |}
12641 |-
12642 c
12643 </p>
12644 !! end
12645
12646 ###
12647 ### Testing parsing of templates where a template arg
12648 ### has the same name as the template itself.
12649 ###
12650
12651 !! article
12652 Template:quote
12653 !! text
12654 {{{quote|{{{1}}}}}}
12655 !! endarticle
12656
12657 !!test
12658 Templates: Template Name/Arg clash: 1. Use of positional param
12659 !! wikitext
12660 {{quote|foo}}
12661 !! html
12662 <p>foo
12663 </p>
12664 !!end
12665
12666 !!test
12667 Templates: Template Name/Arg clash: 2. Use of named param
12668 !! wikitext
12669 {{quote|quote=foo}}
12670 !! html
12671 <p>foo
12672 </p>
12673 !!end
12674
12675 !!test
12676 Templates: Template Name/Arg clash: 3. Use of named param with empty input
12677 !! wikitext
12678 {{quote|quote}}
12679 !! html
12680 <p>quote
12681 </p>
12682 !!end
12683
12684 ###
12685 ### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
12686 ###
12687
12688 !!test
12689 Templates: 1. Simple use
12690 !! wikitext
12691 {{echo|Foo}}
12692 !! html
12693 <p>Foo
12694 </p>
12695 !!end
12696
12697 !!test
12698 Templates: 2. Inside a block tag
12699 !! wikitext
12700 <div>{{echo|Foo}}</div>
12701 <blockquote>{{echo|Foo}}</blockquote>
12702 !! html
12703 <div>Foo</div>
12704 <blockquote>Foo</blockquote>
12705
12706 !! html+tidy
12707 <div>Foo</div>
12708 <blockquote><p>Foo</p></blockquote>
12709 !!end
12710
12711 !!test
12712 Templates: P-wrapping: 1a. Templates on consecutive lines
12713 !! wikitext
12714 {{echo|Foo}}
12715 {{echo|bar}}
12716 !! html
12717 <p>Foo
12718 bar
12719 </p>
12720 !!end
12721
12722 !!test
12723 Templates: P-wrapping: 1b. Templates on consecutive lines
12724 !! wikitext
12725 Foo
12726
12727 {{echo|bar}}
12728 {{echo|baz}}
12729 !! html
12730 <p>Foo
12731 </p><p>bar
12732 baz
12733 </p>
12734 !!end
12735
12736 !!test
12737 Templates: P-wrapping: 1c. Templates on consecutive lines
12738 !! wikitext
12739 {{echo|Foo}}
12740 {{echo|bar}} <div>baz</div>
12741 !! html
12742 <p>Foo
12743 </p>
12744 bar <div>baz</div>
12745
12746 !! html+tidy
12747 <p>Foo
12748 </p><p>
12749 bar </p><div>baz</div>
12750 !! end
12751
12752 !!test
12753 Templates: P-wrapping: 1d. Template preceded by comment-only line
12754 !!options
12755 parsoid
12756 !! wikitext
12757 <!-- foo -->
12758 {{echo|Bar}}
12759 !! html
12760 <!-- foo -->
12761
12762 <p about="#mwt223" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar"}},"i":0}}]}'>Bar</p>
12763 !!end
12764
12765 !!test
12766 Templates: Inline Text: 1. Multiple template uses
12767 !! wikitext
12768 {{echo|Foo}}bar{{echo|baz}}
12769 !! html
12770 <p>Foobarbaz
12771 </p>
12772 !!end
12773
12774 !!test
12775 Templates: Inline Text: 2. Back-to-back template uses
12776 !! wikitext
12777 {{echo|Foo}}{{echo|bar}}
12778 !! html
12779 <p>Foobar
12780 </p>
12781 !!end
12782
12783 !!test
12784 Templates: Block Tags: 1. Multiple template uses
12785 !! wikitext
12786 {{echo|<div>Foo</div>}}<div>bar</div>{{echo|<div>baz</div>}}
12787 !! html
12788 <div>Foo</div><div>bar</div><div>baz</div>
12789
12790 !!end
12791
12792 !!test
12793 Templates: Block Tags: 2. Back-to-back template uses
12794 !! wikitext
12795 {{echo|<div>Foo</div>}}{{echo|<div>bar</div>}}
12796 !! html
12797 <div>Foo</div><div>bar</div>
12798
12799 !!end
12800
12801 # This is an edge case relating to paragraph wrapping.
12802 !!test
12803 Templates: Correctly encapsulate templates producing </p> tag without a corresponding <p> tag
12804 !! wikitext
12805 {{echo|a
12806 b</p>}}
12807 !! html/parsoid
12808 <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
12809 b</p>
12810 !!end
12811
12812 !!test
12813 Templates: Links: 1. Simple example
12814 !! wikitext
12815 {{echo|[[Foo|bar]]}}
12816 !! html
12817 <p><a href="/wiki/Foo" title="Foo">bar</a>
12818 </p>
12819 !!end
12820
12821 !!test
12822 Templates: Links: 2. Generation of link href
12823 !! wikitext
12824 [[{{echo|Foo}}|bar]]
12825 !! html
12826 <p><a href="/wiki/Foo" title="Foo">bar</a>
12827 </p>
12828 !!end
12829
12830 !!test
12831 Templates: Links: 3. Generation of part of a link href
12832 !! wikitext
12833 [[Fo{{echo|o}}|bar]]
12834
12835 [[Foo{{echo|bar}}]]
12836
12837 [[Foo{{echo|bar}}baz]]
12838
12839 [[Foo{{echo|bar}}|bar]]
12840
12841 [[:Foo{{echo|bar}}]]
12842
12843 [[:Foo{{echo|bar}}|bar]]
12844 !! html
12845 <p><a href="/wiki/Foo" title="Foo">bar</a>
12846 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12847 </p><p><a href="/index.php?title=Foobarbaz&amp;action=edit&amp;redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a>
12848 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12849 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12850 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12851 </p>
12852 !!end
12853
12854 !!test
12855 Templates: Links: 4. Multiple templates generating link href
12856 !! wikitext
12857 [[{{echo|F}}{{echo|o}}ob{{echo|ar}}]]
12858 !! html
12859 <p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12860 </p>
12861 !!end
12862
12863 !!test
12864 Templates: Links: 5. Generation of link text
12865 !! wikitext
12866 [[Foo|{{echo|bar}}]]
12867 !! html
12868 <p><a href="/wiki/Foo" title="Foo">bar</a>
12869 </p>
12870 !!end
12871
12872 !!test
12873 Templates: Links: 5. Nested templates (only outermost template should be marked)
12874 !! wikitext
12875 {{echo|[[{{echo|Foo}}|bar]]}}
12876 !! html
12877 <p><a href="/wiki/Foo" title="Foo">bar</a>
12878 </p>
12879 !!end
12880
12881 !!test
12882 Templates: HTML Tag: 1. Generation of HTML attr. key
12883 !! wikitext
12884 <div {{echo|style}}="color:red;">foo</div>
12885 !! html
12886 <div style="color:red;">foo</div>
12887
12888 !!end
12889
12890 !!test
12891 Templates: HTML Tag: 2. Generation of HTML attr. value
12892 !! wikitext
12893 <div style={{echo|'color:red;'}}>foo</div>
12894 !! html
12895 <div style="color:red;">foo</div>
12896
12897 !!end
12898
12899 !!test
12900 Templates: HTML Tag: 3. Generation of HTML attr key and value
12901 !! wikitext
12902 <div {{echo|style}}={{echo|'color:red;'}}>foo</div>
12903 !! html
12904 <div style="color:red;">foo</div>
12905
12906 !!end
12907
12908 !!test
12909 Templates: HTML Tag: 4. Generation of starting piece of HTML attr value
12910 !! wikitext
12911 <div title="{{echo|This is a long title}} with just one piece templated">foo</div>
12912 !! html
12913 <div title="This is a long title with just one piece templated">foo</div>
12914
12915 !!end
12916
12917 !!test
12918 Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
12919 !! wikitext
12920 <div title="This is a long title with just {{echo|one piece}} templated">foo</div>
12921 !! html
12922 <div title="This is a long title with just one piece templated">foo</div>
12923
12924 !!end
12925
12926 !!test
12927 Templates: HTML Tag: 6. Generation of end piece of HTML attr value
12928 !! wikitext
12929 <div title="This is a long title with just one piece {{echo|templated}}">foo</div>
12930 !! html
12931 <div title="This is a long title with just one piece templated">foo</div>
12932
12933 !!end
12934
12935 # SSS FIXME: While it is great we added support for all this,
12936 # do we want to make this part of the spec? Maybe we want to
12937 # deprecate this kind of usage in the future?
12938 !!test
12939 Templates: HTML Tag: 7. Generation of partial attribute key string
12940 !! wikitext
12941 <div st{{echo|yle}}="color:red;">foo</div>
12942 !! html
12943 <div style="color:red;">foo</div>
12944
12945 !!end
12946
12947 !! test
12948 Templates: HTML Tag: 8. Template-generated attribute (k=v)
12949 !! wikitext
12950 <div {{echo|1=id="v1"}}>bar</div>
12951 !! html
12952 <div id="v1">bar</div>
12953
12954 !!end
12955
12956 !! test
12957 Templates: HTML Tag: 9. Multiple template-generated attributes
12958 !! wikitext
12959 <div {{echo|1=id="v1" title="foo"}}>bar</div>
12960 !! html
12961 <div id="v1" title="foo">bar</div>
12962
12963 !!end
12964
12965 !! test
12966 Templates: Support for templates generating attributes and content
12967 !! wikitext
12968 {| {{mixed_attr_content_template}}
12969 |-
12970 |bar
12971 |}
12972 !! html/php
12973 <table style="color:red;" title="T48811">
12974
12975 <tr>
12976 <td>foo
12977 </td></tr>
12978 <tr>
12979 <td>bar
12980 </td></tr></table>
12981
12982 !! html/parsoid
12983 <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|}"]}'>
12984 <tbody><tr>
12985 <td>foo</td></tr>
12986 <tr>
12987 <td>bar</td></tr>
12988 </tbody></table>
12989 !!end
12990
12991 !! article
12992 Template:attribute_from_template
12993 !! text
12994 class="123"
12995 !! endarticle
12996
12997 !! test
12998 Table cell with attribute before expanded attribute
12999 !! wikitext
13000 {|
13001 | align="center" {{attribute_from_template}} |456
13002 |}
13003 !! html/parsoid
13004 <table>
13005 <tbody><tr><td align="center" class="123" about="#mwt2" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"class","html":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&apos;{\"pi\":[[]],\"dsr\":[20,47,null,null]}&apos; data-mw=&apos;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"attribute_from_template\",\"href\":\"./Template:Attribute_from_template\"},\"params\":{},\"i\":0}}]}&apos;>class=\"123\"&lt;/span>"},{"html":""}]]}'>456</td></tr>
13006 </tbody></table>
13007 !! end
13008
13009 !! test
13010 1. Entities and nowikis inside templated attributes should be handled correctly
13011 !! wikitext
13012 <div {{echo|style{{=}}"background:&#35;f9f9f9;"}}>foo</div>
13013 !! html/php
13014 <div style="background:#f9f9f9;">foo</div>
13015
13016 !! html/parsoid
13017 <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>
13018 !! end
13019
13020 !! test
13021 2. Entities and nowikis inside templated attributes should be handled correctly
13022 !! wikitext
13023 {|
13024 |{{table_attribs_3}}
13025 |}
13026 !! html/php
13027 <table>
13028 <tr>
13029 <td style="background:#f9f9f9;">Foo
13030 </td></tr></table>
13031
13032 !! html/parsoid
13033 <table>
13034 <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>
13035 </tbody></table>
13036 !! end
13037
13038 !! test
13039 3. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13040 !! wikitext
13041 {{tbl-start}}
13042 |{{table_attribs_3}}
13043 {{tbl-end}}
13044 !! html/php
13045 <table>
13046 <tr>
13047 <td style="background:#f9f9f9;">Foo
13048 </td></tr></table>
13049
13050 !! html/parsoid
13051 <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}}]}'>
13052 <tbody><tr><td style="background:#f9f9f9;">Foo</td></tr>
13053 </tbody></table>
13054 !! end
13055
13056 # T107622
13057 !! test
13058 4. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13059 !! wikitext
13060 {|
13061 |{{table_attribs_6}} hi
13062 |}
13063 !! html/php
13064 <table>
13065 <tr>
13066 <td style="background: red;">hi
13067 </td></tr></table>
13068
13069 !! html/parsoid
13070 <table>
13071 <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>
13072 </tbody></table>
13073 !! end
13074
13075 !!test
13076 Templates: HTML Tables: 1. Generating start of a HTML table
13077 !! wikitext
13078 {{echo|<table><tr><td>foo</td>}}</tr></table>
13079 !! html
13080 <table><tr><td>foo</td></tr></table>
13081
13082 !!end
13083
13084 !!test
13085 Templates: HTML Tables: 2a. Generating middle of a HTML table
13086 !! wikitext
13087 <table><tr>{{echo|<td>foo</td>}}</tr></table>
13088 !! html
13089 <table><tr><td>foo</td></tr></table>
13090
13091 !!end
13092
13093 !!test
13094 Templates: HTML Tables: 2b. Generating middle of a HTML table
13095 !! wikitext
13096 <table>{{echo|<tr><td>foo</td></tr>}}</table>
13097 !! html
13098 <table><tr><td>foo</td></tr></table>
13099
13100 !!end
13101
13102 !!test
13103 Templates: HTML Tables: 3. Generating end of a HTML table
13104 !! wikitext
13105 <table><tr>{{echo|<td>foo</td></tr></table>}}
13106 !! html
13107 <table><tr><td>foo</td></tr></table>
13108
13109 !!end
13110
13111 !!test
13112 Templates: HTML Tables: 4a. Generating a single tag of a HTML table
13113 !! wikitext
13114 {{echo|<table>}}<tr><td>foo</td></tr></table>
13115 !! html
13116 <table><tr><td>foo</td></tr></table>
13117
13118 !!end
13119
13120 !!test
13121 Templates: HTML Tables: 4b. Generating a single tag of a HTML table
13122 !! wikitext
13123 <table>{{echo|<tr>}}<td>foo</td></tr></table>
13124 !! html
13125 <table><tr><td>foo</td></tr></table>
13126
13127 !!end
13128
13129 !!test
13130 Templates: HTML Tables: 4c. Generating a single tag of a HTML table
13131 !! wikitext
13132 <table><tr>{{echo|<td>}}foo</td></tr></table>
13133 !! html
13134 <table><tr><td>foo</td></tr></table>
13135
13136 !!end
13137
13138 !!test
13139 Templates: HTML Tables: 4d. Generating a single tag of a HTML table
13140 !! wikitext
13141 <table><tr><td>foo{{echo|</td>}}</tr></table>
13142 !! html
13143 <table><tr><td>foo</td></tr></table>
13144
13145 !!end
13146
13147 !!test
13148 Templates: HTML Tables: 4e. Generating a single tag of a HTML table
13149 !! wikitext
13150 <table><tr><td>foo</td>{{echo|</tr>}}</table>
13151 !! html
13152 <table><tr><td>foo</td></tr></table>
13153
13154 !!end
13155
13156 !!test
13157 Templates: HTML Tables: 4f. Generating a single tag of a HTML table
13158 !! wikitext
13159 <table><tr><td>foo</td></tr>{{echo|</table>}}
13160 !! html
13161 <table><tr><td>foo</td></tr></table>
13162
13163 !!end
13164
13165 !!test
13166 Templates: HTML Tables: 5. Proper fostering of categories from inside
13167 !!options
13168 parsoid=wt2html,wt2wt
13169 !! wikitext
13170 <table>[[Category:foo1]]<tr><td>foo</td></tr></table>
13171 <!--Two categories (T52330)-->
13172 <table>[[Category:bar1]][[Category:bar2]]<tr><td>foo</td></tr></table>
13173 !! html
13174 <link rel="mw:PageProp/Category" href="./Category:Foo1"><table><tbody><tr><td>foo</td></tr></tbody></table>
13175 <!--Two categories (T52330)-->
13176 <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>
13177 !!end
13178
13179 !!test
13180 Templates: Wiki Tables: 1a. Fostering of entire template content
13181 !! wikitext
13182 {|
13183 {{echo|a}}
13184 |}
13185 !! html
13186 <table>
13187 a
13188 <tr><td></td></tr></table>
13189
13190 !! html/php+tidy
13191
13192 a
13193 <table><tbody><tr><td></td></tr></tbody></table>
13194 !! html/parsoid
13195 <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">
13196
13197 </table>
13198 !! end
13199
13200 !!test
13201 Templates: Wiki Tables: 1b. Fostering of entire template content
13202 !! wikitext
13203 {|
13204 {{echo|<div>}}
13205 foo
13206 {{echo|</div>}}
13207 |}
13208 !! html
13209 <table>
13210 <div>
13211 <p>foo
13212 </p>
13213 </div>
13214 <tr><td></td></tr></table>
13215
13216 !! html/php+tidy
13217 <div>
13218 <p>foo
13219 </p>
13220 </div><table>
13221
13222 <tbody><tr><td></td></tr></tbody></table>
13223 !! html/parsoid
13224 <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|}"]}'>
13225 <p>foo</p>
13226 </div><table about="#mwt3">
13227
13228 </table>
13229 !! end
13230
13231 !!test
13232 Templates: Wiki Tables: 2. Fostering of partial template content
13233 !! wikitext
13234 {|
13235 {{echo|a
13236 <div>b</div>}}
13237 |}
13238 !! html
13239 <table>
13240 a
13241 <div>b</div>
13242 <tr><td></td></tr></table>
13243
13244 !! html/php+tidy
13245
13246 a
13247 <div>b</div><table>
13248 <tbody><tr><td></td></tr></tbody></table>
13249 !! html/parsoid
13250 <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">
13251
13252
13253 </table>
13254 !! end
13255
13256 !!test
13257 Templates: Wiki Tables: 3. td-content via multiple templates
13258 !! wikitext
13259 {|
13260 {{echo|{{pipe}}a}}{{echo|b}}
13261 |}
13262 !! html
13263 <table>
13264 <tr>
13265 <td>ab
13266 </td></tr></table>
13267
13268 !!end
13269
13270 !!test
13271 Templates: Wiki Tables: 4. Templated tags, no content
13272 !! wikitext
13273 {{tbl-start}}
13274 {{tbl-end}}
13275 !! html
13276 <table>
13277 <tr><td></td></tr></table>
13278
13279 !!end
13280
13281 !!test
13282 Templates: Wiki Tables: 5. Templated tags, regular td-tags
13283 !! wikitext
13284 {{tbl-start}}
13285 |foo
13286 {{tbl-end}}
13287 !! html
13288 <table>
13289 <tr>
13290 <td>foo
13291 </td></tr></table>
13292
13293 !!end
13294
13295 !!test
13296 Templates: Wiki Tables: 6. Templated tags, templated td-tags
13297 !! wikitext
13298 {{tbl-start}}
13299 {{!}}foo
13300 {{tbl-end}}
13301 !! html
13302 <table>
13303 <tr>
13304 <td>foo
13305 </td></tr></table>
13306
13307 !!end
13308
13309 ## This test case is very specific to Parsoid's internals
13310 ## and is hence only tested for Parsoid's code. Parsoid uses
13311 ## a <meta> marker tag for <ref> tags and they are expanded
13312 ## much later. We are verifying that this <meta> tag usage
13313 ## doesn't prevent foster parenting.
13314 !!test
13315 Templates: Wiki Tables: 7. Fosterable <ref>s should get fostered
13316 !!wikitext
13317 {{PartialTable}}<ref>foo</ref>
13318 |}
13319
13320 <references />
13321 !!html/parsoid
13322 <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">
13323 <tbody>
13324 </tbody></table>
13325
13326 <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>
13327 !!end
13328
13329 !! test
13330 Templates: Wiki Tables: 8. Fosterable meta-tags should get fostered
13331 !! wikitext
13332 {{echo|
13333 {{{!}}
13334 {{!}}-}}
13335 <onlyinclude>
13336 |foo
13337 </onlyinclude>
13338 {{!}}}
13339 !! html/parsoid
13340 <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{{!}}}"]}'>
13341 </span><meta typeof="mw:Includes/OnlyInclude" about="#mwt1"/><table about="#mwt1">
13342 <tbody><tr>
13343
13344 <td>foo
13345 <meta typeof="mw:Includes/OnlyInclude/End"/></td></tr>
13346 </tbody></table>
13347 !! end
13348
13349 !!test
13350 Templates: Lists: Multi-line list-items via templates
13351 !! wikitext
13352 *{{echo|a {{nonexistent|
13353 unused}}}}
13354 *{{echo|b {{nonexistent|
13355 unused}}}}
13356 !! html
13357 <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>
13358 <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>
13359
13360 !!end
13361
13362 !!test
13363 Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo)
13364 !! wikitext
13365 {{echo|''a}}{{echo|b''c''d}}{{echo|''e}}
13366 !! html
13367 <p><i>ab</i>c<i>d</i>e
13368 </p>
13369 !!end
13370
13371 !!test
13372 Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span)
13373 (PHP parser generates misnested html)
13374 !! wikitext
13375 {{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}}
13376 !! html/parsoid
13377 <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>
13378 !!end
13379
13380 !!test
13381 Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div)
13382 (PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s)
13383 !! options
13384 parsoid=wt2html,wt2wt
13385 !! wikitext
13386 {{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}}
13387 !! html
13388 <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>
13389 <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>
13390 <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>
13391 !!end
13392
13393 !!test
13394 Templates: Ugly nesting: 4. Divs opened/closed across templates
13395 !! wikitext
13396 a<div>b{{echo|c</div>d}}e
13397 !! html
13398 a<div>bc</div>de
13399
13400 !! html+tidy
13401 <p>a</p><div>bc</div><p>de
13402 </p>
13403 !! end
13404
13405 !! test
13406 Templates: Ugly templates: 3. newline-only template parameter
13407 !! wikitext
13408 foo {{echo|
13409 }}
13410 !! html
13411 <p>foo
13412 </p>
13413 !! end
13414
13415 # This looks like a bug: a single newline triggers p/br for some reason.
13416 !! test
13417 Templates: Ugly templates: 4. newline-only template parameter inconsistency
13418 !! wikitext
13419 {{echo|
13420 }}
13421 !! html
13422 <p><br />
13423 </p>
13424 !! end
13425
13426 # T66017 -- ugly wikitext with fostered content generates two template ranges that
13427 # have a true overlap (T1-start - T2-start - T1-end - T2-end).
13428 !! test
13429 Templates: Ugly templates: 5. Template encapsulation test: Non-trivial overlap of template ranges is properly handled
13430 !! wikitext
13431 {{echo|<table>}}
13432 {{echo|<div>foo}}
13433 {{echo|</table>}}
13434 !! html/parsoid
13435 <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
13436 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13437 </table>
13438 !! end
13439
13440 # T66017 -- ugly wikitext with fostered content generates two template ranges
13441 # that are "identical" and generate nesting cycles in the algorithm
13442 !! test
13443 Templates: Ugly templates: 6. Template encapsulation test: Cyclical nesting of template ranges is properly handled
13444 !! wikitext
13445 {{echo|<table><tr><td><table>}}
13446 {{echo|<div>}}
13447 {{echo|</div>}}
13448 !! html/parsoid
13449 <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"}'>
13450 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13451 </table></td></tr></tbody></table>
13452 !! end
13453
13454 !! test
13455 Templates: Parameters substituted at the top-level
13456 !! wikitext
13457 {{{foo|''who'' {{echo|me}}? '''never!'''}}}
13458
13459 {{{foo|bar|baz}}}
13460 !! html/php
13461 <p><i>who</i> me? <b>never!</b>
13462 </p><p>bar
13463 </p>
13464 !! html/parsoid
13465 <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>
13466
13467 <p about="#mwt3" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"foo"},"params":{"1":{"wt":"bar"},"2":{"wt":"baz"}},"i":0}}]}'>bar</p>
13468 !! end
13469
13470 !! test
13471 Templates: Param with empty arg in the final position
13472 !! wikitext
13473 {{{hi|}}}
13474 !! html/parsoid
13475 <span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"hi"},"params":{"1":{"wt":""}},"i":0}}]}'></span>
13476 !! end
13477
13478 !!test
13479 Parser Functions: 1. Simple example
13480 !! wikitext
13481 {{uc:foo}}
13482 !! html
13483 <p>FOO
13484 </p>
13485 !!end
13486
13487 !!test
13488 Parser Functions: 2. Nested use (only outermost should be marked up)
13489 !! wikitext
13490 {{uc:{{lc:FOO}}}}
13491 !! html
13492 <p>FOO
13493 </p>
13494 !!end
13495
13496 ## Note that the templates inside the references are not wrapped
13497 !! test
13498 Template nested in extension tag in template
13499 !! wikitext
13500 {{echo|hi<ref>[[ho|{{echo|hi}}]]</ref>}}
13501 {{echo|hi<ref>[http://test.com?q={{echo|ho}}]</ref>}}
13502 <references />
13503 !! html/parsoid
13504 <p><span about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi&lt;ref>[[ho|{{echo|hi}}]]&lt;/ref>"}},"i":0}}]}'>hi</span><sup about="#mwt2" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","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></sup>
13505 <span about="#mwt7" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi&lt;ref>[http://test.com?q={{echo|ho}}]&lt;/ref>"}},"i":0}}]}'>hi</span><sup about="#mwt7" class="mw-ref" id="cite_ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-2"},"attrs":{}}'><a href="./Main_Page#cite_note-2" style="counter-reset: mw-Ref 2;"><span class="mw-reflink-text">[2]</span></a></sup></p>
13506 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt10" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text"><a rel="mw:WikiLink" href="./Ho" title="Ho" data-parsoid='{"stx":"piped","a":{"href":"./Ho"},"sa":{"href":"ho"}}'>hi</a></span></li><li about="#cite_note-2" id="cite_note-2"><a href="./Main_Page#cite_ref-2" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-2" class="mw-reference-text"><a typeof="mw:ExpandedAttrs" about="#mwt11" rel="mw:ExtLink" class="external autonumber" href="http://test.com?q=ho" data-mw='{"attribs":[[{"txt":"href"},{"html":"http://test.com?q=ho"}]]}'></a></span></li></ol>
13507 !! end
13508
13509 ###
13510 ### Pre-save transform tests
13511 ###
13512 !! test
13513 pre-save transform: subst:
13514 !! options
13515 pst
13516 !! wikitext
13517 {{subst:test}}
13518 !! html/php
13519 This is a test template
13520 !! end
13521
13522 !! test
13523 pre-save transform: normal template
13524 !! options
13525 pst
13526 !! wikitext
13527 {{test}}
13528 !! html/php
13529 {{test}}
13530 !! end
13531
13532 !! test
13533 pre-save transform: nonexistent template
13534 !! options
13535 pst
13536 !! wikitext
13537 {{thistemplatedoesnotexist}}
13538 !! html/php
13539 {{thistemplatedoesnotexist}}
13540 !! end
13541
13542 !! test
13543 pre-save transform: subst magic variables
13544 !! options
13545 pst
13546 !! wikitext
13547 {{subst:SITENAME}}
13548 !! html/php
13549 MediaWiki
13550 !! end
13551
13552 # This is T2089, which I fixed. -- wtm
13553 !! test
13554 pre-save transform: subst: templates with parameters
13555 !! options
13556 pst
13557 !! wikitext
13558 {{subst:paramtest|param="something else"}}
13559 !! html/php
13560 This is a test template with parameter "something else"
13561 !! end
13562
13563 !! article
13564 Template:nowikitest
13565 !! text
13566 <nowiki>'''not wiki'''</nowiki>
13567 !! endarticle
13568
13569 !! test
13570 pre-save transform: nowiki in subst (T3188)
13571 !! options
13572 pst
13573 !! wikitext
13574 {{subst:nowikitest}}
13575 !! html/php
13576 <nowiki>'''not wiki'''</nowiki>
13577 !! end
13578
13579 !! article
13580 Template:commenttest
13581 !! text
13582 This template has <!-- a comment --> in it.
13583 !! endarticle
13584
13585 !! test
13586 pre-save transform: comment in subst (T3936)
13587 !! options
13588 pst
13589 !! wikitext
13590 {{subst:commenttest}}
13591 !! html/php
13592 This template has <!-- a comment --> in it.
13593 !! end
13594
13595 !! test
13596 pre-save transform: unclosed tag
13597 !! options
13598 pst
13599 !! wikitext
13600 <nowiki>'''not wiki'''
13601 !! html/php
13602 <nowiki>'''not wiki'''
13603 !! end
13604
13605 !! test
13606 pre-save transform: mixed tag case
13607 !! options
13608 pst
13609 !! wikitext
13610 <NOwiki>'''not wiki'''</noWIKI>
13611 !! html/php
13612 <NOwiki>'''not wiki'''</noWIKI>
13613 !! end
13614
13615 !! test
13616 pre-save transform: unclosed comment in <nowiki>
13617 !! options
13618 pst
13619 !! wikitext
13620 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13621 !! html/php
13622 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13623 !!end
13624
13625 # Leading @ in this template definition works around a limitation
13626 # in parsoid's parserTests which otherwise strips the <span> from the
13627 # result (confusing it for a template wrapper)
13628 !! article
13629 Template:dangerous
13630 !!text
13631 @<span onmouseover="alert('crap')">Oh no</span>
13632 !!endarticle
13633
13634 !!test
13635 (confirming safety of fix for subst T3936)
13636 !! wikitext
13637 {{Template:dangerous}}
13638 !! html
13639 <p>@<span>Oh no</span>
13640 </p>
13641 !! end
13642
13643 !! test
13644 pre-save transform: comment containing gallery (T7024)
13645 !! options
13646 pst
13647 !! wikitext
13648 <!-- <gallery>data</gallery> -->
13649 !! html/php
13650 <!-- <gallery>data</gallery> -->
13651 !!end
13652
13653 !! test
13654 pre-save transform: comment containing extension
13655 !! options
13656 pst
13657 !! wikitext
13658 <!-- <tag>data</tag> -->
13659 !! html/php
13660 <!-- <tag>data</tag> -->
13661 !!end
13662
13663 !! test
13664 pre-save transform: comment containing nowiki
13665 !! options
13666 pst
13667 !! wikitext
13668 <!-- <nowiki>data</nowiki> -->
13669 !! html/php
13670 <!-- <nowiki>data</nowiki> -->
13671 !!end
13672
13673 !! test
13674 pre-save transform: <noinclude> in subst (T5298)
13675 !! options
13676 pst
13677 !! wikitext
13678 {{subst:Includes}}
13679 !! html/php
13680 Foobar
13681 !! end
13682
13683 !! test
13684 pre-save transform: <onlyinclude> in subst (T5298)
13685 !! options
13686 pst
13687 !! wikitext
13688 {{subst:Includes2}}
13689 !! html/php
13690 Foo
13691 !! end
13692
13693 !! article
13694 Template:SubstTest
13695 !!text
13696 {{<includeonly>subst:</includeonly>Includes}}
13697 !! endarticle
13698
13699 !! article
13700 Template:SafeSubstTest
13701 !! text
13702 {{<includeonly>safesubst:</includeonly>Includes}}
13703 !! endarticle
13704
13705 !! test
13706 T24297: safesubst: works during PST
13707 !! options
13708 pst
13709 !! wikitext
13710 {{subst:SafeSubstTest}}{{safesubst:SubstTest}}
13711 !! html/php
13712 FoobarFoobar
13713 !! end
13714
13715 !! test
13716 T24297: safesubst: works during normal parse
13717 !! wikitext
13718 {{SafeSubstTest}}
13719 !! html
13720 <p>Foobar
13721 </p>
13722 !! end
13723
13724 !! test
13725 subst: does not work during normal parse
13726 !! wikitext
13727 {{SubstTest}}
13728 !! html
13729 <p>{{subst:Includes}}
13730 </p>
13731 !! end
13732
13733 !! test
13734 pre-save transform: context links ("pipe trick")
13735 !! options
13736 pst
13737 !! wikitext
13738 [[Article (context)|]]
13739 [[Bar:Article|]]
13740 [[:Bar:Article|]]
13741 [[Bar:Article (context)|]]
13742 [[:Bar:Article (context)|]]
13743 [[|Article]]
13744 [[|Article (context)]]
13745 [[Bar:X (Y) Z|]]
13746 [[:Bar:X (Y) Z|]]
13747 !! html/php
13748 [[Article (context)|Article]]
13749 [[Bar:Article|Article]]
13750 [[:Bar:Article|Article]]
13751 [[Bar:Article (context)|Article]]
13752 [[:Bar:Article (context)|Article]]
13753 [[Article]]
13754 [[Article (context)]]
13755 [[Bar:X (Y) Z|X (Y) Z]]
13756 [[:Bar:X (Y) Z|X (Y) Z]]
13757 !! end
13758
13759 !! test
13760 pre-save transform: context links ("pipe trick") with interwiki prefix
13761 !! options
13762 pst
13763 !! wikitext
13764 [[interwiki:Article|]]
13765 [[:interwiki:Article|]]
13766 [[interwiki:Bar:Article|]]
13767 [[:interwiki:Bar:Article|]]
13768 !! html/php
13769 [[interwiki:Article|Article]]
13770 [[:interwiki:Article|Article]]
13771 [[interwiki:Bar:Article|Bar:Article]]
13772 [[:interwiki:Bar:Article|Bar:Article]]
13773 !! end
13774
13775 !! test
13776 pre-save transform: context links ("pipe trick") with parens in title
13777 !! options
13778 pst title=[[Somearticle (context)]]
13779 !! wikitext
13780 [[|Article]]
13781 !! html/php
13782 [[Article (context)|Article]]
13783 !! end
13784
13785 !! test
13786 pre-save transform: context links ("pipe trick") with comma in title
13787 !! options
13788 pst title=[[Someplace, Somewhere]]
13789 !! wikitext
13790 [[|Otherplace]]
13791 [[Otherplace, Elsewhere|]]
13792 [[Otherplace, Elsewhere, Anywhere|]]
13793 !! html/php
13794 [[Otherplace, Somewhere|Otherplace]]
13795 [[Otherplace, Elsewhere|Otherplace]]
13796 [[Otherplace, Elsewhere, Anywhere|Otherplace]]
13797 !! end
13798
13799 !! test
13800 pre-save transform: context links ("pipe trick") with parens and comma
13801 !! options
13802 pst title=[[Someplace (IGNORED), Somewhere]]
13803 !! wikitext
13804 [[|Otherplace]]
13805 [[Otherplace (place), Elsewhere|]]
13806 !! html/php
13807 [[Otherplace, Somewhere|Otherplace]]
13808 [[Otherplace (place), Elsewhere|Otherplace]]
13809 !! end
13810
13811 !! test
13812 pre-save transform: context links ("pipe trick") with comma and parens
13813 !! options
13814 pst title=[[Who, me? (context)]]
13815 !! wikitext
13816 [[|Yes, you.]]
13817 [[Me, Myself, and I (1937 song)|]]
13818 !! html/php
13819 [[Yes, you. (context)|Yes, you.]]
13820 [[Me, Myself, and I (1937 song)|Me, Myself, and I]]
13821 !! end
13822
13823 !! test
13824 pre-save transform: context links ("pipe trick") with namespace
13825 !! options
13826 pst title=[[Ns:Somearticle]]
13827 !! wikitext
13828 [[|Article]]
13829 !! html/php
13830 [[Ns:Article|Article]]
13831 !! end
13832
13833 !! test
13834 pre-save transform: context links ("pipe trick") with namespace and parens
13835 !! options
13836 pst title=[[Ns:Somearticle (context)]]
13837 !! wikitext
13838 [[|Article]]
13839 !! html/php
13840 [[Ns:Article (context)|Article]]
13841 !! end
13842
13843 !! test
13844 pre-save transform: context links ("pipe trick") with namespace and comma
13845 !! options
13846 pst title=[[Ns:Somearticle, Context, Whatever]]
13847 !! wikitext
13848 [[|Article]]
13849 !! html/php
13850 [[Ns:Article, Context, Whatever|Article]]
13851 !! end
13852
13853 !! test
13854 pre-save transform: context links ("pipe trick") with namespace, comma and parens
13855 !! options
13856 pst title=[[Ns:Somearticle, Context (context)]]
13857 !! wikitext
13858 [[|Article]]
13859 !! html/php
13860 [[Ns:Article (context)|Article]]
13861 !! end
13862
13863 !! test
13864 pre-save transform: context links ("pipe trick") with namespace, parens and comma
13865 !! options
13866 pst title=[[Ns:Somearticle (IGNORED), Context]]
13867 !! wikitext
13868 [[|Article]]
13869 !! html/php
13870 [[Ns:Article, Context|Article]]
13871 !! end
13872
13873 !! test
13874 pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, T32149)
13875 !! options
13876 pst
13877 !! wikitext
13878 [[Article(context)|]]
13879 [[Bar:Article(context)|]]
13880 [[:Bar:Article(context)|]]
13881 [[|Article(context)]]
13882 [[Bar:X(Y)Z|]]
13883 [[:Bar:X(Y)Z|]]
13884 !! html/php
13885 [[Article(context)|Article]]
13886 [[Bar:Article(context)|Article]]
13887 [[:Bar:Article(context)|Article]]
13888 [[Article(context)]]
13889 [[Bar:X(Y)Z|X(Y)Z]]
13890 [[:Bar:X(Y)Z|X(Y)Z]]
13891 !! end
13892
13893 !! test
13894 pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, T32149)
13895 !! options
13896 pst
13897 !! wikitext
13898 [[Article (context)|]]
13899 [[Bar:Article (context)|]]
13900 [[:Bar:Article (context)|]]
13901 [[|Article (context)]]
13902 [[Bar:X (Y) Z|]]
13903 [[:Bar:X (Y) Z|]]
13904 !! html/php
13905 [[Article (context)|Article]]
13906 [[Bar:Article (context)|Article]]
13907 [[:Bar:Article (context)|Article]]
13908 [[Article (context)]]
13909 [[Bar:X (Y) Z|X (Y) Z]]
13910 [[:Bar:X (Y) Z|X (Y) Z]]
13911 !! end
13912
13913 !! test
13914 pre-save transform: context links ("pipe trick") with parens and no space (Korean style, T32149)
13915 !! options
13916 pst
13917 !! wikitext
13918 [[Article(context)|]]
13919 [[Bar:Article(context)|]]
13920 [[:Bar:Article(context)|]]
13921 [[|Article(context)]]
13922 [[Bar:X(Y)Z|]]
13923 [[:Bar:X(Y)Z|]]
13924 !! html/php
13925 [[Article(context)|Article]]
13926 [[Bar:Article(context)|Article]]
13927 [[:Bar:Article(context)|Article]]
13928 [[Article(context)]]
13929 [[Bar:X(Y)Z|X(Y)Z]]
13930 [[:Bar:X(Y)Z|X(Y)Z]]
13931 !! end
13932
13933 !! test
13934 pre-save transform: context links ("pipe trick") with commas (T23660)
13935 !! options
13936 pst
13937 !! wikitext
13938 [[Article (context), context|]]
13939 [[Article (context),context|]]
13940 [[Bar:Article (context), context|]]
13941 [[Bar:Article (context),context|]]
13942 [[:Bar:Article (context), context|]]
13943 [[:Bar:Article (context),context|]]
13944 !! html/php
13945 [[Article (context), context|Article]]
13946 [[Article (context),context|Article]]
13947 [[Bar:Article (context), context|Article]]
13948 [[Bar:Article (context),context|Article]]
13949 [[:Bar:Article (context), context|Article]]
13950 [[:Bar:Article (context),context|Article]]
13951 !! end
13952
13953 !! test
13954 Parsoid: backwards pipe trick
13955 !! wikitext
13956 [[|'''bar''']]
13957 !! html/php
13958 <p>[[|<b>bar</b>]]
13959 </p>
13960 !! html/parsoid
13961 <p>[[|<b>bar</b>]]</p>
13962 !! end
13963
13964 !! test
13965 pre-save transform: trim trailing empty lines
13966 !! options
13967 pst
13968 !! wikitext
13969 Empty lines are trimmed
13970
13971
13972
13973
13974 !! html/php
13975 Empty lines are trimmed
13976 !! end
13977
13978 !! test
13979 pre-save transform: Signature expansion
13980 !! options
13981 pst
13982 !! wikitext
13983 * ~~~
13984 * ~~~~
13985 * ~~~~~
13986 * <noinclude>~~~</noinclude>
13987 * <includeonly>~~~</includeonly>
13988 * <onlyinclude>~~~</onlyinclude>
13989 !! html/php
13990 * [[Special:Contributions/127.0.0.1|127.0.0.1]]
13991 * [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
13992 * 00:02, 1 January 1970 (UTC)
13993 * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
13994 * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
13995 * <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>
13996 !! end
13997
13998
13999 !! test
14000 ParserOutput flags from signature expansion (T84843)
14001 !! options
14002 pst
14003 showflags
14004 !! wikitext
14005 ~~~~
14006 !! html/php
14007 [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
14008 flags=user-signature
14009 !! end
14010
14011
14012 !! test
14013 pre-save transform: Signature expansion in nowiki tags (T2093)
14014 !! options
14015 pst disabled
14016 !! wikitext
14017 Shall not expand:
14018
14019 <nowiki>~~~~</nowiki>
14020
14021 <includeonly><nowiki>~~~~</nowiki></includeonly>
14022
14023 <noinclude><nowiki>~~~~</nowiki></noinclude>
14024
14025 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14026
14027 {{subst:Foo}} shall be converted to FOO
14028
14029 As well as inside noinclude/onlyinclude
14030 <noinclude>{{subst:Foo}}</noinclude>
14031 <onlyinclude>{{subst:Foo}}</onlyinclude>
14032
14033 But not inside includeonly
14034 <includeonly>{{subst:Foo}}</includeonly>
14035 !! html/php
14036 Shall not expand:
14037
14038 <nowiki>~~~~</nowiki>
14039
14040 <includeonly><nowiki>~~~~</nowiki></includeonly>
14041
14042 <noinclude><nowiki>~~~~</nowiki></noinclude>
14043
14044 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14045
14046 FOO shall be converted to FOO
14047
14048 As well as inside noinclude/onlyinclude
14049 <noinclude>FOO</noinclude>
14050 <onlyinclude>FOO</onlyinclude>
14051
14052 But not inside includeonly
14053 <includeonly>{{subst:Foo}}</includeonly>
14054 !! end
14055
14056 !! test
14057 Parsoid: Recognize nowiki with trailing space in tags
14058 !! options
14059 parsoid=wt2html
14060 !! wikitext
14061 <nowiki ><div>[[foo]]</nowiki >
14062
14063 a<nowiki / >b
14064
14065 c<nowiki />d
14066
14067 e<nowiki/ >f
14068 !! html
14069 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
14070 <p>ab</p>
14071 <p>cd</p>
14072 <p>ef</p>
14073 !! end
14074
14075 !! test
14076 Parsoid: Recognize nowiki with odd capitalization
14077 !! options
14078 parsoid=wt2html
14079 !! wikitext
14080 <noWikI ><div>[[foo]]</Nowiki >
14081 !! html
14082 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
14083 !! end
14084
14085
14086 !! test
14087 Parsoid: Escape nowiki with trailing space in tags
14088 !! options
14089 parsoid=html2wt
14090 !! html/parsoid
14091 <p>&lt;nowiki &gt; foo &lt/nowiki ></p>
14092 <p>a&lt;nowiki /&gt;b</p>
14093 <p>c&lt;nowiki/ &gt;d</p>
14094 !! wikitext
14095 &lt;nowiki &gt; foo &lt;/nowiki &gt;
14096
14097 a&lt;nowiki /&gt;b
14098
14099 c&lt;nowiki/ &gt;d
14100 !! end
14101
14102 !! test
14103 Parsoid: Escape weird noWikI capitalizations
14104 !! options
14105 parsoid=html2wt
14106 !! html/parsoid
14107 <p>&lt;noWikI &gt; foo &lt/NoWikI ></p>
14108 !! wikitext
14109 &lt;noWikI &gt; foo &lt;/NoWikI &gt;
14110 !! end
14111
14112 ###
14113 ### Message transform tests
14114 ###
14115 !! test
14116 message transform: magic variables
14117 !! options
14118 msg
14119 !! wikitext
14120 {{SITENAME}}
14121 !! html
14122 MediaWiki
14123 !! end
14124
14125 !! test
14126 message transform: should not transform wiki markup
14127 !! options
14128 msg
14129 !! wikitext
14130 ''test''
14131 !! html
14132 ''test''
14133 !! end
14134
14135 !! test
14136 message transform: <noinclude> in transcluded template (T6926)
14137 !! options
14138 msg
14139 !! wikitext
14140 {{Includes}}
14141 !! html
14142 Foobar
14143 !! end
14144
14145 !! test
14146 message transform: <onlyinclude> in transcluded template (T6926)
14147 !! options
14148 msg
14149 !! wikitext
14150 {{Includes2}}
14151 !! html
14152 Foo
14153 !! end
14154
14155 !! test
14156 {{#special:}} page name, known
14157 !! options
14158 msg
14159 !! wikitext
14160 {{#special:Recentchanges}}
14161 !! html
14162 Special:RecentChanges
14163 !! end
14164
14165 !! test
14166 {{#special:}} page name with subpage, known
14167 !! options
14168 msg
14169 !! wikitext
14170 {{#special:Recentchanges/param}}
14171 !! html
14172 Special:RecentChanges/param
14173 !! end
14174
14175 !! test
14176 {{#special:}} page name, unknown
14177 !! options
14178 msg
14179 !! wikitext
14180 {{#special:foobar nonexistent}}
14181 !! html
14182 Special:Foobar nonexistent
14183 !! end
14184
14185 !! test
14186 {{#speciale:}} page name, known
14187 !! options
14188 msg
14189 !! wikitext
14190 {{#speciale:Recentchanges}}
14191 !! html
14192 Special:RecentChanges
14193 !! end
14194
14195 !! test
14196 {{#speciale:}} page name with subpage, known
14197 !! options
14198 msg
14199 !! wikitext
14200 {{#speciale:Recentchanges/param}}
14201 !! html
14202 Special:RecentChanges/param
14203 !! end
14204
14205 !! test
14206 {{#speciale:}} page name, unknown
14207 !! options
14208 msg
14209 !! wikitext
14210 {{#speciale:foobar nonexistent}}
14211 !! html
14212 Special:Foobar_nonexistent
14213 !! end
14214
14215 ###
14216 ### Images
14217 ###
14218 ### For Parsoid-specific tests, see
14219 #### https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
14220
14221 !! test
14222 Simple image
14223 !! options
14224 parsoid=wt2html,wt2wt,html2html
14225 !! wikitext
14226 [[Image:foobar.jpg]]
14227 !! html/php
14228 <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>
14229 </p>
14230 !! html/parsoid
14231 <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>
14232 !! end
14233
14234 !! test
14235 Serialize simple image with span wrapper
14236 !! options
14237 parsoid=html2wt
14238 !! html/parsoid
14239 <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>
14240 !! wikitext
14241 [[File:Foobar.jpg]]
14242 !! end
14243
14244 !! test
14245 Simple image (using File: namespace, now canonical)
14246 !! wikitext
14247 [[File:Foobar.jpg]]
14248 !! html/php
14249 <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>
14250 </p>
14251 !! html/parsoid
14252 <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>
14253 !! end
14254
14255 !! test
14256 Right-aligned image
14257 !! wikitext
14258 [[File:Foobar.jpg|right]]
14259 !! html/php
14260 <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>
14261
14262 !! html/parsoid
14263 <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>
14264 !! end
14265
14266 !! test
14267 Image with caption
14268 !! wikitext
14269 [[File:Foobar.jpg|right|Caption text]]
14270 !! html/php
14271 <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>
14272
14273 !! html/parsoid
14274 <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>
14275 !! end
14276
14277 !! test
14278 Image with caption, T55312 #1
14279 !! wikitext
14280 [[File:Foobar.jpg|right|Caption page stuff]]
14281 !! html/php
14282 <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>
14283
14284 !! html/parsoid
14285 <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>
14286 !! end
14287
14288 !! test
14289 Image with caption, T55312 #2
14290 !! wikitext
14291 [[File:Foobar.jpg|right|Caption page=]]
14292 !! html/php
14293 <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>
14294
14295 !! html/parsoid
14296 <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>
14297 !! end
14298
14299 !! test
14300 Image with caption, T55312 #3
14301 !! wikitext
14302 [[File:Foobar.jpg|right|Caption page=stuff]]
14303 !! html/php
14304 <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>
14305
14306 !! html/parsoid
14307 <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>
14308 !! end
14309
14310 !! test
14311 Image caption with pipe entity
14312 !! wikitext
14313 [[File:Foobar.jpg|thumb|one &#x7C; two]]
14314 [[File:Foobar.jpg|thumb|one ''two'' &#x7C; three]]
14315 !! html/php
14316 <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>
14317 <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>
14318
14319 !! html/parsoid
14320 <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>
14321 <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>
14322 !! end
14323
14324 !! test
14325 Allow empty links in image captions (T62753)
14326 !! options
14327 thumbsize=220
14328 !! wikitext
14329 [[File:Foobar.jpg|thumb|Caption [[Link1]]
14330 [[]]
14331 [[Link2]]
14332 ]]
14333 !! html/php
14334 <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>
14335
14336 !! html/parsoid
14337 <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>
14338 [[]]
14339 <a rel="mw:WikiLink" href="./Link2" title="Link2" data-parsoid='{"stx":"simple","a":{"href":"./Link2"},"sa":{"href":"Link2"}}'>Link2</a>
14340 </figcaption></figure>
14341 !! end
14342
14343 !! test
14344 Titles in unlinked images (T23454)
14345 !! wikitext
14346 [[File:Foobar.jpg|link=|stuff]]
14347 !! html/php
14348 <p><img alt="stuff" src="http://example.com/images/3/3a/Foobar.jpg" title="stuff" width="1941" height="220" />
14349 </p>
14350 !! html/parsoid
14351 <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>
14352 !! end
14353
14354 !! test
14355 Link with empty target
14356 !! wikitext
14357 [[]]
14358 !! html
14359 <p>[[]]
14360 </p>
14361 !! end
14362
14363 !! test
14364 Image with link trail
14365 !! wikitext
14366 Linktrails should not work for images: [[File:Foobar.jpg]]s
14367 !! html/php
14368 <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
14369 </p>
14370 !! html/parsoid
14371 <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>
14372 !! end
14373
14374 !! test
14375 Image with empty attribute
14376 !! options
14377 parsoid=wt2html,wt2wt,html2html
14378 !! wikitext
14379 [[File:Foobar.jpg|right||Caption text]]
14380 !! html/php
14381 <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>
14382
14383 !! html/parsoid
14384 <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>
14385 !! end
14386
14387 !! test
14388 1. Block image with individual attributes from templates
14389 !! wikitext
14390 [[File:Foobar.jpg|thumb|{{echo|137px}}|This is a caption]]
14391 !! html/php
14392 <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>
14393
14394 !! html/parsoid
14395 <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>
14396 !! end
14397
14398 !! test
14399 2. Block Image with individual attributes from templates
14400 !! wikitext
14401 [[File:Foobar.jpg|{{echo|thumb}}|{{echo|137px}}|This is a caption]]
14402 !! html/php
14403 <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>
14404
14405 !! html/parsoid
14406 <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>
14407 !! end
14408
14409 !! test
14410 3. Inline image with individual attributes from templates
14411 !! wikitext
14412 [[File:Foobar.jpg|{{echo|50px}}]]
14413 !! html/php
14414 <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>
14415 </p>
14416 !! html/parsoid
14417 <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>
14418 !! end
14419
14420 ## Parsoid does not provide editing support for images where templates produce multiple image attributes.
14421 ## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
14422 !! test
14423 Image with multiple attributes from the same template
14424 !! wikitext
14425 [[File:Foobar.jpg|{{image_attribs}}]]
14426 !! html/php
14427 <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>
14428
14429 !! html/parsoid
14430 <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>
14431 !! end
14432
14433 !! test
14434 Image with link tails
14435 !! options
14436 thumbsize=220
14437 !! wikitext
14438 123[[File:Foobar.jpg]]456
14439 123[[File:Foobar.jpg|right]]456
14440 123[[File:Foobar.jpg|thumb]]456
14441 !! html/php
14442 <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
14443 </p>
14444 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
14445 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
14446
14447 !! html/php+tidy
14448 <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
14449 </p><p>
14450 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
14451 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
14452 </p>
14453 !! html/parsoid
14454 <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>
14455 <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>
14456 <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>
14457 !! end
14458
14459 !! test
14460 Image with multiple captions -- only last one is accepted
14461 !! wikitext
14462 [[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]]
14463 !! html/php
14464 <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>
14465
14466 !! html/parsoid
14467 <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>
14468 !! end
14469
14470 !! test
14471 Image with multiple widths -- use last
14472 !! wikitext
14473 [[File:Foobar.jpg|200px|300px|caption]]
14474 !! html/php
14475 <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>
14476 </p>
14477 !! html/parsoid
14478 <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>
14479 !! end
14480
14481 !! test
14482 Image with multiple alignments -- use first (T50664)
14483 !! options
14484 thumbsize=220
14485 !! wikitext
14486 [[File:Foobar.jpg|thumb|left|right|center|caption]]
14487
14488 [[File:Foobar.jpg|middle|text-top|caption]]
14489 !! html/php
14490 <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>
14491 <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>
14492 </p>
14493 !! html/parsoid
14494 <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>
14495 <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>
14496 !! end
14497
14498 !! test
14499 Image with width attribute at different positions
14500 !! wikitext
14501 [[File:Foobar.jpg|200px|right|Caption]]
14502 [[File:Foobar.jpg|right|200px|Caption]]
14503 [[File:Foobar.jpg|right|Caption|200px]]
14504 !! html/php
14505 <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>
14506 <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>
14507 <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>
14508
14509 !! html/parsoid
14510 <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>
14511 <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>
14512 <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>
14513 !! end
14514
14515 # a sad bit of backward-compatibility
14516 !! test
14517 Image with size specified with pxpx (T15500, T53628)
14518 !! options
14519 parsoid=wt2html,wt2wt,html2html
14520 !! wikitext
14521 [[File:Foobar.jpg|20pxpx]]
14522 [[File:Foobar.jpg|200x20pxpx]]
14523 !! html/php
14524 <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>
14525 <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>
14526 </p>
14527 !! html/parsoid
14528 <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>
14529 !! end
14530
14531 !! test
14532 Image with link parameter, wiki target
14533 !! wikitext
14534 [[File:Foobar.jpg|link=Main Page]]
14535 !! html/php
14536 <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>
14537 </p>
14538 !! html/parsoid
14539 <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>
14540 !! end
14541
14542 # parsoid T51293 (part 1)
14543 !! test
14544 Image with link parameter, URL target
14545 !! wikitext
14546 [[File:Foobar.jpg|link=http://example.com/]]
14547 !! html/php
14548 <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>
14549 </p>
14550 !! html/parsoid
14551 <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>
14552 !! end
14553
14554 # parsoid T51293 (part 2)
14555 !! test
14556 Image with link parameter, protocol-less URL target
14557 !! wikitext
14558 [[File:Foobar.jpg|link=//example.com/]]
14559 !! html/php
14560 <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>
14561 </p>
14562 !! html/parsoid
14563 <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>
14564 !! end
14565
14566 !! test
14567 Escaping non-block captions (T107435)
14568 !! options
14569 parsoid={
14570 "modes": ["wt2wt"],
14571 "changes": [
14572 ["[typeof~='mw:Image']", "attr", "data-mw", "{\"caption\": \"|\"}"]
14573 ]
14574 }
14575 !! wikitext
14576 [[Image:Foobar.jpg|caption]]
14577 !! wikitext/edited
14578 [[Image:Foobar.jpg|<nowiki>|</nowiki>]]
14579 !! end
14580
14581 # wgExternalLinkTarget not supported by Parsoid
14582 !! test
14583 Image with link parameter, wgExternalLinkTarget
14584 !! wikitext
14585 [[Image:foobar.jpg|link=http://example.com/]]
14586 !! config
14587 wgExternalLinkTarget='foobar'
14588 !! html/php
14589 <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>
14590 </p>
14591 !! end
14592
14593 !! test
14594 Image with link parameter, wgNoFollowLinks set to false
14595 !! wikitext
14596 [[Image:foobar.jpg|link=http://example.com/]]
14597 !! config
14598 wgNoFollowLinks=false
14599 !! html/php
14600 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14601 </p>
14602 !! end
14603
14604 !! test
14605 Image with link parameter, wgNoFollowDomainExceptions
14606 !! wikitext
14607 [[Image:foobar.jpg|link=http://example.com/]]
14608 !! config
14609 wgNoFollowDomainExceptions='example.com'
14610 !! html/php
14611 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14612 </p>
14613 !! end
14614
14615 # wgExternalLinkTarget not supported by Parsoid
14616 !! test
14617 Image with link parameter, wgExternalLinkTarget, unnamed parameter
14618 !! wikitext
14619 [[Image:foobar.jpg|link=http://example.com/|Title]]
14620 !! config
14621 wgExternalLinkTarget='foobar'
14622 !! html/php
14623 <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>
14624 </p>
14625 !! end
14626
14627 !! test
14628 Image with empty link parameter
14629 !! wikitext
14630 [[File:Foobar.jpg|link=]]
14631 !! html/php
14632 <p><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" />
14633 </p>
14634 !! html/parsoid
14635 <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>
14636 !! end
14637
14638 !! test
14639 Image with link parameter (wiki target) and unnamed parameter
14640 !! wikitext
14641 [[File:Foobar.jpg|link=Main_Page|Title]]
14642 !! html/php
14643 <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>
14644 </p>
14645 !! html/parsoid
14646 <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>
14647 !! end
14648
14649 !! test
14650 Image with link parameter (URL target) and unnamed parameter
14651 !! wikitext
14652 [[File:Foobar.jpg|link=http://example.com/|Title]]
14653 !! html/php
14654 <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>
14655 </p>
14656 !! html/parsoid
14657 <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>
14658 !! end
14659
14660 !! test
14661 Thumbnail image with link parameter
14662 !! options
14663 thumbsize=220
14664 parsoid=wt2html,wt2wt,html2html
14665 !! wikitext
14666 [[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
14667 !! html/php
14668 <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>
14669
14670 !! html/parsoid
14671 <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>
14672 !! end
14673
14674 !! test
14675 Manually-specified thumbnail image
14676 !! options
14677 thumbsize=220
14678 !! wikitext
14679 [[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
14680 !! html/php
14681 <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>
14682
14683 !! html/parsoid
14684 <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>
14685 !! end
14686
14687 !! test
14688 Manually-specified thumbnail image with explicit link to wiki page
14689 !! options
14690 thumbsize=220
14691 parsoid=wt2html,wt2wt,html2html
14692 !! wikitext
14693 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
14694 !! html/php
14695 <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>
14696
14697 !! html/parsoid
14698 <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>
14699 !! end
14700
14701 !! test
14702 Manually-specified thumbnail image with explicit link to url
14703 !! options
14704 thumbsize=220
14705 parsoid=wt2html,wt2wt,html2html
14706 !! wikitext
14707 [[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
14708 !! html/php
14709 <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>
14710
14711 !! html/parsoid
14712 <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>
14713 !! end
14714
14715 !! test
14716 Manually-specified thumbnail image with explicit no link
14717 !! options
14718 thumbsize=220
14719 parsoid=wt2html,wt2wt,html2html
14720 !! wikitext
14721 [[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
14722 !! html/php
14723 <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>
14724
14725 !! html/parsoid
14726 <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>
14727 !! end
14728
14729 !! test
14730 Manually-specified thumbnail image with explicit link and alt text
14731 !! options
14732 thumbsize=220
14733 parsoid=wt2html,wt2wt,html2html
14734 !! wikitext
14735 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
14736 !! html/php
14737 <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>
14738
14739 !! html/parsoid
14740 <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>
14741 !! end
14742
14743 !! test
14744 Image with frame and link
14745 !! options
14746 parsoid=wt2html,wt2wt,html2html
14747 !! wikitext
14748 [[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
14749 !! html/php
14750 <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>
14751
14752 !! html/parsoid
14753 <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>
14754 !! end
14755
14756 !! test
14757 Image with frame and link and explicit alt
14758 !! options
14759 parsoid=wt2html,wt2wt,html2html
14760 !! wikitext
14761 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]]
14762 !! html/php
14763 <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>
14764
14765 !! html/parsoid
14766 <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>
14767 !! end
14768
14769 !! test
14770 Image with wiki markup in implicit alt
14771 !! wikitext
14772 [[Image:Foobar.jpg|testing '''bold''' in alt]]
14773
14774 [[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
14775 !! html/php
14776 <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>
14777 </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>
14778 </p>
14779 !! html/parsoid
14780 <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>
14781
14782 <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>
14783 !! end
14784
14785 !! test
14786 Alt image option should handle most kinds of wikitext without barfing
14787 !! wikitext
14788 [[Image:Foobar.jpg|thumb|This is the image caption|alt=This is a [[link]] and a {{echo|''bold template''}}.]]
14789 !! html/php
14790 <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>
14791
14792 !! html/parsoid
14793 <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>
14794 !! end
14795
14796 !! test
14797 Image with table with attributes in caption
14798 !! options
14799 parsoid=wt2html,html2html
14800 !! wikitext
14801 [[File:Foobar.jpg|thumb|
14802 {| class="123" |
14803 |- class="456" |
14804 | ha
14805 |}
14806 ]]
14807 !! html/parsoid
14808 <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>
14809 <table class="123">
14810 <tbody><tr class="456" data-parsoid='{"startTagSrc":"|-"}'>
14811 <td> ha</td></tr>
14812 </tbody></table>
14813 </figcaption></figure>
14814 !! end
14815
14816 !! test
14817 Image with table with rows from templates in caption
14818 !! wikitext
14819 [[File:Foobar.jpg|thumb|
14820 {|
14821 {{echo|{{!}} hi}}
14822 |}
14823 ]]
14824 !! html/parsoid
14825 <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>
14826 <table>
14827 <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>
14828 </tbody></table>
14829 </figcaption></figure>
14830 !! end
14831
14832 !! test
14833 Image with nested tables in caption
14834 !! wikitext
14835 [[File:Foobar.jpg|thumb|Foo<br />
14836 {|
14837 |
14838 {|
14839 |z
14840 |}
14841 |}
14842 ]]
14843 !! html/parsoid
14844 <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}'/>
14845 <table>
14846 <tbody><tr><td>
14847 <table>
14848 <tbody><tr><td>z</td></tr>
14849 </tbody></table></td></tr>
14850 </tbody></table>
14851 </figcaption></figure>
14852 !! end
14853
14854 !! test
14855 Image with heading and horizontal rule in caption
14856 !! wikitext
14857 [[File:Foobar.jpg|thumb|
14858 ===Testing===
14859 123
14860 --------------
14861 ]]
14862 !! html/php
14863 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div><h3><span class="mw-headline" id="Testing">Testing</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Testing">edit</a><span class="mw-editsection-bracket">]</span></span></h3> 123 <hr /></div></div></div>
14864
14865 !! html/parsoid
14866 <figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"\n=== Testing ===\n123\n--------------\n"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{"href":"File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>
14867 <h3 id="Testing">Testing</h3>
14868 123
14869 <hr data-parsoid='{"extra_dashes":10}'/>
14870 </figcaption></figure>
14871 !! end
14872
14873 ###################
14874 # Conflicting image format options.
14875 # First option specified should 'win'.
14876 # All three cases in each test should be identical.
14877
14878 !! test
14879 Image with 'frameless' first.
14880 !! options
14881 parsoid=wt2html,wt2wt,html2html
14882 !! wikitext
14883 [[File:Foobar.jpg|frameless|caption]]
14884
14885 [[File:Foobar.jpg|frameless|frame|caption]]
14886
14887 [[File:Foobar.jpg|frameless|thumb|caption]]
14888 !! html/php
14889 <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>
14890 </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>
14891 </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>
14892 </p>
14893 !! html/parsoid
14894 <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>
14895 <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>
14896 <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>
14897 !! end
14898
14899 !! test
14900 Image with 'frame' first.
14901 !! options
14902 parsoid=wt2html,wt2wt,html2html
14903 !! wikitext
14904 [[File:Foobar.jpg|frame|caption]]
14905 [[File:Foobar.jpg|frame|frameless|caption]]
14906 [[File:Foobar.jpg|frame|thumb|caption]]
14907 !! html/php
14908 <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>
14909 <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>
14910 <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>
14911
14912 !! html/parsoid
14913 <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>
14914 <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>
14915 <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>
14916 !! end
14917
14918 !! test
14919 Image with 'thumb' first.
14920 !! options
14921 parsoid=wt2html,wt2wt,html2html
14922 !! wikitext
14923 [[File:Foobar.jpg|thumb|caption]]
14924 [[File:Foobar.jpg|thumb|frameless|caption]]
14925 [[File:Foobar.jpg|thumb|frame|caption]]
14926 !! html/php
14927 <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>
14928 <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>
14929 <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>
14930
14931 !! html/parsoid
14932 <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>
14933 <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>
14934 <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>
14935 !! end
14936
14937 ###################
14938 # Image sizing.
14939 # See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
14940 # and https://phabricator.wikimedia.org/T64258
14941 # Foobar has actual size of 1941x220
14942 # 1. Thumbs & frameless always reduce, can't be enlarged unless it's
14943 # a scalable format.
14944 # 2. Framed images always ignore size options; always render at default size.
14945 # 3. "Unspecified format" and border are the only types which can be
14946 # enlarged.
14947
14948 !! test
14949 Image: unspecified format and border enlarge
14950 !! options
14951 parsoid=wt2html,wt2wt,html2html
14952 !! wikitext
14953 [[File:Foobar.jpg|2000px]]
14954
14955 [[File:Foobar.jpg|border|2000px]]
14956 !! html/php
14957 <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>
14958 </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>
14959 </p>
14960 !! html/parsoid
14961 <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>
14962 <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>
14963 !! end
14964
14965 !! test
14966 Image: "unspecified format" and border reduce
14967 !! options
14968 parsoid=wt2html,wt2wt,html2html
14969 !! wikitext
14970 [[File:Foobar.jpg|1000px]]
14971
14972 [[File:Foobar.jpg|border|1000px]]
14973 !! html/php
14974 <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>
14975 </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>
14976 </p>
14977 !! html/parsoid
14978 <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>
14979 <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>
14980 !! end
14981
14982 !! test
14983 Image: thumbs reduce
14984 !! options
14985 parsoid=wt2html,wt2wt,html2html
14986 !! wikitext
14987 [[File:Foobar.jpg|thumb|50px]]
14988 !! html/php
14989 <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>
14990
14991 !! html/parsoid
14992 <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>
14993 !! end
14994
14995 !! test
14996 Image: bitmap thumbs can't be enlarged past original size, but vector can.
14997 !! options
14998 parsoid=wt2html,wt2wt,html2html
14999 !! wikitext
15000 [[File:Foobar.jpg|thumb|2000px]]
15001
15002 [[File:Foobar.svg|thumb|2000px]]
15003 !! html/php
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 class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div></div></div></div>
15005 <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>
15006
15007 !! html/parsoid
15008 <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>
15009 <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>
15010 !! end
15011
15012 !! test
15013 Image: frameless can reduce in size
15014 !! options
15015 parsoid=wt2html,wt2wt,html2html
15016 !! wikitext
15017 [[File:Foobar.jpg|frameless|50px]]
15018 !! html/php
15019 <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>
15020 </p>
15021 !! html/parsoid
15022 <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>
15023 !! end
15024
15025 !! test
15026 Image: bitmap frameless can't be enlarged past original size, but vector can
15027 !! options
15028 parsoid=wt2html,wt2wt,html2html
15029 !! wikitext
15030 [[File:Foobar.jpg|frameless|2000px]]
15031
15032 [[File:Foobar.svg|frameless|2000px]]
15033 !! html/php
15034 <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>
15035 </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>
15036 </p>
15037 !! html/parsoid
15038 <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>
15039 <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>
15040 !! end
15041
15042 !! test
15043 Image: framed images are always unscaled.
15044 !! options
15045 parsoid=wt2html,wt2wt,html2html
15046 !! wikitext
15047 [[File:Foobar.jpg|frame]]
15048
15049 [[File:Foobar.jpg|frame|50px]]
15050
15051 [[File:Foobar.jpg|frame|50x50px]]
15052
15053 [[File:Foobar.jpg|frame|2000px]]
15054 !! html/php
15055 <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>
15056 <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>
15057 <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>
15058 <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>
15059
15060 !! html/parsoid
15061 <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>
15062 <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>
15063 <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>
15064 <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>
15065 !! end
15066
15067 ###################
15068
15069 !! test
15070 Link to image page- image page normally doesn't exists, hence edit link
15071 Add test with existing image page
15072 #<p><a href="/wiki/File:Test" title="Image:Test">Image:test</a>
15073 !! wikitext
15074 [[:Image:test]]
15075 !! html
15076 <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>
15077 </p>
15078 !! end
15079
15080 !! test
15081 T20784 Link to non-existent image page with caption should use caption as link text
15082 !! wikitext
15083 [[:Image:test|caption]]
15084 !! html
15085 <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>
15086 </p>
15087 !! end
15088
15089 !! test
15090 Frameless image caption with a free URL
15091 !! wikitext
15092 [[File:Foobar.jpg|http://example.com]]
15093 !! html/php
15094 <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>
15095 </p>
15096 !! html/parsoid
15097 <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>
15098 !! end
15099
15100 !! test
15101 Thumbnail image caption with a free URL
15102 !! options
15103 thumbsize=220
15104 !! wikitext
15105 [[File:Foobar.jpg|thumb|http://example.com]]
15106 !! html/php
15107 <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>
15108
15109 !! html/parsoid
15110 <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>
15111 !! end
15112
15113 !! test
15114 Thumbnail image caption with a free URL and explicit alt
15115 !! options
15116 thumbsize=220
15117 parsoid=wt2html,wt2wt,html2html
15118 !! wikitext
15119 [[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]]
15120 !! html/php
15121 <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>
15122
15123 !! html/parsoid
15124 <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>
15125 !! end
15126
15127 !! test
15128 SVG thumbnails with no language set
15129 !! options
15130 !! wikitext
15131 [[File:Foobar.svg|thumb|caption]]
15132 !! html/php
15133 <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>
15134
15135 !! html/parsoid
15136 <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>
15137 !! end
15138
15139 !! test
15140 SVG thumbnails with language de
15141 !! options
15142 parsoid=wt2html,wt2wt,html2html
15143 !! wikitext
15144 [[File:Foobar.svg|thumb|caption|lang=de]]
15145 !! html/php
15146 <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>
15147
15148 !! html/parsoid
15149 <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>
15150 !! end
15151
15152 !! test
15153 SVG thumbnails with invalid language code
15154 !! options
15155 parsoid=wt2html,wt2wt,html2html
15156 !! wikitext
15157 [[File:Foobar.svg|thumb|caption|lang=invalid:language:code]]
15158 !! html/php
15159 <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>
15160
15161 !! html/parsoid
15162 <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>
15163 !! end
15164
15165 !! test
15166 T3887: A ISBN with a thumbnail
15167 !! wikitext
15168 [[File:Foobar.jpg|thumb|ISBN 1235467890]]
15169 !! html/php
15170 <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>
15171
15172 !! html/parsoid
15173 <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>
15174 !! end
15175
15176 !! test
15177 T3887: A RFC with a thumbnail
15178 !! wikitext
15179 [[File:Foobar.jpg|thumb|This is RFC 12354]]
15180 !! html/php
15181 <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>
15182
15183 !! html/parsoid
15184 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>This is <a href="https://tools.ietf.org/html/rfc12354" rel="mw:ExtLink" class="external mw-magiclink">RFC 12354</a></figcaption></figure>
15185 !! end
15186
15187 !! test
15188 T3887: A mailto link with a thumbnail
15189 !! wikitext
15190 [[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
15191 !! html/php
15192 <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>
15193
15194 !! html/parsoid
15195 <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>
15196 !! end
15197
15198 # Pending resolution to T2368
15199 !! test
15200 T2648: Frameless image caption with a link
15201 !! wikitext
15202 [[File:Foobar.jpg|text with a [[link]] in it]]
15203 !! html/php
15204 <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>
15205 </p>
15206 !! html/parsoid
15207 <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>
15208 !! end
15209
15210 !! test
15211 T2648: Frameless image caption with a link (suffix)
15212 !! wikitext
15213 [[File:Foobar.jpg|text with a [[link]]foo in it]]
15214 !! html/php
15215 <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>
15216 </p>
15217 !! html/parsoid
15218 <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>
15219 !! end
15220
15221 !! test
15222 T2648: Frameless image caption with an interwiki link
15223 !! wikitext
15224 [[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
15225 !! html/php
15226 <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>
15227 </p>
15228 !! html/parsoid
15229 <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>
15230 !! end
15231
15232 !! test
15233 T2648: Frameless image caption with a piped interwiki link
15234 !! wikitext
15235 [[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
15236 !! html/php
15237 <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>
15238 </p>
15239 !! html/parsoid
15240 <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>
15241 !! end
15242
15243 !! test
15244 T107474: Frameless image caption with <nowiki>
15245 !! wikitext
15246 [[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]]
15247 !! html/parsoid
15248 <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>
15249 !! end
15250
15251 !! test
15252 Escape HTML special chars in image alt text
15253 !! wikitext
15254 [[File:Foobar.jpg|& < > "]]
15255 !! html/php
15256 <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>
15257 </p>
15258 !! html/parsoid
15259 <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>
15260 !! end
15261
15262 !! test
15263 Escape HTML special chars in image alt text with LanguageConverter
15264 !! options
15265 language=zh
15266 !! wikitext
15267 [[File:Foobar.jpg|& < > "]]
15268 !! html/php
15269 <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>
15270 </p>
15271 !! html/parsoid
15272 <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>
15273 !! end
15274
15275 !! test
15276 Entities in file name and attributes
15277 !! wikitext
15278 [[File:7%25 solution.gif|manualthumb=7%25 solution.gif|link=7%25 solution|[[7%25 solution]]]]
15279 !! html/php
15280 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=7%25_solution.gif" class="new" title="File:7% solution.gif">7% solution</a>
15281 </p>
15282 !! html/parsoid
15283 <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>
15284 !! end
15285
15286 !! test
15287 T2499: Alt text should have &#1234;, not &amp;1234;
15288 !! wikitext
15289 [[File:Foobar.jpg|&#9792;]]
15290 !! html/php
15291 <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>
15292 </p>
15293 !! html/parsoid
15294 <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>
15295 !! end
15296
15297 !! test
15298 Broken image caption with link
15299 !! options
15300 parsoid=wt2html,wt2wt,html2html
15301 !! wikitext
15302 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
15303 !! html/php
15304 <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.
15305 </p>
15306 !! html/parsoid
15307 <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>
15308 !! end
15309
15310 !! test
15311 Image caption containing another image
15312 !! wikitext
15313 [[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
15314 !! html/php
15315 <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>
15316
15317 !! html/parsoid
15318 <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>
15319 !! end
15320
15321 !! test
15322 Image: caption containing a newline
15323 !! wikitext
15324 [[File:Foobar.jpg|This
15325 *is some text]]
15326 !! html/php
15327 <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>
15328 </p>
15329 !! html/parsoid
15330 <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>
15331 !!end
15332
15333 !!test
15334 Image: caption containing leading space
15335 (The leading space should not trigger nowiki escaping in wt2wt mode)
15336 !! wikitext
15337 [[File:Foobar.jpg|thumb| bar]]
15338 !! html/php
15339 <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>
15340
15341 !! html/parsoid
15342 <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>
15343 !!end
15344
15345 # html/php output not have newlines after table, td, th, etc. because
15346 # Linker::makeThumbLink2() replaces the newlines with spaces since
15347 # the table is inside a caption.
15348 # FIXME: Verify if that circa 2004 fix is still required.
15349 !! test
15350 Image: caption containing a table
15351 !! options
15352 parsoid=wt2html,wt2wt,html2html
15353 !! wikitext
15354 [[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
15355 {|
15356 !Foo!!Bar
15357 |-
15358 |Foo1||Bar1
15359 |}
15360 and some more text.]]
15361 !! html/php
15362 <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>
15363
15364 !! html/parsoid
15365 <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
15366 <table>
15367 <tbody>
15368 <tr><th>Foo</th><th>Bar</th></tr>
15369 <tr>
15370 <td>Foo1</td>
15371 <td>Bar1</td></tr></tbody></table>and some more text.</figcaption></figure>
15372 !! end
15373
15374 !! test
15375 T5090: External links other than http: in image captions
15376 !! wikitext
15377 [[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
15378 !! html/php
15379 <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>
15380
15381 !! html/parsoid
15382 <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>
15383 !! end
15384
15385 !! test
15386 Custom class
15387 !! options
15388 parsoid=wt2html,wt2wt,html2html
15389 !! wikitext
15390 [[Image:foobar.jpg|a|class=b]]
15391 !! html/php
15392 <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>
15393 </p>
15394 !! html/parsoid
15395 <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>
15396 !! end
15397
15398 !! test
15399 Localized image handling (1).
15400 !! options
15401 parsoid=wt2html,wt2wt,html2html
15402 language=es
15403 !! wikitext
15404 [[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]]
15405 !! html/php
15406 <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>
15407
15408 !! html/parsoid
15409 <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>
15410 !! end
15411
15412 !! test
15413 Localized image handling (2).
15414 !! options
15415 thumbsize=220
15416 parsoid=wt2html,wt2wt,html2html
15417 language=es
15418 !! wikitext
15419 [[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
15420 !! html/php
15421 <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>
15422
15423 !! html/parsoid
15424 <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>
15425 !! end
15426
15427 !! test
15428 Localized image handling (3).
15429 !! options
15430 language=fa
15431 parsoid=html2wt
15432 !! html/parsoid
15433 <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>
15434 !! wikitext
15435 [[File:Foobar.jpg|بندانگشتی]]
15436 !! end
15437
15438 !! test
15439 "border", "frameless" and "class" attributes on an image.
15440 !! options
15441 thumbsize=220
15442 parsoid=wt2html,wt2wt,html2html
15443 !! wikitext
15444 [[File:Foobar.jpg|frameless|border|class=extra|caption]]
15445 !! html/php
15446 <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>
15447 </p>
15448 !! html/parsoid
15449 <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>
15450 !! end
15451
15452 # Note that 'right' is the default alignment, despite the misspelled 'righ' below
15453 !! test
15454 Invalid image attributes (T64500)
15455 !! options
15456 thumbsize=220
15457 parsoid=wt2html,wt2wt,html2html
15458 !! wikitext
15459 [[File:Foobar.jpg|thumb|float|left|caption]]
15460
15461 [[File:Foobar.jpg|thumb|righ|caption]]
15462
15463 [[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]]
15464 !! html/php
15465 <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>
15466 <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>
15467 <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>
15468
15469 !! html/parsoid
15470 <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>
15471 <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>
15472 <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>
15473 !! end
15474
15475 !! article
15476 File:Barfoo.jpg
15477 !! text
15478 #REDIRECT [[File:Barfoo.jpg]]
15479 !! endarticle
15480
15481 # FIXME: Parsoid should run this test -- but we'd need to teach the
15482 # mockAPI about the redirected Barfoo.jpg image.
15483 !! test
15484 Redirected image
15485 !! wikitext
15486 [[Image:Barfoo.jpg]]
15487 !! html/php
15488 <p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
15489 </p>
15490 !! end
15491
15492 !! test
15493 Missing image with uploads disabled
15494 !! options
15495 wgEnableUploads=0
15496 !! wikitext
15497 [[File:Foobaz.jpg]]
15498 !! html/php
15499 <p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a>
15500 </p>
15501 !! html/parsoid
15502 <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>
15503 !! end
15504
15505 # Parsoid-specific testing for images
15506 # https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
15507 # Currently imperfect due to a flaw in the Parsoid testrunner
15508 # Work in progress
15509 # THESE TESTS SHOULD BE MOVED UP and merged with the php-specific
15510 # image tests.
15511
15512 !! test
15513 Parsoid-specific image handling - simple image with size and middle alignment
15514 !! wikitext
15515 [[File:Foobar.jpg|middle|50px]]
15516 !! html/parsoid
15517 <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>
15518 !! end
15519
15520 !! test
15521 Parsoid-specific image handling - simple image with size, middle alignment, non-standard namespace alias
15522 !! options
15523 parsoid=wt2wt,wt2html,html2html
15524 !! wikitext
15525 [[Image:Foobar.jpg|middle|50px]]
15526 !! html/parsoid
15527 <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>
15528 !! end
15529
15530 !! test
15531 Parsoid-specific image handling - simple image with size and middle alignment (existing content)
15532 !! wikitext
15533 [[File:Foobar.jpg|50px|middle]]
15534 !! html/parsoid
15535 <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>
15536 !! end
15537
15538 !! test
15539 Parsoid-specific image handling - simple image with size and middle alignment and non-standard namespace name
15540 !! options
15541 parsoid=wt2html,wt2wt,html2html
15542 !! wikitext
15543 [[Image:Foobar.jpg|50px|middle]]
15544 !! html/parsoid
15545 <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>
15546 !! end
15547
15548 !! test
15549 Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
15550 !! wikitext
15551 [[File:Foobar.jpg|500x10px|baseline|caption]]
15552 !! html/parsoid
15553 <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>
15554 !! end
15555
15556 !! test
15557 Parsoid-specific image handling - simple image with border and size spec
15558 !! wikitext
15559 [[File:Foobar.jpg|50px|border|caption]]
15560 !! html/parsoid
15561 <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>
15562 !! end
15563
15564 !! test
15565 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15566 !! options
15567 parsoid=wt2html,html2html
15568 !! wikitext
15569 [[File:Foobar.jpg|left|baseline|thumb|caption content]]
15570 !! html/parsoid
15571 <figure class="mw-default-size mw-halign-left" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption content</figcaption></figure>
15572 !! end
15573
15574 !! test
15575 Parsoid-specific image handling - thumbnail with halign, valign, and caption (existing content)
15576 !! options
15577 parsoid=wt2html,html2html
15578 !! wikitext
15579 [[File:Foobar.jpg|thumb|left|baseline|caption content]]
15580 !! html/parsoid
15581 <figure class="mw-default-size mw-halign-left" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"left","ak":"left"},{"ck":"baseline","ak":"baseline"},{"ck":"caption","ak":"caption content"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>caption content</figcaption></figure>
15582 !! end
15583
15584 !! test
15585 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption
15586 !! options
15587 parsoid=wt2html,html2html
15588 !! wikitext
15589 [[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
15590 !! html/parsoid
15591 <figure class="mw-halign-right" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50"/></a><figcaption>caption</figcaption></figure>
15592 !! end
15593
15594 !! test
15595 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption (existing content)
15596 !! options
15597 parsoid=wt2html,html2html
15598 !! wikitext
15599 [[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
15600 !! html/parsoid
15601 <figure class="mw-halign-right" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"width","ak":"50x50px"},{"ck":"right","ak":"right"},{"ck":"middle","ak":"middle"},{"ck":"caption","ak":"caption"}],"size":"50x50"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"6","width":"50"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>caption</figcaption></figure>
15602 !! end
15603
15604 !! test
15605 Parsoid-specific image handling - framed image with specific size and caption (size is ignored)
15606 !! options
15607 parsoid=wt2html,wt2wt,html2html
15608 !! wikitext
15609 [[File:Foobar.jpg|frame|500x50px|caption]]
15610 !! html/parsoid
15611 <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>
15612 !! end
15613
15614 !! test
15615 Parsoid-specific image handling - framed image with specific size, halign, valign, and caption (size is ignored)
15616 !! options
15617 parsoid=wt2html,html2html
15618 !! wikitext
15619 [[File:Foobar.jpg|left|baseline|frame|500x50px|caption]]
15620 !! html/parsoid
15621 <figure class="mw-halign-left" typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>caption</figcaption></figure>
15622 !! end
15623
15624 !! test
15625 Parsoid-specific image handling - frameless image with specific size, border, and caption
15626 !! wikitext
15627 [[File:Foobar.jpg|frameless|442x50px|border|caption]]
15628 !! html/parsoid
15629 <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>
15630 !! end
15631
15632 !! test
15633 Parsoid-specific image handling - simple image with a formatted caption
15634 !! wikitext
15635 [[File:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]]
15636 !! html/parsoid
15637 <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>
15638 !! end
15639
15640 !! test
15641 Parsoid-specific image handling - caption with a template in it
15642 !! wikitext
15643 [[File:Foobar.jpg|thumb|200x23px|This caption has a {{echo|transclusion}} in it.]]
15644 !! html/parsoid
15645 <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>
15646 !! end
15647
15648 !! test
15649 Parsoid-specific image handling - caption with unbalanced tags in it
15650 !! options
15651 parsoid=wt2html,wt2wt,html2html
15652 !! wikitext
15653 foo
15654 [[File:Foobar.jpg|thumb|200x200px|This caption has a <center>unbalanced tag in it.]]
15655 bar
15656 !! html/parsoid
15657 <p>foo</p>
15658 <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>
15659 <p>bar</p>
15660 !! end
15661
15662 !! test
15663 Parsoid-specific image handling - empty caption (1)
15664 !! options
15665 parsoid=wt2html,wt2wt
15666 !! wikitext
15667 [[File:Foobar.jpg|thumb|]]
15668 !! html/parsoid
15669 <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>
15670 !! end
15671
15672 # empty captions don't get serialized unless we're in the "round trip" case
15673 !! test
15674 Parsoid-specific image handling - empty caption (2)
15675 !! options
15676 parsoid=html2wt
15677 !! html/parsoid
15678 <figure class="mw-default-size" typeof="mw:Image/Thumb">
15679 <a href="./File:Foobar.jpg">
15680 <img resource="./File:Foobar.jpg"
15681 src="//example.com/images/3/3a/Foobar.jpg"
15682 data-file-width="1941" data-file-height="220" data-file-type="bitmap"
15683 height="25" width="220"/>
15684 </a>
15685 <figcaption></figcaption>
15686 </figure>
15687 !! wikitext
15688 [[File:Foobar.jpg|thumb]]
15689 !! end
15690
15691 !! test
15692 Parsoid-specific image handling - whitespace caption
15693 !! wikitext
15694 [[File:Foobar.jpg|thumb| ]]
15695 !! html/parsoid
15696 <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>
15697 !! end
15698
15699 !! test
15700 Parsoid-specific image handling - lang option
15701 !! wikitext
15702 foo
15703 [[File:Foobar.svg|lang=de|caption]]
15704 bar
15705 !! html/parsoid
15706 <p>foo
15707 <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>
15708 bar</p>
15709 !! end
15710
15711 ## Edge case bugs in Parsoid from T93580
15712 !! test
15713 T93580: 1. Templated <ref> inside block images
15714 !! wikitext
15715 [[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]]
15716
15717 <references />
15718 !! html/parsoid
15719 <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>
15720
15721 <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>
15722 !! end
15723
15724 !! test
15725 T93580: 2. <ref> inside inline images
15726 !! wikitext
15727 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: <ref>foo</ref>]]
15728
15729 <references />
15730 !! html/parsoid
15731 <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>
15732
15733 <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>
15734 !! end
15735
15736 !! test
15737 T93580: 3. Templated <ref> inside inline images
15738 !! wikitext
15739 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}]]
15740
15741 <references />
15742 !! html/parsoid
15743 <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>
15744
15745 <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>
15746 !! end
15747
15748 ###
15749 ### Subpages
15750 ###
15751 !! article
15752 Subpage test/subpage
15753 !! text
15754 foo
15755 !! endarticle
15756
15757 !! test
15758 Subpage link
15759 !! options
15760 subpage title=[[Subpage test]]
15761 !! wikitext
15762 [[/subpage]]
15763 !! html
15764 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
15765 </p>
15766 !! end
15767
15768 !! test
15769 Subpage noslash link
15770 !! options
15771 subpage title=[[Subpage test]]
15772 !! wikitext
15773 [[/subpage/]]
15774 !! html
15775 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
15776 </p>
15777 !! end
15778
15779 !! article
15780 Subpage test/1/2/subpage
15781 !! text
15782 blah
15783 !! endarticle
15784
15785 !! test
15786 Relative subpage noslash link
15787 !! options
15788 parsoid=wt2wt,wt2html,html2html
15789 subpage title=[[Subpage test/1/2/3/4]]
15790 !! wikitext
15791 [[../../subpage/]]
15792
15793 [[../../subpage]]
15794 !! html/php
15795 <p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a>
15796 </p><p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage test/1/2/subpage</a>
15797 </p>
15798 !! html/parsoid
15799 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a></p>
15800 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage_test/1/2/subpage</a></p>
15801 !! end
15802
15803 !! test
15804 Parsoid: dot-slash prefixed wikilinks
15805 !! wikitext
15806 [[./foo]]
15807
15808 [[././bar]]
15809
15810 [[././baz/]]
15811 !! html/php
15812 <p>[[./foo]]
15813 </p><p>[[././bar]]
15814 </p><p>[[././baz/]]
15815 </p>
15816 !! html/parsoid
15817 <p>[[./foo]]
15818 </p><p>[[././bar]]
15819 </p><p>[[././baz/]]
15820 </p>
15821 !! end
15822
15823 !! test
15824 Render invalid page names as plain text (T53090)
15825 !! wikitext
15826 [[./../foo|bar]]
15827 [[foo�|bar]]
15828 [[foo/.|bar]]
15829 [[foo/..|bar]]
15830 [[foo~~~bar]]
15831 [[foo>bar]]
15832 [[foo[bar]]
15833 [[.]]
15834 [[..]]
15835 [[foo././bar]]
15836 [[foo[http://example.com]xyz]]
15837
15838 [[{{echo|./../foo}}|bar]]
15839 [[{{echo|foo/.}}|bar]]
15840 [[{{echo|foo/..}}|bar]]
15841 [[{{echo|foo~~~~bar}}]]
15842 [[{{echo|foo>bar}}]]
15843 [[{{echo|foo././bar}}]]
15844 [[{{echo|foo{bar}}]]
15845 [[{{echo|foo}bar}}]]
15846 [[{{echo|foo[bar}}]]
15847 [[{{echo|foo]bar}}]]
15848 [[{{echo|foo<bar}}]]
15849 !!html/php
15850 <p>[[./../foo|bar]]
15851 [[foo�|bar]]
15852 [[foo/.|bar]]
15853 [[foo/..|bar]]
15854 [[foo~~~bar]]
15855 [[foo&gt;bar]]
15856 [[foo[bar]]
15857 [[.]]
15858 [[..]]
15859 [[foo././bar]]
15860 [[foo<a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>xyz]]
15861 </p><p>[[./../foo|bar]]
15862 [[foo/.|bar]]
15863 [[foo/..|bar]]
15864 [[foo~~~~bar]]
15865 [[foo&gt;bar]]
15866 [[foo././bar]]
15867 [[foo{bar]]
15868 [[foo}bar]]
15869 [[foo[bar]]
15870 [[foo]bar]]
15871 [[foo&lt;bar]]
15872 </p>
15873 !!html/parsoid
15874 <p>[[./../foo|bar]]
15875 [[foo�|bar]]
15876 [[foo/.|bar]]
15877 [[foo/..|bar]]
15878 [[foo~~~bar]]
15879 [[foo>bar]]
15880 [[foo[bar]]
15881 [[.]]
15882 [[..]]
15883 [[foo././bar]]
15884 [[foo<a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>xyz]]</p>
15885
15886 <p>[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"./../foo"}},"i":0}}]}'>./../foo</span>|bar]]
15887 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/."}},"i":0}}]}'>foo/.</span>|bar]]
15888 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/.."}},"i":0}}]}'>foo/..</span>|bar]]
15889 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo~~~~bar"}},"i":0}}]}'>foo~~~~bar</span>]]
15890 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo>bar"}},"i":0}}]}'>foo>bar</span>]]
15891 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo././bar"}},"i":0}}]}'>foo././bar</span>]]
15892 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo{bar"}},"i":0}}]}'>foo{bar</span>]]
15893 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}bar"}},"i":0}}]}'>foo}bar</span>]]
15894 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo[bar"}},"i":0}}]}'>foo[bar</span>]]
15895 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo]bar"}},"i":0}}]}'>foo]bar</span>]]
15896 [[<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>
15897 !!end
15898
15899 !! test
15900 Disabled subpages
15901 !! wikitext
15902 [[/subpage]]
15903 !! html
15904 <p><a href="/index.php?title=/subpage&amp;action=edit&amp;redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a>
15905 </p>
15906 !! end
15907
15908 !! test
15909 T2561: {{/Subpage}}
15910 !! options
15911 subpage title=[[Page]]
15912 !! wikitext
15913 {{/Subpage}}
15914 !! html
15915 <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>
15916 </p>
15917 !! end
15918
15919 ###
15920 ### Categories
15921 ###
15922 !! article
15923 Category:MediaWiki User's Guide
15924 !! text
15925 blah
15926 !! endarticle
15927
15928 !! test
15929 Link to category
15930 !! wikitext
15931 [[:Category:MediaWiki User's Guide]]
15932 !! html
15933 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User&#39;s Guide">Category:MediaWiki User's Guide</a>
15934 </p>
15935 !! end
15936
15937 !! test
15938 Simple category
15939 !! options
15940 cat
15941 !! wikitext
15942 [[Category:MediaWiki User's Guide]]
15943 !! html/php
15944 cat=MediaWiki_User's_Guide sort=
15945 !! html/parsoid
15946 <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"}}'/>
15947 !! end
15948
15949 !! test
15950 PAGESINCATEGORY invalid title fatal (r33546 fix)
15951 !! wikitext
15952 {{PAGESINCATEGORY:<bogus>}}
15953 !! html
15954 <p>0
15955 </p>
15956 !! end
15957
15958 !! test
15959 Category with different sort key
15960 !! options
15961 cat
15962 !! wikitext
15963 [[Category:MediaWiki User's Guide|Foo]]
15964 !! html/php
15965 cat=MediaWiki_User's_Guide sort=Foo
15966 !! html/parsoid
15967 <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"}}'/>
15968 !! end
15969
15970 !! test
15971 Category with identical sort key
15972 !! options
15973 cat
15974 !! wikitext
15975 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
15976 !! html/php
15977 cat=MediaWiki_User's_Guide sort=MediaWiki User's Guide
15978 !! html/parsoid
15979 <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"}}'/>
15980 !! end
15981
15982 !! test
15983 Category with empty sort key
15984 !! options
15985 cat
15986 pst
15987 !! wikitext
15988 [[Category:MediaWiki User's Guide|]]
15989 !! html/php
15990 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
15991 !! end
15992
15993 !! test
15994 Category with empty sort key and parentheses
15995 !! options
15996 cat
15997 pst
15998 !! wikitext
15999 [[Category:Foo (bar)|]]
16000 !! html/php
16001 [[Category:Foo (bar)|Foo]]
16002 !! end
16003
16004 !! test
16005 Category with link tail
16006 !! options
16007 cat
16008 pst
16009 !! wikitext
16010 123[[Category:Foo]]456
16011 !! html/php
16012 123[[Category:Foo]]456
16013 !! end
16014
16015 !! test
16016 Category with template
16017 !! options
16018 cat
16019 pst
16020 !! wikitext
16021 [[Category:{{echo|Foo}}]]
16022 !! html/php
16023 [[Category:{{echo|Foo}}]]
16024 !! end
16025
16026 !! test
16027 Category with template in sort key
16028 !! options
16029 cat
16030 pst
16031 !! wikitext
16032 [[Category:Foo|{{echo|Bar}}]]
16033 !! html/php
16034 [[Category:Foo|{{echo|Bar}}]]
16035 !! end
16036
16037 !! test
16038 Category with template in sort key and title
16039 !! options
16040 cat
16041 pst
16042 !! wikitext
16043 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16044 !! html/php
16045 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16046 !! end
16047
16048 ## We used to, but no longer wt2wt this test since the default serializer
16049 ## will normalize all categories to serialize on their own line.
16050 ## This wikitext usage is going to be fairly uncommon in production and
16051 ## selser will take care of preserving formatting in those scenarios.
16052 !! test
16053 Category / paragraph interactions
16054 !! options
16055 parsoid=wt2html
16056 !! wikitext
16057 Foo [[Category:Baz]] Bar
16058
16059 Foo [[Category:Baz]]
16060 Bar
16061
16062 Foo
16063 [[Category:Baz]]
16064 Bar
16065
16066 Foo
16067 [[Category:Baz]] Bar
16068
16069 Foo
16070 [[Category:Baz]]
16071 [[Category:Baz]]
16072 [[Category:Baz]]
16073 Bar
16074
16075 [[Category:Baz]]
16076 [[Category:Baz]]
16077 [[Category:Baz]]
16078
16079 [[Category:Baz]]
16080 {{echo|[[Category:Baz]]}}
16081 [[Category:Baz]]
16082 !! html/php
16083 <p>Foo Bar
16084 </p><p>Foo
16085 Bar
16086 </p><p>Foo
16087 Bar
16088 </p><p>Foo Bar
16089 </p><p>Foo
16090 Bar
16091 </p>
16092 !! html/parsoid
16093 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16094 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16095 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16096 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16097 <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>
16098 <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}}]}'/>
16099 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
16100 !! end
16101
16102 ## We used to, but no longer wt2wt this test since the default serializer
16103 ## will normalize all categories to serialize on their own line.
16104 ## This wikitext usage is going to be fairly uncommon in production and
16105 ## selser will take care of preserving formatting in those scenarios.
16106 ##
16107 ## The whitespace on the empty line is part of the test. Please do not delete
16108 !! test
16109 1. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16110 !! options
16111 parsoid=wt2html
16112 !! wikitext
16113 This
16114
16115 [[Category:Foo]] and this should be part of same paragraph (not an indent-pre)
16116
16117 {{echo|[[Category:Foo]] and so should this!}}
16118 !! html/php
16119 <p>This and this should be part of same paragraph (not an indent-pre) and so should this!
16120 </p>
16121 !! html/parsoid
16122 <p>This
16123
16124 <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of same paragraph (not an indent-pre)
16125
16126 <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>
16127 !! end
16128
16129 ## Parsoid will not try to wt2wt this while preserving newlines because
16130 ## it suppresses excess newlines within list items -- and we don't want to
16131 ## introduce a special case just for categories, which is, in reality somewhat
16132 ## odd behavior -- categories are unlikely to be used in list items like this
16133 ## in top-level pages and are only likely to show up in template-generated
16134 ## list items where this RT-ing is a non-issue.
16135 ##
16136 ## The whitespace on the empty line is part of the test. Please do not delete
16137 !! test
16138 2. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16139 !! options
16140 parsoid=wt2html
16141 !! wikitext
16142 * This
16143
16144 [[Category:Foo]] and this should be part of the same list item
16145 * So should this
16146
16147 {{echo|[[Category:Foo]] and this should be part of the same list item}}
16148 !! html
16149 <ul><li>This and this should be part of the same list item</li>
16150 <li>So should this and this should be part of the same list item</li></ul>
16151 !! html/parsoid
16152 <ul>
16153 <li>This <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of the same list item</li>
16154 <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>
16155 </ul>
16156 !! end
16157
16158 ## Newlines and categories that follow the last item of a list
16159 ## are treated differently because this (list followed by categories)
16160 ## is an extremely common pattern on wikis.
16161 !! test
16162 3. Categories and newlines: newline suppression for last list item should RT properly
16163 !! wikitext
16164 *a
16165 *b
16166
16167 [[Category:Foo]]
16168
16169 [[Category:Bar]]
16170 [[Category:Baz]]
16171
16172 :c
16173
16174 [[Category:C]]
16175
16176 ;d
16177
16178 [[Category:D]]
16179 !! html/parsoid
16180 <ul><li>a</li>
16181 <li>b</li></ul>
16182
16183 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
16184
16185 <link rel="mw:PageProp/Category" href="./Category:Bar"/>
16186 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
16187
16188 <dl><dd>c</dd></dl>
16189
16190 <link rel="mw:PageProp/Category" href="./Category:C"/>
16191
16192 <dl><dt>d</dt></dl>
16193
16194 <link rel="mw:PageProp/Category" href="./Category:D"/>
16195 !! end
16196
16197 !! test
16198 4. Categories and newlines: newline suppression for last list item should RT properly
16199 !! wikitext
16200 *a
16201 ****b
16202
16203 [[Category:Foo]]
16204 !! html/parsoid
16205 <ul><li>a
16206 <ul><li><ul><li><ul><li>b</li></ul></li></ul></li></ul></li></ul>
16207
16208 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16209 !! end
16210
16211 ## only wt2html for this to make sure the algo only applies to the rightmost path
16212 !! test
16213 5. Categories and newlines: migrateTrailingCategories dom pass should only run on the rightmost path of nested lists
16214 !! options
16215 parsoid=wt2html
16216 !! wikitext
16217 *a
16218 **b
16219 [[Category:Foo]]
16220 *c
16221 **d
16222 [[Category:Foo]]
16223 !! html/parsoid
16224 <ul><li>a
16225 <ul><li>b
16226 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul></li>
16227 <li>c
16228 <ul><li>d</li></ul></li></ul>
16229 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16230 !! end
16231
16232 ## We used to, but no longer wt2wt this test since the default serializer
16233 ## will normalize all categories to serialize on their own line.
16234 ## This wikitext usage is going to be fairly uncommon in production and
16235 ## selser will take care of preserving formatting in those scenarios.
16236 !! test
16237 6. Categories and newlines: migrateTrailingCategories dom pass should not migrate categories not preceded by newlines
16238 !! options
16239 parsoid=wt2html
16240 !! wikitext
16241 *a [[Category:Foo]]
16242 !! html/parsoid
16243 <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>
16244 !! end
16245
16246 # This test also demonstrates because of newline+category tunneling
16247 # through the list hander, template wrapping doesn't expand to the
16248 # containing list when the list item swallows the category.
16249 !! test
16250 7. Categories and newlines: migrateTrailingCategories dom pass should leave template content alone
16251 !! wikitext
16252 *{{echo|a
16253 [[Category:Foo]]}}
16254 !! html/parsoid
16255 <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
16256 </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>
16257 !! end
16258
16259 !! test
16260 8. Categories and newlines: migrateTrailingCategories dom pass should not get tripped by intervening templates
16261 !! wikitext
16262 *a
16263
16264 {{echo|[[Category:Foo]]
16265 [[Category:Bar]]}}
16266 [[Category:Baz]]
16267 !! html/parsoid
16268 <ul><li>a</li></ul>
16269
16270 <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">
16271 </span><link rel="mw:PageProp/Category" href="./Category:Bar" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
16272 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
16273 !! end
16274
16275 !! test
16276 Categories and newlines: migrateTrailingCategories dom pass should not get tripped by comments and whitespace
16277 !! wikitext
16278 *a
16279
16280 [[Category:Bar]]<!--boo1--> <!--boo2-->
16281 [[Category:Baz]]<!--boo3--> <!--boo4-->
16282 !! html/parsoid
16283 <ul><li>a</li></ul>
16284
16285 <link rel="mw:PageProp/Category" href="./Category:Bar"/><!--boo1--> <!--boo2-->
16286 <link rel="mw:PageProp/Category" href="./Category:Baz"/><!--boo3--> <!--boo4-->
16287 !! end
16288
16289 !! test
16290 Categories and newlines: should behave properly with linkprefix (T87753)
16291 !! options
16292 language=ar
16293 !! wikitext
16294 foo bar
16295 foo bar
16296 [[تصنيف:Foo]]
16297 [[تصنيف:Bar]]
16298 !! html/php
16299 <p>foo bar
16300 foo bar
16301 </p>
16302 !! html/parsoid
16303 <p>foo bar
16304 foo bar</p>
16305 <link rel="mw:PageProp/Category" href="./تصنيف:Foo"/>
16306 <link rel="mw:PageProp/Category" href="./تصنيف:Bar"/>
16307 !! end
16308
16309 !! test
16310 No regressions on internal links following category (T174639)
16311 !! options
16312 parsoid=wt2html,html2html
16313 !! wikitext
16314 [[Category:Foo]]<div>a
16315
16316 [[Foo]]</div>
16317 !! html/php
16318 <div>a
16319 <a href="/wiki/Foo" title="Foo">Foo</a></div>
16320
16321 !! html/parsoid
16322 <link rel="mw:PageProp/Category" href="./Category:Foo"/><div>a
16323
16324 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></div>
16325 !! end
16326
16327 # Note that Parsoid differs slightly from PHP due to T175421
16328 !! test
16329 11. Special case where only newlines separate links (T175416)
16330 !! options
16331 parsoid=wt2html,html2html
16332 !! wikitext
16333 [[Category:Foo]]
16334
16335 [[Foo]][[es:Alimento]]
16336
16337 [[Foo]]
16338 !! html/php
16339 <p><br />
16340 <a href="/wiki/Foo" title="Foo">Foo</a>
16341 </p><p><a href="/wiki/Foo" title="Foo">Foo</a>
16342 </p>
16343 !! html/parsoid
16344 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
16345
16346 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p><link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
16347
16348 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p>
16349 !! end
16350
16351 !! test
16352 Category links with multiple namespaces
16353 !! wikitext
16354 [[Category:Project:Foo]]
16355 !! html/parsoid
16356 <link rel="mw:PageProp/Category" href="./Category:Project:Foo" />
16357 !! end
16358
16359 !! test
16360 Parsoid: Serialize link to category page with colon escape
16361 !! options
16362 parsoid
16363 !! wikitext
16364
16365 [[:Category:Foo]]
16366 [[:Category:Foo|Bar]]
16367 !! html
16368 <p>
16369 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Category:Foo</a>
16370 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Bar</a>
16371 </p>
16372 !! end
16373
16374 # We used to, but no longer wt2wt this test since the default serializer
16375 # will normalize all categories to serialize on their own line.
16376 # This wikitext usage is going to be fairly uncommon in production and
16377 # selser will take care of preventing whitespace insertion if this
16378 # occurs in an article.
16379 #
16380 # html2html disabled for the same reason (whitespace insertion between
16381 # x and y).
16382 #
16383 # html2wt disabled because it localizes the "Category" namespace.
16384 !! test
16385 Link prefix/suffixes aren't applied to category links
16386 !! options
16387 parsoid=wt2html
16388 language=is
16389 !! wikitext
16390 x[[Category:Foo]]y
16391 !! html/php
16392 <p>xy
16393 </p>
16394 !! html/parsoid
16395 <p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p>
16396 !! end
16397
16398 !! test
16399 Link prefix/suffixes aren't applied to language links
16400 !! options
16401 parsoid=wt2html
16402 language=is
16403 !! wikitext
16404 x[[es:Foo]]y
16405 !! html/php
16406 <p>xy
16407 </p>
16408 !! html/parsoid
16409 <p>x<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo" data-parsoid=""/>y</p>
16410 !! end
16411
16412 !! test
16413 Parsoid: Serialize link to file page with colon escape
16414 !! options
16415 parsoid
16416 !! wikitext
16417
16418 [[:File:Foo.png]]
16419 [[:File:Foo.png|Bar]]
16420 !! html
16421 <p>
16422 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">File:Foo.png</a>
16423 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">Bar</a>
16424 </p>
16425 !! end
16426
16427 !! test
16428 Parsoid: Serialize a genuine category link without colon escape
16429 !! options
16430 parsoid
16431 !! wikitext
16432 [[Category:Foo]]
16433 [[Category:Foo|Bar]]
16434 !! html
16435 <link rel="mw:PageProp/Category" href="./Category:Foo">
16436 <link rel="mw:PageProp/Category" href="./Category:Foo#Bar">
16437 !! end
16438
16439 !! test
16440 Normalize hrefs properly before testing for invalid link targets (T72894)
16441 !! options
16442 parsoid=html2wt
16443 !! html/parsoid
16444 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/>
16445 !! wikitext
16446 [[Category:Toxine bactérienne]]
16447 !! end
16448
16449 !! test
16450 Parsoid: Defaultsort
16451 !! wikitext
16452 {{DEFAULTSORT:Foo}}
16453 !! html/parsoid
16454 <meta property="mw:PageProp/categorydefaultsort" content="Foo"/>
16455 !! end
16456
16457 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
16458 # But, this is a limitation of our representation and is documented in
16459 # TemplateHandler.js in processSpecialMagicWord
16460 !! test
16461 Parsoid: Defaultsort (template-generated)
16462 !! wikitext
16463 {{{{echo|DEFAULTSORT}}:Foo}}
16464 !! html/parsoid
16465 <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"}]]}'/>
16466 !! end
16467
16468 ###
16469 ### Inter-language links
16470 ###
16471 !! test
16472 Interlanguage links
16473 !! options
16474 ill
16475 !! wikitext
16476 [[es:Alimento]]
16477 [[fr:Nourriture]]
16478 [[zh:食品]]
16479 !! html/php
16480 es:Alimento fr:Nourriture zh:食品
16481 !! html/parsoid
16482 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
16483 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Nourriture"/>
16484 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/食品"/>
16485 !! end
16486
16487 !! test
16488 Duplicate interlanguage links (T26502)
16489 !! options
16490 ill
16491 !! wikitext
16492 [[es:1]]
16493 [[es:2]]
16494 [[fr:1]]
16495 [[fr:2]]
16496 !! html/php
16497 es:1 fr:1
16498 !! html/parsoid
16499 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/1"/>
16500 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/2"/>
16501 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/1"/>
16502 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/2"/>
16503 !! end
16504
16505 ###
16506 ### Sections
16507 ###
16508 !! test
16509 Basic section headings
16510 !! wikitext
16511 ==Headline 1==
16512 Some text
16513
16514 ==Headline 2==
16515 More
16516 ===Smaller headline===
16517 Blah blah
16518 !! html
16519 <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>
16520 <p>Some text
16521 </p>
16522 <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>
16523 <p>More
16524 </p>
16525 <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>
16526 <p>Blah blah
16527 </p>
16528 !! end
16529
16530 !! test
16531 Section headings with TOC
16532 !! wikitext
16533 ==Headline 1==
16534 ===Subheadline 1===
16535 =====Skipping a level=====
16536 ======Skipping a level======
16537
16538 ==Headline 2==
16539 Some text
16540 ===Another headline===
16541 !! html
16542 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16543 <ul>
16544 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
16545 <ul>
16546 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
16547 <ul>
16548 <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>
16549 <ul>
16550 <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>
16551 </ul>
16552 </li>
16553 </ul>
16554 </li>
16555 </ul>
16556 </li>
16557 <li class="toclevel-1 tocsection-5"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
16558 <ul>
16559 <li class="toclevel-2 tocsection-6"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
16560 </ul>
16561 </li>
16562 </ul>
16563 </div>
16564
16565 <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>
16566 <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>
16567 <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>
16568 <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>
16569 <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>
16570 <p>Some text
16571 </p>
16572 <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>
16573
16574 !! end
16575
16576 !! test
16577 TOC anchors don't collide
16578 !! wikitext
16579 __FORCETOC__
16580 ==Headline 2==
16581 ==Headline==
16582 ==Headline 2==
16583 ==Headline==
16584 !! html/php
16585 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16586 <ul>
16587 <li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
16588 <li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
16589 <li class="toclevel-1 tocsection-3"><a href="#Headline_2_2"><span class="tocnumber">3</span> <span class="toctext">Headline 2</span></a></li>
16590 <li class="toclevel-1 tocsection-4"><a href="#Headline_3"><span class="tocnumber">4</span> <span class="toctext">Headline</span></a></li>
16591 </ul>
16592 </div>
16593
16594 <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>
16595 <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>
16596 <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>
16597 <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>
16598
16599 !! end
16600
16601 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
16602 # Parsoid html2wt direction adds <nowiki> for level 7 and up.
16603 !! test
16604 Handling of sections up to level 6 and beyond
16605 !! options
16606 parsoid=wt2html
16607 !! wikitext
16608 =Level 1 Heading=
16609 ==Level 2 Heading==
16610 ===Level 3 Heading===
16611 ====Level 4 Heading====
16612 =====Level 5 Heading=====
16613 ======Level 6 Heading======
16614 =======Level 7 Heading=======
16615 ========Level 8 Heading========
16616 =========Level 9 Heading=========
16617 ==========Level 10 Heading==========
16618 !! html/php
16619 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16620 <ul>
16621 <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
16622 <ul>
16623 <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>
16624 <ul>
16625 <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>
16626 <ul>
16627 <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>
16628 <ul>
16629 <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>
16630 <ul>
16631 <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>
16632 <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>
16633 <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>
16634 <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>
16635 <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>
16636 </ul>
16637 </li>
16638 </ul>
16639 </li>
16640 </ul>
16641 </li>
16642 </ul>
16643 </li>
16644 </ul>
16645 </li>
16646 </ul>
16647 </div>
16648
16649 <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>
16650 <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>
16651 <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>
16652 <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>
16653 <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>
16654 <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>
16655 <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>
16656 <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>
16657 <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>
16658 <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>
16659
16660 !! html/parsoid
16661 <h1 id="Level_1_Heading" data-parsoid='{}'>Level 1 Heading</h1>
16662 <h2 id="Level_2_Heading" data-parsoid='{}'>Level 2 Heading</h2>
16663 <h3 id="Level_3_Heading" data-parsoid='{}'>Level 3 Heading</h3>
16664 <h4 id="Level_4_Heading" data-parsoid='{}'>Level 4 Heading</h4>
16665 <h5 id="Level_5_Heading" data-parsoid='{}'>Level 5 Heading</h5>
16666 <h6 id="Level_6_Heading" data-parsoid='{}'>Level 6 Heading</h6>
16667 <h6 id="=Level_7_Heading=" data-parsoid='{}'><span id=".3DLevel_7_Heading.3D" typeof="mw:FallbackId"></span>=Level 7 Heading=</h6>
16668 <h6 id="==Level_8_Heading==" data-parsoid='{}'><span id=".3D.3DLevel_8_Heading.3D.3D" typeof="mw:FallbackId"></span>==Level 8 Heading==</h6>
16669 <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>
16670 <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>
16671 !! end
16672
16673 !! test
16674 TOC regression (T11764)
16675 !! wikitext
16676 ==title 1==
16677 ===title 1.1===
16678 ====title 1.1.1====
16679 ===title 1.2===
16680 ==title 2==
16681 ===title 2.1===
16682 !! html
16683 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16684 <ul>
16685 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16686 <ul>
16687 <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>
16688 <ul>
16689 <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>
16690 </ul>
16691 </li>
16692 <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>
16693 </ul>
16694 </li>
16695 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16696 <ul>
16697 <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>
16698 </ul>
16699 </li>
16700 </ul>
16701 </div>
16702
16703 <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>
16704 <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>
16705 <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>
16706 <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>
16707 <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>
16708 <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>
16709
16710 !! end
16711
16712 !! test
16713 TOC for heading containing <span id="..."></span> (T96153)
16714 !! wikitext
16715 __FORCETOC__
16716 ==<span id="old-anchor"></span>New title==
16717 !! html/php
16718 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16719 <ul>
16720 <li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
16721 </ul>
16722 </div>
16723
16724 <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>
16725
16726 !! end
16727
16728 !! test
16729 TOC with wgMaxTocLevel=3 (T8204)
16730 !! options
16731 wgMaxTocLevel=3
16732 !! wikitext
16733 ==title 1==
16734 ===title 1.1===
16735 ====title 1.1.1====
16736 ===title 1.2===
16737 ==title 2==
16738 ===title 2.1===
16739 !! html
16740 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16741 <ul>
16742 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16743 <ul>
16744 <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>
16745 <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>
16746 </ul>
16747 </li>
16748 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16749 <ul>
16750 <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>
16751 </ul>
16752 </li>
16753 </ul>
16754 </div>
16755
16756 <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>
16757 <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>
16758 <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>
16759 <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>
16760 <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>
16761 <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>
16762
16763 !! end
16764
16765 !! test
16766 TOC with wgMaxTocLevel=3 and two level four headings (T8204)
16767 !! options
16768 wgMaxTocLevel=3
16769 !! wikitext
16770 ==Section 1==
16771 ===Section 1.1===
16772 ====Section 1.1.1====
16773 ====Section 1.1.1.1====
16774 ==Section 2==
16775 !! html
16776 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16777 <ul>
16778 <li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
16779 <ul>
16780 <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>
16781 </ul>
16782 </li>
16783 <li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li>
16784 </ul>
16785 </div>
16786
16787 <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>
16788 <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>
16789 <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>
16790 <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>
16791 <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>
16792
16793 !! end
16794
16795
16796 !! test
16797 Resolving duplicate section names
16798 !! wikitext
16799 ==Foo bar==
16800 ==Foo bar==
16801 !! html
16802 <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>
16803 <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>
16804
16805 !! end
16806
16807 !! test
16808 Resolving duplicate section names with differing case (T12721)
16809 !! wikitext
16810 ==Foo bar==
16811 ==Foo Bar==
16812 !! html
16813 <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>
16814 <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>
16815
16816 !! end
16817
16818 !! article
16819 Template:sections
16820 !! text
16821 ===Section 1===
16822 ==Section 2==
16823 !! endarticle
16824
16825 !! test
16826 Template with sections, __NOTOC__
16827 !! wikitext
16828 __NOTOC__
16829 ==Section 0==
16830 {{sections}}
16831 ==Section 4==
16832 !! html
16833 <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>
16834 <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>
16835 <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>
16836 <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>
16837
16838 !! end
16839
16840 !! test
16841 __NOEDITSECTION__ keyword
16842 !! wikitext
16843 __NOEDITSECTION__
16844 ==Section 1==
16845 ==Section 2==
16846 !! html
16847 <h2><span class="mw-headline" id="Section_1">Section 1</span></h2>
16848 <h2><span class="mw-headline" id="Section_2">Section 2</span></h2>
16849
16850 !! end
16851
16852 !! test
16853 Link inside a section heading
16854 !! wikitext
16855 ==Section with a [[Main Page|link]] in it==
16856 !! html
16857 <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>
16858
16859 !! end
16860
16861 !! test
16862 TOC regression (T14077)
16863 !! wikitext
16864 __TOC__
16865 ==title 1==
16866 ===title 1.1===
16867 ==title 2==
16868 !! html
16869 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16870 <ul>
16871 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16872 <ul>
16873 <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>
16874 </ul>
16875 </li>
16876 <li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li>
16877 </ul>
16878 </div>
16879
16880 <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>
16881 <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>
16882 <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>
16883
16884 !! end
16885
16886 !! test
16887 T3219 URL next to image (good)
16888 !! wikitext
16889 http://example.com [[File:Foobar.jpg]]
16890 !! html/php
16891 <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>
16892 </p>
16893 !! html/parsoid
16894 <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>
16895 !!end
16896
16897 # Parsoid doesn't wt2wt this cleanly because it adds <nowiki>s.
16898 !! test
16899 Short headings with trailing space should match behavior of Parser::doHeadings (T21910)
16900 !! options
16901 parsoid=wt2html,html2html
16902 !! wikitext
16903 ===
16904 The line above must have a trailing space!
16905 === <!--
16906 --> <!-- -->
16907 But just in case it doesn't...
16908 !! html/php
16909 <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>
16910 <p>The line above must have a trailing space!
16911 </p>
16912 <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>
16913 <p>But just in case it doesn't...
16914 </p>
16915 !! html/parsoid
16916 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
16917 <p>The line above must have a trailing space!</p>
16918 <h1 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h1> <!--
16919 --> <!-- -->
16920 <p>But just in case it doesn't...</p>
16921 !! end
16922
16923 !! test
16924 Header with special characters (T27462)
16925 !! wikitext
16926 The tooltips shall not show entities to the user (ie. be double escaped)
16927
16928 ==text > text==
16929 section 1
16930
16931 ==text < text==
16932 section 2
16933
16934 ==text & text==
16935 section 3
16936
16937 ==text ' text==
16938 section 4
16939
16940 ==text " text==
16941 section 5
16942 !! html/php
16943 <p>The tooltips shall not show entities to the user (ie. be double escaped)
16944 </p>
16945 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16946 <ul>
16947 <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>
16948 <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>
16949 <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>
16950 <li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li>
16951 <li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li>
16952 </ul>
16953 </div>
16954
16955 <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>
16956 <p>section 1
16957 </p>
16958 <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>
16959 <p>section 2
16960 </p>
16961 <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>
16962 <p>section 3
16963 </p>
16964 <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>
16965 <p>section 4
16966 </p>
16967 <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>
16968 <p>section 5
16969 </p>
16970 !! html/parsoid
16971 <p>The tooltips shall not show entities to the user (ie. be double escaped)</p>
16972
16973 <h2 id="text_>_text"><span id="text_.3E_text" typeof="mw:FallbackId"></span>text > text</h2>
16974 <p>section 1</p>
16975
16976 <h2 id="text_&lt;_text"><span id="text_.3C_text" typeof="mw:FallbackId"></span>text &lt; text</h2>
16977 <p>section 2</p>
16978
16979 <h2 id="text_&amp;_text"><span id="text_.26_text" typeof="mw:FallbackId"></span>text &amp; text</h2>
16980 <p>section 3</p>
16981
16982 <h2 id="text_'_text"><span id="text_.27_text" typeof="mw:FallbackId"></span>text ' text</h2>
16983 <p>section 4</p>
16984
16985 <h2 id='text_"_text'><span id="text_.22_text" typeof="mw:FallbackId"></span>text " text</h2>
16986 <p>section 5</p>
16987 !! end
16988
16989 !! test
16990 Header with space, plus and underscore as entity
16991 !! wikitext
16992 Id should not contain + for spaces
16993
16994 ==Space between Text==
16995 section 1
16996
16997 ==Space-Entity&#32;between&#32;Text==
16998 section 2
16999
17000 ==Plus+between+Text==
17001 section 3
17002
17003 ==Plus-Entity&#43;between&#43;Text==
17004 section 4
17005
17006 ==Underscore_between_Text==
17007 section 5
17008
17009 ==Underscore-Entity&#95;between&#95;Text==
17010 section 6
17011
17012 [[#Space between Text]]
17013 [[#Space-Entity&#32;between&#32;Text]]
17014 [[#Plus+between+Text]]
17015 [[#Plus-Entity&#43;between&#43;Text]]
17016 [[#Underscore_between_Text]]
17017 [[#Underscore-Entity&#95;between&#95;Text]]
17018 !! html/php
17019 <p>Id should not contain + for spaces
17020 </p>
17021 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
17022 <ul>
17023 <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>
17024 <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>
17025 <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>
17026 <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>
17027 <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>
17028 <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>
17029 </ul>
17030 </div>
17031
17032 <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>
17033 <p>section 1
17034 </p>
17035 <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>
17036 <p>section 2
17037 </p>
17038 <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>
17039 <p>section 3
17040 </p>
17041 <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>
17042 <p>section 4
17043 </p>
17044 <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>
17045 <p>section 5
17046 </p>
17047 <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>
17048 <p>section 6
17049 </p><p><a href="#Space_between_Text">#Space between Text</a>
17050 <a href="#Space-Entity_between_Text">#Space-Entity&#32;between&#32;Text</a>
17051 <a href="#Plus.2Bbetween.2BText">#Plus+between+Text</a>
17052 <a href="#Plus-Entity.2Bbetween.2BText">#Plus-Entity&#43;between&#43;Text</a>
17053 <a href="#Underscore_between_Text">#Underscore_between_Text</a>
17054 <a href="#Underscore-Entity_between_Text">#Underscore-Entity&#95;between&#95;Text</a>
17055 </p>
17056 !! html/parsoid
17057 <p>Id should not contain + for spaces</p>
17058
17059 <h2 id="Space_between_Text">Space between Text</h2>
17060 <p>section 1</p>
17061
17062 <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>
17063 <p>section 2</p>
17064
17065 <h2 id="Plus+between+Text"><span id="Plus.2Bbetween.2BText" typeof="mw:FallbackId"></span>Plus+between+Text</h2>
17066 <p>section 3</p>
17067
17068 <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>
17069 <p>section 4</p>
17070
17071 <h2 id="Underscore_between_Text">Underscore_between_Text</h2>
17072 <p>section 5</p>
17073
17074 <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>
17075 <p>section 6</p>
17076
17077 <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>
17078 <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>
17079 <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>
17080 <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>
17081 <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>
17082 <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>
17083 !! end
17084
17085 # Parsoid html2wt disabled because it adds padding spaces around =
17086 !! test
17087 Headers with excess '=' characters
17088 (Are similar tests necessary beyond the 1st level?)
17089 !! options
17090 parsoid=wt2html,wt2wt,html2html
17091 !! wikitext
17092 =foo==
17093 ==foo=
17094 =''italic'' heading==
17095 ==''italic'' heading=
17096 !! html/php
17097 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
17098 <ul>
17099 <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
17100 <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
17101 <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>
17102 <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>
17103 </ul>
17104 </div>
17105
17106 <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>
17107 <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>
17108 <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>
17109 <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>
17110
17111 !! html/parsoid
17112 <h1 id="foo="><span id="foo.3D" typeof="mw:FallbackId"></span>foo=</h1>
17113 <h1 id="=foo"><span id=".3Dfoo" typeof="mw:FallbackId"></span>=foo</h1>
17114 <h1 id="italic_heading="><span id="italic_heading.3D" typeof="mw:FallbackId"></span><i>italic</i> heading=</h1>
17115 <h1 id="=italic_heading"><span id=".3Ditalic_heading" typeof="mw:FallbackId"></span>=<i>italic</i> heading</h1>
17116 !! end
17117
17118 !! test
17119 HTML headers vs TOC (T25393)
17120 (__NOEDITSECTION__ for clearer output, doesn't matter here)
17121 !! wikitext
17122 <h1>Header 1</h1>
17123 ==Header 1.1==
17124 ==Header 1.2==
17125
17126 <h1>Header 2
17127 </h1>
17128 ==Header 2.1==
17129 ==Header 2.2==
17130 __NOEDITSECTION__
17131 !! html/php
17132 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
17133 <ul>
17134 <li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
17135 <ul>
17136 <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>
17137 <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>
17138 </ul>
17139 </li>
17140 <li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a>
17141 <ul>
17142 <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>
17143 <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>
17144 </ul>
17145 </li>
17146 </ul>
17147 </div>
17148
17149 <h1><span class="mw-headline" id="Header_1">Header 1</span></h1>
17150 <h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2>
17151 <h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2>
17152 <h1><span class="mw-headline" id="Header_2">Header 2
17153 </span></h1>
17154 <h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2>
17155 <h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2>
17156
17157 !! html/parsoid
17158 <h1 id="Header_1" data-parsoid='{"stx":"html"}'>Header 1</h1>
17159 <h2 id="Header_1.1" data-parsoid='{}'>Header 1.1</h2>
17160 <h2 id="Header_1.2" data-parsoid='{}'>Header 1.2</h2>
17161
17162 <h1 id="Header_2" data-parsoid='{"stx":"html"}'>Header 2
17163 </h1>
17164 <h2 id="Header_2.1" data-parsoid='{}'>Header 2.1</h2>
17165 <h2 id="Header_2.2" data-parsoid='{}'>Header 2.2</h2>
17166 <meta property="mw:PageProp/noeditsection"/>
17167 !! end
17168
17169 !! test
17170 Single-line or multiline-comments can follow headings
17171 !! options
17172 parsoid=wt2html,wt2wt
17173 !! wikitext
17174 ==foo==<!---->
17175 ==bar==<!--c1-->
17176 ==baz==<!--
17177 c2
17178 c3-->
17179 !! html/php
17180 <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>
17181 <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>
17182 <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>
17183
17184 !! html/parsoid
17185 <h2 id="foo">foo</h2><!---->
17186 <h2 id="bar">bar</h2><!--c1-->
17187 <h2 id="baz">baz</h2><!--
17188 c2
17189 c3-->
17190 !! end
17191
17192 !! test
17193 T3219 URL next to image (broken)
17194 !! wikitext
17195 http://example.com[[File:Foobar.jpg]]
17196 !! html/php
17197 <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>
17198 </p>
17199 !! html/parsoid
17200 <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>
17201 !!end
17202
17203 !! test
17204 T3186 news: in the middle of text
17205 !! wikitext
17206 http://en.wikinews.org/wiki/Wikinews:Workplace
17207 !! html
17208 <p><a rel="nofollow" class="external free" href="http://en.wikinews.org/wiki/Wikinews:Workplace">http://en.wikinews.org/wiki/Wikinews:Workplace</a>
17209 </p>
17210 !!end
17211
17212
17213 !! test
17214 Namespaced link must have a title
17215 !! wikitext
17216 [[Project:]]
17217 !! html
17218 <p>[[Project:]]
17219 </p>
17220 !!end
17221
17222 !! test
17223 Namespaced link must have a title (bad fragment version)
17224 !! wikitext
17225 [[Project:#fragment]]
17226 !! html
17227 <p>[[Project:#fragment]]
17228 </p>
17229 !!end
17230
17231
17232 ###
17233 ### HTML tags and HTML attributes
17234 ###
17235
17236 !! test
17237 div with no attributes
17238 !! wikitext
17239 <div>HTML rocks</div>
17240 !! html
17241 <div>HTML rocks</div>
17242
17243 !! end
17244
17245 !! test
17246 div with double-quoted attribute
17247 !! wikitext
17248 <div id="rock">HTML rocks</div>
17249 !! html
17250 <div id="rock">HTML rocks</div>
17251
17252 !! end
17253
17254 !! test
17255 div with single-quoted attribute
17256 !! wikitext
17257 <div id='rock'>HTML rocks</div>
17258 !! html
17259 <div id="rock">HTML rocks</div>
17260
17261 !! end
17262
17263 !! test
17264 div with unquoted attribute
17265 !! wikitext
17266 <div id=rock>HTML rocks</div>
17267 !! html
17268 <div id="rock">HTML rocks</div>
17269
17270 !! end
17271
17272 !! test
17273 div with illegal double attributes
17274 !! wikitext
17275 <div id="a" id="b">HTML rocks</div>
17276 !! html
17277 <div id="b">HTML rocks</div>
17278
17279 !!end
17280
17281 !! test
17282 div with empty attribute value, space before equals
17283 !! options
17284 parsoid=wt2html,html2html
17285 !! wikitext
17286 <div class =>HTML rocks</div>
17287 !! html/php
17288 <div class="">HTML rocks</div>
17289
17290 !! html/parsoid
17291 <div class="" data-parsoid='{"stx":"html"}'>HTML rocks</div>
17292 !! end
17293
17294 !! test
17295 div with multiple empty attribute values
17296 !! config
17297 wgFragmentMode=[ 'html5', 'legacy' ]
17298 !! options
17299 parsoid=wt2html,html2html
17300 !! wikitext
17301 <div id= title=>HTML rocks</div>
17302 !! html/php
17303 <div id="title=">HTML rocks</div>
17304
17305 !! html/parsoid
17306 <div id="title=" data-parsoid='{"stx":"html"}'>HTML rocks</div>
17307 !! end
17308
17309 # FIXME Parsoid doesn't actually match PHP here.
17310 # Probably we should use the synthetic <foo /> or <indicator>
17311 # extensions for this test, which are enabled when running parser tests.
17312 !! test
17313 Extension tag in attribute value
17314 !! wikitext
17315 <span title="<translate>123</translate>">ok</span>
17316 !! html/php+disabled
17317 <p>&lt;span title="&lt;translate&gt;123&lt;/translate&gt;"&gt;ok&lt;/span&gt;
17318 </p>
17319 !! html/parsoid
17320 <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>
17321 !! end
17322
17323 !! test
17324 table with multiple empty attribute values
17325 !! options
17326 parsoid=wt2html,html2html
17327 !! wikitext
17328 {| title= id=
17329 |hi
17330 |}
17331 !! html/php
17332 <table title="id=">
17333 <tr>
17334 <td>hi
17335 </td></tr></table>
17336
17337 !! html/parsoid
17338 <table title="id=">
17339 <tbody><tr><td>hi</td></tr>
17340 </tbody></table>
17341 !! end
17342
17343 !! test
17344 div with braces in attribute value
17345 !! wikitext
17346 <div title="{}">Foo</div>
17347 !! html/php
17348 <div title="&#123;&#125;">Foo</div>
17349
17350 !! html/parsoid
17351 <div title="{}">Foo</div>
17352 !! end
17353
17354 !! test
17355 div with empty attribute value, no space before equals
17356 !! options
17357 parsoid=wt2html,html2html
17358 !! wikitext
17359 <div class=>HTML rocks</div>
17360 !! html/php
17361 <div class="">HTML rocks</div>
17362
17363 !! html/parsoid
17364 <div class="">HTML rocks</div>
17365 !! end
17366
17367 !! test
17368 HTML multiple attributes correction
17369 !! wikitext
17370 <p class="error" class="awesome">Awesome!</p>
17371 !! html
17372 <p class="awesome">Awesome!</p>
17373
17374 !!end
17375
17376 !! test
17377 Table multiple attributes correction
17378 !! wikitext
17379 {|
17380 !+ class="error" class="awesome"|status
17381 |}
17382 !! html
17383 <table>
17384 <tr>
17385 <th class="awesome">status
17386 </th></tr></table>
17387
17388 !!end
17389
17390 !! test
17391 DIV IN UPPERCASE
17392 !! wikitext
17393 <DIV ID="x">HTML ROCKS</DIV>
17394 !! html
17395 <div id="x">HTML ROCKS</div>
17396
17397 !!end
17398
17399 !! test
17400 Non-ASCII pseudo-tags are rendered as text
17401 !! wikitext
17402 <khyô>
17403 !! html
17404 <p>&lt;khyô&gt;
17405 </p>
17406 !! end
17407
17408 !! test
17409 Pseudo-tag with URL 'name' renders as url link
17410 !! wikitext
17411 <http://example.com/>
17412 !! html
17413 <p>&lt;<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&gt;
17414 </p>
17415 !! end
17416
17417 !! test
17418 text with amp in the middle of nowhere
17419 !! wikitext
17420 Remember AT&T?
17421 !! html
17422 <p>Remember AT&amp;T?
17423 </p>
17424 !! end
17425
17426 !! test
17427 text with character entity: eacute
17428 !! wikitext
17429 I always thought &eacute; was a cute letter.
17430 !! html+tidy
17431 <p>I always thought &#233; was a cute letter.
17432 </p>
17433 !! end
17434
17435 !! test
17436 text with entity-escaped character entity-like string: eacute
17437 !! wikitext
17438 I always thought &amp;eacute; was a cute letter.
17439 !! html
17440 <p>I always thought &amp;eacute; was a cute letter.
17441 </p>
17442 !! end
17443
17444 !! test
17445 text with undefined character entity: xacute
17446 !! wikitext
17447 I always thought &xacute; was a cute letter.
17448 !! html
17449 <p>I always thought &amp;xacute; was a cute letter.
17450 </p>
17451 !! end
17452
17453 !! test
17454 HTML5 tags
17455 !! wikitext
17456 <data value="5">five</data>
17457 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
17458 <mark>This highlighted text</mark>
17459 !! html
17460 <p><data value="5">five</data>
17461 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
17462 <mark>This highlighted text</mark>
17463 </p>
17464 !! end
17465
17466 !! test
17467 HTML tag with leading space is parsed as text
17468 !! wikitext
17469 < div>foo< /div>
17470 !! html
17471 <p>&lt; div&gt;foo&lt; /div&gt;
17472 </p>
17473 !! end
17474
17475 ## Don't expect Parsoid and PHP to match, since PHP isn't exactly following
17476 ## the HTML5 parsing spec.
17477 !! test
17478 Element with broken attribute syntax
17479 !! options
17480 parsoid=wt2html
17481 !! wikitext
17482 <div style=" style="123">hi</div>
17483 <div =>ho</div>
17484 !! html/php
17485 <div style="123">hi</div>
17486 <div>ho</div>
17487
17488 !! html/parsoid
17489 <div style=" style=" data-parsoid='{"stx":"html","a":{"123\"":null},"sa":{"123\"":""}}'>hi</div>
17490 <div data-parsoid='{"stx":"html","a":{"=":null},"sa":{"=":""}}'>ho</div>
17491 !! end
17492
17493 ###
17494 ### Nesting tests (see T43545, T52604, T53081)
17495 ###
17496
17497 # This test case is fixed in Parsoid by domino 1.0.12. (T52604)
17498 # Note that html2wt is considerably more difficult if we use <b> in
17499 # the test case, instead of <small>
17500 !! test
17501 Ensure that HTML adoption agency algorithm is properly implemented.
17502 !! wikitext
17503 <small>X<small>Y</small>Z</small>
17504 !! html
17505 <p><small>X<small>Y</small>Z</small>
17506 </p>
17507 !! end
17508
17509 # This was T43545 in the PHP parser.
17510 !! test
17511 Nesting of <kbd>
17512 !! wikitext
17513 <kbd>X<kbd>Y</kbd>Z</kbd>
17514 !! html+tidy
17515 <p><kbd>X<kbd>Y</kbd>Z</kbd>
17516 </p>
17517 !! end
17518
17519 # The following cases were T53081 in the PHP parser.
17520 # Note that there are some other nestable tags (b, i, etc) which are
17521 # not covered; see T53081 for discussion.
17522
17523 !! test
17524 Nesting of <em>
17525 !! wikitext
17526 <em>X<em>Y</em>Z</em>
17527 !! html+tidy
17528 <p><em>X<em>Y</em>Z</em>
17529 </p>
17530 !! end
17531
17532 !! test
17533 Nesting of <strong>
17534 !! wikitext
17535 <strong>X<strong>Y</strong>Z</strong>
17536 !! html+tidy
17537 <p><strong>X<strong>Y</strong>Z</strong>
17538 </p>
17539 !! end
17540
17541 !! test
17542 Nesting of <q>
17543 !! wikitext
17544 <q>X<q>Y</q>Z</q>
17545 !! html+tidy
17546 <p><q>X<q>Y</q>Z</q>
17547 </p>
17548 !! end
17549
17550 !! test
17551 Nesting of <ruby>
17552 !! wikitext
17553 <ruby>X<ruby>Y</ruby>Z</ruby>
17554 !! html
17555 <p><ruby>X<ruby>Y</ruby>Z</ruby>
17556 </p>
17557 !! end
17558
17559 !! test
17560 Nesting of <bdo>
17561 !! wikitext
17562 <bdo>X<bdo>Y</bdo>Z</bdo>
17563 !! html
17564 <p><bdo>X<bdo>Y</bdo>Z</bdo>
17565 </p>
17566 !! end
17567
17568
17569 ###
17570 ### Media links
17571 ###
17572
17573 !! test
17574 Media link
17575 !! wikitext
17576 [[Media:Foobar.jpg]]
17577 [[Media:Video.ogv]]
17578 [[:Media:Video.ogv]]
17579 !! html/php
17580 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a>
17581 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
17582 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
17583 </p>
17584 !! html/parsoid
17585 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a>
17586 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" title="Video.ogv">Media:Video.ogv</a>
17587 <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>
17588 !! end
17589
17590 !! test
17591 Media link with text
17592 !! wikitext
17593 [[Media:Foobar.jpg|A neat file to look at]]
17594 !! html/php
17595 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">A neat file to look at</a>
17596 </p>
17597 !! html/parsoid
17598 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
17599 !! end
17600
17601 # FIXME: this is still bad HTML tag nesting
17602 # FIXME: doBlockLevels won't wrap this in a paragraph because it contains a div
17603 # Parsoid & Remex fix the p-wrapping since they operate on the DOM.
17604 !! test
17605 Media link with nasty text
17606 !! wikitext
17607 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
17608 !! html/php
17609 <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>
17610
17611 !! html/php+tidy
17612 <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>
17613 !! html/parsoid
17614 <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>
17615
17616 !! end
17617
17618 !! test
17619 Media link to nonexistent file (T3702)
17620 !! wikitext
17621 [[Media:No such.jpg]]
17622 [[Media:No_such file.jpg]]
17623 !! html/php
17624 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a>
17625 <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>
17626 </p>
17627 !! html/parsoid
17628 <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>
17629 <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>
17630 !! end
17631
17632 !! test
17633 Image link to nonexistent file (T3850 - good)
17634 !! wikitext
17635 [[File:No_such.jpg]]
17636 !! html/php
17637 <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>
17638 </p>
17639 !! html/parsoid
17640 <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>
17641 !! end
17642
17643 !! test
17644 :Image link to nonexistent file (T3850 - bad)
17645 !! wikitext
17646 [[:Image:No such.jpg]]
17647 !! html/php
17648 <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>
17649 </p>
17650 !! html/parsoid
17651 <p><a rel="mw:WikiLink" href="./File:No_such.jpg" title="File:No such.jpg">Image:No such.jpg</a></p>
17652 !! end
17653
17654 !! test
17655 Character reference normalization in link text (T3938)
17656 !! wikitext
17657 [[Main Page|this&that]]
17658 !! html
17659 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
17660 </p>
17661 !!end
17662
17663 !! article
17664 אַ
17665 !! text
17666 Test for unicode normalization
17667
17668 The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
17669 !! endarticle
17670
17671 !! test
17672 (T21451) Links should refer to the normalized form.
17673 !! wikitext
17674 [[&#xFB2E;]]
17675 [[&#x5d0;&#x5b7;]]
17676 [[&#x5d0;ַ]]
17677 [[א&#x5b7;]]
17678 [[אַ]]
17679 !! html
17680 <p><a href="/wiki/%D7%90%D6%B7" title="אַ">&#xfb2e;</a>
17681 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;&#x5b7;</a>
17682 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;ַ</a>
17683 <a href="/wiki/%D7%90%D6%B7" title="אַ">א&#x5b7;</a>
17684 <a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a>
17685 </p>
17686 !! end
17687
17688 !! test
17689 Empty attribute crash test (T4067)
17690 !! wikitext
17691 <font color="">foo</font>
17692 !! html
17693 <p><font color="">foo</font>
17694 </p>
17695 !! end
17696
17697 !! test
17698 Empty attribute crash test single-quotes (T4067)
17699 !! wikitext
17700 <font color=''>foo</font>
17701 !! html
17702 <p><font color="">foo</font>
17703 </p>
17704 !! end
17705
17706 !! test
17707 Attribute test: equals, then nothing
17708 !! options
17709 parsoid=wt2html,html2html
17710 !! wikitext
17711 <font color=>foo</font>
17712 !! html/php
17713 <p><font color="">foo</font>
17714 </p>
17715 !! html/parsoid
17716 <p><font color="" data-parsoid='{"stx":"html"}'>foo</font></p>
17717 !! end
17718
17719 !! test
17720 Attribute test: unquoted value
17721 !! options
17722 parsoid=wt2html,html2html
17723 !! wikitext
17724 <font color=x>foo</font>
17725 !! html/php
17726 <p><font color="x">foo</font>
17727 </p>
17728 !! html/parsoid
17729 <p><font color="x" data-parsoid='{"stx":"html"}'>foo</font></p>
17730 !! end
17731
17732 !! test
17733 Attribute test: unquoted but illegal value (hash)
17734 !! wikitext
17735 <font color=#x>foo</font>
17736 !! html
17737 <p><font color="#x">foo</font>
17738 </p>
17739 !! end
17740
17741 # Parsoid does not serialize to empty attribute syntax,
17742 # so wt2wt and html2wt cases are skipped
17743 !! test
17744 Attribute test: no value (T54330)
17745 !! options
17746 parsoid=wt2html,html2html
17747 !! wikitext
17748 <font color>foo</font>
17749 !! html/php
17750 <p><font color="">foo</font>
17751 </p>
17752 !! html/parsoid
17753 <p><font color="">foo</font></p>
17754 !! end
17755
17756 !! test
17757 T4095: link with three closing brackets
17758 !! wikitext
17759 [[Main Page]]]
17760 !! html/php
17761 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
17762 </p>
17763 !! html/parsoid
17764 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>]</p>
17765 !! end
17766
17767 !! test
17768 T4095: link with pipe and three closing brackets
17769 !! wikitext
17770 [[Main Page|link]]]
17771 !! html/php
17772 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
17773 </p>
17774 !! html/parsoid
17775 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">link</a>]</p>
17776 !! end
17777
17778 !! test
17779 T4095: link with pipe and three closing brackets, version 2
17780 !! wikitext
17781 [[Main Page|[http://example.com/]]]
17782 !! html/php
17783 <p><a href="/wiki/Main_Page" title="Main Page">[http://example.com/]</a>
17784 </p>
17785 !! html/parsoid
17786 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">[http://example.com/]</a></p>
17787 !! end
17788
17789
17790 ###
17791 ### Safety
17792 ###
17793
17794 !! article
17795 Template:Dangerous attribute
17796 !! text
17797 " onmouseover="alert(document.cookie)
17798 !! endarticle
17799
17800 !! article
17801 Template:Dangerous style attribute
17802 !! text
17803 border-size: expression(alert(document.cookie))
17804 !! endarticle
17805
17806 !! article
17807 Template:Div style
17808 !! text
17809 <div style="float: right; {{{1}}}">Magic div</div>
17810 !! endarticle
17811
17812 !! test
17813 T4304: HTML attribute safety (safe template; regression T4309)
17814 !! wikitext
17815 <div title="{{test}}"></div>
17816 !! html/php
17817 <div title="This is a test template"></div>
17818
17819 !! html/parsoid
17820 <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>
17821 !! end
17822
17823 # Parsoid has enough context to handle this case
17824 !! test
17825 T4304: HTML attribute safety (dangerous template; 2309)
17826 !! wikitext
17827 <div title="{{dangerous attribute}}"></div>
17828 !! html/php
17829 <div title=""></div>
17830
17831 !! html/parsoid
17832 <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>
17833 !! end
17834
17835 !! test
17836 T4304: HTML attribute safety (dangerous style template; 2309)
17837 !! wikitext
17838 <div style="{{dangerous style attribute}}"></div>
17839 !! html/php
17840 <div style="/* insecure input */"></div>
17841
17842 !! html/parsoid
17843 <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>
17844 !! end
17845
17846 !! test
17847 T4304: HTML attribute safety (safe parameter; 2309)
17848 !! wikitext
17849 {{div style|width: 200px}}
17850 !! html/php
17851 <div style="float: right; width: 200px">Magic div</div>
17852
17853 !! html/parsoid
17854 <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>
17855 !! end
17856
17857 !! test
17858 T4304: HTML attribute safety (unsafe parameter; 2309)
17859 !! wikitext
17860 {{div style|width: expression(alert(document.cookie))}}
17861 !! html/php
17862 <div style="/* insecure input */">Magic div</div>
17863
17864 !! html/parsoid
17865 <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>
17866 !! end
17867
17868 ## Parsoid output here differs; needs investigation.
17869 !! test
17870 T4304: HTML attribute safety (unsafe breakout parameter; 2309)
17871 !! wikitext
17872 {{div style|"><script>alert(document.cookie)</script>}}
17873 !! html
17874 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17875
17876 !! end
17877
17878 ## Parsoid output here differs; needs investigation.
17879 !! test
17880 T4304: HTML attribute safety (unsafe breakout parameter 2; 2309)
17881 !! wikitext
17882 {{div style|" ><script>alert(document.cookie)</script>}}
17883 !! html
17884 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17885
17886 !! end
17887
17888 !! test
17889 T4304: HTML attribute safety (link)
17890 !! wikitext
17891 <div title="[[Main Page]]"></div>
17892 !! html/php
17893 <div title="&#91;&#91;Main Page&#93;&#93;"></div>
17894
17895 !! html/parsoid
17896 <div title="[[Main Page]]"></div>
17897 !! end
17898
17899 !! test
17900 T4304: HTML attribute safety (italics)
17901 !! wikitext
17902 <div title="''foobar''"></div>
17903 !! html
17904 <div title="&#39;&#39;foobar&#39;&#39;"></div>
17905
17906 !! end
17907
17908 !! test
17909 T4304: HTML attribute safety (bold)
17910 !! wikitext
17911 <div title="'''foobar'''"></div>
17912 !! html
17913 <div title="&#39;&#39;&#39;foobar&#39;&#39;&#39;"></div>
17914
17915 !! end
17916
17917 !! test
17918 T4304: HTML attribute safety (ISBN)
17919 !! wikitext
17920 <div title="ISBN 1234567890"></div>
17921 !! html
17922 <div title="&#73;SBN 1234567890"></div>
17923
17924 !! end
17925
17926 !! test
17927 T4304: HTML attribute safety (RFC)
17928 !! wikitext
17929 <div title="RFC 1234"></div>
17930 !! html
17931 <div title="&#82;FC 1234"></div>
17932
17933 !! end
17934
17935 !! test
17936 T4304: HTML attribute safety (PMID)
17937 !! wikitext
17938 <div title="PMID 1234567890"></div>
17939 !! html
17940 <div title="&#80;MID 1234567890"></div>
17941
17942 !! end
17943
17944 !! test
17945 T4304: HTML attribute safety (web link)
17946 !! wikitext
17947 <div title="http://example.com/"></div>
17948 !! html
17949 <div title="http&#58;//example.com/"></div>
17950
17951 !! end
17952
17953 !! test
17954 T4304: HTML attribute safety (named web link)
17955 !! wikitext
17956 <div title="[http://example.com/ link]"></div>
17957 !! html/php
17958 <div title="&#91;http&#58;//example.com/ link&#93;"></div>
17959
17960 !! html/parsoid
17961 <div title="[http://example.com/ link]"></div>
17962 !! end
17963
17964 !! test
17965 T5244: HTML attribute safety (extension; safe)
17966 !! wikitext
17967 <div style="<nowiki>background:blue</nowiki>"></div>
17968 !! html/php
17969 <div style="background:blue"></div>
17970
17971 !! html/parsoid
17972 <div style="background:blue" data-parsoid='{"stx":"html","a":{"style":"background:blue"},"sa":{"style":"&lt;nowiki>background:blue&lt;/nowiki>"}}'></div>
17973 !! end
17974
17975 !! test
17976 T5244: HTML attribute safety (extension; unsafe)
17977 !! wikitext
17978 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
17979 !! html/php
17980 <div style="/* insecure input */"></div>
17981
17982 !! html/parsoid
17983 <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>
17984 !! end
17985
17986 # More MSIE fun discovered by Tom Gilder
17987
17988 !! test
17989 MSIE CSS safety test: spurious slash
17990 !! wikitext
17991 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
17992 !! html/php
17993 <div style="/* insecure input */">evil</div>
17994
17995 !! html/parsoid
17996 <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>
17997 !! end
17998
17999 !! test
18000 MSIE CSS safety test: hex code
18001 !! wikitext
18002 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
18003 !! html/php
18004 <div style="/* insecure input */">evil</div>
18005
18006 !! html/parsoid
18007 <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>
18008 !! end
18009
18010 !! test
18011 MSIE CSS safety test: comment in url
18012 !! wikitext
18013 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
18014 !! html/php
18015 <div style="background-image:u rl(javascript:alert(&#39;boo&#39;))">evil</div>
18016
18017 !! html/parsoid
18018 <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>
18019 !! end
18020
18021 !! test
18022 MSIE CSS safety test: comment in expression
18023 !! wikitext
18024 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
18025 !! html/php
18026 <div style="background-image:expres sion(alert(&#39;boo4&#39;))">evil4</div>
18027
18028 !! html/parsoid
18029 <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>
18030 !! end
18031
18032 !! test
18033 CSS safety test (all browsers): vertical tab (T57332 / CVE-2013-4567)
18034 !! wikitext
18035 <p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p>
18036 !! html/php
18037 <p style="/* invalid control char */">A</p>
18038
18039 !! html/parsoid
18040 <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>
18041 !! end
18042
18043 !! test
18044 MSIE 6 CSS safety test: Fullwidth (T57332)
18045 !! wikitext
18046 <p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p>
18047 <div style="top:EXPRESSION(alert())">B</div>
18048 !! html/php
18049 <p style="/* insecure input */">A</p>
18050 <div style="/* insecure input */">B</div>
18051
18052 !! html/parsoid
18053 <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>
18054 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"top:EXPRESSION(alert())"}}'>B</div>
18055 !! end
18056
18057 !! test
18058 MSIE 6 CSS safety test: IPA extensions (T57332)
18059 !! wikitext
18060 <div style="background-image:uʀʟ(javascript:alert())">A</div>
18061 <p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p>
18062 !! html/php
18063 <div style="/* insecure input */">A</div>
18064 <p style="/* insecure input */">B</p>
18065
18066 !! html/parsoid
18067 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:uʀʟ(javascript:alert())"}}'>A</div>
18068 <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>
18069 !! end
18070
18071 !! test
18072 MSIE 6 CSS safety test: sup/sub script (T57332)
18073 !! wikitext
18074 <div style="background-image:url⁽javascript:alert())">A</div>
18075 <div style="background-image:url₍javascript:alert())">B</div>
18076 <p style="font-size: 100px; color: expressioⁿ((title='XSSed'),'red')">C</p>
18077 !! html/php
18078 <div style="/* insecure input */">A</div>
18079 <div style="/* insecure input */">B</div>
18080 <p style="/* insecure input */">C</p>
18081
18082 !! html/parsoid
18083 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url⁽javascript:alert())"}}'>A</div>
18084 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url₍javascript:alert())"}}'>B</div>
18085 <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>
18086 !! end
18087
18088 !! test
18089 Opera -o-link CSS
18090 !! options
18091 parsoid=wt2html,html2html
18092 !! wikitext
18093 <div
18094 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;"
18095 style="-o-link:attr(title);-o-link-source:current">X</div>
18096 !! html/php
18097 <div title="data:text/html,&lt;img src=1 onerror=alert(1)&gt;" style="/* insecure input */">X</div>
18098
18099 !! html/parsoid
18100 <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>
18101 !! end
18102
18103 !! test
18104 MSIE 6 CSS safety test: Repetition markers (T57332)
18105 !! wikitext
18106 <p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p>
18107 <p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p>
18108 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">C</p>
18109 <p style="font-size: 100px; color: expresヽion((title='XSSed'),'red')">D</p>
18110 <p style="font-size: 100px; color: expresﹽion((title='XSSed'),'red')">E</p>
18111 <p style="font-size: 100px; color: expresﹼion((title='XSSed'),'red')">F</p>
18112 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">G</p>
18113 !! html/php
18114 <p style="/* insecure input */">A</p>
18115 <p style="/* insecure input */">B</p>
18116 <p style="/* insecure input */">C</p>
18117 <p style="/* insecure input */">D</p>
18118 <p style="/* insecure input */">E</p>
18119 <p style="/* insecure input */">F</p>
18120 <p style="/* insecure input */">G</p>
18121
18122 !! html/parsoid
18123 <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>
18124 <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>
18125 <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>
18126 <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>
18127 <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>
18128 <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>
18129 <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>
18130 !! end
18131
18132 !! test
18133 Table attribute legitimate extension
18134 !! wikitext
18135 {|
18136 !+ style="<nowiki>color:blue</nowiki>"|status
18137 |}
18138 !! html
18139 <table>
18140 <tr>
18141 <th style="color:blue">status
18142 </th></tr></table>
18143
18144 !!end
18145
18146 !! test
18147 Table attribute safety
18148 !! wikitext
18149 {|
18150 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"|status
18151 |}
18152 !! html
18153 <table>
18154 <tr>
18155 <th style="/* insecure input */">status
18156 </th></tr></table>
18157
18158 !! end
18159
18160 !! test
18161 CSS line continuation 1
18162 !! wikitext
18163 <div style="background-image: u\&#10;rl(test.jpg);"></div>
18164 !! html
18165 <div style="/* insecure input */"></div>
18166
18167 !! end
18168
18169 !! test
18170 CSS line continuation 2
18171 !! wikitext
18172 <div style="background-image: u\&#13;rl(test.jpg); "></div>
18173 !! html
18174 <div style="/* invalid control char */"></div>
18175
18176 !! end
18177
18178 !! article
18179 Template:Identity
18180 !! text
18181 {{{1}}}
18182 !! endarticle
18183
18184 !! test
18185 Expansion of multi-line templates in attribute values (T8255)
18186 !! wikitext
18187 <div style="background: {{identity|#00FF00}}">-</div>
18188 !! html
18189 <div style="background: #00FF00">-</div>
18190
18191 !! end
18192
18193 !! test
18194 Expansion of multi-line templates in attribute values (T8255 sanity check)
18195 !! wikitext
18196 <div style="background:
18197 #00FF00">-</div>
18198 !! html/php
18199 <div style="background: #00FF00">-</div>
18200
18201 !! html/parsoid
18202 <div style="background:
18203 #00FF00">-</div>
18204 !! end
18205
18206 !! test
18207 Expansion of multi-line templates in attribute values (T8255 sanity check 2)
18208 !! wikitext
18209 <div style="background: &#10;#00FF00">-</div>
18210 !! html
18211 <div style="background: &#10;#00FF00">-</div>
18212
18213 !! end
18214
18215 !! test
18216 Tags which are hidden from tidiers cannot pass through the Sanitizer
18217 !! wikitext
18218 <mw:toc><script>alert();</script></mw:toc>
18219 !! html+tidy
18220 <p>&lt;mw:toc&gt;&lt;script&gt;alert();&lt;/script&gt;&lt;/mw:toc&gt;
18221 </p>
18222 !! end
18223
18224 ###
18225 ### Parser hooks (see tests/parser/parserTestsParserHook.php for the <tag> extension)
18226 ###
18227
18228 !! test
18229 Parser hook: empty input
18230 !! wikitext
18231 <tag></tag>
18232 !! html/php
18233 <pre>
18234 ''
18235 array (
18236 )
18237 </pre>
18238
18239 !! html/parsoid
18240 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18241 !! end
18242
18243 ## Don't expect parsoid to rt this form.
18244 !! test
18245 Parser hook: empty input using terminated empty elements
18246 !! options
18247 parsoid=wt2html,html2html
18248 !! wikitext
18249 <tag/>
18250 !! html/php
18251 <pre>
18252 NULL
18253 array (
18254 )
18255 </pre>
18256
18257 !! html/parsoid
18258 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
18259 !! end
18260
18261 !! test
18262 Parser hook: empty input using terminated empty elements (space before)
18263 !! wikitext
18264 <tag />
18265 !! html/php
18266 <pre>
18267 NULL
18268 array (
18269 )
18270 </pre>
18271
18272 !! html/parsoid
18273 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
18274 !! end
18275
18276 !! test
18277 Parser hook: basic input
18278 !! wikitext
18279 <tag>input</tag>
18280 !! html/php
18281 <pre>
18282 'input'
18283 array (
18284 )
18285 </pre>
18286
18287 !! html/parsoid
18288 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18289 !! end
18290
18291 ## Don't expect parsoid to rt this form.
18292 !! test
18293 Parser hook: case insensitive
18294 !! options
18295 parsoid=wt2html,html2html
18296 !! wikitext
18297 <TAG>input</TAG>
18298 !! html/php
18299 <pre>
18300 'input'
18301 array (
18302 )
18303 </pre>
18304
18305 !! html/parsoid
18306 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18307 !! end
18308
18309 ## Don't expect parsoid to rt this form.
18310 !! test
18311 Parser hook: case insensitive, redux
18312 !! options
18313 parsoid=wt2html,html2html
18314 !! wikitext
18315 <TaG>input</TAg>
18316 !! html/php
18317 <pre>
18318 'input'
18319 array (
18320 )
18321 </pre>
18322
18323 !! html/parsoid
18324 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18325 !! end
18326
18327 !! test
18328 Parser hook: nested tags
18329 !! wikitext
18330 <tag><tag></tag></tag>
18331 !! html/php
18332 <pre>
18333 '<tag>'
18334 array (
18335 )
18336 </pre>&lt;/tag&gt;
18337
18338 !! html/parsoid
18339 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"&lt;tag>"}}' data-parsoid='{}' about="#mwt2"></pre>&lt;/tag>
18340 !! end
18341
18342 !! test
18343 Parser hook: basic arguments
18344 !! wikitext
18345 <tag width="200" height="100" depth="50" square=""></tag>
18346 !! html/php
18347 <pre>
18348 ''
18349 array (
18350 'width' => '200',
18351 'height' => '100',
18352 'depth' => '50',
18353 'square' => '',
18354 )
18355 </pre>
18356
18357 !! html/parsoid
18358 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18359 !! end
18360
18361 ## Don't expect parsoid to rt this form.
18362 !! test
18363 Parser hook: basic arguments, variations
18364 !! options
18365 parsoid=wt2html,html2html
18366 !! wikitext
18367 <tag width=200 height = "100" depth = '50' square></tag>
18368 !! html/php
18369 <pre>
18370 ''
18371 array (
18372 'width' => '200',
18373 'height' => '100',
18374 'depth' => '50',
18375 'square' => '',
18376 )
18377 </pre>
18378
18379 !! html/parsoid
18380 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18381 !! end
18382
18383 !! test
18384 Parser hook: argument containing a forward slash (T7344)
18385 !! wikitext
18386 <tag filename="/tmp/bla"></tag>
18387 !! html/php
18388 <pre>
18389 ''
18390 array (
18391 'filename' => '/tmp/bla',
18392 )
18393 </pre>
18394
18395 !! html/parsoid
18396 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"filename":"/tmp/bla"},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18397 !! end
18398
18399 ## Don't expect parsoid to rt this form.
18400 !! test
18401 Parser hook: empty input using terminated empty elements (T4374)
18402 !! options
18403 parsoid=wt2html,html2html
18404 !! wikitext
18405 <tag foo=bar/>text
18406 !! html/php
18407 <pre>
18408 NULL
18409 array (
18410 'foo' => 'bar',
18411 )
18412 </pre>text
18413
18414 !! html/parsoid
18415 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"foo":"bar"},"body":null}' data-parsoid='{}' about="#mwt2"></pre>text
18416 !! end
18417
18418 ## </tag> should be output literally since there is no matching tag that begins it
18419 ## Don't expect parsoid to rt this form.
18420 !! test
18421 Parser hook: basic arguments using terminated empty elements (T4374)
18422 !! options
18423 parsoid=wt2html
18424 !! wikitext
18425 <tag width=200 height = "100" depth = '50' square/>
18426 other stuff
18427 </tag>
18428 !! html/php
18429 <pre>
18430 NULL
18431 array (
18432 'width' => '200',
18433 'height' => '100',
18434 'depth' => '50',
18435 'square' => '',
18436 )
18437 </pre>
18438 <p>other stuff
18439 &lt;/tag&gt;
18440 </p>
18441 !! html/parsoid
18442 <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
18443 &lt;/tag></p>
18444 !! end
18445
18446 ## Don't expect parsoid to rt this form.
18447 !! test
18448 Parser hook: Don't allow unclosed extension tags
18449 !! options
18450 parsoid=wt2html
18451 !! wikitext
18452 test <tag>123
18453
18454 this is a '''test'''
18455 !! html/php
18456 <p>test &lt;tag&gt;123
18457 </p><p>this is a <b>test</b>
18458 </p>
18459 !! html/parsoid
18460 <p>test &lt;tag>123</p>
18461
18462 <p>this is a <b>test</b></p>
18463 !! end
18464
18465 !! test
18466 Parser hook: horizontal rule inside extension tag that outputs <pre>
18467 !! wikitext
18468 <tag>
18469 Hello
18470 <hr/>
18471 Goodbye
18472 </tag>
18473 !! html/php
18474 <pre>
18475 '
18476 Hello
18477 <hr/>
18478 Goodbye
18479 '
18480 array (
18481 )
18482 </pre>
18483
18484 !! end
18485
18486 ###
18487 ### (see tests/parser/parserTestsParserHook.php for the <statictag> extension)
18488 ###
18489
18490 !! test
18491 Parser hook: static parser hook not inside a comment
18492 !! wikitext
18493 <statictag>hello, world</statictag>
18494
18495 <statictag action="flush" />
18496 !! html/php
18497 <p><br />
18498 hello, world
18499 </p>
18500 !! html/parsoid
18501 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{},"body":{"extsrc":"hello, world"}}' data-parsoid='{}' about="#mwt2"></span></p>
18502 <p typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about="#mwt4">hello, world</p>
18503 !! end
18504
18505 !! test
18506 Parser hook: static parser hook inside a comment
18507 !! wikitext
18508 <!-- <statictag>hello, world</statictag> -->
18509 <statictag action="flush" />
18510 !! html/php
18511 <p><br />
18512 </p>
18513 !! html/parsoid
18514 <!-- <statictag&#x3E;hello, world</statictag&#x3E; -->
18515 <p typeof='mw:Extension/statictag' data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about='#mwt2'></p>
18516 !! end
18517
18518 # Nested template calls; this case was broken by Parser.php rev 1.506,
18519 # since reverted.
18520
18521 !! article
18522 Template:One-parameter
18523 !! text
18524 (My parameter is: {{{1}}})
18525 !! endarticle
18526
18527 !! article
18528 Template:Map-one-parameter
18529 !! text
18530 {{{{{1}}}|{{{2}}}}}
18531 !! endarticle
18532
18533 !! test
18534 Nested template calls
18535 !! wikitext
18536 {{Map-one-parameter|One-parameter|param}}
18537 !! html
18538 <p>(My parameter is: param)
18539 </p>
18540 !! end
18541
18542
18543 ###
18544 ### Sanitizer
18545 ###
18546
18547 # Remex wraps empty tag runs with p-tags.
18548 # Parsoid strips them out during p-wrapping.
18549 !! test
18550 Sanitizer: Closing of open tags
18551 !! wikitext
18552 <s></s><table></table>
18553 !! html/php+tidy
18554 <p><s></s></p><table></table>
18555 !! html/parsoid
18556 <s></s><table></table>
18557 !! end
18558
18559 !! test
18560 Sanitizer: Closing of open but not closed tags
18561 !! wikitext
18562 <s>foo
18563 !! html
18564 <p><s>foo</s>
18565 </p>
18566 !! end
18567
18568 !! test
18569 Sanitizer: Closing of closed but not open tags
18570 !! options
18571 parsoid=wt2html
18572 !! wikitext
18573 </s>
18574 !! html/php+tidy
18575 <p class="mw-empty-elt">
18576 </p>
18577 !! html/parsoid
18578 !! end
18579
18580 !! test
18581 Sanitizer: Closing of closed but not open table tags
18582 !! options
18583 parsoid=wt2html
18584 !! wikitext
18585 Table not started</td></tr></table>
18586 !! html+tidy
18587 <p>Table not started
18588 </p>
18589 !! end
18590
18591 !! test
18592 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
18593 !! config
18594 wgFragmentMode=[ 'html5', 'legacy' ]
18595 !! wikitext
18596 <span id="æ: v">byte</span>[[#æ: v|backlink]]
18597 !! html/php
18598 <p><span id="æ:_v">byte</span><a href="#æ:_v">backlink</a>
18599 </p>
18600 !! html/parsoid
18601 <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>
18602 !! end
18603
18604 !! test
18605 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id="" (legacy)
18606 !! config
18607 wgFragmentMode=[ 'legacy' ]
18608 !! wikitext
18609 <span id="æ: v">byte</span>[[#æ: v|backlink]]
18610 !! html/php
18611 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v">backlink</a>
18612 </p>
18613 !! end
18614
18615 # In HTML5, the restrictions are that id must contain at least one character,
18616 # and must not contain any space characters.
18617 !! test
18618 Sanitizer: Validating the contents of the id attribute (T6515)
18619 !! options
18620 disabled
18621 !! wikitext
18622 <br id="" /><br id="a space" />
18623 !! html
18624 Something ...
18625 !! end
18626
18627 # In HTML5, id must be unique amongst all the ids in the element's home subtree.
18628 !! test
18629 Sanitizer: Validating id attribute uniqueness (T6515, T8301)
18630 !! options
18631 disabled
18632 !! wikitext
18633 <br id="foo" /><br id="foo" />
18634 !! html
18635 Something need to be done. foo-2 ?
18636 !! end
18637
18638 !! test
18639 Sanitizer: Validating that <meta> and <link> work, but only for Microdata
18640 !! wikitext
18641 <div itemscope>
18642 <meta itemprop="hello" content="world">
18643 <meta http-equiv="refresh" content="5">
18644 <meta itemprop="hello" http-equiv="refresh" content="5">
18645 <link itemprop="hello" href="{{SERVER}}">
18646 <link rel="stylesheet" href="{{SERVER}}">
18647 <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
18648 </div>
18649 !! html
18650 <div itemscope="">
18651 <p> <meta itemprop="hello" content="world" />
18652 &lt;meta http-equiv="refresh" content="5"&gt;
18653 <meta itemprop="hello" content="5" />
18654 <link itemprop="hello" href="http&#58;//example.org" />
18655 &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"&gt;
18656 <link itemprop="hello" href="http&#58;//example.org" />
18657 </p>
18658 </div>
18659
18660 !! end
18661
18662 !! test
18663 Sanitizer: Strip comments from CSS attributes
18664 !! options
18665 parsoid=wt2html,wt2wt
18666 !! wikitext
18667 <span style="margin:/*negate mbox-text padding */-0.125em -0.45em; /*rainbow*/rgba(255, 0, 0, 0.3)">2013</span>
18668 !! html/php
18669 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span>
18670 </p>
18671 !! html/parsoid
18672 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span></p>
18673 !! end
18674
18675 !! test
18676 Sanitizer: Avoid unnecessary percent encoded characters in interwiki links
18677 !! wikitext
18678 [[meatball:Soft"Security]]
18679 !! html/php
18680 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Soft%22Security" class="extiw" title="meatball:Soft&quot;Security">meatball:Soft"Security</a>
18681 </p>
18682 !! html/parsoid
18683 <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>
18684 !! end
18685
18686 !! test
18687 Sanitizer: angle brackets are invalid, even in interwiki links (T182338)
18688 !! wikitext
18689 [[meatball:Foo<Bar]]
18690 [[meatball:Foo>Bar]]
18691 [[meatball:Foo&lt;bar]]
18692 [[meatball:Foo&gt;bar]]
18693 !! html/php
18694 <p>[[meatball:Foo&lt;Bar]]
18695 [[meatball:Foo&gt;Bar]]
18696 [[meatball:Foo&lt;bar]]
18697 [[meatball:Foo&gt;bar]]
18698 </p>
18699 !! html/parsoid
18700 <p>[[meatball:Foo&lt;Bar]]
18701 [[meatball:Foo>Bar]]
18702 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span>bar]]
18703 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;gt;","srcContent":">"}'>></span>bar]]</p>
18704 !! end
18705
18706 !! test
18707 Language converter: output gets cut off unexpectedly (T7757)
18708 !! options
18709 language=zh
18710 !! wikitext
18711 this bit is safe: }-
18712
18713 but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}-
18714
18715 then we get cut off here: }-
18716
18717 all additional text is vanished
18718 !! html/php
18719 <p>this bit is safe: }-
18720 </p><p>but if we add a conversion instance: xxx
18721 </p><p>then we get cut off here: }-
18722 </p><p>all additional text is vanished
18723 </p>
18724 !! html/parsoid
18725 <p>this bit is safe: }-</p>
18726 <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>
18727 <p>then we get cut off here: }-</p>
18728 <p>all additional text is vanished</p>
18729 !! end
18730
18731 !! test
18732 Language converter glossary rules inside attributes (T119158)
18733 !! options
18734 language=sr variant=sr-el
18735 !! wikitext
18736 -{H|foAjrjvi=>sr-el:" onload="alert(1)" data-foo="}-
18737
18738 [[File:Foobar.jpg|alt=-{}-foAjrjvi-{}-]]
18739 !! html/php
18740 <p>
18741 </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>
18742 </p>
18743 !! html/parsoid
18744 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"foAjrjvi","l":"sr-el","t":"\" onload=\"alert(1)\" data-foo=\""}]}'/></p>
18745
18746 <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>
18747 !! end
18748
18749 !! test
18750 Self closed html pairs (T7487)
18751 !! wikitext
18752 <center><font id="bug" />Centered text</center>
18753 <div><font id="bug2" />In div text</div>
18754 !! html+tidy
18755 <center><font id="bug"></font>Centered text</center>
18756 <div><font id="bug2"></font>In div text</div>
18757 !! end
18758
18759 !! test
18760 Punctuation: nbsp before exclamation
18761 !! wikitext
18762 C'est grave !
18763 !! html
18764 <p>C'est grave&#160;!
18765 </p>
18766 !! end
18767
18768 !! test
18769 Punctuation: CSS !important (T13874)
18770 !! wikitext
18771 <div style="width:50% !important">important</div>
18772 !! html
18773 <div style="width:50% !important">important</div>
18774
18775 !!end
18776
18777 !! test
18778 Punctuation: CSS ! important (T13874; with space after)
18779 !! wikitext
18780 <div style="width:50% ! important">important</div>
18781 !! html
18782 <div style="width:50%&#32;! important">important</div>
18783
18784 !!end
18785
18786 !! test
18787 HTML bullet list, closed tags (T7497)
18788 !! wikitext
18789 <ul>
18790 <li>One</li>
18791 <li>Two</li>
18792 </ul>
18793 !! html/php
18794 <ul>
18795 <li>One</li>
18796 <li>Two</li>
18797 </ul>
18798
18799 !! html/parsoid
18800 <ul data-parsoid='{"stx":"html"}'>
18801 <li data-parsoid='{"stx":"html"}'>One</li>
18802 <li data-parsoid='{"stx":"html"}'>Two</li>
18803 </ul>
18804
18805 !! end
18806
18807 !! test
18808 HTML bullet list, unclosed tags (T7497)
18809 !! wikitext
18810 <ul>
18811 <li>One
18812 <li>Two
18813 </ul>
18814 !! html/php+tidy
18815 <ul>
18816 <li>One
18817 </li><li>Two
18818 </li></ul>
18819 !! html/parsoid
18820 <ul data-parsoid='{"stx":"html"}'>
18821 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18822 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18823 </ul>
18824
18825 !! end
18826
18827 !! test
18828 HTML ordered list, closed tags (T7497)
18829 !! wikitext
18830 <ol>
18831 <li>One</li>
18832 <li>Two</li>
18833 </ol>
18834 !! html/php
18835 <ol>
18836 <li>One</li>
18837 <li>Two</li>
18838 </ol>
18839
18840 !! html/parsoid
18841 <ol data-parsoid='{"stx":"html"}'>
18842 <li data-parsoid='{"stx":"html"}'>One</li>
18843 <li data-parsoid='{"stx":"html"}'>Two</li>
18844 </ol>
18845
18846 !! end
18847
18848 !! test
18849 HTML ordered list, unclosed tags (T7497)
18850 !! options
18851 !! wikitext
18852 <ol>
18853 <li>One
18854 <li>Two
18855 </ol>
18856 !! html/php+tidy
18857 <ol>
18858 <li>One
18859 </li><li>Two
18860 </li></ol>
18861 !! html/parsoid
18862 <ol data-parsoid='{"stx":"html"}'>
18863 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18864 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18865 </ol>
18866
18867 !! end
18868
18869 !! test
18870 HTML nested bullet list, closed tags (T7497)
18871 !! wikitext
18872 <ul>
18873 <li>One</li>
18874 <li>Two:
18875 <ul>
18876 <li>Sub-one</li>
18877 <li>Sub-two</li>
18878 </ul>
18879 </li>
18880 </ul>
18881 !! html/php
18882 <ul>
18883 <li>One</li>
18884 <li>Two:
18885 <ul>
18886 <li>Sub-one</li>
18887 <li>Sub-two</li>
18888 </ul>
18889 </li>
18890 </ul>
18891
18892 !! html/parsoid
18893 <ul data-parsoid='{"stx":"html"}'>
18894 <li data-parsoid='{"stx":"html"}'>One</li>
18895 <li data-parsoid='{"stx":"html"}'>Two:
18896 <ul data-parsoid='{"stx":"html"}'>
18897 <li data-parsoid='{"stx":"html"}'>Sub-one</li>
18898 <li data-parsoid='{"stx":"html"}'>Sub-two</li>
18899 </ul>
18900 </li>
18901 </ul>
18902 !! end
18903
18904 !! test
18905 HTML nested bullet list, open tags (T7497)
18906 !! wikitext
18907 <ul>
18908 <li>One
18909 <li>Two:
18910 <ul>
18911 <li>Sub-one
18912 <li>Sub-two
18913 </ul>
18914 </ul>
18915 !! html+tidy
18916 <ul>
18917 <li>One
18918 </li><li>Two:
18919 <ul>
18920 <li>Sub-one
18921 </li><li>Sub-two
18922 </li></ul>
18923 </li></ul>
18924 !! end
18925
18926 !! test
18927 HTML nested ordered list, closed tags (T7497)
18928 !! wikitext
18929 <ol>
18930 <li>One</li>
18931 <li>Two:
18932 <ol>
18933 <li>Sub-one</li>
18934 <li>Sub-two</li>
18935 </ol>
18936 </li>
18937 </ol>
18938 !! html
18939 <ol>
18940 <li>One</li>
18941 <li>Two:
18942 <ol>
18943 <li>Sub-one</li>
18944 <li>Sub-two</li>
18945 </ol>
18946 </li>
18947 </ol>
18948
18949 !! end
18950
18951 !! test
18952 HTML nested ordered list, open tags (T7497)
18953 !! wikitext
18954 <ol>
18955 <li>One
18956 <li>Two:
18957 <ol>
18958 <li>Sub-one
18959 <li>Sub-two
18960 </ol>
18961 </ol>
18962 !! html/php
18963 <ol>
18964 <li>One
18965 <li>Two:
18966 <ol>
18967 <li>Sub-one
18968 <li>Sub-two
18969 </ol>
18970 </ol>
18971
18972 !! html/parsoid
18973 <ol>
18974 <li>One
18975 </li>
18976 <li>Two:
18977 <ol>
18978 <li>Sub-one
18979 </li>
18980 <li>Sub-two
18981 </li>
18982 </ol>
18983 </li>
18984 </ol>
18985
18986 !! end
18987
18988 !! test
18989 HTML ordered list item with parameters oddity
18990 !! wikitext
18991 <ol><li id="fragment">One</li>
18992 </ol>
18993 !! html
18994 <ol><li id="fragment">One</li>
18995 </ol>
18996
18997 !! end
18998
18999 # parsoid doesn't explicitly mark autonumbered links, see T55505
19000 !!test
19001 T7918: autonumbering
19002 !! wikitext
19003 [http://first/] [http://second] [ftp://ftp]
19004
19005 ftp://inlineftp
19006
19007 [mailto:enclosed@mail.tld With target]
19008
19009 [mailto:enclosed@mail.tld]
19010
19011 mailto:inline@mail.tld
19012 !! html/php
19013 <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>
19014 </p><p><a rel="nofollow" class="external free" href="ftp://inlineftp">ftp://inlineftp</a>
19015 </p><p><a rel="nofollow" class="external text" href="mailto:enclosed@mail.tld">With target</a>
19016 </p><p><a rel="nofollow" class="external autonumber" href="mailto:enclosed@mail.tld">[4]</a>
19017 </p><p><a rel="nofollow" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a>
19018 </p>
19019 !! html/parsoid
19020 <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>
19021 <p><a rel="mw:ExtLink" class="external free" href="ftp://inlineftp">ftp://inlineftp</a></p>
19022 <p><a rel="mw:ExtLink" class="external text" href="mailto:enclosed@mail.tld">With target</a></p>
19023 <p><a rel="mw:ExtLink" class="external autonumber" href="mailto:enclosed@mail.tld"></a></p>
19024 <p><a rel="mw:ExtLink" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a></p>
19025 !! end
19026
19027
19028 #
19029 # Security and HTML correctness
19030 # From Nick Jenkins' fuzz testing
19031 #
19032
19033 !! test
19034 Fuzz testing: Parser13
19035 !! wikitext
19036 {|
19037 | http://a|
19038 !! html
19039 <table>
19040 <tr>
19041 <td>
19042 </td>
19043 </tr>
19044 </table>
19045
19046 !! end
19047
19048 # Note that Parsoid output differs from the PHP parser here: the PHP
19049 # parser breaks the URL for the magic word, while in Parsoid the URL
19050 # production takes precedence.
19051 !! test
19052 Fuzz testing: Parser14
19053 !! wikitext
19054 ==onmouseover===
19055 http://__TOC__
19056 !! html/php
19057 <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>
19058 http://<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
19059 <ul>
19060 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
19061 </ul>
19062 </div>
19063
19064
19065 !! html/php+tidy
19066 <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>
19067 http://</p><div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
19068 <ul>
19069 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
19070 </ul>
19071 </div>
19072 !! html/parsoid
19073 <h2 id="onmouseover="><span id="onmouseover.3D" typeof="mw:FallbackId"></span>onmouseover=</h2>
19074 <p><a rel="mw:ExtLink" class="external free" href="http://__TOC__" data-parsoid='{"stx":"url"}'>http://__TOC__</a></p>
19075 !! end
19076
19077 !! test
19078 Fuzz testing: Parser14-table
19079 !! options
19080 parsoid=wt2html,html2html
19081 !! wikitext
19082 ==a==
19083 {| STYLE=__TOC__
19084 !! html
19085 <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>
19086 <table style="&#95;_TOC&#95;_">
19087 <tr><td></td></tr>
19088 </table>
19089
19090 !! html+tidy
19091 <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>
19092 <table style="__TOC__">
19093 <tr>
19094 <td></td>
19095 </tr>
19096 </table>
19097 !! html/parsoid
19098 <h2 id="a">a</h2>
19099 <table style="__TOC__"></table>
19100 !! end
19101
19102 # Known to produce bogus xml (extra </td>)
19103 # Don't add the html/php section since it generates broken HTML
19104 !! test
19105 Fuzz testing: Parser16
19106 !! wikitext
19107 {|
19108 !https://||||||
19109 !! html+tidy
19110 <table>
19111 <tbody><tr>
19112 <th>https://</th>
19113 <th></th>
19114 <th></th>
19115 <th>
19116
19117 </th></tr>
19118 </tbody></table>
19119 !! end
19120
19121 !! test
19122 Fuzz testing: Parser21
19123 !! wikitext
19124 {|
19125 !irc://{{ftp://a" onmouseover="alert('hello world');"
19126 |
19127 !! html
19128 <table>
19129 <tr>
19130 <th><a rel="nofollow" class="external free" href="irc://{{ftp://a">irc://{{ftp://a</a>" onmouseover="alert('hello world');"
19131 </th>
19132 <td>
19133 </td>
19134 </tr>
19135 </table>
19136
19137 !! end
19138
19139 !! test
19140 Fuzz testing: Parser22
19141 !! wikitext
19142 http://===r:::https://b
19143
19144 {|
19145 !! html
19146 <p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a>
19147 </p>
19148 <table>
19149 <tr><td></td></tr>
19150 </table>
19151
19152 !! end
19153
19154 # Known to produce bad XML for now
19155 !! test
19156 Fuzz testing: Parser24
19157 !! options
19158 parsoid=wt2html
19159 !! wikitext
19160 {|
19161 {{{|
19162 <u CLASS=
19163 | {{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}} >
19164 <br style="onmouseover='alert(document.cookie);' " />
19165
19166 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19167 |
19168 !! html/php
19169 <table>
19170 {{{|
19171 <u class="&#124;">}}}} &gt;
19172 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
19173
19174 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19175 <tr>
19176 <td></u>
19177 </td>
19178 </tr>
19179 </table>
19180
19181 !! html/parsoid
19182 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>{{{|
19183 <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>"}'/>}}}} >
19184 <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}'>
19185
19186
19187
19188 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'></td></tr></tbody></table>
19189 !! end
19190
19191 # Note: the current result listed for this is not what the original one was,
19192 # but the original bug was JavaScript injection, which is fixed in any case.
19193 # It's not clear that the original result listed was any more correct than the
19194 # current one. Original result:
19195 # <p>{{{|
19196 # </p>
19197 # <li class="&#124;&#124;">
19198 # }}}blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
19199 !!test
19200 Fuzz testing: Parser25 (T8055)
19201 !! wikitext
19202 {{{
19203 |
19204 <LI CLASS=||
19205 >
19206 }}}blah" onmouseover="alert('hello world');" align="left"'''MOVE MOUSE CURSOR OVER HERE
19207 !! html/php
19208 <p>&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
19209 </p>
19210 !! html/parsoid
19211 <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"]}'>
19212 </span><p about="#mwt1">&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b></p>
19213 !! end
19214
19215 !!test
19216 Fuzz testing: URL adjacent extension (with space, clean)
19217 !! wikitext
19218 http://example.com <nowiki>junk</nowiki>
19219 !! html/php
19220 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> junk
19221 </p>
19222 !! html/parsoid
19223 <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>
19224 !! end
19225
19226 !!test
19227 Fuzz testing: URL adjacent extension (no space, dirty; nowiki)
19228 !! wikitext
19229 http://example.com<nowiki>junk</nowiki>
19230 !! html/php
19231 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>junk
19232 </p>
19233 !! html/parsoid
19234 <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>
19235 !! end
19236
19237 !! test
19238 Fuzz testing: URL adjacent extension (no space, dirty; pre)
19239 !! wikitext
19240 http://example.com<pre>junk</pre>
19241 !! html/php
19242 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre>
19243
19244 !! html/php+tidy
19245 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p><pre>junk</pre>
19246 !! html/parsoid
19247 <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>
19248 !! end
19249
19250 !! test
19251 Fuzz testing: image with bogus manual thumbnail
19252 !! wikitext
19253 [[Image:foobar.jpg|thumbnail= ]]
19254 !! html/php
19255 <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div>
19256
19257 !! html/parsoid
19258 <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>
19259 !! end
19260
19261 # Parsoid will emit the newline literally in wt2wt; see next test case.
19262 !! test
19263 Fuzz testing: encoded newline in generated HTML replacements (T8577)
19264 !! options
19265 parsoid=wt2html
19266 !! wikitext
19267 <pre dir="&#10;"></pre>
19268 !! html/php
19269 <pre dir="&#10;"></pre>
19270
19271 !! html/parsoid
19272 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
19273 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
19274 !! end
19275
19276 !! test
19277 Fuzz testing: encoded newline in generated HTML replacements, html2wt (T8577)
19278 !! options
19279 parsoid=html2wt
19280 !! html/parsoid
19281 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
19282 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
19283 !! wikitext
19284 <pre dir="
19285 "></pre>
19286 !! html/php
19287 <pre dir=""></pre>
19288
19289 !! end
19290
19291 !! test
19292 Templates in extension attributes are not expanded
19293 !! wikitext
19294 <pre dir="{{echo|ltr}}"></pre>
19295 !! html/php
19296 <pre dir="{{echo|ltr}}"></pre>
19297
19298 !! html/parsoid
19299 <pre typeof="mw:Extension/pre" about="#mwt2" dir="{{echo|ltr}}" data-mw='{"name":"pre","attrs":{"dir":"{{echo|ltr}}"},"body":{"extsrc":""}}'></pre>
19300 !! end
19301
19302 !! test
19303 Parsing optional HTML elements (T8171)
19304 !! options
19305 !! wikitext
19306 <table>
19307 <tr>
19308 <td> Some tabular data</td>
19309 <td> More tabular data ...
19310 <td> And yet som tabular data</td>
19311 </tr>
19312 </table>
19313 !! html
19314 <table>
19315 <tr>
19316 <td> Some tabular data</td>
19317 <td> More tabular data ...
19318 </td><td> And yet som tabular data</td>
19319 </tr>
19320 </table>
19321
19322 !! end
19323
19324 !! test
19325 Correct handling of <td>, <tr> (T8171)
19326 !! options
19327 !! wikitext
19328 <table>
19329 <tr>
19330 <td> Some tabular data</td>
19331 <td> More tabular data ...</td>
19332 <td> And yet som tabular data</td>
19333 </tr>
19334 </table>
19335 !! html
19336 <table>
19337 <tr>
19338 <td> Some tabular data</td>
19339 <td> More tabular data ...</td>
19340 <td> And yet som tabular data</td>
19341 </tr>
19342 </table>
19343
19344 !! end
19345
19346
19347 !! test
19348 Parsing crashing regression (fr:JavaScript)
19349 !! wikitext
19350 </body></x>
19351 !! html
19352 <p>&lt;/body&gt;&lt;/x&gt;
19353 </p>
19354 !! end
19355
19356 !! test
19357 Inline wiki vs wiki block nesting
19358 !! wikitext
19359 '''Bold paragraph
19360
19361 New wiki paragraph
19362 !! html
19363 <p><b>Bold paragraph</b>
19364 </p><p>New wiki paragraph
19365 </p>
19366 !! end
19367
19368 # FIXME: The current php output is documented
19369 # and desired output is the parsoid target.
19370 !! test
19371 Inline HTML vs wiki block nesting
19372 !! wikitext
19373 <b>Bold paragraph
19374
19375 New wiki paragraph
19376 !! html/php
19377 <p><b>Bold paragraph
19378 </p><p>New wiki paragraph</b>
19379 </p>
19380 !! html/parsoid
19381 <p><b>Bold paragraph</b>
19382 </p><p>New wiki paragraph
19383 </p>
19384 !! end
19385
19386 # Original result was this:
19387 # <p><b>bold</b><b>bold<i>bolditalics</i></b>
19388 # </p>
19389 # While that might be marginally more intuitive, maybe, the six-apostrophe
19390 # construct is clearly pathological and the result stated here (which is what
19391 # the parser actually does) is about as reasonable as anything.
19392 !!test
19393 Mixing markup for italics and bold
19394 !! options
19395 !! wikitext
19396 '''bold''''''bold''bolditalics'''''
19397 !! html
19398 <p>'<i>bold'</i><b>bold<i>bolditalics</i></b>
19399 </p>
19400 !! end
19401
19402
19403 !! article
19404 Xyzzyx
19405 !! text
19406 Article for special page transclusion test
19407 !! endarticle
19408
19409 !! test
19410 Special page transclusion
19411 !! options
19412 !! wikitext
19413 {{Special:Prefixindex/Xyzzyx}}
19414 !! html
19415 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19416 </ul>
19417
19418 !! end
19419
19420 !! test
19421 Special page transclusion twice (T7021)
19422 !! options
19423 !! wikitext
19424 {{Special:Prefixindex/Xyzzyx}}
19425 {{Special:Prefixindex/Xyzzyx}}
19426 !! html
19427 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19428 </ul>
19429 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19430 </ul>
19431
19432 !! end
19433
19434 !! test
19435 Transclusion of default MediaWiki message
19436 !! wikitext
19437 {{MediaWiki:Mainpage}}
19438 !! html
19439 <p>Main Page
19440 </p>
19441 !! end
19442
19443 !! test
19444 Transclusion of nonexistent MediaWiki message
19445 !! wikitext
19446 {{MediaWiki:Mainpagexxx}}
19447 !! html
19448 <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>
19449 </p>
19450 !! end
19451
19452 !! test
19453 Transclusion of MediaWiki message with underscore
19454 !! wikitext
19455 {{MediaWiki:history_short}}
19456 !! html
19457 <p>History
19458 </p>
19459 !! end
19460
19461 !! test
19462 Transclusion of MediaWiki message with space
19463 !! wikitext
19464 {{MediaWiki:history short}}
19465 !! html
19466 <p>History
19467 </p>
19468 !! end
19469
19470 !! test
19471 Invalid header with following text
19472 !! wikitext
19473 = x = y
19474 !! html
19475 <p>= x = y
19476 </p>
19477 !! end
19478
19479
19480 !! test
19481 Section extraction test (section 0)
19482 !! options
19483 section=0
19484 !! wikitext
19485 start
19486 ==a==
19487 ===aa===
19488 ====aaa====
19489 ==b==
19490 ===ba===
19491 ===bb===
19492 ====bba====
19493 ===bc===
19494 ==c==
19495 ===ca===
19496 !! html/php
19497 start
19498 !! end
19499
19500 !! test
19501 Section extraction test (section 1)
19502 !! options
19503 section=1
19504 !! wikitext
19505 start
19506 ==a==
19507 ===aa===
19508 ====aaa====
19509 ==b==
19510 ===ba===
19511 ===bb===
19512 ====bba====
19513 ===bc===
19514 ==c==
19515 ===ca===
19516 !! html/php
19517 ==a==
19518 ===aa===
19519 ====aaa====
19520 !! end
19521
19522 !! test
19523 Section extraction test (section 2)
19524 !! options
19525 section=2
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 ===aa===
19540 ====aaa====
19541 !! end
19542
19543 !! test
19544 Section extraction test (section 3)
19545 !! options
19546 section=3
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 ====aaa====
19561 !! end
19562
19563 !! test
19564 Section extraction test (section 4)
19565 !! options
19566 section=4
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 ==b==
19581 ===ba===
19582 ===bb===
19583 ====bba====
19584 ===bc===
19585 !! end
19586
19587 !! test
19588 Section extraction test (section 5)
19589 !! options
19590 section=5
19591 !! wikitext
19592 start
19593 ==a==
19594 ===aa===
19595 ====aaa====
19596 ==b==
19597 ===ba===
19598 ===bb===
19599 ====bba====
19600 ===bc===
19601 ==c==
19602 ===ca===
19603 !! html/php
19604 ===ba===
19605 !! end
19606
19607 !! test
19608 Section extraction test (section 6)
19609 !! options
19610 section=6
19611 !! wikitext
19612 start
19613 ==a==
19614 ===aa===
19615 ====aaa====
19616 ==b==
19617 ===ba===
19618 ===bb===
19619 ====bba====
19620 ===bc===
19621 ==c==
19622 ===ca===
19623 !! html/php
19624 ===bb===
19625 ====bba====
19626 !! end
19627
19628 !! test
19629 Section extraction test (section 7)
19630 !! options
19631 section=7
19632 !! wikitext
19633 start
19634 ==a==
19635 ===aa===
19636 ====aaa====
19637 ==b==
19638 ===ba===
19639 ===bb===
19640 ====bba====
19641 ===bc===
19642 ==c==
19643 ===ca===
19644 !! html/php
19645 ====bba====
19646 !! end
19647
19648 !! test
19649 Section extraction test (section 8)
19650 !! options
19651 section=8
19652 !! wikitext
19653 start
19654 ==a==
19655 ===aa===
19656 ====aaa====
19657 ==b==
19658 ===ba===
19659 ===bb===
19660 ====bba====
19661 ===bc===
19662 ==c==
19663 ===ca===
19664 !! html/php
19665 ===bc===
19666 !! end
19667
19668 !! test
19669 Section extraction test (section 9)
19670 !! options
19671 section=9
19672 !! wikitext
19673 start
19674 ==a==
19675 ===aa===
19676 ====aaa====
19677 ==b==
19678 ===ba===
19679 ===bb===
19680 ====bba====
19681 ===bc===
19682 ==c==
19683 ===ca===
19684 !! html/php
19685 ==c==
19686 ===ca===
19687 !! end
19688
19689 !! test
19690 Section extraction test (section 10)
19691 !! options
19692 section=10
19693 !! wikitext
19694 start
19695 ==a==
19696 ===aa===
19697 ====aaa====
19698 ==b==
19699 ===ba===
19700 ===bb===
19701 ====bba====
19702 ===bc===
19703 ==c==
19704 ===ca===
19705 !! html/php
19706 ===ca===
19707 !! end
19708
19709 !! test
19710 Section extraction test (nonexistent section 11)
19711 !! options
19712 section=11
19713 !! wikitext
19714 start
19715 ==a==
19716 ===aa===
19717 ====aaa====
19718 ==b==
19719 ===ba===
19720 ===bb===
19721 ====bba====
19722 ===bc===
19723 ==c==
19724 ===ca===
19725 !! html/php
19726 !! end
19727
19728 !! test
19729 Section extraction test with bogus heading (section 1)
19730 !! options
19731 section=1
19732 !! wikitext
19733 ==a==
19734 ==bogus== not a legal section
19735 ==b==
19736 !! html/php
19737 ==a==
19738 ==bogus== not a legal section
19739 !! end
19740
19741 !! test
19742 Section extraction test with bogus heading (section 2)
19743 !! options
19744 section=2
19745 !! wikitext
19746 ==a==
19747 ==bogus== not a legal section
19748 ==b==
19749 !! html/php
19750 ==b==
19751 !! end
19752
19753 !! test
19754 Section extraction test with comment after heading (section 1)
19755 !! options
19756 section=1
19757 !! wikitext
19758 ==a==
19759 ==b== <!-- -->
19760 ==c==
19761 !! html/php
19762 ==a==
19763 !! end
19764
19765 !! test
19766 Section extraction test with comment after heading (section 2)
19767 !! options
19768 section=2
19769 !! wikitext
19770 ==a==
19771 ==b== <!-- -->
19772 ==c==
19773 !! html/php
19774 ==b== <!-- -->
19775 !! end
19776
19777 !! test
19778 Section extraction test with bogus <nowiki> heading (section 1)
19779 !! options
19780 section=1
19781 !! wikitext
19782 ==a==
19783 ==bogus== <nowiki>not a legal section</nowiki>
19784 ==b==
19785 !! html/php
19786 ==a==
19787 ==bogus== <nowiki>not a legal section</nowiki>
19788 !! end
19789
19790 !! test
19791 Section extraction test with bogus <nowiki> heading (section 2)
19792 !! options
19793 section=2
19794 !! wikitext
19795 ==a==
19796 ==bogus== <nowiki>not a legal section</nowiki>
19797 ==b==
19798 !! html/php
19799 ==b==
19800 !! end
19801
19802 # Formerly testing for T4587, now resolved by the use of unmarked sections
19803 # instead of respecting commented sections
19804 !! test
19805 Section extraction prefixed by comment (section 1)
19806 !! options
19807 section=1
19808 !! wikitext
19809 <!-- -->==sec1==
19810 ==sec2==
19811 !! html/php
19812 ==sec2==
19813 !!end
19814
19815 !! test
19816 Section extraction prefixed by comment (section 2)
19817 !! options
19818 section=2
19819 !! wikitext
19820 <!-- -->==sec1==
19821 ==sec2==
19822 !! html/php
19823
19824 !!end
19825
19826 # Formerly testing for T4607, now resolved by the use of unmarked sections
19827 # instead of respecting HTML-style headings
19828 !! test
19829 Section extraction, mixed wiki and html (section 1)
19830 !! options
19831 section=1
19832 !! wikitext
19833 <h2>unmarked</h2>
19834 unmarked
19835 ==1==
19836 one
19837 ==2==
19838 two
19839 !! html/php
19840 ==1==
19841 one
19842 !! end
19843
19844 !! test
19845 Section extraction, mixed wiki and html (section 2)
19846 !! options
19847 section=2
19848 !! wikitext
19849 <h2>unmarked</h2>
19850 unmarked
19851 ==1==
19852 one
19853 ==2==
19854 two
19855 !! html/php
19856 ==2==
19857 two
19858 !! end
19859
19860
19861 # Formerly testing for T5342
19862 !! test
19863 Section extraction, heading surrounded by <noinclude>
19864 !! options
19865 section=1
19866 !! wikitext
19867 <noinclude>==unmarked==</noinclude>
19868 ==marked==
19869 !! html/php
19870 ==marked==
19871 !!end
19872
19873 # Test behavior of T21910
19874 !! test
19875 Sectiion with all-equals
19876 !! options
19877 section=2
19878 !! wikitext
19879 ===
19880 The line above must have a trailing space
19881 === <!--
19882 --> <!-- -->
19883 But just in case it doesn't...
19884 !! html/php
19885 === <!--
19886 --> <!-- -->
19887 But just in case it doesn't...
19888 !! end
19889
19890 !! test
19891 Section replacement test (section 0)
19892 !! options
19893 replace=0,"xxx"
19894 !! wikitext
19895 start
19896 ==a==
19897 ===aa===
19898 ====aaa====
19899 ==b==
19900 ===ba===
19901 ===bb===
19902 ====bba====
19903 ===bc===
19904 ==c==
19905 ===ca===
19906 !! html/php
19907 xxx
19908
19909 ==a==
19910 ===aa===
19911 ====aaa====
19912 ==b==
19913 ===ba===
19914 ===bb===
19915 ====bba====
19916 ===bc===
19917 ==c==
19918 ===ca===
19919 !! end
19920
19921 !! test
19922 Section replacement test (section 1)
19923 !! options
19924 replace=1,"xxx"
19925 !! wikitext
19926 start
19927 ==a==
19928 ===aa===
19929 ====aaa====
19930 ==b==
19931 ===ba===
19932 ===bb===
19933 ====bba====
19934 ===bc===
19935 ==c==
19936 ===ca===
19937 !! html/php
19938 start
19939 xxx
19940
19941 ==b==
19942 ===ba===
19943 ===bb===
19944 ====bba====
19945 ===bc===
19946 ==c==
19947 ===ca===
19948 !! end
19949
19950 !! test
19951 Section replacement test (section 2)
19952 !! options
19953 replace=2,"xxx"
19954 !! wikitext
19955 start
19956 ==a==
19957 ===aa===
19958 ====aaa====
19959 ==b==
19960 ===ba===
19961 ===bb===
19962 ====bba====
19963 ===bc===
19964 ==c==
19965 ===ca===
19966 !! html/php
19967 start
19968 ==a==
19969 xxx
19970
19971 ==b==
19972 ===ba===
19973 ===bb===
19974 ====bba====
19975 ===bc===
19976 ==c==
19977 ===ca===
19978 !! end
19979
19980 !! test
19981 Section replacement test (section 3)
19982 !! options
19983 replace=3,"xxx"
19984 !! wikitext
19985 start
19986 ==a==
19987 ===aa===
19988 ====aaa====
19989 ==b==
19990 ===ba===
19991 ===bb===
19992 ====bba====
19993 ===bc===
19994 ==c==
19995 ===ca===
19996 !! html/php
19997 start
19998 ==a==
19999 ===aa===
20000 xxx
20001
20002 ==b==
20003 ===ba===
20004 ===bb===
20005 ====bba====
20006 ===bc===
20007 ==c==
20008 ===ca===
20009 !! end
20010
20011 !! test
20012 Section replacement test (section 4)
20013 !! options
20014 replace=4,"xxx"
20015 !! wikitext
20016 start
20017 ==a==
20018 ===aa===
20019 ====aaa====
20020 ==b==
20021 ===ba===
20022 ===bb===
20023 ====bba====
20024 ===bc===
20025 ==c==
20026 ===ca===
20027 !! html/php
20028 start
20029 ==a==
20030 ===aa===
20031 ====aaa====
20032 xxx
20033
20034 ==c==
20035 ===ca===
20036 !! end
20037
20038 !! test
20039 Section replacement test (section 5)
20040 !! options
20041 replace=5,"xxx"
20042 !! wikitext
20043 start
20044 ==a==
20045 ===aa===
20046 ====aaa====
20047 ==b==
20048 ===ba===
20049 ===bb===
20050 ====bba====
20051 ===bc===
20052 ==c==
20053 ===ca===
20054 !! html/php
20055 start
20056 ==a==
20057 ===aa===
20058 ====aaa====
20059 ==b==
20060 xxx
20061
20062 ===bb===
20063 ====bba====
20064 ===bc===
20065 ==c==
20066 ===ca===
20067 !! end
20068
20069 !! test
20070 Section replacement test (section 6)
20071 !! options
20072 replace=6,"xxx"
20073 !! wikitext
20074 start
20075 ==a==
20076 ===aa===
20077 ====aaa====
20078 ==b==
20079 ===ba===
20080 ===bb===
20081 ====bba====
20082 ===bc===
20083 ==c==
20084 ===ca===
20085 !! html/php
20086 start
20087 ==a==
20088 ===aa===
20089 ====aaa====
20090 ==b==
20091 ===ba===
20092 xxx
20093
20094 ===bc===
20095 ==c==
20096 ===ca===
20097 !! end
20098
20099 !! test
20100 Section replacement test (section 7)
20101 !! options
20102 replace=7,"xxx"
20103 !! wikitext
20104 start
20105 ==a==
20106 ===aa===
20107 ====aaa====
20108 ==b==
20109 ===ba===
20110 ===bb===
20111 ====bba====
20112 ===bc===
20113 ==c==
20114 ===ca===
20115 !! html/php
20116 start
20117 ==a==
20118 ===aa===
20119 ====aaa====
20120 ==b==
20121 ===ba===
20122 ===bb===
20123 xxx
20124
20125 ===bc===
20126 ==c==
20127 ===ca===
20128 !! end
20129
20130 !! test
20131 Section replacement test (section 8)
20132 !! options
20133 replace=8,"xxx"
20134 !! wikitext
20135 start
20136 ==a==
20137 ===aa===
20138 ====aaa====
20139 ==b==
20140 ===ba===
20141 ===bb===
20142 ====bba====
20143 ===bc===
20144 ==c==
20145 ===ca===
20146 !! html/php
20147 start
20148 ==a==
20149 ===aa===
20150 ====aaa====
20151 ==b==
20152 ===ba===
20153 ===bb===
20154 ====bba====
20155 xxx
20156
20157 ==c==
20158 ===ca===
20159 !!end
20160
20161 !! test
20162 Section replacement test (section 9)
20163 !! options
20164 replace=9,"xxx"
20165 !! wikitext
20166 start
20167 ==a==
20168 ===aa===
20169 ====aaa====
20170 ==b==
20171 ===ba===
20172 ===bb===
20173 ====bba====
20174 ===bc===
20175 ==c==
20176 ===ca===
20177 !! html/php
20178 start
20179 ==a==
20180 ===aa===
20181 ====aaa====
20182 ==b==
20183 ===ba===
20184 ===bb===
20185 ====bba====
20186 ===bc===
20187 xxx
20188 !! end
20189
20190 !! test
20191 Section replacement test (section 10)
20192 !! options
20193 replace=10,"xxx"
20194 !! wikitext
20195 start
20196 ==a==
20197 ===aa===
20198 ====aaa====
20199 ==b==
20200 ===ba===
20201 ===bb===
20202 ====bba====
20203 ===bc===
20204 ==c==
20205 ===ca===
20206 !! html/php
20207 start
20208 ==a==
20209 ===aa===
20210 ====aaa====
20211 ==b==
20212 ===ba===
20213 ===bb===
20214 ====bba====
20215 ===bc===
20216 ==c==
20217 xxx
20218 !! end
20219
20220 !! test
20221 Section replacement test with initial whitespace (T15728)
20222 !! options
20223 replace=2,"xxx"
20224 !! wikitext
20225 Preformatted initial line
20226 ==a==
20227 ===a===
20228 !! html/php
20229 Preformatted initial line
20230 ==a==
20231 xxx
20232 !! end
20233
20234
20235 !! test
20236 Section extraction, heading followed by pre with 20 spaces (T8398)
20237 !! options
20238 section=1
20239 !! wikitext
20240 ==a==
20241 a
20242 !! html/php
20243 ==a==
20244 a
20245 !! end
20246
20247 !! test
20248 Section extraction, heading followed by pre with 19 spaces (T8398 sanity check)
20249 !! options
20250 section=1
20251 !! wikitext
20252 ==a==
20253 a
20254 !! html/php
20255 ==a==
20256 a
20257 !! end
20258
20259
20260 !! test
20261 Section extraction, <pre> around bogus header (T12309)
20262 !! options
20263 section=2
20264 !! wikitext
20265 == Section One ==
20266 <pre>
20267 =======
20268 </pre>
20269
20270 == Section Two ==
20271 stuff
20272 !! html/php
20273 == Section Two ==
20274 stuff
20275 !! end
20276
20277 !! test
20278 Section replacement, <pre> around bogus header (T12309)
20279 !! options
20280 replace=2,"xxx"
20281 !! wikitext
20282 == Section One ==
20283 <pre>
20284 =======
20285 </pre>
20286
20287 == Section Two ==
20288 stuff
20289 !! html/php
20290 == Section One ==
20291 <pre>
20292 =======
20293 </pre>
20294
20295 xxx
20296 !! end
20297
20298 !! test
20299 Handling of &#x0A; in URLs
20300 !! wikitext
20301 *irc://&#x0A;a
20302 !! html/php
20303 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
20304
20305 !! html/parsoid
20306 <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>
20307 !! end
20308
20309 !! test
20310 Handling of %0A in URLs
20311 !! wikitext
20312 *irc://%0Aa
20313 !! html/php
20314 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
20315
20316 !! html/parsoid
20317 <ul><li><a rel="mw:ExtLink" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
20318 !! end
20319
20320 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
20321 !! test
20322 5 quotes, code coverage +1 line
20323 !! options
20324 parsoid=wt2html
20325 !! wikitext
20326 '''''
20327 !! html/php
20328 !! html/parsoid
20329 <b><i></i></b>
20330 !! end
20331
20332 # same html as previous, but wikitext adjusted to match parsoid html2wt
20333 # note that wt2html and html2html will put the <i> before the <b>
20334 !! test
20335 5 quotes, code coverage +1 line w/ nowiki (1)
20336 !! options
20337 parsoid=wt2wt,html2wt
20338 !! wikitext
20339 '''''<nowiki/>'''''
20340 !! html/php
20341 <p><i></i>
20342 </p>
20343 !! html/parsoid
20344 <p><b><i></i></b></p>
20345 !! end
20346
20347 # same as previous, just swapping the <i> and <b>
20348 !! test
20349 5 quotes, code coverage +1 line w/ nowiki (2)
20350 !! wikitext
20351 '''''<nowiki/>'''''
20352 !! html/php
20353 <p><i></i>
20354 </p>
20355 !! html/parsoid
20356 <p><i><b></b></i></p>
20357 !! end
20358
20359 !! test
20360 Special:Search page linking.
20361 !! wikitext
20362 {{Special:search}}
20363 !! html
20364 <p><a href="/wiki/Special:Search" title="Special:Search">Special:Search</a>
20365 </p>
20366 !! end
20367
20368 !! test
20369 {{!}} is a magic word
20370 !! wikitext
20371 {{!}} is a magic word there and {{!}} is still a magic word here
20372 | is not a magic word here but {{!}} is still a magic word here
20373 !! html/php
20374 <p>| is a magic word there and | is still a magic word here
20375 | is not a magic word here but | is still a magic word here
20376 </p>
20377 !! html/parsoid
20378 <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
20379 | 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>
20380 !! end
20381
20382 !! test
20383 Say the magic word
20384 !! options
20385 title=[[Parser test]]
20386 !! wikitext
20387 *{{PAGENAME}}
20388 *{{PAGENAMEE}}
20389 *{{FULLPAGENAME}}
20390 *{{FULLPAGENAMEE}}
20391 *{{BASEPAGENAME}}
20392 *{{BASEPAGENAMEE}}
20393 *{{SUBPAGENAME}}
20394 *{{SUBPAGENAMEE}}
20395 *{{ROOTPAGENAME}}
20396 *{{ROOTPAGENAMEE}}
20397 *{{TALKPAGENAME}}
20398 *{{TALKPAGENAMEE}}
20399 *{{SUBJECTPAGENAME}}
20400 *{{SUBJECTPAGENAMEE}}
20401 *{{NAMESPACEE}}
20402 *{{NAMESPACE}}
20403 *{{NAMESPACENUMBER}}
20404 *{{TALKSPACE}}
20405 *{{TALKSPACEE}}
20406 *{{SUBJECTSPACE}}
20407 *{{SUBJECTSPACEE}}
20408 *{{Dynamic|{{NUMBEROFUSERS}}|{{NUMBEROFPAGES}}|{{CURRENTVERSION}}|{{CONTENTLANGUAGE}}|{{DIRECTIONMARK}}|{{CURRENTTIMESTAMP}}|{{NUMBEROFARTICLES}}}}
20409 !! html
20410 <ul><li>Parser test</li>
20411 <li>Parser_test</li>
20412 <li>Parser test</li>
20413 <li>Parser_test</li>
20414 <li>Parser test</li>
20415 <li>Parser_test</li>
20416 <li>Parser test</li>
20417 <li>Parser_test</li>
20418 <li>Parser test</li>
20419 <li>Parser_test</li>
20420 <li>Talk:Parser test</li>
20421 <li>Talk:Parser_test</li>
20422 <li>Parser test</li>
20423 <li>Parser_test</li>
20424 <li></li>
20425 <li></li>
20426 <li>0</li>
20427 <li>Talk</li>
20428 <li>Talk</li>
20429 <li></li>
20430 <li></li>
20431 <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>
20432
20433 !! end
20434 ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included.
20435
20436 !! test
20437 Gallery with valid attributes
20438 !! wikitext
20439 <gallery type="123" summary="345">
20440 File:File:Foobar.jpg
20441 </gallery>
20442 !! html/php
20443 <ul class="gallery mw-gallery-traditional" type="123">
20444 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20445 <div class="thumb" style="height: 150px;">File:Foobar.jpg</div>
20446 <div class="gallerytext">
20447 </div>
20448 </div></li>
20449 </ul>
20450
20451 !! html/parsoid
20452 <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"}}'>
20453 <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>
20454 </ul>
20455 !! end
20456
20457 ## Parsoid thinks the "centre" here is a property, not a caption.
20458 !! test
20459 Gallery
20460 !! options
20461 parsoid={
20462 "modes": ["wt2html"],
20463 "nativeGallery": true
20464 }
20465 !! wikitext
20466 <gallery>
20467 image1.png |
20468 image2.gif|||||
20469
20470 image3|
20471 image4 |300px| centre
20472 image5.svg| http://///////
20473 [[x|xx]]]]
20474 * image6
20475 </gallery>
20476 !! html/php
20477 <ul class="gallery mw-gallery-traditional">
20478 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20479 <div class="thumb" style="height: 150px;">Image1.png</div>
20480 <div class="gallerytext">
20481 </div>
20482 </div></li>
20483 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20484 <div class="thumb" style="height: 150px;">Image2.gif</div>
20485 <div class="gallerytext">
20486 </div>
20487 </div></li>
20488 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20489 <div class="thumb" style="height: 150px;">Image3</div>
20490 <div class="gallerytext">
20491 </div>
20492 </div></li>
20493 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20494 <div class="thumb" style="height: 150px;">Image4</div>
20495 <div class="gallerytext">
20496 <pre>centre
20497 </pre>
20498 </div>
20499 </div></li>
20500 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20501 <div class="thumb" style="height: 150px;">Image5.svg</div>
20502 <div class="gallerytext">
20503 <p><a rel="nofollow" class="external free" href="http://///////">http://///////</a>
20504 </p>
20505 </div>
20506 </div></li>
20507 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20508 <div class="thumb" style="height: 150px;">* image6</div>
20509 <div class="gallerytext">
20510 </div>
20511 </div></li>
20512 </ul>
20513
20514 !! html/parsoid
20515 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20516 <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>
20517 <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>
20518 <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>
20519 <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>
20520 <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>
20521 <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>
20522 </ul>
20523 !! end
20524
20525 !! test
20526 Gallery (with options, html)
20527 !! options
20528 parsoid={
20529 "modes": ["wt2html", "html2html"],
20530 "nativeGallery": true
20531 }
20532 !! wikitext
20533 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
20534 File:Nonexistent.jpg|caption
20535 File:Nonexistent.jpg
20536 image:foobar.jpg|some '''caption''' [[Main Page]]
20537 image:foobar.jpg
20538 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
20539 </gallery>
20540 !! html/php
20541 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
20542 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
20543 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20544 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20545 <div class="gallerytext">
20546 <p>caption
20547 </p>
20548 </div>
20549 </div></li>
20550 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20551 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20552 <div class="gallerytext">
20553 </div>
20554 </div></li>
20555 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20556 <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>
20557 <div class="gallerytext">
20558 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20559 </p>
20560 </div>
20561 </div></li>
20562 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20563 <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>
20564 <div class="gallerytext">
20565 </div>
20566 </div></li>
20567 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20568 <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>
20569 <div class="gallerytext">
20570 <p>blabla.
20571 </p>
20572 </div>
20573 </div></li>
20574 </ul>
20575
20576 !! html/parsoid
20577 <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":{}}'>
20578 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
20579 <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>
20580 <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>
20581 <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>
20582 <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>
20583 <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>
20584 </ul>
20585 !! end
20586
20587 !! test
20588 Gallery (with options, extsrc)
20589 !! options
20590 parsoid={
20591 "nativeGallery": false
20592 }
20593 !! wikitext
20594 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
20595 File:Nonexistent.jpg|caption
20596 File:Nonexistent.jpg
20597 image:foobar.jpg|some '''caption''' [[Main Page]]
20598 image:foobar.jpg
20599 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
20600 </gallery>
20601 !! html/php
20602 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
20603 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
20604 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20605 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20606 <div class="gallerytext">
20607 <p>caption
20608 </p>
20609 </div>
20610 </div></li>
20611 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20612 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20613 <div class="gallerytext">
20614 </div>
20615 </div></li>
20616 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20617 <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>
20618 <div class="gallerytext">
20619 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20620 </p>
20621 </div>
20622 </div></li>
20623 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20624 <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>
20625 <div class="gallerytext">
20626 </div>
20627 </div></li>
20628 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20629 <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>
20630 <div class="gallerytext">
20631 <p>blabla.
20632 </p>
20633 </div>
20634 </div></li>
20635 </ul>
20636
20637 !! html/parsoid
20638 <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"}}'>
20639 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
20640 <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>
20641 <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>
20642 <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>
20643 <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>
20644 <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>
20645 </ul>
20646 !! end
20647
20648 !! test
20649 Gallery (without px units)
20650 !! wikitext
20651 <gallery widths="70" heights="40">
20652 File:Foobar.jpg
20653 </gallery>
20654 !! html/php
20655 <ul class="gallery mw-gallery-traditional">
20656 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20657 <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>
20658 <div class="gallerytext">
20659 </div>
20660 </div></li>
20661 </ul>
20662
20663 !! html/parsoid
20664 <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"}}'>
20665 <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>
20666 </ul>
20667 !! end
20668
20669 !! test
20670 Gallery (with invalid units)
20671 !! wikitext
20672 <gallery widths="70em" heights="40em">
20673 File:Foobar.jpg
20674 </gallery>
20675 !! html/php
20676 <ul class="gallery mw-gallery-traditional">
20677 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20678 <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>
20679 <div class="gallerytext">
20680 </div>
20681 </div></li>
20682 </ul>
20683
20684 !! html/parsoid
20685 <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"}}'>
20686 <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>
20687 </ul>
20688 !! end
20689
20690 !! test
20691 Gallery with link that has fragment
20692 !! options
20693 parsoid={
20694 "modes": ["wt2html", "html2html"],
20695 "nativeGallery": true
20696 }
20697 !! wikitext
20698 <gallery>
20699 image:foobar.jpg|link=Main_Page
20700 image:foobar.jpg|link=Main_Page#section
20701 image:foobar.jpg|link=Main Page#section|caption
20702 </gallery>
20703 !! html/php
20704 <ul class="gallery mw-gallery-traditional">
20705 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20706 <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>
20707 <div class="gallerytext">
20708 </div>
20709 </div></li>
20710 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20711 <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>
20712 <div class="gallerytext">
20713 </div>
20714 </div></li>
20715 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20716 <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>
20717 <div class="gallerytext">
20718 <p>caption
20719 </p>
20720 </div>
20721 </div></li>
20722 </ul>
20723
20724 !! html/parsoid
20725 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20726 <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>
20727 <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>
20728 <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>
20729 </ul>
20730 !! end
20731
20732 ## Whoops, Parsoid shouldn't be parsing templates in the attribute caption!
20733 !! test
20734 Gallery with template inside caption
20735 !! options
20736 parsoid={
20737 "nativeGallery": true
20738 }
20739 !! wikitext
20740 <gallery caption="{{echo|hi}}">
20741 File:Foobar.jpg|{{echo|ho}}
20742 </gallery>
20743 !! html/php
20744 <ul class="gallery mw-gallery-traditional">
20745 <li class='gallerycaption'>{{echo|hi}}</li>
20746 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20747 <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>
20748 <div class="gallerytext">
20749 <p>ho
20750 </p>
20751 </div>
20752 </div></li>
20753 </ul>
20754
20755 !! html/parsoid
20756 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20757 <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>
20758 <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>
20759 </ul>
20760 !! end
20761
20762 !! test
20763 Gallery with wikitext inside caption
20764 !! options
20765 parsoid={
20766 "nativeGallery": true
20767 }
20768 !! wikitext
20769 <gallery>
20770 File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]]
20771 File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}}
20772 </gallery>
20773 !! html/php
20774 <ul class="gallery mw-gallery-traditional">
20775 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20776 <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>
20777 <div class="gallerytext">
20778 <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>
20779 </p>
20780 </div>
20781 </div></li>
20782 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20783 <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>
20784 <div class="gallerytext">
20785 <p>This is a test template
20786 </p>
20787 </div>
20788 </div></li>
20789 </ul>
20790
20791 !! html/parsoid
20792 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20793 <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>
20794 <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>
20795 </ul>
20796 !! end
20797
20798 !! test
20799 Gallery (with showfilename option)
20800 !! options
20801 parsoid={
20802 "nativeGallery": true
20803 }
20804 !! wikitext
20805 <gallery showfilename="">
20806 File:Nonexistent.jpg|caption
20807 File:Nonexistent.jpg
20808 File:Foobar.jpg|some '''caption''' [[Main Page]]
20809 File:Foobar.jpg
20810 </gallery>
20811 !! html/php
20812 <ul class="gallery mw-gallery-traditional">
20813 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20814 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20815 <div class="gallerytext">
20816 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
20817 caption
20818 </p>
20819 </div>
20820 </div></li>
20821 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20822 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20823 <div class="gallerytext">
20824 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
20825 </p>
20826 </div>
20827 </div></li>
20828 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20829 <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>
20830 <div class="gallerytext">
20831 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
20832 some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20833 </p>
20834 </div>
20835 </div></li>
20836 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20837 <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>
20838 <div class="gallerytext">
20839 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
20840 </p>
20841 </div>
20842 </div></li>
20843 </ul>
20844
20845 !! html/parsoid
20846 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
20847 <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>
20848 <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>
20849 <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>
20850 <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>
20851 </ul>
20852 !! end
20853
20854 ## Should Parsoid be preserving these variations? See T151367
20855 !! test
20856 Gallery (with namespace-less filenames)
20857 !! options
20858 parsoid={
20859 "modes": ["wt2html", "html2html"],
20860 "nativeGallery": true
20861 }
20862 !! wikitext
20863 <gallery>
20864 File:Nonexistent.jpg
20865 Nonexistent.jpg
20866 image:foobar.jpg
20867 foobar.jpg
20868 </gallery>
20869 !! html/php
20870 <ul class="gallery mw-gallery-traditional">
20871 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20872 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20873 <div class="gallerytext">
20874 </div>
20875 </div></li>
20876 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20877 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20878 <div class="gallerytext">
20879 </div>
20880 </div></li>
20881 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20882 <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>
20883 <div class="gallerytext">
20884 </div>
20885 </div></li>
20886 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20887 <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>
20888 <div class="gallerytext">
20889 </div>
20890 </div></li>
20891 </ul>
20892
20893 !! html/parsoid
20894 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20895 <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>
20896 <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>
20897 <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>
20898 <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>
20899 </ul>
20900 !! end
20901
20902 !! test
20903 Gallery override link with wikilink (T36852)
20904 !! options
20905 parsoid={
20906 "nativeGallery": true
20907 }
20908 !! wikitext
20909 <gallery>
20910 File:Foobar.jpg|alt=galleryalt|link=Wikilink
20911 </gallery>
20912 !! html/php
20913 <ul class="gallery mw-gallery-traditional">
20914 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20915 <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>
20916 <div class="gallerytext">
20917 </div>
20918 </div></li>
20919 </ul>
20920
20921 !! html/parsoid
20922 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20923 <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>
20924 </ul>
20925 !! end
20926
20927 !! test
20928 Gallery override link with absolute external link (T36852)
20929 !! options
20930 parsoid={
20931 "nativeGallery": true
20932 }
20933 !! wikitext
20934 <gallery>
20935 File:Foobar.jpg|alt=galleryalt|link=http://www.example.org
20936 </gallery>
20937 !! html/php
20938 <ul class="gallery mw-gallery-traditional">
20939 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20940 <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>
20941 <div class="gallerytext">
20942 </div>
20943 </div></li>
20944 </ul>
20945
20946 !! html/parsoid
20947 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20948 <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>
20949 </ul>
20950 !! end
20951
20952 !! test
20953 Gallery override link with absolute external link with LanguageConverter
20954 !! options
20955 language=zh
20956 !! wikitext
20957 <gallery>
20958 File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org
20959 </gallery>
20960 !! html/php
20961 <ul class="gallery mw-gallery-traditional">
20962 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20963 <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>
20964 <div class="gallerytext">
20965 <p>caption
20966 </p>
20967 </div>
20968 </div></li>
20969 </ul>
20970
20971 !! html/parsoid
20972 <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"}}'>
20973 <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>
20974 </ul>
20975 !! end
20976
20977 !! test
20978 Gallery override link with malicious javascript (T36852)
20979 !! options
20980 parsoid={
20981 "modes": ["wt2html", "html2html"],
20982 "nativeGallery": true
20983 }
20984 !! wikitext
20985 <gallery>
20986 File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!');
20987 </gallery>
20988 !! html/php
20989 <ul class="gallery mw-gallery-traditional">
20990 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20991 <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>
20992 <div class="gallerytext">
20993 </div>
20994 </div></li>
20995 </ul>
20996
20997 !! html/parsoid
20998 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20999 <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>
21000 </ul>
21001 !! end
21002
21003 # Note that parsoid uses the invalid link as a caption, PHP does not.
21004 !! test
21005 Gallery with invalid title as link (T45964)
21006 !! options
21007 parsoid={
21008 "modes": ["wt2html", "html2html"],
21009 "nativeGallery": true
21010 }
21011 !! wikitext
21012 <gallery>
21013 File:Foobar.jpg|link=<
21014 </gallery>
21015 !! html/php
21016 <ul class="gallery mw-gallery-traditional">
21017 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21018 <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>
21019 <div class="gallerytext">
21020 </div>
21021 </div></li>
21022 </ul>
21023
21024 !! html/parsoid
21025 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21026 <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>
21027 </ul>
21028 !! end
21029
21030 !! test
21031 Serialize gallery without attrs in data-mw
21032 !! options
21033 parsoid={
21034 "modes": ["html2wt"],
21035 "nativeGallery": true
21036 }
21037 !! html/parsoid
21038 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'>
21039 <li class="gallerycaption">123</li>
21040 <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>
21041 </ul>
21042 !! wikitext
21043 <gallery caption="123">
21044 File:Test.png
21045 </gallery>
21046 !! end
21047
21048 !! test
21049 Gallery with class and style attributes
21050 !! options
21051 parsoid={
21052 "nativeGallery": true
21053 }
21054 !! wikitext
21055 <gallery class="center" style="text-align: center;">
21056 File:Foobar.jpg
21057 </gallery>
21058 !! html/php
21059 <ul class="gallery mw-gallery-traditional center" style="text-align: center;">
21060 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21061 <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>
21062 <div class="gallerytext">
21063 </div>
21064 </div></li>
21065 </ul>
21066
21067 !! html/parsoid
21068 <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":{}}'>
21069 <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>
21070 </ul>
21071 !! end
21072
21073 !! test
21074 Gallery in slideshow mode
21075 !! options
21076 parsoid={
21077 "nativeGallery": true
21078 }
21079 !! wikitext
21080 <gallery mode="slideshow" showthumbnails="">
21081 File:Foobar.jpg
21082 </gallery>
21083 !! html/php
21084 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1">
21085 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21086 <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>
21087 <div class="gallerytext">
21088 </div>
21089 </div></li>
21090 </ul>
21091
21092 !! html/parsoid
21093 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'>
21094 <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>
21095 </ul>
21096 !! end
21097
21098 !! test
21099 Serialize gallery image captions on a line
21100 !! options
21101 parsoid={
21102 "modes": ["html2wt"],
21103 "nativeGallery": true
21104 }
21105 !! html/parsoid
21106 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21107 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext"><p>hi</p><p>ho</p></div></li>
21108 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext">hi<br />ho</div></li>
21109 </ul>
21110 !! wikitext
21111 <gallery>
21112 File:Foobar.jpg| hi ho
21113 File:Foobar.jpg|hi<br />ho
21114 </gallery>
21115 !! end
21116
21117 !! test
21118 HTML Hex character encoding (spells the word "JavaScript")
21119 !! options
21120 parsoid=wt2html,wt2wt,html2html
21121 !! wikitext
21122 &#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
21123 !! html/php
21124 <p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
21125 </p>
21126 !! html/parsoid
21127 <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>
21128 !! end
21129
21130 !! test
21131 HTML Hex character encoding bogus encoding (T28437 regression check)
21132 !! wikitext
21133 &#xsee;&#XSEE;
21134 !! html
21135 <p>&amp;#xsee;&amp;#XSEE;
21136 </p>
21137 !! end
21138
21139 !! test
21140 HTML Hex character encoding mixed case
21141 !! options
21142 parsoid=wt2html,wt2wt,html2html
21143 !! wikitext
21144 &#xEE;&#Xee;
21145 !! html/php
21146 <p>&#xee;&#xee;
21147 </p>
21148 !! html/parsoid
21149 <p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
21150 !! end
21151
21152 # See: https://www.w3.org/TR/html5/syntax.html#character-references
21153 # Note that U+000C (form feed) is not a valid XML character, so
21154 # it is banned even though allowed in HTML5.
21155 !! test
21156 Illegal character references (T106578)
21157 !! wikitext
21158 ; Null: &#00;
21159 ; FF: &#xC;
21160 ; CR: &#xD;
21161 ; Control (low): &#8;
21162 ; Control (high): &#x7F; &#x9F;
21163 ; Surrogate: &#xD83D;&#xDCA9;
21164 ; This is an okay astral character: &#x1F4A9;
21165 !! html+tidy
21166 <dl><dt>Null</dt>
21167 <dd>&amp;#00;</dd>
21168 <dt>FF</dt>
21169 <dd>&amp;#xC;</dd>
21170 <dt>CR</dt>
21171 <dd>&amp;#xD;</dd>
21172 <dt>Control (low)</dt>
21173 <dd>&amp;#8;</dd>
21174 <dt>Control (high)</dt>
21175 <dd>&amp;#x7F; &amp;#x9F;</dd>
21176 <dt>Surrogate</dt>
21177 <dd>&amp;#xD83D;&amp;#xDCA9;</dd>
21178 <dt>This is an okay astral character</dt>
21179 <dd>&#x1f4a9;</dd></dl>
21180 !! end
21181
21182 !! test
21183 __FORCETOC__ override
21184 !! wikitext
21185 __NEWSECTIONLINK__
21186 __FORCETOC__
21187 !! html/php
21188 <p><br />
21189 </p>
21190 !! end
21191
21192 !! test
21193 ISBN code coverage
21194 !! wikitext
21195 ISBN 978-0-1234-56&#x20;789
21196 !! html/php
21197 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a>&#x20;789
21198 </p>
21199 !! html/parsoid
21200 <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>
21201 !! end
21202
21203 !! test
21204 ISBN followed by 5 spaces
21205 !! wikitext
21206 ISBN
21207 !! html
21208 <p>ISBN
21209 </p>
21210 !! end
21211
21212 !! test
21213 Double ISBN
21214 !! wikitext
21215 ISBN ISBN 1234567890
21216 !! html/php
21217 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21218 </p>
21219 !! html/parsoid
21220 <p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
21221 !! end
21222
21223 # Uppercase X and lowercase x as well
21224 !! test
21225 ISBN with an X
21226 !! wikitext
21227 ISBN 3-462-04561-X
21228 ISBN 3-462-04561-x
21229 ISBN 080442957X
21230 ISBN 080442957x
21231 ISBN 978080442957X
21232 ISBN 978080442957x
21233 !! html/php
21234 <p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a>
21235 <a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a>
21236 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a>
21237 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a>
21238 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a>
21239 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
21240 </p>
21241 !! html/parsoid
21242 <p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
21243 <a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
21244 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
21245 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
21246 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
21247 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
21248 !! end
21249
21250 !! test
21251 ISBN with empty prefix (parsoid test)
21252 !! wikitext
21253 ISBN 1234567890
21254 !! html/php
21255 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21256 </p>
21257 !! html/parsoid
21258 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p>
21259 !! end
21260
21261 !! test
21262 T24905: <abbr> followed by ISBN followed by </a>
21263 !! wikitext
21264 <abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
21265 !! html/php
21266 <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>
21267 </p>
21268 !! html/parsoid
21269 <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>
21270 !! end
21271
21272 !! test
21273 Double RFC
21274 !! wikitext
21275 RFC RFC 1234
21276 !! html/php
21277 <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a>
21278 </p>
21279 !! html/parsoid
21280 <p>RFC <a href="https://tools.ietf.org/html/rfc1234" rel="mw:ExtLink" class="external mw-magiclink">RFC 1234</a></p>
21281 !! end
21282
21283 !! test
21284 Double RFC with a wiki link
21285 !! wikitext
21286 RFC [[RFC 1234]]
21287 !! html/php
21288 <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>
21289 </p>
21290 !! html/parsoid
21291 <p>RFC <a rel="mw:WikiLink" href="./RFC_1234" title="RFC 1234">RFC 1234</a></p>
21292 !! end
21293
21294 !! test
21295 RFC code coverage
21296 !! wikitext
21297 RFC 983&#x20;987
21298 !! html/php
21299 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
21300 </p>
21301 !! html/parsoid
21302 <p><a href="https://tools.ietf.org/html/rfc983" rel="mw:ExtLink" class="external mw-magiclink" data-parsoid='{"stx":"magiclink"}'>RFC 983</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#x20;","srcContent":" "}'> </span>987</p>
21303 !! end
21304
21305 !! test
21306 Centre-aligned image
21307 !! wikitext
21308 [[Image:foobar.jpg|centre]]
21309 !! html/php
21310 <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>
21311
21312 !! html/parsoid
21313 <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>
21314 !! end
21315
21316 !! test
21317 None-aligned image
21318 !! wikitext
21319 [[Image:foobar.jpg|none]]
21320 !! html/php
21321 <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>
21322
21323 !! html/parsoid
21324 <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>
21325 !! end
21326
21327 !! test
21328 Width + Height sized image (using px) (height is ignored)
21329 !! wikitext
21330 [[Image:foobar.jpg|640x480px]]
21331 !! html/php
21332 <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>
21333 </p>
21334 !! html/parsoid
21335 <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>
21336 !! end
21337
21338 !! test
21339 Width-sized image (using px, no following whitespace)
21340 !! wikitext
21341 [[Image:foobar.jpg|640px]]
21342 !! html/php
21343 <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>
21344 </p>
21345 !! html/parsoid
21346 <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>
21347 !! end
21348
21349 !! test
21350 Width-sized image (using px, with following whitespace - test regression from r39467)
21351 !! wikitext
21352 [[Image:foobar.jpg|640px ]]
21353 !! html/php
21354 <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>
21355 </p>
21356 !! html/parsoid
21357 <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>
21358 !!end
21359
21360 !! test
21361 Width-sized image (using px, with preceding whitespace - test regression from r39467)
21362 !! wikitext
21363 [[Image:foobar.jpg| 640px]]
21364 !! html/php
21365 <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>
21366 </p>
21367 !! html/parsoid
21368 <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>
21369 !! end
21370
21371 !! test
21372 Image with page parameter
21373 !! options
21374 djvu
21375 !! wikitext
21376 [[File:LoremIpsum.djvu|page=2]]
21377 !! html/php
21378 <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>
21379 </p>
21380 !! html/parsoid
21381 <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>
21382 !! end
21383
21384 !! test
21385 Another italics / bold test
21386 !! wikitext
21387 ''' ''x'
21388 !! html
21389 <pre>'<i> </i>x'
21390 </pre>
21391 !!end
21392
21393 # FIXME: The php output seems broken. It's interleaving some open/close tags.
21394 !! test
21395 dt/dd/dl test
21396 !! wikitext
21397 :;;;::
21398 !! html/php
21399 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dt></dl></dd></dl></dd></dl></dd></dl></dd></dl></dd></dl>
21400
21401 !! html/parsoid
21402 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dd></dl></dd></dl></dt></dl></dt></dl></dt></dl></dd></dl>
21403
21404 !!end
21405
21406 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
21407 !! test
21408 Images with the "|" character in the comment
21409 !! wikitext
21410 [[File:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
21411 !! html/php
21412 <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>
21413
21414 !! html/parsoid
21415 <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>
21416 !! end
21417
21418 !! test
21419 [Before] HTML without raw HTML enabled ($wgRawHtml==false)
21420 !! wikitext
21421 <html><script>alert(1);</script></html>
21422 !! html
21423 <p>&lt;html&gt;&lt;script&gt;alert(1);&lt;/script&gt;&lt;/html&gt;
21424 </p>
21425 !! end
21426
21427 !! test
21428 HTML with raw HTML ($wgRawHtml==true)
21429 !! options
21430 wgRawHtml=1
21431 !! wikitext
21432 <html><script>alert(1);</script></html>
21433 !! html/php
21434 <p><script>alert(1);</script>
21435 </p>
21436 !! end
21437
21438 !! test
21439 Parents of subpages, one level up
21440 !! options
21441 subpage title=[[Subpage test/L1/L2/L3]]
21442 !! wikitext
21443 [[../|L2]]
21444 !! html
21445 <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>
21446 </p>
21447 !! end
21448
21449
21450 !! test
21451 Parents of subpages, one level up, not named
21452 !! options
21453 subpage title=[[Subpage test/L1/L2/L3]]
21454 !! wikitext
21455 [[../]]
21456 !! html
21457 <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>
21458 </p>
21459 !! end
21460
21461
21462
21463 !! test
21464 Parents of subpages, two levels up
21465 !! options
21466 subpage title=[[Subpage test/L1/L2/L3]]
21467 !! wikitext
21468 [[../../|L1]]2
21469
21470 [[../../|L1]]l
21471 !! html
21472 <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
21473 </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>
21474 </p>
21475 !! end
21476
21477 !! test
21478 Parents of subpages, two levels up, without trailing slash or name.
21479 !! options
21480 subpage title=[[Subpage test/L1/L2/L3]]
21481 !! wikitext
21482 [[../..]]
21483 !! html
21484 <p>[[../..]]
21485 </p>
21486 !! end
21487
21488 !! test
21489 Parents of subpages, two levels up, with lots of extra trailing slashes.
21490 !! options
21491 subpage title=[[Subpage test/L1/L2/L3]]
21492 !! wikitext
21493 [[../../////]]
21494 !! html
21495 <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>
21496 </p>
21497 !! end
21498
21499 !! article
21500 Subpage test/L1/L2/L3Sibling
21501 !! text
21502 Sibling article
21503 !! endarticle
21504
21505 !! test
21506 Transclusion of a sibling page (one level up)
21507 !! options
21508 subpage title=[[Subpage test/L1/L2/L3]]
21509 !! wikitext
21510 {{../L3Sibling}}
21511 !! html
21512 <p>Sibling article
21513 </p>
21514 !! end
21515
21516 !! test
21517 Transclusion of a child page
21518 !! options
21519 subpage title=[[Subpage test/L1/L2]]
21520 !! wikitext
21521 {{/L3Sibling}}
21522 !! html
21523 <p>Sibling article
21524 </p>
21525 !! end
21526
21527 # This is wt2html only in Parsoid because we add <nowiki>
21528 # because of {{..}} and we don't expect to fix that to
21529 # eliminate the nowikis selective for {{..}} markup.
21530 !! test
21531 Non-transclusion because of too many up levels
21532 !! options
21533 subpage title=[[Subpage test/L1/L2/L3]]
21534 parsoid=wt2html
21535 !! wikitext
21536 {{../../../../More than parent}}
21537 !! html/php
21538 <p>{{../../../../More than parent}}
21539 </p>
21540 !! html/parsoid
21541 <p>{{../../../../More than parent}}</p>
21542 !! end
21543
21544 !! test
21545 Definition list code coverage
21546 !! wikitext
21547 ;title :def
21548 ;title :def
21549 ;title:def
21550 !! html/php
21551 <dl><dt>title</dt>
21552 <dd>def</dd>
21553 <dt>title</dt>
21554 <dd>def</dd>
21555 <dt>title</dt>
21556 <dd>def</dd></dl>
21557
21558 !! html/parsoid
21559 <dl><dt>title </dt><dd>def</dd>
21560 <dt>title </dt><dd>def</dd>
21561 <dt>title</dt><dd>def</dd></dl>
21562 !! end
21563
21564 !! test
21565 Don't fall for the self-closing div
21566 !! wikitext
21567 <div>hello world</div/>
21568 !! html
21569 <div>hello world</div>
21570
21571 !! end
21572
21573 !! test
21574 MSGNW magic word
21575 !! wikitext
21576 {{MSGNW:msg}}
21577 !! html/php
21578 <p>&#91;&#91;:Template:Msg&#93;&#93;
21579 </p>
21580 !! end
21581
21582 !! test
21583 RAW magic word
21584 !! wikitext
21585 {{RAW:QUERTY}}
21586 !! html
21587 <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>
21588 </p>
21589 !! end
21590
21591 # This isn't needed for XHTML conformance, but would be handy as a fallback security measure
21592 !! test
21593 Always escape literal '>' in output, not just after '<'
21594 !! wikitext
21595 ><>
21596 !! html
21597 <p>&gt;&lt;&gt;
21598 </p>
21599 !! end
21600
21601 !! test
21602 Template caching
21603 !! wikitext
21604 {{Test}}
21605 {{Test}}
21606 !! html
21607 <p>This is a test template
21608 This is a test template
21609 </p>
21610 !! end
21611
21612
21613 !! article
21614 MediaWiki:Fake
21615 !! text
21616 ==header==
21617 !! endarticle
21618
21619 !! test
21620 Inclusion of !userCanEdit() content
21621 !! wikitext
21622 {{MediaWiki:Fake}}
21623 !! html
21624 <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>
21625
21626 !! end
21627
21628
21629 !! test
21630 Out-of-order TOC heading levels
21631 !! wikitext
21632 ==2==
21633 ======6======
21634 ===3===
21635 =1=
21636 =====5=====
21637 ==2==
21638 !! html
21639 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
21640 <ul>
21641 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
21642 <ul>
21643 <li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
21644 <li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
21645 </ul>
21646 </li>
21647 <li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
21648 <ul>
21649 <li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
21650 <li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
21651 </ul>
21652 </li>
21653 </ul>
21654 </div>
21655
21656 <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>
21657 <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>
21658 <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>
21659 <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>
21660 <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>
21661 <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>
21662
21663 !! end
21664
21665
21666 !! test
21667 ISBN with a dummy number
21668 !! wikitext
21669 ISBN ---
21670 !! html
21671 <p>ISBN ---
21672 </p>
21673 !! end
21674
21675
21676 !! test
21677 ISBN with space-delimited number
21678 !! wikitext
21679 ISBN 92 9017 032 8
21680 !! html/php
21681 <p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a>
21682 </p>
21683 !! html/parsoid
21684 <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>
21685 !! end
21686
21687
21688 !! test
21689 ISBN with multiple spaces, no number
21690 !! wikitext
21691 ISBN foo
21692 !! html
21693 <p>ISBN foo
21694 </p>
21695 !! end
21696
21697
21698 !! test
21699 ISBN length
21700 !! wikitext
21701 ISBN 123456789
21702
21703 ISBN 1234567890
21704
21705 ISBN 12345678901
21706 !! html/php
21707 <p>ISBN 123456789
21708 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21709 </p><p>ISBN 12345678901
21710 </p>
21711 !! html/parsoid
21712 <p>ISBN 123456789</p>
21713
21714 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
21715
21716 <p>ISBN 12345678901</p>
21717 !! end
21718
21719
21720 !! test
21721 ISBN with trailing year (T9110)
21722 !! wikitext
21723 ISBN 1-234-56789-0 - 2006
21724
21725 ISBN 1 234 56789 0 - 2006
21726 !! html/php
21727 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006
21728 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006
21729 </p>
21730 !! html/parsoid
21731 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p>
21732
21733 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p>
21734 !! end
21735
21736
21737 !! test
21738 anchorencode
21739 !! config
21740 wgFragmentMode=[ 'html5', 'legacy' ]
21741 !! wikitext
21742 {{anchorencode:foo bar©#%n}}
21743 !! html/php
21744 <p>foo_bar©#%n
21745 </p>
21746 !! html/parsoid
21747 <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>
21748 !! end
21749
21750 !! test
21751 anchorencode (legacy)
21752 !! config
21753 wgFragmentMode=[ 'legacy' ]
21754 !! wikitext
21755 {{anchorencode:foo bar©#%n}}
21756 !! html/php
21757 <p>foo_bar.C2.A9.23.25n
21758 </p>
21759 !! end
21760
21761 !! test
21762 anchorencode trims spaces
21763 !! config
21764 wgFragmentMode=[ 'html5', 'legacy' ]
21765 !! wikitext
21766 {{anchorencode: __pretty__please__}}
21767 !! html/php
21768 <p>pretty_please
21769 </p>
21770 !! html/parsoid
21771 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: __pretty__please__","function":"anchorencode"},"params":{},"i":0}}]}'>pretty_please</p>
21772 !! end
21773
21774 !! test
21775 anchorencode deals with links
21776 !! config
21777 wgFragmentMode=[ 'html5', 'legacy' ]
21778 !! wikitext
21779 {{anchorencode: [[hello|world]] [[hi]]}}
21780 !! html/php
21781 <p>world_hi
21782 </p>
21783 !! html/parsoid
21784 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: [[hello|world]] [[hi]]","function":"anchorencode"},"params":{},"i":0}}]}'>world_hi</p>
21785 !! end
21786
21787 !! test
21788 anchorencode deals with templates
21789 !! config
21790 wgFragmentMode=[ 'html5', 'legacy' ]
21791 !! wikitext
21792 {{anchorencode: {{Foo}} x}}
21793 !! html/php
21794 <p>FOO_x
21795 </p>
21796 !! html/parsoid
21797 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: {{Foo}} x","function":"anchorencode"},"params":{},"i":0}}]}'>FOO_x</p>
21798 !! end
21799
21800 !! test
21801 anchorencode encodes like the TOC generator: (T20431)
21802 !! config
21803 wgFragmentMode=[ 'html5', 'legacy' ]
21804 !! wikitext
21805 ===_ +:.3A%3A _ &&amp;]] x===
21806 {{anchorencode: _ +:.3A%3A _ &&amp;]] x}}
21807 __NOEDITSECTION__
21808 !! html/php
21809 <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>
21810 <p>+:.3A%3A_&amp;&amp;&#93;&#93;_x
21811 </p>
21812 !! html/parsoid
21813 <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>
21814 <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>
21815 <meta property="mw:PageProp/noeditsection"/>
21816 !! end
21817
21818 !! test
21819 anchorencode encodes like the TOC generator: (T20431) (legacy)
21820 !! config
21821 wgFragmentMode=[ 'legacy' ]
21822 !! wikitext
21823 ===_ +:.3A%3A&&amp;]]===
21824 {{anchorencode: _ +:.3A%3A&&amp;]] }}
21825 __NOEDITSECTION__
21826 !! html/php
21827 <h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&amp;&amp;]]</span></h3>
21828 <p>.2B:.3A.253A.26.26.5D.5D
21829 </p>
21830 !! end
21831
21832 !! test
21833 T8200: blockquotes and paragraph formatting
21834 !! wikitext
21835 <blockquote>
21836 foo
21837 </blockquote>
21838
21839 bar
21840
21841 baz
21842 !! html
21843 <blockquote>
21844 <p>foo
21845 </p>
21846 </blockquote>
21847 <p>bar
21848 </p>
21849 <pre>baz
21850 </pre>
21851 !! end
21852
21853 !! test
21854 T10293: Use of center tag ruins paragraph formatting
21855 !! wikitext
21856 <center>
21857 foo
21858 </center>
21859
21860 bar
21861
21862 baz
21863 !! html
21864 <center>
21865 <p>foo
21866 </p>
21867 </center>
21868 <p>bar
21869 </p>
21870 <pre>baz
21871 </pre>
21872 !! end
21873
21874 !!test
21875 Parsing of overlapping (improperly nested) inline html tags
21876 !! wikitext
21877 <span><s>x</span></s>
21878 !! html/php
21879 <p><span><s>x&lt;/span&gt;</s></span>
21880 </p>
21881 !! html/parsoid
21882 <p><span><s>x</s></span>
21883 </p>
21884 !!end
21885
21886 ###
21887 ### Language variants related tests
21888 ###
21889
21890 # Parsoid does not mark self-links.
21891 # Parsoid does not convert links; PHP will do any necessary redirects.
21892
21893 !! test
21894 Self-link in language variants
21895 !! options
21896 title=[[Dunav]] language=sr
21897 !! wikitext
21898 Both [[Dunav]] and [[Дунав]] are names for this river.
21899 !! html/php
21900 <p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
21901 </p>
21902 !! html/parsoid
21903 <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>
21904 !! end
21905
21906 !! article
21907 Дуна
21908 !! text
21909 content
21910 !! endarticle
21911
21912 !! test
21913 Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
21914 !! options
21915 title=[[Duna]] language=sr
21916 !! wikitext
21917 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
21918 !! html/php
21919 <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.
21920 </p>
21921 !! html/parsoid
21922 <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>
21923 !! end
21924
21925 !! test
21926 Link to a section of a variant of this title shouldn't be parsed as self-link
21927 !! options
21928 title=[[Duna]] language=sr
21929 !! wikitext
21930 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
21931 !! html/php
21932 <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.
21933 </p>
21934 !! html/parsoid
21935 <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>
21936 !! end
21937
21938 !! test
21939 Link to pages in language variants
21940 !! options
21941 language=sr
21942 !! wikitext
21943 Main Page can be written as [[Маин Паге]]
21944 !! html/php
21945 <p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>
21946 </p>
21947 !! html/parsoid
21948 <p>Main Page can be written as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a></p>
21949 !! end
21950
21951
21952 !! test
21953 Multiple links to pages in language variants
21954 !! options
21955 language=sr
21956 !! wikitext
21957 [[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
21958 !! html/php
21959 <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>.
21960 </p>
21961 !! html/parsoid
21962 <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>
21963 !! end
21964
21965
21966 !! test
21967 Simple template in language variants
21968 !! options
21969 language=sr
21970 !! wikitext
21971 {{тест}}
21972 !! html/php
21973 <p>This is a test template
21974 </p>
21975 !! end
21976
21977
21978 !! test
21979 Template with explicit namespace in language variants
21980 !! options
21981 language=sr
21982 !! wikitext
21983 {{Template:тест}}
21984 !! html/php
21985 <p>This is a test template
21986 </p>
21987 !! end
21988
21989
21990 !! test
21991 Basic test for template parameter in language variants
21992 !! options
21993 language=sr
21994 !! wikitext
21995 {{парамтест|param=foo}}
21996 !! html/php
21997 <p>This is a test template with parameter foo
21998 </p>
21999 !! end
22000
22001 !! test
22002 Simple category in language variants
22003 !! options
22004 language=sr cat
22005 !! wikitext
22006 [[Category:МедиаWики Усер'с Гуиде]]
22007 !! html/php
22008 cat=МедиаWики_Усер'с_Гуиде sort=
22009 !! html/parsoid
22010 <link rel="mw:PageProp/Category" href="./Категорија:МедиаWики_Усер'с_Гуиде" data-parsoid='{"stx":"simple","a":{"href":"./Категорија:МедиаWики_Усер&#39;с_Гуиде"},"sa":{"href":"Category:МедиаWики Усер&#39;с Гуиде"}}'/>
22011 !! end
22012
22013 !! article
22014 Category:分类
22015 !! text
22016 blah
22017 !! endarticle
22018
22019 !! article
22020 Category:分類
22021 !! text
22022 blah
22023 !! endarticle
22024
22025 ## We used to, but no longer wt2wt this test since the default serializer
22026 ## will normalize all categories to serialize on their own line.
22027 ## This wikitext usage is going to be fairly uncommon in production and
22028 ## selser will take care of preserving formatting in those scenarios.
22029 !! test
22030 Don't convert blue categorylinks to another variant (T35210)
22031 !! options
22032 cat
22033 language=zh
22034 parsoid=wt2html
22035 !! wikitext
22036 [[A]][[Category:分类]]
22037 !! html/php
22038 cat=分类 sort=
22039 !! html/parsoid
22040 <p><a rel="mw:WikiLink" href="./A" title="A">A</a></p>
22041 <link rel="mw:PageProp/Category" href="./Category:分类"/>
22042 !! end
22043
22044 !! test
22045 Stripping -{}- tags (language variants)
22046 !! options
22047 language=sr
22048 !! wikitext
22049 Latin proverb: -{Ne nuntium necare}-
22050 !! html/php
22051 <p>Latin proverb: Ne nuntium necare
22052 </p>
22053 !! html/parsoid
22054 <p>Latin proverb: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22055 !! end
22056
22057
22058 !! test
22059 Prevent conversion with -{}- tags (language variants)
22060 !! options
22061 language=sr variant=sr-ec
22062 !! wikitext
22063 Latinski: -{Ne nuntium necare}-
22064 !! html/php
22065 <p>Латински: Ne nuntium necare
22066 </p>
22067 !! html/parsoid
22068 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22069 !! end
22070
22071
22072 !! test
22073 Prevent conversion of text with -{}- tags (language variants)
22074 !! options
22075 language=sr variant=sr-ec
22076 !! wikitext
22077 Latinski: -{Ne nuntium necare}-
22078 !! html/php
22079 <p>Латински: Ne nuntium necare
22080 </p>
22081 !! html/parsoid
22082 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22083 !! end
22084
22085
22086 !! test
22087 Prevent conversion of links with -{}- tags (language variants)
22088 !! options
22089 language=sr variant=sr-ec
22090 !! wikitext
22091 -{[[Main Page]]}-
22092 !! html/php
22093 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
22094 </p>
22095 !! html/parsoid
22096 <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>
22097 !! end
22098
22099
22100 !! test
22101 -{}- tags within headlines (within html for parserConvert())
22102 !! config
22103 wgFragmentMode=[ 'html5', 'legacy' ]
22104 !! options
22105 language=sr variant=sr-ec
22106 !! wikitext
22107 ==-{Naslov}-==
22108
22109 Note that even an unprotected headline ID is not affected by language
22110 conversion:
22111
22112 ==Latinski==
22113 !! html/php
22114 <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>
22115 <p>Ноте тхат евен ан унпротецтед хеадлине ИД ис нот аффецтед бy лангуаге
22116 цонверсион:
22117 </p>
22118 <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>
22119
22120 !! html/parsoid
22121 <h2 id="-{Naslov}-"><span id="-.7BNaslov.7D-" typeof="mw:FallbackId"></span><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Naslov"}}'></span></h2>
22122
22123 <p>Note that even an unprotected headline ID is not affected by language
22124 conversion:</p>
22125
22126 <h2 id="Latinski">Latinski</h2>
22127 !! end
22128
22129 !! test
22130 Explicit definition of language variant alternatives
22131 !! options
22132 language=zh variant=zh-tw
22133 !! wikitext
22134 -{zh:China;zh-tw:Taiwan}-, not China
22135 !! html/php
22136 <p>Taiwan, not China
22137 </p>
22138 !! html/parsoid
22139 <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>
22140 !! end
22141
22142 !! test
22143 Filter syntax for language variants
22144 !! options
22145 language=zh variant=zh-tw
22146 !! wikitext
22147 foo-{zh;zh-hans;zh-hant|blog, WEBJOURNAL, WEBLOG}-quux
22148 !! html/php
22149 <p>fooblog, WEBJOURNAL, WEBLOGquux
22150 </p>
22151 !! html/parsoid
22152 <p>foo<span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"blog, WEBJOURNAL, WEBLOG"}}'></span>quux</p>
22153 !! end
22154
22155 # Note that Parsoid post-processing for language variants needs to
22156 # update the `title` attribute here, based on the mw:ExpandedAttrs property
22157 !! test
22158 Conversion around HTML tags
22159 !! options
22160 language=sr variant=sr-ec
22161 !! wikitext
22162 -{H|span=>sr-ec:script;title=>sr-ec:src}-
22163 <span title="La-{sr-el:L;sr-ec:C}-tin">ski</span>
22164 !! html/php
22165 <p>
22166 <span title="ЛаCтин">ски</span>
22167 </p>
22168 !! html/parsoid
22169 <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"}]}'/>
22170 <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>
22171 !! end
22172
22173 !! test
22174 Explicit session-wise two-way language variant mapping (A flag and - flag)
22175 !! options
22176 language=zh variant=zh-tw
22177 !! wikitext
22178 This is -{zh:China; zh-tw:Taiwan}-, but we'll forget that now.
22179
22180 Taiwan is not China.
22181
22182 But -{A|zh:China; zh-tw:Taiwan}- is China,
22183
22184 (This-{-|zh:China; zh-tw:Taiwan}- should be stripped!)
22185
22186 and -{China}- is China.
22187 !! html/php
22188 <p>This is Taiwan, but we'll forget that now.
22189 </p><p>Taiwan is not China.
22190 </p><p>But Taiwan is Taiwan,
22191 </p><p>(This should be stripped!)
22192 </p><p>and China is China.
22193 </p>
22194 !! html/parsoid
22195 <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>
22196 <p>Taiwan is not China.</p>
22197 <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>
22198 <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>
22199 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"China"}}'></span> is China.</p>
22200 !! end
22201
22202 !! test
22203 Explicit session-wise one-way language variant mapping (A flag and - flag)
22204 !! options
22205 language=zh variant=zh-tw
22206 !! wikitext
22207 This is -{COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}-, but we'll forget that now.
22208
22209 COUNTRY is China or Taiwan.
22210
22211 But -{A|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- is COUNTRY,
22212
22213 (This-{-|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
22214
22215 and -{COUNTRY}- is COUNTRY.
22216 !! html/php
22217 <p>This is Taiwan, but we'll forget that now.
22218 </p><p>COUNTRY is China or Taiwan.
22219 </p><p>But Taiwan is Taiwan,
22220 </p><p>(This should be stripped!)
22221 </p><p>and COUNTRY is COUNTRY.
22222 </p>
22223 !! html/parsoid
22224 <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>
22225 <p>COUNTRY is China or Taiwan.</p>
22226 <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>
22227 <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>
22228 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"COUNTRY"}}'></span> is COUNTRY.</p>
22229 !! end
22230
22231 !! test
22232 Explicit session-wise two-way language variant mapping (H flag for hide)
22233 !! options
22234 language=zh variant=zh-tw
22235 !! wikitext
22236 (This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
22237
22238 Taiwan is China.
22239 !! html/php
22240 <p>(This should be stripped!)
22241 </p><p>Taiwan is Taiwan.
22242 </p>
22243 !! html/parsoid
22244 <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>
22245 <p>Taiwan is China.</p>
22246 !! end
22247
22248 !! test
22249 Explicit session-wise one-way language variant mapping (H flag for hide)
22250 !! options
22251 language=zh variant=zh-tw
22252 !! wikitext
22253 (This-{H|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
22254
22255 COUNTRY is Taiwan or China.
22256 !! html/php
22257 <p>(This should be stripped!)
22258 </p><p>Taiwan is Taiwan or China.
22259 </p>
22260 !! html/parsoid
22261 <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>
22262 <p>COUNTRY is Taiwan or China.</p>
22263 !! end
22264
22265 ## Note that parsoid test runner does not support 'showtitle' option.
22266 !! test
22267 Adding explicit conversion rule for title (T flag)
22268 !! options
22269 language=zh variant=zh-tw showtitle
22270 !! wikitext
22271 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
22272
22273 Taiwan is China.
22274 !! html/php
22275 Taiwan
22276 <p>Should be stripped!
22277 </p><p>Taiwan is China.
22278 </p>
22279 !! html/parsoid
22280 <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>
22281 <p>Taiwan is China.</p>
22282 !! end
22283
22284 !! test
22285 Code coverage: T combined with H flag
22286 !! options
22287 language=zh variant=zh-tw showtitle
22288 !! wikitext
22289 Should be stripped-{T;H|zh:China; zh-tw:Taiwan}-!
22290
22291 Taiwan is China.
22292 !! html/php
22293 Taiwan
22294 <p>Should be stripped!
22295 </p><p>Taiwan is Taiwan.
22296 </p>
22297 !! html/parsoid
22298 <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>
22299 <p>Taiwan is China.</p>
22300 !! end
22301
22302 !! test
22303 Code coverage: T with no variants
22304 !! options
22305 language=zh variant=zh-tw showtitle
22306 !! wikitext
22307 -{H|zh:China; zh-tw:Taiwan}-
22308 Taiwan is China.-{T|Taiwan is China}-
22309 !! html/php
22310 Taiwan is China
22311 <p>
22312 Taiwan is Taiwan.
22313 </p>
22314 !! html/parsoid
22315 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
22316 Taiwan is China.<meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Taiwan is China"},"title":true}'/></p>
22317 !! end
22318
22319 !! test
22320 Code coverage: rules with no variants
22321 !! options
22322 language=zh variant=zh-tw
22323 !! wikitext
22324 -{H|zh:China; zh-tw:Taiwan}-
22325 Taiwan is China.
22326 -{H|China}-
22327 Taiwan is China.
22328 !! html/php
22329 <p>
22330 Taiwan is Taiwan.
22331
22332 Taiwan is China.
22333 </p>
22334 !! html/parsoid
22335 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
22336 Taiwan is China.
22337 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":"China"}]}'/>
22338 Taiwan is China.</p>
22339 !! end
22340
22341
22342 !! test
22343 Code coverage: D flag for conversion rule
22344 !! options
22345 language=zh variant=zh-tw
22346 !! wikitext
22347 -{D|zh-cn:XA; zh-tw:YA}-
22348 -{A;D|zh-cn:XB; zh-tw:YB}-
22349 -{D;H|zh-cn:XC; zh-tw:YC}-
22350
22351 -{D;H|FOO=>zh-tw:BAR;FOO=>zh-cn:BAT}-
22352
22353 -{D|0=>zh-tw:1}-
22354 -{A;D|2=>zh-tw:3}-
22355 -{D;H|4=>zh-tw:5}-
22356
22357 XA XB XC YA YB YC FOO BAR BAT 012345
22358 !! html/php
22359 <p>大陆:XA;台灣:YA;
22360
22361 大陆:XC;台灣:YC;
22362 </p><p>FOO⇒台灣:BAR;FOO⇒大陆:BAT;
22363 </p><p>0⇒台灣:1;
22364
22365 4⇒台灣:5;
22366 </p><p>XA YB YC YA YB YC BAR BAR BAT 013355
22367 </p>
22368 !! html/parsoid
22369 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"twoway":[{"l":"zh-cn","t":"XA"},{"l":"zh-tw","t":"YA"}]}'></span>
22370 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XB"},{"l":"zh-tw","t":"YB"}]}'/>
22371 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XC"},{"l":"zh-tw","t":"YC"}]}'></span></p>
22372 <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>
22373 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"oneway":[{"f":"0","l":"zh-tw","t":"1"}]}'></span>
22374 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"2","l":"zh-tw","t":"3"}]}'/>
22375 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"4","l":"zh-tw","t":"5"}]}'></span></p>
22376 <p>XA XB XC YA YB YC FOO BAR BAT 012345</p>
22377 !! end
22378
22379 !! test
22380 Code coverage: N flag for conversion rule
22381 !! options
22382 language=zh variant=zh-cn
22383 !! wikitext
22384 -{N|zh-cn}-
22385
22386 -{N|zh-tw}-
22387
22388 -{N|sr-ec}-
22389 !! html/php
22390 <p>大陆
22391 </p><p>台灣
22392 </p><p>српски (ћирилица)‎
22393 </p>
22394 !! html/parsoid
22395 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-cn"}}'></span></p>
22396 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-tw"}}'></span></p>
22397 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"sr-ec"}}'></span></p>
22398 !! end
22399
22400 # html2wt suppresses the bogus 'D' flag, so this is wt2html only
22401 !! test
22402 Code coverage: N flag for conversion rule (wt2html only)
22403 !! options
22404 language=zh variant=zh-cn
22405 parsoid=wt2html,html2html
22406 !! wikitext
22407 -{D;N|en}-
22408 !! html/php
22409 <p>English
22410 </p>
22411 !! html/parsoid
22412 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"en"}}' data-parsoid='{"fl":["D","N"]}'></span></p>
22413 !! end
22414
22415 !! test
22416 Testing that changing the language variant here in the tests actually works
22417 !! options
22418 language=zh variant=zh showtitle
22419 !! wikitext
22420 Should be stripped-{T|zh:China; zh-tw:Taiwan}-!
22421 !! html/php
22422 China
22423 <p>Should be stripped!
22424 </p>
22425 !! html/parsoid
22426 <p>Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
22427 !! end
22428
22429 !! test
22430 Recursive conversion of alt and title attrs shouldn't clear converter state
22431 !! options
22432 language=zh variant=zh-cn
22433 showtitle
22434 !! wikitext
22435 -{H|zh-cn:Exclamation; zh-tw:exclamation}-
22436 Should be stripped-{T|zh-cn:China; zh-tw:Taiwan}-<span title="exclamation">!</span>
22437 !! html/php
22438 China
22439 <p>
22440 Should be stripped<span title="Exclamation">!</span>
22441 </p>
22442 !! html/parsoid
22443 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh-cn","t":"Exclamation"},{"l":"zh-tw","t":"exclamation"}]}'/>
22444 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>
22445 !! end
22446
22447 !! test
22448 T26072: more test on conversion rule for title
22449 !! options
22450 language=zh variant=zh-tw showtitle
22451 !! wikitext
22452 This should be stripped-{T|zh:China; zh-tw:Taiwan}-!
22453
22454 This won't take interferes with the title rule-{H|zh:Beijing; zh-tw:Taipei}-.
22455 !! html/php
22456 Taiwan
22457 <p>This should be stripped!
22458 </p><p>This won't take interferes with the title rule.
22459 </p>
22460 !! html/parsoid
22461 <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>
22462 <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>
22463 !! end
22464
22465 !! test
22466 Partly disable title conversion if variant == main language code
22467 !! options
22468 language=zh variant=zh title=[[ZH]] showtitle
22469 !! wikitext
22470 -{T|zh-cn:CN;zh-tw:TW}-
22471 !! html/php
22472 ZH
22473 <p>
22474 </p>
22475 !! html/parsoid
22476 <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>
22477 !! end
22478
22479 !! test
22480 Partly disable title conversion if variant == main language code, more
22481 !! options
22482 language=zh variant=zh title=[[ZH]] showtitle
22483 !! wikitext
22484 -{T|TW}-
22485 !! html/php
22486 ZH
22487 <p>
22488 </p>
22489 !! html/parsoid
22490 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"TW"},"title":true}'/></p>
22491 !! end
22492
22493 !! test
22494 Raw output of variant escape tags (R flag)
22495 !! options
22496 language=zh variant=zh-tw
22497 !! wikitext
22498 Raw: -{R|zh:China;zh-tw:Taiwan}-
22499 !! html/php
22500 <p>Raw: zh:China;zh-tw:Taiwan
22501 </p>
22502 !! html/parsoid
22503 <p>Raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"zh:China;zh-tw:Taiwan"}}'></span></p>
22504 !! end
22505
22506 # html2wt suppresses the bogus 'D' flags, so this is wt2html only
22507 !! test
22508 Raw output of variant escape tags (R flag) (wt2html only)
22509 !! options
22510 language=zh variant=zh-tw
22511 parsoid=wt2html,html2html
22512 !! wikitext
22513 -{Variant}- -{D|syntax}- -{D;R|options}-
22514 !! html/php
22515 <p>Variant syntax options
22516 </p>
22517 !! html/parsoid
22518 <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>
22519 !! end
22520
22521 !! test
22522 Nested markup inside raw output of variant escape tags (R flag)
22523 !! options
22524 language=zh variant=zh-tw
22525 !! wikitext
22526 Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
22527 !! html/php
22528 <p>Nested raw: nested Taiwan nested
22529 </p>
22530 !! html/parsoid
22531 <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>
22532 !! end
22533
22534 !! test
22535 Nested markup and spaces inside raw output of variant escape tags (R flag)
22536 !! options
22537 language=zh variant=zh-tw
22538 !! wikitext
22539 X-{ outer -{ inner }- outer }-X
22540 !! html/php
22541 <p>X outer inner outer X
22542 </p>
22543 !! html/parsoid
22544 <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>
22545 !! end
22546
22547 !! test
22548 Templates inside raw output of variant escape tags (R flag)
22549 !! options
22550 language=zh variant=zh-tw
22551 !! wikitext
22552 Nested raw: -{R|nested {{echo|hi}} templates}-
22553 !! html/php
22554 <p>Nested raw: nested hi templates
22555 </p>
22556 !! html/parsoid
22557 <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>
22558 !! end
22559
22560 !! test
22561 Strings evaluating false shouldn't be ignored by Language converter (T51072)
22562 !! options
22563 language=zh variant=zh-cn
22564 !! wikitext
22565 -{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
22566 !! html/php
22567 <p>0
22568 </p>
22569 !! html/parsoid
22570 <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>
22571 !! end
22572
22573 !! test
22574 Conversion rules from [numeric-only string] to [something else] (T48634)
22575 !! options
22576 language=zh variant=zh-cn
22577 !! wikitext
22578 -{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
22579 !! html/php
22580 <p>D12345EE12345
22581 </p>
22582 !! html/parsoid
22583 <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>
22584 !! end
22585
22586 !! test
22587 Two-way converter rule entries with an empty value should be ignored (T53551)
22588 !! options
22589 language=zh variant=zh-cn
22590 !! wikitext
22591 -{H|zh-cn:foo;zh-tw:;}-foobar
22592 !! html/php
22593 <p>foobar
22594 </p>
22595 !! html/parsoid
22596 <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>
22597 !! end
22598
22599 !! test
22600 One-way converter rule entries with an empty "from" string should be ignored (T53551)
22601 !! options
22602 language=zh variant=zh-cn
22603 !! wikitext
22604 -{H|=>zh-cn:foo;}-foobar
22605 !! html/php
22606 <p>foobar
22607 </p>
22608 !! html/parsoid
22609 <p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[5]}' data-mw-variant='{"add":true,"oneway":[{"f":"","l":"zh-cn","t":"foo"}]}'/>foobar</p>
22610 !! end
22611
22612 !! test
22613 Empty converter rule entries shouldn't be inserted into the conversion table (T53551)
22614 !! options
22615 language=zh variant=zh-cn
22616 !! wikitext
22617 -{H|}-foobar
22618 !! html/php
22619 <p>foobar
22620 </p>
22621 !! html/parsoid
22622 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":""}]}'/>foobar</p>
22623 !! end
22624
22625 !! test
22626 Nested using of manual convert syntax
22627 !! options
22628 language=zh variant=zh-hk
22629 !! wikitext
22630 Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
22631 !! html/php
22632 <p>Nested: Hello Hong Kong!
22633 </p>
22634 !! html/parsoid
22635 <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>
22636 !! end
22637
22638 !! test
22639 HTML markups with conversion syntax in attribs, nested in other conversion blocks
22640 !! options
22641 language=zh variant=zh-cn
22642 !! wikitext
22643 -{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}-
22644 !! html/php
22645 <p><span title="X">A</span>
22646 </p>
22647 !! html/parsoid
22648 <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>
22649 !! end
22650
22651 !! test
22652 HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet in PHP parser)
22653 !! options
22654 language=zh variant=zh-cn
22655 !! wikitext
22656 -{<span title="-{X}-">A</span>}-
22657 !! html/php+disabled
22658 <p><span title="X">A</span>
22659 </p>
22660 !! html/parsoid
22661 <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>
22662 !! end
22663
22664 # Parsoid and PHP disagree on how to parse this example: Parsoid
22665 # insists that the content of a language converter element be a valid
22666 # DOM fragment or attribute string
22667 !! test
22668 Language converter markup with block content
22669 !! options
22670 language=zh variant=zh-cn
22671 !! wikitext
22672 <span>a-{b<div>c}-d
22673
22674 <span>a-{zh;zh-hans;zh-hant|b<div>c}-d
22675
22676 <span>a-{H|0=>zh-cn:x<span>y;0=>zh-tw:b<div>c}-d
22677 !! html/php+tidy
22678 <span>ab<div>cd
22679 <span>ab<div>cd
22680 <span>ad
22681 </span></div></span></div></span>
22682 !! html/parsoid
22683 <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>
22684
22685 <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>
22686
22687 <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>
22688 !! end
22689
22690 !! test
22691 LanguageConverter selser (1)
22692 !! options
22693 language=zh variant=zh-cn
22694 parsoid={
22695 "modes": ["wt2wt", "selser"],
22696 "changes": [
22697 ["span[typeof]", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
22698 ]
22699 }
22700 !! wikitext
22701 -{raw}-
22702 !! wikitext/edited
22703 -{edited}-
22704 !! end
22705
22706 !! test
22707 LanguageConverter selser (2)
22708 !! options
22709 language=zh variant=zh-cn
22710 parsoid={
22711 "modes": ["wt2wt", "selser"],
22712 "changes": [
22713 ["span[class='x']", "contents", "text", "-{foo}-"],
22714 ["a", "contents", "text", "-{"],
22715 ["span[typeof]", "attr", "data-mw", "{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"-{\"}},\"i\":0}}]}"]
22716 ]
22717 }
22718 !! wikitext
22719 <span class="x">TEXT1</span>
22720 [http://example.com TEXT2]
22721 [[Foo|TEXT3]]
22722 {{echo|TEXT4}}
22723 !! wikitext/edited
22724 <span class="x"><nowiki>-{foo}-</nowiki></span>
22725 [http://example.com -{]
22726 [[Foo|<nowiki>-{</nowiki>]]
22727 {{1x|<nowiki>-{</nowiki>}}
22728 !! end
22729
22730 # Tests LanguageVariantText in ConstrainedText
22731 !! test
22732 LanguageConverter selser (3)
22733 !! options
22734 language=zh variant=zh-cn
22735 parsoid={
22736 "modes": ["wt2wt", "selser"],
22737 "changes": [
22738 ["td > span", "attr", "typeof", "mw:LanguageVariant"],
22739 ["td > span", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
22740 ]
22741 }
22742 !! wikitext
22743 {|
22744 |-
22745 |<span>Foo</span>
22746 |}
22747 !! wikitext/edited
22748 {|
22749 |-
22750 |<nowiki/>-{edited}-
22751 |}
22752 !! end
22753
22754 # Tests LanguageVariantText._fromSelSer
22755 !! test
22756 LanguageConverter selser (4)
22757 !! options
22758 language=zh variant=zh-cn
22759 parsoid={
22760 "modes": ["wt2wt", "selser"],
22761 "changes": [
22762 ["td > span.x", "remove"]
22763 ]
22764 }
22765 !! wikitext
22766 {|
22767 |-
22768 |<span class="x">Foo</span>-{Bar}-
22769 ||<span class="x">Foo</span>-{Bar}-
22770 |}
22771 !! wikitext/edited
22772 {|
22773 |-
22774 |<nowiki/>-{Bar}-
22775 ||-{Bar}-
22776 |}
22777 !! end
22778
22779 # Since Parsoid is starting to emit canonical wikitext for links,
22780 # [http://example.com http://example.com] will not RT back to that
22781 # form anymore.
22782 # Parsoid does not language-convert links (it is done in a
22783 # post-processing step)
22784 !! test
22785 Proper conversion of text in external links
22786 !! options
22787 language=sr variant=sr-ec
22788 parsoid=wt2html
22789 !! wikitext
22790 http://www.google.com
22791 gopher://www.google.com
22792 [http://www.google.com http://www.google.com]
22793 [gopher://www.google.com gopher://www.google.com]
22794 [https://www.google.com irc://www.google.com]
22795 [ftp://www.google.com www.google.com/ftp://dir]
22796 [//www.google.com www.google.com]
22797 !! html/php
22798 <p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
22799 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
22800 <a rel="nofollow" class="external text" href="http://www.google.com">http://www.google.com</a>
22801 <a rel="nofollow" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
22802 <a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
22803 <a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
22804 <a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
22805 </p>
22806 !! html/parsoid
22807 <p><a rel="mw:ExtLink" class="external free" href="http://www.google.com">http://www.google.com</a>
22808 <a rel="mw:ExtLink" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
22809 <a rel="mw:ExtLink" class="external text" href="http://www.google.com">http://www.google.com</a>
22810 <a rel="mw:ExtLink" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
22811 <a rel="mw:ExtLink" class="external text" href="https://www.google.com">irc://www.google.com</a>
22812 <a rel="mw:ExtLink" class="external text" href="ftp://www.google.com">www.google.com/ftp://dir</a>
22813 <a rel="mw:ExtLink" class="external text" href="//www.google.com">www.google.com</a></p>
22814 !! end
22815
22816 !! test
22817 Do not convert roman numbers to language variants
22818 !! options
22819 language=sr variant=sr-ec
22820 !! wikitext
22821 Fridrih IV je car.
22822 !! html/php
22823 <p>Фридрих IV је цар.
22824 </p>
22825 !! html/parsoid
22826 <p>Fridrih IV je car.</p>
22827 !! end
22828
22829 !! test
22830 Unclosed language converter markup "-{"
22831 !! options
22832 language=sr
22833 !! wikitext
22834 -{T|hello
22835 !! html
22836 <p>-{T|hello
22837 </p>
22838 !! end
22839
22840 !! test
22841 Don't convert raw rule "-{R|=&gt;}-" to "=>"
22842 !! options
22843 language=sr
22844 !! wikitext
22845 -{R|=&gt;}-
22846 !! html/php
22847 <p>=&gt;
22848 </p>
22849 !! html/parsoid
22850 <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>
22851 !!end
22852
22853 !! test
22854 Don't break link parsing if language converter markup is in the caption.
22855 !! options
22856 language=sr variant=sr-ec
22857 !! wikitext
22858 [[Main Page|-{R|main page}-]]
22859 !! html/php
22860 <p><a href="/wiki/Main_Page" title="Маин Паге">main page</a>
22861 </p>
22862 !! html/parsoid
22863 <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>
22864 !! end
22865
22866 !! test
22867 T146304: Don't break template parsing if language converter markup is in the parameter.
22868 !! options
22869 language=sr variant=sr-ec
22870 !! wikitext
22871 {{echo|-{R|foo}-}}
22872 !! html/php
22873 <p>foo
22874 </p>
22875 !! html/parsoid
22876 <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>
22877 !! end
22878
22879 !! test
22880 T146305: Don't break image parsing if language converter markup is in the caption.
22881 !! options
22882 language=sr
22883 !! wikitext
22884 [[Датотека:Foobar.jpg|thumb|-{R|caption:}-]]
22885 !! html/php
22886 <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>
22887
22888 !! html/parsoid
22889 <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>
22890 !! end
22891
22892 !! test
22893 T146305: Don't break image parsing if nested language converter markup is in the caption.
22894 !! options
22895 language=zh variant=zh-cn
22896 !! wikitext
22897 [[File:Foobar.jpg|thumb|-{|zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
22898 !! html/php
22899 <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>
22900
22901 !! html/parsoid
22902 <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>
22903 !! end
22904
22905 # XXX html2wt disabled because rich markup in alt is not preserved.
22906 !! test
22907 Don't break gallery if language converter markup is inside.
22908 !! options
22909 language=zh
22910 !! wikitext
22911 <gallery>
22912 File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-
22913 File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt
22914 </gallery>
22915 !! html/php
22916 <ul class="gallery mw-gallery-traditional">
22917 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
22918 <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>
22919 <div class="gallerytext">
22920 <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>
22921 </p>
22922 </div>
22923 </div></li>
22924 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
22925 <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>
22926 <div class="gallerytext">
22927 <p>This is a test template
22928 </p>
22929 </div>
22930 </div></li>
22931 </ul>
22932
22933 !! html/parsoid
22934 <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"}}'>
22935 <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>
22936 <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>
22937 </ul>
22938 !! end
22939
22940 !! test
22941 T153135: Don't break list handling if language converter markup is in the item.
22942 !! options
22943 language=zh variant=zh-cn
22944 !! wikitext
22945 ;-{zh-cn:AAA;zh-tw:BBB}-
22946 ;-{R|foo:bar}-
22947 !! html/php
22948 <dl><dt>AAA</dt>
22949 <dt>foo:bar</dt></dl>
22950
22951 !! html/parsoid
22952 <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>
22953 <dt data-parsoid='{"dsr":[25,39,1,0]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"foo:bar"}}'></span></dt>
22954 </dl>
22955 !! end
22956
22957 // Note that parsoid does not protect colons unless language converter
22958 // markup is properly nested, because it is a backtracking parser.
22959 !! test
22960 T153135: Unclosed markup in definition list (code coverage)
22961 !! options
22962 language=zh variant=zh-cn
22963 !! wikitext
22964 ;<b>foo:bar
22965 ;-{zh-cn:AAA
22966 !! html/php+tidy
22967 <dl><dt><b>foo:bar</b></dt><b>
22968 <dt>-{zh-cn:AAA</dt></b></dl><p><b>
22969 </b></p>
22970 !! html/parsoid
22971 <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}'>
22972 <dt data-parsoid='{"dsr":[12,20,1,0]}'>-{zh-cn</dt>
22973 <dd data-parsoid='{"stx":"row","dsr":[20,24,1,0]}'>AAA</dd>
22974 </b></dl>
22975 !! end
22976
22977 !! test
22978 T153135: Nested language converter markup in definition list (code coverage)
22979 !! options
22980 language=zh variant=zh-cn
22981 !! wikitext
22982 ;-{|zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
22983 !! html/php
22984 <dl><dt>AAA foo:bar bat:baz</dt>
22985 <dd>def</dd></dl>
22986
22987 !! html/parsoid
22988 <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>
22989 <dd data-parsoid='{"stx":"row","dsr":[49,53,1,0]}'>def</dd>
22990 </dl>
22991 !! end
22992
22993 # html2wt mode disabled due to <nowiki> insertion.
22994 !! test
22995 T153140: Don't break table handling if language converter markup is in the cell.
22996 !! options
22997 language=sr variant=sr-ec
22998 parsoid=wt2html,wt2wt,html2html
22999 !! wikitext
23000 {|
23001 |-
23002 | -{R|B}-
23003 |}
23004 !! html/php
23005 <table>
23006
23007 <tr>
23008 <td>B
23009 </td></tr></table>
23010
23011 !! html/parsoid
23012 <table>
23013 <tbody>
23014 <tr>
23015 <td><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"B"}}'></span></td>
23016 </tr>
23017 </tbody>
23018 </table>
23019 !! end
23020
23021 !! test
23022 Language converter tricky html2wt cases (1)
23023 !! options
23024 language=sr
23025 parsoid=html2wt,wt2wt
23026 !! html/parsoid
23027 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"}-"}}'></span></p>
23028 !! wikitext
23029 -{<nowiki>}-</nowiki>}-
23030 !! html/php
23031 <p>&#125;-
23032 </p>
23033 !! end
23034
23035 !! test
23036 Language converter tricky html2wt cases (2)
23037 !! options
23038 language=sr
23039 parsoid=html2wt,wt2wt
23040 !! html/parsoid
23041 <p>-{foo}-</p>
23042 !! wikitext
23043 <nowiki>-{foo}-</nowiki>
23044 !! html/php
23045 <p>-&#123;foo&#125;-
23046 </p>
23047 !! end
23048
23049 !! test
23050 Language converter tricky html2wt cases (3)
23051 !! options
23052 language=sr
23053 parsoid=html2wt,wt2wt
23054 !! html/parsoid
23055 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"|"}}'></span></p>
23056 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"R|raw"}}'></span></p>
23057 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"-{foo}-"}}'></span></p>
23058 !! wikitext
23059 -{R||}-
23060
23061 -{R|R|raw}-
23062
23063 -{<nowiki>-{foo}-</nowiki>}-
23064 !! html/php
23065 <p>|
23066 </p><p>R|raw
23067 </p><p>-&#123;foo&#125;-
23068 </p>
23069 !! end
23070
23071 !! test
23072 Language converter tricky html2wt cases (4)
23073 !! options
23074 language=sr
23075 parsoid=html2wt,wt2wt
23076 !! html/parsoid
23077 <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>
23078 !! wikitext
23079 -{R|{{echo|hey}}}-
23080 !! html/php
23081 <p>hey
23082 </p>
23083 !! end
23084
23085 # Note that the <nowiki> escaping added by parsoid for source text,
23086 # destination text, and language names only works on the PHP side
23087 # for *destination text*. (HTML entity escaping wouldn't work
23088 # any better.) This is probably a bug, at least for source texts.
23089 # (For language names PHP uses a precise regexp based on the languages
23090 # it currently knows have variants, which is fragile since this set
23091 # can grow/shrink over time.)
23092 !! test
23093 Language converter tricky html2wt cases (5)
23094 !! options
23095 language=zh variant=zh-cn
23096 !! html/parsoid
23097 <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>
23098 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"A","l":"bo:g;us","t":"B"}]}'/></p>
23099 <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>
23100 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"bo:g;us","t":"xyz"},{"l":"zh-cn","t":"abc"}]}'></span></p>
23101 <p>a:b=>c xyz</p>
23102 !! wikitext
23103 -{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
23104
23105 -{H|A=><nowiki>bo:g;us</nowiki>:B}-
23106
23107 -{A|zh-tw:xyz; zh-cn:<nowiki>0;zh-tw:bar</nowiki>}-
23108
23109 -{<nowiki>bo:g;us</nowiki>:xyz; zh-cn:abc}-
23110
23111 a:b=>c xyz
23112 !! html/php+disabled
23113 <p>foobat;xyz=&gt;zh-cn:abc
23114 </p><p>A
23115 </p><p>0;zh-tw:bar
23116 </p><p>abc
23117 </p><p>a:b=&gt;c 0;zh-tw:bar
23118 </p>
23119 !! end
23120
23121 !! test
23122 T179579: Nowiki and lc interaction
23123 !! options
23124 parsoid=wt2html
23125 language=sr
23126 !! wikitext
23127 -{</nowiki>123}-
23128
23129 -{123<nowiki>|</nowiki>456}-
23130 !! html/parsoid
23131 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&amp;lt;/nowiki>123"}}' data-parsoid='{"fl":[],"src":"-{&lt;/nowiki>123}-"}'></span></p>
23132
23133 <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>
23134 !! end
23135
23136 !! test
23137 T2529: Uncovered bullet
23138 !! wikitext
23139 *Foo {{bullet}}
23140 !! html
23141 <ul><li>Foo</li>
23142 <li>Bar</li></ul>
23143
23144 !! end
23145
23146 !! test
23147 T2529: Uncovered bullet in a deeply nested list
23148 !! wikitext
23149 *******Foo {{bullet}}
23150 !! html
23151 <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>
23152 <li>Bar</li></ul>
23153
23154 !! end
23155
23156 !! test
23157 T2529: Uncovered table already at line-start
23158 !! wikitext
23159 x
23160
23161 {{table}}
23162 y
23163 !! html
23164 <p>x
23165 </p>
23166 <table>
23167 <tr>
23168 <td>1</td>
23169 <td>2
23170 </td></tr>
23171 <tr>
23172 <td>3</td>
23173 <td>4
23174 </td></tr></table>
23175 <p>y
23176 </p>
23177 !! end
23178
23179 !! test
23180 T2529: Uncovered bullet in parser function result
23181 !! wikitext
23182 *Foo {{lc:{{bullet}} }}
23183 !! html
23184 <ul><li>Foo</li>
23185 <li>bar</li></ul>
23186
23187 !! end
23188
23189 !! test
23190 T7678: Double-parsed template argument
23191 !! wikitext
23192 {{lc:{{{1}}}|hello}}
23193 !! html
23194 <p>{{{1}}}
23195 </p>
23196 !! end
23197
23198 !! test
23199 T7678: Double-parsed template invocation
23200 !! wikitext
23201 {{lc:{{paramtest {{!}} param = hello }} }}
23202 !! html
23203 <p>{{paramtest | param = hello }}
23204 </p>
23205 !! end
23206
23207 !! test
23208 Case insensitivity of parser functions for non-ASCII characters (T10143)
23209 !! options
23210 language=cs
23211 title=[[Main Page]]
23212 !! wikitext
23213 {{PRVNÍVELKÉ:ěščř}}
23214 {{prvnívelké:ěščř}}
23215 {{PRVNÍMALÉ:ěščř}}
23216 {{prvnímalé:ěščř}}
23217 {{MALÁ:ěščř}}
23218 {{malá:ěščř}}
23219 {{VELKÁ:ěščř}}
23220 {{velká:ěščř}}
23221 !! html
23222 <p>Ěščř
23223 Ěščř
23224 ěščř
23225 ěščř
23226 ěščř
23227 ěščř
23228 ĚŠČŘ
23229 ĚŠČŘ
23230 </p>
23231 !! end
23232
23233 !! test
23234 Morwen/13: Unclosed link followed by heading
23235 !! wikitext
23236 [[link
23237 ==heading==
23238 !! html
23239 <p>[[link
23240 </p>
23241 <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>
23242
23243 !! end
23244
23245 !! test
23246 HHP2.1: Heuristics for headings in preprocessor parenthetical structures
23247 !! wikitext
23248 {{foo|
23249 =heading=
23250 !! html
23251 <p>{{foo|
23252 </p>
23253 <h1><span class="mw-headline" id="heading">heading</span></h1>
23254
23255 !! end
23256
23257 !! test
23258 HHP2.2: Heuristics for headings in preprocessor parenthetical structures
23259 !! wikitext
23260 {{foo|
23261 ==heading==
23262 !! html
23263 <p>{{foo|
23264 </p>
23265 <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>
23266
23267 !! end
23268
23269 !! test
23270 Tildes in comments
23271 !! options
23272 pst
23273 !! wikitext
23274 <!-- ~~~~ -->
23275 !! html/php
23276 <!-- ~~~~ -->
23277 !! end
23278
23279 !! test
23280 Paragraphs inside divs (no extra line breaks)
23281 !! wikitext
23282 <div>Line one
23283
23284 Line two</div>
23285 !! html
23286 <div>Line one
23287 Line two</div>
23288
23289 !! end
23290
23291 !! test
23292 Paragraphs inside divs (extra line break on open)
23293 !! wikitext
23294 <div>
23295 Line one
23296
23297 Line two</div>
23298 !! html
23299 <div>
23300 <p>Line one
23301 </p>
23302 Line two</div>
23303
23304 !! end
23305
23306 !! test
23307 Paragraphs inside divs (extra line break on close)
23308 !! wikitext
23309 <div>Line one
23310
23311 Line two
23312 </div>
23313 !! html
23314 <div>Line one
23315 <p>Line two
23316 </p>
23317 </div>
23318
23319 !! end
23320
23321 !! test
23322 Paragraphs inside divs (extra line break on open and close)
23323 !! wikitext
23324 <div>
23325 Line one
23326
23327 Line two
23328 </div>
23329 !! html
23330 <div>
23331 <p>Line one
23332 </p><p>Line two
23333 </p>
23334 </div>
23335
23336 !! end
23337
23338 # doBlockLevels screws up this output and Remex cleans up as much as it can.
23339 # Parsoid seems to do a better job here since its p-wrapper is probably smarter.
23340 !! test
23341 Nesting tags, paragraphs on lines which begin with <div>
23342 !! wikitext
23343 <div></div><strong>A
23344 B</strong>
23345 !! html/php+tidy
23346 <div></div><p><strong>A
23347 </strong></p><strong></strong><p><strong>B</strong>
23348 </p>
23349 !! html/parsoid
23350 <div></div>
23351 <p><strong>A
23352 B</strong>
23353 </p>
23354 !! end
23355
23356 # T8200: <blockquote> should behave like <div> with respect to line breaks
23357 !! test
23358 T8200: paragraphs inside blockquotes (no extra line breaks)
23359 !! wikitext
23360 <blockquote>Line one
23361
23362 Line two</blockquote>
23363 !! html
23364 <blockquote>Line one
23365 Line two</blockquote>
23366
23367 !! html+tidy
23368 <blockquote><p>Line one
23369 Line two</p></blockquote>
23370 !! end
23371
23372 !! test
23373 T8200: paragraphs inside blockquotes (extra line break on open)
23374 !! wikitext
23375 <blockquote>
23376 Line one
23377
23378 Line two</blockquote>
23379 !! html
23380 <blockquote>
23381 <p>Line one
23382 </p>
23383 Line two</blockquote>
23384
23385 !! html+tidy
23386 <blockquote>
23387 <p>Line one
23388 </p><p>
23389 Line two</p></blockquote>
23390 !! end
23391
23392 # Parsoid's output is broken on this because of Tidy-compatibility cruft
23393 !! test
23394 T8200: paragraphs inside blockquotes (extra line break on close)
23395 !! wikitext
23396 <blockquote>Line one
23397
23398 Line two
23399 </blockquote>
23400 !! html
23401 <blockquote>Line one
23402 <p>Line two
23403 </p>
23404 </blockquote>
23405
23406 !! html+tidy
23407 <blockquote><p>Line one
23408 </p><p>Line two
23409 </p>
23410 </blockquote>
23411 !! end
23412
23413 !! test
23414 T8200: paragraphs inside blockquotes (extra line break on open and close)
23415 !! wikitext
23416 <blockquote>
23417 Line one
23418
23419 Line two
23420 </blockquote>
23421 !! html
23422 <blockquote>
23423 <p>Line one
23424 </p><p>Line two
23425 </p>
23426 </blockquote>
23427
23428 !! end
23429
23430 # FIXME: Why does/should the blockquote+div combo suppress p-wrapping here?
23431 !! test
23432 Paragraphs inside blockquotes/divs (no extra line breaks)
23433 !! wikitext
23434 <blockquote><div>Line one
23435
23436 Line two</div></blockquote>
23437 !! html
23438 <blockquote><div>Line one
23439 Line two</div></blockquote>
23440
23441 !! end
23442
23443 !! test
23444 Paragraphs inside blockquotes/divs (extra line break on open)
23445 !! wikitext
23446 <blockquote><div>
23447 Line one
23448
23449 Line two</div></blockquote>
23450 !! html
23451 <blockquote><div>
23452 <p>Line one
23453 </p>
23454 Line two</div></blockquote>
23455
23456 !! end
23457
23458 !! test
23459 Paragraphs inside blockquotes/divs (extra line break on close)
23460 !! wikitext
23461 <blockquote><div>Line one
23462
23463 Line two
23464 </div></blockquote>
23465 !! html
23466 <blockquote><div>Line one
23467 <p>Line two
23468 </p>
23469 </div></blockquote>
23470
23471 !! end
23472
23473 !! test
23474 Paragraphs inside blockquotes/divs (extra line break on open and close)
23475 !! wikitext
23476 <blockquote><div>
23477 Line one
23478
23479 Line two
23480 </div></blockquote>
23481 !! html
23482 <blockquote><div>
23483 <p>Line one
23484 </p><p>Line two
23485 </p>
23486 </div></blockquote>
23487
23488 !! end
23489
23490 !! test
23491 Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion
23492 !! options
23493 wgLinkHolderBatchSize=0
23494 !! wikitext
23495 [[meatball:1]]
23496 [[meatball:2]]
23497 [[meatball:3]]
23498 !! html
23499 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?1" class="extiw" title="meatball:1">meatball:1</a>
23500 <a href="http://www.usemod.com/cgi-bin/mb.pl?2" class="extiw" title="meatball:2">meatball:2</a>
23501 <a href="http://www.usemod.com/cgi-bin/mb.pl?3" class="extiw" title="meatball:3">meatball:3</a>
23502 </p>
23503 !! end
23504
23505 !! test
23506 Free external link invading image caption
23507 !! wikitext
23508 [[Image:Foobar.jpg|thumb|http://x|hello]]
23509 !! html/php
23510 <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>
23511
23512 !! html/parsoid
23513 <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>
23514 !! end
23515
23516 !! test
23517 T17196: localised external link numbers
23518 !! options
23519 language=fa
23520 !! wikitext
23521 [http://en.wikipedia.org/]
23522 !! html/php
23523 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/">[۱]</a>
23524 </p>
23525 !! html/parsoid
23526 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/"></a></p>
23527 !! end
23528
23529 !! test
23530 Multibyte character in padleft
23531 !! wikitext
23532 {{padleft:-Hello|7|Æ}}
23533 !! html/php
23534 <p>Æ-Hello
23535 </p>
23536 !! html/parsoid
23537 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:-Hello","function":"padleft"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Æ-Hello</p>
23538 !! end
23539
23540 !! test
23541 Multibyte character in padright
23542 !! wikitext
23543 {{padright:Hello-|7|Æ}}
23544 !! html/php
23545 <p>Hello-Æ
23546 </p>
23547 !! html/parsoid
23548 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:Hello-","function":"padright"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Hello-Æ</p>
23549 !! end
23550
23551 !!test
23552 formatdate parser function
23553 !! wikitext
23554 {{#formatdate:2009-03-24}}
23555 !! html
23556 <p><span class="mw-formatted-date" title="2009-03-24">2009-03-24</span>
23557 </p>
23558 !! end
23559
23560 !!test
23561 formatdate parser function, with default format
23562 !! wikitext
23563 {{#formatdate:2009-03-24|mdy}}
23564 !! html
23565 <p><span class="mw-formatted-date" title="2009-03-24">March 24, 2009</span>
23566 </p>
23567 !! end
23568
23569 !! test
23570 Spacing of numbers in formatted dates
23571 !! wikitext
23572 {{#formatdate:January 15}}
23573 !! html
23574 <p><span class="mw-formatted-date" title="01-15">January 15</span>
23575 </p>
23576 !! end
23577
23578 !! test
23579 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
23580 !! options
23581 language=nl title=[[MediaWiki:Common.css]]
23582 !! wikitext
23583 {{#formatdate:2009-03-24|dmy}}
23584 !! html
23585 <p><span class="mw-formatted-date" title="2009-03-24">24 March 2009</span>
23586 </p>
23587 !! end
23588
23589 #
23590 #
23591 #
23592
23593 #
23594 # Edit comments
23595 #
23596
23597 !! test
23598 Edit comment with link
23599 !! options
23600 comment
23601 !! wikitext
23602 I like the [[Main Page]] a lot
23603 !! html/php
23604 I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot
23605 !!end
23606
23607 !! test
23608 Edit comment with link and link text
23609 !! options
23610 comment
23611 !! wikitext
23612 I like the [[Main Page|best pages]] a lot
23613 !! html/php
23614 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
23615 !!end
23616
23617 !! test
23618 Edit comment with link and link text with suffix
23619 !! options
23620 comment
23621 !! wikitext
23622 I like the [[Main Page|best page]]s a lot
23623 !! html/php
23624 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
23625 !!end
23626
23627 !! test
23628 Edit comment with section link (non-local, eg in history list)
23629 !! options
23630 comment title=[[Main Page]]
23631 !! wikitext
23632 /* External links */ removed bogus entries
23633 !! html/php
23634 <a href="/wiki/Main_Page#External_links" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
23635 !!end
23636
23637 !! test
23638 Edit comment with section link and text before it (non-local, eg in history list)
23639 !! options
23640 comment title=[[Main Page]]
23641 !! wikitext
23642 pre-comment text /* External links */ removed bogus entries
23643 !! html/php
23644 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>
23645 !!end
23646
23647 !! test
23648 Edit comment with section link (local, eg in diff view)
23649 !! options
23650 comment local title=[[Main Page]]
23651 !! wikitext
23652 /* External links */ removed bogus entries
23653 !! html/php
23654 <a href="#External_links">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
23655 !!end
23656
23657 !! test
23658 Edit comment with subpage link (T16080)
23659 !! options
23660 comment
23661 subpage
23662 title=[[Subpage test]]
23663 !! wikitext
23664 Poked at a [[/subpage]] here...
23665 !! html/php
23666 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> here...
23667 !!end
23668
23669 !! test
23670 Edit comment with subpage link and link text (T16080)
23671 !! options
23672 comment
23673 subpage
23674 title=[[Subpage test]]
23675 !! wikitext
23676 Poked at a [[/subpage|neat little page]] here...
23677 !! html/php
23678 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">neat little page</a> here...
23679 !!end
23680
23681 !! test
23682 Edit comment with bogus subpage link in non-subpage NS (T16080)
23683 !! options
23684 comment
23685 title=[[Subpage test]]
23686 !! wikitext
23687 Poked at a [[/subpage]] here...
23688 !! html/php
23689 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...
23690 !!end
23691
23692 !! test
23693 Edit comment with bare anchor link (local, as on diff)
23694 !! options
23695 comment
23696 local
23697 title=[[Main Page]]
23698 !! wikitext
23699 [[#section]]
23700 !! html/php
23701 <a href="#section">#section</a>
23702 !! end
23703
23704 !! test
23705 Edit comment with bare anchor link (non-local, as on history)
23706 !! options
23707 comment
23708 title=[[Main Page]]
23709 !! wikitext
23710 [[#section]]
23711 !! html/php
23712 <a href="/wiki/Main_Page#section" title="Main Page">#section</a>
23713 !! end
23714
23715 !! test
23716 Anchor starting with underscore
23717 !! options
23718 title=[[Foo]]
23719 !! wikitext
23720 [[#_ref|One]]
23721 !! html/php
23722 <p><a href="#_ref">One</a>
23723 </p>
23724 !! html/parsoid
23725 <p><a rel="mw:WikiLink" href="./Foo#_ref" data-parsoid='{"stx":"piped","a":{"href":"./Foo#_ref"},"sa":{"href":"#_ref"}}'>One</a></p>
23726 !! end
23727
23728 !! test
23729 Id starting with underscore
23730 !! wikitext
23731 <div id="_ref"></div>
23732 !! html/*
23733 <div id="_ref"></div>
23734
23735 !! end
23736
23737 !! test
23738 Edit comment with link with more than one pipe (T99346)
23739 !! options
23740 comment
23741 !! wikitext
23742 [[Main Page|Many|pipes]]
23743 !! html/php
23744 <a href="/wiki/Main_Page" title="Main Page">Many|pipes</a>
23745 !! end
23746
23747 !! test
23748 Complex edit comment with link with more than one pipe (T99346)
23749 !! options
23750 comment
23751 !! wikitext
23752 Created page with "<noinclude>[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]]</noinclude> === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..."
23753 !! html/php
23754 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;
23755 !! end
23756
23757 !! test
23758 Space normalisation on autocomment (T24784)
23759 !! options
23760 comment
23761 title=[[Main Page]]
23762 !! wikitext
23763 /* __hello__world__ */
23764 !! html/php
23765 <a href="/wiki/Main_Page#hello_world" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">__hello__world__</span></span>
23766 !! end
23767
23768 !! test
23769 percent-encoding and + signs in comments (T28410)
23770 !! options
23771 comment
23772 !! wikitext
23773 [[ABC%33D% ++]] [[ABC%33D% ++|+%20]]
23774 !! html/php
23775 <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>
23776 !! end
23777
23778 # Parsoid doesn't support this yet: see T75581
23779 # but it *should* omit the 'src' attribute if the image is bad.
23780 # PHP side of tests was disabled in
23781 # mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
23782 # because of issues in the PHP parserTests infrastructure
23783 # (but the output below is indeed what the PHP side emits)
23784 !! test
23785 Bad images - basic functionality
23786 !! wikitext
23787 [[File:Bad.jpg]]
23788 !! html/php+disabled
23789 !! html/parsoid
23790 <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>
23791 !! end
23792
23793 !! test
23794 Bad images - T18039: text after bad image disappears
23795 !! wikitext
23796 Foo bar
23797 [[File:Bad.jpg]]
23798 Bar foo
23799 !! html/php+disabled
23800 <p>Foo bar
23801 </p><p>Bar foo
23802 </p>
23803 !! html/parsoid
23804 <p>Foo bar
23805 <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>
23806 Bar foo</p>
23807 !! end
23808
23809 !! test
23810 Verify that displaytitle works (T24501) no displaytitle
23811 !! options
23812 showtitle
23813 !! config
23814 wgAllowDisplayTitle=true
23815 wgRestrictDisplayTitle=false
23816 !! wikitext
23817 this is not the the title
23818 !! html/php
23819 Parser test
23820 <p>this is not the the title
23821 </p>
23822 !! end
23823
23824 !! test
23825 Verify that displaytitle works (T24501) RestrictDisplayTitle=false
23826 !! options
23827 showtitle
23828 title=[[Screen]]
23829 !! config
23830 wgAllowDisplayTitle=true
23831 wgRestrictDisplayTitle=false
23832 !! wikitext
23833 this is not the the title
23834 {{DISPLAYTITLE:whatever}}
23835 !! html/php
23836 whatever
23837 <p>this is not the the title
23838 </p>
23839 !! end
23840
23841 !! test
23842 Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch
23843 !! options
23844 showtitle
23845 title=[[Screen]]
23846 !! config
23847 wgAllowDisplayTitle=true
23848 wgRestrictDisplayTitle=true
23849 !! wikitext
23850 this is not the the title
23851 {{DISPLAYTITLE:whatever}}
23852 !! html/php
23853 Screen
23854 <p>this is not the the title
23855 </p>
23856 !! end
23857
23858 !! test
23859 Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching
23860 !! options
23861 showtitle
23862 title=[[Screen]]
23863 !! config
23864 wgAllowDisplayTitle=true
23865 wgRestrictDisplayTitle=true
23866 !! wikitext
23867 this is not the the title
23868 {{DISPLAYTITLE:screen}}
23869 !! html/php
23870 screen
23871 <p>this is not the the title
23872 </p>
23873 !! end
23874
23875 !! test
23876 Verify that displaytitle works (T24501) AllowDisplayTitle=false
23877 !! options
23878 showtitle
23879 title=[[Screen]]
23880 !! config
23881 wgAllowDisplayTitle=false
23882 !! wikitext
23883 this is not the the title
23884 {{DISPLAYTITLE:screen}}
23885 !! html/php
23886 Screen
23887 <p>this is not the the title
23888 <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>
23889 </p>
23890 !! end
23891
23892 !! test
23893 Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE
23894 !! options
23895 showtitle
23896 title=[[Screen]]
23897 !! config
23898 wgAllowDisplayTitle=false
23899 !! wikitext
23900 this is not the the title
23901 !! html/php
23902 Screen
23903 <p>this is not the the title
23904 </p>
23905 !! end
23906
23907 !! test
23908 Verify that displaytitle handles inline CSS styles (T28547) - rejected value
23909 !! options
23910 showtitle
23911 title=[[Screen]]
23912 !! config
23913 wgAllowDisplayTitle=true
23914 wgRestrictDisplayTitle=true
23915 !! wikitext
23916 this is not the the title
23917 {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
23918 !! html/php
23919 <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
23920 <p>this is not the the title
23921 </p>
23922 !! end
23923
23924 !! test
23925 Verify that displaytitle handles inline CSS styles (T28547) - accepted value
23926 !! options
23927 showtitle
23928 title=[[Screen]]
23929 !! config
23930 wgAllowDisplayTitle=true
23931 wgRestrictDisplayTitle=true
23932 !! wikitext
23933 this is not the the title
23934 {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
23935 !! html/php
23936 <span style="color: red;">s</span>creen
23937 <p>this is not the the title
23938 </p>
23939 !! end
23940
23941 !! test
23942 Page status indicators: Empty name is invalid
23943 !! options
23944 showindicators
23945 !! wikitext
23946 <indicator name=" "></indicator>
23947 <indicator></indicator>
23948 !! html/php
23949 <p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
23950 <span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
23951 </p>
23952 !! end
23953
23954 !! test
23955 Page status indicators: Weird syntaxes that are okay
23956 !! options
23957 showindicators
23958 !! wikitext
23959 <indicator name="empty" />
23960 <indicator name="name"></indicator>
23961 !! html/php
23962 empty=
23963 name=
23964 <p><br />
23965 </p>
23966 !! end
23967
23968 !! test
23969 Page status indicators: Torture test
23970 !! options
23971 showindicators
23972 !! wikitext
23973 <indicator name="01">hello world</indicator>
23974 <indicator name="02">[[Main Page]]</indicator>
23975 <indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator>
23976 <indicator name="04">[[File:Foobar.jpg|25px]]</indicator>
23977 <indicator name="05">*foo
23978 *bar</indicator>
23979 <indicator name="06"><nowiki>foo</nowiki></indicator>
23980 <indicator name="07"> Preformatted</indicator>
23981 <indicator name="08"><div>Broken tag</indicator>
23982 <indicator name="09">{| class=wikitable
23983 |cell
23984 |}</indicator>
23985 <indicator name="10">Two
23986
23987 paragraphs</indicator>
23988 !! html/php
23989 01=hello world
23990 02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
23991 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" />
23992 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>
23993 05=<ul><li>foo</li>
23994 <li>bar</li></ul>
23995
23996 06=foo
23997 07=<pre>Preformatted
23998 </pre>
23999 08=<div>Broken tag</div>
24000
24001 09=<table class="wikitable">
24002 <tr>
24003 <td>cell
24004 </td></tr></table>
24005
24006 10=<p>Two
24007 </p><p>paragraphs
24008 </p>
24009 <p><br />
24010 </p><p><br />
24011 </p><p><br />
24012 </p><p><br />
24013 </p><p><br />
24014 </p>
24015 !! end
24016
24017 !! test
24018 preload: check <noinclude> and <includeonly>
24019 !! options
24020 preload
24021 !! wikitext
24022 Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
24023 !! html/php
24024 Hello kind world.
24025 !! end
24026
24027 !! test
24028 preload: check <onlyinclude>
24029 !! options
24030 preload
24031 !! wikitext
24032 Goodbye <onlyinclude>Hello world</onlyinclude>
24033 !! html/php
24034 Hello world
24035 !! end
24036
24037 !! test
24038 preload: can pass tags through if we want to
24039 !! options
24040 preload
24041 !! wikitext
24042 <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
24043 !! html/php
24044 <includeonly>Hello world</includeonly>
24045 !! end
24046
24047 !! test
24048 preload: check that it doesn't try to do tricks
24049 !! options
24050 preload
24051 !! wikitext
24052 * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
24053 !! html/php
24054 * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
24055 !! end
24056
24057 !! test
24058 Play a bit with r67090 and T5158
24059 !! wikitext
24060 <div style="width:50% !important">&nbsp;</div>
24061 <div style="width:50%&nbsp;!important">&nbsp;</div>
24062 <div style="width:50%&#160;!important">&nbsp;</div>
24063 <div style="border : solid;">&nbsp;</div>
24064 !! html/php
24065 <div style="width:50% !important">&#160;</div>
24066 <div style="width:50% !important">&#160;</div>
24067 <div style="width:50% !important">&#160;</div>
24068 <div style="border&#32;: solid;">&#160;</div>
24069
24070 !! html/parsoid
24071 <div style="width:50% !important" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
24072 <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>
24073 <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>
24074 <div style="border : solid;" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
24075
24076 !! end
24077
24078 !! test
24079 French spaces in wikitext
24080 !! wikitext
24081 foo ! bar ? bat 50 % is less than 75 %.
24082
24083 Hello : this ; is « something ‹ else › again »
24084 !! html
24085 <p>foo&#160;! bar&#160;? bat 50&#160;% is less than 75&#160;%.
24086 </p><p>Hello&#160;: this&#160;; is «&#160;something ‹&#160;else&#160;› again&#160;»
24087 </p>
24088 !! end
24089
24090 # It would be reasonable for Parsoid and PHP to differ here.
24091 # The PHP behavior is arguably a bug.
24092 !! test
24093 Corner case: french spaces in definition list
24094 !! wikitext
24095 ;foo : bar
24096 !! html+tidy
24097 <dl><dt>foo&#160;</dt>
24098 <dd>bar</dd></dl>
24099 !! end
24100
24101 !! test
24102 T5158: Test for French spaces in attributes
24103 !! wikitext
24104 <br style=" clear : both ; " />
24105 !! html/php
24106 <p><br style="clear&#32;: both&#32;;" />
24107 </p>
24108 !! end
24109
24110 !! test
24111 HTML5 data attributes
24112 !! wikitext
24113 <span data-foo="bar">Baz</span>
24114 <p data-abc-def_hij="">Quuz</p>
24115 !! html/php
24116 <p><span data-foo="bar">Baz</span>
24117 </p>
24118 <p data-abc-def_hij="">Quuz</p>
24119
24120 !! html/parsoid
24121 <p><span data-foo="bar" data-parsoid='{"stx":"html"}'>Baz</span></p>
24122 <p data-abc-def_hij="" data-parsoid='{"stx":"html"}'>Quuz</p>
24123 !! end
24124
24125 !! test
24126 Strip reserved data attributes
24127 !! wikitext
24128 <div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
24129 !! html/php
24130 <div data-ok="fred">d</div>
24131
24132 !! html/parsoid
24133 <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>
24134 !! end
24135
24136 !! test
24137 percent-encoding and + signs in internal links (T28410)
24138 !! wikitext
24139 [[User:+%]] [[Page+title%]]
24140 [[%+]] [[%+|%20]] [[%+ ]] [[%+r]]
24141 [[%]] [[+]] [[File:%+abc%39|foo|[[bar]]]]
24142 [[%33%45]] [[%33%45+]]
24143 !! html/php
24144 <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>
24145 <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>
24146 <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>
24147 <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>
24148 </p>
24149 !! html/parsoid
24150 <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>
24151 <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>
24152 <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>
24153 <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>
24154 !! end
24155
24156 !! test
24157 Special characters in embedded file links (T29679)
24158 !! wikitext
24159 [[File:Contains & ampersand.jpg]]
24160 [[File:Does not exist.jpg|Title with & ampersand]]
24161 !! html/php
24162 <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>
24163 <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>
24164 </p>
24165 !! html/parsoid
24166 <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>
24167 <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>
24168 !! end
24169
24170 !! test
24171 Confirm that 'apos' named character reference doesn't make it to output (not legal in HTML 4)
24172 !! wikitext
24173 Text&apos;s been normalized?
24174 !! html
24175 <p>Text&#39;s been normalized?
24176 </p>
24177 !! end
24178
24179 !! test
24180 T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
24181 !! wikitext
24182 http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
24183 !! html
24184 <p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> &lt;-- U+3000 (vim: ^Vu3000)
24185 </p>
24186 !! end
24187
24188 !! test
24189 T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
24190 !! wikitext
24191 [http://www.example.org/ ideograms]
24192 !! html
24193 <p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a>
24194 </p>
24195 !! end
24196
24197 !! test
24198 T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
24199 !! wikitext
24200 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
24201 !! html
24202 <p><img src="http://www.example.org/pic.png" alt="pic.png"/> &lt;-- U+3000 (vim: ^Vu3000)
24203 </p>
24204 !! end
24205
24206 !! article
24207 Mediawiki:loop1
24208 !! text
24209 {{Identical|A}}
24210 !! endarticle
24211
24212 !! article
24213 Mediawiki:loop2
24214 !! text
24215 {{Identical|B}}
24216 !! endarticle
24217
24218 !! article
24219 Template:Identical
24220 !! text
24221 {{int:loop1}}
24222 {{int:loop2}}
24223 !! endarticle
24224
24225 !! test
24226 T33098 Template which includes system messages which includes the template
24227 !! wikitext
24228 {{Identical}}
24229 !! html
24230 <p><span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
24231 <span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
24232 </p>
24233 !! end
24234
24235 !! test
24236 T33490 Turkish: ucfirst 'blah'
24237 !! options
24238 language=tr
24239 !! wikitext
24240 {{ucfirst:blah}}
24241 !! html
24242 <p>Blah
24243 </p>
24244 !! end
24245
24246 !! test
24247 T33490 Turkish: ucfirst 'ix'
24248 !! options
24249 language=tr
24250 !! wikitext
24251 {{ucfirst:ix}}
24252 !! html
24253 <p>İx
24254 </p>
24255 !! end
24256
24257 !! test
24258 T33490 Turkish: lcfirst 'BLAH'
24259 !! options
24260 language=tr
24261 !! wikitext
24262 {{lcfirst:BLAH}}
24263 !! html
24264 <p>bLAH
24265 </p>
24266 !! end
24267
24268 !! test
24269 T33490 Turkish: ucfırst (with a dotless i)
24270 !! options
24271 language=tr
24272 !! wikitext
24273 {{ucfırst:blah}}
24274 !! html
24275 <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>
24276 </p>
24277 !! end
24278
24279 !! test
24280 T33490 ucfırst (with a dotless i) with English language
24281 !! options
24282 language=en
24283 !! wikitext
24284 {{ucfırst:blah}}
24285 !! html
24286 <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>
24287 </p>
24288 !! end
24289
24290 # Note that Parsoid doesn't emit an explicit TOC.
24291 # Note also that the html2wt direction tends to emit an extra newline
24292 # between the __TOC__ magicword and the first heading unless *both*
24293 # the <meta> and the <h2> have a data-parsoid attribute set (even if
24294 # it's "{}").
24295
24296 !! test
24297 T28375: TOC with italics
24298 !! options
24299 title=[[Main Page]]
24300 !! wikitext
24301 __TOC__
24302 ==''Lost'' episodes==
24303 !! html/php
24304 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24305 <ul>
24306 <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>
24307 </ul>
24308 </div>
24309
24310 <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>
24311
24312 !! html/parsoid
24313 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24314 <h2 id="Lost_episodes" data-parsoid='{}'><i>Lost</i> episodes</h2>
24315 !! end
24316
24317 !! test
24318 T28375: TOC with bold
24319 !! options
24320 title=[[Main Page]]
24321 !! wikitext
24322 __TOC__
24323 =='''should be bold''' then normal text==
24324 !! html/php
24325 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24326 <ul>
24327 <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>
24328 </ul>
24329 </div>
24330
24331 <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>
24332
24333 !! html/parsoid
24334 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24335 <h2 id="should_be_bold_then_normal_text" data-parsoid='{}'><b>should be bold</b> then normal text</h2>
24336 !! end
24337
24338 !! test
24339 T35845: Headings become cursive in TOC when they contain an image
24340 !! options
24341 title=[[Main Page]]
24342 !! wikitext
24343 __TOC__
24344 ==Image [[Image:foobar.jpg]]==
24345 !! html/php
24346 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24347 <ul>
24348 <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
24349 </ul>
24350 </div>
24351
24352 <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>
24353
24354 !! html/parsoid
24355 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24356 <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>
24357 !! end
24358
24359 !! test
24360 T35845 (2): Headings become bold in TOC when they contain a blockquote
24361 !! options
24362 title=[[Main Page]]
24363 !! wikitext
24364 __TOC__
24365 ==<blockquote>Quote</blockquote>==
24366 !! html/php
24367 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24368 <ul>
24369 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
24370 </ul>
24371 </div>
24372
24373 <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>
24374
24375 !! html/php+tidy
24376 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24377 <ul>
24378 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
24379 </ul>
24380 </div>
24381
24382 <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>
24383 !! html/parsoid
24384 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24385 <h2 id="Quote" data-parsoid='{}'><blockquote>Quote</blockquote></h2>
24386 !! end
24387
24388 !! test
24389 Unclosed tags in TOC
24390 !! config
24391 wgFragmentMode=[ 'html5', 'legacy' ]
24392 !! options
24393 title=[[Main Page]]
24394 !! wikitext
24395 __TOC__
24396 ==Proof: 2 < 3==
24397 <small>Hanc marginis exiguitas non caperet.</small>
24398 QED
24399 !! html/php
24400 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24401 <ul>
24402 <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>
24403 </ul>
24404 </div>
24405
24406 <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>
24407 <p><small>Hanc marginis exiguitas non caperet.</small>
24408 QED
24409 </p>
24410 !! html/parsoid
24411 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24412 <h2 id="Proof:_2_&lt;_3" data-parsoid='{}'><span id="Proof:_2_.3C_3" typeof="mw:FallbackId"></span>Proof: 2 &lt; 3</h2>
24413 <p><small>Hanc marginis exiguitas non caperet.</small>
24414 QED</p>
24415 !! end
24416
24417 !! test
24418 Multiple tags in TOC
24419 !! wikitext
24420 __TOC__
24421 ==<i>Foo</i> <b>Bar</b>==
24422
24423 ==<i>Foo</i> <blockquote>Bar</blockquote>==
24424 !! html/php
24425 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24426 <ul>
24427 <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>
24428 <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>
24429 </ul>
24430 </div>
24431
24432 <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>
24433 <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>
24434
24435 !! html/php+tidy
24436 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24437 <ul>
24438 <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>
24439 <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>
24440 </ul>
24441 </div>
24442
24443 <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>
24444 <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>
24445 !! html/parsoid
24446 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24447 <h2 id="Foo_Bar" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b></h2>
24448
24449 <h2 id="Foo_Bar_2" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote>Bar</blockquote></h2>
24450 !! end
24451
24452 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
24453 # html5 tag parsing.
24454 !! test
24455 Tags with parameters in TOC
24456 !! options
24457 parsoid=wt2html
24458 !! wikitext
24459 __TOC__
24460 ==<sup class="in-h2">Hello</sup>==
24461
24462 ==<sup class="a > b">Evilbye</sup>==
24463 !! html/php
24464 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24465 <ul>
24466 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
24467 <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>
24468 </ul>
24469 </div>
24470
24471 <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>
24472 <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>
24473
24474 !! html/parsoid
24475 <meta property="mw:PageProp/toc" />
24476 <h2 id="Hello"><sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup></h2>
24477
24478 <h2 id='b">Evilbye'><span id="b.22.3EEvilbye" typeof="mw:FallbackId"></span><sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup></h2>
24479 !! end
24480
24481 !! test
24482 span tags with directionality in TOC
24483 !! wikitext
24484 __TOC__
24485 ==<span dir="ltr">C++</span>==
24486
24487 ==<span dir="rtl">זבנג!</span>==
24488
24489 ==<span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span>==
24490
24491 ==<span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span>==
24492
24493 ==<span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span>==
24494 !! html/php
24495 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24496 <ul>
24497 <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>
24498 <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>
24499 <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>
24500 <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>
24501 <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>
24502 </ul>
24503 </div>
24504
24505 <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>
24506 <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>
24507 <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>
24508 <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>
24509 <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>
24510
24511 !! html/parsoid
24512 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24513 <h2 id="C++" data-parsoid='{}'><span id="C.2B.2B" typeof="mw:FallbackId"></span><span dir="ltr">C++</span></h2>
24514 <h2 id="זבנג!"><span id=".D7.96.D7.91.D7.A0.D7.92.21" typeof="mw:FallbackId"></span><span dir="rtl">זבנג!</span></h2>
24515 <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>
24516 <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>
24517 <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>
24518 !! end
24519
24520 !! test
24521 T74884: bdi element in ToC
24522 !! wikitext
24523 __TOC__
24524 ==<bdi>test</bdi>==
24525 !! html/php
24526 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24527 <ul>
24528 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
24529 </ul>
24530 </div>
24531
24532 <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>
24533
24534 !! html/parsoid
24535 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24536 <h2 id="test" data-parsoid='{}'><bdi>test</bdi></h2>
24537 !! end
24538
24539 !! test
24540 T35715: s/strike element in ToC
24541 !! wikitext
24542 __TOC__
24543 ==<s>test</s> test <strike>test</strike>==
24544 !! html/php
24545 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24546 <ul>
24547 <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>
24548 </ul>
24549 </div>
24550
24551 <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>
24552
24553 !! html/parsoid
24554 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24555 <h2 id="test_test_test" data-parsoid='{}'><s>test</s> test <strike>test</strike></h2>
24556 !! end
24557
24558 !! test
24559 Empty <p> tag in TOC, removed by Sanitizer (T92892)
24560 !! wikitext
24561 __TOC__
24562 ==x==
24563 !! html/php
24564 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24565 <ul>
24566 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
24567 </ul>
24568 </div>
24569
24570 <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>
24571
24572 !! html/parsoid
24573 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24574 <h2 id="x" data-parsoid='{}'>x</h2>
24575 !! end
24576
24577 !! article
24578 MediaWiki:T34057
24579 !! text
24580 == {{int:headline_sample}} ==
24581 !! endarticle
24582
24583 !! test
24584 T34057: Title needed when expanding <h> nodes.
24585 !! options
24586 title=[[Main Page]]
24587 !! wikitext
24588 {{int:T34057}}
24589 !! html
24590 <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>
24591
24592 !! end
24593
24594 !! test
24595 Strip marker in urlencode
24596 !! wikitext
24597 {{urlencode:x<nowiki/>y}}
24598 {{urlencode:x<nowiki/>y|wiki}}
24599 {{urlencode:x<nowiki/>y|path}}
24600 {{urlencode:x<pre id="one">two</pre>y}}
24601 !! html/php
24602 <p>xy
24603 xy
24604 xy
24605 xy
24606 </p>
24607 !! end
24608
24609 !! test
24610 Strip marker in lc
24611 !! wikitext
24612 {{lc:x<nowiki/>y}}
24613 !! html
24614 <p>xy
24615 </p>
24616 !! end
24617
24618 !! test
24619 Strip marker in uc
24620 !! wikitext
24621 {{uc:x<nowiki/>y}}
24622 !! html
24623 <p>XY
24624 </p>
24625 !! end
24626
24627 !! test
24628 Strip marker in formatNum
24629 !! wikitext
24630 {{formatnum:1<nowiki/>2}}
24631 {{formatnum:1<nowiki/>2|R}}
24632 !! html
24633 <p>12
24634 12
24635 </p>
24636 !! end
24637
24638 !! test
24639 Check noCommafy in formatNum
24640 !! options
24641 language=be-tarask
24642 !! wikitext
24643 {{formatnum:123456.78}}
24644 {{formatnum:123456.78|NOSEP}}
24645 !! html
24646 <p>123 456,78
24647 123456.78
24648 </p>
24649 !! end
24650
24651 !! test
24652 Wrong option for formatNum (T58199)
24653 !! wikitext
24654 {{formatnum:1,234.56|Random}}
24655 {{formatnum:1,234.56|EVERYTHING}}
24656 {{formatnum:1234.56|any argument that has the string 'NOSEP'}}
24657 !! html
24658 <p>1,234.56
24659 1,234.56
24660 1,234.56
24661 </p>
24662 !! end
24663
24664 !! test
24665 Strip marker in grammar
24666 !! options
24667 language=fi
24668 !! wikitext
24669 {{grammar:elative|foo<nowiki/>bar}}
24670 !! html
24671 <p>foobarista
24672 </p>
24673 !! end
24674
24675 !! test
24676 Strip marker in padleft
24677 !! wikitext
24678 {{padleft:|2|x<nowiki/>y}}
24679 !! html
24680 <p>xy
24681 </p>
24682 !! end
24683
24684 !! test
24685 Strip marker in padright
24686 !! wikitext
24687 {{padright:|2|x<nowiki/>y}}
24688 !! html
24689 <p>xy
24690 </p>
24691 !! end
24692
24693 !! test
24694 Strip marker in anchorencode
24695 !! wikitext
24696 {{anchorencode:x<nowiki/>y}}
24697 !! html/php
24698 <p>xy
24699 </p>
24700 !! html/parsoid
24701 <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>
24702 !! end
24703
24704 !! test
24705 nowiki inside link inside heading (T20295)
24706 !! wikitext
24707 ==[[foo|x<nowiki>y</nowiki>z]]==
24708 !! html
24709 <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>
24710
24711 !! end
24712
24713 !! test
24714 new support for bdi element (T33817)
24715 !! wikitext
24716 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
24717 !! html
24718 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
24719
24720 !!end
24721
24722 !! test
24723 Ignore pipe between table row attributes
24724 !! wikitext
24725 {|
24726 |quux
24727 |- id=foo | style='color: red'
24728 |bar
24729 |}
24730 !! html
24731 <table>
24732 <tr>
24733 <td>quux
24734 </td></tr>
24735 <tr id="foo" style="color: red">
24736 <td>bar
24737 </td></tr></table>
24738
24739 !! end
24740
24741 !!test
24742 Language parser function
24743 !! wikitext
24744 {{#language:ar}}
24745 !! html
24746 <p>العربية
24747 </p>
24748 !! end
24749
24750 !!test
24751 Padleft and padright (default 0-padding)
24752 !! wikitext
24753 {{padleft:xyz|5}}
24754 {{padright:xyz|5}}
24755 !! html/php
24756 <p>00xyz
24757 xyz00
24758 </p>
24759 !! html/parsoid
24760 <p><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:xyz","function":"padleft"},"params":{"1":{"wt":"5"}},"i":0}}]}'>00xyz</span>
24761 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:xyz","function":"padright"},"params":{"1":{"wt":"5"}},"i":0}}]}'>xyz00</span></p>
24762 !! end
24763
24764 !!test
24765 Padleft and padright (partial fill)
24766 !! wikitext
24767 {{padleft:xyz|6|ab}}
24768 {{padright:xyz|6|ab}}
24769 !! html/php
24770 <p>abaxyz
24771 xyzaba
24772 </p>
24773 !! html/parsoid
24774 <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>
24775 <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>
24776 !! end
24777
24778 !!test
24779 Padleft and padright as substr
24780 !! wikitext
24781 {{padleft:|3|abcde}}
24782 {{padright:|3|abcde}}
24783 !! html/php
24784 <p>abc
24785 abc
24786 </p>
24787 !! html/parsoid
24788 <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>
24789 <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>
24790 !! end
24791
24792 !! test
24793 Padleft and padright with non-numerical length (T180403)
24794 !! wikitext
24795 {{padleft:abcdef|junk}}
24796 {{padright:abcdef|junk}}
24797 !! html/php
24798 <p>abcdef
24799 abcdef
24800 </p>
24801 !! end
24802
24803 !!test
24804 Special parser function
24805 !! wikitext
24806 {{#special:RandomPage}}
24807 {{#special:BaDtItLe}}
24808 {{#special:Foobar}}
24809 !! html
24810 <p>Special:Random
24811 Special:Badtitle
24812 Special:Foobar
24813 </p>
24814 !! end
24815
24816 !!test
24817 T36939 - Case insensitive link parsing ([HttP://])
24818 !! wikitext
24819 [HttP://MediaWiki.Org/]
24820 !! html/php
24821 <p><a rel="nofollow" class="external autonumber" href="HttP://MediaWiki.Org/">[1]</a>
24822 </p>
24823 !! html/parsoid
24824 <p><a rel="mw:ExtLink" class="external autonumber" href="HttP://MediaWiki.Org/"></a></p>
24825 !! end
24826
24827 !!test
24828 T36939 - Case insensitive link parsing ([HttP:// title])
24829 !! wikitext
24830 [HttP://MediaWiki.Org/ MediaWiki]
24831 !! html
24832 <p><a rel="nofollow" class="external text" href="HttP://MediaWiki.Org/">MediaWiki</a>
24833 </p>
24834 !! end
24835
24836 !!test
24837 T36939 - Case insensitive link parsing (HttP://)
24838 !! wikitext
24839 HttP://MediaWiki.Org/
24840 !! html/php
24841 <p><a rel="nofollow" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a>
24842 </p>
24843 !! html/parsoid
24844 <p><a rel="mw:ExtLink" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a></p>
24845 !! end
24846
24847 !!test
24848 Disable TOC
24849 !! options
24850 notoc
24851 !! wikitext
24852 Lead
24853 ==Section 1==
24854 ==Section 2==
24855 ==Section 3==
24856 ==Section 4==
24857 ==Section 5==
24858 !! html
24859 <p>Lead
24860 </p>
24861
24862 <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>
24863 <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>
24864 <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>
24865 <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>
24866 <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>
24867
24868 !! end
24869
24870
24871 ###
24872 ### Parsoid-specific tests
24873 ### Parsoid-PHP parser incompatibilities
24874 ###
24875 !!test
24876 1. SOL-sensitive wikitext tokens as template-args
24877 !!options
24878 parsoid=wt2html,wt2wt
24879 !! wikitext
24880 {{echo|*a}}
24881 {{echo|#a}}
24882 {{echo|:a}}
24883 !! html
24884 <span about="#mwt1" typeof="mw:Transclusion">
24885 </span><ul about="#mwt1"><li>a</li>
24886 </ul>
24887 <span about="#mwt2" typeof="mw:Transclusion">
24888 </span><ol about="#mwt2"><li>a</li>
24889 </ol>
24890 <span about="#mwt3" typeof="mw:Transclusion">
24891 </span><dl about="#mwt3"><dd>a</dd>
24892 </dl>
24893 !!end
24894
24895 #### -----------------------------------------------------------------
24896 #### Parsoid-specific functionality tests
24897 #### -----------------------------------------------------------------
24898
24899 # T65642/T68749: Formatting elt fixup around images is cleaned up.
24900 # We know wt2wt will fail, but we expect selser to pass.
24901 # Due to the nature of our testing, wt2wt and selser tests will enter the
24902 # blacklist and we'll catch selser regressions based on changes to the
24903 # blacklist entries for selser tests.
24904 !! test
24905 1. Bad treebuilder fixup of formatting elt is cleaned up
24906 !! options
24907 parsoid=wt2html,wt2wt
24908 !! wikitext
24909 {|
24910 |
24911 <small>
24912 [[Image:Foobar.jpg|right|Test]]
24913 </small>
24914 |}
24915 !! html/parsoid
24916 <table>
24917 <tbody><tr><td>
24918 <small>
24919 <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>
24920 </small>
24921 </td></tr>
24922 </tbody></table>
24923 !! end
24924
24925 !! test
24926 2. Bad treebuilder fixup of formatting elt is cleaned up
24927 !! options
24928 parsoid=wt2html,wt2wt
24929 !! wikitext
24930 '''foo[[File:Foobar.jpg|thumb|caption]]bar'''
24931
24932 <small>[[Image:Foobar.jpg|right|300px]]</small>
24933 !! html/parsoid
24934
24935 <p><b>foo</b></p>
24936 <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>
24937 <p><b>bar</b></p>
24938 <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>
24939 !! end
24940
24941 !! test
24942 3. Bad treebuilder fixup of formatting elt is cleaned up
24943 !! options
24944 parsoid=wt2html,wt2wt
24945 !! wikitext
24946 <small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
24947 !! html/parsoid
24948 <p><small><b>foo</b></small></p>
24949 <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>
24950 <p><small><b>bar</b></small></p>
24951 !! end
24952
24953 !! test
24954 4. Bad treebuilder fixup of formatting elt is cleaned up: formatting tags around captionless images are ignored
24955 !! options
24956 parsoid=wt2html,wt2wt
24957 !! wikitext
24958 '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
24959 !! html/parsoid
24960 <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>
24961 !! end
24962
24963 #### ----------------------------------------------------------------
24964 #### Parsoid-only testing of Parsoid's impl of LST
24965 #### Not implemented yet, see
24966 #### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
24967 #### ----------------------------------------------------------------
24968
24969 ## We still need to support serializing the older format while content is stored.
24970 !! test
24971 LST Sections: Backwards compatibility
24972 !! options
24973 parsoid={
24974 "suppressErrors": true,
24975 "modes": ["html2wt"]
24976 }
24977 !! wikitext
24978 <section begin="2011-05-16" />
24979 <section end="2014-04-10 (MW 1.23wmf22)" />
24980 !! html/parsoid
24981 <p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/>
24982 <meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p>
24983 !! end
24984
24985 !! test
24986 LST Sections: Newfangled approach
24987 !! wikitext
24988 <section begin="2011-05-16" />
24989 <section end="2014-04-10 (MW 1.23wmf22)" />
24990 !! html/parsoid
24991 <p><span typeof="mw:Extension/section" about="#mwt4" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"},"body":null}'>
24992 </span>
24993 <span typeof="mw:Extension/section" about="#mwt6" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"},"body":null}'>
24994 </span></p>
24995 !! end
24996
24997 #--------- Test stripping of empty nodes in template content ----------
24998
24999 !! test
25000 Empty LI and TR nodes should be stripped from template content
25001 !! wikitext
25002 {{EmptyLITest}}
25003 {{EmptyTRTest}}
25004 !! html/parsoid
25005 <ul about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyLITest","href":"./Template:EmptyLITest"},"params":{},"i":0}}]}'>
25006 <li>a</li>
25007 <li>b</li>
25008 </ul>
25009 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRTest","href":"./Template:EmptyTRTest"},"params":{},"i":0}}]}'>
25010 <tbody>
25011 <tr>
25012 <td>foo</td>
25013 </tr>
25014 <tr>
25015 <td>bar</td>
25016 </tr>
25017 </tbody>
25018 </table>
25019 !! end
25020
25021 !! test
25022 Empty LI and TR nodes should not be stripped from top-level content
25023 !! wikitext
25024 *a
25025 *
25026 *b
25027
25028 {|
25029 |-
25030 |-
25031 |foo
25032 |}
25033 !! html/parsoid
25034 <ul>
25035 <li>a</li>
25036 <li class='mw-empty-elt'></li>
25037 <li>b</li>
25038 </ul>
25039 <table>
25040 <tbody>
25041 <tr class='mw-empty-elt'></tr>
25042 <tr>
25043 <td>foo</td>
25044 </tr>
25045 </tbody>
25046 </table>
25047 !! end
25048
25049 !! test
25050 Empty TR nodes should not be stripped if they have any attributes set
25051 !! wikitext
25052 {{EmptyTRWithHTMLAttrTest}}
25053 !! html/parsoid
25054 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'>
25055 <tr align='center'></tr>
25056 <tr><td>foo</td></tr>
25057 <tr align='center'></tr>
25058 <tr><td>bar</td></tr>
25059 </table>
25060 !! end
25061
25062 #### ----------------------------------------------------------------
25063 #### The following section of tests are primarily to test
25064 #### wikitext escaping capabilities of Parsoid. Given that
25065 #### escaping can be done any number of ways, the wikitext (input)
25066 #### is always adjusted to reflect how Parsoid adds nowiki
25067 #### escape tags.
25068 ####
25069 #### We are marking several tests as parsoid-only since the
25070 #### HTML in the result section is different from what the
25071 #### PHP parser generates for it.
25072 #### ----------------------------------------------------------------
25073
25074
25075 #### --------------- Headings ---------------
25076 #### 0. Unnested
25077 #### 1. Nested inside html <h1>=foo=</h1>
25078 #### 2. Outside heading nest on a single line <h1>foo</h1>*bar
25079 #### 3. Nested inside html with wikitext split by html tags
25080 #### 4. No escape needed
25081 #### 5. Empty headings <h1></h1>
25082 #### 6. Heading chars in SOL context
25083 #### ----------------------------------------
25084 !! test
25085 Headings: 0. Unnested
25086 !! options
25087 parsoid=html2wt
25088 !! html/parsoid
25089 <p>=foo=</p>
25090
25091 <p> =foo=
25092 <!--cmt-->
25093 =foo=</p>
25094
25095 <p>=foo<i>a</i>=</p>
25096 !! wikitext
25097 <nowiki>=foo=</nowiki>
25098
25099 <nowiki> </nowiki>=foo=
25100 <!--cmt-->
25101 <nowiki>=foo=</nowiki>
25102
25103 =foo''a''<nowiki>=</nowiki>
25104 !!end
25105
25106 # New headings and existing headings are handled differently
25107 !! test
25108 Headings: 1. Nested inside html
25109 !! options
25110 parsoid=html2wt
25111 !! html/parsoid
25112 <h1>=foo=</h1>
25113 <h2>=foo=</h2>
25114 <h3>=foo=</h3>
25115
25116 <h1 data-parsoid=''>=foo=</h1>
25117 <h2 data-parsoid=''>=foo=</h2>
25118 <h3 data-parsoid=''>=foo=</h3>
25119 <h4 data-parsoid=''>=foo=</h4>
25120 <h5 data-parsoid=''>=foo=</h5>
25121 <h6 data-parsoid=''>=foo=</h6>
25122 !! wikitext
25123 = =foo= =
25124
25125 == =foo= ==
25126
25127 === =foo= ===
25128
25129 =<nowiki>=foo=</nowiki>=
25130 ==<nowiki>=foo=</nowiki>==
25131 ===<nowiki>=foo=</nowiki>===
25132 ====<nowiki>=foo=</nowiki>====
25133 =====<nowiki>=foo=</nowiki>=====
25134 ======<nowiki>=foo=</nowiki>======
25135
25136 !!end
25137
25138 !! test
25139 Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
25140 !! options
25141 parsoid=html2wt
25142 !! html/parsoid
25143 <h1>foo</h1>*bar
25144 <h1>foo</h1>=bar
25145 <h1>foo</h1>=bar=
25146 !! wikitext
25147 = foo =
25148 <nowiki>*</nowiki>bar
25149
25150 = foo =
25151 =bar
25152
25153 = foo =
25154 <nowiki>=bar=</nowiki>
25155 !!end
25156
25157 !! test
25158 Headings: 3. Nested inside html with wikitext split by html tags
25159 !! options
25160 parsoid=html2wt
25161 !! html/parsoid
25162 <h1>=<b>bold</b>foo=</h1>
25163 !! wikitext
25164 = ='''bold'''foo= =
25165 !!end
25166
25167 !! test
25168 Headings: 4a. No escaping needed (testing just h1 and h2)
25169 !! options
25170 parsoid=html2wt
25171 !! html/parsoid
25172 <h1>=foo</h1>
25173 <h1>foo=</h1>
25174 <h1> =foo= </h1>
25175 <h1>=foo= bar</h1>
25176 <h2>=foo</h2>
25177 <h2>foo=</h2>
25178 <h1>=</h1>
25179 <h1><i>=</i>foo=</h1>
25180 !! wikitext
25181 = =foo =
25182
25183 = foo= =
25184
25185 = =foo= =
25186
25187 = =foo= bar =
25188
25189 == =foo ==
25190
25191 == foo= ==
25192
25193 = = =
25194
25195 = ''=''foo= =
25196 !!end
25197
25198 !! test
25199 Headings: 4b. No escaping needed (inside p-tags)
25200 !! options
25201 parsoid=html2wt
25202 !! html/parsoid
25203 <p>=foo= x
25204 =foo= <s></s>
25205 </p>
25206 !! wikitext
25207 =foo= x
25208 =foo= <s></s>
25209 !! html/php
25210 <p>=foo= x
25211 =foo= <s></s>
25212 </p>
25213 !!end
25214
25215 !! test
25216 Headings: 4c. Short headings (1)
25217 !! options
25218 parsoid=html2wt
25219 !! html/parsoid
25220 <p>===
25221 </p>
25222 !! wikitext
25223 <nowiki>===</nowiki>
25224 !! html/php
25225 <p>===
25226 </p>
25227 !! end
25228
25229 # in the html2wt direction we emit '= = =' or '=<nowiki>=</nowiki>='
25230 !! test
25231 Headings: 4d. Short headings (2)
25232 !! options
25233 parsoid=wt2html,html2html
25234 !! wikitext
25235 =
25236 ==
25237 ===
25238 ====
25239 =====
25240 !! html/php
25241 <p>=
25242 ==
25243 </p>
25244 <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>
25245 <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>
25246 <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>
25247
25248 !! html/parsoid
25249 <p>=
25250 ==</p>
25251 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
25252 <h1 id="=="><span id=".3D.3D" typeof="mw:FallbackId"></span>==</h1>
25253 <h2 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h2>
25254 !! end
25255
25256 !! test
25257 Headings: 5. Empty headings
25258 !! options
25259 parsoid=html2wt
25260 !! html/parsoid
25261 <h1 data-parsoid='{}'></h1>
25262
25263 <h2 data-parsoid='{}'></h2>
25264
25265 <h3 data-parsoid='{}'></h3>
25266
25267 <h4 data-parsoid='{}'></h4>
25268
25269 <h5 data-parsoid='{}'></h5>
25270
25271 <h6 data-parsoid='{}'></h6>
25272 !! wikitext
25273 =<nowiki/>=
25274
25275 ==<nowiki/>==
25276
25277 ===<nowiki/>===
25278
25279 ====<nowiki/>====
25280
25281 =====<nowiki/>=====
25282
25283 ======<nowiki/>======
25284 !!end
25285
25286 !! test
25287 Headings: 6a. Heading chars in SOL context (with trailing spaces)
25288 !! options
25289 parsoid=html2wt
25290 !! html/parsoid
25291 <p>=a=</p>
25292
25293 <p>=a=</p>
25294
25295 <p>=a=</p>
25296 !! wikitext
25297 <nowiki>=a=</nowiki>
25298
25299 <nowiki>=a=</nowiki>
25300
25301 <nowiki>=a=</nowiki>
25302 !!end
25303
25304 !! test
25305 Headings: 6b. Heading chars in SOL context (with trailing newlines)
25306 !! options
25307 parsoid=html2wt
25308 !! html/parsoid
25309 <p>=a=
25310 b</p>
25311
25312 <p>=a=
25313 b</p>
25314
25315 <p>=a=
25316 b</p>
25317 !! wikitext
25318 <nowiki>=a=</nowiki>
25319 b
25320
25321 <nowiki>=a=</nowiki>
25322 b
25323
25324 <nowiki>=a=</nowiki>
25325 b
25326 !!end
25327
25328 !! test
25329 Headings: 6c. Heading chars in SOL context (leading newline break)
25330 !! options
25331 parsoid=html2wt
25332 !! html/parsoid
25333 <p>a
25334 =b=</p>
25335 !! wikitext
25336 a
25337 <nowiki>=b=</nowiki>
25338 !!end
25339
25340 !! test
25341 Headings: 6d. Heading chars in SOL context (with interspersed comments)
25342 !! options
25343 parsoid=html2wt
25344 !! html/parsoid
25345 <!--c0--><p>=a=</p>
25346
25347 <!--c1--><p>=a=</p> <!--c2--> <!--c3-->
25348 !! wikitext
25349 <!--c0--><nowiki>=a=</nowiki>
25350
25351 <!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3-->
25352 !!end
25353
25354 !! test
25355 Headings: 6d. Heading chars in SOL context (No escaping needed)
25356 !! options
25357 parsoid=html2wt
25358 !! html/parsoid
25359 =a=<div>b</div>
25360 !! wikitext
25361 =a=<div>b</div>
25362 !!end
25363
25364 !! test
25365 Headings: 7. Insert a newline between new content and headings
25366 !! options
25367 parsoid=html2wt
25368 !! html/parsoid
25369 <h2>NEW</h2>
25370 <p>new</p>
25371 <h2 data-parsoid='{}'>A</h2>
25372 <p data-parsoid='{}'>a</p>
25373 !! wikitext
25374 == NEW ==
25375 new
25376
25377 ==A==
25378 a
25379
25380 !! end
25381
25382 !! test
25383 Headings: Used as horizontal rule
25384 !! config
25385 wgFragmentMode=[ 'html5', 'legacy' ]
25386 !! options
25387 parsoid=wt2html
25388 !! wikitext
25389 ===============
25390 !! html/php
25391 <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>
25392
25393 !! html/parsoid
25394 <h6 id="==="><span id=".3D.3D.3D" typeof="mw:FallbackId"></span>===</h6>
25395 !! end
25396
25397 #### --------------- Lists ---------------
25398 #### 0. Outside nests (*foo, etc.)
25399 #### 1. Nested inside html <ul><li>*foo</li></ul>
25400 #### 2. Inside definition lists
25401 #### 3. Only bullets at start should be escaped
25402 #### 4. No escapes needed
25403 #### 5. No unnecessary escapes
25404 #### 6. Escape bullets in SOL position
25405 #### 7. Escape bullets in a multi-line context
25406 #### ----------------------------------------
25407
25408 !! test
25409 Lists: 0. Outside nests
25410 !! options
25411 parsoid=html2wt
25412 !! html/parsoid
25413 <p>*foo</p>
25414
25415 <p>#foo</p>
25416
25417 <p>;Foo:bar</p>
25418 !! wikitext
25419 <nowiki>*</nowiki>foo
25420
25421 <nowiki>#</nowiki>foo
25422
25423 <nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar
25424 !!end
25425
25426 ## Making these next 3 tests Parsoid-only since they are html2wt tests
25427 ## to test wikitext escaping, and insignificant whitespace diffs
25428 ## cause PHP parser tests to barf
25429 !! test
25430 Lists: 1. Nested inside html (No unnecessary escapes)
25431 !! options
25432 parsoid=html2wt
25433 !! html/parsoid
25434 <ul>
25435 <li>*foo</li>
25436 <li>#foo</li>
25437 <li>:foo</li>
25438 <li>;foo</li>
25439 <li data-parsoid='{}'>*foo</li>
25440 <li data-parsoid='{}'>#foo</li>
25441 <li data-parsoid='{}'>:foo</li>
25442 <li data-parsoid='{}'>;foo</li>
25443 </ul>
25444
25445 <ol>
25446 <li>*foo</li>
25447 <li>#foo</li>
25448 <li>:foo</li>
25449 <li>;foo</li>
25450 <li data-parsoid='{}'>*foo</li>
25451 <li data-parsoid='{}'>#foo</li>
25452 <li data-parsoid='{}'>:foo</li>
25453 <li data-parsoid='{}'>;foo</li>
25454 </ol>
25455 !! wikitext
25456 * *foo
25457 * #foo
25458 * :foo
25459 * ;foo
25460 *<nowiki>*foo</nowiki>
25461 *<nowiki>#foo</nowiki>
25462 *<nowiki>:foo</nowiki>
25463 *<nowiki>;foo</nowiki>
25464
25465 # *foo
25466 # #foo
25467 # :foo
25468 # ;foo
25469 #<nowiki>*foo</nowiki>
25470 #<nowiki>#foo</nowiki>
25471 #<nowiki>:foo</nowiki>
25472 #<nowiki>;foo</nowiki>
25473 !!end
25474
25475 !! test
25476 Lists: 2. Inside definition lists
25477 !! options
25478 parsoid=html2wt
25479 !! html/parsoid
25480 <dl><dt>;foo</dt></dl>
25481 <dl><dt>:foo</dt></dl>
25482 <dl><dt>:foo</dt>
25483 <dd>bar</dd></dl>
25484 <dl><dd>:foo</dd></dl>
25485 !! wikitext
25486 ; ;foo
25487
25488 ; <nowiki>:foo</nowiki>
25489
25490 ; <nowiki>:foo</nowiki>
25491 : bar
25492
25493 : :foo
25494 !!end
25495
25496 !! test
25497 Lists: 3. Only bullets at start of text in wikitext-generated HTML should be escaped
25498 !! options
25499 parsoid=html2wt
25500 !! html/parsoid
25501 <ul>
25502 <li>*foo*bar</li>
25503 <li data-parsoid='{}'>*foo<i>it</i>*bar</li>
25504 </ul>
25505 !! wikitext
25506 * *foo*bar
25507 *<nowiki>*foo</nowiki>''it''*bar
25508 !!end
25509
25510 !! test
25511 Lists: 4. No escapes needed
25512 !! options
25513 parsoid=html2wt
25514 !! html/parsoid
25515 <ul>
25516 <li>foo*bar
25517 </li>
25518 </ul>
25519 <ul>
25520 <li><i>foo</i>*bar
25521 </li>
25522 </ul>
25523 <ul>
25524 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>: bar
25525 </li>
25526 </ul>
25527 <ul>
25528 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar
25529 </li>
25530 </ul>
25531 !! wikitext
25532 *foo*bar
25533
25534 *''foo''*bar
25535
25536 *[[Foo]]: bar
25537
25538 *[[Foo]]*bar
25539 !!end
25540
25541 !! test
25542 Lists: 5. No unnecessary escapes
25543 !! options
25544 parsoid=html2wt
25545 !! html/parsoid
25546 <ul><li> bar <span>[[foo]]</span></li></ul>
25547 <ul><li> =bar <span>[[foo]]</span></li></ul>
25548 <ul><li> [[bar <span>[[foo]]</span></li></ul>
25549 <ul><li> ]]bar <span>[[foo]]</span></li></ul>
25550 <ul><li> =bar <span>foo]]</span>=</li></ul>
25551 <ul><li> <s></s>: a</li></ul>
25552 <ul><li> <i>* foo</i></li></ul>
25553
25554 !! wikitext
25555 * bar <span><nowiki>[[foo]]</nowiki></span>
25556
25557 * =bar <span><nowiki>[[foo]]</nowiki></span>
25558
25559 * [[bar <span><nowiki>[[foo]]</nowiki></span>
25560
25561 * ]]bar <span><nowiki>[[foo]]</nowiki></span>
25562
25563 * =bar <span>foo]]</span>=
25564
25565 * <s></s>: a
25566
25567 * ''* foo''
25568 !!end
25569
25570 !! test
25571 Lists: 6. Escape bullets in SOL position
25572 !! options
25573 parsoid=html2wt
25574 !! html/parsoid
25575 <p><!--cmt-->*foo</p>
25576 !! wikitext
25577 <!--cmt--><nowiki>*</nowiki>foo
25578 !!end
25579
25580 !! test
25581 Lists: 7. Escape bullets in a multi-line context
25582 !! options
25583 parsoid=html2wt
25584 !! html/parsoid
25585 <p>a
25586 *b
25587 </p>
25588 !! wikitext
25589 a
25590 <nowiki>*</nowiki>b
25591 !!end
25592
25593 !! test
25594 Lists: 8. Escape colons only if not present in tags
25595 !! options
25596 parsoid=html2wt
25597 !! html/parsoid
25598 <dl><dt>a:b<i>c:d</i></dt></dl>
25599 !! wikitext
25600 ; <nowiki>a:b</nowiki>''c:d''
25601 !! end
25602
25603 #### --------------- HRs ---------------
25604 #### 1. Single line
25605 #### -----------------------------------
25606
25607 !! test
25608 HRs: 1. Single line
25609 !! options
25610 parsoid=html2wt
25611 !! html/parsoid
25612 <hr />----
25613 <hr />=foo=
25614 <hr />*foo
25615 !! wikitext
25616 ----<nowiki>----</nowiki>
25617 ----=foo=
25618 ----*foo
25619 !! end
25620
25621 #### --------------- Tables ---------------
25622 #### 1a. Simple example
25623 #### 1b. No escaping needed (!foo)
25624 #### 1c. No escaping needed (|foo)
25625 #### 1d. No escaping needed (|}foo)
25626 ####
25627 #### 2a. Nested in td (<td>foo|bar</td>)
25628 #### 2b. Nested in td (<td>foo||bar</td>)
25629 #### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
25630 ####
25631 #### 3a. Nested in th (<th>foo!bar</th>)
25632 #### 3b. Nested in th (<th>foo!!bar</th>)
25633 #### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
25634 ####
25635 #### 4a. Escape -
25636 #### 4b. Escape +
25637 #### 4c. No escaping needed
25638 #### --------------------------------------
25639
25640 !! test
25641 Tables: 1a. Simple example
25642 !! options
25643 parsoid=html2wt
25644 !! html/parsoid
25645 <p>{|
25646 |}
25647 </p>
25648 !! wikitext
25649 <nowiki>{|</nowiki>
25650 |}
25651 !! end
25652
25653 !! test
25654 Tables: 1b. No escaping needed
25655 !! options
25656 parsoid=html2wt
25657 !! html/parsoid
25658 <p>!foo
25659 </p>
25660 !! wikitext
25661 !foo
25662 !! end
25663
25664 !! test
25665 Tables: 1c. No escaping needed
25666 !! options
25667 parsoid=html2wt
25668 !! html/parsoid
25669 <p>|foo
25670 </p>
25671 !! wikitext
25672 |foo
25673 !! end
25674
25675 !! test
25676 Tables: 1d. No escaping needed
25677 !! options
25678 parsoid=html2wt
25679 !! html/parsoid
25680 <p>|}foo
25681 </p>
25682 !! wikitext
25683 |}foo
25684 !! end
25685
25686 !! test
25687 Tables: 2a. Nested in td
25688 !! options
25689 parsoid=html2wt
25690 !! html/parsoid
25691 <table><tbody><tr>
25692 <td>foo|bar</td></tr>
25693 <tr><td>x<div>a|b</div></td>
25694 </tbody></table>
25695 !! wikitext
25696 {|
25697 |<nowiki>foo|bar</nowiki>
25698 |-
25699 |x<div><nowiki>a|b</nowiki></div>
25700 |}
25701 !! html/php+tidy
25702 <table>
25703 <tbody><tr>
25704 <td>foo|bar
25705 </td></tr>
25706 <tr>
25707 <td>x<div>a|b</div>
25708 </td></tr></tbody></table>
25709 !! end
25710
25711 !! test
25712 Tables: 2b. Nested in td
25713 !! options
25714 parsoid=html2wt
25715 !! html/parsoid
25716 <table><tbody><tr>
25717 <td>foo||bar</td>
25718 <td>a<i>b||c</i></td>
25719 <td>a<i><div>b||c</div></i></td>
25720 </tr></tbody></table>
25721 !! wikitext
25722 {|
25723 |<nowiki>foo||bar</nowiki>
25724 |a''<nowiki>b||c</nowiki>''
25725 |a''<div><nowiki>b||c</nowiki></div>''
25726 |}
25727 !! html/php
25728 <table>
25729 <tr>
25730 <td>foo||bar
25731 </td>
25732 <td>a<i>b||c</i>
25733 </td>
25734 <td>a<i><div>b||c</div></i>
25735 </td></tr></table>
25736
25737 !! end
25738
25739 !! test
25740 Tables: 2c. Nested in td -- no escaping needed
25741 !! options
25742 parsoid=html2wt
25743 !! html/*
25744 <table>
25745 <tr>
25746 <td>foo!!bar
25747 </td></tr></table>
25748
25749 !! wikitext
25750 {|
25751 |foo!!bar
25752 |}
25753 !! end
25754
25755 !! test
25756 Tables: 3a. Nested in th
25757 !! options
25758 parsoid=html2wt
25759 !! html/*
25760 <table>
25761 <tr>
25762 <th>foo!bar
25763 </th></tr></table>
25764
25765 !! wikitext
25766 {|
25767 !foo!bar
25768 |}
25769 !! end
25770
25771 !! test
25772 Tables: 3b. Nested in th
25773 !! options
25774 parsoid=html2wt
25775 !! html/parsoid
25776 <table><tbody>
25777 <tr><th>foo!!bar</th>
25778 <th><i>foo|bar</i></th>
25779 <th><i>foo!!bar</i></th>
25780 <th><i><span>foo!!bar</span></i></th>
25781 </tr></tbody></table>
25782 !! wikitext
25783 {|
25784 !<nowiki>foo!!bar</nowiki>
25785 !''<nowiki>foo|bar</nowiki>''
25786 !''<nowiki>foo!!bar</nowiki>''
25787 !''<span><nowiki>foo!!bar</nowiki></span>''
25788 |}
25789 !! html/php
25790 <table>
25791 <tr>
25792 <th>foo!!bar
25793 </th>
25794 <th><i>foo|bar</i>
25795 </th>
25796 <th><i>foo!!bar</i>
25797 </th>
25798 <th><i><span>foo!!bar</span></i>
25799 </th></tr></table>
25800
25801 !! end
25802
25803 !! test
25804 Tables: 3c. Nested in th
25805 !! options
25806 parsoid=html2wt
25807 !! html/parsoid
25808 <table><tbody>
25809 <tr><th>foo||bar</th>
25810 <th><span typeof="mw:Nowiki">foo||bar</span></th>
25811 </tr></tbody></table>
25812 !! wikitext
25813 {|
25814 !<nowiki>foo||bar</nowiki>
25815 !<nowiki>foo||bar</nowiki>
25816 |}
25817 !! html/php
25818 <table>
25819 <tr>
25820 <th>foo||bar
25821 </th>
25822 <th>foo||bar
25823 </th></tr></table>
25824
25825 !! end
25826
25827 !! test
25828 Tables: 4a. Escape -
25829 !! options
25830 parsoid=html2wt
25831 !! html/*
25832 <table>
25833 <tr>
25834 <th>-bar
25835 </th></tr>
25836 <tr>
25837 <td>-bar
25838 </td></tr></table>
25839
25840 !! wikitext
25841 {|
25842 !-bar
25843 |-
25844 |<nowiki>-bar</nowiki>
25845 |}
25846 !! end
25847
25848 !! test
25849 Tables: 4b. Escape +
25850 !! options
25851 parsoid=html2wt
25852 !! html/*
25853 <table>
25854 <tr>
25855 <th>+bar
25856 </th></tr>
25857 <tr>
25858 <td>+bar
25859 </td></tr></table>
25860
25861 !! wikitext
25862 {|
25863 !+bar
25864 |-
25865 |<nowiki>+bar</nowiki>
25866 |}
25867 !! end
25868
25869 !! test
25870 Tables: 4c. No escaping needed
25871 !! options
25872 parsoid=html2wt
25873 !! html/parsoid
25874 <table><tbody>
25875 <tr><td>foo-bar</td><td>foo+bar</td></tr>
25876 <tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
25877 <tr><td>foo
25878 <p>bar|baz
25879 +bar
25880 -bar</p></td></tr>
25881 <tr><td>x
25882 <div>a|b</div></td>
25883 </tbody></table>
25884 !! wikitext
25885 {|
25886 |foo-bar
25887 |foo+bar
25888 |-
25889 |''foo''-bar
25890 |''foo''+bar
25891 |-
25892 |foo
25893 bar|baz
25894 +bar
25895 -bar
25896 |-
25897 |x
25898 <div>a|b</div>
25899 |}
25900 !! html/php
25901 <table>
25902 <tr>
25903 <td>foo-bar
25904 </td>
25905 <td>foo+bar
25906 </td></tr>
25907 <tr>
25908 <td><i>foo</i>-bar
25909 </td>
25910 <td><i>foo</i>+bar
25911 </td></tr>
25912 <tr>
25913 <td>foo
25914 <p>bar|baz
25915 +bar
25916 -bar
25917 </p>
25918 </td></tr>
25919 <tr>
25920 <td>x
25921 <div>a|b</div>
25922 </td></tr></table>
25923
25924 !! end
25925
25926 !! test
25927 Tables: 4d. No escaping needed
25928 !! options
25929 parsoid=html2wt
25930 !! html/parsoid
25931 <table>
25932 <tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
25933 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
25934 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
25935 </tbody></table>
25936 !! wikitext
25937 {|
25938 |[[Foo]]-bar
25939 ||+1
25940 ||-2
25941 |}
25942 !! html/php
25943 <table>
25944 <tr>
25945 <td><a href="/wiki/Foo" title="Foo">Foo</a>-bar
25946 </td>
25947 <td>+1
25948 </td>
25949 <td>-2
25950 </td></tr></table>
25951
25952 !! end
25953
25954 !! test
25955 Tables: 5. Empty table cells should get whitespace to avoid need for nowikis
25956 !! options
25957 parsoid=html2wt
25958 !! html/parsoid
25959 <table><tr><td></td><td align="center" data-parsoid='{"stx":"row"}'></td><td data-parsoid='{"stx":"row"}'></td></tr></table>
25960
25961 <table><tr><td></td><td align="center"></td><td></td></tr></table>
25962
25963 <table><tr><td></td><td align="center" data-parsoid='{"stx":"row", "startTagSrc":"{{!}}{{!}}"}'></td><td data-parsoid='{"stx":"row"}'></td></tr></table>
25964
25965 <table><tr><th></th><th align="center" data-parsoid='{"stx":"row"}'></th><th data-parsoid='{"stx":"row"}'></th></tr></table>
25966 !! wikitext
25967 {|
25968 | || align="center" | ||
25969 |}
25970
25971 {|
25972 |
25973 | align="center" |
25974 |
25975 |}
25976
25977 {|
25978 | {{!}}{{!}} align="center" | ||
25979 |}
25980
25981 {|
25982 ! !! align="center" | !!
25983 |}
25984 !! html/php+tidy
25985 <table>
25986 <tbody><tr>
25987 <td></td>
25988 <td align="center"></td>
25989 <td>
25990 </td></tr></tbody></table>
25991 <table>
25992 <tbody><tr>
25993 <td>
25994 </td>
25995 <td align="center">
25996 </td>
25997 <td>
25998 </td></tr></tbody></table>
25999 <table>
26000 <tbody><tr>
26001 <td></td>
26002 <td align="center"></td>
26003 <td>
26004 </td></tr></tbody></table>
26005 <table>
26006 <tbody><tr>
26007 <th></th>
26008 <th align="center"></th>
26009 <th>
26010 </th></tr></tbody></table>
26011 !! end
26012
26013 !! test
26014 T97430: Don't emit empty nowiki pairs around marker meta tags
26015 !! options
26016 parsoid=html2wt
26017 !! html/parsoid
26018 <p>*This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
26019 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
26020 !! wikitext
26021 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
26022 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
26023 !! end
26024
26025 !! test
26026 Unclosed xmlish element in table line shouldn't eat end delimiters
26027 !! options
26028 parsoid=html2wt
26029 !! html/parsoid
26030 <table>
26031 <tbody><tr><td> &lt;foo</td>
26032 <td> bar></td></tr>
26033 </tbody></table>
26034 !! wikitext
26035 {|
26036 | <foo
26037 | bar>
26038 |}
26039 !! html/php
26040 <table>
26041 <tr>
26042 <td>&lt;foo
26043 </td>
26044 <td>bar&gt;
26045 </td></tr></table>
26046
26047 !! end
26048
26049 #### --------------- Links ----------------
26050 #### 1. Quote marks in link text
26051 #### 2. Wikilinks: Escapes needed
26052 #### 3. Wikilinks: No escapes needed
26053 #### 4. Extlinks: Escapes needed
26054 #### 5. Extlinks: No escapes needed
26055 #### --------------------------------------
26056 !! test
26057 Links 1. WikiLinks: No escapes needed
26058 !! options
26059 parsoid=html2wt
26060 !! html/parsoid
26061 <p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
26062 <a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
26063 <a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
26064 !! wikitext
26065 [[Foo|Foo''boo'']]
26066 [[Foo|[Foobar]]]
26067 [[Foo|x [Foobar] x]]
26068 !! html/php
26069 <p><a href="/wiki/Foo" title="Foo">Foo<i>boo</i></a>
26070 <a href="/wiki/Foo" title="Foo">[Foobar]</a>
26071 <a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
26072 </p>
26073 !! end
26074
26075 !! test
26076 Links 2. WikiLinks: Escapes needed
26077 !! options
26078 parsoid=html2wt
26079 !! html/parsoid
26080 <a href="Foo" rel="mw:WikiLink">Foobar]</a>
26081 <a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
26082 <a href="Foo" rel="mw:WikiLink">[[Bar]]</a>
26083 <a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a>
26084 <a href="Foo" rel="mw:WikiLink">|Bar</a>
26085 <a href="Foo" rel="mw:WikiLink">]]bar</a>
26086 <a href="Foo" rel="mw:WikiLink">[[bar</a>
26087 <a href="Foo" rel="mw:WikiLink">x [[ y</a>
26088 <a href="Foo" rel="mw:WikiLink">x ]] y</a>
26089 <a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a>
26090 !! wikitext
26091 [[Foo|<nowiki>Foobar]</nowiki>]]
26092 [[Foo|x <nowiki>[http://google.com g]</nowiki> x]]
26093 [[Foo|<nowiki>[[Bar]]</nowiki>]]
26094 [[Foo|<nowiki>x [[Bar]] x</nowiki>]]
26095 [[Foo|<nowiki>|Bar</nowiki>]]
26096 [[Foo|<nowiki>]]bar</nowiki>]]
26097 [[Foo|<nowiki>[[bar</nowiki>]]
26098 [[Foo|<nowiki>x [[ y</nowiki>]]
26099 [[Foo|<nowiki>x ]] y</nowiki>]]
26100 [[Foo|<nowiki>x ]] y [[ z</nowiki>]]
26101 !! html/php
26102 <p><a href="/wiki/Foo" title="Foo">Foobar]</a>
26103 <a href="/wiki/Foo" title="Foo">x [http://google.com g] x</a>
26104 <a href="/wiki/Foo" title="Foo">[[Bar]]</a>
26105 <a href="/wiki/Foo" title="Foo">x [[Bar]] x</a>
26106 <a href="/wiki/Foo" title="Foo">|Bar</a>
26107 <a href="/wiki/Foo" title="Foo">]]bar</a>
26108 <a href="/wiki/Foo" title="Foo">[[bar</a>
26109 <a href="/wiki/Foo" title="Foo">x [[ y</a>
26110 <a href="/wiki/Foo" title="Foo">x ]] y</a>
26111 <a href="/wiki/Foo" title="Foo">x ]] y [[ z</a>
26112 </p>
26113 !! end
26114
26115 !! test
26116 Links 3. WikiLinks: No escapes needed
26117 !! options
26118 parsoid=html2wt
26119 !! html/parsoid
26120 <p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
26121 <a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
26122 !! wikitext
26123 [[Foo|[Foobar]]
26124 [[Foo|foo|bar]]
26125 !! html/php
26126 <p><a href="/wiki/Foo" title="Foo">[Foobar</a>
26127 <a href="/wiki/Foo" title="Foo">foo|bar</a>
26128 </p>
26129 !! end
26130
26131 !! test
26132 Links 4. ExtLinks: Escapes needed
26133 !! options
26134 parsoid=html2wt
26135 !! html/parsoid
26136 <p><a rel="mw:ExtLink" href="http://google.com">[google]</a>
26137 <a rel="mw:ExtLink" href="http://google.com">google]</a>
26138 <a rel="mw:ExtLink" href="http://google.com">goog] le</a></p>
26139 <p>[http://google.com]</p>
26140 <p>[http://google.com google]</p>
26141 <p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p>
26142 <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>
26143 !! wikitext
26144 [http://google.com <nowiki>[google]</nowiki>]
26145 [http://google.com <nowiki>google]</nowiki>]
26146 [http://google.com <nowiki>goog] le</nowiki>]
26147
26148 <nowiki>[http://google.com]</nowiki>
26149
26150 <nowiki>[http://google.com google]</nowiki>
26151
26152 [http://google.com<nowiki>]</nowiki>
26153
26154 [{{echo|http://google.com}}<nowiki>]</nowiki>
26155 !! html/php
26156 <p><a rel="nofollow" class="external text" href="http://google.com">[google]</a>
26157 <a rel="nofollow" class="external text" href="http://google.com">google]</a>
26158 <a rel="nofollow" class="external text" href="http://google.com">goog] le</a>
26159 </p><p>[http://google.com]
26160 </p><p>[http://google.com google]
26161 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
26162 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
26163 </p>
26164 !! end
26165
26166 !! test
26167 Links 5. ExtLinks: No escapes needed
26168 !! options
26169 parsoid=html2wt
26170 !! html/parsoid
26171 <p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
26172 <p>[<a ref="mw:ExtLink" href="http://google.com"></a>]</p>
26173 !! wikitext
26174 [http://google.com [google]
26175
26176 [[http://google.com]]
26177 !! html/php
26178 <p><a rel="nofollow" class="external text" href="http://google.com">[google</a>
26179 </p><p>[<a rel="nofollow" class="external autonumber" href="http://google.com">[1]</a>]
26180 </p>
26181 !! end
26182
26183 !! test
26184 Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300)
26185 !! options
26186 parsoid=html2wt
26187 !! html/parsoid
26188 <p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y
26189 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>?x
26190 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>&amp;x
26191 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>'x
26192 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,x
26193 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.x
26194 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
26195 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>:x
26196 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
26197 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>!x
26198 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>=x
26199 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>(x)
26200 <a rel="mw:ExtLink" href="http://example.com(x" data-parsoid='{"stx":"url"}'>http://example.com(x</a>)
26201 </p>
26202 !! wikitext
26203 x<nowiki/>http://example.com<nowiki/>y
26204 http://example.com<nowiki/>?x
26205 http://example.com<nowiki/>&x
26206 http://example.com<nowiki/>'x
26207 http://example.com<nowiki/>,x
26208 http://example.com<nowiki/>.x
26209 http://example.com<nowiki/>;x
26210 http://example.com<nowiki/>:x
26211 http://example.com<nowiki/>;x
26212 http://example.com<nowiki/>!x
26213 http://example.com<nowiki/>=x
26214 http://example.com<nowiki/>(x)
26215 http://example.com(x<nowiki/>)
26216 !! end
26217
26218 !! test
26219 Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
26220 !! options
26221 parsoid=html2wt
26222 !! html/parsoid
26223 <p>x
26224 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>
26225 y
26226 "<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>"
26227 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>)
26228 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>) foo
26229 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,
26230 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, foo
26231 </p>
26232 !! wikitext
26233 x
26234 http://example.com
26235 y
26236 "http://example.com"
26237 (http://example.com)
26238 (http://example.com) foo
26239 http://example.com,
26240 http://example.com, foo
26241 !! html/php
26242 <p>x
26243 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
26244 y
26245 "<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>"
26246 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
26247 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) foo
26248 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
26249 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, foo
26250 </p>
26251 !! end
26252
26253 !! test
26254 Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
26255 !! options
26256 parsoid=html2wt
26257 !! html/parsoid
26258 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\
26259 -<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p>
26260 !! wikitext
26261 http://example.com.,;:!?\
26262 -http://example.com:
26263 !! html/php
26264 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.,;:!?\
26265 -<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
26266 </p>
26267 !! end
26268
26269 !! test
26270 Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
26271 !! options
26272 parsoid=html2wt
26273 !! html/parsoid
26274 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
26275 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
26276 X<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
26277 !! wikitext
26278 RFC 123<nowiki/>4
26279 RFC 123<nowiki/>y
26280 X<nowiki/>RFC 123<nowiki/>y
26281 !! end
26282
26283 !! test
26284 Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
26285 !! options
26286 parsoid=html2wt
26287 !! html/parsoid
26288 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
26289 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
26290 -<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
26291 </p>
26292 !! wikitext
26293 RFC 123?foo
26294 RFC 123&foo
26295 -RFC 123-
26296 !! html/php
26297 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>?foo
26298 <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
26299 -<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>-
26300 </p>
26301 !! end
26302
26303 !! test
26304 Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300)
26305 !! options
26306 parsoid=html2wt
26307 !! html/parsoid
26308 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4
26309 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
26310 X<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
26311 !! wikitext
26312 PMID 123<nowiki/>4
26313 PMID 123<nowiki/>y
26314 X<nowiki/>PMID 123<nowiki/>y
26315 !! end
26316
26317 !! test
26318 Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300)
26319 !! options
26320 parsoid=html2wt
26321 !! html/parsoid
26322 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo
26323 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo
26324 -<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>-
26325 </p>
26326 !! wikitext
26327 PMID 123?foo
26328 PMID 123&foo
26329 -PMID 123-
26330 !! html/php
26331 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>?foo
26332 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>&amp;foo
26333 -<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>-
26334 </p>
26335 !! end
26336
26337 !! test
26338 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300)
26339 !! options
26340 parsoid=html2wt
26341 !! html/parsoid
26342 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
26343 <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
26344 a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
26345 </p>
26346 !! wikitext
26347 ISBN 1234567890<nowiki/>1
26348 ISBN 1234567890<nowiki/>x
26349 a<nowiki/>ISBN 1234567890<nowiki/>b
26350 !! end
26351
26352 !! test
26353 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (T66300)
26354 !! options
26355 parsoid=html2wt
26356 !! html/parsoid
26357 <p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
26358 !! wikitext
26359 -ISBN 1234567890's
26360 !! html/php
26361 <p>-<a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>'s
26362 </p>
26363 !! end
26364
26365 !! test
26366 Links 14. Protect link-like plain text. (Parsoid bug T78425)
26367 !! options
26368 parsoid=html2wt
26369 !! html/*
26370 <p>this is not a link: http://example.com
26371 </p>
26372 !! wikitext
26373 this is not a link: <nowiki>http://example.com</nowiki>
26374 !! end
26375
26376 !! test
26377 Links 15. Link trails can't become link prefixes.
26378 !! options
26379 language=is
26380 parsoid=html2wt
26381 !! html/parsoid
26382 <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>
26383 !! wikitext
26384 [[Söfnuður]]-[[00]]
26385 !! html/php
26386 <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>
26387 </p>
26388 !! end
26389
26390 #### --------------- Quotes ---------------
26391 #### 1. Quotes inside <b> and <i>
26392 #### 2. Link fragments separated by <i> and <b> tags
26393 #### 3. Link fragments inside <i> and <b>
26394 #### 4. No escaping needed
26395 #### --------------------------------------
26396 !! test
26397 1a. Quotes inside <b> and <i>
26398 !! options
26399 parsoid=html2wt
26400 !! html/*
26401 <p><i>'foo'</i>
26402 <i>''foo''</i>
26403 <i>'''foo'''</i>
26404 <i>foo</i>'s
26405 <b>'foo'</b>
26406 <b>''foo''</b>
26407 <b>'''foo'''</b>
26408 <b>foo'<i>bar'</i>baz</b>
26409 <b>foo</b>'s
26410 '<i>foo</i>
26411 <i>foo</i>'
26412 <i>foo'</i>'
26413 '<i>foo</i>'
26414 '<b>foo</b>
26415 <b>foo</b>'
26416 '<b>foo</b>'
26417 <i>fools'<span> errand</span></i>
26418 <i><span>fool</span>'s errand</i>
26419 '<i>foo</i> bar '<i>baz</i>
26420 a|!*#-:;+-~[]{}b'<i>x</i>
26421 </p>
26422 !! wikitext
26423 ''<nowiki/>'foo'''
26424 ''<nowiki>''foo''</nowiki>''
26425 ''<nowiki>'''foo'''</nowiki>''
26426 ''foo''<nowiki/>'s
26427 '''<nowiki/>'foo''''
26428 '''<nowiki>''foo''</nowiki>'''
26429 '''<nowiki>'''foo'''</nowiki>'''
26430 '''foo'<nowiki/>''bar'<nowiki/>''baz'''
26431 '''foo'''<nowiki/>'s
26432 '''foo''
26433 ''foo''<nowiki/>'
26434 ''foo'''<nowiki/>'
26435 '''foo''<nowiki/>'
26436 ''''foo'''
26437 '''foo'''<nowiki/>'
26438 ''''foo'''<nowiki/>'
26439 ''fools'<span> errand</span>''
26440 ''<span>fool</span>'s errand''
26441 '<nowiki/>''foo'' bar '''baz''
26442 a|!*#-:;+-~[]{}b'''x''
26443 !! end
26444
26445 !! test
26446 1b. Quotes inside <b> and <i> with other tags on same line
26447 !! options
26448 parsoid=html2wt
26449 !! html/parsoid
26450 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
26451 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
26452 <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>
26453 <a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" rel="mw:WikiLink" title="Bar">bar</a></i>
26454 '<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>
26455 '<i>foo</i> <div title="name">test</div>
26456 '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
26457 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
26458 <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>
26459 </ol>
26460 !! wikitext
26461 '''a'' foo ''[[bar]]''
26462 ''a''' foo ''[[bar]]''
26463 ''a''' foo '''{{echo|[[bar]]}}'''
26464 [[foo]] x'''[[bar]]''
26465 '''foo'' <ref>test</ref>
26466 '''foo'' <div title="name">test</div>
26467 '''foo'' and <br> bar
26468 <references />
26469 !! end
26470
26471 !! test
26472 2. Link fragments separated by <i> and <b> tags
26473 !! options
26474 parsoid=html2wt
26475 !! html/parsoid
26476 <p>[[<i>foo</i>hello]]</p>
26477 <p>[[<b>foo</b>hello]]</p>
26478 !! wikitext
26479 [[''foo''<nowiki>hello]]</nowiki>
26480
26481 [['''foo'''<nowiki>hello]]</nowiki>
26482 !! end
26483
26484 # FIXME: Escaping one or both of [[ and ]] is also acceptable --
26485 # this is one of the shortcomings of this format
26486 !! test
26487 3. Link fragments inside <i> and <b>
26488 !! options
26489 parsoid=html2wt
26490 !! html/parsoid
26491 <p><i>[[foo</i>]]</p>
26492 <p><b>[[foo</b>]]</p>
26493 !! wikitext
26494 ''[[foo''<nowiki>]]</nowiki>
26495
26496 '''[[foo'''<nowiki>]]</nowiki>
26497 !! end
26498
26499 !! test
26500 4. No escaping needed
26501 !! options
26502 parsoid=html2wt
26503 !! html/parsoid
26504 <p>'<span><i>bar</i></span>'
26505 '<span><b>bar</b></span>'
26506 'a:b'foo
26507 </p>
26508 !! wikitext
26509 '<span>''bar''</span>'
26510 '<span>'''bar'''</span>'
26511 'a:b'foo
26512 !! end
26513
26514 #### ----------- Paragraphs ---------------
26515 #### 1. No unnecessary escapes
26516 #### --------------------------------------
26517
26518 !! test
26519 1. No unnecessary escapes
26520 !! options
26521 parsoid=html2wt
26522 !! html/parsoid
26523 <p>bar <span>[[foo]]</span>
26524 </p><p>=bar <span>[[foo]]</span>
26525 </p><p>[[bar <span>[[foo]]</span>
26526 </p><p>]]bar <span>[[foo]]</span>
26527 </p><p>=bar <span>foo]]</span>=
26528 </p>
26529 !! wikitext
26530 bar <span><nowiki>[[foo]]</nowiki></span>
26531
26532 =bar <span><nowiki>[[foo]]</nowiki></span>
26533
26534 [[bar <span><nowiki>[[foo]]</nowiki></span>
26535
26536 ]]bar <span><nowiki>[[foo]]</nowiki></span>
26537
26538 =bar <span>foo]]</span><nowiki>=</nowiki>
26539 !!end
26540
26541 #### ----------------------- PRE --------------------------
26542 !! test
26543 1. Leading whitespace in SOL context should be escaped
26544 !! options
26545 parsoid=html2wt
26546 !! html/parsoid
26547 <p> a</p>
26548
26549 <p> a</p>
26550
26551 <p> a(tab)</p>
26552
26553 <p> a
26554 <!--cmt-->
26555 a</p>
26556
26557 <p>a
26558 b</p>
26559
26560 <p>a
26561 b</p>
26562
26563 <p>a
26564 b</p>
26565 !! wikitext
26566 <nowiki> </nowiki>a
26567
26568 <nowiki> </nowiki> a
26569
26570 a(tab)
26571
26572 <nowiki> </nowiki> a
26573 <!--cmt-->
26574 <nowiki> </nowiki>a
26575
26576 a
26577 <nowiki> </nowiki>b
26578
26579 a
26580 b
26581
26582 a
26583 b
26584 !! html/php
26585 <p> a
26586 </p><p> a
26587 </p><p> a(tab)
26588 </p><p> a
26589 a
26590 </p><p>a
26591 b
26592 </p><p>a
26593 b
26594 </p><p>a
26595 b
26596 </p>
26597 !! end
26598
26599 !! test
26600 2. Leading whitespace in non-indent-pre contexts should not be escaped
26601 !! options
26602 parsoid=html2wt
26603 !! html/parsoid
26604 <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>
26605 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
26606 <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>
26607 b</span></li>
26608 </ol>
26609 !! wikitext
26610 foo <ref>''a''
26611 b</ref>
26612 <references />
26613 !! end
26614
26615 !! test
26616 3. Leading whitespace in indent-pre suppressing contexts should not be escaped
26617 !! options
26618 parsoid=html2wt
26619 !! html/parsoid
26620 <blockquote>
26621 <p>
26622 a
26623 <span>b</span>
26624 c</p>
26625 </blockquote>
26626 !! wikitext
26627 <blockquote>
26628 a
26629 <span>b</span>
26630 c
26631 </blockquote>
26632 !! end
26633
26634 !! test
26635 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
26636 !! options
26637 parsoid=html2wt
26638 !! html/parsoid
26639 <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>
26640 !! wikitext
26641 [[File:Foobar.jpg|thumb|caption]]
26642 !! end
26643
26644 !! test
26645 5. Nowiki escaping should account for indent-pres
26646 !! options
26647 parsoid=html2wt
26648 !! html/parsoid
26649 <pre>==foo==</pre>
26650 !! wikitext
26651 ==foo==
26652 !! end
26653
26654 !! test
26655 T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
26656 !! options
26657 parsoid=html2wt
26658 !! html/parsoid
26659 <pre>
26660 * foo
26661 * bar
26662 </pre>
26663 !! wikitext
26664 * foo
26665 * bar
26666 !! end
26667
26668 !! test
26669 Whitespace scrubbing in SOL position should account for SOL-sensitive wikitext markup
26670 !! options
26671 parsoid = {
26672 "modes": ["html2wt"],
26673 "scrubWikitext": true
26674 }
26675 !! html/parsoid
26676 <p> foo</p>
26677 <p> %foo</p>
26678 <p> *foo</p>
26679 <p> #foo</p>
26680 <p> =foo=</p>
26681 <p><link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid="{}"> *foo</p>
26682 <p> <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid="{}">*foo</p>
26683 <p> <!--boo-->*foo</p>
26684 <p><!--boo--> *foo</p>
26685 <p><!--a--> <!--b--> <!--c--> <!--d--> <!--e--> foo</p>
26686 <p><!--a--> <!--b--> <!--c--> <!--d--> <!--e--> *foo</p>
26687 !! wikitext
26688 foo
26689
26690 %foo
26691
26692 <nowiki/>*foo
26693
26694 <nowiki/>#foo
26695
26696 <nowiki/>=foo=
26697
26698 [[Category:Foo]]
26699 <nowiki/>*foo
26700
26701 [[Category:Foo]]
26702 <nowiki>*</nowiki>foo
26703
26704 <nowiki/><!--boo-->*foo
26705
26706 <!--boo--><nowiki/>*foo
26707
26708 <!--a--><!--b--><!--c--><!--d--><!--e-->foo
26709
26710 <!--a--><nowiki/><!--b--><!--c--><!--d--><!--e-->*foo
26711 !! end
26712
26713 #### --------------- Behavior Switches --------------------
26714
26715 !! test
26716 1. Valid behavior switches should be escaped
26717 !! options
26718 parsoid=html2wt
26719 !! html/parsoid
26720 __TOC__
26721 <i>__TOC__</i>
26722 !! wikitext
26723 <nowiki>__TOC__</nowiki>
26724 ''<nowiki>__TOC__</nowiki>''
26725 !! end
26726
26727 !! test
26728 2. Invalid behavior switches should not be escaped
26729 !! options
26730 parsoid=html2wt
26731 !! html/parsoid
26732 __TOO__
26733 __|__
26734 !! wikitext
26735 __TOO__
26736 __|__
26737 !! end
26738
26739 # We use indent-pre as an indirect way to test for sol-transparent behavior.
26740 !! test
26741 Behavior switches should be SOL-transparent
26742 !! options
26743 parsoid=html2wt
26744 !! html/parsoid
26745 <meta property="mw:PageProp/toc" />
26746
26747 <!-- this one's bogus -->
26748 <pre>__TOO__</pre>
26749
26750 <pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre>
26751
26752 <meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre>
26753 !! wikitext
26754 __TOC__
26755
26756 <!-- this one's bogus -->
26757 __TOO__
26758
26759 __TOC__ foo
26760
26761 __TOC__
26762 bar
26763 !! end
26764
26765 #### --------------- HTML tags ---------------
26766 #### 1. a tags
26767 #### 2. other tags
26768 #### 3. multi-line html tag
26769 #### 4. extension tags
26770 #### -----------------------------------------
26771 !! test
26772 1. a tags
26773 !! options
26774 parsoid=html2wt
26775 !! html/parsoid
26776 &lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
26777 !! wikitext
26778 <a href="http://google.com">google</a>
26779 !! end
26780
26781 !! test
26782 2. other tags
26783 !! options
26784 parsoid=html2wt
26785 !! html/parsoid
26786 <ul><li> &lt;div&gt;foo&lt;/div&gt;</li>
26787 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
26788 <li> &lt;td&gt;</li></ul>
26789
26790 !! wikitext
26791 * <nowiki><div>foo</div></nowiki>
26792 * <nowiki><div style="color:red">foo</div></nowiki>
26793 * <nowiki><td></nowiki>
26794 !! end
26795
26796 !! test
26797 3. multi-line html tag
26798 !! options
26799 parsoid=html2wt
26800 !! html/parsoid
26801 <p>&lt;div
26802 &gt;foo&lt;/div
26803 &gt;
26804 </p>
26805 !! wikitext
26806 <nowiki><div
26807 >foo</div
26808 ></nowiki>
26809 !! end
26810
26811 !! test
26812 4. extension tags
26813 !! options
26814 parsoid=html2wt
26815 !! html/parsoid
26816 <p>&lt;ref&gt;foo&lt;/ref&gt;
26817 </p><p>&lt;ref&gt;bar
26818 </p><p>baz&lt;/ref&gt;
26819 </p>
26820 !! wikitext
26821 <nowiki><ref>foo</ref></nowiki>
26822
26823 <nowiki><ref>bar</nowiki>
26824
26825 baz<nowiki></ref></nowiki>
26826 !! end
26827
26828 !! test
26829 Parsoid: newline inducing block nodes don't suppress <nowiki>
26830 !! options
26831 parsoid=html2wt
26832 !! html/parsoid
26833 a<h1>foo</h1>
26834 !! wikitext
26835 <nowiki> </nowiki>a
26836
26837 = foo =
26838 !! end
26839
26840 #### --------------- Others ---------------
26841 !! test
26842 Escaping nowikis
26843 !! options
26844 parsoid=html2wt
26845 !! html/parsoid
26846 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
26847 </p>
26848 !! wikitext
26849 &lt;nowiki&gt;foo&lt;/nowiki&gt;
26850 !! end
26851
26852 ## The quote-char in the input is necessary for triggering the bug
26853 !! test
26854 (T54035) Nowiki-escaping should not get tripped by " :" in text
26855 !! options
26856 parsoid=html2wt
26857 !! html/parsoid
26858 <p>foo's bar :</p>
26859 !! wikitext
26860 foo's bar :
26861 !! end
26862
26863 #----------- End of wikitext escaping tests --------------
26864
26865 !! test
26866
26867 Tag-like HTML structures are passed through as text
26868 !! wikitext
26869 <x y>
26870
26871 <x.y>
26872
26873 <x-y>
26874
26875 1>2
26876
26877 x<y
26878
26879 a>b
26880
26881 1<d e>f
26882 !! html
26883 <p>&lt;x y&gt;
26884 </p><p>&lt;x.y&gt;
26885 </p><p>&lt;x-y&gt;
26886 </p><p>1&gt;2
26887 </p><p>x&lt;y
26888 </p><p>a&gt;b
26889 </p><p>1&lt;d e&gt;f
26890 </p>
26891 !! end
26892
26893 !! test
26894 HTML tag with necessary entities in attributes
26895 !! wikitext
26896 <span title="&amp;amp;">foo</span>
26897 !! html
26898 <p><span title="&amp;amp;">foo</span>
26899 </p>
26900 !! end
26901
26902 !! test
26903 HTML tag with 'unnecessary' entity encoding in attributes
26904 !! wikitext
26905 <span title="&amp;">foo</span>
26906 !! html
26907 <p><span title="&amp;">foo</span>
26908 </p>
26909 !! end
26910
26911 !! test
26912 HTML tag with broken attribute value quoting
26913 !! options
26914 parsoid=wt2html,html2html
26915 !! wikitext
26916 <span title="Hello world>Foo</span>
26917 !! html/php
26918 <p><span title="Hello world">Foo</span>
26919 </p>
26920 !! html/parsoid
26921 <p><span title="Hello world">Foo</span></p>
26922 !! end
26923
26924 !! test
26925 Self-closed tag with broken attribute value quoting
26926 !! options
26927 parsoid=wt2html,html2html
26928 !! wikitext
26929 <div title="Hello world />Foo
26930 !! html/php+tidy
26931 <div title="Hello world"></div><p>Foo
26932 </p>
26933 !! html/parsoid
26934 <div title="Hello world " data-parsoid='{"stx":"html","selfClose":true}'></div><p>Foo</p>
26935 !! end
26936
26937 !! test
26938 Table with broken attribute value quoting
26939 !! options
26940 parsoid=wt2html,html2html
26941 !! wikitext
26942 {|
26943 | title="Hello world|Foo
26944 |}
26945 !! html/php
26946 <table>
26947 <tr>
26948 <td title="Hello world">Foo
26949 </td></tr></table>
26950
26951 !! html/parsoid
26952 <table>
26953 <tr>
26954 <td title="Hello world">Foo
26955 </td></tr></table>
26956
26957 !! end
26958
26959 !! test
26960 Table with broken attribute value quoting on consecutive lines
26961 !! options
26962 parsoid=wt2html,html2html
26963 !! wikitext
26964 {|
26965 | title="Hello world|Foo
26966 | style="color:red|Bar
26967 |}
26968 !! html/php
26969 <table>
26970 <tr>
26971 <td title="Hello world">Foo
26972 </td>
26973 <td style="color:red">Bar
26974 </td></tr></table>
26975
26976 !! html/parsoid
26977 <table><tbody>
26978 <tr>
26979 <td title="Hello world">Foo
26980 </td><td style="color: red">Bar
26981 </td></tr></tbody></table>
26982
26983 !! end
26984
26985 !!test
26986 Accept empty td cell attribute
26987 !! wikitext
26988 {|
26989 | align="center" |foo|| |
26990 |}
26991 !! html
26992 <table>
26993 <tr>
26994 <td align="center">foo</td>
26995 <td>
26996 </td></tr></table>
26997
26998 !!end
26999
27000 !!test
27001 Non-empty attributes in th-cells
27002 !! wikitext
27003 {|
27004 !Foo!! style="color: red" |Bar
27005 |}
27006 !! html
27007 <table>
27008 <tr>
27009 <th>Foo</th>
27010 <th style="color: red">Bar
27011 </th></tr></table>
27012
27013 !!end
27014
27015 !!test
27016 Accept empty attributes in th-cells
27017 !! wikitext
27018 {|
27019 !|foo!!|bar
27020 |}
27021 !! html
27022 <table>
27023 <tr>
27024 <th>foo</th>
27025 <th>bar
27026 </th></tr></table>
27027
27028 !!end
27029
27030 !!test
27031 Empty table rows go away
27032 !! wikitext
27033 {|
27034 |Hello
27035 |there
27036 |- class="foo"
27037 |-
27038 |}
27039 !! html
27040 <table>
27041 <tr>
27042 <td>Hello
27043 </td>
27044 <td>there
27045 </td></tr>
27046
27047 </table>
27048
27049 !! end
27050
27051 ###
27052 ### Parsoid-centric tests for testing RTing of inter-element separators
27053 ### Edge cases not tested by existing parser tests and specific to
27054 ### Parsoid-specific serialization strategies.
27055 ###
27056
27057 !!test
27058 RT-ed inter-element separators should be valid separators
27059 !! wikitext
27060 {|
27061 |- [[foo]]
27062 |}
27063 !! html/php
27064 <table>
27065
27066 </table>
27067
27068 !! html/parsoid
27069 <table>
27070 <tbody><tr class='mw-empty-elt' data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
27071 </tbody></table>
27072 !!end
27073
27074 # Parsoid-only test of a DOM pass
27075 !!test
27076 Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out
27077 !! wikitext
27078 {|
27079 |<small>foo
27080 bar
27081 |}
27082
27083 {|
27084 |<small>foo<small>
27085 |}
27086 !! html/parsoid
27087 <table>
27088 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo
27089 <p>bar</p></small></td></tr>
27090 </tbody></table>
27091
27092 <table>
27093 <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>
27094 </tbody></table>
27095 !!end
27096
27097 # Note that the "style" attribute is really a template parameter here.
27098 # The = would have to be {{=}} if you wanted the literal.
27099 !!test
27100 Empty TD followed by TD with tpl-generated attribute
27101 !! wikitext
27102 {|
27103 |-
27104 |
27105 |{{echo|style='color:red'}}|foo
27106 |}
27107 !! html
27108 <table>
27109
27110 <tr>
27111 <td>
27112 </td>
27113 <td>foo
27114 </td></tr></table>
27115
27116 !!end
27117
27118 !!test
27119 Indented table with an empty td
27120 !! wikitext
27121 {|
27122 |-
27123 |
27124 |foo
27125 |}
27126 !! html
27127 <table>
27128
27129 <tr>
27130 <td>
27131 </td>
27132 <td>foo
27133 </td></tr></table>
27134
27135 !!end
27136
27137 ## We have some newline diffs RT-ing this edge case
27138 ## and it is not important enough -- we seem to be emitting
27139 ## at most 2 newlines after a </tr> and this is unrelated to
27140 ## the issue from T85627 that this is testing.
27141 !!test
27142 Indented table with blank lines in between (T85627)
27143 !! options
27144 parsoid=wt2html
27145 !! wikitext
27146 {|
27147 |foo
27148
27149
27150 |}
27151 !! html
27152 <table>
27153
27154 <tr>
27155 <td>foo
27156 </td></tr></table>
27157
27158 !!end
27159
27160 !!test
27161 Indented block & table
27162 !! wikitext
27163 <div>foo</div>
27164 {|
27165 |foo
27166 |}
27167 !! html/php
27168 <div>foo</div>
27169 <table>
27170 <tr>
27171 <td>foo
27172 </td></tr></table>
27173
27174 !! html/parsoid
27175 <div data-parsoid='{"stx":"html"}'>foo</div>
27176 <table><tbody>
27177 <tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>foo</td></tr>
27178 </tbody></table>
27179 !!end
27180
27181 !! test
27182 Indent and comment before table row
27183 !! wikitext
27184 {|
27185 <!--hi-->|-
27186 |there
27187 |}
27188 !! html/php
27189 <table>
27190
27191 <tr>
27192 <td>there
27193 </td></tr></table>
27194
27195 !! html/parsoid
27196 <table>
27197 <!--hi--><tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
27198 <td data-parsoid='{"autoInsertedEnd":true}'> there</td></tr>
27199 </tbody></table>
27200 !! end
27201
27202 # Parsoid-specific since PHP parser doesn't handle this mixed tbl-wikitext
27203 !!test
27204 Empty TR followed by a template-generated TR
27205 !!options
27206 parsoid
27207 !! wikitext
27208 {|
27209 |-
27210 {{echo|<tr><td>foo</td></tr>}}
27211 |}
27212 !! html
27213 <table>
27214 <tbody>
27215 <tr class='mw-empty-elt'></tr>
27216 <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}}]}'>
27217 <td>foo</td></tr>
27218 </tbody></table>
27219 !!end
27220
27221 ## PHP and parsoid output differ for this, and since this is primarily
27222 ## for testing Parsoid's serializer, marking this Parsoid only
27223 !!test
27224 Empty TR followed by mixed-ws-comment line should RT correctly
27225 !!options
27226 parsoid
27227 !! wikitext
27228 {|
27229 |-
27230 <!--c-->
27231 |-
27232 <!--c--> <!--d-->
27233 |}
27234 !! html
27235 <table>
27236 <tbody>
27237 <tr class='mw-empty-elt'></tr>
27238 <!--c-->
27239 <tr>
27240 <!--c--> </tr><!--d-->
27241 </tbody></table>
27242
27243 !!end
27244
27245 !!test
27246 Multi-line image caption generated by templates with/without trailing newlines
27247 !! wikitext
27248 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]]
27249 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]]
27250 !! html/parsoid
27251 <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>
27252 <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>
27253 !!end
27254
27255 !! test
27256 New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly
27257 !! options
27258 parsoid=html2wt
27259 !! html/parsoid
27260 <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>
27261
27262 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{}'/><h1>new heading</h1>
27263 !! wikitext
27264 <includeonly>foo</includeonly>
27265 new para
27266
27267 [[Category:Foo]]
27268
27269 = new heading =
27270 !! end
27271
27272 ## PHP emits broken html for this, and since this is primarily
27273 ## a Parsoid serializer test, marking this Parsoid only
27274 !!test
27275 Improperly nested inline or quotes tags with whitespace in between
27276 !! wikitext
27277 <span> <s>x</span> </s>
27278 ''' ''x''' ''
27279 !! html/parsoid
27280 <p><span> <s>x</s></span><s> </s>
27281 <b> <i>x</i></b><i> </i>
27282 </p>
27283 !!end
27284
27285 !!test
27286 Encapsulate protected attributes from wt
27287 !! wikitext
27288 <div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
27289
27290 {| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true"
27291 |ok
27292 |}
27293 !! html/parsoid
27294 <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>
27295
27296 <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">
27297 <tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'>ok</td></tr>
27298 </tbody></table>
27299 !!end
27300
27301 ## Currently the p-wrapper is fragile in how it adds / removes transformations.
27302 ## Having nested or stray pre tags results in the attempt to add duplicates,
27303 ## causing an assertion fail. This test tries to prevent that situation.
27304 !!test
27305 Ensure ParagraphWrapper can deal with stray closing pre tags
27306 !!options
27307 parsoid=wt2html
27308 !! wikitext
27309 plain text</pre>
27310 !! html/parsoid
27311 plain text
27312 !!end
27313
27314 !! test
27315 1. Ensure fostered text content is wrapped in element nodes
27316 !! options
27317 parsoid=wt2html
27318 !! wikitext
27319 <table>hi</table><table>ho</table>
27320 !! html/php+tidy
27321 hi<table></table>ho<table></table>
27322 !! html/parsoid
27323 <span data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>hi</span><table data-parsoid='{"stx":"html"}'></table><span data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>ho</span><table data-parsoid='{"stx":"html"}'></table>
27324 !! end
27325
27326 !! test
27327 2. Ensure fostered text content is wrapped in element nodes (traps regressions around fostered marker on the element getting lost)
27328 !! options
27329 parsoid=wt2html,wt2wt
27330 !! wikitext
27331 <table>
27332 <tr> || ||
27333 <td> a
27334 </table>
27335 !! html/php+tidy
27336 || ||
27337 <table>
27338 <tbody><tr><td> a
27339 </td></tr></tbody></table>
27340 !! html/parsoid
27341 <span data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'> || ||
27342 </span><table data-parsoid='{"stx":"html"}'>
27343 <tbody><tr data-parsoid='{"stx":"html","autoInsertedEnd":true}'><td data-parsoid='{"stx":"html","autoInsertedEnd":true}'> a
27344 </td></tr></tbody></table>
27345 !! end
27346
27347 !! test
27348 Encapsulation properly handles null DSR information from foster box
27349 !! options
27350 parsoid=wt2html,wt2wt
27351 !! wikitext
27352 {{echo|<table>foo<tr><td>bar</td></tr></table>}}
27353 !! html/parsoid
27354 <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>
27355 !! end
27356
27357 !! test
27358 1. Encapsulate foster-parented transclusion content
27359 !! options
27360 parsoid=wt2wt,wt2html
27361 !! wikitext
27362 <table>{{echo|foo<tr><td>bar</td></tr>}}</table>
27363 !! html/php+tidy
27364 foo<table><tbody><tr><td>bar</td></tr></tbody></table>
27365 !! html/parsoid
27366 <span about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE_html","pi":[[{"k":"1"}]]}' data-mw='{"parts":["&lt;table>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo&lt;tr>&lt;td>bar&lt;/td>&lt;/tr>"}},"i":0}},"&lt;/table>"]}'>foo</span><table about="#mwt2" data-parsoid='{"stx":"html}'><tbody><tr><td>bar</td></tr></tbody></table>
27367 !! end
27368
27369 !! test
27370 2. Encapsulate foster-parented transclusion content
27371 !! options
27372 parsoid=wt2wt,wt2html
27373 !! wikitext
27374 <table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table>
27375 !! html/parsoid
27376 <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>
27377 <table>
27378 <tbody>
27379 <tr>
27380 <td>bar</td>
27381 </tr>
27382 </tbody>
27383 </table>
27384 !! end
27385
27386 !! test
27387 3. Encapsulate foster-parented transclusion content
27388 !! options
27389 parsoid=wt2wt,wt2html
27390 !! wikitext
27391 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
27392 !! html/parsoid
27393 <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;]}">
27394 <p>foo</p>
27395 </div>
27396 <table>
27397 <tbody>
27398 <tr>
27399 <td>bar</td>
27400 </tr>
27401 </tbody>
27402 </table>
27403 !! end
27404
27405 !! test
27406 4. Encapsulate foster-parented transclusion content
27407 !! options
27408 parsoid=wt2wt,wt2html
27409 !! wikitext
27410 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
27411 !! html/parsoid
27412 <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;]}">
27413 <p>foo</p>
27414 </div>
27415 <table>
27416 <tbody>
27417 <tr>
27418 <td>bar</td>
27419 </tr>
27420 </tbody>
27421 </table>
27422 !! end
27423
27424 !! test
27425 5. Encapsulate foster-parented transclusion content
27426 !!options
27427 parsoid=wt2wt,wt2html
27428 !! wikitext
27429 <table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table>
27430 !! html/php+tidy
27431 foo<table><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table>
27432 !! html/parsoid
27433 <span about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE_html","pi":[[{"k":"1"}]]}' data-mw='{"parts":["&lt;table>&lt;tr>&lt;td>&lt;div>&lt;p>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo&lt;/p>&lt;/div>&lt;/td>foo"}},"i":0}},"&lt;/tr>&lt;/table>"]}'>foo</span><table about="#mwt2" data-parsoid='{"stx":"html"}'><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table>
27434 !! end
27435
27436 !! test
27437 6. Encapsulate foster-parented transclusion content
27438 !! options
27439 parsoid=wt2wt,wt2html
27440 !! wikitext
27441 <table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p>
27442 !! html/php+tidy
27443 foo<table><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table><p>ok</p>
27444 !! html/parsoid
27445 <span about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE_html","pi":[[{"k":"1"}]]}' data-mw='{"parts":["&lt;table>&lt;tr>&lt;td>&lt;div>&lt;p>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo&lt;/p>&lt;/div>&lt;/td>foo&lt;/tr>&lt;/table>"}},"i":0}}]}'>foo</span><table about="#mwt2" data-parsoid='{"stx":"html"}'><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table><p data-parsoid='{"stx":"html"}'>ok</p>
27446 !! end
27447
27448 !! test
27449 7. Encapsulate foster-parented transclusion content
27450 !!options
27451 parsoid=wt2wt,wt2html
27452 !! wikitext
27453 <table>{{echo|<p>foo</p>}}<td>bar</td></table>
27454 !! html/parsoid
27455 <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>
27456 <table>
27457 <tbody>
27458 <tr>
27459 <td>bar</td>
27460 </tr>
27461 </tbody>
27462 </table>
27463 !! end
27464
27465 # Note that the wt is broken on purpose: the = should be {{=}} if you
27466 # don't want it to be a template parameter key.
27467 !! test
27468 8. Encapsulate foster-parented transclusion content
27469 !! options
27470 parsoid=wt2wt,wt2html
27471 !! wikitext
27472 {{echo|a
27473 }}{|{{echo|style='color:red'}}
27474 |-
27475 |b
27476 |}
27477 !! html/php+tidy
27478 <p>a
27479 </p>
27480 <table>
27481
27482 <tbody><tr>
27483 <td>b
27484 </td></tr></tbody></table>
27485 !! html/parsoid
27486 <p about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n"}},"i":0}}]}'>a</p><span about="#mwt1">
27487 </span><span about="#mwt3" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE","pi":[[{"k":"style","named":true}]]}' data-mw='{"parts":["{|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"style":{"wt":"&apos;color:red&apos;"}},"i":0}},"\n|-\n|b\n|}"]}'>{{{1}}}</span><table about="#mwt3">
27488 <tbody><tr>
27489 <td>b
27490 </td></tr></tbody></table>
27491 !! end
27492
27493 !! test
27494 9. Encapsulate foster-parented transclusion content
27495 !!options
27496 parsoid=wt2wt,wt2html
27497 !! wikitext
27498 <table>{{echo|hi</table>hello}}
27499 !! html/php+tidy
27500 hi<table></table><p>hello
27501 </p>
27502 !! html/parsoid
27503 <span about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE_html","pi":[[{"k":"1"}]]}' data-mw='{"parts":["&lt;table>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi&lt;/table>hello"}},"i":0}}]}'>hi</span><table about="#mwt2"></table><p about="#mwt2">hello</p>
27504 !! end
27505
27506 !! test
27507 Table in fosterable position
27508 !!options
27509 parsoid=wt2html
27510 !! wikitext
27511 {{OpenTable}}
27512 <div>
27513 {|
27514 |}
27515 </div>
27516 |}
27517 !! html/parsoid
27518 <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">
27519 </span>
27520 <table about="#mwt1" data-parsoid='{"autoInsertedEnd":true}'></table>
27521
27522 <table>
27523 </table>
27524 !! end
27525
27526 # Parsoid only for T66747
27527 !! test
27528 Properly encapsulate empty-content transclusions in fosterable positions
27529 !! wikitext
27530 <table>
27531 {{#if:|
27532 <td>foo</td>
27533 }}
27534 </table>
27535 !! html/parsoid
27536 <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"}]]}'>
27537
27538 </table>
27539 !! end
27540
27541 !! test
27542 Always encapsulate foster box when template range is expanded to table
27543 !! options
27544 parsoid=wt2wt
27545 !! wikitext
27546 {|
27547 hello
27548 {{OpenTable}}
27549 |}
27550 !! html/parsoid
27551
27552 !! end
27553
27554 !! test
27555 T115289: Unclosed table
27556 !! wikitext
27557 {{echo|<table>}}<!--c-->[[Category:Two]]
27558 !! html/parsoid
27559 <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>
27560 !! end
27561
27562 !! test
27563 T115289: Don't migrate newlines out of tables with fostered content
27564 !! wikitext
27565 <table><td></td>{{echo|<tr>[[Category:One]]}}<!--c-->[[Category:Two]]
27566 !! html/parsoid
27567 <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>
27568 !! end
27569
27570 !! test
27571 T73074: More fostering fun
27572 !! wikitext
27573 <table><td></td>{{echo|<tr>}}<!--c-->[[Category:Two]]
27574 !! html/parsoid
27575 <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>
27576 !! end
27577
27578 !!test
27579 Support <object> element with .data attribute
27580 !!options
27581 parsoid=html2wt
27582 !! html/parsoid
27583 <object data="test.swf"></object>
27584 !! wikitext
27585 <object data="test.swf"></object>
27586 !!end
27587
27588 !! test
27589 Don't block XML namespace declaration
27590 !! wikitext
27591 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span>
27592 !! html/php
27593 <p><span xmlns:dct="http&#58;//purl.org/dc/terms/" property="dct:title">MediaWiki</span>
27594 </p>
27595 !! html/parsoid
27596 <p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p>
27597 !! end
27598
27599 # -----------------------------------------------------------------
27600 # The following section of tests are primarily to spec requirements
27601 # around Parsoid's serialization (old, new, edited content)
27602 #
27603 # All these tests are marked Parsoid html2wt and html2html only
27604 # ----------------------------------------------------------------
27605
27606 !! test
27607 Ignore rel attribute in a-tags during serialization to url-links
27608 !! options
27609 parsoid=html2wt
27610 !! html/parsoid
27611 <a href='http://en.wikipedia.org/wiki/Foobar'>http://en.wikipedia.org/wiki/Foobar</a>
27612 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:ExtLink'>http://en.wikipedia.org/wiki/Foobar</a>
27613 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:WikiLink'>http://en.wikipedia.org/wiki/Foobar</a>
27614 !! wikitext
27615 http://en.wikipedia.org/wiki/Foobar
27616 http://en.wikipedia.org/wiki/Foobar
27617 http://en.wikipedia.org/wiki/Foobar
27618 !! end
27619
27620 # 'mi' is a localinterwiki prefix as well as a language
27621 !! test
27622 Serialize interwiki links pointing to the current wiki as plain wiki links (T67869)
27623 !! options
27624 parsoid=html2wt
27625 !! html/parsoid
27626 <p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p>
27627 !! wikitext
27628 [[Foo]]
27629 !! end
27630
27631 !! test
27632 Parsoid should accept interwiki shortcuts
27633 !! options
27634 parsoid=html2wt
27635 !! html/parsoid
27636 <p><a rel='mw:WikiLink' href='./fr:Foo'>Foo</a>
27637 <a rel='mw:ExtLink' href='./fr:Foo'>Foo</a>
27638 <a href='./fr:Foo'>Foo</a></p>
27639 <p><a rel='mw:WikiLink' href='fr%3AFoo'>Foo</a>
27640 <a rel='mw:ExtLink' href='fr%3AFoo'>Foo</a>
27641 <a href='fr%3AFoo'>Foo</a></p>
27642 <p><a href='FR%3AFoo'>Foo</a>
27643 <a href='./FR:Foo'>Foo</a></p>
27644 !! wikitext
27645 [[:fr:Foo|Foo]]
27646 [[:fr:Foo|Foo]]
27647 [[:fr:Foo|Foo]]
27648
27649 [[:fr:Foo|Foo]]
27650 [[:fr:Foo|Foo]]
27651 [[:fr:Foo|Foo]]
27652
27653 [[:fr:Foo|Foo]]
27654 [[:fr:Foo|Foo]]
27655 !! end
27656
27657 !! test
27658 Parsoid should not accept invalid interwiki shortcuts
27659 !! options
27660 parsoid=html2wt
27661 !! html/parsoid
27662 <p><a rel='mw:WikiLink' href='news:Foo'>Foo</a>
27663 <a rel='mw:ExtLink' href='news:Foo'>Foo</a>
27664 <a href='news:Foo'>Foo</a></p>
27665 !! wikitext
27666 [news:Foo Foo]
27667 [news:Foo Foo]
27668 [news:Foo Foo]
27669 !! end
27670
27671 # See T93839
27672 !! test
27673 New wikilinks should be serialized properly
27674 !! options
27675 parsoid=html2wt
27676 !! html/parsoid
27677 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
27678 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
27679 <a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a>
27680 <a href="http://en.wikipedia.org/wiki/Foo">http://en.wikipedia.org/wiki/Foo</a>
27681 <a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a>
27682 !! wikitext
27683 [[Foo]]
27684 [[Foo]]
27685 [[:en:Foo|//en.wikipedia.org/wiki/Foo]]
27686 http://en.wikipedia.org/wiki/Foo
27687 [[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]]
27688 !! end
27689
27690 !! test
27691 New wiki links (href variations)
27692 !! options
27693 parsoid=html2wt
27694 !! html/parsoid
27695 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
27696 <a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a>
27697 <a rel="mw:WikiLink" href="Foo bar">Foo_bar</a>
27698 <a rel="mw:WikiLink" href="./Toxine_bact%C3%A9rienne">Toxine bactérienne</a>
27699 !! wikitext
27700 [[Foo_bar]]
27701 [[Foo_bar]]
27702 [[Foo_bar]]
27703 [[Toxine bactérienne]]
27704 !! end
27705
27706 !! test
27707 New wiki links (content string variations)
27708 !! options
27709 parsoid=html2wt
27710 !! html/parsoid
27711 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
27712 <a rel="mw:WikiLink" href="./Foo_bar">Foo bar</a>
27713 <a rel="mw:WikiLink" href="./Foo_bar">./Foo_bar</a>
27714 !! wikitext
27715 [[Foo_bar]]
27716 [[Foo bar]]
27717 [[Foo_bar|./Foo_bar]]
27718 !! end
27719
27720 !! test
27721 New category links (href variations)
27722 !! options
27723 parsoid=html2wt
27724 !! html/parsoid
27725 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" />
27726 <link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" />
27727 <link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" />
27728 !! wikitext
27729 [[Category:Toxine bactérienne]]
27730 [[Category:Toxine bactérienne]]
27731 [[Category:Toxine bactérienne]]
27732 !! end
27733
27734 !! test
27735 New sol transparent links don't need indent-pre nowiki protection
27736 !! options
27737 parsoid=html2wt
27738 language=de
27739 !! html/parsoid
27740 <link rel="mw:PageProp/redirect" href="./Main_Page">
27741 <!-- this is good --> <link rel="mw:PageProp/Category" href="./Category:Good" />
27742 <!-- this is great --> <link rel="mw:PageProp/Category" href="./Kategorie:Great" />
27743 !! wikitext
27744 #WEITERLEITUNG [[Main Page]]
27745 <!-- this is good --> [[Category:Good]]
27746 <!-- this is great --> [[Kategorie:Great]]
27747 !! end
27748
27749 !! test
27750 New interlanguage links (href variations)
27751 !! options
27752 parsoid=html2wt
27753 !! html/parsoid
27754 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" />
27755 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" />
27756 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" />
27757 !! wikitext
27758 [[es:Toxine bactérienne]]
27759 [[es:Toxine_bactérienne]]
27760 [[es:Toxine_bactérienne]]
27761 !! end
27762
27763 !! test
27764 Image: Modifying size of an image (1)
27765 !! options
27766 parsoid={
27767 "modes": ["wt2wt"],
27768 "changes": [
27769 ["img[height]", "attr", "height", "22"],
27770 ["img[width]", "attr", "width", "200"]
27771 ]
27772 }
27773 !! wikitext
27774 [[Image:Foobar.jpg|230x230px]]
27775 !! wikitext/edited
27776 [[Image:Foobar.jpg|200x200px]]
27777 !!end
27778
27779 !! test
27780 Image: Modifying size of an image (2)
27781 !! options
27782 parsoid={
27783 "modes": ["wt2wt"],
27784 "changes": [
27785 ["img[height]", "attr", "height", "100"],
27786 ["img[width]", "attr", "width", "500"]
27787 ]
27788 }
27789 !! wikitext
27790 [[Image:Foobar.jpg|230x230px]]
27791 !! wikitext/edited
27792 [[Image:Foobar.jpg|500x500px]]
27793 !!end
27794
27795 # Change in size is ignored so long as class='mw-default-size'
27796 !! test
27797 Image: Modifying size of an image (3)
27798 !! options
27799 parsoid={
27800 "modes": ["wt2wt"],
27801 "changes": [
27802 ["figure[class]", "removeClass", "mw-default-size"],
27803 ["figure img", "attr", "height", "19"],
27804 ["figure img", "attr", "width", "170"]
27805 ]
27806 }
27807 !! wikitext
27808 [[Image:Foobar.jpg|thumb]]
27809 !! wikitext/edited
27810 [[Image:Foobar.jpg|thumb|170x170px]]
27811 !!end
27812
27813 !! test
27814 Image: Modifying alignment of an image (T50665)
27815 !! options
27816 parsoid={
27817 "modes": ["wt2wt"],
27818 "changes": [
27819 ["figure[class]", "removeClass", "mw-halign-right"],
27820 ["figure[class]", "addClass", "mw-halign-left"]
27821 ]
27822 }
27823 !! wikitext
27824 [[Image:Foobar.jpg|thumb|caption|right]]
27825 !! wikitext/edited
27826 [[Image:Foobar.jpg|thumb|caption|left]]
27827 !! end
27828
27829 !! test
27830 Image: Modifying mw-default-size of an frameless image (T64805)
27831 !! options
27832 parsoid={
27833 "modes": ["wt2wt"],
27834 "changes": [
27835 ["figure.mw-default-size", "removeClass", "mw-default-size"]
27836 ]
27837 }
27838 !! wikitext
27839 [[Image:Foobar.jpg|frameless|right]]
27840 !! wikitext/edited
27841 [[Image:Foobar.jpg|frameless|right|220x220px]]
27842 !! end
27843
27844 !! test
27845 Image: Modifying valign of an image (T51221)
27846 !! options
27847 parsoid={
27848 "modes": ["wt2wt"],
27849 "changes": [
27850 ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
27851 ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
27852 ]
27853 }
27854 !! wikitext
27855 [[File:Foobar.jpg|20px|middle]]
27856 !! wikitext/edited
27857 [[File:Foobar.jpg|20px|text-top]]
27858 !! end
27859
27860 !! test
27861 Image: Modifying alt attribute of an image (T58400)
27862 !! options
27863 parsoid={
27864 "modes": ["wt2wt"],
27865 "changes": [
27866 ["img[alt]", "attr", "alt", "some alternate edited text"]
27867 ]
27868 }
27869 !! wikitext
27870 [[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
27871 !! wikitext/edited
27872 [[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
27873 !!end
27874
27875 !! test
27876 Image: Modifying caption of an image
27877 !! options
27878 parsoid={
27879 "modes": ["wt2wt"],
27880 "changes": [
27881 ["figcaption", "text", "new caption"]
27882 ]
27883 }
27884 !! wikitext
27885 [[Image:Foobar.jpg|thumb|original caption]]
27886 !! wikitext/edited
27887 [[Image:Foobar.jpg|thumb|new caption]]
27888 !!end
27889
27890 !! test
27891 Image: empty alt attribute (T50924)
27892 !! options
27893 parsoid
27894 !! wikitext
27895 [[File:Foobar.jpg|thumb|alt=|bar]]
27896 !! html
27897 <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>
27898 !! end
27899
27900 !! test
27901 Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
27902 !! options
27903 parsoid=html2wt
27904 language=ar
27905 disabled
27906 !! html/parsoid
27907 <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>
27908 !! wikitext
27909 [[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
27910 !! end
27911
27912 !! test
27913 Image: Block level image should have \n before and after
27914 !! wikitext
27915 123
27916 [[File:Foobar.jpg|right|thumb|150x150px]]
27917 456
27918 !! html/parsoid
27919 <p>123</p>
27920 <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>
27921 <p>456</p>
27922 !! end
27923
27924 !! test
27925 Image: New block level image should have \n before and after (existing content)
27926 !! wikitext
27927 123
27928 [[File:Foobar.jpg|right|thumb|150x150px]]
27929 456
27930 !! html/parsoid
27931 <p>123</p>
27932 <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>
27933 <p>456</p>
27934 !! end
27935
27936 !! test
27937 Image: upright option (parsoid)
27938 !! wikitext
27939 [[File:Foobar.jpg|thumb|upright|caption]]
27940 [[File:Foobar.jpg|thumb|upright=0.5|caption]]
27941 [[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]]
27942 !! html/parsoid
27943 <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>
27944 <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>
27945 <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>
27946 !! end
27947
27948 !! test
27949 Image: upright option is ignored on inline and frame images (parsoid)
27950 !! wikitext
27951 [[File:Foobar.jpg|500x500px|upright=0.5|caption]]
27952 !! html/parsoid
27953 <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>
27954 !! end
27955
27956 !! test
27957 Image: in template parameter with empty parameter
27958 !! wikitext
27959 {{echo|[[File:Foobar.jpg|link=]]}}
27960 !! html/parsoid
27961 <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>
27962 !! end
27963
27964 !! test
27965 Image: from basic HTML (1)
27966 !! options
27967 parsoid=html2wt
27968 !! html/parsoid
27969 <span typeof="mw:Image">
27970 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
27971 </span>
27972 !! wikitext
27973 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
27974 !! end
27975
27976 !! test
27977 Image: from basic HTML (2)
27978 !! options
27979 parsoid=html2wt
27980 !! html/parsoid
27981 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
27982 !! wikitext
27983 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
27984 !! end
27985
27986 !! test
27987 Image: from basic HTML (3)
27988 !! options
27989 parsoid=html2wt
27990 !! html/parsoid
27991 <a href="Main"><img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"></a>
27992 !! wikitext
27993 [[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
27994 !! end
27995
27996 !! test
27997 Image: from basic HTML (4)
27998 !! options
27999 parsoid=html2wt
28000 !! html/parsoid
28001 <img src="./File:Foobar.jpg">
28002 !! wikitext
28003 [[File:Foobar.jpg|link=]]
28004 !! end
28005
28006 !! test
28007 Image: Invalid title as link
28008 !! wikitext
28009 [[File:Foobar.jpg|link=<]]
28010 !! html/php
28011 <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>
28012 </p>
28013 !! html/parsoid
28014 <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>
28015 !! end
28016
28017 !! test
28018 Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
28019 !! options
28020 parsoid=html2wt
28021 !! html/parsoid
28022 <ul>
28023 <li><p>foo</p></li>
28024 </ul>
28025 !! wikitext
28026 * foo
28027 !! end
28028
28029 !! test
28030 Lists: Serialize correctly even when list tags has unneeded whitespace between tags
28031 !! options
28032 parsoid=html2wt
28033 !! html/parsoid
28034 <ul> <li>foo</li></ul>
28035 !! wikitext
28036 * foo
28037 !! end
28038
28039 !! test
28040 Don't strip leading whitespace when handling indent-pre suppressing tags
28041 !! options
28042 parsoid=html2wt
28043 !! html/parsoid
28044 <table>
28045 <tr><td> indented row</td></tr>
28046 </table>
28047 <blockquote><p>
28048 <b>This is very bold of you!</b>
28049 </p>
28050 <table><tr><td>
28051 indented cell (no pre-wrapping!)
28052 </td></tr></table>
28053 </blockquote>
28054 <p>foo</p>
28055 <div>bar</div>
28056 !! wikitext
28057 {|
28058 | indented row
28059 |}
28060 <blockquote>
28061 '''This is very bold of you!'''
28062
28063 {|
28064 |
28065 indented cell (no pre-wrapping!)
28066 |}
28067 </blockquote>
28068 foo
28069 <div>bar</div>
28070 !! end
28071
28072 !! test
28073 Nowiki-wrap leading whitespace when handling indent-pre inducing tags
28074 !! options
28075 parsoid=html2wt
28076 !! html/parsoid
28077 <p>foo</p>
28078 <span>bar</span>
28079
28080 <span>foo2
28081 </span>bar2
28082
28083 <div>foo</div>
28084 <span>bar</span>
28085
28086 <div>
28087 <span>foo</span>
28088 </div>
28089 !! wikitext
28090 foo
28091
28092 <span>bar</span>
28093
28094 <span>foo2
28095 <nowiki> </nowiki></span>bar2
28096
28097 <div>foo</div>
28098 <nowiki> </nowiki><span>bar</span>
28099
28100 <div>
28101 <nowiki> </nowiki><span>foo</span>
28102 </div>
28103 !! end
28104
28105 !! test
28106 Lists: Dont insert newlines in a serialized list item.
28107 !! options
28108 parsoid=html2wt
28109 !! html/parsoid
28110 <ul><li>a<br>b</li><li>c</li></ul>
28111 !! wikitext
28112 * a<br />b
28113 * c
28114 !! end
28115
28116 !! test
28117 1. Headings: Force sol-transparent links and behavior switches to serialize before/after
28118 !! options
28119 parsoid={
28120 "modes": ["html2wt"],
28121 "scrubWikitext": false
28122 }
28123 !! html/parsoid
28124 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
28125 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
28126
28127 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
28128 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
28129
28130 <h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2>
28131
28132 <h2><meta property="mw:PageProp/toc" /> ok</h2>
28133 !! wikitext
28134 == hello there [[Category:A1]] ==
28135
28136 == [[Category:A2]] hi pal ==
28137
28138 == <!--foo--> [[Category:A3]] how goes it ==
28139
28140 == it goes well [[Category:A4]] <!--bar--> ==
28141
28142 ==howdy [[Category:A5]]==
28143
28144 == __TOC__ ok ==
28145 !! end
28146
28147 !! test
28148 2. Headings: Force sol-transparent links and behavior switches to serialize before/after
28149 !! options
28150 parsoid={
28151 "modes": ["html2wt"],
28152 "scrubWikitext": true
28153 }
28154 !! html/parsoid
28155 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
28156 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
28157
28158 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
28159 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
28160
28161 <h2><meta property="mw:PageProp/toc" /> ok</h2>
28162 !! wikitext
28163 == hello there ==
28164 [[Category:A1]]
28165 [[Category:A2]]
28166
28167 == hi pal ==
28168
28169 <!--foo-->[[Category:A3]]
28170
28171 == how goes it ==
28172
28173 == it goes well ==
28174 [[Category:A4]] <!--bar-->
28175
28176 __TOC__
28177
28178 == ok ==
28179 !! end
28180
28181 !! test
28182 Headings: Don't hoist metas that come from templates
28183 !! options
28184 parsoid={
28185 "modes": ["html2wt"],
28186 "scrubWikitext": true
28187 }
28188 !! html/parsoid
28189 <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>
28190 !! wikitext
28191 == {{echo|foo [[Category:Foo]]}} ==
28192 !! end
28193
28194 !! test
28195 Headings: Category in ref isn't hoisted
28196 !! options
28197 parsoid={
28198 "modes": ["html2wt"],
28199 "scrubWikitext": true
28200 }
28201 !! html/parsoid
28202 <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>
28203
28204 <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>
28205 !! wikitext
28206 == foo <ref>bar
28207 [[Category:Baz]] </ref> ==
28208
28209 <references />
28210 !! end
28211
28212 !! test
28213 Parsoid: Serialize positional parameters with = in them as named parameter
28214 !! options
28215 parsoid=html2wt
28216 !! html/parsoid
28217 <p about="#mwt1" typeof="mw:Transclusion"
28218 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p>
28219
28220 <p about="#mwt1" typeof="mw:Transclusion"
28221 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p>
28222
28223 <!--Orig params with data-parsoid has heuristics for handling = chars-->
28224 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
28225 <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>
28226 !! wikitext
28227 {{echo|1=f=oo}}
28228
28229 {{echo|1=f=oo|2=bar}}
28230
28231 <!--Orig params with data-parsoid has heuristics for handling = chars-->
28232 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
28233 {{echo|<nowiki>f=oo</nowiki>|bar}}
28234 !! end
28235
28236 !! test
28237 Parsoid: Serialize positional parameters with = in extlink as named parameter
28238 !! options
28239 parsoid=html2wt
28240 !! html/parsoid
28241 <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>
28242 !! wikitext
28243 {{echo|1=http://stuff?is=ok}}
28244 !! end
28245
28246 !! test
28247 Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes
28248 !! options
28249 parsoid=html2wt
28250 !! html/parsoid
28251 <div>a<p>b</p></div>
28252 <div>a
28253 <p>b</p></div>
28254 <div>
28255 a
28256 <p>b</p></div>
28257 !! wikitext
28258 <div>a
28259 b
28260 </div>
28261 <div>a
28262 b
28263 </div>
28264 <div>
28265 a
28266
28267 b
28268 </div>
28269 !! end
28270
28271 !! test
28272 Substrings resembling wikitext in hrefs should not get nowiki escapes
28273 !! options
28274 parsoid=html2wt
28275 !! html/parsoid
28276 <a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a>
28277 !! wikitext
28278 [[Foo''bar''baz]]
28279 !! end
28280
28281 !! test
28282 Enforce single-line context in the serializer
28283 !! options
28284 parsoid=html2wt
28285 !! html/parsoid
28286 <h2>testing
28287 123</h2>
28288
28289 <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">
28290 </span><span about="#mwt1">you</span> </h2>
28291
28292 <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>
28293
28294 <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
28295 there</span></li></ol>
28296
28297 <ul><li>asd
28298 sdf</li></ul>
28299
28300 <ul><li>foo
28301 bar
28302 baz</li>
28303 <li>foo <b>bar</b>
28304 baz</li></ul>
28305
28306 <dl><dt>hi
28307 ho </dt><dd data-parsoid='{"stx":"row"}'> hi
28308 ho</dd></dl>
28309
28310 <dl><dd> <table>
28311 <tbody><tr><td> ha
28312 ha
28313 ha</td></tr>
28314 </tbody></table></dd></dl>
28315 !! wikitext
28316 == testing 123 ==
28317
28318 == hi {{bogus|there
28319 you}} ==
28320
28321 == foo <ref>hello
28322 there</ref> ==
28323
28324 <references />
28325
28326 * asd sdf
28327
28328 * foo bar baz
28329 * foo '''bar''' baz
28330
28331 ; hi ho : hi ho
28332
28333 : {|
28334 | ha
28335 ha
28336 ha
28337 |}
28338 !! end
28339
28340 !! test
28341 Serialize new placeholder space without spans
28342 !! options
28343 parsoid=html2wt
28344 !! html/parsoid
28345 <p>foo<span typeof="mw:Placeholder"> </span>: bar</p>
28346
28347 <p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p>
28348
28349 <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>
28350 !! wikitext
28351 foo : bar
28352
28353 foo : bar
28354
28355 <ref>foo : bar</ref>ok
28356 !! end
28357
28358
28359 #-----------------------
28360 # Tag minimization tests
28361 #-----------------------
28362
28363 !! test
28364 1. I/B quote minimization: wikitext-only tags should be combined
28365 !! options
28366 parsoid=html2wt
28367 !! html/parsoid
28368 <p><i>A</i><i>B</i></p>
28369 <p><b>A</b><b>B</b></p>
28370 <p><i>A</i><b><i>B</i></b></p>
28371 <p><b>A</b><i><b>B</b></i></p>
28372 <p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p>
28373 <p><i><b>A</b></i><i><b>B</b></i></p>
28374 <p><i><b>A</b></i><b><i>B</i></b></p>
28375 <p><b><i>A</i></b><i><b>B</b></i></p>
28376 !! wikitext
28377 ''AB''
28378
28379 '''AB'''
28380
28381 ''A'''B'''''
28382
28383 '''A''B'''''
28384
28385 '''A''BC''D'''
28386
28387 '''''AB'''''
28388
28389 '''''AB'''''
28390
28391 '''''AB'''''
28392 !! end
28393
28394 !! test
28395 2. I/B quote minimization: wikitext and html tags should not be combined
28396 !! options
28397 parsoid=html2wt
28398 !! html/parsoid
28399 <p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
28400 <p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
28401 !! wikitext
28402 ''A''<i>B</i>
28403
28404 ''A''<nowiki/>'''<i>B</i>'''
28405 !! end
28406
28407 !! test
28408 3. I/B quote minimization: templated content stops minimization
28409 !! options
28410 parsoid=html2wt
28411 !! html/parsoid
28412 <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>
28413 <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>
28414 !! wikitext
28415 ''A''{{echo|''B''}}
28416
28417 ''A''{{echo|'''''B'''''}}
28418 !! end
28419
28420 !! test
28421 4. I/B quote minimization: new content should be mimimized with adjacent old content
28422 !! options
28423 parsoid=html2wt
28424 !! html/parsoid
28425 <p><i>A</i><i>B</i></p>
28426 <p><b>A</b><b>B</b></p>
28427 <p><i>A</i><b><i>B</i></b></p>
28428 !! wikitext
28429 ''AB''
28430
28431 '''AB'''
28432
28433 ''A'''B'''''
28434 !! end
28435
28436 !! test
28437 5a. Merge adjacent quote nodes if they've been edited
28438 !! options
28439 parsoid={
28440 "modes": ["wt2wt", "selser"],
28441 "changes": [
28442 ["p", "contents", "remove", ":contains('b')"]
28443 ]
28444 }
28445 !! wikitext
28446 ''a''b''c''
28447 !! wikitext/edited
28448 ''ac''
28449 !! end
28450
28451 !! test
28452 5b. Merge adjacent quote nodes if they've been edited
28453 !! options
28454 parsoid={
28455 "modes": ["wt2wt", "selser"],
28456 "changes": [
28457 ["#x", "remove"]
28458 ]
28459 }
28460 !! wikitext
28461 ''a''<span id="x">b</span>''c''
28462 !! wikitext/edited
28463 ''ac''
28464 !! end
28465
28466 !! test
28467 1. Merge adjacent link nodes as long as at least one element is new
28468 !! options
28469 parsoid={
28470 "modes": ["html2wt"],
28471 "scrubWikitext": true
28472 }
28473 !! html/parsoid
28474 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28475 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28476 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a>
28477 !! wikitext
28478 [[Football]]
28479 [[Football]]
28480 [[Football|Foot]][[Football|ball]]
28481 !! end
28482
28483 !! test
28484 2. Merge adjacent link nodes and enable additional normalizations
28485 !! options
28486 parsoid={
28487 "modes": ["html2wt"],
28488 "scrubWikitext": true
28489 }
28490 !! html/parsoid
28491 <a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a>
28492 !! wikitext
28493 ''[[Football]]''
28494 !! end
28495
28496 !! test
28497 3. Don't merge adjacent link nodes if scrubWikitext is false
28498 !! options
28499 parsoid={
28500 "modes": ["html2wt"],
28501 "scrubWikitext": false
28502 }
28503 !! html/parsoid
28504 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28505 !! wikitext
28506 [[Football|Foot]][[Football|ball]]
28507 !! end
28508
28509 !! test
28510 1. Move format tags outside of WikiLink
28511 !! options
28512 parsoid={
28513 "modes": ["html2wt"],
28514 "scrubWikitext": true
28515 }
28516 !! html/parsoid
28517 <a rel="mw:WikiLink" href="./Football"><i>Football</i></a>
28518 <a rel="mw:WikiLink" href="./Football"><i><b>Football</b></i></a>
28519 <a rel="mw:WikiLink" href="./Football"><u><i><b>Football</b></i></u></a>
28520 !! wikitext
28521 ''[[Football]]''
28522 '''''[[Football]]'''''
28523 <u>'''''[[Football]]'''''</u>
28524 !! end
28525
28526 !! test
28527 2. Move format tags outside of WikiLink with mergable A tags
28528 !! options
28529 parsoid={
28530 "modes": ["html2wt"],
28531 "scrubWikitext": true
28532 }
28533 !! html/parsoid
28534 <a rel="mw:WikiLink" href="./Football"><i><b>Foot</b></i></a><a rel="mw:WikiLink" href="./Football"><i><b>ball</b></i></a>
28535 !! wikitext
28536 '''''[[Football]]'''''
28537 !! end
28538
28539 !! test
28540 3. Move format tags outside of WikiLink while preserving formats already outside WikiLink
28541 !! options
28542 parsoid={
28543 "modes": ["html2wt"],
28544 "scrubWikitext": true
28545 }
28546 !! html/parsoid
28547 <font color="red"><a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><u><b>Foo</b></u></a></font>
28548 !! wikitext
28549 <font color="red"><u>'''[[Foo]]'''</u></font>
28550 !! end
28551
28552 !! test
28553 4. Do not move format tags outside of WikiLink which includes attributes color, style and class
28554 !! options
28555 parsoid={
28556 "modes": ["html2wt"],
28557 "scrubWikitext": true
28558 }
28559 !! html/parsoid
28560 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><font color="red">Foo</font></a>
28561 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><span style="color: blue; font-size: 46px;">Foo></span></a>
28562 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><span class="Bar">Foo</span></a>
28563 !! wikitext
28564 [[Foo|<font color="red">Foo</font>]]
28565 [[Foo|<span style="color: blue; font-size: 46px;">Foo></span>]]
28566 [[Foo|<span class="Bar">Foo</span>]]
28567 !! end
28568
28569 !! test
28570 5. T194083 Regression test: Manual edit test that also enables scrubWikitext to move format tags outside wikilinks
28571 !! options
28572 parsoid={
28573 "modes": ["selser"],
28574 "scrubWikitext": true,
28575 "changes": [
28576 ["a", "html", "<i>Foo</i>"]
28577 ]
28578 }
28579 !! wikitext
28580 [[Foo]]
28581 !! wikitext/edited
28582 ''[[Foo]]''
28583 !! end
28584
28585 !! test
28586 6. Regression test: Manual edit test to ensure diff markers are not lost
28587 !! options
28588 parsoid={
28589 "modes": ["selser"],
28590 "scrubWikitext": true,
28591 "changes": [
28592 ["i", "wrap", "<a href='./Foo' rel='mw:WikiLink'></a>"]
28593 ]
28594 }
28595 !! wikitext
28596 ''Foo''
28597 !! wikitext/edited
28598 ''[[Foo]]''
28599 !! end
28600
28601 #------------------------------
28602 # End of tag minimization tests
28603 #------------------------------
28604
28605 !!test
28606 T56262: New entities
28607 !! options
28608 parsoid=html2wt
28609 !! html/parsoid
28610 <span typeof="mw:Entity">&nbsp;</span>
28611 !! wikitext
28612 &nbsp;
28613 !! end
28614
28615 ## Note that there is no wikitext output for 'unknownproperty' ##
28616 ## Unknown magic words are silently dropped ##
28617
28618 !! test
28619 Magic words
28620 !! options
28621 parsoid=html2wt
28622 !! html/parsoid
28623 <meta property='mw:PageProp/toc' />
28624 <meta property='mw:PageProp/notoc' />
28625 <meta property='mw:PageProp/forcetoc' />
28626 <meta property='mw:PageProp/index' />
28627 <meta property='mw:PageProp/noindex' />
28628 <meta property='mw:PageProp/nogallery' />
28629 <meta property='mw:PageProp/noeditsection' />
28630 <meta property='mw:PageProp/notitleconvert' />
28631 <meta property='mw:PageProp/nocontentconvert' />
28632 <meta property='mw:PageProp/unknownproperty' />
28633 !! wikitext
28634 __TOC__
28635 __NOTOC__
28636 __FORCETOC__
28637 __INDEX__
28638 __NOINDEX__
28639 __NOGALLERY__
28640 __NOEDITSECTION__
28641 __NOTITLECONVERT__
28642 __NOCONTENTCONVERT__
28643 !! end
28644
28645 !! test
28646 Consecutive <pre>s should not get merged
28647 !! options
28648 parsoid=html2wt,html2html
28649 !! html/parsoid
28650 <pre>a</pre><pre>b</pre>
28651
28652 <pre>c
28653 </pre><pre>
28654 d</pre>
28655
28656 <pre>e
28657
28658 </pre><pre>
28659
28660 f</pre>
28661 !! wikitext
28662 a
28663
28664 b
28665
28666 c
28667
28668 d
28669
28670 e
28671
28672
28673
28674 f
28675 !! end
28676
28677 !! test
28678 Edited ISBN links not serializable as ISBN links should serialize as wikilinks
28679 !! options
28680 parsoid=html2wt
28681 !! html/parsoid
28682 <a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a>
28683 !! wikitext
28684 [[Special:BookSources/1234567890|ISBN 1234567895]]
28685 !! end
28686
28687 !! test
28688 Edited RFC links not serializable as RFC links should serialize as extlinks
28689 !! options
28690 parsoid=html2wt
28691 !! html/parsoid
28692 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
28693 !! wikitext
28694 [https://tools.ietf.org/html/rfc123 New RFC]
28695 !! end
28696
28697 !! test
28698 Edited PMID links not serializable as PMID links should serialize as extlinks
28699 !! options
28700 parsoid=html2wt
28701 !! html/parsoid
28702 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a>
28703 !! wikitext
28704 [//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID]
28705 !! end
28706
28707 !! test
28708 WTS of autolinks with trailing/surrounding context
28709 !! options
28710 parsoid=html2wt
28711 !! html/parsoid
28712 <p><a href="http://cscott.net">http://cscott.net</a><b>foo</b></p>
28713 <p><a href="http://cscott.net">http://cscott.net</a><b data-parsoid='{"stx":"html"}'>foo</b></p>
28714 <p><b><a href="http://cscott.net">http://cscott.net</a></b></p>
28715 <p><b><a href="http://cscott.net">http://cscott.net</a> </b></p>
28716 <p><b><a href="http://cscott.net">http://cscott.net</a>x</b></p>
28717 <p><a href="http://cscott.net">http://cscott.net</a>x</p>
28718 !! wikitext
28719 http://cscott.net'''foo'''
28720
28721 http://cscott.net<b>foo</b>
28722
28723 '''http://cscott.net'''
28724
28725 '''http://cscott.net '''
28726
28727 '''http://cscott.net<nowiki/>x'''
28728
28729 http://cscott.net<nowiki/>x
28730 !! end
28731
28732 !! test
28733 WTS of autolinks with nowikis (round-trip)
28734 !! wikitext
28735 x<nowiki/>http://cscott.net<nowiki/>x
28736 !! html/parsoid
28737 <p>x<a rel="mw:ExtLink" class="external free" href="http://cscott.net">http://cscott.net</a>x</p>
28738 !! end
28739
28740 # this is the "easy" test because it leaves in place all the
28741 # data-parsoid information indicating this is an autolink
28742 !! test
28743 WTS of autolinks with escapes (editing)
28744 !! options
28745 parsoid={
28746 "modes": ["wt2wt"],
28747 "changes": [
28748 [ "span", "remove" ]
28749 ]
28750 }
28751 !! wikitext
28752 x<nowiki/>http://cscott.net<nowiki/>x
28753 !! wikitext/edited
28754 x<nowiki/>http://cscott.net<nowiki/>x
28755 !! end
28756
28757 !! test
28758 WTS of edited autolink-like text (T103364)
28759 !! options
28760 parsoid={
28761 "modes": ["wt2wt"],
28762 "changes": [
28763 [ "span[typeof]", "removeAttr", "typeof" ]
28764 ]
28765 }
28766 !! wikitext
28767 Not a link: <nowiki>http://example.com</nowiki>.
28768 !! wikitext/edited
28769 Not a link: <span><nowiki>http://example.com</nowiki></span>.
28770 !! end
28771
28772 !! test
28773 WTS of newly-authored autolink-like text (T103364)
28774 !! options
28775 parsoid=html2wt
28776 !! html/parsoid
28777 <p>http://example.com is not a link.</p>
28778 !! wikitext
28779 <nowiki>http://example.com</nowiki> is not a link.
28780 !! end
28781
28782 !! test
28783 WTS of autolink-like text after an autolink (T108563)
28784 !! options
28785 parsoid=html2wt
28786 !! html/parsoid
28787 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p>
28788 !! wikitext
28789 http://example.com <nowiki>http://example.com</nowiki> is not a link.
28790 !! end
28791
28792 !! test
28793 Magic links inside links (not autolinked)
28794 !! wikitext
28795 [[Foo|http://example.com]]
28796 [[Foo|RFC 1234]]
28797 [[Foo|PMID 1234]]
28798 [[Foo|ISBN 123456789x]]
28799
28800 [http://foo.com http://example.com]
28801 [http://foo.com RFC 1234]
28802 [http://foo.com PMID 1234]
28803 [http://foo.com ISBN 123456789x]
28804 !! html+tidy
28805 <p><a href="/wiki/Foo" title="Foo">http://example.com</a>
28806 <a href="/wiki/Foo" title="Foo">RFC 1234</a>
28807 <a href="/wiki/Foo" title="Foo">PMID 1234</a>
28808 <a href="/wiki/Foo" title="Foo">ISBN 123456789x</a>
28809 </p><p><a rel="nofollow" class="external text" href="http://foo.com">http://example.com</a>
28810 <a rel="nofollow" class="external text" href="http://foo.com">RFC 1234</a>
28811 <a rel="nofollow" class="external text" href="http://foo.com">PMID 1234</a>
28812 <a rel="nofollow" class="external text" href="http://foo.com">ISBN 123456789x</a>
28813 </p>
28814 !! html/parsoid
28815 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a>
28816 <a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a>
28817 <a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a>
28818 <a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p>
28819
28820 <p><a rel="mw:ExtLink" class="external text" href="http://foo.com">http://example.com</a>
28821 <a rel="mw:ExtLink" class="external text" href="http://foo.com">RFC 1234</a>
28822 <a rel="mw:ExtLink" class="external text" href="http://foo.com">PMID 1234</a>
28823 <a rel="mw:ExtLink" class="external text" href="http://foo.com">ISBN 123456789x</a></p>
28824 !! end
28825
28826 !! test
28827 Magic links inside image captions (autolinked)
28828 !! wikitext
28829 [[File:Foobar.jpg|thumb|http://example.com]]
28830 [[File:Foobar.jpg|thumb|RFC 1234]]
28831 [[File:Foobar.jpg|thumb|PMID 1234]]
28832 [[File:Foobar.jpg|thumb|ISBN 123456789x]]
28833 !! html+tidy
28834 <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>
28835 <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>
28836 <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>
28837 <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>
28838 !! html/parsoid
28839 <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>
28840 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="https://tools.ietf.org/html/rfc1234" rel="mw:ExtLink" class="external mw-magiclink">RFC 1234</a></figcaption></figure>
28841 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external mw-magiclink">PMID 1234</a></figcaption></figure>
28842 <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>
28843 !! end
28844
28845 !! test
28846 WTS of magic word text (T109371)
28847 !! options
28848 parsoid=html2wt
28849 !! html/parsoid
28850 <p>RFC 1234</p>
28851 <p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p>
28852 <p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p>
28853 !! wikitext
28854 <nowiki>RFC 1234</nowiki>
28855
28856 [http://foo.com RFC 1234]
28857
28858 [[Foo|RFC 1234]]
28859 !! end
28860
28861 !! test
28862 Edited Redirect link should emit a non-piped wikitext link
28863 !! options
28864 parsoid=html2wt
28865 !! html/parsoid
28866 <link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>
28867 !! wikitext
28868 #REDIRECT [[Bar]]
28869 !! end
28870
28871 !! test
28872 T75121: Infer extension name from typeOf if data-mw is not present
28873 !! options
28874 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28875 !! html/parsoid
28876 <div typeOf="mw:Extension/foo"></div>
28877 !! wikitext
28878 <foo />
28879 !! end
28880
28881 # Note that the <p> wrapping isn't present in PHP parser output
28882 # The important thing for this test is that P-wrapping doesn't
28883 # interfere with the <nowiki> protection for leading - in <td>
28884 # (which isn't necessary for <th>).
28885 !! test
28886 T88318: p-wrapped dash in table.
28887 !! options
28888 parsoid=html2wt,wt2wt
28889 !! html/parsoid
28890 <table><tbody>
28891 <tr><th><p>-</p></th><th><p>- </p></th></tr>
28892 <tr><td><p>-</p></td><td><p>- </p></td></tr>
28893 <tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr>
28894 </tbody></table>
28895 !! wikitext
28896 {|
28897 !-
28898 !-
28899 |-
28900 |<nowiki>-</nowiki>
28901 |<nowiki>- </nowiki>
28902 |-
28903 |<small>-</small>
28904 |<br />
28905 -
28906 |<br />-
28907 |}
28908 !! html/php+tidy
28909 <table>
28910 <tbody><tr>
28911 <th>-
28912 </th>
28913 <th>-
28914 </th></tr>
28915 <tr>
28916 <td>-
28917 </td>
28918 <td>-
28919 </td></tr>
28920 <tr>
28921 <td><small>-</small>
28922 </td>
28923 <td><br />
28924 <p>-
28925 </p>
28926 </td>
28927 <td><br />-
28928 </td></tr></tbody></table>
28929 !! end
28930
28931 !! test
28932 T149209: WTS: Handle newlines in table cells properly
28933 !! options
28934 parsoid=html2wt
28935 !! html/parsoid
28936 <table>
28937 <tbody>
28938 <tr><td>a
28939 b
28940 </td><td data-parsoid='{"stx":"row"}'>c</td></tr>
28941 <tr><td><p>x</p>
28942 </td><td data-parsoid='{"stx":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr>
28943 </tbody></table>
28944 <table>
28945 <tbody>
28946 <tr><th>a
28947 b
28948 </th><th data-parsoid='{"stx":"row"}'>c</th></tr>
28949 <tr><th><p>x</h>
28950 </th><th data-parsoid='{"stx":"row"}'>y</th></tr>
28951 </tbody></table>
28952 !! wikitext
28953 {|
28954 |a
28955 b
28956 |c
28957 |-
28958 |x
28959 {{!}}y
28960 |}
28961 {|
28962 !a
28963 b
28964 !c
28965 |-
28966 !x
28967 !y
28968 |}
28969 !! end
28970
28971 !! test
28972 T149209: Selser: Handle newlines in table cells properly
28973 !! options
28974 parsoid={
28975 "modes": ["selser"],
28976 "changes": [
28977 [ "#h1", "html", "a\nb\n" ],
28978 [ "#h2", "html", "a\nb\n" ],
28979 [ "#c1", "html", "a\nb\n" ],
28980 [ "#c2", "html", "<p>a</p>" ],
28981 [ "#c3", "html", "<p>a</p>" ],
28982 [ "#c4", "html", "edit-me<p>a</p>" ]
28983 ]
28984 }
28985 !! wikitext
28986 {|
28987 ! id="h1" |edit-me!!1
28988 |-
28989 ! id="h2" |edit-me||2
28990 |-
28991 | id="c1" |edit-me||3
28992 |-
28993 | id="c2" |edit-me||4
28994 |-
28995 | id="c3" |edit-me||p||q||r
28996 |-
28997 | id="c4" |edit-me||p||q||r
28998 |}
28999 !! wikitext/edited
29000 {|
29001 ! id="h1" |a
29002 b
29003 !1
29004 |-
29005 ! id="h2" |a
29006 b
29007 !2
29008 |-
29009 | id="c1" |a
29010 b
29011 |3
29012 |-
29013 | id="c2" |a
29014 |4
29015 |-
29016 | id="c3" |a
29017 |p||q||r
29018 |-
29019 | id="c4" |edit-me
29020 a
29021 |p||q||r
29022 |}
29023 !! end
29024
29025 !! test
29026 HTML id attribute with Parsoid-like element ids should not be serialized to wikitext
29027 !! options
29028 parsoid=html2wt
29029 !! html/parsoid
29030 <table id='mwAb'>
29031 <td id='mwAc'>foo</td>
29032 <td id='serialize-this'>bar</td>
29033 </table>
29034 !! wikitext
29035 {|
29036 |foo
29037 | id="serialize-this" |bar
29038 |}
29039 !! end
29040
29041 !! test
29042 Parsoid-like element ids should not be serialized to wikitext unless shadowed
29043 !! options
29044 parsoid=html2wt
29045 !! html/parsoid
29046 <div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div>
29047 !! wikitext
29048 <div id="hello">ok</div>
29049 !! end
29050
29051 !! test
29052 Testing serialization after deletion in references
29053 !! options
29054 parsoid={
29055 "modes": ["wt2wt"],
29056 "changes": [
29057 ["#x", "remove"]
29058 ]
29059 }
29060 !! wikitext
29061 hi <ref><div id="x">ho</div></ref>
29062
29063 <references />
29064 !! wikitext/edited
29065 hi <ref></ref>
29066
29067 <references />
29068 !! end
29069
29070 !!test
29071 Testing serialization after deletion of table cells
29072 !!options
29073 parsoid={
29074 "modes": ["wt2wt", "selser"],
29075 "changes": [
29076 ["#x", "remove"]
29077 ]
29078 }
29079 !!wikitext
29080 {|
29081 !h1 !!h2 !!h3
29082 | id="x" |c1 {{!}}{{!}}{{!}}c2 |||c3
29083 |}
29084 !! wikitext/edited
29085 {|
29086 !h1!!h2!!h3
29087 |c2|||c3
29088 |}
29089 !!end
29090
29091 !! test
29092 Testing selser after addition of new row before first row (T125419)
29093 !! options
29094 parsoid={
29095 "modes": ["wt2wt", "selser"],
29096 "changes": [
29097 [ "tr", "before", "<tr><td>X</td></tr>" ]
29098 ]
29099 }
29100 !! wikitext
29101 {|
29102 |a
29103 |}
29104 !! wikitext/edited
29105 {|
29106 |X
29107 |-
29108 |a
29109 |}
29110 !! end
29111
29112 !! test
29113 Serialize new table rows in a HTML table using HTML tags
29114 !! options
29115 parsoid={
29116 "modes": ["wt2wt", "selser"],
29117 "changes": [
29118 [ "tr", "before", "<tr><td>X</td></tr>" ]
29119 ]
29120 }
29121 !! wikitext
29122 <table><tr><td>a</td></tr></table>
29123 !! wikitext/edited
29124 <table><tr><td>X</td></tr><tr><td>a</td></tr></table>
29125 !! end
29126
29127 !! test
29128 Serialize new table cells in a HTML row using HTML tags
29129 !! options
29130 parsoid={
29131 "modes": ["wt2wt", "selser"],
29132 "changes": [
29133 [ "td", "before", "<td>X</td>" ]
29134 ]
29135 }
29136 !! wikitext
29137 <table><tr><td>a</td></tr></table>
29138 !! wikitext/edited
29139 <table><tr><td>X</td><td>a</td></tr></table>
29140 !! end
29141
29142 !! test
29143 Serialize wikitext list items as HTML list items when embedded in a HTML list
29144 !! options
29145 parsoid=html2wt
29146 !! html
29147 <ul data-parsoid='{"stx": "html"}'>
29148 <li data-parsoid='{}'>a</li>
29149 <li>b</li>
29150 </ul>
29151 !! wikitext
29152 <ul>
29153 <li>a</li>
29154 <li>b</li>
29155 </ul>
29156 !! end
29157
29158 # SSS FIXME: Is this actually a good thing given the
29159 # odd nested list output that is generated by MW?
29160 # <ul><li>foo<ul>..</ul></li></ul> instead of
29161 # <ul><li>foo</li><ul>..</ul></ul>
29162 !! test
29163 Wikitext lists can be nested inside HTML lists
29164 !! options
29165 parsoid=html2wt
29166 !! html
29167 <ul data-parsoid='{"stx": "html"}'>
29168 <li data-parsoid='{"stx": "html"}'>a
29169 <ul><li>b</li></ul>
29170 </li>
29171 </ul>
29172
29173 <ul data-parsoid='{"stx": "html"}'>
29174 <li>x
29175 <ul><li>y</li></ul>
29176 </li>
29177 </ul>
29178 !! wikitext
29179 <ul>
29180 <li>a
29181 * b
29182 </li>
29183 </ul>
29184
29185 <ul>
29186 <li>x
29187 * y
29188 </li>
29189 </ul>
29190 !! end
29191
29192 !! test
29193 WTS change modes
29194 !! options
29195 parsoid={
29196 "modes": ["wt2wt"],
29197 "changes": [
29198 [ "#xyz", "before", "<b>before</b> stuff " ],
29199 [ "#xyz", "after", " stuff <i>after</i>" ],
29200 [ "#xyz", "html", "x <b>y</b> z" ]
29201 ]
29202 }
29203 !! wikitext
29204 <span id="xyz">hello</span>
29205 !! wikitext/edited
29206 '''before''' stuff <span id="xyz">x '''y''' z</span> stuff ''after''
29207 !! end
29208
29209 !! test
29210 Never serialize a-tag as html, regardless of what data-parsoid has to say
29211 !! options
29212 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
29213 !! html/parsoid
29214 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a>
29215 !! wikitext
29216 [[Foo]]
29217 !! end
29218
29219 ## SSS FIXME: This is broken output nevertheless.
29220 ## What might be a reasonable non-broken output for this?
29221 ## This is an edge case unlikely to be seen in production
29222 ## that I am not wasting more time on this right now.
29223 !! test
29224 Never serialize a-tag as html, no matter what attributes it has
29225 !! options
29226 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
29227 !! html/parsoid
29228 <a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a>
29229 !! wikitext
29230 [http://boo.org http://boohoo.org]
29231 !! end
29232
29233 # Misnested is an indication that selser can reuse the source but these have
29234 # shown to sneak through on occasion. See T101768.
29235 # The original wikitext here is: [http://test.com [[one]] two three]
29236 !! test
29237 Strip span tags added to mark misnested links
29238 !! options
29239 parsoid=html2wt
29240 !! html/parsoid
29241 <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>
29242 !! wikitext
29243 [http://test.com][[one]] two three
29244 !! end
29245
29246 !! test
29247 Catch regression when unpacking misnested links
29248 !! options
29249 parsoid=wt2html
29250 !! wikitext
29251 {{echo|hi}}[http://example.com [[ho]]]
29252 !! html/parsoid
29253 <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>
29254 !! end
29255
29256 !! test
29257 Catch regression when unpacking with trailing content
29258 !! wikitext
29259 {{echo|Foo <references/> bar}}
29260 !! html/parsoid
29261 <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>
29262 !! end
29263
29264 !! test
29265 Use data-parsoid.firstWikitextNode to compute newline constraints for template content
29266 !! options
29267 parsoid=html2wt
29268 !! html/parsoid
29269 <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|}"]}'>
29270 <tbody><tr><td>d
29271 </td></tr>
29272 </tbody></table>
29273 !! wikitext
29274 {{echo|a}}
29275 {|{{echo|c
29276 {{!}}d
29277 }}
29278 |}
29279 !! end
29280
29281 ## This test verifies the presence and computation of this attribute indirectly
29282 ## by making an edit and ensuring that the serialization is correct (which it would be
29283 ## only if firstWikitextNode is properly set).
29284 !! test
29285 data-parsoid.firstWikitextNode should be computed properly in the presence of fostered content
29286 !! options
29287 parsoid= {
29288 "modes": ["wt2wt"],
29289 "changes": [
29290 [ "div#x", "remove" ],
29291 [ "div", "before", "<div>new</div>" ]
29292 ]
29293 }
29294 !! wikitext
29295 <div id="x">foo</div>
29296 {|
29297 {{echo|<div>boo</div>
29298 {{!}}b}}
29299 |c
29300 |}
29301 !! wikitext/edited
29302
29303 <div>new</div>
29304 {|
29305 {{echo|<div>boo</div>
29306 {{!}}b}}
29307 |c
29308 |}
29309 !! end
29310
29311 # --------------------------------------------
29312 # Tests spec'ing wikitext serialization norms |
29313 # --------------------------------------------
29314
29315 !! test
29316 Serialize multi-line indent-pre starting with wikitext syntax
29317 !! options
29318 parsoid=html2wt
29319 !! html/parsoid
29320 <pre>* 1
29321 ** 2
29322 * 3</pre>
29323 !! wikitext
29324 * 1
29325 ** 2
29326 * 3
29327 !! end
29328
29329 !! test
29330 1. Categories should always be serialized on their own line
29331 !! options
29332 parsoid=html2wt
29333 !! html/parsoid
29334 foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar
29335 !! wikitext
29336 foo
29337 [[Category:Foo]]
29338 bar
29339 !! end
29340
29341 !! test
29342 2. Categories that are part of templates should not introduce a line break
29343 !! wikitext
29344 foo {{echo|<span>bar</span> [[Category:baz]]}} bar
29345 !! html/parsoid
29346 <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>
29347 !! end
29348
29349 # Careful while editing these next 2 tests. There are \u200f characters
29350 # before and after the <link> tags in the HTML and following some
29351 # of the categories in wikitext
29352 # Do not remove these characters in edits.
29353 #
29354 # As part of the serialization, these bidi characters will get stripped.
29355 !! test
29356 RTL (\u200f) and LTR (\u200e) markers around category tags should be stripped
29357 !! options
29358 parsoid={
29359 "modes": ["html2wt"],
29360 "scrubWikitext": true
29361 }
29362 !! html/parsoid
29363 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏
29364 ‏<link rel="mw:PageProp/Category" href="./קטגוריה:_שיטות_משפט" />‏</p>
29365 !! wikitext
29366 [[קטגוריה:טקסים]]
29367 [[קטגוריה: שיטות משפט]]
29368 !! end
29369
29370 !! test
29371 RTL (\u200f) and LTR (\u200e) markers should not be stripped if followed by a text node
29372 !! options
29373 parsoid={
29374 "modes": ["html2wt"],
29375 "scrubWikitext": true
29376 }
29377 !! html/parsoid
29378 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏y</p>
29379 !! wikitext
29380 [[קטגוריה:טקסים]]
29381 ‏y
29382 !! end
29383
29384 !! test
29385 Lists: Add space after bullets
29386 !! options
29387 parsoid=html2wt
29388 !! html/parsoid
29389 <ul>
29390 <li>foo</li>
29391 <li> bar</li>
29392 <li><span> baz</span></li>
29393 </ul>
29394 !! wikitext
29395 * foo
29396 * bar
29397 * <span> baz</span>
29398 !! end
29399
29400 !! test
29401 1. Headings: Add space before/after == (T53744)
29402 !! options
29403 parsoid=html2wt
29404 !! html/parsoid
29405 <h2>foo</h2>
29406 <h2> bar</h2>
29407 <h2>baz </h2>
29408 <h2><span> baz</span></h2>
29409 !! wikitext
29410 == foo ==
29411
29412 == bar ==
29413
29414 == baz ==
29415
29416 == <span> baz</span> ==
29417 !! end
29418
29419 !! test
29420 2. Headings: Add space before/after == even after hoisted content
29421 !! options
29422 parsoid={
29423 "modes": ["html2wt"],
29424 "scrubWikitext": true
29425 }
29426 !! html/parsoid
29427 <h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2>
29428 !! wikitext
29429 [[Category:A2]]
29430
29431 == ok ==
29432 !! end
29433
29434 !! test
29435 1. Headings: suppress newly created empty headings
29436 !! options
29437 parsoid={
29438 "modes": ["html2wt"],
29439 "scrubWikitext": true
29440 }
29441 !! html/parsoid
29442 <h2></h2>
29443 !! wikitext
29444 !! end
29445
29446 !! test
29447 2. Headings: don't suppress empty headings if scrubWikitext is false
29448 !! options
29449 parsoid=html2wt
29450 !! html/parsoid
29451 <h2></h2>
29452 !! wikitext
29453 ==<nowiki/>==
29454 !! end
29455
29456 !! test
29457 3. Headings: suppress empty headings on edits
29458 !! options
29459 parsoid={
29460 "modes": ["selser"],
29461 "scrubWikitext": true,
29462 "changes": [
29463 [ "#x", "remove"]
29464 ]
29465 }
29466 !! wikitext
29467 ==<span id="x">foo</span>==
29468 !! wikitext/edited
29469 !! end
29470
29471 !! test
29472 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = true)
29473 !! options
29474 parsoid={
29475 "modes": ["html2wt"],
29476 "scrubWikitext": true
29477 }
29478 !! html/parsoid
29479 <h2>foo<br/>bar</h2>
29480 <h2>foo <span><br/>bar</span> baz</h2>
29481 !! wikitext
29482 == foo bar ==
29483
29484 == foo <span> bar</span> baz ==
29485 !! end
29486
29487 !! test
29488 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = false)
29489 !! options
29490 parsoid={
29491 "modes": ["html2wt"],
29492 "scrubWikitext": false
29493 }
29494 !! html/parsoid
29495 <h2>foo<br/>bar</h2>
29496 !! wikitext
29497 == foo<br />bar ==
29498 !! end
29499
29500 !! test
29501 1. WT Quote Tags: suppress newly created empty style tags
29502 !! options
29503 parsoid={
29504 "modes": ["html2wt"],
29505 "scrubWikitext": true
29506 }
29507 !! html/parsoid
29508 <i></i><b></b>
29509 !! wikitext
29510 !! end
29511
29512 !! test
29513 2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false
29514 !! options
29515 parsoid=html2wt
29516 !! html/parsoid
29517 <i></i><b></b>
29518 !! wikitext
29519 ''<nowiki/>'''''<nowiki/>'''
29520 !! end
29521
29522 !! test
29523 3. WT Quote Tags: suppress empty style tags on edits
29524 !! options
29525 parsoid={
29526 "modes": ["selser"],
29527 "scrubWikitext": true,
29528 "changes": [
29529 [ "#x", "remove"]
29530 ]
29531 }
29532 !! wikitext
29533 '''<span id="x">foo</span>'''
29534 !! wikitext/edited
29535 !! end
29536
29537 !! test
29538 1. Anchors: suppress newly created empty anchors
29539 !! options
29540 parsoid={
29541 "modes": ["html2wt"],
29542 "scrubWikitext": true
29543 }
29544 !! html/parsoid
29545 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
29546 !! wikitext
29547 !! end
29548
29549 !! test
29550 2. Anchors: don't suppress empty anchors if scrubWikitext is false
29551 !! options
29552 parsoid={
29553 "modes": ["html2wt"],
29554 "scrubWikitext": false
29555 }
29556 !! html/parsoid
29557 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
29558 !! wikitext
29559 [[Test|<nowiki/>]]
29560 !! end
29561
29562 !! test
29563 3. Anchors: suppress empty anchors on edits
29564 !! options
29565 parsoid={
29566 "modes": ["selser"],
29567 "scrubWikitext": true,
29568 "changes": [
29569 [ "#x", "remove"]
29570 ]
29571 }
29572 !! wikitext
29573 [[Test|<span id="x">foo</span>]]
29574 !! wikitext/edited
29575 !! end
29576
29577 !! test
29578 3a. Anchors: do not suppress numbered extlinks
29579 !! options
29580 parsoid={
29581 "modes": ["wt2wt"],
29582 "scrubWikitext": true
29583 }
29584 !! wikitext
29585 [http://foo.com]
29586 !! html/parsoid
29587 <a rel="mw:ExtLink" href="http://foo.com"></a>
29588 !! end
29589
29590 !! test
29591 3b. Anchors: do not suppress numbered extlinks
29592 !! options
29593 parsoid={
29594 "modes": ["wt2wt"],
29595 "scrubWikitext": true,
29596 "changes": [
29597 [ "#x", "remove"]
29598 ]
29599 }
29600 !! wikitext
29601 [http://foo.com <span id="x">foo</span>]
29602 !! wikitext/edited
29603 [http://foo.com]
29604 !! end
29605
29606 !!test
29607 Normalizations should be restricted to edited content
29608 !!options
29609 parsoid={
29610 "modes": ["selser"],
29611 "scrubWikitext": true,
29612 "changes": [
29613 [ "h1", "before", "<i></i>"]
29614 ]
29615 }
29616 !!wikitext
29617 a
29618 = =
29619 b
29620 !!wikitext/edited
29621 a
29622 = =
29623 b
29624 !!end
29625
29626 !! test
29627 1. Multiple normalizations (html2wt)
29628 !! options
29629 parsoid={
29630 "modes": ["html2wt"],
29631 "scrubWikitext": true
29632 }
29633 !! html
29634 <h2><i></i></h2>
29635 <p><a href='Foo' rel='mw:WikiLink'>foo<i></i>
29636 </a><b><i></i></b>x</p>
29637 !! wikitext
29638
29639 [[foo]]
29640 x
29641
29642 !! end
29643
29644 !! test
29645 2. Multiple normalizations (selser)
29646 !! options
29647 parsoid={
29648 "modes": ["selser"],
29649 "scrubWikitext": true,
29650 "changes": [
29651 [ "#x", "after", "<h1><i></i></h1>\n<p> x<b></b></p>"]
29652 ]
29653 }
29654 !! wikitext
29655 <span id="x">foo</span>
29656 !! wikitext/edited
29657 <span id="x">foo</span>
29658
29659 x
29660 !! end
29661
29662 !! test
29663 1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
29664 !! options
29665 parsoid={
29666 "modes": ["html2wt"],
29667 "scrubWikitext": true
29668 }
29669 !! html/parsoid
29670 <p> hi</p>
29671 <p> hello</p>
29672 !! wikitext
29673 hi
29674
29675 hello
29676 !! end
29677
29678 !! test
29679 2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false
29680 !! options
29681 parsoid=html2wt
29682 !! html/parsoid
29683 <p> hi</p>
29684 <p> hello</p>
29685 !! wikitext
29686 <nowiki> </nowiki>hi
29687
29688 <nowiki> </nowiki> hello
29689 !! end
29690
29691 !! test
29692 3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
29693 !! options
29694 parsoid={
29695 "modes": ["html2wt"],
29696 "scrubWikitext": true
29697 }
29698 !! html/parsoid
29699 <p>Foo
29700 bar
29701 baz</p>
29702
29703 <table><tr><td>Foo
29704 bar
29705 baz bang</td></tr></table>
29706
29707 <p><!--boo--> foo
29708 bar</p>
29709
29710 <p> foo
29711 bar<span>boo</span></p>
29712 !! wikitext
29713 Foo
29714 bar
29715 baz
29716
29717 {|
29718 |Foo
29719 bar
29720 baz bang
29721 |}
29722
29723 <!--boo-->foo
29724 bar
29725
29726 foo
29727 bar<span>boo</span>
29728 !! end
29729
29730 !! test
29731 4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs
29732 !! options
29733 parsoid={
29734 "modes": ["selser"],
29735 "scrubWikitext": true,
29736 "changes": [
29737 [ "p", "html", " a\n b" ]
29738 ]
29739 }
29740 !! wikitext
29741 xyz
29742 !! wikitext/edited
29743 a
29744 b
29745 !! end
29746
29747 !! test
29748 1. New links that end in spaces
29749 !! options
29750 parsoid={
29751 "modes": ["html2wt"],
29752 "scrubWikitext": false
29753 }
29754 !! html/parsoid
29755 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
29756 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
29757 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
29758 !! wikitext
29759 [[Berlin ]]<nowiki/>is the capital of Germany.
29760
29761 [[Foo ]]'''bar'''
29762
29763 [[Boston ]] is a city.
29764 !! end
29765
29766 !! test
29767 2. New links that end in spaces
29768 !! options
29769 parsoid={
29770 "modes": ["html2wt"],
29771 "scrubWikitext": true
29772 }
29773 !! html/parsoid
29774 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
29775 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
29776 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
29777 !! wikitext
29778 [[Berlin]] is the capital of Germany.
29779
29780 [[Foo]] '''bar'''
29781
29782 [[Boston]] is a city.
29783 !! end
29784
29785 !! test
29786 1. Table cells with escapable prefixes
29787 !! options
29788 parsoid={
29789 "modes": ["html2wt"],
29790 "scrubWikitext": false
29791 }
29792 !! html
29793 <table>
29794 <tr><td>a</td></tr>
29795 <tr><td>-</td></tr>
29796 <tr><td>+</td></tr>
29797 </table>
29798 !! wikitext
29799 {|
29800 |a
29801 |-
29802 |<nowiki>-</nowiki>
29803 |-
29804 |<nowiki>+</nowiki>
29805 |}
29806 !! end
29807
29808 !! test
29809 2. Table cells with escapable prefixes
29810 !! options
29811 parsoid={
29812 "modes": ["html2wt"],
29813 "scrubWikitext": true
29814 }
29815 !! html
29816 <table>
29817 <tr><td>a</td></tr>
29818 <tr><td>-</td></tr>
29819 <tr><td>+</td></tr>
29820 </table>
29821 !! wikitext
29822 {|
29823 |a
29824 |-
29825 | -
29826 |-
29827 | +
29828 |}
29829 !! end
29830
29831 !! test
29832 3a. Table cells with escapable prefixes after edits
29833 !! options
29834 parsoid={
29835 "modes": ["selser"],
29836 "scrubWikitext": true,
29837 "changes": [
29838 [ "table tbody tr:first-child td:first-child", "remove"]
29839 ]
29840 }
29841 !! wikitext
29842 {|
29843 |a||-
29844 |}
29845 !! wikitext/edited
29846 {|
29847 | -
29848 |}
29849 !! end
29850
29851 !! test
29852 3b. Table cells with escapable prefixes after edits
29853 !! options
29854 parsoid={
29855 "modes": ["selser"],
29856 "scrubWikitext": true,
29857 "changes": [
29858 [ "table tbody tr:first-child td:first-child", "html", "-" ],
29859 [ "#x", "remove" ]
29860 ]
29861 }
29862 !! wikitext
29863 {|
29864 |pqr
29865 |<span id="x">foo</span>+
29866 |}
29867 !! wikitext/edited
29868 {|
29869 | -
29870 | +
29871 |}
29872 !! end
29873
29874 # FIXME: This test will fail because
29875 # normalization doesn't realize that the id attribute
29876 # will eliminate the escapable scenario
29877 !! test
29878 4a. Table cells without escapable prefixes after edits
29879 !! options
29880 parsoid={
29881 "modes": ["selser"],
29882 "scrubWikitext": true,
29883 "changes": [
29884 [ "#x", "html", "-" ]
29885 ]
29886 }
29887 !! wikitext
29888 {|
29889 | id="x" |abcd
29890 |}
29891 !! wikitext/edited
29892 {|
29893 | id="x" |-
29894 |}
29895 !! end
29896
29897 ## This tests normalizer's ability to discriminate between
29898 ## cells having identical content.
29899 !! test
29900 4b. Table cells without escapable prefixes after edits
29901 !! options
29902 parsoid={
29903 "modes": ["selser"],
29904 "scrubWikitext": true,
29905 "changes": [
29906 [ "td", "html", "-" ]
29907 ]
29908 }
29909 !! wikitext
29910 {|
29911 |a||b
29912 |}
29913 !! wikitext/edited
29914 {|
29915 | -||-
29916 |}
29917 !! end
29918
29919 ## This tests normalizer's ability to not be tripped by
29920 ## comments (and whitespace)
29921 !! test
29922 4c. Table cells without escapable prefixes after edits
29923 !! options
29924 parsoid={
29925 "modes": ["selser"],
29926 "scrubWikitext": true,
29927 "changes": [
29928 [ "table tbody tr td:first-child", "remove" ]
29929 ]
29930 }
29931 !! wikitext
29932 {|
29933 |-
29934 <!--foo--> |a||-
29935 |}
29936 !! wikitext/edited
29937 {|
29938 |-
29939 <!--foo--> | -
29940 |}
29941 !! end
29942
29943 ## This tests normalizer's ability to handle HTML cells
29944 !! test
29945 4d. Table cells without escapable prefixes after edits
29946 !! options
29947 parsoid={
29948 "modes": ["selser"],
29949 "scrubWikitext": true,
29950 "changes": [
29951 [ "td", "html", "-" ]
29952 ]
29953 }
29954 !! wikitext
29955 <table>
29956 <tr><td>a</td></tr>
29957 </table>
29958 !! wikitext/edited
29959 <table>
29960 <tr><td>-</td></tr>
29961 </table>
29962 !! end
29963
29964 ## T111151 Remove font elements without attributes
29965 !! test
29966 5a. font tags without attributes should be dropped in scrubWikitext mode
29967 !! options
29968 parsoid={
29969 "modes": ["html2wt"],
29970 "scrubWikitext": true
29971 }
29972 !! html
29973 <font>foo</font>
29974 <font><font>bar</font></font>
29975 <font class="x">boo</font>
29976 !! wikitext
29977 foo
29978 bar
29979 <font class="x">boo</font>
29980 !! end
29981
29982 !! test
29983 5b. font tags should not be dropped without scrubWikitext being enabled
29984 !! options
29985 parsoid={
29986 "modes": ["html2wt"],
29987 "scrubWikitext": false
29988 }
29989 !! html
29990 <font>foo</font>
29991 !! wikitext
29992 <font>foo</font>
29993 !! end
29994
29995 !! test
29996 Escape nowiki DOM elements
29997 !! options
29998 parsoid=html2wt
29999 !! html/parsoid
30000 <nowiki><i>foo</i></nowiki>
30001 !! wikitext
30002 &lt;nowiki&gt;''foo''&lt;/nowiki&gt;
30003 !! end
30004
30005 # This is meant to be an interim fix while we go about figuring out
30006 # how to not introduce these trailing <nowiki/>s in the first place.
30007 !! test
30008 T115717: Strip trailing <nowiki/>s (without affecting valid uses)
30009 !! options
30010 parsoid=html2wt
30011 !! html/parsoid
30012 <p>x<meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/>
30013 y</p>
30014 <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>
30015 <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>
30016 !! wikitext
30017 x
30018 y
30019
30020 {{echo|
30021 1 = <nowiki/>}}
30022
30023 {{echo|
30024 1 = <nowiki/>
30025 }}
30026 !! end
30027
30028 !! test
30029 New list is serialized on newlines
30030 !! options
30031 parsoid=html2wt
30032 !! html/parsoid
30033 <p>The quick brown fox jumps over the lazy dog.</p><ul>
30034 <li>Yesterday</li>
30035 <li>Today</li>
30036 <li>Tomorrow</li>
30037 </ul><p>The quick onyx goblin jumps over the lazy dwarf.</p>
30038 !! wikitext
30039 The quick brown fox jumps over the lazy dog.
30040
30041 * Yesterday
30042 * Today
30043 * Tomorrow
30044
30045 The quick onyx goblin jumps over the lazy dwarf.
30046 !! end
30047
30048 !! test
30049 New lists in formatting elements serialized w/o newlines
30050 !! options
30051 parsoid=html2wt
30052 !! html/parsoid
30053 <small>
30054
30055 <ul>
30056 <li>123</li>
30057 </ul>
30058
30059 </small>
30060
30061 <small><ul><li>hi</li></ul></small>
30062 !! wikitext
30063 <small>
30064 * 123
30065 </small>
30066
30067 <small>
30068 * hi
30069 </small>
30070 !! end
30071
30072 !! test
30073 New list in table doesn't need newlines
30074 !! options
30075 parsoid=html2wt
30076 !! html/parsoid
30077 <table><tr><td><ul><li>test</li><li>123</li></td></tr></table>
30078 !! wikitext
30079 {|
30080 |
30081 * test
30082 * 123
30083 |}
30084 !! end
30085
30086 # ---------------------------------------------------
30087 # End of tests spec'ing wikitext serialization norms |
30088 # ---------------------------------------------------
30089
30090 # T104032
30091 !! test
30092 Bare inline nodes not wrapped inside p-tags should be treated as p-wrapped
30093 !! options
30094 parsoid=html2wt
30095 !! html/parsoid
30096 a<p>b</p>
30097 <b>c</b><p>d</p>
30098 <table><tr>
30099 <td>a<p>b</p></td>
30100 <td><b>c</b><p>d</p></td>
30101 </tr></table>
30102 !! wikitext
30103 a
30104
30105 b
30106
30107 '''c'''
30108
30109 d
30110 {|
30111 |a
30112 b
30113 |'''c'''
30114 d
30115 |}
30116 !! end
30117
30118 !! test
30119 Anchor without href scenarios
30120 !! options
30121 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
30122 !! html/parsoid
30123 <a class="bc"></a>
30124 <a class="no">dice</a>
30125 <a name="foo"></a>
30126 !! wikitext
30127
30128 dice
30129 <span name="foo"></span>
30130 !! end
30131
30132 !! test
30133 New transclusion added after a list should be serialized after the list
30134 !! options
30135 parsoid=html2wt
30136 !! html/parsoid
30137 <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>
30138 !! wikitext
30139 * a
30140 {{echo|foo}}
30141 !! end
30142
30143 # -----------------------------------------------------------------
30144 # End of section for Parsoid-only html2wt tests for serialization
30145 # of new content
30146 # -----------------------------------------------------------------
30147
30148 # -----------------------------------------------------------------
30149 # The following section of tests are primarily to spec behavior of
30150 # the selective serializer. All these tests have manual selser
30151 # changes. The automated selser changes for all tests handle the
30152 # wide variation of changes, but these tests here capture specs
30153 # deterministically.
30154 # ----------------------------------------------------------------
30155
30156 ## T90517
30157 !! test
30158 Selser: New comments should not be lost
30159 !! options
30160 parsoid={
30161 "modes": ["selser"],
30162 "changes": [
30163 [ "#a", "after", "<!--c1-->" ],
30164 [ "#b", "before", "<!--c2-->" ]
30165 ]
30166 }
30167 !! wikitext
30168 <span id="a">a</span>
30169
30170 <span id="b">b</span>
30171 !! wikitext/edited
30172 <span id="a">a</span><!--c1-->
30173
30174 <!--c2--><span id="b">b</span>
30175 !! end
30176
30177 ## T89383
30178 !! test
30179 Selser: Check for validity of DSR before using it
30180 !! options
30181 parsoid={
30182 "modes": ["selser"],
30183 "changes": [
30184 [ "#a", "before", "<meta property='mw:PageProp/displaytitle' content='foo'>" ]
30185 ]
30186 }
30187 !! wikitext
30188 <span id="a">a</span>
30189 !! wikitext/edited
30190 {{DISPLAYTITLE:foo}}
30191 <span id="a">a</span>
30192 !! end
30193
30194 !! test
30195 1. DOMDiff: Changes to <ref> content should be looked up using id
30196 !! options
30197 parsoid={
30198 "modes": ["selser"],
30199 "changes": [
30200 ["#X", "after", "bar"],
30201 ["#Y", "after", "baz"]
30202 ]
30203 }
30204 !! wikitext
30205 X <ref><span id="X">foo</span></ref>
30206 Y <ref name="a" />
30207 <references>
30208 <ref name="a"><span id="Y">foo</span></ref>
30209 </references>
30210 !! wikitext/edited
30211 X <ref><span id="X">foo</span>bar</ref>
30212 Y <ref name="a" />
30213 <references>
30214 <ref name="a"><span id="Y">foo</span>baz</ref>
30215 </references>
30216 !! end
30217
30218 !! test
30219 2. DOMDiff: Changes to <ref> content should be looked up using id
30220 !! options
30221 parsoid={
30222 "modes": ["selser"],
30223 "changes": [
30224 ["#Z", "after", "bar"]
30225 ]
30226 }
30227 !! wikitext
30228 A <ref>foo bar for a</ref>
30229 B <ref group="X" name="b" />
30230
30231 <references />
30232
30233 <references group="X">
30234 <ref name="b"><span id="Z">foo</span></ref>
30235 </references>
30236 !! wikitext/edited
30237 A <ref>foo bar for a</ref>
30238 B <ref group="X" name="b" />
30239
30240 <references />
30241
30242 <references group="X">
30243 <ref name="b"><span id="Z">foo</span>bar</ref>
30244 </references>
30245 !! end
30246
30247 !! test
30248 DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388)
30249 !! options
30250 parsoid={
30251 "modes": ["selser"],
30252 "changes": [
30253 [ "div:first-child", "text", "bar" ]
30254 ]
30255 }
30256 !! wikitext
30257 <div style="{{1x|color:red;}}%">foo</div>
30258 !! wikitext/edited
30259 <div style="{{1x|color:red;}}%">bar</div>
30260 !! end
30261
30262 !! test
30263 Empty LI (T49673)
30264 !! wikitext
30265 *a
30266 *
30267 *
30268 *b
30269 !! html+tidy
30270 <ul><li>a</li>
30271 <li class="mw-empty-elt"></li>
30272 <li class="mw-empty-elt"></li>
30273 <li>b</li></ul>
30274 !! end
30275
30276 !! test
30277 Thumbnail output
30278 !! wikitext
30279 [[File:Thumb.png|thumb]]
30280 !! html/php+tidy
30281 <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>
30282 !! html/parsoid
30283 <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>
30284 !! end
30285
30286 !! test
30287 unclosed internal link XSS (T137264)
30288 !! wikitext
30289 [[#%3Cscript%3Ealert(1)%3C/script%3E|
30290 !! html/php
30291 <p>[[#&lt;script&gt;alert(1)&lt;/script&gt;|
30292 </p>
30293 !! html/parsoid
30294 <p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p>
30295 !! end
30296
30297 !! test
30298 Validating that <style> isn't eaten by tidy (T167349)
30299 !! options
30300 styletag=1
30301 !! wikitext
30302 <div class="foo">
30303 <style>.foo::before { content: "<foo>"; }</style>
30304 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
30305 </div>
30306 !! html/php+tidy
30307 <div class="foo">
30308 <style>.foo::before { content: "<foo>"; }</style>
30309 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
30310 </div>
30311 !! end
30312
30313 !! test
30314 Validating that <style> isn't wrapped in a paragraph (T186965)
30315 !! options
30316 styletag=1
30317 !! wikitext
30318 A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
30319
30320 <style>.foo::before { content: "<foo>"; }</style>
30321
30322 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
30323
30324 But if it's on a line with other content, let it be wrapped.
30325
30326 <style>.foo::before { content: "<foo>"; }</style> bar
30327
30328 foo <style>.foo::before { content: "<foo>"; }</style>
30329
30330 foo <style>.foo::before { content: "<foo>"; }</style> bar
30331
30332 And the same if we have non-paragraph-breaking whitespace
30333
30334 foo
30335 <style>.foo::before { content: "<foo>"; }</style>
30336 bar
30337 !! html/php
30338 <p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
30339 </p>
30340 <style>.foo::before { content: "<foo>"; }</style>
30341 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
30342 <p>But if it's on a line with other content, let it be wrapped.
30343 </p><p><style>.foo::before { content: "<foo>"; }</style> bar
30344 </p><p>foo <style>.foo::before { content: "<foo>"; }</style>
30345 </p><p>foo <style>.foo::before { content: "<foo>"; }</style> bar
30346 </p><p>And the same if we have non-paragraph-breaking whitespace
30347 </p><p>foo
30348 <style>.foo::before { content: "<foo>"; }</style>
30349 bar
30350 </p>
30351 !! end
30352
30353 !! test
30354 Validating that <link> isn't wrapped in a paragraph (T186965)
30355 !! options
30356 styletag=1
30357 !! wikitext
30358 A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
30359
30360 <link rel="foo" href="bar"/>
30361
30362 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
30363
30364 But if it's on a line with other content, let it be wrapped.
30365
30366 <link rel="foo" href="bar"/> bar
30367
30368 foo <link rel="foo" href="bar"/>
30369
30370 foo <link rel="foo" href="bar"/> bar
30371
30372 And the same if we have non-paragraph-breaking whitespace
30373
30374 foo
30375 <link rel="foo" href="bar"/>
30376 bar
30377 !! html/php
30378 <p>A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
30379 </p>
30380 <link rel="foo" href="bar"/>
30381 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
30382 <p>But if it's on a line with other content, let it be wrapped.
30383 </p><p><link rel="foo" href="bar"/> bar
30384 </p><p>foo <link rel="foo" href="bar"/>
30385 </p><p>foo <link rel="foo" href="bar"/> bar
30386 </p><p>And the same if we have non-paragraph-breaking whitespace
30387 </p><p>foo
30388 <link rel="foo" href="bar"/>
30389 bar
30390 </p>
30391 !! end
30392
30393 !! test
30394 Decoding of HTML entities in headings and links for IDs and link fragments (T103714)
30395 !! config
30396 wgFragmentMode=[ 'html5', 'legacy' ]
30397 !! wikitext
30398 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
30399 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
30400 !! html/php
30401 <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>
30402 <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>
30403 </p>
30404 !! html/parsoid
30405 <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>
30406 <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>
30407 !! end
30408
30409 !! test
30410 Decoding of HTML entities in headings and links for IDs and link fragments (T103714) (legacy)
30411 !! config
30412 wgFragmentMode=[ 'legacy' ]
30413 !! wikitext
30414 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
30415 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
30416 !! html/php
30417 <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>
30418 <p><a href="#A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a>
30419 </p>
30420 !! end
30421
30422 !! test
30423 Decoding of HTML entities in embedded HTML tags
30424 !! wikitext
30425 <table class="1&2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
30426 !! html/php
30427 <table class="1&amp;2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
30428
30429 !! html/parsoid
30430 <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>
30431 !! end
30432
30433 !! test
30434 Decoding of HTML entities in indicator names for IDs (T104196)
30435 !! options
30436 parsoid=wt2html,html2html
30437 showindicators
30438 !! wikitext
30439 <indicator name="1&2&amp;3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
30440 !! html/php
30441 1&2&3&amp;4&amp;amp;5=Indicator
30442
30443 !! html/parsoid
30444 <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>
30445 !! end
30446
30447 # this version of the test strips out the ambiguity so Parsoid rts cleanly
30448 !! test
30449 Decoding of HTML entities in indicator names for IDs (unambiguous) (T104196)
30450 !! options
30451 showindicators
30452 !! wikitext
30453 <indicator name="1&2&3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
30454 !! html/php
30455 1&2&3&amp;4&amp;amp;5=Indicator
30456
30457 !! html/parsoid
30458 <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>
30459 !! end
30460
30461 # This fragment mode is what Parsoid supports.
30462 !! test
30463 HTML5 ids: fallback to legacy
30464 !! config
30465 wgFragmentMode=[ 'html5', 'legacy' ]
30466 !! wikitext
30467 ==Foo bar==
30468
30469 ==foo Bar==
30470
30471 ==Тест==
30472
30473 ==Тест==
30474
30475 ==тест==
30476
30477 ==Hey < # " > % : '==
30478 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
30479
30480 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
30481
30482 <!-- These two links should produce identical HTML -->
30483 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
30484
30485 !! html/php
30486 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
30487 <ul>
30488 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
30489 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
30490 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
30491 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
30492 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
30493 <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>
30494 </ul>
30495 </div>
30496
30497 <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>
30498 <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>
30499 <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>
30500 <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>
30501 <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>
30502 <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>
30503 <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>
30504 </p><p>💩 <span id="💩"></span>
30505 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
30506 </p>
30507 !! html/parsoid
30508 <h2 id="Foo_bar">Foo bar</h2>
30509
30510 <h2 id="foo_Bar_2">foo Bar</h2>
30511
30512 <h2 id="Тест"><span id=".D0.A2.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>Тест</h2>
30513
30514 <h2 id="Тест_2"><span id=".D0.A2.D0.B5.D1.81.D1.82_2" typeof="mw:FallbackId"></span>Тест</h2>
30515
30516 <h2 id="тест"><span id=".D1.82.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>тест</h2>
30517
30518 <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>
30519 <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>
30520
30521 <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>
30522
30523 <!-- These two links should produce identical HTML -->
30524 <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>
30525 !! end
30526
30527 # Parsoid doesn't support this mode
30528 !! test
30529 HTML5 ids: legacy with a fallback to modern
30530 !! config
30531 wgFragmentMode=[ 'legacy', 'html5' ]
30532 !! wikitext
30533 ==Foo bar==
30534
30535 ==foo Bar==
30536
30537 ==Тест==
30538
30539 ==Тест==
30540
30541 ==тест==
30542
30543 ==Hey < # " > % : '==
30544 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
30545
30546 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
30547
30548 <!-- These two links should produce identical HTML -->
30549 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
30550
30551 !! html/php
30552 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
30553 <ul>
30554 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
30555 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
30556 <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>
30557 <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>
30558 <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>
30559 <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>
30560 </ul>
30561 </div>
30562
30563 <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>
30564 <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>
30565 <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>
30566 <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>
30567 <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>
30568 <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>
30569 <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>
30570 </p><p>.F0.9F.92.A9 <span id=".F0.9F.92.A9"></span>
30571 </p><p><a href="#.E5.95.A4.E9.85.92">#啤酒</a> <a href="#.E5.95.A4.E9.85.92">#啤酒</a>
30572 </p>
30573 !! end
30574
30575 # Parsoid doesn't support this mode.
30576 !! test
30577 HTML5 ids: no legacy
30578 !! config
30579 wgFragmentMode=[ 'html5' ]
30580 !! wikitext
30581 ==Foo bar==
30582
30583 ==foo Bar==
30584
30585 ==Тест==
30586
30587 ==Тест==
30588
30589 ==тест==
30590
30591 ==Hey < # " > % : '==
30592 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
30593
30594 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
30595
30596 <!-- These two links should produce identical HTML -->
30597 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
30598
30599 !! html/php
30600 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
30601 <ul>
30602 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
30603 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
30604 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
30605 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
30606 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
30607 <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>
30608 </ul>
30609 </div>
30610
30611 <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>
30612 <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>
30613 <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>
30614 <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>
30615 <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>
30616 <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>
30617 <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>
30618 </p><p>💩 <span id="💩"></span>
30619 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
30620 </p>
30621 !! end
30622
30623 !! test
30624 T90902: Normalize weird characters in section IDs
30625 !! config
30626 wgFragmentMode=[ 'html5', 'legacy' ]
30627 !! wikitext
30628 ==Foo&nbsp;bar==
30629 [[#Foo&nbsp;bar]]
30630
30631 !! html/php
30632 <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>
30633 <p><a href="#Foo_bar">#Foo&#160;bar</a>
30634 </p>
30635 !! html/parsoid
30636 <h2 id="Foo_bar"> Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span>bar </h2>
30637 <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>
30638 !! end
30639
30640 !! test
30641 T51672: Test for brackets in attributes of elements in external link texts
30642 !! wikitext
30643 [http://example.com/ link <span title="title with [brackets]">span</span>]
30644 [http://example.com/ link <span title="title with &#91;brackets&#93;">span</span>]
30645
30646 !! html/php
30647 <p><a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
30648 <a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
30649 </p>
30650 !! html/parsoid
30651 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/">link <span title="title with [brackets]">span</span></a>
30652 <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>
30653 !! end
30654
30655 !! test
30656 T72875: Test for brackets in attributes of elements in internal link texts
30657 !! wikitext
30658 [[Foo|link <span title="title with [[double brackets]]">span</span>]]
30659 [[Foo|link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span>]]
30660
30661 !! html/php
30662 <p><a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
30663 <a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
30664 </p>
30665 !! html/parsoid
30666 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">link <span title="title with [[double brackets]]">span</span></a>
30667 <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>
30668 !! end
30669
30670 !! test
30671 T179544: {{anchorencode:}} output should be always usable in links
30672 !! config
30673 wgFragmentMode=[ 'html5' ]
30674 !! wikitext
30675 <span id="{{anchorencode:[foo]}}"></span>[[#{{anchorencode:[foo]}}]]
30676 !! html/php
30677 <p><span id="&#91;foo&#93;"></span><a href="#[foo]">#&#91;foo&#93;</a>
30678 </p>
30679 !! html/parsoid
30680 <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>
30681 !! end
30682
30683 ## ------------------------------
30684 ## Parsoid section-wrapping tests
30685 ## ------------------------------
30686 !! test
30687 Section wrapping for well-nested sections (no leading content)
30688 !! options
30689 parsoid={
30690 "wrapSections": true
30691 }
30692 !! wikitext
30693 =1=
30694 a
30695
30696 =2=
30697 b
30698
30699 ==2.1==
30700 c
30701
30702 ==2.2==
30703 d
30704
30705 ===2.2.1===
30706 e
30707
30708 =3=
30709 f
30710 !! html/parsoid
30711 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
30712 <p>a</p>
30713
30714 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
30715 <p>b</p>
30716
30717 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
30718 <p>c</p>
30719
30720 </section><section data-mw-section-id="4"><h2 id="2.2">2.2</h2>
30721 <p>d</p>
30722
30723 <section data-mw-section-id="5"><h3 id="2.2.1">2.2.1</h3>
30724 <p>e</p>
30725
30726 </section></section></section><section data-mw-section-id="6"><h1 id="3">3</h1>
30727 <p>f</p>
30728
30729 </section>
30730 !! end
30731
30732 !! test
30733 Section wrapping for well-nested sections (with leading content)
30734 !! options
30735 parsoid={
30736 "wrapSections": true
30737 }
30738 !! wikitext
30739 Para 1.
30740
30741 Para 2 with a <div>nested in it</div>
30742
30743 Para 3.
30744
30745 =1=
30746 a
30747
30748 =2=
30749 b
30750
30751 ==2.1==
30752 c
30753 !! html/parsoid
30754 <section data-mw-section-id="0"><p>Para 1.</p>
30755
30756 <p>Para 2 with a </p><div>nested in it</div>
30757
30758 <p>Para 3.</p>
30759
30760 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
30761 <p>a</p>
30762
30763 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
30764 <p>b</p>
30765
30766 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
30767 <p>c</p>
30768
30769 </section></section>
30770 !! end
30771
30772 !! test
30773 Section wrapping with template-generated sections (good nesting 1)
30774 !! options
30775 parsoid={
30776 "wrapSections": true
30777 }
30778 !! wikitext
30779 =1=
30780 a
30781
30782 {{echo|1=
30783 ==1.1==
30784 b
30785 }}
30786
30787 ==1.2==
30788 c
30789
30790 =2=
30791 d
30792 !! html/parsoid
30793 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
30794 <p>a</p>
30795
30796 <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">
30797 </span><p about="#mwt1">b</p>
30798 </section><section data-mw-section-id="3"><h2 id="1.2">1.2</h2>
30799 <p>c</p>
30800
30801 </section></section><section data-mw-section-id="4"><h1 id="2">2</h1>
30802 <p>d</p></section>
30803 !! end
30804
30805 # In this example, the template scope is mildly expanded to incorporate the
30806 # trailing newline after the transclusion since that is part of section 1.1.1
30807 !! test
30808 Section wrapping with template-generated sections (good nesting 2)
30809 !! options
30810 parsoid={
30811 "wrapSections": true,
30812 "modes": ["wt2html", "wt2wt"]
30813 }
30814 !! wikitext
30815 =1=
30816 a
30817
30818 {{echo|1=
30819 ==1.1==
30820 b
30821 ===1.1.1===
30822 d
30823 }}
30824 =2=
30825 e
30826 !! html/parsoid
30827 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
30828 <p>a</p>
30829
30830 <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">
30831 </span><p about="#mwt1">b</p><span about="#mwt1">
30832 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.1.1">1.1.1</h3><span about="#mwt1">
30833 </span><p about="#mwt1">d</p><span about="#mwt1">
30834 </span></section></section></section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="2">2</h1>
30835 <p>e</p></section>
30836 !! end
30837
30838 # In this example, the template scope is mildly expanded to incorporate the
30839 # trailing newline after the transclusion since that is part of section 1.2.1
30840 !! test
30841 Section wrapping with template-generated sections (good nesting 3)
30842 !! options
30843 parsoid={
30844 "wrapSections": true,
30845 "modes": ["wt2html", "wt2wt"]
30846 }
30847 !! wikitext
30848 =1=
30849 a
30850
30851 {{echo|1=
30852 x
30853 ==1.1==
30854 b
30855 ==1.2==
30856 c
30857 ===1.2.1===
30858 d
30859 }}
30860 =2=
30861 e
30862 !! html/parsoid
30863 <section data-mw-section-id="0"></section><section data-mw-section-id="1" data-parsoid="{}"><h1 id="1"> 1 </h1>
30864 <p>a</p>
30865
30866 <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">
30867 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.1">1.1</h2><span about="#mwt1">
30868 </span><p about="#mwt1">b</p><span about="#mwt1">
30869 </span></section><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.2">1.2</h2><span about="#mwt1">
30870 </span><p about="#mwt1">c</p><span about="#mwt1">
30871 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.2.1">1.2.1</h3><span about="#mwt1">
30872 </span><p about="#mwt1">d</p><span about="#mwt1">
30873 </span></section></section></section><section data-mw-section-id="5"><h1 id="2">2</h1>
30874 <p>e</p></section>
30875 !! end
30876
30877 # Because of section-wrapping and template-wrapping interactions,
30878 # the scope of the template is expanded so that the template markup
30879 # is valid in the presence of <section> tags.
30880 # This exercises the s1 is null scenario in the wrapSections code
30881 !! test
30882 Section wrapping with template-generated sections (bad nesting 1)
30883 !! options
30884 parsoid={
30885 "wrapSections": true
30886 }
30887 !! wikitext
30888 <div>
30889 a
30890
30891 {{echo|
30892 =1=
30893 b
30894 }}
30895
30896 c
30897 </div>
30898 !! html/parsoid
30899 <section data-mw-section-id="-1"></section><section data-mw-section-id="-2"><div data-parsoid='{"stx":"html"}'>
30900 <p>a</p>
30901
30902 <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"]}'>
30903 </span><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="1">1</h1><span about="#mwt1">
30904 </span><p about="#mwt1">b
30905 </p><span about="#mwt1">
30906
30907 </span><p about="#mwt1">c</p><span about="#mwt1">
30908 </span></section></div></section>
30909 !! end
30910
30911 # Because of section-wrapping and template-wrapping interactions,
30912 # the scope of the template is expanded so that the template markup
30913 # is valid in the presence of <section> tags.
30914 # This exercises the s1 is ancestor of s2 scenario in the wrapSections code
30915 !! test
30916 Section wrapping with template-generated sections (bad nesting 2)
30917 !! options
30918 parsoid={
30919 "wrapSections": true
30920 }
30921 !! wikitext
30922 =1=
30923 a
30924
30925 {{echo|1=
30926 =2=
30927 b
30928 ==2.1==
30929 c
30930 }}
30931
30932 d
30933
30934 =3=
30935 e
30936 !! html/parsoid
30937 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
30938 <p>a</p>
30939
30940 </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">
30941 </span><p about="#mwt1">b</p><span about="#mwt1">
30942 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="2.1">2.1</h2><span about="#mwt1">
30943 </span><p about="#mwt1">c</p><span about="#mwt1">
30944
30945 </span><p about="#mwt1">d</p><span about="#mwt1">
30946
30947 </span></section></section><section data-mw-section-id="4"><h1 id="3">3</h1>
30948 <p>e</p></section>
30949 !! end
30950
30951 # Because of section-wrapping and template-wrapping interactions,
30952 # additional template wrappers are added to <section> tags
30953 # so that template wrapping semantics are valid whether section
30954 # tags are retained or stripped. But, the template scope can expand
30955 # greatly when accounting for section tags.
30956 # This exercises the s1 and s2 are in different subtrees scenario
30957 !! test
30958 Section wrapping with template-generated sections (bad nesting 3)
30959 !! options
30960 parsoid={
30961 "wrapSections": true,
30962 "modes": ["wt2html", "wt2wt"]
30963 }
30964 !! wikitext
30965 =1=
30966 a
30967
30968 {{echo|1=
30969 ==1.2==
30970 b
30971 =2=
30972 c
30973 }}
30974
30975 d
30976
30977 =3=
30978 e
30979 !! html/parsoid
30980 <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>
30981 <p>a</p>
30982
30983 <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">
30984 </span><p about="#mwt1">b</p><span about="#mwt1">
30985 </span></section></section><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="2">2</h1><span about="#mwt1">
30986 </span><p about="#mwt1">c</p>
30987
30988 <p>d</p>
30989 </section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="3">3</h1>
30990 <p>e</p></section>
30991 !! end
30992
30993 !! test
30994 Section wrapping with uneditable lead section + div wrapping multiple sections
30995 !! options
30996 parsoid={
30997 "wrapSections": true
30998 }
30999 !! wikitext
31000 foo
31001
31002 <div style="border:1px solid red;">
31003 =1=
31004 a
31005
31006 ==1.1==
31007 b
31008
31009 =2=
31010 c
31011 </div>
31012
31013 =3=
31014 d
31015
31016 ==3.1==
31017 e
31018 !! html/parsoid
31019 <section data-mw-section-id="-1"><p>foo</p>
31020
31021 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
31022 <section data-mw-section-id="1"><h1 id="1">1</h1>
31023 <p>a</p>
31024
31025 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
31026 <p>b</p>
31027
31028 </section></section><section data-mw-section-id="-1"><h1 id="2">2</h1>
31029 <p>c</p>
31030 </section></div>
31031
31032 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
31033 <p>d</p>
31034
31035 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
31036 <p>e</p>
31037 </section></section>
31038 !! end
31039
31040 !! test
31041 Section wrapping with editable lead section + div overlapping multiple sections
31042 !! options
31043 parsoid={
31044 "wrapSections": true
31045 }
31046 !! wikitext
31047 foo
31048
31049 =1=
31050 a
31051 <div style="border:1px solid red;">
31052 b
31053
31054 ==1.1==
31055 c
31056
31057 =2=
31058 d
31059 </div>
31060 e
31061
31062 =3=
31063 f
31064
31065 ==3.1==
31066 g
31067 !! html/parsoid
31068 <section data-mw-section-id="0"><p>foo</p>
31069
31070 </section><section data-mw-section-id="-1"><h1 id="1">1</h1>
31071 <p>a</p>
31072 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
31073 <p>b</p>
31074
31075 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
31076 <p>c</p>
31077
31078 </section><section data-mw-section-id="-1"><h1 id="2">2</h1>
31079 <p>d</p>
31080 </section></div>
31081 <p>e</p>
31082
31083 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
31084 <p>f</p>
31085
31086 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
31087 <p>g</p>
31088 </section></section>
31089 !! end
31090
31091 !! test
31092 HTML header tags should not be wrapped in section tags
31093 !! options
31094 parsoid={
31095 "wrapSections": true
31096 }
31097 !! wikitext
31098 foo
31099
31100 <h1>a</h1>
31101
31102 =b=
31103
31104 <h1>c</h1>
31105
31106 =d=
31107 !! html/parsoid
31108 <section data-mw-section-id="0"><p>foo</p>
31109
31110 <h1 id="a" data-parsoid='{"stx":"html"}'>a</h1>
31111
31112 </section><section data-mw-section-id="1"><h1 id="b">b</h1>
31113
31114 <h1 id="c" data-parsoid='{"stx":"html"}'>c</h1>
31115
31116 </section><section data-mw-section-id="2"><h1 id="d">d</h1></section>
31117 !! end
31118
31119 !! test
31120 Lead section containing only whitespace and comments.
31121 !! options
31122 parsoid={
31123 "wrapSections": true
31124 }
31125 !! wikitext
31126
31127 <!-- this is a comment, presumably significant to editors -->
31128 =1=
31129 a
31130
31131 =2=
31132 b
31133 !! html/parsoid
31134 <section data-mw-section-id="0" data-parsoid="{}">
31135 <!-- this is a comment, presumably significant to editors -->
31136 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
31137 <p>a</p>
31138
31139 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
31140 <p>b</p></section>
31141 !! end
31142
31143 !! test
31144 Pseudo-sections emitted by templates should have id -2
31145 !! options
31146 parsoid={
31147 "wrapSections": true
31148 }
31149 !! wikitext
31150 foo
31151 {{echo|<div>
31152 ==a==
31153 ==b==
31154 </div>
31155 }}
31156 !! html/parsoid
31157 <section data-mw-section-id="-1"><p>foo</p>
31158 </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}}]}'>
31159 <section data-mw-section-id="-1"><h2 id="a">a</h2>
31160 </section><section data-mw-section-id="-1"><h2 id="b">b</h2>
31161 </section></div><span about="#mwt1">
31162 </span></section>
31163 !! end
31164
31165 ##########################################################################
31166 Tests demonstrating white-space insensitivity in input wikitext
31167 for wikitext headings, wikitext list items, and wikitext table captions,
31168 headings, and cells. HTML versions of the same should preserve whitespace.
31169 ##########################################################################
31170 !! test
31171 Trim whitespace in wikitext headings, list items, table captions, headings, and cells
31172 !! options
31173 parsoid={
31174 "modes": ["wt2html"],
31175 "preserveIEW": true
31176 }
31177 !! wikitext
31178 __NOTOC__
31179 == <!--c1--> <!--c2--> Spaces <!--c3--> <!--c4--> ==
31180 == <!--c1--> <!--c2--> Tabs <!--c3--><!--c4--> ==
31181 == <!--Headings with fallback ids--> Личная жизнь ==
31182 * <!--c1--> <!--c2--> List item <!--c3--> <!--c4-->
31183 ; <!--term to define--> term : <!--term's definition--> definition
31184 {|
31185 |+ <!--c1--> <!--c2--> Table Caption <!--c3--> <!--c4-->
31186 |-
31187 ! <!--c1--> <!--c2--> Table Heading 1 <!--c3--> <!--c4--> !! Table Heading 2 <!--c5-->
31188 |-
31189 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
31190 |-
31191 | class="foo" || <!--c1--> <!--c2--> Table Cell 3 <!--c3--> <!--c4-->
31192 |-
31193 | <!--c1--> testing [[one|two]] <!--c2--> | <!--c3--> some content
31194 |}
31195 : {|
31196 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
31197 |} foo <!--c1-->
31198 !! html/php+tidy
31199 <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>
31200 <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>
31201 <h2><span class="mw-headline" id=".D0.9B.D0.B8.D1.87.D0.BD.D0.B0.D1.8F_.D0.B6.D0.B8.D0.B7.D0.BD.D1.8C">Личная жизнь</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Личная жизнь">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
31202 <ul><li>List item</li></ul>
31203 <dl><dt>term&#160;</dt>
31204 <dd>definition</dd></dl>
31205 <table>
31206 <caption>Table Caption
31207 </caption>
31208 <tbody><tr>
31209 <th>Table Heading 1</th>
31210 <th>Table Heading 2
31211 </th></tr>
31212 <tr>
31213 <td>Table Cell 1</td>
31214 <td>Table Cell 2
31215 </td></tr>
31216 <tr>
31217 <td>class="foo"</td>
31218 <td>Table Cell 3
31219 </td></tr>
31220 <tr>
31221 <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
31222 </td></tr></tbody></table>
31223 <dl><dd><table>
31224 <tbody><tr>
31225 <td>Table Cell 1</td>
31226 <td>Table Cell 2
31227 </td></tr></tbody></table> foo</dd></dl>
31228 !! html/parsoid
31229 <meta property="mw:PageProp/notoc">
31230 <h2 id="Spaces"><!--c1--><!--c2-->Spaces<!--c3--><!--c4--></h2>
31231 <h2 id="Tabs"><!--c1--><!--c2-->Tabs<!--c3--><!--c4--></h2>
31232 <h2 id="Личная_жизнь"><span id=".D0.9B.D0.B8.D1.87.D0.BD.D0.B0.D1.8F_.D0.B6.D0.B8.D0.B7.D0.BD.D1.8C" typeof="mw:FallbackId"></span><!--Headings with fallback ids-->Личная жизнь</h2>
31233 <ul><li><!--c1--><!--c2-->List item<!--c3--><!--c4--></li></ul>
31234 <dl><dt><!--term to define-->term&nbsp;</dt><dd><!--term's definition-->definition</dd></dl>
31235 <table>
31236 <caption><!--c1--><!--c2-->Table Caption<!--c3--><!--c4--></caption>
31237 <tbody><tr>
31238 <th><!--c1--><!--c2-->Table Heading 1<!--c3--><!--c4--></th><th>Table Heading 2<!--c5--></th></tr>
31239 <tr>
31240 <td><!--c1--><!--c2-->Table Cell 1<!--c3--><!--c4--></td><td>Table Cell 2<!--c5--></td></tr>
31241 <tr>
31242 <td>class="foo"</td><td><!--c1--><!--c2-->Table Cell 3<!--c3--><!--c4--></td></tr>
31243 <tr>
31244 <td><!--c1-->testing <a rel="mw:WikiLink" href="./One" title="One">two</a> <!--c2--> | <!--c3--> some content</td></tr>
31245 </tbody></table>
31246 <dl><dd><table>
31247 <tbody><tr><td><!--c1--><!--c2-->Table Cell 1<!--c3--><!--c4--></td><td>Table Cell 2<!--c5--></td></tr>
31248 </tbody></table><p> foo </p><!--c1--></dd></dl>
31249 !! end
31250
31251 # Looks like <caption> is not accepted in HTML
31252 !! test
31253 Do not trim whitespace in HTML headings, list items, table captions, headings, and cells
31254 !! options
31255 parsoid={
31256 "modes": ["wt2html"],
31257 "preserveIEW": true
31258 }
31259 !! wikitext
31260 __NOTOC__
31261 <h2> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
31262 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
31263 <table>
31264 <tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> <th></tr>
31265 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> <th></tr>
31266 </table>
31267 !! html/php+tidy
31268 <h2><span class="mw-headline" id="Heading"> Heading </span></h2>
31269 <ul><li> List item </li></ul>
31270 <table>
31271 <tbody><tr><th> Table Heading </th><th></th></tr>
31272 <tr><td> Table Cell </td><th></th></tr>
31273 </tbody></table>
31274 !! html/parsoid
31275 <meta property="mw:PageProp/notoc"/>
31276 <h2 id="Heading"> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
31277 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
31278 <table>
31279 <tbody><tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> </th><th></th></tr>
31280 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> </td><th></th></tr>
31281 </tbody></table>
31282 !! end
31283
31284 !! test
31285 Do not trim whitespace in links and quotes
31286 !! options
31287 parsoid={
31288 "modes": ["wt2html"],
31289 "preserveIEW": true
31290 }
31291 !! wikitext
31292 foo '' <!--c1--> italic <!--c2--> '' and ''' <!--c3--> bold <!--c4--> '''
31293 [[Foo| some text ]]
31294 !! html/php+tidy
31295 <p>foo <i> italic </i> and <b> bold </b>
31296 <a href="/wiki/Foo" title="Foo"> some text </a>
31297 </p>
31298 !! html/parsoid
31299 <p>foo <i> <!--c1--> italic <!--c2--> </i> and <b> <!--c3--> bold <!--c4--> </b>
31300 <a rel="mw:WikiLink" href="./Foo" title="Foo"> some text </a></p>
31301 !! end
31302
31303 !! test
31304 Remove p tags surrounding a single element in a figcaption
31305 !! options
31306 parsoid=html2wt
31307 !! wikitext
31308 [[File:Foobar.jpg|right|200x200px|Caption]]
31309 !! html/parsoid
31310 <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>
31311 !! end
31312
31313 !! test
31314 Selser preserves lack of newline before list and allows newline after the list
31315 !! options
31316 parsoid={
31317 "modes": ["selser"],
31318 "scrubWikitext": true,
31319 "changes": [
31320 [ "ul", "after", "<p>footer</p>" ]
31321 ]
31322 }
31323 !! wikitext
31324 header
31325 *foo
31326 *bar
31327 !! wikitext/edited
31328 header
31329 *foo
31330 *bar
31331
31332 footer
31333 !! end
31334
31335
31336 !! test
31337 Selser does not introduce newlines between unedited paragraph preceding the list
31338 !! options
31339 parsoid={
31340 "modes": ["selser"],
31341 "changes": [
31342 [ "table tbody tr td p:last-child", "empty" ]
31343 ]
31344 }
31345 !! wikitext
31346 {|
31347 |
31348 header
31349 *foo
31350 *bar
31351 footer
31352 |}
31353 !! wikitext/edited
31354 {|
31355 |
31356 header
31357 *foo
31358 *bar
31359
31360 |}
31361 !! end
31362
31363 !! test
31364 Selser does not introduce newlines between unedited paragraph following the list
31365 !! options
31366 parsoid={
31367 "modes": ["selser"],
31368 "changes": [
31369 [ "table tbody tr td p:first-child", "empty" ]
31370 ]
31371 }
31372 !! wikitext
31373 {|
31374 |
31375 header
31376 *foo
31377 *bar
31378 footer
31379 |}
31380 !! wikitext/edited
31381 {|
31382 |
31383
31384 *foo
31385 *bar
31386 footer
31387 |}
31388 !! end
31389
31390 !! test
31391 Remove a list item but do not insert newline above list
31392 !! options
31393 parsoid={
31394 "modes": ["selser"],
31395 "changes": [
31396 [ "ul li:last-child", "remove" ]
31397 ]
31398 }
31399 !! wikitext
31400 header
31401 *foo
31402 *bar
31403 footer
31404 !! wikitext/edited
31405 header
31406 *foo
31407 footer
31408 !! end